xiatian пре 4 година
родитељ
комит
f6b4b68233

+ 12 - 1
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamServiceImpl.java

@@ -42,6 +42,7 @@ import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
 import com.qmth.themis.business.cache.bean.ExamStudentPaperStructCacheBean;
 import com.qmth.themis.business.config.SystemConfig;
 import com.qmth.themis.business.dao.TEExamMapper;
+import com.qmth.themis.business.dto.cache.TEStudentCacheDto;
 import com.qmth.themis.business.dto.response.TEExamActivityDto;
 import com.qmth.themis.business.dto.response.TEExamDto;
 import com.qmth.themis.business.entity.TEExam;
@@ -154,12 +155,16 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
             es = teExamStudentService.getExamStudnetCacheBean(examStudentId);
         }
         if (es == null) {
-            throw new BusinessException("未找到考");
+            throw new BusinessException("未找到考");
         }
 
         if (!studentId.equals(es.getStudentId())) {
             throw new BusinessException("考生Id和当前登录用户不一致");
         }
+        TEStudentCacheDto teStudentCacheDto = (TEStudentCacheDto) redisUtil.getStudent(es.getStudentId());
+        if(teStudentCacheDto.getUnFinishedRecordId()!=null) {
+        	throw new BusinessException("有尚未完成的考试,不能再次开始候考");
+        }
         if (es.getLeftExamCount() == 0) {
             throw new BusinessException("没有剩余考试次数");
         }
@@ -229,6 +234,8 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         redisUtil.set(RedisKeyHelper.examStudentCacheKey(examStudentId), es);
         //更新场次-考试记录缓存
         ExamActivityRecordCacheUtil.setExamRecordStatus(activityId, recordId, ExamRecordCacheUtil.getStatus(recordId));
+        teStudentCacheDto.setUnFinishedRecordId(recordId);
+        redisUtil.setStudent(studentId, teStudentCacheDto, null, null);
         return ret;
     }
 
@@ -581,6 +588,10 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         ExamRecordCacheUtil.setStatus(recordId, ExamRecordStatusEnum.FINISHED);
         //更新场次-考试记录缓存
         ExamActivityRecordCacheUtil.setExamRecordStatus(es.getExamActivityId(), recordId, ExamRecordCacheUtil.getStatus(recordId));
+        //更新未完成考试记录id
+        TEStudentCacheDto teStudentCacheDto = (TEStudentCacheDto) redisUtil.getStudent(es.getStudentId());
+        teStudentCacheDto.setUnFinishedRecordId(null);
+        redisUtil.setStudent(studentId, teStudentCacheDto, null, null);
         return ret;
     }