Browse Source

3.2.7 bug修改

xiaofei 1 năm trước cách đây
mục cha
commit
dfbde0d900

+ 0 - 8
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamTaskMapper.java

@@ -47,14 +47,6 @@ public interface ExamTaskMapper extends BaseMapper<ExamTask> {
 
     List<ClientExamTaskDto> listClientExamTaskPage(@Param("schoolId") Long schoolId, @Param("semesterId") Long semesterId, @Param("examId") Long examId, @Param("machineCode") String machineCode, @Param("printPlanId") Long printPlanId, @Param("courseCode") String courseCode, @Param("paperNumber") String paperNumber, @Param("isTry") Boolean isTry, @Param("isPass") Boolean isPass, @Param("orgId") Long orgId, @Param("printPlanStatus") String printPlanStatus, @Param("examDetailStatus") String[] examDetailStatus);
 
-    /**
-     * 查询审核样品
-     *
-     * @param examTaskId 命题任务id
-     * @return 结果
-     */
-    List<ReviewSampleDto> listReviewSampleInfoByExamTaskId(@Param("examTaskId") Long examTaskId);
-
     List<ExamTask> listExamTaskExpire(@Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("status") String[] status);
 
     List<ExamTask> listExamTaskAuditExpire(@Param("startTime") Long startTime, @Param("endTime") Long endTime);

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

@@ -91,14 +91,6 @@ public interface ExamTaskService extends IService<ExamTask> {
      */
     void checkDataByExamination(Long printPlanId, List<Long> examDetailIdList, SysUser user) throws IOException;
 
-    /**
-     * 根据命题任务id从('exam_task_detail'表和'exam_task_paper_log'表查找审核样品信息)
-     *
-     * @param examTaskId 命题任务主键
-     * @return 命题任务信息
-     */
-    ReviewSampleDto findReviewSampleInfoByExamTaskId(Long examTaskId);
-
     List<ExamTaskDetailDto> listTaskPaper(Long semesterId, Long examId, String courseCode, String paperNumber, Long cardRuleId, MakeMethodEnum makeMethod, Long startTime, Long endTime);
 
     TBTask taskDownloadPdf(Long semesterId, Long examId, String courseCode, String paperNumber, Long cardRuleId, MakeMethodEnum makeMethod, Long startTime, Long endTime);

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

@@ -116,6 +116,9 @@ public class ExamDetailServiceImpl extends ServiceImpl<ExamDetailMapper, ExamDet
     @Resource
     ExamTaskService examTaskService;
 
+    @Resource
+    ExamTaskDetailService examTaskDetailService;
+
     @Resource
     RedisUtil redisUtil;
 
@@ -369,6 +372,32 @@ public class ExamDetailServiceImpl extends ServiceImpl<ExamDetailMapper, ExamDet
             String time = String.valueOf(dateMap.get("time"));
             examinationResult.setExamDate(date);
             examinationResult.setExamTime(time);
+
+            Set<String> stringSet = new HashSet<>();
+            for (String id : examinationResult.getExamDetailCourseIds().split(",")) {
+                ExamDetailCourse examDetailCourse = examDetailCourseService.getById(id);
+                if (StringUtils.isNotBlank(examDetailCourse.getPaperType())) {
+                    ExamTask examTask = examTaskService.getByCourseCodeAndPaperNumber(schoolId, examinationResult.getExamId(), examDetailCourse.getCourseCode(), examDetailCourse.getPaperNumber());
+                    ExamTaskDetail examTaskDetail = examTaskDetailService.getByExamTaskId(examTask.getId());
+                    String paperType = examDetailCourse.getPaperType();
+                    List<String> paperTypes = Arrays.asList(paperType.split(","));
+                    List<JSONObject> paperAttachments = JSON.parseArray(examTaskDetail.getPaperAttachmentIds(), JSONObject.class).stream().filter(m -> paperTypes.contains(m.getString("name"))).collect(Collectors.toList());
+                    for (JSONObject jsonObject : paperAttachments) {
+                        String cardTypeString = jsonObject.getString("cardType");
+                        String createMethod = jsonObject.getString("createMethod");
+                        if (cardTypeString.equals(CardTypeEnum.GENERIC.name()) && StringUtils.isNotBlank(createMethod) && createMethod.equals(CardCreateMethodEnum.UPLOAD.name())) {
+                            stringSet.add(SyncCardTypeEnum.GENERIC.getDesc());
+                        } else {
+                            stringSet.add(SyncCardTypeEnum.CUSTOM.getDesc());
+                        }
+                    }
+                }
+            }
+            if (stringSet.size() > 0) {
+                examinationResult.setCardType(String.join(",", stringSet));
+            } else {
+                examinationResult.setCardType("-");
+            }
         }
         return page;
     }

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

