Эх сурвалжийг харах

图片管理-下载图片

haogh 11 сар өмнө
parent
commit
6a3b8752ef

+ 10 - 1
paper-library-business/src/main/java/com/qmth/paper/library/business/mapper/PictureManageMapper.java

@@ -14,5 +14,14 @@ public interface PictureManageMapper {
             @Param(value = "collegeNames") List<String> collegeNames, @Param(value = "majorNames") List<String> majorNames,
             @Param(value = "classNames") List<String> classNames, @Param(value = "teacher") String teacher, @Param(value = "teachClass") String teachClass,
             @Param(value = "param") String param, @Param(value = "minScore") Double minScore,
-            @Param(value = "maxScore") Double maxScore, @Param(value = "pictureSymbol") String pictureSymbol, @Param(value = "pictureCount") Integer pictureCount);
+            @Param(value = "maxScore") Double maxScore, @Param(value = "pictureSymbol") String pictureSymbol,
+            @Param(value = "pictureCount") Integer pictureCount);
+
+    List<PictureManageDetailResult> pageData(@Param(value = "semesterIds") List<Long> semesterIds,
+            @Param(value = "examIds") List<Long> examIds, @Param(value = "courseCodes") List<String> courseCodes,
+            @Param(value = "collegeNames") List<String> collegeNames, @Param(value = "majorNames") List<String> majorNames,
+            @Param(value = "classNames") List<String> classNames, @Param(value = "teacher") String teacher, @Param(value = "teachClass") String teachClass,
+            @Param(value = "param") String param, @Param(value = "minScore") Double minScore,
+            @Param(value = "maxScore") Double maxScore, @Param(value = "pictureSymbol") String pictureSymbol,
+            @Param(value = "pictureCount") Integer pictureCount);
 }

+ 3 - 0
paper-library-business/src/main/java/com/qmth/paper/library/business/service/PictureManageService.java

@@ -2,6 +2,7 @@ package com.qmth.paper.library.business.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.qmth.paper.library.business.bean.result.PictureManageDetailResult;
+import com.qmth.paper.library.common.bean.params.DownloadPictureParams;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.util.List;
@@ -16,4 +17,6 @@ public interface PictureManageService {
             String pictureSymbol, Integer pictureCount, Integer pageNumber, Integer pageSize);
 
     boolean savePicture(MultipartFile file, String fileMd5, String fileUrl, Long paperLibraryId);
+
+    List<PictureManageDetailResult> listPictureResult(DownloadPictureParams params);
 }

+ 29 - 0
paper-library-business/src/main/java/com/qmth/paper/library/business/service/impl/PictureManageServiceImpl.java

@@ -6,6 +6,7 @@ import com.qmth.paper.library.business.bean.result.PictureManageDetailResult;
 import com.qmth.paper.library.business.mapper.PictureManageMapper;
 import com.qmth.paper.library.business.service.PaperLibraryService;
 import com.qmth.paper.library.business.service.PictureManageService;
+import com.qmth.paper.library.common.bean.params.DownloadPictureParams;
 import com.qmth.paper.library.common.enums.ExceptionResultEnum;
 import com.qmth.paper.library.common.util.FileStoreUtil;
 import org.apache.commons.codec.digest.DigestUtils;
@@ -68,4 +69,32 @@ public class PictureManageServiceImpl implements PictureManageService {
         return true;
     }
 
+    @Override
+    public List<PictureManageDetailResult> listPictureResult(DownloadPictureParams params) {
+        List<Long> semesterIds = params.getSemesterIds();
+        List<Long> examIds = params.getExamIds();
+        List<String> courseCodes = params.getCourseCodes();
+        List<String> collegeNames = params.getCollegeNames();
+        List<String> majorNames = params.getMajorNames();
+        List<String> classNames = params.getClassNames();
+        String teacher = params.getTeacher();
+        String teachClass = params.getTeachClass();
+        String param = params.getParam();
+        Double minScore = params.getMinScore();
+        Double maxScore = params.getMaxScore();
+        String pictureSymbol = params.getPictureSymbol();
+        Integer pictureCount = params.getPictureCount();
+        List<PictureManageDetailResult> pictureList = pictureManageMapper.pageData(semesterIds, examIds, courseCodes, collegeNames, majorNames,
+                classNames, teacher, teachClass, param, minScore, maxScore, pictureSymbol, pictureCount);
+        for(PictureManageDetailResult result : pictureList) {
+            //一个考生 可能会存在多个批次号
+            List<String> batchNoList = paperLibraryService.listBatchNo(result.getStudentId());
+            if(!batchNoList.isEmpty()) {
+                result.setBatchNo(String.join(",", batchNoList));
+            }
+        }
+        return pictureList;
+    }
+
+
 }

