Browse Source

3.4.0 update

xiaofei 11 tháng trước cách đây
mục cha
commit
642f5f70e9

+ 1 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamTaskDetailService.java

@@ -61,6 +61,7 @@ public interface ExamTaskDetailService extends IService<ExamTaskDetail> {
     ExamTaskDetail getByExamIdAndCourseIdAndPaperNumber(Long examId, Long courseId, String paperNumber);
 
     void updateExposePaperType(Long examId, List<ExamDetailCourse> listByExamDetailId);
+    void updateUnexposePaperType(Long examId, String paperNumber, String exposePaperType);
 
     int countByCardId(Long cardId);
 }

+ 5 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicExamStudentServiceImpl.java

@@ -186,6 +186,11 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
                         markPaperService.updateUploadCount(examId, paperNumber,
                                 markStudentService.countUploadedByExamIdAndPaperNumber(examId, paperNumber));
                     }
+
+                    // 考务数据全删除时,将卷型更新为未曝光
+                    if (examStudentService.countByExamIdAndPaperNumber(examId, paperNumber) == 0) {
+                        examTaskDetailService.updateUnexposePaperType(examId, paperNumber, markPaper.getPaperType());
+                    }
                 }
             }
             this.removeByIds(idList);

+ 7 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamDetailServiceImpl.java

@@ -766,8 +766,12 @@ public class ExamDetailServiceImpl extends ServiceImpl<ExamDetailMapper, ExamDet
                     // 删除扫描数据
                     markStudentService.removeByIds(examStudentIds);
                     // 当考务数据考生表中学生数量为0时,扫描表中学生数量大于0,说明从考生管理新增的考生未删除,则通过试卷编号全部删掉
-                    if (examStudentService.countByExamIdAndPaperNumber(examDetail.getExamId(), examDetailCourse.getPaperNumber()) == 0 && markStudentService.countByExamIdAndPaperNumber(examDetail.getExamId(), examDetailCourse.getPaperNumber(), null) > 0) {
-                        markStudentService.deleteByExamIdAndPaperNumber(examDetail.getExamId(), examDetailCourse.getPaperNumber());
+                    if (examStudentService.countByExamIdAndPaperNumber(examDetail.getExamId(), examDetailCourse.getPaperNumber()) == 0) {
+                        if (markStudentService.countByExamIdAndPaperNumber(examDetail.getExamId(), examDetailCourse.getPaperNumber(), null) > 0) {
+                            markStudentService.deleteByExamIdAndPaperNumber(examDetail.getExamId(), examDetailCourse.getPaperNumber());
+                        }
+                        // 考生数据全部删除时,还原已曝光卷型
+                        examTaskDetailService.updateUnexposePaperType(examDetail.getExamId(), examDetailCourse.getPaperNumber(), examDetailCourse.getPaperType());
                     }
                     if (markStudentService.countByExamIdAndPaperNumber(examDetail.getExamId(), examDetailCourse.getPaperNumber(), null) == 0) {
                         markPaperService.deleteByExamIdAndPaperNumber(examDetail.getExamId(), examDetailCourse.getPaperNumber());
@@ -782,7 +786,7 @@ public class ExamDetailServiceImpl extends ServiceImpl<ExamDetailMapper, ExamDet
                             markPaperService.updateStudentCountByExamIdAndPaperNumberAndPaperType(examDetail.getExamId(), examDetailCourse.getPaperNumber(), paperType);
                         }
                     }
-                    if(markPaperService.getByExamIdAndPaperNumber(examDetail.getExamId(), examDetailCourse.getPaperNumber()) != null) {
+                    if (markPaperService.getByExamIdAndPaperNumber(examDetail.getExamId(), examDetailCourse.getPaperNumber()) != null) {
                         // 清空考生管理中卷型
                         basicExamStudentService.clearPaperNumberAndPaperTypeById(examStudents.stream().filter(m -> m.getBasicStudentId() != null).map(ExamStudent::getBasicStudentId).collect(Collectors.toList()));
                     } else {

+ 23 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskDetailServiceImpl.java

@@ -696,6 +696,29 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
         }
     }
 
