|
@@ -79,9 +79,6 @@ public class ExamPaperStructureServiceImpl extends ServiceImpl<ExamPaperStructur
|
|
|
@Resource
|
|
|
ExamPaperGroupService examPaperGroupService;
|
|
|
|
|
|
- @Resource
|
|
|
- ExamCardService examCardService;
|
|
|
-
|
|
|
@Resource
|
|
|
ExamCardDetailService examCardDetailService;
|
|
|
|
|
@@ -306,15 +303,15 @@ public class ExamPaperStructureServiceImpl extends ServiceImpl<ExamPaperStructur
|
|
|
@Override
|
|
|
public List<CardJpgResult> findCardJpgFileByPaperNumber(Long examId, String courseCode, String paperNumber) {
|
|
|
Long examTaskId = examTaskService.getOne(new QueryWrapper<ExamTask>().lambda()
|
|
|
- .eq(ExamTask::getExamId,examId)
|
|
|
- .eq(ExamTask::getCourseCode,courseCode)
|
|
|
- .eq(ExamTask::getPaperNumber,paperNumber)).getId();
|
|
|
+ .eq(ExamTask::getExamId, examId)
|
|
|
+ .eq(ExamTask::getCourseCode, courseCode)
|
|
|
+ .eq(ExamTask::getPaperNumber, paperNumber)).getId();
|
|
|
Long cardId = examTaskDetailService.getOne(new QueryWrapper<ExamTaskDetail>().lambda()
|
|
|
- .eq(ExamTaskDetail::getExamTaskId,examTaskId)).getCardId();
|
|
|
+ .eq(ExamTaskDetail::getExamTaskId, examTaskId)).getCardId();
|
|
|
String jpgAttachmentInfo = examCardDetailService.getOne(new QueryWrapper<ExamCardDetail>().lambda()
|
|
|
- .eq(ExamCardDetail::getCardId,cardId)).getJpgAttachmentInfo();
|
|
|
+ .eq(ExamCardDetail::getCardId, cardId)).getJpgAttachmentInfo();
|
|
|
|
|
|
- List<ConvertJpgStorage> convertJpgStorageList = JSONObject.parseArray(jpgAttachmentInfo,ConvertJpgStorage.class);
|
|
|
+ List<ConvertJpgStorage> convertJpgStorageList = JSONObject.parseArray(jpgAttachmentInfo, ConvertJpgStorage.class);
|
|
|
|
|
|
return convertJpgStorageList.stream().flatMap(e -> {
|
|
|
BasicAttachment basicAttachment = basicAttachmentService.getById(e.getAttachmentId());
|
|
@@ -347,7 +344,7 @@ public class ExamPaperStructureServiceImpl extends ServiceImpl<ExamPaperStructur
|
|
|
String courseCode = basicPaperInfo.getCourseCode();
|
|
|
String courseName = basicPaperInfo.getCourseName();
|
|
|
List<String> paperTypeList = basicPaperInfo.getPaperTypes();
|
|
|
- if (paperTypeList == null || paperTypeList.size() == 0){
|
|
|
+ if (paperTypeList == null || paperTypeList.size() == 0) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("缺少试卷类型");
|
|
|
}
|
|
|
String paperType = String.join(",", paperTypeList);
|
|
@@ -378,7 +375,14 @@ public class ExamPaperStructureServiceImpl extends ServiceImpl<ExamPaperStructur
|
|
|
examPaperStructure.setPropositionTeacherId(propositionTeacherId);
|
|
|
examPaperStructure.setEnable(true);
|
|
|
if (SystemConstant.longNotNull(examPaperStructureId)) {
|
|
|
+ // 如果是编辑试卷机构,当客观题信息(大题名称、大题号、小题号、分数)全都没变的情况下不更新客观题机构(因为答案可能已经上传)
|
|
|
examPaperStructure.setId(examPaperStructureId);
|
|
|
+ // 数据库中的原客观题结构
|
|
|
+ String oldObjectiveQuestion = this.getById(examPaperStructureId).getObjectiveStructure();
|
|
|
+ if (this.matchObjectiveQuestion(objectiveStructure, oldObjectiveQuestion)) {
|
|
|
+ // 如果本次编辑试卷结构 客观题结构和之前数据库中存储的确实一致,则不更新客观题结构(把原数据库的客观题结构作为更新的)
|
|
|
+ examPaperStructure.setObjectiveStructure(oldObjectiveQuestion);
|
|
|
+ }
|
|
|
}
|
|
|
this.saveOrUpdate(examPaperStructure);
|
|
|
return examPaperStructure;
|
|
@@ -500,7 +504,7 @@ public class ExamPaperStructureServiceImpl extends ServiceImpl<ExamPaperStructur
|
|
|
}
|
|
|
}
|
|
|
if (excelErrorTemp.size() > 0) {
|
|
|
- List<String> errors = excelErrorTemp.stream().map(m -> m.getExcelErrorType()).collect(Collectors.toList());
|
|
|
+ List<String> errors = excelErrorTemp.stream().map(ExcelError::getExcelErrorType).collect(Collectors.toList());
|
|
|
throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(errors));
|
|
|
}
|
|
|
return finalExcelList;
|
|
@@ -557,4 +561,42 @@ public class ExamPaperStructureServiceImpl extends ServiceImpl<ExamPaperStructur
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 匹配客观题结构是否更改(若未上传答案则直接返回true)
|
|
|
+ *
|
|
|
+ * @param newQuestions 新的结构
|
|
|
+ * @param dbQuestions 旧的结构
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ private boolean matchObjectiveQuestion(String newQuestions, String dbQuestions) {
|
|
|
+ List<Question> dbList = JSON.parseArray(dbQuestions, Question.class);
|
|
|
+ if (dbList.size() == 0) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ // 旧结构没有答案,直接更新
|
|
|
+ if (!SystemConstant.strNotNull(dbList.get(0).getAnswer())) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Question> freshList = JSON.parseArray(newQuestions, Question.class);
|
|
|
+
|
|
|
+ // 两个结构内元素数量不一致直接返回错误
|
|
|
+ if (dbList.size() != freshList.size()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 排序
|
|
|
+ List<Question> dbSort = dbList.stream().sorted(Comparator.comparing(Question::getMainNumber).thenComparing(Question::getSubNumber)).collect(Collectors.toList());
|
|
|
+ List<Question> freshSort = freshList.stream().sorted(Comparator.comparing(Question::getMainNumber).thenComparing(Question::getSubNumber)).collect(Collectors.toList());
|
|
|
+
|
|
|
+ for (int i = 0; i < dbSort.size(); i++) {
|
|
|
+ Question db = dbSort.get(i);
|
|
|
+ Question fresh = freshSort.get(i);
|
|
|
+ if (!Question.matchTwoObjects(db, fresh)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|