+ 67 - 0
paper-library-business/src/main/java/com/qmth/paper/library/business/templete/execute/AsyncDownloadPictureService.java

@@ -0,0 +1,67 @@
+package com.qmth.paper.library.business.templete.execute;
+
+import cn.hutool.core.date.DateUtil;
+import com.qmth.boot.api.exception.ApiException;
+import com.qmth.paper.library.business.templete.export.AsyncExportTaskTemplate;
+import com.qmth.paper.library.business.templete.service.TaskLogicService;
+import com.qmth.paper.library.common.contant.SpringContextHolder;
+import com.qmth.paper.library.common.contant.SystemConstant;
+import com.qmth.paper.library.common.entity.TBTask;
+import com.qmth.paper.library.common.enums.TaskResultEnum;
+import com.qmth.paper.library.common.enums.TaskStatusEnum;
+import com.qmth.paper.library.common.service.TBTaskService;
+import com.qmth.paper.library.common.util.Result;
+import com.qmth.paper.library.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 图片管理-考生图片下载-异步执行service
+ */
+@Service
+public class AsyncDownloadPictureService extends AsyncExportTaskTemplate {
+
+    private static final Logger log = LoggerFactory.getLogger(AsyncDownloadPictureService.class);
+
+    static final String OBJ_TITLE = "zip数据";
+
+    @Override
+    public Result exportTask(Map<String, Object> map) {
+        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);
+            taskLogicService.executeDownloadPictureLogic(map);
+            stringJoinerSummary.add(
+                    MessageFormat.format("{0}{1}{2}{3}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), FINISH_TITLE, map.get("size"),
+                            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());
+            tbTask.setStatus(TaskStatusEnum.FINISH);
+            tbTaskService.updateById(tbTask);
+        }
+        return ResultUtil.ok(map);
+    }
+}

+ 7 - 0
paper-library-business/src/main/java/com/qmth/paper/library/business/templete/service/TaskLogicService.java

@@ -36,4 +36,11 @@ public interface TaskLogicService {
      * @param map 数据源
      */
     Map<String, Object> executeDownloadPaperLogic(Map<String, Object> map);
+
+    /**
+     * 下载试卷
+     *
+     * @param map 数据源
+     */
+    Map<String, Object> executeDownloadPictureLogic(Map<String, Object> map);
 }

+ 259 - 0
paper-library-business/src/main/java/com/qmth/paper/library/business/templete/service/impl/TaskLogicServiceImpl.java

@@ -2,10 +2,12 @@ package com.qmth.paper.library.business.templete.service.impl;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.google.common.collect.Lists;
 import com.qmth.boot.api.exception.ApiException;
 import com.qmth.paper.library.business.bean.result.DocManageDetailResult;
+import com.qmth.paper.library.business.bean.result.PictureManageDetailResult;
 import com.qmth.paper.library.business.entity.PaperLibrary;
 import com.qmth.paper.library.business.entity.PaperScanTask;
 import com.qmth.paper.library.business.service.*;
@@ -14,6 +16,7 @@ import com.qmth.paper.library.common.bean.dto.excel.DescribeImportDto;
 import com.qmth.paper.library.common.bean.dto.excel.SysOrgImportDto;
 import com.qmth.paper.library.common.bean.dto.excel.SysUserImportDto;
 import com.qmth.paper.library.common.bean.params.DownLoadPaperParams;