@@ -1075,7 +1075,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
                 String paperNumber = examDetailCourse.getPaperNumber();
                 Long schoolId = examDetailCourse.getSchoolId();
 
-                List<ExamTask> examTaskList = examTaskMapper.findExamTaskByFlowStatus(schoolId, examPrintPlan.getExamId(), courseCode, paperNumber, FlowStatusEnum.FINISH.name());
+//                List<ExamTask> examTaskList = examTaskMapper.findExamTaskByFlowStatus(schoolId, examPrintPlan.getExamId(), courseCode, paperNumber, FlowStatusEnum.FINISH.name());
 //                if (CollectionUtils.isEmpty(examTaskList)) {
 //                    stringSet.add(String.format("课程[%s(%s)],试卷编号[%s]的任务未创建或者未审核通过", courseName, courseCode, paperNumber));
 //                }
@@ -1114,15 +1114,6 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
         }
     }
 
-    @Override
-    public ReviewSampleDto findReviewSampleInfoByExamTaskId(Long examTaskId) {
-        List<ReviewSampleDto> reviewSampleDtoList = examTaskMapper.listReviewSampleInfoByExamTaskId(examTaskId);
-        if (reviewSampleDtoList.size() != 1) {
-            throw ExceptionResultEnum.ERROR.exception("不能找到所选命题任务[" + examTaskId + "]的审核样本信息");
-        }
-        return reviewSampleDtoList.get(0);
-    }
-
     @Override
     public List<ExamTaskDetailDto> listTaskPaper(Long semesterId, Long examId, String courseCode, String paperNumber, Long cardRuleId, MakeMethodEnum makeMethod, Long startTime, Long
             endTime) {

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

@@ -297,7 +297,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                 CreatePdfCacheUtil.setPaperType(key, paperType);
             } else {
 //                if (StringUtils.isBlank(examDetailCourse.getPaperType())) {
-                    paperType = createPdfUtil.getPaperType(examPrintPlan.getDrawRule(), examTaskDetail, key);
+                paperType = createPdfUtil.getPaperType(examPrintPlan.getDrawRule(), examTaskDetail, key);
 //                } else {
 //                    paperType = examDetailCourse.getPaperType();
 //                }
@@ -1145,7 +1145,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
         File zipFile = null;
         String zipLocalRootPath = null;
         try {
-            int count = 0;
             TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
             Long time = System.currentTimeMillis();
             boolean oss = dictionaryConfig.sysDomain().isOss();
@@ -1162,123 +1161,99 @@ public class TaskLogicServiceImpl implements TaskLogicService {
 
             // 跟文件路径
             Long[] ids = (Long[]) map.get("ids");
+            int count = 0;
             for (Long id : ids) {
                 ExamTask examTask = examTaskService.getById(id);
                 if (Objects.isNull(examTask)) {
-                    throw ExceptionResultEnum.ERROR.exception("未找到命题任务");
+                    throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s]的命题任务不存在", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber()));
                 }
                 String examTaskSign = examTask.getCourseName() + SystemConstant.HYPHEN + examTask.getPaperNumber();
                 String firstPath = zipLocalRootPath + File.separator + examTaskSign;
-                ReviewSampleDto reviewSampleDto = examTaskService.findReviewSampleInfoByExamTaskId(id);
+                ExamTaskDetail examTaskDetail = examTaskDetailService.getByExamTaskId(id);
+                if (examTaskDetail == null) {
+                    throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s]的" + ExceptionResultEnum.EXAM_TASK_NOT_SUBMIT.getMessage(), examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber()));
+                }
 
                 // 收集处理试卷和题卡
-                List<ExamPaperInfoDto> paperInfoDtoList = JSONObject.parseArray(reviewSampleDto.getPaperAttachmentIds(), ExamPaperInfoDto.class);
+                List<ExamPaperInfoDto> paperInfoDtoList = JSONObject.parseArray(examTaskDetail.getPaperAttachmentIds(), ExamPaperInfoDto.class);
                 if (Objects.isNull(paperInfoDtoList)) {
-                    throw ExceptionResultEnum.ERROR.exception("试卷信息不存在");
-                }
-                Set<Long> attPaperIds = new HashSet<>();
-                List<ExamCardDto> examCardDtoList = new ArrayList<>();
-                for (ExamPaperInfoDto paperInfo : paperInfoDtoList) {
-                    Long attachmentId = paperInfo.getAttachmentId();
-                    Long cardId = paperInfo.getCardId();
-                    String paperType = paperInfo.getName();
-                    if (SystemConstant.longNotNull(attachmentId)) {
-                        attPaperIds.add(attachmentId);
-                    }
-                    if (SystemConstant.longNotNull(cardId)) {
-                        ExamCardDto examCardDto = new ExamCardDto();
-                        examCardDto.setCardId(cardId);
-                        examCardDto.setPaperType(paperType);
-                        examCardDtoList.add(examCardDto);
-                    }
+                    throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s]的命题任务未上传试卷或题卡", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber()));
                 }
-                if (attPaperIds.size() > 0) {
-                    List<BasicAttachment> paperAttachmentList = basicAttachmentService.listByIds(attPaperIds);
-                    for (BasicAttachment paperAttachment : paperAttachmentList) {
+
+                for (ExamPaperInfoDto examPaperInfoDto : paperInfoDtoList) {
+                    // 下载试卷
+                    if (examPaperInfoDto.getAttachmentId() != null) {
+                        BasicAttachment paperAttachment = basicAttachmentService.getById(examPaperInfoDto.getAttachmentId());
                         JSONObject jsonObject = JSONObject.parseObject(paperAttachment.getPath());
                         UploadFileEnum uploadFileEnum = UploadFileEnum.valueOf((String) jsonObject.get(SystemConstant.UPLOAD_TYPE));
-                        String paperPath = firstPath + File.separator + "试卷" + File.separator + paperAttachment.getName() + paperAttachment.getType();
+                        String paperPath = firstPath + File.separator + "试卷" + File.separator + examPaperInfoDto.getName() + "-" + paperAttachment.getName() + paperAttachment.getType();
                         if (oss || (!oss && dictionaryConfig.fssPrivateDomain().getConfig().startsWith(SystemConstant.START_PARENT))) {
                             fileStoreUtil.ossDownload((String) jsonObject.get(SystemConstant.PATH), paperPath, uploadFileEnum.getFssType());
                         } else {
                             FileUtil.copyFile(jsonObject.getString(SystemConstant.PATH), paperPath);
                         }
-                        count++;
                     }
-                }
 
-                // 处理审核样品
-                List<Map> confirmInfo = JSONObject.parseArray(reviewSampleDto.getPaperConfirmAttachmentIds(), Map.class);
-                Set<Long> attConfirmIds = new HashSet<>();
-                for (Map confirmMap : confirmInfo) {
-                    if (Objects.isNull(confirmMap.get("attachmentId"))) {
-                        throw ExceptionResultEnum.ERROR.exception("未找到附件id");
-                    }
-                    Long attachmentId = Long.valueOf(String.valueOf(confirmMap.get("attachmentId")));
-                    attConfirmIds.add(attachmentId);
-                }
-                if (attConfirmIds.size() > 0) {
-                    List<BasicAttachment> confirmAttachmentList = basicAttachmentService.listByIds(attConfirmIds);
-                    for (BasicAttachment confirmAttachment : confirmAttachmentList) {
-                        JSONObject jsonObject = JSONObject.parseObject(confirmAttachment.getPath());
-                        UploadFileEnum uploadFileEnum = UploadFileEnum.valueOf((String) jsonObject.get(SystemConstant.UPLOAD_TYPE));
-                        String confirmPath = firstPath + File.separator + "审核样本" + File.separator + confirmAttachment.getName() + confirmAttachment.getType();
-                        if (oss || (!oss && dictionaryConfig.fssPrivateDomain().getConfig().startsWith(SystemConstant.START_PARENT))) {
-                            fileStoreUtil.ossDownload((String) jsonObject.get(SystemConstant.PATH), confirmPath, uploadFileEnum.getFssType());
+                    // 下载题卡
+                    Long cardId = examPaperInfoDto.getCardId();
+                    if (cardId != null) {
+                        String paperType = examPaperInfoDto.getName();
+                        ExamCard examCard = examCardService.getById(cardId);
+                        if (Objects.isNull(examCard)) {
+                            throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s],卷型[%s]的题卡不存在", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber(), paperType));
+                        }
+                        MakeMethodEnum makeMethodEnum = examCard.getMakeMethod();
+                        if (MakeMethodEnum.SELECT.equals(makeMethodEnum) && CardCreateMethodEnum.UPLOAD.equals(examCard.getCreateMethod())) {
+                            Long attachmentId = examCard.getAttachmentId();
+                            if (attachmentId == null || attachmentId == 0) {
+                                throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s],卷型[%s]的题卡未上传", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber(), paperType));
+                            }
+                            BasicAttachment cardAttachment = basicAttachmentService.getById(attachmentId);
+                            if (Objects.isNull(cardAttachment)) {
+                                throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s],卷型[%s]的题卡未找到上传附件数据", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber(), paperType));
+                            }
+                            JSONObject jsonObject = JSONObject.parseObject(cardAttachment.getPath());
+                            // 题卡路径
+                            String cardPath = firstPath + File.separator + "题卡" + File.separator + paperType + "-" + cardAttachment.getName() + cardAttachment.getType();
+                            UploadFileEnum uploadFileEnum = UploadFileEnum.valueOf((String) jsonObject.get(SystemConstant.UPLOAD_TYPE));
+
+                            if (oss || (!oss && dictionaryConfig.fssPrivateDomain().getConfig().startsWith(SystemConstant.START_PARENT))) {
+                                fileStoreUtil.ossDownload((String) jsonObject.get(SystemConstant.PATH), cardPath, uploadFileEnum.getFssType());
+                            } else {
+                                FileUtil.copyFile(jsonObject.getString(SystemConstant.PATH), cardPath);
+                            }
                         } else {
-                            FileUtil.copyFile(jsonObject.getString(SystemConstant.PATH), confirmPath);
+                            String htmlContent = examCard.getHtmlContent();
+                            byte[] bytes = htmlContent.getBytes(StandardCharsets.UTF_8);
+                            // 题卡路径
+                            String cardPath = firstPath + File.separator + "题卡" + File.separator + paperType + "-" + examCard.getTitle() + SystemConstant.HTML_PREFIX;
+                            File localFile = new File(cardPath);
+                            if (!localFile.getParentFile().exists()) {
+                                localFile.getParentFile().mkdirs();
+                            }
+                            FileCopyUtils.copy(bytes, localFile);
                         }
-                        count++;
                     }
-                }
 
-                // 处理题卡
-                for (ExamCardDto examCardDto : examCardDtoList) {
-                    Long cardId = examCardDto.getCardId();
-                    String paperType = examCardDto.getPaperType();
-                    ExamCard examCard = examCardService.getById(cardId);
-                    if (Objects.isNull(examCard)) {
-                        throw ExceptionResultEnum.ERROR.exception("找不到答题卡");
-                    }
-                    MakeMethodEnum makeMethodEnum = examCard.getMakeMethod();
-                    if (MakeMethodEnum.SELECT.equals(makeMethodEnum) && CardCreateMethodEnum.UPLOAD.equals(examCard.getCreateMethod())) {
-                        Long attachmentId = examCard.getAttachmentId();
-                        if (attachmentId == null || attachmentId == 0) {
-                            throw ExceptionResultEnum.ERROR.exception("找不到模板对应的附件");
-                        }
-                        BasicAttachment cardAttachment = basicAttachmentService.getById(attachmentId);
-                        if (Objects.isNull(cardAttachment)) {
-                            throw ExceptionResultEnum.ERROR.exception("找不到附件");
+                    // 处理审核样品
+                    List<Map> confirmInfo = JSONObject.parseArray(examTaskDetail.getPaperConfirmAttachmentIds(), Map.class);
+                    for (Map confirmMap : confirmInfo) {
+                        if (Objects.isNull(confirmMap.get("attachmentId"))) {
+                            throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s]的附件未上传", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber()));
                         }
-                        JSONObject jsonObject = JSONObject.parseObject(cardAttachment.getPath());
-                        // 题卡路径
-                        String cardPath = firstPath + File.separator + "题卡" + File.separator + cardAttachment.getName() + cardAttachment.getType();
-                        if (SystemConstant.strNotNull(paperType)) {
-                            cardPath = cardPath + "(" + paperType + ")";
+                        Long attachmentId = Long.valueOf(String.valueOf(confirmMap.get("attachmentId")));
+                        BasicAttachment confirmAttachment = basicAttachmentService.getById(attachmentId);
+                        if (confirmAttachment == null) {
+                            throw ExceptionResultEnum.ERROR.exception(String.format("课程[%s(%s)],试卷编号[%s]的附件未找到上传数据", examTask.getCourseName(), examTask.getCourseCode(), examTask.getPaperNumber()));
                         }
+                        JSONObject jsonObject = JSONObject.parseObject(confirmAttachment.getPath());
                         UploadFileEnum uploadFileEnum = UploadFileEnum.valueOf((String) jsonObject.get(SystemConstant.UPLOAD_TYPE));
-
+                        String confirmPath = firstPath + File.separator + "审核样本" + File.separator + confirmAttachment.getName() + confirmAttachment.getType();
                         if (oss || (!oss && dictionaryConfig.fssPrivateDomain().getConfig().startsWith(SystemConstant.START_PARENT))) {
-                            fileStoreUtil.ossDownload((String) jsonObject.get(SystemConstant.PATH), cardPath, uploadFileEnum.getFssType());
+                            fileStoreUtil.ossDownload((String) jsonObject.get(SystemConstant.PATH), confirmPath, uploadFileEnum.getFssType());
                         } else {
-                            FileUtil.copyFile(jsonObject.getString(SystemConstant.PATH), cardPath);
-                        }
-                    } else {
-                        String htmlContent = examCard.getHtmlContent();
-                        byte[] bytes = htmlContent.getBytes(StandardCharsets.UTF_8);
-
-                        // 题卡路径
-                        String cardPath = firstPath + File.separator + "题卡" + File.separator + examCard.getTitle();
-                        if (SystemConstant.strNotNull(paperType)) {
-                            cardPath = cardPath + "(" + paperType + ")";
-                        }
-                        cardPath = cardPath + SystemConstant.HTML_PREFIX;
-
-                        File localFile = new File(cardPath);
-                        if (!localFile.getParentFile().exists()) {
-                            localFile.getParentFile().mkdirs();
+                            FileUtil.copyFile(jsonObject.getString(SystemConstant.PATH), confirmPath);
                         }
-                        FileCopyUtils.copy(bytes, localFile);
                     }
                 }
                 count++;

+ 19 - 22
distributed-print-business/src/main/resources/mapper/ExamTaskMapper.xml

@@ -721,21 +721,6 @@
             </if>
         </where>
     </select>
-    <select id="listReviewSampleInfoByExamTaskId"
-            resultType="com.qmth.distributed.print.business.bean.dto.ReviewSampleDto">
-        SELECT
-            IFNULL(log.paper_attachment_ids,
-                   det.paper_attachment_ids) AS paperAttachmentIds,
-            det.paper_confirm_attachment_ids AS paperConfirmAttachmentIds
-        FROM
-            exam_task_detail det
-                left JOIN
-            exam_task_paper_log log ON det.exam_task_id = log.exam_task_id
-                AND log.review = 0
-        WHERE
-            det.exam_task_id = #{examTaskId}
-        ORDER BY det.update_time DESC
-    </select>
     <select id="listExamTaskExpire" resultMap="BaseResultMap">
         select * from exam_task a
         <where>
@@ -800,7 +785,7 @@
     </sql>
 
     <select id="getFlowTaskReadyList" resultType="com.qmth.distributed.print.business.bean.result.WorkResult">
-          select * from(select
+          select t.* from(select
                 et.id,
                 et.school_id schoolId,
                 et.org_id as orgId,
@@ -851,8 +836,12 @@
                 sys_org so ON et.teaching_room_id = so.id
             LEFT JOIN exam_task_detail det ON
                 det.exam_task_id = et.id
+            LEFT JOIN
+                basic_exam be ON et.exam_id = be.id
+            LEFT JOIN
+                basic_semester bs ON be.semester_id = bs.id
             where
-                et.enable = true
+                et.enable = true and be.enable = true and bs.enable = true
                 and art.ASSIGNEE_ = cast(#{userId} as char)
                 and et.school_id = #{schoolId}
             UNION all
@@ -909,9 +898,13 @@
                 sys_org so ON et.teaching_room_id = so.id
             LEFT JOIN exam_task_detail det ON
                     det.exam_task_id = et.id
+            LEFT JOIN
+                basic_exam be ON et.exam_id = be.id
+            LEFT JOIN
+                basic_semester bs ON be.semester_id = bs.id
             where
-                  et.enable = true
-                and art.ASSIGNEE_ is null
+                  et.enable = true and be.enable = true and bs.enable = true
+              and art.ASSIGNEE_ is null
                 and ari.USER_ID_ = cast(#{userId} as char)
                 and ari.TYPE_ = 'candidate'
                 and et.school_id = #{schoolId}
@@ -959,11 +952,15 @@
                   sys_org so ON et.teaching_room_id = so.id
                   LEFT JOIN exam_task_detail det ON
                   det.exam_task_id = et.id
+                  LEFT JOIN
+                 basic_exam be ON et.exam_id = be.id
+                  LEFT JOIN
+                 basic_semester bs ON be.semester_id = bs.id
           where
-              et.enable = true
-            AND et.status = 'STAGE'
+              et.enable = true and be.enable = true and bs.enable = true
+            AND et.status = 'STAGE' AND et.flow_id is null
             AND et.user_id = #{userId}
-            and et.school_id = #{schoolId} ) t order by t.updateTime desc
+            and et.school_id = #{schoolId} ) t  order by t.updateTime desc
     </select>
 
     <sql id="findFlowIdToMySelfSql">