소스 검색

1.0.4 bug

xiaofei 1 년 전
부모
커밋
575f8309dd

+ 26 - 4
paper-library-business/src/main/java/com/qmth/paper/library/business/service/impl/ExamStudentServiceImpl.java

@@ -70,15 +70,21 @@ public class ExamStudentServiceImpl extends ServiceImpl<ExamStudentMapper, ExamS
             if (StringUtils.isBlank(examStudent.getStudentCode())) {
                 throw ExceptionResultEnum.ERROR.exception("学号必填");
             }
+            // 学号去掉空格
+            examStudent.setStudentCode(StringUtils.deleteWhitespace(examStudent.getStudentCode()));
             if (StringUtils.isBlank(examStudent.getStudentName())) {
                 throw ExceptionResultEnum.ERROR.exception("姓名必填");
             }
             if (StringUtils.isBlank(examStudent.getCourseCode())) {
                 throw ExceptionResultEnum.ERROR.exception("课程代码必填");
             }
+            // 课程代码去掉空格
+            examStudent.setCourseCode(StringUtils.deleteWhitespace(examStudent.getCourseCode()));
             if (StringUtils.isBlank(examStudent.getCourseName())) {
                 throw ExceptionResultEnum.ERROR.exception("课程名称必填");
             }
+            // 课程名称去掉空格
+            examStudent.setCourseName(StringUtils.deleteWhitespace(examStudent.getCourseName()));
 
             // 校验是否设置了存储方式
             SimpleObject recognitionTypeSimpleObject = commonCacheService.getSysSetting(sysUser.getSchoolId()).get(SysSettingConstant.RECOGNITION_TYPE);
@@ -104,6 +110,11 @@ public class ExamStudentServiceImpl extends ServiceImpl<ExamStudentMapper, ExamS
             examStudent.setSchoolId(sysUser.getSchoolId());
             examStudent.setCreateId(sysUser.getId());
             examStudent.setCreateTime(System.currentTimeMillis());
+
+            // 考场去掉空格
+            examStudent.setExamRoom(StringUtils.isNotBlank(examStudent.getExamRoom()) ? StringUtils.deleteWhitespace(examStudent.getExamRoom()) : null);
+            // 班级去掉空格
+            examStudent.setClassName(StringUtils.isNotBlank(examStudent.getClassName()) ? StringUtils.deleteWhitespace(examStudent.getClassName()) : null);
             boolean save = this.save(examStudent);
 
             if (save) {
@@ -193,14 +204,14 @@ public class ExamStudentServiceImpl extends ServiceImpl<ExamStudentMapper, ExamS
             validStudentData(semesterId, examId, basicStudentList, storeType, sysUser);
             // 保存课程
             List<ExamCourse> examCourses = examCourseService.saveBatchStudentCourse(examId, basicStudentList);
-            // 新建任务
-            paperScanTaskService.addBatchScanTask(examId, recognitionType, storeType, examCourses, basicStudentList);
             for (ExamCourse examCourse : examCourses) {
                 this.removeByExamIdAndCourseCode(examId, examCourse.getCourseCode());
             }
             // 保存学生
             this.saveBatch(basicStudentList);
-        }catch (Exception e) {
+            // 新建任务
+            paperScanTaskService.addBatchScanTask(examId, recognitionType, storeType, examCourses, basicStudentList);
+        } catch (Exception e) {
             throw ExceptionResultEnum.ERROR.exception(e.getMessage());
         }
     }
@@ -275,10 +286,21 @@ public class ExamStudentServiceImpl extends ServiceImpl<ExamStudentMapper, ExamS
                 }
             }
 
-            if(StringUtils.isNotBlank(errorMsg.toString())){
+            if (StringUtils.isNotBlank(errorMsg.toString())) {
                 throw ExceptionResultEnum.ERROR.exception(errorMsg.toString());
             }
 
+            // 学号去掉空格
+            basicStudent.setStudentCode(StringUtils.isNotBlank(basicStudent.getStudentCode()) ? StringUtils.deleteWhitespace(basicStudent.getStudentCode()) : null);
+            // 课程代码去掉空格
+            basicStudent.setCourseCode(StringUtils.isNotBlank(basicStudent.getCourseCode()) ? StringUtils.deleteWhitespace(basicStudent.getCourseCode()) : null);
+            // 课程名称去掉空格
+            basicStudent.setCourseName(StringUtils.isNotBlank(basicStudent.getCourseName()) ? StringUtils.deleteWhitespace(basicStudent.getCourseName()) : null);
+            // 考场去掉空格
+            basicStudent.setExamRoom(StringUtils.isNotBlank(basicStudent.getExamRoom()) ? StringUtils.deleteWhitespace(basicStudent.getExamRoom()) : null);
+            // 班级去掉空格
+            basicStudent.setClassName(StringUtils.isNotBlank(basicStudent.getClassName()) ? StringUtils.deleteWhitespace(basicStudent.getClassName()) : null);
+
             basicStudent.setId(SystemConstant.getDbUuid());
             basicStudent.setSchoolId(sysUser.getSchoolId());
             basicStudent.setSemesterId(semesterId);

+ 12 - 4
paper-library-business/src/main/java/com/qmth/paper/library/business/service/impl/PaperScanTaskServiceImpl.java

@@ -121,11 +121,19 @@ public class PaperScanTaskServiceImpl extends ServiceImpl<PaperScanTaskMapper, P
         List<PaperScanTask> paperScanTaskList = new ArrayList<>();
         for (ExamCourse examCourse : examCourses) {
             int studentCount = Math.toIntExact(basicStudentList.stream().filter(m -> m.getCourseCode().equals(examCourse.getCourseCode())).count());
-            String scanTaskName = String.format("%s(%s)", examCourse.getCourseName(), examCourse.getCourseCode());
-            String scanTaskCode = paperLibraryCommonService.getScanTaskCode(schoolId);
-            paperScanTaskList.add(new PaperScanTask(schoolId, examId, scanTaskCode, scanTaskName, examCourse.getCourseCode(), examCourse.getCourseName(), recognitionType, storeType, studentCount));
+            PaperScanTask paperScanTask = this.getByExamIdAndCourseCode(examId, examCourse.getCourseCode());
+            if (paperScanTask == null) {
+                String scanTaskName = String.format("%s(%s)", examCourse.getCourseName(), examCourse.getCourseCode());
+                String scanTaskCode = paperLibraryCommonService.getScanTaskCode(schoolId);
+                paperScanTask = new PaperScanTask(schoolId, examId, scanTaskCode, scanTaskName, examCourse.getCourseCode(), examCourse.getCourseName(), recognitionType, storeType, studentCount);
+            } else {
+                paperScanTask.setRecognitionType(recognitionType);
+                paperScanTask.setStoreType(storeType);
+                paperScanTask.setStudentCount(studentCount);
+            }
+            paperScanTaskList.add(paperScanTask);
         }
-        this.saveBatch(paperScanTaskList);
+        this.saveOrUpdateBatch(paperScanTaskList);
     }
 
     @Override