xiaofei 1 éve
szülő
commit
9efd71f360
61 módosított fájl, 909 hozzáadás és 2750 törlés
  1. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ExamDetailCourseFieldsDto.java
  2. 0 69
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ExamStudentPdfInfoDto.java
  3. 2 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ExaminationImportDto.java
  4. 0 187
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/MarkStudentImportDto.java
  5. 8 6
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/PdfPackageDto.java
  6. 5 3
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/PdfSignDto.java
  7. 0 24
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/StudentExtendDto.java
  8. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/importFile/BasicExamStudentImport.java
  9. 0 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/importFile/BasicExamStudentParseDto.java
  10. 133 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/pdf/ExamStudentInfo.java
  11. 18 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/params/ExamDetailList.java
  12. 15 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/ClientStatus.java
  13. 2 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/ExamDetailCourse.java
  14. 0 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ConditionMapper.java
  15. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamDetailCourseMapper.java
  16. 0 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamDetailMapper.java
  17. 3 6
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamStudentMapper.java
  18. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ClientService.java
  19. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ClientStatusService.java
  20. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamDetailCourseService.java
  21. 2 3
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamDetailService.java
  22. 6 4
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamStudentService.java
  23. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/PrintCommonService.java
  24. 2 3
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicExamRuleServiceImpl.java
  25. 6 4
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicTemplateServiceImpl.java
  26. 3 3
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ClientServiceImpl.java
  27. 4 4
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ClientStatusServiceImpl.java
  28. 9 18
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/DownloadServiceImpl.java
  29. 4 5
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamCardServiceImpl.java
  30. 16 3
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamDetailCourseServiceImpl.java
  31. 5 10
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamDetailServiceImpl.java
  32. 14 10
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamStudentServiceImpl.java
  33. 3 3
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskAssignPaperTypeServiceImpl.java
  34. 7 7
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskDetailServiceImpl.java
  35. 8 8
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskServiceImpl.java
  36. 3 3
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/PrintCommonServiceImpl.java
  37. 3 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/AsyncCreatePdfTemplateService.java
  38. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/AsyncExaminationImportTemplateService.java
  39. 1 15
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/SyncBasicExamStudentImportService.java
  40. 2 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/ImportLogicServiceImpl.java
  41. 41 34
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/PdfTaskLogicServiceImpl.java
  42. 6 6
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/TaskLogicServiceImpl.java
  43. 346 778
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/CreatePdfUtil.java
  44. 12 147
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/CreatePrintPdfUtil.java
  45. 66 134
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/PdfFillUtils.java
  46. 0 1146
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/pdf/CreatePdfNewUtil.java
  47. 1 1
      distributed-print-business/src/main/resources/mapper/ExamDetailCourseMapper.xml
  48. 0 14
      distributed-print-business/src/main/resources/mapper/ExamDetailMapper.xml
  49. 21 49
      distributed-print-business/src/main/resources/mapper/ExamStudentMapper.xml
  50. 8 1
      distributed-print/install/mysql/upgrade/3.4.0.sql
  51. 1 1
      distributed-print/src/main/java/com/qmth/distributed/print/api/ExamTaskQueryController.java
  52. 2 2
      distributed-print/src/main/java/com/qmth/distributed/print/api/client/PrintController.java
  53. 7 14
      distributed-print/src/main/java/com/qmth/distributed/print/api/mark/ScanAnswerController.java
  54. 1 1
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/examRule/CodeName.java
  55. 1 1
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/examRule/CodeNameEnable.java
  56. 1 1
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/examRule/CodeNameEnableDisabled.java
  57. 1 1
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/examRule/CodeNameEnableRate.java
  58. 1 1
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/examRule/CodeNameEnableValue.java
  59. 1 1
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/examRule/FieldsDto.java
  60. 58 1
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/entity/BasicExamStudent.java
  61. 42 0
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/enums/BasicExamStudentStatusEnum.java

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ExamDetailCourseFieldsDto.java

@@ -1,6 +1,6 @@
 package com.qmth.distributed.print.business.bean.dto;
 
-import com.qmth.distributed.print.business.bean.examRule.CodeName;
+import com.qmth.teachcloud.common.bean.examRule.CodeName;
 import com.qmth.distributed.print.business.entity.ExamDetailCourse;
 
 import java.util.List;

+ 0 - 69
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ExamStudentPdfInfoDto.java

@@ -1,69 +0,0 @@
-package com.qmth.distributed.print.business.bean.dto;
-
-import com.qmth.distributed.print.business.entity.ExamStudent;
-import io.swagger.annotations.ApiModelProperty;
-
-/**
- * 生成pdf需要的考生信息
- */
-public class ExamStudentPdfInfoDto extends ExamStudent {
-
-    private String courseCode;
-    private String courseName;
-    private String paperNumber;
-    private String examPlace;
-    private String examRoom;
-    private String teacherName;
-
-    public String getCourseCode() {
-        return courseCode;
-    }
-
-    public void setCourseCode(String courseCode) {
-        this.courseCode = courseCode;
-    }
-
-    public String getCourseName() {
-        return courseName;
-    }
-
-    public void setCourseName(String courseName) {
-        this.courseName = courseName;
-    }
-
-    @Override
-    public String getPaperNumber() {
-        return paperNumber;
-    }
-
-    @Override
-    public void setPaperNumber(String paperNumber) {
-        this.paperNumber = paperNumber;
-    }
-
-    public String getExamPlace() {
-        return examPlace;
-    }
-
-    public void setExamPlace(String examPlace) {
-        this.examPlace = examPlace;
-    }
-
-    public String getExamRoom() {
-        return examRoom;
-    }
-
-    public void setExamRoom(String examRoom) {
-        this.examRoom = examRoom;
-    }
-
-    @Override
-    public String getTeacherName() {
-        return teacherName;
-    }
-
-    @Override
-    public void setTeacherName(String teacherName) {
-        this.teacherName = teacherName;
-    }
-}

+ 2 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ExaminationImportDto.java

@@ -1,7 +1,7 @@
 package com.qmth.distributed.print.business.bean.dto;
 
-import com.qmth.distributed.print.business.bean.examRule.CodeNameEnableValue;
-import com.qmth.distributed.print.business.bean.examRule.FieldsDto;
+import com.qmth.teachcloud.common.bean.examRule.CodeNameEnableValue;
+import com.qmth.teachcloud.common.bean.examRule.FieldsDto;
 import com.qmth.teachcloud.common.annotation.ExcelDBFieldDesc;
 import io.swagger.annotations.ApiModelProperty;
 

+ 0 - 187
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/MarkStudentImportDto.java

@@ -1,187 +0,0 @@
-package com.qmth.distributed.print.business.bean.dto;
-
-import com.qmth.teachcloud.common.annotation.ExcelNote;
-import com.qmth.teachcloud.common.annotation.ExcelProperty;
-import io.swagger.annotations.ApiModelProperty;
-
-import javax.validation.constraints.NotNull;
-
-/**
- * @Description: 阅卷导入
- * @Author: CaoZixuan
- * @Date: 2024-03-09
- */
-public class MarkStudentImportDto {
-
-    @ApiModelProperty("课程名称")
-    @ExcelProperty(name = "课程名称", width = 10, index = 1)
-    @ExcelNote(value = "课程名称")
-    @NotNull
-    private String courseName;
-
-    @ApiModelProperty("课程编号")
-    @ExcelProperty(name = "课程编号", width = 10, index = 2)
-    @ExcelNote(value = "课程编号")
-    @NotNull
-    private String courseCode;
-
-    @ApiModelProperty("试卷编号")
-    @ExcelProperty(name = "试卷编号", width = 10, index = 3)
-    @ExcelNote(value = "试卷编号")
-    @NotNull
-    private String paperNumber;
-
-    @ApiModelProperty("姓名")
-    @ExcelProperty(name = "姓名", width = 10, index = 4)
-    @ExcelNote(value = "姓名")
-    @NotNull
-    private String studentName;
-
-    @ApiModelProperty("学号")
-    @ExcelProperty(name = "学号", width = 10, index = 5)
-    @ExcelNote(value = "学号")
-    @NotNull
-    private String studentCode;
-
-    @ApiModelProperty("学院")
-    @ExcelProperty(name = "学院", width = 10, index = 6)
-    @ExcelNote(value = "学院")
-    private String college;
-
-    @ApiModelProperty("专业")
-    @ExcelProperty(name = "专业", width = 10, index = 7)
-    @ExcelNote(value = "专业")
-    private String major;
-
-    @ApiModelProperty("班级")
-    @ExcelProperty(name = "班级", width = 10, index = 8)
-    @ExcelNote(value = "班级")
-    private String clazz;
-
-    @ApiModelProperty("考试日期")
-    @ExcelProperty(name = "考试日期", width = 10, index = 9)
-    @ExcelNote(value = "考试日期")
-    private String examDate;
-
-    @ApiModelProperty("考试时间")
-    @ExcelProperty(name = "考试时间", width = 10, index = 10)
-    @ExcelNote(value = "考试时间")
-    private String examTime;
-
-    @ApiModelProperty("考点")
-    @ExcelProperty(name = "考点", width = 10, index = 11)
-    @ExcelNote(value = "考点")
-    private String examPlace;
-
-    @ApiModelProperty("考场")
-    @ExcelProperty(name = "考场", width = 10, index = 12)
-    @ExcelNote(value = "考场")
-    private String examRoom;
-
-    @ApiModelProperty("异常信息")
-    private String errorMsg;
-
-    public String getCourseName() {
-        return courseName;
-    }
-
-    public void setCourseName(String courseName) {
-        this.courseName = courseName;
-    }
-
-    public String getCourseCode() {
-        return courseCode;
-    }
-
-    public void setCourseCode(String courseCode) {
-        this.courseCode = courseCode;
-    }
-
-    public String getPaperNumber() {
-        return paperNumber;
-    }
-
-    public void setPaperNumber(String paperNumber) {
-        this.paperNumber = paperNumber;
-    }
-
-    public String getStudentName() {
-        return studentName;
-    }
-
-    public void setStudentName(String studentName) {
-        this.studentName = studentName;
-    }
-
-    public String getStudentCode() {
-        return studentCode;
-    }
-
-    public void setStudentCode(String studentCode) {
-        this.studentCode = studentCode;
-    }
-
-    public String getCollege() {
-        return college;
-    }
-
-    public void setCollege(String college) {
-        this.college = college;
-    }
-
-    public String getMajor() {
-        return major;
-    }
-
-    public void setMajor(String major) {
-        this.major = major;
-    }
-
-    public String getClazz() {
-        return clazz;
-    }
-
-    public void setClazz(String clazz) {
-        this.clazz = clazz;
-    }
-
-    public String getExamDate() {
-        return examDate;
-    }
-
-    public void setExamDate(String examDate) {
-        this.examDate = examDate;
-    }
-
-    public String getExamTime() {
-        return examTime;
-    }
-
-    public void setExamTime(String examTime) {
-        this.examTime = examTime;
-    }
-
-    public String getExamPlace() {
-        return examPlace;
-    }
-
-    public void setExamPlace(String examPlace) {
-        this.examPlace = examPlace;
-    }
-
-    public String getExamRoom() {
-        return examRoom;
-    }
-
-    public void setExamRoom(String examRoom) {
-        this.examRoom = examRoom;
-    }
-
-    public String getErrorMsg() {
-        return errorMsg;
-    }
-
-    public void setErrorMsg(String errorMsg) {
-        this.errorMsg = errorMsg;
-    }
-}

+ 8 - 6
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/PdfPackageDto.java

@@ -1,5 +1,7 @@
 package com.qmth.distributed.print.business.bean.dto;
 
+import com.qmth.teachcloud.common.bean.examRule.CodeNameEnableValue;
+
 import java.util.List;
 import java.util.Map;
 
