Jelajahi Sumber

3.4.2 update-1227编辑考生卷型报错

xiaofei 5 bulan lalu
induk
melakukan
1fbd0224d9

+ 25 - 9
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicExamStudentServiceImpl.java

@@ -79,6 +79,8 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
     @Resource
     private MarkTaskService markTaskService;
     @Resource
+    private ExamTaskService examTaskService;
+    @Resource
     private ExamTaskDetailService examTaskDetailService;
     @Resource
     private ExamStudentService examStudentService;
@@ -217,7 +219,7 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
         String teacherCode = basicExamStudentParam.getTeacherCode();
         String paperType = basicExamStudentParam.getPaperType();
 
-        if(StringUtils.isNotBlank(studentCode) && !studentCode.matches(SystemConstant.REGULAR_EXPRESSION_OF_STUDENT_CODE)){
+        if (StringUtils.isNotBlank(studentCode) && !studentCode.matches(SystemConstant.REGULAR_EXPRESSION_OF_STUDENT_CODE)) {
             throw ExceptionResultEnum.ERROR.exception("学号只能由字母、数字组成");
         }
 
@@ -241,10 +243,10 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
                     teacherId = sysUser.getId();
                     // 校验同课程、同教学班下任课老师必须相同
                     List<BasicExamStudent> basicExamStudentList = this.listByExamIdAndCourseIdAndTeachClassName(basicExamStudentParam.getExamId(), basicExamStudentParam.getCourseId(), basicExamStudentParam.getTeachClassName());
-                    if(CollectionUtils.isNotEmpty(basicExamStudentList)){
+                    if (CollectionUtils.isNotEmpty(basicExamStudentList)) {
                         long count = basicExamStudentList.stream().filter(m -> m.getTeacherId() != null && !sysUser.getId().equals(m.getTeacherId())).count();
-                        if(count > 0){
-                            throw ExceptionResultEnum.ERROR.exception("教学班["+basicExamStudentParam.getTeachClassName()+"]存在其它任课老师,教学班的任课老师必须相同");
+                        if (count > 0) {
+                            throw ExceptionResultEnum.ERROR.exception("教学班[" + basicExamStudentParam.getTeachClassName() + "]存在其它任课老师,教学班的任课老师必须相同");
                         }
                     }
                 }
@@ -265,10 +267,24 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
         // 校验试卷编号和卷型
         if (!ExamModelEnum.MODEL4.equals(basicExam.getExamModel()) && StringUtils.isNoneBlank(basicExamStudentParam.getPaperNumber(), basicExamStudentParam.getPaperType())) {
             // 默认取备用卷1的卷型(所有备用卷的卷型一样,A或者AB)
-            ExamTaskDetail examTaskDetail = examTaskDetailService.getByExamIdAndPaperNumberAndSerialNumber(basicExamStudentParam.getExamId(), basicExamStudentParam.getPaperNumber(), 1);
-            if (examTaskDetail != null) {
-                if (!examTaskDetail.getPaperType().contains(basicExamStudentParam.getPaperType())) {
-                    throw ExceptionResultEnum.ERROR.exception("试卷编号[" + basicExamStudentParam.getPaperNumber() + "]的命题任务卷型为[" + examTaskDetail.getPaperType() + "]");
+            ExamTask examTask = examTaskService.getByExamIdAndPaperNumber(basicExamStudentParam.getExamId(), basicExamStudentParam.getPaperNumber());
+            if (examTask == null) {
+                throw ExceptionResultEnum.ERROR.exception("试卷编号[" + basicExamStudentParam.getPaperNumber() + "]命题任务不存在");
+            }
+            ExamTaskDetail examTaskDetail;
+            if (examTask.getOpenAb()) {
+                examTaskDetail = examTaskDetailService.getByExamIdAndPaperNumberAndSerialNumber(basicExamStudentParam.getExamId(), basicExamStudentParam.getPaperNumber(), 1);
+                if (examTaskDetail != null) {
+                    if (!examTaskDetail.getPaperType().contains(basicExamStudentParam.getPaperType())) {
+                        throw ExceptionResultEnum.ERROR.exception("试卷编号[" + basicExamStudentParam.getPaperNumber() + "]的命题任务卷型为[" + examTaskDetail.getPaperType() + "]");
+                    }
+                }
+            } else {
+                List<ExamTaskDetail> examTaskDetails = examTaskDetailService.listByExamTaskId(examTask.getId());
+                examTaskDetail = examTaskDetails.stream().filter(m -> m.getPaperType().equals(basicExamStudentParam.getPaperType())).findFirst().orElse(null);
+                if (examTaskDetail == null) {
+                    throw ExceptionResultEnum.ERROR.exception("试卷编号[" + basicExamStudentParam.getPaperNumber() + "]的命题任务不存在卷型[" + basicExamStudentParam.getPaperType() + "]");
+
                 }
             }
         }
@@ -486,7 +502,7 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
         for (Map.Entry<String, List<BasicExamStudent>> entry : stringMap.entrySet()) {
             BasicExamStudent basicExamStudent = entry.getValue().get(0);
             AbInfoVo abInfoVo = markStudentService.findExamTaskPaperTypeOpenStatus(examId, entry.getKey());
-            boolean containPaperType = abInfoVo!= null && (ExamNumberStyleEnum.PRINT.equals(abInfoVo.getExamNumberStyle()) || (ExamNumberStyleEnum.FILL.equals(abInfoVo.getExamNumberStyle()) && !abInfoVo.getOpenAb()));
+            boolean containPaperType = abInfoVo != null && (ExamNumberStyleEnum.PRINT.equals(abInfoVo.getExamNumberStyle()) || (ExamNumberStyleEnum.FILL.equals(abInfoVo.getExamNumberStyle()) && !abInfoVo.getOpenAb()));
             MarkPaper markPaper = markPaperService.getByExamIdAndPaperNumber(examId, entry.getKey());
             if (markPaper == null && ExamModelEnum.MODEL4.equals(basicExam.getExamModel())) {
                 String paperType = SystemConstant.DEFAULT_PAPER_TYPE_A;