xiaof преди 3 години
родител
ревизия
1961dbf70d

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

@@ -29,7 +29,7 @@ public interface ClientService {
 
 
     List<Map<String, Object>> getPrintDataBatch(String machineCode, String orgId, String printPlanId, String status, String courseCode, String paperNumber, String examPlace, String examRoom, Long examStartTime, Long examEndTime, Boolean isDownload, Boolean validate);
     List<Map<String, Object>> getPrintDataBatch(String machineCode, String orgId, String printPlanId, String status, String courseCode, String paperNumber, String examPlace, String examRoom, Long examStartTime, Long examEndTime, Boolean isDownload, Boolean validate);
 
 
-    Map<String, String> getUrlByExamDetailId(Long examDetailId);
+    Map<String, Object> getUrlByExamDetailId(Long examDetailId);
 
 
     Boolean updateDownload(Long examDetailId, String machineCode, Boolean isDownload);
     Boolean updateDownload(Long examDetailId, String machineCode, Boolean isDownload);
 
 

+ 27 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ClientServiceImpl.java

@@ -353,11 +353,35 @@ public class ClientServiceImpl implements ClientService {
     }
     }
 
 
     @Override
     @Override
-    public Map<String, String> getUrlByExamDetailId(Long examDetailId) {
-        Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
+    public Map<String, Object> getUrlByExamDetailId(Long examDetailId) {
+        Map<String, Object> finalMap = new HashMap<>();
         ExamDetail examDetail = examDetailService.getById(examDetailId);
         ExamDetail examDetail = examDetailService.getById(examDetailId);
         BasicAttachment attachment = basicAttachmentService.getById(examDetail.getAttachmentId());
         BasicAttachment attachment = basicAttachmentService.getById(examDetail.getAttachmentId());
-        return attachment == null ? null : teachcloudCommonService.filePreviewByAttachmentId(attachment.getId(), false);
+        finalMap.put("total", attachment == null ? null : teachcloudCommonService.filePreviewByAttachmentId(attachment.getId(), false));
+
+        ExamPrintPlan examPrintPlan = examPrintPlanService.getById(examDetail.getPrintPlanId());
+        String variableContent = examPrintPlan.getVariableContent();
+        String ordinaryContent = examPrintPlan.getOrdinaryContent();
+        List<Map> variableList = JSONObject.parseArray(variableContent, Map.class);
+        List<Map> otherList = new ArrayList<>();
+        //印品附件信息
+        String attachmentPath = examDetail.getAttachmentPath();
+        if (StringUtils.isNotBlank(attachmentPath)) {
+            JSONObject jsonObject = JSONObject.parseObject(attachmentPath);
+            String pathString = jsonObject.getString("path");
+            List<Map> pathList = JSONObject.parseArray(pathString, Map.class);
+            if (!pathList.isEmpty()) {
+                for (Map contentMap : variableList) {
+                    spliceOtherContent(otherList, pathList, contentMap);
+                }
+                List<Map> ordinaryList = JSONObject.parseArray(ordinaryContent, Map.class);
+                for (Map contentMap : ordinaryList) {
+                    spliceOtherContent(otherList, pathList, contentMap);
+                }
+            }
+        }
+        finalMap.put("other", otherList);
+        return finalMap;
     }
     }
 
 
     @Override
     @Override

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

@@ -194,13 +194,17 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
 //            examStudentService.updatePaperType(examDetailCourseIds, paperParam.getRelatePaperType());
 //            examStudentService.updatePaperType(examDetailCourseIds, paperParam.getRelatePaperType());
             ExamTaskDetail examTaskDetail = this.getByExamTaskId(newExamTask.getId());
             ExamTaskDetail examTaskDetail = this.getByExamTaskId(newExamTask.getId());
             List<String> types = Arrays.asList(paperParam.getRelatePaperType().split("/"));
             List<String> types = Arrays.asList(paperParam.getRelatePaperType().split("/"));
