xiatian 4 лет назад
Родитель
Сommit
f9ff63edbe

+ 4 - 5
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamServiceImpl.java

@@ -390,12 +390,11 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
             answerCache.setVersion(version);
             answerCache.setDurationSeconds(durationSeconds);
         } else {
-            if (version.longValue() < answerCache.getVersion().longValue()) {
-                throw new BusinessException("版本时间戳过期");
+            if (version.longValue() > answerCache.getVersion().longValue()) {
+	            answerCache.setAnswer(answer);
+	            answerCache.setVersion(version);
+	            answerCache.setDurationSeconds(durationSeconds);
             }
-            answerCache.setAnswer(answer);
-            answerCache.setVersion(version);
-            answerCache.setDurationSeconds(durationSeconds);
         }
         // 每次提交,清空得分
         answerCache.setScore(null);

+ 20 - 29
themis-exam/src/main/java/com/qmth/themis/exam/api/TEExamController.java

@@ -163,37 +163,28 @@ public class TEExamController {
 	@ApiResponses({ @ApiResponse(code = 200, message = "试卷信息") })
 	public Result answerSubmit(@RequestBody AnswerSubmitParamBean param) {
 		TEStudentCacheDto teStudent = (TEStudentCacheDto) ServletUtil.getRequestStudentAccount();
-		String lockKey = SystemConstant.REDIS_LOCK_STUDENT_PREFIX + teStudent.getId();
-		Boolean lock = redisUtil.lock(lockKey, SystemConstant.REDIS_CACHE_TIME_OUT);
-		if (!lock) {
-			throw new BusinessException(ExceptionResultEnum.REQUEST_AWAIT);
+		if (param.getRecordId() == null) {
+			throw new BusinessException("考试记录id不能为空");
 		}
-		try {
-			if (param.getRecordId() == null) {
-				throw new BusinessException("考试记录id不能为空");
-			}
-			if (param.getMainNumber() == null) {
-				throw new BusinessException("大题号不能为空");
-			}
-			if (param.getSubNumber() == null) {
-				throw new BusinessException("小题号不能为空");
-			}
-			if (param.getAnswer() == null) {
-				throw new BusinessException("答案json字符串不能为空");
-			}
-			if (param.getVersion() == null) {
-				throw new BusinessException("时间戳不能为空");
-			}
-			AnswerSubmitBean ret = teExamService.answerSubmit(teStudent.getId(), param.getRecordId(), param.getMainNumber(),
-					param.getSubNumber(), param.getSubIndex(), param.getAnswer(), param.getVersion(),
-					param.getDurationSeconds());
-			// 发消息计算客观分
-			calculateObjectiveScore(param.getRecordId(), param.getMainNumber(), param.getSubNumber(),
-					param.getSubIndex());
-			return ResultUtil.ok(ret);
-		} finally {
-			redisUtil.releaseLock(lockKey);
+		if (param.getMainNumber() == null) {
+			throw new BusinessException("大题号不能为空");
+		}
+		if (param.getSubNumber() == null) {
+			throw new BusinessException("小题号不能为空");
+		}
+		if (param.getAnswer() == null) {
+			throw new BusinessException("答案json字符串不能为空");
+		}
+		if (param.getVersion() == null) {
+			throw new BusinessException("时间戳不能为空");
 		}
+		AnswerSubmitBean ret = teExamService.answerSubmit(teStudent.getId(), param.getRecordId(), param.getMainNumber(),
+				param.getSubNumber(), param.getSubIndex(), param.getAnswer(), param.getVersion(),
+				param.getDurationSeconds());
+		// 发消息计算客观分
+		calculateObjectiveScore(param.getRecordId(), param.getMainNumber(), param.getSubNumber(),
+				param.getSubIndex());
+		return ResultUtil.ok(ret);
 	}
 
 	@ApiOperation(value = "更新音频剩余播放次数")