Browse Source

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

xiaof 4 năm trước cách đây
mục cha
commit
558a484655

+ 3 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/cache/CreatePdfCacheUtil.java

@@ -2,8 +2,10 @@ package com.qmth.distributed.print.business.cache;
 
 import com.qmth.distributed.print.business.util.RedisUtil;
 import com.qmth.distributed.print.common.contant.SpringContextHolder;
+import com.qmth.distributed.print.common.contant.SystemConstant;
 
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 
 /**
  * @Description: 生成pdf cache
@@ -17,6 +19,7 @@ public class CreatePdfCacheUtil {
 
     public static void setCurrentPaperType(Long printPlanId, Map<String, Object> map) {
         redisUtil.setForHash(RedisKeyHelper.printPlanIdCurrentPaperTypeKey(printPlanId), map);
+        redisUtil.expire(RedisKeyHelper.printPlanIdCurrentPaperTypeKey(printPlanId), SystemConstant.REDIS_CREATE_PDF_EXPIRE_TIME, TimeUnit.SECONDS);
     }
 
     public static Map getCurrentPaperType(Long printPlanId) {

+ 4 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicExamRuleServiceImpl.java

@@ -91,10 +91,11 @@ public class BasicExamRuleServiceImpl extends ServiceImpl<BasicExamRuleMapper, B
                         String enable1 = String.valueOf(map1.get("enable"));
                         if (code.equals(code1) && name.equals(name1) && enable.equals(enable1)) {
                             flag = false;
+                            break;
                         }
-                        if (flag) {
-                            throw ExceptionResultEnum.ERROR.exception("有未结束的印刷计划,不能修改扩展字段");
-                        }
+                    }
+                    if (flag) {
+                        throw ExceptionResultEnum.ERROR.exception("有未结束的印刷计划,不能修改扩展字段");
                     }
                 }
             }

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

@@ -238,9 +238,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                             examTaskDetail.setRelatePaperType(paperType);
 
                             //获取试卷pdf
-                            PdfDto pdfDto = createPdfUtil.getPaperPdf(paperType, examTaskDetail, examPrintPlan.getBackupCount(), paperPdfTempList, backupPaperTempPdfList);
+                            PdfDto pdfDto = createPdfUtil.getPaperPdf(paperType, examTaskDetail, examPrintPlan.getBackupCount(), null, backupPaperTempPdfList);
                             examDetailCourse.setPaperPagesA3(Objects.nonNull(pdfDto) ? pdfDto.getPageCount() : examDetailCourse.getPaperPagesA3());
-                            paperPdfList.addAll(paperPdfTempList);
                             backupPaperPdfList.addAll(backupPaperTempPdfList);
 
                             basicAttachmentList = Objects.isNull(basicAttachmentList) ? basicAttachmentList = new ArrayList<>() : basicAttachmentList;
@@ -291,6 +290,9 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                                 });
 
                                 for (ExamStudent t : examStudentList) {
+                                    createPdfUtil.getPaperPdf(paperType, examTaskDetail, 1, paperPdfTempList, null);
+                                    paperPdfList.addAll(paperPdfTempList);
+
                                     basicAttachmentList.add(createPdfUtil.examStudentHtml(attachmentIds, studentContent, t, paperType, examCard, sysUser.getId(), examStudentTempPdfList));
                                 }
                                 examStudentPdfList.addAll(examStudentTempPdfList);
@@ -662,7 +664,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
 
             // 处理试卷样品
             List<Map> paperInfo = JSONObject.parseArray(examTaskDetail.getPaperAttachmentIds(), Map.class);
-            if (Objects.isNull(paperInfo)){
+            if (Objects.isNull(paperInfo)) {
                 throw ExceptionResultEnum.ERROR.exception("试卷信息不存在");
             }
             System.out.println("paperInfo = " + JSON.toJSONString(paperInfo));
@@ -746,7 +748,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                 }
                 FileCopyUtils.copy(bytes, localFile);
             }
-            count ++;
+            count++;
         }
         ZipUtil.zip(zipLocalRootPath, zipFile.getPath(), true);
         ossUtil.ossUpload(dirNameTmp, zipFile, BinaryUtil.toBase64String(HexUtils.decodeHex(DigestUtils.md5Hex(new FileInputStream(zipFile)))));

+ 7 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/CreatePdfUtil.java

@@ -320,9 +320,13 @@ public class CreatePdfUtil {
                     pages = (int) object.get("pages");
                     tag = pages > 2 ? true : false;
                     PdfDto pdfDto = PdfUtil.addPdfPage(file);
-                    pdfList[0].add(new PdfDto(file.getPath(), PageSizeEnum.A3, pdfDto.getPageCount()));
-                    for (int j = 1; j <= backupCount; j++) {
-                        pdfList[1].add(new PdfDto(file.getPath(), PageSizeEnum.A3, pdfDto.getPageCount()));
+                    if (Objects.nonNull(pdfList[0])) {
+                        pdfList[0].add(new PdfDto(file.getPath(), PageSizeEnum.A3, pdfDto.getPageCount()));
+                    }
+                    if (Objects.nonNull(pdfList[1])) {
+                        for (int j = 1; j <= backupCount; j++) {
+                            pdfList[1].add(new PdfDto(file.getPath(), PageSizeEnum.A3, pdfDto.getPageCount()));
+                        }
                     }
                 }
                 return new PdfDto(PageSizeEnum.A3, pages, tag);

+ 1 - 0
distributed-print-common/src/main/java/com/qmth/distributed/print/common/contant/SystemConstant.java

@@ -92,6 +92,7 @@ public class SystemConstant {
      */
     public static final int DEFAULT_SESSION_EXPIRE = 1;//过期时间1天
     public static final long REDIS_DEFAULT_EXPIRE_TIME = 24 * 60L * 60L;//过期时间24小时
+    public static final long REDIS_CREATE_PDF_EXPIRE_TIME = 1 * 60L * 60L;//过期时间1小时
 
     /**
      * redis lock