Browse Source

3.2.5 签到表改造,多卷型同步bug修复

xiaofei 2 years ago
parent
commit
d2b7da7ebb
22 changed files with 591 additions and 310 deletions
  1. 11 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/PdfSignDto.java
  2. 27 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/BasicTemplate.java
  3. 15 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/ExamTaskSync.java
  4. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamDetailCourseMapper.java
  5. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamStudentMapper.java
  6. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamDetailCourseService.java
  7. 1 3
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamStudentService.java
  8. 1 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamTaskSyncService.java
  9. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/PrintCommonService.java
  10. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicTemplateServiceImpl.java
  11. 53 52
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/DataSyncServiceImpl.java
  12. 2 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamDetailCourseServiceImpl.java
  13. 2 6
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamStudentServiceImpl.java
  14. 3 4
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskSyncServiceImpl.java
  15. 2 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/PrintCommonServiceImpl.java
  16. 127 156
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/CreatePdfUtil.java
  17. 105 47
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/CreatePrintPdfUtil.java
  18. 176 22
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/PdfFillUtils.java
  19. 13 1
      distributed-print-business/src/main/resources/db/log/脚本-xiaof.sql
  20. 41 2
      distributed-print-business/src/main/resources/mapper/ExamDetailCourseMapper.xml
  21. 5 4
      distributed-print-business/src/main/resources/mapper/ExamPaperStructureMapper.xml
  22. 2 1
      distributed-print-business/src/main/resources/mapper/ExamStudentMapper.xml

+ 11 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/PdfSignDto.java