@@ -26,12 +28,12 @@ public class PdfPackageDto {
     /**
      * 标题信息
      */
-    private List<Map<String, String>> titlePlate;
+    private List<CodeNameEnableValue> titlePlate;
 
     /**
      * 基础板块信息
      */
-    private List<Map<String, String>> basicPlate;
+    private List<CodeNameEnableValue> basicPlate;
 
 
     public String getTitle() {
@@ -58,19 +60,19 @@ public class PdfPackageDto {
         this.packageNumber = packageNumber;
     }
 
-    public List<Map<String, String>> getTitlePlate() {
+    public List<CodeNameEnableValue> getTitlePlate() {
         return titlePlate;
     }
 
-    public void setTitlePlate(List<Map<String, String>> titlePlate) {
+    public void setTitlePlate(List<CodeNameEnableValue> titlePlate) {
         this.titlePlate = titlePlate;
     }
 
-    public List<Map<String, String>> getBasicPlate() {
+    public List<CodeNameEnableValue> getBasicPlate() {
         return basicPlate;
     }
 
-    public void setBasicPlate(List<Map<String, String>> basicPlate) {
+    public void setBasicPlate(List<CodeNameEnableValue> basicPlate) {
         this.basicPlate = basicPlate;
     }
 }

+ 5 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/PdfSignDto.java

@@ -1,5 +1,7 @@
 package com.qmth.distributed.print.business.bean.dto;
 
+import com.qmth.teachcloud.common.bean.examRule.CodeNameEnableValue;
+
 import java.util.List;
 import java.util.Map;
 
@@ -21,7 +23,7 @@ public class PdfSignDto {
     /**
      * 基础板块信息
      */
-    private List<Map<String, String>> basicPlate;
+    private List<CodeNameEnableValue> basicPlate;
 
     /**
      * 考生表头信息
@@ -55,11 +57,11 @@ public class PdfSignDto {
         this.packageNumber = packageNumber;
     }
 
-    public List<Map<String, String>> getBasicPlate() {
+    public List<CodeNameEnableValue> getBasicPlate() {
         return basicPlate;
     }
 
-    public void setBasicPlate(List<Map<String, String>> basicPlate) {
+    public void setBasicPlate(List<CodeNameEnableValue> basicPlate) {
         this.basicPlate = basicPlate;
     }
 

+ 0 - 24
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/StudentExtendDto.java

@@ -1,24 +0,0 @@
-package com.qmth.distributed.print.business.bean.dto;
-
-public class StudentExtendDto {
-
-    private String fieldName;
-
-    private Object value;
-
-    public String getFieldName() {
-        return fieldName;
-    }
-
-    public void setFieldName(String fieldName) {
-        this.fieldName = fieldName;
-    }
-
-    public Object getValue() {
-        return value;
-    }
-
-    public void setValue(Object value) {
-        this.value = value;
-    }
-}

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/importFile/BasicExamStudentImport.java

@@ -1,6 +1,6 @@
 package com.qmth.distributed.print.business.bean.dto.importFile;
 
-import com.qmth.distributed.print.business.bean.examRule.CodeNameEnableValue;
+import com.qmth.teachcloud.common.bean.examRule.CodeNameEnableValue;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.util.ArrayList;

+ 0 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/importFile/BasicExamStudentParseDto.java

@@ -1,9 +1,7 @@
 package com.qmth.distributed.print.business.bean.dto.importFile;
 
-import com.qmth.distributed.print.business.bean.examRule.CodeNameEnableValue;
 import io.swagger.annotations.ApiModelProperty;
 
-import java.util.ArrayList;
 import java.util.List;
 
 public class BasicExamStudentParseDto {

+ 133 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/pdf/ExamStudentInfo.java

@@ -0,0 +1,133 @@
+package com.qmth.distributed.print.business.bean.dto.pdf;
+
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.qmth.teachcloud.common.bean.examRule.CodeNameEnableValue;
+import io.swagger.annotations.ApiModelProperty;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ExamStudentInfo {
+
+    @ApiModelProperty("考务学生ID")
+    private Long examStudentId;
+    @ApiModelProperty("考生ID")
+    private Long studentId;
+    @ApiModelProperty("试卷类型")
+    private String paperType;
+    @ApiModelProperty("学号")
+    private String studentCode;
+    @ApiModelProperty("姓名")
+    private String studentName;
+    @ApiModelProperty("课程代码")
+    private String courseCode;
+    @ApiModelProperty("课程名称")
+    private String courseName;
+    @ApiModelProperty("考生题卡ID")
+    private Long attachmentId;
+    @ApiModelProperty("基础字段")
+    private String requiredFields;
+    @ApiModelProperty("扩展字段")
+    private String extendFields;
+    @ApiModelProperty("所有字段集合")
+    @TableField(exist = false)
+    private List<CodeNameEnableValue> fieldList;
+
+    public Long getExamStudentId() {
+        return examStudentId;
+    }
+
+    public void setExamStudentId(Long examStudentId) {
+        this.examStudentId = examStudentId;
+    }
+
+    public Long getStudentId() {
+        return studentId;
+    }
+
+    public void setStudentId(Long studentId) {
+        this.studentId = studentId;
+    }
+
+    public String getPaperType() {
+        return paperType;
+    }
+
+    public void setPaperType(String paperType) {
+        this.paperType = paperType;
+    }
+
+    public String getStudentCode() {
+        return studentCode;
+    }
+
+    public void setStudentCode(String studentCode) {
+        this.studentCode = studentCode;
+    }
+
+    public String getStudentName() {
+        return studentName;
+    }
+
+    public void setStudentName(String studentName) {
+        this.studentName = studentName;
+    }
+
+    public String getCourseCode() {
+        return courseCode;
+    }
+
+    public void setCourseCode(String courseCode) {
+        this.courseCode = courseCode;
+    }
+
+    public String getCourseName() {
+        return courseName;
+    }
+
+    public void setCourseName(String courseName) {
+        this.courseName = courseName;
+    }
+
+    public Long getAttachmentId() {
+        return attachmentId;
+    }
+
+    public void setAttachmentId(Long attachmentId) {
+        this.attachmentId = attachmentId;
+    }
+
+    public String getRequiredFields() {
+        return requiredFields;
+    }
+
+    public void setRequiredFields(String requiredFields) {
+        this.requiredFields = requiredFields;
+    }
+
+    public String getExtendFields() {
+        return extendFields;
+    }
+
+    public void setExtendFields(String extendFields) {
+        this.extendFields = extendFields;
+    }
+
+    public List<CodeNameEnableValue> getFieldList() {
+        List<CodeNameEnableValue> fieldList = new ArrayList<>();
+        if (StringUtils.isNotBlank(requiredFields)) {
+            CollectionUtils.addAll(fieldList, JSON.parseArray(requiredFields, CodeNameEnableValue.class));
+        }
+        if (StringUtils.isNotBlank(extendFields)) {
+            CollectionUtils.addAll(fieldList, JSON.parseArray(extendFields, CodeNameEnableValue.class));
+        }
+        return fieldList;
+    }
+
+    public void setFieldList(List<CodeNameEnableValue> fieldList) {
+        this.fieldList = fieldList;
+    }
+}

+ 18 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/params/ExamDetailList.java

@@ -11,6 +11,8 @@ public class ExamDetailList {
     private String examRoom;
     private String classId;
     private String className;
+    private Long examStartTime;
+    private Long examEndTime;
 
     private Double backupCount;
     private Integer studentCount;
@@ -35,6 +37,22 @@ public class ExamDetailList {
         this.className = className;
     }
 
+    public Long getExamStartTime() {
+        return examStartTime;
+    }
+
+    public void setExamStartTime(Long examStartTime) {
+        this.examStartTime = examStartTime;
+    }
+
+    public Long getExamEndTime() {
+        return examEndTime;
+    }
+
+    public void setExamEndTime(Long examEndTime) {
+        this.examEndTime = examEndTime;
+    }
+
     public Double getBackupCount() {
         return backupCount;
     }

+ 15 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/ClientStatus.java

@@ -52,6 +52,13 @@ public class ClientStatus extends BaseEntity implements Serializable {
     @TableField("print_plan_id")
     private Long printPlanId;
 
+    /**
+     * 课程ID
+     */
+    @JsonSerialize(using = ToStringSerializer.class)
+    @TableField("course_id")
+    private Long courseId;
+
     /**
      * 课程代码
      */
@@ -136,6 +143,14 @@ public class ClientStatus extends BaseEntity implements Serializable {
         this.printPlanId = printPlanId;
     }
 
+    public Long getCourseId() {
+        return courseId;
+    }
+
+    public void setCourseId(Long courseId) {
+        this.courseId = courseId;
+    }
+
     public String getCourseCode() {
         return courseCode;
     }

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

@@ -35,10 +35,10 @@ public class ExamDetailCourse extends BaseEntity implements Serializable {
     @TableField("course_id")
     private Long courseId;
 
-    @TableField("course_code")
+    @TableField(exist = false)
     private String courseCode;
 
-    @TableField("course_name")
+    @TableField(exist = false)
     private String courseName;
 
     @TableField("paper_number")

+ 0 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ConditionMapper.java

@@ -2,7 +2,6 @@ package com.qmth.distributed.print.business.mapper;
 
 import com.qmth.distributed.print.business.bean.result.PrintPlanBrief;
 import com.qmth.teachcloud.common.bean.dto.DataPermissionRule;
-import com.qmth.teachcloud.common.entity.BasicClazz;
 import com.qmth.teachcloud.common.entity.BasicCourse;
 import org.apache.ibatis.annotations.Param;
 

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamDetailCourseMapper.java

@@ -28,7 +28,7 @@ public interface ExamDetailCourseMapper extends BaseMapper<ExamDetailCourse> {
 
     List<BasicCourse> listCoursesByPrintPlanId(@Param("param") String param, @Param("printPlanIdList") List<Long> printPlanIdList);
 
-    List<ExamDetailCourse> listByPrintPlanIdAndCourseCodeAndPaperNumber(@Param("schoolId") Long schoolId, @Param("printPlanId") Long printPlanId, @Param("courseCode") String courseCode, @Param("paperNumber") String paperNumber);
+    List<ExamDetailCourse> listByPrintPlanIdAndCourseCodeAndPaperNumber(@Param("schoolId") Long schoolId, @Param("printPlanId") Long printPlanId, @Param("courseId") Long courseId, @Param("paperNumber") String paperNumber);
 
     List<ExamDetailCourse> listExamDetailByExamIdAndPaperNumber(@Param("schoolId") Long schoolId, @Param("examId") Long examId, @Param("paperNumber") String paperNumber);
 

+ 0 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamDetailMapper.java

@@ -126,7 +126,6 @@ public interface ExamDetailMapper extends BaseMapper<ExamDetail> {
 
     int countMakeupUsedByExamIdAndPaperNumber(@Param("examId") Long examId, @Param("paperNumber") String paperNumber);
 
-    List<ExamDetail> listByExamIdAndCourseCodeAndPaperNumber(@Param("schoolId") Long schoolId, @Param("examId") Long examId, @Param("courseCode") String courseCode, @Param("paperNumber") String paperNumber);
     List<ExamDetail> listByExamIdAndCourseIdAndPaperNumber(@Param("schoolId") Long schoolId, @Param("examId") Long examId, @Param("courseId") Long courseId, @Param("paperNumber") String paperNumber);
 
     List<ExamDetailCourseInitMarkDto> listPrintFinishPackageCode(@Param("examId") Long examId, @Param("paperNumber") String paperNumber, @Param("paperType") String paperType);

+ 3 - 6
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamStudentMapper.java

@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.qmth.distributed.print.business.bean.dto.ExamStudentCourseClassDto;
 import com.qmth.distributed.print.business.bean.dto.ExamStudentCourseDto;
 import com.qmth.distributed.print.business.bean.dto.ExamStudentDto;
-import com.qmth.distributed.print.business.bean.dto.ExamStudentPdfInfoDto;
+import com.qmth.distributed.print.business.bean.dto.pdf.ExamStudentInfo;
 import com.qmth.distributed.print.business.entity.ExamStudent;
 import org.apache.ibatis.annotations.Param;
 
@@ -42,16 +42,11 @@ public interface ExamStudentMapper extends BaseMapper<ExamStudent> {
      */
     List<ExamStudent> listExamStudentBySchoolIdAndClazzId(@Param("schoolId") Long schoolId, @Param("classId") String classId);
 
-    ExamStudentPdfInfoDto getByStudentId(Long id);
 
     @SuppressWarnings("MybatisXMapperMethodInspection")
     List<ExamStudentCourseClassDto> listExamStudentByPaperNumberAndPaperType(@Param("batchId") Long batchId, @Param("examId") Long examId, @Param("paperNumber") String paperNumber,
                                                                              @Param("paperType") String paperType);
 
-    List<String> listUserClass(@Param("schoolId") Long schoolId, @Param("examId") Long examId, @Param("paperNumber") String paperNumber);
-
-    ExamStudent listByExamDetailCourseIdLimit1(@Param("schoolId") Long schoolId, @Param("examDetailCourseId") Long examDetailCourseId);
-
     List<ExamStudent> listByExamDetailCourseIdNotIntMarkStudent(@Param("examDetailCourseId") Long examDetailCourseId, @Param("paperType") String paperType);
 
     /**
@@ -63,4 +58,6 @@ public interface ExamStudentMapper extends BaseMapper<ExamStudent> {
      * @return
      */
     ExamStudentDto queryExamStudent(@Param("examId") Long examId, @Param("courseCode") String courseCode, @Param("paperNumber") String paperNumber);
+
+    List<ExamStudentInfo> listByExamDetailCourseId(Long examDetailCourseId);
 }

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ClientService.java

@@ -16,7 +16,7 @@ public interface ClientService {
 
     List<Map<String, Object>> getPaperUrl(List<JSONObject> objects);
 
-    Boolean tagPass(Long printPlanId, String courseCode, String courseName, String paperNumber, String machineCode, Boolean isPass, Long userId);
+    Boolean tagPass(Long printPlanId, Long courseId, String courseName, String paperNumber, String machineCode, Boolean isPass, Long userId);
 
     Boolean updatePrintProgress(Long examDetailId, String machineCode, Integer printProgress, Boolean isPrint);
 

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ClientStatusService.java

@@ -12,5 +12,5 @@ import com.qmth.distributed.print.business.entity.ClientStatus;
  * @since 2021-04-19
  */
 public interface ClientStatusService extends IService<ClientStatus> {
-    Boolean tagPass(Long schoolId, Long printPlanId, String courseCode, String courseName, String paperNumber, String machineCode, Boolean isPass, Long userId);
+    Boolean tagPass(Long schoolId, Long printPlanId, Long courseId, String courseName, String paperNumber, String machineCode, Boolean isPass, Long userId);
 }

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamDetailCourseService.java

@@ -28,7 +28,7 @@ public interface ExamDetailCourseService extends IService<ExamDetailCourse> {
 
     List<BasicCourse> listCoursesByPrintPlanId(String param, List<Long> printPlanIdList);
 
-    List<ExamDetailCourse> listByPrintPlanIdAndCourseCodeAndPaperNumber(Long schoolId, Long printPlanId, String courseCode, String paperNumber);
+    List<ExamDetailCourse> listByPrintPlanIdAndCourseCodeAndPaperNumber(Long schoolId, Long printPlanId, Long courseId, String paperNumber);
 
     List<ExamDetailCourse> listExamDetailByExamIdAndPaperNumber(Long schoolId, Long examId, String paperNumber);
 

+ 2 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamDetailService.java

@@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.distributed.print.business.bean.dto.*;
 import com.qmth.distributed.print.business.bean.dto.initMarkData.ExamDetailCourseInitMarkDto;
 import com.qmth.distributed.print.business.bean.dto.initMarkData.InitExamDetailDto;
-import com.qmth.distributed.print.business.bean.examRule.FieldsDto;
+import com.qmth.teachcloud.common.bean.examRule.FieldsDto;
 import com.qmth.distributed.print.business.bean.result.ExaminationDetailResult;
 import com.qmth.distributed.print.business.bean.result.ExaminationResult;
 import com.qmth.distributed.print.business.bean.result.SummarizedDataResult;
@@ -183,7 +183,7 @@ public interface ExamDetailService extends IService<ExamDetail> {
      */
     void deleteExaminationData(Long printPlanId, ExamDataSourceEnum source);
 
-    List<ExamDetail> listByPrintPlanIdAndCourseCodeAndPaperNumber(Long schoolId, Long printPlanId, String courseCode, String paperNumber);
+    List<ExamDetail> listByPrintPlanIdAndCourseCodeAndPaperNumber(Long schoolId, Long printPlanId, Long courseId, String paperNumber);
 
     /**
      * 查询考务数据-场次导出数据源
@@ -195,7 +195,6 @@ public interface ExamDetailService extends IService<ExamDetail> {
 
     List<Map> listStudentByExamDetailCourseId(Long schoolId, Long examDetailCourseId, String ticketNumber, String type);
 
-    List<ExamDetail> listByCourseCodeAndPaperNumber(Long schoolId, Long examId, String courseCode, String paperNumber);
     List<ExamDetail> listByCourseIdAndPaperNumber(Long schoolId, Long examId, Long courseId, String paperNumber);
 
     boolean taskNormal(ExamDetail examDetail);

+ 6 - 4
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamStudentService.java

@@ -3,7 +3,7 @@ package com.qmth.distributed.print.business.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.distributed.print.business.bean.dto.ExamStudentCourseDto;
 import com.qmth.distributed.print.business.bean.dto.ExamStudentDto;
-import com.qmth.distributed.print.business.bean.dto.ExamStudentPdfInfoDto;
+import com.qmth.distributed.print.business.bean.dto.pdf.ExamStudentInfo;
 import com.qmth.distributed.print.business.entity.ExamStudent;
 import com.qmth.distributed.print.business.entity.ExamTask;
 import com.qmth.teachcloud.common.entity.SysUser;
@@ -34,13 +34,11 @@ public interface ExamStudentService extends IService<ExamStudent> {
      */
     List<ExamStudentCourseDto> queryBySchoolIdAndExamDetailCourseIds(Long schoolId, List<Long> examDetailCourseIds);
 
-    ExamStudentPdfInfoDto getByStudentId(Long id);
-
     void removeByExamDetailCourseId(Long id);
 
     List<ExamStudent> listByExamDetailCourseIdNotIntMarkStudent(Long examDetailCourseId, String paperType);
 
-    List<ExamStudent> listByExamDetailCourseId(Long examDetailCourseId);
+    List<ExamStudent> listByExamDetailCourseId1(Long examDetailCourseId);
 
     /**
      * 查询班级和老师信息
@@ -53,4 +51,8 @@ public interface ExamStudentService extends IService<ExamStudent> {
     ExamStudentDto queryExamStudent(Long examId, String courseCode, String paperNumber);
 
     List<ExamStudent> saveStudentForExamApply(ExamTask examTask, String extendFields, List<Long> examTaskStudentObjectParamList, Long examDetailCourseId, SysUser sysUser);
+
+    List<ExamStudentInfo> listByExamDetailCourseId(Long examDetailCourseId);
+
+    void updateAttachmentIdById(ExamStudentInfo t);
 }

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/PrintCommonService.java

@@ -181,7 +181,7 @@ public interface PrintCommonService {
      * @param paperNumber
      * @return
      */
-    Boolean checkExamDetailStatus(Long schoolId, Long printPlanId, Long examId, String courseCode, String paperNumber);
+    Boolean checkExamDetailStatus(Long schoolId, Long printPlanId, Long examId, Long courseId, String paperNumber);
 
     /**
      * 生成唯一的试卷编号

+ 2 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicExamRuleServiceImpl.java

@@ -4,9 +4,8 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.qmth.distributed.print.business.bean.examRule.CodeName;
-import com.qmth.distributed.print.business.bean.examRule.CodeNameEnableDisabled;
-import com.qmth.distributed.print.business.bean.examRule.FieldsDto;
+import com.qmth.teachcloud.common.bean.examRule.CodeName;
+import com.qmth.teachcloud.common.bean.examRule.FieldsDto;
 import com.qmth.distributed.print.business.entity.BasicExamRule;
 import com.qmth.distributed.print.business.enums.RequiredFieldsEnum;
 import com.qmth.distributed.print.business.mapper.BasicExamRuleMapper;

+ 6 - 4
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicTemplateServiceImpl.java

@@ -7,9 +7,9 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.qmth.distributed.print.business.bean.examRule.CodeName;
-import com.qmth.distributed.print.business.bean.examRule.CodeNameEnable;
-import com.qmth.distributed.print.business.bean.examRule.CodeNameEnableRate;
+import com.qmth.teachcloud.common.bean.examRule.CodeName;
+import com.qmth.teachcloud.common.bean.examRule.CodeNameEnable;
+import com.qmth.teachcloud.common.bean.examRule.CodeNameEnableRate;
 import com.qmth.distributed.print.business.bean.result.TemplatePrintInfoResult;
 import com.qmth.distributed.print.business.entity.BasicExamRule;
 import com.qmth.distributed.print.business.entity.BasicTemplate;
@@ -113,7 +113,9 @@ public class BasicTemplateServiceImpl extends ServiceImpl<BasicTemplateMapper, B
                     JSONObject jsonObject = JSON.parseObject(basicTemplate.getPreviewPath());
                     String type = jsonObject.getString(SystemConstant.TYPE);
                     if (Objects.nonNull(type) && type.equalsIgnoreCase(SystemConstant.LOCAL)) {
-                        FileUtils.forceDelete(new File(jsonObject.getString(SystemConstant.PATH)));
+                        File file = new File(jsonObject.getString(SystemConstant.PATH));
+                        if (file.exists())
+                            FileUtils.forceDelete(file);
                     }
                 }
             }

+ 3 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ClientServiceImpl.java

@@ -107,9 +107,9 @@ public class ClientServiceImpl implements ClientService {
     }
 
     @Override
-    public Boolean tagPass(Long printPlanId, String courseCode, String courseName, String paperNumber, String machineCode, Boolean isPass, Long userId) {
+    public Boolean tagPass(Long printPlanId, Long courseId, String courseName, String paperNumber, String machineCode, Boolean isPass, Long userId) {
         Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
-        return clientStatusService.tagPass(schoolId, printPlanId, courseCode, courseName, paperNumber, machineCode, isPass, userId);
+        return clientStatusService.tagPass(schoolId, printPlanId, courseId, courseName, paperNumber, machineCode, isPass, userId);
     }
 
     @Override
@@ -957,7 +957,7 @@ public class ClientServiceImpl implements ClientService {
     @Override
     public List<Map<String, String>> getPaperUrl(Long schoolId, Long printPlanId, Long examTaskId) {
         ExamTask examTask = examTaskService.getById(examTaskId);
-        List<ExamDetailCourse> examDetailCourses = examDetailCourseService.listByPrintPlanIdAndCourseCodeAndPaperNumber(schoolId, printPlanId, examTask.getCourseCode(), examTask.getPaperNumber());
+        List<ExamDetailCourse> examDetailCourses = examDetailCourseService.listByPrintPlanIdAndCourseCodeAndPaperNumber(schoolId, printPlanId, examTask.getCourseId(), examTask.getPaperNumber());
         if (CollectionUtils.isNotEmpty(examDetailCourses)) {
             Set<String> relatePaperTypes = examDetailCourses.stream().filter(m -> StringUtils.isNotBlank(m.getPaperType())).map(m -> m.getPaperType()).collect(Collectors.toSet());
             List<Map<String, String>> paperList = new ArrayList<>();

+ 4 - 4
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ClientStatusServiceImpl.java

@@ -24,12 +24,12 @@ public class ClientStatusServiceImpl extends ServiceImpl<ClientStatusMapper, Cli
     private ExamDetailCourseService examDetailCourseService;
 
     @Override
-    public Boolean tagPass(Long schoolId, Long printPlanId, String courseCode, String courseName, String paperNumber, String machineCode, Boolean isPass, Long userId) {
-        List<ExamDetailCourse> examDetailCourses = examDetailCourseService.listByPrintPlanIdAndCourseCodeAndPaperNumber(schoolId, printPlanId, courseCode, paperNumber);
+    public Boolean tagPass(Long schoolId, Long printPlanId, Long courseId, String courseName, String paperNumber, String machineCode, Boolean isPass, Long userId) {
+        List<ExamDetailCourse> examDetailCourses = examDetailCourseService.listByPrintPlanIdAndCourseCodeAndPaperNumber(schoolId, printPlanId, courseId, paperNumber);
         long currentTime = System.currentTimeMillis();
         for (ExamDetailCourse examDetailCours : examDetailCourses) {
             QueryWrapper<ClientStatus> queryWrapper = new QueryWrapper<>();
-            queryWrapper.lambda().eq(ClientStatus::getSchoolId, schoolId).eq(ClientStatus::getExamDetailId, examDetailCours.getExamDetailId()).eq(ClientStatus::getPrintPlanId, printPlanId).eq(ClientStatus::getCourseCode, courseCode).eq(ClientStatus::getPaperNumber, paperNumber).eq(ClientStatus::getMachineCode, machineCode);
+            queryWrapper.lambda().eq(ClientStatus::getSchoolId, schoolId).eq(ClientStatus::getExamDetailId, examDetailCours.getExamDetailId()).eq(ClientStatus::getPrintPlanId, printPlanId).eq(ClientStatus::getCourseId, courseId).eq(ClientStatus::getPaperNumber, paperNumber).eq(ClientStatus::getMachineCode, machineCode);
             ClientStatus clientStatus = this.getOne(queryWrapper);
             if(clientStatus != null){
                 clientStatus.setTry(true);
@@ -48,7 +48,7 @@ public class ClientStatusServiceImpl extends ServiceImpl<ClientStatusMapper, Cli
                 clientStatus.setExamDetailId(examDetailCours.getExamDetailId());
                 clientStatus.setPrintPlanId(printPlanId);
                 clientStatus.setMachineCode(machineCode);
-                clientStatus.setCourseCode(courseCode);
+                clientStatus.setCourseId(courseId);
                 clientStatus.setCourseName(courseName);
                 clientStatus.setPaperNumber(paperNumber);
                 clientStatus.setTry(true);

+ 9 - 18
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/DownloadServiceImpl.java

@@ -3,31 +3,28 @@ package com.qmth.distributed.print.business.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.qmth.distributed.print.business.bean.dto.*;
-import com.qmth.distributed.print.business.util.pdf.CreatePdfNewUtil;
-import com.qmth.teachcloud.common.bean.vo.PaperInfoVo;
-import com.qmth.distributed.print.business.entity.*;
-import com.qmth.distributed.print.business.enums.MakeMethodEnum;
+import com.qmth.distributed.print.business.bean.dto.ExamTaskDetailDto;
+import com.qmth.distributed.print.business.entity.ExamCard;
+import com.qmth.distributed.print.business.entity.ExamTask;
+import com.qmth.distributed.print.business.entity.ExamTaskDetail;
 import com.qmth.distributed.print.business.mapper.ExamCardMapper;
 import com.qmth.distributed.print.business.mapper.ExamTaskDetailMapper;
 import com.qmth.distributed.print.business.mapper.ExamTaskMapper;
-import com.qmth.distributed.print.business.service.BasicCardRuleService;
 import com.qmth.distributed.print.business.service.DownloadService;
-import com.qmth.distributed.print.business.service.ExamPrintPlanService;
 import com.qmth.distributed.print.business.util.CreatePdfUtil;
-import com.qmth.teachcloud.common.util.HtmlToPdfUtil;
 import com.qmth.teachcloud.common.bean.dto.DataPermissionRule;
-import com.qmth.teachcloud.common.config.DictionaryConfig;
+import com.qmth.teachcloud.common.bean.vo.PaperInfoVo;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.BasicAttachment;
 import com.qmth.teachcloud.common.entity.SysUser;
-import com.qmth.teachcloud.common.enums.CardCreateMethodEnum;
 import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
 import com.qmth.teachcloud.common.enums.PageSizeEnum;
 import com.qmth.teachcloud.common.mapper.BasicAttachmentMapper;
-import com.qmth.teachcloud.common.service.*;
+import com.qmth.teachcloud.common.service.AttachmentCommonService;
+import com.qmth.teachcloud.common.service.BasicRoleDataPermissionService;
 import com.qmth.teachcloud.common.util.ConvertUtil;
 import com.qmth.teachcloud.common.util.ExamTaskUtil;
+import com.qmth.teachcloud.common.util.HtmlToPdfUtil;
 import com.qmth.teachcloud.common.util.ServletUtil;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -56,18 +53,12 @@ public class DownloadServiceImpl implements DownloadService {
 
     @Resource
     ExamCardMapper examCardMapper;
-
-    @Resource
-    BasicCardRuleService basicCardRuleService;
-
     @Resource
     AttachmentCommonService attachmentCommonService;
 
     @Resource
     CreatePdfUtil createPdfUtil;
     @Resource
-    CreatePdfNewUtil createPdfNewUtil;
-    @Resource
     private BasicRoleDataPermissionService basicRoleDataPermissionService;
 
     @Override
@@ -143,7 +134,7 @@ public class DownloadServiceImpl implements DownloadService {
                         htmlFile.getParentFile().mkdirs();
                         htmlFile.createNewFile();
                     }
-                    String htmlContent = createPdfNewUtil.replaceBlankHtmlContent(examCard.getHtmlContent());
+                    String htmlContent = createPdfUtil.replaceBlankHtmlContent(examCard.getHtmlContent());
                     // 生成html文件
                     FileCopyUtils.copy(htmlContent.getBytes(StandardCharsets.UTF_8), htmlFile);
                     fileList.add(htmlFile);

+ 4 - 5
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamCardServiceImpl.java

@@ -19,13 +19,12 @@ import com.qmth.distributed.print.business.mapper.ExamCardMapper;
 import com.qmth.distributed.print.business.service.*;
 import com.qmth.distributed.print.business.util.HtmlToJpgUtil;
 import com.qmth.distributed.print.business.util.PdfUtil;
-import com.qmth.distributed.print.business.util.pdf.CreatePdfNewUtil;
+import com.qmth.distributed.print.business.util.CreatePdfUtil;
 import com.qmth.teachcloud.common.bean.dto.DataPermissionRule;
 import com.qmth.teachcloud.common.bean.vo.FilePathVo;
 import com.qmth.teachcloud.common.bean.vo.PaperInfoVo;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.BasicAttachment;
-import com.qmth.teachcloud.common.entity.BasicCourse;
 import com.qmth.teachcloud.common.entity.BasicPrintConfig;
 import com.qmth.teachcloud.common.entity.SysUser;
 import com.qmth.teachcloud.common.enums.CardCreateMethodEnum;
@@ -77,7 +76,7 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
     @Resource
     BasicRoleDataPermissionService basicRoleDataPermissionService;
     @Resource
-    CreatePdfNewUtil createPdfNewUtil;
+    CreatePdfUtil createPdfUtil;
     @Resource
     private FileUploadService fileUploadService;
     @Resource
@@ -417,7 +416,7 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
             }
 
             // 通用模板
-            String htmlContent = createPdfNewUtil.replaceBlankHtmlContent(examCard.getHtmlContent());
+            String htmlContent = createPdfUtil.replaceBlankHtmlContent(examCard.getHtmlContent());
             // html文件
             File htmlFile = new File(downloadFilePath, examCard.getTitle() + SystemConstant.HTML_PREFIX);
             if (!htmlFile.exists()) {
@@ -577,7 +576,7 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
     @Override
     public ExamCard createJpgImage(ExamCard examCard) {
         BasicCardRule basicCardRule = basicCardRuleService.getById(examCard.getCardRuleId());
-        String replaceBackupCardHtmlContent = createPdfNewUtil.replaceBackupCardHtmlParam(examCard, null, basicCardRule, null);
+        String replaceBackupCardHtmlContent = createPdfUtil.replaceBackupCardHtmlParam(examCard, null, basicCardRule, null);
         File pdfFile = PdfUtil.htmlToPdf(replaceBackupCardHtmlContent);
         try {
             String fileName = PdfUtil.md5FileName("BLANK" + examCard.getId()) + SystemConstant.PDF_PREFIX;

+ 16 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamDetailCourseServiceImpl.java

@@ -12,10 +12,12 @@ import com.qmth.distributed.print.business.service.ExamDetailCourseService;
 import com.qmth.teachcloud.common.bean.result.TbTaskDetailResult;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.BasicCourse;
+import com.qmth.teachcloud.common.service.BasicCourseService;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.util.*;
 
 /**
@@ -29,6 +31,9 @@ import java.util.*;
 @Service
 public class ExamDetailCourseServiceImpl extends ServiceImpl<ExamDetailCourseMapper, ExamDetailCourse> implements ExamDetailCourseService {
 
+    @Resource
+    private BasicCourseService basicCourseService;
+
 
     @Override
     public List<Map<String, Object>> listClientByExamDetailIdAndStatus(Long examDetailId) {
@@ -55,8 +60,8 @@ public class ExamDetailCourseServiceImpl extends ServiceImpl<ExamDetailCourseMap
     }
 
     @Override
-    public List<ExamDetailCourse> listByPrintPlanIdAndCourseCodeAndPaperNumber(Long schoolId, Long printPlanId, String courseCode, String paperNumber) {
-        return this.baseMapper.listByPrintPlanIdAndCourseCodeAndPaperNumber(schoolId, printPlanId, courseCode, paperNumber);
+    public List<ExamDetailCourse> listByPrintPlanIdAndCourseCodeAndPaperNumber(Long schoolId, Long printPlanId, Long courseId, String paperNumber) {
+        return this.baseMapper.listByPrintPlanIdAndCourseCodeAndPaperNumber(schoolId, printPlanId, courseId, paperNumber);
     }
 
     @Override
@@ -78,7 +83,15 @@ public class ExamDetailCourseServiceImpl extends ServiceImpl<ExamDetailCourseMap
     public List<ExamDetailCourse> listByExamDetailId(Long examDetailId) {
         QueryWrapper<ExamDetailCourse> queryWrapper = new QueryWrapper<>();
         queryWrapper.lambda().eq(ExamDetailCourse::getExamDetailId, examDetailId);
-        return this.list(queryWrapper);
+        List<ExamDetailCourse> examDetailCourseList = this.list(queryWrapper);
+        for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
+            BasicCourse basicCourse = basicCourseService.getById(examDetailCourse.getCourseId());
+            if (basicCourse != null) {
+                examDetailCourse.setCourseName(basicCourse.getName());
+                examDetailCourse.setCourseCode(basicCourse.getCode());
+            }
+        }
+        return examDetailCourseList;
     }
 
     @Override

+ 5 - 10
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamDetailServiceImpl.java

@@ -14,8 +14,8 @@ import com.qmth.boot.api.exception.ApiException;
 import com.qmth.distributed.print.business.bean.dto.*;
 import com.qmth.distributed.print.business.bean.dto.initMarkData.ExamDetailCourseInitMarkDto;
 import com.qmth.distributed.print.business.bean.dto.initMarkData.InitExamDetailDto;
-import com.qmth.distributed.print.business.bean.examRule.CodeNameEnableValue;
-import com.qmth.distributed.print.business.bean.examRule.FieldsDto;
+import com.qmth.teachcloud.common.bean.examRule.CodeNameEnableValue;
+import com.qmth.teachcloud.common.bean.examRule.FieldsDto;
 import com.qmth.distributed.print.business.bean.result.ExaminationDetailResult;
 import com.qmth.distributed.print.business.bean.result.ExaminationResult;
 import com.qmth.distributed.print.business.bean.result.SummarizedDataResult;
@@ -554,7 +554,7 @@ public class ExamDetailServiceImpl extends ServiceImpl<ExamDetailMapper, ExamDet
                     .eq(ExamTask::getPaperNumber, examDetailCours.getPaperNumber());
             examTaskService.update(examTaskUpdateWrapper);
 
-            List<ExamDetail> examDetailList = this.listByPrintPlanIdAndCourseCodeAndPaperNumber(detail.getSchoolId(), detail.getPrintPlanId(), examDetailCours.getCourseCode(), examDetailCours.getPaperNumber());
+            List<ExamDetail> examDetailList = this.listByPrintPlanIdAndCourseCodeAndPaperNumber(detail.getSchoolId(), detail.getPrintPlanId(), examDetailCours.getCourseId(), examDetailCours.getPaperNumber());
             long count = examDetailList.stream().filter(m -> !m.getStatus().name().equals(ExamDetailStatusEnum.NEW.name()) && !m.getStatus().name().equals(ExamDetailStatusEnum.READY.name())).count();
             if (count == 0) {
                 UpdateWrapper<ClientStatus> clientStatusUpdateWrapper = new UpdateWrapper<>();
@@ -769,8 +769,8 @@ public class ExamDetailServiceImpl extends ServiceImpl<ExamDetailMapper, ExamDet
     }
 
     @Override
-    public List<ExamDetail> listByPrintPlanIdAndCourseCodeAndPaperNumber(Long schoolId, Long printPlanId, String courseCode, String paperNumber) {
-        List<ExamDetailCourse> examDetailCourses = examDetailCourseService.listByPrintPlanIdAndCourseCodeAndPaperNumber(schoolId, printPlanId, courseCode, paperNumber);
+    public List<ExamDetail> listByPrintPlanIdAndCourseCodeAndPaperNumber(Long schoolId, Long printPlanId, Long courseId, String paperNumber) {
+        List<ExamDetailCourse> examDetailCourses = examDetailCourseService.listByPrintPlanIdAndCourseCodeAndPaperNumber(schoolId, printPlanId, courseId, paperNumber);
         if (examDetailCourses != null && examDetailCourses.size() > 0) {
             Set<Long> examDetailIds = examDetailCourses.stream().map(ExamDetailCourse::getExamDetailId).collect(Collectors.toSet());
             return this.listByIds(examDetailIds);
@@ -859,11 +859,6 @@ public class ExamDetailServiceImpl extends ServiceImpl<ExamDetailMapper, ExamDet
         return this.baseMapper.listStudentByExamDetailCourseId(schoolId, examDetailCourseId, studentCode, type);
     }
 
-    @Override
-    public List<ExamDetail> listByCourseCodeAndPaperNumber(Long schoolId, Long examId, String courseCode, String paperNumber) {
-        return this.baseMapper.listByExamIdAndCourseCodeAndPaperNumber(schoolId, examId, courseCode, paperNumber);
-    }
-
     @Override
     public List<ExamDetail> listByCourseIdAndPaperNumber(Long schoolId, Long examId, Long courseId, String paperNumber) {
         return this.baseMapper.listByExamIdAndCourseIdAndPaperNumber(schoolId, examId, courseId, paperNumber);

+ 14 - 10
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamStudentServiceImpl.java

@@ -6,8 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.distributed.print.business.bean.dto.ExamStudentCourseDto;
 import com.qmth.distributed.print.business.bean.dto.ExamStudentDto;
-import com.qmth.distributed.print.business.bean.dto.ExamStudentPdfInfoDto;
-import com.qmth.distributed.print.business.bean.params.ExamTaskStudentObjectParam;
+import com.qmth.distributed.print.business.bean.dto.pdf.ExamStudentInfo;
 import com.qmth.distributed.print.business.entity.ExamDetailCourse;
 import com.qmth.distributed.print.business.entity.ExamStudent;
 import com.qmth.distributed.print.business.entity.ExamTask;
@@ -18,13 +17,11 @@ import com.qmth.distributed.print.business.service.ExamStudentService;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.BasicExamStudent;
 import com.qmth.teachcloud.common.entity.SysUser;
-import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.*;
-import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 
 /**
@@ -84,11 +81,6 @@ public class ExamStudentServiceImpl extends ServiceImpl<ExamStudentMapper, ExamS
         return examStudentMapper.queryBySchoolIdAndExamDetailCourseIds(schoolId, examDetailCourseIds);
     }
 
-    @Override
-    public ExamStudentPdfInfoDto getByStudentId(Long id) {
-        return this.baseMapper.getByStudentId(id);
-    }
-
     @Override
     public void removeByExamDetailCourseId(Long id) {
         UpdateWrapper<ExamStudent> updateWrapper = new UpdateWrapper<>();
@@ -102,7 +94,7 @@ public class ExamStudentServiceImpl extends ServiceImpl<ExamStudentMapper, ExamS
     }
 
     @Override
-    public List<ExamStudent> listByExamDetailCourseId(Long examDetailCourseId) {
+    public List<ExamStudent> listByExamDetailCourseId1(Long examDetailCourseId) {
         QueryWrapper<ExamStudent> queryWrapper = new QueryWrapper<>();
         queryWrapper.lambda().eq(ExamStudent::getExamDetailCourseId, examDetailCourseId)
                 .orderByAsc(ExamStudent::getId);
@@ -143,4 +135,16 @@ public class ExamStudentServiceImpl extends ServiceImpl<ExamStudentMapper, ExamS
         }
         return examStudentList;
     }
+
+    @Override
+    public List<ExamStudentInfo> listByExamDetailCourseId(Long examDetailCourseId) {
+        return this.baseMapper.listByExamDetailCourseId(examDetailCourseId);
+    }
+
+    @Override
+    public void updateAttachmentIdById(ExamStudentInfo t) {
+        UpdateWrapper<ExamStudent> updateWrapper = new UpdateWrapper<>();
+        updateWrapper.lambda().set(ExamStudent::getAttachmentId, t.getAttachmentId()).eq(ExamStudent::getId, t.getExamStudentId());
+        this.update(updateWrapper);
+    }
 }

+ 3 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskAssignPaperTypeServiceImpl.java

@@ -7,7 +7,7 @@ import com.qmth.distributed.print.business.enums.AssignModeEnum;
 import com.qmth.distributed.print.business.mapper.ExamTaskAssignPaperTypeMapper;
 import com.qmth.distributed.print.business.service.ExamDetailService;
 import com.qmth.distributed.print.business.service.ExamTaskAssignPaperTypeService;
-import com.qmth.distributed.print.business.util.pdf.CreatePdfNewUtil;
+import com.qmth.distributed.print.business.util.CreatePdfUtil;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -26,7 +26,7 @@ public class ExamTaskAssignPaperTypeServiceImpl extends MppServiceImpl<ExamTaskA
     @Resource
     ExamDetailService examDetailService;
     @Resource
-    CreatePdfNewUtil createPdfNewUtil;
+    CreatePdfUtil createPdfUtil;
 
     @Lockable(name = "#p0.examId + '-' + #p1.paperNumber")
     @Override
@@ -40,7 +40,7 @@ public class ExamTaskAssignPaperTypeServiceImpl extends MppServiceImpl<ExamTaskA
         }
         ExamTaskAssignPaperType examTaskAssignPaperType = this.selectByMultiId(new ExamTaskAssignPaperType(tbTaskPdf.getExamId(), examDetailCourse.getPaperNumber(), examDetail.getExamStartTime(), examDetail.getExamEndTime()));
         if (examTaskAssignPaperType == null) {
-            String paperType = createPdfNewUtil.getPaperType(examDetail.getPrintPlanId(), examDetail.getExamId(), examDetailCourse.getPaperNumber());
+            String paperType = createPdfUtil.getPaperType(examDetail.getPrintPlanId(), examDetail.getExamId(), examDetailCourse.getPaperNumber());
             examTaskAssignPaperType = new ExamTaskAssignPaperType(tbTaskPdf.getExamId(), examDetailCourse.getPaperNumber(), examDetail.getExamStartTime(), examDetail.getExamEndTime(), paperType, AssignModeEnum.AUTO);
             this.saveOrUpdateByMultiId(examTaskAssignPaperType);
         }

+ 7 - 7
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskDetailServiceImpl.java

@@ -88,7 +88,7 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
     @Override
     public boolean enable(ExamTaskDetail examTaskDetail) {
         ExamTask examTask = examTaskService.getById(examTaskDetail.getId());
-        List<ExamDetail> examDetails = examDetailService.listByCourseCodeAndPaperNumber(examTask.getSchoolId(), examTask.getExamId(), examTask.getCourseCode(), examTask.getPaperNumber());
+        List<ExamDetail> examDetails = examDetailService.listByCourseIdAndPaperNumber(examTask.getSchoolId(), examTask.getExamId(), examTask.getCourseId(), examTask.getPaperNumber());
         if (examDetails != null && examDetails.size() > 0) {
             // 有考场提交打印,不能禁用启用
             long count = examDetails.stream().filter(m -> !ExamDetailStatusEnum.NEW.name().equals(m.getStatus().name()) && !ExamDetailStatusEnum.READY.name().equals(m.getStatus().name())).count();
@@ -124,7 +124,7 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
                             .in(ExamDetail::getId, examDetailIds);
                     examDetailService.update(examDetailUpdateWrapper);
                     // 更新绑定关系
-                    List<ExamDetailCourse> examDetailCourses = examDetailCourseService.listByPrintPlanIdAndCourseCodeAndPaperNumber(examTask.getSchoolId(), listEntry.getKey(), examTask.getCourseCode(), examTask.getPaperNumber());
+                    List<ExamDetailCourse> examDetailCourses = examDetailCourseService.listByPrintPlanIdAndCourseCodeAndPaperNumber(examTask.getSchoolId(), listEntry.getKey(), examTask.getCourseId(), examTask.getPaperNumber());
                     List<Long> examDetailCourseIds = examDetailCourses.stream().map(m -> m.getId()).collect(Collectors.toList());
                     UpdateWrapper<ExamDetailCourse> examDetailCourseUpdateWrapper = new UpdateWrapper<>();
                     examDetailCourseUpdateWrapper.lambda()
@@ -152,7 +152,7 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
     public boolean updatePaper(RelatePaperParam paperParam) {
         ExamTask examTask = examTaskService.getById(paperParam.getExamTaskId());
         // 提交印刷的考场,不允许修改关联试卷
-        List<ExamDetail> examDetails = examDetailService.listByPrintPlanIdAndCourseCodeAndPaperNumber(examTask.getSchoolId(), paperParam.getPrintPlanId(), examTask.getCourseCode(), examTask.getPaperNumber());
+        List<ExamDetail> examDetails = examDetailService.listByPrintPlanIdAndCourseCodeAndPaperNumber(examTask.getSchoolId(), paperParam.getPrintPlanId(), examTask.getCourseId(), examTask.getPaperNumber());
         List<ExamDetail> examDetailsPrint = examDetails.stream().filter(m -> !ExamDetailStatusEnum.NEW.equals(m.getStatus()) && !ExamDetailStatusEnum.READY.equals(m.getStatus())).collect(Collectors.toList());
         if (CollectionUtils.isNotEmpty(examDetailsPrint)) {
             throw ExceptionResultEnum.ERROR.exception("部分考场pdf文件已提交印刷或已印刷,不能修改卷型");
@@ -306,7 +306,7 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
         }
 
         ExamTask examTask = examTaskService.getById(examTaskDetail.getExamTaskId());
-        List<ExamDetail> examDetails = examDetailService.listByCourseCodeAndPaperNumber(examTask.getSchoolId(), examTask.getExamId(), examTask.getCourseCode(), examTask.getPaperNumber());
+        List<ExamDetail> examDetails = examDetailService.listByCourseIdAndPaperNumber(examTask.getSchoolId(), examTask.getExamId(), examTask.getCourseId(), examTask.getPaperNumber());
         if (CollectionUtils.isNotEmpty(examDetails)) {
             StringJoiner stringJoiner = new StringJoiner("_");
             stringJoiner.add(String.valueOf(examDetails.get(0).getSchoolId()))
@@ -377,7 +377,7 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
 
         Map<String, Object> mapVar = new HashMap<>();
         ExamTask examTask = examTaskService.getById(examTaskDetail.getExamTaskId());
-        List<ExamDetail> examDetailList = examDetailService.listByCourseCodeAndPaperNumber(examTask.getSchoolId(), examTask.getExamId(), examTask.getCourseCode(), examTask.getPaperNumber());
+        List<ExamDetail> examDetailList = examDetailService.listByCourseIdAndPaperNumber(examTask.getSchoolId(), examTask.getExamId(), examTask.getCourseId(), examTask.getPaperNumber());
         if (CollectionUtils.isNotEmpty(examDetailList)) {
             ExamTaskDetail taskDetail = this.getByExamTaskId(examTaskDetail.getExamTaskId());
             List<Long> examDetailIds = examDetailList.stream().map(ExamDetail::getId).collect(Collectors.toList());
@@ -585,7 +585,7 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
         ExamTask examTask = examTaskService.getById(id);
         String paperNumber = examTask.getPaperNumber();
 
-        List<ExamDetail> examDetailList = examDetailService.listByCourseCodeAndPaperNumber(examTask.getSchoolId(), examTask.getExamId(), examTask.getCourseCode(), examTask.getPaperNumber());
+        List<ExamDetail> examDetailList = examDetailService.listByCourseIdAndPaperNumber(examTask.getSchoolId(), examTask.getExamId(), examTask.getCourseId(), examTask.getPaperNumber());
         if (CollectionUtils.isNotEmpty(examDetailList)) {
             ExamTaskDetail taskDetail = this.getByExamTaskId(id);
             if (StringUtils.isNotBlank(taskDetail.getExposedPaperType())) {
@@ -744,7 +744,7 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
         }
 
         // 提交印刷的考场,不允许修改关联试卷
-        List<ExamDetail> examDetails = examDetailService.listByCourseCodeAndPaperNumber(examTask.getSchoolId(), examTask.getExamId(), examTask.getCourseCode(), examTask.getPaperNumber());
+        List<ExamDetail> examDetails = examDetailService.listByCourseIdAndPaperNumber(examTask.getSchoolId(), examTask.getExamId(), examTask.getCourseId(), examTask.getPaperNumber());
         if (CollectionUtils.isNotEmpty(examDetails)) {
             List<ExamDetail> examDetails1 = examDetails.stream().filter(m -> !ExamDetailStatusEnum.NEW.equals(m.getStatus())
                     && !ExamDetailStatusEnum.READY.equals(m.getStatus())

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

@@ -24,7 +24,7 @@ import com.qmth.distributed.print.business.mapper.ExamTaskMapper;
 import com.qmth.distributed.print.business.service.*;
 import com.qmth.distributed.print.business.templete.execute.AsyncPaperReviewPdfExportService;
 import com.qmth.distributed.print.business.util.PdfUtil;
-import com.qmth.distributed.print.business.util.pdf.CreatePdfNewUtil;
+import com.qmth.distributed.print.business.util.CreatePdfUtil;
 import com.qmth.teachcloud.common.bean.dto.AssignTeacherDto;
 import com.qmth.teachcloud.common.bean.dto.BlurryUserDto;
 import com.qmth.teachcloud.common.bean.dto.DataPermissionRule;
@@ -137,7 +137,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
     @Resource
     TFFlowJoinService tfFlowJoinService;
     @Resource
-    CreatePdfNewUtil createPdfNewUtil;
+    CreatePdfUtil createPdfUtil;
     @Resource
     BasicPrintConfigService basicPrintConfigService;
     @Resource
@@ -893,7 +893,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
                     String cardHtmlPath = dirPath + "题卡" + SystemConstant.HYPHEN + name + SystemConstant.HTML_PREFIX;
                     String cardPdfPath = dirPath + "题卡" + SystemConstant.HYPHEN + name + SystemConstant.PDF_PREFIX;
 
-                    String htmlContent = createPdfNewUtil.replaceBlankHtmlContent(examCard.getHtmlContent());
+                    String htmlContent = createPdfUtil.replaceBlankHtmlContent(examCard.getHtmlContent());
                     // html
                     File htmlFile = new File(cardHtmlPath);
                     if (!htmlFile.exists()) {
@@ -1231,9 +1231,9 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
                 examPrintPlan.setOrgId(sysUser.getOrgId());
                 examPrintPlan.setName(examTask.getCourseName() + examTask.getPaperNumber());
                 if (!ExamCategoryEnum.REBUILD.equals(basicExam.getCategory())) {
-                    ConvertUtil.analyzeAndCompareDateAndTime(examDetailParams.getExamStartTime(), examDetailParams.getExamEndTime());
-                    examPrintPlan.setExamStartTime(examDetailParams.getExamStartTime());
-                    examPrintPlan.setExamEndTime(examDetailParams.getExamEndTime());
+//                    ConvertUtil.analyzeAndCompareDateAndTime(examDetailParams.getExamStartTime(), examDetailParams.getExamEndTime());
+//                    examPrintPlan.setExamStartTime(examDetailParams.getExamStartTime());
+//                    examPrintPlan.setExamEndTime(examDetailParams.getExamEndTime());
                 }
                 List<String> stringList = JSONObject.parseArray(basicPrintConfig.getPrintContent(), String.class);
                 if (!stringList.contains("PAPER")) {
@@ -1296,8 +1296,8 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
                         examDetail.setExamRoom(examDetailList.getExamRoom()); // 无默认值
                         examDetail.setStatus(ExamDetailStatusEnum.NEW);
                         if (!ExamCategoryEnum.REBUILD.equals(basicExam.getCategory())) {
-                            examDetail.setExamStartTime(examDetailParams.getExamStartTime());
-                            examDetail.setExamEndTime(examDetailParams.getExamEndTime());
+                            examDetail.setExamStartTime(examDetailList.getExamStartTime());
+                            examDetail.setExamEndTime(examDetailList.getExamEndTime());
                         }
                         examDetail.setTotalSubjects(count);
                         examDetail.setExamDataSource(ExamDataSourceEnum.EXAM_TASK);

+ 3 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/PrintCommonServiceImpl.java

@@ -1097,12 +1097,12 @@ public class PrintCommonServiceImpl implements PrintCommonService {
      * @return
      */
     @Override
-    public Boolean checkExamDetailStatus(Long schoolId, Long printPlanId, Long examId, String courseCode, String paperNumber) {
+    public Boolean checkExamDetailStatus(Long schoolId, Long printPlanId, Long examId, Long courseId, String paperNumber) {
         List<ExamDetail> examDetails;
         if (printPlanId != null) {
-            examDetails = examDetailService.listByPrintPlanIdAndCourseCodeAndPaperNumber(schoolId, printPlanId, courseCode, paperNumber);
+            examDetails = examDetailService.listByPrintPlanIdAndCourseCodeAndPaperNumber(schoolId, printPlanId, courseId, paperNumber);
         } else {
-            examDetails = examDetailService.listByCourseCodeAndPaperNumber(schoolId, examId, courseCode, paperNumber);
+            examDetails = examDetailService.listByCourseIdAndPaperNumber(schoolId, examId, courseId, paperNumber);
         }
         if (CollectionUtils.isNotEmpty(examDetails)) {
             long count = examDetails.stream().filter(m -> !ExamDetailStatusEnum.NEW.name().equals(m.getStatus().name()) && !ExamDetailStatusEnum.READY.name().equals(m.getStatus().name())).count();

+ 3 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/AsyncCreatePdfTemplateService.java

@@ -2,6 +2,7 @@ package com.qmth.distributed.print.business.templete.execute;
 
 import cn.hutool.core.date.DateUtil;
 import com.qmth.distributed.print.business.entity.TBTaskPdf;
+import com.qmth.distributed.print.business.enums.ExamDetailStatusEnum;
 import com.qmth.distributed.print.business.service.TBTaskPdfService;
 import com.qmth.distributed.print.business.templete.callback.CallbackCreatePdf;
 import com.qmth.distributed.print.business.templete.create.AsyncCreateTaskTemplete;
@@ -44,6 +45,7 @@ public class AsyncCreatePdfTemplateService extends AsyncCreateTaskTemplete {
     @Override
     public Result createPdf(TBTaskPdf tbTaskPdf, CallbackCreatePdf callbackCreatePdf) {
         StringJoiner stringJoinerSummary = new StringJoiner("\n").add(MessageFormat.format("{0}{1}{2}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), BEGIN_TITLE, OBJ_TITLE));
+        SystemConstant.addSummary(stringJoinerSummary, "开始处理PDF文件生成数据");
         TBTaskPdfService tbTaskPdfService = SpringContextHolder.getBean(TBTaskPdfService.class);
         // 任务状态为进行中,直接结束
         if (TaskStatusEnum.RUNNING.equals(tbTaskPdf.getStatus())) {
@@ -56,7 +58,7 @@ public class AsyncCreatePdfTemplateService extends AsyncCreateTaskTemplete {
             pdfTaskLogicService.executeCreatePdfLogic(tbTaskPdf, stringJoinerSummary);
             tbTaskPdf.setResult(TaskResultEnum.SUCCESS);
         } catch (Exception e) {
-            stringJoinerSummary.add(MessageFormat.format("{0}{1}{2}{3}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), EXCEPTION_TITLE, EXCEPTION_DATA, e.getMessage()));
+            SystemConstant.addSummary(stringJoinerSummary, "数据处理完成且发生异常。异常信息为["+ e.getMessage()+"]");
             tbTaskPdf.setResult(TaskResultEnum.ERROR);
         } finally {
             tbTaskPdf.setStatus(TaskStatusEnum.FINISH);

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/AsyncExaminationImportTemplateService.java

@@ -5,7 +5,7 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.qmth.boot.api.exception.ApiException;
 import com.qmth.distributed.print.business.bean.dto.ExaminationImportDto;
-import com.qmth.distributed.print.business.bean.examRule.FieldsDto;
+import com.qmth.teachcloud.common.bean.examRule.FieldsDto;
 import com.qmth.distributed.print.business.service.ExamDetailService;
 import com.qmth.distributed.print.business.service.ExamTaskService;
 import com.qmth.distributed.print.business.templete.importData.AsyncImportTaskTemplete;

+ 1 - 15
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/SyncBasicExamStudentImportService.java

@@ -4,14 +4,12 @@ import cn.hutool.core.date.DateUtil;
 import com.alibaba.fastjson.JSON;
 import com.qmth.boot.tools.excel.ExcelWriter;
 import com.qmth.boot.tools.excel.enums.ExcelType;
-import com.qmth.distributed.print.business.bean.dto.BasicExamStudentDto;
 import com.qmth.distributed.print.business.bean.dto.importFile.BasicExamStudentImport;
-import com.qmth.distributed.print.business.bean.examRule.CodeNameEnableValue;
+import com.qmth.teachcloud.common.bean.examRule.CodeNameEnableValue;
 import com.qmth.distributed.print.business.service.BasicExamService;
 import com.qmth.distributed.print.business.service.BasicExamStudentService;
 import com.qmth.distributed.print.business.templete.importData.SyncImportTaskTemplate;
 import com.qmth.distributed.print.business.templete.service.ImportLogicService;
-import com.qmth.teachcloud.common.annotation.ExcelNote;
 import com.qmth.teachcloud.common.bean.vo.FilePathVo;
 import com.qmth.teachcloud.common.contant.SpringContextHolder;
 import com.qmth.teachcloud.common.contant.SystemConstant;
@@ -24,27 +22,15 @@ import com.qmth.teachcloud.common.service.TBTaskService;
 import com.qmth.teachcloud.common.util.Result;
 import com.qmth.teachcloud.common.util.ResultUtil;
 import com.qmth.teachcloud.mark.service.MarkPaperService;
-import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.poi.ss.usermodel.FillPatternType;
-import org.apache.poi.ss.usermodel.Font;
-import org.apache.poi.ss.usermodel.HorizontalAlignment;
-import org.apache.poi.ss.usermodel.IndexedColors;
-import org.apache.poi.ss.util.CellRangeAddress;
-import org.apache.poi.xssf.usermodel.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import javax.servlet.ServletOutputStream;
 import java.io.File;
 import java.io.FileOutputStream;
-import java.io.IOException;
 import java.io.InputStream;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
 import java.text.MessageFormat;
 import java.util.*;
 

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

@@ -9,7 +9,7 @@ import com.qmth.distributed.print.business.bean.dto.ObjectiveStructDto;
 import com.qmth.distributed.print.business.bean.dto.SubjectiveStructDto;
 import com.qmth.distributed.print.business.bean.dto.importFile.BasicExamStudentImport;
 import com.qmth.distributed.print.business.bean.dto.importFile.BasicExamStudentParseDto;
-import com.qmth.distributed.print.business.bean.examRule.CodeNameEnableValue;
+import com.qmth.teachcloud.common.bean.examRule.CodeNameEnableValue;
 import com.qmth.distributed.print.business.entity.BasicExamRule;
 import com.qmth.distributed.print.business.enums.RequiredFieldsEnum;
 import com.qmth.distributed.print.business.service.BasicExamRuleService;
@@ -133,6 +133,7 @@ public class ImportLogicServiceImpl implements ImportLogicService {
             basicExamStudent.setSchoolId(schoolId);
             basicExamStudent.setSemesterId(semesterId);
             basicExamStudent.setExamId(examId);
+            basicExamStudent.setRequiredFields(CollectionUtils.isNotEmpty(basicExamStudentImport.getRequiredFieldList()) ? JSON.toJSONString(basicExamStudentImport.getRequiredFieldList()) : null);
             basicExamStudent.setExtendFields(CollectionUtils.isNotEmpty(basicExamStudentImport.getExtendFieldList()) ? JSON.toJSONString(basicExamStudentImport.getExtendFieldList()) : null);
 
             StringJoiner stringJoiner = new StringJoiner(";");

+ 41 - 34
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/PdfTaskLogicServiceImpl.java

@@ -11,6 +11,7 @@ import com.qmth.distributed.print.business.bean.dto.CreatePdfDto;
 import com.qmth.distributed.print.business.bean.dto.ExamStudentCourseDto;
 import com.qmth.distributed.print.business.bean.dto.PaperPdfDto;
 import com.qmth.distributed.print.business.bean.dto.PdfDto;
+import com.qmth.distributed.print.business.bean.dto.pdf.ExamStudentInfo;
 import com.qmth.distributed.print.business.entity.*;
 import com.qmth.distributed.print.business.enums.ExamDetailStatusEnum;
 import com.qmth.distributed.print.business.enums.ExamStatusEnum;
@@ -18,7 +19,7 @@ import com.qmth.distributed.print.business.enums.PrintPlanStatusEnum;
 import com.qmth.distributed.print.business.service.*;
 import com.qmth.distributed.print.business.templete.service.PdfTaskLogicService;
 import com.qmth.distributed.print.business.util.PdfUtil;
-import com.qmth.distributed.print.business.util.pdf.CreatePdfNewUtil;
+import com.qmth.distributed.print.business.util.CreatePdfUtil;
 import com.qmth.teachcloud.common.base.BaseEntity;
 import com.qmth.teachcloud.common.bean.vo.FilePathVo;
 import com.qmth.teachcloud.common.bean.vo.PaperInfoVo;
@@ -48,11 +49,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 
 /**
- * @Description: 任务处理逻辑impl
- * @Param:
- * @return:
- * @Author: wangliang
- * @Date: 2021/3/29
+ * PDF任务处理逻辑
  */
 @Service
 public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
@@ -75,7 +72,7 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
     @Resource
     CommonCacheService commonCacheService;
     @Resource
-    CreatePdfNewUtil createPdfNewUtil;
+    CreatePdfUtil createPdfUtil;
     @Resource
     BasicCardRuleService basicCardRuleService;
     @Autowired
@@ -92,9 +89,10 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
         CreatePdfDto createPdfDto = new CreatePdfDto();
         try {
             long startTime = System.currentTimeMillis();
-            addSummary(stringJoinerSummary, "开始处理数据");
+            SystemConstant.addSummary(stringJoinerSummary, "开始处理数据,更新考场状态为["+ExamDetailStatusEnum.CREATING.getName()+"]");
             // 更新状态(考场状态、印刷计划状态)
             updatePdfDataStatus(tbTaskPdf);
+            SystemConstant.addSummary(stringJoinerSummary, "考场状态更新成功,开始准备PDF文件生成数据");
 
             ExamDetail examDetail = examDetailService.getById(tbTaskPdf.getId());
             if (examDetail == null) {
@@ -111,10 +109,10 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
                 throw ExceptionResultEnum.EXAM_DETAIL_COURSE_IS_NULL.exception();
             }
             createPdfDto.setExamDetailCourseList(examDetailCourseList);
-
+            SystemConstant.addSummary(stringJoinerSummary, "PDF文件生成数据准备完成,准备生成PDF打印文件");
             createPdfCore(tbTaskPdf, createPdfDto, stringJoinerSummary);
             long endTime = System.currentTimeMillis();
-            addSummary(stringJoinerSummary, "pdf文件生成成功,共处理" + examDetail.getTotalSubjects() + "科次。耗时:" + (endTime - startTime) / 1000 + "秒");
+            SystemConstant.addSummary(stringJoinerSummary, "PDF打印文件生成成功,共处理" + examDetail.getTotalSubjects() + "科次。耗时:" + (endTime - startTime) / 1000 + "秒");
         } catch (Exception e) {
             throw ExceptionResultEnum.ERROR.exception(e.getMessage());
         } finally {
@@ -130,20 +128,26 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
     public void createPdfCore(TBTaskPdf tbTaskPdf, CreatePdfDto createPdfDto, StringJoiner stringJoinerSummary) {
         ExamDetailStatusEnum examDetailStatusEnum = null;
         try {
+            SystemConstant.addSummary(stringJoinerSummary, "开始抽取卷型并分配给考生");
             // 抽取卷型,更新考场、考生对应卷型值
             updateAssignPaperType(tbTaskPdf, createPdfDto);
+            SystemConstant.addSummary(stringJoinerSummary, "抽取卷型并分配给考生完成,准备PDF文件需要的试卷和题卡文件");
             // 查询生成pdf需要文件
             assemblePdfFile(tbTaskPdf, createPdfDto);
-            addSummary(stringJoinerSummary, "处理数据结束,准备生成pdf");
+            SystemConstant.addSummary(stringJoinerSummary, "文件准备完成,开始生成并合并试卷PDF文件");
             // 生成pdf文件并合并
             //合并(试卷+备用试卷)
-            String dirNamePaper = createPdfNewUtil.mergeA3Pdf(createPdfDto.getPaperPdfList());
+            String dirNamePaper = createPdfUtil.mergeA3Pdf(createPdfDto.getPaperPdfList());
+            SystemConstant.addSummary(stringJoinerSummary, "试卷PDF生成并合并完成,准备生成并合并题卡PDF文件");
             //合并A3(题卡+备用题卡)
-            String dirNameCardA3 = createPdfNewUtil.mergeA3Pdf(createPdfDto.getCardPdfList());
+            String dirNameCardA3 = createPdfUtil.mergeA3Pdf(createPdfDto.getCardPdfList());
+            SystemConstant.addSummary(stringJoinerSummary, "题卡PDF生成并合并完成,准备生成印品PDF文件");
             // 生成A4文件
             createA4File(tbTaskPdf, createPdfDto.getExamDetailCourseList(), createPdfDto.getFileTempList());
+            SystemConstant.addSummary(stringJoinerSummary, "印品PDF文件生成完成,准备上传PDF文件并更新状态");
             // 更新文件路径、更新考场状态、印刷计划状态
-            createPdfNewUtil.mergePdfSaveDb(dirNamePaper, dirNameCardA3, tbTaskPdf);
+            createPdfUtil.mergePdfSaveDb(dirNamePaper, dirNameCardA3, tbTaskPdf);
+            SystemConstant.addSummary(stringJoinerSummary, "上传PDF文件并更新状态完成");
         } catch (Exception e) {
             examDetailStatusEnum = ExamDetailStatusEnum.NEW;
             throw ExceptionResultEnum.ERROR.exception(e.getMessage());
@@ -182,7 +186,7 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
     public void updateAssignPaperType(TBTaskPdf tbTaskPdf, CreatePdfDto createPdfDto) {
         for (ExamDetailCourse examDetailCourse : createPdfDto.getExamDetailCourseList()) {
             ExamTaskAssignPaperType examTaskAssignPaperType = examTaskAssignPaperTypeService.extractPaperType(tbTaskPdf, examDetailCourse);
-            List<ExamStudent> examStudentList = examStudentService.listByExamDetailCourseId(examDetailCourse.getId());
+            List<ExamStudent> examStudentList = examStudentService.listByExamDetailCourseId1(examDetailCourse.getId());
             // 考生实际关联试卷类型
             List<String> relatePaperTypes = new ArrayList<>();
             List<String> paperTypes = Arrays.stream(examTaskAssignPaperType.getPaperType().split(",")).sorted(Comparator.comparing(String::valueOf)).collect(Collectors.toList());
@@ -251,15 +255,15 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
             // 计算备份数量,默认最小为1份。
             int backupCount = SystemConstant.calcBackupCount(examDetail.getBackupCount(), examDetail.getTotalSubjects(), 1);
 
-            List<ExamStudent> examStudentList = examStudentService.listByExamDetailCourseId(examDetailCourse.getId());
+            List<ExamStudentInfo> examStudentInfoList = examStudentService.listByExamDetailCourseId(examDetailCourse.getId());
             // 试卷数据组装
             if ((CreatePdfTypeEnum.ALL.equals(createPdfType) || CreatePdfTypeEnum.PAPER.equals(createPdfType)) && printContent.contains("PAPER")) {
-                List<PaperPdfDto> paperPdfDtoList = createPdfNewUtil.getPaperPdfFile(examDetailCourse.getPaperType(), examTaskDetail.getPaperInfoVoList(null), createPdfDto);
+                List<PaperPdfDto> paperPdfDtoList = createPdfUtil.getPaperPdfFile(examDetailCourse.getPaperType(), examTaskDetail.getPaperInfoVoList(null), createPdfDto);
                 // 生成考生试卷
-                if (CollectionUtils.isNotEmpty(examStudentList)) {
-                    for (ExamStudent t : examStudentList) {
-                        String[] waterMarkNames = {t.getStudentName(), t.getTicketNumber()};
-                        createPdfNewUtil.getExamStudentPaperPdf(t.getPaperType(), paperPdfDtoList, createPdfDto, waterMarkNames);
+                if (CollectionUtils.isNotEmpty(examStudentInfoList)) {
+                    for (ExamStudentInfo t : examStudentInfoList) {
+                        String[] waterMarkNames = {t.getStudentName(), t.getStudentCode()};
+                        createPdfUtil.getExamStudentPaperPdf(t.getPaperType(), paperPdfDtoList, createPdfDto, waterMarkNames);
                     }
                 } else if (examDetail.getTotalSubjects() != null) {
                     AtomicInteger atomicInteger = new AtomicInteger(0);
@@ -267,7 +271,7 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
                     while (i < examDetail.getTotalSubjects()) {
                         int seq = atomicInteger.getAndIncrement();
                         int mod = seq % paperTypes.length;
-                        createPdfNewUtil.getExamStudentPaperPdf(paperTypes[mod], paperPdfDtoList, createPdfDto, null);
+                        createPdfUtil.getExamStudentPaperPdf(paperTypes[mod], paperPdfDtoList, createPdfDto, null);
                         i++;
                     }
                 } else {
@@ -275,7 +279,7 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
                 }
 
                 // 获取备份试卷
-                PdfDto pdfDto = createPdfNewUtil.getBackupPaperPdfList(paperPdfDtoList, backupCount, createPdfDto);
+                PdfDto pdfDto = createPdfUtil.getBackupPaperPdfList(paperPdfDtoList, backupCount, createPdfDto);
                 if (Objects.nonNull(pdfDto)) {
                     examDetailCourse.setPaperPagesA3(pdfDto.getPageCount());
                 }
@@ -298,12 +302,12 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
                 }
 
                 JSONArray stuJsonArray = new JSONArray();
-                if (examStudentList != null && examStudentList.size() > 0) {
-                    for (ExamStudent t : examStudentList) {
+                if (CollectionUtils.isNotEmpty(examStudentInfoList)) {
+                    for (ExamStudentInfo t : examStudentInfoList) {
                         // 用带条码的模板
-                        createPdfNewUtil.examStudentHtml(examCardMap.get(t.getPaperType()).getHtmlContent(), t, t.getPaperType(), examDetail, tbTaskPdf.getCreateId(), createPdfDto.getCardPdfList(), createPdfDto.getFileTempList(), basicCardRule);
+                        createPdfUtil.examStudentHtml(examCardMap.get(t.getPaperType()).getHtmlContent(), t, t.getPaperType(), examDetail, tbTaskPdf.getCreateId(), createPdfDto.getCardPdfList(), createPdfDto.getFileTempList(), basicCardRule);
+                        examStudentService.updateAttachmentIdById(t);
                     }
-                    examStudentService.updateBatchById(examStudentList);
                 } else if (examDetailCourse.getTotalSubjects() != null) {
                     AtomicInteger atomicInteger = new AtomicInteger(0);
                     Map<String, BasicAttachment> stringBasicAttachmentMap = new HashMap<>();
@@ -312,7 +316,7 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
                         int seq = atomicInteger.getAndIncrement();
                         int mod = seq % examTaskDetail.getDrawCount();
                         String tempPaperType = paperTypes[mod];
-                        BasicAttachment basicAttachment = createPdfNewUtil.examStudentHtml(examCardMap.get(tempPaperType).getHtmlContent(), null, tempPaperType, examDetail, tbTaskPdf.getCreateId(), createPdfDto.getCardPdfList(), createPdfDto.getFileTempList(), basicCardRule);
+                        BasicAttachment basicAttachment = createPdfUtil.examStudentHtml(examCardMap.get(tempPaperType).getHtmlContent(), null, tempPaperType, examDetail, tbTaskPdf.getCreateId(), createPdfDto.getCardPdfList(), createPdfDto.getFileTempList(), basicCardRule);
 
                         if (!stringBasicAttachmentMap.containsKey(tempPaperType)) {
                             stringBasicAttachmentMap.put(tempPaperType, basicAttachment);
@@ -334,7 +338,7 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
                     examCard = examCardMap.get(s);
                     for (int i = 1; i <= backupCount; i++) {
                         String backupPackageCode = examDetail.getPackageCode() + String.format(SystemConstant.DATE_TIME_FORMAT, i);
-                        String replaceBackupCardHtmlContent = createPdfNewUtil.replaceBackupCardHtmlParam(examCard, s, basicCardRule, backupPackageCode);
+                        String replaceBackupCardHtmlContent = createPdfUtil.replaceBackupCardHtmlParam(examCard, s, basicCardRule, backupPackageCode);
                         File pdfFile = PdfUtil.htmlToPdf(replaceBackupCardHtmlContent);
                         PdfDto pdfDto = PdfUtil.addPdfPage(pdfFile);
                         FilePathVo filePathVo = fileUploadService.uploadFile(pdfFile, UploadFileEnum.PDF, pdfFile.getName());
@@ -384,7 +388,7 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
                 if (Objects.nonNull(jsonObjectOrdinary.get("attachmentId")) && !Objects.equals("", jsonObjectOrdinary.get("attachmentId"))) {
                     Long attachmentId = Long.parseLong((String) jsonObjectOrdinary.get("attachmentId"));
                     BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
-                    createPdfNewUtil.createCheckIn(examDetail, basicAttachment, (Integer) jsonObjectOrdinary.get("backupCount"), fileTempList);
+                    createPdfUtil.createCheckIn(examDetail, basicAttachment, (Integer) jsonObjectOrdinary.get("backupCount"), fileTempList);
                 }
             }
         }
@@ -392,8 +396,11 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
         if (basicExam.getCategory().equals(ExamCategoryEnum.FORMAL)) {
             String variableContent = examPrintPlan.getVariableContent();
             if (StringUtils.isNotBlank(variableContent)) {
-                List<Long> examDetailCourseListIds = examDetailCourseList.stream().map(BaseEntity::getId).collect(Collectors.toList());
-                List<ExamStudentCourseDto> examStudentCourseDtoList = examStudentService.queryBySchoolIdAndExamDetailCourseIds(basicSchool.getId(), examDetailCourseListIds);
+                List<ExamStudentInfo> examStudentInfoList = new ArrayList<>();
+                for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
+                    CollectionUtils.addAll(examStudentInfoList, examStudentService.listByExamDetailCourseId(examDetailCourse.getId()));
+                }
+
                 //获取变量印品
                 JSONArray jsonArrayVariable = JSONArray.parseArray(variableContent);
                 for (int i = 0; i < jsonArrayVariable.size(); i++) {
@@ -402,10 +409,10 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
                     if (Objects.nonNull(jsonObjectVariable.get("templateId")) && !Objects.equals("", jsonObjectVariable.get("templateId"))) {
                         Long templateId = Long.parseLong((String) jsonObjectVariable.get("templateId"));
                         if ((CreatePdfTypeEnum.ALL.equals(createPdfType) || CreatePdfTypeEnum.SIGN.equals(createPdfType)) && Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "SIGN")) {//签到表
-                            createPdfNewUtil.createSignBook(templateId, basicSchool.getName(), examDetail, examStudentCourseDtoList, (Integer) jsonObjectVariable.get("backupCount"), examDetailCourseList);
+                            createPdfUtil.createSignBook(templateId, basicSchool.getName(), examDetail, examStudentInfoList, (Integer) jsonObjectVariable.get("backupCount"), examDetailCourseList);
                         } else if ((CreatePdfTypeEnum.ALL.equals(createPdfType) || CreatePdfTypeEnum.PACKAGE.equals(createPdfType)) && Objects.nonNull(type) && Objects.equals(type.toUpperCase(), "PACKAGE")) {//卷袋贴
                             Integer backupCount = SystemConstant.calcBackupCount(examDetail.getBackupCount(), examDetail.getTotalSubjects(), 1);
-                            createPdfNewUtil.createPaperPackage(templateId, basicSchool.getName(), examDetail, examStudentCourseDtoList, backupCount, (Integer) jsonObjectVariable.get("backupCount"), examDetailCourseList, examPrintPlan.getExamId());
+                            createPdfUtil.createPaperPackage(templateId, basicSchool.getName(), examDetail, examStudentInfoList, backupCount, (Integer) jsonObjectVariable.get("backupCount"), examDetailCourseList, examPrintPlan.getExamId());
                         }
                     }
                 }

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

@@ -9,8 +9,8 @@ import com.google.common.reflect.TypeToken;
 import com.google.gson.Gson;
 import com.qmth.boot.api.exception.ApiException;
 import com.qmth.distributed.print.business.bean.dto.*;
-import com.qmth.distributed.print.business.bean.examRule.CodeNameEnableValue;
-import com.qmth.distributed.print.business.bean.examRule.FieldsDto;
+import com.qmth.teachcloud.common.bean.examRule.CodeNameEnableValue;
+import com.qmth.teachcloud.common.bean.examRule.FieldsDto;
 import com.qmth.distributed.print.business.bean.params.DownloadPaperFileParam;
 import com.qmth.distributed.print.business.bean.result.DictionaryResult;
 import com.qmth.distributed.print.business.bean.result.TSyncExamStudentScoreResult;
@@ -21,7 +21,7 @@ import com.qmth.distributed.print.business.enums.PaperFileDownloadExposureStatus
 import com.qmth.distributed.print.business.enums.PrintPlanStatusEnum;
 import com.qmth.distributed.print.business.service.*;
 import com.qmth.distributed.print.business.templete.service.TaskLogicService;
-import com.qmth.distributed.print.business.util.pdf.CreatePdfNewUtil;
+import com.qmth.distributed.print.business.util.CreatePdfUtil;
 import com.qmth.teachcloud.common.annotation.ExcelDBFieldDesc;
 import com.qmth.teachcloud.common.base.BaseEntity;
 import com.qmth.teachcloud.common.bean.dto.DataPermissionRule;
@@ -97,7 +97,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
     @Resource
     BasicCourseService basicCourseService;
     @Resource
-    CreatePdfNewUtil createPdfNewUtil;
+    CreatePdfUtil createPdfUtil;
     @Resource
     TBTaskPdfService tbTaskPdfService;
     @Resource
@@ -638,7 +638,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                         String cardHtmlPath = dirPath + "题卡" + SystemConstant.HYPHEN + name + SystemConstant.HTML_PREFIX;
                         String cardPdfPath = dirPath + "题卡" + SystemConstant.HYPHEN + name + SystemConstant.PDF_PREFIX;
                         // 通用题卡
-                        String htmlContent = createPdfNewUtil.replaceBlankHtmlContent(examCard.getHtmlContent());
+                        String htmlContent = createPdfUtil.replaceBlankHtmlContent(examCard.getHtmlContent());
                         // html
                         File localFile = new File(cardHtmlPath);
                         if (!localFile.exists()) {
@@ -1132,7 +1132,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                             localFile.createNewFile();
                         }
                         // 通用题卡
-                        String htmlContent = createPdfNewUtil.replaceBlankHtmlContent(examCard.getHtmlContent());
+                        String htmlContent = createPdfUtil.replaceBlankHtmlContent(examCard.getHtmlContent());
                         // 生成html文件
                         FileCopyUtils.copy(htmlContent.getBytes(StandardCharsets.UTF_8), localFile);
                         // 转pdf文件

+ 346 - 778
distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/CreatePdfUtil.java

@@ -1,16 +1,20 @@
 package com.qmth.distributed.print.business.util;
 
 import cn.hutool.core.date.DateUtil;
-import cn.hutool.core.util.ReflectUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.itextpdf.text.pdf.PdfReader;
 import com.qmth.distributed.print.business.bean.dto.*;
-import com.qmth.distributed.print.business.cache.CreatePdfCacheUtil;
+import com.qmth.distributed.print.business.bean.dto.pdf.ExamStudentInfo;
 import com.qmth.distributed.print.business.entity.*;
 import com.qmth.distributed.print.business.enums.ExamDetailStatusEnum;
 import com.qmth.distributed.print.business.enums.ExamNumberStyleEnum;
+import com.qmth.distributed.print.business.enums.PrintPlanStatusEnum;
+import com.qmth.distributed.print.business.enums.RequiredFieldsEnum;
 import com.qmth.distributed.print.business.service.*;
+import com.qmth.teachcloud.common.bean.examRule.CodeNameEnable;
+import com.qmth.teachcloud.common.bean.examRule.CodeNameEnableValue;
 import com.qmth.teachcloud.common.bean.vo.FilePathVo;
 import com.qmth.teachcloud.common.bean.vo.OriginalVo;
 import com.qmth.teachcloud.common.bean.vo.PaperInfoVo;
@@ -19,15 +23,12 @@ import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.BasicAttachment;
 import com.qmth.teachcloud.common.entity.BasicPrintConfig;
 import com.qmth.teachcloud.common.entity.BasicSemester;
-import com.qmth.teachcloud.common.entity.TBTask;
 import com.qmth.teachcloud.common.enums.*;
 import com.qmth.teachcloud.common.service.BasicAttachmentService;
 import com.qmth.teachcloud.common.service.BasicSemesterService;
-import com.qmth.teachcloud.common.service.TeachcloudCommonService;
-import com.qmth.teachcloud.common.util.ConvertUtil;
+import com.qmth.teachcloud.common.service.FileUploadService;
 import com.qmth.teachcloud.common.util.ExamTaskUtil;
 import com.qmth.teachcloud.common.util.FileUtil;
-import com.qmth.teachcloud.common.util.RedisUtil;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
@@ -38,7 +39,9 @@ import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -54,46 +57,37 @@ public class CreatePdfUtil {
     private final static Logger log = LoggerFactory.getLogger(CreatePdfUtil.class);
 
     @Resource
-    BasicAttachmentService basicAttachmentService;
+    private BasicAttachmentService basicAttachmentService;
     @Resource
     @Lazy
-    PrintCommonService printCommonService;
-
+    private PrintCommonService printCommonService;
     @Resource
-    ExamDetailService detailService;
-
+    private ExamDetailService examDetailService;
     @Resource
-    RedisUtil redisUtil;
-
+    private BasicTemplateService basicTemplateService;
     @Resource
-    TeachcloudCommonService teachcloudCommonService;
-
+    private BasicSemesterService basicSemesterService;
     @Resource
-    ExamStudentService examStudentService;
-
+    private ExamTaskService examTaskService;
     @Resource
-    BasicTemplateService basicTemplateService;
-
+    private ExamTaskDetailService examTaskDetailService;
     @Resource
-    BasicSemesterService basicSemesterService;
-
+    private ExamPrintPlanService examPrintPlanService;
     @Resource
-    ExamTaskService examTaskService;
-
+    private BasicPrintConfigService basicPrintConfigService;
     @Resource
-    ExamTaskDetailService examTaskDetailService;
-
+    private FileUploadService fileUploadService;
 
     /**
      * 创建登记表
      *
      * @param examDetail
      * @param basicAttachment
-     * @param ordinaryPdfList
      * @param printCount
      * @param fileTempList
+     * @throws Exception
      */
-    public void createCheckIn(ExamDetail examDetail, BasicAttachment basicAttachment, List<PdfDto> ordinaryPdfList, Integer printCount, List<File> fileTempList) throws Exception {
+    public void createCheckIn(ExamDetail examDetail, BasicAttachment basicAttachment, Integer printCount, List<File> fileTempList) throws Exception {
         Optional.ofNullable(basicAttachment).orElseThrow(() -> ExceptionResultEnum.ATTACHMENT_IS_NULL.exception());
 
         String type = basicAttachment.getType();
@@ -104,26 +98,24 @@ public class CreatePdfUtil {
             PrintPathVo printPathVo = new PrintPathVo(ClassifyEnum.CHECK_IN, filePathVo.getUploadType(), filePathVo.getType(), filePath, basicAttachment.getMd5(), null, null);
             examDetail.setAttachmentPath(printCommonService.parseAttachmentPath(examDetail.getAttachmentPath(), printPathVo));
 
-            for (int i = 0; i < printCount; i++) {
-                ordinaryPdfList.add(new PdfDto(filePath, PageSizeEnum.A4, 0));
-            }
+//            for (int i = 0; i < printCount; i++) {
+//                ordinaryPdfList.add(new PdfDto(filePath, PageSizeEnum.A4, 0));
+//            }
         } else {
-            printCommonService.saveAttachmentPdf(ClassifyEnum.CHECK_IN, examDetail, basicAttachment, ordinaryPdfList, printCount, 0);
+            File htmlFileTemp = SystemConstant.getFileTempVar(SystemConstant.HTML_PREFIX);
+            fileUploadService.downloadFile(basicAttachment.getId(), htmlFileTemp.getPath());
+            BasicAttachment attachment = printCommonService.saveAttachmentPdfFromHtml(String.valueOf(basicAttachment.getId()), htmlFileTemp, examDetail.getCreateId(), null, fileTempList, PageSizeEnum.A4);
+            FilePathVo filePathVo1 = JSON.parseObject(attachment.getPath(), FilePathVo.class);
+            PrintPathVo printPathVo = new PrintPathVo(ClassifyEnum.CHECK_IN, filePathVo1.getUploadType(), filePathVo1.getType(), filePathVo1.getPath(), attachment.getMd5(), null, null);
+            examDetail.setAttachmentPath(printCommonService.parseAttachmentPath(examDetail.getAttachmentPath(), printPathVo));
         }
     }
 
 
     /**
      * 生成卷袋贴
-     *
-     * @param schoolName
-     * @param examStudentList
-     * @param variablePdfList
-     * @param printCount
-     * @param examDetailCourseList
-     * @param fileTempList
      */
-    public void createPaperPackage(Long templateId, String schoolName, ExamDetail examDetail, List<ExamStudentCourseDto> examStudentList, List<PdfDto> variablePdfList, Integer backupCount, Integer printCount, List<ExamDetailCourse> examDetailCourseList, Long examId, List<File> fileTempList) {
+    public void createPaperPackage(Long templateId, String schoolName, ExamDetail examDetail, List<ExamStudentInfo> examStudentInfoList, Integer backupCount, Integer printCount, List<ExamDetailCourse> examDetailCourseList, Long examId) {
         BasicTemplate basicTemplate = basicTemplateService.getById(templateId);
         if (Objects.isNull(basicTemplate)) {
             throw ExceptionResultEnum.ERROR.exception("印品数据有误");
@@ -135,9 +127,9 @@ public class CreatePdfUtil {
         pdfPackageDto.setTitle(schoolName);
         pdfPackageDto.setPackageNumber(examDetail.getPackageCode());
 
-        boolean isTag = false;
+        boolean isTag;
         for (ExamDetailCourse detailCourse : examDetailCourseList) {
-            ExamTask examTask = examTaskService.getByExamIdAndCourseCodeAndPaperNumber(examId, detailCourse.getCourseCode(), detailCourse.getPaperNumber());
+            ExamTask examTask = examTaskService.getByExamIdAndCourseIdAndPaperNumber(examId, detailCourse.getCourseId(), detailCourse.getPaperNumber());
             ExamTaskDetail examTaskDetail = examTaskDetailService.getByExamTaskId(examTask.getId());
             List<PaperInfoVo> paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetail.getPaperAttachmentIds());
             for (PaperInfoVo paperInfoVo : paperInfoVoList) {
@@ -151,196 +143,77 @@ public class CreatePdfUtil {
         }
 
         // 标题信息
-        List<JSONObject> objectTitleList = JSON.parseArray(object.getString("title"), JSONObject.class).stream().filter(m -> m.getBoolean("enable")).collect(Collectors.toList());
-        List<Map<String, String>> titlePlate = new ArrayList<>();
-        for (JSONObject jsonObject : objectTitleList) {
-            Map<String, String> titleMap = new HashMap<>();
-            String code = jsonObject.getString("code");
-            String name = jsonObject.getString("name");
-            titleMap.put("code", code);
-            titleMap.put("name", name);
-            if ("semesterName".equals(code)) {
-                BasicSemester basicSemester = basicSemesterService.selectByExamId(examId);
-                titleMap.put("value", basicSemester == null ? null : basicSemester.getName() + "  课程考试");
-            }
-            titlePlate.add(titleMap);
+        List<CodeNameEnable> objectTitleList = JSON.parseArray(object.getString("title"), CodeNameEnable.class).stream().filter(m -> m.getEnable()).collect(Collectors.toList());
+        List<CodeNameEnableValue> titlePlate = new ArrayList<>();
+        CodeNameEnableValue codeNameEnableValue;
+        for (CodeNameEnable jsonObject : objectTitleList) {
+            String code = jsonObject.getCode();
+            String name = jsonObject.getName();
+            BasicSemester basicSemester = basicSemesterService.selectByExamId(examId);
+            codeNameEnableValue = new CodeNameEnableValue(code, name, jsonObject.getEnable(), "semesterName".equals(code) && basicSemester != null ? basicSemester.getName() + "  课程考试" : null);
+            titlePlate.add(codeNameEnableValue);
         }
         pdfPackageDto.setTitlePlate(titlePlate);
 
-        List<JSONObject> objectList = JSON.parseArray(object.getString("basic"), JSONObject.class).stream().filter(m -> m.getBoolean("enable")).collect(Collectors.toList());
+        List<CodeNameEnable> objectList = JSON.parseArray(object.getString("basic"), CodeNameEnable.class).stream().filter(m -> m.getEnable()).collect(Collectors.toList());
+
+        boolean isCourseHasTwo = objectList.stream().filter(m -> RequiredFieldsEnum.COURSE_CODE.getCode().equals(m.getCode()) || RequiredFieldsEnum.COURSE_NAME.getCode().equals(m.getCode())).count() == 2;
+        boolean isDateHasTwo = objectList.stream().filter(m -> RequiredFieldsEnum.EXAM_DATE.getCode().equals(m.getCode()) || RequiredFieldsEnum.EXAM_TIME.getCode().equals(m.getCode())).count() == 2;
+
+        Set<List<CodeNameEnableValue>> examStudentFieldSet = examStudentInfoList.stream().map(m -> m.getFieldList()).collect(Collectors.toSet());
 
-        boolean isCourseHasTwo = objectList.stream().filter(m -> "courseCode".equals(m.getString("code")) || "courseName".equals(m.getString("code"))).count() == 2;
-        boolean isDateHasTwo = objectList.stream().filter(m -> "examDate".equals(m.getString("code")) || "examTime".equals(m.getString("code"))).count() == 2;
         boolean isCourseFill = false;
         boolean isDateFill = false;
+        CodeNameEnableValue basicValue;
         // 基础信息
-        List<Map<String, String>> basicPlate = new ArrayList<>();
-        for (JSONObject jsonObject : objectList) {
-            String code = jsonObject.getString("code");
-            String name = jsonObject.getString("name");
-            if ("examDate".equals(code) || "examTime".equals(code)) {
-                String startDate = DateUtil.format(new Date(examDetail.getExamStartTime()), SystemConstant.DATE_PATTERN);
-                String endDate = DateUtil.format(new Date(examDetail.getExamEndTime()), SystemConstant.DATE_PATTERN);
-                String startTime = DateUtil.format(new Date(examDetail.getExamStartTime()), SystemConstant.TIME_PATTERN);
-                String endTime = DateUtil.format(new Date(examDetail.getExamEndTime()), SystemConstant.TIME_PATTERN);
-                Map<String, String> basicMap = new HashMap<>();
-                if (isDateHasTwo) {
-                    if (isDateFill) {
-                        continue;
-                    }
-                    String examTime;
-                    if (startDate.equals(endDate)) {
-                        examTime = startDate + " " + startTime + SystemConstant.HYPHEN + endTime;
-                    } else {
-                        examTime = startDate + " " + startTime + SystemConstant.HYPHEN + endDate + " " + endTime;
-                    }
-                    basicMap.put("code", "examTime");
-                    basicMap.put("name", "考试时间");
-                    basicMap.put("value", examTime);
-                    isDateFill = true;
-                } else {
-                    String examTime = "";
-                    if ("examDate".equals(code)) {
-                        if (startDate.equals(endDate)) {
-                            examTime = startDate;
-                        } else {
-                            examTime = startDate + SystemConstant.HYPHEN + endDate;
-                        }
-                    } else if ("examTime".equals(code)) {
-                        if (startDate.equals(endDate)) {
-                            examTime = startDate + " " + startTime + SystemConstant.HYPHEN + endTime;
-                        } else {
-                            examTime = startDate + " " + startTime + SystemConstant.HYPHEN + endDate + " " + endTime;
-                        }
-                    }
-                    basicMap.put("code", code);
-                    basicMap.put("name", name);
-                    basicMap.put("value", examTime);
-                }
-                basicPlate.add(basicMap);
-            } else if ("courseCode".equals(code) || "courseName".equals(code)) {
-                Map<String, String> basicMap = new HashMap<>();
+        List<CodeNameEnableValue> basicPlate = new ArrayList<>();
+        for (CodeNameEnable jsonObject : objectList) {
+            String code = jsonObject.getCode();
+            String name = jsonObject.getName();
+
+            if (RequiredFieldsEnum.COURSE_CODE.getCode().equals(code) || RequiredFieldsEnum.COURSE_NAME.getCode().equals(code)) {
                 if (isCourseHasTwo) {
                     if (isCourseFill) {
                         continue;
                     }
                     List<String> courseNames = examDetailCourseList.stream().map(m -> String.format("%s(%s)", m.getCourseName(), m.getCourseCode())).collect(Collectors.toList());
-                    basicMap.put("code", "courseName");
-                    basicMap.put("name", "课程名称");
-                    basicMap.put("value", CollectionUtils.isNotEmpty(courseNames) ? String.join(SystemConstant.COMMA_OF_CHINESE, courseNames) : "");
+                    basicValue = new CodeNameEnableValue(RequiredFieldsEnum.COURSE_NAME.getCode(), RequiredFieldsEnum.COURSE_NAME.getName(), true, String.join(SystemConstant.COMMA_OF_CHINESE, courseNames));
                     isCourseFill = true;
                 } else {
-                    List<String> courseNames = examDetailCourseList.stream().map(m -> "courseCode".equals(code) ? m.getCourseCode() : "courseName".equals(code) ? m.getCourseName() : "").collect(Collectors.toList());
-                    basicMap.put("code", code);
-                    basicMap.put("name", name);
-                    basicMap.put("value", CollectionUtils.isNotEmpty(courseNames) ? String.join(SystemConstant.COMMA_OF_CHINESE, courseNames) : "");
+                    basicValue = defaultCodeNameEnableValue(code, name, examStudentFieldSet);
                 }
-                basicPlate.add(basicMap);
-            } else if ("paperNumber".equals(code)) {
-                List<String> paperNumbers = examDetailCourseList.stream().map(ExamDetailCourse::getPaperNumber).collect(Collectors.toList());
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", CollectionUtils.isNotEmpty(paperNumbers) ? String.join(SystemConstant.COMMA_OF_CHINESE, paperNumbers) : "");
-                basicPlate.add(basicMap);
-            } else if ("examPlace".equals(code) || "campusName".equals(code)) {
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", examDetail.getExamPlace());
-                basicPlate.add(basicMap);
-            } else if ("examRoom".equals(code) || "examClassroomName".equals(code)) {
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", examDetail.getExamRoom());
-                basicPlate.add(basicMap);
-            } else if ("collegeName".equals(code)) {
-                Set<String> collegeNames = examStudentList.stream().map(ExamStudent::getCollegeName).collect(Collectors.toSet());
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", CollectionUtils.isNotEmpty(collegeNames) ? String.join(SystemConstant.COMMA_OF_CHINESE, collegeNames) : "");
-                basicPlate.add(basicMap);
-            } else if ("majorName".equals(code)) {
-                Set<String> stringSet = new HashSet<>();
-                Set<String> majorNames = examStudentList.stream().filter(m -> StringUtils.isNotBlank(m.getMajorName())).map(ExamStudent::getMajorName).collect(Collectors.toSet());
-                if (!majorNames.isEmpty()) {
-                    stringSet.addAll(majorNames);
-                }
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", CollectionUtils.isNotEmpty(stringSet) ? String.join(SystemConstant.COMMA_OF_CHINESE, stringSet) : "");
-                basicPlate.add(basicMap);
-            } else if ("clazzName".equals(code)) {
-                Set<String> clazzNames = examStudentList.stream().filter(m -> StringUtils.isNotBlank(m.getClazzName())).map(ExamStudent::getClazzName).collect(Collectors.toSet());
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", CollectionUtils.isNotEmpty(clazzNames) ? String.join(SystemConstant.COMMA_OF_CHINESE, clazzNames) : "");
-                basicPlate.add(basicMap);
-            } else if ("teachClazzName".equals(code)) {
-                Set<String> teachClazzNames = examStudentList.stream().filter(m -> StringUtils.isNotBlank(m.getTeachClazzName())).map(ExamStudent::getTeachClazzName).collect(Collectors.toSet());
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", CollectionUtils.isNotEmpty(teachClazzNames) ? String.join(SystemConstant.COMMA_OF_CHINESE, teachClazzNames) : "");
-                basicPlate.add(basicMap);
-            } else {
-                // 扩展字段走本校验,进行数据组装
-                Set<String> extendFieldsSet = examStudentList.stream().map(ExamStudentCourseDto::getExtendFields).collect(Collectors.toSet());
-                Set<String> finalSet = new HashSet<>();
-                for (String extendField : extendFieldsSet) {
-                    List<JSONObject> jsonObjects = JSON.parseArray(extendField, JSONObject.class);
-                    Set<String> values = jsonObjects.stream().filter(m -> code.equals(m.getString("code"))).map(m -> m.getString("value")).collect(Collectors.toSet());
-                    finalSet.addAll(values);
+            } else if (RequiredFieldsEnum.EXAM_DATE.getCode().equals(code) || RequiredFieldsEnum.EXAM_TIME.getCode().equals(code)) {
+                if (isDateHasTwo) {
+                    if (isDateFill) {
+                        continue;
+                    }
+                    String startDate = DateUtil.format(new Date(examDetail.getExamStartTime()), SystemConstant.DATE_PATTERN);
+                    String startTime = DateUtil.format(new Date(examDetail.getExamStartTime()), SystemConstant.TIME_PATTERN);
+                    String endTime = DateUtil.format(new Date(examDetail.getExamEndTime()), SystemConstant.TIME_PATTERN);
+                    basicValue = new CodeNameEnableValue(RequiredFieldsEnum.EXAM_TIME.getCode(), RequiredFieldsEnum.EXAM_TIME.getName(), true, startDate + " " + startTime + SystemConstant.HYPHEN + endTime);
+                    isDateFill = true;
+                } else {
+                    basicValue = defaultCodeNameEnableValue(code, name, examStudentFieldSet);
                 }
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", String.join(SystemConstant.COMMA_OF_CHINESE, finalSet));
-                basicPlate.add(basicMap);
-            }
-
-            if ("paperCount".equals(code)) {
-                Map<String, String> basicMap1 = new HashMap<>();
-                basicMap1.put("code", "paperCount");
-                basicMap1.put("name", "试卷数量");
-                basicMap1.put("value", examStudentList.size() + " + " + backupCount);
-                basicPlate.add(basicMap1);
+            } else if ("paperCount".equals(code)) {
+                basicValue = new CodeNameEnableValue(code, name, true, examStudentInfoList.size() + " + " + backupCount);
             } else if ("examCount".equals(code)) {
-                Map<String, String> basicMap2 = new HashMap<>();
-                basicMap2.put("code", "examCount");
-                basicMap2.put("name", "应考人数");
-                basicMap2.put("value", String.valueOf(examStudentList.size()));
-                basicPlate.add(basicMap2);
+                basicValue = new CodeNameEnableValue(code, name, true, String.valueOf(examStudentInfoList.size()));
             } else if ("actualExamCount".equals(code)) {
-                Map<String, String> basicMap3 = new HashMap<>();
-                basicMap3.put("code", "actualExamCount");
-                basicMap3.put("name", "实考人数");
-                basicMap3.put("value", "");
-                basicPlate.add(basicMap3);
+                basicValue = new CodeNameEnableValue(code, name, true, "");
+            } else {
+                basicValue = defaultCodeNameEnableValue(code, name, examStudentFieldSet);
             }
+            basicPlate.add(basicValue);
         }
-
         pdfPackageDto.setBasicPlate(basicPlate);
-        printCommonService.saveAttachmentPackagePdf(pdfPackageDto, examDetail, variablePdfList, printCount, fileTempList);
+        printCommonService.saveAttachmentPackagePdf(pdfPackageDto, examDetail, printCount);
     }
 
     /**
      * 创建签到表
-     *
-     * @param templateId
-     * @param schoolName
-     * @param examDetail
-     * @param examStudentList
-     * @param variablePdfList
-     * @param printCount
-     * @param examDetailCourseList
-     * @param fileTempList
      */
-    public void createSignBook(Long templateId, String schoolName, ExamDetail examDetail, List<ExamStudentCourseDto> examStudentList, List<PdfDto> variablePdfList, Integer printCount, List<ExamDetailCourse> examDetailCourseList, List<File> fileTempList) {
+    public void createSignBook(Long templateId, String schoolName, ExamDetail examDetail, List<ExamStudentInfo> examStudentInfoList, Integer printCount, List<ExamDetailCourse> examDetailCourseList) {
         BasicTemplate basicTemplate = basicTemplateService.getById(templateId);
         if (Objects.isNull(basicTemplate)) {
             throw ExceptionResultEnum.ERROR.exception("印品数据有误");
@@ -351,88 +224,49 @@ public class CreatePdfUtil {
         pdfFillDto.setTextDesc(basicTemplate.getTextDesc());
 
         JSONObject jsonObject = JSON.parseObject(basicTemplate.getDisplayRange());
-        List<JSONObject> objectList = JSON.parseArray(jsonObject.getString("basic"), JSONObject.class).stream().filter(m -> m.getBoolean("enable")).collect(Collectors.toList());
+        List<CodeNameEnable> basicList = JSON.parseArray(jsonObject.getString("basic"), CodeNameEnable.class).stream().filter(m -> m.getEnable()).collect(Collectors.toList());
 
-        boolean isCourseHasTwo = objectList.stream().filter(m -> "courseCode".equals(m.getString("code")) || "courseName".equals(m.getString("code"))).count() == 2;
-        boolean isDateHasTwo = objectList.stream().filter(m -> "examDate".equals(m.getString("code")) || "examTime".equals(m.getString("code"))).count() == 2;
-        boolean isPlaceHasTwo = objectList.stream().filter(m -> "examPlace".equals(m.getString("code")) || "examRoom".equals(m.getString("code"))).count() == 2;
+        boolean isCourseHasTwo = basicList.stream().filter(m -> RequiredFieldsEnum.COURSE_CODE.getCode().equals(m.getCode()) || RequiredFieldsEnum.COURSE_NAME.getCode().equals(m.getCode())).count() == 2;
+        boolean isDateHasTwo = basicList.stream().filter(m -> RequiredFieldsEnum.EXAM_DATE.getCode().equals(m.getCode()) || RequiredFieldsEnum.EXAM_TIME.getCode().equals(m.getCode())).count() == 2;
+        boolean isPlaceHasTwo = basicList.stream().filter(m -> RequiredFieldsEnum.EXAM_PLACE.getCode().equals(m.getCode()) || RequiredFieldsEnum.EXAM_ROOM.getCode().equals(m.getCode())).count() == 2;
 
+        Set<List<CodeNameEnableValue>> examStudentFieldSet = examStudentInfoList.stream().map(m -> m.getFieldList()).collect(Collectors.toSet());
         // 基础信息
-        List<Map<String, String>> basicPlate = new ArrayList<>();
+        List<CodeNameEnableValue> basicPlate = new ArrayList<>();
         boolean isCourseFill = false;
         boolean isDateFill = false;
         boolean isPlaceFill = false;
-        for (JSONObject object : objectList) {
-            String code = object.getString("code");
-            String name = object.getString("name");
-            if ("courseCode".equals(code) || "courseName".equals(code)) {
-                Map<String, String> basicMap = new HashMap<>();
+        CodeNameEnableValue codeNameEnableValue;
+        for (CodeNameEnable basicObject : basicList) {
+            String code = basicObject.getCode();
+            String name = basicObject.getName();
+
+            if (RequiredFieldsEnum.COURSE_CODE.getCode().equals(code) || RequiredFieldsEnum.COURSE_NAME.getCode().equals(code)) {
                 if (isCourseHasTwo) {
                     if (isCourseFill) {
                         continue;
                     }
                     List<String> courseNames = examDetailCourseList.stream().map(m -> String.format("%s(%s)", m.getCourseName(), m.getCourseCode())).collect(Collectors.toList());
-                    basicMap.put("code", "courseName");
-                    basicMap.put("name", "课程名称");
-                    basicMap.put("value", CollectionUtils.isNotEmpty(courseNames) ? String.join(SystemConstant.COMMA_OF_CHINESE, courseNames) : "");
+                    codeNameEnableValue = new CodeNameEnableValue(RequiredFieldsEnum.COURSE_NAME.getCode(), RequiredFieldsEnum.COURSE_NAME.getName(), true, String.join(SystemConstant.COMMA_OF_CHINESE, courseNames));
                     isCourseFill = true;
                 } else {
-                    List<String> courseNames = examDetailCourseList.stream().map(m -> "courseCode".equals(code) ? m.getCourseCode() : "courseName".equals(code) ? m.getCourseName() : "").collect(Collectors.toList());
-                    basicMap.put("code", code);
-                    basicMap.put("name", name);
-                    basicMap.put("value", CollectionUtils.isNotEmpty(courseNames) ? String.join(SystemConstant.COMMA_OF_CHINESE, courseNames) : "");
+                    codeNameEnableValue = defaultCodeNameEnableValue(code, name, examStudentFieldSet);
                 }
-                basicPlate.add(basicMap);
-            } else if ("paperNumber".equals(code)) {
-                List<String> paperNumbers = examDetailCourseList.stream().map(ExamDetailCourse::getPaperNumber).collect(Collectors.toList());
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", CollectionUtils.isNotEmpty(paperNumbers) ? String.join(SystemConstant.COMMA_OF_CHINESE, paperNumbers) : "");
-                basicPlate.add(basicMap);
-            } else if ("examDate".equals(code) || "examTime".equals(code)) {
-                String startDate = DateUtil.format(new Date(examDetail.getExamStartTime()), SystemConstant.DATE_PATTERN);
-                String endDate = DateUtil.format(new Date(examDetail.getExamEndTime()), SystemConstant.DATE_PATTERN);
-                String startTime = DateUtil.format(new Date(examDetail.getExamStartTime()), SystemConstant.TIME_PATTERN);
-                String endTime = DateUtil.format(new Date(examDetail.getExamEndTime()), SystemConstant.TIME_PATTERN);
 
-                Map<String, String> basicMap = new HashMap<>();
+            } else if (RequiredFieldsEnum.EXAM_DATE.getCode().equals(code) || RequiredFieldsEnum.EXAM_TIME.getCode().equals(code)) {
                 if (isDateHasTwo) {
                     if (isDateFill) {
                         continue;
                     }
-                    String examTime;
-                    if (startDate.equals(endDate)) {
-                        examTime = startDate + " " + startTime + SystemConstant.HYPHEN + endTime;
-                    } else {
-                        examTime = startDate + " " + startTime + SystemConstant.HYPHEN + endDate + " " + endTime;
-                    }
-                    basicMap.put("code", "examTime");
-                    basicMap.put("name", "考试时间");
-                    basicMap.put("value", examTime);
+                    String startDate = DateUtil.format(new Date(examDetail.getExamStartTime()), SystemConstant.DATE_PATTERN);
+                    String startTime = DateUtil.format(new Date(examDetail.getExamStartTime()), SystemConstant.TIME_PATTERN);
+                    String endTime = DateUtil.format(new Date(examDetail.getExamEndTime()), SystemConstant.TIME_PATTERN);
+                    codeNameEnableValue = new CodeNameEnableValue(RequiredFieldsEnum.EXAM_TIME.getCode(), RequiredFieldsEnum.EXAM_TIME.getName(), true, startDate + " " + startTime + SystemConstant.HYPHEN + endTime);
                     isDateFill = true;
                 } else {
-                    String examTime = "";
-                    if ("examDate".equals(code)) {
-                        if (startDate.equals(endDate)) {
-                            examTime = startDate;
-                        } else {
-                            examTime = startDate + SystemConstant.HYPHEN + endDate;
-                        }
-                    } else if ("examTime".equals(code)) {
-                        if (startDate.equals(endDate)) {
-                            examTime = startDate + " " + startTime + SystemConstant.HYPHEN + endTime;
-                        } else {
-                            examTime = startDate + " " + startTime + SystemConstant.HYPHEN + endDate + " " + endTime;
-                        }
-                    }
-                    basicMap.put("code", code);
-                    basicMap.put("name", name);
-                    basicMap.put("value", examTime);
+                    codeNameEnableValue = defaultCodeNameEnableValue(code, name, examStudentFieldSet);
                 }
-                basicPlate.add(basicMap);
-            } else if ("examPlace".equals(code) || "examRoom".equals(code)) {
-                Map<String, String> basicMap = new HashMap<>();
+            } else if (RequiredFieldsEnum.EXAM_PLACE.getCode().equals(code) || RequiredFieldsEnum.EXAM_ROOM.getCode().equals(code)) {
                 if (isPlaceHasTwo) {
                     if (isPlaceFill) {
                         continue;
@@ -444,200 +278,68 @@ public class CreatePdfUtil {
                     if (StringUtils.isNotBlank(examDetail.getExamRoom())) {
                         stringJoiner.add(examDetail.getExamRoom());
                     }
-                    basicMap.put("code", "examRoom");
-                    basicMap.put("name", "考试地点");
-                    basicMap.put("value", stringJoiner.toString());
+                    codeNameEnableValue = new CodeNameEnableValue(RequiredFieldsEnum.EXAM_ROOM.getCode(), RequiredFieldsEnum.EXAM_ROOM.getName(), true, stringJoiner.toString());
                     isPlaceFill = true;
                 } else {
-                    StringJoiner stringJoiner = new StringJoiner("");
-                    if ("examPlace".equals(code) && StringUtils.isNotBlank(examDetail.getExamPlace())) {
-                        stringJoiner.add(examDetail.getExamPlace());
-                    }
-                    if ("examRoom".equals(code) && StringUtils.isNotBlank(examDetail.getExamRoom())) {
-                        stringJoiner.add(examDetail.getExamRoom());
-                    }
-                    basicMap.put("code", code);
-                    basicMap.put("name", name);
-                    basicMap.put("value", stringJoiner.toString());
+                    codeNameEnableValue = defaultCodeNameEnableValue(code, name, examStudentFieldSet);
                 }
-                basicPlate.add(basicMap);
-            } else if ("collegeName".equals(code)) {
-                Set<String> collegeNames = examStudentList.stream().filter(m -> StringUtils.isNotBlank(m.getCollegeName())).map(ExamStudentCourseDto::getCollegeName).collect(Collectors.toSet());
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", CollectionUtils.isNotEmpty(collegeNames) ? String.join(SystemConstant.COMMA_OF_CHINESE, collegeNames) : "");
-                basicPlate.add(basicMap);
-            } else if ("majorName".equals(code)) {
-                Set<String> majorNames = examStudentList.stream().filter(m -> StringUtils.isNotBlank(m.getMajorName())).map(ExamStudentCourseDto::getMajorName).collect(Collectors.toSet());
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", CollectionUtils.isNotEmpty(majorNames) ? String.join(SystemConstant.COMMA_OF_CHINESE, majorNames) : "");
-                basicPlate.add(basicMap);
-            } else if ("teachClazzName".equals(code)) {
-                Set<String> teachClassNames = examStudentList.stream().filter(m -> StringUtils.isNotBlank(m.getTeachClazzName())).map(ExamStudentCourseDto::getTeachClazzName).collect(Collectors.toSet());
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", CollectionUtils.isNotEmpty(teachClassNames) ? String.join(SystemConstant.COMMA_OF_CHINESE, teachClassNames) : "");
-                basicPlate.add(basicMap);
-            } else if ("clazzName".equals(code)) {
-                Set<String> classNames = examStudentList.stream().filter(m -> StringUtils.isNotBlank(m.getClazzName())).map(ExamStudentCourseDto::getClazzName).collect(Collectors.toSet());
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", CollectionUtils.isNotEmpty(classNames) ? String.join(SystemConstant.COMMA_OF_CHINESE, classNames) : "");
-                basicPlate.add(basicMap);
             } else if ("examCount".equals(code)) {
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", String.valueOf(examStudentList.size()));
-                basicPlate.add(basicMap);
+                codeNameEnableValue = new CodeNameEnableValue(code, name, true, String.valueOf(examStudentInfoList.size()));
             } else if ("actualExamCount".equals(code)) {
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", "");
-                basicPlate.add(basicMap);
+                codeNameEnableValue = new CodeNameEnableValue(code, name, true, "");
             } else {
-                // 扩展字段走本校验,进行数据组装
-                Set<String> extendFieldsSet = examStudentList.stream().map(ExamStudentCourseDto::getExtendFields).collect(Collectors.toSet());
-                Set<String> finalSet = new HashSet<>();
-                for (String extendField : extendFieldsSet) {
-                    List<JSONObject> jsonObjects = JSON.parseArray(extendField, JSONObject.class);
-                    Set<String> values = jsonObjects.stream().filter(m -> code.equals(m.getString("code"))).map(m -> m.getString("value")).collect(Collectors.toSet());
-                    finalSet.addAll(values);
-                }
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", String.join(SystemConstant.COMMA_OF_CHINESE, finalSet));
-                basicPlate.add(basicMap);
+                codeNameEnableValue = defaultCodeNameEnableValue(code, name, examStudentFieldSet);
             }
+            basicPlate.add(codeNameEnableValue);
         }
         pdfFillDto.setBasicPlate(basicPlate);
 
         // 表头信息
-        List<JSONObject> tableList = JSON.parseArray(jsonObject.getString("table"), JSONObject.class).stream().filter(m -> m.getBoolean("enable")).collect(Collectors.toList());
+        List<CodeNameEnable> tableList = JSON.parseArray(jsonObject.getString("table"), CodeNameEnable.class).stream().filter(m -> m.getEnable()).collect(Collectors.toList());
         Map<String, String> studentHeadPlateMap = new LinkedHashMap<>();
-        for (JSONObject object : tableList) {
-            studentHeadPlateMap.put(object.getString("code"), object.getString("name"));
+        for (CodeNameEnable object : tableList) {
+            studentHeadPlateMap.put(object.getCode(), object.getName());
         }
         studentHeadPlateMap.put("studentSign", "签名");
         pdfFillDto.setStudentHeadPlate(studentHeadPlateMap);
 
         // 考生信息
         List<Map<String, String>> studentPlate = new ArrayList<>();
-        for (ExamStudentCourseDto examStudentCourseDto : examStudentList) {
+        for (ExamStudentInfo examStudentInfo : examStudentInfoList) {
+            List<CodeNameEnableValue> fieldList = examStudentInfo.getFieldList();
             Map<String, String> studentMap = new LinkedHashMap<>();
-            if (studentHeadPlateMap.containsKey("siteNumber")) {
-                studentMap.put("siteNumber", examStudentCourseDto.getSiteNumber());
-            }
-            if (studentHeadPlateMap.containsKey("studentName")) {
-                studentMap.put("studentName", examStudentCourseDto.getStudentName());
-            }
-            if (studentHeadPlateMap.containsKey("studentCode")) {
-                studentMap.put("studentCode", examStudentCourseDto.getStudentCode());
-            }
-            if (studentHeadPlateMap.containsKey("courseName")) {
-                studentMap.put("courseName", examStudentCourseDto.getCourseName());
-            }
-            if (studentHeadPlateMap.containsKey("clazzName")) {
-                studentMap.put("clazzName", examStudentCourseDto.getClazzName());
-            }
-            if (studentHeadPlateMap.containsKey("teachClazzName")) {
-                studentMap.put("teachClazzName", examStudentCourseDto.getTeachClazzName());
-            }
-            if (studentHeadPlateMap.containsKey("ticketNumber")) {
-                studentMap.put("ticketNumber", examStudentCourseDto.getTicketNumber());
-            }
-            if (studentHeadPlateMap.containsKey("studentSign")) {
-                studentMap.put("studentSign", "");
+            for (Map.Entry<String, String> entry : studentHeadPlateMap.entrySet()) {
+                Optional<CodeNameEnableValue> optional = fieldList.stream().filter(m -> m.getCode().equals(entry.getKey())).findFirst();
+                studentMap.put(entry.getKey(), optional.isPresent() ? optional.get().getValue() : "");
             }
             studentPlate.add(studentMap);
         }
         pdfFillDto.setStudentPlate(studentPlate);
 
-        printCommonService.saveAttachmentSignPdf(pdfFillDto, examDetail, variablePdfList, printCount, fileTempList, basicTemplate);
+        printCommonService.saveAttachmentSignPdf(pdfFillDto, examDetail, printCount, basicTemplate);
     }
 
-    /**
-     * 替换html通用模版中的条码信息
-     *
-     * @param content 题卡详细内容
-     */
-    public String resetHtmlTemplateBar(String content) {
-        content = content.replaceAll("<img src=\"data:image/png;base64,\\$\\{examNumber\\}\">", "");
-        content = content.replaceAll("\\$\\{examNumberStr\\}", "");
-        return content;
+    private CodeNameEnableValue defaultCodeNameEnableValue(String code, String name, Set<List<CodeNameEnableValue>> examStudentFieldSet) {
+        Set<String> valueSet = new HashSet<>();
+        for (List<CodeNameEnableValue> codeNameEnableValues : examStudentFieldSet) {
+            CollectionUtils.addAll(valueSet, codeNameEnableValues.stream().filter(m -> code.equals(m.getCode())).map(m -> m.getValue()).collect(Collectors.toSet()));
+        }
+        return new CodeNameEnableValue(code, name, true, CollectionUtils.isNotEmpty(valueSet) ? String.join(SystemConstant.COMMA_OF_CHINESE, valueSet) : "");
     }
 
     /**
-     * 替换自定义题卡参数
+     * 题卡html内容,所有参数置空
      *
-     * @param examCard
+     * @param htmlContent
      * @return
      */
-    public String replaceHtmlCardAllParams(ExamCard examCard, BasicCardRule basicCardRule) {
-        //通用题卡
-        String cardTemp = examCard.getHtmlContent();
-        cardTemp = cardTemp.replaceAll("\\$\\{paperTypeName\\}", "");
-        //随机生成试卷条码并将图片转成base64
-        cardTemp = cardTemp.replaceAll("\\$\\{paperType\\}", "");
-        cardTemp = cardTemp.replaceAll("<img src=\"data:image/png;base64,\\$\\{examNumber\\}\">", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{examNumberStr\\}", "");
-        if (Objects.nonNull(basicCardRule) && Objects.nonNull(basicCardRule.getExtendFields())) {
-            JSONArray jsonObjectExtend = (JSONArray) JSONArray.parse(basicCardRule.getExtendFields());//扩展字段
-            if (Objects.nonNull(jsonObjectExtend)) {
-                for (int i = 0; i < jsonObjectExtend.size(); i++) {
-                    JSONObject object = (JSONObject) jsonObjectExtend.get(i);
-                    cardTemp = cardTemp.replaceAll("\\$\\{" + object.get("code") + "\\}", "");
-                }
-            }
-        }
-        cardTemp = cardTemp.replaceAll("\\$\\{examDate\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{examTime\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{ticketNumber\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{siteNumber\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{paperTypeName\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{studentCode\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{studentName\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{courseName\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{courseCode\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{examPlace\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{examRoom\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{paperNumber\\}", "");
-
-        // 根据题卡规则必选字段,替换相应值,没有则“”
-        List<StudentExtendDto> studentExtendDtos = createExtendObjectNull(basicCardRule);
-        if (studentExtendDtos != null) {
-            for (StudentExtendDto extendDto : studentExtendDtos) {
-                cardTemp = cardTemp.replaceAll("\\$\\{" + extendDto.getFieldName() + "\\}", String.valueOf(extendDto.getValue()));
-            }
-        }
-
-        return cardTemp;
-    }
+    public String replaceBlankHtmlContent(String htmlContent) {
+        // 替换条码参数
+        htmlContent = htmlContent.replaceAll("<img src=\"data:image/png;base64,\\$\\{examNumber\\}\">", "");
+        // 正则匹配所有参数,填入空值
+        htmlContent = htmlContent.replaceAll("\\$\\{[A-Za-z0-9]+\\}", "");
+        return htmlContent;
 
-    /**
-     * 获取题卡attachmentId
-     *
-     * @param examCard
-     * @param attachmentIds
-     */
-    public void getCardAttachmentId(ExamCard examCard, Set<Long> attachmentIds) {
-        if (Objects.nonNull(examCard.getBackupAttachment()) && !Objects.equals("", examCard.getBackupAttachment())) {
-            JSONObject jsonObjectCard = JSONObject.parseObject(examCard.getBackupAttachment());
-            JSONArray jsonArrayCard = (JSONArray) jsonObjectCard.get("card");
-            for (int i = 0; i < jsonArrayCard.size(); i++) {
-                JSONObject object = (JSONObject) jsonArrayCard.get(i);
-                if (Objects.nonNull(object.get("attachmentId")) && !Objects.equals("", object.get("attachmentId"))) {
-                    attachmentIds.add((Long) (object.get("attachmentId")));
-                }
-            }
-        }
     }
 
     /**
@@ -645,10 +347,10 @@ public class CreatePdfUtil {
      *
      * @param stuPaperType   考生卷型
      * @param paperPdfDto    抽取的试卷文件信息
-     * @param pdfList        考生试卷集合
+     * @param createPdfDto   生成pdf
      * @param waterMarkNames 水印内容
      */
-    public PdfDto getExamStudentPaperPdf(String stuPaperType, List<PaperPdfDto> paperPdfDto, List<PdfDto> pdfList, String[] waterMarkNames) throws IOException {
+    public PdfDto getExamStudentPaperPdf(String stuPaperType, List<PaperPdfDto> paperPdfDto, CreatePdfDto createPdfDto, String[] waterMarkNames) throws IOException {
         Set<Integer> pagesList = new HashSet<>();
         if (!CollectionUtils.isEmpty(paperPdfDto)) {
             for (PaperPdfDto dto : paperPdfDto) {
@@ -657,7 +359,7 @@ public class CreatePdfUtil {
                     pagesList.add(pages);
                     PdfDto pdfDto = PdfUtil.addPdfPage(dto.getFile());
                     File file = paperPdfDto.size() > 1 ? PdfUtil.addWaterMark(dto.getFile(), waterMarkNames, 0.5f, 12, 0) : dto.getFile();
-                    pdfList.add(new PdfDto(file.getPath(), dto.getPageSize(), pdfDto.getPageCount()));
+                    createPdfDto.getPaperPdfList().add(new PdfDto(file.getPath(), dto.getPageSize(), pdfDto.getPageCount()));
                 }
             }
             int pageCount = pagesList.stream().mapToInt(Integer::intValue).sum();
@@ -668,24 +370,24 @@ public class CreatePdfUtil {
     }
 
     /**
-     * 获取试卷pdf
+     * 获取备份试卷pdf
      *
-     * @param paperPdfDto 抽取的试卷文件信息
-     * @param backupCount 备份数量
-     * @param pdfList     备份试卷集合
+     * @param paperPdfDto  抽取的试卷文件信息
+     * @param backupCount  备份数量
+     * @param createPdfDto 生成pdf对象
      */
-    public PdfDto getPaperPdf(List<PaperPdfDto> paperPdfDto, Integer backupCount, List<PdfDto> pdfList) throws
+    public PdfDto getBackupPaperPdfList(List<PaperPdfDto> paperPdfDto, Integer backupCount, CreatePdfDto createPdfDto) throws
             IOException {
         Set<Integer> pagesList = new HashSet<>();
         boolean tag = false;
-        if (!CollectionUtils.isEmpty(paperPdfDto)) {
+        if (CollectionUtils.isNotEmpty(paperPdfDto)) {
             for (PaperPdfDto dto : paperPdfDto) {
                 int pages = dto.getPages();
                 pagesList.add(pages);
                 tag = pages > 2;
                 PdfDto pdfDto = PdfUtil.addPdfPage(dto.getFile());
                 for (int j = 1; j <= backupCount; j++) {
-                    pdfList.add(new PdfDto(dto.getFile().getPath(), dto.getPageSize(), pdfDto.getPageCount()));
+                    createPdfDto.getPaperPdfList().add(new PdfDto(dto.getFile().getPath(), dto.getPageSize(), pdfDto.getPageCount()));
                 }
             }
             int pageCount = pagesList.stream().mapToInt(Integer::intValue).sum();
@@ -698,145 +400,46 @@ public class CreatePdfUtil {
     /**
      * 获取考试试卷
      *
-     * @param paperType      抽取的试卷型(多个用,分隔)
-     * @param examTaskDetail 命题任务上传试卷信息
-     * @param fileTempList
+     * @param paperType       抽取的试卷型(多个用,分隔)
+     * @param paperInfoVoList 命题任务上传试卷信息
      */
-    public List<PaperPdfDto> getPaperPdfFile(String paperType, ExamTaskDetail examTaskDetail, List<File> fileTempList) throws Exception {
+    public List<PaperPdfDto> getPaperPdfFile(String paperType, List<PaperInfoVo> paperInfoVoList, CreatePdfDto createPdfDto) throws Exception {
         String[] paperTypes = paperType.split(",");
         List<PaperPdfDto> paperPdfDtoList = new ArrayList<>();
         PaperPdfDto paperPdfDto;
-        List<PaperInfoVo> paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetail.getPaperAttachmentIds());
         for (PaperInfoVo paperInfoVo : paperInfoVoList) {
-            String attachmentId = paperInfoVo.getAttachmentId();
-            if (StringUtils.isNotBlank(attachmentId)) {
-                BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
-                Optional.ofNullable(basicAttachment).orElseThrow(() -> ExceptionResultEnum.ATTACHMENT_IS_NULL.exception("所在路径不存在"));
-
-                String name = paperInfoVo.getName();
-                OriginalVo original = paperInfoVo.getOriginal();
-                // 返回抽中的试卷
-                for (String type : paperTypes) {
-                    if (Objects.equals(name.toUpperCase(), type.toUpperCase())) {
-                        File file = teachcloudCommonService.getFile(basicAttachment.getPath(), false, fileTempList);
-                        int pages = original.getPages();
-
-                        PageSizeEnum pageSizeEnum = PageSizeEnum.valueOf(original.getPageSize());
-                        Optional.ofNullable(pageSizeEnum).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未设置pdf格式"));
-
-                        paperPdfDto = new PaperPdfDto(type, file, pages, pageSizeEnum);
-                        paperPdfDtoList.add(paperPdfDto);
-                        break;
-                    }
-                }
-            }
-        }
-        return paperPdfDtoList;
-    }
-
-    /**
-     * 抽取试卷
-     *
-     * @param drawRule
-     * @param examTaskDetail
-     * @param key
-     * @return
-     */
-    public String getPaperType(DrawRuleEnum drawRule, ExamTaskDetail examTaskDetail, String key, String specifyPaperType) {
-        String paperType = null;
-        if (Objects.nonNull(specifyPaperType)) {
-            CreatePdfCacheUtil.setPaperType(key, paperType);
-            return specifyPaperType;
-        }
-        //抽取卷型
-        drawRule = Objects.nonNull(drawRule) ? drawRule : DrawRuleEnum.ONE;
-        //未曝光卷型
-        String unexposedPaperType = examTaskDetail.getUnexposedPaperType();
-        //已曝光卷型
-        String exposedPaperType = examTaskDetail.getExposedPaperType();
-
-        if (drawRule == DrawRuleEnum.ONE) {
-            if (Objects.isNull(unexposedPaperType) || Objects.equals(unexposedPaperType.trim(), "")) {
-//                CreatePdfCacheUtil.deletePaperType(key);
-                throw ExceptionResultEnum.PAPER_ERROR.exception();
-            }
-        } else {
-            if ((Objects.isNull(exposedPaperType) || Objects.equals(exposedPaperType.trim(), "")) && (Objects.isNull(unexposedPaperType) || Objects.equals(unexposedPaperType.trim(), ""))) {
-//                CreatePdfCacheUtil.deletePaperType(key);
-                throw ExceptionResultEnum.PAPER_ERROR.exception();
-            }
-        }
-        // 单次抽取套数
-        int drawCount = examTaskDetail.getDrawCount().intValue();
-
-        String[] paperTypes;
-        boolean lock = true;
-        for (int i = 0; i < SystemConstant.MAX_RETRY_COUNT; i++) {
-            lock = redisUtil.lock(key, SystemConstant.REDIS_CACHE_TIME_OUT);
-            if (lock) {
-                try {
-                    paperType = CreatePdfCacheUtil.getPaperType(key);
-                    if (StringUtils.isBlank(paperType)) {
-                        if (drawRule == DrawRuleEnum.ONE) {
-                            paperTypes = unexposedPaperType.split(",");
-                            if (paperTypes.length - drawCount < 0) {
-                                throw ExceptionResultEnum.ERROR.exception("没有可用卷型");
-                            }
-                        } else {
-                            if (Objects.nonNull(unexposedPaperType)) {
-                                paperTypes = unexposedPaperType.split(",");
-                            } else {
-                                paperTypes = exposedPaperType.split(",");
-                            }
-                        }
-                        paperType = randomPaperType(paperTypes, exposedPaperType, drawCount);
-                        CreatePdfCacheUtil.setPaperType(key, paperType);
-                    }
+            BasicAttachment basicAttachment = basicAttachmentService.getById(paperInfoVo.getAttachmentId());
+            Optional.ofNullable(basicAttachment).orElseThrow(() -> ExceptionResultEnum.ATTACHMENT_IS_NULL.exception("命题任务中上传试卷文件路径不存在"));
+
+            // 卷型
+            String name = paperInfoVo.getName();
+            OriginalVo original = paperInfoVo.getOriginal();
+            // 返回抽中的试卷
+            for (String type : paperTypes) {
+                if (StringUtils.equalsIgnoreCase(name, type)) {
+                    File file = SystemConstant.getFileTempVar(SystemConstant.PDF_PREFIX);
+                    createPdfDto.getFileTempList().add(file);
+                    fileUploadService.downloadFile(basicAttachment, file.getPath());
+//                    PageSizeEnum pageSizeEnum = PageSizeEnum.valueOf(original.getPageSize());
+//                    Optional.ofNullable(pageSizeEnum).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("命题任务中上传试卷文件未设置pdf格式"));
+                    paperPdfDto = new PaperPdfDto(type, file, new PdfReader(new FileInputStream(file)).getNumberOfPages(), null);
+                    paperPdfDtoList.add(paperPdfDto);
                     break;
-                } catch (Exception e) {
-                    log.error(SystemConstant.LOG_ERROR, e);
-                } finally {
-                    redisUtil.releaseLock(key);
-                }
-            } else {//未获取到锁,等待500毫秒继续获取
-                try {
-                    Thread.sleep(500);
-                } catch (InterruptedException e) {
-                    log.error(SystemConstant.LOG_ERROR, e);
                 }
             }
         }
-        log.info("getPaperType key:{},paperType:{},lock:{}", key, paperType, lock);
-        if (!lock) {
-            log.info("getPaperType 未获取到锁,key:{}", key);
-            throw ExceptionResultEnum.PAPER_TYPE_ERROR.exception();
-        }
-        return paperType;
+        return paperPdfDtoList;
     }
 
-    private String randomPaperType(String[] unexposedPaperTypes, String exposedPaperTypes, int drawCount) {
+    private String randomPaperType(String[] unexposedPaperTypes, int drawCount) {
         List<String> finalTypes = new ArrayList<>();
         List<String> unexposedPaperTypesList = new ArrayList<>(Arrays.asList(unexposedPaperTypes));
-        List<String> exposedPaperTypesList = StringUtils.isBlank(exposedPaperTypes) ? new ArrayList<>() : new ArrayList<>(Arrays.asList(exposedPaperTypes.split(",")));
-        if (unexposedPaperTypesList.size() - drawCount >= 0) {
-            for (int i = 0; i < drawCount; i++) {
-                int paperRandom = new Random().nextInt(unexposedPaperTypesList.size());
-                finalTypes.add(unexposedPaperTypesList.get(paperRandom));
-                unexposedPaperTypesList.remove(paperRandom);
-            }
-
-        } else {
-            for (int i = 0; i < unexposedPaperTypesList.size(); i++) {
-                int paperRandom = new Random().nextInt(unexposedPaperTypesList.size());
-                finalTypes.add(unexposedPaperTypesList.get(paperRandom));
-                unexposedPaperTypesList.remove(paperRandom);
-            }
-            for (int i = 0; i < drawCount - unexposedPaperTypesList.size(); i++) {
-                int paperRandom = new Random().nextInt(exposedPaperTypesList.size());
-                finalTypes.add(exposedPaperTypesList.get(paperRandom));
-                exposedPaperTypesList.remove(paperRandom);
-            }
+        for (int i = 0; i < drawCount; i++) {
+            int index = new Random().nextInt(unexposedPaperTypesList.size());
+            finalTypes.add(unexposedPaperTypesList.get(index));
+            unexposedPaperTypesList.remove(index);
         }
+
         finalTypes = finalTypes.stream().sorted(Comparator.comparing(String::valueOf)).collect(Collectors.toList());
         return String.join(",", finalTypes);
     }
@@ -844,18 +447,17 @@ public class CreatePdfUtil {
     /**
      * 合并A3 pdf
      *
-     * @param fileTempList
      * @param list
      * @return
      * @throws IOException
      */
-    public String mergeA3Pdf(List<File> fileTempList, List<PdfDto>... list) throws IOException {
+    public String mergeA3Pdf(List<PdfDto>... list) {
         List<PdfDto> mergePdfA3List = new ArrayList<>();
         for (int i = 0; i < list.length; i++) {
             mergePdfA3List.addAll(list[i]);
         }
         List<String> pathA3List = mergePdfA3List.stream().map(PdfDto::getPath).collect(Collectors.toList());
-        return PdfUtil.mergePdf(pathA3List.toArray(new String[mergePdfA3List.size()]), null, fileTempList);
+        return PdfUtil.mergePdf(pathA3List.toArray(new String[mergePdfA3List.size()]), null);
     }
 
     /**
@@ -865,7 +467,7 @@ public class CreatePdfUtil {
      * @return
      * @throws IOException
      */
-    public String mergeA4Pdf(List<File> fileTempList, List<PdfDto>... list) throws IOException {
+    public String mergeA4Pdf(List<File> fileTempList, List<PdfDto>... list) {
         List<PdfDto> mergePdfA4List = new ArrayList<>();
         for (int i = 0; i < list.length; i++) {
             mergePdfA4List.addAll(list[i]);
@@ -879,281 +481,247 @@ public class CreatePdfUtil {
      *
      * @param dirNamePaper
      * @param dirNameCardA3
-     * @param tbTask
-     * @param userId
-     * @param examDetail
-     * @param basicPrintConfig
-     * @param fileTempList
+     * @param tbTaskPdf
      * @return
-     * @throws IOException
+     * @throws Exception
      */
     @Transactional
-    public BasicAttachment mergePdfSaveDb(String dirNamePaper,
-                                          String dirNameCardA3,
-                                          TBTask tbTask,
-                                          Long userId,
-                                          ExamDetail examDetail,
-                                          BasicPrintConfig basicPrintConfig,
-                                          List<File> fileTempList) throws Exception {
-        File localA4PdfFile = null, localPaperPdfFile = null, localA3PdfCardFile = null;
-        BasicAttachment basicAttachment = null;
+    public void mergePdfSaveDb(String dirNamePaper,
+                               String dirNameCardA3,
+                               TBTaskPdf tbTaskPdf) throws Exception {
+        ExamDetail examDetail = examDetailService.getById(tbTaskPdf.getId());
+        BasicPrintConfig basicPrintConfig = basicPrintConfigService.getByExamId(tbTaskPdf.getExamId());
         // 试卷+题卡
         if (StringUtils.isNotBlank(dirNamePaper)) {
-            dirNamePaper = FileUtil.replaceSplit(dirNamePaper);
-            localPaperPdfFile = new File(dirNamePaper);
+            File localPaperPdfFile = new File(FileUtil.replaceSplit(dirNamePaper));
             examDetail.setPaperPages(PdfUtil.getPdfPages(localPaperPdfFile));
-            basicAttachment = basicAttachmentService.saveAttachmentPdf(dirNamePaper, userId);
-            if (StringUtils.isBlank(tbTask.getImportFileName())) {
-                tbTask.setImportFileName(basicAttachment.getName());
-            }
-            if (StringUtils.isBlank(tbTask.getImportFilePath())) {
-                tbTask.setImportFilePath(basicAttachment.getPath());
-            }
+
+            String uploadFileName = PdfUtil.md5FileName(CreatePdfTypeEnum.PAPER.name() + tbTaskPdf.getId()) + SystemConstant.PDF_PREFIX;
+            FilePathVo filePathVo = fileUploadService.uploadFile(localPaperPdfFile, UploadFileEnum.PDF, uploadFileName);
+            BasicAttachment basicAttachment = new BasicAttachment(JSON.toJSONString(filePathVo), localPaperPdfFile.getName(), SystemConstant.PDF_PREFIX, new BigDecimal(localPaperPdfFile.length()), filePathVo.getMd5(), tbTaskPdf.getCreateId());
+            basicAttachmentService.save(basicAttachment);
             examDetail.setAttachmentId(basicAttachment.getId());
         }
         // 题卡
         if (StringUtils.isNotBlank(dirNameCardA3)) {
-            localA3PdfCardFile = new File(FileUtil.replaceSplit(dirNameCardA3));
+            File localA3PdfCardFile = new File(FileUtil.replaceSplit(dirNameCardA3));
             examDetail.setCardPages(PdfUtil.getPdfPages(localA3PdfCardFile));
-            basicAttachment = basicAttachmentService.saveAttachmentPdf(dirNameCardA3, userId);
-            if (StringUtils.isBlank(tbTask.getImportFileName())) {
-                tbTask.setImportFileName(basicAttachment.getName());
-            }
-            if (StringUtils.isBlank(tbTask.getImportFilePath())) {
-                tbTask.setImportFilePath(basicAttachment.getPath());
-            }
+
+            String uploadFileName = PdfUtil.md5FileName(CreatePdfTypeEnum.CARD_A3.name() + tbTaskPdf.getId()) + SystemConstant.PDF_PREFIX;
+            FilePathVo filePathVo = fileUploadService.uploadFile(localA3PdfCardFile, UploadFileEnum.PDF, uploadFileName);
+            BasicAttachment basicAttachment = new BasicAttachment(JSON.toJSONString(filePathVo), localA3PdfCardFile.getName(), SystemConstant.PDF_PREFIX, new BigDecimal(localA3PdfCardFile.length()), filePathVo.getMd5(), tbTaskPdf.getCreateId());
+            basicAttachmentService.save(basicAttachment);
             examDetail.setCardAttachmentId(basicAttachment.getId());
         }
-//        examDetail.setPagesA4(PdfUtil.getPdfPages(localA4PdfFile));
         if (PrintMethodEnum.AUTO == basicPrintConfig.getPrintMethod()) {
             examDetail.setStatus(ExamDetailStatusEnum.WAITING);
         } else {
             examDetail.setStatus(ExamDetailStatusEnum.READY);
         }
         examDetail.setNormal(true);
-        detailService.saveOrUpdate(examDetail);
-        return basicAttachment;
+        examDetailService.saveOrUpdate(examDetail);
+
+        ExamPrintPlan examPrintPlan = examPrintPlanService.getById(tbTaskPdf.getPrintPlanId());
+        if (PrintMethodEnum.AUTO == basicPrintConfig.getPrintMethod()) {
+            examPrintPlan.setStatus(PrintPlanStatusEnum.PRINTING);
+            examPrintPlanService.updateById(examPrintPlan);
+        }
     }
 
     /**
      * 考生题卡html
      *
-     * @param studentContent     题卡html内容
+     * @param studentHtml        题卡html内容
      * @param examStudent        考生对象
      * @param examDetail         考场对象
-     * @param examDetailCourse   考场课程对象
      * @param userId             当前用户ID
      * @param examStudentPdfList 考生题卡集合
+     * @param fileTempList
      * @param basicCardRule      题卡规则
      */
-    public BasicAttachment examStudentHtml(String studentContent, ExamStudent examStudent, String
-            paperType, ExamDetail examDetail, ExamDetailCourse examDetailCourse,
-                                           Long userId, List<PdfDto> examStudentPdfList, BasicCardRule basicCardRule,
-                                           List<File> fileTempList) throws IOException {
-        String studentHtml = studentContent;
-
-        if (ExamNumberStyleEnum.PRINT.equals(basicCardRule.getExamNumberStyle())) {
-            // 生成学生考号条码并将图片转成base64
-            studentHtml = studentHtml.replaceAll("\\$\\{studentCodeBarcode\\}", examStudent != null && examStudent.getStudentCode() != null ? GoogleBarCodeUtil.createBarCode(examStudent.getStudentCode(), false) : "");
-            studentHtml = studentHtml.replaceAll("\\$\\{ticketNumberBarcode\\}", examStudent != null && examStudent.getTicketNumber() != null ? GoogleBarCodeUtil.createBarCode(examStudent.getTicketNumber(), false) : "");
-            studentHtml = studentHtml.replaceAll("\\$\\{examNumber\\}", examStudent != null && examStudent.getStudentCode() != null ? GoogleBarCodeUtil.createBarCode(examStudent.getStudentCode(), false) : "");
-            studentHtml = studentHtml.replaceAll("\\$\\{examNumberStr\\}", examStudent != null && examStudent.getStudentCode() != null ? examStudent.getStudentCode() : "");
-            // 随机生成学生试卷条码并将图片转成base64
-            studentHtml = studentHtml.replaceAll("\\$\\{paperType\\}", examStudent != null && examStudent.getPaperType() != null ? GoogleBarCodeUtil.createBarCode(SystemConstant.convertPaperType(examStudent.getPaperType()), false) : StringUtils.isNotBlank(paperType) ? GoogleBarCodeUtil.createBarCode(SystemConstant.convertPaperType(paperType), false) : "");
-            // 替换考生卷型
-            studentHtml = studentHtml.replaceAll("\\$\\{paperTypeName\\}", examStudent != null && examStudent.getPaperType() != null ? examStudent.getPaperType() : StringUtils.isNotBlank(paperType) ? paperType : "");
-
-            if (examStudent != null) {
-                // 根据题卡规则必选字段,替换相应值,没有则“”
-                List<StudentExtendDto> studentExtendDtos = createExtendObject(examDetail, examStudent, basicCardRule);
-                if (studentExtendDtos != null) {
-                    for (StudentExtendDto extendDto : studentExtendDtos) {
-                        studentHtml = studentHtml.replaceAll("\\$\\{" + extendDto.getFieldName() + "\\}", String.valueOf(extendDto.getValue()));
+    public BasicAttachment examStudentHtml(String studentHtml, ExamStudentInfo examStudent, String paperType, ExamDetail examDetail,
+                                           Long userId, List<PdfDto> examStudentPdfList, List<File> fileTempList, BasicCardRule basicCardRule) throws IOException {
+        if (basicCardRule != null) {
+            if (ExamNumberStyleEnum.PRINT.equals(basicCardRule.getExamNumberStyle())) {
+                // 生成学生考号条码并将图片转成base64
+                studentHtml = studentHtml.replaceAll("\\$\\{studentCodeBarcode\\}", examStudent != null && examStudent.getStudentCode() != null ? GoogleBarCodeUtil.createBarCode(examStudent.getStudentCode(), false) : "");
+                studentHtml = studentHtml.replaceAll("\\$\\{ticketNumberBarcode\\}", "");
+                studentHtml = studentHtml.replaceAll("\\$\\{examNumber\\}", examStudent != null && examStudent.getStudentCode() != null ? GoogleBarCodeUtil.createBarCode(examStudent.getStudentCode(), false) : "");
+                studentHtml = studentHtml.replaceAll("\\$\\{examNumberStr\\}", examStudent != null && examStudent.getStudentCode() != null ? examStudent.getStudentCode() : "");
+                // 随机生成学生试卷条码并将图片转成base64
+                studentHtml = studentHtml.replaceAll("\\$\\{paperType\\}", examStudent != null && examStudent.getPaperType() != null ? GoogleBarCodeUtil.createBarCode(SystemConstant.convertPaperType(examStudent.getPaperType()), false) : StringUtils.isNotBlank(paperType) ? GoogleBarCodeUtil.createBarCode(SystemConstant.convertPaperType(paperType), false) : "");
+                // 替换考生卷型
+                studentHtml = studentHtml.replaceAll("\\$\\{paperTypeName\\}", examStudent != null && examStudent.getPaperType() != null ? examStudent.getPaperType() : StringUtils.isNotBlank(paperType) ? paperType : "");
+
+                if (examStudent != null) {
+                    for (CodeNameEnableValue extendDto : examStudent.getFieldList()) {
+                        String value = extendDto.getValue();
+                        // 考点和考场数据,用考场表中的值
+                        if (RequiredFieldsEnum.EXAM_PLACE.getCode().equals(extendDto.getCode())) {
+                            value = examDetail.getExamPlace();
+                        } else if (RequiredFieldsEnum.EXAM_ROOM.getCode().equals(extendDto.getCode())) {
+                            value = examDetail.getExamRoom();
+                        }
+                        studentHtml = studentHtml.replaceAll("\\$\\{" + extendDto.getCode() + "\\}", value);
+                    }
+                }
+            } else if (ExamNumberStyleEnum.FILL.equals(basicCardRule.getExamNumberStyle())) {
+                String fillFields = basicCardRule.getFillFields();
+                if (StringUtils.isNotBlank(fillFields)) {
+                    if (examStudent != null) {
+                        for (String s : fillFields.split(",")) {
+                            Optional<CodeNameEnableValue> extendDto = examStudent.getFieldList().stream().filter(m -> m.getCode().equals(s)).findFirst();
+                            if (extendDto.isPresent()) {
+                                CodeNameEnableValue studentExtendDto = extendDto.get();
+                                String value = String.valueOf(studentExtendDto.getValue());
+                                // 考点和考场数据,用考场表中的值
+                                if (RequiredFieldsEnum.EXAM_PLACE.getCode().equals(studentExtendDto.getCode())) {
+                                    value = examDetail.getExamPlace();
+                                } else if (RequiredFieldsEnum.EXAM_ROOM.getCode().equals(studentExtendDto.getCode())) {
+                                    value = examDetail.getExamRoom();
+                                }
+                                studentHtml = studentHtml.replaceAll("\\$\\{" + studentExtendDto.getCode() + "\\}", value);
+                            }
+                        }
                     }
                 }
             }
+        } else {
+            // 替换条码参数
+            studentHtml = studentHtml.replaceAll("<img src=\"data:image/png;base64,\\$\\{examNumber\\}\">", "");
+            studentHtml = studentHtml.replaceAll("\\$\\{examNumberStr\\}", "");
         }
 
         studentHtml = studentHtml.replaceAll("\\$\\{packageCodeDom\\}", "");
-
         // 将其它未匹配到值的参数,填入空值
         studentHtml = studentHtml.replaceAll("\\$\\{[A-Za-z0-9]+\\}", "");
-
         //学生题卡
-        BasicAttachment examStudentAttachment = printCommonService.saveAttachmentHtml(examDetail.getSchoolId() + "|" + examDetailCourse.getCourseCode() + (examStudent != null && examStudent.getTicketNumber() != null ? "|" + examStudent.getTicketNumber() : ""), studentHtml, userId, examStudentPdfList, fileTempList);
+        BasicAttachment examStudentAttachment = printCommonService.saveAttachmentPdfFromHtml(examStudent != null ? examStudent.getExamStudentId() + "|" + examStudent.getStudentCode() : SystemConstant.getNanoId(), studentHtml, userId, examStudentPdfList, fileTempList);
         if (examStudent != null) {
             examStudent.setAttachmentId(examStudentAttachment.getId());
         }
         return examStudentAttachment;
     }
 
-    /**
-     * 题卡规则字段
-     *
-     * @param examDetail
-     * @param examStudent   考生对象
-     * @param basicCardRule 题卡规则对象
-     */
-    private List<StudentExtendDto> createExtendObject(ExamDetail examDetail, ExamStudent examStudent, BasicCardRule
-            basicCardRule) {
-        ExamStudentPdfInfoDto examStudentPdfInfoDto = examStudent == null ? null : examStudentService.getByStudentId(examStudent.getId());
-        if (basicCardRule == null) {
-            return null;
-        }
-        List<JSONObject> requiredFieldsJson = JSONArray.parseArray(basicCardRule.getRequiredFields(), JSONObject.class);
-        List<StudentExtendDto> studentExtendDtos = new ArrayList<>();
-        if (requiredFieldsJson.size() > 0) {
-            for (JSONObject jsonObject : requiredFieldsJson) {
-                StudentExtendDto studentExtendDto = new StudentExtendDto();
-                String code = String.valueOf(jsonObject.get("code"));
-                studentExtendDto.setFieldName(code);
-                Object value = examStudentPdfInfoDto == null ? null : ReflectUtil.getFieldValue(examStudentPdfInfoDto, code);
-                studentExtendDto.setValue(value == null ? "" : value);
-                studentExtendDtos.add(studentExtendDto);
-            }
-        }
-        List<JSONObject> extendFieldsJson = JSONArray.parseArray(basicCardRule.getExtendFields(), JSONObject.class);
-        if (extendFieldsJson.size() > 0) {
-            Map<String, Object> studentExtendMap = null;
-            if (examStudentPdfInfoDto != null && StringUtils.isNotBlank(examStudentPdfInfoDto.getExtendFields())) {
-                studentExtendMap = JSONArray.parseArray(examStudentPdfInfoDto.getExtendFields(), JSONObject.class).stream().collect(Collectors.toMap(k -> String.valueOf(k.get("code")), v -> v.get("value")));
-            }
-
-            Map<String, Object> map = ConvertUtil.analyzeDateAndTime(examDetail.getExamStartTime(), examDetail.getExamEndTime());
-
-            for (JSONObject jsonObject : extendFieldsJson) {
-                boolean enable = Boolean.parseBoolean(jsonObject.get("enable").toString());
-                StudentExtendDto studentExtendDto = new StudentExtendDto();
-                String code = String.valueOf(jsonObject.get("code"));
-
-                studentExtendDto.setFieldName(code);
-                Object value = examStudentPdfInfoDto == null ? null : ReflectUtil.getFieldValue(examStudentPdfInfoDto, code);
-                // 时间需要特殊处理
-                if ("examDate".equals(code)) {
-                    value = Objects.nonNull(map.get("date")) ? (String) map.get("date") : "";
-                }
-                if ("examTime".equals(code)) {
-                    value = Objects.nonNull(map.get("time")) ? (String) map.get("time") : "";
-                }
-                if (value == null) {
-                    value = studentExtendMap == null ? null : studentExtendMap.get(code);
-                }
-                studentExtendDto.setValue(value == null ? "" : value);
-                studentExtendDtos.add(studentExtendDto);
-            }
-        }
-        return studentExtendDtos;
-    }
-
-    /**
-     * 题卡规则字段
-     *
-     * @param basicCardRule 题卡规则对象
-     */
-    private List<StudentExtendDto> createExtendObjectNull(BasicCardRule basicCardRule) {
-        if (basicCardRule == null) {
-            return null;
-        }
-        List<JSONObject> requiredFieldsJson = JSONArray.parseArray(basicCardRule.getRequiredFields(), JSONObject.class);
-        List<StudentExtendDto> studentExtendDtos = new ArrayList<>();
-        if (requiredFieldsJson.size() > 0) {
-            for (JSONObject jsonObject : requiredFieldsJson) {
-                StudentExtendDto studentExtendDto = new StudentExtendDto();
-                String code = String.valueOf(jsonObject.get("code"));
-                studentExtendDto.setFieldName(code);
-                studentExtendDto.setValue("");
-                studentExtendDtos.add(studentExtendDto);
-            }
-        }
-        List<JSONObject> extendFieldsJson = JSONArray.parseArray(basicCardRule.getExtendFields(), JSONObject.class);
-        if (extendFieldsJson.size() > 0) {
-            for (JSONObject jsonObject : extendFieldsJson) {
-                StudentExtendDto studentExtendDto = new StudentExtendDto();
-                String code = String.valueOf(jsonObject.get("code"));
-                studentExtendDto.setFieldName(code);
-                studentExtendDto.setValue("");
-                studentExtendDtos.add(studentExtendDto);
-            }
-        }
-        return studentExtendDtos;
-    }
-
     /**
      * 通用题卡html
      *
-     * @param sequence         序号
-     * @param cardContent      题卡内容
-     * @param examDetail       考场对象
-     * @param examDetailCourse 考场课程对象
-     * @param jsonArray        组装json返回
-     * @param userId           当前用户ID
-     * @param cardPdfList      备用题卡集合
-     * @param basicCardRule    题卡规则对象
-     * @param fileTempList
+     * @param examCard          examCard
+     * @param paperType         卷型
+     * @param basicCardRule     题卡规则
+     * @param backupPackageCode 备用题卡条码号
      */
-    public BasicAttachment cardHtml(String sequence, String cardContent, ExamDetail examDetail, ExamDetailCourse examDetailCourse, String paperType, JSONArray jsonArray, Long userId, List<PdfDto> cardPdfList, BasicCardRule basicCardRule, List<File> fileTempList) throws
-            IOException {
-        //通用题卡
-        String cardTemp = cardContent;
-        cardTemp = cardTemp.replaceAll("\\$\\{paperTypeName\\}", paperType);
-        //随机生成试卷条码并将图片转成base64
+    public String replaceBackupCardHtmlParam(ExamCard examCard, String paperType, BasicCardRule basicCardRule, String backupPackageCode) {
+        String htmlContent = examCard.getHtmlContent();
+        // 替换条码参数
+        htmlContent = htmlContent.replaceAll("<img src=\"data:image/png;base64,\\$\\{examNumber\\}\">", "");
+        htmlContent = htmlContent.replaceAll("\\$\\{examNumberStr\\}", "");
+
+        //替换卷型参数
+        htmlContent = htmlContent.replaceAll("\\$\\{paperTypeName\\}", StringUtils.isBlank(paperType) ? "" : paperType);
+        //替换卷型条码(base64)
         if (Objects.nonNull(paperType)) {
-            cardTemp = cardTemp.replaceAll("\\$\\{paperType\\}", GoogleBarCodeUtil.createBarCode(SystemConstant.convertPaperType(paperType), false));
+            htmlContent = htmlContent.replaceAll("\\$\\{paperType\\}", GoogleBarCodeUtil.createBarCode(SystemConstant.convertPaperType(paperType), false));
         }
+        // 替换考生变量参数
         if (Objects.nonNull(basicCardRule) && Objects.nonNull(basicCardRule.getExtendFields())) {
+            JSONArray jsonObjectRequired = (JSONArray) JSONArray.parse(basicCardRule.getRequiredFields());//必选字段
+            if (Objects.nonNull(jsonObjectRequired)) {
+                int i = 0;
+                while (i < jsonObjectRequired.size()) {
+                    JSONObject object = (JSONObject) jsonObjectRequired.get(i);
+                    htmlContent = htmlContent.replaceAll("\\$\\{" + object.get("code") + "\\}", "");
+                    i++;
+                }
+            }
+
             JSONArray jsonObjectExtend = (JSONArray) JSONArray.parse(basicCardRule.getExtendFields());//扩展字段
             if (Objects.nonNull(jsonObjectExtend)) {
                 int i = 0;
                 while (i < jsonObjectExtend.size()) {
                     JSONObject object = (JSONObject) jsonObjectExtend.get(i);
-                    cardTemp = cardTemp.replaceAll("\\$\\{" + object.get("code") + "\\}", "");
+                    htmlContent = htmlContent.replaceAll("\\$\\{" + object.get("code") + "\\}", "");
                     i++;
                 }
             }
         }
-        cardTemp = cardTemp.replaceAll("\\$\\{examDate\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{examTime\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{ticketNumber\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{siteNumber\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{paperTypeName\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{studentCode\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{studentName\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{courseName\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{courseCode\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{examPlace\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{examRoom\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{paperNumber\\}", "");
 
-        //通用题卡生成卷袋贴条码
-        String packageCode = examDetail.getPackageCode() + sequence;
-        String packageCodeImg = GoogleBarCodeUtil.createBarCode(packageCode, false);
-        cardTemp = cardTemp.replaceAll("\\$\\{packageCodeDom\\}", "<img src='" + "data:image/png;base64," + packageCodeImg + "'><p>" + packageCode + "</p>");
-//        cardTemp = cardTemp.replaceAll("\\$\\{packageCode\\}", packageCode);
-        // 上传通卡
-//        if (cardTemp.contains("<div class=\"page-box page-box-0\">")) {
-//            String packageCodeDiv = "<div class=\"page-box page-box-0\"><div class=\"package-number\" style=\"position: absolute;width: 200px;height: 40px;top: 10px;right: 25%;margin-left: -100px;text-align: center;z-index: 99;\"><img src=\"data:image/png;base64," + packageCodeImg + "\" style=\"display: block; height: 28px; width: 100%\" /><p style=\"line-height: 1; font-size: 12px; margin: 0;\">" + packageCode + "</p></div>";
-//            cardTemp = cardTemp.replaceAll("<div class=\"page-box page-box-0\">", packageCodeDiv);
-//        } else if (cardTemp.contains("<div class=\"page-box page-box-A3 page-box-0\">")) {
-//            String packageCodeDiv = "<div class=\"page-box page-box-A3 page-box-0\"><div class=\"package-number\" style=\"position: absolute;width: 200px;height: 40px;top: 10px;right: 25%;margin-left: -100px;text-align: center;z-index: 99;\"><img src=\"data:image/png;base64," + packageCodeImg + "\" style=\"display: block; height: 28px; width: 100%\" /><p style=\"line-height: 1; font-size: 12px; margin: 0;\">" + packageCode + "</p></div>";
-//            cardTemp = cardTemp.replaceAll("<div class=\"page-box page-box-A3 page-box-0\">", packageCodeDiv);
-//        } else if (cardTemp.contains("<div class=\"page-box page-box-A3 page-box-0 page-box-less\">")) {
-//            String packageCodeDiv = "<div class=\"page-box page-box-A3 page-box-0 page-box-less\"><div class=\"package-number\" style=\"position: absolute;width: 200px;height: 40px;top: 10px;right: 25%;margin-left: -100px;text-align: center;z-index: 99;\"><img src=\"data:image/png;base64," + packageCodeImg + "\" style=\"display: block; height: 28px; width: 100%\" /><p style=\"line-height: 1; font-size: 12px; margin: 0;\">" + packageCode + "</p></div>";
-//            cardTemp = cardTemp.replaceAll("<div class=\"page-box page-box-A3 page-box-0 page-box-less\">", packageCodeDiv);
-//        } else if (cardTemp.contains("<div class=\"page-box page-box-A4 page-box-0\">")) {
-//            String packageCodeDiv = "<div class=\"page-box page-box-A4 page-box-0\"><div class=\"package-number\" style=\"position: absolute;width: 200px;height: 40px;top: 10px;right: 25%;margin-left: -100px;text-align: center;z-index: 99;\"><img src=\"data:image/png;base64," + packageCodeImg + "\" style=\"display: block; height: 28px; width: 100%\" /><p style=\"line-height: 1; font-size: 12px; margin: 0;\">" + packageCode + "</p></div>";
-//            cardTemp = cardTemp.replaceAll("<div class=\"page-box page-box-A4 page-box-0\">", packageCodeDiv);
-//        } else if (cardTemp.contains("<div class=\"page-box page-box-A4 page-box-0 page-box-less\">")) {
-//            String packageCodeDiv = "<div class=\"page-box page-box-A4 page-box-0 page-box-less\"><div class=\"package-number\" style=\"position: absolute;width: 200px;height: 40px;top: 10px;right: 25%;margin-left: -100px;text-align: center;z-index: 99;\"><img src=\"data:image/png;base64," + packageCodeImg + "\" style=\"display: block; height: 28px; width: 100%\" /><p style=\"line-height: 1; font-size: 12px; margin: 0;\">" + packageCode + "</p></div>";
-//            cardTemp = cardTemp.replaceAll("<div class=\"page-box page-box-A4 page-box-0 page-box-less\">", packageCodeDiv);
-//        }
+        if (StringUtils.isNotBlank(backupPackageCode)) {
+            //通用题卡生成卷袋贴条码
+            String packageCodeImg = GoogleBarCodeUtil.createBarCode(backupPackageCode, false);
+            // 上传通卡
+            if (CardCreateMethodEnum.UPLOAD.equals(examCard.getCreateMethod())) {
+                if (htmlContent.contains("<div class=\"page-box page-box-0\">")) {
+                    String packageCodeDiv = "<div class=\"page-box page-box-0\"><div class=\"package-number\" style=\"position: absolute;width: 200px;height: 40px;top: 10px;right: 25%;margin-left: -100px;text-align: center;z-index: 99;\"><img src=\"data:image/png;base64," + packageCodeImg + "\" style=\"display: block; height: 28px; width: 100%\" /><p style=\"line-height: 1; font-size: 12px; margin: 0;\">" + backupPackageCode + "</p></div>";
+                    htmlContent = htmlContent.replaceAll("<div class=\"page-box page-box-0\">", packageCodeDiv);
+                } else if (htmlContent.contains("<div class=\"page-box page-box-A3 page-box-0\">")) {
+                    String packageCodeDiv = "<div class=\"page-box page-box-A3 page-box-0\"><div class=\"package-number\" style=\"position: absolute;width: 200px;height: 40px;top: 10px;right: 25%;margin-left: -100px;text-align: center;z-index: 99;\"><img src=\"data:image/png;base64," + packageCodeImg + "\" style=\"display: block; height: 28px; width: 100%\" /><p style=\"line-height: 1; font-size: 12px; margin: 0;\">" + backupPackageCode + "</p></div>";
+                    htmlContent = htmlContent.replaceAll("<div class=\"page-box page-box-A3 page-box-0\">", packageCodeDiv);
+                } else if (htmlContent.contains("<div class=\"page-box page-box-A3 page-box-0 page-box-less\">")) {
+                    String packageCodeDiv = "<div class=\"page-box page-box-A3 page-box-0 page-box-less\"><div class=\"package-number\" style=\"position: absolute;width: 200px;height: 40px;top: 10px;right: 25%;margin-left: -100px;text-align: center;z-index: 99;\"><img src=\"data:image/png;base64," + packageCodeImg + "\" style=\"display: block; height: 28px; width: 100%\" /><p style=\"line-height: 1; font-size: 12px; margin: 0;\">" + backupPackageCode + "</p></div>";
+                    htmlContent = htmlContent.replaceAll("<div class=\"page-box page-box-A3 page-box-0 page-box-less\">", packageCodeDiv);
+                } else if (htmlContent.contains("<div class=\"page-box page-box-A4 page-box-0\">")) {
+                    String packageCodeDiv = "<div class=\"page-box page-box-A4 page-box-0\"><div class=\"package-number\" style=\"position: absolute;width: 200px;height: 40px;top: 10px;right: 25%;margin-left: -100px;text-align: center;z-index: 99;\"><img src=\"data:image/png;base64," + packageCodeImg + "\" style=\"display: block; height: 28px; width: 100%\" /><p style=\"line-height: 1; font-size: 12px; margin: 0;\">" + backupPackageCode + "</p></div>";
+                    htmlContent = htmlContent.replaceAll("<div class=\"page-box page-box-A4 page-box-0\">", packageCodeDiv);
+                } else if (htmlContent.contains("<div class=\"page-box page-box-A4 page-box-0 page-box-less\">")) {
+                    String packageCodeDiv = "<div class=\"page-box page-box-A4 page-box-0 page-box-less\"><div class=\"package-number\" style=\"position: absolute;width: 200px;height: 40px;top: 10px;right: 25%;margin-left: -100px;text-align: center;z-index: 99;\"><img src=\"data:image/png;base64," + packageCodeImg + "\" style=\"display: block; height: 28px; width: 100%\" /><p style=\"line-height: 1; font-size: 12px; margin: 0;\">" + backupPackageCode + "</p></div>";
+                    htmlContent = htmlContent.replaceAll("<div class=\"page-box page-box-A4 page-box-0 page-box-less\">", packageCodeDiv);
+                } else if (htmlContent.contains("<div id=\"preview-page-box-0\" class=\"page-box page-box-A3 page-box-0 page-box-less\">")) {
+                    String packageCodeDiv = "<div id=\"preview-page-box-0\" class=\"page-box page-box-A3 page-box-0 page-box-less\"><div class=\"package-number\" style=\"position: absolute;width: 200px;height: 40px;top: 10px;right: 25%;margin-left: -100px;text-align: center;z-index: 99;\"><img src=\"data:image/png;base64," + packageCodeImg + "\" style=\"display: block; height: 28px; width: 100%\" /><p style=\"line-height: 1; font-size: 12px; margin: 0;\">" + backupPackageCode + "</p></div>";
+                    htmlContent = htmlContent.replaceAll("<div id=\"preview-page-box-0\" class=\"page-box page-box-A3 page-box-0 page-box-less\">", packageCodeDiv);
+                }
+            } else {
+                htmlContent = htmlContent.replaceAll("\\$\\{packageCodeDom\\}", "<img src='" + "data:image/png;base64," + packageCodeImg + "'><p>" + backupPackageCode + "</p>");
+            }
+        } else {
+            htmlContent = htmlContent.replaceAll("\\$\\{packageCodeDom\\}", "");
+        }
+        return htmlContent;
+    }
+
+    public String getPaperType(Long printPlanId, Long examId, String paperNumber) {
+        ExamPrintPlan examPrintPlan = examPrintPlanService.getById(printPlanId);
+        //抽取卷型
+        DrawRuleEnum drawRule = Objects.nonNull(examPrintPlan.getDrawRule()) ? examPrintPlan.getDrawRule() : DrawRuleEnum.ONE;
+        ExamTaskDetail examTaskDetail = examTaskDetailService.getByExamIdAndCourseCodeAndPaperNumber(examId, null, paperNumber);
+        // 单次抽取套数
+        int drawCount = examTaskDetail.getDrawCount().intValue();
 
-        BasicAttachment cardAttachment = printCommonService.saveAttachmentHtml(examDetail.getSchoolId() + "|" + examDetailCourse.getCourseCode(), cardTemp, userId, cardPdfList, fileTempList);
-        JSONObject object = new JSONObject();
-        object.put("name", paperType);
-        object.put("examDetailCourseId", examDetailCourse.getId());
-        object.put("attachmentId", cardAttachment.getId());
-        object.put("packageCode", packageCode);
-        jsonArray.add(object);
-        return cardAttachment;
+        String paperType = null;
+        try {
+            //未曝光卷型
+            String unexposedPaperType = examTaskDetail.getUnexposedPaperType();
+            //已曝光卷型
+            String exposedPaperType = examTaskDetail.getExposedPaperType();
+            String totalPaperType = examTaskDetail.getPaperType();
+            String[] paperTypes;
+            if (drawRule == DrawRuleEnum.ONE) {
+                if (StringUtils.isBlank(unexposedPaperType)) {
+                    throw ExceptionResultEnum.PAPER_ERROR.exception();
+                }
+                paperTypes = unexposedPaperType.split(",");
+                if (paperTypes.length - drawCount < 0) {
+                    throw ExceptionResultEnum.ERROR.exception("可用卷型数量小于抽取数量");
+                }
+            } else {
+                if (StringUtils.isAllBlank(totalPaperType, unexposedPaperType)) {
+                    throw ExceptionResultEnum.PAPER_ERROR.exception();
+                }
+                if (StringUtils.isNotBlank(unexposedPaperType)) {
+                    paperTypes = unexposedPaperType.split(",");
+                    // 未曝光卷型小于抽取数量,则使用所有卷型
+                    if (paperTypes.length - drawCount < 0) {
+                        paperTypes = totalPaperType.split(",");
+                    }
+                } else {
+                    paperTypes = totalPaperType.split(",");
+                }
+            }
+            paperType = randomPaperType(paperTypes, drawCount);
+        } catch (Exception e) {
+            log.error(SystemConstant.LOG_ERROR, e);
+        }
+        return paperType;
     }
+
 }

+ 12 - 147
distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/CreatePrintPdfUtil.java

@@ -1,14 +1,13 @@
 package com.qmth.distributed.print.business.util;
 
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.itextpdf.text.*;
 import com.itextpdf.text.pdf.*;
 import com.qmth.distributed.print.business.bean.dto.PdfPackageDto;
 import com.qmth.distributed.print.business.bean.dto.PdfSignDto;
-import com.qmth.distributed.print.business.bean.examRule.CodeNameEnableRate;
+import com.qmth.teachcloud.common.bean.examRule.CodeNameEnableRate;
 import com.qmth.distributed.print.business.entity.BasicTemplate;
-import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
+import com.qmth.teachcloud.common.bean.examRule.CodeNameEnableValue;
 import com.qmth.teachcloud.common.enums.FontSizeEnum;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
@@ -125,19 +124,13 @@ public class CreatePrintPdfUtil {
 
         // 空格
         Paragraph blank = new Paragraph(" ");
-        // 标题table
-//        PdfPTable titleTable = PdfFillUtils.createTable(new float[]{100});
-//        titleTable.addCell(PdfFillUtils.createCell(pdfFillDto.getTitle(), PdfFillUtils.textFont16, null, Element.ALIGN_CENTER, 15, 3, 1));
-//        titleTable.getDefaultCell().setFixedHeight(50f);
-//        document.add(titleTable);
-
 
         // 基础信息表格
         PdfPTable basicTable = PdfFillUtils.createTable(6);
         basicTable.addCell(PdfFillUtils.createTitleCell(pdfFillDto.getTitle(), PdfFillUtils.textFont16, 60f, 15, 1, 6));
-        List<Map<String, String>> basicPlate = pdfFillDto.getBasicPlate();
-        for (Map<String, String> stringMap : basicPlate) {
-            basicTable.addCell(PdfFillUtils.createCell(stringMap.get("name") + ":" + stringMap.get("value"), PdfFillUtils.textFont10, null, Element.ALIGN_LEFT, 0, 1, 3));
+        List<CodeNameEnableValue> basicPlate = pdfFillDto.getBasicPlate();
+        for (CodeNameEnableValue codeNameEnableValue : basicPlate) {
+            basicTable.addCell(PdfFillUtils.createCell(codeNameEnableValue.getName() + ":" + codeNameEnableValue.getValue(), PdfFillUtils.textFont10, null, Element.ALIGN_LEFT, 0, 1, 3));
         }
         if (basicPlate.size() % 2 > 0) {
             basicTable.addCell(PdfFillUtils.createCell(" ", PdfFillUtils.textFont10, null, Element.ALIGN_LEFT, 0, 1, 3));
@@ -307,9 +300,9 @@ public class CreatePrintPdfUtil {
 
             titleTable.addCell(PdfFillUtils.createCell(pdfPackageDto.getTitle(), PdfFillUtils.textFont22, null, Element.ALIGN_CENTER, 15, 1, 2));
 
-            List<Map<String, String>> titlePlate = pdfPackageDto.getTitlePlate();
-            for (Map<String, String> stringMap : titlePlate) {
-                String value = stringMap.get("value");
+            List<CodeNameEnableValue> titlePlate = pdfPackageDto.getTitlePlate();
+            for (CodeNameEnableValue stringMap : titlePlate) {
+                String value = stringMap.getValue();
                 if (StringUtils.isNotBlank(value)) {
                     titleTable.addCell(PdfFillUtils.createCell(value, PdfFillUtils.textFont16, null, Element.ALIGN_CENTER, 15, 1, 2));
                 }
@@ -321,12 +314,12 @@ public class CreatePrintPdfUtil {
 
             // 基础信息表格
             PdfPTable basicTable = PdfFillUtils.createTable(new float[]{1, 23, 3, 73});
-            List<Map<String, String>> basicPlate = pdfPackageDto.getBasicPlate();
-            for (Map<String, String> stringMap : basicPlate) {
+            List<CodeNameEnableValue> basicPlate = pdfPackageDto.getBasicPlate();
+            for (CodeNameEnableValue stringMap : basicPlate) {
                 basicTable.addCell(PdfFillUtils.createCell("", PdfFillUtils.textFont14, 50f, Element.ALIGN_JUSTIFIED_ALL, 0f));
-                basicTable.addCell(PdfFillUtils.createCell(stringMap.get("name"), PdfFillUtils.textFont14, 50f, Element.ALIGN_RIGHT, 0f));
+                basicTable.addCell(PdfFillUtils.createCell(stringMap.getName(), PdfFillUtils.textFont14, 50f, Element.ALIGN_RIGHT, 0f));
                 basicTable.addCell(PdfFillUtils.createCell(": ", PdfFillUtils.textFont14, 50f, Element.ALIGN_JUSTIFIED_ALL, 0f));
-                basicTable.addCell(PdfFillUtils.createCell(stringMap.get("value"), PdfFillUtils.textFont14, 50f, Element.ALIGN_LEFT, 0f));
+                basicTable.addCell(PdfFillUtils.createCell(stringMap.getValue(), PdfFillUtils.textFont14, 50f, Element.ALIGN_LEFT, 0f));
             }
             document.add(basicTable);
             document.add(blank);
@@ -490,132 +483,4 @@ public class CreatePrintPdfUtil {
             ColumnText.showTextAligned(totalPage, Element.ALIGN_LEFT, new Paragraph(text, PdfFillUtils.textFont8), 2, 6, 0);
         }
     }
-
-
-    /**
-     * 测试方法
-     *
-     * @param args
-     */
-    public static void main(String[] args) {
-        PdfSignDto pdfFillDto = new PdfSignDto();
-        pdfFillDto.setTitle("测试签到表");
-        pdfFillDto.setPackageNumber("1000004");
-
-        // 基础信息
-        List<Map<String, String>> basicPlate = new ArrayList<>();
-        Map<String, String> basicMap = new HashMap<>();
-        basicMap.put("code", "courseCode");
-        basicMap.put("name", "课程代码");
-        basicMap.put("value", "高等数学");
-        basicPlate.add(basicMap);
-
-        basicMap = new HashMap<>();
-        basicMap.put("code", "paperNumber");
-        basicMap.put("name", "试卷编号");
-        basicMap.put("value", "bh001");
-        basicPlate.add(basicMap);
-
-        basicMap = new HashMap<>();
-        basicMap.put("code", "examTime");
-        basicMap.put("name", "考试时间");
-        basicMap.put("value", "2022-09-10 9:00-12:00");
-        basicPlate.add(basicMap);
-
-        basicMap = new HashMap<>();
-        basicMap.put("code", "examRoom");
-        basicMap.put("name", "考试地点");
-        basicMap.put("value", "教学楼301");
-        basicPlate.add(basicMap);
-
-        basicMap = new HashMap<>();
-        basicMap.put("code", "examCount");
-        basicMap.put("name", "应考人数");
-        basicMap.put("value", "61");
-        basicPlate.add(basicMap);
-
-        basicMap = new HashMap<>();
-        basicMap.put("code", "actualExamCount");
-        basicMap.put("name", "实考人数");
-        basicMap.put("value", "");
-        basicPlate.add(basicMap);
-
-        pdfFillDto.setBasicPlate(basicPlate);
-
-        // 表头信息
-        Map<String, String> studentHeadPlateMap = new LinkedHashMap<>();
-        studentHeadPlateMap.put("seq", "序号");
-        studentHeadPlateMap.put("studentCode", "学号");
-        studentHeadPlateMap.put("studentName", "姓名");
-        studentHeadPlateMap.put("className", "班级");
-        studentHeadPlateMap.put("studentSign", "签名");
-        pdfFillDto.setStudentHeadPlate(studentHeadPlateMap);
-
-        // 考生信息
-        List<Map<String, String>> studentPlate = new ArrayList<>();
-        for (int i = 0; i < 150; i++) {
-            Map<String, String> studentMap = new HashMap<>();
-            String seq = String.valueOf(i + 1);
-            studentMap.put("seq", seq);
-            studentMap.put("studentCode", "20010" + String.format("%03d", i + 1));
-            if (i > 10 && i < 20) {
-                studentMap.put("studentName", "学生" + String.format("%06d", i + 1));
-            } else if (i > 34 && i < 50) {
-                studentMap.put("studentName", "学生" + String.format("%010d", i + 1));
-            } else {
-                studentMap.put("studentName", "学生" + seq);
-            }
-            studentMap.put("className", "班级1");
-            studentMap.put("studentSign", "");
-            studentPlate.add(studentMap);
-        }
-        pdfFillDto.setStudentPlate(studentPlate);
-
-        PdfPackageDto pdfPackageDto = new PdfPackageDto();
-        pdfPackageDto.setTitle("测试卷袋贴");
-        pdfPackageDto.setPackageNumber("1000004");
-
-        // 基础信息
-        List<Map<String, String>> basicPlate1 = new ArrayList<>();
-        Map<String, String> basicMap1 = new HashMap<>();
-        basicMap1.put("code", "courseCode");
-        basicMap1.put("name", "课程代码");
-        basicMap1.put("value", "高等数学");
-        basicPlate1.add(basicMap1);
-
-        basicMap1 = new HashMap<>();
-        basicMap1.put("code", "paperNumber");
-        basicMap1.put("name", "试卷编号");
-        basicMap1.put("value", "bh001");
-        basicPlate1.add(basicMap1);
-
-        basicMap1 = new HashMap<>();
-        basicMap1.put("code", "examTime");
-        basicMap1.put("name", "考试时间");
-        basicMap1.put("value", "2022-09-10 9:00-12:00");
-        basicPlate1.add(basicMap1);
-
-        basicMap1 = new HashMap<>();
-        basicMap1.put("code", "examRoom");
-        basicMap1.put("name", "考试地点");
-        basicMap1.put("value", "教学楼301");
-        basicPlate1.add(basicMap1);
-
-        basicMap1 = new HashMap<>();
-        basicMap1.put("code", "examCount");
-        basicMap1.put("name", "应考人数");
-        basicMap1.put("value", "61");
-        basicPlate1.add(basicMap1);
-
-        pdfPackageDto.setBasicPlate(basicPlate1);
-
-        try {
-            CreatePrintPdfUtil createPrintPdfUtil = new CreatePrintPdfUtil();
-            createPrintPdfUtil.createSignPdf(pdfFillDto, "/Users/xiaofei/sign.pdf", null);
-//            createPrintPdfUtil.createPackagePdf(pdfPackageDto, "D:/package.pdf");
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
 }

+ 66 - 134
distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/PdfFillUtils.java

@@ -1,5 +1,6 @@
 package com.qmth.distributed.print.business.util;
 
+import cn.hutool.core.date.DateUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.itextpdf.awt.AsianFontMapper;
@@ -8,9 +9,14 @@ import com.itextpdf.text.pdf.*;
 import com.qmth.distributed.print.business.bean.dto.PdfPackageDto;
 import com.qmth.distributed.print.business.bean.dto.PdfSignDto;
 import com.qmth.distributed.print.business.entity.BasicTemplate;
+import com.qmth.distributed.print.business.enums.RequiredFieldsEnum;
 import com.qmth.distributed.print.business.service.PrintCommonService;
+import com.qmth.teachcloud.common.bean.examRule.CodeNameEnable;
+import com.qmth.teachcloud.common.bean.examRule.CodeNameEnableValue;
 import com.qmth.teachcloud.common.contant.SpringContextHolder;
+import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.enums.ClassifyEnum;
+import org.apache.commons.collections4.CollectionUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -75,103 +81,69 @@ public class PdfFillUtils {
 
         JSONObject jsonObject = JSON.parseObject(basicTemplate.getDisplayRange());
         // 基础信息
-        List<Map<String, String>> basicPlate = new ArrayList<>();
+        List<CodeNameEnableValue> basicPlate = new ArrayList<>();
         String basicData = jsonObject.getString("basic");
-        List<JSONObject> basicObjectList = JSON.parseArray(basicData, JSONObject.class).stream().filter(m -> m.getBoolean("enable")).collect(Collectors.toList());
+        List<CodeNameEnable> basicObjectList = JSON.parseArray(basicData, CodeNameEnable.class).stream().filter(m -> m.getEnable()).collect(Collectors.toList());
 
-        boolean isCourseHasTwo = basicObjectList.stream().filter(m -> "courseCode".equals(m.getString("code")) || "courseName".equals(m.getString("code"))).count() == 2;
-        boolean isDateHasTwo = basicObjectList.stream().filter(m -> "examDate".equals(m.getString("code")) || "examTime".equals(m.getString("code"))).count() == 2;
-        boolean isPlaceHasTwo = basicObjectList.stream().filter(m -> "examPlace".equals(m.getString("code")) || "examRoom".equals(m.getString("code"))).count() == 2;
+        boolean isCourseHasTwo = basicObjectList.stream().filter(m -> RequiredFieldsEnum.COURSE_CODE.getCode().equals(m.getCode()) || RequiredFieldsEnum.COURSE_NAME.getCode().equals(m.getCode())).count() == 2;
+        boolean isDateHasTwo = basicObjectList.stream().filter(m -> RequiredFieldsEnum.EXAM_DATE.getCode().equals(m.getCode()) || RequiredFieldsEnum.EXAM_TIME.getCode().equals(m.getCode())).count() == 2;
+        boolean isPlaceHasTwo = basicObjectList.stream().filter(m -> RequiredFieldsEnum.EXAM_PLACE.getCode().equals(m.getCode()) || RequiredFieldsEnum.EXAM_ROOM.getCode().equals(m.getCode())).count() == 2;
 
 
         boolean isCourseFill = false;
         boolean isDateFill = false;
         boolean isPlaceFill = false;
 
-        Map<String, String> basicMap;
-        for (JSONObject object : basicObjectList) {
-            String code = object.getString("code");
-            String name = object.getString("name");
+        CodeNameEnableValue basicvalue;
+        for (CodeNameEnable object : basicObjectList) {
+            String code = object.getCode();
+            String name = object.getName();
 
-            if ("courseCode".equals(code) || "courseName".equals(code)) {
-                basicMap = new HashMap<>();
+            if (RequiredFieldsEnum.COURSE_CODE.getCode().equals(code) || RequiredFieldsEnum.COURSE_NAME.getCode().equals(code)) {
                 if (isCourseHasTwo) {
                     if (isCourseFill) {
                         continue;
                     }
-                    basicMap.put("code", "courseName");
-                    basicMap.put("name", "课程名称");
-                    basicMap.put("value", "xxx(xxx)");
+                    basicvalue = new CodeNameEnableValue(RequiredFieldsEnum.COURSE_NAME.getCode(), RequiredFieldsEnum.COURSE_NAME.getName(), true, "xxx(xxx)");
                     isCourseFill = true;
                 } else {
-                    basicMap.put("code", code);
-                    basicMap.put("name", name);
-                    basicMap.put("value", "xxx");
+                    basicvalue = new CodeNameEnableValue(code, name, true, "xxx");
                 }
-                basicPlate.add(basicMap);
-            } else if ("examDate".equals(code) || "examTime".equals(code)) {
-                basicMap = new HashMap<>();
+            } else if (RequiredFieldsEnum.EXAM_DATE.getCode().equals(code) || RequiredFieldsEnum.EXAM_TIME.getCode().equals(code)) {
                 if (isDateHasTwo) {
                     if (isDateFill) {
                         continue;
                     }
-                    String examTime;
-                    basicMap.put("code", "examTime");
-                    basicMap.put("name", "考试时间");
-                    basicMap.put("value", "xxxx-xx-xx xx:xx-xx:xx");
+                    basicvalue = new CodeNameEnableValue(RequiredFieldsEnum.EXAM_TIME.getCode(), RequiredFieldsEnum.EXAM_TIME.getName(), true, "xxxx-xx-xx xx:xx-xx:xx");
                     isDateFill = true;
                 } else {
-                    String examTime = "";
-                    if ("examDate".equals(code)) {
-                        examTime = "xxxx-xx-xx";
-                    } else if ("examTime".equals(code)) {
-                        examTime = "xx:xx-xx:xx";
-                    }
-                    basicMap.put("code", code);
-                    basicMap.put("name", name);
-                    basicMap.put("value", examTime);
+                    basicvalue = new CodeNameEnableValue(code, name, true, "xxxx");
                 }
-                basicPlate.add(basicMap);
-            } else if ("examPlace".equals(code) || "examRoom".equals(code)) {
-                basicMap = new HashMap<>();
+
+            } else if (RequiredFieldsEnum.EXAM_PLACE.getCode().equals(code) || RequiredFieldsEnum.EXAM_ROOM.getCode().equals(code)) {
                 if (isPlaceHasTwo) {
                     if (isPlaceFill) {
                         continue;
                     }
-                    basicMap.put("code", "examRoom");
-                    basicMap.put("name", "考试地点");
-                    basicMap.put("value", "xx地点 xx教室");
+                    basicvalue = new CodeNameEnableValue(RequiredFieldsEnum.EXAM_ROOM.getCode(), RequiredFieldsEnum.EXAM_ROOM.getName(), true, "xx地点 xx教室");
                     isPlaceFill = true;
                 } else {
-                    String string = null;
-                    if ("examPlace".equals(code)) {
-                        string = "xx地点";
-                    }
-                    if ("examRoom".equals(code)) {
-                        string = "xx教室";
-                    }
-                    basicMap.put("code", code);
-                    basicMap.put("name", name);
-                    basicMap.put("value", string);
+                    basicvalue = new CodeNameEnableValue(code, name, true, "xxx");
                 }
-                basicPlate.add(basicMap);
             } else {
-                basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", "xxx");
-                basicPlate.add(basicMap);
+                basicvalue = new CodeNameEnableValue(code, name, true, "xxx");
             }
+            basicPlate.add(basicvalue);
         }
 
         pdfFillDto.setBasicPlate(basicPlate);
 
         // 表头信息
         String studentData = jsonObject.getString("table");
-        List<JSONObject> studentObjectList = JSON.parseArray(studentData, JSONObject.class).stream().filter(m -> m.getBoolean("enable")).collect(Collectors.toList());
+        List<CodeNameEnable> studentObjectList = JSON.parseArray(studentData, CodeNameEnable.class).stream().filter(m -> m.getEnable()).collect(Collectors.toList());
         Map<String, String> studentHeadPlateMap = new LinkedHashMap<>();
-        for (JSONObject object : studentObjectList) {
-            studentHeadPlateMap.put(object.getString("code"), object.getString("name"));
+        for (CodeNameEnable object : studentObjectList) {
+            studentHeadPlateMap.put(object.getCode(), object.getName());
         }
         studentHeadPlateMap.put("studentSign", "签名");
         pdfFillDto.setStudentHeadPlate(studentHeadPlateMap);
@@ -180,10 +152,12 @@ public class PdfFillUtils {
         // 考生信息
         List<Map<String, String>> studentPlate = new ArrayList<>();
         int studentCount = basicTemplate.getDiallel() == null || basicTemplate.getDiallel() ? 80 : 40;
-        for (int i = 0; i < studentCount; i++) {
+        for (
+                int i = 0;
+                i < studentCount; i++) {
             Map<String, String> studentMap = new HashMap<>();
-            for (JSONObject object : studentObjectList) {
-                studentMap.put(object.getString("code"), "xxx");
+            for (CodeNameEnable object : studentObjectList) {
+                studentMap.put(object.getCode(), "xxx");
             }
             studentMap.put("studentSign", "");
             studentPlate.add(studentMap);
@@ -213,98 +187,56 @@ public class PdfFillUtils {
         pdfPackageDto.setPackageNumber("123456789");
 
         JSONObject objectList = JSON.parseObject(data);
-        List<JSONObject> titleObjectList = JSON.parseArray(objectList.getString("title"), JSONObject.class);
-        List<Map<String, String>> titlePlate = new ArrayList<>();
-        for (JSONObject object : titleObjectList) {
-            if (object.getBoolean("enable")) {
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", object.getString("code"));
-                basicMap.put("name", object.getString("name"));
-                basicMap.put("value", "xxx-xxx学期 课程考试");
-                titlePlate.add(basicMap);
+        List<CodeNameEnable> titleObjectList = JSON.parseArray(objectList.getString("title"), CodeNameEnable.class);
+        List<CodeNameEnableValue> titlePlate = new ArrayList<>();
+        for (CodeNameEnable object : titleObjectList) {
+            if (object.getEnable()) {
+                titlePlate.add(new CodeNameEnableValue(object.getCode(), object.getName(), true, "xxx-xxx学期 课程考试"));
             }
         }
         pdfPackageDto.setTitlePlate(titlePlate);
         // 基础信息
-        List<JSONObject> basicObjectList = JSON.parseArray(objectList.getString("basic"), JSONObject.class).stream().filter(m -> m.getBoolean("enable")).collect(Collectors.toList());
-        boolean isCourseHasTwo = basicObjectList.stream().filter(m -> "courseCode".equals(m.getString("code")) || "courseName".equals(m.getString("code"))).count() == 2;
-        boolean isDateHasTwo = basicObjectList.stream().filter(m -> "examDate".equals(m.getString("code")) || "examTime".equals(m.getString("code"))).count() == 2;
+        List<CodeNameEnable> basicObjectList = JSON.parseArray(objectList.getString("basic"), CodeNameEnable.class).stream().filter(m -> m.getEnable()).collect(Collectors.toList());
+        boolean isCourseHasTwo = basicObjectList.stream().filter(m -> RequiredFieldsEnum.COURSE_CODE.getCode().equals(m.getCode()) || RequiredFieldsEnum.COURSE_NAME.getCode().equals(m.getCode())).count() == 2;
+        boolean isDateHasTwo = basicObjectList.stream().filter(m -> RequiredFieldsEnum.EXAM_DATE.getCode().equals(m.getCode()) || RequiredFieldsEnum.EXAM_TIME.getCode().equals(m.getCode())).count() == 2;
         boolean isCourseFill = false;
         boolean isDateFill = false;
 
-        List<Map<String, String>> basicPlate = new ArrayList<>();
-        for (JSONObject object : basicObjectList) {
-            String code = object.getString("code");
-            String name = object.getString("name");
-            if ("examDate".equals(code) || "examTime".equals(code)) {
-                Map<String, String> basicMap = new HashMap<>();
-                if (isDateHasTwo) {
-                    if (isDateFill) {
+
+        List<CodeNameEnableValue> basicPlate = new ArrayList<>();
+        CodeNameEnableValue basicValue;
+        for (CodeNameEnable object : basicObjectList) {
+            String code = object.getCode();
+            String name = object.getName();
+
+            if (RequiredFieldsEnum.COURSE_CODE.getCode().equals(code) || RequiredFieldsEnum.COURSE_NAME.getCode().equals(code)) {
+                if (isCourseHasTwo) {
+                    if (isCourseFill) {
                         continue;
                     }
-                    basicMap.put("code", "examTime");
-                    basicMap.put("name", "考试时间");
-                    basicMap.put("value", "xxxx-xx-xx xx:xx-xx:xx");
-                    isDateFill = true;
+                    basicValue = new CodeNameEnableValue(RequiredFieldsEnum.COURSE_NAME.getCode(), RequiredFieldsEnum.COURSE_NAME.getName(), true, "xxx(xxx)");
+                    isCourseFill = true;
                 } else {
-                    String examTime = "";
-                    if ("examDate".equals(code)) {
-                        examTime = "xxxx-xx-xx";
-                    } else if ("examTime".equals(code)) {
-                        examTime = "xx:xx-xx:xx";
-                    }
-                    basicMap.put("code", code);
-                    basicMap.put("name", name);
-                    basicMap.put("value", examTime);
+                    basicValue = new CodeNameEnableValue(code, name, true, "xxx");
                 }
-                basicPlate.add(basicMap);
-            } else if ("courseCode".equals(code) || "courseName".equals(code)) {
-                Map<String, String> basicMap = new HashMap<>();
-                if (isCourseHasTwo) {
-                    if (isCourseFill) {
+            } else if (RequiredFieldsEnum.EXAM_DATE.getCode().equals(code) || RequiredFieldsEnum.EXAM_TIME.getCode().equals(code)) {
+                if (isDateHasTwo) {
+                    if (isDateFill) {
                         continue;
                     }
-                    basicMap.put("code", "courseName");
-                    basicMap.put("name", "课程名称");
-                    basicMap.put("value", "xxx(xxx)");
-                    isCourseFill = true;
+                    basicValue = new CodeNameEnableValue(RequiredFieldsEnum.EXAM_TIME.getCode(), RequiredFieldsEnum.EXAM_TIME.getName(), true, "xxxx-xx-xx xx:xx-xx:xx");
+                    isDateFill = true;
                 } else {
-                    basicMap.put("code", code);
-                    basicMap.put("name", name);
-                    basicMap.put("value", "xxx");
+                    basicValue = new CodeNameEnableValue(code, name, true, "xxxx");
                 }
-                basicPlate.add(basicMap);
-            } else if ("examPlace".equals(code) || "campusName".equals(code)) {
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", "xxx");
-                basicPlate.add(basicMap);
-            } else if ("examRoom".equals(code) || "examClassroomName".equals(code)) {
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", "xxx");
-                basicPlate.add(basicMap);
             } else if ("examCount".equals(code)) {
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", "xxx + x");
-                basicPlate.add(basicMap);
+                basicValue = new CodeNameEnableValue(code, name, true, "xxx + x");
             } else if ("actualExamCount".equals(code)) {
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", "");
-                basicPlate.add(basicMap);
+                basicValue = new CodeNameEnableValue(code, name, true, "");
             } else {
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", "xxx");
-                basicPlate.add(basicMap);
+                basicValue = new CodeNameEnableValue(code, name, true, "xxx");
             }
+            basicPlate.add(basicValue);
         }
         pdfPackageDto.setBasicPlate(basicPlate);
 

+ 0 - 1146
distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/pdf/CreatePdfNewUtil.java

@@ -1,1146 +0,0 @@
-package com.qmth.distributed.print.business.util.pdf;
-
-import cn.hutool.core.date.DateUtil;
-import cn.hutool.core.util.ReflectUtil;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.itextpdf.text.pdf.PdfReader;
-import com.qmth.distributed.print.business.bean.dto.*;
-import com.qmth.distributed.print.business.entity.*;
-import com.qmth.distributed.print.business.enums.ExamDetailStatusEnum;
-import com.qmth.distributed.print.business.enums.ExamNumberStyleEnum;
-import com.qmth.distributed.print.business.enums.PrintPlanStatusEnum;
-import com.qmth.distributed.print.business.service.*;
-import com.qmth.distributed.print.business.util.GoogleBarCodeUtil;
-import com.qmth.distributed.print.business.util.PdfUtil;
-import com.qmth.teachcloud.common.bean.vo.FilePathVo;
-import com.qmth.teachcloud.common.bean.vo.OriginalVo;
-import com.qmth.teachcloud.common.bean.vo.PaperInfoVo;
-import com.qmth.teachcloud.common.bean.vo.PrintPathVo;
-import com.qmth.teachcloud.common.contant.SystemConstant;
-import com.qmth.teachcloud.common.entity.BasicAttachment;
-import com.qmth.teachcloud.common.entity.BasicPrintConfig;
-import com.qmth.teachcloud.common.entity.BasicSemester;
-import com.qmth.teachcloud.common.enums.*;
-import com.qmth.teachcloud.common.service.BasicAttachmentService;
-import com.qmth.teachcloud.common.service.BasicSemesterService;
-import com.qmth.teachcloud.common.service.FileUploadService;
-import com.qmth.teachcloud.common.service.TeachcloudCommonService;
-import com.qmth.teachcloud.common.util.ConvertUtil;
-import com.qmth.teachcloud.common.util.ExamTaskUtil;
-import com.qmth.teachcloud.common.util.FileUtil;
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.annotation.Lazy;
-import org.springframework.stereotype.Component;
-import org.springframework.transaction.annotation.Transactional;
-
-import javax.annotation.Resource;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.math.BigDecimal;
-import java.util.*;
-import java.util.stream.Collectors;
-
-/**
- * @Description: 创建pdf util
- * @Param:
- * @return:
- * @Author: wangliang
- * @Date: 2021/4/14
- */
-@Component
-public class CreatePdfNewUtil {
-    private final static Logger log = LoggerFactory.getLogger(CreatePdfNewUtil.class);
-
-    @Resource
-    private BasicAttachmentService basicAttachmentService;
-    @Resource
-    @Lazy
-    private PrintCommonService printCommonService;
-    @Resource
-    private TeachcloudCommonService teachcloudCommonService;
-    @Resource
-    private ExamDetailService examDetailService;
-    @Resource
-    private ExamStudentService examStudentService;
-    @Resource
-    private BasicTemplateService basicTemplateService;
-    @Resource
-    private BasicSemesterService basicSemesterService;
-    @Resource
-    private ExamTaskService examTaskService;
-    @Resource
-    private ExamTaskDetailService examTaskDetailService;
-    @Resource
-    private ExamPrintPlanService examPrintPlanService;
-    @Resource
-    private BasicPrintConfigService basicPrintConfigService;
-    @Resource
-    private FileUploadService fileUploadService;
-
-    /**
-     * 创建登记表
-     *
-     * @param examDetail
-     * @param basicAttachment
-     * @param printCount
-     * @param fileTempList
-     * @throws Exception
-     */
-    public void createCheckIn(ExamDetail examDetail, BasicAttachment basicAttachment, Integer printCount, List<File> fileTempList) throws Exception {
-        Optional.ofNullable(basicAttachment).orElseThrow(() -> ExceptionResultEnum.ATTACHMENT_IS_NULL.exception());
-
-        String type = basicAttachment.getType();
-        FilePathVo filePathVo = JSON.parseObject(basicAttachment.getPath(), FilePathVo.class);
-
-        if (Objects.nonNull(type) && Objects.equals(type, SystemConstant.PDF_PREFIX)) {
-            String filePath = filePathVo.getPath();
-            PrintPathVo printPathVo = new PrintPathVo(ClassifyEnum.CHECK_IN, filePathVo.getUploadType(), filePathVo.getType(), filePath, basicAttachment.getMd5(), null, null);
-            examDetail.setAttachmentPath(printCommonService.parseAttachmentPath(examDetail.getAttachmentPath(), printPathVo));
-
-//            for (int i = 0; i < printCount; i++) {
-//                ordinaryPdfList.add(new PdfDto(filePath, PageSizeEnum.A4, 0));
-//            }
-        } else {
-            File htmlFileTemp = SystemConstant.getFileTempVar(SystemConstant.HTML_PREFIX);
-            fileUploadService.downloadFile(basicAttachment.getId(), htmlFileTemp.getPath());
-            BasicAttachment attachment = printCommonService.saveAttachmentPdfFromHtml(String.valueOf(basicAttachment.getId()), htmlFileTemp, examDetail.getCreateId(), null, fileTempList, PageSizeEnum.A4);
-            FilePathVo filePathVo1 = JSON.parseObject(attachment.getPath(), FilePathVo.class);
-            PrintPathVo printPathVo = new PrintPathVo(ClassifyEnum.CHECK_IN, filePathVo1.getUploadType(), filePathVo1.getType(), filePathVo1.getPath(), attachment.getMd5(), null, null);
-            examDetail.setAttachmentPath(printCommonService.parseAttachmentPath(examDetail.getAttachmentPath(), printPathVo));
-        }
-    }
-
-
-    /**
-     * 生成卷袋贴
-     *
-     * @param templateId
-     * @param schoolName
-     * @param examDetail
-     * @param examStudentList
-     * @param backupCount
-     * @param printCount
-     * @param examDetailCourseList
-     * @param examId
-     */
-    public void createPaperPackage(Long templateId, String schoolName, ExamDetail examDetail, List<ExamStudentCourseDto> examStudentList, Integer backupCount, Integer printCount, List<ExamDetailCourse> examDetailCourseList, Long examId) {
-        BasicTemplate basicTemplate = basicTemplateService.getById(templateId);
-        if (Objects.isNull(basicTemplate)) {
-            throw ExceptionResultEnum.ERROR.exception("印品数据有误");
-        }
-
-        JSONObject object = JSON.parseObject(basicTemplate.getDisplayRange());
-
-        PdfPackageDto pdfPackageDto = new PdfPackageDto();
-        pdfPackageDto.setTitle(schoolName);
-        pdfPackageDto.setPackageNumber(examDetail.getPackageCode());
-
-        boolean isTag = false;
-        for (ExamDetailCourse detailCourse : examDetailCourseList) {
-            ExamTask examTask = examTaskService.getByExamIdAndCourseCodeAndPaperNumber(examId, detailCourse.getCourseCode(), detailCourse.getPaperNumber());
-            ExamTaskDetail examTaskDetail = examTaskDetailService.getByExamTaskId(examTask.getId());
-            List<PaperInfoVo> paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetail.getPaperAttachmentIds());
-            for (PaperInfoVo paperInfoVo : paperInfoVoList) {
-                int pages = paperInfoVo.getPages();
-                isTag = pages > 2;
-                pdfPackageDto.setTag(isTag);
-                if (isTag) {
-                    break;
-                }
-            }
-        }
-
-        // 标题信息
-        List<JSONObject> objectTitleList = JSON.parseArray(object.getString("title"), JSONObject.class).stream().filter(m -> m.getBoolean("enable")).collect(Collectors.toList());
-        List<Map<String, String>> titlePlate = new ArrayList<>();
-        for (JSONObject jsonObject : objectTitleList) {
-            Map<String, String> titleMap = new HashMap<>();
-            String code = jsonObject.getString("code");
-            String name = jsonObject.getString("name");
-            titleMap.put("code", code);
-            titleMap.put("name", name);
-            if ("semesterName".equals(code)) {
-                BasicSemester basicSemester = basicSemesterService.selectByExamId(examId);
-                titleMap.put("value", basicSemester == null ? null : basicSemester.getName() + "  课程考试");
-            }
-            titlePlate.add(titleMap);
-        }
-        pdfPackageDto.setTitlePlate(titlePlate);
-
-        List<JSONObject> objectList = JSON.parseArray(object.getString("basic"), JSONObject.class).stream().filter(m -> m.getBoolean("enable")).collect(Collectors.toList());
-
-        boolean isCourseHasTwo = objectList.stream().filter(m -> "courseCode".equals(m.getString("code")) || "courseName".equals(m.getString("code"))).count() == 2;
-        boolean isDateHasTwo = objectList.stream().filter(m -> "examDate".equals(m.getString("code")) || "examTime".equals(m.getString("code"))).count() == 2;
-        boolean isCourseFill = false;
-        boolean isDateFill = false;
-        // 基础信息
-        List<Map<String, String>> basicPlate = new ArrayList<>();
-        for (JSONObject jsonObject : objectList) {
-            String code = jsonObject.getString("code");
-            String name = jsonObject.getString("name");
-            if ("examDate".equals(code) || "examTime".equals(code)) {
-                String startDate = DateUtil.format(new Date(examDetail.getExamStartTime()), SystemConstant.DATE_PATTERN);
-                String endDate = DateUtil.format(new Date(examDetail.getExamEndTime()), SystemConstant.DATE_PATTERN);
-                String startTime = DateUtil.format(new Date(examDetail.getExamStartTime()), SystemConstant.TIME_PATTERN);
-                String endTime = DateUtil.format(new Date(examDetail.getExamEndTime()), SystemConstant.TIME_PATTERN);
-                Map<String, String> basicMap = new HashMap<>();
-                if (isDateHasTwo) {
-                    if (isDateFill) {
-                        continue;
-                    }
-                    String examTime;
-                    if (startDate.equals(endDate)) {
-                        examTime = startDate + " " + startTime + SystemConstant.HYPHEN + endTime;
-                    } else {
-                        examTime = startDate + " " + startTime + SystemConstant.HYPHEN + endDate + " " + endTime;
-                    }
-                    basicMap.put("code", "examTime");
-                    basicMap.put("name", "考试时间");
-                    basicMap.put("value", examTime);
-                    isDateFill = true;
-                } else {
-                    String examTime = "";
-                    if ("examDate".equals(code)) {
-                        if (startDate.equals(endDate)) {
-                            examTime = startDate;
-                        } else {
-                            examTime = startDate + SystemConstant.HYPHEN + endDate;
-                        }
-                    } else if ("examTime".equals(code)) {
-                        if (startDate.equals(endDate)) {
-                            examTime = startDate + " " + startTime + SystemConstant.HYPHEN + endTime;
-                        } else {
-                            examTime = startDate + " " + startTime + SystemConstant.HYPHEN + endDate + " " + endTime;
-                        }
-                    }
-                    basicMap.put("code", code);
-                    basicMap.put("name", name);
-                    basicMap.put("value", examTime);
-                }
-                basicPlate.add(basicMap);
-            } else if ("courseCode".equals(code) || "courseName".equals(code)) {
-                Map<String, String> basicMap = new HashMap<>();
-                if (isCourseHasTwo) {
-                    if (isCourseFill) {
-                        continue;
-                    }
-                    List<String> courseNames = examDetailCourseList.stream().map(m -> String.format("%s(%s)", m.getCourseName(), m.getCourseCode())).collect(Collectors.toList());
-                    basicMap.put("code", "courseName");
-                    basicMap.put("name", "课程名称");
-                    basicMap.put("value", String.join(SystemConstant.COMMA_OF_CHINESE, courseNames));
-                    isCourseFill = true;
-                } else {
-                    List<String> courseNames = examDetailCourseList.stream().map(m -> "courseCode".equals(code) ? m.getCourseCode() : "courseName".equals(code) ? m.getCourseName() : "").collect(Collectors.toList());
-                    basicMap.put("code", code);
-                    basicMap.put("name", name);
-                    basicMap.put("value", String.join(SystemConstant.COMMA_OF_CHINESE, courseNames));
-                }
-                basicPlate.add(basicMap);
-            } else if ("paperNumber".equals(code)) {
-                List<String> paperNumbers = examDetailCourseList.stream().map(ExamDetailCourse::getPaperNumber).collect(Collectors.toList());
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", String.join(SystemConstant.COMMA_OF_CHINESE, paperNumbers));
-                basicPlate.add(basicMap);
-            } else if ("examPlace".equals(code) || "campusName".equals(code)) {
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", examDetail.getExamPlace());
-                basicPlate.add(basicMap);
-            } else if ("examRoom".equals(code) || "examClassroomName".equals(code)) {
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", examDetail.getExamRoom());
-                basicPlate.add(basicMap);
-            } else if ("collegeName".equals(code)) {
-                Set<String> collegeNames = examStudentList.stream().filter(m -> StringUtils.isNotBlank(m.getCollegeName())).map(ExamStudent::getCollegeName).collect(Collectors.toSet());
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", CollectionUtils.isEmpty(collegeNames) ? "" : String.join(SystemConstant.COMMA_OF_CHINESE, collegeNames));
-                basicPlate.add(basicMap);
-            } else if ("majorName".equals(code)) {
-                Set<String> stringSet = new HashSet<>();
-                Set<String> majorNames = examStudentList.stream().filter(m -> StringUtils.isNotBlank(m.getMajorName())).map(ExamStudent::getMajorName).collect(Collectors.toSet());
-                if (!majorNames.isEmpty()) {
-                    stringSet.addAll(majorNames);
-                }
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", CollectionUtils.isEmpty(stringSet) ? "" : String.join(SystemConstant.COMMA_OF_CHINESE, stringSet));
-                basicPlate.add(basicMap);
-            } else if ("teachClazzName".equals(code)) {
-                Set<String> stringSet = new HashSet<>();
-                Set<String> teachClazzNames = examStudentList.stream().filter(m -> StringUtils.isNotBlank(m.getTeachClazzName())).map(ExamStudentCourseDto::getTeachClazzName).collect(Collectors.toSet());
-                if (!teachClazzNames.isEmpty()) {
-                    stringSet.addAll(teachClazzNames);
-                }
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", CollectionUtils.isEmpty(stringSet) ? "" : String.join(SystemConstant.COMMA_OF_CHINESE, stringSet));
-                basicPlate.add(basicMap);
-            } else if ("clazzName".equals(code)) {
-                Set<String> stringSet = new HashSet<>();
-                Set<String> clazzNames = examStudentList.stream().filter(m -> StringUtils.isNotBlank(m.getClazzName())).map(ExamStudentCourseDto::getClazzName).collect(Collectors.toSet());
-                if (!clazzNames.isEmpty()) {
-                    stringSet.addAll(clazzNames);
-                }
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", CollectionUtils.isEmpty(stringSet) ? "" : String.join(SystemConstant.COMMA_OF_CHINESE, stringSet));
-                basicPlate.add(basicMap);
-            } else if ("teacherName".equals(code)) {
-                Set<String> stringSet = new HashSet<>();
-                Set<String> teachNames = examStudentList.stream().filter(m -> StringUtils.isNotBlank(m.getTeacherName())).map(ExamStudentCourseDto::getTeacherName).collect(Collectors.toSet());
-                if (!teachNames.isEmpty()) {
-                    stringSet.addAll(teachNames);
-                }
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", CollectionUtils.isEmpty(stringSet) ? "" : String.join(SystemConstant.COMMA_OF_CHINESE, stringSet));
-                basicPlate.add(basicMap);
-            } else if ("paperCount".equals(code)) {
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", "paperCount");
-                basicMap.put("name", "试卷数量");
-                basicMap.put("value", examStudentList.size() + " + " + backupCount);
-                basicPlate.add(basicMap);
-            } else if ("examCount".equals(code)) {
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", "examCount");
-                basicMap.put("name", "应考人数");
-                basicMap.put("value", String.valueOf(examStudentList.size()));
-                basicPlate.add(basicMap);
-            } else if ("actualExamCount".equals(code)) {
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", "actualExamCount");
-                basicMap.put("name", "实考人数");
-                basicMap.put("value", "");
-                basicPlate.add(basicMap);
-            } else {
-                // 扩展字段走本校验,进行数据组装
-                Set<String> extendFieldsSet = examStudentList.stream().map(ExamStudentCourseDto::getExtendFields).collect(Collectors.toSet());
-                Set<String> finalSet = new HashSet<>();
-                for (String extendField : extendFieldsSet) {
-                    List<JSONObject> jsonObjects = JSON.parseArray(extendField, JSONObject.class);
-                    Set<String> values = jsonObjects.stream().filter(m -> code.equals(m.getString("code"))).map(m -> m.getString("value")).collect(Collectors.toSet());
-                    finalSet.addAll(values);
-                }
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", String.join(SystemConstant.COMMA_OF_CHINESE, finalSet));
-                basicPlate.add(basicMap);
-            }
-        }
-        pdfPackageDto.setBasicPlate(basicPlate);
-        printCommonService.saveAttachmentPackagePdf(pdfPackageDto, examDetail, printCount);
-    }
-
-    /**
-     * 创建签到表
-     *
-     * @param templateId
-     * @param schoolName
-     * @param examDetail
-     * @param examStudentList
-     * @param printCount
-     * @param examDetailCourseList
-     */
-    public void createSignBook(Long templateId, String schoolName, ExamDetail examDetail, List<ExamStudentCourseDto> examStudentList, Integer printCount, List<ExamDetailCourse> examDetailCourseList) {
-        BasicTemplate basicTemplate = basicTemplateService.getById(templateId);
-        if (Objects.isNull(basicTemplate)) {
-            throw ExceptionResultEnum.ERROR.exception("印品数据有误");
-        }
-        PdfSignDto pdfFillDto = new PdfSignDto();
-        pdfFillDto.setTitle(schoolName + "签到表");
-        pdfFillDto.setPackageNumber(examDetail.getPackageCode());
-        pdfFillDto.setTextDesc(basicTemplate.getTextDesc());
-
-        JSONObject jsonObject = JSON.parseObject(basicTemplate.getDisplayRange());
-        List<JSONObject> objectList = JSON.parseArray(jsonObject.getString("basic"), JSONObject.class).stream().filter(m -> m.getBoolean("enable")).collect(Collectors.toList());
-
-        boolean isCourseHasTwo = objectList.stream().filter(m -> "courseCode".equals(m.getString("code")) || "courseName".equals(m.getString("code"))).count() == 2;
-        boolean isDateHasTwo = objectList.stream().filter(m -> "examDate".equals(m.getString("code")) || "examTime".equals(m.getString("code"))).count() == 2;
-        boolean isPlaceHasTwo = objectList.stream().filter(m -> "examPlace".equals(m.getString("code")) || "examRoom".equals(m.getString("code"))).count() == 2;
-
-        // 基础信息
-        List<Map<String, String>> basicPlate = new ArrayList<>();
-        boolean isCourseFill = false;
-        boolean isDateFill = false;
-        boolean isPlaceFill = false;
-        for (JSONObject object : objectList) {
-            String code = object.getString("code");
-            String name = object.getString("name");
-            if ("courseCode".equals(code) || "courseName".equals(code)) {
-                Map<String, String> basicMap = new HashMap<>();
-                if (isCourseHasTwo) {
-                    if (isCourseFill) {
-                        continue;
-                    }
-                    List<String> courseNames = examDetailCourseList.stream().map(m -> String.format("%s(%s)", m.getCourseName(), m.getCourseCode())).collect(Collectors.toList());
-                    basicMap.put("code", "courseName");
-                    basicMap.put("name", "课程名称");
-                    basicMap.put("value", String.join(SystemConstant.COMMA_OF_CHINESE, courseNames));
-                    isCourseFill = true;
-                } else {
-                    List<String> courseNames = examDetailCourseList.stream().map(m -> "courseCode".equals(code) ? m.getCourseCode() : "courseName".equals(code) ? m.getCourseName() : "").collect(Collectors.toList());
-                    basicMap.put("code", code);
-                    basicMap.put("name", name);
-                    basicMap.put("value", String.join(SystemConstant.COMMA_OF_CHINESE, courseNames));
-                }
-                basicPlate.add(basicMap);
-            } else if ("paperNumber".equals(code)) {
-                List<String> paperNumbers = examDetailCourseList.stream().map(ExamDetailCourse::getPaperNumber).collect(Collectors.toList());
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", String.join(SystemConstant.COMMA_OF_CHINESE, paperNumbers));
-                basicPlate.add(basicMap);
-            } else if ("examDate".equals(code) || "examTime".equals(code)) {
-                String startDate = DateUtil.format(new Date(examDetail.getExamStartTime()), SystemConstant.DATE_PATTERN);
-                String endDate = DateUtil.format(new Date(examDetail.getExamEndTime()), SystemConstant.DATE_PATTERN);
-                String startTime = DateUtil.format(new Date(examDetail.getExamStartTime()), SystemConstant.TIME_PATTERN);
-                String endTime = DateUtil.format(new Date(examDetail.getExamEndTime()), SystemConstant.TIME_PATTERN);
-
-                Map<String, String> basicMap = new HashMap<>();
-                if (isDateHasTwo) {
-                    if (isDateFill) {
-                        continue;
-                    }
-                    String examTime;
-                    if (startDate.equals(endDate)) {
-                        examTime = startDate + " " + startTime + SystemConstant.HYPHEN + endTime;
-                    } else {
-                        examTime = startDate + " " + startTime + SystemConstant.HYPHEN + endDate + " " + endTime;
-                    }
-                    basicMap.put("code", "examTime");
-                    basicMap.put("name", "考试时间");
-                    basicMap.put("value", examTime);
-                    isDateFill = true;
-                } else {
-                    String examTime = "";
-                    if ("examDate".equals(code)) {
-                        if (startDate.equals(endDate)) {
-                            examTime = startDate;
-                        } else {
-                            examTime = startDate + SystemConstant.HYPHEN + endDate;
-                        }
-                    } else if ("examTime".equals(code)) {
-                        if (startDate.equals(endDate)) {
-                            examTime = startDate + " " + startTime + SystemConstant.HYPHEN + endTime;
-                        } else {
-                            examTime = startDate + " " + startTime + SystemConstant.HYPHEN + endDate + " " + endTime;
-                        }
-                    }
-                    basicMap.put("code", code);
-                    basicMap.put("name", name);
-                    basicMap.put("value", examTime);
-                }
-                basicPlate.add(basicMap);
-            } else if ("examPlace".equals(code) || "examRoom".equals(code)) {
-                Map<String, String> basicMap = new HashMap<>();
-                if (isPlaceHasTwo) {
-                    if (isPlaceFill) {
-                        continue;
-                    }
-                    StringJoiner stringJoiner = new StringJoiner("");
-                    if (StringUtils.isNotBlank(examDetail.getExamPlace())) {
-                        stringJoiner.add(examDetail.getExamPlace());
-                    }
-                    if (StringUtils.isNotBlank(examDetail.getExamRoom())) {
-                        stringJoiner.add(examDetail.getExamRoom());
-                    }
-                    basicMap.put("code", "examRoom");
-                    basicMap.put("name", "考试地点");
-                    basicMap.put("value", stringJoiner.toString());
-                    isPlaceFill = true;
-                } else {
-                    StringJoiner stringJoiner = new StringJoiner("");
-                    if ("examPlace".equals(code) && StringUtils.isNotBlank(examDetail.getExamPlace())) {
-                        stringJoiner.add(examDetail.getExamPlace());
-                    }
-                    if ("examRoom".equals(code) && StringUtils.isNotBlank(examDetail.getExamRoom())) {
-                        stringJoiner.add(examDetail.getExamRoom());
-                    }
-                    basicMap.put("code", code);
-                    basicMap.put("name", name);
-                    basicMap.put("value", stringJoiner.toString());
-                }
-                basicPlate.add(basicMap);
-            } else if ("collegeName".equals(code)) {
-                Set<String> collegeNames = examStudentList.stream().filter(m -> StringUtils.isNotBlank(m.getCollegeName())).map(ExamStudentCourseDto::getCollegeName).collect(Collectors.toSet());
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", String.join(SystemConstant.COMMA_OF_CHINESE, collegeNames));
-                basicPlate.add(basicMap);
-            } else if ("majorName".equals(code)) {
-                Set<String> majorNames = examStudentList.stream().filter(m -> StringUtils.isNotBlank(m.getMajorName())).map(ExamStudentCourseDto::getMajorName).collect(Collectors.toSet());
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", String.join(SystemConstant.COMMA_OF_CHINESE, majorNames));
-                basicPlate.add(basicMap);
-            } else if ("teachClazzName".equals(code)) {
-                Set<String> teachClazzNames = examStudentList.stream().filter(m -> StringUtils.isNotBlank(m.getTeachClazzName())).map(ExamStudentCourseDto::getTeachClazzName).collect(Collectors.toSet());
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", String.join(SystemConstant.COMMA_OF_CHINESE, teachClazzNames));
-                basicPlate.add(basicMap);
-            } else if ("clazzName".equals(code)) {
-                Set<String> clazzNames = examStudentList.stream().filter(m -> StringUtils.isNotBlank(m.getClazzName())).map(ExamStudentCourseDto::getClazzName).collect(Collectors.toSet());
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", String.join(SystemConstant.COMMA_OF_CHINESE, clazzNames));
-                basicPlate.add(basicMap);
-            } else if ("teacherName".equals(code)) {
-                Set<String> teacherNames = examStudentList.stream().filter(m -> StringUtils.isNotBlank(m.getTeacherName())).map(ExamStudentCourseDto::getTeacherName).collect(Collectors.toSet());
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", String.join(SystemConstant.COMMA_OF_CHINESE, teacherNames));
-                basicPlate.add(basicMap);
-            } else if ("examCount".equals(code)) {
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", String.valueOf(examStudentList.size()));
-                basicPlate.add(basicMap);
-            } else if ("actualExamCount".equals(code)) {
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", "");
-                basicPlate.add(basicMap);
-            } else {
-                // 扩展字段走本校验,进行数据组装
-                Set<String> extendFieldsSet = examStudentList.stream().map(ExamStudentCourseDto::getExtendFields).collect(Collectors.toSet());
-                Set<String> finalSet = new HashSet<>();
-                for (String extendField : extendFieldsSet) {
-                    List<JSONObject> jsonObjects = JSON.parseArray(extendField, JSONObject.class);
-                    Set<String> values = jsonObjects.stream().filter(m -> code.equals(m.getString("code"))).map(m -> m.getString("value")).collect(Collectors.toSet());
-                    finalSet.addAll(values);
-                }
-                Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", String.join(SystemConstant.COMMA_OF_CHINESE, finalSet));
-                basicPlate.add(basicMap);
-            }
-        }
-        pdfFillDto.setBasicPlate(basicPlate);
-
-        // 表头信息
-        List<JSONObject> tableList = JSON.parseArray(jsonObject.getString("table"), JSONObject.class).stream().filter(m -> m.getBoolean("enable")).collect(Collectors.toList());
-        Map<String, String> studentHeadPlateMap = new LinkedHashMap<>();
-        for (JSONObject object : tableList) {
-            studentHeadPlateMap.put(object.getString("code"), object.getString("name"));
-        }
-        studentHeadPlateMap.put("studentSign", "签名");
-        pdfFillDto.setStudentHeadPlate(studentHeadPlateMap);
-
-        // 考生信息
-        List<Map<String, String>> studentPlate = new ArrayList<>();
-        for (ExamStudentCourseDto examStudentCourseDto : examStudentList) {
-            Map<String, String> studentMap = new LinkedHashMap<>();
-            if (studentHeadPlateMap.containsKey("siteNumber")) {
-                studentMap.put("siteNumber", examStudentCourseDto.getSiteNumber());
-            }
-            if (studentHeadPlateMap.containsKey("studentName")) {
-                studentMap.put("studentName", examStudentCourseDto.getStudentName());
-            }
-            if (studentHeadPlateMap.containsKey("studentCode")) {
-                studentMap.put("studentCode", examStudentCourseDto.getStudentCode());
-            }
-            if (studentHeadPlateMap.containsKey("courseName")) {
-                studentMap.put("courseName", examStudentCourseDto.getCourseName());
-            }
-            if (studentHeadPlateMap.containsKey("teachClazzName")) {
-                studentMap.put("teachClazzName", examStudentCourseDto.getTeachClazzName());
-            }
-            if (studentHeadPlateMap.containsKey("clazzName")) {
-                studentMap.put("clazzName", examStudentCourseDto.getClazzName());
-            }
-            if (studentHeadPlateMap.containsKey("ticketNumber")) {
-                studentMap.put("ticketNumber", examStudentCourseDto.getTicketNumber());
-            }
-            if (studentHeadPlateMap.containsKey("studentSign")) {
-                studentMap.put("studentSign", "");
-            }
-            studentPlate.add(studentMap);
-        }
-        pdfFillDto.setStudentPlate(studentPlate);
-
-        printCommonService.saveAttachmentSignPdf(pdfFillDto, examDetail, printCount, basicTemplate);
-    }
-
-    /**
-     * 题卡html内容,所有参数置空
-     *
-     * @param htmlContent
-     * @return
-     */
-    public String replaceBlankHtmlContent(String htmlContent) {
-        // 替换条码参数
-        htmlContent = htmlContent.replaceAll("<img src=\"data:image/png;base64,\\$\\{examNumber\\}\">", "");
-        // 正则匹配所有参数,填入空值
-        htmlContent = htmlContent.replaceAll("\\$\\{[A-Za-z0-9]+\\}", "");
-        return htmlContent;
-
-    }
-
-    /**
-     * 获取题卡attachmentId
-     *
-     * @param examCard
-     * @param attachmentIds
-     */
-    public void getCardAttachmentId(ExamCard examCard, Set<Long> attachmentIds) {
-        if (Objects.nonNull(examCard.getBackupAttachment()) && !Objects.equals("", examCard.getBackupAttachment())) {
-            JSONObject jsonObjectCard = JSONObject.parseObject(examCard.getBackupAttachment());
-            JSONArray jsonArrayCard = (JSONArray) jsonObjectCard.get("card");
-            for (int i = 0; i < jsonArrayCard.size(); i++) {
-                JSONObject object = (JSONObject) jsonArrayCard.get(i);
-                if (Objects.nonNull(object.get("attachmentId")) && !Objects.equals("", object.get("attachmentId"))) {
-                    attachmentIds.add((Long) (object.get("attachmentId")));
-                }
-            }
-        }
-    }
-
-    /**
-     * 获取试卷pdf
-     *
-     * @param stuPaperType   考生卷型
-     * @param paperPdfDto    抽取的试卷文件信息
-     * @param createPdfDto   生成pdf
-     * @param waterMarkNames 水印内容
-     */
-    public PdfDto getExamStudentPaperPdf(String stuPaperType, List<PaperPdfDto> paperPdfDto, CreatePdfDto createPdfDto, String[] waterMarkNames) throws IOException {
-        Set<Integer> pagesList = new HashSet<>();
-        if (!CollectionUtils.isEmpty(paperPdfDto)) {
-            for (PaperPdfDto dto : paperPdfDto) {
-                if (stuPaperType.equals(dto.getType())) {
-                    int pages = dto.getPages();
-                    pagesList.add(pages);
-                    PdfDto pdfDto = PdfUtil.addPdfPage(dto.getFile());
-                    File file = paperPdfDto.size() > 1 ? PdfUtil.addWaterMark(dto.getFile(), waterMarkNames, 0.5f, 12, 0) : dto.getFile();
-                    createPdfDto.getPaperPdfList().add(new PdfDto(file.getPath(), dto.getPageSize(), pdfDto.getPageCount()));
-                }
-            }
-            int pageCount = pagesList.stream().mapToInt(Integer::intValue).sum();
-            return new PdfDto(paperPdfDto.get(0).getPageSize(), pageCount);
-        } else {
-            return null;
-        }
-    }
-
-    /**
-     * 获取备份试卷pdf
-     *
-     * @param paperPdfDto  抽取的试卷文件信息
-     * @param backupCount  备份数量
-     * @param createPdfDto 生成pdf对象
-     */
-    public PdfDto getBackupPaperPdfList(List<PaperPdfDto> paperPdfDto, Integer backupCount, CreatePdfDto createPdfDto) throws
-            IOException {
-        Set<Integer> pagesList = new HashSet<>();
-        boolean tag = false;
-        if (CollectionUtils.isNotEmpty(paperPdfDto)) {
-            for (PaperPdfDto dto : paperPdfDto) {
-                int pages = dto.getPages();
-                pagesList.add(pages);
-                tag = pages > 2;
-                PdfDto pdfDto = PdfUtil.addPdfPage(dto.getFile());
-                for (int j = 1; j <= backupCount; j++) {
-                    createPdfDto.getPaperPdfList().add(new PdfDto(dto.getFile().getPath(), dto.getPageSize(), pdfDto.getPageCount()));
-                }
-            }
-            int pageCount = pagesList.stream().mapToInt(Integer::intValue).sum();
-            return new PdfDto(paperPdfDto.get(0).getPageSize(), pageCount, tag);
-        } else {
-            return null;
-        }
-    }
-
-    /**
-     * 获取考试试卷
-     *
-     * @param paperType       抽取的试卷型(多个用,分隔)
-     * @param paperInfoVoList 命题任务上传试卷信息
-     */
-    public List<PaperPdfDto> getPaperPdfFile(String paperType, List<PaperInfoVo> paperInfoVoList, CreatePdfDto createPdfDto) throws Exception {
-        String[] paperTypes = paperType.split(",");
-        List<PaperPdfDto> paperPdfDtoList = new ArrayList<>();
-        PaperPdfDto paperPdfDto;
-        for (PaperInfoVo paperInfoVo : paperInfoVoList) {
-            BasicAttachment basicAttachment = basicAttachmentService.getById(paperInfoVo.getAttachmentId());
-            Optional.ofNullable(basicAttachment).orElseThrow(() -> ExceptionResultEnum.ATTACHMENT_IS_NULL.exception("命题任务中上传试卷文件路径不存在"));
-
-            // 卷型
-            String name = paperInfoVo.getName();
-            OriginalVo original = paperInfoVo.getOriginal();
-            // 返回抽中的试卷
-            for (String type : paperTypes) {
-                if (StringUtils.equalsIgnoreCase(name, type)) {
-                    File file = SystemConstant.getFileTempVar(SystemConstant.PDF_PREFIX);
-                    createPdfDto.getFileTempList().add(file);
-                    fileUploadService.downloadFile(basicAttachment, file.getPath());
-//                    PageSizeEnum pageSizeEnum = PageSizeEnum.valueOf(original.getPageSize());
-//                    Optional.ofNullable(pageSizeEnum).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("命题任务中上传试卷文件未设置pdf格式"));
-                    paperPdfDto = new PaperPdfDto(type, file, new PdfReader(new FileInputStream(file)).getNumberOfPages(), null);
-                    paperPdfDtoList.add(paperPdfDto);
-                    break;
-                }
-            }
-        }
-        return paperPdfDtoList;
-    }
-
-    private String randomPaperType(String[] unexposedPaperTypes, int drawCount) {
-        List<String> finalTypes = new ArrayList<>();
-        List<String> unexposedPaperTypesList = new ArrayList<>(Arrays.asList(unexposedPaperTypes));
-        for (int i = 0; i < drawCount; i++) {
-            int index = new Random().nextInt(unexposedPaperTypesList.size());
-            finalTypes.add(unexposedPaperTypesList.get(index));
-            unexposedPaperTypesList.remove(index);
-        }
-
-        finalTypes = finalTypes.stream().sorted(Comparator.comparing(String::valueOf)).collect(Collectors.toList());
-        return String.join(",", finalTypes);
-    }
-
-    /**
-     * 合并A3 pdf
-     *
-     * @param list
-     * @return
-     * @throws IOException
-     */
-    public String mergeA3Pdf(List<PdfDto>... list) {
-        List<PdfDto> mergePdfA3List = new ArrayList<>();
-        for (int i = 0; i < list.length; i++) {
-            mergePdfA3List.addAll(list[i]);
-        }
-        List<String> pathA3List = mergePdfA3List.stream().map(PdfDto::getPath).collect(Collectors.toList());
-        return PdfUtil.mergePdf(pathA3List.toArray(new String[mergePdfA3List.size()]), null);
-    }
-
-    /**
-     * 合并A4 pdf
-     *
-     * @param list
-     * @return
-     * @throws IOException
-     */
-    public String mergeA4Pdf(List<File> fileTempList, List<PdfDto>... list) {
-        List<PdfDto> mergePdfA4List = new ArrayList<>();
-        for (int i = 0; i < list.length; i++) {
-            mergePdfA4List.addAll(list[i]);
-        }
-        List<String> pathA4List = mergePdfA4List.stream().map(PdfDto::getPath).collect(Collectors.toList());
-        return PdfUtil.mergePdf(pathA4List.toArray(new String[mergePdfA4List.size()]), null, fileTempList);
-    }
-
-    /**
-     * 合并pdf后保存数据库
-     *
-     * @param dirNamePaper
-     * @param dirNameCardA3
-     * @param tbTaskPdf
-     * @return
-     * @throws Exception
-     */
-    @Transactional
-    public void mergePdfSaveDb(String dirNamePaper,
-                               String dirNameCardA3,
-                               TBTaskPdf tbTaskPdf) throws Exception {
-        ExamDetail examDetail = examDetailService.getById(tbTaskPdf.getId());
-        BasicPrintConfig basicPrintConfig = basicPrintConfigService.getByExamId(tbTaskPdf.getExamId());
-        // 试卷+题卡
-        if (StringUtils.isNotBlank(dirNamePaper)) {
-            File localPaperPdfFile = new File(FileUtil.replaceSplit(dirNamePaper));
-            examDetail.setPaperPages(PdfUtil.getPdfPages(localPaperPdfFile));
-
-            String uploadFileName = PdfUtil.md5FileName(CreatePdfTypeEnum.PAPER.name() + tbTaskPdf.getId()) + SystemConstant.PDF_PREFIX;
-            FilePathVo filePathVo = fileUploadService.uploadFile(localPaperPdfFile, UploadFileEnum.PDF, uploadFileName);
-            BasicAttachment basicAttachment = new BasicAttachment(JSON.toJSONString(filePathVo), localPaperPdfFile.getName(), SystemConstant.PDF_PREFIX, new BigDecimal(localPaperPdfFile.length()), filePathVo.getMd5(), tbTaskPdf.getCreateId());
-            basicAttachmentService.save(basicAttachment);
-            examDetail.setAttachmentId(basicAttachment.getId());
-        }
-        // 题卡
-        if (StringUtils.isNotBlank(dirNameCardA3)) {
-            File localA3PdfCardFile = new File(FileUtil.replaceSplit(dirNameCardA3));
-            examDetail.setCardPages(PdfUtil.getPdfPages(localA3PdfCardFile));
-
-            String uploadFileName = PdfUtil.md5FileName(CreatePdfTypeEnum.CARD_A3.name() + tbTaskPdf.getId()) + SystemConstant.PDF_PREFIX;
-            FilePathVo filePathVo = fileUploadService.uploadFile(localA3PdfCardFile, UploadFileEnum.PDF, uploadFileName);
-            BasicAttachment basicAttachment = new BasicAttachment(JSON.toJSONString(filePathVo), localA3PdfCardFile.getName(), SystemConstant.PDF_PREFIX, new BigDecimal(localA3PdfCardFile.length()), filePathVo.getMd5(), tbTaskPdf.getCreateId());
-            basicAttachmentService.save(basicAttachment);
-            examDetail.setCardAttachmentId(basicAttachment.getId());
-        }
-        if (PrintMethodEnum.AUTO == basicPrintConfig.getPrintMethod()) {
-            examDetail.setStatus(ExamDetailStatusEnum.WAITING);
-        } else {
-            examDetail.setStatus(ExamDetailStatusEnum.READY);
-        }
-        examDetail.setNormal(true);
-        examDetailService.saveOrUpdate(examDetail);
-
-        ExamPrintPlan examPrintPlan = examPrintPlanService.getById(tbTaskPdf.getPrintPlanId());
-        if (PrintMethodEnum.AUTO == basicPrintConfig.getPrintMethod()) {
-            examPrintPlan.setStatus(PrintPlanStatusEnum.PRINTING);
-            examPrintPlanService.updateById(examPrintPlan);
-        }
-    }
-
-    /**
-     * 考生题卡html
-     *
-     * @param studentHtml        题卡html内容
-     * @param examStudent        考生对象
-     * @param examDetail         考场对象
-     * @param userId             当前用户ID
-     * @param examStudentPdfList 考生题卡集合
-     * @param fileTempList
-     * @param basicCardRule      题卡规则
-     */
-    public BasicAttachment examStudentHtml(String studentHtml, ExamStudent examStudent, String paperType, ExamDetail examDetail,
-                                           Long userId, List<PdfDto> examStudentPdfList, List<File> fileTempList, BasicCardRule basicCardRule) throws IOException {
-        if (basicCardRule != null) {
-            if (ExamNumberStyleEnum.PRINT.equals(basicCardRule.getExamNumberStyle())) {
-                // 生成学生考号条码并将图片转成base64
-                studentHtml = studentHtml.replaceAll("\\$\\{studentCodeBarcode\\}", examStudent != null && examStudent.getStudentCode() != null ? GoogleBarCodeUtil.createBarCode(examStudent.getStudentCode(), false) : "");
-                studentHtml = studentHtml.replaceAll("\\$\\{ticketNumberBarcode\\}", examStudent != null && examStudent.getTicketNumber() != null ? GoogleBarCodeUtil.createBarCode(examStudent.getTicketNumber(), false) : "");
-                studentHtml = studentHtml.replaceAll("\\$\\{examNumber\\}", examStudent != null && examStudent.getStudentCode() != null ? GoogleBarCodeUtil.createBarCode(examStudent.getStudentCode(), false) : "");
-                studentHtml = studentHtml.replaceAll("\\$\\{examNumberStr\\}", examStudent != null && examStudent.getStudentCode() != null ? examStudent.getStudentCode() : "");
-                // 随机生成学生试卷条码并将图片转成base64
-                studentHtml = studentHtml.replaceAll("\\$\\{paperType\\}", examStudent != null && examStudent.getPaperType() != null ? GoogleBarCodeUtil.createBarCode(SystemConstant.convertPaperType(examStudent.getPaperType()), false) : StringUtils.isNotBlank(paperType) ? GoogleBarCodeUtil.createBarCode(SystemConstant.convertPaperType(paperType), false) : "");
-                // 替换考生卷型
-                studentHtml = studentHtml.replaceAll("\\$\\{paperTypeName\\}", examStudent != null && examStudent.getPaperType() != null ? examStudent.getPaperType() : StringUtils.isNotBlank(paperType) ? paperType : "");
-
-                if (examStudent != null) {
-                    // 根据题卡规则必选字段,替换相应值,没有则“”
-                    List<StudentExtendDto> studentExtendDtos = createExtendObject(examDetail, examStudent, basicCardRule);
-                    if (studentExtendDtos != null) {
-                        for (StudentExtendDto extendDto : studentExtendDtos) {
-                            studentHtml = studentHtml.replaceAll("\\$\\{" + extendDto.getFieldName() + "\\}", String.valueOf(extendDto.getValue()));
-                        }
-                    }
-                }
-            } else if (ExamNumberStyleEnum.FILL.equals(basicCardRule.getExamNumberStyle())) {
-                String fillFields = basicCardRule.getFillFields();
-                if (StringUtils.isNotBlank(fillFields)) {
-                    if (examStudent != null) {
-                        // 根据题卡规则必选字段,替换相应值,没有则“”
-                        List<StudentExtendDto> studentExtendDtos = createExtendObject(examDetail, examStudent, basicCardRule);
-                        if (CollectionUtils.isNotEmpty(studentExtendDtos)) {
-                            for (String s : fillFields.split(",")) {
-                                Optional<StudentExtendDto> extendDto = studentExtendDtos.stream().filter(m -> m.getFieldName().equals(s)).findFirst();
-                                if (extendDto.isPresent()) {
-                                    StudentExtendDto studentExtendDto = extendDto.get();
-                                    studentHtml = studentHtml.replaceAll("\\$\\{" + studentExtendDto.getFieldName() + "\\}", String.valueOf(studentExtendDto.getValue()));
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        } else {
-            // 替换条码参数
-            studentHtml = studentHtml.replaceAll("<img src=\"data:image/png;base64,\\$\\{examNumber\\}\">", "");
-            studentHtml = studentHtml.replaceAll("\\$\\{examNumberStr\\}", "");
-        }
-
-        studentHtml = studentHtml.replaceAll("\\$\\{packageCodeDom\\}", "");
-        // 将其它未匹配到值的参数,填入空值
-        studentHtml = studentHtml.replaceAll("\\$\\{[A-Za-z0-9]+\\}", "");
-        //学生题卡
-        BasicAttachment examStudentAttachment = printCommonService.saveAttachmentPdfFromHtml(examStudent != null ? examStudent.getId() + "|" + examStudent.getStudentCode() : SystemConstant.getNanoId(), studentHtml, userId, examStudentPdfList, fileTempList);
-        if (examStudent != null) {
-            examStudent.setAttachmentId(examStudentAttachment.getId());
-        }
-        return examStudentAttachment;
-    }
-
-    /**
-     * 题卡规则字段
-     *
-     * @param examDetail
-     * @param examStudent   考生对象
-     * @param basicCardRule 题卡规则对象
-     */
-    private List<StudentExtendDto> createExtendObject(ExamDetail examDetail, ExamStudent examStudent, BasicCardRule
-            basicCardRule) {
-        ExamStudentPdfInfoDto examStudentPdfInfoDto = examStudent == null ? null : examStudentService.getByStudentId(examStudent.getId());
-        if (basicCardRule == null) {
-            return null;
-        }
-        List<JSONObject> requiredFieldsJson = JSONArray.parseArray(basicCardRule.getRequiredFields(), JSONObject.class);
-        List<StudentExtendDto> studentExtendDtos = new ArrayList<>();
-        if (requiredFieldsJson.size() > 0) {
-            for (JSONObject jsonObject : requiredFieldsJson) {
-                StudentExtendDto studentExtendDto = new StudentExtendDto();
-                String code = String.valueOf(jsonObject.get("code"));
-                studentExtendDto.setFieldName(code);
-                Object value = examStudentPdfInfoDto == null ? null : ReflectUtil.getFieldValue(examStudentPdfInfoDto, code);
-                studentExtendDto.setValue(value == null ? "" : value);
-                studentExtendDtos.add(studentExtendDto);
-            }
-        }
-        List<JSONObject> extendFieldsJson = JSONArray.parseArray(basicCardRule.getExtendFields(), JSONObject.class);
-        if (extendFieldsJson.size() > 0) {
-            Map<String, Object> studentExtendMap = null;
-            if (examStudentPdfInfoDto != null && StringUtils.isNotBlank(examStudentPdfInfoDto.getExtendFields())) {
-                studentExtendMap = JSONArray.parseArray(examStudentPdfInfoDto.getExtendFields(), JSONObject.class).stream().collect(Collectors.toMap(k -> String.valueOf(k.get("code")), v -> v.get("value")));
-            }
-
-            Map<String, Object> map = ConvertUtil.analyzeDateAndTime(examDetail.getExamStartTime(), examDetail.getExamEndTime());
-
-            for (JSONObject jsonObject : extendFieldsJson) {
-                boolean enable = Boolean.parseBoolean(jsonObject.get("enable").toString());
-                StudentExtendDto studentExtendDto = new StudentExtendDto();
-                String code = String.valueOf(jsonObject.get("code"));
-
-                studentExtendDto.setFieldName(code);
-                Object value = examStudentPdfInfoDto == null ? null : ReflectUtil.getFieldValue(examStudentPdfInfoDto, code);
-                // 时间需要特殊处理
-                if ("examDate".equals(code)) {
-                    value = Objects.nonNull(map.get("date")) ? (String) map.get("date") : "";
-                }
-                if ("examTime".equals(code)) {
-                    value = Objects.nonNull(map.get("time")) ? (String) map.get("time") : "";
-                }
-                if (value == null) {
-                    value = studentExtendMap == null ? null : studentExtendMap.get(code);
-                }
-                studentExtendDto.setValue(value == null ? "" : value);
-                studentExtendDtos.add(studentExtendDto);
-            }
-        }
-        return studentExtendDtos;
-    }
-
-    /**
-     * 题卡规则字段
-     *
-     * @param basicCardRule 题卡规则对象
-     */
-    private List<StudentExtendDto> createExtendObjectNull(BasicCardRule basicCardRule) {
-        if (basicCardRule == null) {
-            return null;
-        }
-        List<JSONObject> requiredFieldsJson = JSONArray.parseArray(basicCardRule.getRequiredFields(), JSONObject.class);
-        List<StudentExtendDto> studentExtendDtos = new ArrayList<>();
-        if (requiredFieldsJson.size() > 0) {
-            for (JSONObject jsonObject : requiredFieldsJson) {
-                StudentExtendDto studentExtendDto = new StudentExtendDto();
-                String code = String.valueOf(jsonObject.get("code"));
-                studentExtendDto.setFieldName(code);
-                studentExtendDto.setValue("");
-                studentExtendDtos.add(studentExtendDto);
-            }
-        }
-        List<JSONObject> extendFieldsJson = JSONArray.parseArray(basicCardRule.getExtendFields(), JSONObject.class);
-        if (extendFieldsJson.size() > 0) {
-            for (JSONObject jsonObject : extendFieldsJson) {
-                StudentExtendDto studentExtendDto = new StudentExtendDto();
-                String code = String.valueOf(jsonObject.get("code"));
-                studentExtendDto.setFieldName(code);
-                studentExtendDto.setValue("");
-                studentExtendDtos.add(studentExtendDto);
-            }
-        }
-        return studentExtendDtos;
-    }
-
-    /**
-     * 通用题卡html
-     *
-     * @param packageCode
-     * @param cardContent
-     * @param paperType
-     * @param userId
-     * @param cardPdfList
-     * @param basicCardRule
-     * @return
-     * @throws IOException
-     */
-    public BasicAttachment cardHtml(String packageCode, String cardContent, String paperType, Long userId, List<PdfDto> cardPdfList, List<File> fileTempList, BasicCardRule basicCardRule) throws
-            IOException {
-        //通用题卡
-        String cardTemp = cardContent;
-        cardTemp = cardTemp.replaceAll("\\$\\{paperTypeName\\}", paperType);
-        //随机生成试卷条码并将图片转成base64
-        if (Objects.nonNull(paperType)) {
-            cardTemp = cardTemp.replaceAll("\\$\\{paperType\\}", GoogleBarCodeUtil.createBarCode(SystemConstant.convertPaperType(paperType), false));
-        }
-        if (Objects.nonNull(basicCardRule) && Objects.nonNull(basicCardRule.getExtendFields())) {
-            JSONArray jsonObjectExtend = (JSONArray) JSONArray.parse(basicCardRule.getExtendFields());//扩展字段
-            if (Objects.nonNull(jsonObjectExtend)) {
-                int i = 0;
-                while (i < jsonObjectExtend.size()) {
-                    JSONObject object = (JSONObject) jsonObjectExtend.get(i);
-                    cardTemp = cardTemp.replaceAll("\\$\\{" + object.get("code") + "\\}", "");
-                    i++;
-                }
-            }
-        }
-        cardTemp = cardTemp.replaceAll("\\$\\{examDate\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{examTime\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{ticketNumber\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{siteNumber\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{paperTypeName\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{studentCode\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{studentName\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{courseName\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{courseCode\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{examPlace\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{examRoom\\}", "");
-        cardTemp = cardTemp.replaceAll("\\$\\{paperNumber\\}", "");
-
-        //通用题卡生成卷袋贴条码
-        String packageCodeImg = GoogleBarCodeUtil.createBarCode(packageCode, false);
-        cardTemp = cardTemp.replaceAll("\\$\\{packageCodeDom\\}", "<img src='" + "data:image/png;base64," + packageCodeImg + "'><p>" + packageCode + "</p>");
-
-        return printCommonService.saveAttachmentPdfFromHtml(packageCode + paperType, cardTemp, userId, cardPdfList, fileTempList);
-    }
-
-    /**
-     * 通用题卡html
-     *
-     * @param examCard          examCard
-     * @param paperType         卷型
-     * @param basicCardRule     题卡规则
-     * @param backupPackageCode 备用题卡条码号
-     */
-    public String replaceBackupCardHtmlParam(ExamCard examCard, String paperType, BasicCardRule basicCardRule, String backupPackageCode) {
-        String htmlContent = examCard.getHtmlContent();
-        // 替换条码参数
-        htmlContent = htmlContent.replaceAll("<img src=\"data:image/png;base64,\\$\\{examNumber\\}\">", "");
-        htmlContent = htmlContent.replaceAll("\\$\\{examNumberStr\\}", "");
-
-        //替换卷型参数
-        htmlContent = htmlContent.replaceAll("\\$\\{paperTypeName\\}", StringUtils.isBlank(paperType) ? "" : paperType);
-        //替换卷型条码(base64)
-        if (Objects.nonNull(paperType)) {
-            htmlContent = htmlContent.replaceAll("\\$\\{paperType\\}", GoogleBarCodeUtil.createBarCode(SystemConstant.convertPaperType(paperType), false));
-        }
-        // 替换考生变量参数
-        if (Objects.nonNull(basicCardRule) && Objects.nonNull(basicCardRule.getExtendFields())) {
-            JSONArray jsonObjectRequired = (JSONArray) JSONArray.parse(basicCardRule.getRequiredFields());//必选字段
-            if (Objects.nonNull(jsonObjectRequired)) {
-                int i = 0;
-                while (i < jsonObjectRequired.size()) {
-                    JSONObject object = (JSONObject) jsonObjectRequired.get(i);
-                    htmlContent = htmlContent.replaceAll("\\$\\{" + object.get("code") + "\\}", "");
-                    i++;
-                }
-            }
-
-            JSONArray jsonObjectExtend = (JSONArray) JSONArray.parse(basicCardRule.getExtendFields());//扩展字段
-            if (Objects.nonNull(jsonObjectExtend)) {
-                int i = 0;
-                while (i < jsonObjectExtend.size()) {
-                    JSONObject object = (JSONObject) jsonObjectExtend.get(i);
-                    htmlContent = htmlContent.replaceAll("\\$\\{" + object.get("code") + "\\}", "");
-                    i++;
-                }
-            }
-        }
-
-        if (StringUtils.isNotBlank(backupPackageCode)) {
-            //通用题卡生成卷袋贴条码
-            String packageCodeImg = GoogleBarCodeUtil.createBarCode(backupPackageCode, false);
-            // 上传通卡
-            if (CardCreateMethodEnum.UPLOAD.equals(examCard.getCreateMethod())) {
-                if (htmlContent.contains("<div class=\"page-box page-box-0\">")) {
-                    String packageCodeDiv = "<div class=\"page-box page-box-0\"><div class=\"package-number\" style=\"position: absolute;width: 200px;height: 40px;top: 10px;right: 25%;margin-left: -100px;text-align: center;z-index: 99;\"><img src=\"data:image/png;base64," + packageCodeImg + "\" style=\"display: block; height: 28px; width: 100%\" /><p style=\"line-height: 1; font-size: 12px; margin: 0;\">" + backupPackageCode + "</p></div>";
-                    htmlContent = htmlContent.replaceAll("<div class=\"page-box page-box-0\">", packageCodeDiv);
-                } else if (htmlContent.contains("<div class=\"page-box page-box-A3 page-box-0\">")) {
-                    String packageCodeDiv = "<div class=\"page-box page-box-A3 page-box-0\"><div class=\"package-number\" style=\"position: absolute;width: 200px;height: 40px;top: 10px;right: 25%;margin-left: -100px;text-align: center;z-index: 99;\"><img src=\"data:image/png;base64," + packageCodeImg + "\" style=\"display: block; height: 28px; width: 100%\" /><p style=\"line-height: 1; font-size: 12px; margin: 0;\">" + backupPackageCode + "</p></div>";
-                    htmlContent = htmlContent.replaceAll("<div class=\"page-box page-box-A3 page-box-0\">", packageCodeDiv);
-                } else if (htmlContent.contains("<div class=\"page-box page-box-A3 page-box-0 page-box-less\">")) {
-                    String packageCodeDiv = "<div class=\"page-box page-box-A3 page-box-0 page-box-less\"><div class=\"package-number\" style=\"position: absolute;width: 200px;height: 40px;top: 10px;right: 25%;margin-left: -100px;text-align: center;z-index: 99;\"><img src=\"data:image/png;base64," + packageCodeImg + "\" style=\"display: block; height: 28px; width: 100%\" /><p style=\"line-height: 1; font-size: 12px; margin: 0;\">" + backupPackageCode + "</p></div>";
-                    htmlContent = htmlContent.replaceAll("<div class=\"page-box page-box-A3 page-box-0 page-box-less\">", packageCodeDiv);
-                } else if (htmlContent.contains("<div class=\"page-box page-box-A4 page-box-0\">")) {
-                    String packageCodeDiv = "<div class=\"page-box page-box-A4 page-box-0\"><div class=\"package-number\" style=\"position: absolute;width: 200px;height: 40px;top: 10px;right: 25%;margin-left: -100px;text-align: center;z-index: 99;\"><img src=\"data:image/png;base64," + packageCodeImg + "\" style=\"display: block; height: 28px; width: 100%\" /><p style=\"line-height: 1; font-size: 12px; margin: 0;\">" + backupPackageCode + "</p></div>";
-                    htmlContent = htmlContent.replaceAll("<div class=\"page-box page-box-A4 page-box-0\">", packageCodeDiv);
-                } else if (htmlContent.contains("<div class=\"page-box page-box-A4 page-box-0 page-box-less\">")) {
-                    String packageCodeDiv = "<div class=\"page-box page-box-A4 page-box-0 page-box-less\"><div class=\"package-number\" style=\"position: absolute;width: 200px;height: 40px;top: 10px;right: 25%;margin-left: -100px;text-align: center;z-index: 99;\"><img src=\"data:image/png;base64," + packageCodeImg + "\" style=\"display: block; height: 28px; width: 100%\" /><p style=\"line-height: 1; font-size: 12px; margin: 0;\">" + backupPackageCode + "</p></div>";
-                    htmlContent = htmlContent.replaceAll("<div class=\"page-box page-box-A4 page-box-0 page-box-less\">", packageCodeDiv);
-                } else if (htmlContent.contains("<div id=\"preview-page-box-0\" class=\"page-box page-box-A3 page-box-0 page-box-less\">")) {
-                    String packageCodeDiv = "<div id=\"preview-page-box-0\" class=\"page-box page-box-A3 page-box-0 page-box-less\"><div class=\"package-number\" style=\"position: absolute;width: 200px;height: 40px;top: 10px;right: 25%;margin-left: -100px;text-align: center;z-index: 99;\"><img src=\"data:image/png;base64," + packageCodeImg + "\" style=\"display: block; height: 28px; width: 100%\" /><p style=\"line-height: 1; font-size: 12px; margin: 0;\">" + backupPackageCode + "</p></div>";
-                    htmlContent = htmlContent.replaceAll("<div id=\"preview-page-box-0\" class=\"page-box page-box-A3 page-box-0 page-box-less\">", packageCodeDiv);
-                }
-            } else {
-                htmlContent = htmlContent.replaceAll("\\$\\{packageCodeDom\\}", "<img src='" + "data:image/png;base64," + packageCodeImg + "'><p>" + backupPackageCode + "</p>");
-            }
-        } else {
-            htmlContent = htmlContent.replaceAll("\\$\\{packageCodeDom\\}", "");
-        }
-        return htmlContent;
-    }
-
-    public String getPaperType(Long printPlanId, Long examId, String paperNumber) {
-        ExamPrintPlan examPrintPlan = examPrintPlanService.getById(printPlanId);
-        //抽取卷型
-        DrawRuleEnum drawRule = Objects.nonNull(examPrintPlan.getDrawRule()) ? examPrintPlan.getDrawRule() : DrawRuleEnum.ONE;
-        ExamTaskDetail examTaskDetail = examTaskDetailService.getByExamIdAndCourseCodeAndPaperNumber(examId, null, paperNumber);
-        // 单次抽取套数
-        int drawCount = examTaskDetail.getDrawCount().intValue();
-
-        String paperType = null;
-        try {
-            //未曝光卷型
-            String unexposedPaperType = examTaskDetail.getUnexposedPaperType();
-            //已曝光卷型
-            String exposedPaperType = examTaskDetail.getExposedPaperType();
-            String totalPaperType = examTaskDetail.getPaperType();
-            String[] paperTypes;
-            if (drawRule == DrawRuleEnum.ONE) {
-                if (StringUtils.isBlank(unexposedPaperType)) {
-                    throw ExceptionResultEnum.PAPER_ERROR.exception();
-                }
-                paperTypes = unexposedPaperType.split(",");
-                if (paperTypes.length - drawCount < 0) {
-                    throw ExceptionResultEnum.ERROR.exception("可用卷型数量小于抽取数量");
-                }
-            } else {
-                if (StringUtils.isAllBlank(totalPaperType, unexposedPaperType)) {
-                    throw ExceptionResultEnum.PAPER_ERROR.exception();
-                }
-                if (StringUtils.isNotBlank(unexposedPaperType)) {
-                    paperTypes = unexposedPaperType.split(",");
-                    // 未曝光卷型小于抽取数量,则使用所有卷型
-                    if (paperTypes.length - drawCount < 0) {
-                        paperTypes = totalPaperType.split(",");
-                    }
-                } else {
-                    paperTypes = totalPaperType.split(",");
-                }
-            }
-            paperType = randomPaperType(paperTypes, drawCount);
-        } catch (Exception e) {
-            log.error(SystemConstant.LOG_ERROR, e);
-        }
-        return paperType;
-    }
-
-}

+ 1 - 1
distributed-print-business/src/main/resources/mapper/ExamDetailCourseMapper.xml

@@ -102,7 +102,7 @@
         WHERE
             a.school_id = #{schoolId}
                 AND b.print_plan_id = #{printPlanId}
-                AND a.course_code = #{courseCode}
+                AND a.course_id = #{courseId}
                 AND a.paper_number = #{paperNumber}
     </select>
     <select id="listExamDetailByExamIdAndPaperNumber"

+ 0 - 14
distributed-print-business/src/main/resources/mapper/ExamDetailMapper.xml

@@ -814,20 +814,6 @@
                           ed.print_plan_id = epp.id
                         AND epp.category = 'MAKEUP')
     </select>
-    <select id="listByExamIdAndCourseCodeAndPaperNumber"
-            resultType="com.qmth.distributed.print.business.entity.ExamDetail">
-        SELECT
-            b.*
-        FROM
-            exam_detail_course a
-                JOIN
-            exam_detail b ON a.exam_detail_id = b.id
-        WHERE
-            a.school_id = #{schoolId}
-          AND b.exam_id = #{examId}
-          AND a.course_code = #{courseCode}
-          AND a.paper_number = #{paperNumber}
-    </select>
     <select id="listByExamIdAndCourseIdAndPaperNumber"
             resultType="com.qmth.distributed.print.business.entity.ExamDetail">
         SELECT

+ 21 - 49
distributed-print-business/src/main/resources/mapper/ExamStudentMapper.xml

@@ -148,36 +148,6 @@
         </where>
         ) t0;
     </select>
-    <select id="getByStudentId"
-            resultType="com.qmth.distributed.print.business.bean.dto.ExamStudentPdfInfoDto">
-        SELECT a.student_code  studentCode,
-               a.student_name  studentName,
-               a.ticket_number ticketNumber,
-               a.site_number   siteNumber,
-               a.extend_fields extendFields,
-               a.paper_type    paperType,
-               a.college_name  collegeName,
-               a.major_name    majorName,
-               a.clazz_id      clazzId,
-               a.clazz_name    clazzName,
-               a.teach_clazz_name teachClazzName,
-               a.campus_name   campusName,
-               a.attachment_id attachmentId,
-               b.course_code   courseCode,
-               b.course_name   courseName,
-               b.paper_number  paperNumber,
-               c.exam_place    examPlace,
-               c.exam_room     examRoom,
-               su.real_name teacherName
-        FROM exam_student a
-                 JOIN
-             exam_detail_course b ON a.exam_detail_course_id = b.id
-                 JOIN
-             exam_detail c ON b.exam_detail_id = c.id
-                left join
-             sys_user su on a.teacher_id = su.id
-        WHERE a.id = #{id}
-    </select>
     <select id="listExamStudentByPaperNumberAndPaperType"
             resultType="com.qmth.distributed.print.business.bean.dto.ExamStudentCourseClassDto">
         SELECT
@@ -212,25 +182,6 @@
                 AND a.paper_type = b.paper_type
                 AND a.clazz_name = b.clazz_name
     </select>
-    <select id="listUserClass" resultType="java.lang.String">
-        SELECT DISTINCT
-            clazz_name
-        FROM
-            exam_student
-        WHERE
-            school_id = #{schoolId} AND exam_id = #{examId}
-          AND paper_number = #{paperNumber}
-          AND clazz_name IS NOT NULL
-    </select>
-    <select id="listByExamDetailCourseIdLimit1" resultMap="BaseResultMap">
-        <include refid="Base_Column_List"></include>
-        <where>
-             and school_id = #{schoolId}
-            and exam_detail_course_id = #{examDetailCourseId}
-        </where>
-        limit 1
-    </select>
-
     <select id="listByExamDetailCourseIdNotIntMarkStudent" resultType="com.qmth.distributed.print.business.entity.ExamStudent">
         SELECT
             es.*,
@@ -268,4 +219,25 @@
             </if>
         </where>
     </select>
+    <select id="listByExamDetailCourseId" resultType="com.qmth.distributed.print.business.bean.dto.pdf.ExamStudentInfo"
+            parameterType="java.lang.Long">
+        SELECT
+            es.id examStudentId,
+            es.paper_type paperType,
+            es.student_id studentId,
+            bes.student_code studentCode,
+            bes.student_name studentName,
+            bc.code courseCode,
+            bc.name courseName,
+            bes.required_fields requiredFields,
+            bes.extend_fields extendFields
+        FROM
+            exam_student es
+                LEFT JOIN
+            basic_exam_student bes ON es.student_id = bes.id
+                LEFT JOIN
+            basic_course bc ON bes.course_id = bc.id
+        WHERE
+            es.exam_detail_course_id = #{examDetailCourseId}
+    </select>
 </mapper>

+ 8 - 1
distributed-print/install/mysql/upgrade/3.4.0.sql

@@ -15,6 +15,8 @@ ALTER TABLE `mark_task` ADD COLUMN `course_id` BIGINT(20) NULL COMMENT '课程ID
 ALTER TABLE `teach_course` ADD COLUMN `course_id` BIGINT(20) NULL COMMENT '课程ID(basic_course表ID)' AFTER `exam_id`;
 ALTER TABLE `t_p_course` ADD COLUMN `course_id` BIGINT(20) NULL COMMENT '课程ID(basic_course表ID)' AFTER `professional_id`;
 ALTER TABLE `t_b_sync_task` ADD COLUMN `course_id` BIGINT(20) NULL COMMENT '课程ID(basic_course表ID)' AFTER `exam_id`;
+ALTER TABLE `client_status` ADD COLUMN `course_id` BIGINT(20) NULL COMMENT '课程ID(basic_course表ID)' AFTER `print_plan_id`;
+
 
 ALTER TABLE `basic_course` CHANGE COLUMN `org_id` `org_id` BIGINT NULL COMMENT '机构id' ;
 ALTER TABLE `basic_course` DROP INDEX `course_schoolId_code_idx` , ADD UNIQUE INDEX `uq_1` USING BTREE (`school_id`, `teaching_room_id`, `code`);
@@ -88,7 +90,7 @@ update mark_group a left join basic_exam be on a.exam_id = be.id left join basic
 update mark_paper a left join basic_exam be on a.exam_id = be.id left join basic_course bc on be.school_id = bc.school_id and a.course_code = bc.code set a.course_id = bc.id where a.course_id is null;
 update mark_task a left join basic_exam be on a.exam_id = be.id left join basic_course bc on be.school_id = bc.school_id and a.course_code = bc.code set a.course_id = bc.id where a.course_id is null;
 update mark_paper_package a left join basic_exam be on a.exam_id = be.id left join basic_course bc on be.school_id = bc.school_id and a.course_code = bc.code set a.course_id = bc.id where a.course_id is null;
-
+update client_status a set a.course_id = (select bc.id from basic_course bc where a.school_id = bc.school_id and a.course_code = bc.code) where a.course_id is null;
 
 ALTER TABLE `exam_print_plan` DROP COLUMN `third_relate_name`, DROP COLUMN `third_relate_id`;
 ALTER TABLE `exam_student` DROP COLUMN `can_delete`;
@@ -103,6 +105,11 @@ update basic_exam_student bes set bes.teach_class_name = (select btc.clazz_name
 ALTER TABLE `mark_paper` ADD COLUMN `question_status` TINYINT(1) NULL DEFAULT '0' COMMENT '试卷结构是否提交' AFTER `show_object_score`;
 update mark_paper set question_status = group_status;
 
+ALTER TABLE `basic_exam_student`
+    ADD COLUMN `status` VARCHAR(1) NULL DEFAULT 'N' COMMENT '状态,默认N-正常,D-缓考,F-免考,M-缺考,B-违纪' AFTER `class_name`,
+ADD COLUMN `required_fields` MEDIUMTEXT NULL COMMENT '基础字段' AFTER `exam_room`;
+
+
 -- drop table if exists exam_detail_course_paper_type;
 -- drop table if exists basic_template_org;
 -- drop table if exists cloud_user_push_status;

+ 1 - 1
distributed-print/src/main/java/com/qmth/distributed/print/api/ExamTaskQueryController.java

@@ -100,7 +100,7 @@ public class ExamTaskQueryController {
             SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
             ExamTask examTask = examTaskService.getById(examTaskDetail.getId());
             // 校验课程关联考场,是否已经提交打印
-            Boolean isCreate = printCommonService.checkExamDetailStatus(examTask.getSchoolId(), null, examTask.getExamId(), examTask.getCourseCode(), examTask.getPaperNumber());
+            Boolean isCreate = printCommonService.checkExamDetailStatus(examTask.getSchoolId(), null, examTask.getExamId(), examTask.getCourseId(), examTask.getPaperNumber());
             // 校验是否可以提交打印状态
             if (isCreate) {
                 printCommonService.checkExamDataAndCreatePdfTask(examTask.getSchoolId(), examTask.getExamId(), examTask.getCourseId(), examTask.getPaperNumber(), sysUser);

+ 2 - 2
distributed-print/src/main/java/com/qmth/distributed/print/api/client/PrintController.java

@@ -80,13 +80,13 @@ public class PrintController {
     @ApiOperation(value = "试卷打样-标记合格状态")
     @PostMapping("/paper_try/tag_pass")
     public Result paperTryTagPass(@ApiParam(value = "印刷计划ID", required = true) @RequestParam("printPlanId") Long printPlanId,
-                                  @ApiParam(value = "课程代码", required = true) @RequestParam("courseCode") String courseCode,
+                                  @ApiParam(value = "课程ID", required = true) @RequestParam("courseId") Long courseId,
                                   @ApiParam(value = "课程名称", required = true) @RequestParam("courseName") String courseName,
                                   @ApiParam(value = "试卷编号", required = true) @RequestParam("paperNumber") String paperNumber,
                                   @ApiParam(value = "机器码", required = true) @RequestParam("machineCode") String machineCode,
                                   @ApiParam(value = "是否通过", required = true) @RequestParam("isPass") Boolean isPass,
                                   @ApiParam(value = "用户ID", required = true) @RequestParam("userId") Long userId) {
-        Boolean isSuccess = clientService.tagPass(printPlanId, courseCode, courseName, paperNumber, machineCode, isPass, userId);
+        Boolean isSuccess = clientService.tagPass(printPlanId, courseId, courseName, paperNumber, machineCode, isPass, userId);
         return ResultUtil.ok(isSuccess);
     }
 

+ 7 - 14
distributed-print/src/main/java/com/qmth/distributed/print/api/mark/ScanAnswerController.java

@@ -1,19 +1,7 @@
 package com.qmth.distributed.print.api.mark;
 
-import com.qmth.boot.core.exception.ParameterException;
-import com.qmth.teachcloud.common.entity.BasicClazz;
-import com.qmth.teachcloud.mark.entity.MarkStudent;
-import com.qmth.teachcloud.mark.entity.ScanBatch;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.multipart.MultipartFile;
-
 import com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.boot.core.exception.ParameterException;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.SysUser;
 import com.qmth.teachcloud.common.util.Result;
@@ -26,13 +14,18 @@ import com.qmth.teachcloud.mark.bean.papermigrate.PaperMigrateVo;
 import com.qmth.teachcloud.mark.bean.scananswer.AnswerQueryDomain;
 import com.qmth.teachcloud.mark.bean.scananswer.SheetUploadVo;
 import com.qmth.teachcloud.mark.dto.refix.AnswerRefixDomain;
+import com.qmth.teachcloud.mark.entity.MarkStudent;
+import com.qmth.teachcloud.mark.entity.ScanBatch;
 import com.qmth.teachcloud.mark.service.MarkStudentService;
 import com.qmth.teachcloud.mark.service.ScanBatchService;
 import com.qmth.teachcloud.mark.service.ScanPaperService;
 import com.qmth.teachcloud.mark.service.ScanRefixBatchService;
-
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 /**
  * <p>

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/examRule/CodeName.java → teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/examRule/CodeName.java

@@ -1,4 +1,4 @@
-package com.qmth.distributed.print.business.bean.examRule;
+package com.qmth.teachcloud.common.bean.examRule;
 
 /**
  * basic_exam_rule表中sign_scope、package_scope字段对应实体

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/examRule/CodeNameEnable.java → teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/examRule/CodeNameEnable.java

@@ -1,4 +1,4 @@
-package com.qmth.distributed.print.business.bean.examRule;
+package com.qmth.teachcloud.common.bean.examRule;
 
 /**
  * basic_card_rule表中required_fields、extend_fields字段对应实体

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/examRule/CodeNameEnableDisabled.java → teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/examRule/CodeNameEnableDisabled.java

@@ -1,4 +1,4 @@
-package com.qmth.distributed.print.business.bean.examRule;
+package com.qmth.teachcloud.common.bean.examRule;
 
 /**
  * basic_exam_rule表中required_fields、extend_fields字段对应实体

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/examRule/CodeNameEnableRate.java → teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/examRule/CodeNameEnableRate.java

@@ -1,4 +1,4 @@
-package com.qmth.distributed.print.business.bean.examRule;
+package com.qmth.teachcloud.common.bean.examRule;
 
 /**
  * basic_template表中display_range字段对应实体

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/examRule/CodeNameEnableValue.java → teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/examRule/CodeNameEnableValue.java

@@ -1,4 +1,4 @@
-package com.qmth.distributed.print.business.bean.examRule;
+package com.qmth.teachcloud.common.bean.examRule;
 
 /**
  * exam_student表中required_fields、extend_fields字段对应实体

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/examRule/FieldsDto.java → teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/examRule/FieldsDto.java

@@ -1,4 +1,4 @@
-package com.qmth.distributed.print.business.bean.examRule;
+package com.qmth.teachcloud.common.bean.examRule;
 
 import io.swagger.annotations.ApiModelProperty;
 

+ 58 - 1
teachcloud-common/src/main/java/com/qmth/teachcloud/common/entity/BasicExamStudent.java

@@ -1,10 +1,21 @@
 package com.qmth.teachcloud.common.entity;
 
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.qmth.teachcloud.common.base.BaseEntity;
+import com.qmth.teachcloud.common.bean.examRule.CodeNameEnableValue;
+import com.qmth.teachcloud.common.enums.BasicExamStudentStatusEnum;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import org.apache.batik.transcoder.TranscodingHints;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -14,7 +25,7 @@ import io.swagger.annotations.ApiModelProperty;
  * @author CaoZixuan
  * @since 2024-02-22
  */
-@ApiModel(value="BasicExamStudent对象", description="考生字典表")
+@ApiModel(value = "BasicExamStudent对象", description = "考生字典表")
 public class BasicExamStudent extends BaseEntity {
 
     private static final long serialVersionUID = 1L;
@@ -81,9 +92,23 @@ public class BasicExamStudent extends BaseEntity {
     @ApiModelProperty("考场(考试教室)")
     private String examRoom;
 
+    @ApiModelProperty("基础字段")
+    private String requiredFields;
+
     @ApiModelProperty("扩展字段")
     private String extendFields;
 
+    @ApiModelProperty("状态")
+    private BasicExamStudentStatusEnum status;
+
+    @ApiModelProperty("基础字段集合")
+    @TableField(exist = false)
+    private List<CodeNameEnableValue> requiredFieldList;
+
+    @ApiModelProperty("扩展字段集合")
+    @TableField(exist = false)
+    private List<CodeNameEnableValue> extendFieldList;
+
     public Long getSchoolId() {
         return schoolId;
     }
@@ -236,6 +261,14 @@ public class BasicExamStudent extends BaseEntity {
         this.examRoom = examRoom;
     }
 
+    public String getRequiredFields() {
+        return requiredFields;
+    }
+
+    public void setRequiredFields(String requiredFields) {
+        this.requiredFields = requiredFields;
+    }
+
     public String getExtendFields() {
         return extendFields;
     }
@@ -243,4 +276,28 @@ public class BasicExamStudent extends BaseEntity {
     public void setExtendFields(String extendFields) {
         this.extendFields = extendFields;
     }
+
+    public BasicExamStudentStatusEnum getStatus() {
+        return status;
+    }
+
+    public void setStatus(BasicExamStudentStatusEnum status) {
+        this.status = status;
+    }
+
+    public List<CodeNameEnableValue> getRequiredFieldList() {
+        return StringUtils.isNotBlank(this.requiredFields) ? JSON.parseArray(this.requiredFields, CodeNameEnableValue.class) : Collections.emptyList();
+    }
+
+    public void setRequiredFieldList(List<CodeNameEnableValue> requiredFieldList) {
+        this.requiredFieldList = requiredFieldList;
+    }
+
+    public List<CodeNameEnableValue> getExtendFieldList() {
+        return StringUtils.isNotBlank(this.extendFields) ? JSON.parseArray(this.extendFields, CodeNameEnableValue.class) : Collections.emptyList();
+    }
+
+    public void setExtendFieldList(List<CodeNameEnableValue> extendFieldList) {
+        this.extendFieldList = extendFieldList;
+    }
 }

+ 42 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/enums/BasicExamStudentStatusEnum.java

@@ -0,0 +1,42 @@
+package com.qmth.teachcloud.common.enums;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 考生状态
+ */
+public enum BasicExamStudentStatusEnum {
+
+    N("正常"),
+    D("缓考"),
+    F("免考"),
+    M("缺考"),
+    B("违纪");
+
+    BasicExamStudentStatusEnum(String name) {
+        this.name = name;
+    }
+
+    private String name;
+
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * @return
+     */
+    public static List<EnumResult> listTypes() {
+        List<EnumResult> list = new ArrayList<EnumResult>();
+        for (BasicExamStudentStatusEnum value : BasicExamStudentStatusEnum.values()) {
+            EnumResult result = new EnumResult();
+            result.setCode(value.name());
+            result.setName(value.getName());
+            result.setOrdinal(value.ordinal());
+            list.add(result);
+        }
+        return list;
+    }
+
+}