Browse Source

考务导入接口

wangliang 5 years ago
parent
commit
dfd814aabd

+ 0 - 4
themis-backend/src/main/java/com/qmth/themis/backend/api/TEExamStudentController.java

@@ -150,8 +150,6 @@ public class TEExamStudentController {
         if (Objects.isNull(examId) || Objects.equals(examId, "")) {
             throw new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL);
         }
-        log.info("开始考生导入");
-        long start = System.currentTimeMillis();
         Map<String, Object> mapParameter = BackendConstant.getAttachmentEnv(type);
         TBAttachment tbAttachment = null;
         TBTaskHistory tbTaskHistory = null;
@@ -204,8 +202,6 @@ public class TEExamStudentController {
             MqDto mqDto = new MqDto(dictionaryConfig.mqConfigDomain().getTaskTopic(), dictionaryConfig.mqConfigDomain().getTaskTopicExamStudentTag(), transMap, MqEnum.TASK_LOG, String.valueOf(tbTaskHistory.getId()), tbUser.getName());
             mqDtoService.assembleSendOneWayMsg(mqDto);
             //mq发送消息end
-            long end = System.currentTimeMillis();
-            log.info("考生导入结束,============耗时============:{}秒", (end - start) / 1000);
         } catch (Exception e) {
             e.printStackTrace();
             if (Objects.nonNull(tbAttachment)) {

+ 2 - 0
themis-business/src/main/java/com/qmth/themis/business/constant/SystemConstant.java

@@ -71,6 +71,8 @@ public class SystemConstant {
      */
     public static final String REDIS_LOCK_MQ_PREFIX = "lock:mq:";
     public static final long REDIS_LOCK_MQ_TIME_OUT = 1L;
+    public static final String REDIS_CACHE = "cache:task:";
+    public static final long REDIS_CACHE_TIME_OUT = 30L;
     /**
      * redis过期时间
      */

+ 0 - 126
themis-business/src/main/java/com/qmth/themis/business/forkjoin/ForkJoinTask.java

@@ -1,126 +0,0 @@
-package com.qmth.themis.business.forkjoin;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.google.gson.Gson;
-import com.qmth.themis.business.constant.SpringContextHolder;
-import com.qmth.themis.business.constant.SystemConstant;
-import com.qmth.themis.business.dto.ExamStudentDtoImport;
-import com.qmth.themis.business.entity.*;
-import com.qmth.themis.business.enums.RoleEnum;
-import com.qmth.themis.business.enums.TaskTypeExecEnum;
-import com.qmth.themis.business.service.TBTaskHistoryService;
-import com.qmth.themis.business.service.TBUserRoleService;
-import com.qmth.themis.business.service.TEExamStudentService;
-import com.qmth.themis.business.service.TEStudentService;
-import com.qmth.themis.common.exception.BusinessException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.math.BigDecimal;
-import java.util.*;
-import java.util.concurrent.RecursiveTask;
-
-public class ForkJoinTask extends RecursiveTask<List<TEExamStudent>> {
-    private final static Logger log = LoggerFactory.getLogger(ForkJoinTask.class);
-
-    private int threshold = 500, start, end;//阀值,开始,结束,类型
-    private List<Object> examStudentDtoImportList;
-    private Map<String, Object> map = null;
-
-    public ForkJoinTask() {
-
-    }
-
-    public ForkJoinTask(int threshold, int start, int end, List<Object> examStudentDtoImportList, Map<String, Object> map) {
-        this.threshold = threshold;
-        this.start = start;
-        this.end = end;
-        this.examStudentDtoImportList = examStudentDtoImportList;
-        this.map = map;
-    }
-
-    @Override
-    @Transactional
-    protected List<TEExamStudent> compute() {
-        Gson gson = new Gson();
-        List<TEExamStudent> teExamStudentList = new ArrayList<>();
-        Map tbTaskHistoryMap = (Map) map.get("tbTaskHistory");
-        tbTaskHistoryMap = SystemConstant.timeTransform(tbTaskHistoryMap);
-        TBTaskHistory tbTaskHistory = gson.fromJson(gson.toJson(tbTaskHistoryMap), TBTaskHistory.class);
-        Long examId = Long.parseLong(String.valueOf(map.get("examId")));
-        Long orgId = Long.parseLong(String.valueOf(map.get("orgId")));
-        Long createId = Long.parseLong(String.valueOf(map.get("createId")));
-        Map<String, TEExamActivity> teExamActivityMap = (Map<String, TEExamActivity>) map.get("teExamActivityMap");
-        if ((end - start) <= threshold) {
-            TEExamStudentService teExamStudentService = SpringContextHolder.getBean(TEExamStudentService.class);
-            TBTaskHistoryService tbTaskHistoryService = SpringContextHolder.getBean(TBTaskHistoryService.class);
-            TEStudentService teStudentService = SpringContextHolder.getBean(TEStudentService.class);
-            TBUserRoleService tbUserRoleService = SpringContextHolder.getBean(TBUserRoleService.class);
-            for (int i = start; i <= end; i++) {
-                ExamStudentDtoImport examStudentDtoImport = (ExamStudentDtoImport) examStudentDtoImportList.get(i);
-                Map m = (Map) teExamActivityMap.get(examStudentDtoImport.getExamActivityCode());
-                m = SystemConstant.timeTransform(m);
-                TEExamActivity teExamActivity = gson.fromJson(gson.toJson(m), TEExamActivity.class);
-                if (Objects.isNull(teExamActivity)) {
-                    throw new BusinessException("没有" + examStudentDtoImport.getExamActivityCode() + "的考场");
-                }
-                //先根据证件号+科目代码查询考生是否存在,存在则更新,不存在则插入
-                QueryWrapper<TEExamStudent> teExamStudentQueryWrapper = new QueryWrapper<>();
-                teExamStudentQueryWrapper.lambda().eq(TEExamStudent::getIdentity, examStudentDtoImport.getIdentity()).eq(TEExamStudent::getCourseCode, examStudentDtoImport.getCourseCode());
-                TEExamStudent teExamStudent = teExamStudentService.getOne(teExamStudentQueryWrapper);
-                //如果为空则插入考生数据,插入考生前先插入学生档案数据
-                if (Objects.isNull(teExamStudent)) {
-                    //先插入学生档案数据
-                    TEStudent teStudent = new TEStudent(orgId, examStudentDtoImport.getIdentity(), examStudentDtoImport.getName(), createId);
-                    teStudentService.save(teStudent);
-
-                    //插入用户角色关系
-                    TBUserRole tbUserRole = new TBUserRole(teStudent.getId(), RoleEnum.STUDENT.name());
-                    tbUserRoleService.save(tbUserRole);
-
-                    teExamStudent = gson.fromJson(gson.toJson(examStudentDtoImport), TEExamStudent.class);
-                    teExamStudent.setExamId(examId);
-                    teExamStudent.setExamActivityId(teExamActivity.getId());
-                    teExamStudent.setStudentId(teStudent.getId());
-                    teExamStudent.setCreateId(createId);
-                } else {
-                    teExamStudent.setUpdateId(createId);
-                    teExamStudent.setName(examStudentDtoImport.getName());
-                    teExamStudent.setCourseName(examStudentDtoImport.getCourseName());
-                    teExamStudent.setGrade(examStudentDtoImport.getGrade());
-                    teExamStudent.setClassNo(examStudentDtoImport.getClassNo());
-                    teExamStudent.setRoomCode(examStudentDtoImport.getRoomCode());
-                    teExamStudent.setRoomName(examStudentDtoImport.getRoomName());
-                    teExamStudent.setExamActivityId(teExamActivity.getId());
-                }
-                teExamStudentList.add(teExamStudent);
-            }
-            BigDecimal bigDecimal = new BigDecimal(100);
-            int size = examStudentDtoImportList.size();
-            BigDecimal endBigDecimal = new BigDecimal(teExamStudentList.size());
-            BigDecimal progress = new BigDecimal(Double.valueOf(endBigDecimal.divide(new BigDecimal(size), 2, BigDecimal.ROUND_HALF_UP).multiply(bigDecimal).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue())).setScale(0, BigDecimal.ROUND_HALF_UP);
-            teExamStudentService.saveOrUpdateBatch(teExamStudentList);
-            if (progress.intValue() == 100) {
-                tbTaskHistory.setStatus(TaskTypeExecEnum.finish.ordinal());
-                tbTaskHistory.setSummary("共处理了" + size + "条数据");
-                tbTaskHistory.setFinishTime(new Date());
-            } else {
-                tbTaskHistory.setStatus(TaskTypeExecEnum.running.ordinal());
-                tbTaskHistory.setSummary("正在处理第" + start + "条至" + end + "条数据");
-            }
-            tbTaskHistory.setProgress(progress.doubleValue());
-            tbTaskHistoryService.updateById(tbTaskHistory);
-            log.info("start:{},end:{}", start, end);
-        } else {
-            // 将大任务分解成两个小任务
-            int middle = (start + end) / 2;
-            ForkJoinTask left = new ForkJoinTask(threshold, start, middle, examStudentDtoImportList, map);
-            ForkJoinTask right = new ForkJoinTask(threshold, middle + 1, end, examStudentDtoImportList, map);
-            invokeAll(left, right);
-            teExamStudentList.addAll(left.join());
-            teExamStudentList.addAll(right.join());
-        }
-        return teExamStudentList;
-    }
-}

+ 9 - 1
themis-business/src/main/java/com/qmth/themis/business/templete/TaskImportTemplete.java

@@ -1,7 +1,6 @@
 package com.qmth.themis.business.templete;
 
 import com.qmth.themis.common.util.Result;
-import org.springframework.web.multipart.MultipartFile;
 
 import java.io.File;
 import java.io.IOException;
@@ -16,5 +15,14 @@ import java.util.Map;
  */
 public interface TaskImportTemplete {
 
+    /**
+     * 导入任务
+     *
+     * @param file
+     * @param map
+     * @return
+     * @throws IOException
+     * @throws InterruptedException
+     */
     Result importTask(File file, Map<String, Object> map) throws IOException, InterruptedException;
 }

+ 151 - 49
themis-business/src/main/java/com/qmth/themis/business/templete/impl/ExamStudentTemplete.java

@@ -1,18 +1,23 @@
 package com.qmth.themis.business.templete.impl;
 
+import cn.hutool.core.date.DateUtil;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.google.common.collect.Lists;
+import com.google.gson.Gson;
 import com.qmth.themis.business.constant.SpringContextHolder;
+import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.dto.ExamStudentDtoImport;
-import com.qmth.themis.business.entity.TBExamInvigilateUser;
-import com.qmth.themis.business.entity.TEExamStudent;
+import com.qmth.themis.business.entity.*;
 import com.qmth.themis.business.enums.ExamModeEnum;
-import com.qmth.themis.business.forkjoin.ForkJoinTask;
-import com.qmth.themis.business.service.TBExamInvigilateUserService;
+import com.qmth.themis.business.enums.RoleEnum;
+import com.qmth.themis.business.enums.TaskTypeExecEnum;
+import com.qmth.themis.business.service.*;
 import com.qmth.themis.business.templete.TaskImportTemplete;
 import com.qmth.themis.business.util.ExcelCallback;
 import com.qmth.themis.business.util.ExcelError;
 import com.qmth.themis.business.util.ExcelUtil;
+import com.qmth.themis.business.util.JacksonUtil;
 import com.qmth.themis.common.exception.BusinessException;
 import com.qmth.themis.common.util.Result;
 import com.qmth.themis.common.util.ResultUtil;
@@ -23,10 +28,9 @@ import org.springframework.util.LinkedMultiValueMap;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
+import java.math.BigDecimal;
 import java.util.*;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ForkJoinPool;
-import java.util.concurrent.Future;
+import java.util.stream.Collectors;
 
 /**
  * @Description: 考生导入模版
@@ -41,8 +45,6 @@ public class ExamStudentTemplete implements TaskImportTemplete {
     @Override
     public Result importTask(File file, Map<String, Object> map) throws IOException, InterruptedException {
         Integer mode = Integer.parseInt(String.valueOf(map.get("mode")));
-        Long orgId = Long.parseLong(String.valueOf(map.get("orgId")));
-        Long createId = Long.parseLong(String.valueOf(map.get("createId")));
         FileInputStream inputStream = new FileInputStream(file);
         List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(inputStream, Lists.newArrayList(ExamStudentDtoImport.class), new ExcelCallback() {
             @Override
@@ -72,51 +74,151 @@ public class ExamStudentTemplete implements TaskImportTemplete {
         });
         //保存数据到数据库
         if (Objects.nonNull(finalList) && finalList.size() > 0) {
-            log.info("开始forkjoin数据拆分");
+            log.info("开始导入考生数据");
             long start = System.currentTimeMillis();
-            ForkJoinPool forkJoinPool = new ForkJoinPool();
-            for (int i = 0; i < finalList.size(); i++) {
-                LinkedMultiValueMap<Integer, Object> multiValueMap = finalList.get(i);
-                List<Object> examStudentDtoImportList = multiValueMap.get(i);
-                ForkJoinTask forkJoinTask = new ForkJoinTask(500, 0, examStudentDtoImportList.size() - 1, examStudentDtoImportList, map);
-                Future<List<TEExamStudent>> result = forkJoinPool.submit(forkJoinTask);
-                if (forkJoinTask.isCompletedAbnormally()) {
-                    //检查任务是否已经抛出异常或已经被取消了,要注意此方法。由于提交任务之后,检测该任务是否有异常,不是阻塞的。所以需要上面的等待任务的完成。才能正确的获取到是否有异常
-                    throw new BusinessException(forkJoinTask.getException().getMessage());
-                }
-                try {
-                    List<TEExamStudent> list = result.get();
-                    Map<String, String> tbExamInvigilateUserMap = (Map<String, String>) map.get("tbExamInvigilateUserMap");
-                    if (Objects.nonNull(list) && list.size() > 0) {
-                        //考场的创建
-                        TBExamInvigilateUserService tbExamInvigilateUserService = SpringContextHolder.getBean(TBExamInvigilateUserService.class);
-                        Set<String> roomCodeAndNameSet = new HashSet<>();
-                        list.forEach(s -> {
-                            roomCodeAndNameSet.add(s.getRoomCode() + ":" + s.getRoomName());
-                        });
-                        List<TBExamInvigilateUser> tbExamInvigilateUserList = new ArrayList<>();
-                        roomCodeAndNameSet.forEach(s -> {
-                            if (Objects.isNull(tbExamInvigilateUserMap) || (Objects.nonNull(tbExamInvigilateUserMap) && Objects.isNull(tbExamInvigilateUserMap.get(s)))) {
-                                String[] strs = s.split(":");
-                                TBExamInvigilateUser tbExamInvigilateUser = new TBExamInvigilateUser(orgId, createId, strs[0], strs[1]);
-                                tbExamInvigilateUserList.add(tbExamInvigilateUser);
-                            }
-                        });
-                        tbExamInvigilateUserService.saveBatch(tbExamInvigilateUserList);
+            TEExamStudentService teExamStudentService = SpringContextHolder.getBean(TEExamStudentService.class);
+            TEStudentService teStudentService = SpringContextHolder.getBean(TEStudentService.class);
+            TBUserRoleService tbUserRoleService = SpringContextHolder.getBean(TBUserRoleService.class);
+            TBTaskHistoryService tbTaskHistoryService = SpringContextHolder.getBean(TBTaskHistoryService.class);
+            TBExamInvigilateUserService tbExamInvigilateUserService = SpringContextHolder.getBean(TBExamInvigilateUserService.class);
+            Long orgId = Long.parseLong(String.valueOf(map.get("orgId")));
+            Long createId = Long.parseLong(String.valueOf(map.get("createId")));
+            Long examId = Long.parseLong(String.valueOf(map.get("examId")));
+            List<TEExamStudent> teExamStudentList = new ArrayList<>();
+            List<TEStudent> teStudentList = new ArrayList<>();
+            List<TBUserRole> tbUserRoleList = new ArrayList<>();
+            List<TBExamInvigilateUser> tbExamInvigilateUserList = new ArrayList<>();
+            JSONObject jsonObject = new JSONObject();
+            TBTaskHistory tbTaskHistory = null;
+            jsonObject.put(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"), "开始准备处理导入的考生数据");
+            int y = 0, min = 0;
+            try {
+                Gson gson = new Gson();
+                Set<String> roomCodeAndNameSet = new HashSet<>();
+                Map<String, TEExamActivity> teExamActivityMap = (Map<String, TEExamActivity>) map.get("teExamActivityMap");
+                Map tbTaskHistoryMap = (Map) map.get("tbTaskHistory");
+                tbTaskHistoryMap = SystemConstant.timeTransform(tbTaskHistoryMap);
+                tbTaskHistory = gson.fromJson(gson.toJson(tbTaskHistoryMap), TBTaskHistory.class);
+                //保存用户
+                for (int i = 0; i < finalList.size(); i++) {
+                    LinkedMultiValueMap<Integer, Object> finalMap = finalList.get(i);
+                    List<Object> examStudentDtoImportList = finalMap.get(i);
+                    min = 0;
+                    int max = 500, size = examStudentDtoImportList.size();
+                    if (max >= size) {
+                        max = size;
                     }
-                    log.info("list.size:{}", list.size());
-                } catch (ExecutionException | InterruptedException e) {
-                    e.printStackTrace();
-                } finally {
-                    if (Objects.nonNull(forkJoinPool)) {
-                        forkJoinPool.shutdown();
+                    while (max <= size) {
+                        List subList = examStudentDtoImportList.subList(min, max);
+                        for (y = 0; y < subList.size(); y++) {
+                            ExamStudentDtoImport examStudentDtoImport = (ExamStudentDtoImport) subList.get(y);
+                            Map m = (Map) teExamActivityMap.get(examStudentDtoImport.getExamActivityCode());
+                            m = SystemConstant.timeTransform(m);
+                            TEExamActivity teExamActivity = gson.fromJson(gson.toJson(m), TEExamActivity.class);
+                            //先根据证件号+科目代码查询考生是否存在,存在则更新,不存在则插入
+                            QueryWrapper<TEExamStudent> teExamStudentQueryWrapper = new QueryWrapper<>();
+                            teExamStudentQueryWrapper.lambda().eq(TEExamStudent::getIdentity, examStudentDtoImport.getIdentity()).eq(TEExamStudent::getCourseCode, examStudentDtoImport.getCourseCode());
+                            TEExamStudent teExamStudent = teExamStudentService.getOne(teExamStudentQueryWrapper);
+                            //如果为空则插入考生数据,插入考生前先插入学生档案数据
+                            if (Objects.isNull(teExamStudent)) {
+                                //先插入学生档案数据
+                                TEStudent teStudent = new TEStudent(orgId, examStudentDtoImport.getIdentity(), examStudentDtoImport.getName(), createId);
+                                teStudentService.save(teStudent);
+                                teStudentList.add(teStudent);
+
+                                //插入用户角色关系
+                                TBUserRole tbUserRole = new TBUserRole(teStudent.getId(), RoleEnum.STUDENT.name());
+                                tbUserRoleService.save(tbUserRole);
+                                tbUserRoleList.add(tbUserRole);
+
+                                teExamStudent = gson.fromJson(gson.toJson(examStudentDtoImport), TEExamStudent.class);
+                                teExamStudent.setExamId(examId);
+                                teExamStudent.setExamActivityId(teExamActivity.getId());
+                                teExamStudent.setStudentId(teStudent.getId());
+                                teExamStudent.setCreateId(createId);
+                            } else {
+                                teExamStudent.setUpdateId(createId);
+                                teExamStudent.setName(examStudentDtoImport.getName());
+                                teExamStudent.setCourseName(examStudentDtoImport.getCourseName());
+                                teExamStudent.setGrade(examStudentDtoImport.getGrade());
+                                teExamStudent.setClassNo(examStudentDtoImport.getClassNo());
+                                teExamStudent.setRoomCode(examStudentDtoImport.getRoomCode());
+                                teExamStudent.setRoomName(examStudentDtoImport.getRoomName());
+                                teExamStudent.setExamActivityId(teExamActivity.getId());
+                            }
+                            roomCodeAndNameSet.add(teExamStudent.getRoomCode() + ":" + teExamStudent.getRoomName());
+                            teExamStudentList.add(teExamStudent);
+                        }
+                        BigDecimal bigDecimal = new BigDecimal(100);
+                        BigDecimal progress = new BigDecimal(Double.valueOf(new BigDecimal(max).divide(new BigDecimal(size), 2, BigDecimal.ROUND_HALF_UP).multiply(bigDecimal).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue())).setScale(0, BigDecimal.ROUND_HALF_UP);
+                        teExamStudentService.saveOrUpdateBatch(teExamStudentList);
+                        log.info("progress:{}", progress);
+                        if (progress.intValue() == 100) {
+                            tbTaskHistory.setStatus(TaskTypeExecEnum.finish.ordinal());
+                            tbTaskHistory.setSummary("共处理了" + size + "条数据");
+                            tbTaskHistory.setFinishTime(new Date());
+                            jsonObject.put(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"), "考生数据处理完毕," + tbTaskHistory.getSummary());
+                        } else {
+                            tbTaskHistory.setStatus(TaskTypeExecEnum.running.ordinal());
+                            tbTaskHistory.setSummary("正在处理第" + min + "条至" + max + "条数据");
+                            jsonObject.put(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"), "考生数据处理中," + tbTaskHistory.getSummary());
+                        }
+                        tbTaskHistory.setProgress(progress.doubleValue());
+                        tbTaskHistoryService.updateById(tbTaskHistory);
+                        if (max == size) {
+                            break;
+                        }
+                        min = max;
+                        max += 500;
+                        if (max >= size) {
+                            max = size;
+                        }
                     }
                 }
+                //考场创建
+                if (Objects.nonNull(roomCodeAndNameSet) && roomCodeAndNameSet.size() > 0) {
+                    Map<String, String> tbExamInvigilateUserMap = (Map<String, String>) map.get("tbExamInvigilateUserMap");
+                    roomCodeAndNameSet.forEach(s -> {
+                        if (Objects.isNull(tbExamInvigilateUserMap) || (Objects.nonNull(tbExamInvigilateUserMap) && Objects.isNull(tbExamInvigilateUserMap.get(s)))) {
+                            String[] strs = s.split(":");
+                            TBExamInvigilateUser tbExamInvigilateUser = new TBExamInvigilateUser(orgId, createId, strs[0], strs[1]);
+                            tbExamInvigilateUserList.add(tbExamInvigilateUser);
+                        }
+                    });
+                }
+                if (Objects.nonNull(tbExamInvigilateUserList) && tbExamInvigilateUserList.size() > 0) {
+                    tbExamInvigilateUserService.saveBatch(tbExamInvigilateUserList);
+                    jsonObject.put(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"), "创建了" + tbExamInvigilateUserList.size() + "条考场数据");
+                }
+                long end = System.currentTimeMillis();
+                log.info("导入考生数据结束,============耗时============:{}秒", (end - start) / 1000);
+            } catch (Exception e) {
+                e.printStackTrace();
+                String exceptionStr = "考生数据处理到第" + (min + y + 1) + "条时发生异常:" + e.getMessage();
+                jsonObject.put(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"), exceptionStr);
+                tbTaskHistory.setSummary(exceptionStr);
+                tbTaskHistoryService.updateById(tbTaskHistory);
+                if (Objects.nonNull(teStudentList) && teStudentList.size() > 0) {
+                    teStudentService.removeByIds(teStudentList.stream().map(s -> s.getId()).collect(Collectors.toList()));
+                }
+                if (Objects.nonNull(tbUserRoleList) && tbUserRoleList.size() > 0) {
+                    tbUserRoleService.removeByIds(tbUserRoleList.stream().map(s -> s.getId()).collect(Collectors.toList()));
+                }
+                if (Objects.nonNull(teExamStudentList) && teExamStudentList.size() > 0) {
+                    teExamStudentService.removeByIds(teExamStudentList.stream().map(s -> s.getId()).collect(Collectors.toList()));
+                }
+                if (Objects.nonNull(tbExamInvigilateUserList) && tbExamInvigilateUserList.size() > 0) {
+                    tbExamInvigilateUserService.removeByIds(tbExamInvigilateUserList.stream().map(s -> s.getId()).collect(Collectors.toList()));
+                }
+                if (e instanceof BusinessException) {
+                    throw new BusinessException(e.getMessage());
+                } else {
+                    throw new RuntimeException(e);
+                }
+            } finally {
+                log.info("jsonObject:{}", jsonObject.toJSONString());
             }
-            long end = System.currentTimeMillis();
-            log.info("forkjoin数据拆分结束,============耗时============:{}秒", (end - start) / 1000);
         }
-        Map resultMap = new HashMap<>();
-        return ResultUtil.ok(resultMap);
+        return ResultUtil.ok(JacksonUtil.parseJson(SystemConstant.SUCCESS));
     }
 }

+ 46 - 0
themis-business/src/main/java/com/qmth/themis/business/util/RedisUtil.java

@@ -277,4 +277,50 @@ public class RedisUtil {
             return false;
         }
     }
+
+    /**
+     * 设置缓存
+     *
+     * @param key
+     * @param hashKey
+     * @param o
+     */
+    public void setCacheValue(String key, String hashKey, Object o) {
+        redisTemplate.opsForValue().set(key + hashKey, o);
+    }
+
+    /**
+     * 设置缓存
+     *
+     * @param key
+     * @param hashKey
+     * @param o
+     * @param time
+     * @param timeUnit
+     */
+    public void setCacheValue(String key, String hashKey, Object o, long time, TimeUnit timeUnit) {
+        redisTemplate.opsForValue().set(key + hashKey, o, time, timeUnit);
+    }
+
+    /**
+     * 获取缓存
+     *
+     * @param key
+     * @param hashKey
+     * @return
+     */
+    public Object getCacheValue(String key, String hashKey) {
+        return redisTemplate.opsForValue().get(key + hashKey);
+    }
+
+    /**
+     * 删除缓存
+     *
+     * @param key
+     * @param hashKey
+     * @return
+     */
+    public Object deleteCacheValue(String key, String hashKey) {
+        return redisTemplate.delete(key + hashKey);
+    }
 }

+ 4 - 4
themis-task/src/main/java/com/qmth/themis/task/listener/RocketTaskConsumer.java

@@ -1,5 +1,6 @@
 package com.qmth.themis.task.listener;
 
+import cn.hutool.core.date.DateUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.google.gson.Gson;
 import com.qmth.themis.business.constant.SystemConstant;
@@ -31,10 +32,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.io.File;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.StringJoiner;
+import java.util.*;
 import java.util.concurrent.TimeUnit;
 
 /**
@@ -85,6 +83,8 @@ public class RocketTaskConsumer implements MessageListenerConcurrently {
                     } else {
                         file = ossUtil.ossDownload(TaskConstant.getAttachmentEnv(uploadType), localPath.toString(), localPath.toString());
                     }
+                    JSONObject object = new JSONObject(new LinkedHashMap<>());
+                    object.put(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"), "准备开始处理考生导入数据");
                     TaskImportTemplete examStudentTemplete = new ExamStudentTemplete();
                     examStudentTemplete.importTask(file, map);
                     mqDto.setAck(SystemConstant.STANDARD_ACK_TYPE);