+    @Override
+    public void updateUnexposePaperType(Long examId, String paperNumber, String exposePaperType) {
+        // 更新曝光卷型、未曝光卷型
+        ExamTaskDetail examTaskDetail = this.getByExamIdAndCourseIdAndPaperNumber(examId, null, paperNumber);
+        // 考生使用卷型
+        List<String> studentPaperTypes = Arrays.asList(exposePaperType.split(","));
+        List<String> paperTypeList = Objects.isNull(examTaskDetail.getPaperType()) ? new ArrayList<>() : Arrays.asList(examTaskDetail.getPaperType().split(","));
+        List<String> exposedPaperTypeList = Objects.isNull(examTaskDetail.getExposedPaperType()) ? new ArrayList<>() : Arrays.asList(examTaskDetail.getExposedPaperType().split(","));
+
+        List<String> exposedList = (List<String>) CollectionUtils.subtract(exposedPaperTypeList, studentPaperTypes);
+
+        // 未曝光卷型
+        List<String> subtractList = (List<String>) CollectionUtils.subtract(paperTypeList, exposedList);
+        UpdateWrapper<ExamTaskDetail> examTaskDetailUpdateWrapper = new UpdateWrapper<>();
+        String exposedPaper = String.join(",", exposedList);
+        String unexposedPaper = String.join(",", subtractList);
+        examTaskDetailUpdateWrapper.lambda()
+                .set(ExamTaskDetail::getExposedPaperType, StringUtils.isBlank(exposedPaper) ? null : exposedPaper)
+                .set(ExamTaskDetail::getUnexposedPaperType, StringUtils.isBlank(unexposedPaper) ? null : unexposedPaper)
+                .eq(ExamTaskDetail::getExamTaskId, examTaskDetail.getExamTaskId());
+        this.update(examTaskDetailUpdateWrapper);
+    }
+
     @Override
     public int countByCardId(Long cardId) {
         return examTaskDetailMapper.countByCardId(cardId);

+ 6 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskWholeServiceImpl.java

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.boot.api.exception.ApiException;
+import com.qmth.boot.core.concurrent.service.ConcurrentService;
 import com.qmth.distributed.print.business.entity.ExamDetail;
 import com.qmth.distributed.print.business.entity.ExamTaskWhole;
 import com.qmth.distributed.print.business.enums.ExamTaskWholeStatusEnum;
@@ -23,6 +24,7 @@ import com.qmth.teachcloud.common.enums.UploadFileEnum;
 import com.qmth.teachcloud.common.service.BasicAttachmentService;
 import com.qmth.teachcloud.common.service.FileUploadService;
 import com.qmth.teachcloud.common.util.FileUtil;
+import com.qmth.teachcloud.mark.enums.LockType;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
@@ -49,11 +51,14 @@ public class ExamTaskWholeServiceImpl extends ServiceImpl<ExamTaskWholeMapper, E
     @Resource
     private FileUploadService fileUploadService;
     @Resource
+    private ConcurrentService concurrentService;
+    @Resource
     private AsyncCreateWholePdfTemplateService asyncCreateWholePdfTemplateService;
 
     @Override
     public void checkAndCreateTask(Long examId, Long courseId, String paperNumber) {
         String key = examId + valueOf(courseId) + paperNumber;
+        concurrentService.getReadWriteLock(LockType.EXAM_TASK_WHOLE + "-" + key).writeLock().lock();
         try {
             if (examTaskWholeList.contains(key)) {
                 return;
@@ -90,6 +95,7 @@ public class ExamTaskWholeServiceImpl extends ServiceImpl<ExamTaskWholeMapper, E
             throw ExceptionResultEnum.ERROR.exception(e.getMessage());
         } finally {
             examTaskWholeList.remove(key);
+            concurrentService.getReadWriteLock(LockType.EXAM_TASK_WHOLE + "-" + key).writeLock().lock();
         }
     }
 

+ 17 - 17
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/ImportLogicServiceImpl.java

@@ -204,7 +204,7 @@ public class ImportLogicServiceImpl implements ImportLogicService {
                             basicCourseIdMap.put(key, basicCourse.getId());
                         }
                     } else {
-                        stringJoiner.add("开课学院[" + basicExamStudentImport.getTeachingRoomName() + "]存在多个");
+                        stringJoiner.add("开课学院[" + basicExamStudentImport.getTeachingRoomName() + "]存在多个相同值");
                     }
                 } else {
                     basicExamStudent.setCourseId(basicCourseIdMap.get(key));
@@ -599,7 +599,7 @@ public class ImportLogicServiceImpl implements ImportLogicService {
                             basicCourseIdMap.put(key, basicCourse.getId());
                         }
                     } else {
-                        stringJoiner.add("开课学院[" + basicExamStudentImport.getTeachingRoomName() + "]存在多个");
+                        stringJoiner.add("开课学院[" + basicExamStudentImport.getTeachingRoomName() + "]存在多个相同值");
                     }
                 } else {
                     basicExamStudent.setCourseId(basicCourseIdMap.get(key));
@@ -616,25 +616,25 @@ public class ImportLogicServiceImpl implements ImportLogicService {
                 } else {
                     paperNumberCourseIdInMap.put(basicExamStudent.getPaperNumber(), basicExamStudent.getCourseId());
                 }
-            }
 
