|
@@ -2338,7 +2338,13 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
List<MarkPaper> markPaperList = markPaperService.list(
|
|
List<MarkPaper> markPaperList = markPaperService.list(
|
|
new QueryWrapper<MarkPaper>().lambda().eq(MarkPaper::getExamId, examId));
|
|
new QueryWrapper<MarkPaper>().lambda().eq(MarkPaper::getExamId, examId));
|
|
// 题号重复校验
|
|
// 题号重复校验
|
|
- Set<String> paperCheckSet = new HashSet<>();
|
|
|
|
|
|
+ // 导入的客观题题号集合
|
|
|
|
+ Set<String> questionNumberCheckSet = new HashSet<>();
|
|
|
|
+ // 该试卷已存在的主观题题号集合
|
|
|
|
+ Set<String> dbSubjectiveQuestionNumberSet = markQuestionService.list(
|
|
|
|
+ new QueryWrapper<MarkQuestion>().lambda().eq(MarkQuestion::getExamId, examId)
|
|
|
|
+ .eq(MarkQuestion::getObjective, false)).stream()
|
|
|
|
+ .map(e -> e.getPaperNumber() + SystemConstant.HYPHEN + e.getMainNumber() + SystemConstant.HYPHEN + e.getSubNumber()).collect(Collectors.toSet());
|
|
|
|
|
|
ExcelResult<ObjectiveStructDto> excelResult = ConvertUtil.analyzeExcel(inputStream, ObjectiveStructDto.class,
|
|
ExcelResult<ObjectiveStructDto> excelResult = ConvertUtil.analyzeExcel(inputStream, ObjectiveStructDto.class,
|
|
true, 0);
|
|
true, 0);
|
|
@@ -2365,11 +2371,14 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
if (SystemConstant.strNotNull(paperNumber) && mainNumber != null && subNumber != null) {
|
|
if (SystemConstant.strNotNull(paperNumber) && mainNumber != null && subNumber != null) {
|
|
logicErrorCommonNotice = String.format("试卷编号为[%s],大题号为[%s],小题号为[%s]的数据异常 : ", paperNumber, mainNumber,
|
|
logicErrorCommonNotice = String.format("试卷编号为[%s],大题号为[%s],小题号为[%s]的数据异常 : ", paperNumber, mainNumber,
|
|
subNumber);
|
|
subNumber);
|
|
- String questionKey = paperNumber + SystemConstant.HYPHEN + mainNumber + SystemConstant.HYPHEN + subNumber;
|
|
|
|
- if (paperCheckSet.contains(questionKey)) {
|
|
|
|
- logicErrorList.add("题号重复");
|
|
|
|
|
|
+ String questionNumberKey = paperNumber + SystemConstant.HYPHEN + mainNumber + SystemConstant.HYPHEN + subNumber;
|
|
|
|
+ if (questionNumberCheckSet.contains(questionNumberKey)) {
|
|
|
|
+ logicErrorList.add("excel中题号重复");
|
|
} else {
|
|
} else {
|
|
- paperCheckSet.add(questionKey);
|
|
|
|
|
|
+ questionNumberCheckSet.add(questionNumberKey);
|
|
|
|
+ }
|
|
|
|
+ if (dbSubjectiveQuestionNumberSet.contains(questionNumberKey)) {
|
|
|
|
+ logicErrorList.add("该题号已存在主观题中");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2396,23 +2405,31 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
|
|
|
// 4.判断答案是否符合题型
|
|
// 4.判断答案是否符合题型
|
|
if (questionType != null && SystemConstant.strNotNull(answer)) {
|
|
if (questionType != null && SystemConstant.strNotNull(answer)) {
|
|
- //单选题的答案只能有一个
|
|
|
|
- if (Objects.equals(QuestionType.SINGLE.getValue(), questionType)) {
|
|
|
|
|
|
+ switch (questionType) {
|
|
|
|
+ case 1:
|
|
if (answer.length() > 1) {
|
|
if (answer.length() > 1) {
|
|
logicErrorList.add("单选题答案只能有一个");
|
|
logicErrorList.add("单选题答案只能有一个");
|
|
}
|
|
}
|
|
- }
|
|
|
|
- //判断题的答案只能为A&B
|
|
|
|
- if (Objects.equals(QuestionType.TRUE_OR_FALSE.getValue(), questionType)) {
|
|
|
|
|
|
+ break;
|
|
|
|
+ case 2:
|
|
|
|
+ break;
|
|
|
|
+ case 3:
|
|
if (!OptionsEnum.A.getCode().equals(answer) && !OptionsEnum.B.getCode().equals(answer)) {
|
|
if (!OptionsEnum.A.getCode().equals(answer) && !OptionsEnum.B.getCode().equals(answer)) {
|
|
logicErrorList.add("判断题答案只能为A&B");
|
|
logicErrorList.add("判断题答案只能为A&B");
|
|
}
|
|
}
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ logicErrorList.add("[题型(1-单选,2-多选,3-判断)]必须从1、2、3中填写");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// 整理异常信息
|
|
// 整理异常信息
|
|
if (CollectionUtils.isNotEmpty(logicErrorList)) {
|
|
if (CollectionUtils.isNotEmpty(logicErrorList)) {
|
|
- errorMsg = errorMsg + logicErrorCommonNotice + String.join(";", logicErrorList);
|
|
|
|
|
|
+ if (SystemConstant.strNotNull(errorMsg)) {
|
|
|
|
+ errorMsg = errorMsg + "、" + logicErrorCommonNotice + String.join("、", logicErrorList);
|
|
|
|
+ } else {
|
|
|
|
+ errorMsg = logicErrorCommonNotice + String.join("、", logicErrorList);
|
|
|
|
+ }
|
|
objectiveStructDto.setErrorMsg(errorMsg);
|
|
objectiveStructDto.setErrorMsg(errorMsg);
|
|
} else {
|
|
} else {
|
|
MarkQuestion markQuestion = new MarkQuestion();
|
|
MarkQuestion markQuestion = new MarkQuestion();
|
|
@@ -2442,16 +2459,9 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
// 优先删除该试卷编号下的客观题
|
|
// 优先删除该试卷编号下的客观题
|
|
markQuestionService.remove(new QueryWrapper<MarkQuestion>().lambda().eq(MarkQuestion::getExamId, examId)
|
|
markQuestionService.remove(new QueryWrapper<MarkQuestion>().lambda().eq(MarkQuestion::getExamId, examId)
|
|
.eq(MarkQuestion::getPaperNumber, k).eq(MarkQuestion::getObjective, true));
|
|
.eq(MarkQuestion::getPaperNumber, k).eq(MarkQuestion::getObjective, true));
|
|
-
|
|
|
|
- MarkQuestionParams markQuestionParams = new MarkQuestionParams();
|
|
|
|
- markQuestionParams.setQuestions(v);
|
|
|
|
- markQuestionParams.setExamId(examId);
|
|
|
|
- markQuestionParams.setPaperNumber(k);
|
|
|
|
- try {
|
|
|
|
- markQuestionService.saveQuestions(markQuestionParams);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception(e.getMessage());
|
|
|
|
- }
|
|
|
|
|
|
+ // 保存客观题
|
|
|
|
+ markQuestionService.saveBatch(v);
|
|
|
|
+ markQuestionService.updateMarkPaperScore(examId, k, null);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
return map;
|
|
return map;
|