Explorar o código

3.4.1 联调bug修复

xiaofei hai 9 meses
pai
achega
66bfca4d6f

+ 14 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/ExamTaskDetail.java

@@ -100,6 +100,12 @@ public class ExamTaskDetail extends BaseEntity implements Serializable {
     @TableField(exist = false)
     private List<Long> approveUserIds;
 
+    /**
+     * 保存内容
+     */
+    @TableField(exist = false)
+    private String examTaskContent;
+
     @ApiModelProperty(value = "卷型解析内容")
     @TableField(exist = false)
     List<PaperInfoVo> paperInfoVoList;
@@ -204,6 +210,14 @@ public class ExamTaskDetail extends BaseEntity implements Serializable {
         this.operateType = operateType;
     }
 
+    public String getExamTaskContent() {
+        return examTaskContent;
+    }
+
+    public void setExamTaskContent(String examTaskContent) {
+        this.examTaskContent = examTaskContent;
+    }
+
     public List<PaperInfoVo> getPaperInfoVoList(String paperTypes) {
         List<PaperInfoVo> paperInfoVos = new ArrayList<>();
         if(StringUtils.isNotBlank(paperAttachmentIds)){

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamCardServiceImpl.java

@@ -444,7 +444,7 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
             if (StringUtils.isNotBlank(jpgAttachmentIds)) {
                 List<ConvertJpgStorage> jsonObjectList = JSONObject.parseArray(jpgAttachmentIds, ConvertJpgStorage.class);
                 for (ConvertJpgStorage convertJpgStorage : jsonObjectList) {
-                    Long jpgAttachmentId = convertJpgStorage.getAttachmentId();
+                    String jpgAttachmentId = convertJpgStorage.getAttachmentId();
                     Integer index = convertJpgStorage.getIndex();
                     if (jpgAttachmentId != null) {
                         BasicAttachment attachment = basicAttachmentService.getById(jpgAttachmentId);

+ 217 - 174
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskServiceImpl.java

@@ -63,6 +63,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
+import javax.websocket.RemoteEndpoint;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -635,11 +636,11 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
     }
 
     @Override
-    public IPage<ExamTaskDto> listTaskApply(Long semesterId, Long examId, String auditStatus,Long openCollegeId, Long courseId, String paperNumber, Long startTime, Long endTime, String userName, Integer pageNumber, Integer pageSize) {
+    public IPage<ExamTaskDto> listTaskApply(Long semesterId, Long examId, String auditStatus, Long openCollegeId, Long courseId, String paperNumber, Long startTime, Long endTime, String userName, Integer pageNumber, Integer pageSize) {
         userName = SystemConstant.translateSpecificSign(userName);
         Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
-        IPage<ExamTaskDto> examTaskDtoIPage = this.baseMapper.listTaskApply(new Page<>(pageNumber, pageSize), schoolId, semesterId, examId, auditStatus,openCollegeId, courseId, paperNumber, startTime, endTime, sysUser.getId(), userName);
+        IPage<ExamTaskDto> examTaskDtoIPage = this.baseMapper.listTaskApply(new Page<>(pageNumber, pageSize), schoolId, semesterId, examId, auditStatus, openCollegeId, courseId, paperNumber, startTime, endTime, sysUser.getId(), userName);
         for (ExamTaskDto record : examTaskDtoIPage.getRecords()) {
             if ((Objects.nonNull(record.getReview()) && record.getReview() && FlowStatusEnum.FINISH.name().equals(record.getAuditStatus()) && !ExamModelEnum.MODEL3.equals(record.getExamModel()))) {
                 record.setApproveFormStatus(true);
@@ -660,7 +661,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
     }
 
     @Override
-    public IPage<ExamTaskDto> listTaskReviewAudited(Long semesterId, Long examId,Long openCollegeId, Long courseId, String
+    public IPage<ExamTaskDto> listTaskReviewAudited(Long semesterId, Long examId, Long openCollegeId, Long courseId, String
             paperNumber, Long userId, Long startTime, Long endTime, Long startCreateTime, Long endCreateTime, Integer pageNumber, Integer pageSize) {
         Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
         Set<Long> orgIds = teachcloudCommonService.listSubOrgIds(null);
@@ -670,7 +671,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
     }
 
     @Override
-    public IPage<ExamTaskDetailDto> listTaskPaper(Long semesterId, Long examId,Long openCollegeId, Long courseId, String paperNumber, Long startTime, Long endTime, Integer pageNumber, Integer pageSize) {
+    public IPage<ExamTaskDetailDto> listTaskPaper(Long semesterId, Long examId, Long openCollegeId, Long courseId, String paperNumber, Long startTime, Long endTime, Integer pageNumber, Integer pageSize) {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         boolean containsQuestionTeacher = false;
         Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
@@ -743,6 +744,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
                 .set(ExamTask::getUpdateTime, System.currentTimeMillis())
                 .set(ExamTask::getReviewStatus, null)
                 .set(ExamTask::getFlowId, examTask.getFlowId())
+                .set(ExamTask::getExamTaskContent, examTaskDetail.getExamTaskContent())
                 .eq(ExamTask::getId, examTask.getId());
         this.update(updateWrapper);
 
@@ -769,11 +771,47 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
         }
         examTaskDetail.setUpdateId(sysUser.getId());
         examTaskDetail.setUpdateTime(System.currentTimeMillis());
+
+        List<PaperInfoVo> filePathVoList = examTaskDetail.getPaperInfoVoList(null);
+        for (PaperInfoVo paperInfoVo : filePathVoList) {
+            BasicAttachment basicAttachment = basicAttachmentService.getById(paperInfoVo.getAttachmentId());
+            FilePathVo filePathVo = JSON.parseObject(basicAttachment.getPath(), FilePathVo.class);
+            InputStream inputStream = fileUploadService.downloadFile(filePathVo.getPath(), filePathVo.getUploadType(), filePathVo.getType());
+            List<ConvertJpgStorage> convertJpgStorageList = htmlToJpgUtil.convertPdfToJpg(Long.valueOf(paperInfoVo.getAttachmentId()), inputStream, sysUser.getId());
+            if (convertJpgStorageList.size() > 0) {
+                paperInfoVo.setJpgAttachmentId(JSON.toJSONString(convertJpgStorageList));
+            } else {
+                paperInfoVo.setJpgAttachmentId(null);
+            }
+        }
+        examTaskDetail.setPaperAttachmentIds(JSON.toJSONString(filePathVoList));
         examTaskDetailService.saveOrUpdate(examTaskDetail);
 
         // 将题卡更新为已绑定
         List<PaperInfoVo> paperAttachmentList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetail.getPaperAttachmentIds());
         examCardService.updateUsedById(paperAttachmentList.stream().filter(m -> StringUtils.isNotBlank(m.getCardId())).map(m -> Long.parseLong(m.getCardId())).collect(Collectors.toList()));
+
+        ExamTaskSubmitContent examTaskSubmitContent = JSON.parseObject(examTaskDetail.getExamTaskContent(), ExamTaskSubmitContent.class);
+        if (examTaskSubmitContent != null) {
+            List<ExamDetailCourse> examDetailCourseList = examDetailCourseService.listExamDetailByExamIdAndPaperNumber(sysUser.getSchoolId(), examTask.getExamId(), examTask.getPaperNumber());
+            if (CollectionUtils.isNotEmpty(examDetailCourseList)) {
+                Set<Long> examDetailIds = examDetailCourseList.stream().map(ExamDetailCourse::getExamDetailId).collect(Collectors.toSet());
+                List<ExamDetail> examDetailList = examDetailService.listByIds(examDetailIds);
+                if (CollectionUtils.isNotEmpty(examDetailList)) {
+                    // 删除原考场
+                    examDetailService.removeByIds(examDetailIds);
+                }
+                examDetailCourseService.removeByIds(examDetailCourseList.stream().map(ExamDetailCourse::getId).collect(Collectors.toList()));
+                // 删除原考生
+                examDetailCourseList.forEach(m -> examStudentService.removeByExamDetailCourseId(m.getId()));
+
+                BasicExam basicExam = basicExamService.getById(examTask.getExamId());
+                ExamPrintPlan examPrintPlan = examPrintPlanService.getById(examDetailList.get(0).getPrintPlanId());
+                // 新增考场、考生
+                this.addExamDetailAndStudent(examTask, basicExam, examTaskSubmitContent.getExamDetail(), examPrintPlan, sysUser);
+            }
+        }
+
         return map;
     }
 
@@ -1077,7 +1115,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
             examTask.setStatus(ExamStatusEnum.SUBMIT);
             examTask.setSource(ExamTaskSourceEnum.SELF);
             examTask.insertInfo(sysUser.getId());
-            examTask.setExamTaskContent(JSON.toJSONString(examTaskSubmitPram));
+            examTask.setExamTaskContent(examTaskSubmitPram.getExamTaskContent());
 
             if (Objects.isNull(examTask.getFlowId())) {
                 if (Objects.nonNull(basicPrintConfig.getReview()) && basicPrintConfig.getReview()) {
@@ -1103,7 +1141,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
             List<PaperInfoVo> filePathVoList = examTaskDetail.getPaperInfoVoList(null);
             for (PaperInfoVo paperInfoVo : filePathVoList) {
                 BasicAttachment basicAttachment = basicAttachmentService.getById(paperInfoVo.getAttachmentId());
-                FilePathVo  filePathVo = JSON.parseObject(basicAttachment.getPath(), FilePathVo.class);
+                FilePathVo filePathVo = JSON.parseObject(basicAttachment.getPath(), FilePathVo.class);
                 InputStream inputStream = fileUploadService.downloadFile(filePathVo.getPath(), filePathVo.getUploadType(), filePathVo.getType());
                 List<ConvertJpgStorage> convertJpgStorageList = htmlToJpgUtil.convertPdfToJpg(Long.valueOf(paperInfoVo.getAttachmentId()), inputStream, sysUser.getId());
                 if (convertJpgStorageList.size() > 0) {
@@ -1142,7 +1180,6 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
             BasicExam basicExam = basicExamService.getById(examTask.getExamId());
             if (ExamModelEnum.MODEL1.equals(basicExam.getExamModel()) || ExamModelEnum.MODEL2.equals(basicExam.getExamModel())) {
                 // 创建印刷计划
-                ExamDetailParams examDetailParams = examTaskSubmitContent.getExamDetail();
                 ExamPrintPlan examPrintPlan = new ExamPrintPlan();
                 examPrintPlan.insertInfo(sysUser.getId());
                 examPrintPlan.setSchoolId(schoolId);
@@ -1172,171 +1209,8 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
                 examPrintPlan.setStatus(PrintPlanStatusEnum.READY);
                 examPrintPlanService.save(examPrintPlan);
 
-                List<ExamDetailCourseDto> examDetailCourseList = examDetailService.listByExamIdAndCourseId(schoolId, examTask.getExamId(), examTask.getCourseId());
-
-                // 查询考试+课程下已用过的班级
-                Map<Long, String> basicStudentIdUserMap = new HashMap<>();
-
-                String paperNumber = examTask.getPaperNumber();
-                if (ExamModelEnum.MODEL1.equals(basicExam.getExamModel())) {
-                    for (ExamDetailList examDetailList : examDetailParams.getList()) {
-                        int count = examDetailList.getStudentCount();
-                        String className = examDetailList.getClassName();
-                        if (count == 0) {
-                            throw ExceptionResultEnum.ERROR.exception("选择的考试对象[" + className + "]下没有考生");
-                        }
-
-                        if (!CollectionUtils.isEmpty(examDetailCourseList)) {
-                            examDetailCourseList.stream().filter(m -> StringUtils.isNotBlank(m.getClazzName())).forEach(m -> {
-                                examStudentService.listStudentByExamDetailCourseId(m.getId()).stream().filter(t -> t.getBasicStudentId() != null).forEach(s -> basicStudentIdUserMap.put(s.getBasicStudentId(), String.format("%s(%s)", m.getRealName(), m.getLoginName())));
-                            });
-                        }
-
-                        // 校验班级或班级内考生是否已命题
-                        List<Long> examTaskStudentObjectParamList = examDetailList.getExamTaskStudentObjectParamListIds();
-                        if (MapUtils.isNotEmpty(basicStudentIdUserMap)) {
-                            examTaskStudentObjectParamList.forEach(i -> {
-                                if (basicStudentIdUserMap.containsKey(i)) {
-                                    BasicExamStudent basicExamStudent = basicExamStudentService.getById(i);
-                                    if (basicExamStudent != null) {
-                                        throw ExceptionResultEnum.ERROR.exception("教学班[" + basicExamStudent.getTeachClassName() + "]内有考生已被[" + basicStudentIdUserMap.get(i) + "]选择");
-                                    }
-                                }
-                            });
-                        }
-
-                        ExamDetail examDetail = new ExamDetail();
-                        examDetail.setId(SystemConstant.getDbUuid());
-                        examDetail.setPackageCode("1" + redisCounterUtil.getCounter(schoolId, 6, "packageCode"));
-                        examDetail.setSchoolId(schoolId);
-                        examDetail.setOrgId(sysUser.getOrgId());
-                        examDetail.setPrintPlanId(examPrintPlan.getId());
-                        examDetail.setExamId(examPrintPlan.getExamId());
-                        examDetail.setPrintPlanName(examPrintPlan.getName());
-                        examDetail.setExamPlace(examDetailList.getExamPlace()); // 无默认值
-                        examDetail.setExamRoom(examDetailList.getExamRoom()); // 无默认值
-                        examDetail.setStatus(ExamDetailStatusEnum.NEW);
-                        if (!ExamCategoryEnum.REBUILD.equals(basicExam.getCategory())) {
-                            examDetail.setExamStartTime(examDetailList.getExamStartTime());
-                            examDetail.setExamEndTime(examDetailList.getExamEndTime());
-                        }
-                        examDetail.setTotalSubjects(count);
-                        examDetail.setExamDataSource(ExamDataSourceEnum.EXAM_TASK);
-                        examDetail.setNormal(true);
-                        examDetail.setPrintHouseId(examDetailList.getPrintHouseId());
-                        examDetail.setBackupCount(examDetailList.getBackupCount());
-                        examDetail.setCreateId(sysUser.getId());
-                        examDetail.setCreateTime(System.currentTimeMillis());
-                        examDetailService.save(examDetail);
-
-                        ExamDetailCourse examDetailCourse = new ExamDetailCourse();
-                        examDetailCourse.setId(SystemConstant.getDbUuid());
-                        examDetailCourse.setSchoolId(schoolId);
-                        examDetailCourse.setExamDetailId(examDetail.getId());
-                        examDetailCourse.setCourseId(examTask.getCourseId());
-                        examDetailCourse.setPaperNumber(paperNumber);
-                        examDetailCourse.setCoursePaperId(String.valueOf(examTask.getId()));
-                        examDetailCourse.setClazzName(examDetailList.getClassName());
-                        examDetailCourse.setTotalSubjects(examDetailList.getStudentCount());
-                        examDetailCourse.setCreateId(sysUser.getId());
-                        examDetailCourseService.save(examDetailCourse);
-
-                        // 更新实际考生数量
-                        List<ExamStudent> examStudents = examStudentService.saveStudentForExamApply(examTask, examDetailList.getExtendFields(), examTaskStudentObjectParamList, examDetailCourse.getId(), sysUser);
-
-                        if (!CollectionUtils.isEmpty(examStudents)) {
-                            examStudentService.saveBatch(examStudents);
-                        }
-                        int studentCount = examStudents.size();
-
-                        if (studentCount - examDetail.getTotalSubjects() != 0) {
-                            UpdateWrapper<ExamDetail> updateWrapper = new UpdateWrapper<>();
-                            updateWrapper.lambda().set(ExamDetail::getTotalSubjects, studentCount).eq(ExamDetail::getId, examDetail.getId());
-                            examDetailService.update(updateWrapper);
-                        }
-                        if (studentCount - examDetailCourse.getTotalSubjects() != 0) {
-                            UpdateWrapper<ExamDetailCourse> updateWrapper = new UpdateWrapper<>();
-                            updateWrapper.lambda().set(ExamDetailCourse::getTotalSubjects, studentCount).eq(ExamDetailCourse::getId, examDetailCourse.getId());
-                            examDetailCourseService.update(updateWrapper);
-                        }
-                    }
-                } else if (ExamModelEnum.MODEL2.equals(basicExam.getExamModel())) {
-                    // 查询考试+课程下已用过的班级
-                    Map<String, String> usedClassNameMap = new HashMap<>();
-                    if (!CollectionUtils.isEmpty(examDetailCourseList)) {
-                        examDetailCourseList.stream().filter(m -> StringUtils.isNotBlank(m.getClazzName())).forEach(m -> {
-                            for (String className : m.getClazzName().split(",")) {
-                                usedClassNameMap.put(className, String.format("%s(%s)", m.getRealName(), m.getLoginName()));
-                            }
-                        });
-                    }
-
-                    List<String> errorClassNames = new ArrayList<>();
-                    if (StringUtils.isNotBlank(examDetailParams.getClassName()) && MapUtils.isNotEmpty(usedClassNameMap)) {
-                        for (String s : examDetailParams.getClassName().split(",")) {
-                            if (usedClassNameMap.containsKey(s)) {
-                                errorClassNames.add(s);
-                            }
-                        }
-                    }
-
-                    // 选择学生时,不校验
-                    boolean containsPrivilege = teachcloudCommonService.containsPrivilege(sysUser.getId(), "button", "SelectStudent");
-                    if (!containsPrivilege || ExamCategoryEnum.REBUILD.equals(basicExam.getCategory())) {
-                        Map<String, Set<String>> finalMap = new HashMap<>();
-                        StringJoiner stringJoiner = new StringJoiner(",");
-                        for (String errorClassName : errorClassNames) {
-                            String key = usedClassNameMap.get(errorClassName);
-                            Set<String> value;
-                            if (finalMap.containsKey(key)) {
-                                value = finalMap.get(key);
-                            } else {
-                                value = new HashSet<>();
-                            }
-                            value.add(errorClassName);
-                            finalMap.put(key, value);
-                        }
-                        for (Map.Entry<String, Set<String>> entry : finalMap.entrySet()) {
-                            stringJoiner.add("考试对象[" + String.join(",", entry.getValue()) + "]已被[" + entry.getKey() + "]选择");
-                        }
-                        if (StringUtils.isNotBlank(stringJoiner.toString())) {
-                            throw ExceptionResultEnum.ERROR.exception(stringJoiner.toString());
-                        }
-                    }
-
-                    ExamDetail examDetail = new ExamDetail();
-                    examDetail.setId(SystemConstant.getDbUuid());
-                    examDetail.setPackageCode("1" + redisCounterUtil.getCounter(schoolId, 6, "packageCode"));
-                    examDetail.setSchoolId(schoolId);
-                    examDetail.setOrgId(sysUser.getOrgId());
-                    examDetail.setPrintPlanId(examPrintPlan.getId());
-                    examDetail.setPrintPlanName(examPrintPlan.getName());
-                    examDetail.setExamId(examPrintPlan.getExamId());
-                    examDetail.setStatus(ExamDetailStatusEnum.NEW);
-                    if (!ExamCategoryEnum.REBUILD.equals(basicExam.getCategory())) {
-                        examDetail.setExamStartTime(examDetailParams.getExamStartTime());
-                        examDetail.setExamEndTime(examDetailParams.getExamEndTime());
-                    }
-                    examDetail.setTotalSubjects(examDetailParams.getTotalSubjects());
-                    examDetail.setExamDataSource(ExamDataSourceEnum.EXAM_TASK);
-                    examDetail.setNormal(true);
-                    examDetail.setPrintHouseId(examDetailParams.getPrintHouseId());
-                    examDetail.setBackupCount(examDetailParams.getBackupCount());
-                    examDetail.setCreateId(sysUser.getId());
-                    examDetail.setCreateTime(System.currentTimeMillis());
-                    examDetailService.save(examDetail);
-
-                    ExamDetailCourse examDetailCourse = new ExamDetailCourse();
-                    examDetailCourse.setId(SystemConstant.getDbUuid());
-                    examDetailCourse.setSchoolId(schoolId);
-                    examDetailCourse.setExamDetailId(examDetail.getId());
-                    examDetailCourse.setCourseId(examTask.getCourseId());
-                    examDetailCourse.setPaperNumber(paperNumber);
-                    examDetailCourse.setClazzName(examDetailParams.getClassName());
-                    examDetailCourse.setTotalSubjects(examDetailParams.getTotalSubjects());
-                    examDetailCourse.setCreateId(sysUser.getId());
-                    examDetailCourseService.save(examDetailCourse);
-                }
+                // 保存考场、考生
+                this.addExamDetailAndStudent(examTask, basicExam, examTaskSubmitContent.getExamDetail(), examPrintPlan, sysUser);
             }
 
             if (Objects.nonNull(examTask.getFlowId())) {
@@ -1367,6 +1241,175 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
         return null;
     }
 
+    private void addExamDetailAndStudent(ExamTask examTask, BasicExam basicExam, ExamDetailParams examDetailParams, ExamPrintPlan examPrintPlan, SysUser sysUser) {
+        Long schoolId = sysUser.getSchoolId();
+        List<ExamDetailCourseDto> examDetailCourseList = examDetailService.listByExamIdAndCourseId(schoolId, examTask.getExamId(), examTask.getCourseId());
+
+        // 查询考试+课程下已用过的班级
+        Map<Long, String> basicStudentIdUserMap = new HashMap<>();
+
+        String paperNumber = examTask.getPaperNumber();
+        if (ExamModelEnum.MODEL1.equals(basicExam.getExamModel())) {
+            for (ExamDetailList examDetailList : examDetailParams.getList()) {
+                int count = examDetailList.getStudentCount();
+                String className = examDetailList.getClassName();
+                if (count == 0) {
+                    throw ExceptionResultEnum.ERROR.exception("选择的考试对象[" + className + "]下没有考生");
+                }
+
+                if (!CollectionUtils.isEmpty(examDetailCourseList)) {
+                    examDetailCourseList.stream().filter(m -> StringUtils.isNotBlank(m.getClazzName())).forEach(m -> {
+                        examStudentService.listStudentByExamDetailCourseId(m.getId()).stream().filter(t -> t.getBasicStudentId() != null).forEach(s -> basicStudentIdUserMap.put(s.getBasicStudentId(), String.format("%s(%s)", m.getRealName(), m.getLoginName())));
+                    });
+                }
+
+                // 校验班级或班级内考生是否已命题
+                List<Long> examTaskStudentObjectParamList = examDetailList.getExamTaskStudentObjectParamListIds();
+                if (MapUtils.isNotEmpty(basicStudentIdUserMap)) {
+                    examTaskStudentObjectParamList.forEach(i -> {
+                        if (basicStudentIdUserMap.containsKey(i)) {
+                            BasicExamStudent basicExamStudent = basicExamStudentService.getById(i);
+                            if (basicExamStudent != null) {
+                                throw ExceptionResultEnum.ERROR.exception("教学班[" + basicExamStudent.getTeachClassName() + "]内有考生已被[" + basicStudentIdUserMap.get(i) + "]选择");
+                            }
+                        }
+                    });
+                }
+
+                ExamDetail examDetail = new ExamDetail();
+                examDetail.setId(SystemConstant.getDbUuid());
+                examDetail.setPackageCode("1" + redisCounterUtil.getCounter(schoolId, 6, "packageCode"));
+                examDetail.setSchoolId(schoolId);
+                examDetail.setOrgId(sysUser.getOrgId());
+                examDetail.setPrintPlanId(examPrintPlan.getId());
+                examDetail.setExamId(examPrintPlan.getExamId());
+                examDetail.setPrintPlanName(examPrintPlan.getName());
+                examDetail.setExamPlace(examDetailList.getExamPlace()); // 无默认值
+                examDetail.setExamRoom(examDetailList.getExamRoom()); // 无默认值
+                examDetail.setStatus(ExamDetailStatusEnum.NEW);
+                if (!ExamCategoryEnum.REBUILD.equals(basicExam.getCategory())) {
+                    examDetail.setExamStartTime(examDetailList.getExamStartTime());
+                    examDetail.setExamEndTime(examDetailList.getExamEndTime());
+                }
+                examDetail.setTotalSubjects(count);
+                examDetail.setExamDataSource(ExamDataSourceEnum.EXAM_TASK);
+                examDetail.setNormal(true);
+                examDetail.setPrintHouseId(examDetailList.getPrintHouseId());
+                examDetail.setBackupCount(examDetailList.getBackupCount());
+                examDetail.setCreateId(sysUser.getId());
+                examDetail.setCreateTime(System.currentTimeMillis());
+                examDetailService.save(examDetail);
+
+                ExamDetailCourse examDetailCourse = new ExamDetailCourse();
+                examDetailCourse.setId(SystemConstant.getDbUuid());
+                examDetailCourse.setSchoolId(schoolId);
+                examDetailCourse.setExamDetailId(examDetail.getId());
+                examDetailCourse.setCourseId(examTask.getCourseId());
+                examDetailCourse.setPaperNumber(paperNumber);
+                examDetailCourse.setCoursePaperId(String.valueOf(examTask.getId()));
+                examDetailCourse.setClazzName(examDetailList.getClassName());
+                examDetailCourse.setTotalSubjects(examDetailList.getStudentCount());
+                examDetailCourse.setCreateId(sysUser.getId());
+                examDetailCourseService.save(examDetailCourse);
+
+                // 更新实际考生数量
+                List<ExamStudent> examStudents = examStudentService.saveStudentForExamApply(examTask, examDetailList.getExtendFields(), examTaskStudentObjectParamList, examDetailCourse.getId(), sysUser);
+
+                if (!CollectionUtils.isEmpty(examStudents)) {
+                    examStudentService.saveBatch(examStudents);
+                }
+                int studentCount = examStudents.size();
+
+                if (studentCount - examDetail.getTotalSubjects() != 0) {
+                    UpdateWrapper<ExamDetail> updateWrapper = new UpdateWrapper<>();
+                    updateWrapper.lambda().set(ExamDetail::getTotalSubjects, studentCount).eq(ExamDetail::getId, examDetail.getId());
+                    examDetailService.update(updateWrapper);
+                }
+                if (studentCount - examDetailCourse.getTotalSubjects() != 0) {
+                    UpdateWrapper<ExamDetailCourse> updateWrapper = new UpdateWrapper<>();
+                    updateWrapper.lambda().set(ExamDetailCourse::getTotalSubjects, studentCount).eq(ExamDetailCourse::getId, examDetailCourse.getId());
+                    examDetailCourseService.update(updateWrapper);
+                }
+            }
+        } else if (ExamModelEnum.MODEL2.equals(basicExam.getExamModel())) {
+            // 查询考试+课程下已用过的班级
+            Map<String, String> usedClassNameMap = new HashMap<>();
+            if (!CollectionUtils.isEmpty(examDetailCourseList)) {
+                examDetailCourseList.stream().filter(m -> StringUtils.isNotBlank(m.getClazzName())).forEach(m -> {
+                    for (String className : m.getClazzName().split(",")) {
+                        usedClassNameMap.put(className, String.format("%s(%s)", m.getRealName(), m.getLoginName()));
+                    }
+                });
+            }
+
+            List<String> errorClassNames = new ArrayList<>();
+            if (StringUtils.isNotBlank(examDetailParams.getClassName()) && MapUtils.isNotEmpty(usedClassNameMap)) {
+                for (String s : examDetailParams.getClassName().split(",")) {
+                    if (usedClassNameMap.containsKey(s)) {
+                        errorClassNames.add(s);
+                    }
+                }
+            }
+
+            // 选择学生时,不校验
+            boolean containsPrivilege = teachcloudCommonService.containsPrivilege(sysUser.getId(), "button", "SelectStudent");
+            if (!containsPrivilege || ExamCategoryEnum.REBUILD.equals(basicExam.getCategory())) {
+                Map<String, Set<String>> finalMap = new HashMap<>();
+                StringJoiner stringJoiner = new StringJoiner(",");
+                for (String errorClassName : errorClassNames) {
+                    String key = usedClassNameMap.get(errorClassName);
+                    Set<String> value;
+                    if (finalMap.containsKey(key)) {
+                        value = finalMap.get(key);
+                    } else {
+                        value = new HashSet<>();
+                    }
+                    value.add(errorClassName);
+                    finalMap.put(key, value);
+                }
+                for (Map.Entry<String, Set<String>> entry : finalMap.entrySet()) {
+                    stringJoiner.add("考试对象[" + String.join(",", entry.getValue()) + "]已被[" + entry.getKey() + "]选择");
+                }
+                if (StringUtils.isNotBlank(stringJoiner.toString())) {
+                    throw ExceptionResultEnum.ERROR.exception(stringJoiner.toString());
+                }
+            }
+
+            ExamDetail examDetail = new ExamDetail();
+            examDetail.setId(SystemConstant.getDbUuid());
+            examDetail.setPackageCode("1" + redisCounterUtil.getCounter(schoolId, 6, "packageCode"));
+            examDetail.setSchoolId(schoolId);
+            examDetail.setOrgId(sysUser.getOrgId());
+            examDetail.setPrintPlanId(examPrintPlan.getId());
+            examDetail.setPrintPlanName(examPrintPlan.getName());
+            examDetail.setExamId(examPrintPlan.getExamId());
+            examDetail.setStatus(ExamDetailStatusEnum.NEW);
+            if (!ExamCategoryEnum.REBUILD.equals(basicExam.getCategory())) {
+                examDetail.setExamStartTime(examDetailParams.getExamStartTime());
+                examDetail.setExamEndTime(examDetailParams.getExamEndTime());
+            }
+            examDetail.setTotalSubjects(examDetailParams.getTotalSubjects());
+            examDetail.setExamDataSource(ExamDataSourceEnum.EXAM_TASK);
+            examDetail.setNormal(true);
+            examDetail.setPrintHouseId(examDetailParams.getPrintHouseId());
+            examDetail.setBackupCount(examDetailParams.getBackupCount());
+            examDetail.setCreateId(sysUser.getId());
+            examDetail.setCreateTime(System.currentTimeMillis());
+            examDetailService.save(examDetail);
+
+            ExamDetailCourse examDetailCourse = new ExamDetailCourse();
+            examDetailCourse.setId(SystemConstant.getDbUuid());
+            examDetailCourse.setSchoolId(schoolId);
+            examDetailCourse.setExamDetailId(examDetail.getId());
+            examDetailCourse.setCourseId(examTask.getCourseId());
+            examDetailCourse.setPaperNumber(paperNumber);
+            examDetailCourse.setClazzName(examDetailParams.getClassName());
+            examDetailCourse.setTotalSubjects(examDetailParams.getTotalSubjects());
+            examDetailCourse.setCreateId(sysUser.getId());
+            examDetailCourseService.save(examDetailCourse);
+        }
+    }
+
     @Override
     public ExamTaskApprovalFormDto findExamTaskApprovalForm(Long examTaskId, Long examId, String paperNumber) {
         Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
@@ -1685,10 +1728,10 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
                 list2 = ExamDetailCourses.stream().map(ExamDetailCourse::getPaperNumber).distinct().collect(Collectors.toList());
             }
             list.addAll(list2);
-            return list.stream().filter(m->!m.endsWith("作废")).distinct().collect(Collectors.toList());
+            return list.stream().filter(m -> !m.endsWith("作废")).distinct().collect(Collectors.toList());
         } else {
             List<String> paperNumberList = examDetailCourseService.listPaperNumberByPrintPlanId(param, printPlanIdList, orgIds);
-            return paperNumberList.stream().filter(m->!m.endsWith("作废")).distinct().collect(Collectors.toList());
+            return paperNumberList.stream().filter(m -> !m.endsWith("作废")).distinct().collect(Collectors.toList());
         }
     }
 

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

@@ -98,7 +98,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();
+            concurrentService.getReadWriteLock(LockType.EXAM_TASK_WHOLE + "-" + key).writeLock().unlock();
         }
     }
 

+ 9 - 5
distributed-print/src/main/java/com/qmth/distributed/print/api/SysController.java

@@ -625,12 +625,16 @@ public class SysController {
     @ApiOperation(value = "文件预览接口")
     @RequestMapping(value = "/file/preview", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = EditResult.class)})
-    public Result filePreview(@ApiParam(value = "附件id", required = false, defaultValue = "") @RequestParam(value = "id", required = false, defaultValue = "") String id) {
-        if (StringUtils.isBlank(id)) {
-            throw ExceptionResultEnum.ERROR.exception("没有件");
+    public Result filePreview(@ApiParam(value = "附件id", defaultValue = "") @RequestParam(value = "ids", required = false) List<Long> ids) {
+        if (CollectionUtils.isEmpty(ids)) {
+            throw ExceptionResultEnum.ERROR.exception("没有找到文件");
         } else {
-            BasicAttachment basicAttachment = basicAttachmentService.getById(Long.parseLong(id));
-            return ResultUtil.ok(new EditResult(teachcloudCommonService.filePreview(basicAttachment.getPath())));
+            List<EditResult> list = new ArrayList<>();
+            for (Long id : ids) {
+                BasicAttachment basicAttachment = basicAttachmentService.getById(id);
+                list.add(new EditResult(teachcloudCommonService.filePreview(basicAttachment.getPath())));
+            }
+            return ResultUtil.ok(list);
         }
     }
 

+ 6 - 4
teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/marking/ConvertJpgStorage.java

@@ -1,5 +1,7 @@
 package com.qmth.teachcloud.common.bean.marking;
 
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import io.swagger.annotations.ApiModelProperty;
 
 /**
@@ -9,7 +11,7 @@ import io.swagger.annotations.ApiModelProperty;
  */
 public class ConvertJpgStorage {
     @ApiModelProperty("jpg附件id")
-    private Long attachmentId;
+    private String attachmentId;
 
     @ApiModelProperty("jpg是题卡的第几页")
     private Integer index;
@@ -18,15 +20,15 @@ public class ConvertJpgStorage {
     }
 
     public ConvertJpgStorage(Long attachmentId, Integer index) {
-        this.attachmentId = attachmentId;
+        this.attachmentId = String.valueOf(attachmentId);
         this.index = index;
     }
 
-    public Long getAttachmentId() {
+    public String getAttachmentId() {
         return attachmentId;
     }
 
-    public void setAttachmentId(Long attachmentId) {
+    public void setAttachmentId(String attachmentId) {
         this.attachmentId = attachmentId;
     }