xiaofei преди 1 година
родител
ревизия
c2a109391f

+ 4 - 9
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/DownloadServiceImpl.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qmth.distributed.print.business.bean.dto.*;
+import com.qmth.distributed.print.business.util.pdf.CreatePdfNewUtil;
 import com.qmth.teachcloud.common.bean.vo.PaperInfoVo;
 import com.qmth.distributed.print.business.entity.*;
 import com.qmth.distributed.print.business.enums.MakeMethodEnum;
@@ -65,6 +66,8 @@ public class DownloadServiceImpl implements DownloadService {
     @Resource
     CreatePdfUtil createPdfUtil;
     @Resource
+    CreatePdfNewUtil createPdfNewUtil;
+    @Resource
     private BasicRoleDataPermissionService basicRoleDataPermissionService;
 
     @Override
@@ -137,21 +140,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;
 
-                    String htmlContent;
-                    // 通用模板
-                    if (MakeMethodEnum.SELECT.equals(examCard.getMakeMethod()) && CardCreateMethodEnum.UPLOAD.equals(examCard.getCreateMethod())) {
-                        htmlContent = createPdfUtil.resetHtmlTemplateBar(examCard.getHtmlContent());
-                    } else {
-                        BasicCardRule basicCardRule = basicCardRuleService.getById(examTask.getCardRuleId());
-                        htmlContent = createPdfUtil.replaceHtmlCardAllParams(examCard, basicCardRule);
-                    }
-
                     // html
                     File htmlFile = new File(cardHtmlPath);
                     if (!htmlFile.exists()) {
                         htmlFile.getParentFile().mkdirs();
                         htmlFile.createNewFile();
                     }
+                    String htmlContent = createPdfNewUtil.replaceBlankHtmlContent(examCard.getContent());
                     // 生成html文件
                     FileCopyUtils.copy(htmlContent.getBytes(StandardCharsets.UTF_8), htmlFile);
                     fileList.add(htmlFile);

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

@@ -22,6 +22,7 @@ import com.qmth.distributed.print.business.enums.*;
 import com.qmth.distributed.print.business.service.*;
 import com.qmth.distributed.print.business.templete.service.TaskLogicService;
 import com.qmth.distributed.print.business.util.CreatePdfUtil;
+import com.qmth.distributed.print.business.util.pdf.CreatePdfNewUtil;
 import com.qmth.teachcloud.common.annotation.ExcelDBFieldDesc;
 import com.qmth.teachcloud.common.base.BaseEntity;
 import com.qmth.teachcloud.common.bean.dto.DataPermissionRule;
@@ -114,6 +115,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
     @Resource
     CreatePdfUtil createPdfUtil;
     @Resource
+    CreatePdfNewUtil createPdfNewUtil;
+    @Resource
     TBTaskPdfService tbTaskPdfService;
     @Resource
     BasicCardRuleService basicCardRuleService;
@@ -1811,7 +1814,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
             throw ExceptionResultEnum.ERROR.exception("请选择下载文件");
         }
         PaperFileDownloadExposureStatusEnum paperFileDownloadExposureStatus = downloadPaperFileParam.getPaperFileDownloadExposureStatus();
-        if (Objects.isNull(paperFileDownloadExposureStatus)) {
+        if ((PaperFileDownloadContentEnum.ONLY_PAPER.equals(paperFileDownloadContent) || PaperFileDownloadContentEnum.PAPER_AND_CARD.equals(paperFileDownloadContent)) && Objects.isNull(paperFileDownloadExposureStatus)) {
             throw ExceptionResultEnum.ERROR.exception("请选择试卷状态");
         }
         Boolean namedByCourseInfo = downloadPaperFileParam.getNamedByCourseInfo();
@@ -1853,7 +1856,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
             for (ExamTaskDetailDto examTaskDetailDto : examTaskDetailDtoList) {
                 ExamTaskPaperExportDto examTaskPaperExportDto = new ExamTaskPaperExportDto(examTaskDetailDto);
                 examTaskPaperExportDtoList.add(examTaskPaperExportDto);
-                List<PaperInfoVo> paperInfoVoList = new ArrayList<>();
+                List<PaperInfoVo> paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetailDto.getPaperAttachmentIds());
                 // 选择曝光卷型
                 if (PaperFileDownloadExposureStatusEnum.EXPOSED_PAPER.equals(paperFileDownloadExposureStatus)) {
                     if (StringUtils.isBlank(examTaskDetailDto.getExposedPaperType())) {
@@ -1872,10 +1875,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                         paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetailDto.getPaperAttachmentIds(), examTaskDetailDto.getUnexposedPaperType());
                     }
                 }
