wangliang 4 년 전
부모
커밋
fbd8bf736b

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

@@ -70,10 +70,10 @@ public class ExamDetail extends BaseEntity implements Serializable {
     private String packageCode;
 
     @TableField("pages_a3")
-    private String pagesA3;
+    private Integer pagesA3;
 
     @TableField("pages_a4")
-    private String pagesA4;
+    private Integer pagesA4;
 
     private Boolean validate;
 
@@ -197,19 +197,19 @@ public class ExamDetail extends BaseEntity implements Serializable {
         this.packageCode = packageCode;
     }
 
-    public String getPagesA3() {
+    public Integer getPagesA3() {
         return pagesA3;
     }
 
-    public void setPagesA3(String pagesA3) {
+    public void setPagesA3(Integer pagesA3) {
         this.pagesA3 = pagesA3;
     }
 
-    public String getPagesA4() {
+    public Integer getPagesA4() {
         return pagesA4;
     }
 
-    public void setPagesA4(String pagesA4) {
+    public void setPagesA4(Integer pagesA4) {
         this.pagesA4 = pagesA4;
     }
 

+ 22 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/ExamDetailCourse.java

@@ -37,10 +37,10 @@ public class ExamDetailCourse extends BaseEntity implements Serializable {
     private String paperNumber;
 
     @TableField("paper_pages_a3")
-    private String paperPagesA3;
+    private Integer paperPagesA3;
 
     @TableField("card_pages_a3")
-    private String cardPagesA3;
+    private Integer cardPagesA3;
 
     public Long getSchoolId() {
         return schoolId;
@@ -81,4 +81,24 @@ public class ExamDetailCourse extends BaseEntity implements Serializable {
     public void setPaperNumber(String paperNumber) {
         this.paperNumber = paperNumber;
     }
+
+    public static long getSerialVersionUID() {
+        return serialVersionUID;
+    }
+
+    public Integer getPaperPagesA3() {
+        return paperPagesA3;
+    }
+
+    public void setPaperPagesA3(Integer paperPagesA3) {
+        this.paperPagesA3 = paperPagesA3;
+    }
+
+    public Integer getCardPagesA3() {
+        return cardPagesA3;
+    }
+
+    public void setCardPagesA3(Integer cardPagesA3) {
+        this.cardPagesA3 = cardPagesA3;
+    }
 }

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

@@ -20,14 +20,12 @@ import com.qmth.distributed.print.business.service.*;
 import com.qmth.distributed.print.business.templete.service.TaskLogicService;
 import com.qmth.distributed.print.business.util.*;
 import com.qmth.distributed.print.business.util.excel.ExcelError;
-import com.qmth.distributed.print.common.contant.SpringContextHolder;
 import com.qmth.distributed.print.common.contant.SystemConstant;
 import com.qmth.distributed.print.common.enums.ExceptionResultEnum;
 import com.qmth.distributed.print.common.util.Base64Util;
 import com.qmth.distributed.print.common.util.HexUtils;
 import com.qmth.distributed.print.common.util.ResultUtil;
 import org.apache.commons.codec.digest.DigestUtils;
-import org.apache.commons.io.FileUtils;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.Row;
@@ -222,6 +220,11 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                 }
 
                 for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
+                    List<String> paperPdfTempList = new ArrayList<>();//所有试卷
+                    List<String> examStudentTempPdfList = new ArrayList<>();//所有题卡
+                    List<String> backupPaperTempPdfList = new ArrayList<>();//备份试卷
+                    List<String> cardPdfTempList = new ArrayList<>();//备份题卡
+
                     //查询试卷
                     QueryWrapper<ExamTask> examTaskQueryWrapper = new QueryWrapper<>();
                     examTaskQueryWrapper.lambda().eq(ExamTask::getSchoolId, sysUser.getSchoolId())
@@ -256,7 +259,9 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                         String paperType = getPaperType(examPrintPlan, examTaskDetail);
 
                         //获取试卷pdf
-                        getPaperPdf(examTaskDetail, examPrintPlan.getBackupCount(), paperPdfList, backupPaperPdfList);
+                        getPaperPdf(examTaskDetail, examPrintPlan.getBackupCount(), paperPdfTempList, backupPaperTempPdfList);
+                        paperPdfList.addAll(paperPdfTempList);
+                        backupPaperPdfList.addAll(backupPaperTempPdfList);
 
                         basicAttachmentList = Objects.isNull(basicAttachmentList) ? basicAttachmentList = new ArrayList<>() : basicAttachmentList;
                         for (ExamCardDetail examCardDetail : examCardDetailList) {
@@ -267,8 +272,9 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                             String studentContent = cardContent;
 
                             for (int i = 1; i <= examPrintPlan.getBackupCount(); i++) {
-                                basicAttachmentList.add(cardHtml(cardContent, paperType, examDetailCourse, examCard, jsonArray, sysUser.getId(), cardPdfList));
+                                basicAttachmentList.add(cardHtml(cardContent, paperType, examDetailCourse, examCard, jsonArray, sysUser.getId(), cardPdfTempList));
                             }
+                            cardPdfList.addAll(cardPdfTempList);
 
                             //查询考生
                             QueryWrapper<ExamStudent> examStudentQueryWrapper = new QueryWrapper<>();
@@ -294,8 +300,9 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                             }
 
                             for (ExamStudent t : examStudentList) {
-                                basicAttachmentList.add(examStudentHtml(attachmentIds, studentContent, t, paperType, examCard, sysUser.getId(), examStudentPdfList));
+                                basicAttachmentList.add(examStudentHtml(attachmentIds, studentContent, t, paperType, examCard, sysUser.getId(), examStudentTempPdfList));
                             }
+                            examStudentPdfList.addAll(examStudentTempPdfList);
                             examStudentService.saveOrUpdateBatch(examStudentList);
                             jsonObject.put("card", jsonArray);
                             examCardDetail.setAttachmentId(jsonObject.toJSONString());
@@ -303,7 +310,15 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                         examCardDetailService.saveOrUpdateBatch(examCardDetailList);
                     }
                     examTaskDetailService.saveOrUpdateBatch(examTaskDetailList);
+
+                    Integer paperPageA3 = 0;
+                    Integer cardPageA3 = 0;
+                    paperPageA3 = paperPageA3 + paperPdfTempList.size() + backupPaperTempPdfList.size();
+                    cardPageA3 = cardPageA3 + examStudentTempPdfList.size() + cardPdfTempList.size();
+                    examDetailCourse.setPaperPagesA3(paperPageA3);
+                    examDetailCourse.setCardPagesA3(cardPageA3);
                 }
+                detailCourseService.saveOrUpdateBatch(examDetailCourseList);
                 //合并pdf
                 basicAttachmentList.add(mergePdf(tbTask, examDetail, sysUser.getId(), variablePdfList, ordinaryPdfList, paperPdfList, examStudentPdfList, backupPaperPdfList, cardPdfList));
             }
@@ -363,7 +378,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
         ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
         ExcelUtil.excelMake(ExaminationResult.class, examinationResultList, outputStream);
         InputStream in = new ByteArrayInputStream(outputStream.toByteArray());
-        IoUtil.copy(in,outputStream);
+        IoUtil.copy(in, outputStream);
 
 //        UploadFileEnum.FILE/
         LocalDateTime nowTime = LocalDateTime.now();
@@ -377,7 +392,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
         JSONObject jsonObject = new JSONObject();
         stringJoiner.add(File.separator).add(SystemConstant.getUuid()).add(".").add(SystemConstant.XLSX);
 
-        String dirName = stringJoiner.toString().replaceAll("\\\\","/");
+        String dirName = stringJoiner.toString().replaceAll("\\\\", "/");
 //        File file = new File(dirName);
 //        ConvertUtil.inputStream2File(in,file);
         ossUtil.ossUpload(dirName, in, DigestUtils.md5Hex(in));
@@ -790,7 +805,14 @@ public class TaskLogicServiceImpl implements TaskLogicService {
     public BasicAttachment mergePdf(TBTask tbTask, ExamDetail examDetail, Long userId, List<String>... list) throws IOException {
         StringJoiner stringJoiner = new StringJoiner("").add(SystemConstant.PDF_TEMP_FILES_DIR).add(File.separator);
         List<String> mergePdfList = new ArrayList<>();
+        int pageA3Count = 0;
+        int pageA4Count = 0;
         for (int i = 0; i < list.length; i++) {
+            if (i < 2) {
+                pageA4Count = pageA4Count + list[i].size();
+            } else {
+                pageA3Count = pageA3Count + list[i].size();
+            }
             mergePdfList.addAll(list[i]);
         }
         String dirName = PdfUtil.mergePdf(mergePdfList.toArray(new String[mergePdfList.size()]), null);
@@ -799,6 +821,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
         tbTask.setImportFileName(basicAttachment.getName());
         tbTask.setImportFilePath(basicAttachment.getPath());
         examDetail.setAttachmentId(basicAttachment.getId());
+        examDetail.setPagesA3(pageA3Count);
+        examDetail.setPagesA4(pageA4Count);
         detailService.saveOrUpdate(examDetail);
         ossUtil.ossUpload(dirName, localPdfFile, BinaryUtil.toBase64String(HexUtils.decodeHex(DigestUtils.md5Hex(new FileInputStream(localPdfFile)))));
         localPdfFile.delete();