Răsfoiți Sursa

3.3.1 生成pdf优化

xiaofei 1 an în urmă
părinte
comite
c9fbff9ad1
28 a modificat fișierele cu 410 adăugiri și 440 ștergeri
  1. 9 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/params/RelatePaperParam.java
  2. 2 3
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TBTaskPdf.java
  3. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamTaskDetailService.java
  4. 0 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamTaskService.java
  5. 0 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/PrintCommonService.java
  6. 6 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/TBTaskPdfService.java
  7. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamDetailCourseServiceImpl.java
  8. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamDetailServiceImpl.java
  9. 59 85
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskDetailServiceImpl.java
  10. 1 11
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskServiceImpl.java
  11. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/GradeBatchServiceImpl.java
  12. 12 86
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/PrintCommonServiceImpl.java
  13. 26 3
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TBTaskPdfServiceImpl.java
  14. 8 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/AsyncCreatePdfTempleteService.java
  15. 58 72
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/PdfTaskLogicServiceImpl.java
  16. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/TaskLogicServiceImpl.java
  17. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/CreatePdfUtil.java
  18. 5 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/PdfUtil.java
  19. 71 38
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/pdf/CreatePdfNewUtil.java
  20. 0 109
      distributed-print-business/src/main/resources/db/log/脚本-caozx.sql
  21. 141 1
      distributed-print/install/mysql/upgrade/3.3.1.sql
  22. 2 3
      distributed-print/src/main/java/com/qmth/distributed/print/api/TBTaskController.java
  23. 1 1
      distributed-print/src/main/java/com/qmth/distributed/print/api/WorkController.java
  24. 1 1
      distributed-print/src/main/java/com/qmth/distributed/print/api/mark/MarkSettingController.java
  25. 0 2
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/TBTaskService.java
  26. 1 1
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/BasicAttachmentServiceImpl.java
  27. 0 12
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/TBTaskServiceImpl.java
  28. 1 1
      teachcloud-task/src/main/java/com/qmth/teachcloud/task/service/impl/PrintFinishServiceImpl.java

+ 9 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/params/RelatePaperParam.java

