فهرست منبع

3.4.3 update-20241230

xiaofei 5 ماه پیش
والد
کامیت
4b957a0f63

+ 20 - 4
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicExamStudentServiceImpl.java

@@ -82,6 +82,8 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
     @Resource
     private MarkTaskService markTaskService;
     @Resource
+    private ExamTaskService examTaskService;
+    @Resource
     private ExamTaskDetailService examTaskDetailService;
     @Resource
     private ExamStudentService examStudentService;
@@ -268,10 +270,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() + "]");
+
                 }
             }
         }