Kaynağa Gözat

3.2.2-印品管理、推送管理

xiaof 2 yıl önce
ebeveyn
işleme
52e8c13545
14 değiştirilmiş dosya ile 439 ekleme ve 154 silme
  1. 3 3
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/SyncExamTaskDto.java
  2. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamDetailCourseMapper.java
  3. 0 7
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicExamRuleServiceImpl.java
  4. 0 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicExamServiceImpl.java
  5. 2 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicPrintConfigServiceImpl.java
  6. 42 7
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamDetailCourseServiceImpl.java
  7. 15 18
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskServiceImpl.java
  8. 9 9
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/TaskLogicServiceImpl.java
  9. 224 79
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/CreatePdfUtil.java
  10. 4 3
      distributed-print-business/src/main/resources/mapper/ExamDetailCourseMapper.xml
  11. 99 0
      distributed-print/src/test/java/com/qmth/distributed/print/UploadCardTest.java
  12. 0 23
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/entity/BasicExam.java
  13. 38 0
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/entity/BasicPrintConfig.java
  14. 2 0
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/enums/ExceptionResultEnum.java

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

@@ -10,7 +10,7 @@ import com.qmth.distributed.print.business.enums.SyncCardTypeEnum;
 public class SyncExamTaskDto extends ExamTask {
 public class SyncExamTaskDto extends ExamTask {
 
 
     private String paperType;
     private String paperType;
-    private SyncCardTypeEnum syncCardType;
+    private String syncCardType;
     private Integer totalSubjects;
     private Integer totalSubjects;
 
 
     private Integer syncSuccessCount;
     private Integer syncSuccessCount;
@@ -27,11 +27,11 @@ public class SyncExamTaskDto extends ExamTask {
         this.paperType = paperType;
         this.paperType = paperType;
     }
     }
 
 
-    public SyncCardTypeEnum getSyncCardType() {
+    public String getSyncCardType() {
         return syncCardType;
         return syncCardType;
     }
     }
 
 
-    public void setSyncCardType(SyncCardTypeEnum syncCardType) {
+    public void setSyncCardType(String syncCardType) {
         this.syncCardType = syncCardType;
         this.syncCardType = syncCardType;
     }
     }
 
 

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

@@ -34,7 +34,7 @@ public interface ExamDetailCourseMapper extends BaseMapper<ExamDetailCourse> {
 
 
     List<ExamDetailCourse> listByAndCourseCodeAndPaperNumber(@Param("schoolId") Long schoolId,@Param("courseCode") String courseCode,@Param("paperNumber") String paperNumber);
     List<ExamDetailCourse> listByAndCourseCodeAndPaperNumber(@Param("schoolId") Long schoolId,@Param("courseCode") String courseCode,@Param("paperNumber") String paperNumber);
 
 
-    List<SyncExamTaskDto> listSyncCourseByPringPlanId(List<Long> printPlanIds);
+    List<SyncExamTaskDto> listSyncCourseByPrintPlanId(@Param("printPlanIds") List<Long> printPlanIds);
 
 
     List<ExamDetailCourseDto> listByPrintPlanIdAndExamTaskId(@Param("printPlanId") Long printPlanId, @Param("examTaskIds") List<Long> examTaskIds);
     List<ExamDetailCourseDto> listByPrintPlanIdAndExamTaskId(@Param("printPlanId") Long printPlanId, @Param("examTaskIds") List<Long> examTaskIds);
 }
 }

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

@@ -47,16 +47,9 @@ public class BasicExamRuleServiceImpl extends ServiceImpl<BasicExamRuleMapper, B
     public BasicExamRule getBySchoolId() {
     public BasicExamRule getBySchoolId() {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
         Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
-        DataPermissionRule dpr = basicRoleDataPermissionService.findDataPermission(schoolId,sysUser.getId(),ServletUtil.getRequest().getServletPath());
 
 
         QueryWrapper<BasicExamRule> queryWrapper = new QueryWrapper<>();
         QueryWrapper<BasicExamRule> queryWrapper = new QueryWrapper<>();
         queryWrapper.lambda().eq(BasicExamRule::getSchoolId, schoolId);
         queryWrapper.lambda().eq(BasicExamRule::getSchoolId, schoolId);
-        if (SystemConstant.longNotNull(dpr.getRequestUserId())){
-            queryWrapper.lambda().eq(BasicExamRule::getCreateId,dpr.getRequestUserId());
-        }
-        if (dpr.getOrgIdSet() != null && dpr.getOrgIdSet().size() > 0){
-            queryWrapper.lambda().in(BasicExamRule::getOrgId,dpr.getOrgIdSet());
-        }
 
 
         BasicExamRule basicExamRule = this.getOne(queryWrapper);
         BasicExamRule basicExamRule = this.getOne(queryWrapper);
         if(basicExamRule == null){
         if(basicExamRule == null){

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

@@ -67,8 +67,6 @@ public class BasicExamServiceImpl extends ServiceImpl<BasicExamMapper, BasicExam
                     .set(BasicExam::getName, basicExam.getName())
                     .set(BasicExam::getName, basicExam.getName())
                     .set(BasicExam::getCategory, basicExam.getCategory())
                     .set(BasicExam::getCategory, basicExam.getCategory())
                     .set(BasicExam::getExamModel, basicExam.getExamModel())
                     .set(BasicExam::getExamModel, basicExam.getExamModel())
-                    .set(BasicExam::getReview, basicExam.getReview())
-                    .set(BasicExam::getPrintMethod, basicExam.getPrintMethod())
                     .set(BasicExam::getUpdateId, sysUser.getId())
                     .set(BasicExam::getUpdateId, sysUser.getId())
                     .set(BasicExam::getUpdateTime, System.currentTimeMillis()));
                     .set(BasicExam::getUpdateTime, System.currentTimeMillis()));
         } else {
         } else {

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

@@ -122,6 +122,7 @@ public class BasicPrintConfigServiceImpl extends ServiceImpl<BasicPrintConfigMap
             }
             }
 
 
             basicPrintConfig.setId(SystemConstant.getDbUuid());
             basicPrintConfig.setId(SystemConstant.getDbUuid());
+            basicPrintConfig.setOrgId(sysUser.getOrgId());
             basicPrintConfig.setCreateId(sysUser.getId());
             basicPrintConfig.setCreateId(sysUser.getId());
             basicPrintConfig.setCreateTime(System.currentTimeMillis());
             basicPrintConfig.setCreateTime(System.currentTimeMillis());
             isSuccess = this.save(basicPrintConfig);
             isSuccess = this.save(basicPrintConfig);
