فهرست منبع

ExamTaskDetail去掉cardId

wangliang 2 سال پیش
والد
کامیت
aae5f7e28f
12فایلهای تغییر یافته به همراه361 افزوده شده و 204 حذف شده
  1. 24 13
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/ExamTaskDetail.java
  2. 9 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamTaskDetailMapper.java
  3. 8 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamTaskDetailService.java
  4. 40 30
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/DownloadServiceImpl.java
  5. 4 3
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamCardServiceImpl.java
  6. 27 17
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamPaperStructureServiceImpl.java
  7. 79 20
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskDetailServiceImpl.java
  8. 79 58
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskServiceImpl.java
  9. 49 39
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/TaskLogicServiceImpl.java
  10. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/CreatePdfUtil.java
  11. 18 0
      distributed-print-business/src/main/resources/mapper/ExamTaskDetailMapper.xml
  12. 23 21
      distributed-print/src/main/java/com/qmth/distributed/print/api/MenuCustomController.java

+ 24 - 13
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/ExamTaskDetail.java

@@ -54,12 +54,12 @@ public class ExamTaskDetail extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "转换后A3试卷附件")
     @TableField("paper_attachment_ids")
     private String paperAttachmentIds;
-    /**
-     * 题卡ID
-     */
-    @JsonSerialize(using = ToStringSerializer.class)
-    @TableField("card_id")
-    private Long cardId;
+//    /**
+//     * 题卡ID
+//     */
+//    @JsonSerialize(using = ToStringSerializer.class)
+//    @TableField("card_id")
+//    private Long cardId;
 
     @TableField("make_method")
     private String makeMethod;
