Jelajahi Sumber

pdf生成bug

xiaof 3 tahun lalu
induk
melakukan
98e00a50e5

+ 17 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/PaperPdfDto.java

@@ -20,6 +20,9 @@ public class PaperPdfDto implements Serializable {
     @ApiModelProperty(name = "页面大小")
     @ApiModelProperty(name = "页面大小")
     int pages;
     int pages;
 
 
+    @ApiModelProperty(name = "卷型")
+    String type;
+
     public PaperPdfDto() {
     public PaperPdfDto() {
 
 
     }
     }
@@ -29,6 +32,12 @@ public class PaperPdfDto implements Serializable {
         this.pages = pages;
         this.pages = pages;
     }
     }
 
 
+    public PaperPdfDto(String type, File file, int pages) {
+        this.type = type;
+        this.file = file;
+        this.pages = pages;
+    }
+
     public File getFile() {
     public File getFile() {
         return file;
         return file;
     }
     }
@@ -44,4 +53,12 @@ public class PaperPdfDto implements Serializable {
     public void setPages(int pages) {
     public void setPages(int pages) {
         this.pages = pages;
         this.pages = pages;
     }
     }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
 }
 }

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

@@ -329,11 +329,12 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                             List<String> paperTypes = Arrays.asList(paperType.split(",")).stream().sorted(Comparator.comparing(String::valueOf)).collect(Collectors.toList());
                             List<String> paperTypes = Arrays.asList(paperType.split(",")).stream().sorted(Comparator.comparing(String::valueOf)).collect(Collectors.toList());
                             int i = 0;
                             int i = 0;
                             for (ExamStudent t : examStudentList) {
                             for (ExamStudent t : examStudentList) {
+                                int mod = i % examTaskDetail.getDrawCount().intValue();
+                                String stuPaperType = paperTypes.get(mod);
                                 if (Objects.nonNull(pdfDto)) {
                                 if (Objects.nonNull(pdfDto)) {
-                                    createPdfUtil.getExamStudentPaperPdf(paperPdfDto, paperPdfTempList);
+                                    createPdfUtil.getExamStudentPaperPdf(stuPaperType, paperPdfDto, paperPdfTempList);
                                 }
                                 }
-                                int mod = i % examTaskDetail.getDrawCount().intValue();
-                                t.setPaperType(paperTypes.get(mod));
+                                t.setPaperType(stuPaperType);
                                 basicAttachmentList.add(createPdfUtil.examStudentHtml(attachmentIds, studentContent, t, examDetail, examDetailCourse, sysUser.getId(), examStudentTempPdfList));
                                 basicAttachmentList.add(createPdfUtil.examStudentHtml(attachmentIds, studentContent, t, examDetail, examDetailCourse, sysUser.getId(), examStudentTempPdfList));
                                 i++;
                                 i++;
                             }
                             }

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

@@ -394,19 +394,23 @@ public class CreatePdfUtil {
     /**
     /**
      * 获取试卷pdf
      * 获取试卷pdf
      *
      *
+     *
+     * @param stuPaperType
      * @param paperPdfDto
      * @param paperPdfDto
      * @param pdfList
      * @param pdfList
      * @return
      * @return
      * @throws IOException
      * @throws IOException
      */
      */
-    public PdfDto getExamStudentPaperPdf(List<PaperPdfDto> paperPdfDto, List<PdfDto> pdfList) throws IOException {
+    public PdfDto getExamStudentPaperPdf(String stuPaperType, List<PaperPdfDto> paperPdfDto, List<PdfDto> pdfList) throws IOException {
         Set<String> pagesList = new HashSet<>();
         Set<String> pagesList = new HashSet<>();
         if (!CollectionUtils.isEmpty(paperPdfDto)) {
         if (!CollectionUtils.isEmpty(paperPdfDto)) {
             for (PaperPdfDto dto : paperPdfDto) {
             for (PaperPdfDto dto : paperPdfDto) {
-                int pages = dto.getPages();
-                pagesList.add(String.valueOf(pages));
-                PdfDto pdfDto = PdfUtil.addPdfPage(dto.getFile());
-                pdfList.add(new PdfDto(dto.getFile().getPath(), PageSizeEnum.A3, pdfDto.getPageCount()));
+                if(stuPaperType.equals(dto.getType())){
+                    int pages = dto.getPages();
+                    pagesList.add(String.valueOf(pages));
+                    PdfDto pdfDto = PdfUtil.addPdfPage(dto.getFile());
+                    pdfList.add(new PdfDto(dto.getFile().getPath(), PageSizeEnum.A3, pdfDto.getPageCount()));
+                }
             }
             }
             return new PdfDto(PageSizeEnum.A3, String.join(",", pagesList));
             return new PdfDto(PageSizeEnum.A3, String.join(",", pagesList));
         } else {
         } else {
@@ -469,7 +473,7 @@ public class CreatePdfUtil {
                     if (Objects.equals(name.toUpperCase(), type.toUpperCase())) {
                     if (Objects.equals(name.toUpperCase(), type.toUpperCase())) {
                         File file = teachcloudCommonService.getFile(basicAttachment.getPath(), false);
                         File file = teachcloudCommonService.getFile(basicAttachment.getPath(), false);
                         int pages = (int) object.get("pages");
                         int pages = (int) object.get("pages");
-                        paperPdfDto = new PaperPdfDto(file, pages);
+                        paperPdfDto = new PaperPdfDto(type, file, pages);
                         paperPdfDtoList.add(paperPdfDto);
                         paperPdfDtoList.add(paperPdfDto);
                         break;
                         break;
                     }
                     }