-                // 选择全部卷型
-                if (PaperFileDownloadExposureStatusEnum.ALL_PAPER.equals(paperFileDownloadExposureStatus)) {
-                    paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetailDto.getPaperAttachmentIds());
-                }
 
                 if (CollectionUtils.isEmpty(paperInfoVoList)) {
                     examTaskPaperExportDto.setResult("所选试卷状态未查询到上传的试卷信息,下载失败");
@@ -1895,10 +1894,10 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                 // 目录规则(课程名称(课程代码)/试卷编号)
                 String secondPath = examTaskDetailDto.getCourseName() + SystemConstant.HYPHEN + examTaskDetailDto.getCourseCode() + File.separator + examTaskDetailDto.getPaperNumber();
                 for (PaperInfoVo paperInfoVo : paperInfoVoList) {
-                    // 不管什么命名规则,默认都加上卷型前缀
-                    fileNamePath = "试卷" + SystemConstant.HYPHEN + paperInfoVo.getName() + SystemConstant.HYPHEN + fileNamePath;
                     // 下载试卷
                     if (downloadPaper) {
+                        // 不管什么命名规则,默认都加上卷型前缀
+                        fileNamePath = "试卷" + SystemConstant.HYPHEN + paperInfoVo.getName() + SystemConstant.HYPHEN + fileNamePath;
                         // 原文件名
                         if (namedByOriginalFile) {
                             fileNamePath = fileNamePath + File.separator + paperInfoVo.getFilename();
@@ -1920,8 +1919,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                         ExamCard examCard = examCardService.getById(cardId);
                         Optional.ofNullable(examCard).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("找不到答题卡"));
 
-                        MakeMethodEnum makeMethodEnum = examCard.getMakeMethod();
-
                         String cardHtmlPath = zipLocalRootPath + File.separator + secondPath + File.separator + "题卡" + SystemConstant.HYPHEN + paperInfoVo.getName() + SystemConstant.HYPHEN + fileNamePath;
                         String cardPdfPath = zipLocalRootPath + File.separator + secondPath + File.separator + "题卡" + SystemConstant.HYPHEN + paperInfoVo.getName() + SystemConstant.HYPHEN + fileNamePath;
                         // 原文件名
@@ -1933,20 +1930,14 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                             cardPdfPath = StringUtils.deleteWhitespace(cardPdfPath + SystemConstant.PDF_PREFIX);
                         }
 
-                        // 通用题卡
-                        String htmlContent;
-                        if (MakeMethodEnum.SELECT.equals(makeMethodEnum)) {
-                            htmlContent = createPdfUtil.resetHtmlTemplateBar(examCard.getHtmlContent());
-                        } else {
-                            BasicCardRule basicCardRule = basicCardRuleService.getById(examTaskDetailDto.getCardRuleId());
-                            htmlContent = createPdfUtil.replaceHtmlCardAllParams(examCard, basicCardRule);
-                        }
                         // html
                         File localFile = new File(cardHtmlPath);
                         if (!localFile.exists()) {
                             localFile.getParentFile().mkdirs();
                             localFile.createNewFile();
                         }
+                        // 通用题卡
+                        String htmlContent = createPdfNewUtil.replaceBlankHtmlContent(examCard.getHtmlContent());
                         // 生成html文件
                         FileCopyUtils.copy(htmlContent.getBytes(StandardCharsets.UTF_8), localFile);
                         // 转pdf文件

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

@@ -12,6 +12,7 @@ import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
 import com.qmth.teachcloud.common.enums.TaskTypeEnum;
 import com.qmth.teachcloud.common.util.ResultUtil;
 import io.swagger.annotations.*;
+import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.*;
 
@@ -70,7 +71,7 @@ public class DownloadController {
     @RequestMapping(value = "/download_batch", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "批量下载", response = TaskListResult.class)})
     public Object downloadBatch(@Valid @RequestBody DownloadPaperFileParam downloadPaperFileParam, BindingResult bindingResult) throws Exception {
-        if (downloadPaperFileParam.getExamId() == null) {
+        if (CollectionUtils.isEmpty(downloadPaperFileParam.getIdSet()) && downloadPaperFileParam.getExamId() == null) {
             throw ExceptionResultEnum.EXAM_ID_IS_NULL.exception();
         }
         if (bindingResult.hasErrors()) {