wangliang 1 рік тому
батько
коміт
d9ee16d9db
18 змінених файлів з 93 додано та 96 видалено
  1. 4 18
      themis-admin/src/main/java/com/qmth/themis/admin/api/TBUserController.java
  2. 4 4
      themis-admin/src/main/java/com/qmth/themis/admin/api/TEExamController.java
  3. 1 1
      themis-admin/src/main/java/com/qmth/themis/admin/api/TEExamStudentController.java
  4. 3 4
      themis-admin/src/main/java/com/qmth/themis/admin/api/TIeInvigilateWarnInfoController.java
  5. 1 1
      themis-business/src/main/java/com/qmth/themis/business/constant/SystemConstant.java
  6. 13 1
      themis-business/src/main/java/com/qmth/themis/business/dto/response/TEExamWaitDto.java
  7. 12 12
      themis-business/src/main/java/com/qmth/themis/business/service/ThemisCacheService.java
  8. 2 2
      themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamActivityServiceImpl.java
  9. 6 12
      themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamServiceImpl.java
  10. 2 0
      themis-business/src/main/java/com/qmth/themis/business/service/impl/TEOrgSummaryServiceImpl.java
  11. 1 1
      themis-business/src/main/java/com/qmth/themis/business/service/impl/TIeReportServiceImpl.java
  12. 2 1
      themis-business/src/main/java/com/qmth/themis/business/service/impl/TOeExamRecordServiceImpl.java
  13. 28 26
      themis-business/src/main/java/com/qmth/themis/business/service/impl/ThemisCacheServiceImpl.java
  14. 1 0
      themis-business/src/main/java/com/qmth/themis/business/service/impl/WarningServiceImpl.java
  15. 1 1
      themis-business/src/main/java/com/qmth/themis/business/templete/impl/TaskExamStudentImportTemplete.java
  16. 5 5
      themis-task/src/main/java/com/qmth/themis/task/quartz/ExamSummaryJob.java
  17. 6 6
      themis-task/src/main/java/com/qmth/themis/task/quartz/MqActivityJob.java
  18. 1 1
      themis-task/src/main/java/com/qmth/themis/task/start/StartRunning.java

+ 4 - 18
themis-admin/src/main/java/com/qmth/themis/admin/api/TBUserController.java

@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qmth.themis.business.annotation.ApiJsonObject;
 import com.qmth.themis.business.annotation.ApiJsonProperty;
-import com.qmth.themis.business.cache.ExamRecordCacheUtil;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.dto.AuthDto;
 import com.qmth.themis.business.dto.ExpireTimeDTO;
@@ -15,7 +14,10 @@ import com.qmth.themis.business.entity.TBOrg;
 import com.qmth.themis.business.entity.TBSession;
 import com.qmth.themis.business.entity.TBUser;
 import com.qmth.themis.business.entity.TBUserRole;
-import com.qmth.themis.business.enums.*;
+import com.qmth.themis.business.enums.FieldUniqueEnum;
+import com.qmth.themis.business.enums.MqTagEnum;
+import com.qmth.themis.business.enums.RoleEnum;
+import com.qmth.themis.business.enums.SystemOperationEnum;
 import com.qmth.themis.business.service.*;
 import com.qmth.themis.business.util.*;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
