Эх сурвалжийг харах

Merge remote-tracking branch 'origin/dev_v3.0.0' into dev_v3.0.0

wangliang 3 жил өмнө
parent
commit
02af46636f

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

@@ -85,16 +85,23 @@ public class BasicPrintConfigServiceImpl extends ServiceImpl<BasicPrintConfigMap
         boolean isSuccess;
         // 新增
         if (Objects.isNull(basicPrintConfig.getId())) {
-            // 一个学院只能对应一个印品配置方案
+            // 同一个考试下,一个学院只能对应一个印品配置方案
             Long[] orgIds = basicPrintConfig.getOrgIds();
-            QueryWrapper<BasicTemplateOrg> queryWrapper = new QueryWrapper<>();
-            queryWrapper.lambda().eq(BasicTemplateOrg::getType, TemplateTypeEnum.PRINT_CONFIG)
-                    .in(BasicTemplateOrg::getOrgId, orgIds);
-            List<BasicTemplateOrg> basicTemplateOrgList = basicTemplateOrgService.list(queryWrapper);
-            if (basicTemplateOrgList != null && basicTemplateOrgList.size() > 0) {
+            QueryWrapper<BasicPrintConfig> queryWrapper = new QueryWrapper<>();
+            queryWrapper.lambda().eq(BasicPrintConfig::getSchoolId, schoolId).eq(BasicPrintConfig::getExamId, basicPrintConfig.getExamId());
+            List<BasicPrintConfig> basicPrintConfigs = this.list(queryWrapper);
+
+            if(basicPrintConfigs != null && basicPrintConfigs.size() > 0) {
+                List<Long> printConfigIds = basicPrintConfigs.stream().map(BasicPrintConfig::getId).collect(Collectors.toList());
+                QueryWrapper<BasicTemplateOrg> basicTemplateOrgQueryWrapper = new QueryWrapper<>();
+                basicTemplateOrgQueryWrapper.lambda().in(BasicTemplateOrg::getRuleId, printConfigIds).eq(BasicTemplateOrg::getType, TemplateTypeEnum.PRINT_CONFIG)
+                        .in(BasicTemplateOrg::getOrgId, orgIds);
+                List<BasicTemplateOrg> basicTemplateOrgList = basicTemplateOrgService.list(basicTemplateOrgQueryWrapper);
+                if (basicTemplateOrgList != null && basicTemplateOrgList.size() > 0) {
 //                List<Long> useOrgIds = basicTemplateOrgList.stream().map(BasicTemplateOrg::getOrgId).collect(Collectors.toList());
 //                List<SysOrg> sysOrgList = sysOrgService.findByOrgIds(useOrgIds);
-                throw ExceptionResultEnum.ERROR.exception("有" + basicTemplateOrgList.size() + "个机构已经设置了印品,不能重复设置");
+                    throw ExceptionResultEnum.ERROR.exception("有" + basicTemplateOrgList.size() + "个机构已经设置了印品,不能重复设置");
+                }
             }
 
             basicPrintConfig.setId(SystemConstant.getDbUuid());

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

@@ -24,7 +24,6 @@ import com.qmth.distributed.print.business.templete.service.TaskLogicService;
 import com.qmth.distributed.print.business.util.CreatePdfUtil;
 import com.qmth.distributed.print.business.util.HtmlToPdfUtil;
 import com.qmth.teachcloud.common.annotation.ExcelDBFieldDesc;
-import com.qmth.teachcloud.common.base.BaseEntity;
 import com.qmth.teachcloud.common.bean.dto.excel.*;
 import com.qmth.teachcloud.common.bean.params.ArraysParams;
 import com.qmth.teachcloud.common.contant.SystemConstant;
@@ -232,6 +231,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
      */
     @Transactional
     public List<BasicAttachment> createPdfCoreLogic(List<ExamDetailCourse> examDetailCourseList,
+                                                    ExamPrintPlan examPrintPlan,
                                                     ExamDetail examDetail,
                                                     SysUser sysUser,
                                                     String paperTypeParam,
@@ -250,7 +250,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                 // 印品
                 BasicPrintConfig basicPrintConfig = basicPrintConfigService.getByCourseCodeAndPaperNumber(examDetailCourse.getCourseCode(), examDetailCourse.getPaperNumber());
 
-                String printContent = basicPrintConfig.getPrintContent();
+                String printContent = StringUtils.isNotBlank(examPrintPlan.getPrintContent()) ? examPrintPlan.getPrintContent() : basicPrintConfig.getPrintContent();
                 if (StringUtils.isBlank(printContent)) {
                     return null;
                 }
@@ -307,7 +307,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                         paperType = paperTypeParam;
                         CreatePdfCacheUtil.setPaperType(key, paperType);
                     } else {
-                        paperType = createPdfUtil.getPaperType(basicPrintConfig.getDrawRule(), examTaskDetail, key);//抽取卷型
+                        DrawRuleEnum drawRuleEnum = examPrintPlan.getDrawRule() != null ? examPrintPlan.getDrawRule() : basicPrintConfig.getDrawRule();
+                        paperType = createPdfUtil.getPaperType(drawRuleEnum, examTaskDetail, key);//抽取卷型
                     }
                     examTaskDetail.setRelatePaperType(paperType);
                     examDetailCourse.setPaperType(paperType);
@@ -328,11 +329,14 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                     }
 
                     List<PaperPdfDto> paperPdfDto = null;
+
+                    int backupCount = examPrintPlan.getBackupCount() != null ? examPrintPlan.getBackupCount().intValue() : basicPrintConfig.getBackupCount();
+
                     if (printContent.contains("PAPER")) {
                         paperPdfDto = createPdfUtil.getPaperPdfFile(paperType, examTaskDetail);
 
                         //获取试卷pdf
-                        PdfDto pdfDto = createPdfUtil.getPaperPdf(paperPdfDto, basicPrintConfig.getBackupCount(), backupPaperTempPdfList);
+                        PdfDto pdfDto = createPdfUtil.getPaperPdf(paperPdfDto, backupCount, backupPaperTempPdfList);
                         if (Objects.nonNull(pdfDto)) {
                             examDetailCourse.setPaperPagesA3(pdfDto.getPageCount());
                         } else {
@@ -359,7 +363,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                             String cardContent = createPdfUtil.replaceHtmlTemplete(examCardDetail);
                             String studentContent = examCardDetail.getHtmlContent();
 
-                            for (int i = 1; i <= basicPrintConfig.getBackupCount(); i++) {
+                            for (int i = 1; i <= backupCount; i++) {
                                 BasicAttachment basicAttachment = createPdfUtil.cardHtml(String.format("%02d", i), cardContent, examDetail, examDetailCourse, examCard, jsonArray, sysUser.getId(), cardPdfTempList, basicCardRule);
                                 examDetailCourse.setCardPagesA3(basicAttachment.getPages());
                                 basicAttachmentList.add(basicAttachment);
@@ -400,10 +404,16 @@ public class TaskLogicServiceImpl implements TaskLogicService {
      */
     @Transactional
     public void createA4File(ExamPrintPlan examPrintPlan, ExamDetail examDetail, BasicSchool basicSchool, Set<File> ftlList, List<ExamDetailCourse> examDetailCourseList, List<PdfDto>... list) throws Exception {
+        // 印品
+        ExamDetailCourse examDetailCourse = examDetailCourseList.get(0);
+        BasicPrintConfig basicPrintConfig = basicPrintConfigService.getByCourseCodeAndPaperNumber(examDetailCourse.getCourseCode(), examDetailCourse.getPaperNumber());
         List<Long> examDetailCourseListIds = examDetailCourseList.stream().map(s -> s.getId()).collect(Collectors.toList());
-        if (Objects.nonNull(examPrintPlan.getOrdinaryContent())) {
+
+        String ordinaryContent = StringUtils.isNotBlank(examPrintPlan.getOrdinaryContent()) ? examPrintPlan.getOrdinaryContent() : basicPrintConfig.getOrdinaryContent();
+
+        if (StringUtils.isNotBlank(ordinaryContent)) {
             //获取普通印品
-            JSONArray jsonArrayOrdinary = JSONArray.parseArray(examPrintPlan.getOrdinaryContent());
+            JSONArray jsonArrayOrdinary = JSONArray.parseArray(ordinaryContent);
             for (int i = 0; i < jsonArrayOrdinary.size(); i++) {
                 JSONObject jsonObjectOrdinary = jsonArrayOrdinary.getJSONObject(i);
                 if (Objects.nonNull(jsonObjectOrdinary.get("attachmentId")) && !Objects.equals("", jsonObjectOrdinary.get("attachmentId"))) {
@@ -414,13 +424,15 @@ public class TaskLogicServiceImpl implements TaskLogicService {
             }
         }
 
-        if (Objects.nonNull(examPrintPlan.getVariableContent())) {
+        String variableContent = StringUtils.isNotBlank(examPrintPlan.getVariableContent()) ? examPrintPlan.getVariableContent() : basicPrintConfig.getVariableContent();
+
+        if (StringUtils.isNotBlank(variableContent)) {
             List<ExamStudentCourseDto> examStudentCourseDtoList = examStudentService.queryBySchoolIdAndExamDetailCourseIds(basicSchool.getId(), examDetailCourseListIds);
             int count = (int) examStudentCourseDtoList.stream().filter(s -> s.getPaperPageA3() != null && s.getPaperPageA3() > 2).count();
             boolean tag = count > 0 ? true : false;
 
             //获取变量印品
-            JSONArray jsonArrayVariable = JSONArray.parseArray(examPrintPlan.getVariableContent());
+            JSONArray jsonArrayVariable = JSONArray.parseArray(variableContent);
             for (int i = 0; i < jsonArrayVariable.size(); i++) {
                 JSONObject jsonObjectVariable = jsonArrayVariable.getJSONObject(i);
                 String type = (String) jsonObjectVariable.get("type");
@@ -510,6 +522,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
 
                 //创建pdf核心逻辑
                 basicAttachmentList = createPdfCoreLogic(examDetailCourseList,
+                        examPrintPlan,
                         examDetail,
                         sysUser,
                         paperTypeParam,
@@ -676,7 +689,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
         List<ExaminationImportDto> examinationImportDtoList = new ArrayList<>();
         for (int r = 1; r < totalRows; r++) {
             Row row = sheet.getRow(r);
-            if (ExcelUtil.isRowAllCellEmpty(row,head)){
+            if (ExcelUtil.isRowAllCellEmpty(row, head)) {
                 // excel中整行为空,直接跳过
                 continue;
             }
@@ -824,11 +837,11 @@ public class TaskLogicServiceImpl implements TaskLogicService {
             if (Objects.nonNull(examDetailList)) {
                 Set<Long> attachmentIds = new HashSet<>();
                 Set<Long> allAttachmentIds = examDetailList.stream().map(ExamDetail::getAttachmentId).collect(Collectors.toSet());
-                if(!CollectionUtils.isEmpty(allAttachmentIds)){
+                if (!CollectionUtils.isEmpty(allAttachmentIds)) {
                     attachmentIds.addAll(allAttachmentIds);
                 }
                 Set<Long> cardAttachmentIds = examDetailList.stream().map(ExamDetail::getCardAttachmentId).collect(Collectors.toSet());
-                if(!CollectionUtils.isEmpty(cardAttachmentIds)){
+                if (!CollectionUtils.isEmpty(cardAttachmentIds)) {
                     attachmentIds.addAll(cardAttachmentIds);
                 }
                 List<BasicAttachment> basicAttachmentList = basicAttachmentService.listByIds(attachmentIds);