wangliang 4 rokov pred
rodič
commit
8dcc082e45

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

@@ -237,6 +237,11 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                             String paperType = Objects.nonNull(paperTypeParam) ? paperTypeParam : createPdfUtil.getPaperType(examPrintPlan, examTaskDetail, examDetail, examDetailCourse);
                             examTaskDetail.setRelatePaperType(paperType);
 
+                            //获取试卷pdf
+                            PdfDto pdfDto = createPdfUtil.getPaperPdf(paperType, examTaskDetail, examPrintPlan.getBackupCount(), null, backupPaperTempPdfList);
+                            examDetailCourse.setPaperPagesA3(Objects.nonNull(pdfDto) ? pdfDto.getPageCount() : examDetailCourse.getPaperPagesA3());
+                            backupPaperPdfList.addAll(backupPaperTempPdfList);
+
                             basicAttachmentList = Objects.isNull(basicAttachmentList) ? basicAttachmentList = new ArrayList<>() : basicAttachmentList;
                             for (ExamCardDetail examCardDetail : examCardDetailList) {
                                 createPdfUtil.getCardAttachmentId(examCardDetail, attachmentIds);
@@ -245,15 +250,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                                 String cardContent = createPdfUtil.replaceHtmlTemplete(examCardDetail);
                                 String studentContent = cardContent;
 
-                                PdfDto pdfDto = null;
                                 for (int i = 1; i <= examPrintPlan.getBackupCount(); i++) {
-                                    //获取试卷pdf
-                                    pdfDto = createPdfUtil.getPaperPdf(paperType, examTaskDetail, examPrintPlan.getBackupCount(), paperPdfTempList, backupPaperTempPdfList);
-                                    examDetailCourse.setPaperPagesA3(Objects.nonNull(pdfDto) ? pdfDto.getPageCount() : examDetailCourse.getPaperPagesA3());
-                                    paperPdfList.addAll(paperPdfTempList);
-                                    backupPaperPdfList.addAll(backupPaperTempPdfList);
-
-                                    //获取题卡
                                     BasicAttachment basicAttachment = createPdfUtil.cardHtml(String.format("%02d", i), cardContent, paperType, examDetail, examDetailCourse, examCard, jsonArray, sysUser.getId(), cardPdfTempList);
                                     examDetailCourse.setCardPagesA3(basicAttachment.getPages());
                                     basicAttachmentList.add(basicAttachment);
@@ -293,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);

+ 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);