wangliang 4 éve
szülő
commit
1dfc18425b

+ 13 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/ExamDetailCourse.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.qmth.distributed.print.business.base.BaseEntity;
+import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
 
@@ -44,6 +45,18 @@ public class ExamDetailCourse extends BaseEntity implements Serializable {
     @TableField("card_pages_a3")
     private Integer cardPagesA3;
 
+    @ApiModelProperty(value = "当前试卷类型")
+    @TableField("paper_type")
+    private String paperType;
+
+    public String getPaperType() {
+        return paperType;
+    }
+
+    public void setPaperType(String paperType) {
+        this.paperType = paperType;
+    }
+
     public Long getSchoolId() {
         return schoolId;
     }

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

@@ -233,6 +233,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                             //抽取卷型
                             String paperType = Objects.nonNull(paperTypeParam) ? paperTypeParam : createPdfUtil.getPaperType(examPrintPlan, examTaskDetail, examDetail, examDetailCourse);
                             examTaskDetail.setRelatePaperType(paperType);
+                            examDetailCourse.setPaperType(paperType);
 
                             PaperPdfDto paperPdfDto = createPdfUtil.getPaperPdfFile(paperType, examTaskDetail);
 
@@ -250,7 +251,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                                 String studentContent = cardContent;
 
                                 for (int i = 1; i <= examPrintPlan.getBackupCount(); i++) {
-                                    BasicAttachment basicAttachment = createPdfUtil.cardHtml(String.format("%02d", i), cardContent, paperType, examDetail, examDetailCourse, examCard, jsonArray, sysUser.getId(), cardPdfTempList);
+                                    BasicAttachment basicAttachment = createPdfUtil.cardHtml(String.format("%02d", i), cardContent, examDetail, examDetailCourse, examCard, jsonArray, sysUser.getId(), cardPdfTempList);
                                     examDetailCourse.setCardPagesA3(basicAttachment.getPages());
                                     basicAttachmentList.add(basicAttachment);
                                 }

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

@@ -281,7 +281,7 @@ public class CreatePdfUtil {
      * @param attachmentIds
      */
     public void getCardAttachmentId(ExamCardDetail examCardDetail, Set<Long> attachmentIds) {
-        if (Objects.nonNull(examCardDetail.getAttachmentId())) {
+        if (Objects.nonNull(examCardDetail.getAttachmentId()) && !Objects.equals("", examCardDetail.getAttachmentId())) {
             JSONObject jsonObjectCard = JSONObject.parseObject(examCardDetail.getAttachmentId());
             JSONArray jsonArrayCard = (JSONArray) jsonObjectCard.get("card");
             for (int i = 0; i < jsonArrayCard.size(); i++) {
@@ -561,7 +561,6 @@ public class CreatePdfUtil {
      * 通用题卡html
      *
      * @param cardContent
-     * @param paperType
      * @param examDetailCourse
      * @param examCard
      * @param jsonArray
@@ -570,12 +569,12 @@ public class CreatePdfUtil {
      * @return
      * @throws IOException
      */
-    public BasicAttachment cardHtml(String sequence, String cardContent, String paperType, ExamDetail examDetail, ExamDetailCourse examDetailCourse, ExamCard examCard, JSONArray jsonArray, Long userId, List<PdfDto> cardPdfList) throws IOException {
+    public BasicAttachment cardHtml(String sequence, String cardContent, ExamDetail examDetail, ExamDetailCourse examDetailCourse, ExamCard examCard, JSONArray jsonArray, Long userId, List<PdfDto> cardPdfList) throws IOException {
         //通用题卡
         String cardTemp = cardContent;
-        cardTemp = cardTemp.replaceAll("\\$\\{paperTypeName\\}", paperType);
+        cardTemp = cardTemp.replaceAll("\\$\\{paperTypeName\\}", examDetailCourse.getPaperType());
         //随机生成试卷条码并将图片转成base64
-        cardTemp = cardTemp.replaceAll("\\$\\{paperType\\}", GoogleBarCodeUtil.createBarCode(SystemConstant.convertPaperType(paperType), false));
+        cardTemp = cardTemp.replaceAll("\\$\\{paperType\\}", GoogleBarCodeUtil.createBarCode(SystemConstant.convertPaperType(examDetailCourse.getPaperType()), false));
         //通用题卡生成卷袋贴条码
         String packageCode = examDetail.getPackageCode() + sequence;
         String packageCodeImg = GoogleBarCodeUtil.createBarCode(packageCode, false);
@@ -583,7 +582,7 @@ public class CreatePdfUtil {
         cardTemp = cardTemp.replaceAll("<div class=\"page-box page-box-0\">", packageCodeDiv);
         BasicAttachment cardAttachment = basicAttachmentService.saveAttachmentHtml(examCard.getSchoolId() + "|" + examCard.getCourseCode(), cardTemp, userId, cardPdfList);
         JSONObject object = new JSONObject();
-        object.put("name", paperType);
+        object.put("name", examDetailCourse.getPaperType());
         object.put("examDetailCourseId", examDetailCourse.getId());
         object.put("attachmentId", cardAttachment.getId());
         object.put("packageCode", packageCode);