Jelajahi Sumber

题卡pdf合并

xiaof 3 tahun lalu
induk
melakukan
f04590b22f

+ 14 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/ExamDetail.java

@@ -93,11 +93,15 @@ public class ExamDetail extends BaseEntity implements Serializable {
     @TableField("print_end_time")
     private Long printEndTime;
 
-    @ApiModelProperty(value = "附件id")
+    @ApiModelProperty(value = "合成pdf的A3附件id")
     @TableField(value = "attachment_id")
     private Long attachmentId;
 
-    @ApiModelProperty(value = "附件路径")
+    @ApiModelProperty(value = "题卡合成pdf的A3附件id")
+    @TableField(value = "card_attachment_id")
+    private Long cardAttachmentId;
+
+    @ApiModelProperty(value = "印品附件路径")
     @TableField("attachment_path")
     private String attachmentPath;
 
@@ -301,4 +305,12 @@ public class ExamDetail extends BaseEntity implements Serializable {
     public void setPrintHouseId(Long printHouseId) {
         this.printHouseId = printHouseId;
     }
+
+    public Long getCardAttachmentId() {
+        return cardAttachmentId;
+    }
+
+    public void setCardAttachmentId(Long cardAttachmentId) {
+        this.cardAttachmentId = cardAttachmentId;
+    }
 }

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

@@ -1,5 +1,6 @@
 package com.qmth.distributed.print.business.service;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.distributed.print.business.bean.dto.*;
@@ -45,7 +46,7 @@ public interface ExamDetailService extends IService<ExamDetail> {
 
     PrintTaskTotalDto taskTotalData(Long printPlanId, String status, String courseCode, String paperNumber, String examPlace, String examRoom, Long examStartTime, Long examEndTime, Long printStartTime, Long printEndTime,Long printingHouseId);
 
-    String taskViewPDF(Long examDetailId);
+    List<JSONObject> taskViewPDF(Long examDetailId);
 
     /**
      * 查询有效的考务字段

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

@@ -241,6 +241,9 @@ public class ClientServiceImpl implements ClientService {
             }
 
             if (printContent.contains("CARD")) {
+                Map<String, String> totalCardPathUrl = teachcloudCommonService.filePreviewByAttachmentId(examDetail.getCardAttachmentId(), false);
+                finalMap.put("cardTotal", totalCardPathUrl);
+
                 // 生成题卡List
                 detailMap.put("card", spliceCardContent(studentList));
 
@@ -370,6 +373,9 @@ public class ClientServiceImpl implements ClientService {
         BasicAttachment attachment = basicAttachmentService.getById(examDetail.getAttachmentId());
         finalMap.put("total", 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));
+
         ExamPrintPlan examPrintPlan = examPrintPlanService.getById(examDetail.getPrintPlanId());
         String variableContent = examPrintPlan.getVariableContent();
         String ordinaryContent = examPrintPlan.getOrdinaryContent();

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

@@ -25,6 +25,7 @@ import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.*;
 import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
 import com.qmth.teachcloud.common.enums.MqTagEnum;
+import com.qmth.teachcloud.common.enums.PdfTypeEnum;
 import com.qmth.teachcloud.common.enums.TaskTypeEnum;
 import com.qmth.teachcloud.common.service.*;
 import com.qmth.teachcloud.common.util.ConvertUtil;
@@ -147,13 +148,24 @@ public class ExamDetailServiceImpl extends ServiceImpl<ExamDetailMapper, ExamDet
     }
 
     @Override
-    public String taskViewPDF(Long examDetailId) {
+    public List<JSONObject> taskViewPDF(Long examDetailId) {
         ExamDetail examDetail = this.getById(examDetailId);
+        List<JSONObject> list = new ArrayList<>();
         if (examDetail.getAttachmentId() != null) {
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.put("type", PdfTypeEnum.ALL_A3);
             BasicAttachment attachment = basicAttachmentService.getById(examDetail.getAttachmentId());
-            return attachment == null ? null : teachcloudCommonService.filePreview(attachment.getPath());
+            jsonObject.put("url",attachment == null ? null : teachcloudCommonService.filePreview(attachment.getPath()));
+            list.add(jsonObject);
         }
-        return null;
+        if (examDetail.getCardAttachmentId() != null) {
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.put("type", PdfTypeEnum.CARD_A3);
+            BasicAttachment attachment = basicAttachmentService.getById(examDetail.getCardAttachmentId());
+            jsonObject.put("url",attachment == null ? null : teachcloudCommonService.filePreview(attachment.getPath()));
+            list.add(jsonObject);
+        }
+        return list;
     }
 
     @Transactional(rollbackFor = Exception.class)

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

@@ -515,14 +515,17 @@ public class TaskLogicServiceImpl implements TaskLogicService {
 
                 createA4File(examPrintPlan, examDetail, basicSchool, ftlList, examDetailCourseList, ordinaryPdfList, variablePdfList);
 
-                //合并pdf
+                //合并A3(试卷+题卡+备用试卷+备用题卡)
                 String dirNameA3 = createPdfUtil.mergeA3Pdf(paperPdfList, examStudentPdfList, backupPaperPdfList, cardPdfList);
+                //合并A4(签到表+卷袋贴+登记表)
                 String dirNameA4 = createPdfUtil.mergeA4Pdf(variablePdfList, ordinaryPdfList);
+                //合并A3(题卡+备用题卡)
+                String dirNameCardA3 = createPdfUtil.mergeA3Pdf(examStudentPdfList, cardPdfList);
 
                 List<PdfDto> mergePdfDeleteList = new ArrayList<>();
                 mergePdfDeleteList.addAll(examStudentPdfList);
                 mergePdfDeleteList.addAll(cardPdfList);
-                BasicAttachment attachment = createPdfUtil.mergePdfSaveDb(dirNameA4, dirNameA3, tbTask, sysUser.getId(), examDetail, basicExamRule, mergePdfDeleteList);
+                BasicAttachment attachment = createPdfUtil.mergePdfSaveDb(dirNameA4, dirNameA3, dirNameCardA3, tbTask, sysUser.getId(), examDetail, basicExamRule, mergePdfDeleteList);
                 if (basicAttachmentList != null) {
                     basicAttachmentList.add(attachment);
                 }
@@ -807,7 +810,15 @@ public class TaskLogicServiceImpl implements TaskLogicService {
             //查询examDetail
             List<ExamDetail> examDetailList = examDetailService.listByIds(Arrays.asList(arraysParams.getIds()));
             if (Objects.nonNull(examDetailList)) {
-                Set<Long> attachmentIds = examDetailList.stream().map(ExamDetail::getAttachmentId).collect(Collectors.toSet());
+                Set<Long> attachmentIds = new HashSet<>();
+                Set<Long> allAttachmentIds = examDetailList.stream().map(ExamDetail::getAttachmentId).collect(Collectors.toSet());
+                if(!CollectionUtils.isEmpty(allAttachmentIds)){
+                    attachmentIds.addAll(allAttachmentIds);
+                }
+                Set<Long> cardAttachmentIds = examDetailList.stream().map(ExamDetail::getCardAttachmentId).collect(Collectors.toSet());
+                if(!CollectionUtils.isEmpty(cardAttachmentIds)){
+                    attachmentIds.addAll(cardAttachmentIds);
+                }
                 List<BasicAttachment> basicAttachmentList = basicAttachmentService.listByIds(attachmentIds);
 
                 if (Objects.nonNull(basicAttachmentList) && basicAttachmentList.size() > 0) {

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

@@ -663,6 +663,7 @@ public class CreatePdfUtil {
      *
      * @param dirNameA4
      * @param dirNameA3
+     * @param dirNameCardA3
      * @param tbTask
      * @param userId
      * @param examDetail
@@ -674,6 +675,7 @@ public class CreatePdfUtil {
     @Transactional
     public BasicAttachment mergePdfSaveDb(String dirNameA4,
                                           String dirNameA3,
+                                          String dirNameCardA3,
                                           TBTask tbTask,
                                           Long userId,
                                           ExamDetail examDetail,
@@ -695,6 +697,14 @@ public class CreatePdfUtil {
             tbTask.setImportFilePath(basicAttachment.getPath());
             examDetail.setAttachmentId(basicAttachment.getId());
         }
+        if (Objects.nonNull(dirNameCardA3)) {
+            dirNameCardA3 = dirNameCardA3.replaceAll("\\\\", "/");
+            localA3PdfFile = new File(stringJoiner.toString() + File.separator + dirNameCardA3);
+            basicAttachment = basicAttachmentService.saveAttachmentPdf(dirNameCardA3, userId);
+            tbTask.setImportFileName(basicAttachment.getName());
+            tbTask.setImportFilePath(basicAttachment.getPath());
+            examDetail.setCardAttachmentId(basicAttachment.getId());
+        }
         examDetail.setPagesA3(PdfUtil.getPdfPages(localA3PdfFile));
         examDetail.setPagesA4(PdfUtil.getPdfPages(localA4PdfFile));
         if (PrintMethodEnum.AUTO == basicExamRule.getPrintMethod()) {

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

@@ -1,6 +1,5 @@
 package com.qmth.distributed.print.api;
 
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.qmth.boot.api.annotation.Aac;

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

@@ -1,5 +1,6 @@
 package com.qmth.distributed.print.api;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.distributed.print.business.bean.dto.ExamTaskDetailDto;
@@ -315,8 +316,8 @@ public class ExamPrintPlanController {
     @ApiOperation(value = "印刷任务管理-查看PDF")
     @RequestMapping(value = "/task_view_pdf", method = RequestMethod.POST)
     public Result taskViewPDF(@RequestBody Map<String, Long> map) {
-        String path = examDetailService.taskViewPDF(map.get("examDetailId"));
-        return ResultUtil.ok((Object) path);
+        List<JSONObject> list = examDetailService.taskViewPDF(map.get("examDetailId"));
+        return ResultUtil.ok(list);
     }
 
     @ApiOperation(value = "印刷任务管理-批量下载PDF")

+ 45 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/enums/PdfTypeEnum.java

@@ -0,0 +1,45 @@
+package com.qmth.teachcloud.common.enums;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 角色类型
+ * @Date: 2021/3/23.
+ */
+public enum PdfTypeEnum {
+
+    ALL_A3("所有A3合并文件"),
+    CARD_A3("题卡A3合并文件");
+
+    PdfTypeEnum(String desc) {
+        this.desc = desc;
+    }
+
+    private String desc;
+
+    public String getDesc() {
+        return desc;
+    }
+
+    /**
+     * @param hasAdmin 是否需要管理员
+     * @return
+     */
+    public static List<EnumResult> listTypes(boolean hasAdmin) {
+        List<EnumResult> list = new ArrayList<EnumResult>();
+        for (PdfTypeEnum value : PdfTypeEnum.values()) {
+            if (!hasAdmin && "ADMIN".equals(value.name())) {
+                continue;
+            }
+            EnumResult result = new EnumResult();
+            result.setName(value.name());
+            result.setOrdinal(value.ordinal());
+            result.setCode(null);
+            result.setDesc(value.getDesc());
+            list.add(result);
+        }
+        return list;
+    }
+
+}