@@ -448,14 +450,12 @@ public class TBUserController {
     //        teExamStudent.setEnable(1);
     //        teExamStudentService.save(teExamStudent);
     //
-    //        //todo
     ////        MTEStudentEntity mteStudentEntity = gson.fromJson(gson.toJson(teStudent), MTEStudentEntity.class);
     ////        MTEExamEntity mteExamEntity = gson.fromJson(gson.toJson(teExam), MTEExamEntity.class);
     ////        MTEExamActivityEntity mteExamActivityEntity = gson.fromJson(gson.toJson(teExamActivity), MTEExamActivityEntity.class);
     ////        MTEExamPaperEntity mteExamPaperEntity = gson.fromJson(gson.toJson(teExamPaper), MTEExamPaperEntity.class);
     ////        MTEExamCourseEntity mteExamCourseEntity = gson.fromJson(gson.toJson(teExamCourse), MTEExamCourseEntity.class);
     ////        MTEExamStudentEntity mteExamStudentEntity = gson.fromJson(gson.toJson(teExamStudent), MTEExamStudentEntity.class);
-    //        //todo
     //
     ////        List list = Arrays.asList(mteExamPaperEntity);
     ////        mteExamCourseEntity.setMteExamPaperEntityList(list);
@@ -469,7 +469,6 @@ public class TBUserController {
     ////        mteExamStudentEntity.setMteStudentEntity(mteStudentEntity);
     ////        mteExamStudentEntity.setMteExamCourseEntityList(list);
     //
-    //        //todo
     ////        mongoTemplate.save(mteStudentEntity);
     ////        mongoTemplate.save(mteExamEntity);
     ////        mongoTemplate.save(mteExamActivityEntity);
@@ -520,7 +519,6 @@ public class TBUserController {
     ////            MTEExamStudentEntity t = gson.fromJson(gson.toJson(s), MTEExamStudentEntity.class);
     ////            ps1.add(t);
     ////        });
-    //        //todo
     ////        teExamActivityService.dropTable(tableName);
     //        return ResultUtil.ok(SystemConstant.SUCCESS);
     //    }
@@ -569,18 +567,6 @@ public class TBUserController {
                         @ApiParam(value = "机构id", required = false) @RequestParam(required = false) String orgId,
                         @ApiParam(value = "分页页码", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) int pageNumber,
                         @ApiParam(value = "分页数", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) int pageSize) {
-        long timestamp = System.currentTimeMillis();
-        ExamRecordCacheUtil.setWarningCount(1L, 1, timestamp);
-        Integer warningCount = ExamRecordCacheUtil.getWarningCount(id);
-        ExamRecordStatusEnum status = ExamRecordCacheUtil.getStatus(id);
-        if (Objects.nonNull(status) && status != ExamRecordStatusEnum.PERSISTED) {
-            if (Objects.nonNull(warningCount)) {
-                ExamRecordCacheUtil.setWarningCount(id, warningCount + 1, timestamp);
-            } else {
-                ExamRecordCacheUtil.setWarningCount(id, 1, timestamp);
-            }
-        }
-
         TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
         AuthDto authDto = themisCacheService.addAccountAuthCache(tbUser.getId());
         if (authDto.getRoleCodes().toString().contains(RoleEnum.SUPER_ADMIN.name())) {

+ 4 - 4
themis-admin/src/main/java/com/qmth/themis/admin/api/TEExamController.java

@@ -230,9 +230,9 @@ public class TEExamController {
             List<TEExamActivity> teExamActivityList = teExamActivityService.list(new QueryWrapper<TEExamActivity>().lambda().eq(TEExamActivity::getExamId, teExam.getId()).eq(TEExamActivity::getEnable, 1));
             for (TEExamActivity t : teExamActivityList) {
                 if (Objects.nonNull(t.getEnable()) && t.getEnable().intValue() == 1 && (Objects.nonNull(t.getFinishTime()) && t.getFinishTime().longValue() > System.currentTimeMillis())) {
-                    themisCacheService.updateTodayExamListCache(t.getExamId().toString(), t.getId());
+                    themisCacheService.updateCurrentExamListCache(t.getExamId().toString(), t.getId());
                 } else {
-                    themisCacheService.removeTodayExamListCache(t.getExamId().toString(), t.getId());
+                    themisCacheService.removeCurrentExamListCache(t.getExamId().toString(), t.getId());
                 }
                 themisCacheService.updateOrgExamListCache(teExam.getOrgId().toString(), t.getExamId().toString(), t.getId());
             }
@@ -345,9 +345,9 @@ public class TEExamController {
         List<TEExamActivity> teExamActivityList = teExamActivityService.list(new QueryWrapper<TEExamActivity>().lambda().eq(TEExamActivity::getExamId, teExam.getId()).eq(TEExamActivity::getEnable, 1));
         for (TEExamActivity t : teExamActivityList) {
             if (Objects.nonNull(t.getEnable()) && t.getEnable().intValue() == 1 && (Objects.nonNull(t.getFinishTime()) && t.getFinishTime().longValue() > System.currentTimeMillis())) {
-                themisCacheService.updateTodayExamListCache(t.getExamId().toString(), t.getId());
+                themisCacheService.updateCurrentExamListCache(t.getExamId().toString(), t.getId());
             } else {
-                themisCacheService.removeTodayExamListCache(t.getExamId().toString(), t.getId());
+                themisCacheService.removeCurrentExamListCache(t.getExamId().toString(), t.getId());
             }
             themisCacheService.updateOrgExamListCache(teExam.getOrgId().toString(), t.getExamId().toString(), t.getId());
         }

+ 1 - 1
themis-admin/src/main/java/com/qmth/themis/admin/api/TEExamStudentController.java

@@ -321,7 +321,7 @@ public class TEExamStudentController {
         for (TEExamStudent es : teExamStudentList) {
             teExamStudentService.updateExamStudentCacheBean(es.getId());
             //加入更新考试列表缓存方法
-            themisCacheService.updateTodayExamListCache(es.getExamId().toString(), es.getExamActivityId());
+            themisCacheService.updateCurrentExamListCache(es.getExamId().toString(), es.getExamActivityId());
             ExamCacheBean examCacheBean = teExamService.getExamCacheBean(es.getExamId());
             themisCacheService.updateOrgExamListCache(examCacheBean.getOrgId().toString(), es.getExamId().toString(), es.getExamActivityId());
         }

+ 3 - 4
themis-admin/src/main/java/com/qmth/themis/admin/api/TIeInvigilateWarnInfoController.java

@@ -54,9 +54,6 @@ public class TIeInvigilateWarnInfoController {
     @Resource
     TBExamInvigilateUserService tbExamInvigilateUserService;
 
-    @Resource
-    TEExamSummaryService teExamSummaryService;
-
     @Resource
     TEExamActivityService teExamActivityService;
 
@@ -93,10 +90,11 @@ public class TIeInvigilateWarnInfoController {
         } else {
             //取当前用户机构id所属考试id集合
             List<TEExam> teExamList = teExamService.list(new QueryWrapper<TEExam>().lambda().eq(TEExam::getOrgId, tbUser.getOrgId()));
+            //TODO 查询数据库拉取当前机构下所有考试批次、场次、考场编码集合(启用状态)
             if (!CollectionUtils.isEmpty(teExamList)) {
                 List<TEExamSummary> teExamSummaryAllList = new ArrayList<>();
                 for (TEExam t : teExamList) {
-                    List<ExamListBean> examListBeanList = themisCacheService.getTodayExamListCache(t.getId().toString());
+                    List<ExamListBean> examListBeanList = themisCacheService.getCurrentExamListCache(t.getId().toString());
                     if (!CollectionUtils.isEmpty(examListBeanList)) {
                         for (ExamListBean e : examListBeanList) {
                             Set<String> roomCodeSet = new HashSet<>(Arrays.asList(e.getRoomCode().split(", ")));
@@ -212,6 +210,7 @@ public class TIeInvigilateWarnInfoController {
             } else if (Objects.nonNull(examActivityId)) {
                 tOeExamRecordQueryWrapper.lambda().eq(TOeExamRecord::getExamActivityId, examActivityId);
             }
+            //TODO 查询条件补足
             List<TOeExamRecord> tOeExamRecordList = tOeExamRecordService.list(tOeExamRecordQueryWrapper);
             for (TOeExamRecord t : tOeExamRecordList) {
                 tOeExamRecordService.updateWarningUnreadByDb(t.getId(), 0);

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

@@ -216,7 +216,7 @@ public class SystemConstant {
     public static final String BLACK_LIST_CACHE = "blacklist:cache";
     public static final String SYS_NOTIFY_CACHE = "sys:notify:cache";
     public static final String PROBLEM_CACHE = "problem:cache";
-    public static final String TODAY_EXAM_LIST_MAP_CACHE = "today:exam:list:map:cache";
+    public static final String CURRENT_EXAM_LIST_MAP_CACHE = "current:exam:list:map:cache";
     public static final String ORG_EXAM_LIST_MAP_CACHE = "org:exam:list:map:cache:";
 
     public volatile static Searcher SEARCHER = null;

+ 13 - 1
themis-business/src/main/java/com/qmth/themis/business/dto/response/TEExamWaitDto.java

@@ -3,6 +3,7 @@ package com.qmth.themis.business.dto.response;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import io.swagger.annotations.ApiModelProperty;
+import org.jetbrains.annotations.NotNull;
 
 import java.io.Serializable;
 import java.util.List;
@@ -15,7 +16,7 @@ import java.util.Objects;
  * @Author: wangliang
  * @Date: 2020/8/3
  */
-public class TEExamWaitDto implements Serializable {
+public class TEExamWaitDto implements Serializable, Comparable<TEExamWaitDto> {
 
     @JsonSerialize(using = ToStringSerializer.class)
     @ApiModelProperty(name = "考试批次id")
@@ -88,4 +89,15 @@ public class TEExamWaitDto implements Serializable {
     public void setActivities(List<TEExamActivityWaitDto> activities) {
         this.activities = activities;
     }
+
+    @Override
+    public int compareTo(@NotNull TEExamWaitDto o) {
+        if (o.getId() < this.getId()) {
+            return 1;
+        } else if (o.getId() > this.getId()) {
+            return -1;
+        } else {
+            return 0;
+        }
+    }
 }

+ 12 - 12
themis-business/src/main/java/com/qmth/themis/business/service/ThemisCacheService.java

@@ -308,16 +308,16 @@ public interface ThemisCacheService {
     public void removeProblemCache();
 
     /**
-     * 设置当考试缓存
+     * 设置当考试缓存
      */
-    public void setTodayExamListCache();
+    public void setCurrentExamListCache();
 
     /**
-     * 获取当考试列表缓存
+     * 获取当考试列表缓存
      *
      * @return
      */
-    public Map<String, List<ExamListBean>> getTodayExamListCache();
+    public Map<String, List<ExamListBean>> getCurrentExamListCache();
 
     /**
      * 设置机构考试列表缓存
@@ -375,34 +375,34 @@ public interface ThemisCacheService {
     public void removeOrgExamListCache(String orgId, String examId, Long examActivityId);
 
     /**
-     * 获取当考试缓存
+     * 获取当考试缓存
      *
      * @param examId
      * @return
      */
-    public List<ExamListBean> getTodayExamListCache(String examId);
+    public List<ExamListBean> getCurrentExamListCache(String examId);
 
     /**
-     * 更新当考试缓存
+     * 更新当考试缓存
      *
      * @param examId
      * @param examActivityId
      */
-    public void updateTodayExamListCache(String examId, Long examActivityId);
+    public void updateCurrentExamListCache(String examId, Long examActivityId);
 
     /**
-     * 删除当考试缓存
+     * 删除当考试缓存
      *
      * @return
      */
-    public void removeTodayExamListCache(String examId);
+    public void removeCurrentExamListCache(String examId);
 
     /**
-     * 删除当考试缓存
+     * 删除当考试缓存
      *
      * @return
      */
-    public void removeTodayExamListCache(String examId, Long examActivityId);
+    public void removeCurrentExamListCache(String examId, Long examActivityId);
 
     /**
      * 获取考试统计缓存

+ 2 - 2
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamActivityServiceImpl.java

@@ -417,9 +417,9 @@ public class TEExamActivityServiceImpl extends ServiceImpl<TEExamActivityMapper,
                 //加入更新考试列表缓存方法
                 ExamActivityCacheBean examActivityCacheBean = this.getExamActivityCacheBean(ac.getId());
                 if (Objects.nonNull(examActivityCacheBean.getEnable()) && examActivityCacheBean.getEnable().intValue() == 1 && Objects.nonNull(examActivityCacheBean.getFinishTime()) && examActivityCacheBean.getFinishTime().longValue() > System.currentTimeMillis()) {
-                    themisCacheService.updateTodayExamListCache(ac.getExamId().toString(), ac.getId());
+                    themisCacheService.updateCurrentExamListCache(ac.getExamId().toString(), ac.getId());
                 } else {
-                    themisCacheService.removeTodayExamListCache(ac.getExamId().toString(), ac.getId());
+                    themisCacheService.removeCurrentExamListCache(ac.getExamId().toString(), ac.getId());
                 }
                 themisCacheService.updateOrgExamListCache(teExam.getOrgId().toString(), ac.getExamId().toString(), ac.getId());
 

+ 6 - 12
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamServiceImpl.java

@@ -50,7 +50,6 @@ import java.math.BigDecimal;
 import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
-import java.util.stream.Collectors;
 
 /**
  * @Description: 考试批次 服务实现类
@@ -157,22 +156,21 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         if (Objects.isNull(examId)) {
             Map<String, Set<Long>> examList = themisCacheService.getOrgExamListCache(orgId.toString());
             if (!CollectionUtils.isEmpty(examList)) {
-                examList = examList.entrySet().stream()
-                        .sorted(Map.Entry.comparingByKey())
-                        .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, LinkedHashMap::new));
+                Set<Long> examActivityIds = new HashSet<>();
                 for (Map.Entry<String, Set<Long>> entry : examList.entrySet()) {
-                    List<TEExamActivityWaitDto> teExamActivityWaitList = teExamActivityService.getWaitingExam(studentId, entry.getValue(), null);
-                    list = this.waitingExamCommon(list, teExamActivityWaitList);
+                    examActivityIds.addAll(entry.getValue());
                 }
+                List<TEExamActivityWaitDto> teExamActivityWaitList = teExamActivityService.getWaitingExam(studentId, examActivityIds, orgId);
+                list = this.waitingExamCommon(list, teExamActivityWaitList);
             }
         } else {
             Set<Long> examActivityIdSet = themisCacheService.getOrgExamListCache(orgId.toString(), examId.toString());
             if (!CollectionUtils.isEmpty(examActivityIdSet)) {
-                examActivityIdSet = examActivityIdSet.stream().sorted().collect(Collectors.toCollection(LinkedHashSet::new));
-                List<TEExamActivityWaitDto> teExamActivityWaitList = teExamActivityService.getWaitingExam(studentId, examActivityIdSet, null);
+                List<TEExamActivityWaitDto> teExamActivityWaitList = teExamActivityService.getWaitingExam(studentId, examActivityIdSet, orgId);
                 list = this.waitingExamCommon(list, teExamActivityWaitList);
             }
         }
+        Collections.sort(list);
         return list;
     }
 
@@ -190,9 +188,6 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
             teExamActivityWaitList.forEach(i -> {
                 ExamCacheBean examCache = getExamCacheBeanNative(i.getExamId());
                 TEExamWaitDto teExamWaitDto = new TEExamWaitDto(i.getExamId(), i.getExamActivityId(), examCache.getName(), examCache.getCode());
-//                if (Objects.nonNull(examCache.getEnable()) && Objects.nonNull(i.getEnable())
-//                        && examCache.getEnable().intValue() == 1 && i.getEnable().intValue() == 1
-//                        && i.getFinishTime().longValue() > System.currentTimeMillis()) {
                 setMap.put(i.getExamId(), teExamWaitDto);
                 Set<TEExamActivityWaitDto> teExamActivityWaitDtos = Objects.nonNull(map.get(i.getExamId())) ? map.get(i.getExamId()) : new LinkedHashSet<>();
                 teExamActivityWaitDtos.add(i);
@@ -200,7 +195,6 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
                 ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(i.getExamStudentId());
                 Integer leftExamCount = examCache.getExamCount().intValue() - examStudentCacheBean.getAlreadyExamCount().intValue() < 0 ? 0 : examCache.getExamCount().intValue() - examStudentCacheBean.getAlreadyExamCount().intValue();
                 i.setLeftExamCount(leftExamCount);
-//                }
             });
             setMap.forEach((k, v) -> {
                 v.setActivities(new ArrayList<>(map.get(k)));

+ 2 - 0
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEOrgSummaryServiceImpl.java

@@ -46,6 +46,7 @@ public class TEOrgSummaryServiceImpl extends ServiceImpl<TEOrgSummaryMapper, TEO
     @Override
     public void orgSummary(Long orgId, List<Long> examIdSet) {
         if (orgId.longValue() == 0) {//全局机构
+            //todo 全局统计需求和产品探讨(能否不显示考试科目数和已完成考生数),sql合并
             List<Integer> list = this.baseMapper.orgSummary(orgId, examIdSet);
             TEOrgSummary teOrgSummary = new TEOrgSummary(orgId, list.get(0), list.get(1), list.get(2), list.get(3));
             teOrgSummaryService.saveOrUpdate(teOrgSummary);
@@ -79,6 +80,7 @@ public class TEOrgSummaryServiceImpl extends ServiceImpl<TEOrgSummaryMapper, TEO
                             finishStudentCount = finishStudentCount + t.getFinishCount();
                         }
                     }
+                    //TODO finishCount可以从缓存取?
                     Integer finishCount = this.baseMapper.orgSummaryByFinishCount(orgId, v);
                     TEOrgSummary teOrgSummary = new TEOrgSummary(orgId, onlineCount, examCount, finishCount, finishStudentCount);
                     teOrgSummaryService.saveOrUpdate(teOrgSummary);

+ 1 - 1
themis-business/src/main/java/com/qmth/themis/business/service/impl/TIeReportServiceImpl.java

@@ -429,7 +429,7 @@ public class TIeReportServiceImpl implements TIeReportService {
         if (!CollectionUtils.isEmpty(teExamList)) {
             List<TEExamSummary> teExamSummaryAllList = new ArrayList<>();
             for (TEExam t : teExamList) {
-                List<ExamListBean> examListBeanList = themisCacheService.getTodayExamListCache(t.getId().toString());
+                List<ExamListBean> examListBeanList = themisCacheService.getCurrentExamListCache(t.getId().toString());
                 if (!CollectionUtils.isEmpty(examListBeanList)) {
                     for (ExamListBean e : examListBeanList) {
                         Set<String> roomCodeSet = new HashSet<>(Arrays.asList(e.getRoomCode().split(", ")));

+ 2 - 1
themis-business/src/main/java/com/qmth/themis/business/service/impl/TOeExamRecordServiceImpl.java

@@ -428,6 +428,7 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
             //更新考生信息
             teExamStudentService.updateExamStudentByCache(er.getExamStudentId());
             ExamStudentCacheBean examStudentCache = (ExamStudentCacheBean) redisUtil.get(RedisKeyHelper.examStudentCacheKey(er.getExamStudentId()));
+            //todo orgId当参数传递,更新当前orgId和全局orgId
             if (Objects.nonNull(examStudentCache.getAlreadyExamCount()) &&
                     examStudentCache.getAlreadyExamCount().longValue() == 1) {
                 teOrgSummaryService.updateOrgZeroSummary(1);
@@ -1778,7 +1779,7 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
      */
     @Override
     public List<OrgDataCountBean> orgDataCount() {
-        Set<String> examIdSetSet = redisUtil.getHashKeys(SystemConstant.TODAY_EXAM_LIST_MAP_CACHE);
+        Set<String> examIdSetSet = redisUtil.getHashKeys(SystemConstant.CURRENT_EXAM_LIST_MAP_CACHE);
         if (!CollectionUtils.isEmpty(examIdSetSet)) {
             Set<Long> examIdSet = examIdSetSet.stream().map(s -> Long.parseLong(s)).collect(Collectors.toSet());
             LinkedMultiValueMap<Long, Long> orgExamIdMap = tbOrgService.mergeOrgId(examIdSet);

+ 28 - 26
themis-business/src/main/java/com/qmth/themis/business/service/impl/ThemisCacheServiceImpl.java

@@ -608,24 +608,25 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
     }
 
     /**
-     * 设置当考试缓存
+     * 设置当考试缓存
      */
     @Override
-    public void setTodayExamListCache() {
+    public void setCurrentExamListCache() {
         try {
             Date now = new Date();
             SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
-            String today = sdf1.format(now);
+            String current = sdf1.format(now);
             SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            Long startTime = sdf2.parse(today + " 00:00:00").getTime();
-            Long endTime = sdf2.parse(today + " 23:59:59").getTime();
+            Long startTime = sdf2.parse(current + " 00:00:00").getTime();
+            Long endTime = sdf2.parse(current + " 23:59:59").getTime();
+            //todo 联合teexam表查一次(enable为true),暂定1小时刷新一次,取缓存时不判断enable状态,不做删除缓存操作
             List<TEExamActivity> teExamActivityList = teExamActivityService.list(new QueryWrapper<TEExamActivity>().lambda()
                     .and(w -> w.ge(TEExamActivity::getStartTime, startTime).le(TEExamActivity::getStartTime, endTime))
                     .or(w -> w.le(TEExamActivity::getStartTime, startTime).ge(TEExamActivity::getFinishTime, endTime))
                     .eq(TEExamActivity::getEnable, 1));
             //统计当天00:00:00~23:59:59可以进行的考试批次、场次、考场编码信息
             if (!CollectionUtils.isEmpty(teExamActivityList)) {
-                LinkedMultiValueMap<Long, ExamListBean> todayExamListMap = new LinkedMultiValueMap<>();//考试批次、场次集合/考场编码集合
+                LinkedMultiValueMap<Long, ExamListBean> currentExamListMap = new LinkedMultiValueMap<>();//考试批次、场次集合/考场编码集合
                 Map<Long, Set<Long>> examActivityIdMap = new HashMap<>();//考试批次id,场次id集合
                 Map<Long, Set<String>> roomCodeMap = new HashMap<>();//考试场次id,考场编码集合
                 for (TEExamActivity t : teExamActivityList) {
@@ -648,11 +649,11 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
                 examActivityIdMap.forEach((k, v) -> {
                     for (Long l : v) {
                         String s = StringUtils.join(roomCodeMap.get(l)).replaceAll("\\[", "").replaceAll("\\]", "");
-                        todayExamListMap.add(k, new ExamListBean(l, s));
+                        currentExamListMap.add(k, new ExamListBean(l, s));
                     }
                 });
-                todayExamListMap.forEach((k, v) -> {
-                    redisUtil.set(SystemConstant.TODAY_EXAM_LIST_MAP_CACHE, k.toString(), v);
+                currentExamListMap.forEach((k, v) -> {
+                    redisUtil.set(SystemConstant.CURRENT_EXAM_LIST_MAP_CACHE, k.toString(), v);
                 });
             }
         } catch (Exception e) {
@@ -661,13 +662,13 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
     }
 
     /**
-     * 获取当考试列表缓存
+     * 获取当考试列表缓存
      *
      * @return
      */
     @Override
-    public Map<String, List<ExamListBean>> getTodayExamListCache() {
-        return redisUtil.getHashEntries(SystemConstant.TODAY_EXAM_LIST_MAP_CACHE);
+    public Map<String, List<ExamListBean>> getCurrentExamListCache() {
+        return redisUtil.getHashEntries(SystemConstant.CURRENT_EXAM_LIST_MAP_CACHE);
     }
 
     /**
@@ -676,6 +677,7 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
     @Override
     public void setOrgExamListCache() {
         //查询考试场次结束时间大于当前时间的所有考试
+        //todo 和产品确认待考天数大于N天显示(和上个版本一致),或者重列待考天数逻辑,联合teexam表查一次
         List<TEExamActivity> teExamActivityList = teExamActivityService.list(new QueryWrapper<TEExamActivity>().lambda().gt(TEExamActivity::getFinishTime, System.currentTimeMillis()).eq(TEExamActivity::getEnable, 1));
         if (!CollectionUtils.isEmpty(teExamActivityList)) {
             Map<Long, Set<Long>> orgMap = new HashMap<>();//机构id,考试批次id集合
@@ -799,33 +801,33 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
     }
 
     /**
-     * 获取当考试列表缓存
+     * 获取当考试列表缓存
      *
      * @param examId
      * @return
      */
     @Override
-    public List<ExamListBean> getTodayExamListCache(String examId) {
-        Map<String, List<ExamListBean>> map = this.getTodayExamListCache();
+    public List<ExamListBean> getCurrentExamListCache(String examId) {
+        Map<String, List<ExamListBean>> map = this.getCurrentExamListCache();
         return !CollectionUtils.isEmpty(map) ? map.get(examId) : null;
     }
 
     /**
-     * 更新当考试缓存
+     * 更新当考试缓存
      *
      * @param examId
      * @return
      */
     @Override
-    public void updateTodayExamListCache(String examId, Long examActivityId) {
+    public void updateCurrentExamListCache(String examId, Long examActivityId) {
         List<TEExamStudent> teExamStudentList = teExamStudentService.list(new QueryWrapper<TEExamStudent>().lambda().eq(TEExamStudent::getExamId, Long.parseLong(examId)).eq(TEExamStudent::getExamActivityId, examActivityId));
         if (!CollectionUtils.isEmpty(teExamStudentList)) {
             Set<String> roomCodeSet = teExamStudentList.stream().map(s -> s.getRoomCode()).collect(Collectors.toSet());
-            this.removeTodayExamListCache(examId, examActivityId);
-            List<ExamListBean> examListBeanList = this.getTodayExamListCache(examId);
+            this.removeCurrentExamListCache(examId, examActivityId);
+            List<ExamListBean> examListBeanList = this.getCurrentExamListCache(examId);
             CopyOnWriteArrayList<ExamListBean> copyOnWriteArrayList = !CollectionUtils.isEmpty(examListBeanList) ? new CopyOnWriteArrayList(examListBeanList) : new CopyOnWriteArrayList();
             copyOnWriteArrayList.add(new ExamListBean(examActivityId, StringUtils.join(roomCodeSet).replaceAll("\\[", "").replaceAll("\\]", "")));
-            redisUtil.set(SystemConstant.TODAY_EXAM_LIST_MAP_CACHE, examId, new LinkedList<>(copyOnWriteArrayList));
+            redisUtil.set(SystemConstant.CURRENT_EXAM_LIST_MAP_CACHE, examId, new LinkedList<>(copyOnWriteArrayList));
         }
     }
 
@@ -835,8 +837,8 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
      * @param examId
      */
     @Override
-    public void removeTodayExamListCache(String examId) {
-        redisUtil.delete(SystemConstant.TODAY_EXAM_LIST_MAP_CACHE, examId);
+    public void removeCurrentExamListCache(String examId) {
+        redisUtil.delete(SystemConstant.CURRENT_EXAM_LIST_MAP_CACHE, examId);
     }
 
     /**
@@ -846,8 +848,8 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
      * @param examActivityId
      */
     @Override
-    public void removeTodayExamListCache(String examId, Long examActivityId) {
-        List<ExamListBean> examListBeanList = this.getTodayExamListCache(examId);
+    public void removeCurrentExamListCache(String examId, Long examActivityId) {
+        List<ExamListBean> examListBeanList = this.getCurrentExamListCache(examId);
         if (!CollectionUtils.isEmpty(examListBeanList)) {
             CopyOnWriteArrayList<ExamListBean> copyOnWriteArrayList = new CopyOnWriteArrayList(examListBeanList);
             for (ExamListBean e : copyOnWriteArrayList) {
@@ -857,9 +859,9 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
                 }
             }
             if (!CollectionUtils.isEmpty(copyOnWriteArrayList)) {
-                redisUtil.set(SystemConstant.TODAY_EXAM_LIST_MAP_CACHE, examId, new LinkedList<>(copyOnWriteArrayList));
+                redisUtil.set(SystemConstant.CURRENT_EXAM_LIST_MAP_CACHE, examId, new LinkedList<>(copyOnWriteArrayList));
             } else {
-                this.removeTodayExamListCache(examId);
+                this.removeCurrentExamListCache(examId);
             }
         }
     }

+ 1 - 0
themis-business/src/main/java/com/qmth/themis/business/service/impl/WarningServiceImpl.java

@@ -246,6 +246,7 @@ public class WarningServiceImpl implements WarningService {
      * @param tIeInvigilateWarnInfo
      */
     public void setWarningCount(Long recordId, TIeInvigilateWarnInfo tIeInvigilateWarnInfo) {
+        //todo 直接写数据库不走redis缓存,orgId同步修改
         tOeExamRecordService.updateWarningCountCache(recordId, tIeInvigilateWarnInfo);
     }
 

+ 1 - 1
themis-business/src/main/java/com/qmth/themis/business/templete/impl/TaskExamStudentImportTemplete.java

@@ -144,7 +144,7 @@ public class TaskExamStudentImportTemplete implements TaskImportTemplete {
                 List<TEExamActivity> teExamActivityList = GsonUtil.fromJson(GsonUtil.toJson(teExamActivityMap.values()), new TypeToken<List<TEExamActivity>>() {
                 }.getType());
                 for (TEExamActivity t : teExamActivityList) {
-                    themisCacheService.updateTodayExamListCache(String.valueOf(examId), t.getId());
+                    themisCacheService.updateCurrentExamListCache(String.valueOf(examId), t.getId());
                     ExamCacheBean examCacheBean = teExamService.getExamCacheBean(examId);
                     themisCacheService.updateOrgExamListCache(examCacheBean.getOrgId().toString(), examId.toString(), t.getId());
                 }

+ 5 - 5
themis-task/src/main/java/com/qmth/themis/task/quartz/ExamSummaryJob.java

@@ -51,7 +51,7 @@ public class ExamSummaryJob extends QuartzJobBean {
     @Override
     protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
         log.info("ExamSummaryJob进来了,context:{}", context);
-        Map<String, List<ExamListBean>> examListMap = themisCacheService.getTodayExamListCache();
+        Map<String, List<ExamListBean>> examListMap = themisCacheService.getCurrentExamListCache();
         //获取当天考试列表
         if (!CollectionUtils.isEmpty(examListMap)) {
             LinkedMultiValueMap<Long, Long> orgExamIdMap = new LinkedMultiValueMap<>();//机构/考试批次id列表map
@@ -60,13 +60,13 @@ public class ExamSummaryJob extends QuartzJobBean {
                 ExamCacheBean examCacheBean = teExamService.getExamCacheBean(examId);
                 //不在考试时间范围内或者禁用,则删除当前考试批次id,更新缓存
                 if (examCacheBean.getEnable().intValue() == 0 || examCacheBean.getEndTime().longValue() <= System.currentTimeMillis()) {
-                    themisCacheService.removeTodayExamListCache(entry.getKey());
+                    themisCacheService.removeCurrentExamListCache(entry.getKey());
                     continue;
                 }
                 TBOrg tbOrg = themisCacheService.addOrgCache(examCacheBean.getOrgId());
                 orgExamIdMap.add(tbOrg.getId(), examId);
 
-                List<ExamListBean> examListBeanList = themisCacheService.getTodayExamListCache(entry.getKey());
+                List<ExamListBean> examListBeanList = themisCacheService.getCurrentExamListCache(entry.getKey());
                 if (!CollectionUtils.isEmpty(examListBeanList)) {
                     for (ExamListBean e : examListBeanList) {
                         Set<String> roomCodeSet = new HashSet<>(Arrays.asList(e.getRoomCode().split(", ")));
@@ -82,11 +82,11 @@ public class ExamSummaryJob extends QuartzJobBean {
                             teExamSummaryService.examSummary(examId, e.getExamActivityId(), roomCodeSet);
                             teRegionSummaryService.regionSummary(examId, e.getExamActivityId());
                         } else if (ac.getEnable().intValue() == 0 || endTime <= timestamp) {//禁用或超过考试结束时间则删除考试场次缓存
-                            themisCacheService.removeTodayExamListCache(entry.getKey(), e.getExamActivityId());
+                            themisCacheService.removeCurrentExamListCache(entry.getKey(), e.getExamActivityId());
                         }
                     }
                 } else {
-                    themisCacheService.removeTodayExamListCache(entry.getKey());
+                    themisCacheService.removeCurrentExamListCache(entry.getKey());
                 }
             }
             //统计机构信息

+ 6 - 6
themis-task/src/main/java/com/qmth/themis/task/quartz/MqActivityJob.java

@@ -63,27 +63,27 @@ public class MqActivityJob extends QuartzJobBean {
     @Override
     protected void executeInternal(JobExecutionContext context) {
         log.info("mq_activity_job进来了,context:{}", context);
-        themisCacheService.setTodayExamListCache();
+        themisCacheService.setCurrentExamListCache();
         //每天凌晨清理考试缓存数据
-        Map<String, List<ExamListBean>> examListMap = themisCacheService.getTodayExamListCache();
+        Map<String, List<ExamListBean>> examListMap = themisCacheService.getCurrentExamListCache();
         if (!CollectionUtils.isEmpty(examListMap)) {
             for (Map.Entry<String, List<ExamListBean>> entry : examListMap.entrySet()) {
                 Long examId = Long.parseLong(entry.getKey());
                 ExamCacheBean examCacheBean = teExamService.getExamCacheBean(examId);
                 if (examCacheBean.getEnable().intValue() == 0 || examCacheBean.getEndTime().longValue() <= System.currentTimeMillis()) {
-                    themisCacheService.removeTodayExamListCache(entry.getKey());
+                    themisCacheService.removeCurrentExamListCache(entry.getKey());
                     continue;
                 }
-                List<ExamListBean> examListBeanList = themisCacheService.getTodayExamListCache(entry.getKey());
+                List<ExamListBean> examListBeanList = themisCacheService.getCurrentExamListCache(entry.getKey());
                 if (!CollectionUtils.isEmpty(examListBeanList)) {
                     for (ExamListBean e : examListBeanList) {
                         ExamActivityCacheBean examActivityCacheBean = teExamActivityService.getExamActivityCacheBean(e.getExamActivityId());
                         if (examActivityCacheBean.getEnable().intValue() == 0 || examActivityCacheBean.getFinishTime().longValue() <= System.currentTimeMillis()) {
-                            themisCacheService.removeTodayExamListCache(entry.getKey(), e.getExamActivityId());
+                            themisCacheService.removeCurrentExamListCache(entry.getKey(), e.getExamActivityId());
                         }
                     }
                 } else {
-                    themisCacheService.removeTodayExamListCache(entry.getKey());
+                    themisCacheService.removeCurrentExamListCache(entry.getKey());
                 }
             }
         }

+ 1 - 1
themis-task/src/main/java/com/qmth/themis/task/start/StartRunning.java

@@ -58,7 +58,7 @@ public class StartRunning implements CommandLineRunner {
     public void run(String... args) throws Exception {
         log.info("服务器启动时执行 start");
         log.info("增加mqjob start");
-        themisCacheService.setTodayExamListCache();
+        themisCacheService.setCurrentExamListCache();
         themisCacheService.setOrgExamListCache();
 
         Map mqMap = new HashMap();