瀏覽代碼

3.4.2 AB卷开关

xiaofei 8 月之前
父節點
當前提交
357904987a

+ 6 - 6
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/ExamTaskDetail.java

@@ -42,8 +42,8 @@ public class ExamTaskDetail extends BaseEntity implements Serializable {
     @TableField("paper_type")
     private String paperType;
 
-    @TableField("draw_count")
-    private Integer drawCount;
+    @TableField("open_ab")
+    private Boolean openAb;
     /**
      * [
      * {
@@ -138,12 +138,12 @@ public class ExamTaskDetail extends BaseEntity implements Serializable {
         this.paperType = paperType;
     }
 
-    public Integer getDrawCount() {
-        return drawCount;
+    public Boolean getOpenAb() {
+        return openAb;
     }
 
-    public void setDrawCount(Integer drawCount) {
-        this.drawCount = drawCount;
+    public void setOpenAb(Boolean openAb) {
+        this.openAb = openAb;
     }
 
     public String getPaperAttachmentIds() {

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

@@ -195,7 +195,7 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
         // 更新考生关联类型
         ExamTaskDetail examTaskDetail = this.getByExamTaskId(newExamTask.getId());
         List<String> types = Arrays.asList(paperParam.getRelatePaperType().split(","));
-        int drawCount = examTaskDetail.getDrawCount().intValue();
+        int drawCount = examTaskDetail.getOpenAb() ? 2 : 1;
         if (drawCount - types.size() != 0) {
             throw ExceptionResultEnum.ERROR.exception("关联卷型与设置数量不一致");
         }
@@ -293,7 +293,7 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
                 .set(ExamTaskDetail::getPaperAttachmentIds, examTaskDetail.getPaperAttachmentIds())
                 .set(ExamTaskDetail::getUnexposedPaperType, unexposedPaperType)
                 .set(ExamTaskDetail::getRelatePaperType, null)
-                .set(ExamTaskDetail::getDrawCount, examTaskDetail.getDrawCount())
+                .set(ExamTaskDetail::getOpenAb, examTaskDetail.getOpenAb())
                 .eq(ExamTaskDetail::getExamTaskId, examTaskDetail.getExamTaskId());
         this.update(examTaskDetailUpdateWrapper);
 

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

@@ -2245,7 +2245,8 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
         }
 
         String[] paperTypes = examTaskDetail.getPaperType().split(",");
-        if (paperTypes.length - examTaskDetail.getDrawCount() < 0) {
+        int drawCount = examTaskDetail.getOpenAb() ? 2 : 1;
+        if (paperTypes.length - drawCount < 0) {
             throw ExceptionResultEnum.ERROR.exception("单次抽卷数量不能大于卷型数量");
         }
 

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

@@ -309,10 +309,11 @@ public class PdfTaskLogicServiceImpl implements PdfTaskLogicService {
                     Map<String, BasicAttachment> stringBasicAttachmentMap = new HashMap<>();
                     ExamStudentInfo examStudentInfo = new ExamStudentInfo();
                     examStudentInfo.setCourseCode(basicCourse.getCode());
+                    int drawCount = examTaskDetail.getOpenAb() ? 2 : 1;
                     int i = 0;
                     while (i < examDetailCourse.getTotalSubjects()) {
                         int seq = atomicInteger.getAndIncrement();
-                        int mod = seq % examTaskDetail.getDrawCount();
+                        int mod = seq % drawCount;
                         String tempPaperType = paperTypes[mod];
                         BasicAttachment basicAttachment = createPdfUtil.examStudentHtml(examCardMap.get(tempPaperType).getHtmlContent(), examStudentInfo, tempPaperType, examDetail, tbTaskPdf.getCreateId(), createPdfDto.getCardPdfList(), createPdfDto.getFileTempList(), basicCardRule);
 

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

@@ -336,7 +336,7 @@ public class CreatePdfUtil {
         Set<String> valueSet = new HashSet<>();
         for (List<CodeNameEnableValue> codeNameEnableValues : examStudentFieldSet) {
             Set<String> collect = codeNameEnableValues.stream().filter(m -> code.equals(m.getCode()) && StringUtils.isNotBlank(m.getValue())).map(m -> m.getValue()).collect(Collectors.toSet());
-            if(CollectionUtils.isEmpty(collect)){
+            if (CollectionUtils.isEmpty(collect)) {
                 continue;
             }
             CollectionUtils.addAll(valueSet, collect);
@@ -563,9 +563,9 @@ public class CreatePdfUtil {
                                            Long userId, List<PdfDto> examStudentPdfList, List<File> fileTempList, BasicCardRule basicCardRule) throws IOException {
         if (basicCardRule != null) {
             if (ExamNumberStyleEnum.PRINT.equals(basicCardRule.getExamNumberStyle())) {
-                if(examStudent == null || StringUtils.isBlank(examStudent.getStudentCode())){
-                    studentHtml = studentHtml.replaceAll("<img src=\"data:image/png;base64,\\$\\{studentCodeBarcode\\}\">",  "");
-                    studentHtml = studentHtml.replaceAll("<img src=\"data:image/png;base64,\\$\\{examNumber\\}\">",  "");
+                if (examStudent == null || StringUtils.isBlank(examStudent.getStudentCode())) {
+                    studentHtml = studentHtml.replaceAll("<img src=\"data:image/png;base64,\\$\\{studentCodeBarcode\\}\">", "");
+                    studentHtml = studentHtml.replaceAll("<img src=\"data:image/png;base64,\\$\\{examNumber\\}\">", "");
                 } else {
                     studentHtml = studentHtml.replaceAll("\\$\\{studentCodeBarcode\\}", examStudent != null && examStudent.getStudentCode() != null ? GoogleBarCodeUtil.createBarCode(examStudent.getStudentCode(), false) : "");
                     studentHtml = studentHtml.replaceAll("\\$\\{examNumber\\}", examStudent != null && examStudent.getStudentCode() != null ? GoogleBarCodeUtil.createBarCode(examStudent.getStudentCode(), false) : "");
@@ -719,7 +719,7 @@ public class CreatePdfUtil {
         DrawRuleEnum drawRule = Objects.nonNull(examPrintPlan.getDrawRule()) ? examPrintPlan.getDrawRule() : DrawRuleEnum.ONE;
         ExamTaskDetail examTaskDetail = examTaskDetailService.getByExamIdAndCourseIdAndPaperNumber(examId, null, paperNumber);
         // 单次抽取套数
-        int drawCount = examTaskDetail.getDrawCount().intValue();
+        int drawCount = examTaskDetail.getOpenAb() ? 2 : 1;
 
         String paperType = null;
         try {

+ 5 - 0
distributed-print-business/src/main/resources/db/log/xf.sql

@@ -0,0 +1,5 @@
+-- 2024-10-10
+ALTER TABLE `exam_task_detail` CHANGE COLUMN `draw_count` `open_ab` TINYINT(1) NULL DEFAULT 0 COMMENT '是否开启AB卷' ;
+update exam_task_detail set open_ab = (case open_ab when 1 then 0 else 1 end);
+
+ALTER TABLE `basic_print_config` ADD COLUMN `open_ab` TINYINT(1) NULL DEFAULT 0 COMMENT '是否开启AB卷' AFTER `card_rule_id`;

+ 14 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/entity/BasicPrintConfig.java

@@ -75,6 +75,12 @@ public class BasicPrintConfig extends BaseEntity implements Serializable {
     @TableField("card_rule_id")
     private Long cardRuleId;
 
+    /**
+     * 是否开启AB卷
+     */
+    @TableField("open_ab")
+    private Boolean openAb;
+
     /**
      * 试卷、题卡
      */
@@ -184,6 +190,14 @@ public class BasicPrintConfig extends BaseEntity implements Serializable {
         this.cardRuleId = cardRuleId;
     }
 
+    public Boolean getOpenAb() {
+        return openAb;
+    }
+
+    public void setOpenAb(Boolean openAb) {
+        this.openAb = openAb;
+    }
+
     public String getPrintContent() {
         return printContent;
     }