|
@@ -1732,13 +1732,17 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
|
examPrintPlanService.save(examPrintPlan);
|
|
|
|
|
|
// 查询考试+课程下已用过的班级
|
|
|
- List<String> usedClassIds = new ArrayList<>();
|
|
|
- List<ExamDetailCourse> examDetailCourseList = examDetailService.listByExamIdAndCourseCode(schoolId, examTask.getExamId(), examTask.getCourseCode());
|
|
|
+ Map<String, String> usedClassIdsMap = new HashMap<>();
|
|
|
+ List<ExamDetailCourseDto> examDetailCourseList = examDetailService.listByExamIdAndCourseCode(schoolId, examTask.getExamId(), examTask.getCourseCode());
|
|
|
if (!CollectionUtils.isEmpty(examDetailCourseList)) {
|
|
|
examDetailCourseList.stream().filter(m -> StringUtils.isNotBlank(m.getClazzId())).forEach(m -> {
|
|
|
- usedClassIds.addAll(Arrays.asList(m.getClazzId().split(",")));
|
|
|
+// usedClassIds.addAll(Arrays.asList(m.getClazzId().split(",")));
|
|
|
+ for (String s : m.getClazzId().split(",")) {
|
|
|
+ usedClassIdsMap.put(s, String.format("%s(%s)", m.getRealName(), m.getLoginName()));
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
+ Set<String> classIdSet = usedClassIdsMap.keySet();
|
|
|
|
|
|
// 已使用过的班级集合(报错用)
|
|
|
List<String> errorClassIds = new ArrayList<>();
|
|
@@ -1753,9 +1757,11 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
|
throw ExceptionResultEnum.ERROR.exception("选择的考试班级【" + clazzName + "】下无学生,请确认该班级学生信息");
|
|
|
}
|
|
|
|
|
|
- for (String s : examDetailList.getClassId().split(",")) {
|
|
|
- if (usedClassIds.contains(s)) {
|
|
|
- errorClassIds.add(s);
|
|
|
+ if (!CollectionUtils.isEmpty(classIdSet)) {
|
|
|
+ for (String s : examDetailList.getClassId().split(",")) {
|
|
|
+ if (classIdSet.contains(s)) {
|
|
|
+ errorClassIds.add(s);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1815,9 +1821,9 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
|
}
|
|
|
}
|
|
|
} else if (ExamModelEnum.MODEL2.equals(basicExam.getExamModel())) {
|
|
|
- if (StringUtils.isNotBlank(examDetailParams.getClassId())) {
|
|
|
+ if (StringUtils.isNotBlank(examDetailParams.getClassId()) && !CollectionUtils.isEmpty(classIdSet)) {
|
|
|
for (String s : examDetailParams.getClassId().split(",")) {
|
|
|
- if (usedClassIds.contains(s)) {
|
|
|
+ if (classIdSet.contains(s)) {
|
|
|
errorClassIds.add(s);
|
|
|
}
|
|
|
}
|
|
@@ -1860,9 +1866,24 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
|
}
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(errorClassIds)) {
|
|
|
+ Map<String, List<String>> finalMap = new HashMap<>();
|
|
|
+ StringJoiner stringJoiner = new StringJoiner(",");
|
|
|
List<BasicClazz> basicClazzList = basicClazzService.listByIds(errorClassIds);
|
|
|
- String clazzNames = basicClazzList.stream().map(m -> m.getClazzName()).collect(Collectors.joining(","));
|
|
|
- throw ExceptionResultEnum.ERROR.exception("考试对象[" + clazzNames + "]已被其它人占用");
|
|
|
+ for (BasicClazz basicClazz : basicClazzList) {
|
|
|
+ String key = usedClassIdsMap.get(basicClazz.getId().toString());
|
|
|
+ List<String> value;
|
|
|
+ if (finalMap.containsKey(key)) {
|
|
|
+ value = finalMap.get(key);
|
|
|
+ } else {
|
|
|
+ value = new ArrayList<>();
|
|
|
+ }
|
|
|
+ value.add(basicClazz.getClazzName());
|
|
|
+ finalMap.put(key, value);
|
|
|
+ }
|
|
|
+ for (Map.Entry<String, List<String>> entry : finalMap.entrySet()) {
|
|
|
+ stringJoiner.add("考试对象[" + String.join(",", entry.getValue()) + "]已被" + entry.getKey() + "选择");
|
|
|
+ }
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(stringJoiner.toString());
|
|
|
}
|
|
|
}
|
|
|
|