@@ -33,6 +33,11 @@ public class PdfSignDto {
      */
     private List<Map<String, String>> studentPlate;
 
+    /**
+     * 文字描述信息
+     */
+    private String textDesc;
+
 
     public String getTitle() {
         return title;
@@ -74,5 +79,11 @@ public class PdfSignDto {
         this.studentPlate = studentPlate;
     }
 
+    public String getTextDesc() {
+        return textDesc;
+    }
 
+    public void setTextDesc(String textDesc) {
+        this.textDesc = textDesc;
+    }
 }

+ 27 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/BasicTemplate.java

@@ -7,6 +7,7 @@ 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.enums.ClassifyEnum;
+import com.sun.org.apache.xpath.internal.operations.Bool;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
@@ -62,6 +63,16 @@ public class BasicTemplate extends BaseEntity implements Serializable {
      * 0-禁用,1-启用
      */
     private Boolean enable = true;
+
+    /**
+     * 考生信息是否双列显示
+     */
+    private Boolean diallel;
+
+    /**
+     * 文字说明
+     */
+    private String textDesc;
     /**
      * 备注
      */
@@ -142,6 +153,22 @@ public class BasicTemplate extends BaseEntity implements Serializable {
         this.enable = enable;
     }
 
+    public Boolean getDiallel() {
+        return diallel;
+    }
+
+    public void setDiallel(Boolean diallel) {
+        this.diallel = diallel;
+    }
+
+    public String getTextDesc() {
+        return textDesc;
+    }
+
+    public void setTextDesc(String textDesc) {
+        this.textDesc = textDesc;
+    }
+
     public String getRemark() {
         return remark;
     }

+ 15 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/ExamTaskSync.java

@@ -55,6 +55,11 @@ public class ExamTaskSync implements Serializable {
     @TableField("paper_number")
     private String paperNumber;
 
+    /**
+     * 试卷类型
+     */
+    @TableField("paper_type")
+    private String paperType;
     /**
      * 机构代码
      */
@@ -93,12 +98,13 @@ public class ExamTaskSync implements Serializable {
     public ExamTaskSync() {
     }
 
-    public ExamTaskSync(Long schoolId, Long examId, String courseCode, String paperNumber, String orgCode, Integer thirdRelateId, ExamTaskSyncStatusEnum syncStatus, Long syncUserId, Long syncStartTime, Long syncEndTime) {
+    public ExamTaskSync(Long schoolId, Long examId, String courseCode, String paperNumber, String paperType, String orgCode, Integer thirdRelateId, ExamTaskSyncStatusEnum syncStatus, Long syncUserId, Long syncStartTime, Long syncEndTime) {
         this.id = SystemConstant.getDbUuid();
         this.schoolId = schoolId;
         this.examId = examId;
         this.courseCode = courseCode;
         this.paperNumber = paperNumber;
+        this.paperType = paperType;
         this.orgCode = orgCode;
         this.thirdRelateId = thirdRelateId;
         this.syncStatus = syncStatus;
@@ -147,6 +153,14 @@ public class ExamTaskSync implements Serializable {
         this.paperNumber = paperNumber;
     }
 
+    public String getPaperType() {
+        return paperType;
+    }
+
+    public void setPaperType(String paperType) {
+        this.paperType = paperType;
+    }
+
     public String getOrgCode() {
         return orgCode;
     }

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

@@ -38,7 +38,7 @@ public interface ExamDetailCourseMapper extends BaseMapper<ExamDetailCourse> {
 
     List<ExamDetailCourse> listByAndCourseCodeAndPaperNumber(@Param("schoolId") Long schoolId,@Param("examId") Long examId,@Param("courseCode") String courseCode,@Param("paperNumber") String paperNumber);
 
-    List<ExamDetailCourseDto> listByPrintPlanIdAndExamTaskId(@Param("printPlanIds") List<Long> printPlanIds, @Param("examTaskId") Long examTaskId);
+    List<ExamDetailCourseDto> listByPrintPlanIdAndExamTaskId(@Param("printPlanIds") List<Long> printPlanIds, @Param("examTaskId") Long examTaskId, @Param("paperType") String paperType);
 
     IPage<SyncExamTaskDto> listSyncCourseByPrintPlanId(@Param("ipage") Page<SyncExamTaskDto> ipage, @Param("semesterId") Long semesterId, @Param("examId") Long examId, @Param("roomOrgIds") Set<Long> roomOrgIds, @Param("orgIds") Set<Long> orgIds, @Param("cardType") SyncCardTypeEnum cardType, @Param("syncStatus") ExamTaskSyncStatusEnum syncStatus, @Param("courseCode") String courseCode, @Param("paperNumber") String paperNumber, @Param("startTime") Long startTime, @Param("endTime") Long endTime);
 }

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

@@ -53,7 +53,7 @@ public interface ExamStudentMapper extends BaseMapper<ExamStudent> {
 
     List<ExamStudentCourseClassDto> listExamStudentByPaperNumberAndPaperType(@Param("batchId") Long batchId, @Param("paperNumber") String paperNumber, @Param("paperType") String paperType);
 
-    List<SyncExamStudentDto> listStudentByExamDetailCourseId(@Param("examDetailCourseId") Long examDetailCourseId);
+    List<SyncExamStudentDto> listStudentByExamDetailCourseId(@Param("examDetailCourseId") Long examDetailCourseId, @Param("paperType") String paperType);
 
     List<String> listTicketNumberBySemesterId(@Param("semesterId") String semesterId, @Param("examId") Long examId);
 }

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

@@ -39,5 +39,5 @@ public interface ExamDetailCourseService extends IService<ExamDetailCourse> {
 
     IPage<SyncExamTaskDto> listSyncCourseByPrintPlanId(Long semesterId, Long examId, Long orgId, SyncCardTypeEnum cardType, ExamTaskSyncStatusEnum syncStatus, String courseCode, String paperNumber, Long startTime, Long endTime, Integer pageNumber, Integer pageSize);
 
-    List<ExamDetailCourseDto> listByPrintPlanIdAndExamTaskId(List<Long> printPlanIds, Long examTaskId);
+    List<ExamDetailCourseDto> listByPrintPlanIdAndExamTaskId(List<Long> printPlanIds, Long examTaskId, String paperType);
 }

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

@@ -5,10 +5,8 @@ import com.qmth.distributed.print.business.bean.dto.ExamDetailCourseDto;
 import com.qmth.distributed.print.business.bean.dto.ExamStudentCourseDto;
 import com.qmth.distributed.print.business.bean.dto.ExamStudentPdfInfoDto;
 import com.qmth.distributed.print.business.bean.dto.SyncExamStudentDto;
-import com.qmth.distributed.print.business.entity.ExamDetailCourse;
 import com.qmth.distributed.print.business.entity.ExamStudent;
 import com.qmth.teachcloud.common.entity.BasicCollege;
-import com.qmth.teachcloud.common.entity.SysOrg;
 
 import java.util.List;
 import java.util.Map;
@@ -46,7 +44,7 @@ public interface ExamStudentService extends IService<ExamStudent> {
 
     List<Map> listStudentScoreSync(Long schoolId, String studentCode, String examNumber, String subjectCode);
 
-    List<SyncExamStudentDto> listStudentByExamDetailCourseId(List<ExamDetailCourseDto> examDetailCourseList);
+    List<SyncExamStudentDto> listStudentByExamDetailCourseId(List<ExamDetailCourseDto> examDetailCourseList, String paperType);
 
     List<String> listTicketNumberBySemesterId(String semesterId, Long examId);
 }

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

@@ -1,7 +1,6 @@
 package com.qmth.distributed.print.business.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
-import com.qmth.distributed.print.business.bean.dto.SyncExamTaskDto;
 import com.qmth.distributed.print.business.entity.ExamTaskSync;
 
 /**
@@ -11,5 +10,5 @@ import com.qmth.distributed.print.business.entity.ExamTaskSync;
  */
 public interface ExamTaskSyncService extends IService<ExamTaskSync> {
 
-    ExamTaskSync getBySchoolIdAndOrgCodeAndPaperNumber(Long schoolId, Long examId, String orgCode, String paperNumber);
+    ExamTaskSync getBySchoolIdAndOrgCodeAndPaperNumberAndPaperType(Long schoolId, Long examId, String orgCode, String paperNumber, String paperType);
 }

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

@@ -50,7 +50,7 @@ public interface PrintCommonService {
      */
     public BasicAttachment saveAttachmentPdf(ClassifyEnum classifyEnum, ExamDetail examDetail, BasicAttachment basicAttachment, List<PdfDto> pdfList, Integer printCount, Integer sequence, List<File> fileTempList) throws IOException, DocumentException;
 
-    public void saveAttachmentSignPdf(PdfSignDto pdfFillDto, ExamDetail examDetail, List<PdfDto> pdfList, Integer printCount, List<File> fileTempList);
+    public void saveAttachmentSignPdf(PdfSignDto pdfFillDto, ExamDetail examDetail, List<PdfDto> pdfList, Integer printCount, List<File> fileTempList, Boolean diallel);
 
     /**
      * 保存html附件

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

@@ -280,7 +280,7 @@ public class BasicTemplateServiceImpl extends ServiceImpl<BasicTemplateMapper, B
             // 签到表
             if (ClassifyEnum.SIGN.equals(classifyEnum)) {
                 if (StringUtils.isBlank(basicTemplate.getPreviewPath())) {
-                    JSONObject json = PdfFillUtils.parseSignTempData(basicTemplate.getDisplayRange(), destUrl);
+                    JSONObject json = PdfFillUtils.parseSignTempData(basicTemplate, destUrl);
                     basicTemplate.setPreviewPath(JSON.toJSONString(json));
                     basicTemplateMapper.updateById(basicTemplate);
                 }

+ 53 - 52
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/DataSyncServiceImpl.java

@@ -148,66 +148,67 @@ public class DataSyncServiceImpl implements DataSyncService {
 
                     Long examTaskId = Long.valueOf(param.getExamTaskId());
                     ExamTask examTask = examTaskService.getById(examTaskId);
-                    ExamTaskSync examTaskSync = examTaskSyncService.getBySchoolIdAndOrgCodeAndPaperNumber(schoolId, examTask.getExamId(), orgCode, examTask.getPaperNumber());
-                    if (examTaskSync != null && ExamTaskSyncStatusEnum.STARTING.equals(examTaskSync.getSyncStatus())) {
-                        throw ExceptionResultEnum.ERROR.exception("其它任务中该课程正在同步中,请刷新列表查看最新状态");
-                    }
-                    ExamTaskSyncStatusEnum syncStatus = ExamTaskSyncStatusEnum.STARTING;
-
-                    if (examTaskSync == null) {
-                        examTaskSync = new ExamTaskSync(schoolId, examTask.getExamId(), examTask.getCourseCode(), examTask.getPaperNumber(), orgCode, Math.toIntExact(thirdRelateId), syncStatus, sysUser.getId(), System.currentTimeMillis(), null);
-                    } else {
-                        examTaskSync.setThirdRelateId(Math.toIntExact(thirdRelateId));
-                        examTaskSync.setSyncStatus(syncStatus);
-                        examTaskSync.setSyncStartTime(System.currentTimeMillis());
-                        examTaskSync.setSyncUserId(sysUser.getId());
-                        examTaskSync.setErrorMsg(null);
-                    }
-                    examTaskSyncService.saveOrUpdate(examTaskSync);
-
-                    String errorMsg = null;
-                    ExamTaskSyncStatusEnum taskSyncStatusEnum = null;
-                    try {
-                        List<Long> printPlanIds = Arrays.asList(param.getPrintPlanIds().split(",")).stream().map(m -> Long.parseLong(m)).collect(Collectors.toList());
-                        List<ExamDetailCourseDto> examDetailCourseList = examDetailCourseService.listByPrintPlanIdAndExamTaskId(printPlanIds, examTaskId);
-                        // 同步考生
-                        List<SyncExamStudentDto> syncExamStudentDtoList = examStudentService.listStudentByExamDetailCourseId(examDetailCourseList);
-
-                        // 没有考生就单独推送科目
-                        if (CollectionUtils.isEmpty(syncExamStudentDtoList)) {
-                            for (ExamDetailCourseDto examDetailCourseDto : examDetailCourseList) {
-                                saveSubject(schoolId, thirdRelateId, examDetailCourseDto.getCourseCode(), examDetailCourseDto.getCourseName(), examDetailCourseDto.getSequence(), examDetailCourseDto.getPaperType());
-                            }
+
+                    for (String paperType : param.getPaperType().split(",")) {
+                        ExamTaskSync examTaskSync = examTaskSyncService.getBySchoolIdAndOrgCodeAndPaperNumberAndPaperType(schoolId, examTask.getExamId(), orgCode, examTask.getPaperNumber(), paperType);
+                        if (examTaskSync != null && ExamTaskSyncStatusEnum.STARTING.equals(examTaskSync.getSyncStatus())) {
+                            throw ExceptionResultEnum.ERROR.exception("任务中有课程正在同步中,请刷新列表查看最新状态");
+                        }
+                        ExamTaskSyncStatusEnum syncStatus = ExamTaskSyncStatusEnum.STARTING;
+
+                        if (examTaskSync == null) {
+                            examTaskSync = new ExamTaskSync(schoolId, examTask.getExamId(), examTask.getCourseCode(), examTask.getPaperNumber(), paperType, orgCode, Math.toIntExact(thirdRelateId), syncStatus, sysUser.getId(), System.currentTimeMillis(), null);
                         } else {
-                            long count = syncExamStudentDtoList.stream().filter(m -> StringUtils.isBlank(m.getPaperType())).count();
-                            if (count > 0) {
-                                throw ExceptionResultEnum.ERROR.exception("部分学生未关联试卷类型,数量[" + count + "]");
-                            }
-                            // 同步考生
-                            saveStudent(schoolId, thirdRelateId, syncExamStudentDtoList);
+                            examTaskSync.setThirdRelateId(Math.toIntExact(thirdRelateId));
+                            examTaskSync.setSyncStatus(syncStatus);
+                            examTaskSync.setSyncStartTime(System.currentTimeMillis());
+                            examTaskSync.setSyncUserId(sysUser.getId());
+                            examTaskSync.setErrorMsg(null);
                         }
+                        examTaskSyncService.saveOrUpdate(examTaskSync);
+
+                        String errorMsg = null;
+                        ExamTaskSyncStatusEnum taskSyncStatusEnum = null;
+                        try {
+                            List<Long> printPlanIds = Arrays.asList(param.getPrintPlanIds().split(",")).stream().map(m -> Long.parseLong(m)).collect(Collectors.toList());
+                            List<ExamDetailCourseDto> examDetailCourseList = examDetailCourseService.listByPrintPlanIdAndExamTaskId(printPlanIds, examTaskId, paperType);
+                            // 同步考生
+                            List<SyncExamStudentDto> syncExamStudentDtoList = examStudentService.listStudentByExamDetailCourseId(examDetailCourseList, paperType);
+
+                            // 没有考生就单独推送科目
+                            if (CollectionUtils.isEmpty(syncExamStudentDtoList)) {
+                                for (ExamDetailCourseDto examDetailCourseDto : examDetailCourseList) {
+                                    // 只同步当前卷型
+                                    saveSubject(schoolId, thirdRelateId, examDetailCourseDto.getCourseCode(), examDetailCourseDto.getCourseName(), examDetailCourseDto.getSequence(), paperType);
+                                }
+                            } else {
+                                long count = syncExamStudentDtoList.stream().filter(m -> StringUtils.isBlank(m.getPaperType())).count();
+                                if (count > 0) {
+                                    throw ExceptionResultEnum.ERROR.exception("部分学生未关联试卷类型,数量[" + count + "]");
+                                }
+                                // 同步考生
+                                saveStudent(schoolId, thirdRelateId, syncExamStudentDtoList);
+                            }
 
-                        // 同步题卡
-                        for (ExamDetailCourseDto examDetailCourseDto : examDetailCourseList) {
                             // 同步题卡
-                            cardUpload(schoolId, thirdRelateId, examTask, examDetailCourseDto.getPaperType());
+                            // 同步题卡(只上传当前卷型)
+                            cardUpload(schoolId, thirdRelateId, examTask, paperType);
+                        } catch (Exception e) {
+                            errorMsg = e.getMessage();
+                            taskSyncStatusEnum = ExamTaskSyncStatusEnum.FAIL;
+                        } finally {
+                            examTaskSync.setErrorMsg(errorMsg);
+                            taskSyncStatusEnum = taskSyncStatusEnum == null ? ExamTaskSyncStatusEnum.FINISH : taskSyncStatusEnum;
+                            examTaskSync.setSyncStatus(taskSyncStatusEnum);
                         }
-                    } catch (Exception e) {
-                        errorMsg = e.getMessage();
-                        taskSyncStatusEnum = ExamTaskSyncStatusEnum.FAIL;
-                    } finally {
-                        examTaskSync.setErrorMsg(errorMsg);
-                        taskSyncStatusEnum = taskSyncStatusEnum == null ? ExamTaskSyncStatusEnum.FINISH : taskSyncStatusEnum;
-                        examTaskSync.setSyncStatus(taskSyncStatusEnum);
-                    }
-                    examTaskSync.setSyncEndTime(System.currentTimeMillis());
-                    examTaskSyncService.saveOrUpdate(examTaskSync);
+                        examTaskSync.setSyncEndTime(System.currentTimeMillis());
+                        examTaskSyncService.saveOrUpdate(examTaskSync);
 
-                    if(StringUtils.isNotBlank(errorMsg)){
-                        throw ExceptionResultEnum.ERROR.exception(errorMsg);
+                        if (StringUtils.isNotBlank(errorMsg)) {
+                            throw ExceptionResultEnum.ERROR.exception(errorMsg);
+                        }
                     }
                 }
-
             }
             // 任务结果
             result = TaskResultEnum.SUCCESS;

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

@@ -149,7 +149,7 @@ public class ExamDetailCourseServiceImpl extends ServiceImpl<ExamDetailCourseMap
     }
 
     @Override
-    public List<ExamDetailCourseDto> listByPrintPlanIdAndExamTaskId(List<Long> printPlanIds, Long examTaskId) {
-        return this.baseMapper.listByPrintPlanIdAndExamTaskId(printPlanIds, examTaskId);
+    public List<ExamDetailCourseDto> listByPrintPlanIdAndExamTaskId(List<Long> printPlanIds, Long examTaskId, String paperType) {
+        return this.baseMapper.listByPrintPlanIdAndExamTaskId(printPlanIds, examTaskId, paperType);
     }
 }

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

@@ -2,21 +2,17 @@ package com.qmth.distributed.print.business.service.impl;
 
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.distributed.print.business.bean.dto.ExamDetailCourseDto;
 import com.qmth.distributed.print.business.bean.dto.ExamStudentCourseDto;
 import com.qmth.distributed.print.business.bean.dto.ExamStudentPdfInfoDto;
 import com.qmth.distributed.print.business.bean.dto.SyncExamStudentDto;
-import com.qmth.distributed.print.business.entity.ExamDetail;
 import com.qmth.distributed.print.business.entity.ExamDetailCourse;
 import com.qmth.distributed.print.business.entity.ExamStudent;
 import com.qmth.distributed.print.business.mapper.ExamDetailCourseMapper;
 import com.qmth.distributed.print.business.mapper.ExamStudentMapper;
 import com.qmth.distributed.print.business.service.ExamStudentService;
 import com.qmth.teachcloud.common.entity.BasicCollege;
-import com.qmth.teachcloud.common.entity.SysOrg;
-import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
@@ -111,10 +107,10 @@ public class ExamStudentServiceImpl extends ServiceImpl<ExamStudentMapper, ExamS
     }
 
     @Override
-    public List<SyncExamStudentDto> listStudentByExamDetailCourseId(List<ExamDetailCourseDto> examDetailCourseList) {
+    public List<SyncExamStudentDto> listStudentByExamDetailCourseId(List<ExamDetailCourseDto> examDetailCourseList, String paperType) {
         List<SyncExamStudentDto> syncExamStudentDtoList = new ArrayList<>();
         for (ExamDetailCourseDto examDetailCourseDto : examDetailCourseList) {
-            List<SyncExamStudentDto> syncExamStudentDtos = this.baseMapper.listStudentByExamDetailCourseId(examDetailCourseDto.getId());
+            List<SyncExamStudentDto> syncExamStudentDtos = this.baseMapper.listStudentByExamDetailCourseId(examDetailCourseDto.getId(), paperType);
             if (!syncExamStudentDtos.isEmpty()) {
                 syncExamStudentDtoList.addAll(syncExamStudentDtos);
             }

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

@@ -2,7 +2,6 @@ package com.qmth.distributed.print.business.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.qmth.distributed.print.business.bean.dto.SyncExamTaskDto;
 import com.qmth.distributed.print.business.entity.ExamTaskSync;
 import com.qmth.distributed.print.business.mapper.ExamTaskSyncMapper;
 import com.qmth.distributed.print.business.service.ExamTaskSyncService;
@@ -18,12 +17,12 @@ import org.springframework.stereotype.Service;
 public class ExamTaskSyncServiceImpl extends ServiceImpl<ExamTaskSyncMapper, ExamTaskSync> implements ExamTaskSyncService {
 
     @Override
-    public ExamTaskSync getBySchoolIdAndOrgCodeAndPaperNumber(Long schoolId, Long examId, String orgCode, String paperNumber) {
-
+    public ExamTaskSync getBySchoolIdAndOrgCodeAndPaperNumberAndPaperType(Long schoolId, Long examId, String orgCode, String paperNumber, String paperType) {
         QueryWrapper<ExamTaskSync> queryWrapper = new QueryWrapper<>();
         queryWrapper.lambda().eq(ExamTaskSync::getSchoolId, schoolId)
                 .eq(ExamTaskSync::getExamId, examId)
-                .eq(ExamTaskSync::getPaperNumber, paperNumber);
+                .eq(ExamTaskSync::getPaperNumber, paperNumber)
+                .eq(ExamTaskSync::getPaperType, paperType);
         if(StringUtils.isNotBlank(orgCode)){
             queryWrapper.lambda().eq(ExamTaskSync::getOrgCode, orgCode);
         } else {

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

@@ -263,7 +263,7 @@ public class PrintCommonServiceImpl implements PrintCommonService {
      */
     @Override
     @Transactional
-    public void saveAttachmentSignPdf(PdfSignDto pdfFillDto, ExamDetail examDetail, List<PdfDto> pdfList, Integer printCount, List<File> fileTempList) {
+    public void saveAttachmentSignPdf(PdfSignDto pdfFillDto, ExamDetail examDetail, List<PdfDto> pdfList, Integer printCount, List<File> fileTempList, Boolean diallel) {
         try {
             boolean oss = dictionaryConfig.sysDomain().isOss();
             StringJoiner pdfStringJoiner = new StringJoiner("");
@@ -276,7 +276,7 @@ public class PrintCommonServiceImpl implements PrintCommonService {
 
             File pdfFileTemp = SystemConstant.getFileTempVar(SystemConstant.PDF_PREFIX);
             fileTempList.add(pdfFileTemp);
-            createPrintPdfUtil.createSignPdf(pdfFillDto, pdfFileTemp.getPath());
+            createPrintPdfUtil.createSignPdf(pdfFillDto, pdfFileTemp.getPath(), diallel);
 
             String pdfDirName = pdfStringJoiner.toString().replaceAll("\\\\", SystemConstant.ORG_SPLIT);
             //pdf生成和上传

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

@@ -321,26 +321,23 @@ public class CreatePdfUtil {
         }
 
         // 标题信息
-        List<JSONObject> objectTitleList = JSON.parseArray(object.getString("title"), JSONObject.class);
+        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<>();
-            if (jsonObject.getBoolean("enable")) {
-                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);
-
+            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);
+        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;
@@ -349,154 +346,132 @@ public class CreatePdfUtil {
         // 基础信息
         List<Map<String, String>> basicPlate = new ArrayList<>();
         for (JSONObject jsonObject : objectList) {
-            if (jsonObject.getBoolean("enable")) {
-                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 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;
                         }
-                        String examTime;
+                    } 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", "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().map(ExamStudent::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> 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", 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 -> m.getStudentClazzType().equals(StudentClazzEnum.BASIC_CLAZZ) && StringUtils.isNotBlank(m.getClazzName())).map(ExamStudent::getClazzName).collect(Collectors.toSet());
-                    if (!clazzNames.isEmpty()) {
-                        stringSet.addAll(clazzNames);
-                    }
-                    Set<String> teachClazzNames = examStudentList.stream().filter(m -> m.getStudentClazzType().equals(StudentClazzEnum.TEACH_CLAZZ) && StringUtils.isNotBlank(m.getTeachClazzName())).map(ExamStudent::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", String.join(SystemConstant.COMMA_OF_CHINESE, stringSet));
-                    basicPlate.add(basicMap);
+                    basicMap.put("value", examTime);
                 }
-//                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 if ("paperCount".equals(code)) {
-//                    Map<String, String> basicMap = new HashMap<>();
-//                    basicMap.put("code", code);
-//                    basicMap.put("name", name);
-//                    basicMap.put("value", examStudentList.size() + " + " + printCount);
-//                    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);
+                basicPlate.add(basicMap);
+            } else if ("courseCode".equals(code) || "courseName".equals(code)) {
+                Map<String, String> basicMap = new HashMap<>();
+                if (isCourseHasTwo) {
+                    if (isCourseFill) {
+                        continue;
                     }
-                    Map<String, String> basicMap = new HashMap<>();
+                    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, finalSet));
-                    basicPlate.add(basicMap);
+                    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().map(ExamStudent::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> 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", 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 -> m.getStudentClazzType().equals(StudentClazzEnum.BASIC_CLAZZ) && StringUtils.isNotBlank(m.getClazzName())).map(ExamStudent::getClazzName).collect(Collectors.toSet());
+                if (!clazzNames.isEmpty()) {
+                    stringSet.addAll(clazzNames);
                 }
+                Set<String> teachClazzNames = examStudentList.stream().filter(m -> m.getStudentClazzType().equals(StudentClazzEnum.TEACH_CLAZZ) && StringUtils.isNotBlank(m.getTeachClazzName())).map(ExamStudent::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", String.join(SystemConstant.COMMA_OF_CHINESE, stringSet));
+                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);
             }
         }
         Map<String, String> basicMap1 = new HashMap<>();
@@ -734,9 +709,10 @@ public class CreatePdfUtil {
         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);
+        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;
@@ -748,9 +724,6 @@ public class CreatePdfUtil {
         boolean isDateFill = false;
         boolean isPlaceFill = false;
         for (JSONObject object : objectList) {
-            if (!object.getBoolean("enable")) {
-                continue;
-            }
             String code = object.getString("code");
             String name = object.getString("name");
             if ("courseCode".equals(code) || "courseName".equals(code)) {
@@ -894,12 +867,10 @@ public class CreatePdfUtil {
         pdfFillDto.setBasicPlate(basicPlate);
 
         // 表头信息
-        List<JSONObject> tableList = JSON.parseArray(jsonObject.getString("table"), JSONObject.class);
+        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) {
-            if (object.getBoolean("enable")) {
-                studentHeadPlateMap.put(object.getString("code"), object.getString("name"));
-            }
+            studentHeadPlateMap.put(object.getString("code"), object.getString("name"));
         }
         studentHeadPlateMap.put("studentSign", "签名");
         pdfFillDto.setStudentHeadPlate(studentHeadPlateMap);
@@ -930,7 +901,7 @@ public class CreatePdfUtil {
         }
         pdfFillDto.setStudentPlate(studentPlate);
 
-        printCommonService.saveAttachmentSignPdf(pdfFillDto, examDetail, variablePdfList, printCount, fileTempList);
+        printCommonService.saveAttachmentSignPdf(pdfFillDto, examDetail, variablePdfList, printCount, fileTempList, basicTemplate.getDiallel());
     }
 
     /**

+ 105 - 47
distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/CreatePrintPdfUtil.java

@@ -29,7 +29,7 @@ public class CreatePrintPdfUtil {
      * @param pdfFillDto   签到表数据
      * @param destFileName 文件名
      */
-    public File createSignPdf(PdfSignDto pdfFillDto, String destFileName) throws Exception {
+    public File createSignPdf(PdfSignDto pdfFillDto, String destFileName, Boolean diallel) throws Exception {
 
         // 1:建立Document对象实例
         Document document = new Document(PageSize.A4, 20F, 20F, 40F, 36F);
@@ -49,7 +49,7 @@ public class CreatePrintPdfUtil {
             // 3:打开文档
             document.open();
             //生成pdf
-            this.generateSignPDF(document, pdfWriter, pdfFillDto);
+            this.generateSignPDF(document, pdfWriter, pdfFillDto, diallel);
             // 5:关闭文档
             document.close();
 
@@ -112,7 +112,8 @@ public class CreatePrintPdfUtil {
      * @param pdfWriter  pdfWriter
      * @param pdfFillDto 签到表数据
      */
-    private void generateSignPDF(Document document, PdfWriter pdfWriter, PdfSignDto pdfFillDto) throws DocumentException {
+    private void generateSignPDF(Document document, PdfWriter pdfWriter, PdfSignDto pdfFillDto, Boolean diallel) throws DocumentException {
+        diallel = diallel == null ? true : diallel;
         // 空格
         Paragraph blank = new Paragraph(" ");
         // 标题table
@@ -142,53 +143,91 @@ public class CreatePrintPdfUtil {
         //表头
         Map<String, String> studentHeadPlate = pdfFillDto.getStudentHeadPlate();
         //计算表格宽度
-        float[] columnWidth = chooseColumnWidth(studentHeadPlate.size());
+        float[] columnWidth = chooseColumnWidth(studentHeadPlate.size(), diallel);
         int columnCount = studentHeadPlate.size();
 
         PdfPTable studentTable = PdfFillUtils.createTable(columnWidth);
-        String[] headKeys = new String[columnCount * 2];
 
-        for (int i = 0; i < 2; i++) {
-            int j = 0;
+        // 双列
+        if (diallel) {
+            String[] headKeys = new String[columnCount * 2];
+            for (int i = 0; i < 2; i++) {
+                int j = 0;
+                for (Map.Entry<String, String> entry : studentHeadPlate.entrySet()) {
+                    headKeys[columnCount * i + j] = entry.getKey();
+                    String value = entry.getValue();
+                    if ("座位号".equals(value)) {
+                        value = "座号";
+                    }
+                    studentTable.addCell(PdfFillUtils.createCell(value, PdfFillUtils.textFont9, BaseColor.LIGHT_GRAY, 16f, Element.ALIGN_CENTER, 0, 1, 1));
+                    j++;
+                }
+            }
+
+            //数据
+            List<Map<String, String>> studentPlate = pdfFillDto.getStudentPlate();
+            int studentPlateCount = studentPlate.size();
+            int forCount = studentPlateCount % 2 == 0 ? studentPlateCount / 2 : studentPlateCount / 2 + 1;
+
+            for (int i = 0; i < forCount; i++) {
+                Map<String, String> stringMap1 = studentPlate.get(2 * i);
+                for (int j = 0; j < stringMap1.size(); j++) {
+                    String value = stringMap1.get(headKeys[j]);
+                    studentTable.addCell(PdfFillUtils.createCell(value, chooseFont(value, columnWidth[j]), null, 0, Element.ALIGN_CENTER, 0, 1, 1));
+                }
+
+                if (studentPlateCount % 2 > 0 && 2 * i + 1 == studentPlate.size()) {
+                    for (int i1 = 0; i1 < columnCount; i1++) {
+                        studentTable.addCell(PdfFillUtils.createCell("", PdfFillUtils.textFont8, null, 0, Element.ALIGN_CENTER, 0, 1, 1));
+                    }
+                    continue;
+                }
+                Map<String, String> stringMap2 = studentPlate.get(2 * i + 1);
+                for (int j = 0; j < stringMap2.size(); j++) {
+                    String value = stringMap2.get(headKeys[j + columnCount]);
+                    studentTable.addCell(PdfFillUtils.createCell(value, chooseFont(value, columnWidth[j + columnCount]), null, 0, Element.ALIGN_CENTER, 0, 1, 1));
+                }
+            }
+        }
+        // 单列
+        else {
+            String[] headKeys = new String[columnCount];
+            int k = 0;
             for (Map.Entry<String, String> entry : studentHeadPlate.entrySet()) {
-                headKeys[columnCount * i + j] = entry.getKey();
+                headKeys[k] = entry.getKey();
                 String value = entry.getValue();
-                if("座位号".equals(value)){
+                if ("座位号".equals(value)) {
                     value = "座号";
                 }
                 studentTable.addCell(PdfFillUtils.createCell(value, PdfFillUtils.textFont9, BaseColor.LIGHT_GRAY, 16f, Element.ALIGN_CENTER, 0, 1, 1));
-                j++;
+                k++;
             }
-        }
 
-        //数据
-        List<Map<String, String>> studentPlate = pdfFillDto.getStudentPlate();
-        int studentPlateCount = studentPlate.size();
-        int forCount = studentPlateCount % 2 == 0 ? studentPlateCount / 2 : studentPlateCount / 2 + 1;
+            //数据
+            List<Map<String, String>> studentPlate = pdfFillDto.getStudentPlate();
+            int studentPlateCount = studentPlate.size();
 
-        for (int i = 0; i < forCount; i++) {
-            Map<String, String> stringMap1 = studentPlate.get(2 * i);
-            for (int j = 0; j < stringMap1.size(); j++) {
-                String value = stringMap1.get(headKeys[j]);
-                studentTable.addCell(PdfFillUtils.createCell(value, chooseFont(value, columnWidth[j]), null, 0, Element.ALIGN_CENTER, 0, 1, 1));
-            }
-
-            if (studentPlateCount % 2 > 0 && 2 * i + 1 == studentPlate.size()) {
-                for (int i1 = 0; i1 < columnCount; i1++) {
-                    studentTable.addCell(PdfFillUtils.createCell("", PdfFillUtils.textFont8, null, 0, Element.ALIGN_CENTER, 0, 1, 1));
+            for (int i = 0; i < studentPlateCount; i++) {
+                Map<String, String> stringMap1 = studentPlate.get(i);
+                for (int j = 0; j < stringMap1.size(); j++) {
+                    String value = stringMap1.get(headKeys[j]);
+                    studentTable.addCell(PdfFillUtils.createCell(value, chooseFont(value, columnWidth[j]), null, 0, Element.ALIGN_CENTER, 0, 1, 1));
                 }
-                continue;
-            }
-            Map<String, String> stringMap2 = studentPlate.get(2 * i + 1);
-            for (int j = 0; j < stringMap2.size(); j++) {
-                String value = stringMap2.get(headKeys[j + columnCount]);
-                studentTable.addCell(PdfFillUtils.createCell(value, chooseFont(value, columnWidth[j + columnCount]), null, 0, Element.ALIGN_CENTER, 0, 1, 1));
             }
         }
+
         document.add(studentTable);
 
         document.add(blank);
 
+        // 文字说明
+        if (StringUtils.isNotBlank(pdfFillDto.getTextDesc())) {
+            Paragraph textDesc = new Paragraph(pdfFillDto.getTextDesc(), PdfFillUtils.textFont9);
+            document.add(textDesc);
+
+            document.add(blank);
+        }
+
         Paragraph pDate = new Paragraph(" 年        月        日", PdfFillUtils.textFont9);
         pDate.setAlignment(Element.ALIGN_RIGHT);
         pDate.setIndentationRight(20);
@@ -306,24 +345,43 @@ public class CreatePrintPdfUtil {
     /**
      * 签到表考生签到table表头宽度选择
      *
-     * @param size 表头字段数量
+     * @param size    表头字段数量
+     * @param diallel
      */
-    private float[] chooseColumnWidth(int size) {
+    private float[] chooseColumnWidth(int size, Boolean diallel) {
         float[] columnWidth;
-        if (size == 1) {
-            columnWidth = new float[]{50, 50};
-        } else if (size == 2) {
-            columnWidth = new float[]{20, 30, 20, 30};
-        } else if (size == 3) {
-            columnWidth = new float[]{15, 20, 15, 15, 20, 15};
-        } else if (size == 4) {
-            columnWidth = new float[]{6, 14, 15, 15, 6, 14, 15, 15};
-        } else if (size == 5) {
-            columnWidth = new float[]{4, 8, 10, 20, 8, 4, 8, 10, 20, 8};
-        } else if (size == 6) {
-            columnWidth = new float[]{6, 9, 9, 9, 9, 8, 6, 9, 9, 9, 9, 8};
+        if (diallel) {
+            if (size == 1) {
+                columnWidth = new float[]{50, 50};
+            } else if (size == 2) {
+                columnWidth = new float[]{20, 30, 20, 30};
+            } else if (size == 3) {
+                columnWidth = new float[]{15, 20, 15, 15, 20, 15};
+            } else if (size == 4) {
+                columnWidth = new float[]{6, 14, 15, 15, 6, 14, 15, 15};
+            } else if (size == 5) {
+                columnWidth = new float[]{4, 8, 10, 20, 8, 4, 8, 10, 20, 8};
+            } else if (size == 6) {
+                columnWidth = new float[]{6, 9, 9, 9, 9, 8, 6, 9, 9, 9, 9, 8};
+            } else {
+                throw ExceptionResultEnum.ERROR.exception("签到表最多只能显示6个信息");
+            }
         } else {
-            throw ExceptionResultEnum.ERROR.exception("签到表最多只能显示6个信息");
+            if (size == 1) {
+                columnWidth = new float[]{100};
+            } else if (size == 2) {
+                columnWidth = new float[]{50, 50};
+            } else if (size == 3) {
+                columnWidth = new float[]{30, 40, 30};
+            } else if (size == 4) {
+                columnWidth = new float[]{12, 28, 30, 30};
+            } else if (size == 5) {
+                columnWidth = new float[]{8, 16, 20, 38, 18};
+            } else if (size == 6) {
+                columnWidth = new float[]{12, 18, 18, 18, 18, 16};
+            } else {
+                throw ExceptionResultEnum.ERROR.exception("签到表最多只能显示6个信息");
+            }
         }
         return columnWidth;
     }
@@ -519,7 +577,7 @@ public class CreatePrintPdfUtil {
 
         try {
             CreatePrintPdfUtil createPrintPdfUtil = new CreatePrintPdfUtil();
-            createPrintPdfUtil.createSignPdf(pdfFillDto, "D:/sign.pdf");
+            createPrintPdfUtil.createSignPdf(pdfFillDto, "D:/sign.pdf", false);
             createPrintPdfUtil.createPackagePdf(pdfPackageDto, "D:/package.pdf");
         } catch (Exception e) {
             e.printStackTrace();

+ 176 - 22
distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/PdfFillUtils.java

@@ -1,15 +1,23 @@
 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;
 import com.itextpdf.text.*;
 import com.itextpdf.text.pdf.*;
+import com.qmth.distributed.print.business.bean.dto.ExamStudentCourseDto;
 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.entity.ExamDetailCourse;
+import com.qmth.distributed.print.business.entity.ExamStudent;
+import com.qmth.distributed.print.business.enums.StudentClazzEnum;
 import com.qmth.distributed.print.business.service.PrintCommonService;
 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.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -61,27 +69,106 @@ public class PdfFillUtils {
     /**
      * 签到表预览数据
      *
-     * @param data     数据内容
-     * @param fileName 文件名
+     * @param basicTemplate 数据内容
+     * @param fileName      文件名
      */
-    public static JSONObject parseSignTempData(String data, String fileName) {
+    public static JSONObject parseSignTempData(BasicTemplate basicTemplate, String fileName) {
         PdfSignDto pdfFillDto = new PdfSignDto();
         pdfFillDto.setTitle("签到表样例");
         pdfFillDto.setPackageNumber("123456789");
+        pdfFillDto.setTextDesc(basicTemplate.getTextDesc());
 
-        JSONObject jsonObject = JSON.parseObject(data);
+        JSONObject jsonObject = JSON.parseObject(basicTemplate.getDisplayRange());
         // 基础信息
         List<Map<String, String>> 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());
+
+        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 isCourseFill = false;
+        boolean isDateFill = false;
+        boolean isPlaceFill = false;
+
         Map<String, String> basicMap;
         for (JSONObject object : basicObjectList) {
-            basicMap = new HashMap<>();
-            basicMap.put("code", object.getString("code"));
-            basicMap.put("name", object.getString("name"));
-            basicMap.put("value", "xxx");
-            basicPlate.add(basicMap);
+            String code = object.getString("code");
+            String name = object.getString("name");
+
+            if ("courseCode".equals(code) || "courseName".equals(code)) {
+                basicMap = new HashMap<>();
+                if (isCourseHasTwo) {
+                    if (isCourseFill) {
+                        continue;
+                    }
+                    basicMap.put("code", "courseName");
+                    basicMap.put("name", "课程名称");
+                    basicMap.put("value", "xxx(xxx)");
+                    isCourseFill = true;
+                } else {
+                    basicMap.put("code", code);
+                    basicMap.put("name", name);
+                    basicMap.put("value", "xxx");
+                }
+                basicPlate.add(basicMap);
+            } else if ("examDate".equals(code) || "examTime".equals(code)) {
+                basicMap = new HashMap<>();
+                if (isDateHasTwo) {
+                    if (isDateFill) {
+                        continue;
+                    }
+                    String examTime;
+                    basicMap.put("code", "examTime");
+                    basicMap.put("name", "考试时间");
+                    basicMap.put("value", "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);
+                }
+                basicPlate.add(basicMap);
+            } else if ("examPlace".equals(code) || "examRoom".equals(code)) {
+                basicMap = new HashMap<>();
+                if (isPlaceHasTwo) {
+                    if (isPlaceFill) {
+                        continue;
+                    }
+                    basicMap.put("code", "examRoom");
+                    basicMap.put("name", "考试地点");
+                    basicMap.put("value", "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);
+                }
+                basicPlate.add(basicMap);
+            } else {
+                basicMap = new HashMap<>();
+                basicMap.put("code", code);
+                basicMap.put("name", name);
+                basicMap.put("value", "xxx");
+                basicPlate.add(basicMap);
+            }
         }
+
         pdfFillDto.setBasicPlate(basicPlate);
 
         // 表头信息
@@ -108,10 +195,11 @@ public class PdfFillUtils {
         pdfFillDto.setStudentPlate(studentPlate);
         try {
             CreatePrintPdfUtil createPrintPdfUtil = new CreatePrintPdfUtil();
-            File file = createPrintPdfUtil.createSignPdf(pdfFillDto, fileName);
+            File file = createPrintPdfUtil.createSignPdf(pdfFillDto, fileName, basicTemplate.getDiallel());
             PrintCommonService printCommonService = SpringContextHolder.getBean(PrintCommonService.class);
             return printCommonService.uploadPdfFile(file, ClassifyEnum.SIGN);
-        } catch (Exception e) {
+        } catch (
+                Exception e) {
             e.printStackTrace();
         }
         return null;
@@ -143,26 +231,92 @@ public class PdfFillUtils {
         }
         pdfPackageDto.setTitlePlate(titlePlate);
         // 基础信息
-        List<JSONObject> basicObjectList = JSON.parseArray(objectList.getString("basic"), JSONObject.class);
+        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;
+        boolean isCourseFill = false;
+        boolean isDateFill = false;
+
         List<Map<String, String>> basicPlate = new ArrayList<>();
         for (JSONObject object : basicObjectList) {
-            if (object.getBoolean("enable")) {
+            String code = object.getString("code");
+            String name = object.getString("name");
+            if ("examDate".equals(code) || "examTime".equals(code)) {
                 Map<String, String> basicMap = new HashMap<>();
-                String code = object.getString("code");
-                basicMap.put("code", code);
-                basicMap.put("name", object.getString("name"));
-                // 实考人数默认为“”
-                if ("actualExamCount".equals(code)) {
-                    basicMap.put("value", " ");
-                } else if ("paperCount".equals(code)) {
-                    basicMap.put("value", "xxx + x");
+                if (isDateHasTwo) {
+                    if (isDateFill) {
+                        continue;
+                    }
+                    basicMap.put("code", "examTime");
+                    basicMap.put("name", "考试时间");
+                    basicMap.put("value", "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);
+                }
+                basicPlate.add(basicMap);
+            } else if ("courseCode".equals(code) || "courseName".equals(code)) {
+                Map<String, String> basicMap = new HashMap<>();
+                if (isCourseHasTwo) {
+                    if (isCourseFill) {
+                        continue;
+                    }
+                    basicMap.put("code", "courseName");
+                    basicMap.put("name", "课程名称");
+                    basicMap.put("value", "xxx(xxx)");
+                    isCourseFill = true;
+                } else {
+                    basicMap.put("code", code);
+                    basicMap.put("name", name);
                     basicMap.put("value", "xxx");
                 }
                 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 {
+                Map<String, String> basicMap = new HashMap<>();
+                basicMap.put("code", code);
+                basicMap.put("name", name);
+                basicMap.put("value", "xxx");
+                basicPlate.add(basicMap);
             }
         }
+
+        Map<String, String> basicMap1 = new HashMap<>();
+        basicMap1.put("code", "paperCount");
+        basicMap1.put("name", "试卷数量");
+        basicMap1.put("value", "xxx + x");
+        basicPlate.add(basicMap1);
+
+        Map<String, String> basicMap2 = new HashMap<>();
+        basicMap2.put("code", "examCount");
+        basicMap2.put("name", "应考人数");
+        basicMap2.put("value", "xxx");
+        basicPlate.add(basicMap2);
+
+        Map<String, String> basicMap3 = new HashMap<>();
+        basicMap3.put("code", "actualExamCount");
+        basicMap3.put("name", "实考人数");
+        basicMap3.put("value", "");
+        basicPlate.add(basicMap3);
         pdfPackageDto.setBasicPlate(basicPlate);
 
         try {

+ 13 - 1
distributed-print-business/src/main/resources/db/log/脚本-xiaof.sql

@@ -55,7 +55,19 @@ ALTER TABLE `exam_paper_structure`
 
 INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('874', '共用接口-查询学院', '/api/admin/basic/condition/list_college', 'URL', '149', '14', 'SYS', '1', '1', '1');
 
+
+-----------------------3.2.5 end----------------------
+
+-----------------------3.2.5 start 补充需求 2023-05-26----------------------
 ALTER TABLE `exam_task_sync`
     ADD COLUMN `paper_type` VARCHAR(10) NULL COMMENT '试卷类型' AFTER `paper_number`;
 
------------------------3.2.5 end----------------------
+ALTER TABLE `basic_template`
+    ADD COLUMN `diallel` TINYINT(1) NULL COMMENT '考生信息是否双列显示' AFTER `enable`,
+    ADD COLUMN `text_desc` VARCHAR(500) NULL COMMENT '文字说明' AFTER `diallel`;
+
+ALTER TABLE `exam_paper_structure`
+    CHANGE COLUMN `paper_type` `paper_type` VARCHAR(20) CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_general_ci' NULL DEFAULT NULL COMMENT '试卷类型' ;
+
+ALTER TABLE `exam_paper_structure`
+    CHANGE COLUMN `paper_number` `paper_number` VARCHAR(50) CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_general_ci' NOT NULL COMMENT '试卷编号' ;

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

@@ -201,7 +201,40 @@
                 AND t.exam_id = et.exam_id
                 AND t.paper_number = et.paper_number
                 LEFT JOIN
-            exam_task_sync ets ON et.school_id = ets.school_id
+                (select
+                     a.school_id,
+                     a.exam_id,
+                     a.course_code,
+                     a.paper_number,
+                     a.org_code,
+                     a.third_relate_id,
+                     a.sync_user_id,
+                     GROUP_CONCAT(a.paper_type ORDER BY a.paper_type) paper_type,
+                     CASE
+                        WHEN LOCATE('STARTING', GROUP_CONCAT(DISTINCT a.sync_status)) THEN 'STARTING'
+                        WHEN LOCATE('FAIL', GROUP_CONCAT(DISTINCT a.sync_status)) THEN 'FAIL'
+                        WHEN LOCATE('FINISH', GROUP_CONCAT(DISTINCT a.sync_status)) THEN 'FINISH'
+                        END sync_status
+                    from exam_task_sync a
+                        left join
+                    basic_exam b on a.exam_id = b.id
+                    <where>
+                        and b.enable = true
+                        <if test="semesterId != null">
+                            and b.semester_id = #{semesterId}
+                        </if>
+                        <if test="examId != null">
+                            and a.exam_id = #{examId}
+                        </if>
+                        <if test="courseCode != null and courseCode != ''">
+                            and a.course_code = #{courseCode}
+                        </if>
+                        <if test="paperNumber != null and paperNumber != ''">
+                            and a.paper_number = #{paperNumber}
+                        </if>
+                    </where>
+                    GROUP BY a.school_id , a.exam_id , a.course_code , a.paper_number , a.org_code , a.third_relate_id , a.sync_user_id
+                ) ets ON et.school_id = ets.school_id
                 AND et.exam_id = ets.exam_id
                 AND et.paper_number = ets.paper_number
                 LEFT JOIN
@@ -247,6 +280,8 @@
                et.sequence
         FROM exam_detail_course b
                  LEFT JOIN
+             exam_detail_course_paper_type edcpt ON edcpt.exam_detail_course_id = b.id
+                 LEFT JOIN
              exam_detail c ON b.exam_detail_id = c.id
                  LEFT JOIN
              exam_task et ON b.school_id = et.school_id
@@ -256,7 +291,8 @@
                  LEFT JOIN
              exam_task_sync ets ON et.school_id = ets.school_id
                 and et.exam_id = ets.exam_id
-                 and et.paper_number = ets.paper_number
+                and et.paper_number = ets.paper_number
+                and edcpt.paper_type = ets.paper_type
         <where>
             <if test="examTaskId != null">
                 and et.id = #{examTaskId}
@@ -267,6 +303,9 @@
                     #{printPlanId}
                 </foreach>
             </if>
+            <if test="paperType != null and paperType != ''">
+                and edcpt.paper_type = #{paperType}
+            </if>
         </where>
     </select>
 

+ 5 - 4
distributed-print-business/src/main/resources/mapper/ExamPaperStructureMapper.xml

@@ -38,6 +38,7 @@
         edc.school_id = ets.school_id
         and ed.exam_id = ets.exam_id
         and edc.paper_number = ets.paper_number
+        and edcpt.paper_type = ets.paper_type
         left join t_sync_stmms_exam tsse on
         edc.school_id = tsse.school_id
         and ets.third_relate_id = tsse.exam_id
@@ -48,10 +49,10 @@
         and et.paper_number = edc.paper_number
         and et.exam_id = ed.exam_id
         left join exam_paper_structure eps on
-        eps.school_id = ed.school_id
-        and eps.exam_id = et.exam_id
-        and eps.paper_number = edc.paper_number
-        and eps.paper_type = edc.paper_type
+        eps.school_id = ets.school_id
+        and eps.exam_id = ets.exam_id
+        and eps.paper_number = ets.paper_number
+        and eps.paper_type = ets.paper_type
         <where>
             and ed.school_id = #{schoolId}
             AND ets.sync_status = #{syncStatus}

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

@@ -108,7 +108,7 @@
                 </foreach>
             </if>
         </where>
-        order by edc.course_code, 0+ cast(es.site_number as char), es.ticket_number
+        order by 0 + cast(es.site_number as char)
     </select>
     <select id="listStudentByExamDetailCourseId"
             resultType="com.qmth.distributed.print.business.bean.dto.SyncExamStudentDto">
@@ -134,6 +134,7 @@
                  and c.exam_id = et.exam_id
                  and b.course_code = et.course_code
                  and b.paper_number = et.paper_number
+            where a.paper_type = #{paperType}
     </select>
     <select id="listExamStudentBySchoolIdAndClazzId"
             resultType="com.qmth.distributed.print.business.entity.ExamStudent">