浏览代码

add:试卷文件批量下载

caozixuan 3 年之前
父节点
当前提交
ea267b32ce
共有 20 个文件被更改,包括 1016 次插入37 次删除
  1. 32 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ExamTaskDetailDto.java
  2. 34 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ExamTaskPaperDto.java
  3. 73 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ExamTaskPaperExportDto.java
  4. 178 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ExamTaskPaperFileDto.java
  5. 133 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/params/DownloadPaperFileParam.java
  6. 22 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/enums/PaperFileDownloadContentEnum.java
  7. 22 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/enums/PaperFileDownloadExposureStatusEnum.java
  8. 13 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamTaskMapper.java
  9. 14 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/DownloadService.java
  10. 8 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamPrintPlanService.java
  11. 119 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/DownloadServiceImpl.java
  12. 29 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamPrintPlanServiceImpl.java
  13. 66 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/AsyncDownloadPaperFileBatchService.java
  14. 2 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/TaskLogicService.java
  15. 162 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/TaskLogicServiceImpl.java
  16. 61 1
      distributed-print-business/src/main/resources/mapper/ExamTaskMapper.xml
  17. 36 25
      distributed-print/src/main/java/com/qmth/distributed/print/api/DownloadController.java
  18. 4 4
      distributed-print/src/main/java/com/qmth/distributed/print/interceptor/AuthInterceptor.java
  19. 3 1
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/enums/TaskTypeEnum.java
  20. 5 3
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/TeachcloudCommonServiceImpl.java

+ 32 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ExamTaskDetailDto.java

