Browse Source

3.3.1 update

xiaofei 1 year ago
parent
commit
c838b7c43c

+ 47 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ExamTaskPaperExportDto.java

@@ -27,10 +27,18 @@ public class ExamTaskPaperExportDto implements Serializable {
     @ExcelProperty(name = "全部卷型", width = 30, index = 4)
     private String paperType;
 
+    @ApiModelProperty(value = "曝光卷型")
+    @ExcelProperty(name = "曝光卷型", width = 30, index = 5)
+    private String exposedPaperType;
+
     @ApiModelProperty(value = "未曝光卷型")
-    @ExcelProperty(name = "未曝光卷型", width = 30, index = 5)
+    @ExcelProperty(name = "未曝光卷型", width = 30, index = 6)
     private String unexposedPaperType;
 
+    @ApiModelProperty(value = "处理结果")
+    @ExcelProperty(name = "处理结果", width = 100, index = 7)
+    private String result;
+
     public String getCourseName() {
         return courseName;
     }
@@ -63,6 +71,36 @@ public class ExamTaskPaperExportDto implements Serializable {
         this.paperType = paperType;
     }
 
+    public ExamTaskPaperExportDto() {
+    }
+
+    public ExamTaskPaperExportDto(ExamTaskDetailDto examTaskDetailDto) {
+        this.courseName = examTaskDetailDto.getCourseName();
+        this.courseCode = examTaskDetailDto.getCourseCode();
+        this.paperNumber = examTaskDetailDto.getPaperNumber();
+        this.paperType = examTaskDetailDto.getPaperType();
+        this.exposedPaperType = examTaskDetailDto.getExposedPaperType();
+        this.unexposedPaperType = examTaskDetailDto.getUnexposedPaperType();
+    }
+
+    public ExamTaskPaperExportDto(String courseName, String courseCode, String paperNumber, String paperType, String exposedPaperType, String unexposedPaperType, String result) {
+        this.courseName = courseName;
+        this.courseCode = courseCode;
+        this.paperNumber = paperNumber;
+        this.paperType = paperType;
+        this.exposedPaperType = exposedPaperType;
+        this.unexposedPaperType = unexposedPaperType;
+        this.result = result;
+    }
+
+    public String getExposedPaperType() {
+        return exposedPaperType;
+    }
+
+    public void setExposedPaperType(String exposedPaperType) {
+        this.exposedPaperType = exposedPaperType;
+    }
+
     public String getUnexposedPaperType() {
         return unexposedPaperType;
     }
@@ -70,4 +108,12 @@ public class ExamTaskPaperExportDto implements Serializable {
     public void setUnexposedPaperType(String unexposedPaperType) {
         this.unexposedPaperType = unexposedPaperType;
     }
+
+    public String getResult() {
+        return result;
+    }
+
+    public void setResult(String result) {
+        this.result = result;
+    }
 }

+ 3 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/enums/PaperFileDownloadContentEnum.java

@@ -6,9 +6,9 @@ package com.qmth.distributed.print.business.enums;
  * @Date: 2022-04-08
  */
 public enum PaperFileDownloadContentEnum {
-    ONLY_PAPER("仅下载试卷"),
-    ONLY_CARD("仅下载题卡"),
-    PAPER_AND_CARD("下载试卷和题卡")
+    ONLY_PAPER("试卷"),
+    ONLY_CARD("题卡"),
+    PAPER_AND_CARD("试卷和题卡")
     ;
     private final String desc;
 

+ 2 - 11
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/DownloadService.java

@@ -5,6 +5,7 @@ import com.qmth.distributed.print.business.bean.dto.ExamTaskDetailDto;
 import com.qmth.distributed.print.business.bean.dto.ExamTaskPaperDto;
 
 import javax.servlet.http.HttpServletResponse;
+import java.util.List;
 import java.util.Set;
 
 /**
@@ -17,15 +18,5 @@ public interface DownloadService {
 
     void paperDownload(HttpServletResponse response, Long id) throws Exception;
 
-    /**
-     * 查找要下载的试卷文件内容
-     *
-     * @param semesterId 学期id
-     * @param examId     考试id
-     * @param orgId      机构id
-     * @param courseName 课程名称
-     * @param idSet      命题任务idSet
-     * @return 要下载的试卷文件内容集合
-     */
-    ExamTaskPaperDto findDownloadContent(Long schoolId, Long semesterId, Long examId, Long orgId, String courseName, Set<Long> idSet);
+    List<ExamTaskDetailDto> listExamQuery(Long semesterId, Long examId, Long orgId, String courseName, Set<Long> idSet);
 }

+ 3 - 110
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/DownloadServiceImpl.java

@@ -29,11 +29,11 @@ import com.qmth.teachcloud.common.service.*;
 import com.qmth.teachcloud.common.util.ConvertUtil;
 import com.qmth.teachcloud.common.util.ExamTaskUtil;
 import com.qmth.teachcloud.common.util.ServletUtil;
+import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
 import org.springframework.util.FileCopyUtils;
 
 import javax.annotation.Resource;
@@ -46,9 +46,6 @@ import java.util.*;
 public class DownloadServiceImpl implements DownloadService {
     private final static Logger log = LoggerFactory.getLogger(DownloadServiceImpl.class);
 
-    @Resource
-    TeachcloudCommonService teachcloudCommonService;
-
     @Resource
     ExamTaskMapper examTaskMapper;
 
@@ -198,112 +195,8 @@ public class DownloadServiceImpl implements DownloadService {
     }
 
     @Override
-    public ExamTaskPaperDto findDownloadContent(Long schoolId, Long semesterId, Long examId, Long orgId, String pCourseName, Set<Long> idSet) {
-        // 没有选择id集合才根据查询条件查询
-        List<ExamTaskDetailDto> examTaskDetailDtoList;
-        if (idSet != null && idSet.size() > 0) {
-            examTaskDetailDtoList = examTaskMapper.listExamTaskDetailDownloadByQuery(null, null, null, null, idSet);
-        } else {
-            Set<Long> orgIds = null;
-            if (orgId != null) {
-                List<Long> orgList = new ArrayList<>();
-                orgList.add(orgId);
-                orgIds = sysOrgService.findDeepOrgIdListByOrgIdList(orgList);
-            }
-            examTaskDetailDtoList = examTaskMapper.listExamTaskDetailDownloadByQuery(semesterId, examId, pCourseName, orgIds, null);
-        }
-
-        List<ExamTaskPaperFileDto> examTaskPaperFileDtoList = new ArrayList<>();
-        // 创建导出接收集合
-        List<ExamTaskPaperExportDto> examTaskPaperExportDtoList = new ArrayList<>();
-
-        if (examTaskDetailDtoList.size() > 0) {
-            for (ExamTaskDetailDto examTaskDetailDto : examTaskDetailDtoList) {
-                Long examTaskId = SystemConstant.convertIdToLong(examTaskDetailDto.getId());
-                String semesterName = examTaskDetailDto.getSemesterName();
-                String examName = examTaskDetailDto.getExamName();
-                String orgName = examTaskDetailDto.getOrgName();
-                String courseCode = examTaskDetailDto.getCourseCode();
-                String courseName = examTaskDetailDto.getCourseName();
-                String paperNumber = examTaskDetailDto.getPaperNumber();
-                Long cardRuleId = SystemConstant.convertIdToLong(examTaskDetailDto.getCardRuleId());
-
-                // 生成导出对象
-                ExamTaskPaperExportDto examTaskPaperExportDto = new ExamTaskPaperExportDto();
-                examTaskPaperExportDto.setCourseCode(courseCode);
-                examTaskPaperExportDto.setCourseName(courseName);
-                examTaskPaperExportDto.setPaperNumber(paperNumber);
-                examTaskPaperExportDto.setPaperType(examTaskDetailDto.getPaperType());
-                examTaskPaperExportDto.setUnexposedPaperType(examTaskDetailDto.getUnexposedPaperType());
-                examTaskPaperExportDtoList.add(examTaskPaperExportDto);
-
-
-                // 所属印刷计划信息
-                List<ExamPrintPlan> examPrintPlanList = examPrintPlanService.findByPaperNumber(schoolId, paperNumber);
-
-
-                // 处理试卷
-                List<String> exposedPaperTypeList = Arrays.asList(examTaskDetailDto.getExposedPaperType().split(","));
-                List<String> unexposedPaperTypeList = Arrays.asList(examTaskDetailDto.getUnexposedPaperType().split(","));
-
-                List<PaperInfoVo> paperInfoVos = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetailDto.getPaperAttachmentIds());
-                if (CollectionUtils.isEmpty(paperInfoVos)) {
-                    throw ExceptionResultEnum.ERROR.exception("试卷信息不存在");
-                }
-                // 试卷信息
-                for (PaperInfoVo paperInfoVo : paperInfoVos) {
-                    String cardId = paperInfoVo.getCardId();
-                    String attachmentId = paperInfoVo.getAttachmentId();
-                    BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
-                    String paperName = null;
-                    String paperSuffix = null;
-                    String paperPath = null;
-                    if (Objects.nonNull(basicAttachment)) {
-                        paperName = basicAttachment.getName();
-                        paperSuffix = basicAttachment.getType();
-                        JSONObject jsonObject = JSONObject.parseObject(basicAttachment.getPath());
-                        paperPath = (String) jsonObject.get(SystemConstant.PATH);
-                    }
-                    String paperType = paperInfoVo.getName();
-
-                    boolean exposureStatus;
-                    if (exposedPaperTypeList.contains(paperType)) {
-                        exposureStatus = true;
-                    } else if (unexposedPaperTypeList.contains(paperType)) {
-                        exposureStatus = false;
-                    } else {
-                        throw ExceptionResultEnum.ERROR.exception("命题任务曝光卷型异常[" + examTaskId + "(" + paperType + ")]");
-                    }
-
-
-                    ExamTaskPaperFileDto cell = new ExamTaskPaperFileDto();
-                    // 基本信息
-                    cell.setExamTaskId(examTaskId);
-                    cell.setSemesterName(semesterName);
-                    cell.setExamName(examName);
-                    cell.setOrgName(orgName);
-                    // 基础信息
-                    cell.setExamPrintPlanList(examPrintPlanList);
-                    cell.setCourseCode(courseCode);
-                    cell.setCourseName(courseName);
-                    cell.setPaperNumber(paperNumber);
-                    // 题卡
-                    cell.setExamCardId(Long.valueOf(cardId));
-                    cell.setCardRuleId(cardRuleId);
-                    // 试卷
-                    cell.setPaperType(paperType);
-                    cell.setExposureStatus(exposureStatus);
-                    cell.setPaperName(paperName);
-                    cell.setPaperSuffix(paperSuffix);
-                    cell.setPaperPath(paperPath);
-                    examTaskPaperFileDtoList.add(cell);
-                }
-            }
-        }
-        ExamTaskPaperDto result = new ExamTaskPaperDto();
-        result.setExamTaskPaperFileDtoList(examTaskPaperFileDtoList);
-        result.setExamTaskPaperExportDtoList(examTaskPaperExportDtoList);
-        return result;
+    public List<ExamTaskDetailDto> listExamQuery(Long semesterId, Long examId, Long orgId, String courseName, Set<Long> idSet) {
+        return examTaskMapper.listExamTaskDetailDownloadByQuery(semesterId, examId, courseName, null, idSet);
     }
 
 }

+ 2 - 8
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/AsyncDownloadPaperFileBatchService.java

@@ -46,15 +46,9 @@ public class AsyncDownloadPaperFileBatchService extends AsyncExportTaskTemplete
             Map<String, Object> result = taskLogicService.executeDownloadPaperFileBatch(map);
 
             // 特殊的成功信息
-            String specialSuccessMessage = String.valueOf(map.get("specialSuccessMessage"));
-            if (SystemConstant.strNotNull(specialSuccessMessage)){
-                stringJoinerSummary.add(MessageFormat.format("{0}{1}{2}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), "数据处理结束:", specialSuccessMessage));
-            }else {
-                stringJoinerSummary.add(MessageFormat.format("{0}{1}{2}{3}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), FINISH_TITLE, result.containsKey("count")? Long.valueOf(String.valueOf(result.get("count"))) : "", FINISH_SIZE));
-            }
-
+            stringJoinerSummary.add(MessageFormat.format("{0}{1}{2}{3}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), FINISH_TITLE, result.containsKey("count") ? Long.valueOf(String.valueOf(result.get("count"))) : "", FINISH_SIZE));
             tbTask.setResult(TaskResultEnum.SUCCESS);
-        }catch (Exception e){
+        } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
             stringJoinerSummary.add(MessageFormat.format("{0}{1}{2}{3}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), EXCEPTION_TITLE, EXCEPTION_DATA, e.getMessage()));
             tbTask.setResult(TaskResultEnum.ERROR);

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

@@ -53,6 +53,7 @@ import com.qmth.teachcloud.mark.service.MarkStudentService;
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.usermodel.Cell;
@@ -1798,41 +1799,30 @@ public class TaskLogicServiceImpl implements TaskLogicService {
 
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public Map<String, Object> executeDownloadPaperFileBatch(Map<String, Object> map) throws Exception {
+    public Map<String, Object> executeDownloadPaperFileBatch(Map<String, Object> map) {
         TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
         DownloadPaperFileParam downloadPaperFileParam = (DownloadPaperFileParam) map.get("downloadPaperFileParam");
-        Long schoolId = tbTask.getSchoolId();
         Long semesterId = downloadPaperFileParam.getSemesterId();
         Long examId = downloadPaperFileParam.getExamId();
         Long orgId = downloadPaperFileParam.getOrgId();
+        PaperFileDownloadContentEnum paperFileDownloadContent = downloadPaperFileParam.getPaperFileDownloadContentType();
+        if (paperFileDownloadContent == null) {
+            throw ExceptionResultEnum.ERROR.exception("请选择下载文件");
+        }
+        PaperFileDownloadExposureStatusEnum paperFileDownloadExposureStatus = downloadPaperFileParam.getPaperFileDownloadExposureStatus();
+        if (Objects.isNull(paperFileDownloadExposureStatus)) {
+            throw ExceptionResultEnum.ERROR.exception("请选择试卷状态");
+        }
         Boolean namedByCourseInfo = downloadPaperFileParam.getNamedByCourseInfo();
         Boolean namedByPaperNumber = downloadPaperFileParam.getNamedByPaperNumber();
         Boolean namedByOriginalFile = downloadPaperFileParam.getNamedByOriginalFile();
-        PaperFileDownloadContentEnum paperFileDownloadContent = downloadPaperFileParam.getPaperFileDownloadContentType();
-        PaperFileDownloadExposureStatusEnum paperFileDownloadExposureStatus = downloadPaperFileParam.getPaperFileDownloadExposureStatus();
-        String specialSuccessMessage = "";
-        if (Objects.nonNull(paperFileDownloadExposureStatus)) {
-            switch (paperFileDownloadExposureStatus) {
-                case EXPOSED_PAPER: // 曝光的
-                    specialSuccessMessage = "所选择的命题任务中没有已曝光的试卷";
-                    break;
-                case UNEXPOSED_PAPER: // 未曝光的
-                    specialSuccessMessage = "所选择的命题任务中没有未曝光的试卷";
-                    break;
-                default:
-                    break;
-            }
+        if (!namedByCourseInfo && !namedByPaperNumber && !namedByOriginalFile) {
+            throw ExceptionResultEnum.ERROR.exception("请选择至少一种命名规则");
         }
 
         String courseName = downloadPaperFileParam.getCourseName();
         Set<Long> idSet = downloadPaperFileParam.getIdSet();
 
-        // 如果idSet集合为空且查询条件的机构id也为空,则请求用户的机构id作为机构数据权限带入查询
-        SysUser requestUser = (SysUser) map.get(SystemConstant.USER);
-        if ((idSet == null || idSet.size() == 0) && !SystemConstant.longNotNull(orgId)) {
-            orgId = requestUser.getOrgId();
-        }
-
         File zipFile = null;
         String zipLocalRootPath = null;
         try {
@@ -1848,219 +1838,125 @@ public class TaskLogicServiceImpl implements TaskLogicService {
             zipFile = SystemConstant.getFileTempDirVarForZip(SystemConstant.getNanoId(), SystemConstant.ZIP_PREFIX);
             zipLocalRootPath = zipFile.getParent() + File.separator + System.currentTimeMillis();
 
-            ExamTaskPaperDto examTaskPaperDto = downloadService.findDownloadContent(schoolId, semesterId, examId, orgId, courseName, idSet);
-            // 导出文件excel
-            List<ExamTaskPaperExportDto> examTaskPaperExportDtoList = examTaskPaperDto.getExamTaskPaperExportDtoList();
-
-            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
-            ExcelUtil.excelMake(ExamTaskPaperExportDto.class, examTaskPaperExportDtoList, outputStream);
-            InputStream in = new ByteArrayInputStream(outputStream.toByteArray());
-
-            String excelName = "试卷使用清单";
-            if (Objects.nonNull(paperFileDownloadExposureStatus)) {
-                excelName = excelName + paperFileDownloadExposureStatus.getDesc();
-            }
-            String excelLocalPath = zipLocalRootPath + File.separator + excelName + "." + SystemConstant.XLSX;
-            FileUtils.copyInputStreamToFile(in, new File(excelLocalPath));
-
-            // 所有试卷信息
-            List<ExamTaskPaperFileDto> examTaskPaperFileDtoList = examTaskPaperDto.getExamTaskPaperFileDtoList();
-            if (examTaskPaperFileDtoList.size() == 0) {
-                throw ExceptionResultEnum.ERROR.exception("没有找到任何试卷信息");
-            }
-            // 二级路径 课程
-            Set<String> courseSet = examTaskPaperFileDtoList.stream().map(e -> e.getCourseName().replaceAll(" ", "") + SystemConstant.HYPHEN + e.getCourseCode()).collect(Collectors.toSet());
-            // 文件数以一级目录文件为准(初始1是excel)
-            int count = 1;
-            for (String course : courseSet) {
-                // 三级路径 课程代码-课程名称/试卷编号
-                int courseCount = 0;
-                Set<String> paperNumberSet = examTaskPaperFileDtoList
-                        .stream()
-                        .filter(e -> course.equals(e.getCourseName().replaceAll(" ", "") + SystemConstant.HYPHEN + e.getCourseCode()))
-                        .map(ExamTaskPaperFileDto::getPaperNumber)
-                        .collect(Collectors.toSet());
-                for (String paperNumber : paperNumberSet) {
-                    // 试卷下文件集
-                    List<ExamTaskPaperFileDto> paperCellList = examTaskPaperFileDtoList
-                            .stream()
-                            .filter(e -> paperNumber.equals(e.getPaperNumber()))
-                            .collect(Collectors.toList());
-
-                    // 文件路径
-                    String filePath = zipLocalRootPath + File.separator + course + File.separator + paperNumber + File.separator;
-
-                    // 试卷文件曝光度筛选
-                    if (Objects.nonNull(paperFileDownloadExposureStatus)) {
-                        switch (paperFileDownloadExposureStatus) {
-                            case EXPOSED_PAPER: // 曝光的
-                                paperCellList = paperCellList.stream().filter(ExamTaskPaperFileDto::getExposureStatus).collect(Collectors.toList());
-                                if (paperCellList.size() > 0) {
-                                    specialSuccessMessage = "";
-                                }
-                                break;
-                            case UNEXPOSED_PAPER: // 未曝光的
-                                paperCellList = paperCellList.stream().filter(e -> !e.getExposureStatus()).collect(Collectors.toList());
-                                if (paperCellList.size() > 0) {
-                                    specialSuccessMessage = "";
-                                }
-                                break;
-                            case ALL_PAPER: // 全部试卷
-                                break;
-                            default:
-                                break;
-                        }
+            boolean downloadPaper = paperFileDownloadContent != null && (PaperFileDownloadContentEnum.ONLY_PAPER.equals(paperFileDownloadContent) || PaperFileDownloadContentEnum.PAPER_AND_CARD.equals(paperFileDownloadContent));
+            boolean downloadCard = paperFileDownloadContent != null && (PaperFileDownloadContentEnum.ONLY_CARD.equals(paperFileDownloadContent) || PaperFileDownloadContentEnum.PAPER_AND_CARD.equals(paperFileDownloadContent));
+
+            // 查询待下载数据
+            List<ExamTaskDetailDto> examTaskDetailDtoList = downloadService.listExamQuery(semesterId, examId, orgId, courseName, idSet);
+            List<ExamTaskPaperExportDto> examTaskPaperExportDtoList = new ArrayList<>();
+            for (ExamTaskDetailDto examTaskDetailDto : examTaskDetailDtoList) {
+                ExamTaskPaperExportDto examTaskPaperExportDto = new ExamTaskPaperExportDto(examTaskDetailDto);
+                examTaskPaperExportDtoList.add(examTaskPaperExportDto);
+                List<PaperInfoVo> paperInfoVoList = new ArrayList<>();
+                // 选择曝光卷型
+                if (PaperFileDownloadExposureStatusEnum.EXPOSED_PAPER.equals(paperFileDownloadExposureStatus)) {
+                    if (StringUtils.isBlank(examTaskDetailDto.getExposedPaperType())) {
+                        examTaskPaperExportDto.setResult("没有曝光卷型,下载失败");
+                        continue;
+                    } else {
+                        paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetailDto.getPaperAttachmentIds(), examTaskDetailDto.getExposedPaperType());
                     }
-
-                    if (Objects.isNull(paperFileDownloadContent)) {
+                }
+                // 选择未曝光卷型
+                if (PaperFileDownloadExposureStatusEnum.UNEXPOSED_PAPER.equals(paperFileDownloadExposureStatus)) {
+                    if (StringUtils.isBlank(examTaskDetailDto.getUnexposedPaperType())) {
+                        examTaskPaperExportDto.setResult("没有未曝光卷型,下载失败");
                         continue;
+                    } else {
+                        paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetailDto.getPaperAttachmentIds(), examTaskDetailDto.getUnexposedPaperType());
                     }
-                    switch (paperFileDownloadContent) {
-                        case ONLY_CARD: // 只下载题卡
-                            for (ExamTaskPaperFileDto examTaskPaperFileDto : paperCellList) {
-                                Long examCardId = examTaskPaperFileDto.getExamCardId();
-                                Long cardRuleId = examTaskPaperFileDto.getCardRuleId();
-                                ExamCard examCard = examCardService.getById(examCardId);
-                                if (examCard != null) {
-                                    String htmlContent;
-                                    if (MakeMethodEnum.SELECT.equals(examCard.getMakeMethod()) && CardCreateMethodEnum.UPLOAD.equals(examCard.getCreateMethod())) {
-                                        htmlContent = createPdfUtil.resetHtmlTemplateBar(examCard.getHtmlContent());
-                                    } else {
-                                        BasicCardRule basicCardRule = basicCardRuleService.getById(cardRuleId);
-                                        htmlContent = createPdfUtil.replaceHtmlCardAllParams(examCard, basicCardRule);
-                                    }
+                }
+                // 选择全部卷型
+                if (PaperFileDownloadExposureStatusEnum.ALL_PAPER.equals(paperFileDownloadExposureStatus)) {
+                    paperInfoVoList = ExamTaskUtil.parsePaperAttachmentPath(examTaskDetailDto.getPaperAttachmentIds());
+                }
 
-                                    byte[] bytes = htmlContent.getBytes(StandardCharsets.UTF_8);
-                                    String cardName = "题卡-";
-                                    if (namedByCourseInfo) {
-                                        cardName = cardName + course;
-                                    }
-                                    if (namedByPaperNumber) {
-                                        cardName = cardName + paperNumber;
-                                    }
-                                    if (namedByOriginalFile) {
-                                        cardName = cardName + examCardService.getById(examCardId).getTitle();
-                                    }
-                                    cardName = cardName + SystemConstant.HYPHEN + examTaskPaperFileDto.getPaperType();
-                                    String cardLocalHtmlPath = filePath + cardName + SystemConstant.HTML_PREFIX;
-                                    String cardLocalPdfPath = filePath + cardName + SystemConstant.PDF_PREFIX;
+                if (CollectionUtils.isEmpty(paperInfoVoList)) {
+                    examTaskPaperExportDto.setResult("所选试卷状态未查询到上传的试卷信息,下载失败");
+                    continue;
+                }
 
-                                    File localFile = new File(cardLocalHtmlPath);
-                                    if (!localFile.getParentFile().exists()) {
-                                        boolean mkr = localFile.getParentFile().mkdirs();
-                                    }
-                                    FileCopyUtils.copy(bytes, localFile);
+                // 命题规则
+                StringJoiner sj = new StringJoiner(SystemConstant.HYPHEN);
+                if (namedByCourseInfo) {
+                    sj.add(examTaskDetailDto.getCourseName()).add(examTaskDetailDto.getCourseCode());
+                }
+                if (namedByPaperNumber) {
+                    sj.add(examTaskDetailDto.getPaperNumber());
+                }
+                String fileNamePath = sj.toString();
 
-                                    File pdfFile = new File(cardLocalPdfPath);
-                                    if (!pdfFile.exists()) {
-                                        boolean cf = pdfFile.createNewFile();
-                                    }
-                                    HtmlToPdfUtil.convert(cardLocalHtmlPath, cardLocalPdfPath, PageSizeEnum.A3);
-                                }
-                                specialSuccessMessage = "";
-                                courseCount = 1;
-                            }
-                            break;
-                        case ONLY_PAPER: // 只下载试卷
-                            for (ExamTaskPaperFileDto examTaskPaperFileDto : paperCellList) {
-                                String paperName = "试卷-";
-                                if (namedByCourseInfo) {
-                                    paperName = paperName + course;
-                                }
-                                if (namedByPaperNumber) {
-                                    paperName = paperName + paperNumber;
-                                }
-                                if (namedByOriginalFile) {
-                                    paperName = paperName + examTaskPaperFileDto.getPaperName();
-                                }
-                                paperName = paperName + SystemConstant.HYPHEN + examTaskPaperFileDto.getPaperType();
-                                String paperLocalPath = filePath + paperName + examTaskPaperFileDto.getPaperSuffix();
-                                String paperPath = examTaskPaperFileDto.getPaperPath();
-                                if (StringUtils.isNotBlank(paperPath)) {
-                                    if (oss || (!oss && dictionaryConfig.fssPrivateDomain().getConfig().startsWith(SystemConstant.START_PARENT))) {
-                                        fileStoreUtil.ossDownload(paperPath, paperLocalPath, fileStoreUtil.getUploadEnumByPath(paperPath).getFssType());
-                                    } else {
-                                        FileUtil.copyFile(paperPath, paperLocalPath);
-                                    }
-                                }
-                                courseCount = 1;
+                // 目录规则(课程名称(课程代码)/试卷编号)
+                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) {
+                        // 原文件名
+                        if (namedByOriginalFile) {
+                            fileNamePath = fileNamePath + File.separator + paperInfoVo.getFilename();
+                        } else {
+                            fileNamePath = fileNamePath + "." + FilenameUtils.getExtension(paperInfoVo.getFilename());
+                        }
+                        Long attachmentId = Long.valueOf(paperInfoVo.getAttachmentId());
+                        if (Objects.nonNull(attachmentId)) {
+                            BasicAttachment attachment = basicAttachmentService.getById(attachmentId);
+                            if (Objects.nonNull(attachment)) {
+                                String fileName = StringUtils.deleteWhitespace(zipLocalRootPath + File.separator + secondPath + File.separator + fileNamePath);
+                                fileUploadService.downloadFile(attachment, fileName);
                             }
-                            break;
-                        case PAPER_AND_CARD: // 全部下载
-                            for (ExamTaskPaperFileDto examTaskPaperFileDto : paperCellList) {
-                                // 题卡
-                                Long examCardId = examTaskPaperFileDto.getExamCardId();
-                                Long cardRuleId = examTaskPaperFileDto.getCardRuleId();
-                                ExamCard examCard = examCardService.getById(examCardId);
-                                if (examCard != null) {
-                                    String htmlContent;
-                                    if (MakeMethodEnum.SELECT.equals(examCard.getMakeMethod()) && CardCreateMethodEnum.UPLOAD.equals(examCard.getCreateMethod())) {
-                                        htmlContent = createPdfUtil.resetHtmlTemplateBar(examCard.getHtmlContent());
-                                    } else {
-                                        BasicCardRule basicCardRule = basicCardRuleService.getById(cardRuleId);
-                                        htmlContent = createPdfUtil.replaceHtmlCardAllParams(examCard, basicCardRule);
-                                    }
+                        }
+                    }
+                    // 下载题卡
+                    if (downloadCard) {
+                        Long cardId = Long.valueOf(paperInfoVo.getCardId());
+                        ExamCard examCard = examCardService.getById(cardId);
+                        Optional.ofNullable(examCard).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("找不到答题卡"));
 
-                                    byte[] bytes = htmlContent.getBytes(StandardCharsets.UTF_8);
-                                    String cardName = "题卡-";
-                                    if (namedByCourseInfo) {
-                                        cardName = cardName + course;
-                                    }
-                                    if (namedByPaperNumber) {
-                                        cardName = cardName + paperNumber;
-                                    }
-                                    if (namedByOriginalFile) {
-                                        cardName = cardName + examCardService.getById(examCardId).getTitle();
-                                    }
-                                    cardName = cardName + SystemConstant.HYPHEN + examTaskPaperFileDto.getPaperType();
-                                    String cardLocalHtmlPath = filePath + cardName + SystemConstant.HTML_PREFIX;
-                                    String cardLocalPdfPath = filePath + cardName + SystemConstant.PDF_PREFIX;
-                                    File localCardFile = new File(cardLocalHtmlPath);
-                                    if (!localCardFile.getParentFile().exists()) {
-                                        boolean mkr = localCardFile.getParentFile().mkdirs();
-                                    }
-                                    FileCopyUtils.copy(bytes, localCardFile);
+                        MakeMethodEnum makeMethodEnum = examCard.getMakeMethod();
 
-                                    File cardPdfFile = new File(cardLocalPdfPath);
-                                    if (!cardPdfFile.exists()) {
-                                        boolean cf = cardPdfFile.createNewFile();
-                                    }
-                                    HtmlToPdfUtil.convert(cardLocalHtmlPath, cardLocalPdfPath, PageSizeEnum.A3);
-                                }
-                                // 试卷
-                                String paperName = "试卷-";
-                                if (namedByCourseInfo) {
-                                    paperName = paperName + course;
-                                }
-                                if (namedByPaperNumber) {
-                                    paperName = paperName + paperNumber;
-                                }
-                                if (namedByOriginalFile) {
-                                    paperName = paperName + examTaskPaperFileDto.getPaperName();
-                                }
-                                paperName = paperName + SystemConstant.HYPHEN + examTaskPaperFileDto.getPaperType();
-                                String paperLocalPath = filePath + paperName + examTaskPaperFileDto.getPaperSuffix();
-                                String paperPath = examTaskPaperFileDto.getPaperPath();
-                                if (StringUtils.isNotBlank(paperPath)) {
-                                    if (oss || (!oss && dictionaryConfig.fssPrivateDomain().getConfig().startsWith(SystemConstant.START_PARENT))) {
-                                        fileStoreUtil.ossDownload(paperPath, paperLocalPath, fileStoreUtil.getUploadEnumByPath(paperPath).getFssType());
-                                    } else {
-                                        FileUtil.copyFile(paperPath, paperLocalPath);
-                                    }
-                                }
-                                courseCount = 1;
-                            }
-                            break;
-                        default:
-                            break;
+                        String cardHtmlPath = StringUtils.deleteWhitespace(zipLocalRootPath + File.separator + secondPath + File.separator + "题卡" + SystemConstant.HYPHEN + paperInfoVo.getName() + SystemConstant.HYPHEN + examCard.getTitle() + SystemConstant.HTML_PREFIX);
+                        String cardPdfPath = StringUtils.deleteWhitespace(zipLocalRootPath + File.separator + secondPath + File.separator + "题卡" + SystemConstant.HYPHEN + paperInfoVo.getName() + SystemConstant.HYPHEN + examCard.getTitle() +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();
+                        }
+                        // 生成html文件
+                        FileCopyUtils.copy(htmlContent.getBytes(StandardCharsets.UTF_8), localFile);
+                        // 转pdf文件
+                        File file = new File(cardPdfPath);
+                        if (!file.exists()) {
+                            file.getParentFile().mkdirs();
+                            file.createNewFile();
+                        }
+                        HtmlToPdfUtil.convert(cardHtmlPath, cardPdfPath, PageSizeEnum.A3);
                     }
+                    examTaskPaperExportDto.setResult("下载成功");
                 }
-                count = count + courseCount;
             }
+
+            // 导出文件excel
+            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+            ExcelUtil.excelMake(ExamTaskPaperExportDto.class, examTaskPaperExportDtoList, outputStream);
+            InputStream in = new ByteArrayInputStream(outputStream.toByteArray());
+
+            String excelLocalPath = zipLocalRootPath + File.separator + "下载清单" + "." + SystemConstant.XLSX;
+            FileUtils.copyInputStreamToFile(in, new File(excelLocalPath));
+            // 所有试卷
             JSONObject jsonObject = SystemConstant.createZip(zipFile, zipLocalRootPath, zipDirName);
             tbTask.setResultFilePath(jsonObject.toJSONString());
-            map.put("count", count);
-            map.put("specialSuccessMessage", specialSuccessMessage);
+            map.put("count", examTaskDetailDtoList.size());
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
         } finally {
@@ -2392,7 +2288,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
 
             // 1.题号重复校验
             if (SystemConstant.strNotNull(paperNumber) && mainNumber != null && subNumber != null) {
-                logicErrorCommonNotice = String.format("课程代码为[%s],试卷编号为[%s],大题号为[%s],小题号为[%s]的数据异常 : ",courseCode, paperNumber, mainNumber,
+                logicErrorCommonNotice = String.format("课程代码为[%s],试卷编号为[%s],大题号为[%s],小题号为[%s]的数据异常 : ", courseCode, paperNumber, mainNumber,
                         subNumber);
                 String questionNumberKey = courseCode + SystemConstant.HYPHEN + paperNumber + SystemConstant.HYPHEN + mainNumber + SystemConstant.HYPHEN + subNumber;
                 if (questionNumberCheckSet.contains(questionNumberKey)) {
@@ -2458,20 +2354,20 @@ public class TaskLogicServiceImpl implements TaskLogicService {
             // 4.判断答案是否符合题型
             if (questionType != null && SystemConstant.strNotNull(answer)) {
                 switch (questionType) {
-                case 1:
-                    if (answer.length() > 1) {
-                        logicErrorList.add("单选题答案只能有一个");
-                    }
-                    break;
-                case 2:
-                    break;
-                case 3:
-                    if (optionCount != 2) {
-                        logicErrorList.add("判断题[选项个数]只能为2");
-                    }
-                    break;
-                default:
-                    logicErrorList.add("[题型(1-单选,2-多选,3-判断)]必须从1、2、3中填写");
+                    case 1:
+                        if (answer.length() > 1) {
+                            logicErrorList.add("单选题答案只能有一个");
+                        }
+                        break;
+                    case 2:
+                        break;
+                    case 3:
+                        if (optionCount != 2) {
+                            logicErrorList.add("判断题[选项个数]只能为2");
+                        }
+                        break;
+                    default:
+                        logicErrorList.add("[题型(1-单选,2-多选,3-判断)]必须从1、2、3中填写");
                 }
             }
 
@@ -2574,7 +2470,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
 
             // 1.题号重复校验
             if (SystemConstant.strNotNull(paperNumber) && mainNumber != null && subNumber != null) {
-                excelErrorCommonNotice = String.format("课程代码为[%s],试卷编号为[%s],大题号为[%s],小题号为[%s]的数据异常 : ",courseCode, paperNumber, mainNumber,
+                excelErrorCommonNotice = String.format("课程代码为[%s],试卷编号为[%s],大题号为[%s],小题号为[%s]的数据异常 : ", courseCode, paperNumber, mainNumber,
                         subNumber);
                 String questionNumberKey = courseCode + SystemConstant.HYPHEN + paperNumber + SystemConstant.HYPHEN + mainNumber + SystemConstant.HYPHEN + subNumber;
                 if (questionNumberCheckSet.contains(questionNumberKey)) {
@@ -2733,7 +2629,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                                     userSaveParams.setPassword(SystemConstant.DEFAULT_PASSWORD);
                                     userSaveParams.setOrgId(orgId);
                                     userSaveParams.setEnable(true);
-                                    userSaveParams.setRoleIds(new Long[] { markerRole.getId() });
+                                    userSaveParams.setRoleIds(new Long[]{markerRole.getId()});
                                     try {
                                         markUser.setUserId(sysUserService.saveUser(userSaveParams));
                                         markUser.setName(markerCode);