wangliang пре 4 година
родитељ
комит
7fa8b889f5

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

@@ -65,12 +65,12 @@ public interface BasicAttachmentService extends IService<BasicAttachment> {
      * 保存附件
      *
      * @param basicAttachment
-     * @param variablePdfList
+     * @param pdfList
      * @param printCount
      * @return
      * @throws IOException
      */
-    public BasicAttachment saveAttachmentPdf(BasicAttachment basicAttachment, List<String> variablePdfList, Integer printCount) throws IOException;
+    public BasicAttachment saveAttachmentPdf(BasicAttachment basicAttachment, List<String> pdfList, Integer printCount) throws IOException;
 
     /**
      * 删除附件

+ 29 - 11
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicAttachmentServiceImpl.java

@@ -209,19 +209,29 @@ public class BasicAttachmentServiceImpl extends ServiceImpl<BasicAttachmentMappe
      * 保存附件
      *
      * @param basicAttachment
-     * @param variablePdfList
+     * @param pdfList
      * @param printCount
      * @return
      * @throws IOException
      */
     @Override
     @Transactional
-    public BasicAttachment saveAttachmentPdf(BasicAttachment basicAttachment, List<String> variablePdfList, Integer printCount) throws IOException {
+    public BasicAttachment saveAttachmentPdf(BasicAttachment basicAttachment, List<String> pdfList, Integer printCount) throws IOException {
         boolean oss = dictionaryConfig.sysDomain().isOss();
         JSONObject jsonObject = JSONObject.parseObject(basicAttachment.getPath());
-        String filePath = (String) jsonObject.get(SystemConstant.HTML_PATH);
-        String url = SystemConstant.TEMP_FILES_DIR + File.separator + filePath;
-        File htmlFile = new File(url);
+        String type = basicAttachment.getType();
+        String filePath = null;
+        String url = null;
+        File htmlFile = null;
+        if (Objects.nonNull(type) && Objects.equals(type, SystemConstant.FTL_PREFIX)) {
+            filePath = (String) jsonObject.get(SystemConstant.HTML_PATH);
+            url = SystemConstant.TEMP_FILES_DIR + File.separator + filePath;
+            htmlFile = new File(url);
+        } else if (Objects.nonNull(type) && Objects.equals(type, SystemConstant.HTML_PREFIX)) {
+            filePath = (String) jsonObject.get(SystemConstant.PATH);
+            url = SystemConstant.TEMP_FILES_DIR + File.separator + filePath;
+            htmlFile = ossUtil.ossDownload(filePath, url);
+        }
         String pdfDirName = filePath.replaceAll(SystemConstant.HTML_PREFIX, SystemConstant.PDF_PREFIX).replaceAll(UploadFileEnum.HTML.name().toLowerCase(), UploadFileEnum.PDF.name().toLowerCase());
         String destUrl = SystemConstant.PDF_TEMP_FILES_DIR + File.separator + pdfDirName;
         HtmlToPdfUtil.convert(htmlFile.getPath(), destUrl, PageSizeEnum.A4);
@@ -234,15 +244,23 @@ public class BasicAttachmentServiceImpl extends ServiceImpl<BasicAttachmentMappe
         if (oss) {//上传至oss
             ossUtil.ossUpload(pdfDirName, pdfFile, BinaryUtil.toBase64String(HexUtils.decodeHex(fileMd5)));
             jsonObject.put(SystemConstant.PDF_PATH, pdfDirName);
-            jsonObject.put(SystemConstant.UPLOAD_TYPE, new UploadFileEnum[]{
-                    UploadFileEnum.FILE,
-                    UploadFileEnum.HTML,
-                    UploadFileEnum.PDF
-            });
+            if (Objects.nonNull(type) && Objects.equals(type, SystemConstant.FTL_PREFIX)) {
+                jsonObject.put(SystemConstant.UPLOAD_TYPE, new UploadFileEnum[]{
+                        UploadFileEnum.FILE,
+                        UploadFileEnum.HTML,
+                        UploadFileEnum.PDF
+                });
+            } else {
+                jsonObject.put(SystemConstant.UPLOAD_TYPE, new UploadFileEnum[]{
+                        UploadFileEnum.FILE,
+                        UploadFileEnum.PDF
+                });
+                htmlFile.delete();
+            }
         }
         basicAttachment.setPath(jsonObject.toJSONString());
         for (int i = 0; i < printCount; i++) {
-            variablePdfList.add(pdfFile.getPath());
+            pdfList.add(pdfFile.getPath());
         }
         this.updateById(basicAttachment);
         return basicAttachment;

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

@@ -209,6 +209,12 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                 if (Objects.nonNull(examPrintPlan.getOrdinaryContent())) {
                     //获取普通印品
                     JSONArray jsonArrayOrdinary = JSONArray.parseArray(examPrintPlan.getOrdinaryContent());
+                    for (int i = 0; i < jsonArrayOrdinary.size(); i++) {
+                        JSONObject jsonObjectOrdinary = jsonArrayOrdinary.getJSONObject(i);
+                        Long attachmentId = (Long) jsonObjectOrdinary.get("attachmentId");
+                        BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
+                        createCheckIn(basicAttachment, ordinaryPdfList, (Integer) jsonObjectOrdinary.get("backupCount"));
+                    }
                 }
 
                 for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
@@ -526,6 +532,28 @@ public class TaskLogicServiceImpl implements TaskLogicService {
         return null;
     }
 
+    /**
+     * 创建登记表
+     *
+     * @param basicAttachment
+     * @param ordinaryPdfList
+     * @param printCount
+     */
+    private void createCheckIn(BasicAttachment basicAttachment, List<String> ordinaryPdfList, Integer printCount) throws IOException {
+        String type = basicAttachment.getType();
+        JSONObject jsonObject = JSONObject.parseObject(basicAttachment.getPath());
+        if (Objects.nonNull(type) && Objects.equals(type, SystemConstant.PDF_PREFIX)) {
+            String filePath = (String) jsonObject.get(SystemConstant.PATH);
+            String url = SystemConstant.TEMP_FILES_DIR + File.separator + filePath;
+            File localFile = ossUtil.ossDownload(filePath, url);
+            for (int i = 0; i < printCount; i++) {
+                ordinaryPdfList.add(localFile.getPath());
+            }
+        } else {
+            basicAttachmentService.saveAttachmentPdf(basicAttachment, ordinaryPdfList, printCount);
+        }
+    }
+
     /**
      * 生成卷袋贴
      *