+import com.qmth.paper.library.common.bean.params.DownloadPictureParams;
 import com.qmth.paper.library.common.config.DictionaryConfig;
 import com.qmth.paper.library.common.contant.SystemConstant;
 import com.qmth.paper.library.common.entity.*;
@@ -77,6 +80,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
     private BasicSemesterService basicSemesterService;
     @Resource
     private BasicExamService basicExamService;
+    @Resource
+    private PictureManageService pictureManageService;
 
     @Transactional
     @Override
@@ -279,6 +284,260 @@ public class TaskLogicServiceImpl implements TaskLogicService {
         return map;
     }
 
+    @Override
+    public Map<String, Object> executeDownloadPictureLogic(Map<String, Object> map) {
+        List<File> sourceFileList = new ArrayList<>();
+        File zipFile = null;
+        String rootPath = null;
+        String zipLocalRootPath;
+        List<PaperLibrary> paperLibraryList;
+        try {
+            BasicSchool school = basicSchoolService.getById(Long.valueOf(map.get("schoolId").toString()));
+            TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
+            DownloadPictureParams downLoadPaperParams = JSON.parseObject(tbTask.getRemark(), DownloadPictureParams.class);
+            List<PictureManageDetailResult> studentList = pictureManageService.listPictureResult(downLoadPaperParams);
+            
+            rootPath = fileStoreUtil.buildPath(UploadFileEnum.DOWNLOAD, true, String.valueOf(System.currentTimeMillis()));
+            String dirName = SystemConstant.getUuid() + SystemConstant.ZIP_SUFFIX;
+            zipFile = new File(rootPath + dirName);
+            if (!zipFile.getParentFile().exists()) {
+                boolean dirSuccess = zipFile.getParentFile().mkdirs();
+                if(!dirSuccess){
+                    log.error(String.format("[图片管理],目录创建失败,dirPath:%s",rootPath));
+                    throw ExceptionResultEnum.ERROR.exception("目录创建失败");
+                }
+            }
+
+            //zip文件存放本地根目录
+            zipLocalRootPath = rootPath + File.separator + school.getName();
+            Map<Long, Integer> successMap = new HashMap<>();
+            Map<Long, Integer> errorMap = new HashMap<>();
+
+            for(PictureManageDetailResult student : studentList) {
+                Long studentId = student.getStudentId();
+                successMap.putIfAbsent(studentId, 0);
+                errorMap.putIfAbsent(studentId, 0);
+
+                //考生的所有试卷
+                LambdaQueryWrapper<PaperLibrary> queryWrapper = new LambdaQueryWrapper<>();
+                queryWrapper.eq(PaperLibrary::getStudentId, studentId);
+                paperLibraryList = paperLibraryService.list(queryWrapper);
+
+                ExamStudent examStudent = examStudentService.getById(studentId);
+                String courseNameCode = String.format("%s(%s)", examStudent.getCourseName(), examStudent.getCourseCode());
+                String imagePath = zipLocalRootPath + File.separator + courseNameCode + File.separator + examStudent.getTeachClass();
+
+                for (PaperLibrary paperLibrary : paperLibraryList) {
+                    List<JSONObject> objectList = JSON.parseArray(paperLibrary.getPath(), JSONObject.class);
+                    //下载考生试卷
+                    for (JSONObject jsonObject : objectList) {
+                        try {
+                            File file = paperLibraryCommonService.downloadFile(imagePath, jsonObject.getString(SystemConstant.PATH),
+                                    jsonObject.getString(SystemConstant.UPLOAD_TYPE), jsonObject.getString(SystemConstant.TYPE));
+                            sourceFileList.add(file);
+                            successMap.put(studentId, successMap.get(studentId) + 1);
+                        } catch (Exception e) {
+                            errorMap.put(studentId, errorMap.get(studentId) + 1);
+                        }
+                    }
+                }
+                
+            }
+
+            if (!CollectionUtils.isEmpty(sourceFileList)) {
+                // 生成清单
+                createPictureDownloadExcel(rootPath, studentList, successMap, errorMap);
+
+                Zip4jUtil.zipEncryptFile(zipFile.getPath(), rootPath, SystemConstant.ZIP_ENCRYPT_PWD);
+                String ossDirName = dirName.replaceAll("\\\\", "/");
+                JSONObject jsonObject = new JSONObject();
+                if (fileStoreUtil.isOssStore()) {
+                    fileStoreUtil.fileUpload(ossDirName, zipFile);
+                    jsonObject.put(SystemConstant.PATH, ossDirName);
+                    jsonObject.put(SystemConstant.TYPE, SystemConstant.OSS);
+                } else {
+                    jsonObject.put(SystemConstant.TYPE, SystemConstant.LOCAL);
+                    jsonObject.put(SystemConstant.PATH, rootPath + ossDirName);
+                }
+                jsonObject.put(SystemConstant.UPLOAD_TYPE, UploadFileEnum.FILE);
+                tbTask.setExportFilePath(jsonObject.toJSONString());
+            }
+            map.put(SystemConstant.SIZE, studentList.size());
+        } catch (Exception e) {
+            log.error(SystemConstant.LOG_ERROR, e);
+            if (e instanceof ApiException) {
+                ResultUtil.error((ApiException) e, e.getMessage());
+            } else {
+                ResultUtil.error(e.getMessage());
+            }
+        } finally {
+            if (Objects.nonNull(rootPath)) {
+                ConvertUtil.delFolder(rootPath);
+            }
+            if (Objects.nonNull(dictionaryConfig.sysDomain()) && fileStoreUtil.isOssStore() && Objects.nonNull(zipFile)) {
+                boolean success = zipFile.delete();
+                if(!success) {
+                    log.warn(String.format("[图片管理],临时zip目录删除失败,zipPath:%s",zipFile.getPath()));
+                }
+            }
+        }
+        return map;
+    }
+
+    private void createPictureDownloadExcel(String zipLocalRootPath, List<PictureManageDetailResult> list, Map<Long, Integer> successMap,
+            Map<Long, Integer> errorMap) throws IOException {
+        String fileName = "下载记录清单.xlsx";
+        XSSFWorkbook wb = new XSSFWorkbook();
+        XSSFSheet sheet = wb.createSheet("数据");
+
+        // 表头
+        CellStyle headerStyle = wb.createCellStyle();
+        headerStyle.setAlignment(HorizontalAlignment.CENTER);
+        headerStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+        headerStyle.setBorderRight(BorderStyle.THIN);
+        headerStyle.setRightBorderColor(IndexedColors.BLACK.getIndex());
+        headerStyle.setBorderLeft(BorderStyle.THIN);
+        headerStyle.setLeftBorderColor(IndexedColors.BLACK.getIndex());
+        headerStyle.setBorderTop(BorderStyle.THIN);
+        headerStyle.setTopBorderColor(IndexedColors.BLACK.getIndex());
+        headerStyle.setBorderBottom(BorderStyle.THIN);
+        headerStyle.setBottomBorderColor(IndexedColors.BLACK.getIndex());
+        // 背景颜色
+        headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        headerStyle.setFillForegroundColor(IndexedColors.GREY_80_PERCENT.getIndex());
+        Font font = wb.createFont();
+        font.setFontHeightInPoints((short) 12);
+        font.setFontName("宋体");
+        font.setColor(IndexedColors.WHITE.getIndex());
+        headerStyle.setFont(font);
+
+        // 数据
+        XSSFCellStyle dataStyle = wb.createCellStyle();
+        dataStyle.setAlignment(HorizontalAlignment.CENTER);
+        dataStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+        dataStyle.setBorderRight(BorderStyle.THIN);
+        dataStyle.setRightBorderColor(IndexedColors.BLACK.getIndex());
+        dataStyle.setBorderLeft(BorderStyle.THIN);
+        dataStyle.setLeftBorderColor(IndexedColors.BLACK.getIndex());
+        dataStyle.setBorderTop(BorderStyle.THIN);
+        dataStyle.setTopBorderColor(IndexedColors.BLACK.getIndex());
+        dataStyle.setBorderBottom(BorderStyle.THIN);
+        dataStyle.setBottomBorderColor(IndexedColors.BLACK.getIndex());
+        dataStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        // 背景颜色
+        dataStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
+        font = wb.createFont();
+        font.setFontHeightInPoints((short) 10);
+        font.setFontName("宋体");
+        dataStyle.setFont(font);
+
+        // 锁定样式
+        XSSFCellStyle lockStyle = wb.createCellStyle();
+        lockStyle.setLocked(true);//设置锁定
+
+        // 未锁定样式
+        XSSFCellStyle unlockStyle = wb.createCellStyle();
+        unlockStyle.setLocked(false);//设置未锁定
+
+        XSSFRow headRow = sheet.createRow(0);
+        // 表头
+        String[] fieldsNameList = {"学号", "姓名", "学期", "考试", "扫描批次号", "课程名称(代码)","任课老师", "教学班", "学院", "专业", "班级",  "绑定图片数量(张)", "下载成功数量(页)", "下载失败(页)"};
+        for (int i = 0; i < fieldsNameList.length; i++) {
+            XSSFCell cell = headRow.createCell(i);
+            cell.setCellValue(fieldsNameList[i]);
+            cell.setCellStyle(headerStyle);
+        }
+
+        for (int i = 1; i <= list.size(); i++) {
+            PictureManageDetailResult result = list.get(i - 1);
+            XSSFRow row = sheet.createRow(i);
+
+            XSSFCell cell0 = row.createCell(0);
+            cell0.setCellStyle(lockStyle);
+            cell0.setCellStyle(dataStyle);
+            cell0.setCellValue(result.getStudentCode());
+
+            XSSFCell cell1 = row.createCell(1);
+            cell1.setCellStyle(lockStyle);
+            cell1.setCellStyle(dataStyle);
+            cell1.setCellValue(result.getStudentName());
+
+            XSSFCell cell2 = row.createCell(2);
+            cell2.setCellStyle(lockStyle);
+            cell2.setCellStyle(dataStyle);
+            cell2.setCellValue(result.getSemesterName());
+
+            XSSFCell cell3 = row.createCell(3);
+            cell3.setCellStyle(lockStyle);
+            cell3.setCellStyle(dataStyle);
+            cell3.setCellValue(result.getExamName());
+
+            XSSFCell cell4 = row.createCell(4);
+            cell4.setCellStyle(lockStyle);
+            cell4.setCellStyle(dataStyle);
+            cell4.setCellValue(Objects.isNull(result.getBatchNo()) || "null".equals(result.getBatchNo()) ? "" : result.getBatchNo());
+
+            XSSFCell cell5 = row.createCell(5);
+            cell5.setCellStyle(lockStyle);
+            cell5.setCellStyle(dataStyle);
+            cell5.setCellValue(result.getCourseName()+"("+result.getCourseCode()+")");
+
+            XSSFCell cell6 = row.createCell(6);
+            cell6.setCellStyle(lockStyle);
+            cell6.setCellStyle(dataStyle);
+            cell6.setCellValue(result.getTeacher());
+
+            XSSFCell cell7 = row.createCell(7);
+            cell7.setCellStyle(lockStyle);
+            cell7.setCellStyle(dataStyle);
+            cell7.setCellValue(result.getTeachClass());
+
+            XSSFCell cell8 = row.createCell(8);
+            cell8.setCellStyle(lockStyle);
+            cell8.setCellStyle(dataStyle);
+            cell8.setCellValue(result.getCollegeName());
+
+            XSSFCell cell9 = row.createCell(9);
+            cell9.setCellStyle(lockStyle);
+            cell9.setCellStyle(dataStyle);
+            cell9.setCellValue(result.getMajorName());
+
+            XSSFCell cell10 = row.createCell(10);
+            cell10.setCellStyle(lockStyle);
+            cell10.setCellStyle(dataStyle);
+            cell10.setCellValue(result.getClassName());
+
+            XSSFCell cell11 = row.createCell(11);
+            cell11.setCellStyle(lockStyle);
+            cell11.setCellStyle(dataStyle);
+            cell11.setCellValue(result.getBindCount());
+
+            XSSFCell cell12 = row.createCell(12);
+            cell12.setCellStyle(lockStyle);
+            cell12.setCellStyle(dataStyle);
+            cell12.setCellValue(successMap.get(result.getStudentId()));
+
+            XSSFCell cell13 = row.createCell(13);
+            cell13.setCellStyle(lockStyle);
+            cell13.setCellStyle(dataStyle);
+            cell13.setCellValue(errorMap.get(result.getStudentId()));
+        }
+
+        for (int i = 0; i < fieldsNameList.length; i++) {
+            sheet.autoSizeColumn(i);
+            sheet.setColumnWidth(i, sheet.getColumnWidth(i) * 17 / 13);
+        }
+
+        // sheet添加保护,这个一定要否则光锁定还是可以编辑的
+        sheet.protectSheet(SystemConstant.EXCEL_PROTECT_KEY);
+
+        File file = new File(zipLocalRootPath, fileName);
+        FileOutputStream outputStream = new FileOutputStream(file);
+        wb.write(outputStream);
+        outputStream.close();
+    }
+
+
     /**
      * 生成清单
      *

+ 158 - 0
paper-library-common/src/main/java/com/qmth/paper/library/common/bean/params/DownloadPictureParams.java

@@ -0,0 +1,158 @@
+package com.qmth.paper.library.common.bean.params;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @Description 考生图片批量下载参数
+ */
+public class DownloadPictureParams implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty("学期IDS")
+    private List<Long> semesterIds;
+
+    @ApiModelProperty("考试IDS")
+    private List<Long> examIds;
+
+    @ApiModelProperty("课程代码")
+    private List<String> courseCodes;
+
+    @ApiModelProperty("学院")
+    private List<String> collegeNames;
+
+    @ApiModelProperty("专业")
+    private List<String> majorNames;
+
+    @ApiModelProperty("班级")
+    private List<String> classNames;
+
+    @ApiModelProperty("任课老师")
+    private String teacher;
+
+    @ApiModelProperty("教学班")
+    private String teachClass;
+
+    @ApiModelProperty("姓名或学号")
+    private String param;
+
+    @ApiModelProperty("成绩(小)")
+    private Double minScore;
+
+    @ApiModelProperty("成绩(大)")
+    private Double maxScore;
+
+    @ApiModelProperty("大于、等于、小于、不等于")
+    private String pictureSymbol;
+
+    @ApiModelProperty("图片张数")
+    private Integer pictureCount;
+
+    public List<Long> getSemesterIds() {
+        return semesterIds;
+    }
+
+    public void setSemesterIds(List<Long> semesterIds) {
+        this.semesterIds = semesterIds;
+    }
+
+    public List<Long> getExamIds() {
+        return examIds;
+    }
+
+    public void setExamIds(List<Long> examIds) {
+        this.examIds = examIds;
+    }
+
+    public List<String> getCourseCodes() {
+        return courseCodes;
+    }
+
+    public void setCourseCodes(List<String> courseCodes) {
+        this.courseCodes = courseCodes;
+    }
+
+    public List<String> getCollegeNames() {
+        return collegeNames;
+    }
+
+    public void setCollegeNames(List<String> collegeNames) {
+        this.collegeNames = collegeNames;
+    }
+
+    public List<String> getMajorNames() {
+        return majorNames;
+    }
+
+    public void setMajorNames(List<String> majorNames) {
+        this.majorNames = majorNames;
+    }
+
+    public List<String> getClassNames() {
+        return classNames;
+    }
+
+    public void setClassNames(List<String> classNames) {
+        this.classNames = classNames;
+    }
+
+    public String getTeacher() {
+        return teacher;
+    }
+
+    public void setTeacher(String teacher) {
+        this.teacher = teacher;
+    }
+
+    public String getTeachClass() {
+        return teachClass;
+    }
+
+    public void setTeachClass(String teachClass) {
+        this.teachClass = teachClass;
+    }
+
+    public String getParam() {
+        return param;
+    }
+
+    public void setParam(String param) {
+        this.param = param;
+    }
+
+    public Double getMinScore() {
+        return minScore;
+    }
+
+    public void setMinScore(Double minScore) {
+        this.minScore = minScore;
+    }
+
+    public Double getMaxScore() {
+        return maxScore;
+    }
+
+    public void setMaxScore(Double maxScore) {
+        this.maxScore = maxScore;
+    }
+
+    public String getPictureSymbol() {
+        return pictureSymbol;
+    }
+
+    public void setPictureSymbol(String pictureSymbol) {
+        this.pictureSymbol = pictureSymbol;
+    }
+
+    public Integer getPictureCount() {
+        return pictureCount;
+    }
+
+    public void setPictureCount(Integer pictureCount) {
+        this.pictureCount = pictureCount;
+    }
+
+}

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

