Bläddra i källkod

入库审核 样本下载

caozixuan 4 år sedan
förälder
incheckning
cd4c3170dc

+ 0 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/AsyncExaminationImportTemplateService.java

@@ -14,7 +14,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
-import javax.annotation.Resource;
 import java.io.InputStream;
 import java.io.InputStream;
 import java.text.MessageFormat;
 import java.text.MessageFormat;
 import java.util.Map;
 import java.util.Map;

+ 37 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/AsyncTaskReviewSampleExportService.java

@@ -1,19 +1,31 @@
 package com.qmth.distributed.print.business.templete.execute;
 package com.qmth.distributed.print.business.templete.execute;
 
 
+import com.qmth.boot.api.exception.ApiException;
+import com.qmth.distributed.print.business.entity.TBTask;
+import com.qmth.distributed.print.business.enums.TaskResultEnum;
+import com.qmth.distributed.print.business.enums.TaskStatusEnum;
+import com.qmth.distributed.print.business.enums.TaskTypeEnum;
 import com.qmth.distributed.print.business.templete.export.AsyncExportTaskTemplete;
 import com.qmth.distributed.print.business.templete.export.AsyncExportTaskTemplete;
 import com.qmth.distributed.print.business.templete.service.TaskLogicService;
 import com.qmth.distributed.print.business.templete.service.TaskLogicService;
+import com.qmth.distributed.print.common.contant.SpringContextHolder;
+import com.qmth.distributed.print.common.contant.SystemConstant;
 import com.qmth.distributed.print.common.util.Result;
 import com.qmth.distributed.print.common.util.Result;
+import com.qmth.distributed.print.common.util.ResultUtil;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
+import java.text.MessageFormat;
 import java.util.Map;
 import java.util.Map;
+import java.util.StringJoiner;
 
 
 /**
 /**
  * @Description: 异步任务-命题任务审核样本导出
  * @Description: 异步任务-命题任务审核样本导出
  * @Author: CaoZixuan
  * @Author: CaoZixuan
  * @Date: 2021-04-19
  * @Date: 2021-04-19
  */
  */