@@ -40,6 +40,14 @@ public class ExamTaskDetailDto {
     private MakeMethodEnum makeMethod;
 
     private Integer setup;
+    @ApiModelProperty(value = "机构id")
+    private String orgName;
+
+    @ApiModelProperty(value = "题卡id")
+    private Long examCardId;
+
+    @ApiModelProperty(value = "命题任务试卷附件")
+    private String paperAttachmentIds;
 
     public String getId() {
         return id;
@@ -248,4 +256,28 @@ public class ExamTaskDetailDto {
     public void setSemesterName(String semesterName) {
         this.semesterName = semesterName;
     }
+
+    public String getOrgName() {
+        return orgName;
+    }
+
+    public void setOrgName(String orgName) {
+        this.orgName = orgName;
+    }
+
+    public Long getExamCardId() {
+        return examCardId;
+    }
+
+    public void setExamCardId(Long examCardId) {
+        this.examCardId = examCardId;
+    }
+
+    public String getPaperAttachmentIds() {
+        return paperAttachmentIds;
+    }
+
+    public void setPaperAttachmentIds(String paperAttachmentIds) {
+        this.paperAttachmentIds = paperAttachmentIds;
+    }
 }

+ 34 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ExamTaskPaperDto.java

@@ -0,0 +1,34 @@
+package com.qmth.distributed.print.business.bean.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.List;
+
+/**
+ * @Description: 命题任务试卷文件
+ * @Author: CaoZixuan
+ * @Date: 2022-04-11
+ */
+public class ExamTaskPaperDto {
+    @ApiModelProperty(value = "命题任务试卷文件Dto")
+    private List<ExamTaskPaperFileDto> examTaskPaperFileDtoList;
+
+    @ApiModelProperty(value = "试卷批量下载导出excelDto")
+    private List<ExamTaskPaperExportDto> examTaskPaperExportDtoList;
+
+    public List<ExamTaskPaperFileDto> getExamTaskPaperFileDtoList() {
+        return examTaskPaperFileDtoList;
+    }
+
+    public void setExamTaskPaperFileDtoList(List<ExamTaskPaperFileDto> examTaskPaperFileDtoList) {
+        this.examTaskPaperFileDtoList = examTaskPaperFileDtoList;
+    }
+
+    public List<ExamTaskPaperExportDto> getExamTaskPaperExportDtoList() {
+        return examTaskPaperExportDtoList;
+    }
+
+    public void setExamTaskPaperExportDtoList(List<ExamTaskPaperExportDto> examTaskPaperExportDtoList) {
+        this.examTaskPaperExportDtoList = examTaskPaperExportDtoList;
+    }
+}

+ 73 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ExamTaskPaperExportDto.java

@@ -0,0 +1,73 @@
+package com.qmth.distributed.print.business.bean.dto;
+
+import com.qmth.teachcloud.common.annotation.ExcelProperty;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+/**
+ * @Description: 试卷批量下载导出excelDto
+ * @Author: CaoZixuan
+ * @Date: 2022-04-11
+ */
+public class ExamTaskPaperExportDto implements Serializable {
+    @ApiModelProperty(value = "课程名称")
+    @ExcelProperty(name = "课程名称", width = 30, index = 1)
+    private String courseName;
+
+    @ApiModelProperty(value = "课程代码")
+    @ExcelProperty(name = "课程代码", width = 30, index = 2)
+    private String courseCode;
+
+    @ApiModelProperty(value = "试卷编号")
+    @ExcelProperty(name = "试卷编号", width = 30, index = 3)
+    private String paperNumber;
+
+    @ApiModelProperty(value = "全部卷型")
+    @ExcelProperty(name = "全部卷型", width = 30, index = 4)
+    private String paperType;
+
+    @ApiModelProperty(value = "未曝光卷型")
+    @ExcelProperty(name = "未曝光卷型", width = 30, index = 5)
+    private String unexposedPaperType;
+
+    public String getCourseName() {
+        return courseName;
+    }
+
+    public void setCourseName(String courseName) {
+        this.courseName = courseName;
+    }
+
+    public String getCourseCode() {
+        return courseCode;
+    }
+
+    public void setCourseCode(String courseCode) {
+        this.courseCode = courseCode;
+    }
+
+    public String getPaperNumber() {
+        return paperNumber;
+    }
+
+    public void setPaperNumber(String paperNumber) {
+        this.paperNumber = paperNumber;
+    }
+
+    public String getPaperType() {
+        return paperType;
+    }
+
+    public void setPaperType(String paperType) {
+        this.paperType = paperType;
+    }
+
+    public String getUnexposedPaperType() {
+        return unexposedPaperType;
+    }
+
+    public void setUnexposedPaperType(String unexposedPaperType) {
+        this.unexposedPaperType = unexposedPaperType;
+    }
+}

+ 178 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ExamTaskPaperFileDto.java

@@ -0,0 +1,178 @@
+package com.qmth.distributed.print.business.bean.dto;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.distributed.print.business.entity.ExamPrintPlan;
+import com.qmth.teachcloud.common.annotation.ExcelProperty;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.List;
+
+/**
+ * @Description: 命题任务试卷文件Dto
+ * @Author: CaoZixuan
+ * @Date: 2022-04-07
+ */
+public class ExamTaskPaperFileDto {
+    // 命题任务基本信息
+    @ApiModelProperty(value = "命题任务id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long examTaskId;
+
+    @ApiModelProperty(value = "学期名称")
+    private String semesterName;
+
+    @ApiModelProperty(value = "考试名称")
+    private String examName;
+
+    @ApiModelProperty(value = "机构名称")
+    private String orgName;
+
+    // 命题任务基础信息
+    @ApiModelProperty(value = "印刷计划集合")
+    private List<ExamPrintPlan> examPrintPlanList;
+
+    @ApiModelProperty(value = "课程名称")
+    @ExcelProperty(name = "课程名称", width = 30, index = 1)
+    private String courseName;
+
+    @ApiModelProperty(value = "课程代码")
+    @ExcelProperty(name = "课程代码", width = 30, index = 2)
+    private String courseCode;
+
+    @ApiModelProperty(value = "试卷编号")
+    @ExcelProperty(name = "试卷编号", width = 30, index = 3)
+    private String paperNumber;
+
+    // 试卷信息
+    @ApiModelProperty(value = "试卷类型")
+    private String paperType;
+
+    @ApiModelProperty(value = "曝光状态 true-已曝光、false-未曝光")
+    private Boolean exposureStatus;
+
+    @ApiModelProperty(value = "试卷文件名称")
+    private String paperName;
+
+    @ApiModelProperty(value = "试卷文件后缀")
+    private String paperSuffix;
+
+    @ApiModelProperty(value = "试卷文件路径")
+    private String paperPath;
+
+    // 题卡信息
+    @ApiModelProperty(value = "该命题任务id")
+    private Long examCardId;
+
+    public Long getExamTaskId() {
+        return examTaskId;
+    }
+
+    public void setExamTaskId(Long examTaskId) {
+        this.examTaskId = examTaskId;
+    }
+
+    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 getOrgName() {
+        return orgName;
+    }
+
+    public void setOrgName(String orgName) {
+        this.orgName = orgName;
+    }
+
+    public List<ExamPrintPlan> getExamPrintPlanList() {
+        return examPrintPlanList;
+    }
+
+    public void setExamPrintPlanList(List<ExamPrintPlan> examPrintPlanList) {
+        this.examPrintPlanList = examPrintPlanList;
+    }
+
+    public String getCourseName() {
+        return courseName;
+    }
+
+    public void setCourseName(String courseName) {
+        this.courseName = courseName;
+    }
+
+    public String getCourseCode() {
+        return courseCode;
+    }
+
+    public void setCourseCode(String courseCode) {
+        this.courseCode = courseCode;
+    }
+
+    public String getPaperNumber() {
+        return paperNumber;
+    }
+
+    public void setPaperNumber(String paperNumber) {
+        this.paperNumber = paperNumber;
+    }
+
+    public String getPaperType() {
+        return paperType;
+    }
+
+    public void setPaperType(String paperType) {
+        this.paperType = paperType;
+    }
+
+    public Boolean getExposureStatus() {
+        return exposureStatus;
+    }
+
+    public void setExposureStatus(Boolean exposureStatus) {
+        this.exposureStatus = exposureStatus;
+    }
+
+    public String getPaperName() {
+        return paperName;
+    }
+
+    public void setPaperName(String paperName) {
+        this.paperName = paperName;
+    }
+
+    public String getPaperSuffix() {
+        return paperSuffix;
+    }
+
+    public void setPaperSuffix(String paperSuffix) {
+        this.paperSuffix = paperSuffix;
+    }
+
+    public String getPaperPath() {
+        return paperPath;
+    }
+
+    public void setPaperPath(String paperPath) {
+        this.paperPath = paperPath;
+    }
+
+    public Long getExamCardId() {
+        return examCardId;
+    }
+
+    public void setExamCardId(Long examCardId) {
+        this.examCardId = examCardId;
+    }
+}

+ 133 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/params/DownloadPaperFileParam.java

@@ -0,0 +1,133 @@
+package com.qmth.distributed.print.business.bean.params;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.distributed.print.business.enums.PaperFileDownloadContentEnum;
+import com.qmth.distributed.print.business.enums.PaperFileDownloadExposureStatusEnum;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.Set;
+
+/**
+ * @Description: 试卷文件下载参数
+ * @Author: CaoZixuan
+ * @Date: 2022-04-08
+ */
+public class DownloadPaperFileParam {
+    // 查询条件
+    @JsonSerialize(using = ToStringSerializer.class)
+    @ApiModelProperty(value = "学期id")
+    private Long semesterId;
+
+    @JsonSerialize(using = ToStringSerializer.class)
+    @ApiModelProperty(value = "考试id")
+    private Long examId;
+
+    @JsonSerialize(using = ToStringSerializer.class)
+    @ApiModelProperty(value = "机构id")
+    private Long orgId;
+
+    @ApiModelProperty(value = "课程名称")
+    private String courseName;
+
+    @JsonSerialize(using = ToStringSerializer.class)
+    @ApiModelProperty(value = "印刷计划id")
+    private Set<Long> idSet;
+
+    @ApiModelProperty(value = "下载的内容:'试卷、题卡、试卷题卡'")
+    private PaperFileDownloadContentEnum paperFileDownloadContentType;
+
+    @ApiModelProperty(value = "下载的曝光类型:'已曝光、未曝光、全部'")
+    private PaperFileDownloadExposureStatusEnum paperFileDownloadExposureStatus;
+
+    @ApiModelProperty(value = "开启根据课程名称-课程代码命名?true 是 false 否")
+    private Boolean namedByCourseInfo;
+
+    @ApiModelProperty(value = "开启根据试卷编号命名?true 是 false 否")
+    private Boolean namedByPaperNumber;
+
+    @ApiModelProperty(value = "开启根据原始文件名命名?true 是 false 否")
+    private Boolean namedByOriginalFile;
+
+
+
+    public Long getSemesterId() {
+        return semesterId;
+    }
+
+    public void setSemesterId(Long semesterId) {
+        this.semesterId = semesterId;
+    }
+
+    public Long getExamId() {
+        return examId;
+    }
+
+    public void setExamId(Long examId) {
+        this.examId = examId;
+    }
+
+    public Long getOrgId() {
+        return orgId;
+    }
+
+    public void setOrgId(Long orgId) {
+        this.orgId = orgId;
+    }
+
+    public String getCourseName() {
+        return courseName;
+    }
+
+    public void setCourseName(String courseName) {
+        this.courseName = courseName;
+    }
+
+    public Set<Long> getIdSet() {
+        return idSet;
+    }
+
+    public void setIdSet(Set<Long> idSet) {
+        this.idSet = idSet;
+    }
+
+    public PaperFileDownloadContentEnum getPaperFileDownloadContentType() {
+        return paperFileDownloadContentType;
+    }
+
+    public void setPaperFileDownloadContentType(PaperFileDownloadContentEnum paperFileDownloadContentType) {
+        this.paperFileDownloadContentType = paperFileDownloadContentType;
+    }
+
+    public PaperFileDownloadExposureStatusEnum getPaperFileDownloadExposureStatus() {
+        return paperFileDownloadExposureStatus;
+    }
+
+    public void setPaperFileDownloadExposureStatus(PaperFileDownloadExposureStatusEnum paperFileDownloadExposureStatus) {
+        this.paperFileDownloadExposureStatus = paperFileDownloadExposureStatus;
+    }
+
+    public Boolean getNamedByCourseInfo() {
+        return namedByCourseInfo;
+    }
+
+    public void setNamedByCourseInfo(Boolean namedByCourseInfo) {
+        this.namedByCourseInfo = namedByCourseInfo;
+    }
+
+    public Boolean getNamedByPaperNumber() {
+        return namedByPaperNumber;
+    }
+
+    public void setNamedByPaperNumber(Boolean namedByPaperNumber) {
+        this.namedByPaperNumber = namedByPaperNumber;
+    }
+
+    public Boolean getNamedByOriginalFile() {
+        return namedByOriginalFile;
+    }
+
+    public void setNamedByOriginalFile(Boolean namedByOriginalFile) {
+        this.namedByOriginalFile = namedByOriginalFile;
+    }
+}

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

@@ -0,0 +1,22 @@
+package com.qmth.distributed.print.business.enums;
+
+/**
+ * @Description: 试卷文件下载内容枚举类
+ * @Author: CaoZixuan
+ * @Date: 2022-04-08
+ */
+public enum PaperFileDownloadContentEnum {
+    ONLY_PAPER("仅下载试卷"),
+    ONLY_CARD("仅下载题卡"),
+    PAPER_AND_CARD("下载试卷和题卡")
+    ;
+    private final String desc;
+
+    PaperFileDownloadContentEnum(String desc) {
+        this.desc = desc;
+    }
+
+    public String getDesc() {
+        return desc;
+    }
+}

+ 22 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/enums/PaperFileDownloadExposureStatusEnum.java

@@ -0,0 +1,22 @@
+package com.qmth.distributed.print.business.enums;
+
+/**
+ * @Description: 试卷文件下载曝光状态枚举
+ * @Author: CaoZixuan
+ * @Date: 2022-04-08
+ */
+public enum PaperFileDownloadExposureStatusEnum {
+    EXPOSED_PAPER("已曝光的试卷"),
+    UNEXPOSED_PAPER("未曝光的试卷"),
+    ALL_PAPER("全部试卷"),
+    ;
+    private final String desc;
+
+    PaperFileDownloadExposureStatusEnum(String desc) {
+        this.desc = desc;
+    }
+
+    public String getDesc() {
+        return desc;
+    }
+}

+ 13 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamTaskMapper.java

@@ -93,7 +93,7 @@ public interface ExamTaskMapper extends BaseMapper<ExamTask> {
 
     List<ExamTask> listExamTaskAuditExpire(@Param("startTime") Long startTime, @Param("endTime") Long endTime);
 
-    List<ExamTaskDetailDto> listTaskPaper(@Param("schoolId") Long schoolId,@Param("semesterId") Long semesterId, @Param("examId") Long examId, @Param("courseCode") String courseCode, @Param("paperNumber") String paperNumber, @Param("cardRuleId") Long cardRuleId, @Param("makeMethod") MakeMethodEnum makeMethod, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("orgIds") Set<Long> orgIds, @Param("containsQuestionTeacher") boolean containsQuestionTeacher, @Param("userId") Long userId);
+    List<ExamTaskDetailDto> listTaskPaper(@Param("schoolId") Long schoolId, @Param("semesterId") Long semesterId, @Param("examId") Long examId, @Param("courseCode") String courseCode, @Param("paperNumber") String paperNumber, @Param("cardRuleId") Long cardRuleId, @Param("makeMethod") MakeMethodEnum makeMethod, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("orgIds") Set<Long> orgIds, @Param("containsQuestionTeacher") boolean containsQuestionTeacher, @Param("userId") Long userId);
 
     /**
      * 获取待办任务
@@ -152,4 +152,16 @@ public interface ExamTaskMapper extends BaseMapper<ExamTask> {
     ExamTaskDto getByExamTaskId(Long examTaskId);
 
     IPage<ExamTaskDetailDto> listExamTaskDetailDownload(@Param("page") Page<ExamTaskDetailDto> page, @Param("semesterId") Long semesterId, @Param("examId") Long examId, @Param("courseName") String courseName, @Param("orgIds") Set<Long> orgIds);
+
+    /**
+     * 根据条件查询要下载的试卷文件
+     *
+     * @param semesterId 学期id
+     * @param examId     考试id
+     * @param courseName 课程明后才能
+     * @param orgIds     机构id
+     * @param idSet      命题任务id集合
+     * @return 命题任务试卷信息
+     */
+    List<ExamTaskDetailDto> listExamTaskDetailDownloadByQuery(@Param("semesterId") Long semesterId, @Param("examId") Long examId, @Param("courseName") String courseName, @Param("orgIds") Set<Long> orgIds, @Param("idSet") Set<Long> idSet);
 }

+ 14 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/DownloadService.java

@@ -4,10 +4,13 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.distributed.print.business.bean.dto.BasicExamDto;
 import com.qmth.distributed.print.business.bean.dto.ExamTaskDetailDto;
+import com.qmth.distributed.print.business.bean.dto.ExamTaskPaperDto;
+import com.qmth.distributed.print.business.bean.dto.ExamTaskPaperFileDto;
 import com.qmth.teachcloud.common.entity.BasicExam;
 
 import javax.servlet.http.HttpServletResponse;
 import java.util.List;
+import java.util.Set;
 
 /**
  * <p>
@@ -18,4 +21,15 @@ public interface DownloadService {
     IPage<ExamTaskDetailDto> page(Long semesterId, Long examId, Long orgId, String courseName, Integer pageNumber, Integer pageSize);
 
     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);
 }

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

@@ -107,4 +107,12 @@ public interface ExamPrintPlanService extends IService<ExamPrintPlan> {
     ExamPrintPlan findByExamDetailId(Long examDetailId);
 
     void sendNoticeUploadStructure(Long id, SysUser sysUser);
+
+    /**
+     * 根据学校id和试卷编号查询印刷计划
+     * @param schoolId 学校id
+     * @param paperNumber 试卷编号
+     * @return 印刷计划
+     */
+    List<ExamPrintPlan> findByPaperNumber(Long schoolId,String paperNumber);
 }

+ 119 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/DownloadServiceImpl.java

@@ -2,6 +2,7 @@ package com.qmth.distributed.print.business.service.impl;
 
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qmth.distributed.print.business.bean.dto.ExamTaskDetailDto;
@@ -9,9 +10,18 @@ import com.qmth.distributed.print.business.entity.*;
 import com.qmth.distributed.print.business.enums.MakeMethodEnum;
 import com.qmth.distributed.print.business.mapper.ExamCardMapper;
 import com.qmth.distributed.print.business.mapper.ExamTaskDetailMapper;
+import com.qmth.distributed.print.business.bean.dto.ExamTaskPaperDto;
+import com.qmth.distributed.print.business.bean.dto.ExamTaskPaperExportDto;
+import com.qmth.distributed.print.business.bean.dto.ExamTaskPaperFileDto;
+import com.qmth.distributed.print.business.entity.ExamPrintPlan;
 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.ExamPrintPlanService;
+import com.qmth.teachcloud.common.contant.SystemConstant;
+import com.qmth.teachcloud.common.entity.BasicAttachment;
+import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
+import com.qmth.teachcloud.common.service.BasicAttachmentService;
 import com.qmth.distributed.print.business.service.ExamCardDetailService;
 import com.qmth.distributed.print.business.util.CreatePdfUtil;
 import com.qmth.distributed.print.business.util.HtmlToPdfUtil;
@@ -28,6 +38,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.FileCopyUtils;
 
 import javax.annotation.Resource;
+import java.util.*;
 import javax.servlet.http.HttpServletResponse;
 import java.io.File;
 import java.util.ArrayList;
@@ -44,6 +55,12 @@ public class DownloadServiceImpl implements DownloadService {
     @Resource
     ExamTaskMapper examTaskMapper;
 
+    @Resource
+    BasicAttachmentService basicAttachmentService;
+
+    @Resource
+    ExamPrintPlanService examPrintPlanService;
+
     @Resource
     ExamTaskDetailMapper examTaskDetailMapper;
 
@@ -152,4 +169,106 @@ public class DownloadServiceImpl implements DownloadService {
         String zipName = examTask.getCourseName() + "未曝光试卷.zip";
         attachmentCommonService.zipFiles(response, rootPath, zipName, fileList);
     }
+
+    @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) {
+                orgIds = teachcloudCommonService.listSubOrgIds(orgId);
+            }
+            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 examCardId= examTaskDetailDto.getExamCardId();
+
+                // 生成导出对象
+                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<Map> paperInfo = JSONObject.parseArray(examTaskDetailDto.getPaperAttachmentIds(), Map.class);
+                if (Objects.isNull(paperInfo)) {
+                    throw ExceptionResultEnum.ERROR.exception("试卷信息不存在");
+                }
+                 // 试卷信息
+                for (Map paper : paperInfo) {
+                    Long attachmentId = SystemConstant.convertIdToLong(String.valueOf(paper.get("attachmentId")));
+                    BasicAttachment basicAttachment = basicAttachmentService.getById(attachmentId);
+                    String paperType = String.valueOf(paper.get("name"));
+                    String paperName = basicAttachment.getName();
+                    String paperSuffix = basicAttachment.getType();
+                    JSONObject jsonObject = JSONObject.parseObject(basicAttachment.getPath());
+                    String paperPath = (String) jsonObject.get(SystemConstant.PATH);
+
+                    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(examCardId);
+                    // 试卷
+                    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;
+    }
+
 }

+ 29 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamPrintPlanServiceImpl.java

@@ -82,6 +82,8 @@ public class ExamPrintPlanServiceImpl extends ServiceImpl<ExamPrintPlanMapper, E
 
     @Autowired
     BasicClazzService basicClazzService;
+    @Resource
+    ExamDetailCourseService examDetailCourseService;
 
     @Transactional(rollbackFor = Exception.class)
     @Override
@@ -477,6 +479,33 @@ public class ExamPrintPlanServiceImpl extends ServiceImpl<ExamPrintPlanMapper, E
         }
     }
 