@@ -12,7 +12,9 @@ import java.util.Objects;
 public enum TaskTypeEnum {
     ORG_IMPORT("导入组织架构"),
     USER_IMPORT("导入用户"),
-    PAPER_DOWNLOAD("批量下载");
+    PAPER_DOWNLOAD("批量下载"),
+    PICTURE_DOWNLOAD("图片下载");
+
 
     private String title;
 

+ 25 - 3
paper-library/src/main/java/com/qmth/paper/library/api/PictureManageController.java

@@ -1,13 +1,21 @@
 package com.qmth.paper.library.api;
 
+import com.alibaba.fastjson.JSON;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.paper.library.business.bean.result.EditResult;
 import com.qmth.paper.library.business.service.PaperLibraryService;
 import com.qmth.paper.library.business.service.PictureManageService;
+import com.qmth.paper.library.business.templete.execute.AsyncDownloadPictureService;
+import com.qmth.paper.library.common.bean.params.DownloadPictureParams;
 import com.qmth.paper.library.common.contant.ApiPrefixConstant;
 import com.qmth.paper.library.common.contant.SystemConstant;
+import com.qmth.paper.library.common.entity.SysUser;
+import com.qmth.paper.library.common.entity.TBTask;
+import com.qmth.paper.library.common.enums.TaskTypeEnum;
+import com.qmth.paper.library.common.service.TBTaskService;
 import com.qmth.paper.library.common.util.Result;
 import com.qmth.paper.library.common.util.ResultUtil;
+import com.qmth.paper.library.common.util.ServletUtil;
 import io.swagger.annotations.*;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -20,6 +28,8 @@ import javax.annotation.Resource;
 import javax.validation.constraints.Max;
 import javax.validation.constraints.Min;
 import java.util.List;
+import java.util.Map;
+import java.util.Objects;
 
 /**
  * @Description 图片管理控制类
@@ -36,6 +46,12 @@ public class PictureManageController {
     @Resource
     private PaperLibraryService paperLibraryService;
 
+    @Resource
+    private TBTaskService tbTaskService;
+
+    @Resource
+    private AsyncDownloadPictureService asyncDownloadPictureService;
+
     @ApiOperation(value = "分页查询")
     @PostMapping("/page")
     @ApiResponses({ @ApiResponse(code = 200, message = "查询成功", response = Result.class) })
@@ -79,9 +95,15 @@ public class PictureManageController {
     @ApiOperation(value = "下载图片异步")
     @PostMapping("/download")
     @ApiResponses({ @ApiResponse(code = 200, message = "下载成功", response = EditResult.class) })
-    public Result download() {
-        //TODO 下载图片
-        return ResultUtil.ok();
+    public Result download(DownloadPictureParams params) {
+        String pictureParams = JSON.toJSONString(params);
+        Map<String, Object> map = tbTaskService.saveTask(TaskTypeEnum.PICTURE_DOWNLOAD, pictureParams, (SysUser) ServletUtil.getRequestUser());
+        Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
+        map.put("schoolId", schoolId);
+        //异步任务 TODO 待优化
+        asyncDownloadPictureService.exportTask(map);
+        TBTask tbTask = Objects.nonNull(map.get(SystemConstant.TASK)) ? (TBTask) map.get(SystemConstant.TASK) : null;
+        return Objects.nonNull(tbTask) ? ResultUtil.ok(new EditResult(tbTask.getId())) : ResultUtil.error("创建任务失败");
     }
 
 }