+@Service
 public class AsyncTaskReviewSampleExportService extends AsyncExportTaskTemplete {
 public class AsyncTaskReviewSampleExportService extends AsyncExportTaskTemplete {
     @Resource
     @Resource
     TaskLogicService taskLogicService;
     TaskLogicService taskLogicService;
@@ -23,6 +35,30 @@ public class AsyncTaskReviewSampleExportService extends AsyncExportTaskTemplete
 
 
     @Override
     @Override
     public Result exportTask(Map<String, Object> map) throws Exception {
     public Result exportTask(Map<String, Object> map) throws Exception {
-        return null;
+        TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
+
+        StringJoiner stringJoinerSummary = new StringJoiner("\n")
+                .add(MessageFormat.format("{0}{1}{2}", FORMAT_TIME, BEGIN_TITLE, OBJ_TITLE));
+        tbTask.setStatus(TaskStatusEnum.RUNNING);
+
+        try {
+            TaskLogicService taskLogicService = SpringContextHolder.getBean(TaskLogicService.class);
+            Map<String, Object> result = taskLogicService.executeExportSampleLogic(map);
+            stringJoinerSummary.add(MessageFormat.format("{0}{1}{2}{3}", FORMAT_TIME, FINISH_TITLE, Long.valueOf(String.valueOf(result.get("count"))), FINISH_SIZE));
+            tbTask.setResult(TaskResultEnum.SUCCESS);
+        } catch (Exception e) {
+            log.error("请求出错", e);
+            stringJoinerSummary.add(MessageFormat.format("{0}{1}{2}{3}", FORMAT_TIME, 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 {//生成txt文件
+            tbTask.setSummary(stringJoinerSummary.toString());
+            super.createTxt(tbTask);
+        }
+        return ResultUtil.ok();
     }
     }
 }
 }

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

@@ -38,4 +38,11 @@ public interface TaskLogicService {
      * @throws IOException
      * @throws IOException
      */
      */
     public Map<String, Object> executeDownloadPdfLogic(Map<String, Object> map) throws Exception;
     public Map<String, Object> executeDownloadPdfLogic(Map<String, Object> map) throws Exception;
+
+    /**
+     * 处理导出命题任务审核文件
+     * @param map
+     * @return
+     */
+    public Map<String,Object> executeExportSampleLogic(Map<String,Object> map) throws IOException;
 }
 }

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

@@ -1,5 +1,6 @@
 package com.qmth.distributed.print.business.templete.service.impl;
 package com.qmth.distributed.print.business.templete.service.impl;
 
 
+import cn.hutool.core.util.ZipUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
@@ -13,6 +14,7 @@ import com.qmth.distributed.print.business.bean.params.ArraysParams;
 import com.qmth.distributed.print.business.bean.params.SerialNumberParams;
 import com.qmth.distributed.print.business.bean.params.SerialNumberParams;
 import com.qmth.distributed.print.business.entity.*;
 import com.qmth.distributed.print.business.entity.*;
 import com.qmth.distributed.print.business.enums.ExamStatusEnum;
 import com.qmth.distributed.print.business.enums.ExamStatusEnum;
+import com.qmth.distributed.print.business.enums.MakeMethodEnum;
 import com.qmth.distributed.print.business.enums.PrintPlanStatusEnum;
 import com.qmth.distributed.print.business.enums.PrintPlanStatusEnum;
 import com.qmth.distributed.print.business.enums.UploadFileEnum;
 import com.qmth.distributed.print.business.enums.UploadFileEnum;
 import com.qmth.distributed.print.business.service.*;
 import com.qmth.distributed.print.business.service.*;
@@ -39,6 +41,7 @@ import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.support.atomic.RedisAtomicLong;
 import org.springframework.data.redis.support.atomic.RedisAtomicLong;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.FileCopyUtils;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import java.io.*;
 import java.io.*;
@@ -103,6 +106,9 @@ public class TaskLogicServiceImpl implements TaskLogicService {
     @Resource
     @Resource
     CreatePdfUtil createPdfUtil;
     CreatePdfUtil createPdfUtil;
 
 
+    @Resource
+    BasicTemplateService basicTemplateService;
+
     @Resource
     @Resource
     RedisTemplate<String, Object> redisTemplate;
     RedisTemplate<String, Object> redisTemplate;
 
 
@@ -597,4 +603,142 @@ public class TaskLogicServiceImpl implements TaskLogicService {
         }
         }
         return map;
         return map;
     }
     }