+    @Override
+    public List<ExamPrintPlan> findByPaperNumber(Long schoolId, String paperNumber) {
+        Set<Long> examDetailIdSet = examDetailCourseService.list(new QueryWrapper<ExamDetailCourse>()
+                        .lambda()
+                        .eq(ExamDetailCourse::getSchoolId, schoolId)
+                        .eq(ExamDetailCourse::getPaperNumber, paperNumber))
+                .stream()
+                .map(ExamDetailCourse::getExamDetailId)
+                .collect(Collectors.toSet());
+
+        Set<Long> examPrintPlanIdSet = new HashSet<>();
+        if (examDetailIdSet.size() > 0) {
+            examPrintPlanIdSet = examDetailService.list(new QueryWrapper<ExamDetail>()
+                            .lambda()
+                            .in(ExamDetail::getId, examDetailIdSet))
+                    .stream()
+                    .map(ExamDetail::getPrintPlanId)
+                    .collect(Collectors.toSet());
+        }
+
+        List<ExamPrintPlan> examPrintPlanList = new ArrayList<>();
+        if (examPrintPlanIdSet.size() > 0){
+            examPrintPlanList = this.list(new QueryWrapper<ExamPrintPlan>().lambda().in(ExamPrintPlan::getId,examPrintPlanIdSet));
+        }
+        return examPrintPlanList;
+    }
+
 
     /**
      * 查找子机构

+ 66 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/AsyncDownloadPaperFileBatchService.java

@@ -0,0 +1,66 @@
+package com.qmth.distributed.print.business.templete.execute;
+
+import cn.hutool.core.date.DateUtil;
+import com.qmth.boot.api.exception.ApiException;
+import com.qmth.distributed.print.business.templete.export.AsyncExportTaskTemplete;
+import com.qmth.distributed.print.business.templete.service.TaskLogicService;
+import com.qmth.teachcloud.common.contant.SpringContextHolder;
+import com.qmth.teachcloud.common.contant.SystemConstant;
+import com.qmth.teachcloud.common.entity.TBTask;
+import com.qmth.teachcloud.common.enums.TaskResultEnum;
+import com.qmth.teachcloud.common.enums.TaskStatusEnum;
+import com.qmth.teachcloud.common.service.TBTaskService;
+import com.qmth.teachcloud.common.util.Result;
+import com.qmth.teachcloud.common.util.ResultUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import java.text.MessageFormat;
+import java.util.Date;
+import java.util.Map;
+import java.util.StringJoiner;
+
+/**
+ * @Description: 异步任务 - 批量下载试卷文件任务
+ * @Author: CaoZixuan
+ * @Date: 2022-04-07
+ */
+@Service
+public class AsyncDownloadPaperFileBatchService extends AsyncExportTaskTemplete {
+
+    public static final String OBJ_TITLE = "试卷文件任务";
+    public static final String BEGIN_TITLE = "->开始准备处理下载的";
+    private final static Logger log = LoggerFactory.getLogger(AsyncDownloadPaperFileBatchService.class);
+
+    @Override
+    public Result exportTask(Map<String, Object> map) throws Exception {
+        TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
+        StringJoiner stringJoinerSummary = new StringJoiner("\n")
+                .add(MessageFormat.format("{0}{1}{2}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), BEGIN_TITLE, OBJ_TITLE));
+        tbTask.setStatus(TaskStatusEnum.RUNNING);
+        TBTaskService tbTaskService = SpringContextHolder.getBean(TBTaskService.class);
+        tbTaskService.updateById(tbTask);
+        try {
+            TaskLogicService taskLogicService = SpringContextHolder.getBean(TaskLogicService.class);
+            Map<String, Object> result = taskLogicService.executeDownloadPaperFileBatch(map);
+
+            // ↓
+            stringJoinerSummary.add(MessageFormat.format("{0}{1}{2}{3}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), FINISH_TITLE, Long.valueOf(String.valueOf(result.get("count"))), FINISH_SIZE));
+            tbTask.setResult(TaskResultEnum.SUCCESS);
+        }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);
+            if (e instanceof ApiException) {
+                ResultUtil.error((ApiException) e, e.getMessage());
+            } else {
+                ResultUtil.error(e.getMessage());
+            }
+        } finally {
+            tbTask.setSummary(stringJoinerSummary.toString());
+            super.createTxt(tbTask);
+        }
+        return ResultUtil.ok();
+    }
+}

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

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

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

@@ -14,6 +14,7 @@ import com.google.gson.Gson;
 import com.itextpdf.text.DocumentException;
 import com.qmth.boot.api.exception.ApiException;
 import com.qmth.distributed.print.business.bean.dto.*;
+import com.qmth.distributed.print.business.bean.params.DownloadPaperFileParam;
 import com.qmth.distributed.print.business.bean.params.SerialNumberParams;
 import com.qmth.distributed.print.business.bean.result.TSyncExamStudentScoreResult;
 import com.qmth.distributed.print.business.cache.CreatePdfCacheUtil;
@@ -170,6 +171,9 @@ public class TaskLogicServiceImpl implements TaskLogicService {
     @Resource
     private BasicExamService basicExamService;
 
+    @Resource
+    private DownloadService downloadService;
+
     /**
      * 创建pdf前置条件
      *
@@ -391,7 +395,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                                 int seq = atomicInteger.getAndIncrement();
                                 int mod = seq % examTaskDetail.getDrawCount();
                                 String tempPaperType = paperTypes.get(mod);
-                                BasicAttachment basicAttachment = createPdfUtil.examStudentHtml(cardContent, null, tempPaperType, examDetail, examDetailCourse, sysUser.getId(), studentCardPdfList, basicCardRule);;
+                                BasicAttachment basicAttachment = createPdfUtil.examStudentHtml(cardContent, null, tempPaperType, examDetail, examDetailCourse, sysUser.getId(), studentCardPdfList, basicCardRule);
+                                ;
                                 if (!stringBasicAttachmentMap.containsKey(tempPaperType)) {
                                     stringBasicAttachmentMap.put(tempPaperType, basicAttachment);
                                     JSONObject object = new JSONObject();
@@ -642,7 +647,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
         jsonObject.put(SystemConstant.PATH, dirName);
         jsonObject.put(SystemConstant.UPLOAD_TYPE, UploadFileEnum.FILE);
         map.put(SystemConstant.PATH, jsonObject.toString());
-        map.put(SystemConstant.DATA_COUNT,examinationExportDtoList.size());
+        map.put(SystemConstant.DATA_COUNT, examinationExportDtoList.size());
         return map;
     }
 
@@ -1631,6 +1636,161 @@ public class TaskLogicServiceImpl implements TaskLogicService {
         return map;
     }
 
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public Map<String, Object> executeDownloadPaperFileBatch(Map<String, Object> map) throws Exception {
+        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();
+        Boolean namedByCourseInfo = downloadPaperFileParam.getNamedByCourseInfo();
+        Boolean namedByPaperNumber = downloadPaperFileParam.getNamedByPaperNumber();
+        Boolean namedByOriginalFile = downloadPaperFileParam.getNamedByOriginalFile();
+        PaperFileDownloadContentEnum paperFileDownloadContent = downloadPaperFileParam.getPaperFileDownloadContentType();
+        PaperFileDownloadExposureStatusEnum paperFileDownloadExposureStatus = downloadPaperFileParam.getPaperFileDownloadExposureStatus();
+
+        String courseName = downloadPaperFileParam.getCourseName();
+        Set<Long> idSet = downloadPaperFileParam.getIdSet();
+
+
+        LocalDateTime nowTime = LocalDateTime.now();
+        String zipJoiner = SystemConstant.TEMP_FILES_DIR + File.separator;
+        String dirName = UploadFileEnum.FILE.getTitle() + File.separator +
+                nowTime.getYear() + File.separator +
+                String.format("%02d", nowTime.getMonthValue()) + File.separator +
+                String.format("%02d", nowTime.getDayOfMonth()) +
+                File.separator + SystemConstant.getUuid() + SystemConstant.ZIP_PREFIX;
+        String dirNameTmp = dirName.replaceAll("\\\\", "/");
+        File zipFile = new File(zipJoiner + dirNameTmp);
+        if (!zipFile.getParentFile().exists()) {
+            boolean mkd = zipFile.getParentFile().mkdirs();
+            boolean cf = zipFile.createNewFile();
+        }
+
+        // 跟文件路径
+        String zipLocalRootPath = SystemConstant.TEMP_FILES_DIR + 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 = "试卷使用清单";
+
+        // 所有试卷信息
+        List<ExamTaskPaperFileDto> examTaskPaperFileDtoList = examTaskPaperDto.getExamTaskPaperFileDtoList();
+        switch (paperFileDownloadExposureStatus) {
+            case EXPOSED_PAPER: // 曝光的
+                excelName = excelName + "(" + paperFileDownloadExposureStatus.getDesc() + ")";
+                examTaskPaperFileDtoList = examTaskPaperFileDtoList.stream().filter(ExamTaskPaperFileDto::getExposureStatus).collect(Collectors.toList());
+                break;
+            case UNEXPOSED_PAPER: // 未曝光的
+                excelName = excelName + "(" + paperFileDownloadExposureStatus.getDesc() + ")";
+                examTaskPaperFileDtoList = examTaskPaperFileDtoList.stream().filter(e -> !e.getExposureStatus()).collect(Collectors.toList());
+                break;
+            case ALL_PAPER: // 全部试卷
+                excelName = excelName + "(" + paperFileDownloadExposureStatus.getDesc() + ")";
+                break;
+        }
+        String excelLocalPath = zipLocalRootPath + File.separator + excelName + "." + SystemConstant.XLSX;
+        convertUtil.saveLocal(in,excelLocalPath);
+
+        // 二级路径 课程
+        Set<String> courseSet = examTaskPaperFileDtoList.stream().map(e -> e.getCourseName() + "-" + e.getCourseCode()).collect(Collectors.toSet());
+        for (String course : courseSet) {
+            // 三级路径 课程代码-课程名称/试卷编号
+            Set<String> paperNumberSet = examTaskPaperFileDtoList
+                    .stream()
+                    .filter(e -> course.equals(e.getCourseName() + "-" + 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;
+
+                Long examCardId = paperCellList.get(0).getExamCardId();
+                ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examCardId);
+                String htmlContent = examCardDetail.getHtmlContent();
+                byte[] bytes = htmlContent.getBytes();
+                String cardLocalPath = filePath + "题卡-" + examCardService.getById(examCardId).getTitle() + SystemConstant.HTML_PREFIX;
+
+                switch (paperFileDownloadContent) {
+                    case ONLY_CARD: // 只下载题卡
+                        File localFile = new File(cardLocalPath);
+                        if (!localFile.getParentFile().exists()) {
+                            boolean mkr = localFile.getParentFile().mkdirs();
+                        }
+                        FileCopyUtils.copy(bytes, localFile);
+                        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();
+                            }
+                            String paperLocalPath = filePath + paperName + examTaskPaperFileDto.getPaperSuffix();
+                            String paperPath = examTaskPaperFileDto.getPaperPath();
+                            fileStoreUtil.ossDownload(paperPath, paperLocalPath, fileStoreUtil.getUploadEnumByPath(paperPath).getFssType());
+                        }
+                        break;
+                    case PAPER_AND_CARD: // 全部下载
+                        // 题卡
+                        File localCardFile = new File(cardLocalPath);
+                        if (!localCardFile.getParentFile().exists()) {
+                            boolean mkr = localCardFile.getParentFile().mkdirs();
+                        }
+                        FileCopyUtils.copy(bytes, localCardFile);
+                        // 试卷
+                        for (ExamTaskPaperFileDto examTaskPaperFileDto : paperCellList) {
+                            String paperName = "试卷-";
+                            if (namedByCourseInfo){
+                                paperName = paperName + course;
+                            }
+                            if (namedByPaperNumber){
+                                paperName = paperName + paperNumber;
+                            }
+                            if (namedByOriginalFile){
+                                paperName = paperName + examTaskPaperFileDto.getPaperName();
+                            }
+                            String paperLocalPath = filePath + paperName + examTaskPaperFileDto.getPaperSuffix();
+                            String paperPath = examTaskPaperFileDto.getPaperPath();
+                            fileStoreUtil.ossDownload(paperPath, paperLocalPath, fileStoreUtil.getUploadEnumByPath(paperPath).getFssType());
+                        }
+
+                }
+            }
+        }
+        ZipUtil.zip(zipLocalRootPath, zipFile.getPath(), false);
+//        ossUtil.ossUpload(dirNameTmp, zipFile, BinaryUtil.toBase64String(HexUtils.decodeHex(DigestUtils.md5Hex(new FileInputStream(zipFile)))));
+        fileStoreUtil.ossUpload(dirNameTmp, zipFile, BinaryUtil.toBase64String(HexUtils.decodeHex(DigestUtils.md5Hex(new FileInputStream(zipFile)))), fileStoreUtil.getUploadEnumByPath(dirNameTmp).getFssType());
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put(SystemConstant.PATH, dirNameTmp);
+        jsonObject.put(SystemConstant.TYPE, SystemConstant.OSS);
+        jsonObject.put(SystemConstant.UPLOAD_TYPE, UploadFileEnum.FILE);
+        tbTask.setResultFilePath(jsonObject.toJSONString());
+        ConvertUtil.delFolder(zipLocalRootPath);
+        zipFile.delete();
+        map.put("count", 1);
+        return map;
+    }
+
 
     public String createTempNumber(SerialNumberParams serialNumberParams) {
         return convertUtil.getIncre(serialNumberParams.getPrefix(), serialNumberParams.getModel(), serialNumberParams.getDigit());

+ 61 - 1
distributed-print-business/src/main/resources/mapper/ExamTaskMapper.xml

@@ -1310,7 +1310,7 @@
                 LEFT JOIN
             exam_task_detail b ON a.id = b.exam_task_id
                 LEFT JOIN
-            basic_course bc ON a.school_id = bc.school_id and a.course_code = b.code
+            basic_course bc ON a.school_id = bc.school_id and a.course_code = bc.code
                 LEFT JOIN
             basic_card_rule e ON a.card_rule_id = e.id
                 LEFT JOIN
@@ -1340,4 +1340,64 @@
             </if>
         </where>
     </select>
+    <select id="listExamTaskDetailDownloadByQuery"
+            resultType="com.qmth.distributed.print.business.bean.dto.ExamTaskDetailDto">
+        SELECT
+            a.id,
+            be.name examName,
+            bs.name semesterName,
+            a.course_code courseCode,
+            a.course_name courseName,
+            a.paper_number paperNumber,
+            b.enable,
+            b.paper_type paperType,
+            IFNULL(b.exposed_paper_type,'') exposedPaperType,
+            IFNULL(b.unexposed_paper_type,'') unexposedPaperType,
+            so.name orgName,
+            b.card_id examCardId,
+            b.paper_attachment_ids paperAttachmentIds
+        FROM
+            exam_task a
+                LEFT JOIN
+            exam_task_detail b ON a.id = b.exam_task_id
+                LEFT JOIN
+            basic_course bc ON a.school_id = bc.school_id
+                AND a.course_code = bc.code
+                LEFT JOIN
+            basic_card_rule e ON a.card_rule_id = e.id
+                LEFT JOIN
+            basic_exam be ON a.exam_id = be.id
+                LEFT JOIN
+            basic_semester bs ON be.semester_id = bs.id
+                LEFT JOIN
+            t_f_flow_approve g ON g.flow_id = a.flow_id
+                LEFT JOIN
+            sys_org so ON bc.teaching_room_id = so.id and so.enable
+        <where>
+            a.status = 'SUBMIT'
+            AND (a.review = 0
+            OR (a.review = 1 AND g.status = 'FINISH'))
+            <if test="semesterId != null and semesterId != ''">
+                and be.semester_id = #{semesterId}
+            </if>
+            <if test="examId != null and examId != ''">
+                and a.exam_id = #{examId}
+            </if>
+            <if test="courseName != null and courseName != ''">
+                and a.course_name like concat('%', #{courseName}, '%')
+            </if>
+            <if test="orgIds != null">
+                and bc.teaching_room_id in
+                <foreach collection="orgIds" item="item" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="idSet != null">
+                and a.id in
+                <foreach collection="idSet" item="item" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+        </where>
+    </select>
 </mapper>

+ 36 - 25
distributed-print/src/main/java/com/qmth/distributed/print/api/DownloadController.java

@@ -1,41 +1,56 @@
 package com.qmth.distributed.print.api;
 
+import com.qmth.boot.api.annotation.Aac;
+import com.qmth.boot.api.annotation.BOOL;
 import com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.distributed.print.business.bean.params.DownloadPaperFileParam;
+import com.qmth.distributed.print.business.bean.params.PrintPlanParams;
 import com.qmth.distributed.print.business.service.DownloadService;
+import com.qmth.distributed.print.business.service.PrintCommonService;
+import com.qmth.distributed.print.business.templete.execute.AsyncDownloadPaperFileBatchService;
 import com.qmth.distributed.print.business.service.ExamTaskService;
 import com.qmth.teachcloud.common.bean.result.TaskListResult;
 import com.qmth.teachcloud.common.contant.SystemConstant;
+import com.qmth.teachcloud.common.entity.TBTask;
+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.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import javax.validation.Valid;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.constraints.Max;
 import javax.validation.constraints.Min;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 下载管理
  */
-@Api(tags = "系统管理-任务管理Controller")
+@Api(tags = "系统管理-下载管理Controller")
 @RestController
 @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/${prefix.url.data}/download")
 public class DownloadController {
 
     @Resource
     private DownloadService downloadService;
+    @Resource
+    private PrintCommonService printCommonService;
+    @Resource
+    private AsyncDownloadPaperFileBatchService asyncDownloadPaperFileBatchService;
 
     /**
      * 分页
      *
-     * @param semesterId  学期ID
-     * @param examId      考试ID
-     * @param orgId 学院
-     * @param courseName  课程名称
-     * @param pageNumber  分页页码
-     * @param pageSize    分页数
+     * @param semesterId 学期ID
+     * @param examId     考试ID
+     * @param orgId      机构Id
+     * @param courseName 课程名称
+     * @param pageNumber 分页页码
+     * @param pageSize   分页数
      * @return Object
      */
     @ApiOperation(value = "分页查询")
@@ -62,22 +77,18 @@ public class DownloadController {
         downloadService.paperDownload(response, id);
     }
 
-    /**
-     * 批量下载
-     *
-     * @param semesterId  学期ID
-     * @param examId      考试ID
-     * @param collegeName 学院
-     * @param courseName  课程名称
-     * @return Object
-     */
     @ApiOperation(value = "批量下载")
     @RequestMapping(value = "/download_batch", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "批量下载", response = TaskListResult.class)})
-    public Object downloadBatch(@ApiParam(value = "学期ID", required = false) @RequestParam(required = false) Long semesterId,
-                                @ApiParam(value = "考试ID", required = false) @RequestParam(required = false) Long examId,
-                                @ApiParam(value = "学院", required = false) @RequestParam(required = false) String collegeName,
-                                @ApiParam(value = "课程名称", required = false) @RequestParam(required = false) String courseName) {
-        return null;
+    @Aac(strict = BOOL.FALSE, auth = BOOL.FALSE)
+    public Object downloadBatch(@Valid @RequestBody DownloadPaperFileParam downloadPaperFileParam, BindingResult bindingResult) throws Exception {
+        if (bindingResult.hasErrors()) {
+            return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
+        }
+        Map<String, Object> map = printCommonService.saveTask(TaskTypeEnum.DOWNLOAD_PAPER_FILE_BATCH);
+        map.put("downloadPaperFileParam", downloadPaperFileParam);
+        asyncDownloadPaperFileBatchService.exportTask(map);
+        TBTask tbTask = Objects.nonNull(map.get(SystemConstant.TASK)) ? (TBTask) map.get(SystemConstant.TASK) : null;
+        return Objects.nonNull(tbTask) ? ResultUtil.ok(tbTask.getId()) : ResultUtil.error("创建任务失败");
     }
 }

+ 4 - 4
distributed-print/src/main/java/com/qmth/distributed/print/interceptor/AuthInterceptor.java

@@ -22,11 +22,11 @@ public class AuthInterceptor extends ExtendInterceptor {
     @Override
     public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
         log.info("preHandle is come in");
-//        if (request.getServletPath().contains(endpoint)) {
+        if (request.getServletPath().contains(endpoint)) {
             return true;
-//        } else {
-//            return AuthUtil.adminAuthInterceptor(request, response, handler);
-//        }
+        } else {
+            return AuthUtil.adminAuthInterceptor(request, response, handler);
+        }
     }
 
     @Override

+ 3 - 1
teachcloud-common/src/main/java/com/qmth/teachcloud/common/enums/TaskTypeEnum.java

@@ -41,7 +41,9 @@ public enum TaskTypeEnum {
 
     SCORE_EXPORT("成绩导出"),
 
-    SCORE_DOWNLOAD("成绩轨迹下载");
+    SCORE_DOWNLOAD("成绩轨迹下载"),
+
+    DOWNLOAD_PAPER_FILE_BATCH("批量下载试卷文件");
 
     private String title;
 

+ 5 - 3
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/TeachcloudCommonServiceImpl.java

@@ -9,6 +9,8 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.google.common.reflect.TypeToken;
 import com.google.gson.Gson;
 import com.qmth.boot.core.enums.Platform;
+import com.qmth.boot.tools.signature.SignatureType;
+import com.qmth.teachcloud.common.SignatureEntityTest;
 import com.qmth.teachcloud.common.bean.auth.AuthBean;
 import com.qmth.teachcloud.common.bean.auth.ExpireTimeBean;
 import com.qmth.teachcloud.common.bean.dto.MenuDto;
@@ -922,7 +924,7 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
         }
         String sessionId = SessionUtil.digest(sysUser.getId(), Math.abs(roleNames.toString().hashCode()), platform.name());
         //TODO 测试用
-//        String test = SignatureEntityTest.build(SignatureType.TOKEN, sessionId, token);
+        String test = SignatureEntityTest.build(SignatureType.TOKEN, sessionId, token);
         ExpireTimeBean expireTime = AuthUtil.getExpireTime(platform);
         TBSession tbSession = new TBSession(sysUser.getSchoolId(), sessionId, String.valueOf(sysUser.getId()), roleNames.toString(),
                 platform.name(), platform.name(), deviceId, ServletUtil.getRequest().getLocalAddr(), token,
@@ -930,8 +932,8 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
         tbSessionService.saveOrUpdate(tbSession);
         redisUtil.setUserSession(sessionId, tbSession, expireTime.getExpireSeconds());
 
-//        LoginResult loginResult = new LoginResult(sysUser, sessionId, test, Objects.nonNull(roleTypes) && roleTypes.size() > 0 ? roleTypes : roleNames, appSource);
-        LoginResult loginResult = new LoginResult(sysUser, sessionId, token, Objects.nonNull(roleTypes) && roleTypes.size() > 0 ? roleTypes : roleNames, appSource);
+        LoginResult loginResult = new LoginResult(sysUser, sessionId, test, Objects.nonNull(roleTypes) && roleTypes.size() > 0 ? roleTypes : roleNames, appSource);
+//        LoginResult loginResult = new LoginResult(sysUser, sessionId, token, Objects.nonNull(roleTypes) && roleTypes.size() > 0 ? roleTypes : roleNames, appSource);
         loginResult.setSchoolInfo(Objects.nonNull(authBean.getSchool()) ? loginResult.new SchoolNativeBean(authBean.getSchool()) : null);
         loginResult.setOrgInfo(Objects.nonNull(authBean.getOrg()) ? loginResult.new OrgNativeBean(authBean.getOrg()) : null);
         loginResult.setTime(System.currentTimeMillis());