Browse Source

3.2.7 优化题卡表

xiaofei 2 years ago
parent
commit
d64187a614
23 changed files with 183 additions and 509 deletions
  1. 0 31
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ExamCardPageDto.java
  2. 52 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/ExamCard.java
  3. 0 93
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/ExamCardDetail.java
  4. 0 21
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamCardDetailMapper.java
  5. 1 7
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamCardMapper.java
  6. 2 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamTaskMapper.java
  7. 0 24
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamCardDetailService.java
  8. 1 5
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamCardService.java
  9. 2 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamTaskService.java
  10. 3 4
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/DataSyncServiceImpl.java
  11. 2 7
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/DownloadServiceImpl.java
  12. 0 44
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamCardDetailServiceImpl.java
  13. 39 105
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamCardServiceImpl.java
  14. 8 8
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamPaperStructureServiceImpl.java
  15. 7 6
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskServiceImpl.java
  16. 12 27
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/TaskLogicServiceImpl.java
  17. 6 6
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/CreatePdfUtil.java
  18. 14 0
      distributed-print-business/src/main/resources/db/log/脚本-xiaof.sql
  19. 0 33
      distributed-print-business/src/main/resources/mapper/ExamCardDetailMapper.xml
  20. 17 67
      distributed-print-business/src/main/resources/mapper/ExamCardMapper.xml
  21. 13 0
      distributed-print-business/src/main/resources/mapper/ExamTaskMapper.xml
  22. 3 5
      distributed-print/src/main/java/com/qmth/distributed/print/api/ExamCardController.java
  23. 1 16
      distributed-print/src/test/java/com/qmth/distributed/print/ServiceTest.java

+ 0 - 31
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ExamCardPageDto.java

@@ -1,31 +0,0 @@
-package com.qmth.distributed.print.business.bean.dto;
-
-import com.qmth.distributed.print.business.entity.ExamCard;
-
-import java.io.Serializable;
-import java.util.List;
-
-/**
- * 题卡管理-题卡分页查询对象
- */
-public class ExamCardPageDto extends ExamCard implements Serializable {
-
-    private String jpgAttachmentInfo;
-    private List<String> imageUrls;
-
-    public String getJpgAttachmentInfo() {
-        return jpgAttachmentInfo;
-    }
-
-    public void setJpgAttachmentInfo(String jpgAttachmentInfo) {
-        this.jpgAttachmentInfo = jpgAttachmentInfo;
-    }
-
-    public List<String> getImageUrls() {
-        return imageUrls;
-    }
-
-    public void setImageUrls(List<String> imageUrls) {
-        this.imageUrls = imageUrls;
-    }
-}

+ 52 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/ExamCard.java

@@ -91,8 +91,21 @@ public class ExamCard extends BaseEntity implements Serializable {
     @TableField("card_rule_id")
     private Long cardRuleId;
 
+    private String content;
+
+    @TableField("html_content")
+    private String htmlContent;
+
+    @TableField("backup_attachment")
+    private String backupAttachment;
+
+    @TableField(value = "jpg_attachment", updateStrategy = FieldStrategy.IGNORED)
+    private String jpgAttachment;
+
     @TableField(exist = false)
     private List<SysOrg> orgs;
+    @TableField(exist = false)
+    private List<String> imageUrls;
 
     public static long getSerialVersionUID() {
         return serialVersionUID;
@@ -226,4 +239,43 @@ public class ExamCard extends BaseEntity implements Serializable {
         this.orgs = orgs;
     }
 
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public String getHtmlContent() {
+        return htmlContent;
+    }
+
+    public void setHtmlContent(String htmlContent) {
+        this.htmlContent = htmlContent;
+    }
+
+    public String getBackupAttachment() {
+        return backupAttachment;
+    }
+
+    public void setBackupAttachment(String backupAttachment) {
+        this.backupAttachment = backupAttachment;
+    }
+
+    public String getJpgAttachment() {
+        return jpgAttachment;
+    }
+
+    public void setJpgAttachment(String jpgAttachment) {
+        this.jpgAttachment = jpgAttachment;
+    }
+
+    public List<String> getImageUrls() {
+        return imageUrls;
+    }
+
+    public void setImageUrls(List<String> imageUrls) {
+        this.imageUrls = imageUrls;
+    }
 }

+ 0 - 93
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/ExamCardDetail.java

@@ -1,93 +0,0 @@
-package com.qmth.distributed.print.business.entity;
-
-import com.baomidou.mybatisplus.annotation.FieldStrategy;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
-import com.qmth.teachcloud.common.base.BaseEntity;
-
-import java.io.Serializable;
-
-/**
- * <p>
- * 题卡详情
- * </p>
- *
- * @author xf
- * @since 2021-03-23
- */
-@TableName("exam_card_detail")
-public class ExamCardDetail extends BaseEntity implements Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-    /**
-     * 题卡ID
-     */
-    @JsonSerialize(using = ToStringSerializer.class)
-    @TableField("card_id")
-    private Long cardId;
-
-    private String content;
-
-    @TableField("html_content")
-    private String htmlContent;
-
-    @TableField("attachment_id")
-    private String attachmentId;
-
-    @TableField("cust_attachment_id")
-    private String custAttachmentId;
-
-    @TableField(value = "jpg_attachment_info", updateStrategy = FieldStrategy.IGNORED)
-    private String jpgAttachmentInfo;
-
-    public Long getCardId() {
-        return cardId;
-    }
-
-    public void setCardId(Long cardId) {
-        this.cardId = cardId;
-    }
-
-    public String getContent() {
-        return content;
-    }
-
-    public void setContent(String content) {
-        this.content = content;
-    }
-
-    public String getHtmlContent() {
-        return htmlContent;
-    }
-
-    public void setHtmlContent(String htmlContent) {
-        this.htmlContent = htmlContent;
-    }
-
-    public String getAttachmentId() {
-        return attachmentId;
-    }
-
-    public void setAttachmentId(String attachmentId) {
-        this.attachmentId = attachmentId;
-    }
-
-    public String getCustAttachmentId() {
-        return custAttachmentId;
-    }
-
-    public void setCustAttachmentId(String custAttachmentId) {
-        this.custAttachmentId = custAttachmentId;
-    }
-
-    public String getJpgAttachmentInfo() {
-        return jpgAttachmentInfo;
-    }
-
-    public void setJpgAttachmentInfo(String jpgAttachmentInfo) {
-        this.jpgAttachmentInfo = jpgAttachmentInfo;
-    }
-}

+ 0 - 21
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamCardDetailMapper.java

@@ -1,21 +0,0 @@
-package com.qmth.distributed.print.business.mapper;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.qmth.distributed.print.business.entity.ExamCardDetail;
-import com.qmth.distributed.print.business.entity.ExamTask;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-
-/**
- * <p>
- * 题卡详情 Mapper 接口
- * </p>
- *
- * @author xf
- * @since 2021-03-23
- */
-public interface ExamCardDetailMapper extends BaseMapper<ExamCardDetail> {
-
-    List<ExamTask> getExamTaskByCourseCodeAndCardId(@Param("schoolId") Long schoolId, @Param("courseCode") String courseCode, @Param("cardId") String cardId);
-}

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

@@ -3,8 +3,6 @@ package com.qmth.distributed.print.business.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.qmth.distributed.print.business.bean.dto.CardDetailDto;
-import com.qmth.distributed.print.business.bean.dto.ExamCardPageDto;
 import com.qmth.distributed.print.business.entity.ExamCard;
 import com.qmth.teachcloud.common.bean.dto.DataPermissionRule;
 import org.apache.ibatis.annotations.Param;