@@ -8,12 +8,21 @@ import com.qmth.teachcloud.common.base.BasePage;
  */
  */
 public class RelatePaperParam extends BasePage {
 public class RelatePaperParam extends BasePage {
 
 
+    private Long examId;
     private Long printPlanId;
     private Long printPlanId;
     private Long examTaskId;
     private Long examTaskId;
     private String paperNumber;
     private String paperNumber;
     private String relatePaperType;
     private String relatePaperType;
     private String examDetailCourseIds;
     private String examDetailCourseIds;
 
 
+    public Long getExamId() {
+        return examId;
+    }
+
+    public void setExamId(Long examId) {
+        this.examId = examId;
+    }
+
     public Long getPrintPlanId() {
     public Long getPrintPlanId() {
         return printPlanId;
         return printPlanId;
     }
     }

+ 2 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TBTaskPdf.java

@@ -1,8 +1,6 @@
 package com.qmth.distributed.print.business.entity;
 package com.qmth.distributed.print.business.entity;
 
 
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.*;
 
 
 import java.io.Serializable;
 import java.io.Serializable;
 
 
@@ -57,6 +55,7 @@ public class TBTaskPdf implements Serializable {
     private String summary;
     private String summary;
 
 
     @ApiModelProperty(value = "数据结果,SUCCESS:成功,ERROR:失败")
     @ApiModelProperty(value = "数据结果,SUCCESS:成功,ERROR:失败")
+    @TableField(updateStrategy = FieldStrategy.IGNORED)
     private TaskResultEnum result;
     private TaskResultEnum result;
 
 
     @ApiModelProperty(value = "创建人")
     @ApiModelProperty(value = "创建人")

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

@@ -60,7 +60,7 @@ public interface ExamTaskDetailService extends IService<ExamTaskDetail> {
 
 
     List<String> listRelateCommonTypes(Long semesterId, Long examId, String relateType, List<Long> idList, String courseCode, String paperNumber, String userName, Long cardRuleId);
     List<String> listRelateCommonTypes(Long semesterId, Long examId, String relateType, List<Long> idList, String courseCode, String paperNumber, String userName, Long cardRuleId);
 
 
-    ExamTaskDetail findByExamIdAndCourseCodeAndPaperNumber(Long schoolId, Long examId, String code, String number);
+    ExamTaskDetail findByExamIdAndCourseCodeAndPaperNumber(Long examId, String code, String number);
 
 
     boolean cancel(Long id, String cancelRemark);
     boolean cancel(Long id, String cancelRemark);
 
 

+ 0 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamTaskService.java

@@ -77,8 +77,6 @@ public interface ExamTaskService extends IService<ExamTask> {
 
 
     void paperDownload(HttpServletResponse response, Long examTaskId) throws Exception;
     void paperDownload(HttpServletResponse response, Long examTaskId) throws Exception;
 
 
-    ExamTask getByCourseCodeAndPaperNumber(Long schoolId, Long examId, String courseCode, String paperNumber);
-
     /**
     /**
      * 根据考务-考场检验该考场下的所有命题任务是否已经完成,全部完成则生成pdf
      * 根据考务-考场检验该考场下的所有命题任务是否已经完成,全部完成则生成pdf
      *
      *

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

@@ -225,7 +225,6 @@ public interface PrintCommonService {
      * @param user
      * @param user
      * @throws IOException
      * @throws IOException
      */
      */
-    void checkData(Long schoolId, Long examId, String courseCode, String paperNumber, SysUser user) throws IOException;
     void checkDataNew(Long schoolId, Long examId, String courseCode, String paperNumber, SysUser user) throws IOException;
     void checkDataNew(Long schoolId, Long examId, String courseCode, String paperNumber, SysUser user) throws IOException;
 
 
     void checkDataMakeup(Long schoolId, ExamDetail examDetail, String courseCode, String paperNumber, SysUser user);
     void checkDataMakeup(Long schoolId, ExamDetail examDetail, String courseCode, String paperNumber, SysUser user);

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

@@ -4,10 +4,12 @@ import com.qmth.distributed.print.business.entity.TBTaskPdf;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.teachcloud.common.bean.result.TbTaskDetailResult;
 import com.qmth.teachcloud.common.bean.result.TbTaskDetailResult;
 import com.qmth.teachcloud.common.entity.SysUser;
 import com.qmth.teachcloud.common.entity.SysUser;
+import com.qmth.teachcloud.common.enums.CreatePdfTypeEnum;
 import com.qmth.teachcloud.common.enums.TaskResultEnum;
 import com.qmth.teachcloud.common.enums.TaskResultEnum;
 import com.qmth.teachcloud.common.enums.TaskStatusEnum;
 import com.qmth.teachcloud.common.enums.TaskStatusEnum;
 import com.qmth.teachcloud.common.enums.TaskTypeEnum;
 import com.qmth.teachcloud.common.enums.TaskTypeEnum;
 
 
+import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
 /**
 /**
@@ -23,4 +25,8 @@ public interface TBTaskPdfService extends IService<TBTaskPdf> {
     boolean updateStatusById(TaskStatusEnum status, TaskResultEnum result, String summary, Long id);
     boolean updateStatusById(TaskStatusEnum status, TaskResultEnum result, String summary, Long id);
 
 
     TBTaskPdf saveTask(TbTaskDetailResult tbTaskDetailResult, TaskTypeEnum createPdf, Long printPlanId, SysUser user, Long id);
     TBTaskPdf saveTask(TbTaskDetailResult tbTaskDetailResult, TaskTypeEnum createPdf, Long printPlanId, SysUser user, Long id);
+
+    void resetRunningCreatePdf(Long id, CreatePdfTypeEnum type);
+
+    int countRunningByExamDetailIds(List<Long> examDetailIds);
 }
 }

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

@@ -158,7 +158,7 @@ public class ExamDetailCourseServiceImpl extends ServiceImpl<ExamDetailCourseMap
         if (count > 0) {
         if (count > 0) {
             throw ExceptionResultEnum.ERROR.exception("考号在本考场已存在");
             throw ExceptionResultEnum.ERROR.exception("考号在本考场已存在");
         }
         }
-        ExamTask examTask = examTaskService.getByCourseCodeAndPaperNumber(examDetail.getSchoolId(), examDetail.getExamId(), examDetailCourse.getCourseCode(), examDetailCourse.getPaperNumber());
+        ExamTask examTask = examTaskService.getByExamIdAndCourseCodeAndPaperNumber(examDetail.getExamId(), examDetailCourse.getCourseCode(), examDetailCourse.getPaperNumber());
         if(examTask == null){
         if(examTask == null){
             throw ExceptionResultEnum.ERROR.exception("命题任务不存在");
             throw ExceptionResultEnum.ERROR.exception("命题任务不存在");
         }
         }

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

@@ -376,7 +376,7 @@ public class ExamDetailServiceImpl extends ServiceImpl<ExamDetailMapper, ExamDet
             for (String id : examinationResult.getExamDetailCourseIds().split(",")) {
             for (String id : examinationResult.getExamDetailCourseIds().split(",")) {
                 ExamDetailCourse examDetailCourse = examDetailCourseService.getById(id);
                 ExamDetailCourse examDetailCourse = examDetailCourseService.getById(id);
                 if (StringUtils.isNotBlank(examDetailCourse.getPaperType())) {
                 if (StringUtils.isNotBlank(examDetailCourse.getPaperType())) {
-                    ExamTask examTask = examTaskService.getByCourseCodeAndPaperNumber(schoolId, examinationResult.getExamId(), examDetailCourse.getCourseCode(), examDetailCourse.getPaperNumber());
+                    ExamTask examTask = examTaskService.getByExamIdAndCourseCodeAndPaperNumber(examinationResult.getExamId(), examDetailCourse.getCourseCode(), examDetailCourse.getPaperNumber());
                     ExamTaskDetail examTaskDetail = examTaskDetailService.getByExamTaskId(examTask.getId());
                     ExamTaskDetail examTaskDetail = examTaskDetailService.getByExamTaskId(examTask.getId());
                     String paperType = examDetailCourse.getPaperType();
                     String paperType = examDetailCourse.getPaperType();
                     List<PaperInfoVo> paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetail.getPaperAttachmentIds(), paperType);
                     List<PaperInfoVo> paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetail.getPaperAttachmentIds(), paperType);

+ 59 - 85
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskDetailServiceImpl.java

@@ -61,19 +61,12 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
     @Resource
     @Resource
     private ExamStudentService examStudentService;
     private ExamStudentService examStudentService;
     @Resource
     @Resource
-    @Lazy
-    private PrintCommonService printCommonService;
-    @Resource
     private ExamPrintPlanService examPrintPlanService;
     private ExamPrintPlanService examPrintPlanService;
     @Resource
     @Resource
-    private TBTaskService tbTaskService;
+    private TBTaskPdfService tbTaskPdfService;
     @Resource
     @Resource
     private TBSyncTaskService tbSyncTaskService;
     private TBSyncTaskService tbSyncTaskService;
     @Resource
     @Resource
-    private TeachcloudCommonService teachcloudCommonService;
-    @Resource
-    private RedisUtil redisUtil;
-    @Resource
     private ActivitiService activitiService;
     private ActivitiService activitiService;
     @Resource
     @Resource
     private TaskService taskService;
     private TaskService taskService;
@@ -93,6 +86,8 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
     private BasicRoleDataPermissionService basicRoleDataPermissionService;
     private BasicRoleDataPermissionService basicRoleDataPermissionService;
     @Resource
     @Resource
     private MarkService markService;
     private MarkService markService;
+    @Resource
+    private ExamTaskAssignPaperTypeService examTaskAssignPaperTypeService;
 
 
     @Transactional
     @Transactional
     @Override
     @Override
@@ -108,8 +103,8 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
 
 
             Map<Long, List<Long>> map = examDetails.stream().collect(Collectors.groupingBy(ExamDetail::getPrintPlanId, Collectors.mapping(ExamDetail::getId, Collectors.toList())));
             Map<Long, List<Long>> map = examDetails.stream().collect(Collectors.groupingBy(ExamDetail::getPrintPlanId, Collectors.mapping(ExamDetail::getId, Collectors.toList())));
             for (Map.Entry<Long, List<Long>> listEntry : map.entrySet()) {
             for (Map.Entry<Long, List<Long>> listEntry : map.entrySet()) {
-                boolean b = tbTaskService.countByPrintPlanIdAndEntityId(examTask.getSchoolId(), listEntry.getKey(), listEntry.getValue());
-                if (!b) {
+                int countRunning = tbTaskPdfService.countRunningByExamDetailIds(listEntry.getValue());
+                if (countRunning > 0) {
                     throw ExceptionResultEnum.ERROR.exception("有关联该任务的考场正在生成打印pdf,不能启用/禁用卷库");
                     throw ExceptionResultEnum.ERROR.exception("有关联该任务的考场正在生成打印pdf,不能启用/禁用卷库");
                 }
                 }
             }
             }
@@ -167,77 +162,56 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
     @Transactional
     @Transactional
     @Override
     @Override
     public boolean updatePaper(RelatePaperParam paperParam) {
     public boolean updatePaper(RelatePaperParam paperParam) {
-        ExamPrintPlan examPrintPlan = examPrintPlanService.getById(paperParam.getPrintPlanId());
         ExamTask examTask = examTaskService.getById(paperParam.getExamTaskId());
         ExamTask examTask = examTaskService.getById(paperParam.getExamTaskId());
-        // 校验课程关联考场,是否已经提交打印
-        Boolean isCreate = printCommonService.checkExamDetailStatus(examTask.getSchoolId(), examPrintPlan.getId(), examTask.getExamId(), examTask.getCourseCode(), examTask.getPaperNumber());
-        if (isCreate) {
-            // 提交印刷的考场,不允许修改关联试卷
-            List<ExamDetail> examDetails = examDetailService.listByPrintPlanIdAndCourseCodeAndPaperNumber(examTask.getSchoolId(), paperParam.getPrintPlanId(), examTask.getCourseCode(), examTask.getPaperNumber());
-            List<ExamDetail> examDetails1 = examDetails.stream().filter(m -> !ExamDetailStatusEnum.NEW.equals(m.getStatus()) && !ExamDetailStatusEnum.READY.equals(m.getStatus())).collect(Collectors.toList());
-            if (!examDetails1.isEmpty()) {
-                throw ExceptionResultEnum.ERROR.exception("有考场已开始打印,不能修改");
-            }
+        // 提交印刷的考场,不允许修改关联试卷
+        List<ExamDetail> examDetails = examDetailService.listByPrintPlanIdAndCourseCodeAndPaperNumber(examTask.getSchoolId(), paperParam.getPrintPlanId(), examTask.getCourseCode(), examTask.getPaperNumber());
+        List<ExamDetail> examDetailsPrint = examDetails.stream().filter(m -> !ExamDetailStatusEnum.NEW.equals(m.getStatus()) && !ExamDetailStatusEnum.READY.equals(m.getStatus())).collect(Collectors.toList());
+        if (CollectionUtils.isNotEmpty(examDetailsPrint)) {
+            throw ExceptionResultEnum.ERROR.exception("部分考场pdf文件已印刷,不能修改卷型");
+        }
 
 
-            List<Long> entityIds = examDetails.stream().map(m -> m.getId()).collect(Collectors.toList());
-            boolean b = tbTaskService.countByPrintPlanIdAndEntityId(examTask.getSchoolId(), paperParam.getPrintPlanId(), entityIds);
-            if (!b) {
-                throw ExceptionResultEnum.ERROR.exception("有关联该任务的考场正在生成打印pdf,不能修改关联类型");
-            }
+        List<Long> examDetailIds = examDetails.stream().map(ExamDetail::getId).collect(Collectors.toList());
+        int countRunning = tbTaskPdfService.countRunningByExamDetailIds(examDetailIds);
+        if (countRunning > 0) {
+            throw ExceptionResultEnum.ERROR.exception("部分考场pdf文件正在生成中,不能修改卷型");
+        }
 
 
-            for (ExamDetail examDetail : examDetails) {
-                List<ExamDetailCourse> examDetailCourses = examDetailCourseService.listByExamDetailIdAndStatus(examDetail.getId());
-                // 4.没有未完成的命题任务
-                if (CollectionUtils.isNotEmpty(examDetailCourses)) {
-                    throw ExceptionResultEnum.ERROR.exception("有关联该任务的考场有未完成的命题任务,不能修改关联类型");
-                }
+        for (ExamDetail examDetail : examDetails) {
+            List<ExamDetailCourse> examDetailCourses = examDetailCourseService.listByExamDetailIdAndStatus(examDetail.getId());
+            // 4.没有未完成的命题任务
+            if (CollectionUtils.isNotEmpty(examDetailCourses)) {
+                throw ExceptionResultEnum.ERROR.exception("部分考场包含的命题任务未完成,不能修改卷型");
             }
             }
+        }
 
 
-            // 更新关联卷型
-            ExamTask newExamTask = examTaskService.getByCourseCodeAndPaperNumber(examTask.getSchoolId(), examTask.getExamId(), examTask.getCourseCode(), paperParam.getPaperNumber());
-            UpdateWrapper<ExamTaskDetail> updateWrapper = new UpdateWrapper<>();
-            updateWrapper.lambda().set(ExamTaskDetail::getRelatePaperType, paperParam.getRelatePaperType()).eq(ExamTaskDetail::getExamTaskId, newExamTask.getId());
-            this.update(updateWrapper);
-
-            // 更新试卷编号
-            String examDetailCourseIdStr = paperParam.getExamDetailCourseIds();
-            List<Long> examDetailCourseIds = Arrays.asList(examDetailCourseIdStr.split(",")).stream().map(m -> Long.valueOf(m)).collect(Collectors.toList());
-            examDetailCourseService.updatePaperNumber(examDetailCourseIds, paperParam.getPaperNumber(), paperParam.getRelatePaperType());
-
-            // 更新考生关联类型
-//            examStudentService.updatePaperType(examDetailCourseIds, paperParam.getRelatePaperType());
-            ExamTaskDetail examTaskDetail = this.getByExamTaskId(newExamTask.getId());
-            List<String> types = Arrays.asList(paperParam.getRelatePaperType().split(","));
-            int drawCount = examTaskDetail.getDrawCount().intValue();
-            if (drawCount - types.size() > 0) {
-                throw ExceptionResultEnum.ERROR.exception("没有足够数量的卷型可用");
-            }
-            for (Long examDetailCourseId : examDetailCourseIds) {
-                QueryWrapper<ExamStudent> studentQueryWrapper = new QueryWrapper<>();
-                studentQueryWrapper.lambda().eq(ExamStudent::getExamDetailCourseId, examDetailCourseId);
-                List<ExamStudent> students = examStudentService.list(studentQueryWrapper);
-                int i = 0;
-                for (ExamStudent student : students) {
-                    int mod = i % drawCount;
-                    student.setPaperType(types.get(mod));
-                    examStudentService.updateById(student);
-                    i++;
-                }
-            }
+        // 更新命题任务中关联卷型
+        ExamTask newExamTask = examTaskService.getByExamIdAndCourseCodeAndPaperNumber(examTask.getExamId(), examTask.getCourseCode(), paperParam.getPaperNumber());
+        UpdateWrapper<ExamTaskDetail> updateWrapper = new UpdateWrapper<>();
+        updateWrapper.lambda().set(ExamTaskDetail::getRelatePaperType, paperParam.getRelatePaperType()).eq(ExamTaskDetail::getExamTaskId, newExamTask.getId());
+        this.update(updateWrapper);
 
 
-            // 重新生成pdf
-            List<ExamDetailCourse> examDetailCourses = examDetailCourseService.listByIds(examDetailCourseIds);
-            Map<Long, List<Long>> examDetailIdMap = examDetailCourses.stream().collect(Collectors.groupingBy(ExamDetailCourse::getExamDetailId, Collectors.mapping(ExamDetailCourse::getId, Collectors.toList())));
-            for (Map.Entry<Long, List<Long>> listEntry : examDetailIdMap.entrySet()) {
-                SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
-                TbTaskDetailResult tbTaskDetailResult = examDetailCourseService.getByExamDetailId(listEntry.getKey());
-                Map<String, Object> map = tbTaskService.saveTask(tbTaskDetailResult, TaskTypeEnum.CREATE_PDF, paperParam.getPrintPlanId(), sysUser, listEntry.getKey());
-                map.computeIfAbsent("examDetailCourseIds", v -> listEntry.getValue());
-                map.computeIfAbsent("paperType", v -> paperParam.getRelatePaperType());
-//                asyncCreatePdfTempleteService.createPdf(map, null);
-                MqDto mqDto = new MqDto(MqTagEnum.PDF.getCode(), map, String.valueOf(map.get(SystemConstant.TB_TASK_ID)));
-                redisUtil.sendMessage(mqDto.getTopic(), mqDto);
-            }
+        // 更新选中的试卷编号、卷型
+        String examDetailCourseIdStr = paperParam.getExamDetailCourseIds();
+        List<Long> examDetailCourseIds = Arrays.asList(examDetailCourseIdStr.split(",")).stream().map(m -> Long.valueOf(m)).collect(Collectors.toList());
+        examDetailCourseService.updatePaperNumber(examDetailCourseIds, paperParam.getPaperNumber(), paperParam.getRelatePaperType());
+
+        // 更新抽取卷型数据
+        for (ExamDetail examDetail : examDetails) {
+            ExamTaskAssignPaperType examTaskAssignPaperType = new ExamTaskAssignPaperType(paperParam.getExamId(), paperParam.getPaperNumber(), examDetail.getExamStartTime(), examDetail.getExamEndTime(), paperParam.getRelatePaperType(), AssignModeEnum.MANUAL);
+            examTaskAssignPaperTypeService.saveOrUpdateByMultiId(examTaskAssignPaperType);
+        }
+
+        // 更新考生关联类型
+        ExamTaskDetail examTaskDetail = this.getByExamTaskId(newExamTask.getId());
+        List<String> types = Arrays.asList(paperParam.getRelatePaperType().split(","));
+        int drawCount = examTaskDetail.getDrawCount().intValue();
+        if (drawCount - types.size() != 0) {
+            throw ExceptionResultEnum.ERROR.exception("关联卷型与设置数量不一致");
+        }
+
+        // 初始化PDF生成任务数据
+        for (ExamDetail examDetail : examDetails) {
+            tbTaskPdfService.resetRunningCreatePdf(examDetail.getId(), CreatePdfTypeEnum.ALL);
         }
         }
         return true;
         return true;
     }
     }
@@ -600,8 +574,8 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
     }
     }
 
 
     @Override
     @Override
-    public ExamTaskDetail findByExamIdAndCourseCodeAndPaperNumber(Long schoolId, Long examId, String code, String number) {
-        ExamTask examTask = examTaskService.getByCourseCodeAndPaperNumber(schoolId, examId, code, number);
+    public ExamTaskDetail findByExamIdAndCourseCodeAndPaperNumber(Long examId, String code, String number) {
+        ExamTask examTask = examTaskService.getByExamIdAndCourseCodeAndPaperNumber(examId, code, number);
         return this.getByExamTaskId(examTask.getId());
         return this.getByExamTaskId(examTask.getId());
     }
     }
 
 
@@ -668,12 +642,12 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
         }
         }
 
 
         // 任务数据改为作废
         // 任务数据改为作废
-        UpdateWrapper<TBTask> tbTaskUpdateWrapper = new UpdateWrapper<>();
-        tbTaskUpdateWrapper.lambda().set(TBTask::getPaperNumber, paperNumberCancel)
-                .eq(TBTask::getSchoolId, examTask.getSchoolId())
-                .eq(TBTask::getExamId, examTask.getExamId())
-                .eq(TBTask::getPaperNumber, paperNumber);
-        tbTaskService.update(tbTaskUpdateWrapper);
+        UpdateWrapper<TBTaskPdf> tbTaskUpdateWrapper = new UpdateWrapper<>();
+        tbTaskUpdateWrapper.lambda().set(TBTaskPdf::getPaperNumber, paperNumberCancel)
+                .eq(TBTaskPdf::getSchoolId, examTask.getSchoolId())
+                .eq(TBTaskPdf::getExamId, examTask.getExamId())
+                .eq(TBTaskPdf::getPaperNumber, paperNumber);
+        tbTaskPdfService.update(tbTaskUpdateWrapper);
 
 
         // 考生表数据改为作废
         // 考生表数据改为作废
         UpdateWrapper<ExamStudent> examStudentUpdateWrapper = new UpdateWrapper<>();
         UpdateWrapper<ExamStudent> examStudentUpdateWrapper = new UpdateWrapper<>();
@@ -747,8 +721,8 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
             }
             }
             Map<Long, List<Long>> map = examDetails.stream().collect(Collectors.groupingBy(ExamDetail::getPrintPlanId, Collectors.mapping(ExamDetail::getId, Collectors.toList())));
             Map<Long, List<Long>> map = examDetails.stream().collect(Collectors.groupingBy(ExamDetail::getPrintPlanId, Collectors.mapping(ExamDetail::getId, Collectors.toList())));
             for (Map.Entry<Long, List<Long>> listEntry : map.entrySet()) {
             for (Map.Entry<Long, List<Long>> listEntry : map.entrySet()) {
-                boolean b = tbTaskService.countByPrintPlanIdAndEntityId(examTask.getSchoolId(), listEntry.getKey(), listEntry.getValue());
-                if (!b) {
+                int countRunning = tbTaskPdfService.countRunningByExamDetailIds(listEntry.getValue());
+                if (countRunning > 0) {
                     throw ExceptionResultEnum.ERROR.exception("关联命题任务的考场正在生成打印文件,不能修改卷库");
                     throw ExceptionResultEnum.ERROR.exception("关联命题任务的考场正在生成打印文件,不能修改卷库");
                 }
                 }
             }
             }

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

@@ -972,16 +972,6 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
         }
         }
     }
     }
 
 
-    @Override
-    public ExamTask getByCourseCodeAndPaperNumber(Long schoolId, Long examId, String courseCode, String paperNumber) {
-        QueryWrapper<ExamTask> queryWrapper = new QueryWrapper<>();
-        queryWrapper.lambda().eq(ExamTask::getSchoolId, schoolId)
-                .eq(ExamTask::getExamId, examId)
-                .eq(ExamTask::getCourseCode, courseCode)
-                .eq(ExamTask::getPaperNumber, paperNumber);
-        return this.getOne(queryWrapper);
-    }
-
     @Override
     @Override
     public void checkDataByExamination(Long printPlanId, List<Long> examDetailIdList, SysUser user) {
     public void checkDataByExamination(Long printPlanId, List<Long> examDetailIdList, SysUser user) {
         Set<String> stringSet = new HashSet<>();
         Set<String> stringSet = new HashSet<>();
@@ -1009,7 +999,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
 //                    stringSet.add(String.format("课程[%s(%s)],试卷编号[%s]的任务未创建或者未审核通过", courseName, courseCode, paperNumber));
 //                    stringSet.add(String.format("课程[%s(%s)],试卷编号[%s]的任务未创建或者未审核通过", courseName, courseCode, paperNumber));
 //                }
 //                }
                 //查询命题任务绑定的试卷和题卡
                 //查询命题任务绑定的试卷和题卡
-                ExamTask examTask = examTaskService.getByCourseCodeAndPaperNumber(schoolId, examPrintPlan.getExamId(), examDetailCourse.getCourseCode(), examDetailCourse.getPaperNumber());
+                ExamTask examTask = examTaskService.getByExamIdAndCourseCodeAndPaperNumber(examPrintPlan.getExamId(), examDetailCourse.getCourseCode(), examDetailCourse.getPaperNumber());
                 if (examTask == null) {
                 if (examTask == null) {
                     stringSet.add(String.format("课程[%s(%s)],试卷编号[%s]的" + ExceptionResultEnum.EXAM_TASK_IS_NOT_EXIST.getMessage(), courseName, courseCode, paperNumber));
                     stringSet.add(String.format("课程[%s(%s)],试卷编号[%s]的" + ExceptionResultEnum.EXAM_TASK_IS_NOT_EXIST.getMessage(), courseName, courseCode, paperNumber));
                 } else {
                 } else {

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

@@ -421,7 +421,7 @@ public class GradeBatchServiceImpl extends ServiceImpl<GradeBatchMapper, GradeBa
             List<Long> orgIds = dtoList.stream().map(m -> m.getCourseCode() + "##" + m.getPaperNumber()).distinct().map(m -> {
             List<Long> orgIds = dtoList.stream().map(m -> m.getCourseCode() + "##" + m.getPaperNumber()).distinct().map(m -> {
                 String[] strings = m.split("##");
                 String[] strings = m.split("##");
                 // todo xf 20230413
                 // todo xf 20230413
-                ExamTask examTask = examTaskService.getByCourseCodeAndPaperNumber(schoolId, gradeBatch.getExamId(), strings[0], strings[1]);
+                ExamTask examTask = examTaskService.getByExamIdAndCourseCodeAndPaperNumber(gradeBatch.getExamId(), strings[0], strings[1]);
                 SysOrg sysOrg = sysOrgService.findCollegeLevelOrgByOrgId(examTask.getTeachingRoomId());
                 SysOrg sysOrg = sysOrgService.findCollegeLevelOrgByOrgId(examTask.getTeachingRoomId());
                 return sysOrg.getId();
                 return sysOrg.getId();
             }).distinct().collect(Collectors.toList());
             }).distinct().collect(Collectors.toList());

+ 12 - 86
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/PrintCommonServiceImpl.java

@@ -52,6 +52,7 @@ import org.apache.poi.ss.usermodel.HorizontalAlignment;
 import org.apache.poi.ss.usermodel.IndexedColors;
 import org.apache.poi.ss.usermodel.IndexedColors;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.xssf.usermodel.*;
 import org.apache.poi.xssf.usermodel.*;
+import org.bouncycastle.crypto.engines.CramerShoupCiphertext;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.context.annotation.Lazy;
@@ -323,7 +324,7 @@ public class PrintCommonServiceImpl implements PrintCommonService {
                 pdfStringJoiner.add(dictionaryConfig.fssPrivateDomain().getConfig()).add(File.separator);
                 pdfStringJoiner.add(dictionaryConfig.fssPrivateDomain().getConfig()).add(File.separator);
             }
             }
             pdfStringJoiner = SystemConstant.getDirName(pdfStringJoiner, UploadFileEnum.PDF, true);
             pdfStringJoiner = SystemConstant.getDirName(pdfStringJoiner, UploadFileEnum.PDF, true);
-            pdfStringJoiner.add(SystemConstant.getNanoId()).add(SystemConstant.PDF_PREFIX);
+            pdfStringJoiner.add(PdfUtil.md5FileName(CreatePdfTypeEnum.SIGN.name() + examDetail.getId())).add(SystemConstant.PDF_PREFIX);
 
 
             pdfFileTemp = SystemConstant.getFileTempVar(SystemConstant.PDF_PREFIX);
             pdfFileTemp = SystemConstant.getFileTempVar(SystemConstant.PDF_PREFIX);
             pdfFileTemp = createPrintPdfUtil.createSignPdf(pdfFillDto, pdfFileTemp.getPath(), basicTemplate);
             pdfFileTemp = createPrintPdfUtil.createSignPdf(pdfFillDto, pdfFileTemp.getPath(), basicTemplate);
@@ -624,7 +625,7 @@ public class PrintCommonServiceImpl implements PrintCommonService {
     @Transactional
     @Transactional
     public BasicAttachment saveAttachmentPdfFromHtml(String fileName, String htmlContent, Long userId, List<PdfDto> localFileList) {
     public BasicAttachment saveAttachmentPdfFromHtml(String fileName, String htmlContent, Long userId, List<PdfDto> localFileList) {
         BasicAttachment basicAttachment = null;
         BasicAttachment basicAttachment = null;
-        File htmlFileTemp = null, pdfFileTemp = null;
+        File htmlFileTemp = null;
         try {
         try {
             htmlFileTemp = SystemConstant.getFileTempVar(SystemConstant.HTML_PREFIX);
             htmlFileTemp = SystemConstant.getFileTempVar(SystemConstant.HTML_PREFIX);
             FileCopyUtils.copy(htmlContent.getBytes(StandardCharsets.UTF_8), htmlFileTemp);
             FileCopyUtils.copy(htmlContent.getBytes(StandardCharsets.UTF_8), htmlFileTemp);
@@ -642,9 +643,6 @@ public class PrintCommonServiceImpl implements PrintCommonService {
             if (htmlFileTemp != null) {
             if (htmlFileTemp != null) {
                 FileUtil.deleteFile(htmlFileTemp);
                 FileUtil.deleteFile(htmlFileTemp);
             }
             }
-//            if (pdfFileTemp != null) {
-//                FileUtil.deleteFile(pdfFileTemp);
-//            }
         }
         }
         return basicAttachment;
         return basicAttachment;
     }
     }
@@ -666,7 +664,7 @@ public class PrintCommonServiceImpl implements PrintCommonService {
 
 
             PdfDto pdfDto = PdfUtil.addPdfPage(pdfFileTemp);
             PdfDto pdfDto = PdfUtil.addPdfPage(pdfFileTemp);
             if (localFileList != null) {
             if (localFileList != null) {
-                localFileList.add(new PdfDto(pdfFileTemp.getPath(), PageSizeEnum.A3, pdfDto.getPageCount()));
+                localFileList.add(new PdfDto(filePathVo.getPath(), PageSizeEnum.A3, pdfDto.getPageCount()));
             }
             }
             basicAttachment = new BasicAttachment(JSON.toJSONString(filePathVo), fileName, SystemConstant.PDF_PREFIX, new BigDecimal(file.length()), filePathVo.getMd5(), userId);
             basicAttachment = new BasicAttachment(JSON.toJSONString(filePathVo), fileName, SystemConstant.PDF_PREFIX, new BigDecimal(file.length()), filePathVo.getMd5(), userId);
             basicAttachment.setPages(pdfDto.getActualPageCount());
             basicAttachment.setPages(pdfDto.getActualPageCount());
@@ -683,9 +681,9 @@ public class PrintCommonServiceImpl implements PrintCommonService {
             if (file != null) {
             if (file != null) {
                 FileUtil.deleteFile(file);
                 FileUtil.deleteFile(file);
             }
             }
-//            if (pdfFileTemp != null) {
-//                FileUtil.deleteFile(pdfFileTemp);
-//            }
+            if (pdfFileTemp != null) {
+                FileUtil.deleteFile(pdfFileTemp);
+            }
         }
         }
         return basicAttachment;
         return basicAttachment;
     }
     }
@@ -1229,16 +1227,15 @@ public class PrintCommonServiceImpl implements PrintCommonService {
     @Override
     @Override
     public Boolean checkExamDetailStatus(Long schoolId, Long printPlanId, Long examId, String courseCode, String paperNumber) {
     public Boolean checkExamDetailStatus(Long schoolId, Long printPlanId, Long examId, String courseCode, String paperNumber) {
         List<ExamDetail> examDetails;
         List<ExamDetail> examDetails;
-        ExamPrintPlan examPrintPlan = examPrintPlanService.getById(printPlanId);
         if (printPlanId != null) {
         if (printPlanId != null) {
             examDetails = examDetailService.listByPrintPlanIdAndCourseCodeAndPaperNumber(schoolId, printPlanId, courseCode, paperNumber);
             examDetails = examDetailService.listByPrintPlanIdAndCourseCodeAndPaperNumber(schoolId, printPlanId, courseCode, paperNumber);
         } else {
         } else {
             examDetails = examDetailService.listByCourseCodeAndPaperNumber(schoolId, examId, courseCode, paperNumber);
             examDetails = examDetailService.listByCourseCodeAndPaperNumber(schoolId, examId, courseCode, paperNumber);
         }
         }
-        if (examDetails != null && examDetails.size() > 0) {
+        if (CollectionUtils.isNotEmpty(examDetails)) {
             long count = examDetails.stream().filter(m -> !ExamDetailStatusEnum.NEW.name().equals(m.getStatus().name()) && !ExamDetailStatusEnum.READY.name().equals(m.getStatus().name())).count();
             long count = examDetails.stream().filter(m -> !ExamDetailStatusEnum.NEW.name().equals(m.getStatus().name()) && !ExamDetailStatusEnum.READY.name().equals(m.getStatus().name())).count();
             if (count > 0) {
             if (count > 0) {
-                throw ExceptionResultEnum.ERROR.exception("已有印刷任务进入打印状态,不能修改");
+                throw ExceptionResultEnum.ERROR.exception("部分考场pdf文件开始印刷,不能修改");
             }
             }
         }
         }
         return true;
         return true;
@@ -1265,81 +1262,10 @@ public class PrintCommonServiceImpl implements PrintCommonService {
         }
         }
     }
     }
 
 
-    /**
-     * 校验是否可以提交
-     *
-     * @param schoolId
-     * @param courseCode
-     * @param paperNumber
-     * @param user
-     * @throws IOException
-     */
-    @Override
-    public void checkData(Long schoolId, Long examId, String courseCode, String paperNumber, SysUser user) throws IOException {
-        // 校验命题任务是否提交
-        ExamTask examTask = examTaskService.getByCourseCodeAndPaperNumber(schoolId, examId, courseCode, paperNumber);
-        BasicExam basicExam = basicExamService.getById(examTask.getExamId());
-        if (basicExam != null && ExamModelEnum.MODEL3.equals(basicExam.getExamModel())) {
-            log.info("考试模式为模式3,不生成pdf");
-            return;
-        }
-
-        if (examTask != null && !examTask.getEnable()) {
-            log.info("命题任务已禁用");
-            return;
-        }
-        ExamTaskDetail examTaskDetail = examTaskDetailService.getByExamTaskId(examTask.getId());
-        if (!examTaskDetail.getEnable()) {
-            log.info("卷库已禁用");
-            return;
-        }
-
-        boolean canCreatePdf = true;
-        if (examTask.getReview()) {
-            TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(examTask.getFlowId());
-            // 1.命题任务已完成
-            if (tfFlowApprove == null || tfFlowApprove.getStatus() != FlowStatusEnum.FINISH) {
-                canCreatePdf = false;
-            }
-        }
-
-        if (canCreatePdf) {
-            // 2.校验考务数据是否导入
-            List<ExamDetail> examDetails = examDetailService.listByCourseCodeAndPaperNumber(schoolId, examId, courseCode, paperNumber);
-            if (examDetails != null && examDetails.size() > 0) {
-                // 3.检查examDetailId下有无其它课程
-                for (ExamDetail examDetail : examDetails) {
-                    List<ExamDetailCourse> examDetailCourses = examDetailCourseService.listByExamDetailIdAndStatus(examDetail.getId());
-                    // 4.没有未完成的命题任务
-                    if (examDetailCourses.isEmpty()) {
-                        // 更新考场状态为初始新建状态
-                        UpdateWrapper<ExamDetail> examDetailUpdateWrapper = new UpdateWrapper<>();
-                        examDetailUpdateWrapper.lambda().set(ExamDetail::getStatus, ExamDetailStatusEnum.NEW).eq(ExamDetail::getId, examDetail.getId());
-                        examDetailService.update(examDetailUpdateWrapper);
-
-                        //所有考场都撤回,印刷任务状态改为就绪
-                        QueryWrapper<ExamDetail> queryWrapper = new QueryWrapper<>();
-                        queryWrapper.lambda().eq(ExamDetail::getPrintPlanId, examDetail.getPrintPlanId()).notIn(ExamDetail::getStatus, ExamDetailStatusEnum.NEW, ExamDetailStatusEnum.READY);
-                        List<ExamDetail> examDetailss = examDetailService.list(queryWrapper);
-                        if (examDetailss.isEmpty()) {
-                            UpdateWrapper<ExamPrintPlan> printPlanUpdateWrapper = new UpdateWrapper<>();
-                            printPlanUpdateWrapper.lambda().set(ExamPrintPlan::getStatus, PrintPlanStatusEnum.READY).eq(ExamPrintPlan::getId, examDetail.getPrintPlanId());
-                            examPrintPlanService.update(printPlanUpdateWrapper);
-                        }
-                        TbTaskDetailResult tbTaskDetailResult = examDetailCourseService.getByExamDetailId(examDetail.getId());
-                        Map<String, Object> map = tbTaskService.saveTask(tbTaskDetailResult, TaskTypeEnum.CREATE_PDF, examDetail.getPrintPlanId(), user, examDetail.getId());
-                        MqDto mqDto = new MqDto(MqTagEnum.PDF.getCode(), map, String.valueOf(map.get(SystemConstant.TB_TASK_ID)));
-                        redisUtil.sendMessage(mqDto.getTopic(), mqDto);
-                    }
-                }
-            }
-        }
-    }
-
     @Override
     @Override
     public void checkDataNew(Long schoolId, Long examId, String courseCode, String paperNumber, SysUser user) throws IOException {
     public void checkDataNew(Long schoolId, Long examId, String courseCode, String paperNumber, SysUser user) throws IOException {
         // 校验命题任务是否提交
         // 校验命题任务是否提交
-        ExamTask examTask = examTaskService.getByCourseCodeAndPaperNumber(schoolId, examId, courseCode, paperNumber);
+        ExamTask examTask = examTaskService.getByExamIdAndCourseCodeAndPaperNumber(examId, courseCode, paperNumber);
         BasicExam basicExam = basicExamService.getById(examTask.getExamId());
         BasicExam basicExam = basicExamService.getById(examTask.getExamId());
         if (basicExam != null && ExamModelEnum.MODEL3.equals(basicExam.getExamModel())) {
         if (basicExam != null && ExamModelEnum.MODEL3.equals(basicExam.getExamModel())) {
             log.info("考试模式为模式3,不生成pdf");
             log.info("考试模式为模式3,不生成pdf");
@@ -1409,7 +1335,7 @@ public class PrintCommonServiceImpl implements PrintCommonService {
     @Override
     @Override
     public void checkDataMakeup(Long schoolId, ExamDetail examDetail, String courseCode, String paperNumber, SysUser user) {
     public void checkDataMakeup(Long schoolId, ExamDetail examDetail, String courseCode, String paperNumber, SysUser user) {
         // 校验命题任务是否提交
         // 校验命题任务是否提交
-        ExamTask examTask = examTaskService.getByCourseCodeAndPaperNumber(schoolId, examDetail.getExamId(), courseCode, paperNumber);
+        ExamTask examTask = examTaskService.getByExamIdAndCourseCodeAndPaperNumber(examDetail.getExamId(), courseCode, paperNumber);
         BasicExam basicExam = basicExamService.getById(examTask.getExamId());
         BasicExam basicExam = basicExamService.getById(examTask.getExamId());
         if (basicExam != null && ExamModelEnum.MODEL3.equals(basicExam.getExamModel())) {
         if (basicExam != null && ExamModelEnum.MODEL3.equals(basicExam.getExamModel())) {
             log.info("考试模式为模式3,不生成pdf");
             log.info("考试模式为模式3,不生成pdf");
@@ -1675,7 +1601,7 @@ public class PrintCommonServiceImpl implements PrintCommonService {
                 pdfStringJoiner.add(dictionaryConfig.fssPrivateDomain().getConfig()).add(File.separator);
                 pdfStringJoiner.add(dictionaryConfig.fssPrivateDomain().getConfig()).add(File.separator);
             }
             }
             pdfStringJoiner = SystemConstant.getDirName(pdfStringJoiner, UploadFileEnum.PDF, true);
             pdfStringJoiner = SystemConstant.getDirName(pdfStringJoiner, UploadFileEnum.PDF, true);
-            pdfStringJoiner.add(SystemConstant.getNanoId()).add(SystemConstant.PDF_PREFIX);
+            pdfStringJoiner.add(PdfUtil.md5FileName(CreatePdfTypeEnum.PACKAGE.name() + examDetail.getId())).add(SystemConstant.PDF_PREFIX);
 
 
             String pdfDirName = FileUtil.replaceSplit(pdfStringJoiner.toString());
             String pdfDirName = FileUtil.replaceSplit(pdfStringJoiner.toString());
             pdfFileTemp = SystemConstant.getFileTempVar(SystemConstant.PDF_PREFIX);
             pdfFileTemp = SystemConstant.getFileTempVar(SystemConstant.PDF_PREFIX);

+ 26 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TBTaskPdfServiceImpl.java

@@ -1,5 +1,6 @@
 package com.qmth.distributed.print.business.service.impl;
 package com.qmth.distributed.print.business.service.impl;
 
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -7,17 +8,19 @@ import com.qmth.boot.api.exception.ApiException;
 import com.qmth.distributed.print.business.entity.TBTaskPdf;
 import com.qmth.distributed.print.business.entity.TBTaskPdf;
 import com.qmth.distributed.print.business.mapper.TBTaskPdfMapper;
 import com.qmth.distributed.print.business.mapper.TBTaskPdfMapper;
 import com.qmth.distributed.print.business.service.TBTaskPdfService;
 import com.qmth.distributed.print.business.service.TBTaskPdfService;
+import com.qmth.teachcloud.common.bean.dto.MqDto;
 import com.qmth.teachcloud.common.bean.result.TbTaskDetailResult;
 import com.qmth.teachcloud.common.bean.result.TbTaskDetailResult;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.SysUser;
 import com.qmth.teachcloud.common.entity.SysUser;
-import com.qmth.teachcloud.common.enums.TaskResultEnum;
-import com.qmth.teachcloud.common.enums.TaskStatusEnum;
-import com.qmth.teachcloud.common.enums.TaskTypeEnum;
+import com.qmth.teachcloud.common.entity.TBTask;
+import com.qmth.teachcloud.common.enums.*;
 import com.qmth.teachcloud.common.util.ResultUtil;
 import com.qmth.teachcloud.common.util.ResultUtil;
+import com.qmth.teachcloud.common.util.ServletUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
 import java.util.HashMap;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
 /**
 /**
@@ -63,4 +66,24 @@ public class TBTaskPdfServiceImpl extends ServiceImpl<TBTaskPdfMapper, TBTaskPdf
         }
         }
         return null;
         return null;
     }
     }
+
+    @Override
+    public void resetRunningCreatePdf(Long id, CreatePdfTypeEnum type) {
+        TBTaskPdf tbTaskPdf = this.getById(id);
+        if (TaskStatusEnum.RUNNING.equals(tbTaskPdf.getStatus())) {
+            throw ExceptionResultEnum.ERROR.exception("任务正在生成中,请稍后再试");
+        }
+        tbTaskPdf.setStatus(TaskStatusEnum.INIT);
+        tbTaskPdf.setCreateType(type);
+        tbTaskPdf.setResult(null);
+        this.updateById(tbTaskPdf);
+    }
+
+    @Override
+    public int countRunningByExamDetailIds(List<Long> examDetailIds) {
+        QueryWrapper<TBTaskPdf> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().in(TBTaskPdf::getId, examDetailIds)
+                .eq(TBTaskPdf::getStatus, TaskStatusEnum.RUNNING);
+        return this.count(queryWrapper);
+    }
 }
 }

+ 8 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/AsyncCreatePdfTempleteService.java

@@ -109,12 +109,16 @@ public class AsyncCreatePdfTempleteService extends AsyncCreateTaskTemplete {
     @Override
     @Override
     public Result createPdf(TBTaskPdf tbTaskPdf, CallbackCreatePdf callbackCreatePdf) throws IOException {
     public Result createPdf(TBTaskPdf tbTaskPdf, CallbackCreatePdf callbackCreatePdf) throws IOException {
         StringJoiner stringJoinerSummary = new StringJoiner("\n").add(MessageFormat.format("{0}{1}{2}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), BEGIN_TITLE, OBJ_TITLE));
         StringJoiner stringJoinerSummary = new StringJoiner("\n").add(MessageFormat.format("{0}{1}{2}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), BEGIN_TITLE, OBJ_TITLE));
-        TBTaskPdfService tbTaskService = SpringContextHolder.getBean(TBTaskPdfService.class);
+        TBTaskPdfService tbTaskPdfService = SpringContextHolder.getBean(TBTaskPdfService.class);
 //        if (Objects.isNull(manual) && (Objects.nonNull(dbTask) && dbTask.getStatus() == TaskStatusEnum.FINISH && Objects.nonNull(dbTask.getResult()))) {//无需重新生成pdf
 //        if (Objects.isNull(manual) && (Objects.nonNull(dbTask) && dbTask.getStatus() == TaskStatusEnum.FINISH && Objects.nonNull(dbTask.getResult()))) {//无需重新生成pdf
 //            return ResultUtil.ok();
 //            return ResultUtil.ok();
 //        }
 //        }
+        // 任务状态为进行中,直接结束
+        if (TaskStatusEnum.RUNNING.equals(tbTaskPdf.getStatus())) {
+            return ResultUtil.ok();
+        }
         tbTaskPdf.setStatus(TaskStatusEnum.RUNNING);
         tbTaskPdf.setStatus(TaskStatusEnum.RUNNING);
-        tbTaskService.updateById(tbTaskPdf);
+        tbTaskPdfService.updateById(tbTaskPdf);
         try {
         try {
             PdfTaskLogicService pdfTaskLogicService = SpringContextHolder.getBean(PdfTaskLogicService.class);
             PdfTaskLogicService pdfTaskLogicService = SpringContextHolder.getBean(PdfTaskLogicService.class);
             pdfTaskLogicService.executeCreatePdfLogic(tbTaskPdf);
             pdfTaskLogicService.executeCreatePdfLogic(tbTaskPdf);
@@ -140,7 +144,9 @@ public class AsyncCreatePdfTempleteService extends AsyncCreateTaskTemplete {
                 ResultUtil.error(e.getMessage());
                 ResultUtil.error(e.getMessage());
             }
             }
         } finally {
         } finally {
+            tbTaskPdf.setStatus(TaskStatusEnum.FINISH);
             tbTaskPdf.setSummary(stringJoinerSummary.toString());
             tbTaskPdf.setSummary(stringJoinerSummary.toString());
+            tbTaskPdfService.updateById(tbTaskPdf);
         }
         }
         return ResultUtil.ok(tbTaskPdf);
         return ResultUtil.ok(tbTaskPdf);
     }
     }

+ 58 - 72
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/PdfTaskLogicServiceImpl.java

@@ -87,63 +87,8 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
     @Resource
     @Resource
     ExamTaskAssignPaperTypeService examTaskAssignPaperTypeService;
     ExamTaskAssignPaperTypeService examTaskAssignPaperTypeService;
     @Resource
     @Resource
-    private PrintCommonService printCommonService;
-    @Resource
     private FileUploadService fileUploadService;
     private FileUploadService fileUploadService;
 
 
-    /**
-     * 创建A4文件
-     *
-     * @param tbTaskPdf
-     * @param examDetailCourseList
-     * @throws Exception
-     */
-    @Transactional
-    public void createA4File(TBTaskPdf tbTaskPdf, List<ExamDetailCourse> examDetailCourseList) throws Exception {
-        CreatePdfTypeEnum createPdfType = tbTaskPdf.getCreateType();
-        ExamPrintPlan examPrintPlan = examPrintPlanService.getById(tbTaskPdf.getPrintPlanId());
-        ExamDetail examDetail = examDetailService.getById(tbTaskPdf.getId());
-        BasicSchool basicSchool = commonCacheService.schoolCache(tbTaskPdf.getSchoolId());
-        // 印品
-        String ordinaryContent = examPrintPlan.getOrdinaryContent();
-        if ((CreatePdfTypeEnum.ALL.equals(createPdfType) || CreatePdfTypeEnum.CHECK_IN.equals(createPdfType)) && StringUtils.isNotBlank(ordinaryContent)) {
-            //获取普通印品
-            JSONArray jsonArrayOrdinary = JSONArray.parseArray(ordinaryContent);
-            for (int i = 0; i < jsonArrayOrdinary.size(); i++) {
-                JSONObject jsonObjectOrdinary = jsonArrayOrdinary.getJSONObject(i);
-                if (Objects.nonNull(jsonObjectOrdinary.get("attachmentId")) && !Objects.equals("", jsonObjectOrdinary.get("attachmentId"))) {
-                    Long attachmentId = Long.parseLong((String) jsonObjectOrdinary.get("attachmentId"));
-                    BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
-                    createPdfNewUtil.createCheckIn(examDetail, basicAttachment, (Integer) jsonObjectOrdinary.get("backupCount"));
-                }
-            }
-        }
-        BasicExam basicExam = basicExamService.getById(examPrintPlan.getExamId());
-        if (basicExam.getCategory().equals(ExamCategoryEnum.FORMAL)) {
-            String variableContent = examPrintPlan.getVariableContent();
-            if (StringUtils.isNotBlank(variableContent)) {
-                List<Long> examDetailCourseListIds = examDetailCourseList.stream().map(BaseEntity::getId).collect(Collectors.toList());
-                List<ExamStudentCourseDto> examStudentCourseDtoList = examStudentService.queryBySchoolIdAndExamDetailCourseIds(basicSchool.getId(), examDetailCourseListIds);
-                //获取变量印品
-                JSONArray jsonArrayVariable = JSONArray.parseArray(variableContent);
-                for (int i = 0; i < jsonArrayVariable.size(); i++) {
-                    JSONObject jsonObjectVariable = jsonArrayVariable.getJSONObject(i);
-                    String type = (String) jsonObjectVariable.get("type");
-                    if (Objects.nonNull(jsonObjectVariable.get("templateId")) && !Objects.equals("", jsonObjectVariable.get("templateId"))) {
-                        Long templateId = Long.parseLong((String) jsonObjectVariable.get("templateId"));
-                        if ((CreatePdfTypeEnum.ALL.equals(createPdfType) || CreatePdfTypeEnum.SIGN.equals(createPdfType)) && Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "SIGN")) {//签到表
-                            createPdfNewUtil.createSignBook(templateId, basicSchool.getName(), examDetail, examStudentCourseDtoList, (Integer) jsonObjectVariable.get("backupCount"), examDetailCourseList);
-                        } else if ((CreatePdfTypeEnum.ALL.equals(createPdfType) || CreatePdfTypeEnum.PACKAGE.equals(createPdfType)) && Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "PACKAGE")) {//卷袋贴
-                            Integer backupCount = SystemConstant.calcBackupCount(examDetail.getBackupCount(), examDetail.getTotalSubjects(), 1);
-                            createPdfNewUtil.createPaperPackage(templateId, basicSchool.getName(), examDetail, examStudentCourseDtoList, backupCount, (Integer) jsonObjectVariable.get("backupCount"), examDetailCourseList, examPrintPlan.getExamId());
-                        }
-                    }
-                }
-            }
-        }
-        examDetailService.updateById(examDetail);
-    }
-
     @Override
     @Override
     public void executeCreatePdfLogic(TBTaskPdf tbTaskPdf) {
     public void executeCreatePdfLogic(TBTaskPdf tbTaskPdf) {
         CreatePdfDto createPdfDto = new CreatePdfDto();
         CreatePdfDto createPdfDto = new CreatePdfDto();
@@ -174,7 +119,7 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
         } catch (Exception e) {
         } catch (Exception e) {
             throw new RuntimeException(e);
             throw new RuntimeException(e);
         } finally {
         } finally {
-            if(CollectionUtils.isNotEmpty(createPdfDto.getFileTempList())){
+            if (CollectionUtils.isNotEmpty(createPdfDto.getFileTempList())) {
                 for (File file : createPdfDto.getFileTempList()) {
                 for (File file : createPdfDto.getFileTempList()) {
                     FileUtil.deleteFile(file);
                     FileUtil.deleteFile(file);
                 }
                 }
@@ -253,13 +198,8 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
         for (ExamDetailCourse examDetailCourse : createPdfDto.getExamDetailCourseList()) {
         for (ExamDetailCourse examDetailCourse : createPdfDto.getExamDetailCourseList()) {
             String[] paperTypes = examDetailCourse.getPaperType().split(",");
             String[] paperTypes = examDetailCourse.getPaperType().split(",");
 
 
-            List<PdfDto> studentPaperPdfList = new ArrayList<>();//所有试卷
-            List<PdfDto> studentCardPdfList = new ArrayList<>();//所有题卡
-            List<PdfDto> backupPaperPdfList = new ArrayList<>();//备份试卷
-            List<PdfDto> backupCardPdfList = new ArrayList<>();//备份题卡
-
             //查询命题任务绑定的试卷和题卡
             //查询命题任务绑定的试卷和题卡
-            ExamTask examTask = examTaskService.getByCourseCodeAndPaperNumber(tbTaskPdf.getSchoolId(), tbTaskPdf.getExamId(), examDetailCourse.getCourseCode(), examDetailCourse.getPaperNumber());
+            ExamTask examTask = examTaskService.getByExamIdAndCourseCodeAndPaperNumber(tbTaskPdf.getExamId(), examDetailCourse.getCourseCode(), examDetailCourse.getPaperNumber());
             if (examTask == null) {
             if (examTask == null) {
                 throw ExceptionResultEnum.EXAM_TASK_IS_NULL.exception();
                 throw ExceptionResultEnum.EXAM_TASK_IS_NULL.exception();
             } else if (examTask.getReview()) {
             } else if (examTask.getReview()) {
@@ -273,8 +213,6 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
             }
             }
             ExamTaskDetail examTaskDetail = examTaskDetailService.getByExamTaskId(examTask.getId());
             ExamTaskDetail examTaskDetail = examTaskDetailService.getByExamTaskId(examTask.getId());
 
 
-            List<ExamStudent> examStudentList = examStudentService.listByExamDetailCourseId(examDetailCourse.getId());
-
             CreatePdfTypeEnum createPdfType = tbTaskPdf.getCreateType();
             CreatePdfTypeEnum createPdfType = tbTaskPdf.getCreateType();
             String printContent = examPrintPlan.getPrintContent();
             String printContent = examPrintPlan.getPrintContent();
             if (StringUtils.isBlank(printContent)) {
             if (StringUtils.isBlank(printContent)) {
@@ -283,10 +221,10 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
             // 计算备份数量,默认最小为1份。
             // 计算备份数量,默认最小为1份。
             int backupCount = SystemConstant.calcBackupCount(examDetail.getBackupCount(), examDetail.getTotalSubjects(), 1);
             int backupCount = SystemConstant.calcBackupCount(examDetail.getBackupCount(), examDetail.getTotalSubjects(), 1);
 
 
+            List<ExamStudent> examStudentList = examStudentService.listByExamDetailCourseId(examDetailCourse.getId());
             // 试卷数据组装
             // 试卷数据组装
             if ((CreatePdfTypeEnum.ALL.equals(createPdfType) || CreatePdfTypeEnum.PAPER.equals(createPdfType)) && printContent.contains("PAPER")) {
             if ((CreatePdfTypeEnum.ALL.equals(createPdfType) || CreatePdfTypeEnum.PAPER.equals(createPdfType)) && printContent.contains("PAPER")) {
                 List<PaperPdfDto> paperPdfDtoList = createPdfNewUtil.getPaperPdfFile(examDetailCourse.getPaperType(), examTaskDetail.getPaperInfoVoList(null), createPdfDto);
                 List<PaperPdfDto> paperPdfDtoList = createPdfNewUtil.getPaperPdfFile(examDetailCourse.getPaperType(), examTaskDetail.getPaperInfoVoList(null), createPdfDto);
-
                 // 生成考生试卷
                 // 生成考生试卷
                 if (CollectionUtils.isNotEmpty(examStudentList)) {
                 if (CollectionUtils.isNotEmpty(examStudentList)) {
                     for (ExamStudent t : examStudentList) {
                     for (ExamStudent t : examStudentList) {
@@ -333,7 +271,7 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
                 if (examStudentList != null && examStudentList.size() > 0) {
                 if (examStudentList != null && examStudentList.size() > 0) {
                     for (ExamStudent t : examStudentList) {
                     for (ExamStudent t : examStudentList) {
                         // 用带条码的模板
                         // 用带条码的模板
-                        createPdfNewUtil.examStudentHtml(examCardMap.get(t.getPaperType()).getHtmlContent(), t, t.getPaperType(), examDetail, tbTaskPdf.getCreateId(), studentCardPdfList, basicCardRule);
+                        createPdfNewUtil.examStudentHtml(examCardMap.get(t.getPaperType()).getHtmlContent(), t, t.getPaperType(), examDetail, tbTaskPdf.getCreateId(), createPdfDto.getCardPdfList(), basicCardRule);
                     }
                     }
                     examStudentService.updateBatchById(examStudentList);
                     examStudentService.updateBatchById(examStudentList);
                 } else if (examDetailCourse.getTotalSubjects() != null) {
                 } else if (examDetailCourse.getTotalSubjects() != null) {
@@ -344,7 +282,7 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
                         int seq = atomicInteger.getAndIncrement();
                         int seq = atomicInteger.getAndIncrement();
                         int mod = seq % examTaskDetail.getDrawCount();
                         int mod = seq % examTaskDetail.getDrawCount();
                         String tempPaperType = paperTypes[mod];
                         String tempPaperType = paperTypes[mod];
-                        BasicAttachment basicAttachment = createPdfNewUtil.examStudentHtml(examCardMap.get(tempPaperType).getHtmlContent(), null, tempPaperType, examDetail, tbTaskPdf.getCreateId(), studentCardPdfList, basicCardRule);
+                        BasicAttachment basicAttachment = createPdfNewUtil.examStudentHtml(examCardMap.get(tempPaperType).getHtmlContent(), null, tempPaperType, examDetail, tbTaskPdf.getCreateId(), createPdfDto.getCardPdfList(), basicCardRule);
 
 
                         if (!stringBasicAttachmentMap.containsKey(tempPaperType)) {
                         if (!stringBasicAttachmentMap.containsKey(tempPaperType)) {
                             stringBasicAttachmentMap.put(tempPaperType, basicAttachment);
                             stringBasicAttachmentMap.put(tempPaperType, basicAttachment);
@@ -352,9 +290,6 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
                             object.put("name", tempPaperType);
                             object.put("name", tempPaperType);
                             object.put("attachmentId", basicAttachment.getId());
                             object.put("attachmentId", basicAttachment.getId());
                             stuJsonArray.add(object);
                             stuJsonArray.add(object);
-
-                            // 用不带条码的模板
-//                            basicAttachmentList.add(basicAttachment);
                         }
                         }
                         i++;
                         i++;
                     }
                     }
@@ -362,8 +297,6 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
                 } else {
                 } else {
                     throw ExceptionResultEnum.ERROR.exception("数据错误:未找到考生或者印刷数量");
                     throw ExceptionResultEnum.ERROR.exception("数据错误:未找到考生或者印刷数量");
                 }
                 }
-                // 题卡
-                createPdfDto.getCardPdfList().addAll(studentCardPdfList);
 
 
                 JSONObject jsonObject = new JSONObject();
                 JSONObject jsonObject = new JSONObject();
                 JSONArray jsonArray = new JSONArray();
                 JSONArray jsonArray = new JSONArray();
@@ -396,4 +329,57 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
         }
         }
     }
     }
 
 
+    /**
+     * 创建A4文件
+     *
+     * @param tbTaskPdf
+     * @param examDetailCourseList
+     * @throws Exception
+     */
+    @Transactional
+    public void createA4File(TBTaskPdf tbTaskPdf, List<ExamDetailCourse> examDetailCourseList) throws Exception {
+        CreatePdfTypeEnum createPdfType = tbTaskPdf.getCreateType();
+        ExamPrintPlan examPrintPlan = examPrintPlanService.getById(tbTaskPdf.getPrintPlanId());
+        ExamDetail examDetail = examDetailService.getById(tbTaskPdf.getId());
+        BasicSchool basicSchool = commonCacheService.schoolCache(tbTaskPdf.getSchoolId());
+        // 印品
+        String ordinaryContent = examPrintPlan.getOrdinaryContent();
+        if ((CreatePdfTypeEnum.ALL.equals(createPdfType) || CreatePdfTypeEnum.CHECK_IN.equals(createPdfType)) && StringUtils.isNotBlank(ordinaryContent)) {
+            //获取普通印品
+            JSONArray jsonArrayOrdinary = JSONArray.parseArray(ordinaryContent);
+            for (int i = 0; i < jsonArrayOrdinary.size(); i++) {
+                JSONObject jsonObjectOrdinary = jsonArrayOrdinary.getJSONObject(i);
+                if (Objects.nonNull(jsonObjectOrdinary.get("attachmentId")) && !Objects.equals("", jsonObjectOrdinary.get("attachmentId"))) {
+                    Long attachmentId = Long.parseLong((String) jsonObjectOrdinary.get("attachmentId"));
+                    BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
+                    createPdfNewUtil.createCheckIn(examDetail, basicAttachment, (Integer) jsonObjectOrdinary.get("backupCount"));
+                }
+            }
+        }
+        BasicExam basicExam = basicExamService.getById(examPrintPlan.getExamId());
+        if (basicExam.getCategory().equals(ExamCategoryEnum.FORMAL)) {
+            String variableContent = examPrintPlan.getVariableContent();
+            if (StringUtils.isNotBlank(variableContent)) {
+                List<Long> examDetailCourseListIds = examDetailCourseList.stream().map(BaseEntity::getId).collect(Collectors.toList());
+                List<ExamStudentCourseDto> examStudentCourseDtoList = examStudentService.queryBySchoolIdAndExamDetailCourseIds(basicSchool.getId(), examDetailCourseListIds);
+                //获取变量印品
+                JSONArray jsonArrayVariable = JSONArray.parseArray(variableContent);
+                for (int i = 0; i < jsonArrayVariable.size(); i++) {
+                    JSONObject jsonObjectVariable = jsonArrayVariable.getJSONObject(i);
+                    String type = (String) jsonObjectVariable.get("type");
+                    if (Objects.nonNull(jsonObjectVariable.get("templateId")) && !Objects.equals("", jsonObjectVariable.get("templateId"))) {
+                        Long templateId = Long.parseLong((String) jsonObjectVariable.get("templateId"));
+                        if ((CreatePdfTypeEnum.ALL.equals(createPdfType) || CreatePdfTypeEnum.SIGN.equals(createPdfType)) && Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "SIGN")) {//签到表
+                            createPdfNewUtil.createSignBook(templateId, basicSchool.getName(), examDetail, examStudentCourseDtoList, (Integer) jsonObjectVariable.get("backupCount"), examDetailCourseList);
+                        } else if ((CreatePdfTypeEnum.ALL.equals(createPdfType) || CreatePdfTypeEnum.PACKAGE.equals(createPdfType)) && Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "PACKAGE")) {//卷袋贴
+                            Integer backupCount = SystemConstant.calcBackupCount(examDetail.getBackupCount(), examDetail.getTotalSubjects(), 1);
+                            createPdfNewUtil.createPaperPackage(templateId, basicSchool.getName(), examDetail, examStudentCourseDtoList, backupCount, (Integer) jsonObjectVariable.get("backupCount"), examDetailCourseList, examPrintPlan.getExamId());
+                        }
+                    }
+                }
+            }
+        }
+        examDetailService.updateById(examDetail);
+    }
+
 }
 }

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

@@ -221,7 +221,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                 return null;
                 return null;
             }
             }
             //查询命题任务绑定的试卷和题卡
             //查询命题任务绑定的试卷和题卡
-            ExamTask examTask = examTaskService.getByCourseCodeAndPaperNumber(sysUser.getSchoolId(), examDetail.getExamId(), examDetailCourse.getCourseCode(), examDetailCourse.getPaperNumber());
+            ExamTask examTask = examTaskService.getByExamIdAndCourseCodeAndPaperNumber(examDetail.getExamId(), examDetailCourse.getCourseCode(), examDetailCourse.getPaperNumber());
             if (examTask == null) {
             if (examTask == null) {
                 throw ExceptionResultEnum.EXAM_TASK_IS_NULL.exception();
                 throw ExceptionResultEnum.EXAM_TASK_IS_NULL.exception();
             } else if (examTask.getReview()) {
             } else if (examTask.getReview()) {

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/CreatePdfUtil.java

@@ -150,7 +150,7 @@ public class CreatePdfUtil {
 
 
         boolean isTag = false;
         boolean isTag = false;
         for (ExamDetailCourse detailCourse : examDetailCourseList) {
         for (ExamDetailCourse detailCourse : examDetailCourseList) {
-            ExamTask examTask = examTaskService.getByCourseCodeAndPaperNumber(examDetail.getSchoolId(), examId, detailCourse.getCourseCode(), detailCourse.getPaperNumber());
+            ExamTask examTask = examTaskService.getByExamIdAndCourseCodeAndPaperNumber(examId, detailCourse.getCourseCode(), detailCourse.getPaperNumber());
             ExamTaskDetail examTaskDetail = examTaskDetailService.getByExamTaskId(examTask.getId());
             ExamTaskDetail examTaskDetail = examTaskDetailService.getByExamTaskId(examTask.getId());
             List<PaperInfoVo> paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetail.getPaperAttachmentIds());
             List<PaperInfoVo> paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetail.getPaperAttachmentIds());
             for (PaperInfoVo paperInfoVo : paperInfoVoList) {
             for (PaperInfoVo paperInfoVo : paperInfoVoList) {

+ 5 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/PdfUtil.java

@@ -23,6 +23,7 @@ import com.qmth.teachcloud.common.util.ResultUtil;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.io.IOUtils;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
+import org.springframework.util.DigestUtils;
 import org.springframework.util.FileCopyUtils;
 import org.springframework.util.FileCopyUtils;
 
 
 import javax.swing.*;
 import javax.swing.*;
@@ -494,4 +495,8 @@ public class PdfUtil {
             }
             }
         }
         }
     }
     }
+
+    public static String md5FileName(String fileName) {
+        return DigestUtils.md5DigestAsHex(fileName.getBytes(StandardCharsets.UTF_8));
+    }
 }
 }

+ 71 - 38
distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/pdf/CreatePdfNewUtil.java

@@ -39,6 +39,7 @@ import org.springframework.transaction.annotation.Transactional;
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import java.io.File;
 import java.io.File;
 import java.io.IOException;
 import java.io.IOException;
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
@@ -138,7 +139,7 @@ public class CreatePdfNewUtil {
 
 
         boolean isTag = false;
         boolean isTag = false;
         for (ExamDetailCourse detailCourse : examDetailCourseList) {
         for (ExamDetailCourse detailCourse : examDetailCourseList) {
-            ExamTask examTask = examTaskService.getByCourseCodeAndPaperNumber(examDetail.getSchoolId(), examId, detailCourse.getCourseCode(), detailCourse.getPaperNumber());
+            ExamTask examTask = examTaskService.getByExamIdAndCourseCodeAndPaperNumber(examId, detailCourse.getCourseCode(), detailCourse.getPaperNumber());
             ExamTaskDetail examTaskDetail = examTaskDetailService.getByExamTaskId(examTask.getId());
             ExamTaskDetail examTaskDetail = examTaskDetailService.getByExamTaskId(examTask.getId());
             List<PaperInfoVo> paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetail.getPaperAttachmentIds());
             List<PaperInfoVo> paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetail.getPaperAttachmentIds());
             for (PaperInfoVo paperInfoVo : paperInfoVoList) {
             for (PaperInfoVo paperInfoVo : paperInfoVoList) {
@@ -174,6 +175,7 @@ public class CreatePdfNewUtil {
         boolean isDateHasTwo = objectList.stream().filter(m -> "examDate".equals(m.getString("code")) || "examTime".equals(m.getString("code"))).count() == 2;
         boolean isDateHasTwo = objectList.stream().filter(m -> "examDate".equals(m.getString("code")) || "examTime".equals(m.getString("code"))).count() == 2;
         boolean isCourseFill = false;
         boolean isCourseFill = false;
         boolean isDateFill = false;
         boolean isDateFill = false;
+        boolean paperCount = false, examCount = false, actualExamCount = false;
         // 基础信息
         // 基础信息
         List<Map<String, String>> basicPlate = new ArrayList<>();
         List<Map<String, String>> basicPlate = new ArrayList<>();
         for (JSONObject jsonObject : objectList) {
         for (JSONObject jsonObject : objectList) {
@@ -289,6 +291,27 @@ public class CreatePdfNewUtil {
                 basicMap.put("name", name);
                 basicMap.put("name", name);
                 basicMap.put("value", String.join(SystemConstant.COMMA_OF_CHINESE, stringSet));
                 basicMap.put("value", String.join(SystemConstant.COMMA_OF_CHINESE, stringSet));
                 basicPlate.add(basicMap);
                 basicPlate.add(basicMap);
+            } else if ("paperCount".equals(code)) {
+                Map<String, String> basicMap = new HashMap<>();
+                basicMap.put("code", "paperCount");
+                basicMap.put("name", "试卷数量");
+                basicMap.put("value", examStudentList.size() + " + " + backupCount);
+                basicPlate.add(basicMap);
+                paperCount = true;
+            } else if ("examCount".equals(code)) {
+                Map<String, String> basicMap = new HashMap<>();
+                basicMap.put("code", "examCount");
+                basicMap.put("name", "应考人数");
+                basicMap.put("value", String.valueOf(examStudentList.size()));
+                basicPlate.add(basicMap);
+                examCount = true;
+            } else if ("actualExamCount".equals(code)) {
+                Map<String, String> basicMap = new HashMap<>();
+                basicMap.put("code", "actualExamCount");
+                basicMap.put("name", "实考人数");
+                basicMap.put("value", "");
+                basicPlate.add(basicMap);
+                actualExamCount = true;
             } else {
             } else {
                 // 扩展字段走本校验,进行数据组装
                 // 扩展字段走本校验,进行数据组装
                 Set<String> extendFieldsSet = examStudentList.stream().map(ExamStudentCourseDto::getExtendFields).collect(Collectors.toSet());
                 Set<String> extendFieldsSet = examStudentList.stream().map(ExamStudentCourseDto::getExtendFields).collect(Collectors.toSet());
@@ -305,23 +328,29 @@ public class CreatePdfNewUtil {
                 basicPlate.add(basicMap);
                 basicPlate.add(basicMap);
             }
             }
         }
         }
-        Map<String, String> basicMap1 = new HashMap<>();
-        basicMap1.put("code", "paperCount");
-        basicMap1.put("name", "试卷数量");
-        basicMap1.put("value", examStudentList.size() + " + " + backupCount);
-        basicPlate.add(basicMap1);
+        if (!paperCount) {
+            Map<String, String> basicMap1 = new HashMap<>();
+            basicMap1.put("code", "paperCount");
+            basicMap1.put("name", "试卷数量");
+            basicMap1.put("value", examStudentList.size() + " + " + backupCount);
+            basicPlate.add(basicMap1);
+        }
 
 
-        Map<String, String> basicMap2 = new HashMap<>();
-        basicMap2.put("code", "examCount");
-        basicMap2.put("name", "应考人数");
-        basicMap2.put("value", String.valueOf(examStudentList.size()));
-        basicPlate.add(basicMap2);
+        if (!examCount) {
+            Map<String, String> basicMap2 = new HashMap<>();
+            basicMap2.put("code", "examCount");
+            basicMap2.put("name", "应考人数");
+            basicMap2.put("value", String.valueOf(examStudentList.size()));
+            basicPlate.add(basicMap2);
+        }
 
 
-        Map<String, String> basicMap3 = new HashMap<>();
-        basicMap3.put("code", "actualExamCount");
-        basicMap3.put("name", "实考人数");
-        basicMap3.put("value", "");
-        basicPlate.add(basicMap3);
+        if (!actualExamCount) {
+            Map<String, String> basicMap3 = new HashMap<>();
+            basicMap3.put("code", "actualExamCount");
+            basicMap3.put("name", "实考人数");
+            basicMap3.put("value", "");
+            basicPlate.add(basicMap3);
+        }
 
 
         pdfPackageDto.setBasicPlate(basicPlate);
         pdfPackageDto.setBasicPlate(basicPlate);
         printCommonService.saveAttachmentPackagePdf(pdfPackageDto, examDetail, printCount);
         printCommonService.saveAttachmentPackagePdf(pdfPackageDto, examDetail, printCount);
@@ -543,16 +572,6 @@ public class CreatePdfNewUtil {
         printCommonService.saveAttachmentSignPdf(pdfFillDto, examDetail, printCount, basicTemplate);
         printCommonService.saveAttachmentSignPdf(pdfFillDto, examDetail, printCount, basicTemplate);
     }
     }
 
 
-    /**
-     * 替换html通用模版中的条码信息
-     *
-     * @param content 题卡详细内容
-     */
-    public String resetHtmlTemplateBar(String content) {
-
-        return content;
-    }
-
     /**
     /**
      * 替换自定义题卡参数
      * 替换自定义题卡参数
      *
      *
@@ -764,26 +783,31 @@ public class CreatePdfNewUtil {
      * @throws Exception
      * @throws Exception
      */
      */
     @Transactional
     @Transactional
-    public BasicAttachment mergePdfSaveDb(String dirNamePaper,
-                                          String dirNameCardA3,
-                                          TBTaskPdf tbTaskPdf) throws Exception {
+    public void mergePdfSaveDb(String dirNamePaper,
+                               String dirNameCardA3,
+                               TBTaskPdf tbTaskPdf) throws Exception {
         ExamDetail examDetail = examDetailService.getById(tbTaskPdf.getId());
         ExamDetail examDetail = examDetailService.getById(tbTaskPdf.getId());
         BasicPrintConfig basicPrintConfig = basicPrintConfigService.getByExamId(tbTaskPdf.getExamId());
         BasicPrintConfig basicPrintConfig = basicPrintConfigService.getByExamId(tbTaskPdf.getExamId());
-        File localPaperPdfFile = null, localA3PdfCardFile = null;
-        BasicAttachment basicAttachment = null;
         // 试卷+题卡
         // 试卷+题卡
         if (StringUtils.isNotBlank(dirNamePaper)) {
         if (StringUtils.isNotBlank(dirNamePaper)) {
-            dirNamePaper = FileUtil.replaceSplit(dirNamePaper);
-            localPaperPdfFile = new File(dirNamePaper);
+            File localPaperPdfFile = new File(FileUtil.replaceSplit(dirNamePaper));
             examDetail.setPaperPages(PdfUtil.getPdfPages(localPaperPdfFile));
             examDetail.setPaperPages(PdfUtil.getPdfPages(localPaperPdfFile));
-            basicAttachment = basicAttachmentService.saveAttachmentPdf(dirNamePaper, tbTaskPdf.getCreateId());
+
+            String uploadFileName = PdfUtil.md5FileName(CreatePdfTypeEnum.PAPER.name() + tbTaskPdf.getId()) + SystemConstant.PDF_PREFIX;
+            FilePathVo filePathVo = fileUploadService.uploadFile(localPaperPdfFile, UploadFileEnum.PDF, uploadFileName);
+            BasicAttachment basicAttachment = new BasicAttachment(JSON.toJSONString(filePathVo), localPaperPdfFile.getName(), SystemConstant.PDF_PREFIX, new BigDecimal(localPaperPdfFile.length()), filePathVo.getMd5(), tbTaskPdf.getCreateId());
+            basicAttachmentService.save(basicAttachment);
             examDetail.setAttachmentId(basicAttachment.getId());
             examDetail.setAttachmentId(basicAttachment.getId());
         }
         }
         // 题卡
         // 题卡
         if (StringUtils.isNotBlank(dirNameCardA3)) {
         if (StringUtils.isNotBlank(dirNameCardA3)) {
-            localA3PdfCardFile = new File(FileUtil.replaceSplit(dirNameCardA3));
+            File localA3PdfCardFile = new File(FileUtil.replaceSplit(dirNameCardA3));
             examDetail.setCardPages(PdfUtil.getPdfPages(localA3PdfCardFile));
             examDetail.setCardPages(PdfUtil.getPdfPages(localA3PdfCardFile));
-            basicAttachment = basicAttachmentService.saveAttachmentPdf(dirNameCardA3, tbTaskPdf.getCreateId());
+
+            String uploadFileName = PdfUtil.md5FileName(CreatePdfTypeEnum.CARD_A3.name() + tbTaskPdf.getId()) + SystemConstant.PDF_PREFIX;
+            FilePathVo filePathVo = fileUploadService.uploadFile(localA3PdfCardFile, UploadFileEnum.PDF, uploadFileName);
+            BasicAttachment basicAttachment = new BasicAttachment(JSON.toJSONString(filePathVo), localA3PdfCardFile.getName(), SystemConstant.PDF_PREFIX, new BigDecimal(localA3PdfCardFile.length()), filePathVo.getMd5(), tbTaskPdf.getCreateId());
+            basicAttachmentService.save(basicAttachment);
             examDetail.setCardAttachmentId(basicAttachment.getId());
             examDetail.setCardAttachmentId(basicAttachment.getId());
         }
         }
         if (PrintMethodEnum.AUTO == basicPrintConfig.getPrintMethod()) {
         if (PrintMethodEnum.AUTO == basicPrintConfig.getPrintMethod()) {
@@ -799,7 +823,6 @@ public class CreatePdfNewUtil {
             examPrintPlan.setStatus(PrintPlanStatusEnum.PRINTING);
             examPrintPlan.setStatus(PrintPlanStatusEnum.PRINTING);
             examPrintPlanService.updateById(examPrintPlan);
             examPrintPlanService.updateById(examPrintPlan);
         }
         }
-        return basicAttachment;
     }
     }
 
 
     /**
     /**
@@ -840,7 +863,7 @@ public class CreatePdfNewUtil {
         // 将其它未匹配到值的参数,填入空值
         // 将其它未匹配到值的参数,填入空值
         studentHtml = studentHtml.replaceAll("\\$\\{[A-Za-z0-9]+\\}", "");
         studentHtml = studentHtml.replaceAll("\\$\\{[A-Za-z0-9]+\\}", "");
         //学生题卡
         //学生题卡
-        BasicAttachment examStudentAttachment = printCommonService.saveAttachmentPdfFromHtml(examStudent != null ? examStudent.getId() + "|" + examStudent.getStudentCode() : String.valueOf(System.currentTimeMillis()), studentHtml, userId, examStudentPdfList);
+        BasicAttachment examStudentAttachment = printCommonService.saveAttachmentPdfFromHtml(examStudent != null ? examStudent.getId() + "|" + examStudent.getStudentCode() : SystemConstant.getNanoId(), studentHtml, userId, examStudentPdfList);
         if (examStudent != null) {
         if (examStudent != null) {
             examStudent.setAttachmentId(examStudentAttachment.getId());
             examStudent.setAttachmentId(examStudentAttachment.getId());
         }
         }
@@ -1012,6 +1035,16 @@ public class CreatePdfNewUtil {
         }
         }
         // 替换考生变量参数
         // 替换考生变量参数
         if (Objects.nonNull(basicCardRule) && Objects.nonNull(basicCardRule.getExtendFields())) {
         if (Objects.nonNull(basicCardRule) && Objects.nonNull(basicCardRule.getExtendFields())) {
+            JSONArray jsonObjectRequired = (JSONArray) JSONArray.parse(basicCardRule.getRequiredFields());//必选字段
+            if (Objects.nonNull(jsonObjectRequired)) {
+                int i = 0;
+                while (i < jsonObjectRequired.size()) {
+                    JSONObject object = (JSONObject) jsonObjectRequired.get(i);
+                    htmlContent = htmlContent.replaceAll("\\$\\{" + object.get("code") + "\\}", "");
+                    i++;
+                }
+            }
+
             JSONArray jsonObjectExtend = (JSONArray) JSONArray.parse(basicCardRule.getExtendFields());//扩展字段
             JSONArray jsonObjectExtend = (JSONArray) JSONArray.parse(basicCardRule.getExtendFields());//扩展字段
             if (Objects.nonNull(jsonObjectExtend)) {
             if (Objects.nonNull(jsonObjectExtend)) {
                 int i = 0;
                 int i = 0;

+ 0 - 109
distributed-print-business/src/main/resources/db/log/脚本-caozx.sql

@@ -1,109 +0,0 @@
-CREATE TABLE `course_target` (
-    `id` BIGINT(20) NOT NULL COMMENT 'id',
-    `school_id` BIGINT(20) NOT NULL COMMENT '学校id',
-    `exam_id` BIGINT(20) NOT NULL COMMENT '考试id',
-    `course_code` VARCHAR(20) NOT NULL COMMENT '课程编号',
-    `target_name` VARCHAR(50) NULL COMMENT '课程目标',
-    `target_content` MEDIUMTEXT NULL COMMENT '毕业要求指标',
-    `degree_requirement` VARCHAR(255) NULL COMMENT '毕业要求',
-    `total_weight` DECIMAL(6 , 2 ) NULL COMMENT '课程目标整体权重',
-    `create_id` BIGINT(20) NULL COMMENT '创建人',
-    `create_time` BIGINT(20) NULL COMMENT '创建时间',
-    `update_id` BIGINT(20) NULL COMMENT '更新人',
-    `update_time` BIGINT(20) NULL COMMENT '更新时间',
-    PRIMARY KEY (`id`)
-)  ENGINE=INNODB DEFAULT CHARACTER SET=UTF8MB4 COMMENT='课程目标表';
-
-ALTER TABLE `course_target` 
-ADD UNIQUE INDEX `course_target_unique` (`school_id` ASC,`exam_id` ASC, `course_code` ASC, `target_name` ASC) VISIBLE;
-;
-
-CREATE TABLE `course_evaluation` (
-    `id` BIGINT(20) NOT NULL COMMENT 'id',
-    `school_id` BIGINT(20) NOT NULL COMMENT '学校id',
-    `exam_id` BIGINT(20) NOT NULL COMMENT '考试id',
-    `course_code` VARCHAR(20) NOT NULL COMMENT '课程编号',
-    `evaluation` VARCHAR(255) NOT NULL COMMENT '评价方式',
-    `evaluation_desc` VARCHAR(255) NULL COMMENT '评价方式描述',
-    `create_id` BIGINT(20) NULL COMMENT '创建人id',
-    `create_time` BIGINT(20) NULL COMMENT '创建时间',
-    `update_id` BIGINT(20) NULL COMMENT '更新人id',
-    `update_time` BIGINT(20) NULL COMMENT '更新时间',
-    PRIMARY KEY (`id`)
-)  ENGINE=INNODB DEFAULT CHARACTER SET=UTF8MB4 COMMENT='课程评价方式表';
-
-ALTER TABLE `course_evaluation` 
-ADD UNIQUE INDEX `course_evaluation_unique` (`school_id` ASC, `exam_id` ASC, `course_code` ASC, `evaluation` ASC) VISIBLE;
-;
-
-CREATE TABLE `course_weight` (
-  `id` BIGINT(20) NOT NULL COMMENT 'id',
-  `school_id` BIGINT(20) NOT NULL COMMENT '学校id',
-  `exam_id` BIGINT(20) NOT NULL COMMENT '考试id',
-  `course_code` VARCHAR(20) NOT NULL COMMENT '课程编号',
-  `target_id` BIGINT(20) NOT NULL COMMENT '课程目标表id',
-  `evaluation_id` BIGINT(20) NOT NULL COMMENT '课程评价表id',
-  `enable` TINYINT(1) NOT NULL DEFAULT '1' COMMENT '使用状态 1:使用 0:未使用',
-  `weight` DECIMAL(6,2) NULL COMMENT '权重',
-  `target_score` DECIMAL(6,2) NULL COMMENT '目标分值',
-  `create_id` BIGINT(20) NULL COMMENT '创建人',
-  `create_time` BIGINT(20) NULL COMMENT '创建时间',
-  `update_id` BIGINT(20) NULL COMMENT '更新人',
-  `update_time` BIGINT(20) NULL COMMENT '更新时间',
-  PRIMARY KEY (`id`))
-ENGINE = InnoDB
-DEFAULT CHARACTER SET = utf8mb4
-COMMENT = '课程权重设置表';
-
-ALTER TABLE `course_weight` 
-ADD UNIQUE INDEX `course_weight_unique` (`school_id` ASC, `exam_id` ASC, `course_code` ASC, `target_id` ASC, `evaluation_id` ASC) VISIBLE;
-;
-
-CREATE TABLE `basic_teach_clazz` (
-  `id` BIGINT(20)NOT NULL COMMENT 'id',
-  `school_id` BIGINT(20)NOT NULL COMMENT '学校id',
-  `exam_id` BIGINT(20)NOT NULL COMMENT '考试id',
-  `course_code` VARCHAR(20) NOT NULL COMMENT '课程编号',
-  `clazz_name` VARCHAR(50) NOT NULL COMMENT '教学班名称',
-  `create_id` BIGINT(20)NULL COMMENT '创建人',
-  `create_time` BIGINT(20)NULL COMMENT '创建时间',
-  `update_id` BIGINT(20)NULL COMMENT '更新人',
-  `update_time` BIGINT(20)NULL COMMENT '更新时间',
-  PRIMARY KEY (`id`))
-ENGINE = InnoDB
-DEFAULT CHARACTER SET = utf8mb4
-COMMENT = '基础教学班表';
-
-ALTER TABLE `basic_teach_clazz` 
-ADD UNIQUE INDEX `basic_teach_clazz_unique` (`school_id` ASC, `exam_id` ASC, `clazz_name` ASC) VISIBLE;
-;
-
-CREATE TABLE `basic_exam_student` (
-    `id` BIGINT(20) NOT NULL COMMENT 'id',
-    `school_id` BIGINT(20) NOT NULL COMMENT '学校id',
-    `semester_id` BIGINT(20) NOT NULL COMMENT '学期id',
-    `exam_id` BIGINT(20) NOT NULL COMMENT '考试id',
-    `course_code` VARCHAR(20) NOT NULL COMMENT '课程编号',
-    `clazz_id` BIGINT(20) NOT NULL COMMENT '教学班id(basic_teach_clazz)',
-    `paper_number` VARCHAR(30) DEFAULT NULL COMMENT '试卷编号',
-    `student_name` VARCHAR(50) NOT NULL COMMENT '姓名',
-    `student_code` VARCHAR(50) NOT NULL COMMENT '学号',
-    `college` VARCHAR(50) NULL COMMENT '学院',
-    `major` VARCHAR(50) NULL COMMENT '专业',
-    `teacher_id` BIGINT(20) NULL COMMENT '任课教师id',
-    `exam_start_time` BIGINT(20) DEFAULT NULL COMMENT '考试开始时间',
-    `exam_end_time` BIGINT(20) DEFAULT NULL COMMENT '考试结束时间',
-    `exam_place` VARCHAR(50) DEFAULT NULL COMMENT '考点',
-    `exam_room` VARCHAR(50) DEFAULT NULL COMMENT '考场',
-    `create_id` BIGINT(20) NULL COMMENT '创建人',
-    `create_time` BIGINT(20) NULL COMMENT '创建时间',
-    `update_id` BIGINT(20) NULL COMMENT '更新人',
-    `update_time` BIGINT(20) NULL COMMENT '更新时间',
-    PRIMARY KEY (`id`)
-)  ENGINE=INNODB DEFAULT CHARACTER SET=UTF8MB4 COMMENT='考生字典表';
-
-ALTER TABLE `basic_exam_student` 
-ADD UNIQUE INDEX `basic_exam_student_unique` (`school_id` ASC, `exam_id` ASC, `course_code` ASC, `student_code` ASC) VISIBLE;
-;
-
-

+ 141 - 1
distributed-print/install/mysql/upgrade/3.3.1.sql

@@ -218,4 +218,144 @@ CREATE TABLE `t_r_exam_student` (
 ALTER TABLE t_r_basic_info ADD credit varchar(50) NULL COMMENT '学分';
 ALTER TABLE t_r_basic_info ADD credit varchar(50) NULL COMMENT '学分';
 ALTER TABLE t_r_basic_info CHANGE credit credit varchar(50) NULL COMMENT '学分' AFTER course_type;
 ALTER TABLE t_r_basic_info CHANGE credit credit varchar(50) NULL COMMENT '学分' AFTER course_type;
 ALTER TABLE t_r_basic_info ADD period varchar(50) NULL COMMENT '学时';
 ALTER TABLE t_r_basic_info ADD period varchar(50) NULL COMMENT '学时';
-ALTER TABLE t_r_basic_info CHANGE period period varchar(50) NULL COMMENT '学时' AFTER credit;
+ALTER TABLE t_r_basic_info CHANGE period period varchar(50) NULL COMMENT '学时' AFTER credit;
+
+DROP TABLE IF EXISTS `exam_task_assign_paper_type`;
+CREATE TABLE `exam_task_assign_paper_type` (
+           `exam_id` bigint NOT NULL COMMENT '考试ID',
+           `paper_number` varchar(100) NOT NULL COMMENT '试卷编号',
+           `exam_start_time` bigint NOT NULL COMMENT '考试时间(开始)',
+           `exam_end_time` bigint NOT NULL COMMENT '考试时间(结束)',
+           `paper_type` varchar(45) DEFAULT NULL COMMENT '卷型',
+           `assign_mode` varchar(10) DEFAULT NULL COMMENT '分配方式:MANUAL-手动关联,AUTO-自动分配',
+           PRIMARY KEY (`exam_id`,`paper_number`,`exam_start_time`,`exam_end_time`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
+
+DROP TABLE IF EXISTS `t_b_task_pdf`;
+CREATE TABLE `t_b_task_pdf` (
+            `id` bigint NOT NULL COMMENT '主键(与exam_detail表id一致)',
+            `school_id` bigint NOT NULL COMMENT '学校id',
+            `semester_id` bigint DEFAULT NULL COMMENT '学期ID',
+            `exam_id` bigint DEFAULT NULL COMMENT '考试ID',
+            `print_plan_id` bigint NOT NULL COMMENT '印刷计划id',
+            `course_name_code` mediumtext COMMENT '课程名称',
+            `paper_number` mediumtext COMMENT '试卷编号',
+            `create_type` varchar(45) DEFAULT NULL COMMENT '生成pdf类型:ALL("全部"),PAPER("试卷"),CARD_A3("题卡"),SIGN("签到表"),PACKAGE("卷袋贴"),CHECK_IN("登记表")',
+            `status` varchar(30) NOT NULL COMMENT '任务状态,INIT:未开始,RUNNING:进行中,FINISH:已完成',
+            `summary` mediumtext COMMENT '实时摘要信息',
+            `result` varchar(30) DEFAULT NULL COMMENT '数据结果,SUCCESS:成功,ERROR:失败',
+            `create_id` bigint DEFAULT NULL COMMENT '创建人',
+            `create_time` bigint DEFAULT NULL COMMENT '创建时间',
+            `update_id` bigint DEFAULT NULL COMMENT '更新人',
+            `update_time` bigint DEFAULT NULL COMMENT '更新时间',
+            `remark` mediumtext COMMENT '备注',
+            PRIMARY KEY (`id`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='pdf生成日志表';
+
+CREATE TABLE `course_target` (
+                                 `id` BIGINT(20) NOT NULL COMMENT 'id',
+                                 `school_id` BIGINT(20) NOT NULL COMMENT '学校id',
+                                 `exam_id` BIGINT(20) NOT NULL COMMENT '考试id',
+                                 `course_code` VARCHAR(20) NOT NULL COMMENT '课程编号',
+                                 `target_name` VARCHAR(50) NULL COMMENT '课程目标',
+                                 `target_content` MEDIUMTEXT NULL COMMENT '毕业要求指标',
+                                 `degree_requirement` VARCHAR(255) NULL COMMENT '毕业要求',
+                                 `total_weight` DECIMAL(6 , 2 ) NULL COMMENT '课程目标整体权重',
+                                 `create_id` BIGINT(20) NULL COMMENT '创建人',
+                                 `create_time` BIGINT(20) NULL COMMENT '创建时间',
+                                 `update_id` BIGINT(20) NULL COMMENT '更新人',
+                                 `update_time` BIGINT(20) NULL COMMENT '更新时间',
+                                 PRIMARY KEY (`id`)
+)  ENGINE=INNODB DEFAULT CHARACTER SET=UTF8MB4 COMMENT='课程目标表';
+
+ALTER TABLE `course_target`
+    ADD UNIQUE INDEX `course_target_unique` (`school_id` ASC,`exam_id` ASC, `course_code` ASC, `target_name` ASC) VISIBLE;
+;
+
+CREATE TABLE `course_evaluation` (
+                                     `id` BIGINT(20) NOT NULL COMMENT 'id',
+                                     `school_id` BIGINT(20) NOT NULL COMMENT '学校id',
+                                     `exam_id` BIGINT(20) NOT NULL COMMENT '考试id',
+                                     `course_code` VARCHAR(20) NOT NULL COMMENT '课程编号',
+                                     `evaluation` VARCHAR(255) NOT NULL COMMENT '评价方式',
+                                     `evaluation_desc` VARCHAR(255) NULL COMMENT '评价方式描述',
+                                     `create_id` BIGINT(20) NULL COMMENT '创建人id',
+                                     `create_time` BIGINT(20) NULL COMMENT '创建时间',
+                                     `update_id` BIGINT(20) NULL COMMENT '更新人id',
+                                     `update_time` BIGINT(20) NULL COMMENT '更新时间',
+                                     PRIMARY KEY (`id`)
+)  ENGINE=INNODB DEFAULT CHARACTER SET=UTF8MB4 COMMENT='课程评价方式表';
+
+ALTER TABLE `course_evaluation`
+    ADD UNIQUE INDEX `course_evaluation_unique` (`school_id` ASC, `exam_id` ASC, `course_code` ASC, `evaluation` ASC) VISIBLE;
+;
+
+CREATE TABLE `course_weight` (
+                                 `id` BIGINT(20) NOT NULL COMMENT 'id',
+                                 `school_id` BIGINT(20) NOT NULL COMMENT '学校id',
+                                 `exam_id` BIGINT(20) NOT NULL COMMENT '考试id',
+                                 `course_code` VARCHAR(20) NOT NULL COMMENT '课程编号',
+                                 `target_id` BIGINT(20) NOT NULL COMMENT '课程目标表id',
+                                 `evaluation_id` BIGINT(20) NOT NULL COMMENT '课程评价表id',
+                                 `enable` TINYINT(1) NOT NULL DEFAULT '1' COMMENT '使用状态 1:使用 0:未使用',
+                                 `weight` DECIMAL(6,2) NULL COMMENT '权重',
+                                 `target_score` DECIMAL(6,2) NULL COMMENT '目标分值',
+                                 `create_id` BIGINT(20) NULL COMMENT '创建人',
+                                 `create_time` BIGINT(20) NULL COMMENT '创建时间',
+                                 `update_id` BIGINT(20) NULL COMMENT '更新人',
+                                 `update_time` BIGINT(20) NULL COMMENT '更新时间',
+                                 PRIMARY KEY (`id`))
+    ENGINE = InnoDB
+DEFAULT CHARACTER SET = utf8mb4
+COMMENT = '课程权重设置表';
+
+ALTER TABLE `course_weight`
+    ADD UNIQUE INDEX `course_weight_unique` (`school_id` ASC, `exam_id` ASC, `course_code` ASC, `target_id` ASC, `evaluation_id` ASC) VISIBLE;
+;
+
+CREATE TABLE `basic_teach_clazz` (
+                                     `id` BIGINT(20)NOT NULL COMMENT 'id',
+                                     `school_id` BIGINT(20)NOT NULL COMMENT '学校id',
+                                     `exam_id` BIGINT(20)NOT NULL COMMENT '考试id',
+                                     `course_code` VARCHAR(20) NOT NULL COMMENT '课程编号',
+                                     `clazz_name` VARCHAR(50) NOT NULL COMMENT '教学班名称',
+                                     `create_id` BIGINT(20)NULL COMMENT '创建人',
+                                     `create_time` BIGINT(20)NULL COMMENT '创建时间',
+                                     `update_id` BIGINT(20)NULL COMMENT '更新人',
+                                     `update_time` BIGINT(20)NULL COMMENT '更新时间',
+                                     PRIMARY KEY (`id`))
+    ENGINE = InnoDB
+DEFAULT CHARACTER SET = utf8mb4
+COMMENT = '基础教学班表';
+
+ALTER TABLE `basic_teach_clazz`
+    ADD UNIQUE INDEX `basic_teach_clazz_unique` (`school_id` ASC, `exam_id` ASC, `clazz_name` ASC) VISIBLE;
+;
+
+CREATE TABLE `basic_exam_student` (
+                                      `id` BIGINT(20) NOT NULL COMMENT 'id',
+                                      `school_id` BIGINT(20) NOT NULL COMMENT '学校id',
+                                      `semester_id` BIGINT(20) NOT NULL COMMENT '学期id',
+                                      `exam_id` BIGINT(20) NOT NULL COMMENT '考试id',
+                                      `course_code` VARCHAR(20) NOT NULL COMMENT '课程编号',
+                                      `clazz_id` BIGINT(20) NOT NULL COMMENT '教学班id(basic_teach_clazz)',
+                                      `paper_number` VARCHAR(30) DEFAULT NULL COMMENT '试卷编号',
+                                      `student_name` VARCHAR(50) NOT NULL COMMENT '姓名',
+                                      `student_code` VARCHAR(50) NOT NULL COMMENT '学号',
+                                      `college` VARCHAR(50) NULL COMMENT '学院',
+                                      `major` VARCHAR(50) NULL COMMENT '专业',
+                                      `teacher_id` BIGINT(20) NULL COMMENT '任课教师id',
+                                      `exam_start_time` BIGINT(20) DEFAULT NULL COMMENT '考试开始时间',
+                                      `exam_end_time` BIGINT(20) DEFAULT NULL COMMENT '考试结束时间',
+                                      `exam_place` VARCHAR(50) DEFAULT NULL COMMENT '考点',
+                                      `exam_room` VARCHAR(50) DEFAULT NULL COMMENT '考场',
+                                      `create_id` BIGINT(20) NULL COMMENT '创建人',
+                                      `create_time` BIGINT(20) NULL COMMENT '创建时间',
+                                      `update_id` BIGINT(20) NULL COMMENT '更新人',
+                                      `update_time` BIGINT(20) NULL COMMENT '更新时间',
+                                      PRIMARY KEY (`id`)
+)  ENGINE=INNODB DEFAULT CHARACTER SET=UTF8MB4 COMMENT='考生字典表';
+
+ALTER TABLE `basic_exam_student`
+    ADD UNIQUE INDEX `basic_exam_student_unique` (`school_id` ASC, `exam_id` ASC, `course_code` ASC, `student_code` ASC) VISIBLE;
+;

+ 2 - 3
distributed-print/src/main/java/com/qmth/distributed/print/api/TBTaskController.java

@@ -122,9 +122,8 @@ public class TBTaskController {
     @ApiResponses({@ApiResponse(code = 200, message = "重新生成pdf", response = EditResult.class)})
     @ApiResponses({@ApiResponse(code = 200, message = "重新生成pdf", response = EditResult.class)})
     public Result resetCreatePdf(@ApiParam(value = "任务id", required = true) @RequestParam Long id,
     public Result resetCreatePdf(@ApiParam(value = "任务id", required = true) @RequestParam Long id,
                                  @ApiParam(value = "pdf生成类型") @RequestParam(defaultValue = "ALL") CreatePdfTypeEnum type) {
                                  @ApiParam(value = "pdf生成类型") @RequestParam(defaultValue = "ALL") CreatePdfTypeEnum type) {
-        TBTask tbTask = tbTaskService.getById(id);
-        examDetailService.resetExamDetail(tbTask.getEntityId(), type, ExamDetailStatusEnum.NEW, false);
-        tbTaskService.resetCreatePdf(tbTask, type);
+        examDetailService.resetExamDetail(id, type, ExamDetailStatusEnum.NEW, false);
+        tbTaskPdfService.resetRunningCreatePdf(id, type);
         return ResultUtil.ok(new EditResult());
         return ResultUtil.ok(new EditResult());
     }
     }
 
 

+ 1 - 1
distributed-print/src/main/java/com/qmth/distributed/print/api/WorkController.java

@@ -93,7 +93,7 @@ public class WorkController {
         Long schoolId = Long.parseLong(ServletUtil.getRequestHeaderSchoolId().toString());
         Long schoolId = Long.parseLong(ServletUtil.getRequestHeaderSchoolId().toString());
         IPage<MarkSettingDto> markSettingDtoIPage = markPaperService.listPaperSetting(null, null, null, false, pageNumber, pageSize);
         IPage<MarkSettingDto> markSettingDtoIPage = markPaperService.listPaperSetting(null, null, null, false, pageNumber, pageSize);
         for (MarkSettingDto record : markSettingDtoIPage.getRecords()) {
         for (MarkSettingDto record : markSettingDtoIPage.getRecords()) {
-            ExamTaskDetail examTaskDetail = examTaskDetailService.findByExamIdAndCourseCodeAndPaperNumber(schoolId, record.getExamId(), record.getCourseCode(), record.getPaperNumber());
+            ExamTaskDetail examTaskDetail = examTaskDetailService.findByExamIdAndCourseCodeAndPaperNumber(record.getExamId(), record.getCourseCode(), record.getPaperNumber());
             List<PaperInfoVo> paperInfoVos = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetail.getPaperAttachmentIds(), record.getPaperType());
             List<PaperInfoVo> paperInfoVos = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetail.getPaperAttachmentIds(), record.getPaperType());
             if (CollectionUtils.isNotEmpty(paperInfoVos)) {
             if (CollectionUtils.isNotEmpty(paperInfoVos)) {
                 record.setCardId(Long.valueOf(paperInfoVos.get(0).getCardId()));
                 record.setCardId(Long.valueOf(paperInfoVos.get(0).getCardId()));

+ 1 - 1
distributed-print/src/main/java/com/qmth/distributed/print/api/mark/MarkSettingController.java

@@ -65,7 +65,7 @@ public class MarkSettingController {
         Long schoolId = Long.parseLong(ServletUtil.getRequestHeaderSchoolId().toString());
         Long schoolId = Long.parseLong(ServletUtil.getRequestHeaderSchoolId().toString());
         IPage<MarkSettingDto> markSettingDtoIPage = markPaperService.listPaperSetting(examId, courseCode, paperNumber, groupStatus, pageNumber, pageSize);
         IPage<MarkSettingDto> markSettingDtoIPage = markPaperService.listPaperSetting(examId, courseCode, paperNumber, groupStatus, pageNumber, pageSize);
         for (MarkSettingDto record : markSettingDtoIPage.getRecords()) {
         for (MarkSettingDto record : markSettingDtoIPage.getRecords()) {
-            ExamTaskDetail examTaskDetail = examTaskDetailService.findByExamIdAndCourseCodeAndPaperNumber(schoolId, record.getExamId(), record.getCourseCode(), record.getPaperNumber());
+            ExamTaskDetail examTaskDetail = examTaskDetailService.findByExamIdAndCourseCodeAndPaperNumber(record.getExamId(), record.getCourseCode(), record.getPaperNumber());
             List<PaperInfoVo> paperInfoVos = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetail.getPaperAttachmentIds(), record.getPaperType());
             List<PaperInfoVo> paperInfoVos = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetail.getPaperAttachmentIds(), record.getPaperType());
             if (CollectionUtils.isNotEmpty(paperInfoVos)) {
             if (CollectionUtils.isNotEmpty(paperInfoVos)) {
                 record.setCardId(Long.valueOf(paperInfoVos.get(0).getCardId()));
                 record.setCardId(Long.valueOf(paperInfoVos.get(0).getCardId()));

+ 0 - 2
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/TBTaskService.java

@@ -141,6 +141,4 @@ public interface TBTaskService extends IService<TBTask> {
     public TBTask saveTaskCommon(BasicAttachment basicAttachment, TaskTypeEnum taskTypeEnum, Map map, SysUser sysUser);
     public TBTask saveTaskCommon(BasicAttachment basicAttachment, TaskTypeEnum taskTypeEnum, Map map, SysUser sysUser);
 
 
     IPage<TaskListResult> queryResult(Page<Map> iPage, Long semesterId, Long examId, String courseCode, String paperNumber, TaskStatusEnum status, TaskTypeEnum type, TaskResultEnum result);
     IPage<TaskListResult> queryResult(Page<Map> iPage, Long semesterId, Long examId, String courseCode, String paperNumber, TaskStatusEnum status, TaskTypeEnum type, TaskResultEnum result);
-
-    void resetCreatePdf(TBTask tbTask, CreatePdfTypeEnum type);
 }
 }

+ 1 - 1
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/BasicAttachmentServiceImpl.java

@@ -66,7 +66,7 @@ public class BasicAttachmentServiceImpl extends ServiceImpl<BasicAttachmentMappe
      */
      */
     @Override
     @Override
     @Transactional
     @Transactional
-    public BasicAttachment saveAttachmentPdf(String dirName, Long userId) throws IOException {
+    public BasicAttachment saveAttachmentPdf(String dirName, Long userId) {
         BasicAttachment basicAttachment = null;
         BasicAttachment basicAttachment = null;
         try {
         try {
             File pdfFile = new File(dirName);
             File pdfFile = new File(dirName);

+ 0 - 12
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/TBTaskServiceImpl.java

@@ -277,16 +277,4 @@ public class TBTaskServiceImpl extends ServiceImpl<TBTaskMapper, TBTask> impleme
         DataPermissionRule dpr = basicRoleDataPermissionService.findDataPermission(schoolId, sysUser.getId(), ServletUtil.getRequest().getServletPath());
         DataPermissionRule dpr = basicRoleDataPermissionService.findDataPermission(schoolId, sysUser.getId(), ServletUtil.getRequest().getServletPath());
         return tbTaskMapper.query(iPage, schoolId, semesterId, examId, courseCode, paperNumber, null, Objects.nonNull(status) ? status.name() : null, Objects.nonNull(type) ? type.name() : null, Objects.nonNull(result) ? result.name() : null, dpr);
         return tbTaskMapper.query(iPage, schoolId, semesterId, examId, courseCode, paperNumber, null, Objects.nonNull(status) ? status.name() : null, Objects.nonNull(type) ? type.name() : null, Objects.nonNull(result) ? result.name() : null, dpr);
     }
     }
-
-    @Override
-    public void resetCreatePdf(TBTask tbTask, CreatePdfTypeEnum type) {
-        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
-        Map<String, Object> map = new HashMap<>();
-        map.computeIfAbsent(SystemConstant.TASK, v -> tbTask);
-        map.computeIfAbsent(SystemConstant.USER, v -> sysUser);
-        map.putIfAbsent(SystemConstant.MANUAL, true);
-        map.putIfAbsent(SystemConstant.CREATE_PDF_TYPE, type);
-        MqDto mqDto = new MqDto(MqTagEnum.PDF.getCode(), map, String.valueOf(tbTask.getId()));
-        redisUtil.sendMessage(mqDto.getTopic(), mqDto);
-    }
 }
 }

+ 1 - 1
teachcloud-task/src/main/java/com/qmth/teachcloud/task/service/impl/PrintFinishServiceImpl.java

@@ -145,7 +145,7 @@ public class PrintFinishServiceImpl implements PrintFinishService {
     @Override
     @Override
     public void insertScanAnswerCardAndMarkQuestion(ExamDetailCourseInitMarkDto dto, String paperType) {
     public void insertScanAnswerCardAndMarkQuestion(ExamDetailCourseInitMarkDto dto, String paperType) {
         if (StringUtils.isNotBlank(paperType)) {
         if (StringUtils.isNotBlank(paperType)) {
-            ExamTaskDetail examTaskDetail = examTaskDetailService.findByExamIdAndCourseCodeAndPaperNumber(dto.getSchoolId(), dto.getExamId(), dto.getCourseCode(), dto.getPaperNumber());
+            ExamTaskDetail examTaskDetail = examTaskDetailService.findByExamIdAndCourseCodeAndPaperNumber(dto.getExamId(), dto.getCourseCode(), dto.getPaperNumber());
             List<PaperInfoVo> paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetail.getPaperAttachmentIds(), paperType);
             List<PaperInfoVo> paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetail.getPaperAttachmentIds(), paperType);
             for (PaperInfoVo paperInfoVo : paperInfoVoList) {
             for (PaperInfoVo paperInfoVo : paperInfoVoList) {
                 ExamCard examCard = examCardService.getById(paperInfoVo.getCardId());
                 ExamCard examCard = examCardService.getById(paperInfoVo.getCardId());