@@ -101,6 +101,18 @@ public class ExamTaskDetail extends BaseEntity implements Serializable {
     @TableField(exist = false)
     private List<Long> approveUserIds;
 
+    @ApiModelProperty(value = "题卡id")
+    @TableField(exist = false)
+    private String cardId;
+
+    public String getCardId() {
+        return cardId;
+    }
+
+    public void setCardId(String cardId) {
+        this.cardId = cardId;
+    }
+
     public static long getSerialVersionUID() {
         return serialVersionUID;
     }
@@ -145,14 +157,13 @@ public class ExamTaskDetail extends BaseEntity implements Serializable {
         this.paperAttachmentIds = paperAttachmentIds;
     }
 
-    public Long getCardId() {
-        return cardId;
-    }
-
-    public void setCardId(Long cardId) {
-        this.cardId = cardId;
-    }
+//    public Long getCardId() {
+//        return cardId;
+//    }
 
+//    public void setCardId(Long cardId) {
+//        this.cardId = cardId;
+//    }
     public String getMakeMethod() {
         return makeMethod;
     }

+ 9 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamTaskDetailMapper.java

@@ -8,7 +8,6 @@ import com.qmth.distributed.print.business.entity.ExamTaskDetail;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
 
 /**
@@ -20,7 +19,15 @@ import java.util.Set;
  * @since 2021-03-23
  */
 public interface ExamTaskDetailMapper extends BaseMapper<ExamTaskDetail> {
-    IPage<ExamTaskDetailDto> listPage(Page<ExamTaskDetailDto> page, @Param("schoolId") Long schoolId,@Param("semesterId") Long semesterId,@Param("examId") Long examId, @Param("relateType") String relateType, @Param("printPlanIdList") List<Long> printPlanIdList, @Param("courseCode") String courseCode, @Param("paperNumber") String paperNumber, @Param("userName") String userName, @Param("cardRuleId") Long cardRuleId, @Param("orgIds") Set<Long> orgIds);
+    IPage<ExamTaskDetailDto> listPage(Page<ExamTaskDetailDto> page, @Param("schoolId") Long schoolId, @Param("semesterId") Long semesterId, @Param("examId") Long examId, @Param("relateType") String relateType, @Param("printPlanIdList") List<Long> printPlanIdList, @Param("courseCode") String courseCode, @Param("paperNumber") String paperNumber, @Param("userName") String userName, @Param("cardRuleId") Long cardRuleId, @Param("orgIds") Set<Long> orgIds);
 
     List<String> listExamDetailCourse(@Param("schoolId") Long schoolId, @Param("paperType") String paperType, @Param("printPlanId") Long printPlanId, @Param("courseCode") String courseCode, @Param("paperNumber") String paperNumber);
+
+    /**
+     * 根据card查找json
+     *
+     * @param cardId
+     * @return
+     */
+    List<ExamTaskDetail> getExamTaskDetailByCardIdJson(@Param("cardId") String cardId);
 }

+ 8 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamTaskDetailService.java

@@ -38,4 +38,12 @@ public interface ExamTaskDetailService extends IService<ExamTaskDetail> {
     boolean paperUpdate(ExamTaskDetail examTaskDetail);
 
     ExamTaskDetail getByExamTaskId(Long examTaskId);
+
+    /**
+     * 根据card查找json
+     *
+     * @param cardId
+     * @return
+     */
+    List<ExamTaskDetail> getExamTaskDetailByCardIdJson(String cardId);
 }

+ 40 - 30
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/DownloadServiceImpl.java

@@ -1,5 +1,6 @@
 package com.qmth.distributed.print.business.service.impl;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -130,40 +131,49 @@ public class DownloadServiceImpl implements DownloadService {
         }
 
         // 题卡
-        Long cardId = examTaskDetail.getCardId();
-        if (cardId != null) {
-            ExamCard examCard = examCardMapper.selectById(cardId);
-
-            String cardPath = rootPath + File.separator + examTask.getCourseName() + "-" + examTask.getCourseCode() + File.separator + examTask.getPaperNumber();
-            String cardHtmlPath = cardPath + File.separator + "题卡" + "_" + examTask.getCourseName() + SystemConstant.HTML_PREFIX;
-            String cardPdfPath = cardPath + File.separator + "题卡" + "_" + examTask.getCourseName() + SystemConstant.PDF_PREFIX;
-
-            ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCard.getId());
-            String htmlContent;
-            // 通用模板
-            if (MakeMethodEnum.SELECT.equals(examCard.getMakeMethod()) && CardCreateMethodEnum.UPLOAD.equals(examCard.getCreateMethod())) {
-                htmlContent = createPdfUtil.resetHtmlTemplateBar(examCardDetail.getHtmlContent());
-            } else {
-                BasicCardRule basicCardRule = basicCardRuleService.getById(examTask.getCardRuleId());
-                htmlContent = createPdfUtil.replaceHtmlCard(examCardDetail, basicCardRule);
+//        Long cardId = examTaskDetail.getCardId();
+        if (Objects.nonNull(examTaskDetail.getPaperAttachmentIds())) {
+            JSONArray jsonArrayPaper = JSONArray.parseArray(examTaskDetail.getPaperAttachmentIds());
+            String cardId = null;
+            for (int i = 0; i < jsonArrayPaper.size(); i++) {
+                JSONObject object = jsonArrayPaper.getJSONObject(i);
+                cardId = (String) object.get("cardId");
             }
+            if (cardId != null) {
+                ExamCard examCard = examCardMapper.selectById(cardId);
+
+                String cardPath = rootPath + File.separator + examTask.getCourseName() + "-" + examTask.getCourseCode() + File.separator + examTask.getPaperNumber();
+                String cardHtmlPath = cardPath + File.separator + "题卡" + "_" + examTask.getCourseName() + SystemConstant.HTML_PREFIX;
+                String cardPdfPath = cardPath + File.separator + "题卡" + "_" + examTask.getCourseName() + SystemConstant.PDF_PREFIX;
+
+                ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCard.getId());
+                String htmlContent;
+                // 通用模板
+                if (MakeMethodEnum.SELECT.equals(examCard.getMakeMethod()) && CardCreateMethodEnum.UPLOAD.equals(examCard.getCreateMethod())) {
+                    htmlContent = createPdfUtil.resetHtmlTemplateBar(examCardDetail.getHtmlContent());
+                } else {
+                    BasicCardRule basicCardRule = basicCardRuleService.getById(examTask.getCardRuleId());
+                    htmlContent = createPdfUtil.replaceHtmlCard(examCardDetail, basicCardRule);
+                }
 
-            // html
-            File htmlFile = new File(cardHtmlPath);
-            if (!htmlFile.getParentFile().exists()) {
-                htmlFile.getParentFile().mkdirs();
-            }
-            // 生成html文件
-            FileCopyUtils.copy(htmlContent.getBytes(), htmlFile);
-            fileList.add(htmlFile);
-            // 转pdf文件
-            File pdfFile = new File(cardPdfPath);
-            if (!pdfFile.exists()) {
-                pdfFile.createNewFile();
+                // html
+                File htmlFile = new File(cardHtmlPath);
+                if (!htmlFile.getParentFile().exists()) {
+                    htmlFile.getParentFile().mkdirs();
+                }
+                // 生成html文件
+                FileCopyUtils.copy(htmlContent.getBytes(), htmlFile);
+                fileList.add(htmlFile);
+                // 转pdf文件
+                File pdfFile = new File(cardPdfPath);
+                if (!pdfFile.exists()) {
+                    pdfFile.createNewFile();
+                }
+                HtmlToPdfUtil.convert(cardHtmlPath, cardPdfPath, PageSizeEnum.A3);
+                fileList.add(pdfFile);
             }
-            HtmlToPdfUtil.convert(cardHtmlPath, cardPdfPath, PageSizeEnum.A3);
-            fileList.add(pdfFile);
         }
+
         if (fileList.size() == 0) {
             throw ExceptionResultEnum.ERROR.exception("没有可导出文件");
         }

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

@@ -423,9 +423,10 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
     @Override
     public Boolean deleteGeneric(Long id) {
         // 校验题卡是否被绑定
-        QueryWrapper<ExamTaskDetail> queryWrapper = new QueryWrapper<>();
-        queryWrapper.lambda().eq(ExamTaskDetail::getCardId, id);
-        List<ExamTaskDetail> examTaskDetails = examTaskDetailService.list(queryWrapper);
+//        QueryWrapper<ExamTaskDetail> queryWrapper = new QueryWrapper<>();
+//        queryWrapper.lambda().eq(ExamTaskDetail::getCardId, id);
+//        List<ExamTaskDetail> examTaskDetails = examTaskDetailService.list(queryWrapper);
+        List<ExamTaskDetail> examTaskDetails = examTaskDetailService.getExamTaskDetailByCardIdJson(String.valueOf(id));
         if (examTaskDetails != null && examTaskDetails.size() > 0) {
             throw ExceptionResultEnum.ERROR.exception("题卡已绑定命题任务,不能删除");
         }

+ 27 - 17
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamPaperStructureServiceImpl.java

@@ -1,9 +1,9 @@
 package com.qmth.distributed.print.business.service.impl;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -359,25 +359,35 @@ public class ExamPaperStructureServiceImpl extends ServiceImpl<ExamPaperStructur
                 .eq(ExamTask::getExamId, examId)
                 .eq(ExamTask::getCourseCode, courseCode)
                 .eq(ExamTask::getPaperNumber, paperNumber)).getId();
-        Long cardId = examTaskDetailService.getOne(new QueryWrapper<ExamTaskDetail>().lambda()
-                .eq(ExamTaskDetail::getExamTaskId, examTaskId)).getCardId();
-        String jpgAttachmentInfo = examCardDetailService.getOne(new QueryWrapper<ExamCardDetail>().lambda()
-                .eq(ExamCardDetail::getCardId, cardId)).getJpgAttachmentInfo();
-        if (StringUtils.isBlank(jpgAttachmentInfo)) {
-            return new ArrayList<>();
-        }
+//        Long cardId = examTaskDetailService.getOne(new QueryWrapper<ExamTaskDetail>().lambda()
+//                .eq(ExamTaskDetail::getExamTaskId, examTaskId)).getCardId();
+        ExamTaskDetail examTaskDetail = examTaskDetailService.getOne(new QueryWrapper<ExamTaskDetail>().lambda()
+                .eq(ExamTaskDetail::getExamTaskId, examTaskId));
+        List<CardJpgResult> cardJpgResultList = null;
+        if (Objects.nonNull(examTaskDetail) && Objects.nonNull(examTaskDetail.getPaperAttachmentIds())) {
+            JSONArray jsonArrayPaper = JSONArray.parseArray(examTaskDetail.getPaperAttachmentIds());
+            for (int i = 0; i < jsonArrayPaper.size(); i++) {
+                JSONObject object = jsonArrayPaper.getJSONObject(i);
+                String jpgAttachmentInfo = examCardDetailService.getOne(new QueryWrapper<ExamCardDetail>().lambda()
+                        .eq(ExamCardDetail::getCardId, Long.parseLong((String) object.get("cardId")))).getJpgAttachmentInfo();
+                if (StringUtils.isBlank(jpgAttachmentInfo)) {
+                    return new ArrayList<>();
+                }
 
-        List<ConvertJpgStorage> convertJpgStorageList = JSONObject.parseArray(jpgAttachmentInfo, ConvertJpgStorage.class);
+                List<ConvertJpgStorage> convertJpgStorageList = JSONObject.parseArray(jpgAttachmentInfo, ConvertJpgStorage.class);
 
-        return convertJpgStorageList.stream().flatMap(e -> {
-            BasicAttachment basicAttachment = basicAttachmentService.getById(e.getAttachmentId());
+                cardJpgResultList.addAll(convertJpgStorageList.stream().flatMap(e -> {
+                    BasicAttachment basicAttachment = basicAttachmentService.getById(e.getAttachmentId());
 
-            CardJpgResult cardJpgResult = new CardJpgResult();
-            cardJpgResult.setName(basicAttachment.getName());
-            cardJpgResult.setIndex(e.getIndex());
-            cardJpgResult.setPath(teachcloudCommonService.filePreview(basicAttachment.getPath()));
-            return Stream.of(cardJpgResult);
-        }).collect(Collectors.toList());
+                    CardJpgResult cardJpgResult = new CardJpgResult();
+                    cardJpgResult.setName(basicAttachment.getName());
+                    cardJpgResult.setIndex(e.getIndex());
+                    cardJpgResult.setPath(teachcloudCommonService.filePreview(basicAttachment.getPath()));
+                    return Stream.of(cardJpgResult);
+                }).collect(Collectors.toList()));
+            }
+        }
+        return cardJpgResultList;
     }
 
     @Override

+ 79 - 20
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskDetailServiceImpl.java

@@ -1,5 +1,6 @@
 package com.qmth.distributed.print.business.service.impl;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -96,6 +97,9 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
     @Resource
     CommonCacheService commonCacheService;
 
+    @Resource
+    ExamTaskDetailMapper examTaskDetailMapper;
+
     @Transactional
     @Override
     public boolean enable(ExamTaskDetail examTaskDetail) {
@@ -246,12 +250,12 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
     }
 
     @Override
-    public IPage<ExamTaskDetailDto> list(Long semesterId,Long examId, String relateType, List<Long> printPlanIdList, String courseCode, String paperNumber, String userName, Long cardRuleId, Integer pageNumber, Integer pageSize) {
+    public IPage<ExamTaskDetailDto> list(Long semesterId, Long examId, String relateType, List<Long> printPlanIdList, String courseCode, String paperNumber, String userName, Long cardRuleId, Integer pageNumber, Integer pageSize) {
         userName = SystemConstant.translateSpecificSign(userName);
         Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
         Set<Long> orgIds = teachcloudCommonService.listSubOrgIds(null);
         Page<ExamTaskDetailDto> page = new Page<>(pageNumber, pageSize);
-        IPage<ExamTaskDetailDto> examDetailDtoIPage = this.baseMapper.listPage(page, schoolId,semesterId,examId, relateType, printPlanIdList, courseCode, paperNumber, userName, cardRuleId, orgIds);
+        IPage<ExamTaskDetailDto> examDetailDtoIPage = this.baseMapper.listPage(page, schoolId, semesterId, examId, relateType, printPlanIdList, courseCode, paperNumber, userName, cardRuleId, orgIds);
         examDetailDtoIPage.getRecords().stream().map(m -> {
             String paperType = StringUtils.isBlank(m.getRelatePaperType()) ? null : m.getRelatePaperType();
             Long printPlanIdT = Long.valueOf(m.getPrintPlanId());
@@ -266,23 +270,56 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
 
     @Override
     public List<ExamTaskDetail> listByCardId(Long cardId) {
-        QueryWrapper<ExamTaskDetail> queryWrapper = new QueryWrapper<>();
-        queryWrapper.lambda().eq(ExamTaskDetail::getCardId, cardId);
-        return this.list(queryWrapper);
+//        QueryWrapper<ExamTaskDetail> queryWrapper = new QueryWrapper<>();
+//        queryWrapper.lambda().eq(ExamTaskDetail::getCardId, cardId);
+        return this.getExamTaskDetailByCardIdJson(String.valueOf(cardId));
     }
 
     @Override
     public void bindCardId(String examTaskId, ExamCard examCard) {
-        UpdateWrapper<ExamTaskDetail> updateWrapper = new UpdateWrapper<>();
-        updateWrapper.lambda().set(ExamTaskDetail::getCardId, examCard.getId()).set(ExamTaskDetail::getMakeMethod, examCard.getMakeMethod().name()).eq(ExamTaskDetail::getExamTaskId, examTaskId);
-        this.update(updateWrapper);
+//        UpdateWrapper<ExamTaskDetail> updateWrapper = new UpdateWrapper<>();
+//        updateWrapper.lambda().set(ExamTaskDetail::getCardId, examCard.getId()).set(ExamTaskDetail::getMakeMethod, examCard.getMakeMethod().name()).eq(ExamTaskDetail::getExamTaskId, examTaskId);
+//        this.update(updateWrapper);
+        QueryWrapper<ExamTaskDetail> examTaskDetailQueryWrapper = new QueryWrapper<>();
+        examTaskDetailQueryWrapper.lambda().eq(ExamTaskDetail::getExamTaskId, Long.parseLong(examTaskId));
+        List<ExamTaskDetail> examTaskDetails = this.list(examTaskDetailQueryWrapper);
+        if (!CollectionUtils.isEmpty(examTaskDetails)) {
+            for (ExamTaskDetail e : examTaskDetails) {
+                e.setMakeMethod(examCard.getMakeMethod().name());
+                if (Objects.nonNull(e.getPaperAttachmentIds())) {
+                    JSONArray jsonArrayPaper = JSONArray.parseArray(e.getPaperAttachmentIds());
+                    for (int i = 0; i < jsonArrayPaper.size(); i++) {
+                        JSONObject object = jsonArrayPaper.getJSONObject(i);
+                        object.put("cardId", examCard.getId());
+                    }
+                    e.setPaperAttachmentIds(jsonArrayPaper.toJSONString());
+                }
+            }
+            this.updateBatchById(examTaskDetails);
+        }
     }
 
     @Override
     public void resetCardId(Long id) {
-        UpdateWrapper<ExamTaskDetail> updateWrapper = new UpdateWrapper<>();
-        updateWrapper.lambda().set(ExamTaskDetail::getCardId, null).eq(ExamTaskDetail::getExamTaskId, id);
-        this.update(updateWrapper);
+//        UpdateWrapper<ExamTaskDetail> updateWrapper = new UpdateWrapper<>();
+//        updateWrapper.lambda().set(ExamTaskDetail::getCardId, null).eq(ExamTaskDetail::getExamTaskId, id);
+//        this.update(updateWrapper);
+        QueryWrapper<ExamTaskDetail> examTaskDetailQueryWrapper = new QueryWrapper<>();
+        examTaskDetailQueryWrapper.lambda().eq(ExamTaskDetail::getExamTaskId, id);
+        List<ExamTaskDetail> examTaskDetails = this.list(examTaskDetailQueryWrapper);
+        if (!CollectionUtils.isEmpty(examTaskDetails)) {
+            for (ExamTaskDetail e : examTaskDetails) {
+                if (Objects.nonNull(e.getPaperAttachmentIds())) {
+                    JSONArray jsonArrayPaper = JSONArray.parseArray(e.getPaperAttachmentIds());
+                    for (int i = 0; i < jsonArrayPaper.size(); i++) {
+                        JSONObject object = jsonArrayPaper.getJSONObject(i);
+                        object.put("cardId", null);
+                    }
+                    e.setPaperAttachmentIds(jsonArrayPaper.toJSONString());
+                }
+            }
+            this.updateBatchById(examTaskDetails);
+        }
     }
 
     @Override
@@ -347,13 +384,24 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
             unexposedPaperType = String.join(",", paperTypeAll);
         }
 
-        UpdateWrapper<ExamTaskDetail> examTaskDetailUpdateWrapper = new UpdateWrapper<>();
-        examTaskDetailUpdateWrapper.lambda().set(ExamTaskDetail::getPaperType, examTaskDetail.getPaperType())
-                .set(ExamTaskDetail::getPaperAttachmentIds, examTaskDetail.getPaperAttachmentIds())
-                .set(ExamTaskDetail::getCardId, examTaskDetail.getCardId())
-                .set(ExamTaskDetail::getUnexposedPaperType, unexposedPaperType)
-                .eq(ExamTaskDetail::getExamTaskId, examTaskDetail.getExamTaskId());
-        this.update(examTaskDetailUpdateWrapper);
+//        UpdateWrapper<ExamTaskDetail> examTaskDetailUpdateWrapper = new UpdateWrapper<>();
+//        examTaskDetailUpdateWrapper.lambda().set(ExamTaskDetail::getPaperType, examTaskDetail.getPaperType())
+//                .set(ExamTaskDetail::getPaperAttachmentIds, examTaskDetail.getPaperAttachmentIds())
+//                .set(ExamTaskDetail::getCardId, examTaskDetail.getCardId())
+//                .set(ExamTaskDetail::getUnexposedPaperType, unexposedPaperType)
+//                .eq(ExamTaskDetail::getExamTaskId, examTaskDetail.getExamTaskId());
+//        this.update(examTaskDetailUpdateWrapper);
+
+        QueryWrapper<ExamTaskDetail> examTaskDetailQueryWrapper = new QueryWrapper<>();
+        examTaskDetailQueryWrapper.lambda().eq(ExamTaskDetail::getExamTaskId, examTaskDetail.getExamTaskId());
+        List<ExamTaskDetail> examTaskDetailList = this.list(examTaskDetailQueryWrapper);
+        if (!CollectionUtils.isEmpty(examTaskDetailList)) {
+            for (ExamTaskDetail e : examTaskDetailList) {
+                e.setPaperType(examTaskDetail.getPaperType());
+                e.setPaperAttachmentIds(examTaskDetail.getPaperAttachmentIds());
+                e.setUnexposedPaperType(unexposedPaperType);
+            }
+        }
 
         ExamTask examTask = examTaskService.getById(examTaskDetail.getExamTaskId());
         List<ExamDetail> examDetails = examDetailService.listByCourseCodeAndPaperNumber(examTask.getSchoolId(), examTask.getCourseCode(), examTask.getPaperNumber());
@@ -406,6 +454,17 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
         return this.getOne(queryWrapper);
     }
 
+    /**
+     * 根据card查找json
+     *
+     * @param cardId
+     * @return
+     */
+    @Override
+    public List<ExamTaskDetail> getExamTaskDetailByCardIdJson(String cardId) {
+        return examTaskDetailMapper.getExamTaskDetailByCardIdJson(cardId);
+    }
+
     /**
      * 卷库校验
      *
@@ -424,7 +483,7 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
         if (oldPaperAttachmentIdsList.size() == newPaperAttachmentIdsList.size()) {
             String oldString = oldPaperAttachmentIdsList.stream().sorted(Comparator.comparing(m -> m.get("name").toString())).map(m -> m.get("name").toString() + m.get("attachmentId").toString()).collect(Collectors.joining());
             String newString = newPaperAttachmentIdsList.stream().sorted(Comparator.comparing(m -> m.get("name").toString())).map(m -> m.get("name").toString() + m.get("attachmentId").toString()).collect(Collectors.joining());
-            if (oldString.equals(newString) && examTaskDetailTemp.getCardId().equals(examTaskDetail.getCardId())) {
+            if (oldString.equals(newString) && examTaskDetailTemp.getPaperAttachmentIds().equals(examTaskDetail.getPaperAttachmentIds())) {
                 return;
             }
         }
@@ -481,7 +540,7 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
             }
 
             // 已有曝光卷型时,题卡不能修改
-            if (!examTaskDetailTemp.getCardId().equals(examTaskDetail.getCardId())) {
+            if (!examTaskDetailTemp.getPaperAttachmentIds().equals(examTaskDetail.getPaperAttachmentIds())) {
                 throw ExceptionResultEnum.ERROR.exception("已有试卷曝光,不能修改题卡");
             }
         }

+ 79 - 58
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskServiceImpl.java

@@ -1,6 +1,7 @@
 package com.qmth.distributed.print.business.service.impl;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -975,39 +976,47 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
         }
 
         // 题卡
-        Long cardId = examTaskDetail.getCardId();
-        if (cardId != null) {
-            ExamCard examCard = examCardService.getById(cardId);
-
-            String cardPath = rootPath + File.separator + examTask.getPaperNumber();
-            String cardHtmlPath = cardPath + File.separator + "题卡" + "_" + examTask.getPaperNumber() + SystemConstant.HTML_PREFIX;
-            String cardPdfPath = cardPath + File.separator + "题卡" + "_" + examTask.getPaperNumber() + SystemConstant.PDF_PREFIX;
-
-            ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCard.getId());
-            String htmlContent;
-            // 通用模板
-            if (MakeMethodEnum.SELECT.equals(examCard.getMakeMethod())) {
-                htmlContent = createPdfUtil.resetHtmlTemplateBar(examCardDetail.getHtmlContent());
-            } else {
-                BasicCardRule basicCardRule = basicCardRuleService.getById(examTask.getCardRuleId());
-                htmlContent = createPdfUtil.replaceHtmlCard(examCardDetail, basicCardRule);
-            }
+//        Long cardId = examTaskDetail.getCardId();
+        if (Objects.nonNull(examTaskDetail.getPaperAttachmentIds())) {
+            JSONArray jsonArrayPaper = JSONArray.parseArray(examTaskDetail.getPaperAttachmentIds());
+            String cardId = null;
+            for (int i = 0; i < jsonArrayPaper.size(); i++) {
+                JSONObject object = jsonArrayPaper.getJSONObject(i);
+                cardId = (String) object.get("cardId");
+            }
+            if (cardId != null) {
+                ExamCard examCard = examCardService.getById(cardId);
+
+                String cardPath = rootPath + File.separator + examTask.getPaperNumber();
+                String cardHtmlPath = cardPath + File.separator + "题卡" + "_" + examTask.getPaperNumber() + SystemConstant.HTML_PREFIX;
+                String cardPdfPath = cardPath + File.separator + "题卡" + "_" + examTask.getPaperNumber() + SystemConstant.PDF_PREFIX;
+
+                ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCard.getId());
+                String htmlContent;
+                // 通用模板
+                if (MakeMethodEnum.SELECT.equals(examCard.getMakeMethod())) {
+                    htmlContent = createPdfUtil.resetHtmlTemplateBar(examCardDetail.getHtmlContent());
+                } else {
+                    BasicCardRule basicCardRule = basicCardRuleService.getById(examTask.getCardRuleId());
+                    htmlContent = createPdfUtil.replaceHtmlCard(examCardDetail, basicCardRule);
+                }
 
-            // html
-            File htmlFile = new File(cardHtmlPath);
-            if (!htmlFile.getParentFile().exists()) {
-                htmlFile.getParentFile().mkdirs();
-            }
-            // 生成html文件
-            FileCopyUtils.copy(htmlContent.getBytes(), htmlFile);
-            fileList.add(htmlFile);
-            // 转pdf文件
-            File pdfFile = new File(cardPdfPath);
-            if (!pdfFile.exists()) {
-                pdfFile.createNewFile();
+                // html
+                File htmlFile = new File(cardHtmlPath);
+                if (!htmlFile.getParentFile().exists()) {
+                    htmlFile.getParentFile().mkdirs();
+                }
+                // 生成html文件
+                FileCopyUtils.copy(htmlContent.getBytes(), htmlFile);
+                fileList.add(htmlFile);
+                // 转pdf文件
+                File pdfFile = new File(cardPdfPath);
+                if (!pdfFile.exists()) {
+                    pdfFile.createNewFile();
+                }
+                HtmlToPdfUtil.convert(cardHtmlPath, cardPdfPath, PageSizeEnum.A3);
+                fileList.add(pdfFile);
             }
-            HtmlToPdfUtil.convert(cardHtmlPath, cardPdfPath, PageSizeEnum.A3);
-            fileList.add(pdfFile);
         }
         if (fileList.size() == 0) {
             throw ExceptionResultEnum.ERROR.exception("没有可导出文件");
@@ -1255,29 +1264,41 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
         if (StringUtils.isNotBlank(examTaskDetail.getExposedPaperType())) {
             throw ExceptionResultEnum.ERROR.exception("已有试卷曝光,不能切换题卡");
         }
-        if (Objects.nonNull(examTaskDetail.getCardId())) {
-            ExamCard examCard = examCardService.getById(examTaskDetail.getCardId());
-            if (examCard == null) {
-                throw ExceptionResultEnum.ERROR.exception("题卡不存在");
-            }
-            if (MakeMethodEnum.CUST.equals(examCard.getMakeMethod())) {
-                throw ExceptionResultEnum.ERROR.exception("客服制卡方式,不能切换");
-            }
+        QueryWrapper<ExamTaskDetail> examTaskDetailQueryWrapper = new QueryWrapper<>();
+        examTaskDetailQueryWrapper.lambda().eq(ExamTaskDetail::getExamTaskId, examTaskId);
+        List<ExamTaskDetail> examTaskDetailList = examTaskDetailService.list(examTaskDetailQueryWrapper);
+        if (!CollectionUtils.isEmpty(examTaskDetailList)) {
+            for (ExamTaskDetail e : examTaskDetailList) {
+                if (Objects.nonNull(e.getPaperAttachmentIds())) {
+                    JSONArray jsonArrayPaper = JSONArray.parseArray(e.getPaperAttachmentIds());
+                    for (int i = 0; i < jsonArrayPaper.size(); i++) {
+                        JSONObject object = jsonArrayPaper.getJSONObject(i);
+                        ExamCard examCard = examCardService.getById(Long.parseLong((String) object.get("cardId")));
+                        if (examCard == null) {
+                            throw ExceptionResultEnum.ERROR.exception("题卡不存在");
+                        }
+                        if (MakeMethodEnum.CUST.equals(examCard.getMakeMethod())) {
+                            throw ExceptionResultEnum.ERROR.exception("客服制卡方式,不能切换");
+                        }
 
-            // 删除自建题卡
-            if (!MakeMethodEnum.SELECT.name().equals(examTaskDetail.getMakeMethod())) {
-                UpdateWrapper<ExamCardDetail> updateWrapper = new UpdateWrapper<>();
-                updateWrapper.lambda().eq(ExamCardDetail::getCardId, examTaskDetail.getCardId());
-                examCardDetailService.remove(updateWrapper);
+                        // 删除自建题卡
+                        if (!MakeMethodEnum.SELECT.name().equals(examTaskDetail.getMakeMethod())) {
+                            UpdateWrapper<ExamCardDetail> updateWrapper = new UpdateWrapper<>();
+                            updateWrapper.lambda().eq(ExamCardDetail::getCardId, examCard.getId());
+                            examCardDetailService.remove(updateWrapper);
+                            examCardService.removeById(examCard.getId());
+                        }
 
-                examCardService.removeById(examTaskDetail.getCardId());
+//                        UpdateWrapper<ExamTaskDetail> examTaskDetailUpdateWrapper = new UpdateWrapper<>();
+//                        examTaskDetailUpdateWrapper.lambda().set(ExamTaskDetail::getCardId, null)
+//                                .set(ExamTaskDetail::getMakeMethod, null)
+//                                .eq(ExamTaskDetail::getId, examTaskDetail.getId());
+                        object.put("cardId", null);
+                        e.setMakeMethod(null);
+                        examTaskDetailService.updateById(e);
+                    }
+                }
             }
-
-            UpdateWrapper<ExamTaskDetail> examTaskDetailUpdateWrapper = new UpdateWrapper<>();
-            examTaskDetailUpdateWrapper.lambda().set(ExamTaskDetail::getCardId, null)
-                    .set(ExamTaskDetail::getMakeMethod, null)
-                    .eq(ExamTaskDetail::getId, examTaskDetail.getId());
-            examTaskDetailService.update(examTaskDetailUpdateWrapper);
         }
     }
 
@@ -1606,7 +1627,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
 
                         // 更新实际考生数量
                         List<ExamTaskStudentObjectParam> examTaskStudentObjectParamList = examDetailList.getExamTaskStudentObjectParamList();
-                        List<ExamStudent> examStudents = printCommonService.createBatchStudentByStudentList(schoolId,examDetailList.getExtendFields(),examTaskStudentObjectParamList,examDetailCourse.getId(),sysUser);
+                        List<ExamStudent> examStudents = printCommonService.createBatchStudentByStudentList(schoolId, examDetailList.getExtendFields(), examTaskStudentObjectParamList, examDetailCourse.getId(), sysUser);
                         if (!CollectionUtils.isEmpty(examStudents)) {
                             examStudentService.insertBatch(examStudents);
                         }
@@ -1706,12 +1727,12 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
         // 查询教研室所在学院
         List<SysOrg> orgList = sysOrgService.findParentsByOrgId(teachingRoom.getId());
         List<SysOrg> schoolOrgList = orgList.stream().filter(e -> OrgTypeEnum.SCHOOL.equals(e.getType())).collect(Collectors.toList());
-        if (schoolOrgList.size() != 1){
+        if (schoolOrgList.size() != 1) {
             throw ExceptionResultEnum.ERROR.exception("学校级机构信息异常");
         }
         SysOrg schoolOrg = schoolOrgList.get(0);
         List<SysOrg> collegeList = orgList.stream().filter(e -> Objects.equals(schoolOrg.getId(), e.getParentId())).collect(Collectors.toList());
-        if (collegeList.size() != 1){
+        if (collegeList.size() != 1) {
             throw ExceptionResultEnum.ERROR.exception("学院级机构信息异常");
         }
 
@@ -1846,13 +1867,13 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
         List<ExamTaskStudentObjectResult> result = new ArrayList<>();
         switch (examObjectType) {
             case TEACH_CLAZZ_STUDENT:
-                TeachCourse teachCourse = teachCourseService.getOne(new QueryWrapper<TeachCourse>().lambda().eq(TeachCourse::getSchoolId,schoolId).eq(TeachCourse::getBasicCourseId,basicCourseId));
-                if (Objects.isNull(teachCourse)){
+                TeachCourse teachCourse = teachCourseService.getOne(new QueryWrapper<TeachCourse>().lambda().eq(TeachCourse::getSchoolId, schoolId).eq(TeachCourse::getBasicCourseId, basicCourseId));
+                if (Objects.isNull(teachCourse)) {
                     throw ExceptionResultEnum.ERROR.exception("未找到教学课程");
                 }
 
                 // 教学班对象
-                List<TeachStudent> teachStudentDatasource = teachStudentService.list(new QueryWrapper<TeachStudent>().lambda().eq(TeachStudent::getSchoolId, schoolId).eq(TeachStudent::getUserId, userId).eq(TeachStudent::getTeachCourseId,teachCourse.getId()));
+                List<TeachStudent> teachStudentDatasource = teachStudentService.list(new QueryWrapper<TeachStudent>().lambda().eq(TeachStudent::getSchoolId, schoolId).eq(TeachStudent::getUserId, userId).eq(TeachStudent::getTeachCourseId, teachCourse.getId()));
 
                 // 教学班id集合
                 List<Long> teachClazzIdList = teachStudentDatasource.stream().map(TeachStudent::getTeachClazzId).distinct().collect(Collectors.toList());
@@ -1933,7 +1954,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
                 studentImportMap.put("inputStream", file.getInputStream());
                 studentImportMap.put(SystemConstant.SYS_USER, requestUser);
                 taskLogicService.executeImportBasicStudentLogic(studentImportMap);
-                List<String> studentCodeList = JSONObject.parseArray(JSON.toJSONString(studentImportMap.get("studentCodeList")),String.class);
+                List<String> studentCodeList = JSONObject.parseArray(JSON.toJSONString(studentImportMap.get("studentCodeList")), String.class);
 
                 // 导入的学生信息查询
                 List<BasicStudentResult> basicStudentResultDatasource = basicStudentService.basicStudentList(schoolId, null, null, null, studentCodeList);

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

@@ -271,12 +271,25 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                 JSONObject jsonObject = new JSONObject();
                 JSONArray jsonArray = new JSONArray();
                 JSONArray stuJsonArray = new JSONArray();
+                Map<String, ExamCard> examCardMap = new HashMap<>();
                 for (ExamTaskDetail examTaskDetail : examTaskDetailList) {
-                    //查询题卡
-                    ExamCard examCard = examCardService.getById(examTaskDetail.getCardId());
-                    if (Objects.isNull(examCard)) {
-                        throw ExceptionResultEnum.EXAM_CARD_IS_NULL.exception();
+                    JSONArray jsonArrayPaper = JSONArray.parseArray(examTaskDetail.getPaperAttachmentIds());
+                    ExamCard examCard = null;
+                    for (int i = 0; i < jsonArrayPaper.size(); i++) {
+                        JSONObject object = jsonArrayPaper.getJSONObject(i);
+                        if (Objects.nonNull(object.get("cardId")) && !Objects.equals("", object.get("cardId"))) {
+                            examCard = examCardService.getById(Long.parseLong((String) object.get("cardId")));
+                            if (Objects.isNull(examCard)) {
+                                throw ExceptionResultEnum.EXAM_CARD_IS_NULL.exception();
+                            }
+                            examCardMap.put((String) object.get("name"), examCard);
+                        }
                     }
+                    //查询题卡
+//                    ExamCard examCard = examCardService.getById(examTaskDetail.getCardId());
+//                    if (Objects.isNull(examCard)) {
+//                        throw ExceptionResultEnum.EXAM_CARD_IS_NULL.exception();
+//                    }
 
                     ExamTask examTask = examTaskMap.get(examTaskDetail.getExamTaskId());
 
@@ -1173,42 +1186,39 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                             }
                         }
                     }
+                    ExamCard examCard = examCardService.getById(Long.parseLong((String) paperMap.get("cardId")));
+                    if (Objects.isNull(examCard)) {
+                        throw ExceptionResultEnum.ERROR.exception("找不到答题卡");
+                    }
+                    MakeMethodEnum makeMethodEnum = examCard.getMakeMethod();
+
+                    String cardPath = zipLocalRootPath + File.separator + examTask.getPaperNumber();
+                    String cardHtmlPath = cardPath + File.separator + "题卡" + paperMap.get("name") + "_" + examTask.getPaperNumber() + SystemConstant.HTML_PREFIX;
+                    String cardPdfPath = cardPath + File.separator + "题卡" + paperMap.get("name") + "_" + examTask.getPaperNumber() + SystemConstant.PDF_PREFIX;
+                    // 通用题卡
+                    ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCard.getId());
+                    String htmlContent;
+                    if (MakeMethodEnum.SELECT.equals(makeMethodEnum)) {
+                        htmlContent = createPdfUtil.resetHtmlTemplateBar(examCardDetail.getHtmlContent());
+                    } else {
+                        BasicCardRule basicCardRule = basicCardRuleService.getById(examTask.getCardRuleId());
+                        htmlContent = createPdfUtil.replaceHtmlCard(examCardDetail, basicCardRule);
+                    }
+                    // html
+                    File localFile = new File(cardHtmlPath);
+                    if (!localFile.getParentFile().exists()) {
+                        localFile.getParentFile().mkdirs();
+                    }
+                    // 生成html文件
+                    FileCopyUtils.copy(htmlContent.getBytes(), localFile);
+                    // 转pdf文件
+                    File file = new File(cardPdfPath);
+                    if (!file.exists()) {
+                        file.createNewFile();
+                    }
+                    HtmlToPdfUtil.convert(cardHtmlPath, cardPdfPath, PageSizeEnum.A3);
                 }
             }
-
-            // 题卡
-            // 处理题卡
-            ExamCard examCard = examCardService.getById(examTaskDetail.getCardId());
-            if (Objects.isNull(examCard)) {
-                throw ExceptionResultEnum.ERROR.exception("找不到答题卡");
-            }
-            MakeMethodEnum makeMethodEnum = examCard.getMakeMethod();
-
-            String cardPath = zipLocalRootPath + File.separator + examTask.getPaperNumber();
-            String cardHtmlPath = cardPath + File.separator + "题卡" + "_" + examTask.getPaperNumber() + SystemConstant.HTML_PREFIX;
-            String cardPdfPath = cardPath + File.separator + "题卡" + "_" + examTask.getPaperNumber() + SystemConstant.PDF_PREFIX;
-            // 通用题卡
-            ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCard.getId());
-            String htmlContent;
-            if (MakeMethodEnum.SELECT.equals(makeMethodEnum)) {
-                htmlContent = createPdfUtil.resetHtmlTemplateBar(examCardDetail.getHtmlContent());
-            } else {
-                BasicCardRule basicCardRule = basicCardRuleService.getById(examTask.getCardRuleId());
-                htmlContent = createPdfUtil.replaceHtmlCard(examCardDetail, basicCardRule);
-            }
-            // html
-            File localFile = new File(cardHtmlPath);
-            if (!localFile.getParentFile().exists()) {
-                localFile.getParentFile().mkdirs();
-            }
-            // 生成html文件
-            FileCopyUtils.copy(htmlContent.getBytes(), localFile);
-            // 转pdf文件
-            File file = new File(cardPdfPath);
-            if (!file.exists()) {
-                file.createNewFile();
-            }
-            HtmlToPdfUtil.convert(cardHtmlPath, cardPdfPath, PageSizeEnum.A3);
         }
 
         File zipFile = new File(zipJoiner.toString() + dirNameTmp);
@@ -1289,7 +1299,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
             if (excelErrorTemp.size() > 0) {
                 throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(excelErrorTemp));
             }
-            map.put("studentCodeList",studentCodeList);
+            map.put("studentCodeList", studentCodeList);
             return finalExcelList;
         });
         return basicStudentService.executeBasicStudentImportLogic(finalList, map);

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

@@ -609,7 +609,7 @@ public class CreatePdfUtil {
         PaperPdfDto paperPdfDto = null;
         JSONArray jsonArrayPaper = JSONArray.parseArray(examTaskDetail.getPaperAttachmentIds());
         for (int i = 0; i < jsonArrayPaper.size(); i++) {
-            JSONObject object = (JSONObject) jsonArrayPaper.get(i);
+            JSONObject object = jsonArrayPaper.getJSONObject(i);
             if (Objects.nonNull(object.get("attachmentId")) && !Objects.equals("", object.get("attachmentId"))) {
                 Long attachmentId = Long.parseLong((String) (object.get("attachmentId")));
                 BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);

+ 18 - 0
distributed-print-business/src/main/resources/mapper/ExamTaskDetailMapper.xml

@@ -153,4 +153,22 @@
             </if>
         </where>
     </select>
+
+    <select id="getExamTaskDetailByCardIdJson" resultType="com.qmth.distributed.print.business.entity.ExamTaskDetail">
+        select
+            *
+        from
+            (
+                select
+                    substring_index(substring_index(CONVERT((etd.paper_attachment_ids ->>'$[*].cardId')
+                                                            USING utf8),']',1),'[',-1) as cardId,
+                    etd.*
+                from
+                    exam_task_detail etd) t
+        <where> 1 = 1
+            <if test="cardId != null and cardId != ''">
+                and FIND_IN_SET('#{cardId}', t.cardId)
+            </if>
+        </where>
+    </select>
 </mapper>

+ 23 - 21
distributed-print/src/main/java/com/qmth/distributed/print/api/MenuCustomController.java

@@ -4,8 +4,12 @@ package com.qmth.distributed.print.api;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.distributed.print.business.bean.params.TSchoolPrivilegeParam;
+import com.qmth.distributed.print.business.bean.result.CustomPrivilegeResult;
+import com.qmth.distributed.print.business.bean.result.TSchoolPrivilegeResult;
 import com.qmth.teachcloud.common.bean.dto.PrivilegeDto;
+import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.*;
+import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
 import com.qmth.teachcloud.common.service.*;
 import com.qmth.teachcloud.common.util.Result;
 import com.qmth.teachcloud.common.util.ResultUtil;
@@ -66,10 +70,9 @@ public class MenuCustomController {
     @RequestMapping(value = "/custom/list", method = RequestMethod.POST)
     public Result customList() {
         List<PrivilegeDto> customPrivilegeList = sysPrivilegeService.addCustomList();
-//        SysConfig sysConfig = commonCacheService.addSysConfigCache(SystemConstant.SYS_PDF_SIZE_LIST);
-//        Optional.ofNullable(sysConfig).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未配置全局pdf格式清单"));
-//        return ResultUtil.ok(new CustomPrivilegeResult(customPrivilegeList, Arrays.asList(sysConfig.getConfigValue().replaceAll("\\[", "").replaceAll("\\]", "").split(", "))));
-        return ResultUtil.ok(customPrivilegeList);
+        SysConfig sysConfig = commonCacheService.addSysConfigCache(SystemConstant.SYS_PDF_SIZE_LIST);
+        Optional.ofNullable(sysConfig).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未配置全局pdf格式清单"));
+        return ResultUtil.ok(new CustomPrivilegeResult(customPrivilegeList, Arrays.asList(sysConfig.getConfigValue().replaceAll("\\[", "").replaceAll("\\]", "").split(", "))));
     }
 
     @ApiOperation(value = "学校新增/修改自定义菜单权限")
@@ -136,20 +139,20 @@ public class MenuCustomController {
             }
         }
 
-//        SysConfig sysConfig = commonCacheService.addSysConfigCache(tSchoolPrivilegeParam.getSchoolId(), SystemConstant.PDF_SIZE_LIST);
-//        if (Objects.isNull(sysConfig)) {
-//            sysConfig = new SysConfig(tSchoolPrivilegeParam.getSchoolId(), SystemConstant.PDF_SIZE_LIST, "pdf格式清单", Arrays.asList(tSchoolPrivilegeParam.getPdfSize()).toString());
-//            commonCacheService.updateSysConfigCache(tSchoolPrivilegeParam.getSchoolId(), SystemConstant.PDF_SIZE_LIST);
-//        } else {
-//            if (Objects.nonNull(tSchoolPrivilegeParam.getPdfSize()) && tSchoolPrivilegeParam.getPdfSize().length > 0) {
-//                sysConfig.setConfigValue(Arrays.asList(tSchoolPrivilegeParam.getPdfSize()).toString());
-//                commonCacheService.updateSysConfigCache(tSchoolPrivilegeParam.getSchoolId(), SystemConstant.PDF_SIZE_LIST);
-//            } else {
-//                sysConfig.setConfigValue(null);
-//                commonCacheService.removeSysConfigCache(tSchoolPrivilegeParam.getSchoolId(), SystemConstant.PDF_SIZE_LIST);
-//            }
-//        }
-//        sysConfigService.saveOrUpdate(sysConfig);
+        SysConfig sysConfig = commonCacheService.addSysConfigCache(tSchoolPrivilegeParam.getSchoolId(), SystemConstant.PDF_SIZE_LIST);
+        if (Objects.isNull(sysConfig)) {
+            sysConfig = new SysConfig(tSchoolPrivilegeParam.getSchoolId(), SystemConstant.PDF_SIZE_LIST, "pdf格式清单", Arrays.asList(tSchoolPrivilegeParam.getPdfSize()).toString());
+            commonCacheService.updateSysConfigCache(tSchoolPrivilegeParam.getSchoolId(), SystemConstant.PDF_SIZE_LIST);
+        } else {
+            if (Objects.nonNull(tSchoolPrivilegeParam.getPdfSize()) && tSchoolPrivilegeParam.getPdfSize().length > 0) {
+                sysConfig.setConfigValue(Arrays.asList(tSchoolPrivilegeParam.getPdfSize()).toString());
+                commonCacheService.updateSysConfigCache(tSchoolPrivilegeParam.getSchoolId(), SystemConstant.PDF_SIZE_LIST);
+            } else {
+                sysConfig.setConfigValue(null);
+                commonCacheService.removeSysConfigCache(tSchoolPrivilegeParam.getSchoolId(), SystemConstant.PDF_SIZE_LIST);
+            }
+        }
+        sysConfigService.saveOrUpdate(sysConfig);
         return ResultUtil.ok(true);
     }
 
@@ -159,8 +162,7 @@ public class MenuCustomController {
     public Result getRolePrivileges(@RequestParam(value = "schoolId", required = true) Long schoolId) {
         List<TSchoolPrivilege> tSchoolPrivilegeList = tSchoolPrivilegeService.findBySchoolId(schoolId);
         List<String> privilegeIdList = tSchoolPrivilegeList.stream().map(s -> String.valueOf(s.getPrivilegeId())).collect(Collectors.toList());
-//        SysConfig sysConfig = commonCacheService.addSysConfigCache(schoolId, SystemConstant.PDF_SIZE_LIST);
-//        return ResultUtil.ok(new TSchoolPrivilegeResult(schoolId, privilegeIdList, Objects.nonNull(sysConfig) ? Arrays.asList(sysConfig.getConfigValue().replaceAll("\\[", "").replaceAll("\\]", "").split(", ")) : null));
-        return ResultUtil.ok(privilegeIdList);
+        SysConfig sysConfig = commonCacheService.addSysConfigCache(schoolId, SystemConstant.PDF_SIZE_LIST);
+        return ResultUtil.ok(new TSchoolPrivilegeResult(schoolId, privilegeIdList, Objects.nonNull(sysConfig) ? Arrays.asList(sysConfig.getConfigValue().replaceAll("\\[", "").replaceAll("\\]", "").split(", ")) : null));
     }
 }