Browse Source

批量下载pdf名称优化

wangliang 2 years ago
parent
commit
092ed95f08

+ 115 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ExamDetailPdfDownloadDto.java

@@ -0,0 +1,115 @@
+package com.qmth.distributed.print.business.bean.dto;
+
+import com.qmth.distributed.print.business.entity.ExamDetail;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.File;
+
+/**
+ * @Description: examDetail pdf dto
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2022/10/13
+ */
+public class ExamDetailPdfDownloadDto extends ExamDetail {
+
+    @ApiModelProperty(value = "学期名称")
+    private String semesterName;
+
+    @ApiModelProperty(value = "考试名称")
+    private String examName;
+
+    @ApiModelProperty(value = "课程名(课程代码)")
+    private String courseNameCode;
+
+    @ApiModelProperty(value = "试卷编号")
+    private String paperNumber;
+
+    @ApiModelProperty(value = "试卷文件")
+    private File paperFile;
+
+    @ApiModelProperty(value = "题卡文件")
+    private File cardFile;
+
+    @ApiModelProperty(value = "卷袋贴文件")
+    private File packageFile;
+
+    @ApiModelProperty(value = "签到表文件")
+    private File signFile;
+
+    @ApiModelProperty(value = "登记表文件")
+    private File checkInFile;
+
+    public File getPaperFile() {
+        return paperFile;
+    }
+
+    public void setPaperFile(File paperFile) {
+        this.paperFile = paperFile;
+    }
+
+    public File getCardFile() {
+        return cardFile;
+    }
+
+    public void setCardFile(File cardFile) {
+        this.cardFile = cardFile;
+    }
+
+    public File getPackageFile() {
+        return packageFile;
+    }
+
+    public void setPackageFile(File packageFile) {
+        this.packageFile = packageFile;
+    }
+
+    public File getSignFile() {
+        return signFile;
+    }
+
+    public void setSignFile(File signFile) {
+        this.signFile = signFile;
+    }
+
+    public File getCheckInFile() {
+        return checkInFile;
+    }
+
+    public void setCheckInFile(File checkInFile) {
+        this.checkInFile = checkInFile;
+    }
+
+    public String getSemesterName() {
+        return semesterName;
+    }
+
+    public void setSemesterName(String semesterName) {
+        this.semesterName = semesterName;
+    }
+
+    public String getExamName() {
+        return examName;
+    }
+
+    public void setExamName(String examName) {
+        this.examName = examName;
+    }
+
+    public String getCourseNameCode() {
+        return courseNameCode;
+    }
+
+    public void setCourseNameCode(String courseNameCode) {
+        this.courseNameCode = courseNameCode;
+    }
+
+    public String getPaperNumber() {
+        return paperNumber;
+    }
+
+    public void setPaperNumber(String paperNumber) {
+        this.paperNumber = paperNumber;
+    }
+}

+ 13 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamDetailMapper.java

@@ -3,7 +3,10 @@ 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.*;
+import com.qmth.distributed.print.business.bean.dto.ClientExamStudentDto;
+import com.qmth.distributed.print.business.bean.dto.ExamDetailPdfDownloadDto;
+import com.qmth.distributed.print.business.bean.dto.PrintTaskDto;
+import com.qmth.distributed.print.business.bean.dto.PrintTaskTotalDto;
 import com.qmth.distributed.print.business.bean.result.ExaminationDetailResult;
 import com.qmth.distributed.print.business.bean.result.ExaminationResult;
 import com.qmth.distributed.print.business.entity.ExamDetail;
@@ -102,5 +105,13 @@ public interface ExamDetailMapper extends BaseMapper<ExamDetail> {
                              @Param("printHouseId") Long printHouseId,
                              @Param("orgIds") Set<Long> orgIds);
 
-    List<ExamDetailCourse> listSyncPaperNumberByPrintPlanId(Long printPlanId);
+    List<ExamDetailCourse> listSyncPaperNumberByPrintPlanId(@Param("printPlanId") Long printPlanId);
+
+    /**
+     * 根据id下载examDetail
+     *
+     * @param ids
+     * @return
+     */
+    List<ExamDetailPdfDownloadDto> findPdfDownload(@Param("ids") List<Long> ids);
 }

+ 11 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamDetailService.java