@@ -189,8 +190,7 @@ public class BasicPrintConfigServiceImpl extends ServiceImpl<BasicPrintConfigMap
     public BasicPrintConfig getByExamIdAndOrgId(Long examId, Long orgId) {
     public BasicPrintConfig getByExamIdAndOrgId(Long examId, Long orgId) {
         BasicExam basicExam = basicExamService.getById(examId);
         BasicExam basicExam = basicExamService.getById(examId);
         SysOrg sysOrg = sysOrgService.getById(orgId);
         SysOrg sysOrg = sysOrgService.getById(orgId);
-        Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
-        List<BasicPrintConfig> basicPrintConfigs = this.baseMapper.listBySchoolIdAndExamIdAndOrgId(schoolId, examId, orgId, TemplateTypeEnum.PRINT_CONFIG.name());
+        List<BasicPrintConfig> basicPrintConfigs = this.baseMapper.listBySchoolIdAndExamIdAndOrgId(sysOrg.getSchoolId(), examId, orgId, TemplateTypeEnum.PRINT_CONFIG.name());
         if (basicPrintConfigs == null || basicPrintConfigs.size() == 0) {
         if (basicPrintConfigs == null || basicPrintConfigs.size() == 0) {
             throw ExceptionResultEnum.ERROR.exception("考试[" + basicExam.getName() + "],教研室[" + sysOrg.getName() + "]未设置印品");
             throw ExceptionResultEnum.ERROR.exception("考试[" + basicExam.getName() + "],教研室[" + sysOrg.getName() + "]未设置印品");
         }
         }

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

@@ -1,23 +1,31 @@
 package com.qmth.distributed.print.business.service.impl;
 package com.qmth.distributed.print.business.service.impl;
 
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 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.ExamDetailCourseDto;
 import com.qmth.distributed.print.business.bean.dto.SyncExamTaskDto;
 import com.qmth.distributed.print.business.bean.dto.SyncExamTaskDto;
+import com.qmth.distributed.print.business.entity.ExamCard;
 import com.qmth.distributed.print.business.entity.ExamDetailCourse;
 import com.qmth.distributed.print.business.entity.ExamDetailCourse;
+import com.qmth.distributed.print.business.entity.ExamTaskDetail;
+import com.qmth.distributed.print.business.enums.CardTypeEnum;
 import com.qmth.distributed.print.business.enums.ExamDetailStatusEnum;
 import com.qmth.distributed.print.business.enums.ExamDetailStatusEnum;
 import com.qmth.distributed.print.business.enums.ExamStatusEnum;
 import com.qmth.distributed.print.business.enums.ExamStatusEnum;
+import com.qmth.distributed.print.business.enums.SyncCardTypeEnum;
 import com.qmth.distributed.print.business.mapper.ExamDetailCourseMapper;
 import com.qmth.distributed.print.business.mapper.ExamDetailCourseMapper;
+import com.qmth.distributed.print.business.service.ExamCardService;
 import com.qmth.distributed.print.business.service.ExamDetailCourseService;
 import com.qmth.distributed.print.business.service.ExamDetailCourseService;
+import com.qmth.distributed.print.business.service.ExamTaskDetailService;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.BasicCourse;
 import com.qmth.teachcloud.common.entity.BasicCourse;
+import com.qmth.teachcloud.common.enums.CardCreateMethodEnum;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
 
 
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import javax.annotation.Resource;
+import java.util.*;
+import java.util.stream.Collectors;
 
 
 /**
 /**
  * <p>
  * <p>
@@ -30,6 +38,12 @@ import java.util.Set;
 @Service
 @Service
 public class ExamDetailCourseServiceImpl extends ServiceImpl<ExamDetailCourseMapper, ExamDetailCourse> implements ExamDetailCourseService {
 public class ExamDetailCourseServiceImpl extends ServiceImpl<ExamDetailCourseMapper, ExamDetailCourse> implements ExamDetailCourseService {
 
 
+    @Resource
+    private ExamTaskDetailService examTaskDetailService;
+
+    @Resource
+    private ExamCardService examCardService;
+
     @Override
     @Override
     public List<Map<String, Object>> listByExamDetailId(Long examDetailId) {
     public List<Map<String, Object>> listByExamDetailId(Long examDetailId) {
         return this.baseMapper.listByExamDetailId(examDetailId, ExamDetailStatusEnum.FINISH.name());
         return this.baseMapper.listByExamDetailId(examDetailId, ExamDetailStatusEnum.FINISH.name());
@@ -71,9 +85,30 @@ public class ExamDetailCourseServiceImpl extends ServiceImpl<ExamDetailCourseMap
 
 
     @Override
     @Override
     public List<SyncExamTaskDto> listSyncCourseByPrintPlanId(List<Long> printPlanIds) {
     public List<SyncExamTaskDto> listSyncCourseByPrintPlanId(List<Long> printPlanIds) {
-        List<SyncExamTaskDto> examTaskDtos = this.baseMapper.listSyncCourseByPringPlanId(printPlanIds);
-        // todo 题卡类型 xf 20221204
-        return null;
+        List<SyncExamTaskDto> examTaskDtos = this.baseMapper.listSyncCourseByPrintPlanId(printPlanIds);
+        for (SyncExamTaskDto examTaskDto : examTaskDtos) {
+            String paperType = examTaskDto.getPaperType();
+            List<String> paperTypes = Arrays.asList(paperType.split(","));
+            ExamTaskDetail examTaskDetail = examTaskDetailService.getByExamTaskId(examTaskDto.getId());
+            List<JSONObject> paperAttachments = JSON.parseArray(examTaskDetail.getPaperAttachmentIds(), JSONObject.class);
+            List<Long> cardIds = paperAttachments.stream().filter(m -> paperTypes.contains(m.getString("name"))).map(m -> m.getLong("cardId")).collect(Collectors.toList());
+            QueryWrapper<ExamCard> queryWrapper = new QueryWrapper<>();
+            queryWrapper.lambda().in(ExamCard::getId, cardIds);
+
+            List<ExamCard> cardList = examCardService.list(queryWrapper);
+            Set<String> stringSet = new HashSet<>();
+            for (ExamCard examCard : cardList) {
+                if (examCard.getType().equals(CardTypeEnum.GENERIC) && examCard.getCreateMethod().equals(CardCreateMethodEnum.UPLOAD)) {
+                    stringSet.add(SyncCardTypeEnum.GENERIC.getDesc());
+                } else {
+                    stringSet.add(SyncCardTypeEnum.ELECTRONIC.getDesc());
+                }
+            }
+            if (stringSet.size() > 0) {
+                examTaskDto.setSyncCardType(String.join(",", stringSet));
+            }
+        }
+        return examTaskDtos;
     }
     }
 
 
     @Override
     @Override

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

@@ -432,8 +432,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
             examTask.insertInfo(sysUser.getId());
             examTask.insertInfo(sysUser.getId());
             examTask.updateInfo(sysUser.getId());
             examTask.updateInfo(sysUser.getId());
 
 
-            BasicExam basicExam = basicExamService.getById(examId);
-            examTask.setReview(basicExam.getReview());
+            examTask.setReview(basicPrintConfig.getReview());
             // 取课程所在机构
             // 取课程所在机构
             Long teachingRoomId = basicCourseService.getOrgIdBySchoolIdAndCourseCode(schoolId, courseCode);
             Long teachingRoomId = basicCourseService.getOrgIdBySchoolIdAndCourseCode(schoolId, courseCode);
             examTask.setOrgId(teachingRoomId);
             examTask.setOrgId(teachingRoomId);
@@ -744,8 +743,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
                 examTask.setStatus(ExamStatusEnum.DRAFT);
                 examTask.setStatus(ExamStatusEnum.DRAFT);
             }
             }
 
 
-            BasicExam basicExam = basicExamService.getById(examId);
-            examTask.setReview(basicExam.getReview());
+            examTask.setReview(basicPrintConfig.getReview());
             list.add(examTask);
             list.add(examTask);
         }
         }
         this.saveBatch(list);
         this.saveBatch(list);
@@ -1437,14 +1435,17 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
             examTask.setSchoolId(schoolId);
             examTask.setSchoolId(schoolId);
             examTask.setOrgId(basicCourseService.getOrgIdBySchoolIdAndCourseCode(schoolId, examTask.getCourseCode()));
             examTask.setOrgId(basicCourseService.getOrgIdBySchoolIdAndCourseCode(schoolId, examTask.getCourseCode()));
             examTask.setCreateId(sysUser.getId());
             examTask.setCreateId(sysUser.getId());
-            BasicExam basicExam = basicExamService.getById(examId);
-            examTask.setReview(basicExam.getReview());
+            BasicPrintConfig basicPrintConfig = basicPrintConfigService.getByExamIdAndCourseCode(examId, courseCode);
+            if (basicPrintConfig == null) {
+                throw ExceptionResultEnum.ERROR.exception("印品配置未设置");
+            }
+            examTask.setReview(basicPrintConfig.getReview());
             examTask.setUserId(sysUser.getId());
             examTask.setUserId(sysUser.getId());
             examTask.updateInfo(sysUser.getId());
             examTask.updateInfo(sysUser.getId());
 
 
             examTask.setStatus(ExamStatusEnum.valueOf(examTaskDetail.getOperateType()));
             examTask.setStatus(ExamStatusEnum.valueOf(examTaskDetail.getOperateType()));
             if (Objects.isNull(examTask.getFlowId())) {
             if (Objects.isNull(examTask.getFlowId())) {
-                if (basicExam.getReview()) {
+                if (basicPrintConfig.getReview()) {
                     Map<String, Object> map = SystemConstant.buildFlowVar(examTask.getId(),
                     Map<String, Object> map = SystemConstant.buildFlowVar(examTask.getId(),
                             examTask,
                             examTask,
                             TFCustomTypeEnum.ELECTRON_FLOW,
                             TFCustomTypeEnum.ELECTRON_FLOW,
@@ -1461,10 +1462,6 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
             // 提交时,校验
             // 提交时,校验
             if (ExamStatusEnum.SUBMIT.name().equals(examTaskDetail.getOperateType())) {
             if (ExamStatusEnum.SUBMIT.name().equals(examTaskDetail.getOperateType())) {
                 //TODO 加入从前端获取userId
                 //TODO 加入从前端获取userId
-                BasicPrintConfig basicPrintConfig = basicPrintConfigService.getByExamIdAndCourseCode(examTask.getExamId(), examTask.getCourseCode());
-                if (basicPrintConfig == null) {
-                    throw ExceptionResultEnum.ERROR.exception("印品配置未设置");
-                }
                 validSubmitParam(examTaskDetail, basicPrintConfig.getPrintContent());
                 validSubmitParam(examTaskDetail, basicPrintConfig.getPrintContent());
                 if (Objects.nonNull(examTask.getFlowId())) {
                 if (Objects.nonNull(examTask.getFlowId())) {
                     // 审核一级
                     // 审核一级
@@ -1578,21 +1575,20 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
             examTask.setSchoolId(schoolId);
             examTask.setSchoolId(schoolId);
             examTask.setOrgId(basicCourseService.getOrgIdBySchoolIdAndCourseCode(schoolId, examTask.getCourseCode()));
             examTask.setOrgId(basicCourseService.getOrgIdBySchoolIdAndCourseCode(schoolId, examTask.getCourseCode()));
 
 
-            BasicExam basicExam = basicExamService.getById(examTask.getExamId());
-            examTask.setReview(basicExam.getReview());
+            BasicPrintConfig basicPrintConfig = basicPrintConfigService.getByExamIdAndCourseCode(examTask.getExamId(), examTask.getCourseCode());
+            if (basicPrintConfig == null) {
+                throw ExceptionResultEnum.ERROR.exception("印品配置未设置");
+            }
+            examTask.setReview(basicPrintConfig.getReview());
             examTask.setUserId(sysUser.getId());
             examTask.setUserId(sysUser.getId());
             examTask.setStatus(ExamStatusEnum.SUBMIT);
             examTask.setStatus(ExamStatusEnum.SUBMIT);
             examTask.setCreateId(sysUser.getId());
             examTask.setCreateId(sysUser.getId());
             examTask.setCreateTime(System.currentTimeMillis());
             examTask.setCreateTime(System.currentTimeMillis());
 
 
-            BasicPrintConfig basicPrintConfig = basicPrintConfigService.getByExamIdAndCourseCode(examTask.getExamId(), examTask.getCourseCode());
-            if (basicPrintConfig == null) {
-                throw ExceptionResultEnum.ERROR.exception("印品配置未设置");
-            }
             examTask.setCardRuleId(basicPrintConfig.getCardRuleId());
             examTask.setCardRuleId(basicPrintConfig.getCardRuleId());
 
 
             if (Objects.isNull(examTask.getFlowId())) {
             if (Objects.isNull(examTask.getFlowId())) {
-                if (basicExam.getReview()) {
+                if (basicPrintConfig.getReview()) {
                     Map<String, Object> map = SystemConstant.buildFlowVar(examTask.getId(),
                     Map<String, Object> map = SystemConstant.buildFlowVar(examTask.getId(),
                             examTask,
                             examTask,
                             TFCustomTypeEnum.ELECTRON_FLOW,
                             TFCustomTypeEnum.ELECTRON_FLOW,
@@ -1620,6 +1616,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
 
 
             BasicCourse basicCourse = basicCourseService.findByCourseCode(examTask.getCourseCode(), schoolId);
             BasicCourse basicCourse = basicCourseService.findByCourseCode(examTask.getCourseCode(), schoolId);
 
 
+            BasicExam basicExam = basicExamService.getById(examTask.getExamId());
             if (ExamModelEnum.MODEL1.equals(basicExam.getExamModel()) || ExamModelEnum.MODEL2.equals(basicExam.getExamModel())) {
             if (ExamModelEnum.MODEL1.equals(basicExam.getExamModel()) || ExamModelEnum.MODEL2.equals(basicExam.getExamModel())) {
                 // 创建印刷计划
                 // 创建印刷计划
                 ExamDetailParams examDetailParams = JSONObject.parseObject(String.valueOf(jsonObject.get("examDetail")), ExamDetailParams.class);
                 ExamDetailParams examDetailParams = JSONObject.parseObject(String.valueOf(jsonObject.get("examDetail")), ExamDetailParams.class);

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

@@ -182,7 +182,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
     DictionaryConfig dictionaryConfig;
     DictionaryConfig dictionaryConfig;
 
 
     @Resource
     @Resource
-    BasicExamService basicExamService;
+    BasicPrintConfigService basicPrintConfigService;
 
 
     /**
     /**
      * 创建pdf前置条件
      * 创建pdf前置条件
@@ -558,9 +558,9 @@ public class TaskLogicServiceImpl implements TaskLogicService {
             }
             }
 
 
             BasicSchool basicSchool = commonCacheService.schoolCache(examPrintPlan.getSchoolId());
             BasicSchool basicSchool = commonCacheService.schoolCache(examPrintPlan.getSchoolId());
-            BasicExam basicExam = basicExamService.getById(examPrintPlan.getExamId());
-            if (Objects.isNull(basicExam)) {
-                throw ExceptionResultEnum.EXAM_IS_NULL.exception();
+            BasicPrintConfig basicPrintConfig = basicPrintConfigService.getByExamIdAndOrgId(examPrintPlan.getExamId(), examPrintPlan.getOrgId());
+            if (Objects.isNull(basicPrintConfig)) {
+                throw ExceptionResultEnum.EXAM_PRINT_CONFIG_IS_NULL.exception();
             }
             }
 
 
             //查询examDetail
             //查询examDetail
@@ -621,14 +621,14 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                 String dirNameCardA3 = createPdfUtil.mergeA3Pdf(fileTempList, examStudentPdfList, backupCardPdfList);
                 String dirNameCardA3 = createPdfUtil.mergeA3Pdf(fileTempList, examStudentPdfList, backupCardPdfList);
 
 
 //                BasicAttachment attachment = createPdfUtil.mergePdfSaveDb(dirNameA4, dirNameA3, dirNameCardA3, tbTask, sysUser.getId(), examDetail, basicExamRule, mergePdfDeleteList);
 //                BasicAttachment attachment = createPdfUtil.mergePdfSaveDb(dirNameA4, dirNameA3, dirNameCardA3, tbTask, sysUser.getId(), examDetail, basicExamRule, mergePdfDeleteList);
-                BasicAttachment attachment = createPdfUtil.mergePdfSaveDb(dirNamePaper, dirNameCardA3, tbTask, sysUser.getId(), examDetail, basicExam, fileTempList);
+                BasicAttachment attachment = createPdfUtil.mergePdfSaveDb(dirNamePaper, dirNameCardA3, tbTask, sysUser.getId(), examDetail, basicPrintConfig, fileTempList);
                 if (basicAttachmentList != null) {
                 if (basicAttachmentList != null) {
                     basicAttachmentList.add(attachment);
                     basicAttachmentList.add(attachment);
                 }
                 }
 
 
                 examDetailService.updateById(examDetail);
                 examDetailService.updateById(examDetail);
             }
             }
-            updateExamPrintPlan(basicExam, examPrintPlan);
+            updateExamPrintPlan(basicPrintConfig, examPrintPlan);
             map.computeIfAbsent("size", v -> examDetailList.size());
             map.computeIfAbsent("size", v -> examDetailList.size());
         } catch (Exception e) {
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
             log.error(SystemConstant.LOG_ERROR, e);
@@ -653,12 +653,12 @@ public class TaskLogicServiceImpl implements TaskLogicService {
     /**
     /**
      * 更新考试计划
      * 更新考试计划
      *
      *
-     * @param basicExam
+     * @param basicPrintConfig
      * @param examPrintPlan
      * @param examPrintPlan
      */
      */
     @Transactional
     @Transactional
-    public void updateExamPrintPlan(BasicExam basicExam, ExamPrintPlan examPrintPlan) {
-        if (PrintMethodEnum.AUTO == basicExam.getPrintMethod()) {
+    public void updateExamPrintPlan(BasicPrintConfig basicPrintConfig, ExamPrintPlan examPrintPlan) {
+        if (PrintMethodEnum.AUTO == basicPrintConfig.getPrintMethod()) {
             examPrintPlan.setStatus(PrintPlanStatusEnum.PRINTING);
             examPrintPlan.setStatus(PrintPlanStatusEnum.PRINTING);
             examPrintPlanService.updateById(examPrintPlan);
             examPrintPlanService.updateById(examPrintPlan);
         }
         }

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

@@ -344,47 +344,112 @@ public class CreatePdfUtil {
         pdfPackageDto.setTitlePlate(titlePlate);
         pdfPackageDto.setTitlePlate(titlePlate);
 
 
         List<JSONObject> objectList = JSON.parseArray(object.getString("basic"), JSONObject.class);
         List<JSONObject> objectList = JSON.parseArray(object.getString("basic"), JSONObject.class);
+
+        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<>();
         List<Map<String, String>> basicPlate = new ArrayList<>();
         for (JSONObject jsonObject : objectList) {
         for (JSONObject jsonObject : objectList) {
-            Map<String, String> basicMap = new HashMap<>();
             if (jsonObject.getBoolean("enable")) {
             if (jsonObject.getBoolean("enable")) {
                 String code = jsonObject.getString("code");
                 String code = jsonObject.getString("code");
                 String name = jsonObject.getString("name");
                 String name = jsonObject.getString("name");
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                if ("examTime".equals(code)) {
+                if ("examDate".equals(code) || "examTime".equals(code)) {
                     String startDate = DateUtil.format(new Date(examDetail.getExamStartTime()), SystemConstant.DATE_PATTERN);
                     String startDate = DateUtil.format(new Date(examDetail.getExamStartTime()), SystemConstant.DATE_PATTERN);
                     String endDate = DateUtil.format(new Date(examDetail.getExamEndTime()), 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 startTime = DateUtil.format(new Date(examDetail.getExamStartTime()), SystemConstant.TIME_PATTERN);
                     String endTime = DateUtil.format(new Date(examDetail.getExamEndTime()), SystemConstant.TIME_PATTERN);
                     String endTime = DateUtil.format(new Date(examDetail.getExamEndTime()), SystemConstant.TIME_PATTERN);
-                    String examTime;
-                    if (startDate.equals(endDate)) {
-                        examTime = startDate + " " + startTime + SystemConstant.HYPHEN + endTime;
+                    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 {
                     } else {
-                        examTime = startDate + " " + startTime + SystemConstant.HYPHEN + endDate + " " + endTime;
+                        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);
                     }
                     }
-                    basicMap.put("value", examTime);
-                } else if ("courseCode".equals(code)) {
-                    List<String> courseNames = examDetailCourseList.stream().map(m -> String.format("%s(%s)", m.getCourseName(), m.getCourseCode())).collect(Collectors.toList());
-                    basicMap.put("value", String.join(",", courseNames));
+                    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)) {
                 } else if ("paperNumber".equals(code)) {
                     List<String> paperNumbers = examDetailCourseList.stream().map(ExamDetailCourse::getPaperNumber).collect(Collectors.toList());
                     List<String> paperNumbers = examDetailCourseList.stream().map(ExamDetailCourse::getPaperNumber).collect(Collectors.toList());
-                    basicMap.put("value", String.join(",", paperNumbers));
-                } 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", String.join(SystemConstant.COMMA_OF_CHINESE, paperNumbers));
+                    basicPlate.add(basicMap);
+                } else if ("examPlace".equals(code)) {
+                    Map<String, String> basicMap = new HashMap<>();
+                    basicMap.put("code", code);
+                    basicMap.put("name", name);
                     basicMap.put("value", examDetail.getExamPlace());
                     basicMap.put("value", examDetail.getExamPlace());
-                } else if ("examRoom".equals(code) || "examClassroomName".equals(code)) {
+                    basicPlate.add(basicMap);
+                } else if ("examRoom".equals(code)) {
+                    Map<String, String> basicMap = new HashMap<>();
+                    basicMap.put("code", code);
+                    basicMap.put("name", name);
                     basicMap.put("value", examDetail.getExamRoom());
                     basicMap.put("value", examDetail.getExamRoom());
+                    basicPlate.add(basicMap);
                 } else if ("collegeName".equals(code)) {
                 } else if ("collegeName".equals(code)) {
                     Set<String> collegeNames = examStudentList.stream().map(ExamStudent::getCollegeName).collect(Collectors.toSet());
                     Set<String> collegeNames = examStudentList.stream().map(ExamStudent::getCollegeName).collect(Collectors.toSet());
-                    basicMap.put("value", String.join(",", collegeNames));
+                    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)) {
                 } else if ("majorName".equals(code)) {
                     Set<String> stringSet = new HashSet<>();
                     Set<String> stringSet = new HashSet<>();
                     Set<String> majorNames = examStudentList.stream().filter(m -> StringUtils.isNotBlank(m.getMajorName())).map(ExamStudent::getMajorName).collect(Collectors.toSet());
                     Set<String> majorNames = examStudentList.stream().filter(m -> StringUtils.isNotBlank(m.getMajorName())).map(ExamStudent::getMajorName).collect(Collectors.toSet());
                     if (!majorNames.isEmpty()) {
                     if (!majorNames.isEmpty()) {
                         stringSet.addAll(majorNames);
                         stringSet.addAll(majorNames);
                     }
                     }
-                    basicMap.put("value", String.join(",", stringSet));
+                    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)) {
                 } else if ("clazzName".equals(code)) {
                     Set<String> stringSet = new HashSet<>();
                     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());
                     Set<String> clazzNames = examStudentList.stream().filter(m -> m.getStudentClazzType().equals(StudentClazzEnum.BASIC_CLAZZ) && StringUtils.isNotBlank(m.getClazzName())).map(ExamStudent::getClazzName).collect(Collectors.toSet());
@@ -395,52 +460,44 @@ public class CreatePdfUtil {
                     if (!teachClazzNames.isEmpty()) {
                     if (!teachClazzNames.isEmpty()) {
                         stringSet.addAll(teachClazzNames);
                         stringSet.addAll(teachClazzNames);
                     }
                     }
-                    basicMap.put("value", String.join(",", stringSet));
+                    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 ("examCount".equals(code)) {
                 } 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()));
                     basicMap.put("value", String.valueOf(examStudentList.size()));
+                    basicPlate.add(basicMap);
                 } else if ("actualExamCount".equals(code)) {
                 } else if ("actualExamCount".equals(code)) {
+                    Map<String, String> basicMap = new HashMap<>();
+                    basicMap.put("code", code);
+                    basicMap.put("name", name);
                     basicMap.put("value", "");
                     basicMap.put("value", "");
+                    basicPlate.add(basicMap);
                 } else if ("paperCount".equals(code)) {
                 } 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);
                     basicMap.put("value", examStudentList.size() + " + " + printCount);
-                }
-                //开课学院
-                else if ("BCollege".equals(code)) {
-                    Set<String> bollegeSet = new HashSet<>();
-                    for (ExamStudentCourseDto studentCourseDto : examStudentList) {
-                        String extendFields = studentCourseDto.getExtendFields();
-                        Set<String> stringSet = JSON.parseArray(extendFields, JSONObject.class).stream().filter(m -> "BCollege".equals(m.getString("code"))).map(m -> m.getString("value")).collect(Collectors.toSet());
-                        if (!stringSet.isEmpty()) {
-                            bollegeSet.addAll(stringSet);
-                        }
-                    }
-                    basicMap.put("value", String.join(SystemConstant.COMMA_OF_CHINESE, bollegeSet));
-                }
-                //派监考学院
-                else if ("STICollege".equals(code)) {
-                    Set<String> stiCollegeSet = new HashSet<>();
-                    for (ExamStudentCourseDto studentCourseDto : examStudentList) {
-                        String extendFields = studentCourseDto.getExtendFields();
-                        Set<String> stringSet = JSON.parseArray(extendFields, JSONObject.class).stream().filter(m -> "STICollege".equals(m.getString("code"))).map(m -> m.getString("value")).collect(Collectors.toSet());
-                        if (!stringSet.isEmpty()) {
-                            stiCollegeSet.addAll(stringSet);
-                        }
-                    }
-                    basicMap.put("value", String.join(SystemConstant.COMMA_OF_CHINESE, stiCollegeSet));
-                }
-                //上课教师
-                else if ("CTeacher".equals(code)) {
-                    Set<String> cTeacherSet = new HashSet<>();
-                    for (ExamStudentCourseDto studentCourseDto : examStudentList) {
-                        String extendFields = studentCourseDto.getExtendFields();
-                        Set<String> stringSet = JSON.parseArray(extendFields, JSONObject.class).stream().filter(m -> "CTeacher".equals(m.getString("code"))).map(m -> m.getString("value")).collect(Collectors.toSet());
-                        if (!stringSet.isEmpty()) {
-                            cTeacherSet.addAll(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);
                     }
                     }
-                    basicMap.put("value", String.join(SystemConstant.COMMA_OF_CHINESE, cTeacherSet));
+                    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);
                 }
                 }
