wangliang 1 年之前
父節點
當前提交
1fc00f771a

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

@@ -103,14 +103,6 @@ public class TEExamSummaryServiceImpl extends ServiceImpl<TEExamSummaryMapper, T
             teExamSummary.setExamId(examId);
             teExamSummary.setExamActivityId(examActivityId);
             teExamSummary.setRoomCode(s);
-            ExamActivityCacheBean ac = teExamActivityService.getExamActivityCacheBean(examActivityId);
-            long timestamp = System.currentTimeMillis();
-            if (ac.getFinishTime() <= timestamp) {//当考试场次结束时间已过,缺考=全部应考-已完成考试
-                teExamSummary.setAbsentCount(teExamSummary.getTotalCount() - teExamSummary.getFinishCount());
-            } else {
-                Integer absentCount = teExamStudentService.getAbsentCount(examId, examActivityId, s);
-                teExamSummary.setAbsentCount(Objects.nonNull(absentCount) ? absentCount : 0);
-            }
             TEExamSummary teExamSummaryDb = this.getOne(new QueryWrapper<TEExamSummary>().lambda()
                     .eq(TEExamSummary::getExamId, examId)
                     .eq(TEExamSummary::getExamActivityId, examActivityId)
@@ -133,6 +125,14 @@ public class TEExamSummaryServiceImpl extends ServiceImpl<TEExamSummaryMapper, T
                 teExamSummaryDb.setId(id);
                 teExamSummaryDb.setFinishCount(finishCount);
             }
+            ExamActivityCacheBean ac = teExamActivityService.getExamActivityCacheBean(examActivityId);
+            long timestamp = System.currentTimeMillis();
+            if (ac.getFinishTime() <= timestamp) {//当考试场次结束时间已过,缺考=全部应考-已完成考试
+                teExamSummaryDb.setAbsentCount(teExamSummaryDb.getTotalCount() - teExamSummaryDb.getFinishCount());
+            } else {
+                Integer absentCount = teExamStudentService.getAbsentCount(examId, examActivityId, s);
+                teExamSummaryDb.setAbsentCount(Objects.nonNull(absentCount) ? absentCount : 0);
+            }
             this.saveOrUpdate(teExamSummaryDb);
             themisCacheService.updateExamSummaryCache(examId, examActivityId, s);
         }

+ 17 - 15
themis-business/src/main/java/com/qmth/themis/business/service/impl/ThemisCacheServiceImpl.java

@@ -777,22 +777,24 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
     @Override
     public void removeOrgExamListCache(String orgId, String examId, Long examActivityId) {
         Map<String, Set<Long>> map = this.getOrgExamListCache(orgId);
-        CopyOnWriteArraySet<Long> examActivityIdSet = new CopyOnWriteArraySet<>();
-        examActivityIdSet.addAll(map.get(examId));
-        for (Long l : examActivityIdSet) {
-            if (l.longValue() == examActivityId.longValue()) {
-                examActivityIdSet.remove(l);
-                break;
+        if (!CollectionUtils.isEmpty(map.get(examId))) {
+            CopyOnWriteArraySet<Long> examActivityIdSet = new CopyOnWriteArraySet<>();
+            examActivityIdSet.addAll(map.get(examId));
+            for (Long l : examActivityIdSet) {
+                if (l.longValue() == examActivityId.longValue()) {
+                    examActivityIdSet.remove(l);
+                    break;
+                }
+            }
+            if (CollectionUtils.isEmpty(examActivityIdSet)) {
+                this.removeOrgExamListCache(orgId, examId);
+            } else {
+                redisUtil.set(SystemConstant.ORG_EXAM_LIST_MAP_CACHE + orgId, examId, new HashSet<>(examActivityIdSet));
+            }
+            map = this.getOrgExamListCache(orgId);
+            if (CollectionUtils.isEmpty(map)) {
+                this.removeOrgExamListCache(orgId);
             }
-        }
-        if (CollectionUtils.isEmpty(examActivityIdSet)) {
-            this.removeOrgExamListCache(orgId, examId);
-        } else {
-            redisUtil.set(SystemConstant.ORG_EXAM_LIST_MAP_CACHE + orgId, examId, new HashSet<>(examActivityIdSet));
-        }
-        map = this.getOrgExamListCache(orgId);
-        if (CollectionUtils.isEmpty(map)) {
-            this.removeOrgExamListCache(orgId);
         }
     }