Browse Source

修复会话过期的bug

lideyin 5 years ago
parent
commit
dcb35c628c

+ 16 - 0
examcloud-core-oe-task-service/src/main/java/cn/com/qmth/examcloud/core/oe/task/service/pipeline/ClearExamDataCacheExecutor.java

@@ -6,10 +6,12 @@ import cn.com.qmth.examcloud.commons.helpers.pipeline.NodeExecuter;
 import cn.com.qmth.examcloud.commons.helpers.pipeline.TaskContext;
 import cn.com.qmth.examcloud.commons.helpers.pipeline.TaskContext;
 import cn.com.qmth.examcloud.commons.logging.ExamCloudLog;
 import cn.com.qmth.examcloud.commons.logging.ExamCloudLog;
 import cn.com.qmth.examcloud.commons.logging.ExamCloudLogFactory;
 import cn.com.qmth.examcloud.commons.logging.ExamCloudLogFactory;
+import cn.com.qmth.examcloud.core.oe.task.service.ExamingSessionService;
 import cn.com.qmth.examcloud.support.Constants;
 import cn.com.qmth.examcloud.support.Constants;
 import cn.com.qmth.examcloud.support.enums.SyncStatus;
 import cn.com.qmth.examcloud.support.enums.SyncStatus;
 import cn.com.qmth.examcloud.support.examing.ExamBoss;
 import cn.com.qmth.examcloud.support.examing.ExamBoss;
 import cn.com.qmth.examcloud.support.examing.ExamRecordData;
 import cn.com.qmth.examcloud.support.examing.ExamRecordData;
+import cn.com.qmth.examcloud.support.examing.ExamingSession;
 import cn.com.qmth.examcloud.support.redis.RedisKeyHelper;
 import cn.com.qmth.examcloud.support.redis.RedisKeyHelper;
 import cn.com.qmth.examcloud.web.bootstrap.PropertyHolder;
 import cn.com.qmth.examcloud.web.bootstrap.PropertyHolder;
 import cn.com.qmth.examcloud.web.helpers.SequenceLockHelper;
 import cn.com.qmth.examcloud.web.helpers.SequenceLockHelper;
@@ -31,6 +33,8 @@ public class ClearExamDataCacheExecutor implements NodeExecuter<Long, ExamRecord
 
 
     @Autowired
     @Autowired
     private RedisClient redisClient;
     private RedisClient redisClient;
+    @Autowired
+    private ExamingSessionService examingSessionService;
     private static final ExamCloudLog LOG = ExamCloudLogFactory.getLog(ClearExamDataCacheExecutor.class);
     private static final ExamCloudLog LOG = ExamCloudLogFactory.getLog(ClearExamDataCacheExecutor.class);
 
 
     /**
     /**
@@ -74,6 +78,12 @@ public class ClearExamDataCacheExecutor implements NodeExecuter<Long, ExamRecord
                 redisClient.delete(RedisKeyHelper.getBuilder().examingHeartbeatKey(examRecordDataId));
                 redisClient.delete(RedisKeyHelper.getBuilder().examingHeartbeatKey(examRecordDataId));
 
 
                 //清除考试会话缓存
                 //清除考试会话缓存
+                ExamingSession examingSession = examingSessionService.getExamingSession(examRecordData.getStudentId());
+                if (null != examingSession && examingSession.getExamRecordDataId().equals(examRecordDataId)) {
+                    String sessionKey = RedisKeyHelper.getBuilder().examingSessionKey(examRecordData.getStudentId());
+                    redisClient.delete(sessionKey);
+                    this.infoLog(String.format("清理交卷未删除的会话:%s", sessionKey), examRecordDataId);
+                }
                 redisClient.delete(RedisKeyHelper.getBuilder().examingSessionKey(examRecordData.getStudentId()));
                 redisClient.delete(RedisKeyHelper.getBuilder().examingSessionKey(examRecordData.getStudentId()));
 
 
                 //清除文件作答和普通作答记录缓存
                 //清除文件作答和普通作答记录缓存
@@ -132,4 +142,10 @@ public class ClearExamDataCacheExecutor implements NodeExecuter<Long, ExamRecord
             LOG.debug("[CLEAR-EXAM-DATA-CACHE-EXECUTOR-" + examRecordDataId + "]:" + msg);
             LOG.debug("[CLEAR-EXAM-DATA-CACHE-EXECUTOR-" + examRecordDataId + "]:" + msg);
         }
         }
     }
     }
+
+    private void infoLog(String msg, Long examRecordDataId) {
+        if (LOG.isInfoEnabled()) {
+            LOG.info("[CLEAR-EXAM-DATA-CACHE-EXECUTOR-" + examRecordDataId + "]:" + msg);
+        }
+    }
 }
 }