@@ -21,15 +19,11 @@ import java.util.List;
  */
 public interface ExamCardMapper extends BaseMapper<ExamCard> {
 
-    CardDetailDto getCardDetail(Long cardId);
-
     List<ExamCard> listGenericCard(@Param("schoolId") Long schoolId, @Param("type") String type, @Param("cardRuleId") Long cardRuleId);
 
     List<ExamCard> listCustom(@Param("schoolId") Long schoolId, @Param("courseCode") String courseCode, @Param("type") String type, @Param("cardRuleId") Long cardRuleId);
 
-    CardDetailDto getCardDetailBySelect(Long cardId);
-
-    IPage<ExamCardPageDto> listPage(@Param("page") Page<ExamCardPageDto> page, @Param("schoolId") Long schoolId, @Param("cardType") String cardType, @Param("title") String title, @Param("createMethod") String createMethod, @Param("enable") Boolean enable, @Param("createStartTime") Long createStartTime, @Param("createEndTime") Long createEndTime, @Param("dpr") DataPermissionRule dpr);
+    IPage<ExamCard> listPage(@Param("page") Page<ExamCard> page, @Param("schoolId") Long schoolId, @Param("cardType") String cardType, @Param("title") String title, @Param("createMethod") String createMethod, @Param("enable") Boolean enable, @Param("createStartTime") Long createStartTime, @Param("createEndTime") Long createEndTime, @Param("dpr") DataPermissionRule dpr);
 
     List<ExamCard> listCustomByExamStage(@Param("schoolId") Long schoolId, @Param("courseCode") String courseCode, @Param("paperNumber") String paperNumber, @Param("type") String type);
 }

+ 2 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamTaskMapper.java

@@ -114,4 +114,6 @@ public interface ExamTaskMapper extends BaseMapper<ExamTask> {
      * @return
      */
     public WorkResult getFlowInfo(@Param("flowId") Long flowId, @Param("taskId") Long taskId);
+
+    List<ExamTask> getExamTaskByCourseCodeAndCardId(@Param("schoolId") Long schoolId, @Param("courseCode") String courseCode, @Param("cardId") String cardId);
 }

+ 0 - 24
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamCardDetailService.java

@@ -1,24 +0,0 @@
-package com.qmth.distributed.print.business.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.qmth.distributed.print.business.entity.ExamCardDetail;
-import com.qmth.distributed.print.business.entity.ExamTask;
-
-import java.util.List;
-
-/**
- * <p>
- * 题卡详情 服务类
- * </p>
- *
- * @author xf
- * @since 2021-03-23
- */
-public interface ExamCardDetailService extends IService<ExamCardDetail> {
-
-    ExamCardDetail getByCardId(Long cardId);
-
-    void removeByCardId(Long id);
-
-    List<ExamTask> getExamTaskByCourseCodeAndCardId(Long schoolId, String courseCode, String cardId);
-}

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

@@ -2,8 +2,6 @@ package com.qmth.distributed.print.business.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
-import com.qmth.distributed.print.business.bean.dto.CardDetailDto;
-import com.qmth.distributed.print.business.bean.dto.ExamCardPageDto;
 import com.qmth.distributed.print.business.bean.params.ExamCardParams;
 import com.qmth.distributed.print.business.bean.params.GenericExamCardParams;
 import com.qmth.distributed.print.business.entity.ExamCard;
