wangliang 4 anni fa
parent
commit
82ccb0752b

+ 12 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/CreatePdfUtil.java

@@ -67,6 +67,9 @@ public class CreatePdfUtil {
      * @param printCount
      * @param printCount
      */
      */
     public void createCheckIn(BasicAttachment basicAttachment, List<PdfDto> ordinaryPdfList, Integer printCount) throws IOException, DocumentException {
     public void createCheckIn(BasicAttachment basicAttachment, List<PdfDto> ordinaryPdfList, Integer printCount) throws IOException, DocumentException {
+        if (Objects.isNull(basicAttachment)) {
+            throw ExceptionResultEnum.ERROR.exception("找不到附件");
+        }
         String type = basicAttachment.getType();
         String type = basicAttachment.getType();
         JSONObject jsonObject = JSONObject.parseObject(basicAttachment.getPath());
         JSONObject jsonObject = JSONObject.parseObject(basicAttachment.getPath());
         if (Objects.nonNull(type) && Objects.equals(type, SystemConstant.PDF_PREFIX)) {
         if (Objects.nonNull(type) && Objects.equals(type, SystemConstant.PDF_PREFIX)) {
@@ -94,6 +97,9 @@ public class CreatePdfUtil {
      * @throws IOException
      * @throws IOException
      */
      */
     public void createPaperPackage(BasicAttachment basicAttachment, String schoolName, ExamDetailCourse examDetailCourse, List<ExamStudent> examStudentList, List<PdfDto> variablePdfList, Integer printCount) throws IOException {
     public void createPaperPackage(BasicAttachment basicAttachment, String schoolName, ExamDetailCourse examDetailCourse, List<ExamStudent> examStudentList, List<PdfDto> variablePdfList, Integer printCount) throws IOException {
+        if (Objects.isNull(basicAttachment)) {
+            throw ExceptionResultEnum.ERROR.exception("找不到附件");
+        }
         Map<String, Object> htmlMap = new HashMap<>();
         Map<String, Object> htmlMap = new HashMap<>();
         htmlMap.put("examDetailCourseId", examDetailCourse.getId());
         htmlMap.put("examDetailCourseId", examDetailCourse.getId());
         htmlMap.put("schoolName", schoolName);
         htmlMap.put("schoolName", schoolName);
@@ -135,6 +141,9 @@ public class CreatePdfUtil {
      * @param printCount
      * @param printCount
      */
      */
     public void createSignBook(BasicAttachment basicAttachment, String schoolName, ExamDetailCourse examDetailCourse, List<ExamStudent> examStudentList, List<PdfDto> variablePdfList, Integer printCount) throws IOException {
     public void createSignBook(BasicAttachment basicAttachment, String schoolName, ExamDetailCourse examDetailCourse, List<ExamStudent> examStudentList, List<PdfDto> variablePdfList, Integer printCount) throws IOException {
+        if (Objects.isNull(basicAttachment)) {
+            throw ExceptionResultEnum.ERROR.exception("找不到附件");
+        }
         Map<String, Object> htmlMap = new HashMap<>();
         Map<String, Object> htmlMap = new HashMap<>();
         htmlMap.put("examDetailCourseId", examDetailCourse.getId());
         htmlMap.put("examDetailCourseId", examDetailCourse.getId());
         htmlMap.put("schoolName", schoolName);
         htmlMap.put("schoolName", schoolName);
@@ -250,6 +259,9 @@ public class CreatePdfUtil {
             if (Objects.nonNull(object.get("attachmentId"))) {
             if (Objects.nonNull(object.get("attachmentId"))) {
                 Long attachmentId = Long.parseLong((String) (object.get("attachmentId")));
                 Long attachmentId = Long.parseLong((String) (object.get("attachmentId")));
                 BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
                 BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
+                if (Objects.isNull(basicAttachment)) {
+                    throw ExceptionResultEnum.ERROR.exception("找不到附件");
+                }
                 File file = commonService.getFile(basicAttachment.getPath(), false);
                 File file = commonService.getFile(basicAttachment.getPath(), false);
                 int pageCount = PdfUtil.addPdfPage(file);
                 int pageCount = PdfUtil.addPdfPage(file);
                 pdfList[0].add(new PdfDto(file.getPath(), PageSizeEnum.A3, pageCount));
                 pdfList[0].add(new PdfDto(file.getPath(), PageSizeEnum.A3, pageCount));