Quellcode durchsuchen

Merge branch 'dev_v3.2.0' of http://git.qmth.com.cn/wangliang/distributed-print-service into dev_v3.2.0

xiaof vor 2 Jahren
Ursprung
Commit
cc56971d17

+ 0 - 11
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ExamTaskDetailDto.java

@@ -45,9 +45,6 @@ public class ExamTaskDetailDto {
     @ApiModelProperty(value = "机构id")
     private String orgName;
 
-    @ApiModelProperty(value = "题卡id")
-    private Long examCardId;
-
     @ApiModelProperty(value = "命题任务试卷附件")
     private String paperAttachmentIds;
 
@@ -267,14 +264,6 @@ public class ExamTaskDetailDto {
         this.orgName = orgName;
     }
 
-    public Long getExamCardId() {
-        return examCardId;
-    }
-
-    public void setExamCardId(Long examCardId) {
-        this.examCardId = examCardId;
-    }
-
     public String getPaperAttachmentIds() {
         return paperAttachmentIds;
     }

+ 31 - 29
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/DownloadServiceImpl.java

@@ -5,10 +5,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.qmth.distributed.print.business.bean.dto.ExamTaskDetailDto;
-import com.qmth.distributed.print.business.bean.dto.ExamTaskPaperDto;
-import com.qmth.distributed.print.business.bean.dto.ExamTaskPaperExportDto;
-import com.qmth.distributed.print.business.bean.dto.ExamTaskPaperFileDto;
+import com.qmth.distributed.print.business.bean.dto.*;
 import com.qmth.distributed.print.business.entity.*;
 import com.qmth.distributed.print.business.enums.MakeMethodEnum;
 import com.qmth.distributed.print.business.mapper.ExamCardMapper;
@@ -110,41 +107,46 @@ public class DownloadServiceImpl implements DownloadService {
         }
         String paperAttachmentIds = examTaskDetail.getPaperAttachmentIds();
         List<JSONObject> jsonObjectList = JSONObject.parseArray(paperAttachmentIds, JSONObject.class);
+
+
+
+        // 收集处理试卷和题卡
         // 本地存储目录
         String rootPath = dictionaryConfig.fssLocalFileDomain().getConfig() + File.separator + System.currentTimeMillis();
         List<File> fileList = new ArrayList<>();
-        // 试卷
+
         List<String> unexposedPaperTypes = Arrays.asList(unexposedPaperType.split(","));
-        for (JSONObject jsonObject : jsonObjectList) {
-            String attachmentId = jsonObject.get("attachmentId").toString();
-            String name = jsonObject.get("name").toString();
-            if (!unexposedPaperTypes.contains(name)) {
+        List<ExamPaperInfoDto> paperInfoDtoList = JSONObject.parseArray(paperAttachmentIds, ExamPaperInfoDto.class);
+        if (Objects.isNull(paperInfoDtoList)) {
+            throw ExceptionResultEnum.ERROR.exception("试卷信息不存在");
+        }
+        for (ExamPaperInfoDto paperInfo : paperInfoDtoList) {
+            String paperType = paperInfo.getName();
+            if (!unexposedPaperTypes.contains(paperType)) {
                 continue;
             }
+
+            // 试卷附件id
+            Long attachmentId = paperInfo.getAttachmentId();
+            // 题卡id
+            Long cardId = paperInfo.getCardId();
+
+            // 试卷
             BasicAttachment attachment = basicAttachmentMapper.selectById(attachmentId);
             if (attachment == null) {
                 throw ExceptionResultEnum.ERROR.exception("附件数据异常");
             }
             String paperPath = rootPath + File.separator + examTask.getCourseName() + "-" + examTask.getCourseCode() + File.separator + examTask.getPaperNumber();
-            String fileName = "试卷" + "_" + attachment.getName() + "_" + name + attachment.getType();
+            String fileName = "试卷" + "_" + attachment.getName() + "_" + paperType + attachment.getType();
             fileList.add(attachmentCommonService.downloadFile(paperPath, fileName, attachment));
-        }
 
-        // 题卡
-//        Long cardId = examTaskDetail.getCardId();
-        if (Objects.nonNull(examTaskDetail.getPaperAttachmentIds())) {
-            JSONArray jsonArrayPaper = JSONArray.parseArray(examTaskDetail.getPaperAttachmentIds());
-            String cardId = null;
-            for (int i = 0; i < jsonArrayPaper.size(); i++) {
-                JSONObject object = jsonArrayPaper.getJSONObject(i);
-                cardId = (String) object.get("cardId");
-            }
-            if (cardId != null) {
+            // 题卡
+            if (cardId != null){
                 ExamCard examCard = examCardMapper.selectById(cardId);
 
                 String cardPath = rootPath + File.separator + examTask.getCourseName() + "-" + examTask.getCourseCode() + File.separator + examTask.getPaperNumber();
-                String cardHtmlPath = cardPath + File.separator + "题卡" + "_" + examTask.getCourseName() + SystemConstant.HTML_PREFIX;
-                String cardPdfPath = cardPath + File.separator + "题卡" + "_" + examTask.getCourseName() + SystemConstant.PDF_PREFIX;
+                String cardHtmlPath = cardPath + File.separator + "题卡" + "_" + examTask.getCourseName() + "_" + paperType + SystemConstant.HTML_PREFIX;
+                String cardPdfPath = cardPath + File.separator + "题卡" + "_" + examTask.getCourseName() + "_" + paperType + SystemConstant.PDF_PREFIX;
 
                 ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCard.getId());
                 String htmlContent;
@@ -210,7 +212,6 @@ public class DownloadServiceImpl implements DownloadService {
                 String courseCode = examTaskDetailDto.getCourseCode();
                 String courseName = examTaskDetailDto.getCourseName();
                 String paperNumber = examTaskDetailDto.getPaperNumber();
-                Long examCardId = examTaskDetailDto.getExamCardId();
                 Long cardRuleId = SystemConstant.convertIdToLong(examTaskDetailDto.getCardRuleId());
 
                 // 生成导出对象
@@ -231,15 +232,16 @@ public class DownloadServiceImpl implements DownloadService {
                 List<String> exposedPaperTypeList = Arrays.asList(examTaskDetailDto.getExposedPaperType().split(","));
                 List<String> unexposedPaperTypeList = Arrays.asList(examTaskDetailDto.getUnexposedPaperType().split(","));
 
-                List<Map> paperInfo = JSONObject.parseArray(examTaskDetailDto.getPaperAttachmentIds(), Map.class);
+                List<ExamPaperInfoDto> paperInfo = JSONObject.parseArray(examTaskDetailDto.getPaperAttachmentIds(), ExamPaperInfoDto.class);
                 if (Objects.isNull(paperInfo)) {
                     throw ExceptionResultEnum.ERROR.exception("试卷信息不存在");
                 }
                 // 试卷信息
-                for (Map paper : paperInfo) {
-                    Long attachmentId = SystemConstant.convertIdToLong(String.valueOf(paper.get("attachmentId")));
+                for (ExamPaperInfoDto paper : paperInfo) {
+                    Long cardId = paper.getCardId();
+                    Long attachmentId = paper.getAttachmentId();
                     BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
-                    String paperType = String.valueOf(paper.get("name"));
+                    String paperType = paper.getName();
                     String paperName = basicAttachment.getName();
                     String paperSuffix = basicAttachment.getType();
                     JSONObject jsonObject = JSONObject.parseObject(basicAttachment.getPath());
@@ -267,7 +269,7 @@ public class DownloadServiceImpl implements DownloadService {
                     cell.setCourseName(courseName);
                     cell.setPaperNumber(paperNumber);
                     // 题卡
-                    cell.setExamCardId(examCardId);
+                    cell.setExamCardId(cardId);
                     cell.setCardRuleId(cardRuleId);
                     // 试卷
                     cell.setPaperType(paperType);

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

@@ -1844,33 +1844,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                 // 文件路径
                 String filePath = zipLocalRootPath + File.separator + course + File.separator + paperNumber + File.separator;
 
-                Long examCardId = paperCellList.get(0).getExamCardId();
-                Long cardRuleId = paperCellList.get(0).getCardRuleId();
-                ExamCard examCard = examCardService.getById(examCardId);
-                ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCardId);
-                String htmlContent;
-                if (MakeMethodEnum.SELECT.equals(examCard.getMakeMethod()) && CardCreateMethodEnum.UPLOAD.equals(examCard.getCreateMethod())) {
-                    htmlContent = createPdfUtil.resetHtmlTemplateBar(examCardDetail.getHtmlContent());
-                } else {
-                    BasicCardRule basicCardRule = basicCardRuleService.getById(cardRuleId);
-                    htmlContent = createPdfUtil.replaceHtmlCard(examCardDetail, basicCardRule);
-                }
-
-
-                byte[] bytes = htmlContent.getBytes();
-                String cardName = "题卡-";
-                if (namedByCourseInfo) {
-                    cardName = cardName + course;
-                }
-                if (namedByPaperNumber) {
-                    cardName = cardName + paperNumber;
-                }
-                if (namedByOriginalFile) {
-                    cardName = cardName + examCardService.getById(examCardId).getTitle();
-                }
-                String cardLocalHtmlPath = filePath + cardName + SystemConstant.HTML_PREFIX;
-                String cardLocalPdfPath = filePath + cardName + SystemConstant.PDF_PREFIX;
-
                 // 试卷文件曝光度筛选
                 if (Objects.nonNull(paperFileDownloadExposureStatus)) {
                     switch (paperFileDownloadExposureStatus) {
@@ -1900,19 +1873,48 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                 }
                 switch (paperFileDownloadContent) {
                     case ONLY_CARD: // 只下载题卡
-                        File localFile = new File(cardLocalHtmlPath);
-                        if (!localFile.getParentFile().exists()) {
-                            boolean mkr = localFile.getParentFile().mkdirs();
-                        }
-                        FileCopyUtils.copy(bytes, localFile);
+                        for (ExamTaskPaperFileDto examTaskPaperFileDto : paperCellList) {
+                            Long examCardId = examTaskPaperFileDto.getExamCardId();
+                            Long cardRuleId = examTaskPaperFileDto.getCardRuleId();
+                            ExamCard examCard = examCardService.getById(examCardId);
+                            ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCardId);
+                            String htmlContent;
+                            if (MakeMethodEnum.SELECT.equals(examCard.getMakeMethod()) && CardCreateMethodEnum.UPLOAD.equals(examCard.getCreateMethod())) {
+                                htmlContent = createPdfUtil.resetHtmlTemplateBar(examCardDetail.getHtmlContent());
+                            } else {
+                                BasicCardRule basicCardRule = basicCardRuleService.getById(cardRuleId);
+                                htmlContent = createPdfUtil.replaceHtmlCard(examCardDetail, basicCardRule);
+                            }
+
+                            byte[] bytes = htmlContent.getBytes();
+                            String cardName = "题卡-";
+                            if (namedByCourseInfo) {
+                                cardName = cardName + course;
+                            }
+                            if (namedByPaperNumber) {
+                                cardName = cardName + paperNumber;
+                            }
+                            if (namedByOriginalFile) {
+                                cardName = cardName + examCardService.getById(examCardId).getTitle();
+                            }
+                            cardName = cardName + "-" + examTaskPaperFileDto.getPaperType();
+                            String cardLocalHtmlPath = filePath + cardName + SystemConstant.HTML_PREFIX;
+                            String cardLocalPdfPath = filePath + cardName + SystemConstant.PDF_PREFIX;
+
+                            File localFile = new File(cardLocalHtmlPath);
+                            if (!localFile.getParentFile().exists()) {
+                                boolean mkr = localFile.getParentFile().mkdirs();
+                            }
+                            FileCopyUtils.copy(bytes, localFile);
 
-                        File pdfFile = new File(cardLocalPdfPath);
-                        if (!pdfFile.exists()) {
-                            boolean cf = pdfFile.createNewFile();
+                            File pdfFile = new File(cardLocalPdfPath);
+                            if (!pdfFile.exists()) {
+                                boolean cf = pdfFile.createNewFile();
+                            }
+                            HtmlToPdfUtil.convert(cardLocalHtmlPath, cardLocalPdfPath, PageSizeEnum.A3);
+                            specialSuccessMessage = "";
+                            courseCount = 1;
                         }
-                        HtmlToPdfUtil.convert(cardLocalHtmlPath, cardLocalPdfPath, PageSizeEnum.A3);
-                        specialSuccessMessage = "";
-                        courseCount = 1;
                         break;
                     case ONLY_PAPER: // 只下载试卷
                         for (ExamTaskPaperFileDto examTaskPaperFileDto : paperCellList) {
@@ -1938,20 +1940,47 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                         }
                         break;
                     case PAPER_AND_CARD: // 全部下载
-                        // 题卡
-                        File localCardFile = new File(cardLocalHtmlPath);
-                        if (!localCardFile.getParentFile().exists()) {
-                            boolean mkr = localCardFile.getParentFile().mkdirs();
-                        }
-                        FileCopyUtils.copy(bytes, localCardFile);
-
-                        File cardPdfFile = new File(cardLocalPdfPath);
-                        if (!cardPdfFile.exists()) {
-                            boolean cf = cardPdfFile.createNewFile();
-                        }
-                        HtmlToPdfUtil.convert(cardLocalHtmlPath, cardLocalPdfPath, PageSizeEnum.A3);
-                        // 试卷
                         for (ExamTaskPaperFileDto examTaskPaperFileDto : paperCellList) {
+                            // 题卡
+                            Long examCardId = examTaskPaperFileDto.getExamCardId();
+                            Long cardRuleId = examTaskPaperFileDto.getCardRuleId();
+                            ExamCard examCard = examCardService.getById(examCardId);
+                            ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCardId);
+                            String htmlContent;
+                            if (MakeMethodEnum.SELECT.equals(examCard.getMakeMethod()) && CardCreateMethodEnum.UPLOAD.equals(examCard.getCreateMethod())) {
+                                htmlContent = createPdfUtil.resetHtmlTemplateBar(examCardDetail.getHtmlContent());
+                            } else {
+                                BasicCardRule basicCardRule = basicCardRuleService.getById(cardRuleId);
+                                htmlContent = createPdfUtil.replaceHtmlCard(examCardDetail, basicCardRule);
+                            }
+
+                            byte[] bytes = htmlContent.getBytes();
+                            String cardName = "题卡-";
+                            if (namedByCourseInfo) {
+                                cardName = cardName + course;
+                            }
+                            if (namedByPaperNumber) {
+                                cardName = cardName + paperNumber;
+                            }
+                            if (namedByOriginalFile) {
+                                cardName = cardName + examCardService.getById(examCardId).getTitle();
+                            }
+                            cardName = cardName + "-" + examTaskPaperFileDto.getPaperType();
+                            String cardLocalHtmlPath = filePath + cardName + SystemConstant.HTML_PREFIX;
+                            String cardLocalPdfPath = filePath + cardName + SystemConstant.PDF_PREFIX;
+                            File localCardFile = new File(cardLocalHtmlPath);
+                            if (!localCardFile.getParentFile().exists()) {
+                                boolean mkr = localCardFile.getParentFile().mkdirs();
+                            }
+                            FileCopyUtils.copy(bytes, localCardFile);
+
+                            File cardPdfFile = new File(cardLocalPdfPath);
+                            if (!cardPdfFile.exists()) {
+                                boolean cf = cardPdfFile.createNewFile();
+                            }
+                            HtmlToPdfUtil.convert(cardLocalHtmlPath, cardLocalPdfPath, PageSizeEnum.A3);
+
+                            // 试卷
                             String paperName = "试卷-";
                             if (namedByCourseInfo) {
                                 paperName = paperName + course;

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

@@ -1112,8 +1112,8 @@
             IFNULL(b.exposed_paper_type,'') exposedPaperType,
             IFNULL(b.unexposed_paper_type,'') unexposedPaperType,
             so.name orgName,
-            REPLACE(substring_index(substring_index(CONVERT((b.paper_attachment_ids ->>'$[*].cardId')
-            USING utf8), ']', 1), '[',-1) examCardId,
+#             REPLACE(substring_index(substring_index(CONVERT((b.paper_attachment_ids ->>'$[*].cardId')
+#             USING utf8), ']', 1), '[',-1) examCardId,
             b.paper_attachment_ids paperAttachmentIds
         FROM
             exam_task a