@@ -45,7 +45,7 @@ public interface ExamDetailService extends IService<ExamDetail> {
      */
     double calculateTotalPackages(Long printPlanId);
 
-    IPage<PrintTaskDto> listPrintTask(Long semesterId,Long examId, Long printPlanId, String status, String courseCode, String paperNumber, String examPlace, String examRoom, Long examStartTime, Long examEndTime, Long printStartTime, Long printEndTime, Long printHouseId, Integer pageNumber, Integer pageSize);
+    IPage<PrintTaskDto> listPrintTask(Long semesterId, Long examId, Long printPlanId, String status, String courseCode, String paperNumber, String examPlace, String examRoom, Long examStartTime, Long examEndTime, Long printStartTime, Long printEndTime, Long printHouseId, Integer pageNumber, Integer pageSize);
 
     PrintTaskTotalDto taskTotalData(Long printPlanId, String status, String courseCode, String paperNumber, String examPlace, String examRoom, Long examStartTime, Long examEndTime, Long printStartTime, Long printEndTime, Long printHouseId);
 
@@ -114,7 +114,7 @@ public interface ExamDetailService extends IService<ExamDetail> {
     /**
      * 查询考务数据-明细
      *
-     * @param schoolId      学校id
+     * @param schoolId        学校id
      * @param semesterId      学期id
      * @param examId          考试id
      * @param printPlanIdList 印刷计划id集合
@@ -129,7 +129,7 @@ public interface ExamDetailService extends IService<ExamDetail> {
      * @param pageSize        分页数量
      * @return 查询结果
      */
-    IPage<ExaminationDetailResult> findExaminationDetail(Long schoolId,Long semesterId,Long examId, List<Long> printPlanIdList, String courseCode, String paperNumber, String examPlace,
+    IPage<ExaminationDetailResult> findExaminationDetail(Long schoolId, Long semesterId, Long examId, List<Long> printPlanIdList, String courseCode, String paperNumber, String examPlace,
                                                          String examRoom, String studentParams, Long startDate, Long endDate, int pageNumber, int pageSize);
 
     IPage<ExaminationDetailResult> findExaminationDetail(Long convertIdToLong, int pageNumber, int pageSize);
@@ -231,4 +231,12 @@ public interface ExamDetailService extends IService<ExamDetail> {
      * @return 班级名称组
      */
     String findClazzNamesByClazzIds(List<Long> clazzIdList, String separator);
+
+    /**
+     * 根据id下载examDetail
+     *
+     * @param ids
+     * @return
+     */
+    List<ExamDetailPdfDownloadDto> findPdfDownload(List<Long> ids);
 }

+ 25 - 10
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamDetailServiceImpl.java

@@ -21,7 +21,6 @@ import com.qmth.distributed.print.business.enums.PrintPlanStatusEnum;
 import com.qmth.distributed.print.business.enums.StudentClazzEnum;
 import com.qmth.distributed.print.business.mapper.ExamDetailMapper;
 import com.qmth.distributed.print.business.service.*;
-import com.qmth.distributed.print.business.templete.execute.AsyncCreatePdfTempleteService;
 import com.qmth.teachcloud.common.bean.dto.MqDto;
 import com.qmth.teachcloud.common.bean.params.BasicStudentExtrasParam;
 import com.qmth.teachcloud.common.contant.SystemConstant;
@@ -66,34 +65,41 @@ import java.util.stream.Stream;
  */
 @Service
 public class ExamDetailServiceImpl extends ServiceImpl<ExamDetailMapper, ExamDetail> implements ExamDetailService {
+    private final static Logger log = LoggerFactory.getLogger(ExamDetailServiceImpl.class);
+
     @Resource
     private ExamDetailCourseService examDetailCourseService;
+
     @Resource
     private BasicExamRuleService basicExamRuleService;
+
     @Resource
     private ExamDetailMapper examDetailMapper;
+
     @Resource
     private CommonCacheService commonCacheService;
+
     @Resource
     private ExamStudentService examStudentService;
+
     @Resource
     private ExamPrintPlanService examPrintPlanService;
+
     @Resource
     private BasicAttachmentService basicAttachmentService;
+
     @Resource
     private BasicStudentService basicStudentService;
 
     @Resource
     TBTaskService tbTaskService;
+
     @Resource
     ConvertUtil convertUtil;
 
     @Autowired
     private ClientPrintDataService clientPrintDataService;
 
-    @Resource
-    AsyncCreatePdfTempleteService asyncCreatePdfTempleteService;
-
     @Autowired
     ClientStatusService clientStatusService;
 
@@ -115,8 +121,6 @@ public class ExamDetailServiceImpl extends ServiceImpl<ExamDetailMapper, ExamDet
     @Resource
     TeachClazzService teachClazzService;
 
-    private final static Logger log = LoggerFactory.getLogger(ExamDetailServiceImpl.class);
-
     @Transactional(rollbackFor = Exception.class)
     @Override
     public double calculateTotalSubjects(Long printPlanId) {
@@ -159,25 +163,25 @@ public class ExamDetailServiceImpl extends ServiceImpl<ExamDetailMapper, ExamDet
         List<JSONObject> list = new ArrayList<>();
         if (examDetail.getAttachmentId() != null) {
             JSONObject jsonObject = new JSONObject();
-            jsonObject.put("type", PdfTypeEnum.PAPER);
+            jsonObject.put(SystemConstant.TYPE, PdfTypeEnum.PAPER);
             BasicAttachment attachment = basicAttachmentService.getById(examDetail.getAttachmentId());
             jsonObject.put("url", attachment == null ? null : teachcloudCommonService.filePreview(attachment.getPath()));
             list.add(jsonObject);
         }
         if (examDetail.getCardAttachmentId() != null) {
             JSONObject jsonObject = new JSONObject();
-            jsonObject.put("type", PdfTypeEnum.CARD_A3);
+            jsonObject.put(SystemConstant.TYPE, PdfTypeEnum.CARD_A3);
             BasicAttachment attachment = basicAttachmentService.getById(examDetail.getCardAttachmentId());
             jsonObject.put("url", attachment == null ? null : teachcloudCommonService.filePreview(attachment.getPath()));
             list.add(jsonObject);
         }
         if (Objects.nonNull(examDetail.getAttachmentPath())) {
             JSONObject js = JSONObject.parseObject(examDetail.getAttachmentPath());
-            JSONArray jsonArray = js.getJSONArray("path");
+            JSONArray jsonArray = js.getJSONArray(SystemConstant.PATH);
             for (int i = 0; i < jsonArray.size(); i++) {
                 JSONObject object = jsonArray.getJSONObject(i);
                 JSONObject jsonObject = new JSONObject();
-                jsonObject.put("type", Objects.nonNull(object.get("printType")) ? PdfTypeEnum.valueOf((String) object.get("printType")) : null);
+                jsonObject.put(SystemConstant.TYPE, Objects.nonNull(object.get("printType")) ? PdfTypeEnum.valueOf((String) object.get("printType")) : null);
                 jsonObject.put("url", Objects.nonNull(object.get(SystemConstant.PDF_PATH)) ? teachcloudCommonService.filePreviewByPathAndType((String) object.get(SystemConstant.PDF_PATH), (String) object.get("type"), false) : null);
                 list.add(jsonObject);
             }
@@ -879,6 +883,17 @@ public class ExamDetailServiceImpl extends ServiceImpl<ExamDetailMapper, ExamDet
         return String.join(separator, clazzNameList);
     }
 
+    /**
+     * 根据id下载examDetail
+     *
+     * @param ids
+     * @return
+     */
+    @Override
+    public List<ExamDetailPdfDownloadDto> findPdfDownload(List<Long> ids) {
+        return examDetailMapper.findPdfDownload(ids);
+    }
+
     @Transactional(rollbackFor = Exception.class)
     @Override
     public void deleteExaminationData(Long printPlanId, ExamDataSourceEnum source) {

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

@@ -133,5 +133,5 @@ public interface TaskLogicService {
      */
     Map<String, Object> executeDownloadScoreLogic(Map<String, Object> map) throws Exception;
 
-    Map<String,Object> executeDownloadPaperFileBatch(Map<String, Object> map) throws Exception;
+    Map<String, Object> executeDownloadPaperFileBatch(Map<String, Object> map) throws Exception;
 }

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

@@ -36,6 +36,7 @@ import com.qmth.teachcloud.common.service.*;
 import com.qmth.teachcloud.common.util.*;
 import com.qmth.teachcloud.common.util.excel.ExcelError;
 import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.usermodel.Cell;
@@ -909,6 +910,9 @@ public class TaskLogicServiceImpl implements TaskLogicService {
     @Override
     @Transactional
     public Map<String, Object> executeDownloadPdfLogic(Map<String, Object> map) throws Exception {
+        List<File> sourceFileList = null;
+        File zipFile = null;
+        String zipLocalRootPath = null;
         try {
             TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
             JSONArray jsonArray = JSONArray.parseArray(tbTask.getRemark());
@@ -918,59 +922,82 @@ public class TaskLogicServiceImpl implements TaskLogicService {
             }
 
             //查询examDetail
-            List<ExamDetail> examDetailList = examDetailService.listByIds(Arrays.asList(arraysParams.getIds()));
-            if (Objects.nonNull(examDetailList)) {
-                Set<Long> attachmentIds = new HashSet<>();
-                Set<Long> allAttachmentIds = examDetailList.stream().map(ExamDetail::getAttachmentId).collect(Collectors.toSet());
-                if (!CollectionUtils.isEmpty(allAttachmentIds)) {
-                    attachmentIds.addAll(allAttachmentIds);
-                }
-                Set<Long> cardAttachmentIds = examDetailList.stream().map(ExamDetail::getCardAttachmentId).collect(Collectors.toSet());
-                if (!CollectionUtils.isEmpty(cardAttachmentIds)) {
-                    attachmentIds.addAll(cardAttachmentIds);
+//            List<ExamDetail> examDetailList = examDetailService.listByIds(Arrays.asList(arraysParams.getIds()));
+            List<ExamDetailPdfDownloadDto> examDetailList = examDetailService.findPdfDownload(Arrays.asList(arraysParams.getIds()));
+            if (!CollectionUtils.isEmpty(examDetailList)) {
+                LocalDateTime nowTime = LocalDateTime.now();
+                StringJoiner stringJoiner = new StringJoiner("")
+                        .add(dictionaryConfig.fssLocalFileDomain().getConfig()).add(File.separator);
+                StringJoiner dirName = new StringJoiner("")
+                        .add(UploadFileEnum.FILE.getTitle()).add(File.separator)
+                        .add(String.valueOf(nowTime.getYear())).add(File.separator)
+                        .add(String.format("%02d", nowTime.getMonthValue())).add(File.separator)
+                        .add(String.format("%02d", nowTime.getDayOfMonth()))
+                        .add(File.separator).add(SystemConstant.getUuid()).add(SystemConstant.ZIP_PREFIX);
+                zipFile = new File(stringJoiner.toString() + dirName.toString());
+                if (!zipFile.getParentFile().exists()) {
+                    zipFile.getParentFile().mkdirs();
                 }
-                List<BasicAttachment> basicAttachmentList = basicAttachmentService.listByIds(attachmentIds);
-
-                if (Objects.nonNull(basicAttachmentList) && basicAttachmentList.size() > 0) {
-                    LocalDateTime nowTime = LocalDateTime.now();
-                    StringJoiner stringJoiner = new StringJoiner("")
-                            .add(dictionaryConfig.fssLocalFileDomain().getConfig()).add(File.separator);
-                    StringJoiner dirName = new StringJoiner("")
-                            .add(UploadFileEnum.FILE.getTitle()).add(File.separator)
-                            .add(String.valueOf(nowTime.getYear())).add(File.separator)
-                            .add(String.format("%02d", nowTime.getMonthValue())).add(File.separator)
-                            .add(String.format("%02d", nowTime.getDayOfMonth()))
-                            .add(File.separator).add(SystemConstant.getUuid()).add(SystemConstant.ZIP_PREFIX);
-
-                    File zipFile = new File(stringJoiner.toString() + dirName.toString());
-                    if (!zipFile.getParentFile().exists()) {
-                        zipFile.getParentFile().mkdirs();
-//                        zipFile.createNewFile();
-                    }
 
-                    boolean oss = dictionaryConfig.sysDomain().isOss();
+                Long time = System.currentTimeMillis();
+                zipLocalRootPath = dictionaryConfig.fssLocalFileDomain().getConfig() + File.separator + time;
+                sourceFileList = new ArrayList<>(examDetailList.size() * 5);
+                for (ExamDetailPdfDownloadDto e : examDetailList) {
+                    //试卷合并文件
+                    if (Objects.nonNull(e.getAttachmentId())) {
+                        BasicAttachment attachment = basicAttachmentService.getById(e.getAttachmentId());
+                        File paperFile = getAttachmentFile(attachment, time + File.separator + e.getSemesterName() + File.separator + e.getExamName() + File.separator + e.getCourseNameCode() + File.separator + e.getPackageCode() + File.separator + e.getCourseNameCode() + "-" + e.getPaperNumber() + "-" + PdfTypeEnum.PAPER.getTitle() + SystemConstant.PDF_PREFIX);
+                        if (Objects.nonNull(paperFile)) {
+                            e.setPaperFile(paperFile);
+                            sourceFileList.add(paperFile);
+                        }
+                    }
 
-                    List<File> sourceFiles = new ArrayList<>();
-                    for (BasicAttachment basicAttachment : basicAttachmentList) {
-                        JSONObject jsonObject = JSONObject.parseObject(basicAttachment.getPath());
-                        UploadFileEnum uploadFileEnum = UploadFileEnum.valueOf((String) jsonObject.get(SystemConstant.UPLOAD_TYPE));
-
-                        StringJoiner stringJoinerPdf = new StringJoiner("")
-                                .add(dictionaryConfig.fssLocalFileDomain().getConfig()).add(File.separator)
-                                .add((String) jsonObject.get(SystemConstant.PATH));
-                        File htmlFile = null;
-                        if (oss) {
-                            htmlFile = fileStoreUtil.ossDownload((String) jsonObject.get(SystemConstant.PATH), stringJoinerPdf.toString(), uploadFileEnum.getFssType());
-                        } else {
-                            htmlFile = new File((String) jsonObject.get(SystemConstant.PATH));
+                    //题卡合并文件
+                    if (Objects.nonNull(e.getCardAttachmentId())) {
+                        BasicAttachment cardAttachment = basicAttachmentService.getById(e.getCardAttachmentId());
+                        File cardFile = getAttachmentFile(cardAttachment, time + File.separator + e.getSemesterName() + File.separator + e.getExamName() + File.separator + e.getCourseNameCode() + File.separator + e.getPackageCode() + File.separator + e.getCourseNameCode() + "-" + e.getPaperNumber() + "-" + PdfTypeEnum.CARD_A3.getTitle() + SystemConstant.PDF_PREFIX);
+                        if (Objects.nonNull(cardFile)) {
+                            e.setCardFile(cardFile);
+                            sourceFileList.add(cardFile);
                         }
-                        sourceFiles.add(htmlFile);
                     }
-//                    FileUtil.doZip(zipFile, sourceFiles);
 
-                    Zip4jUtil.zipEncryptFile(zipFile.getPath(), sourceFiles, SystemConstant.ZIP_ENCRYPT_PWD);
+                    //卷袋贴/签到表/登记表文件
+                    if (Objects.nonNull(e.getCardAttachmentId())) {
+                        JSONObject js = JSONObject.parseObject(e.getAttachmentPath());
+                        JSONArray jsonArrayTemp = js.getJSONArray(SystemConstant.PATH);
+                        for (int i = 0; i < jsonArrayTemp.size(); i++) {
+                            JSONObject object = jsonArrayTemp.getJSONObject(i);
+                            PdfTypeEnum pdfTypeEnum = PdfTypeEnum.valueOf((String) object.get("printType"));
+                            File file = null;
+                            switch (pdfTypeEnum) {
+                                case PACKAGE:
+                                    file = getJsonFile(object, time + File.separator + e.getSemesterName() + File.separator + e.getExamName() + File.separator + e.getCourseNameCode() + File.separator + e.getPackageCode() + File.separator + e.getCourseNameCode() + "-" + e.getPaperNumber() + "-" + pdfTypeEnum.getTitle() + SystemConstant.PDF_PREFIX);
+                                    e.setPackageFile(file);
+                                    sourceFileList.add(file);
+                                    break;
+                                case SIGN:
+                                    file = getJsonFile(object, time + File.separator + e.getSemesterName() + File.separator + e.getExamName() + File.separator + e.getCourseNameCode() + File.separator + e.getPackageCode() + File.separator + e.getCourseNameCode() + "-" + e.getPaperNumber() + "-" + pdfTypeEnum.getTitle() + SystemConstant.PDF_PREFIX);
+                                    e.setSignFile(file);
+                                    sourceFileList.add(file);
+                                    break;
+                                case CHECK_IN:
+                                    file = getJsonFile(object, time + File.separator + e.getSemesterName() + File.separator + e.getExamName() + File.separator + e.getCourseNameCode() + File.separator + e.getPackageCode() + File.separator + e.getCourseNameCode() + "-" + e.getPaperNumber() + "-" + pdfTypeEnum.getTitle() + SystemConstant.PDF_PREFIX);
+                                    e.setCheckInFile(file);
+                                    sourceFileList.add(file);
+                                    break;
+                                default:
+                                    break;
+                            }
+                        }
+                    }
+                }
+                if (!CollectionUtils.isEmpty(sourceFileList)) {
+                    Zip4jUtil.zipEncryptFile(zipFile.getPath(), zipLocalRootPath, SystemConstant.ZIP_ENCRYPT_PWD);
                     String ossDirName = dirName.toString().replaceAll("\\\\", "/");
                     JSONObject jsonObject = new JSONObject();
+                    boolean oss = dictionaryConfig.sysDomain().isOss();
                     if (oss) {//上传至oss
                         fileStoreUtil.ossUpload(ossDirName, zipFile, BinaryUtil.toBase64String(HexUtils.decodeHex(DigestUtils.md5Hex(new FileInputStream(zipFile)))), fileStoreUtil.getUploadEnumByPath(ossDirName).getFssType());
                         jsonObject.put(SystemConstant.PATH, ossDirName);
@@ -981,15 +1008,9 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                     }
                     jsonObject.put(SystemConstant.UPLOAD_TYPE, UploadFileEnum.FILE);
                     tbTask.setResultFilePath(jsonObject.toJSONString());
-                    if (Objects.nonNull(dictionaryConfig.sysDomain()) && dictionaryConfig.sysDomain().isOss()) {
-                        for (File file : sourceFiles) {
-                            file.delete();
-                        }
-                        zipFile.delete();
-                    }
                 }
-                map.computeIfAbsent(SystemConstant.SIZE, v -> attachmentIds.size());
             }
+            map.put(SystemConstant.SIZE, Objects.nonNull(sourceFileList) ? sourceFileList.size() : 0);
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
             if (e instanceof ApiException) {
@@ -997,10 +1018,81 @@ public class TaskLogicServiceImpl implements TaskLogicService {
             } else {
                 ResultUtil.error(e.getMessage());
             }
+        } finally {
+            if (!CollectionUtils.isEmpty(sourceFileList) && Objects.nonNull(dictionaryConfig.sysDomain()) && dictionaryConfig.sysDomain().isOss()) {
+                for (File file : sourceFileList) {
+                    file.delete();
+                }
+                if (Objects.nonNull(zipFile)) {
+                    zipFile.delete();
+                }
+                if (Objects.nonNull(zipLocalRootPath)) {
+                    File file = new File(zipLocalRootPath);
+                    file.delete();
+                }
+            }
         }
         return map;
     }
 
+    /**
+     * 获取附件文件
+     *
+     * @param jsonObject
+     * @param pathName
+     * @return
+     * @throws Exception
+     */
+    private File getJsonFile(JSONObject jsonObject, String pathName) throws Exception {
+        File file = null;
+        String attachmentType = (String) jsonObject.get(SystemConstant.TYPE);
+        StringJoiner stringJoinerPdf = new StringJoiner("")
+                .add(dictionaryConfig.fssLocalFileDomain().getConfig()).add(File.separator)
+                .add(pathName);
+        if (Objects.nonNull(attachmentType) && !Objects.equals(attachmentType, SystemConstant.LOCAL)) {
+            file = fileStoreUtil.ossDownload((String) jsonObject.get(SystemConstant.PDF_PATH), stringJoinerPdf.toString(), UploadFileEnum.PDF.getFssType());
+        } else {
+            file = new File(stringJoinerPdf.toString());
+            if (!file.exists()) {
+                file.getParentFile().mkdirs(); //目标文件目录不存在的话需要创建目录
+                file.createNewFile();
+            }
+            IOUtils.copy(new FileInputStream((String) jsonObject.get(SystemConstant.PDF_PATH)), new FileOutputStream(file));
+        }
+        return file;
+    }
+
+    /**
+     * 获取附件文件
+     *
+     * @param pathName
+     * @param pathName
+     * @return
+     * @throws Exception
+     */
+    private File getAttachmentFile(BasicAttachment attachment, String pathName) throws Exception {
+        File file = null;
+        if (Objects.nonNull(attachment) && Objects.nonNull(attachment.getPath())) {
+            JSONObject jsonObject = JSONObject.parseObject(attachment.getPath());
+            String attachmentType = (String) jsonObject.get(SystemConstant.TYPE);
+            UploadFileEnum uploadFileEnum = UploadFileEnum.valueOf((String) jsonObject.get(SystemConstant.UPLOAD_TYPE));
+            StringJoiner stringJoinerPdf = new StringJoiner("")
+                    .add(dictionaryConfig.fssLocalFileDomain().getConfig()).add(File.separator)
+                    .add(pathName);
+            if (Objects.nonNull(attachmentType) && !Objects.equals(attachmentType, SystemConstant.LOCAL)) {
+                file = fileStoreUtil.ossDownload((String) jsonObject.get(SystemConstant.PATH), stringJoinerPdf.toString(), uploadFileEnum.getFssType());
+            } else {
+                file = new File(stringJoinerPdf.toString());
+                if (!file.exists()) {
+                    file.getParentFile().mkdirs(); //目标文件目录不存在的话需要创建目录
+                    file.createNewFile();
+                }
+                IOUtils.copy(new FileInputStream((String) jsonObject.get(SystemConstant.PATH)), new FileOutputStream(file));
+            }
+        }
+        return file;
+    }
+
     @Override
     @Transactional
     public Map<String, Object> executeExportSampleLogic(Map<String, Object> map) throws Exception {

+ 29 - 0
distributed-print-business/src/main/resources/mapper/ExamDetailMapper.xml

@@ -516,4 +516,33 @@
             a.print_plan_id = #{printPlanId}
     </select>
 
+    <select id="findPdfDownload" resultType="com.qmth.distributed.print.business.bean.dto.ExamDetailPdfDownloadDto">
+        select
+            ed.*,
+            bs.name as semesterName,
+            be.name as examName,
+            GROUP_CONCAT(CONCAT(edc.course_name, '(', edc.course_code, ')')) as courseNameCode,
+            GROUP_CONCAT(edc.paper_number) paperNumber
+        from
+            exam_detail ed
+                join exam_print_plan epp on
+                epp.id = ed.print_plan_id
+                join basic_exam be on
+                be.id = epp.exam_id
+                join basic_semester bs on
+                bs.id = be.semester_id
+                join exam_detail_course edc on
+                edc.exam_detail_id = ed.id
+        <where>
+            <if test="ids != null and ids != '' and ids.size > 0">
+                AND ed.id IN
+                <foreach collection="ids" item="id" index="index" open="(" separator="," close=")">
+                    #{id}
+                </foreach>
+            </if>
+        </where>
+        GROUP BY
+            edc.exam_detail_id
+        order by bs.name
+    </select>
 </mapper>

+ 14 - 6
teachcloud-common/src/main/java/com/qmth/teachcloud/common/enums/PdfTypeEnum.java

@@ -5,26 +5,34 @@ import java.util.List;
 
 /**
  * 角色类型
+ *
  * @Date: 2021/3/23.
  */
 public enum PdfTypeEnum {
 
-    PAPER("试卷合并文件"),
-    CARD_A3("题卡A3合并文件"),
-    PACKAGE("卷袋贴文件"),
-    SIGN("签到表文件"),
-    CHECK_IN("登记表文件");
+    PAPER("试卷合并文件", "试卷"),
+    CARD_A3("题卡A3合并文件", "题卡"),
+    PACKAGE("卷袋贴文件", "卷袋贴"),
+    SIGN("签到表文件", "签到表"),
+    CHECK_IN("登记表文件", "考试情况登记表");
 
-    PdfTypeEnum(String desc) {
+    PdfTypeEnum(String desc, String title) {
         this.desc = desc;
+        this.title = title;
     }
 
     private String desc;
 
+    private String title;
+
     public String getDesc() {
         return desc;
     }
 
+    public String getTitle() {
+        return title;
+    }
+
     /**
      * @param hasAdmin 是否需要管理员
      * @return