瀏覽代碼

增加考试改变zset

wangliang 1 年之前
父節點
當前提交
6ac29bebdb

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

@@ -502,20 +502,35 @@ public class TEExamController {
         if (Objects.nonNull(examId) && Objects.nonNull(examActivityId) && !CollectionUtils.isEmpty(roomCodeSet)) {
             for (String s : roomCodeSet) {
                 if (freshen) {
-                    teExamSummaryService.examSummary(examId, examActivityId, Objects.nonNull(s) ? new HashSet<>(Arrays.asList(s)) : null);
+                    teExamSummaryService.examSummary(examId, examActivityId, Objects.nonNull(s) ? new HashSet<>(Arrays.asList(s)) : null, true);
                 }
-                teExamSummaryAllList.addAll(themisCacheService.getExamSummaryCache(examId, examActivityId, s));
+                List<TEExamSummary> teExamSummaryList = themisCacheService.getExamSummaryCache(examId, examActivityId, s);
+                if (!CollectionUtils.isEmpty(teExamSummaryList)) {
+                    teExamSummaryService.examSummary(examId, examActivityId, Objects.nonNull(s) ? new HashSet<>(Arrays.asList(s)) : null, true);
+                    teExamSummaryList = themisCacheService.getExamSummaryCache(examId, examActivityId, s);
+                }
+                teExamSummaryAllList.addAll(teExamSummaryList);
             }
         } else if (Objects.nonNull(examId) && Objects.nonNull(examActivityId)) {
             if (freshen) {
-                teExamSummaryService.examSummary(examId, examActivityId, null);
+                teExamSummaryService.examSummary(examId, examActivityId, null, true);
+            }
+            List<TEExamSummary> teExamSummaryList = themisCacheService.getExamSummaryCache(examId, examActivityId);
+            if (!CollectionUtils.isEmpty(teExamSummaryList)) {
+                teExamSummaryService.examSummary(examId, examActivityId, null, true);
+                teExamSummaryList = themisCacheService.getExamSummaryCache(examId, examActivityId);
             }
-            teExamSummaryAllList.addAll(themisCacheService.getExamSummaryCache(examId, examActivityId));
+            teExamSummaryAllList.addAll(teExamSummaryList);
         } else {
             if (freshen) {
-                teExamSummaryService.examSummary(examId, null, null);
+                teExamSummaryService.examSummary(examId, null, null, true);
+            }
+            List<TEExamSummary> teExamSummaryList = themisCacheService.getExamSummaryCache(examId);
+            if (!CollectionUtils.isEmpty(teExamSummaryList)) {
+                teExamSummaryService.examSummary(examId, null, null, true);
+                teExamSummaryList = themisCacheService.getExamSummaryCache(examId);
             }
-            teExamSummaryAllList.addAll(themisCacheService.getExamSummaryCache(examId));
+            teExamSummaryAllList.addAll(teExamSummaryList);
         }
         ExamPropCountDto examPropCountDto = new ExamPropCountDto(examId, 0, 0, 0, 0, 0, BigDecimal.valueOf(0));
         if (!CollectionUtils.isEmpty(teExamSummaryAllList)) {

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

@@ -21,7 +21,8 @@ public interface TEExamSummaryService extends IService<TEExamSummary> {
      * @param examId
      * @param examActivityId
      * @param roomCodeSet
+     * @param freshen
      * @return
      */
-    boolean examSummary(Long examId, Long examActivityId, Set<String> roomCodeSet);
+    boolean examSummary(Long examId, Long examActivityId, Set<String> roomCodeSet, boolean freshen);
 }

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

@@ -47,19 +47,22 @@ public class TEExamSummaryServiceImpl extends ServiceImpl<TEExamSummaryMapper, T
      * @param examId
      * @param examActivityId
      * @param roomCodeSet
+     * @param freshen
      * @return
      */
     @Override
-    public boolean examSummary(Long examId, Long examActivityId, Set<String> roomCodeSet) {
+    public boolean examSummary(Long examId, Long examActivityId, Set<String> roomCodeSet, boolean freshen) {
         boolean updateCache = false;
         if (!CollectionUtils.isEmpty(roomCodeSet)) {
             for (String s : roomCodeSet) {
                 Long l = themisCacheService.getExamRecordChangeCache(examActivityId + "_" + s);
-                if (Objects.nonNull(l) && System.currentTimeMillis() - l.longValue() <= 1000 * 60 * 1) {
+                if ((Objects.nonNull(l) && System.currentTimeMillis() - l.longValue() <= 1000 * 60 * 1) || freshen) {
                     //根据考试批次、场次、考场编码统计信息
                     TEExamSummary teExamSummary = this.baseMapper.examSummary(examId, examActivityId, s);
                     this.examSummaryCommon(examId, examActivityId, s, teExamSummary);
                     updateCache = true;
+                } else {
+                    themisCacheService.getExamSummaryCache(examId, examActivityId, s);
                 }
             }
             if (updateCache) {

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

@@ -876,12 +876,7 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
         if (Objects.nonNull(roomCode)) {
             teExamSummaryQueryWrapper.lambda().eq(TEExamSummary::getRoomCode, roomCode);
         }
-        List<TEExamSummary> teExamSummaryList = teExamSummaryService.list(teExamSummaryQueryWrapper);
-        if (CollectionUtils.isEmpty(teExamSummaryList)) {
-            teExamSummaryService.examSummary(examId, examActivityId, Objects.nonNull(roomCode) ? new HashSet<>(Arrays.asList(roomCode)) : null);
-            teExamSummaryList = teExamSummaryService.list(teExamSummaryQueryWrapper);
-        }
-        return teExamSummaryList;
+        return teExamSummaryService.list(teExamSummaryQueryWrapper);
     }
 
     /**

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

@@ -79,7 +79,7 @@ public class ExamSummaryJob extends QuartzJobBean {
                         log.info("examSummaryJob examId:{},examActivityId:{},startTime:{},endTime:{}", examId, e.getExamActivityId(), DateUtil.format(new Date(startTime), "yyyy-MM-dd HH:mm:ss"), DateUtil.format(new Date(endTime), "yyyy-MM-dd HH:mm:ss"));
                         if (startTime <= timestamp && endTime >= timestamp) {
                             log.info("examSummaryJob examId:{},examActivityId:{},roomCodeSet:{} 开始统计", examId, e.getExamActivityId(), roomCodeSet);
-                            boolean change = teExamSummaryService.examSummary(examId, e.getExamActivityId(), roomCodeSet);
+                            boolean change = teExamSummaryService.examSummary(examId, e.getExamActivityId(), roomCodeSet, false);
                             if (change) {
                                 teRegionSummaryService.regionSummary(examId, e.getExamActivityId());
                                 //统计机构信息