wangliang hace 4 años
padre
commit
a3d40882c1

+ 12 - 5
themis-exam/src/main/java/com/qmth/themis/exam/api/TEStudentController.java

@@ -12,12 +12,14 @@ import com.qmth.themis.business.dto.AuthDto;
 import com.qmth.themis.business.dto.cache.TEStudentCacheDto;
 import com.qmth.themis.business.dto.response.TEExamDto;
 import com.qmth.themis.business.dto.response.TEExamResultDto;
-import com.qmth.themis.business.dto.response.TEExamUnFinishDto;
 import com.qmth.themis.business.entity.TBSession;
 import com.qmth.themis.business.entity.TEConfig;
 import com.qmth.themis.business.entity.TEStudent;
 import com.qmth.themis.business.enums.*;
-import com.qmth.themis.business.service.*;
+import com.qmth.themis.business.service.CacheService;
+import com.qmth.themis.business.service.TEConfigService;
+import com.qmth.themis.business.service.TEExamService;
+import com.qmth.themis.business.service.TEStudentService;
 import com.qmth.themis.business.util.JacksonUtil;
 import com.qmth.themis.business.util.RedisUtil;
 import com.qmth.themis.business.util.ServletUtil;
@@ -187,16 +189,21 @@ public class TEStudentController {
             Map<String, Object> objectMap = redisUtil.getHashEntries(RedisKeyHelper.examRecordCacheKey(recordId));
             Long examIdMap = Long.parseLong(String.valueOf(objectMap.get("examId")));
             Long examStudentId = Long.parseLong(String.valueOf(objectMap.get("examStudentId")));
-            Integer durationSeconds = Integer.parseInt(String.valueOf(objectMap.get("durationSeconds")));
+            Integer durationSeconds = null;
+            if (Objects.isNull(objectMap.get("durationSeconds"))) {
+                durationSeconds = 0;
+            } else {
+                durationSeconds = Integer.parseInt(String.valueOf(objectMap.get("durationSeconds")));
+            }
             //获取考试缓存
             ExamCacheBean ec = teExamService.getExamCacheBean(examIdMap);
 
             //获取最近同步时间
             Date clientLastSyncTime = ExamRecordCacheUtil.getClientLastSyncTime(recordId);
             //获取剩余断点次数
-            Integer leftBreakResumeCount = ExamRecordCacheUtil.getLeftBreakResumeCount(recordId);
+            Integer leftBreakResumeCount = Objects.isNull(ExamRecordCacheUtil.getLeftBreakResumeCount(recordId)) ? 0 : ExamRecordCacheUtil.getLeftBreakResumeCount(recordId);
             //如果断点时间大于整体断点时间,则强制交卷
-            if ((System.currentTimeMillis() - clientLastSyncTime.getTime() / 1000) > ec.getBreakExpireSeconds()) {
+            if (Objects.nonNull(clientLastSyncTime) && (System.currentTimeMillis() - clientLastSyncTime.getTime() / 1000) > ec.getBreakExpireSeconds()) {
                 teExamService.finish(examStudentId, recordId, FinishTypeEnum.AUTO.name(), durationSeconds);
             } else {//否则断点次数减1
                 leftBreakResumeCount--;