Explorar el Código

Merge branch 'dev'
merge

wangliang hace 4 años
padre
commit
9dd5e8e0a6

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

@@ -48,6 +48,7 @@ import java.io.*;
 import java.lang.reflect.Field;
 import java.time.LocalDateTime;
 import java.util.*;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 /**
@@ -118,6 +119,9 @@ public class TaskLogicServiceImpl implements TaskLogicService {
     @Resource
     TBTaskService tbTaskService;
 
+    @Resource
+    BasicCardRuleService basicCardRuleService;
+
     /**
      * 创建pdf前置条件
      *
@@ -187,6 +191,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                                                     List<PdfDto>... list
     ) throws IOException, DocumentException {
         if (Objects.nonNull(examDetailCourseList) && examDetailCourseList.size() > 0) {
+            Map<Long, BasicCardRule> basicCardRuleMap = new HashMap<>();
             for (ExamDetailCourse examDetailCourse : examDetailCourseList) {
                 List<PdfDto> paperPdfTempList = new ArrayList<>();//所有试卷
                 List<PdfDto> examStudentTempPdfList = new ArrayList<>();//所有题卡
@@ -207,6 +212,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                     throw ExceptionResultEnum.EXAM_TASK_IS_NULL.exception();
                 }
                 Set<Long> examTaskIds = examTaskList.stream().map(s -> s.getId()).collect(Collectors.toSet());
+                Map<Long, ExamTask> examTaskMap = examTaskList.stream().collect(
+                        Collectors.toMap(ExamTask::getId, Function.identity(), (dto1, dto2) -> dto1));
 
                 QueryWrapper<ExamTaskDetail> examTaskDetailQueryWrapper = new QueryWrapper<>();
                 examTaskDetailQueryWrapper.lambda().in(ExamTaskDetail::getExamTaskId, examTaskIds)
@@ -220,6 +227,19 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                     if (Objects.isNull(examCard)) {
                         throw ExceptionResultEnum.EXAM_CARD_IS_NULL.exception();
                     }
+
+                    //查询题卡规则
+                    ExamTask examTask = examTaskMap.get(examTaskDetail.getExamTaskId());
+                    BasicCardRule basicCardRule = null;
+                    if (Objects.nonNull(examTask)) {
+                        if (!basicCardRuleMap.containsKey(examTask.getCardRuleId())) {
+                            basicCardRule = basicCardRuleService.getById(examTask.getCardRuleId());
+                            BasicCardRule finalBasicCardRule = basicCardRule;
+                            basicCardRuleMap.computeIfAbsent(examTask.getCardRuleId(), v -> finalBasicCardRule);
+                        } else {
+                            basicCardRule = basicCardRuleMap.get(examTask.getCardRuleId());
+                        }
+                    }
                     QueryWrapper<ExamCardDetail> examCardDetailQueryWrapper = new QueryWrapper<>();
                     examCardDetailQueryWrapper.lambda().eq(ExamCardDetail::getCardId, examCard.getId());
                     List<ExamCardDetail> examCardDetailList = examCardDetailService.list(examCardDetailQueryWrapper);
@@ -256,7 +276,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                         String studentContent = cardContent;
 
                         for (int i = 1; i <= examPrintPlan.getBackupCount(); i++) {
-                            BasicAttachment basicAttachment = createPdfUtil.cardHtml(String.format("%02d", i), cardContent, examDetail, examDetailCourse, examCard, jsonArray, sysUser.getId(), cardPdfTempList);
+                            BasicAttachment basicAttachment = createPdfUtil.cardHtml(String.format("%02d", i), cardContent, examDetail, examDetailCourse, examCard, jsonArray, sysUser.getId(), cardPdfTempList, basicCardRule);
                             examDetailCourse.setCardPagesA3(basicAttachment.getPages());
                             basicAttachmentList.add(basicAttachment);
                         }

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

@@ -638,10 +638,11 @@ public class CreatePdfUtil {
      * @param jsonArray
      * @param userId
      * @param cardPdfList
+     * @param basicCardRule
      * @return
      * @throws IOException
      */
-    public BasicAttachment cardHtml(String sequence, String cardContent, ExamDetail examDetail, ExamDetailCourse examDetailCourse, ExamCard examCard, JSONArray jsonArray, Long userId, List<PdfDto> cardPdfList) throws IOException {
+    public BasicAttachment cardHtml(String sequence, String cardContent, ExamDetail examDetail, ExamDetailCourse examDetailCourse, ExamCard examCard, JSONArray jsonArray, Long userId, List<PdfDto> cardPdfList, BasicCardRule basicCardRule) throws IOException {
         //通用题卡
         String cardTemp = cardContent;
         cardTemp = cardTemp.replaceAll("\\$\\{paperTypeName\\}", examDetailCourse.getPaperType());
@@ -649,7 +650,15 @@ public class CreatePdfUtil {
         if (Objects.nonNull(examDetailCourse.getPaperType())) {
             cardTemp = cardTemp.replaceAll("\\$\\{paperType\\}", GoogleBarCodeUtil.createBarCode(SystemConstant.convertPaperType(examDetailCourse.getPaperType()), false));
         }
-        Map<String, Object> map = ConvertUtil.analyzeDateAndTime(examDetail.getExamStartTime(), examDetail.getExamEndTime());
+        if (Objects.nonNull(basicCardRule) && Objects.nonNull(basicCardRule.getExtendFields())) {
+            JSONArray jsonObjectExtend = (JSONArray) JSONArray.parse(basicCardRule.getExtendFields());//扩展字段
+            if (Objects.nonNull(jsonObjectExtend)) {
+                for (int i = 0; i < jsonObjectExtend.size(); i++) {
+                    JSONObject object = (JSONObject) jsonObjectExtend.get(i);
+                    cardTemp = cardTemp.replaceAll("\\$\\{" + object.get("code") + "\\}", String.valueOf(object.get("value")));
+                }
+            }
+        }
         cardTemp = cardTemp.replaceAll("\\$\\{examDate\\}", "");
         cardTemp = cardTemp.replaceAll("\\$\\{examTime\\}", "");
         cardTemp = cardTemp.replaceAll("\\$\\{ticketNumber\\}", "");

+ 3 - 3
distributed-print/src/main/resources/application.properties

@@ -12,7 +12,7 @@ spring.application.name=distributed-print
 #\u6570\u636E\u6E90\u914D\u7F6E
 db.host=localhost
 db.port=3306
-db.name=distributed-136
+db.name=distributed-test
 db.username=root
 db.password=123456789
 
@@ -58,8 +58,8 @@ sys.config.adminLogoUrl=http://qmth-test.oss-cn-shenzhen.aliyuncs.com/frontend/w
 #sys.config.htmlToPdfUrl=/usr/local/bin/wkhtmltopdf
 sys.config.htmlToPdfUrl=/usr/local/bin/wkhtmltopdf
 sys.config.autoCreatePdfResetMaxCount=5
-sys.config.threadPoolCoreSize=5
-sys.config.customThreadPoolCoreSize=false
+sys.config.threadPoolCoreSize=1
+sys.config.customThreadPoolCoreSize=true
 spring.resources.static-locations=file:${sys.config.serverUpload},classpath:/META-INF/resources/,classpath:/resources/
 
 org.center.url=https://solar.qmth.com.cn