|
@@ -10,13 +10,13 @@ import com.qmth.distributed.print.business.bean.dto.SubjectiveStructDto;
|
|
|
import com.qmth.distributed.print.business.bean.dto.importFile.BasicExamStudentImport;
|
|
|
import com.qmth.distributed.print.business.bean.dto.importFile.BasicExamStudentParseDto;
|
|
|
import com.qmth.distributed.print.business.entity.BasicExamRule;
|
|
|
+import com.qmth.distributed.print.business.entity.ExamDetail;
|
|
|
import com.qmth.distributed.print.business.entity.ExamPrintPlan;
|
|
|
import com.qmth.distributed.print.business.entity.ExamTask;
|
|
|
import com.qmth.distributed.print.business.enums.PrintPlanStatusEnum;
|
|
|
import com.qmth.distributed.print.business.enums.RequiredFieldsEnum;
|
|
|
import com.qmth.distributed.print.business.service.*;
|
|
|
import com.qmth.distributed.print.business.templete.service.ImportLogicService;
|
|
|
-import com.qmth.teachcloud.common.base.BaseEntity;
|
|
|
import com.qmth.teachcloud.common.bean.dto.mark.MarkUser;
|
|
|
import com.qmth.teachcloud.common.bean.examRule.CodeNameEnableDisabledValue;
|
|
|
import com.qmth.teachcloud.common.bean.examRule.CodeNameEnableValue;
|
|
@@ -33,7 +33,6 @@ import com.qmth.teachcloud.mark.entity.MarkPaper;
|
|
|
import com.qmth.teachcloud.mark.service.MarkGroupService;
|
|
|
import com.qmth.teachcloud.mark.service.MarkPaperService;
|
|
|
import com.qmth.teachcloud.mark.service.MarkQuestionService;
|
|
|
-import com.qmth.teachcloud.mark.service.MarkStudentService;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
@@ -65,25 +64,25 @@ public class ImportLogicServiceImpl implements ImportLogicService {
|
|
|
@Resource
|
|
|
private BasicExamRuleService basicExamRuleService;
|
|
|
@Resource
|
|
|
- BasicCourseService basicCourseService;
|
|
|
+ private BasicCourseService basicCourseService;
|
|
|
@Resource
|
|
|
- BasicExamService basicExamService;
|
|
|
+ private BasicExamService basicExamService;
|
|
|
@Resource
|
|
|
- SysUserService sysUserService;
|
|
|
+ private SysUserService sysUserService;
|
|
|
@Resource
|
|
|
- SysOrgService sysOrgService;
|
|
|
+ private SysOrgService sysOrgService;
|
|
|
@Resource
|
|
|
- BasicExamStudentService basicExamStudentService;
|
|
|
+ private BasicExamStudentService basicExamStudentService;
|
|
|
@Resource
|
|
|
- MarkPaperService markPaperService;
|
|
|
+ private MarkPaperService markPaperService;
|
|
|
@Resource
|
|
|
- MarkStudentService markStudentService;
|
|
|
+ private ExamDetailService examDetailService;
|
|
|
@Resource
|
|
|
- MarkQuestionService markQuestionService;
|
|
|
+ private MarkQuestionService markQuestionService;
|
|
|
@Resource
|
|
|
- MarkGroupService markGroupService;
|
|
|
+ private MarkGroupService markGroupService;
|
|
|
@Resource
|
|
|
- SysRoleService sysRoleService;
|
|
|
+ private SysRoleService sysRoleService;
|
|
|
@Resource
|
|
|
private CommonCacheService commonCacheService;
|
|
|
@Resource
|
|
@@ -92,6 +91,8 @@ public class ImportLogicServiceImpl implements ImportLogicService {
|
|
|
private ExamPrintPlanService examPrintPlanService;
|
|
|
@Resource
|
|
|
private ExamTaskService examTaskService;
|
|
|
+ @Resource
|
|
|
+ private ExamStudentService examStudentService;
|
|
|
|
|
|
|
|
|
@Transactional
|
|
@@ -107,20 +108,20 @@ public class ImportLogicServiceImpl implements ImportLogicService {
|
|
|
}
|
|
|
Long semesterId = SystemConstant.convertIdToLong(basicExam.getSemesterId());
|
|
|
|
|
|
- SystemConstant.addSummary(stringJoinerSummary, "开始解析文件内容");
|
|
|
+ SystemConstant.addSummary(stringJoinerSummary, "开始解析导入文件内容");
|
|
|
BasicExamStudentParseDto basicExamStudentParseDto;
|
|
|
try {
|
|
|
// 解析excel文件内容
|
|
|
basicExamStudentParseDto = this.parseBasicExamStudent(schoolId, inputStream);
|
|
|
} catch (Exception e) {
|
|
|
- SystemConstant.addSummary(stringJoinerSummary, "解析文件内容结束,解析失败。" + e.getMessage());
|
|
|
+ SystemConstant.addSummary(stringJoinerSummary, "解析导入文件内容结束,解析失败。" + e.getMessage());
|
|
|
throw ExceptionResultEnum.ERROR.exception(e.getMessage());
|
|
|
}
|
|
|
- SystemConstant.addSummary(stringJoinerSummary, "解析文件内容结束,开始进行数据校验");
|
|
|
+ SystemConstant.addSummary(stringJoinerSummary, "解析导入文件内容结束,开始进行数据校验");
|
|
|
|
|
|
List<BasicExamStudentImport> basicExamStudentImportList = basicExamStudentParseDto.getBasicExamStudentImportList();
|
|
|
if (CollectionUtils.isEmpty(basicExamStudentImportList)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("没有可导入数据");
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("未读取到有效数据");
|
|
|
}
|
|
|
|
|
|
List<BasicExamStudent> basicExamStudentList = basicExamStudentService.list(new QueryWrapper<BasicExamStudent>().lambda()
|
|
@@ -206,14 +207,14 @@ public class ImportLogicServiceImpl implements ImportLogicService {
|
|
|
basicExamStudent.setCourseId(basicCourseIdMap.get(key));
|
|
|
}
|
|
|
|
|
|
- // 校验任课老师
|
|
|
+ // 校验任课老师工号和姓名
|
|
|
if (StringUtils.isNotBlank(basicExamStudentImport.getTeacherCode()) && StringUtils.isNotBlank(basicExamStudentImport.getTeacherName())) {
|
|
|
SysUser sysUser = sysUserService.getByLoginName(schoolId, basicExamStudentImport.getTeacherCode());
|
|
|
if (sysUser == null) {
|
|
|
- stringJoiner.add("任课老师工号[" + basicExamStudentImport.getTeacherCode() + "]不存在");
|
|
|
+ stringJoiner.add("任课老师工号[" + basicExamStudentImport.getTeacherCode() + "]用户不存在");
|
|
|
} else {
|
|
|
if (!sysUser.getEnable()) {
|
|
|
- stringJoiner.add("任课老师工号[" + basicExamStudentImport.getTeacherCode() + "]已禁用");
|
|
|
+ stringJoiner.add("任课老师工号[" + basicExamStudentImport.getTeacherCode() + "]用户已禁用");
|
|
|
} else if (!sysUser.getRealName().equals(basicExamStudentImport.getTeacherName())) {
|
|
|
stringJoiner.add("任课老师[" + basicExamStudentImport.getTeacherName() + "]与用户管理中姓名[" + sysUser.getRealName() + "]不一致");
|
|
|
} else {
|
|
@@ -222,33 +223,25 @@ public class ImportLogicServiceImpl implements ImportLogicService {
|
|
|
}
|
|
|
|
|
|
// 校验同课程下,同一教学班只能有一个任课老师
|
|
|
- String courseTeachClassTeacherKey = basicExamStudent.getCourseId() + basicExamStudent.getTeachClassName();
|
|
|
- if (courseTeachClassTeacherMap.containsKey(courseTeachClassTeacherKey)) {
|
|
|
- Long teacherId = courseTeachClassTeacherMap.get(courseTeachClassTeacherKey);
|
|
|
- if ((teacherId == null && basicExamStudent.getTeacherId() != null) || (teacherId != null && basicExamStudent.getTeacherId() == null) || (teacherId != null && !teacherId.equals(basicExamStudent.getTeacherId()))) {
|
|
|
- stringJoiner.add("同课程下相同教学班,只能有一位任课老师");
|
|
|
- }
|
|
|
- } else {
|
|
|
- courseTeachClassTeacherMap.put(courseTeachClassTeacherKey, basicExamStudent.getTeacherId());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 校验课程+学号唯一
|
|
|
- String courseCodeStudentCode = basicExamStudentImport.getCourseCode() + basicExamStudentImport.getStudentCode();
|
|
|
- if (courseCodeStudentCodeList.contains(courseCodeStudentCode)) {
|
|
|
- stringJoiner.add("课程代码[" + basicExamStudentImport.getCourseCode() + "]已存在学号[" + basicExamStudentImport.getStudentCode() + "]的考生数据");
|
|
|
- } else {
|
|
|
- courseCodeStudentCodeList.add(courseCodeStudentCode);
|
|
|
+// String courseTeachClassTeacherKey = basicExamStudent.getCourseId() + basicExamStudent.getTeachClassName();
|
|
|
+// if (courseTeachClassTeacherMap.containsKey(courseTeachClassTeacherKey)) {
|
|
|
+// Long teacherId = courseTeachClassTeacherMap.get(courseTeachClassTeacherKey);
|
|
|
+// if ((teacherId == null && basicExamStudent.getTeacherId() != null) || (teacherId != null && basicExamStudent.getTeacherId() == null) || (teacherId != null && !teacherId.equals(basicExamStudent.getTeacherId()))) {
|
|
|
+// stringJoiner.add("同课程同教学班,只允许设置一个任课老师");
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// courseTeachClassTeacherMap.put(courseTeachClassTeacherKey, basicExamStudent.getTeacherId());
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
if (basicExamStudent.getCourseId() != null) {
|
|
|
if (courseIdStudentCodeMap.containsKey(basicExamStudent.getCourseId() + SystemConstant.HYPHEN + basicExamStudent.getStudentCode())) {
|
|
|
BasicExamStudent student = courseIdStudentCodeMap.get(basicExamStudent.getCourseId() + SystemConstant.HYPHEN + basicExamStudent.getStudentCode());
|
|
|
- basicExamStudent.setId(student.getId());
|
|
|
-
|
|
|
- // 被更改的试卷编号
|
|
|
- if (StringUtils.isNotBlank(basicExamStudent.getPaperNumber()) && StringUtils.isNotBlank(student.getPaperNumber()) && !basicExamStudent.getPaperNumber().equals(student.getPaperNumber())) {
|
|
|
- oldPaperNumberList.add(student.getPaperNumber());
|
|
|
+ if (StringUtils.isNotBlank(student.getPaperNumber()) && student.getPaperNumber().equals(basicExamStudent.getPaperNumber())) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("不允许修改试卷编号");
|
|
|
+ } else {
|
|
|
+ basicExamStudent.setId(student.getId());
|
|
|
+ basicExamStudent.setPaperType(student.getPaperType());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -261,6 +254,14 @@ public class ImportLogicServiceImpl implements ImportLogicService {
|
|
|
paperNumberCourseIdMap.put(basicExamStudent.getPaperNumber(), basicExamStudent.getCourseId());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 校验课程学号唯一
|
|
|
+ String courseCodeStudentCodeKey = basicExamStudent.getCourseId() + basicExamStudentImport.getStudentCode();
|
|
|
+ if (courseCodeStudentCodeList.contains(courseCodeStudentCodeKey)) {
|
|
|
+ stringJoiner.add(String.format("课程代码[%s],开课学院[%s],学号[%s]存在重复考生", basicExamStudentImport.getCourseCode(), basicExamStudentImport.getTeachingRoomName(), basicExamStudentImport.getStudentCode()));
|
|
|
+ } else {
|
|
|
+ courseCodeStudentCodeList.add(courseCodeStudentCodeKey);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (stringJoiner.toString().length() > 0) {
|
|
@@ -288,6 +289,166 @@ public class ImportLogicServiceImpl implements ImportLogicService {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> executeImportBasicExamStudentTeacherLogic(Map<String, Object> map, StringJoiner stringJoinerSummary) {
|
|
|
+ SysUser requestUser = (SysUser) map.get(SystemConstant.USER);
|
|
|
+ InputStream inputStream = (InputStream) map.get("inputStream");
|
|
|
+ Long examId = SystemConstant.convertIdToLong(String.valueOf(map.get("examId")));
|
|
|
+ Long schoolId = requestUser.getSchoolId();
|
|
|
+ BasicExam basicExam = basicExamService.getById(examId);
|
|
|
+ if (Objects.isNull(basicExam)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("考试不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ SystemConstant.addSummary(stringJoinerSummary, "开始解析导入文件内容");
|
|
|
+ BasicExamStudentParseDto basicExamStudentParseDto;
|
|
|
+ try {
|
|
|
+ basicExamStudentParseDto = this.parseBasicExamStudent(schoolId, inputStream);
|
|
|
+ } catch (Exception e) {
|
|
|
+ SystemConstant.addSummary(stringJoinerSummary, "解析导入文件内容结束,解析失败。" + e.getMessage());
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(e.getMessage());
|
|
|
+ }
|
|
|
+ SystemConstant.addSummary(stringJoinerSummary, "解析导入文件内容结束,开始进行数据校验");
|
|
|
+
|
|
|
+ List<BasicExamStudentImport> basicExamStudentImportList = basicExamStudentParseDto.getBasicExamStudentImportList();
|
|
|
+ if (CollectionUtils.isEmpty(basicExamStudentImportList)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("未读取到有效数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<BasicExamStudent> basicExamStudentList = basicExamStudentService.list(new QueryWrapper<BasicExamStudent>().lambda()
|
|
|
+ .select(BasicExamStudent::getId, BasicExamStudent::getCourseId, BasicExamStudent::getStudentCode, BasicExamStudent::getPaperNumber, BasicExamStudent::getTeachClassName, BasicExamStudent::getTeacherId)
|
|
|
+ .eq(BasicExamStudent::getSchoolId, schoolId).eq(BasicExamStudent::getExamId, examId));
|
|
|
+ Map<String, BasicExamStudent> courseIdStudentCodeMap = basicExamStudentList.stream().collect(Collectors.toMap(k -> k.getCourseId() + SystemConstant.HYPHEN + k.getStudentCode(), e -> e));
|
|
|
+
|
|
|
+ Map<String, Long> basicCourseIdMap = new HashMap<>();
|
|
|
+ // 课程学号唯一
|
|
|
+ List<String> courseCodeStudentCodeList = new ArrayList<>();
|
|
|
+ // 课程+教学班->任课老师
|
|
|
+ Map<String, Long> courseTeachClassTeacherMap = new HashMap<>();
|
|
|
+ // 是否有错误提示
|
|
|
+ boolean hasError = false;
|
|
|
+
|
|
|
+ // 必填字段为课程代码、开课学院、学号、教学班、任课老师工号、任课老师
|
|
|
+ List<String> requiredCodes = Arrays.asList(RequiredFieldsEnum.STUDENT_CODE.getCode(), RequiredFieldsEnum.COURSE_CODE.getCode(), RequiredFieldsEnum.TEACHING_ROOM_NAME.getCode(), RequiredFieldsEnum.TEACH_CLASS_NAME.getCode(), RequiredFieldsEnum.TEACHER_NAME.getCode(), RequiredFieldsEnum.TEACHER_CODE.getCode());
|
|
|
+
|
|
|
+ List<BasicExamStudent> basicExamStudents = new ArrayList<>();
|
|
|
+ for (BasicExamStudentImport basicExamStudentImport : basicExamStudentImportList) {
|
|
|
+ BasicExamStudent basicExamStudent = new BasicExamStudent();
|
|
|
+ StringJoiner stringJoiner = new StringJoiner(";");
|
|
|
+
|
|
|
+ // 校验excel内容
|
|
|
+ basicExamStudentImport.getRequiredFieldList().forEach(m -> {
|
|
|
+ if (requiredCodes.contains(m.getCode()) && StringUtils.isBlank(m.getValue())) {
|
|
|
+ stringJoiner.add(m.getName() + "必填");
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 校验课程
|
|
|
+ String key = basicExamStudentImport.getCourseCode() + SystemConstant.HYPHEN + basicExamStudentImport.getTeachingRoomName();
|
|
|
+ if (!basicCourseIdMap.containsKey(key)) {
|
|
|
+ List<SysOrg> sysOrgList = sysOrgService.getSecondOrg(schoolId, basicExamStudentImport.getTeachingRoomName());
|
|
|
+ if (CollectionUtils.isEmpty(sysOrgList)) {
|
|
|
+ stringJoiner.add("开课学院[" + basicExamStudentImport.getTeachingRoomName() + "]在学院层级不存在");
|
|
|
+ } else {
|
|
|
+ SysOrg sysOrg = sysOrgList.get(0);
|
|
|
+ // 校验课程代码和开课学院
|
|
|
+ BasicCourse basicCourse = basicCourseService.getByTeachRoomIdAndCode(sysOrg.getId(), basicExamStudentImport.getCourseCode());
|
|
|
+ if (Objects.isNull(basicCourse)) {
|
|
|
+ stringJoiner.add("课程代码[" + basicExamStudentImport.getCourseCode() + "]在开课学院[" + basicExamStudentImport.getTeachingRoomName() + "]不存在");
|
|
|
+ } else {
|
|
|
+ basicExamStudent.setCourseId(basicCourse.getId());
|
|
|
+ basicCourseIdMap.put(key, basicCourse.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ basicExamStudent.setCourseId(basicCourseIdMap.get(key));
|
|
|
+ }
|
|
|
+
|
|
|
+ //校验任课老师
|
|
|
+ SysUser sysUser = sysUserService.getByLoginName(schoolId, basicExamStudentImport.getTeacherCode());
|
|
|
+ if (sysUser == null) {
|
|
|
+ stringJoiner.add("任课老师工号[" + basicExamStudentImport.getTeacherCode() + "]用户不存在");
|
|
|
+ } else {
|
|
|
+ if (!sysUser.getEnable()) {
|
|
|
+ stringJoiner.add("任课老师工号[" + basicExamStudentImport.getTeacherCode() + "]用户已禁用");
|
|
|
+ } else if (!sysUser.getRealName().equals(basicExamStudentImport.getTeacherName())) {
|
|
|
+ stringJoiner.add("任课老师[" + basicExamStudentImport.getTeacherName() + "]与用户管理中姓名[" + sysUser.getRealName() + "]不一致");
|
|
|
+ } else {
|
|
|
+ basicExamStudent.setTeacherId(sysUser.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (basicExamStudent.getCourseId() != null) {
|
|
|
+ // 校验同课程下,同一教学班只能有一个任课老师
|
|
|
+// if (StringUtils.isNotBlank(basicExamStudent.getTeachClassName())) {
|
|
|
+// String courseTeachClassTeacherKey = basicExamStudent.getCourseId() + basicExamStudent.getTeachClassName();
|
|
|
+// if (courseTeachClassTeacherMap.containsKey(courseTeachClassTeacherKey)) {
|
|
|
+// Long teacherId = courseTeachClassTeacherMap.get(courseTeachClassTeacherKey);
|
|
|
+// if (teacherId != null && basicExamStudent.getTeacherId() != null && !teacherId.equals(basicExamStudent.getTeacherId())) {
|
|
|
+// stringJoiner.add("同课程同教学班,只允许设置一个任课老师");
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// courseTeachClassTeacherMap.put(courseTeachClassTeacherKey, basicExamStudent.getTeacherId());
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+ // 校验课程+学号是否存在
|
|
|
+ if (StringUtils.isNotBlank(basicExamStudentImport.getStudentCode())) {
|
|
|
+ String studentKey = basicExamStudent.getCourseId() + SystemConstant.HYPHEN + basicExamStudentImport.getStudentCode();
|
|
|
+ if (courseIdStudentCodeMap.containsKey(studentKey)) {
|
|
|
+ BasicExamStudent student = courseIdStudentCodeMap.get(studentKey);
|
|
|
+ basicExamStudent.setId(student.getId());
|
|
|
+ basicExamStudent.setPaperNumber(student.getPaperNumber());
|
|
|
+ basicExamStudent.setPaperType(student.getPaperType());
|
|
|
+ // 更新requiredFields中的任课老师和任课老师工号
|
|
|
+ for (CodeNameEnableValue codeNameEnableValue : student.getRequiredFieldList()) {
|
|
|
+ if (codeNameEnableValue.getCode().equals(RequiredFieldsEnum.TEACHER_CODE.getCode())) {
|
|
|
+ codeNameEnableValue.setValue(basicExamStudentImport.getTeacherCode());
|
|
|
+ }
|
|
|
+ if (codeNameEnableValue.getCode().equals(RequiredFieldsEnum.TEACHER_NAME.getCode())) {
|
|
|
+ codeNameEnableValue.setValue(basicExamStudentImport.getTeacherName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ basicExamStudent.setRequiredFields(JSON.toJSONString(student.getRequiredFieldList()));
|
|
|
+ } else {
|
|
|
+ stringJoiner.add(String.format("课程代码[%s],开课学院[%s],学号[%s]考生管理中不存在", basicExamStudentImport.getCourseCode(), basicExamStudentImport.getTeachingRoomName(), basicExamStudentImport.getStudentCode()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 校验课程学号唯一
|
|
|
+ String courseCodeStudentCodeKey = basicExamStudent.getCourseId() + basicExamStudentImport.getStudentCode();
|
|
|
+ if (courseCodeStudentCodeList.contains(courseCodeStudentCodeKey)) {
|
|
|
+ stringJoiner.add(String.format("课程代码[%s],开课学院[%s],学号[%s]存在重复考生", basicExamStudentImport.getCourseCode(), basicExamStudentImport.getTeachingRoomName(), basicExamStudentImport.getStudentCode()));
|
|
|
+ } else {
|
|
|
+ courseCodeStudentCodeList.add(courseCodeStudentCodeKey);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (stringJoiner.toString().length() > 0) {
|
|
|
+ basicExamStudentImport.setErrorMsg(stringJoiner.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!hasError && stringJoiner.toString().length() > 0) {
|
|
|
+ hasError = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (stringJoiner.toString().length() == 0) {
|
|
|
+ basicExamStudents.add(basicExamStudent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ map.put(SystemConstant.ERROR_DATA_LIST, basicExamStudentImportList);
|
|
|
+ map.put(SystemConstant.DATASOURCE, basicExamStudents);
|
|
|
+ map.put(SystemConstant.DATA_COUNT, basicExamStudentImportList.size());
|
|
|
+ map.put(SystemConstant.SUCCESS_DATA_COUNT, basicExamStudents.size());
|
|
|
+ map.put(SystemConstant.ERROR_DATA_COUNT, basicExamStudentImportList.size() - basicExamStudents.size());
|
|
|
+ map.put(SystemConstant.HAS_ERROR_DATA, hasError);
|
|
|
+ map.put(SystemConstant.COLUMN_NAMES, basicExamStudentParseDto.getColumnNames());
|
|
|
+
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public Map<String, Object> executeImportExamStudentLogic(Map<String, Object> map, TBTask tbTask, StringJoiner stringJoinerSummary) {
|
|
@@ -328,13 +489,13 @@ public class ImportLogicServiceImpl implements ImportLogicService {
|
|
|
|
|
|
List<BasicExamStudentImport> basicExamStudentImportList = basicExamStudentParseDto.getBasicExamStudentImportList();
|
|
|
if (CollectionUtils.isEmpty(basicExamStudentImportList)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("没有可导入数据");
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("未读取到有效数据");
|
|
|
}
|
|
|
|
|
|
List<BasicExamStudent> basicExamStudentList = basicExamStudentService.list(new QueryWrapper<BasicExamStudent>().lambda()
|
|
|
.select(BasicExamStudent::getId, BasicExamStudent::getCourseId, BasicExamStudent::getStudentCode, BasicExamStudent::getPaperNumber)
|
|
|
.eq(BasicExamStudent::getSchoolId, schoolId).eq(BasicExamStudent::getExamId, examId));
|
|
|
- Map<String, Long> courseIdStudentCodeMap = basicExamStudentList.stream().collect(Collectors.toMap(k -> k.getCourseId() + SystemConstant.HYPHEN + k.getStudentCode(), BaseEntity::getId));
|
|
|
+ Map<String, BasicExamStudent> courseIdStudentCodeMap = basicExamStudentList.stream().collect(Collectors.toMap(k -> k.getCourseId() + SystemConstant.HYPHEN + k.getStudentCode(), Function.identity()));
|
|
|
|
|
|
// 文件中试卷编号对应多个课程代码
|
|
|
Map<String, Long> paperNumberCourseIdInMap = new HashMap<>();
|
|
@@ -352,6 +513,7 @@ public class ImportLogicServiceImpl implements ImportLogicService {
|
|
|
// 是否有错误提示
|
|
|
boolean hasError = false;
|
|
|
|
|
|
+ // 命题任务列表
|
|
|
List<ExamTask> examTaskList = examTaskService.listByExamId(examId);
|
|
|
Map<String, List<ExamTask>> paperNumberMap = examTaskList.stream().collect(Collectors.groupingBy(m -> m.getPaperNumber()));
|
|
|
|
|
@@ -366,12 +528,13 @@ public class ImportLogicServiceImpl implements ImportLogicService {
|
|
|
basicExamStudent.setExtendFields(CollectionUtils.isNotEmpty(basicExamStudentImport.getExtendFieldList()) ? JSON.toJSONString(basicExamStudentImport.getExtendFieldList()) : null);
|
|
|
|
|
|
StringJoiner stringJoiner = new StringJoiner(";");
|
|
|
- // 校验excel内容
|
|
|
+ // 校验必填项
|
|
|
basicExamStudentImport.getRequiredFieldList().forEach(m -> {
|
|
|
if (m.getEnable() && StringUtils.isBlank(m.getValue())) {
|
|
|
stringJoiner.add(m.getName() + "必填");
|
|
|
}
|
|
|
});
|
|
|
+ // 校验任课老师,都填或者都不填
|
|
|
if (StringUtils.isNotBlank(basicExamStudentImport.getTeacherCode()) && StringUtils.isBlank(basicExamStudentImport.getTeacherName())) {
|
|
|
stringJoiner.add(RequiredFieldsEnum.TEACHER_NAME.getName() + "必填");
|
|
|
}
|
|
@@ -379,6 +542,7 @@ public class ImportLogicServiceImpl implements ImportLogicService {
|
|
|
stringJoiner.add(RequiredFieldsEnum.TEACHER_CODE.getName() + "必填");
|
|
|
}
|
|
|
|
|
|
+ // 解析并校验考试日期、考试时间
|
|
|
try {
|
|
|
Map<String, Object> timeMap = ConvertUtil.analyzeExamTime(basicExamStudentImport.getExamDate(), basicExamStudentImport.getExamTime());
|
|
|
basicExamStudent.setExamStartTime(Long.valueOf(String.valueOf(timeMap.get("startTime"))));
|
|
@@ -387,7 +551,7 @@ public class ImportLogicServiceImpl implements ImportLogicService {
|
|
|
stringJoiner.add(e.getMessage());
|
|
|
}
|
|
|
|
|
|
- // 校验课程
|
|
|
+ // 校验开课学院是否存在该课程代码
|
|
|
String key = basicExamStudentImport.getCourseCode() + SystemConstant.HYPHEN + basicExamStudentImport.getTeachingRoomName();
|
|
|
if (!basicCourseIdMap.containsKey(key)) {
|
|
|
List<SysOrg> sysOrgList = sysOrgService.getSecondOrg(schoolId, basicExamStudentImport.getTeachingRoomName());
|
|
@@ -410,39 +574,42 @@ public class ImportLogicServiceImpl implements ImportLogicService {
|
|
|
basicExamStudent.setCourseId(basicCourseIdMap.get(key));
|
|
|
}
|
|
|
|
|
|
- // 校验试卷编号和课程代码对应关系
|
|
|
+ // 校验试卷编号和课程代码对应关系,试卷编号只能绑定一个课程
|
|
|
if (paperNumberCourseIdInMap.containsKey(basicExamStudent.getPaperNumber())) {
|
|
|
Long courseId = paperNumberCourseIdInMap.get(basicExamStudent.getPaperNumber());
|
|
|
if (!basicExamStudent.getCourseId().equals(courseId)) {
|
|
|
- stringJoiner.add(String.format("文件中试卷编号[%s]对应多个不同的课程代码", basicExamStudent.getPaperNumber()));
|
|
|
+ stringJoiner.add(String.format("试卷编号[%s]对应多个不同的课程代码", basicExamStudent.getPaperNumber()));
|
|
|
}
|
|
|
} else {
|
|
|
paperNumberCourseIdInMap.put(basicExamStudent.getPaperNumber(), basicExamStudent.getCourseId());
|
|
|
}
|
|
|
|
|
|
+ // 校验试卷编号课程代码是否已命题且命题任务中课程代码是否一致
|
|
|
if (paperNumberMap.containsKey(basicExamStudent.getPaperNumber())) {
|
|
|
List<ExamTask> examTasks = paperNumberMap.get(basicExamStudent.getPaperNumber());
|
|
|
if (examTasks.size() > 1) {
|
|
|
- stringJoiner.add(String.format("试卷编号[%s]在考试[%s]下有多条命题任务,请联系管理员处理", basicExamStudent.getPaperNumber(), examId));
|
|
|
+ stringJoiner.add(String.format("试卷编号[%s]在考试[%s]下有多条命题任务,请联系管理员处理", basicExamStudent.getPaperNumber(), basicExam.getName()));
|
|
|
} else {
|
|
|
Long courseId = paperNumberCourseIdInMap.get(basicExamStudent.getPaperNumber());
|
|
|
ExamTask examTask = examTasks.get(0);
|
|
|
if (!examTask.getCourseId().equals(courseId)) {
|
|
|
- stringJoiner.add(String.format("文件中试卷编号[%s]对应课程代码与命题任务中对应课程代码不一致", basicExamStudent.getPaperNumber()));
|
|
|
+ stringJoiner.add(String.format("试卷编号[%s]对应课程代码与命题任务中对应课程代码不一致", basicExamStudent.getPaperNumber()));
|
|
|
} else {
|
|
|
basicExamStudent.setCoursePaperId(String.valueOf(examTask.getId()));
|
|
|
}
|
|
|
}
|
|
|
+ } else {
|
|
|
+ stringJoiner.add(String.format("试卷编号[%s]未命题", basicExamStudent.getPaperNumber()));
|
|
|
}
|
|
|
|
|
|
- //校验任课老师
|
|
|
+ //校验任课老师是否存在,且工号和姓名是否与系统一致
|
|
|
if (StringUtils.isNotBlank(basicExamStudentImport.getTeacherCode()) && StringUtils.isNotBlank(basicExamStudentImport.getTeacherName())) {
|
|
|
SysUser sysUser = sysUserService.getByLoginName(schoolId, basicExamStudentImport.getTeacherCode());
|
|
|
if (sysUser == null) {
|
|
|
- stringJoiner.add("任课老师工号[" + basicExamStudentImport.getTeacherCode() + "]不存在");
|
|
|
+ stringJoiner.add("任课老师工号[" + basicExamStudentImport.getTeacherCode() + "]用户不存在");
|
|
|
} else {
|
|
|
if (!sysUser.getEnable()) {
|
|
|
- stringJoiner.add("任课老师工号[" + basicExamStudentImport.getTeacherCode() + "]已禁用");
|
|
|
+ stringJoiner.add("任课老师工号[" + basicExamStudentImport.getTeacherCode() + "]用户已禁用");
|
|
|
} else if (!sysUser.getRealName().equals(basicExamStudentImport.getTeacherName())) {
|
|
|
stringJoiner.add("任课老师[" + basicExamStudentImport.getTeacherName() + "]与用户管理中姓名[" + sysUser.getRealName() + "]不一致");
|
|
|
} else {
|
|
@@ -451,29 +618,45 @@ public class ImportLogicServiceImpl implements ImportLogicService {
|
|
|
}
|
|
|
|
|
|
// 校验同课程下,同一教学班只能有一个任课老师
|
|
|
- String courseTeachClassTeacherKey = basicExamStudent.getCourseId() + basicExamStudent.getTeachClassName();
|
|
|
- if (courseTeachClassTeacherMap.containsKey(courseTeachClassTeacherKey)) {
|
|
|
- Long teacherId = courseTeachClassTeacherMap.get(courseTeachClassTeacherKey);
|
|
|
- if ((teacherId == null && basicExamStudent.getTeacherId() != null) || (teacherId != null && basicExamStudent.getTeacherId() == null) || (teacherId != null && !teacherId.equals(basicExamStudent.getTeacherId()))) {
|
|
|
- stringJoiner.add("同课程下相同教学班,只能有一位任课老师");
|
|
|
- }
|
|
|
- } else {
|
|
|
- courseTeachClassTeacherMap.put(courseTeachClassTeacherKey, basicExamStudent.getTeacherId());
|
|
|
- }
|
|
|
+// String courseTeachClassTeacherKey = basicExamStudent.getCourseId() + basicExamStudent.getTeachClassName();
|
|
|
+// if (courseTeachClassTeacherMap.containsKey(courseTeachClassTeacherKey)) {
|
|
|
+// Long teacherId = courseTeachClassTeacherMap.get(courseTeachClassTeacherKey);
|
|
|
+// if ((teacherId == null && basicExamStudent.getTeacherId() != null) || (teacherId != null && basicExamStudent.getTeacherId() == null) || (teacherId != null && !teacherId.equals(basicExamStudent.getTeacherId()))) {
|
|
|
+// stringJoiner.add("同课程下相同教学班,只能有一位任课老师");
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// courseTeachClassTeacherMap.put(courseTeachClassTeacherKey, basicExamStudent.getTeacherId());
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
- if (basicExamStudent.getCourseId() != null) {
|
|
|
- if (courseIdStudentCodeMap.containsKey(basicExamStudent.getCourseId() + SystemConstant.HYPHEN + basicExamStudent.getStudentCode())) {
|
|
|
- basicExamStudent.setId(courseIdStudentCodeMap.get(basicExamStudent.getCourseId() + SystemConstant.HYPHEN + basicExamStudent.getStudentCode()));
|
|
|
+ // 校验试卷编号学号是否已生成印刷任务
|
|
|
+ int studentCount = examStudentService.countByExamIdAndPaperNumberAndStudentCode(examId, basicExamStudent.getPaperNumber(), basicExamStudent.getStudentCode());
|
|
|
+ if (studentCount > 0) {
|
|
|
+ stringJoiner.add("试卷编号[" + basicExamStudent.getPaperNumber() + "]、学号[" + basicExamStudent.getStudentCode() + "]已有印刷任务,不允许重复导入");
|
|
|
+ } else {
|
|
|
+ if (basicExamStudent.getCourseId() != null) {
|
|
|
+ // 校验课程学号唯一
|
|
|
+ String courseCodeStudentCodeKey = basicExamStudent.getCourseId() + basicExamStudent.getStudentCode();
|
|
|
+ if (courseCodeStudentCodeList.contains(courseCodeStudentCodeKey)) {
|
|
|
+ stringJoiner.add("课程代码[" + basicExamStudentImport.getCourseCode() + "]已存在学号[" + basicExamStudentImport.getStudentCode() + "]的考生数据");
|
|
|
+ } else {
|
|
|
+ courseCodeStudentCodeList.add(courseCodeStudentCodeKey);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (courseIdStudentCodeMap.containsKey(basicExamStudent.getCourseId() + SystemConstant.HYPHEN + basicExamStudent.getStudentCode())) {
|
|
|
+ BasicExamStudent basicStudent = courseIdStudentCodeMap.get(basicExamStudent.getCourseId() + SystemConstant.HYPHEN + basicExamStudent.getStudentCode());
|
|
|
+ basicExamStudent.setId(basicStudent.getId());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 校验课程学号唯一
|
|
|
- String courseCodeStudentCode = basicExamStudentImport.getCourseCode() + basicExamStudentImport.getStudentCode();
|
|
|
- if (courseCodeStudentCodeList.contains(courseCodeStudentCode)) {
|
|
|
- stringJoiner.add("课程代码[" + basicExamStudentImport.getCourseCode() + "]已存在学号[" + basicExamStudentImport.getStudentCode() + "]的考生数据");
|
|
|
- } else {
|
|
|
- courseCodeStudentCodeList.add(courseCodeStudentCode);
|
|
|
+ // 校验试卷编号、考试日期、考试时间、考点、考场是否已命题
|
|
|
+ List<ExamDetail> examDetailList = examDetailService.listExamDetailByExamIdAndCourseIdAndPaperNumber(examId, basicExamStudent.getCourseId(), basicExamStudent.getPaperNumber());
|
|
|
+ if (CollectionUtils.isNotEmpty(examDetailList)) {
|
|
|
+ long count = examDetailList.stream().filter(m -> basicExamStudent.getExamStartTime().equals(m.getExamStartTime()) && basicExamStudent.getExamEndTime().equals(m.getExamEndTime()) && basicExamStudent.getExamPlace().equals(m.getExamPlace()) && basicExamStudent.getExamRoom().equals(m.getExamRoom())).count();
|
|
|
+ if (count != 0) {
|
|
|
+ stringJoiner.add("试卷编号[" + basicExamStudentImport.getPaperNumber() + "]、考试日期[" + basicExamStudentImport.getExamDate() + "]、考试时间[" + basicExamStudentImport.getExamTime() + "]、考场[" + basicExamStudentImport.getExamPlace() + "]、考点[" + basicExamStudentImport.getExamRoom() + "]已有印刷任务");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (stringJoiner.toString().length() > 0) {
|
|
@@ -505,7 +688,7 @@ public class ImportLogicServiceImpl implements ImportLogicService {
|
|
|
|
|
|
private BasicExamStudentParseDto parseBasicExamStudent(Long schoolId, InputStream inputStream) {
|
|
|
ExcelReader excelReader = ExcelReader.create(ExcelType.XLSX, inputStream, 1);
|
|
|
- List<DataMap> dataMapList = null;
|
|
|
+ List<DataMap> dataMapList;
|
|
|
try {
|
|
|
dataMapList = excelReader.getDataMapList();
|
|
|
} catch (Exception e) {
|
|
@@ -521,13 +704,15 @@ public class ImportLogicServiceImpl implements ImportLogicService {
|
|
|
throw ExceptionResultEnum.ERROR.exception("通用规则未设置");
|
|
|
}
|
|
|
|
|
|
+ // 必填字段
|
|
|
Map<String, EnumResult> requiredMap = basicExamRule.getRequiredFieldList().stream().filter(m -> m.getEnable()).collect(Collectors.toMap(EnumResult::getName, e -> e));
|
|
|
+ // 扩展字段
|
|
|
Map<String, EnumResult> extendMap = basicExamRule.getExtendFieldList().stream().filter(m -> m.getEnable()).collect(Collectors.toMap(EnumResult::getName, e -> e));
|
|
|
|
|
|
// 通用规则表头
|
|
|
List<String> actualTitleList = Stream.concat(requiredMap.keySet().stream(), extendMap.keySet().stream()).collect(Collectors.toList());
|
|
|
if (!CollectionUtils.isEqualCollection(Arrays.asList(columnNames), actualTitleList)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("表头有误,表头字段应为【" + String.join(",", actualTitleList) + "】");
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("表头名称错误,正确表头为【" + String.join(",", actualTitleList) + "】");
|
|
|
}
|
|
|
|
|
|
basicExamStudentParseDto.setColumnNames(columnNames);
|
|
@@ -1071,159 +1256,4 @@ public class ImportLogicServiceImpl implements ImportLogicService {
|
|
|
}
|
|
|
return map;
|
|
|
}
|
|
|
-
|
|
|
- @Transactional
|
|
|
- @Override
|
|
|
- public Map<String, Object> executeImportBasicExamStudentTeacherLogic(Map<String, Object> map, StringJoiner stringJoinerSummary) {
|
|
|
- SysUser requestUser = (SysUser) map.get(SystemConstant.USER);
|
|
|
- InputStream inputStream = (InputStream) map.get("inputStream");
|
|
|
- Long examId = SystemConstant.convertIdToLong(String.valueOf(map.get("examId")));
|
|
|
- Long schoolId = requestUser.getSchoolId();
|
|
|
- BasicExam basicExam = basicExamService.getById(examId);
|
|
|
- if (Objects.isNull(basicExam)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("考试不存在");
|
|
|
- }
|
|
|
-
|
|
|
- SystemConstant.addSummary(stringJoinerSummary, "开始解析文件内容");
|
|
|
- BasicExamStudentParseDto basicExamStudentParseDto;
|
|
|
- try {
|
|
|
- basicExamStudentParseDto = this.parseBasicExamStudent(schoolId, inputStream);
|
|
|
- } catch (Exception e) {
|
|
|
- SystemConstant.addSummary(stringJoinerSummary, "解析文件内容结束,解析失败。" + e.getMessage());
|
|
|
- throw ExceptionResultEnum.ERROR.exception(e.getMessage());
|
|
|
- }
|
|
|
- SystemConstant.addSummary(stringJoinerSummary, "解析文件内容结束,开始进行数据校验");
|
|
|
-
|
|
|
- List<BasicExamStudentImport> basicExamStudentImportList = basicExamStudentParseDto.getBasicExamStudentImportList();
|
|
|
- if (CollectionUtils.isEmpty(basicExamStudentImportList)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("没有可导入数据");
|
|
|
- }
|
|
|
-
|
|
|
- List<BasicExamStudent> basicExamStudentList = basicExamStudentService.list(new QueryWrapper<BasicExamStudent>().lambda()
|
|
|
- .select(BasicExamStudent::getId, BasicExamStudent::getCourseId, BasicExamStudent::getStudentCode, BasicExamStudent::getPaperNumber)
|
|
|
- .eq(BasicExamStudent::getSchoolId, schoolId).eq(BasicExamStudent::getExamId, examId));
|
|
|
- Map<String, BasicExamStudent> courseIdStudentCodeMap = basicExamStudentList.stream().collect(Collectors.toMap(k -> k.getCourseId() + SystemConstant.HYPHEN + k.getStudentCode(), e -> e));
|
|
|
-
|
|
|
- Map<String, Long> basicCourseIdMap = new HashMap<>();
|
|
|
-
|
|
|
- // 课程学号唯一
|
|
|
- List<String> courseCodeStudentCodeList = new ArrayList<>();
|
|
|
- // 课程+教学班->任课老师
|
|
|
- Map<String, Long> courseTeachClassTeacherMap = new HashMap<>();
|
|
|
- // 是否有错误提示
|
|
|
- boolean hasError = false;
|
|
|
-
|
|
|
- // 必填字段为课程代码、开课学院、学号、教学班、任课老师工号、任课老师
|
|
|
- List<String> requiredCodes = Arrays.asList(RequiredFieldsEnum.STUDENT_CODE.getCode(), RequiredFieldsEnum.COURSE_CODE.getCode(), RequiredFieldsEnum.TEACHING_ROOM_NAME.getCode(), RequiredFieldsEnum.TEACH_CLASS_NAME.getCode(), RequiredFieldsEnum.TEACHER_NAME.getCode(), RequiredFieldsEnum.TEACHER_CODE.getCode());
|
|
|
-
|
|
|
- List<BasicExamStudent> basicExamStudents = new ArrayList<>();
|
|
|
- for (BasicExamStudentImport basicExamStudentImport : basicExamStudentImportList) {
|
|
|
- BasicExamStudent basicExamStudent = new BasicExamStudent();
|
|
|
- StringJoiner stringJoiner = new StringJoiner(";");
|
|
|
-
|
|
|
- // 校验excel内容
|
|
|
- basicExamStudentImport.getRequiredFieldList().forEach(m -> {
|
|
|
- if (requiredCodes.contains(m.getCode()) && StringUtils.isBlank(m.getValue())) {
|
|
|
- stringJoiner.add(m.getName() + "必填");
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- // 校验课程
|
|
|
- String key = basicExamStudentImport.getCourseCode() + SystemConstant.HYPHEN + basicExamStudentImport.getTeachingRoomName();
|
|
|
- if (!basicCourseIdMap.containsKey(key)) {
|
|
|
- List<SysOrg> sysOrgList = sysOrgService.getSecondOrg(schoolId, basicExamStudentImport.getTeachingRoomName());
|
|
|
- if (CollectionUtils.isEmpty(sysOrgList)) {
|
|
|
- stringJoiner.add("开课学院[" + basicExamStudentImport.getTeachingRoomName() + "]在学院层级不存在");
|
|
|
- } else {
|
|
|
- SysOrg sysOrg = sysOrgList.get(0);
|
|
|
- // 校验课程代码和开课学院
|
|
|
- BasicCourse basicCourse = basicCourseService.getByTeachRoomIdAndCode(sysOrg.getId(), basicExamStudentImport.getCourseCode());
|
|
|
- if (Objects.isNull(basicCourse)) {
|
|
|
- stringJoiner.add("课程代码[" + basicExamStudentImport.getCourseCode() + "]在开课学院[" + basicExamStudentImport.getTeachingRoomName() + "]不存在");
|
|
|
- } else {
|
|
|
- basicExamStudent.setCourseId(basicCourse.getId());
|
|
|
- basicCourseIdMap.put(key, basicCourse.getId());
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- basicExamStudent.setCourseId(basicCourseIdMap.get(key));
|
|
|
- }
|
|
|
-
|
|
|
- //校验任课老师
|
|
|
- SysUser sysUser = sysUserService.getByLoginName(schoolId, basicExamStudentImport.getTeacherCode());
|
|
|
- if (sysUser == null) {
|
|
|
- stringJoiner.add("任课老师工号[" + basicExamStudentImport.getTeacherCode() + "]不存在");
|
|
|
- } else {
|
|
|
- if (!sysUser.getEnable()) {
|
|
|
- stringJoiner.add("任课老师工号[" + basicExamStudentImport.getTeacherCode() + "]已禁用");
|
|
|
- } else if (!sysUser.getRealName().equals(basicExamStudentImport.getTeacherName())) {
|
|
|
- stringJoiner.add("任课老师[" + basicExamStudentImport.getTeacherName() + "]与用户管理中姓名[" + sysUser.getRealName() + "]不一致");
|
|
|
- } else {
|
|
|
- basicExamStudent.setTeacherId(sysUser.getId());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (basicExamStudent.getCourseId() != null) {
|
|
|
- // 校验同课程下,同一教学班只能有一个任课老师
|
|
|
- String courseTeachClassTeacherKey = basicExamStudent.getCourseId() + basicExamStudent.getTeachClassName();
|
|
|
- if (courseTeachClassTeacherMap.containsKey(courseTeachClassTeacherKey)) {
|
|
|
- Long teacherId = courseTeachClassTeacherMap.get(courseTeachClassTeacherKey);
|
|
|
- if ((teacherId == null && basicExamStudent.getTeacherId() != null) || (teacherId != null && basicExamStudent.getTeacherId() == null) || (teacherId != null && !teacherId.equals(basicExamStudent.getTeacherId()))) {
|
|
|
- stringJoiner.add("同课程下相同教学班,只能有一位任课老师");
|
|
|
- }
|
|
|
- } else {
|
|
|
- courseTeachClassTeacherMap.put(courseTeachClassTeacherKey, basicExamStudent.getTeacherId());
|
|
|
- }
|
|
|
-
|
|
|
- String studentKey = basicExamStudent.getCourseId() + SystemConstant.HYPHEN + basicExamStudentImport.getStudentCode();
|
|
|
- if (courseIdStudentCodeMap.containsKey(studentKey)) {
|
|
|
- BasicExamStudent student = courseIdStudentCodeMap.get(studentKey);
|
|
|
- basicExamStudent.setId(student.getId());
|
|
|
- basicExamStudent.setPaperType(student.getPaperType());
|
|
|
- // 更新requiredFields中的任课老师和任课老师工号
|
|
|
- for (CodeNameEnableValue codeNameEnableValue : student.getRequiredFieldList()) {
|
|
|
- if (codeNameEnableValue.getCode().equals(RequiredFieldsEnum.TEACHER_CODE.getCode())) {
|
|
|
- codeNameEnableValue.setValue(basicExamStudentImport.getTeacherCode());
|
|
|
- }
|
|
|
- if (codeNameEnableValue.getCode().equals(RequiredFieldsEnum.TEACHER_NAME.getCode())) {
|
|
|
- codeNameEnableValue.setValue(basicExamStudentImport.getTeacherName());
|
|
|
- }
|
|
|
- }
|
|
|
- basicExamStudent.setRequiredFields(JSON.toJSONString(student.getRequiredFieldList()));
|
|
|
- } else {
|
|
|
- stringJoiner.add(String.format("课程代码[%s],开课学院[%s],学号[%s]考生管理中不存在", basicExamStudentImport.getCourseCode(), basicExamStudentImport.getTeachingRoomName(), basicExamStudentImport.getStudentCode()));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 校验课程学号唯一
|
|
|
- String courseCodeStudentCode = basicExamStudentImport.getCourseCode() + basicExamStudentImport.getStudentCode();
|
|
|
- if (courseCodeStudentCodeList.contains(courseCodeStudentCode)) {
|
|
|
- stringJoiner.add("课程代码[" + basicExamStudentImport.getCourseCode() + "]已存在学号[" + basicExamStudentImport.getStudentCode() + "]的考生数据");
|
|
|
- } else {
|
|
|
- courseCodeStudentCodeList.add(courseCodeStudentCode);
|
|
|
- }
|
|
|
-
|
|
|
- if (stringJoiner.toString().length() > 0) {
|
|
|
- basicExamStudentImport.setErrorMsg(stringJoiner.toString());
|
|
|
- }
|
|
|
-
|
|
|
- if (!hasError && stringJoiner.toString().length() > 0) {
|
|
|
- hasError = true;
|
|
|
- }
|
|
|
-
|
|
|
- if (stringJoiner.toString().length() == 0) {
|
|
|
- basicExamStudents.add(basicExamStudent);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- map.put(SystemConstant.ERROR_DATA_LIST, basicExamStudentImportList);
|
|
|
- map.put(SystemConstant.DATASOURCE, basicExamStudents);
|
|
|
- map.put(SystemConstant.DATA_COUNT, basicExamStudentImportList.size());
|
|
|
- map.put(SystemConstant.SUCCESS_DATA_COUNT, basicExamStudents.size());
|
|
|
- map.put(SystemConstant.ERROR_DATA_COUNT, basicExamStudentImportList.size() - basicExamStudents.size());
|
|
|
- map.put(SystemConstant.HAS_ERROR_DATA, hasError);
|
|
|
- map.put(SystemConstant.COLUMN_NAMES, basicExamStudentParseDto.getColumnNames());
|
|
|
-
|
|
|
- return map;
|
|
|
- }
|
|
|
}
|