-            // 校验试卷编号课程代码是否已命题且命题任务中课程代码是否一致
-            if (StringUtils.isNotBlank(basicExamStudent.getPaperNumber())) {
-                if (paperNumberMap.containsKey(basicExamStudent.getPaperNumber())) {
-                    List<ExamTask> examTasks = paperNumberMap.get(basicExamStudent.getPaperNumber());
-                    if (examTasks.size() > 1) {
-                        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()));
+                // 校验试卷编号课程代码是否已命题且命题任务中课程代码是否一致
+                if (StringUtils.isNotBlank(basicExamStudent.getPaperNumber())) {
+                    if (paperNumberMap.containsKey(basicExamStudent.getPaperNumber())) {
+                        List<ExamTask> examTasks = paperNumberMap.get(basicExamStudent.getPaperNumber());
+                        if (examTasks.size() > 1) {
+                            stringJoiner.add(String.format("试卷编号[%s]在考试[%s]下有多条命题任务,请联系管理员处理", basicExamStudent.getPaperNumber(), basicExam.getName()));
                         } else {
-                            basicExamStudent.setCoursePaperId(String.valueOf(examTask.getId()));
+                            Long courseId = paperNumberCourseIdInMap.get(basicExamStudent.getPaperNumber());
+                            ExamTask examTask = examTasks.get(0);
+                            if (!examTask.getCourseId().equals(courseId)) {
+                                stringJoiner.add(String.format("试卷编号[%s]对应课程代码与命题任务中对应课程代码不一致", basicExamStudent.getPaperNumber()));
+                            } else {
+                                basicExamStudent.setCoursePaperId(String.valueOf(examTask.getId()));
+                            }
                         }
+                    } else {
+                        stringJoiner.add(String.format("试卷编号[%s]未命题", basicExamStudent.getPaperNumber()));
                     }
-                } else {
-                    stringJoiner.add(String.format("试卷编号[%s]未命题", basicExamStudent.getPaperNumber()));
                 }
             }
 

+ 1 - 0
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/enums/LockType.java

@@ -20,6 +20,7 @@ public enum LockType {
 	CARD_SAVE("card_save"),
 	INIT_MARK_DATA("init_mark_data"),
     CREATE_PDF("create_pdf"),
+    EXAM_TASK_WHOLE("exam_task_whole"),
 	;
 
 	private String name;