+            int drawCount = examTaskDetail.getDrawCount().intValue();
+            if (drawCount - types.size() > 0) {
+                throw ExceptionResultEnum.ERROR.exception("没有足够数量的卷型可用");
+            }
             for (Long examDetailCourseId : examDetailCourseIds) {
             for (Long examDetailCourseId : examDetailCourseIds) {
                 QueryWrapper<ExamStudent> studentQueryWrapper = new QueryWrapper<>();
                 QueryWrapper<ExamStudent> studentQueryWrapper = new QueryWrapper<>();
                 studentQueryWrapper.lambda().eq(ExamStudent::getExamDetailCourseId, examDetailCourseId);
                 studentQueryWrapper.lambda().eq(ExamStudent::getExamDetailCourseId, examDetailCourseId);
                 List<ExamStudent> students = examStudentService.list(studentQueryWrapper);
                 List<ExamStudent> students = examStudentService.list(studentQueryWrapper);
                 int i = 0;
                 int i = 0;
                 for (ExamStudent student : students) {
                 for (ExamStudent student : students) {
-                    int mod = i % examTaskDetail.getDrawCount();
+                    int mod = i % drawCount;
                     student.setPaperType(types.get(mod));
                     student.setPaperType(types.get(mod));
                     examStudentService.updateById(student);
                     examStudentService.updateById(student);
                     i++;
                     i++;
@@ -214,7 +218,6 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
                 SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
                 SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
                 Map<String, Object> map = tbTaskService.saveTask(TaskTypeEnum.CREATE_PDF, paperParam.getPrintPlanId(), sysUser, listEntry.getKey());
                 Map<String, Object> map = tbTaskService.saveTask(TaskTypeEnum.CREATE_PDF, paperParam.getPrintPlanId(), sysUser, listEntry.getKey());
                 map.computeIfAbsent("examDetailCourseIds", v -> listEntry.getValue());
                 map.computeIfAbsent("examDetailCourseIds", v -> listEntry.getValue());
-                // todo xf 多卷型
                 map.computeIfAbsent("paperType", v -> paperParam.getRelatePaperType());
                 map.computeIfAbsent("paperType", v -> paperParam.getRelatePaperType());
                 asyncCreatePdfTempleteService.createPdf(map, null);
                 asyncCreatePdfTempleteService.createPdf(map, null);
             }
             }

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

@@ -215,7 +215,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                                                     List<BasicAttachment> basicAttachmentList,
                                                     List<BasicAttachment> basicAttachmentList,
                                                     Set<Long> attachmentIds,
                                                     Set<Long> attachmentIds,
                                                     List<PdfDto>... list
                                                     List<PdfDto>... list
-    ) throws IOException, DocumentException {
+    ) throws IOException {
         if (Objects.nonNull(examDetailCourseList) && examDetailCourseList.size() > 0) {
         if (Objects.nonNull(examDetailCourseList) && examDetailCourseList.size() > 0) {
             String printContent = examPrintPlan.getPrintContent();
             String printContent = examPrintPlan.getPrintContent();
             if (StringUtils.isBlank(printContent)) {
             if (StringUtils.isBlank(printContent)) {

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

@@ -28,11 +28,13 @@ import com.qmth.teachcloud.common.util.OssUtil;
 import com.qmth.teachcloud.common.util.RedisUtil;
 import com.qmth.teachcloud.common.util.RedisUtil;
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.hibernate.validator.internal.util.logging.formatter.CollectionOfClassesObjectFormatter;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import java.io.File;
 import java.io.File;
@@ -440,6 +442,8 @@ public class CreatePdfUtil {
      * @throws IOException
      * @throws IOException
      */
      */
     public PaperPdfDto getPaperPdfFile(String paperType, ExamTaskDetail examTaskDetail) throws IOException {
     public PaperPdfDto getPaperPdfFile(String paperType, ExamTaskDetail examTaskDetail) throws IOException {
+        String[] paperTypes = paperType.split(",");
+        List<PaperPdfDto> paperPdfDtoList = new ArrayList<>();
         PaperPdfDto paperPdfDto = null;
         PaperPdfDto paperPdfDto = null;
         JSONArray jsonArrayPaper = JSONArray.parseArray(examTaskDetail.getPaperAttachmentIds());
         JSONArray jsonArrayPaper = JSONArray.parseArray(examTaskDetail.getPaperAttachmentIds());
         for (int i = 0; i < jsonArrayPaper.size(); i++) {
         for (int i = 0; i < jsonArrayPaper.size(); i++) {
@@ -451,12 +455,16 @@ public class CreatePdfUtil {
                     throw ExceptionResultEnum.ATTACHMENT_IS_NULL.exception();
                     throw ExceptionResultEnum.ATTACHMENT_IS_NULL.exception();
                 }
                 }
                 String name = (String) object.get("name");
                 String name = (String) object.get("name");
-                if (Objects.equals(name.toUpperCase(), paperType.toUpperCase())) {
-                    File file = teachcloudCommonService.getFile(basicAttachment.getPath(), false);
-                    int pages = (int) object.get("pages");
-                    paperPdfDto = new PaperPdfDto(file, pages);
-                    break;
+                for (String type : paperTypes) {
+                    if (Objects.equals(name.toUpperCase(), type.toUpperCase())) {
+                        File file = teachcloudCommonService.getFile(basicAttachment.getPath(), false);
+                        int pages = (int) object.get("pages");
+                        paperPdfDto = new PaperPdfDto(file, pages);
+                        paperPdfDtoList.add(paperPdfDto);
+                        break;
+                    }
                 }
                 }
+
             }
             }
         }
         }
         return paperPdfDto;
         return paperPdfDto;
@@ -477,6 +485,8 @@ public class CreatePdfUtil {
         String unexposedPaperType = examTaskDetail.getUnexposedPaperType();
         String unexposedPaperType = examTaskDetail.getUnexposedPaperType();
         //已曝光卷型
         //已曝光卷型
         String exposedPaperType = examTaskDetail.getExposedPaperType();
         String exposedPaperType = examTaskDetail.getExposedPaperType();
+        // 单次抽取套数
+        int drawCount = examTaskDetail.getDrawCount().intValue();
         if (drawRule == DrawRuleEnum.ONE) {
         if (drawRule == DrawRuleEnum.ONE) {
             if (Objects.isNull(unexposedPaperType) || Objects.equals(unexposedPaperType.trim(), "")) {
             if (Objects.isNull(unexposedPaperType) || Objects.equals(unexposedPaperType.trim(), "")) {
                 CreatePdfCacheUtil.deletePaperType(key);
                 CreatePdfCacheUtil.deletePaperType(key);
@@ -499,6 +509,9 @@ public class CreatePdfUtil {
                     if (Objects.isNull(paperType) || (StringUtils.isNotBlank(unexposedPaperType) && !unexposedPaperType.contains(paperType))) {
                     if (Objects.isNull(paperType) || (StringUtils.isNotBlank(unexposedPaperType) && !unexposedPaperType.contains(paperType))) {
                         if (drawRule == DrawRuleEnum.ONE) {
                         if (drawRule == DrawRuleEnum.ONE) {
                             paperTypes = unexposedPaperType.split(",");
                             paperTypes = unexposedPaperType.split(",");
+                            if (paperTypes.length - drawCount < 0) {
+                                throw ExceptionResultEnum.ERROR.exception("没有可用卷型");
+                            }
                         } else {
                         } else {
                             if (Objects.nonNull(unexposedPaperType)) {
                             if (Objects.nonNull(unexposedPaperType)) {
                                 paperTypes = unexposedPaperType.split(",");
                                 paperTypes = unexposedPaperType.split(",");
@@ -506,8 +519,7 @@ public class CreatePdfUtil {
                                 paperTypes = exposedPaperType.split(",");
                                 paperTypes = exposedPaperType.split(",");
                             }
                             }
                         }
                         }
-                        int paperRandom = new Random().nextInt(paperTypes.length);
-                        paperType = paperTypes[paperRandom];
+                        paperType = randomPaperType(paperTypes, exposedPaperType.split(","), drawCount);
                         CreatePdfCacheUtil.setPaperType(key, paperType);
                         CreatePdfCacheUtil.setPaperType(key, paperType);
                     }
                     }
                     break;
                     break;
@@ -532,6 +544,32 @@ public class CreatePdfUtil {
         return paperType;
         return paperType;
     }
     }
 
 
+    private String randomPaperType(String[] unexposedPaperTypes, String[] exposedPaperTypes, int drawCount) {
+        List<String> finalTypes = new ArrayList<>();
+        List<String> unexposedPaperTypesList = Arrays.asList(unexposedPaperTypes);
+        List<String> exposedPaperTypesList = Arrays.asList(exposedPaperTypes);
+        if (unexposedPaperTypesList.size() - drawCount >= 0) {
+            for (int i = 0; i < drawCount; i++) {
+                int paperRandom = new Random().nextInt(unexposedPaperTypesList.size());
+                finalTypes.add(unexposedPaperTypesList.get(paperRandom));
+                unexposedPaperTypesList.remove(paperRandom);
+            }
+
+        } else {
+            for (int i = 0; i < unexposedPaperTypesList.size(); i++) {
+                int paperRandom = new Random().nextInt(unexposedPaperTypesList.size());
+                finalTypes.add(unexposedPaperTypesList.get(paperRandom));
+                unexposedPaperTypesList.remove(paperRandom);
+            }
+            for (int i = 0; i < drawCount - unexposedPaperTypesList.size(); i++) {
+                int paperRandom = new Random().nextInt(exposedPaperTypesList.size());
+                finalTypes.add(exposedPaperTypesList.get(paperRandom));
+                exposedPaperTypesList.remove(paperRandom);
+            }
+        }
+        return String.join(",", finalTypes);
+    }
+
     /**
     /**
      * 合并A3 pdf
      * 合并A3 pdf
      *
      *

+ 1 - 1
distributed-print/src/main/java/com/qmth/distributed/print/api/ClientController.java

@@ -302,7 +302,7 @@ public class ClientController {
     @ApiOperation(value = "印刷管理-查看")
     @ApiOperation(value = "印刷管理-查看")
     @RequestMapping(value = "/print/preview", method = RequestMethod.POST)
     @RequestMapping(value = "/print/preview", method = RequestMethod.POST)
     public Result printPreview(@RequestParam("examDetailId") Long examDetailId) {
     public Result printPreview(@RequestParam("examDetailId") Long examDetailId) {
-        Map<String, String> map = clientService.getUrlByExamDetailId(examDetailId);
+        Map<String, Object> map = clientService.getUrlByExamDetailId(examDetailId);
         return ResultUtil.ok(map);
         return ResultUtil.ok(map);
     }
     }
 
 

+ 0 - 9
distributed-print/src/main/java/com/qmth/distributed/print/api/ExamTaskController.java

@@ -559,7 +559,6 @@ public class ExamTaskController {
      */
      */
     @ApiOperation(value = "暂存/提交")
     @ApiOperation(value = "暂存/提交")
     @RequestMapping(value = "/save_task_apply", method = RequestMethod.POST)
     @RequestMapping(value = "/save_task_apply", method = RequestMethod.POST)
-    @Aac(auth = BOOL.FALSE)
     public Result saveTaskApply(@RequestBody ExamTaskApplyParam examTaskApplyParam) throws IOException {
     public Result saveTaskApply(@RequestBody ExamTaskApplyParam examTaskApplyParam) throws IOException {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         examTaskApplyParam.getExamTask().setUserId(sysUser.getId());
         examTaskApplyParam.getExamTask().setUserId(sysUser.getId());
@@ -584,7 +583,6 @@ public class ExamTaskController {
      */
      */
     @ApiOperation(value = "切换题卡")
     @ApiOperation(value = "切换题卡")
     @RequestMapping(value = "/switch_card", method = RequestMethod.POST)
     @RequestMapping(value = "/switch_card", method = RequestMethod.POST)
-    @Aac(auth = BOOL.FALSE)
     public Result switchCard(@RequestParam(value = "examTaskId") Long examTaskId) {
     public Result switchCard(@RequestParam(value = "examTaskId") Long examTaskId) {
         examTaskService.switchCard(examTaskId);
         examTaskService.switchCard(examTaskId);
         return ResultUtil.ok(true, "");
         return ResultUtil.ok(true, "");
@@ -602,7 +600,6 @@ public class ExamTaskController {
      */
      */
     @ApiOperation(value = "卷库查询-发布印刷任务-查看列表")
     @ApiOperation(value = "卷库查询-发布印刷任务-查看列表")
     @RequestMapping(value = "/list_task_print", method = RequestMethod.POST)
     @RequestMapping(value = "/list_task_print", method = RequestMethod.POST)
-    @Aac(auth = BOOL.FALSE)
     public Result listTaskPrintStudent(@RequestParam(value = "printPlanId") Long printPlanId,
     public Result listTaskPrintStudent(@RequestParam(value = "printPlanId") Long printPlanId,
                                        @RequestParam(value = "courseCode") String courseCode,
                                        @RequestParam(value = "courseCode") String courseCode,
                                        @RequestParam(value = "paperNumber") Long paperNumber,
                                        @RequestParam(value = "paperNumber") Long paperNumber,
@@ -620,7 +617,6 @@ public class ExamTaskController {
      */
      */
     @ApiOperation(value = "卷库查询-发布印刷任务-扩展字段列表")
     @ApiOperation(value = "卷库查询-发布印刷任务-扩展字段列表")
     @RequestMapping(value = "/list_task_print_extend_fields", method = RequestMethod.POST)
     @RequestMapping(value = "/list_task_print_extend_fields", method = RequestMethod.POST)
-    @Aac(auth = BOOL.FALSE)
     public Result listTaskPrintExtendFields() {
     public Result listTaskPrintExtendFields() {
         List<TaskPrintExtendFieldsDto> extendFieldsDtos = examTaskPrintService.listTaskPrintExtendFields();
         List<TaskPrintExtendFieldsDto> extendFieldsDtos = examTaskPrintService.listTaskPrintExtendFields();
         return ResultUtil.ok(extendFieldsDtos);
         return ResultUtil.ok(extendFieldsDtos);
@@ -634,7 +630,6 @@ public class ExamTaskController {
      */
      */
     @ApiOperation(value = "卷库查询-发布印刷任务-班级列表")
     @ApiOperation(value = "卷库查询-发布印刷任务-班级列表")
     @RequestMapping(value = "/list_task_print_class", method = RequestMethod.POST)
     @RequestMapping(value = "/list_task_print_class", method = RequestMethod.POST)
-    @Aac(auth = BOOL.FALSE)
     public Result listTaskPrintClass(@RequestParam(value = "printPlanId") String printPlanId,
     public Result listTaskPrintClass(@RequestParam(value = "printPlanId") String printPlanId,
                                      @RequestParam(value = "courseCode") String courseCode,
                                      @RequestParam(value = "courseCode") String courseCode,
                                      @RequestParam(value = "paperNumber") String paperNumber) {
                                      @RequestParam(value = "paperNumber") String paperNumber) {
@@ -649,7 +644,6 @@ public class ExamTaskController {
      */
      */
     @ApiOperation(value = "卷库查询-发布印刷任务-印刷室列表")
     @ApiOperation(value = "卷库查询-发布印刷任务-印刷室列表")
     @RequestMapping(value = "/list_task_print_house", method = RequestMethod.POST)
     @RequestMapping(value = "/list_task_print_house", method = RequestMethod.POST)
-    @Aac(auth = BOOL.FALSE)
     public Result listTaskPrintHouse() {
     public Result listTaskPrintHouse() {
         List<TaskPrintHouseDto> houseDtos = examTaskPrintService.listHouse();
         List<TaskPrintHouseDto> houseDtos = examTaskPrintService.listHouse();
         return ResultUtil.ok(houseDtos);
         return ResultUtil.ok(houseDtos);
@@ -663,7 +657,6 @@ public class ExamTaskController {
      */
      */
     @ApiOperation(value = "卷库查询-发布印刷任务")
     @ApiOperation(value = "卷库查询-发布印刷任务")
     @RequestMapping(value = "/save_task_print", method = RequestMethod.POST)
     @RequestMapping(value = "/save_task_print", method = RequestMethod.POST)
-    @Aac(auth = BOOL.FALSE)
     public Result createTaskPrint(@RequestBody ExamTaskPrint examTaskPrint) throws IOException {
     public Result createTaskPrint(@RequestBody ExamTaskPrint examTaskPrint) throws IOException {
         ExamDetail examDetail = examTaskPrintService.createTaskPrint(examTaskPrint);
         ExamDetail examDetail = examTaskPrintService.createTaskPrint(examTaskPrint);
         // 调用生成pdf方法
         // 调用生成pdf方法
@@ -680,7 +673,6 @@ public class ExamTaskController {
      */
      */
     @ApiOperation(value = "卷库查询-发布印刷任务-查看考生")
     @ApiOperation(value = "卷库查询-发布印刷任务-查看考生")
     @RequestMapping(value = "/list_task_print_student", method = RequestMethod.POST)
     @RequestMapping(value = "/list_task_print_student", method = RequestMethod.POST)
-    @Aac(auth = BOOL.FALSE)
     public Result listTaskPrintStudent(@RequestParam(value = "classId") String classId,
     public Result listTaskPrintStudent(@RequestParam(value = "classId") String classId,
                                        @RequestParam Integer pageNumber,
                                        @RequestParam Integer pageNumber,
                                        @RequestParam Integer pageSize) {
                                        @RequestParam Integer pageSize) {
@@ -696,7 +688,6 @@ public class ExamTaskController {
      */
      */
     @ApiOperation(value = "卷库查询-发布印刷任务-删除")
     @ApiOperation(value = "卷库查询-发布印刷任务-删除")
     @RequestMapping(value = "/remove_task_print", method = RequestMethod.POST)
     @RequestMapping(value = "/remove_task_print", method = RequestMethod.POST)
-    @Aac(auth = BOOL.FALSE)
     public Result listTaskPrintStudent(@RequestParam(value = "examTaskPrintId") Long examTaskPrintId) {
     public Result listTaskPrintStudent(@RequestParam(value = "examTaskPrintId") Long examTaskPrintId) {
         examTaskPrintService.remove(examTaskPrintId);
         examTaskPrintService.remove(examTaskPrintId);
         return ResultUtil.ok(true, "");
         return ResultUtil.ok(true, "");