-                basicPlate.add(basicMap);
-
             }
             }
         }
         }
         pdfPackageDto.setBasicPlate(basicPlate);
         pdfPackageDto.setBasicPlate(basicPlate);
@@ -664,56 +721,130 @@ public class CreatePdfUtil {
         JSONObject jsonObject = JSON.parseObject(basicTemplate.getDisplayRange());
         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);
 
 
+        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<>();
         List<Map<String, String>> basicPlate = new ArrayList<>();
+        boolean isCourseFill = false;
+        boolean isDateFill = false;
+        boolean isPlaceFill = false;
         for (JSONObject object : objectList) {
         for (JSONObject object : objectList) {
             if (!object.getBoolean("enable")) {
             if (!object.getBoolean("enable")) {
                 continue;
                 continue;
             }
             }
             String code = object.getString("code");
             String code = object.getString("code");
             String name = object.getString("name");
             String name = object.getString("name");
-            if ("courseName".equals(code)) {
-                List<String> courseNames = examDetailCourseList.stream().map(m -> String.format("%s(%s)", m.getCourseName(), m.getCourseCode())).collect(Collectors.toList());
+            if ("courseCode".equals(code) || "courseName".equals(code)) {
                 Map<String, String> basicMap = new HashMap<>();
                 Map<String, String> basicMap = new HashMap<>();
-                basicMap.put("code", code);
-                basicMap.put("name", name);
-                basicMap.put("value", String.join(",", courseNames));
+                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);
                 basicPlate.add(basicMap);
             } else if ("paperNumber".equals(code)) {
             } else if ("paperNumber".equals(code)) {
                 List<String> paperNumbers = examDetailCourseList.stream().map(ExamDetailCourse::getPaperNumber).collect(Collectors.toList());
                 List<String> paperNumbers = examDetailCourseList.stream().map(ExamDetailCourse::getPaperNumber).collect(Collectors.toList());
                 Map<String, String> basicMap = new HashMap<>();
                 Map<String, String> basicMap = new HashMap<>();
                 basicMap.put("code", code);
                 basicMap.put("code", code);
                 basicMap.put("name", name);
                 basicMap.put("name", name);
-                basicMap.put("value", String.join(",", paperNumbers));
+                basicMap.put("value", String.join(SystemConstant.COMMA_OF_CHINESE, paperNumbers));
                 basicPlate.add(basicMap);
                 basicPlate.add(basicMap);
-            } else if ("examTime".equals(code)) {
+            } else if ("examDate".equals(code) || "examTime".equals(code)) {
                 String startDate = DateUtil.format(new Date(examDetail.getExamStartTime()), SystemConstant.DATE_PATTERN);
                 String startDate = DateUtil.format(new Date(examDetail.getExamStartTime()), SystemConstant.DATE_PATTERN);
                 String endDate = DateUtil.format(new Date(examDetail.getExamEndTime()), 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 startTime = DateUtil.format(new Date(examDetail.getExamStartTime()), SystemConstant.TIME_PATTERN);
                 String endTime = DateUtil.format(new Date(examDetail.getExamEndTime()), SystemConstant.TIME_PATTERN);
                 String endTime = DateUtil.format(new Date(examDetail.getExamEndTime()), SystemConstant.TIME_PATTERN);
-                String examTime;
-                if (startDate.equals(endDate)) {
-                    examTime = startDate + " " + startTime + SystemConstant.HYPHEN + endTime;
+
+                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 {
                 } else {
-                    examTime = startDate + " " + startTime + SystemConstant.HYPHEN + endDate + " " + endTime;
+                    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().map(ExamStudentCourseDto::getCollegeName).collect(Collectors.toSet());
                 Map<String, String> basicMap = new HashMap<>();
                 Map<String, String> basicMap = new HashMap<>();
                 basicMap.put("code", code);
                 basicMap.put("code", code);
                 basicMap.put("name", name);
                 basicMap.put("name", name);
-                basicMap.put("value", examTime);
+                basicMap.put("value", String.join(SystemConstant.COMMA_OF_CHINESE, collegeNames));
                 basicPlate.add(basicMap);
                 basicPlate.add(basicMap);
-            } else if ("examPlace".equals(code)) {
+            } else if ("majorName".equals(code)) {
+                Set<String> majorNames = examStudentList.stream().map(ExamStudentCourseDto::getMajorName).collect(Collectors.toSet());
                 Map<String, String> basicMap = new HashMap<>();
                 Map<String, String> basicMap = new HashMap<>();
                 basicMap.put("code", code);
                 basicMap.put("code", code);
                 basicMap.put("name", name);
                 basicMap.put("name", name);
-                StringJoiner stringJoiner = new StringJoiner("");
-                if (StringUtils.isNotBlank(examDetail.getExamPlace())) {
-                    stringJoiner.add(examDetail.getExamPlace());
-                }
-                if (StringUtils.isNotBlank(examDetail.getExamRoom())) {
-                    stringJoiner.add(examDetail.getExamRoom());
-                }
-                basicMap.put("value", stringJoiner.toString());
+                basicMap.put("value", String.join(SystemConstant.COMMA_OF_CHINESE, majorNames));
                 basicPlate.add(basicMap);
                 basicPlate.add(basicMap);
             } else if ("examCount".equals(code)) {
             } else if ("examCount".equals(code)) {
                 Map<String, String> basicMap = new HashMap<>();
                 Map<String, String> basicMap = new HashMap<>();
@@ -727,6 +858,20 @@ public class CreatePdfUtil {
                 basicMap.put("name", name);
                 basicMap.put("name", name);
                 basicMap.put("value", "");
                 basicMap.put("value", "");
                 basicPlate.add(basicMap);
                 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);
         pdfFillDto.setBasicPlate(basicPlate);
@@ -1088,7 +1233,7 @@ public class CreatePdfUtil {
      * @param tbTask
      * @param tbTask
      * @param userId
      * @param userId
      * @param examDetail
      * @param examDetail
-     * @param basicExam
+     * @param basicPrintConfig
      * @param fileTempList
      * @param fileTempList
      * @return
      * @return
      * @throws IOException
      * @throws IOException
@@ -1099,7 +1244,7 @@ public class CreatePdfUtil {
                                           TBTask tbTask,
                                           TBTask tbTask,
                                           Long userId,
                                           Long userId,
                                           ExamDetail examDetail,
                                           ExamDetail examDetail,
-                                          BasicExam basicExam,
+                                          BasicPrintConfig basicPrintConfig,
                                           List<File> fileTempList) throws Exception {
                                           List<File> fileTempList) throws Exception {
         File localA4PdfFile = null, localPaperPdfFile = null, localA3PdfCardFile = null;
         File localA4PdfFile = null, localPaperPdfFile = null, localA3PdfCardFile = null;
         BasicAttachment basicAttachment = null;
         BasicAttachment basicAttachment = null;
@@ -1132,7 +1277,7 @@ public class CreatePdfUtil {
         examDetail.setPaperPages(PdfUtil.getPdfPages(localPaperPdfFile));
         examDetail.setPaperPages(PdfUtil.getPdfPages(localPaperPdfFile));
         examDetail.setCardPages(PdfUtil.getPdfPages(localA3PdfCardFile));
         examDetail.setCardPages(PdfUtil.getPdfPages(localA3PdfCardFile));
         examDetail.setPagesA4(PdfUtil.getPdfPages(localA4PdfFile));
         examDetail.setPagesA4(PdfUtil.getPdfPages(localA4PdfFile));
-        if (PrintMethodEnum.AUTO == basicExam.getPrintMethod()) {
+        if (PrintMethodEnum.AUTO == basicPrintConfig.getPrintMethod()) {
             examDetail.setStatus(ExamDetailStatusEnum.WAITING);
             examDetail.setStatus(ExamDetailStatusEnum.WAITING);
         } else {
         } else {
             examDetail.setStatus(ExamDetailStatusEnum.READY);
             examDetail.setStatus(ExamDetailStatusEnum.READY);

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

@@ -142,9 +142,10 @@
                 AND a.paper_number = #{paperNumber}
                 AND a.paper_number = #{paperNumber}
                 AND c.status != 'END'
                 AND c.status != 'END'
     </select>
     </select>
-    <select id="listSyncCourseByPringPlanId"
+    <select id="listSyncCourseByPrintPlanId"
             resultType="com.qmth.distributed.print.business.bean.dto.SyncExamTaskDto">
             resultType="com.qmth.distributed.print.business.bean.dto.SyncExamTaskDto">
-        SELECT b.course_code   courseCode,
+        SELECT et.id,
+               b.course_code   courseCode,
                b.course_name   courseName,
                b.course_name   courseName,
                b.paper_number  paperNumber,
                b.paper_number  paperNumber,
                b.paper_type    paperType,
                b.paper_type    paperType,
@@ -164,7 +165,7 @@
                 <foreach collection="printPlanIds" open="(" close=")" item="printPlanId" separator=",">
                 <foreach collection="printPlanIds" open="(" close=")" item="printPlanId" separator=",">
                     #{printPlanId}
                     #{printPlanId}
                 </foreach>
                 </foreach>
-                GROUP BY b.course_code, b.course_name , b.paper_number, b.paper_type, et.sequence
+                GROUP BY et.id, b.course_code, b.course_name , b.paper_number, b.paper_type, et.sequence
     </select>
     </select>
     <select id="listByPrintPlanIdAndExamTaskId"
     <select id="listByPrintPlanIdAndExamTaskId"
             resultType="com.qmth.distributed.print.business.bean.dto.ExamDetailCourseDto">
             resultType="com.qmth.distributed.print.business.bean.dto.ExamDetailCourseDto">

+ 99 - 0
distributed-print/src/test/java/com/qmth/distributed/print/UploadCardTest.java

@@ -0,0 +1,99 @@
+package com.qmth.distributed.print;
+
+import com.alibaba.fastjson.JSONObject;
+import com.qmth.boot.tools.signature.SignatureType;
+import com.qmth.teachcloud.common.SignatureEntityTest;
+import com.qmth.teachcloud.common.contant.SystemConstant;
+import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
+import com.qmth.teachcloud.common.enums.SyncFileTypeEnum;
+import com.qmth.teachcloud.common.util.HttpKit;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ *
+ */
+@SpringBootTest
+@RunWith(SpringRunner.class)
+public class UploadCardTest {
+
+    static String accessKey = "d81badf113d1450c9f554809e1282ae1";
+    static String accessSecret = "dmILQXiRESNasxUylMNGl05R0JsaVb9t";
+
+    @Test
+    public void uploadCard() {
+        File file = new File("C:\\Users\\xf520\\Desktop\\SOFT400227-操作系统.json");
+        String examId = "230";
+        String subjectCode = "202211160001A10";
+        String hostUrl = "http://192.168.10.225:8000";
+
+        SyncFileTypeEnum type = SyncFileTypeEnum.CARD;
+        String fileUploadUrl = SystemConstant.CLOUD_MARK_FILE_UPLOAD_API;
+        fileUploadUrl = fileUploadUrl.replace("{type}", type.name().toLowerCase());
+        String postUrl = hostUrl.concat(fileUploadUrl);
+        try {
+            Map<String, String> files = new HashMap<>();
+            if (file.exists()) {
+                files.put(file.getName(), file.getPath());
+            }
+            //表单数据
+            Map<String, Object> formText = new HashMap<>();
+            formText.put("examId", examId);
+            formText.put("subjectCode", subjectCode);
+            String fileName = file.getName();
+            String suffix = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
+            if (type.equals(SyncFileTypeEnum.CARD)) {
+                if (!"zip".equals(suffix) && !"json".equals(suffix)) {
+                    throw ExceptionResultEnum.ERROR.exception("文件类型有误");
+                }
+            } else if (type.equals(SyncFileTypeEnum.PAPER) || type.equals(SyncFileTypeEnum.ANSWER)) {
+                if (!"pdf".equals(suffix) && !"json".equals(suffix)) {
+                    throw ExceptionResultEnum.ERROR.exception("文件类型有误");
+                }
+            } else {
+                throw ExceptionResultEnum.ERROR.exception("请传入文件上传类型");
+            }
+            formText.put("format", suffix);
+            formText.put("md5", DigestUtils.md5Hex(new FileInputStream(file)));
+
+            String result = HttpKit.sendPost(postUrl, getHeaders(fileUploadUrl), formText, files, null, null);
+            JSONObject jsonObject = JSONObject.parseObject(result);
+            if (jsonObject.containsKey("success")) {
+                String success = jsonObject.get("success").toString();
+                if (Boolean.parseBoolean(success)) {
+                    if (jsonObject.containsKey("url")) {
+                        System.out.println(jsonObject.get("url").toString());
+                    } else {
+                        System.out.println(success);
+                    }
+                }
+            }
+        } catch (Exception e) {
+            throw ExceptionResultEnum.ERROR.exception(e.getMessage());
+        } finally {
+            if (file != null && file.exists()) {
+                file.delete();
+            }
+        }
+    }
+
+    private Map<String, String> getHeaders(String url) {
+        long time = System.currentTimeMillis();
+        Map<String, String> header = new HashMap<>();
+        header.put(SystemConstant.HEADER_AUTHORIZATION, createSign(time, url));
+        header.put(SystemConstant.HEADER_TIME, String.valueOf(time));
+        return header;
+    }
+
+    private String createSign(long time, String url) {
+        return SignatureEntityTest.build(SignatureType.SECRET, "POST", url, time, accessKey, accessSecret);
+    }
+}

+ 0 - 23
teachcloud-common/src/main/java/com/qmth/teachcloud/common/entity/BasicExam.java

@@ -50,13 +50,6 @@ public class BasicExam extends BaseEntity implements Serializable {
     @TableField("exam_model")
     @TableField("exam_model")
     private ExamModelEnum examModel;
     private ExamModelEnum examModel;
 
 
-    @ApiModelProperty(value = "是否启用入库审核")
-    @TableField("review")
-    private Boolean review;
-
-    @ApiModelProperty(value = "提交打印方式")
-    @TableField("print_method")
-    private PrintMethodEnum printMethod;
 
 
     @ApiModelProperty(value = "启用/禁用")
     @ApiModelProperty(value = "启用/禁用")
     @TableField("enable")
     @TableField("enable")
@@ -122,22 +115,6 @@ public class BasicExam extends BaseEntity implements Serializable {
         this.examModel = examModel;
         this.examModel = examModel;
     }
     }
 
 
-    public Boolean getReview() {
-        return review;
-    }
-
-    public void setReview(Boolean review) {
-        this.review = review;
-    }
-
-    public PrintMethodEnum getPrintMethod() {
-        return printMethod;
-    }
-
-    public void setPrintMethod(PrintMethodEnum printMethod) {
-        this.printMethod = printMethod;
-    }
-
     public Boolean getEnable() {
     public Boolean getEnable() {
         return enable;
         return enable;
     }
     }

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

@@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.qmth.teachcloud.common.base.BaseEntity;
 import com.qmth.teachcloud.common.base.BaseEntity;
 import com.qmth.teachcloud.common.enums.DrawRuleEnum;
 import com.qmth.teachcloud.common.enums.DrawRuleEnum;
+import com.qmth.teachcloud.common.enums.PrintMethodEnum;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
 
 
 import java.io.Serializable;
 import java.io.Serializable;
@@ -28,6 +29,11 @@ public class BasicPrintConfig extends BaseEntity implements Serializable {
     @TableField("school_id")
     @TableField("school_id")
     private Long schoolId;
     private Long schoolId;
 
 
+    @ApiModelProperty(value = "机构id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    @TableField("org_id")
+    private Long orgId;
+
     @ApiModelProperty(value = "考试id")
     @ApiModelProperty(value = "考试id")
     @JsonSerialize(using = ToStringSerializer.class)
     @JsonSerialize(using = ToStringSerializer.class)
     @TableField("exam_id")
     @TableField("exam_id")
@@ -39,6 +45,14 @@ public class BasicPrintConfig extends BaseEntity implements Serializable {
     @TableField("enable")
     @TableField("enable")
     private Boolean enable;
     private Boolean enable;
 
 
+    @ApiModelProperty(value = "是否启用入库审核")
+    @TableField("review")
+    private Boolean review;
+
+    @ApiModelProperty(value = "提交打印方式")
+    @TableField("print_method")
+    private PrintMethodEnum printMethod;
+
     /**
     /**
      * 题卡规则(-1代表通卡)
      * 题卡规则(-1代表通卡)
      */
      */
@@ -95,6 +109,14 @@ public class BasicPrintConfig extends BaseEntity implements Serializable {
         this.schoolId = schoolId;
         this.schoolId = schoolId;
     }
     }
 
 
+    public Long getOrgId() {
+        return orgId;
+    }
+
+    public void setOrgId(Long orgId) {
+        this.orgId = orgId;
+    }
+
     public Long getExamId() {
     public Long getExamId() {
         return examId;
         return examId;
     }
     }
@@ -111,6 +133,22 @@ public class BasicPrintConfig extends BaseEntity implements Serializable {
         this.enable = enable;
         this.enable = enable;
     }
     }
 
 
+    public Boolean getReview() {
+        return review;
+    }
+
+    public void setReview(Boolean review) {
+        this.review = review;
+    }
+
+    public PrintMethodEnum getPrintMethod() {
+        return printMethod;
+    }
+
+    public void setPrintMethod(PrintMethodEnum printMethod) {
+        this.printMethod = printMethod;
+    }
+
     public Long getCardRuleId() {
     public Long getCardRuleId() {
         return cardRuleId;
         return cardRuleId;
     }
     }

+ 2 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/enums/ExceptionResultEnum.java

@@ -73,6 +73,8 @@ public enum ExceptionResultEnum {
 
 
     EXAM_IS_NULL(HttpStatus.INTERNAL_SERVER_ERROR, 50000026, "考试不存在"),
     EXAM_IS_NULL(HttpStatus.INTERNAL_SERVER_ERROR, 50000026, "考试不存在"),
 
 
+    EXAM_PRINT_CONFIG_IS_NULL(HttpStatus.INTERNAL_SERVER_ERROR, 50000026, "考试设置不存在"),
+
     EXAM_DETAIL_IS_NULL(HttpStatus.INTERNAL_SERVER_ERROR, 50000027, "考场数据为空"),
     EXAM_DETAIL_IS_NULL(HttpStatus.INTERNAL_SERVER_ERROR, 50000027, "考场数据为空"),
 
 
     EXAM_CARD_IS_NULL(HttpStatus.INTERNAL_SERVER_ERROR, 50000028, "题卡为空"),
     EXAM_CARD_IS_NULL(HttpStatus.INTERNAL_SERVER_ERROR, 50000028, "题卡为空"),