浏览代码

3.4.1 联调bug修复

xiaofei 9 月之前
父节点
当前提交
5abd6b5adb

+ 54 - 17
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ClientServiceImpl.java

@@ -10,6 +10,7 @@ import com.qmth.distributed.print.business.bean.dto.*;
 import com.qmth.distributed.print.business.bean.dto.client.PrintSingleDto;
 import com.qmth.distributed.print.business.bean.dto.client.UrlMd5Dto;
 import com.qmth.distributed.print.business.entity.*;
+import com.qmth.distributed.print.business.enums.CardTypeEnum;
 import com.qmth.distributed.print.business.enums.ExamDetailStatusEnum;
 import com.qmth.distributed.print.business.enums.PrintPlanStatusEnum;
 import com.qmth.distributed.print.business.mapper.ClientMapper;
@@ -358,7 +359,7 @@ public class ClientServiceImpl implements ClientService {
                     backupMap.put("paper", paperBackupList);
                 }
 
-                if (printContent.contains("CARD")) {
+                if (printContent.contains("CARD") && this.getCardTypeByExamDetailId(examDetail, outputFileTypeList)) {
                     Map<String, String> totalCardPathUrl = teachcloudCommonService.filePreviewByAttachmentId(examDetail.getCardAttachmentId(), false);
                     finalMap.put("cardTotal", totalCardPathUrl);
 
@@ -405,18 +406,24 @@ public class ClientServiceImpl implements ClientService {
                 List<Map> pathList = JSONObject.parseArray(pathString, Map.class);
                 if (!pathList.isEmpty()) {
                     for (Map contentMap : variableList) {
-                        int count = Integer.parseInt(contentMap.get("backupCount").toString());
-                        for (int i = 0; i < count; i++) {
-                            spliceOtherContent(otherList, pathList, contentMap);
+                        String type = contentMap.get("type").toString();
+                        if ((outputFileTypeList.contains(OutputFileTypeEnum.SIGN) && ClassifyEnum.SIGN.name().equals(type))
+                                || (outputFileTypeList.contains(OutputFileTypeEnum.PACKAGE) && ClassifyEnum.PACKAGE.name().equals(type))) {
+                            int count = Integer.parseInt(contentMap.get("backupCount").toString());
+                            for (int i = 0; i < count; i++) {
+                                spliceOtherContent(otherList, pathList, contentMap);
+                            }
                         }
                     }
                     List<Map> ordinaryList = JSONObject.parseArray(ordinaryContent, Map.class);
                     for (Map contentMap : ordinaryList) {
-                        int count = Integer.parseInt(contentMap.get("backupCount").toString());
-                        for (int i = 0; i < count; i++) {
-                            spliceOtherContent(otherList, pathList, contentMap);
+                        String type = contentMap.get("type").toString();
+                        if (outputFileTypeList.contains(OutputFileTypeEnum.SIGN) && ClassifyEnum.SIGN.name().equals(type)) {
+                            int count = Integer.parseInt(contentMap.get("backupCount").toString());
+                            for (int i = 0; i < count; i++) {
+                                spliceOtherContent(otherList, pathList, contentMap);
+                            }
                         }
-
                     }
                 }
             }
@@ -492,12 +499,18 @@ public class ClientServiceImpl implements ClientService {
     public Map<String, Object> getUrlByExamDetailId(Long examDetailId) {
         Map<String, Object> finalMap = new HashMap<>();
         ExamDetail examDetail = examDetailService.getById(examDetailId);
-        BasicAttachment attachment = basicAttachmentService.getById(examDetail.getAttachmentId());
-        finalMap.put("paperTotal", attachment == null ? null : teachcloudCommonService.filePreviewByAttachmentId(attachment.getId(), false));
-
-        BasicAttachment cardAttachment = basicAttachmentService.getById(examDetail.getCardAttachmentId());
-        finalMap.put("cardTotal", cardAttachment == null ? null : teachcloudCommonService.filePreviewByAttachmentId(cardAttachment.getId(), false));
+        BasicPrintConfig basicPrintConfig = basicPrintConfigService.getByExamId(examDetail.getExamId());
+        List<OutputFileTypeEnum> outputFileTypeList = basicPrintConfig.getOutputFileTypeList();
+        if (outputFileTypeList.contains(OutputFileTypeEnum.PAPER)) {
+            BasicAttachment attachment = basicAttachmentService.getById(examDetail.getAttachmentId());
+            finalMap.put("paperTotal", attachment == null ? null : teachcloudCommonService.filePreviewByAttachmentId(attachment.getId(), false));
+        }
 
+        boolean showCard = this.getCardTypeByExamDetailId(examDetail, outputFileTypeList);
+        if (showCard) {
+            BasicAttachment cardAttachment = basicAttachmentService.getById(examDetail.getCardAttachmentId());
+            finalMap.put("cardTotal", cardAttachment == null ? null : teachcloudCommonService.filePreviewByAttachmentId(cardAttachment.getId(), false));
+        }
         ExamPrintPlan examPrintPlan = examPrintPlanService.getById(examDetail.getPrintPlanId());
 
         List<Map> otherList = new ArrayList<>();
@@ -510,11 +523,18 @@ public class ClientServiceImpl implements ClientService {
             if (!pathList.isEmpty()) {
                 List<Map> variableList = JSONObject.parseArray(examPrintPlan.getVariableContent(), Map.class);
                 for (Map contentMap : variableList) {
-                    spliceOtherContent(otherList, pathList, contentMap);
+                    String type = contentMap.get("type").toString();
+                    if ((outputFileTypeList.contains(OutputFileTypeEnum.SIGN) && ClassifyEnum.SIGN.name().equals(type))
+                            || (outputFileTypeList.contains(OutputFileTypeEnum.PACKAGE) && ClassifyEnum.PACKAGE.name().equals(type))) {
+                        spliceOtherContent(otherList, pathList, contentMap);
+                    }
                 }
                 List<Map> ordinaryList = JSONObject.parseArray(examPrintPlan.getOrdinaryContent(), Map.class);
                 for (Map contentMap : ordinaryList) {
-                    spliceOtherContent(otherList, pathList, contentMap);
+                    String type = contentMap.get("type").toString();
+                    if (outputFileTypeList.contains(OutputFileTypeEnum.CHECK_IN) && ClassifyEnum.CHECK_IN.name().equals(type)) {
+                        spliceOtherContent(otherList, pathList, contentMap);
+                    }
                 }
             }
         }
@@ -522,6 +542,25 @@ public class ClientServiceImpl implements ClientService {
         return finalMap;
     }
 
+    private boolean getCardTypeByExamDetailId(ExamDetail examDetail, List<OutputFileTypeEnum> outputFileTypeList) {
+        boolean showCard = false;
+        if (CollectionUtils.isNotEmpty(outputFileTypeList)) {
+            List<ExamDetailCourse> examDetailCourseList = examDetailCourseService.listByExamDetailId(examDetail.getId());
+            for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
+                ExamTaskDetail examTaskDetail = examTaskDetailService.getByExamIdAndCourseIdAndPaperNumber(examDetail.getExamId(), examDetailCourse.getCourseId(), examDetailCourse.getPaperNumber());
+                List<PaperInfoVo> paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetail.getPaperAttachmentIds(), examDetailCourse.getPaperType());
+                for (PaperInfoVo paperInfoVo : paperInfoVoList) {
+                    if ((outputFileTypeList.contains(OutputFileTypeEnum.GENERIC_CARD) && CardTypeEnum.GENERIC.equals(CardTypeEnum.valueOf(paperInfoVo.getCardType())))
+                            || (outputFileTypeList.contains(OutputFileTypeEnum.CUSTOM_CARD) && CardTypeEnum.CUSTOM.equals(CardTypeEnum.valueOf(paperInfoVo.getCardType())))) {
+                        showCard = true;
+                    }
+                }
+            }
+        }
+
+        return showCard;
+    }
+
     @Override
     public Boolean updateDownload(Long examDetailId, String machineCode, Boolean isDownload) {
         ExamDetail examDetail = examDetailService.getById(examDetailId);
@@ -872,8 +911,6 @@ public class ClientServiceImpl implements ClientService {
         for (Map path : pathList) {
             String printType = path.get("printType").toString();
             if (printType.equals(contentMap.get("type").toString())) {
-//                vMap.put("htmlUrl", teachcloudCommonService.filePreviewByPathAndType(path.get("htmlPath").toString(), path.get("type").toString(), false));
-//                vMap.put("htmlMd5", path.get("htmlMd5"));
                 vMap.put("pdfUrl", teachcloudCommonService.filePreviewByPathAndType(path.get(SystemConstant.PDF_PATH).toString(), path.get(SystemConstant.UPLOAD_TYPE).toString(), path.get("type").toString(), false));
                 vMap.put("pdfMd5", path.get("pdfMd5").toString().toLowerCase());
             }