@@ -23,11 +21,9 @@ public interface ExamCardService extends IService<ExamCard> {
 
     String saveExamCard(ExamCardParams examCardParams) throws Exception;
 
-    CardDetailDto getCardDetail(Long cardId);
-
     List<ExamCard> listSelectCard(String courseCode, Long cardRuleId, String paperNumber);
 
-    IPage<ExamCardPageDto> listPage(String cardType, String title, String createMethod, Boolean enable, Long createStartTime, Long createEndTime, Integer pageNumber, Integer pageSize);
+    IPage<ExamCard> listPage(String cardType, String title, String createMethod, Boolean enable, Long createStartTime, Long createEndTime, Integer pageNumber, Integer pageSize);
 
     Long saveGeneric(GenericExamCardParams params) throws Exception;
 

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

@@ -230,4 +230,6 @@ public interface ExamTaskService extends IService<ExamTask> {
     void applyDelete(Long id);
 
     boolean savePreviewLog(Long examTaskId, String paperType, String type);
+
+    List<ExamTask> getExamTaskByCourseCodeAndCardId(Long schoolId, String courseCode, String cardId);
 }

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

@@ -725,9 +725,8 @@ public class DataSyncServiceImpl implements DataSyncService {
                 throw ExceptionResultEnum.ERROR.exception(String.format("[上传题卡格式]数据异常,未找到卷型[%s]绑定题卡ID", s));
             }
             Long cardId = optional.get().getLong("cardId");
-            CardDetailDto cardDetail = examCardService.getCardDetail(cardId);
-            if (cardDetail == null || StringUtils.isBlank(cardDetail.getContent())) {
-//                throw ExceptionResultEnum.ERROR.exception(String.format("[上传题卡格式]数据异常,通过题卡ID[%s],未查到题卡格式信息", cardId));
+            ExamCard examCard = examCardService.getById(cardId);
+            if (examCard == null || StringUtils.isBlank(examCard.getContent())) {
                 continue;
             }
 
@@ -737,7 +736,7 @@ public class DataSyncServiceImpl implements DataSyncService {
                 // 文件临时目录
                 String dirName = dictionaryConfig.fssPrivateDomain().getConfig() + File.separator + "upload-temp" + File.separator + SyncFileTypeEnum.CARD.name().toLowerCase() + File.separator + System.currentTimeMillis();
                 file = new File(dirName, SystemConstant.getNanoId() + SystemConstant.JSON_PREFIX);
-                file = SystemConstant.createJsonFile(file.getPath(), cardDetail.getContent());
+                file = SystemConstant.createJsonFile(file.getPath(), examCard.getContent());
                 if (file.exists()) {
                     String uploadCardUrl = cloudMarkingTaskUtils.syncFile(schoolId, String.valueOf(thirdRelateId), examTask.getCourseCode() + s + examTask.getSequence(), SyncFileTypeEnum.CARD, file);
                     if (StringUtils.isNotBlank(uploadCardUrl)) {

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

@@ -12,7 +12,6 @@ import com.qmth.distributed.print.business.mapper.ExamTaskDetailMapper;
 import com.qmth.distributed.print.business.mapper.ExamTaskMapper;
 import com.qmth.distributed.print.business.service.BasicCardRuleService;
 import com.qmth.distributed.print.business.service.DownloadService;
-import com.qmth.distributed.print.business.service.ExamCardDetailService;
 import com.qmth.distributed.print.business.service.ExamPrintPlanService;
 import com.qmth.distributed.print.business.util.CreatePdfUtil;
 import com.qmth.distributed.print.business.util.HtmlToPdfUtil;
@@ -66,9 +65,6 @@ public class DownloadServiceImpl implements DownloadService {
     @Resource
     ExamCardMapper examCardMapper;
 
-    @Resource
-    ExamCardDetailService examCardDetailService;
-
     @Resource
     BasicCardRuleService basicCardRuleService;
 
@@ -155,14 +151,13 @@ public class DownloadServiceImpl implements DownloadService {
                     String cardHtmlPath = cardPath + File.separator + "题卡" + "_" + examTask.getCourseName() + "_" + paperType + SystemConstant.HTML_PREFIX;
                     String cardPdfPath = cardPath + File.separator + "题卡" + "_" + examTask.getCourseName() + "_" + paperType + 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());
+                        htmlContent = createPdfUtil.resetHtmlTemplateBar(examCard.getHtmlContent());
                     } else {
                         BasicCardRule basicCardRule = basicCardRuleService.getById(examTask.getCardRuleId());
-                        htmlContent = createPdfUtil.replaceHtmlCard(examCardDetail, basicCardRule);
+                        htmlContent = createPdfUtil.replaceHtmlCard(examCard, basicCardRule);
                     }
 
                     // html

+ 0 - 44
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamCardDetailServiceImpl.java

@@ -1,44 +0,0 @@
-package com.qmth.distributed.print.business.service.impl;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.qmth.distributed.print.business.entity.ExamCardDetail;
-import com.qmth.distributed.print.business.entity.ExamTask;
-import com.qmth.distributed.print.business.mapper.ExamCardDetailMapper;
-import com.qmth.distributed.print.business.service.ExamCardDetailService;
-import org.springframework.stereotype.Service;
-
-import javax.management.Query;
-import java.util.List;
-
-/**
- * <p>
- * 题卡详情 服务实现类
- * </p>
- *
- * @author xf
- * @since 2021-03-23
- */
-@Service
-public class ExamCardDetailServiceImpl extends ServiceImpl<ExamCardDetailMapper, ExamCardDetail> implements ExamCardDetailService {
-
-    @Override
-    public ExamCardDetail getByCardId(Long cardId) {
-        QueryWrapper<ExamCardDetail> queryWrapper = new QueryWrapper<>();
-        queryWrapper.lambda().eq(ExamCardDetail::getCardId, cardId);
-        return this.getOne(queryWrapper);
-    }
-
-    @Override
-    public void removeByCardId(Long id) {
-        UpdateWrapper<ExamCardDetail> updateWrapper = new UpdateWrapper<>();
-        updateWrapper.lambda().eq(ExamCardDetail::getCardId, id);
-        this.remove(updateWrapper);
-    }
-
-    @Override
-    public List<ExamTask> getExamTaskByCourseCodeAndCardId(Long schoolId, String courseCode, String cardId) {
-        return this.baseMapper.getExamTaskByCourseCodeAndCardId(schoolId, courseCode, cardId);
-    }
-}

+ 39 - 105
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamCardServiceImpl.java

@@ -7,8 +7,6 @@ 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;
-import com.qmth.distributed.print.business.bean.dto.CardDetailDto;
-import com.qmth.distributed.print.business.bean.dto.ExamCardPageDto;
 import com.qmth.distributed.print.business.bean.marking.ConvertJpgStorage;
 import com.qmth.distributed.print.business.bean.params.ExamCardParams;
 import com.qmth.distributed.print.business.bean.params.GenericExamCardParams;
@@ -65,9 +63,6 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
     @Resource
     private BasicCardRuleService basicCardRuleService;
 
-    @Resource
-    private ExamCardDetailService examCardDetailService;
-
     @Resource
     private ExamTaskDetailService examTaskDetailService;
 
@@ -102,7 +97,6 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
 
         // 新增
         ExamCard examCard;
-        ExamCardDetail examCardDetail;
         if (examCardParams.getTitle().getBytes().length > 80) {
             throw ExceptionResultEnum.ERROR.exception("标题最长只能输入80个字符");
         }
@@ -132,22 +126,15 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
             examCard.setAttachmentId(examCardParams.getAttachmentId());
             examCard.setCardRuleId(examCardParams.getCardRuleId());
             examCard.insertInfo(user.getId());
-            this.save(examCard);
 
-            examCardDetail = new ExamCardDetail();
-            examCardDetail.setCardId(examCard.getId());
-            examCardDetail.setContent(examCardParams.getContent());
+            examCard.setContent(examCardParams.getContent());
             String htmlContent = examCardParams.getHtmlContent();
             List<ConvertJpgStorage> convertJpgStorageList = htmlToJpgUtil.convertHtmlToJpgByCard(examCard.getTitle(), htmlContent, PageSizeEnum.A3);
             if (convertJpgStorageList.size() > 0) {
-                examCardDetail.setJpgAttachmentInfo(JSON.toJSONString(convertJpgStorageList));
-            }
-            examCardDetail.setHtmlContent(htmlContent);
-            if (examCardParams.getAttachmentId() != null) {
-                examCardDetail.setAttachmentId(String.valueOf(examCardParams.getAttachmentId()));
+                examCard.setJpgAttachment(JSON.toJSONString(convertJpgStorageList));
             }
-            examCardDetail.insertInfo(user.getId());
-            examCardDetailService.save(examCardDetail);
+            examCard.setHtmlContent(htmlContent);
+            this.save(examCard);
         }
         // 修改
         else {
@@ -166,39 +153,19 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
             examCard.setStatus(examCardParams.getStatus());
             examCard.setUpdateId(user.getId());
             examCard.setUpdateTime(System.currentTimeMillis());
-            this.updateById(examCard);
-
-            examCardDetail = examCardDetailService.getByCardId(examCardParams.getId());
-            if (examCardDetail == null) {
-                throw ExceptionResultEnum.ERROR.exception("题卡数据有误");
-            }
-            examCardDetail.setContent(examCardParams.getContent());
+            examCard.setContent(examCardParams.getContent());
             String htmlContent = examCardParams.getHtmlContent();
             List<ConvertJpgStorage> convertJpgStorageList = htmlToJpgUtil.convertHtmlToJpgByCard(examCard.getTitle(), htmlContent, PageSizeEnum.A3);
             if (convertJpgStorageList.size() > 0) {
-                examCardDetail.setJpgAttachmentInfo(JSON.toJSONString(convertJpgStorageList));
-            }
-            examCardDetail.setHtmlContent(htmlContent);
-            if (examCardParams.getAttachmentId() != null) {
-                examCardDetail.setAttachmentId(String.valueOf(examCardParams.getAttachmentId()));
+                examCard.setJpgAttachment(JSON.toJSONString(convertJpgStorageList));
             }
-            examCardDetail.updateInfo(user.getId());
-            examCardDetailService.updateById(examCardDetail);
+            examCard.setHtmlContent(htmlContent);
+            this.updateById(examCard);
         }
 
         return String.valueOf(examCard.getId());
     }
 
-    @Override
-    public CardDetailDto getCardDetail(Long cardId) {
-        ExamCard examCard = this.getById(cardId);
-        if (!MakeMethodEnum.SELECT.equals(examCard.getMakeMethod())) {
-            return this.baseMapper.getCardDetail(cardId);
-        } else {
-            return this.baseMapper.getCardDetailBySelect(cardId);
-        }
-    }
-
     @Override
     public List<ExamCard> listSelectCard(String courseCode, Long cardRuleId, String paperNumber) {
         Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
@@ -234,14 +201,14 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
     }
 
     @Override
-    public IPage<ExamCardPageDto> listPage(String cardType, String title, String createMethod, Boolean enable, Long createStartTime, Long createEndTime, Integer pageNumber, Integer pageSize) {
+    public IPage<ExamCard> listPage(String cardType, String title, String createMethod, Boolean enable, Long createStartTime, Long createEndTime, Integer pageNumber, Integer pageSize) {
         Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         DataPermissionRule dpr = basicRoleDataPermissionService.findDataPermission(schoolId, requestUser.getId(), ServletUtil.getRequest().getServletPath());
-        IPage<ExamCardPageDto> cardPageDtoIPage = this.baseMapper.listPage(new Page<>(pageNumber, pageSize), schoolId, cardType, title, createMethod, enable, createStartTime, createEndTime, dpr);
-        for (ExamCardPageDto record : cardPageDtoIPage.getRecords()) {
-            if (StringUtils.isNotBlank(record.getJpgAttachmentInfo())) {
-                List<JSONObject> mapList = JSON.parseArray(record.getJpgAttachmentInfo(), JSONObject.class);
+        IPage<ExamCard> cardPageDtoIPage = this.baseMapper.listPage(new Page<>(pageNumber, pageSize), schoolId, cardType, title, createMethod, enable, createStartTime, createEndTime, dpr);
+        for (ExamCard record : cardPageDtoIPage.getRecords()) {
+            if (StringUtils.isNotBlank(record.getJpgAttachment())) {
+                List<JSONObject> mapList = JSON.parseArray(record.getJpgAttachment(), JSONObject.class);
                 List<String> imageUrls = new ArrayList<>();
                 // 组装图片访问url
                 for (JSONObject object : mapList) {
@@ -266,7 +233,6 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
         ExamCard checkTitleExamCardList = this.getOne(checkTitleQueryWrapper);
 
         ExamCard examCard = new ExamCard();
-        ExamCardDetail examCardDetail = new ExamCardDetail();
         // 新增
         if (Objects.isNull(params.getId())) {
             if (checkTitleExamCardList != null) {
@@ -291,11 +257,6 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
             examCard.setCreateTime(System.currentTimeMillis());
             this.save(examCard);
 
-            // 保存题卡内容
-            examCardDetail.setId(SystemConstant.getDbUuid());
-            examCardDetail.setCardId(examCard.getId());
-            examCardDetail.setCreateId(sysUser.getId());
-            examCardDetail.setCreateTime(System.currentTimeMillis());
             // 方式为上传
             String htmlContent;
             if (CardCreateMethodEnum.UPLOAD.equals(params.getCreateMethod())) {
@@ -310,19 +271,17 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
                     throw ExceptionResultEnum.ERROR.exception("只能上传后缀为.html文件");
                 }
                 htmlContent = teachcloudCommonService.readFileContent(attachment.getPath());
-                examCardDetail.setHtmlContent(htmlContent);
+                examCard.setHtmlContent(htmlContent);
             }
             // 方式为自定义
             else if (CardCreateMethodEnum.STANDARD.equals(params.getCreateMethod())
                     || CardCreateMethodEnum.FREE.equals(params.getCreateMethod())) {
-                examCardDetail.setContent(params.getContent());
+                examCard.setContent(params.getContent());
                 htmlContent = params.getHtmlContent();
-                examCardDetail.setHtmlContent(htmlContent);
+                examCard.setHtmlContent(htmlContent);
             } else {
                 throw ExceptionResultEnum.ERROR.exception("不存在的题卡创建方式");
             }
-
-            examCardDetailService.save(examCardDetail);
         }
         // 修改
         else {
@@ -338,12 +297,8 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
             examCard.setRemark(params.getRemark());
             examCard.setUpdateId(sysUser.getId());
             examCard.setUpdateTime(System.currentTimeMillis());
-            this.updateById(examCard);
 
-            examCardDetail = examCardDetailService.getByCardId(params.getId());
-            examCardDetail.setUpdateId(sysUser.getId());
-            examCardDetail.setUpdateTime(System.currentTimeMillis());
-            String htmlContent = "";
+            String htmlContent;
             // 方式为上传
             if (CardCreateMethodEnum.UPLOAD.equals(params.getCreateMethod())) {
                 if (params.getAttachmentId() == null) {
@@ -357,29 +312,28 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
                     throw ExceptionResultEnum.ERROR.exception("只能上传后缀为.html文件");
                 }
                 htmlContent = teachcloudCommonService.readFileContent(attachment.getPath());
-                examCardDetail.setHtmlContent(htmlContent);
+                examCard.setHtmlContent(htmlContent);
                 // 上传题卡,状态为提交
                 examCard.setStatus(CardStatusEnum.SUBMIT);
             }
             // 方式为自定义
             else if (CardCreateMethodEnum.STANDARD.equals(params.getCreateMethod()) || CardCreateMethodEnum.FREE.equals(params.getCreateMethod())) {
-                examCardDetail.setContent(params.getContent());
+                examCard.setContent(params.getContent());
                 htmlContent = params.getHtmlContent();
-                examCardDetail.setHtmlContent(htmlContent);
+                examCard.setHtmlContent(htmlContent);
             } else {
                 throw ExceptionResultEnum.ERROR.exception("不存在的题卡创建方式");
             }
         }
         // 生成题卡图片
-        List<ConvertJpgStorage> convertJpgStorageList = htmlToJpgUtil.convertHtmlToJpgByCard(examCard.getTitle(), examCardDetail.getHtmlContent(), PageSizeEnum.A3);
+        List<ConvertJpgStorage> convertJpgStorageList = htmlToJpgUtil.convertHtmlToJpgByCard(examCard.getTitle(), examCard.getHtmlContent(), PageSizeEnum.A3);
         if (convertJpgStorageList.size() > 0) {
-            examCardDetail.setJpgAttachmentInfo(JSON.toJSONString(convertJpgStorageList));
+            examCard.setJpgAttachment(JSON.toJSONString(convertJpgStorageList));
         }
-        examCardDetailService.saveOrUpdate(examCardDetail);
+        this.saveOrUpdate(examCard);
         return examCard.getId();
     }
 
-    @Transactional
     @Override
     public Boolean deleteGeneric(Long id) {
         // 校验题卡是否被绑定
@@ -387,7 +341,6 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
         if (examTaskDetails != null && examTaskDetails.size() > 0) {
             throw ExceptionResultEnum.ERROR.exception("题卡已绑定命题任务,不能删除");
         }
-        examCardDetailService.removeByCardId(id);
         return this.removeById(id);
     }
 
@@ -421,45 +374,27 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
         }
         copyExamCard.setRemark(String.format("来源题卡:%s(%s)", id, examCard.getTitle()));
         copyExamCard.setUsed(false);
-        this.save(copyExamCard);
-        Long copyExamCardId = copyExamCard.getId();
-
-        ExamCardDetail examCardDetail = examCardDetailService.getByCardId(id);
-        if (examCardDetail == null) {
-            throw ExceptionResultEnum.ERROR.exception("题卡内容不存在");
-        }
-        // 复制题卡内容
-        ExamCardDetail copyExamCardDetail = new ExamCardDetail();
-        BeanUtils.copyProperties(examCardDetail, copyExamCardDetail);
-        copyExamCardDetail.setId(SystemConstant.getDbUuid());
-        copyExamCardDetail.setCardId(copyExamCardId);
         // 生成图片
-        List<ConvertJpgStorage> convertJpgStorageList = htmlToJpgUtil.convertHtmlToJpgByCard(examCard.getTitle(), copyExamCardDetail.getHtmlContent(), PageSizeEnum.A3);
+        List<ConvertJpgStorage> convertJpgStorageList = htmlToJpgUtil.convertHtmlToJpgByCard(examCard.getTitle(), copyExamCard.getHtmlContent(), PageSizeEnum.A3);
         if (!convertJpgStorageList.isEmpty()) {
-            copyExamCardDetail.setJpgAttachmentInfo(JSON.toJSONString(convertJpgStorageList));
+            copyExamCard.setJpgAttachment(JSON.toJSONString(convertJpgStorageList));
         } else {
-            copyExamCardDetail.setJpgAttachmentInfo(null);
+            copyExamCard.setJpgAttachment(null);
         }
-        examCardDetailService.save(copyExamCardDetail);
-
-        return copyExamCardId;
+        this.save(copyExamCard);
+        return copyExamCard.getId();
     }
 
     @Override
     public void convertImage(Long id) {
         ExamCard examCard = this.getById(id);
-        ExamCardDetail examCardDetail = examCardDetailService.getByCardId(id);
-        if (examCardDetail == null) {
-            throw ExceptionResultEnum.ERROR.exception("题卡不存在");
-        }
-
-        List<ConvertJpgStorage> convertJpgStorageList = htmlToJpgUtil.convertHtmlToJpgByCard(examCard.getTitle(), examCardDetail.getHtmlContent(), PageSizeEnum.A3);
+        List<ConvertJpgStorage> convertJpgStorageList = htmlToJpgUtil.convertHtmlToJpgByCard(examCard.getTitle(), examCard.getHtmlContent(), PageSizeEnum.A3);
         if (convertJpgStorageList.size() > 0) {
             String jpgAttachmentIds = JSON.toJSONString(convertJpgStorageList);
-            UpdateWrapper<ExamCardDetail> updateWrapper = new UpdateWrapper<>();
-            updateWrapper.lambda().set(ExamCardDetail::getJpgAttachmentInfo, jpgAttachmentIds)
-                    .eq(ExamCardDetail::getId, examCardDetail.getId());
-            examCardDetailService.update(updateWrapper);
+            UpdateWrapper<ExamCard> updateWrapper = new UpdateWrapper<>();
+            updateWrapper.lambda().set(ExamCard::getJpgAttachment, jpgAttachmentIds)
+                    .eq(ExamCard::getId, id);
+            this.update(updateWrapper);
         }
     }
 
@@ -478,7 +413,6 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
 
             // 题卡详细信息
             ExamCard examCard = this.getById(id);
-            ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCard.getId());
 
             StringJoiner dirPath = new StringJoiner("");
             dirPath = dirPath.add(rootPath).add(File.separator).add(examCard.getTitle()).add(File.separator);
@@ -487,18 +421,18 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
             // 通用模板
             if (CardTypeEnum.GENERIC.equals(examCard.getType())) {
                 if (CardCreateMethodEnum.UPLOAD.equals(examCard.getCreateMethod())) {
-                    htmlContent = createPdfUtil.resetHtmlTemplateBar(examCardDetail.getHtmlContent());
+                    htmlContent = createPdfUtil.resetHtmlTemplateBar(examCard.getHtmlContent());
                 } else {
                     BasicCardRule basicCardRule = basicCardRuleService.getById(examCard.getCardRuleId());
-                    htmlContent = createPdfUtil.replaceHtmlCard(examCardDetail, basicCardRule);
+                    htmlContent = createPdfUtil.replaceHtmlCard(examCard, basicCardRule);
                 }
             } else {
-                List<ExamTask> examTasks = examCardDetailService.getExamTaskByCourseCodeAndCardId(examCard.getSchoolId(), examCard.getCourseCode(), id);
+                List<ExamTask> examTasks = examTaskService.getExamTaskByCourseCodeAndCardId(examCard.getSchoolId(), examCard.getCourseCode(), id);
                 BasicCardRule basicCardRule = null;
                 if (!CollectionUtils.isEmpty(examTasks)) {
                     basicCardRule = basicCardRuleService.getById(examTasks.get(0).getCardRuleId());
                 }
-                htmlContent = createPdfUtil.replaceHtmlCard(examCardDetail, basicCardRule);
+                htmlContent = createPdfUtil.replaceHtmlCard(examCard, basicCardRule);
             }
 
             // html文件
@@ -521,7 +455,7 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
             HtmlToPdfUtil.convert(cardHtmlPath, cardPdfPath, PageSizeEnum.A3);
 
             // jpg文件
-            String jpgAttachmentIds = examCardDetail.getJpgAttachmentInfo();
+            String jpgAttachmentIds = examCard.getJpgAttachment();
             if (StringUtils.isNotBlank(jpgAttachmentIds)) {
                 List<JSONObject> jsonObjectList = JSONObject.parseArray(jpgAttachmentIds, JSONObject.class);
                 for (JSONObject jsonObject : jsonObjectList) {
@@ -538,7 +472,7 @@ public class ExamCardServiceImpl extends ServiceImpl<ExamCardMapper, ExamCard> i
             }
 
             // json文件
-            String content = examCardDetail.getContent();
+            String content = examCard.getContent();
             if (StringUtils.isNotBlank(content)) {
                 String jsonPath = dirPath + examCard.getTitle() + SystemConstant.JSON_PREFIX;
                 SystemConstant.createJsonFile(jsonPath, content);

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

@@ -89,7 +89,7 @@ public class ExamPaperStructureServiceImpl extends ServiceImpl<ExamPaperStructur
     ExamPaperGroupService examPaperGroupService;
 
     @Resource
-    ExamCardDetailService examCardDetailService;
+    ExamCardService examCardService;
 
     @Resource
     TeachcloudCommonService teachcloudCommonService;
@@ -120,12 +120,12 @@ public class ExamPaperStructureServiceImpl extends ServiceImpl<ExamPaperStructur
 
             ExamTaskDetail examTaskDetail = examTaskDetailService.getOne(new QueryWrapper<ExamTaskDetail>().lambda()
                     .eq(ExamTaskDetail::getExamTaskId, m.getExamTaskId()));
-            if(StringUtils.isNotBlank(examTaskDetail.getPaperAttachmentIds())){
+            if (StringUtils.isNotBlank(examTaskDetail.getPaperAttachmentIds())) {
                 List<JSONObject> jsonObjectList = JSON.parseArray(examTaskDetail.getPaperAttachmentIds(), JSONObject.class);
-               Optional<JSONObject> objectOptional = jsonObjectList.stream().filter(t->m.getPaperType().equals(t.getString("name"))).findFirst();
-               if(objectOptional.isPresent()){
-                   m.setCardId(objectOptional.get().getString("cardId"));
-               }
+                Optional<JSONObject> objectOptional = jsonObjectList.stream().filter(t -> m.getPaperType().equals(t.getString("name"))).findFirst();
+                if (objectOptional.isPresent()) {
+                    m.setCardId(objectOptional.get().getString("cardId"));
+                }
             }
         });
         return examPaperStructureIPage;
@@ -391,8 +391,8 @@ public class ExamPaperStructureServiceImpl extends ServiceImpl<ExamPaperStructur
                     // 试卷类型不匹配跳过
                     continue;
                 }
-                String jpgAttachmentInfo = examCardDetailService.getOne(new QueryWrapper<ExamCardDetail>().lambda()
-                        .eq(ExamCardDetail::getCardId, Long.parseLong((String) object.get("cardId")))).getJpgAttachmentInfo();
+                String jpgAttachmentInfo = examCardService.getOne(new QueryWrapper<ExamCard>().lambda()
+                        .eq(ExamCard::getId, Long.parseLong((String) object.get("cardId")))).getJpgAttachment();
                 if (StringUtils.isBlank(jpgAttachmentInfo)) {
                     return new ArrayList<>();
                 }

+ 7 - 6
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskServiceImpl.java

@@ -113,9 +113,6 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
     @Resource
     private ExamCardService examCardService;
 
-    @Resource
-    private ExamCardDetailService examCardDetailService;
-
     @Resource
     private ExamDetailCourseService examDetailCourseService;
 
@@ -1095,14 +1092,13 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
                     String cardHtmlPath = dirPath.toString() + "题卡" + SystemConstant.HYPHEN + name + SystemConstant.HTML_PREFIX;
                     String cardPdfPath = dirPath.toString() + "题卡" + SystemConstant.HYPHEN + name + SystemConstant.PDF_PREFIX;
 
-                    ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCard.getId());
                     String htmlContent;
                     // 通用模板
                     if (MakeMethodEnum.SELECT.equals(examCard.getMakeMethod())) {
-                        htmlContent = createPdfUtil.resetHtmlTemplateBar(examCardDetail.getHtmlContent());
+                        htmlContent = createPdfUtil.resetHtmlTemplateBar(examCard.getHtmlContent());
                     } else {
                         BasicCardRule basicCardRule = basicCardRuleService.getById(examTask.getCardRuleId());
-                        htmlContent = createPdfUtil.replaceHtmlCard(examCardDetail, basicCardRule);
+                        htmlContent = createPdfUtil.replaceHtmlCard(examCard, basicCardRule);
                     }
 
                     // html
@@ -2261,6 +2257,11 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
         return true;
     }
 
+    @Override
+    public List<ExamTask> getExamTaskByCourseCodeAndCardId(Long schoolId, String courseCode, String cardId) {
+        return this.baseMapper.getExamTaskByCourseCodeAndCardId(schoolId, courseCode, cardId);
+    }
+
     /**
      * 简单校验提交参数
      *

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

@@ -94,9 +94,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
     @Resource
     ExamCardService examCardService;
 
-    @Resource
-    ExamCardDetailService examCardDetailService;
-
     @Resource
     ExamStudentService examStudentService;
 
@@ -372,27 +369,23 @@ public class TaskLogicServiceImpl implements TaskLogicService {
             // 题卡数据组装
             basicAttachmentList = Objects.isNull(basicAttachmentList) ? new ArrayList<>() : basicAttachmentList;
             if (printContent.contains("CARD")) {
-                Map<String, ExamCardDetail> examCardDetailMap = new HashMap<>();
+                Map<String, ExamCard> examCardDetailMap = new HashMap<>();
                 Map<String, String> cardContentMap = new HashMap<>();
                 for (String s : examDetailCourse.getPaperType().split(",")) {
                     examCard = examCardMap.get(s);
                     Optional.ofNullable(examCard).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("卷型" + s + "题卡不存在"));
 
-                    QueryWrapper<ExamCardDetail> examCardDetailQueryWrapper = new QueryWrapper<>();
-                    examCardDetailQueryWrapper.lambda().eq(ExamCardDetail::getCardId, examCard.getId());
-                    ExamCardDetail examCardDetail = examCardDetailService.getOne(examCardDetailQueryWrapper);
-
-                    createPdfUtil.getCardAttachmentId(examCardDetail, attachmentIds);
+                    createPdfUtil.getCardAttachmentId(examCard, attachmentIds);
 
                     //把模板页面上的 ${} 替换成实际内容
-                    String cardContent = createPdfUtil.resetHtmlTemplateBar(examCardDetail.getHtmlContent());
+                    String cardContent = createPdfUtil.resetHtmlTemplateBar(examCard.getHtmlContent());
 
                     for (int i = 1; i <= backupCount; i++) {
                         BasicAttachment basicAttachment = createPdfUtil.cardHtml(String.format(SystemConstant.DATE_TIME_FORMAT, i), cardContent, examDetail, examDetailCourse, s, jsonArray, sysUser.getId(), backupCardPdfList, basicCardRule, fileTempList);
                         examDetailCourse.setCardPagesA3(basicAttachment.getPages());
                         basicAttachmentList.add(basicAttachment);
                     }
-                    examCardDetailMap.put(s, examCardDetail);
+                    examCardDetailMap.put(s, examCard);
                     cardContentMap.put(s, cardContent);
                 }
                 // 备用题卡
@@ -1214,12 +1207,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                             FileUtil.copyFile(jsonObject.getString(SystemConstant.PATH), cardPath);
                         }
                     } else {
-                        List<ExamCardDetail> examCardDetailList = examCardDetailService.list(new QueryWrapper<ExamCardDetail>().lambda().eq(ExamCardDetail::getCardId, cardId));
-                        if (examCardDetailList.size() != 1) {
-                            throw ExceptionResultEnum.ERROR.exception("题卡明细信息异常");
-                        }
-                        ExamCardDetail examCardDetail = examCardDetailService.getByCardId(cardId);
-                        String htmlContent = examCardDetail.getHtmlContent();
+                        String htmlContent = examCard.getHtmlContent();
                         byte[] bytes = htmlContent.getBytes(StandardCharsets.UTF_8);
 
                         // 题卡路径
@@ -1318,13 +1306,12 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                         String cardHtmlPath = dirPath.toString() + "题卡" + SystemConstant.HYPHEN + paperMap.get("name") + SystemConstant.HTML_PREFIX;
                         String cardPdfPath = dirPath.toString() + "题卡" + SystemConstant.HYPHEN + paperMap.get("name") + SystemConstant.PDF_PREFIX;
                         // 通用题卡
-                        ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCard.getId());
                         String htmlContent;
                         if (MakeMethodEnum.SELECT.equals(makeMethodEnum)) {
-                            htmlContent = createPdfUtil.resetHtmlTemplateBar(examCardDetail.getHtmlContent());
+                            htmlContent = createPdfUtil.resetHtmlTemplateBar(examCard.getHtmlContent());
                         } else {
                             BasicCardRule basicCardRule = basicCardRuleService.getById(examTask.getCardRuleId());
-                            htmlContent = createPdfUtil.replaceHtmlCard(examCardDetail, basicCardRule);
+                            htmlContent = createPdfUtil.replaceHtmlCard(examCard, basicCardRule);
                         }
                         // html
                         File localFile = new File(cardHtmlPath);
@@ -1926,13 +1913,12 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                                 Long cardRuleId = examTaskPaperFileDto.getCardRuleId();
                                 ExamCard examCard = examCardService.getById(examCardId);
                                 if (examCard != null) {
-                                    ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCardId);
                                     String htmlContent;
                                     if (MakeMethodEnum.SELECT.equals(examCard.getMakeMethod()) && CardCreateMethodEnum.UPLOAD.equals(examCard.getCreateMethod())) {
-                                        htmlContent = createPdfUtil.resetHtmlTemplateBar(examCardDetail.getHtmlContent());
+                                        htmlContent = createPdfUtil.resetHtmlTemplateBar(examCard.getHtmlContent());
                                     } else {
                                         BasicCardRule basicCardRule = basicCardRuleService.getById(cardRuleId);
-                                        htmlContent = createPdfUtil.replaceHtmlCard(examCardDetail, basicCardRule);
+                                        htmlContent = createPdfUtil.replaceHtmlCard(examCard, basicCardRule);
                                     }
 
                                     byte[] bytes = htmlContent.getBytes(StandardCharsets.UTF_8);
@@ -1997,14 +1983,13 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                                 Long examCardId = examTaskPaperFileDto.getExamCardId();
                                 Long cardRuleId = examTaskPaperFileDto.getCardRuleId();
                                 ExamCard examCard = examCardService.getById(examCardId);
-                                if (examCard == null) {
-                                    ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCardId);
+                                if (examCard != null) {
                                     String htmlContent;
                                     if (MakeMethodEnum.SELECT.equals(examCard.getMakeMethod()) && CardCreateMethodEnum.UPLOAD.equals(examCard.getCreateMethod())) {
-                                        htmlContent = createPdfUtil.resetHtmlTemplateBar(examCardDetail.getHtmlContent());
+                                        htmlContent = createPdfUtil.resetHtmlTemplateBar(examCard.getHtmlContent());
                                     } else {
                                         BasicCardRule basicCardRule = basicCardRuleService.getById(cardRuleId);
-                                        htmlContent = createPdfUtil.replaceHtmlCard(examCardDetail, basicCardRule);
+                                        htmlContent = createPdfUtil.replaceHtmlCard(examCard, basicCardRule);
                                     }
 
                                     byte[] bytes = htmlContent.getBytes(StandardCharsets.UTF_8);

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

@@ -922,9 +922,9 @@ public class CreatePdfUtil {
      * @return
      * @throws IOException
      */
-    public String replaceHtmlCard(ExamCardDetail examCardDetail, BasicCardRule basicCardRule) throws IOException {
+    public String replaceHtmlCard(ExamCard examCard, BasicCardRule basicCardRule) throws IOException {
         //通用题卡
-        String cardTemp = examCardDetail.getHtmlContent();
+        String cardTemp = examCard.getHtmlContent();
         cardTemp = cardTemp.replaceAll("\\$\\{paperTypeName\\}", "");
         //随机生成试卷条码并将图片转成base64
         cardTemp = cardTemp.replaceAll("\\$\\{paperType\\}", "");
@@ -966,12 +966,12 @@ public class CreatePdfUtil {
     /**
      * 获取题卡attachmentId
      *
-     * @param examCardDetail
+     * @param examCard
      * @param attachmentIds
      */
-    public void getCardAttachmentId(ExamCardDetail examCardDetail, Set<Long> attachmentIds) {
-        if (Objects.nonNull(examCardDetail.getAttachmentId()) && !Objects.equals("", examCardDetail.getAttachmentId())) {
-            JSONObject jsonObjectCard = JSONObject.parseObject(examCardDetail.getAttachmentId());
+    public void getCardAttachmentId(ExamCard examCard, Set<Long> attachmentIds) {
+        if (Objects.nonNull(examCard.getBackupAttachment()) && !Objects.equals("", examCard.getBackupAttachment())) {
+            JSONObject jsonObjectCard = JSONObject.parseObject(examCard.getBackupAttachment());
             JSONArray jsonArrayCard = (JSONArray) jsonObjectCard.get("card");
             for (int i = 0; i < jsonArrayCard.size(); i++) {
                 JSONObject object = (JSONObject) jsonArrayCard.get(i);

+ 14 - 0
distributed-print-business/src/main/resources/db/log/脚本-xiaof.sql

@@ -190,3 +190,17 @@ DELETE FROM `sys_privilege` WHERE (`id` = '424');
 DELETE FROM `sys_privilege` WHERE (`id` = '436');
 DELETE FROM `sys_privilege` WHERE (`id` = '307');
 
+ALTER TABLE `exam_card`
+    ADD COLUMN `content` MEDIUMTEXT NULL COMMENT '题卡工具制作题卡内容' AFTER `status`,
+ADD COLUMN `html_content` MEDIUMTEXT NULL COMMENT 'html格式内容' AFTER `content`,
+ADD COLUMN `backup_attachment` MEDIUMTEXT NULL COMMENT '备用题卡json' AFTER `card_rule_id`,
+ADD COLUMN `jpg_attachment` TEXT NULL COMMENT '题卡转换成的jpg文件信息' AFTER `backup_attachment`,
+CHANGE COLUMN `create_id` `create_id` BIGINT NULL DEFAULT NULL COMMENT '创建人' AFTER `jpg_attachment_info`,
+CHANGE COLUMN `create_time` `create_time` BIGINT NULL DEFAULT NULL COMMENT '创建时间' AFTER `create_id`,
+CHANGE COLUMN `update_id` `update_id` BIGINT NULL DEFAULT NULL COMMENT '更新人' AFTER `create_time`,
+CHANGE COLUMN `update_time` `update_time` BIGINT NULL DEFAULT NULL COMMENT '更新时间' AFTER `update_id`;
+
+update exam_card a set a.content = (select b.content from exam_card_detail b where a.id = b.card_id);
+update exam_card a set a.html_content = (select b.html_content from exam_card_detail b where a.id = b.card_id);
+update exam_card a set a.backup_attachment = (select b.attachment_id from exam_card_detail b where a.id = b.card_id);
+update exam_card a set a.jpg_attachment = (select b.jpg_attachment_info from exam_card_detail b where a.id = b.card_id);

+ 0 - 33
distributed-print-business/src/main/resources/mapper/ExamCardDetailMapper.xml

@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.qmth.distributed.print.business.mapper.ExamCardDetailMapper">
-
-    <!-- 通用查询映射结果 -->
-    <resultMap id="BaseResultMap" type="com.qmth.distributed.print.business.entity.ExamCardDetail">
-    <result column="id" property="id" />
-        <result column="card_id" property="cardId" />
-        <result column="content" property="content" />
-        <result column="html_content" property="htmlContent" />
-        <result column="attachment_id" property="attachmentId" />
-    </resultMap>
-
-    <!-- 通用查询结果列 -->
-    <sql id="Base_Column_List">
-        id,
-        card_id, content, html_content, attachment_id
-    </sql>
-    <select id="getExamTaskByCourseCodeAndCardId"
-            resultMap="com.qmth.distributed.print.business.mapper.ExamTaskMapper.BaseResultMap">
-        SELECT
-            *
-        FROM
-            exam_task et
-                LEFT JOIN
-            exam_task_detail etd ON et.id = etd.exam_task_id
-        WHERE
-            et.school_id = #{schoolId}
-          AND et.course_code = #{courseCode}
-          and FIND_IN_SET(#{cardId}, REPLACE(REPLACE(substring_index(substring_index(CONVERT((etd.paper_attachment_ids ->>'$[*].cardId') USING utf8), ']', 1), '[',-1),' "','"'),'"',''))
-    </select>
-
-</mapper>

+ 17 - 67
distributed-print-business/src/main/resources/mapper/ExamCardMapper.xml

@@ -19,6 +19,10 @@
         <result column="type" property="type"/>
         <result column="create_method" property="createMethod"/>
         <result column="attachment_id" property="attachmentId"/>
+        <result column="content" property="content"/>
+        <result column="html_content" property="htmlContent"/>
+        <result column="backup_attachment" property="backupAttachment"/>
+        <result column="jpg_attachment" property="jpgAttachment"/>
         <result column="sync_status" property="syncStatus"/>
         <result column="enable" property="enable"/>
         <result column="used" property="used"/>
@@ -28,24 +32,8 @@
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id,
-        school_id,org_id, course_code, course_name, title, make_method, status, create_id, create_time, update_id, update_time, type, create_method, attachment_id, sync_status, enable, used, remark, card_rule_id
+       select id, school_id,org_id, course_code, course_name, title, make_method, status, type, create_method, content,html_content, backup_attachment, jpg_attachment,attachment_id, sync_status, enable, used, remark, card_rule_id, create_id, create_time, update_id, update_time from exam_card
     </sql>
-    <select id="getCardDetail" resultType="com.qmth.distributed.print.business.bean.dto.CardDetailDto">
-        SELECT
-            a.id cardId,
-            a.title,
-            a.create_method createMethod,
-            a.make_method makeMethod,
-            a.type,
-            b.content,
-            b.html_content htmlContent
-        FROM
-            exam_card a
-                LEFT JOIN
-            exam_card_detail b ON a.id = b.card_id
-        where a.id = #{cardId}
-    </select>
     <select id="listGenericCard" resultType="com.qmth.distributed.print.business.entity.ExamCard">
         SELECT
             distinct a.id, a.title, a.type, a.make_method makeMethod, a.create_method createMethod
@@ -78,79 +66,41 @@
             AND a.create_time >= 1680624000000
         order by a.create_time desc
     </select>
-    <select id="getCardDetailBySelect" resultType="com.qmth.distributed.print.business.bean.dto.CardDetailDto">
-        SELECT
-            a.id cardId,
-            a.title,
-            a.create_method createMethod,
-            a.make_method makeMethod,
-            a.type,
-            b.content,
-            b.html_content htmlContent
-        FROM
-            exam_card a
-                LEFT JOIN
-            exam_card_detail b ON a.id = b.card_id
-        where a.id = #{cardId}
-    </select>
-    <select id="listPage" resultType="com.qmth.distributed.print.business.bean.dto.ExamCardPageDto">
-        select
-            ec.id id,
-            ec.school_id schoolId,
-            ec.org_id orgId,
-            ec.course_code courseCode,
-            ec.course_name courseName,
-            ec.title title,
-            ec.make_method makeMethod,
-            ec.status status,
-            ec.create_id createId,
-            ec.create_time createTime,
-            ec.update_id updateId,
-            ec.update_time updateTime,
-            ec.type type,
-            ec.create_method createMethod,
-            ec.attachment_id attachmentId,
-            ec.sync_status syncStatus,
-            ec.enable enable,
-            ec.used used,
-            ec.remark remark,
-            ec.card_rule_id cardRuleId,
-            ecd.jpg_attachment_info jpgAttachmentInfo
-        from exam_card ec
-            left join exam_card_detail ecd on ec.id = ecd.card_id
+    <select id="listPage" resultMap="BaseResultMap">
+        <include refid="Base_Column_List"></include>
         <where>
-            ec.school_id = #{schoolId}
+            school_id = #{schoolId}
             <if test="cardType != null and cardType != ''">
-                and ec.type = #{cardType}
+                and type = #{cardType}
             </if>
             <if test="title != null and title != ''">
-                and ec.title like concat('%', #{title}, '%')
+                and title like concat('%', #{title}, '%')
             </if>
             <if test="createMethod != null and createMethod != ''">
-                and ec.create_method = #{createMethod}
+                and create_method = #{createMethod}
             </if>
             <if test="enable != null and enable != ''">
-                and ec.enable = #{enable}
+                and enable = #{enable}
             </if>
             <if test="createStartTime != null and createStartTime != ''">
-                and ec.create_time &gt;= #{createStartTime}
+                and create_time &gt;= #{createStartTime}
             </if>
             <if test="createEndTime != null and createEndTime != ''">
-                and ec.create_time &lt;= #{createEndTime}
+                and create_time &lt;= #{createEndTime}
             </if>
             <if test="dpr != null">
                 <if test="dpr.requestUserId != null">
-                    AND ec.create_id = #{dpr.requestUserId}
+                    AND create_id = #{dpr.requestUserId}
                 </if>
                 <if test="dpr.orgIdSet != null and dpr.orgIdSet != '' and dpr.orgIdSet.size > 0">
-                    AND ec.org_id IN
+                    AND org_id IN
                     <foreach collection="dpr.orgIdSet" item="item" index="index" open="(" separator="," close=")">
                         #{item}
                     </foreach>
                 </if>
             </if>
         </where>
-        order by ec.create_time desc
+        order by create_time desc
     </select>
     <select id="listCustomByExamStage" resultType="com.qmth.distributed.print.business.entity.ExamCard">
         SELECT

+ 13 - 0
distributed-print-business/src/main/resources/mapper/ExamTaskMapper.xml

@@ -1246,4 +1246,17 @@
               </if>
           </where>
     </select>
+    <select id="getExamTaskByCourseCodeAndCardId"
+            resultMap="BaseResultMap">
+        SELECT
+            *
+        FROM
+            exam_task et
+                LEFT JOIN
+            exam_task_detail etd ON et.id = etd.exam_task_id
+        WHERE
+            et.school_id = #{schoolId}
+          AND et.course_code = #{courseCode}
+          and FIND_IN_SET(#{cardId}, REPLACE(REPLACE(substring_index(substring_index(CONVERT((etd.paper_attachment_ids ->>'$[*].cardId') USING utf8), ']', 1), '[',-1),' "','"'),'"',''))
+    </select>
 </mapper>

+ 3 - 5
distributed-print/src/main/java/com/qmth/distributed/print/api/ExamCardController.java

@@ -3,8 +3,6 @@ package com.qmth.distributed.print.api;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.qmth.boot.api.constant.ApiConstant;
-import com.qmth.distributed.print.business.bean.dto.CardDetailDto;
-import com.qmth.distributed.print.business.bean.dto.ExamCardPageDto;
 import com.qmth.distributed.print.business.bean.params.ExamCardParams;
 import com.qmth.distributed.print.business.bean.params.GenericExamCardParams;
 import com.qmth.distributed.print.business.entity.ExamCard;
@@ -72,7 +70,7 @@ public class ExamCardController {
                        @RequestParam(value = "createEndTime", required = false) Long createEndTime,
                        @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
                        @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
-        IPage<ExamCardPageDto> examCardIPage = examCardService.listPage(cardType, title, createMethod, enable, createStartTime, createEndTime, pageNumber, pageSize);
+        IPage<ExamCard> examCardIPage = examCardService.listPage(cardType, title, createMethod, enable, createStartTime, createEndTime, pageNumber, pageSize);
         return ResultUtil.ok(examCardIPage);
     }
 
@@ -125,8 +123,8 @@ public class ExamCardController {
     @ApiOperation(value = "根据ID获取题卡详情")
     @RequestMapping(value = "/get_one", method = RequestMethod.POST)
     public Result getOne(@RequestParam("cardId") Long cardId) {
-        CardDetailDto cardDetailDto = examCardService.getCardDetail(cardId);
-        return ResultUtil.ok(cardDetailDto);
+        ExamCard examCard = examCardService.getById(cardId);
+        return ResultUtil.ok(examCard);
     }
 
     /**

+ 1 - 16
distributed-print/src/test/java/com/qmth/distributed/print/ServiceTest.java

@@ -5,16 +5,14 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.qmth.distributed.print.business.bean.dto.examObject.ExamObjectDto;
 import com.qmth.distributed.print.business.bean.marking.CardJpgResult;
-import com.qmth.distributed.print.business.entity.ExamCardDetail;
 import com.qmth.distributed.print.business.entity.ExamPrintPlan;
 import com.qmth.distributed.print.business.entity.ExamStudent;
-import com.qmth.teachcloud.common.enums.MessageEnum;
 import com.qmth.distributed.print.business.mapper.ExamStudentMapper;
 import com.qmth.distributed.print.business.service.*;
 import com.qmth.teachcloud.common.contant.SystemConstant;
-import com.qmth.teachcloud.common.entity.BasicAttachment;
 import com.qmth.teachcloud.common.entity.BasicCourse;
 import com.qmth.teachcloud.common.entity.BasicPrintConfig;
+import com.qmth.teachcloud.common.enums.MessageEnum;
 import com.qmth.teachcloud.common.service.BasicCourseService;
 import com.qmth.teachcloud.common.service.BasicVerifyCodeService;
 import com.qmth.teachcloud.common.util.ConvertUtil;
@@ -24,7 +22,6 @@ import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
 import javax.annotation.Resource;
-import java.io.IOException;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -56,9 +53,6 @@ public class ServiceTest {
     @Resource
     private PrintCommonService printCommonService;
 
-    @Resource
-    private ExamCardDetailService examCardDetailService;
-
     @Resource
     private BasicPrintConfigService basicPrintConfigService;
 
@@ -146,15 +140,6 @@ public class ServiceTest {
         System.out.println(JSON.toJSONString(examTaskService.findExamTaskApprovalForm(examTask)));
     }
 
-    @Test
-    public void saveHtmlAndPdf() throws IOException {
-        Long id = 165147096339447808L;
-        ExamCardDetail examCardDetail = examCardDetailService.getById(id);
-        String htmlContent = examCardDetail.getHtmlContent();
-        BasicAttachment basicAttachment = printCommonService.saveAttachmentHtmlAndPdf("那不勒斯", htmlContent, 1L);
-        System.out.println(JSON.toJSONString(basicAttachment));
-    }
-
     @Test
     public void findExamObject() {
         String paperNumber = "cn004-0906-001";