wangliang 1 éve
szülő
commit
3b9168a951

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

@@ -312,6 +312,13 @@ public interface ThemisCacheService {
      */
     public void setTodayExamListCache();
 
+    /**
+     * 获取当天考试列表缓存
+     *
+     * @return
+     */
+    public Map<String, List<ExamListBean>> getTodayExamListCache();
+
     /**
      * 设置机构考试列表缓存
      */

+ 18 - 8
themis-business/src/main/java/com/qmth/themis/business/service/impl/ThemisCacheServiceImpl.java

@@ -623,8 +623,8 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
             //统计当天00:00:00~23:59:59可以进行的考试批次、场次、考场编码信息
             if (!CollectionUtils.isEmpty(teExamActivityList)) {
                 LinkedMultiValueMap<Long, ExamListBean> todayExamListMap = new LinkedMultiValueMap<>();//考试批次、场次集合/考场编码集合
-                Map<Long, Set<Long>> examActivityIdMap = new LinkedHashMap<>();//考试批次id,场次id集合
-                Map<Long, Set<String>> roomCodeMap = new LinkedHashMap<>();//考试场次id,考场编码集合
+                Map<Long, Set<Long>> examActivityIdMap = new HashMap<>();//考试批次id,场次id集合
+                Map<Long, Set<String>> roomCodeMap = new HashMap<>();//考试场次id,考场编码集合
                 for (TEExamActivity t : teExamActivityList) {
                     ExamCacheBean examCacheBean = teExamService.getExamCacheBean(t.getExamId());
                     if (Objects.nonNull(examCacheBean.getEnable()) && examCacheBean.getEnable().intValue() == 1 && Objects.nonNull(t.getEnable()) && t.getEnable().intValue() == 1) {
@@ -657,6 +657,16 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
         }
     }
 
+    /**
+     * 获取当天考试列表缓存
+     *
+     * @return
+     */
+    @Override
+    public Map<String, List<ExamListBean>> getTodayExamListCache() {
+        return redisUtil.getHashEntries(SystemConstant.TODAY_EXAM_LIST_MAP_CACHE);
+    }
+
     /**
      * 设置考试列表缓存
      */
@@ -665,8 +675,8 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
         //查询考试场次结束时间大于当前时间的所有考试
         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 LinkedHashMap<>();//机构id,考试批次id集合
-            Map<Long, Set<Long>> examMap = new LinkedHashMap<>();//考试批次id,场次id集合
+            Map<Long, Set<Long>> orgMap = new HashMap<>();//机构id,考试批次id集合
+            Map<Long, Set<Long>> examMap = new HashMap<>();//考试批次id,场次id集合
             for (TEExamActivity t : teExamActivityList) {
                 ExamCacheBean examCacheBean = teExamService.getExamCacheBean(t.getExamId());
                 if (Objects.nonNull(examCacheBean.getEnable()) && examCacheBean.getEnable().intValue() == 1) {
@@ -714,7 +724,7 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
      */
     @Override
     public Set<Long> getOrgExamListCache(String orgId, String examId) {
-        Map<String, Set<Long>> map = redisUtil.getHashEntries(SystemConstant.ORG_EXAM_LIST_MAP_CACHE + orgId);
+        Map<String, Set<Long>> map = this.getOrgExamListCache(orgId);
         return !CollectionUtils.isEmpty(map) ? map.get(examId) : null;
     }
 
@@ -725,7 +735,7 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
      */
     @Override
     public void updateOrgExamListCache(String orgId, String examId, Long examActivityId) {
-        Map<String, Set<Long>> map = redisUtil.getHashEntries(SystemConstant.ORG_EXAM_LIST_MAP_CACHE + orgId);
+        Map<String, Set<Long>> map = this.getOrgExamListCache(orgId);
         if (CollectionUtils.isEmpty(map)) {
             redisUtil.set(SystemConstant.ORG_EXAM_LIST_MAP_CACHE + orgId, examId, new HashSet<>(Arrays.asList(examActivityId)));
         } else {
@@ -768,7 +778,7 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
      */
     @Override
     public void removeOrgExamListCache(String orgId, String examId, Long examActivityId) {
-        Map<String, Set<Long>> map = redisUtil.getHashEntries(SystemConstant.ORG_EXAM_LIST_MAP_CACHE + orgId);
+        Map<String, Set<Long>> map = this.getOrgExamListCache(orgId);
         CopyOnWriteArraySet<Long> examActivityIdSet = new CopyOnWriteArraySet<>();
         examActivityIdSet.addAll(map.get(examId));
         for (Long l : examActivityIdSet) {
@@ -793,7 +803,7 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
      */
     @Override
     public List<ExamListBean> getTodayExamListCache(String examId) {
-        Map<String, List<ExamListBean>> map = redisUtil.getHashEntries(SystemConstant.TODAY_EXAM_LIST_MAP_CACHE);
+        Map<String, List<ExamListBean>> map = this.getTodayExamListCache();
         return !CollectionUtils.isEmpty(map) ? map.get(examId) : null;
     }
 

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

@@ -7,7 +7,6 @@ import com.qmth.themis.business.cache.bean.ExamCacheBean;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.entity.TBOrg;
 import com.qmth.themis.business.service.*;
-import com.qmth.themis.business.util.RedisUtil;
 import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
 import org.slf4j.Logger;
@@ -49,13 +48,10 @@ public class ExamSummaryJob extends QuartzJobBean {
     @Resource
     TERegionSummaryService teRegionSummaryService;
 
-    @Resource
-    RedisUtil redisUtil;
-
     @Override
     protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
         log.info("ExamSummaryJob进来了,context:{}", context);
-        Map<String, List<ExamListBean>> examListMap = redisUtil.getHashEntries(SystemConstant.TODAY_EXAM_LIST_MAP_CACHE);
+        Map<String, List<ExamListBean>> examListMap = themisCacheService.getTodayExamListCache();
         //获取当天考试列表
         if (!CollectionUtils.isEmpty(examListMap)) {
             LinkedMultiValueMap<Long, Long> orgExamIdMap = new LinkedMultiValueMap<>();//机构/考试批次id列表map

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

@@ -65,7 +65,7 @@ public class MqActivityJob extends QuartzJobBean {
         log.info("mq_activity_job进来了,context:{}", context);
         themisCacheService.setTodayExamListCache();
         //每天凌晨清理考试缓存数据
-        Map<String, List<ExamListBean>> examListMap = redisUtil.getHashEntries(SystemConstant.TODAY_EXAM_LIST_MAP_CACHE);
+        Map<String, List<ExamListBean>> examListMap = themisCacheService.getTodayExamListCache();
         if (!CollectionUtils.isEmpty(examListMap)) {
             for (Map.Entry<String, List<ExamListBean>> entry : examListMap.entrySet()) {
                 Long examId = Long.parseLong(entry.getKey());