+
+    @Override
+    @Transactional
+    public Map<String, Object> executeExportSampleLogic(Map<String, Object> map) throws IOException {
+        int count = 0;
+        TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
+        LocalDateTime nowTime = LocalDateTime.now();
+        StringJoiner zipJoiner = new StringJoiner("")
+                .add(SystemConstant.TEMP_FILES_DIR).add(File.separator);
+        StringJoiner dirName = new StringJoiner("")
+                .add(UploadFileEnum.FILE.getTitle()).add(File.separator)
+                .add(String.valueOf(nowTime.getYear())).add(File.separator)
+                .add(String.format("%02d", nowTime.getMonthValue())).add(File.separator)
+                .add(String.format("%02d", nowTime.getDayOfMonth()))
+                .add(File.separator).add(SystemConstant.getUuid()).add(SystemConstant.ZIP_PREFIX);
+        String dirNameTmp = dirName.toString().replaceAll("\\\\", "/");
+        File zipFile = new File(zipJoiner.toString() + dirNameTmp);
+        if (!zipFile.getParentFile().exists()) {
+            zipFile.getParentFile().mkdirs();
+            zipFile.createNewFile();
+        }
+
+        // 跟文件路径
+        String zipLocalRootPath = SystemConstant.TEMP_FILES_DIR + File.separator + System.currentTimeMillis();
+        Long[] ids = (Long[]) map.get("ids");
+        for (Long id : ids) {
+            ExamTask examTask = examTaskService.getById(id);
+            if (Objects.isNull(examTask)){
+                throw ExceptionResultEnum.ERROR.exception("未找到命题任务");
+            }
+            String examTaskSign = examTask.getSchoolId() + "-" + examTask.getCourseName() + "-" + examTask.getPaperNumber();
+            String firstPath = zipLocalRootPath + File.separator + examTaskSign;
+            List<ExamTaskDetail> examTaskDetailList = examTaskDetailService.list(new QueryWrapper<ExamTaskDetail>().lambda().eq(ExamTaskDetail::getExamTaskId,id));
+            if (examTaskDetailList.size() != 1){
+                throw ExceptionResultEnum.ERROR.exception("获取命题任务详情失败 命题任务id : " + id);
+            }
+            ExamTaskDetail examTaskDetail = examTaskDetailList.get(0);
+
+
+            // 处理试卷样品
+            List<Map> paperInfo = JSONObject.parseArray(examTaskDetail.getPaperAttachmentIds(), Map.class);
+            System.out.println("paperInfo = " + JSON.toJSONString(paperInfo));
+            Set<Long> attPaperIds = new HashSet<>();
+            for (Map paperMap : paperInfo) {
+                if (Objects.isNull(paperMap.get("attachmentId"))){
+                    throw ExceptionResultEnum.ERROR.exception("未找到附件id");
+                }
+                Long attachmentId = Long.valueOf(String.valueOf(paperMap.get("attachmentId")));
+                attPaperIds.add(attachmentId);
+            }
+            List<BasicAttachment> paperAttachmentList = basicAttachmentService.listByIds(attPaperIds);
+            if (Objects.nonNull(paperAttachmentList)){
+                for (BasicAttachment paperAttachment : paperAttachmentList) {
+                    JSONObject jsonObject = JSONObject.parseObject(paperAttachment.getPath());
+                    String paperPath = firstPath + File.separator + "试卷" + File.separator + paperAttachment.getName() + paperAttachment.getType();
+                    ossUtil.ossDownload((String) jsonObject.get("path"), paperPath);
+                    count ++;
+                }
+            }
+
+            // 处理审核样品
+            List<Map> confirmInfo = JSONObject.parseArray(examTaskDetail.getPaperConfirmAttachmentIds(), Map.class);
+            System.out.println("confirmInfo = " + JSON.toJSONString(confirmInfo));
+            Set<Long> attConfirmIds = new HashSet<>();
+            for (Map confirmMap : confirmInfo) {
+                if (Objects.isNull(confirmMap.get("attachmentId"))){
+                    throw ExceptionResultEnum.ERROR.exception("未找到附件id");
+                }
+                Long attachmentId = Long.valueOf(String.valueOf(confirmMap.get("attachmentId")));
+                attConfirmIds.add(attachmentId);
+            }
+            List<BasicAttachment> confirmAttachmentList = basicAttachmentService.listByIds(attConfirmIds);
+            if (Objects.nonNull(confirmAttachmentList)){
+                for (BasicAttachment confirmAttachment : confirmAttachmentList) {
+                    JSONObject jsonObject = JSONObject.parseObject(confirmAttachment.getPath());
+                    String confirmPath = firstPath + File.separator + "审核样本" + File.separator + confirmAttachment.getName() + confirmAttachment.getType();
+                    ossUtil.ossDownload((String) jsonObject.get("path"), confirmPath);
+                    count ++;
+                }
+            }
+
+            // 处理题卡
+            Long cardId = examTaskDetail.getCardId();
+            ExamCard examCard = examCardService.getById(cardId);
+            if (Objects.isNull(examCard)){
+                throw ExceptionResultEnum.ERROR.exception("找不到答题卡 cardId = " + cardId);
+            }
+            MakeMethodEnum makeMethodEnum = examCard.getMakeMethod();
+            if (MakeMethodEnum.SELECT.equals(makeMethodEnum)){
+                Long templateId = examCard.getTemplateId();
+                if (templateId == null || templateId == 0){
+                    throw ExceptionResultEnum.ERROR.exception("找不到题卡对应的模板 templateId = " + templateId);
+                }
+                BasicTemplate basicTemplate = basicTemplateService.getById(templateId);
+                if (Objects.isNull(basicTemplate)){
+                    throw ExceptionResultEnum.ERROR.exception("找不到模板信息 templateId = " + templateId);
+                }
+                Long attachmentId = basicTemplate.getAttachmentId();
+                if (attachmentId == null || attachmentId == 0){
+                    throw ExceptionResultEnum.ERROR.exception("找不到模板对应的附件 templateId = " + templateId);
+                }
+                BasicAttachment cardAttachment = basicAttachmentService.getById(attachmentId);
+                if (Objects.isNull(cardAttachment)){
+                    throw ExceptionResultEnum.ERROR.exception("找不到附件 attachmentId = " + attachmentId);
+                }
+                JSONObject jsonObject = JSONObject.parseObject(cardAttachment.getPath());
+                String cardPath = firstPath + File.separator + "题卡" + File.separator + cardAttachment.getName() + cardAttachment.getType();
+                ossUtil.ossDownload((String) jsonObject.get("path"), cardPath);
+                count ++;
+            }else {
+                List<ExamCardDetail> examCardDetailList = examCardDetailService.list(new QueryWrapper<ExamCardDetail>().lambda().eq(ExamCardDetail::getCardId,cardId));
+                if (examCardDetailList.size() != 1){
+                    throw ExceptionResultEnum.ERROR.exception("题卡明细信息异常 card_id = " + cardId);
+                }
+                ExamCardDetail examCardDetail = examCardDetailService.getByCardId(cardId);
+                String htmlContent = examCardDetail.getHtmlContent();
+                byte[] bytes = htmlContent.getBytes();
+                String cardPath = firstPath + File.separator + "题卡" + File.separator + examCard.getTitle() + SystemConstant.HTML_PREFIX;
+                File localFile = new File(cardPath);
+                if (!localFile.getParentFile().exists()) {
+                    localFile.getParentFile().mkdirs();
+                }
+                FileCopyUtils.copy(bytes, localFile);
+                count ++;
+            }
+        }
+        ZipUtil.zip(zipLocalRootPath, zipFile.getPath(), true);
+        ossUtil.ossUpload(dirNameTmp, zipFile, BinaryUtil.toBase64String(HexUtils.decodeHex(DigestUtils.md5Hex(new FileInputStream(zipFile)))));
+        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",count);
+        return map;
+    }
 }
 }

