|
@@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.qmth.distributed.print.business.bean.dto.excel.GradePaperStructDto;
|
|
|
import com.qmth.distributed.print.business.bean.dto.open.PaperStructure;
|
|
|
-import com.qmth.teachcloud.common.bean.marking.Question;
|
|
|
import com.qmth.distributed.print.business.bean.params.analyze.GradePaperStructDatasource;
|
|
|
import com.qmth.distributed.print.business.bean.params.analyze.GradePaperStructParam;
|
|
|
import com.qmth.distributed.print.business.bean.result.analyze.GradePaperStructResult;
|
|
@@ -16,11 +15,15 @@ import com.qmth.distributed.print.business.mapper.GradePaperStructMapper;
|
|
|
import com.qmth.distributed.print.business.service.ExamTaskService;
|
|
|
import com.qmth.distributed.print.business.service.GradeBatchPaperService;
|
|
|
import com.qmth.distributed.print.business.service.GradePaperStructService;
|
|
|
+import com.qmth.teachcloud.common.bean.marking.Question;
|
|
|
+import com.qmth.teachcloud.common.bean.result.MarkQuestionResult;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
+import com.qmth.teachcloud.common.entity.BasicCourse;
|
|
|
import com.qmth.teachcloud.common.entity.MarkQuestion;
|
|
|
import com.qmth.teachcloud.common.entity.SysUser;
|
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
import com.qmth.teachcloud.common.enums.ObjectiveType;
|
|
|
+import com.qmth.teachcloud.common.service.BasicCourseService;
|
|
|
import com.qmth.teachcloud.common.util.ExcelUtil;
|
|
|
import com.qmth.teachcloud.common.util.ServletUtil;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
@@ -47,17 +50,23 @@ import java.util.stream.Stream;
|
|
|
*/
|
|
|
@Service
|
|
|
public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMapper, GradePaperStruct> implements GradePaperStructService {
|
|
|
+
|
|
|
@Resource
|
|
|
private GradeBatchPaperService gradeBatchPaperService;
|
|
|
+
|
|
|
@Resource
|
|
|
private ExamTaskService examTaskService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private BasicCourseService basicCourseService;
|
|
|
+
|
|
|
@Override
|
|
|
- public List<GradePaperStructResult> findGradePaperStructureResultList(Long examId, String paperNumber, String paperType, SysUser requestUser, List<MarkQuestion> markQuestionList) {
|
|
|
+ public List<GradePaperStructResult> findGradePaperStructureResultList(Long examId, String paperNumber, String paperType, SysUser requestUser, List<MarkQuestionResult> markQuestionList) {
|
|
|
Long schoolId = requestUser.getSchoolId();
|
|
|
List<GradePaperStructResult> result = new ArrayList<>();
|
|
|
// 先从分析试卷结构表取
|
|
|
- List<GradePaperStructResult> gradeStructDatasource = this.baseMapper.findStructByGradePaper(schoolId, examId, paperNumber, paperType);
|
|
|
+ List<GradePaperStructResult> gradeStructDatasource = this.baseMapper.findStructByGradePaper(schoolId, examId,
|
|
|
+ paperNumber, paperType);
|
|
|
if (gradeStructDatasource != null && gradeStructDatasource.size() > 0) {
|
|
|
// 如果已经设置了试卷结构查询之前配置好的分析参数-试卷结构
|
|
|
result = gradeStructDatasource;
|
|
@@ -71,10 +80,8 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
List<Question> examPaperObjList = examCloudPaperStructMap.get(ObjectiveType.OBJECTIVE);
|
|
|
List<Question> examPaperSubList = examCloudPaperStructMap.get(ObjectiveType.SUBJECTIVE);
|
|
|
|
|
|
- List<ExamTask> examTaskList = examTaskService.list(new QueryWrapper<ExamTask>().lambda()
|
|
|
- .eq(ExamTask::getSchoolId, schoolId)
|
|
|
- .eq(ExamTask::getExamId, examId)
|
|
|
- .eq(ExamTask::getPaperNumber, paperNumber));
|
|
|
+ List<ExamTask> examTaskList = examTaskService.list(
|
|
|
+ new QueryWrapper<ExamTask>().lambda().eq(ExamTask::getSchoolId, schoolId).eq(ExamTask::getExamId, examId).eq(ExamTask::getPaperNumber, paperNumber));
|
|
|
if (Objects.isNull(examTaskList)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("没有找到试卷编号对应的命题任务");
|
|
|
}
|
|
@@ -82,12 +89,21 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
throw ExceptionResultEnum.ERROR.exception("有多个考试任务异常");
|
|
|
}
|
|
|
ExamTask examTask = examTaskList.get(0);
|
|
|
- String courseCode = examTask.getCourseCode();
|
|
|
- String courseName = examTask.getCourseName();
|
|
|
+
|
|
|
+ Long courseId = examTask.getCourseId();
|
|
|
+ BasicCourse basicCourse = basicCourseService.getById(courseId);
|
|
|
+ if (Objects.isNull(basicCourse)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("没有找到课程信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ String courseCode = basicCourse.getCode();
|
|
|
+ String courseName = basicCourse.getName();
|
|
|
|
|
|
// 按题号排序
|
|
|
- examPaperObjList = examPaperObjList.stream().sorted(Comparator.comparing(Question::getMainNumber).thenComparing(Question::getSubNumber)).collect(Collectors.toList());
|
|
|
- examPaperSubList = examPaperSubList.stream().sorted(Comparator.comparing(Question::getMainNumber).thenComparing(Question::getSubNumber)).collect(Collectors.toList());
|
|
|
+ examPaperObjList = examPaperObjList.stream().sorted(Comparator.comparing(Question::getMainNumber).thenComparing(Question::getSubNumber))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ examPaperSubList = examPaperSubList.stream().sorted(Comparator.comparing(Question::getMainNumber).thenComparing(Question::getSubNumber))
|
|
|
+ .collect(Collectors.toList());
|
|
|
for (Question question : examPaperObjList) {
|
|
|
GradePaperStructResult cell = new GradePaperStructResult();
|
|
|
cell.setCourseCode(courseCode);
|
|
@@ -137,11 +153,8 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
// 检验结构正确性并构建分析试卷结构
|
|
|
List<GradePaperStruct> gradePaperStructList = this.checkAndBuildGradePaperStruct(datasource, examId, paperNumber, paperType, paperName, requestUser);
|
|
|
// 删除旧的试卷结构
|
|
|
- this.remove(new QueryWrapper<GradePaperStruct>()
|
|
|
- .lambda()
|
|
|
- .eq(GradePaperStruct::getSchoolId, schoolId)
|
|
|
- .eq(GradePaperStruct::getExamId, examId)
|
|
|
- .eq(GradePaperStruct::getPaperNumber, paperNumber)
|
|
|
+ this.remove(new QueryWrapper<GradePaperStruct>().lambda().eq(GradePaperStruct::getSchoolId, schoolId)
|
|
|
+ .eq(GradePaperStruct::getExamId, examId).eq(GradePaperStruct::getPaperNumber, paperNumber)
|
|
|
.eq(GradePaperStruct::getPaperType, paperType));
|
|
|
this.saveBatch(gradePaperStructList);
|
|
|
gradeBatchPaperService.updatePaperAndBatchStatus(schoolId, examId, paperNumber, paperType);
|
|
@@ -149,20 +162,23 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public void importGradePaperStruct(MultipartFile file, String paperNumber, String paperType, String paperName, SysUser requestUser) throws IOException, NoSuchFieldException {
|
|
|
+ public void importGradePaperStruct(MultipartFile file, Long examId, String paperNumber, String paperType, String paperName,
|
|
|
+ SysUser requestUser) throws IOException, NoSuchFieldException {
|
|
|
if (Objects.isNull(file)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("找不到附件");
|
|
|
}
|
|
|
- List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(file.getInputStream(), Lists.newArrayList(GradePaperStructDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
|
|
|
- if (finalExcelErrorList.size() > 0) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
|
|
|
- }
|
|
|
- return finalExcelList;
|
|
|
- }, 1);
|
|
|
+ List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(file.getInputStream(), Lists.newArrayList(GradePaperStructDto.class),
|
|
|
+ (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
|
|
|
+ if (finalExcelErrorList.size() > 0) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
|
|
|
+ }
|
|
|
+ return finalExcelList;
|
|
|
+ }, 1);
|
|
|
GradePaperStructParam gradePaperStructParam = new GradePaperStructParam();
|
|
|
gradePaperStructParam.setPaperNumber(paperNumber);
|
|
|
gradePaperStructParam.setPaperType(paperType);
|
|
|
gradePaperStructParam.setPaperName(paperName);
|
|
|
+ gradePaperStructParam.setExamId(examId);
|
|
|
List<GradePaperStructDatasource> gradePaperStructDatasourceList = new ArrayList<>();
|
|
|
|
|
|
if (Objects.nonNull(finalList) && finalList.size() > 0) {
|
|
@@ -191,18 +207,24 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void exportGradePaperStructTemplate(Long examId, String paperNumber, String paperType, @NotNull SysUser requestUser, List<MarkQuestion> markQuestionList) throws Exception {
|
|
|
+ public void exportGradePaperStructTemplate(Long examId, String paperNumber, String paperType, @NotNull SysUser requestUser, List<MarkQuestionResult> markQuestionList) throws Exception {
|
|
|
|
|
|
- ExamTask examTask = examTaskService.getOne(new QueryWrapper<ExamTask>().lambda()
|
|
|
- .eq(ExamTask::getSchoolId, requestUser.getSchoolId())
|
|
|
- .eq(ExamTask::getPaperNumber, paperNumber));
|
|
|
+ ExamTask examTask = examTaskService.getOne(
|
|
|
+ new QueryWrapper<ExamTask>().lambda().eq(ExamTask::getSchoolId, requestUser.getSchoolId()).eq(ExamTask::getPaperNumber, paperNumber));
|
|
|
if (Objects.isNull(examTask)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("没有找到试卷编号对应的命题任务");
|
|
|
}
|
|
|
- String courseCode = examTask.getCourseCode();
|
|
|
- String courseName = examTask.getCourseName();
|
|
|
+ Long courseId = examTask.getCourseId();
|
|
|
+ BasicCourse basicCourse = basicCourseService.getById(courseId);
|
|
|
+ if (Objects.isNull(basicCourse)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("未找到课程信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ String courseCode = basicCourse.getCode();
|
|
|
+ String courseName = basicCourse.getName();
|
|
|
|
|
|
- List<GradePaperStructResult> datasource = this.findGradePaperStructureResultList(examId, paperNumber, paperType, requestUser, markQuestionList);
|
|
|
+ List<GradePaperStructResult> datasource = this.findGradePaperStructureResultList(examId, paperNumber, paperType,
|
|
|
+ requestUser, markQuestionList);
|
|
|
List<GradePaperStructDto> gradePaperStructDtoList = datasource.stream().flatMap(e -> {
|
|
|
GradePaperStructDto cell = new GradePaperStructDto();
|
|
|
cell.setCourseCode(courseCode);
|
|
@@ -222,7 +244,8 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<PaperStructure> findBySchoolIdAndPaperNumberAndPaperType(Long schoolId, Long examId, String paperNumber, String paperType) {
|
|
|
+ public List<PaperStructure> findBySchoolIdAndPaperNumberAndPaperType(Long schoolId, Long examId, String paperNumber,
|
|
|
+ String paperType) {
|
|
|
return this.baseMapper.findBySchoolIdAndPaperNumberAndPaperType(schoolId, examId, paperNumber, paperType);
|
|
|
}
|
|
|
|
|
@@ -236,10 +259,10 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
// 如果没有客观题 试卷类型传空
|
|
|
paperType = null;
|
|
|
// todo 3.3.0待更新
|
|
|
-// String cloudInfoJson = cloudMarkingTaskUtils.queryPaperStructure(schoolId, examId, subjectCode, paperType);
|
|
|
-// examPaperStructure.setCloudInfoJson(cloudInfoJson);
|
|
|
-// examPaperStructure.setStructureChange(false);
|
|
|
-// examPaperStructureService.updateById(examPaperStructure);
|
|
|
+ // String cloudInfoJson = cloudMarkingTaskUtils.queryPaperStructure(schoolId, examId, subjectCode, paperType);
|
|
|
+ // examPaperStructure.setCloudInfoJson(cloudInfoJson);
|
|
|
+ // examPaperStructure.setStructureChange(false);
|
|
|
+ // examPaperStructureService.updateById(examPaperStructure);
|
|
|
|
|
|
// 更新grade_paper_struct
|
|
|
QueryWrapper<GradePaperStruct> willDeleteQueryWrapper = new QueryWrapper<>();
|
|
@@ -271,7 +294,8 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
gradePaperStruct.setPaperNumber(paperNumber);
|
|
|
gradePaperStruct.setPaperType(paperType);
|
|
|
gradePaperStruct.setPaperName(paperName);
|
|
|
- gradePaperStruct.setQuestionName(e.getBigTopicName() + " " + e.getBigQuestionNumber() + SystemConstant.HYPHEN + e.getSmallQuestionNumber());
|
|
|
+ gradePaperStruct.setQuestionName(
|
|
|
+ e.getBigTopicName() + " " + e.getBigQuestionNumber() + SystemConstant.HYPHEN + e.getSmallQuestionNumber());
|
|
|
gradePaperStruct.setNumberType(e.getNumberType());
|
|
|
gradePaperStruct.setBigQuestionNumber(e.getBigQuestionNumber());
|
|
|
gradePaperStruct.setSmallQuestionNumber(e.getSmallQuestionNumber());
|
|
@@ -289,7 +313,7 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
}).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
- private Map<ObjectiveType, List<Question>> parseExamCloudPaperStruct(List<MarkQuestion> markQuestionList) {
|
|
|
+ private Map<ObjectiveType, List<Question>> parseExamCloudPaperStruct(List<MarkQuestionResult> markQuestionList) {
|
|
|
Map<ObjectiveType, List<Question>> result = new HashMap<>();
|
|
|
List<Question> objList = new ArrayList<>();
|
|
|
List<Question> subList = new ArrayList<>();
|