+ 64 - 21
distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/ConvertUtil.java

@@ -5,7 +5,6 @@ import org.apache.poi.hssf.usermodel.HSSFDateUtil;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.CellType;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.data.redis.support.atomic.RedisAtomicInteger;
 import org.springframework.data.redis.support.atomic.RedisAtomicLong;
 import org.springframework.data.redis.support.atomic.RedisAtomicLong;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 
 
@@ -44,7 +43,7 @@ public class ConvertUtil {
         return new ByteArrayInputStream(baos.toByteArray());
         return new ByteArrayInputStream(baos.toByteArray());
     }
     }
 
 
-    public static void inputStream2File (InputStream is, File file) throws IOException {
+    public static void inputStream2File(InputStream is, File file) throws IOException {
         OutputStream os = null;
         OutputStream os = null;
         try {
         try {
             os = new FileOutputStream(file);
             os = new FileOutputStream(file);
@@ -62,14 +61,15 @@ public class ConvertUtil {
 
 
     /**
     /**
      * 转换,解析时间
      * 转换,解析时间
+     *
      * @param date 日期(考试日期,必须是同一天     example: 2021-04-13)
      * @param date 日期(考试日期,必须是同一天     example: 2021-04-13)
      * @param time 时间(考试时间,必须使用‘-’隔开  example: 18:00-20:00)
      * @param time 时间(考试时间,必须使用‘-’隔开  example: 18:00-20:00)
-     * @return 开始时间和结束时间键值对("startTime":1618308000000 ,"endTime":1618315200000)
+     * @return 开始时间和结束时间键值对(" startTime " : 1618308000000, " endTime " : 1618315200000)
      */
      */
-    public static Map<String,Object> analyzeStartAndEndTime(String date,String time){
-        time = time.replaceAll(" ",""); // 去掉所有空格
+    public static Map<String, Object> analyzeStartAndEndTime(String date, String time) {
+        time = time.replaceAll(" ", ""); // 去掉所有空格
         String[] arr = time.split("-");
         String[] arr = time.split("-");
-        if (arr.length != 2){
+        if (arr.length != 2) {
             // 不能使用'-'拆分成两个时间的报错
             // 不能使用'-'拆分成两个时间的报错
             throw ExceptionResultEnum.ERROR.exception("提供的时间格式异常 时间 : " + time + " 应该使用如下的格式 '考试时间' :18:00-20:00");
             throw ExceptionResultEnum.ERROR.exception("提供的时间格式异常 时间 : " + time + " 应该使用如下的格式 '考试时间' :18:00-20:00");
         }
         }
@@ -77,7 +77,7 @@ public class ConvertUtil {
         String endTimeStr = date + " " + arr[1];
         String endTimeStr = date + " " + arr[1];
         long startTime = DateDisposeUtils.parseDate(startTimeStr).getTime();
         long startTime = DateDisposeUtils.parseDate(startTimeStr).getTime();
         long endTime = DateDisposeUtils.parseDate(endTimeStr).getTime();
         long endTime = DateDisposeUtils.parseDate(endTimeStr).getTime();
-        if (startTime >= endTime){
+        if (startTime >= endTime) {
             System.out.println("开始时间要小于结束时间 时间: " + time);
             System.out.println("开始时间要小于结束时间 时间: " + time);
         }
         }
 
 
@@ -85,19 +85,20 @@ public class ConvertUtil {
         System.out.println("开始时间 : " + startTime + " 结束时间 : " + endTime);
         System.out.println("开始时间 : " + startTime + " 结束时间 : " + endTime);
         System.out.println(new Date().getTime());
         System.out.println(new Date().getTime());
 
 
-        Map<String,Object> timeMap = new HashMap<>();
-        timeMap.put("startTime",startTime);
-        timeMap.put("endTime",endTime);
+        Map<String, Object> timeMap = new HashMap<>();
+        timeMap.put("startTime", startTime);
+        timeMap.put("endTime", endTime);
         return timeMap;
         return timeMap;
     }
     }
 
 
     /**
     /**
      * 根据开始时间和结束时间解析日期和时间
      * 根据开始时间和结束时间解析日期和时间
+     *
      * @param startTime 开始时间
      * @param startTime 开始时间
-     * @param endTime 结束时间
+     * @param endTime   结束时间
      * @return 键值对
      * @return 键值对
      */
      */
-    public static Map<String,Object> analyzeDateAndTime(Long startTime,Long endTime){
+    public static Map<String, Object> analyzeDateAndTime(Long startTime, Long endTime) {
         String tmpDateStart;
         String tmpDateStart;
         String tmpDateEnd;
         String tmpDateEnd;
         String tmpTimeStart;
         String tmpTimeStart;
@@ -106,7 +107,7 @@ public class ConvertUtil {
         String time;
         String time;
 
 
 
 
-        Map<String,Object> map = new HashMap<>();
+        Map<String, Object> map = new HashMap<>();
 
 
         Calendar calendar = Calendar.getInstance();
         Calendar calendar = Calendar.getInstance();
         calendar.setTime(new Date(startTime));
         calendar.setTime(new Date(startTime));
@@ -117,14 +118,14 @@ public class ConvertUtil {
         tmpDateEnd = (new SimpleDateFormat("yyyy-MM-dd")).format(calendar.getTime());
         tmpDateEnd = (new SimpleDateFormat("yyyy-MM-dd")).format(calendar.getTime());
         tmpTimeEnd = (new SimpleDateFormat("HH:mm:ss")).format(calendar.getTime());
         tmpTimeEnd = (new SimpleDateFormat("HH:mm:ss")).format(calendar.getTime());
 
 
-        if (!tmpDateStart.equals(tmpDateEnd)){
+        if (!tmpDateStart.equals(tmpDateEnd)) {
             throw ExceptionResultEnum.ERROR.exception("开始时间和结束时间不在同一天");
             throw ExceptionResultEnum.ERROR.exception("开始时间和结束时间不在同一天");
         }
         }
 
 
         date = tmpDateStart;
         date = tmpDateStart;
         time = tmpTimeStart + " - " + tmpTimeEnd;
         time = tmpTimeStart + " - " + tmpTimeEnd;
-        map.put("date",date);
-        map.put("time",time);
+        map.put("date", date);
+        map.put("time", time);
 
 
         return map;
         return map;
     }
     }
@@ -132,14 +133,15 @@ public class ConvertUtil {
 
 
     /**
     /**
      * 获取递增序列号
      * 获取递增序列号
+     *
      * @param prefix 前缀
      * @param prefix 前缀
-     * @param model 模块
-     * @param digit 补齐位数
+     * @param model  模块
+     * @param digit  补齐位数
      * @return 序列号
      * @return 序列号
      */
      */
-    public String getIncre(String prefix,String model,int digit) {
+    public String getIncre(String prefix, String model, int digit) {
         StringBuilder temp = new StringBuilder();
         StringBuilder temp = new StringBuilder();
-        for (int i = 0;i < digit;i ++){
+        for (int i = 0; i < digit; i++) {
             temp.append("0");
             temp.append("0");
         }
         }
         //序列号前缀加特定标识,如系统模块名之类的 防止重复
         //序列号前缀加特定标识,如系统模块名之类的 防止重复
@@ -164,10 +166,11 @@ public class ConvertUtil {
 
 
     /**
     /**
      * 解析excel单元格类型
      * 解析excel单元格类型
+     *
      * @param cell 单元格
      * @param cell 单元格
      * @return 转换成字符串后的值
      * @return 转换成字符串后的值
      */
      */
-    public static String analyzeExcelCellValue(Cell cell){
+    public static String analyzeExcelCellValue(Cell cell) {
         String cellValue;
         String cellValue;
         CellType cellType = cell.getCellTypeEnum();
         CellType cellType = cell.getCellTypeEnum();
         switch (cellType) {
         switch (cellType) {
@@ -212,4 +215,44 @@ public class ConvertUtil {
         }
         }
         return cellValue;
         return cellValue;
     }
     }
+
+    public static void delFolder(String folderPath) {
+        try {
+            delAllFile(folderPath); //删除完里面所有内容
+            String filePath = folderPath;
+            filePath = filePath.toString();
+            java.io.File myFilePath = new java.io.File(filePath);
+            myFilePath.delete(); //删除空文件夹
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public static void delAllFile(String path) {
+        boolean flag = false;
+        File file = new File(path);
+        if (!file.exists()) {
+            return;
+        }
+        if (!file.isDirectory()) {
+            return;
+        }
+        String[] tempList = file.list();
+        File temp = null;
+        for (int i = 0; i < Objects.requireNonNull(tempList).length; i++) {
+            if (path.endsWith(File.separator)) {
+                temp = new File(path + tempList[i]);
+            } else {
+                temp = new File(path + File.separator + tempList[i]);
+            }
+            if (temp.isFile()) {
+                temp.delete();
+            }
+            if (temp.isDirectory()) {
+                delAllFile(path + "/" + tempList[i]);//先删除文件夹里面的文件
+                delFolder(path + "/" + tempList[i]);//再删除空文件夹
+                flag = true;
+            }
+        }
+    }
 }
 }

+ 18 - 11
distributed-print/src/main/java/com/qmth/distributed/print/api/ExamTaskController.java

@@ -9,15 +9,12 @@ import com.qmth.boot.api.exception.ApiException;
 import com.qmth.distributed.print.business.bean.dto.*;
 import com.qmth.distributed.print.business.bean.dto.*;
 import com.qmth.distributed.print.business.bean.params.ArraysParams;
 import com.qmth.distributed.print.business.bean.params.ArraysParams;
 import com.qmth.distributed.print.business.bean.params.PrintPlanParams;
 import com.qmth.distributed.print.business.bean.params.PrintPlanParams;
-import com.qmth.distributed.print.business.entity.BasicAttachment;
-import com.qmth.distributed.print.business.entity.ExamTask;
-import com.qmth.distributed.print.business.entity.ExamTaskDetail;
-import com.qmth.distributed.print.business.entity.ExamTaskReviewLog;
+import com.qmth.distributed.print.business.bean.result.EditResult;
+import com.qmth.distributed.print.business.entity.*;
+import com.qmth.distributed.print.business.enums.TaskTypeEnum;
 import com.qmth.distributed.print.business.enums.UploadFileEnum;
 import com.qmth.distributed.print.business.enums.UploadFileEnum;
-import com.qmth.distributed.print.business.service.BasicAttachmentService;
-import com.qmth.distributed.print.business.service.ExamTaskDetailService;
-import com.qmth.distributed.print.business.service.ExamTaskReviewLogService;
-import com.qmth.distributed.print.business.service.ExamTaskService;
+import com.qmth.distributed.print.business.service.*;
+import com.qmth.distributed.print.business.templete.execute.AsyncTaskReviewSampleExportService;
 import com.qmth.distributed.print.business.util.ServletUtil;
 import com.qmth.distributed.print.business.util.ServletUtil;
 import com.qmth.distributed.print.common.contant.SystemConstant;
 import com.qmth.distributed.print.common.contant.SystemConstant;
 import com.qmth.distributed.print.common.enums.ExceptionResultEnum;
 import com.qmth.distributed.print.common.enums.ExceptionResultEnum;
@@ -31,12 +28,14 @@ import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartFile;
 
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import javax.validation.Valid;
 import java.io.IOException;
 import java.io.IOException;
 import java.util.Collections;
 import java.util.Collections;
 import java.util.List;
 import java.util.List;
+import java.util.Map;
 import java.util.Objects;
 import java.util.Objects;
 
 
 /**
 /**
@@ -65,6 +64,11 @@ public class ExamTaskController {
     @Autowired
     @Autowired
     private BasicAttachmentService basicAttachmentService;
     private BasicAttachmentService basicAttachmentService;
 
 
+    @Resource
+    private TBTaskService tbTaskService;
+
+    @Resource
+    private AsyncTaskReviewSampleExportService asyncTaskReviewSampleExportService;
     /**
     /**
      * 查询
      * 查询
      *
      *
@@ -372,13 +376,16 @@ public class ExamTaskController {
 
 
     @ApiOperation(value = "导出审核样本")
     @ApiOperation(value = "导出审核样本")
     @RequestMapping(value = "/review_export", method = RequestMethod.POST)
     @RequestMapping(value = "/review_export", method = RequestMethod.POST)
-    public Result taskReviewExport(@Valid @RequestBody ArraysParams arraysParams, BindingResult bindingResult) {
+    public Result taskReviewExport(@Valid @RequestBody ArraysParams arraysParams, BindingResult bindingResult) throws Exception {
         if (bindingResult.hasErrors()) {
         if (bindingResult.hasErrors()) {
             return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
             return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
         }
         }
         Long[] ids = arraysParams.getIds();
         Long[] ids = arraysParams.getIds();
-        // todo 导出
-        return ResultUtil.ok(true);
+        Map<String, Object> map = tbTaskService.saveTask(TaskTypeEnum.SAMPLE_EXPORT);
+        map.put("ids",ids);
+        asyncTaskReviewSampleExportService.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("创建任务失败");
     }
     }
 
 
     /**
     /**