|
@@ -10,12 +10,15 @@ import javax.annotation.Resource;
|
|
import org.apache.commons.lang3.RandomStringUtils;
|
|
import org.apache.commons.lang3.RandomStringUtils;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import com.qmth.themis.business.bean.exam.MobileAnswerSubmitReponseBean;
|
|
import com.qmth.themis.business.bean.mobile.MobileAuthorizationBean;
|
|
import com.qmth.themis.business.bean.mobile.MobileAuthorizationBean;
|
|
import com.qmth.themis.business.bean.mobile.MobileAuthorizationMonitorBean;
|
|
import com.qmth.themis.business.bean.mobile.MobileAuthorizationMonitorBean;
|
|
import com.qmth.themis.business.bean.mobile.MobileAuthorizationParamBean;
|
|
import com.qmth.themis.business.bean.mobile.MobileAuthorizationParamBean;
|
|
import com.qmth.themis.business.bean.mobile.MobileAuthorizationUploadBean;
|
|
import com.qmth.themis.business.bean.mobile.MobileAuthorizationUploadBean;
|
|
import com.qmth.themis.business.cache.ExamRecordCacheUtil;
|
|
import com.qmth.themis.business.cache.ExamRecordCacheUtil;
|
|
import com.qmth.themis.business.cache.MobileAuthCacheUtil;
|
|
import com.qmth.themis.business.cache.MobileAuthCacheUtil;
|
|
|
|
+import com.qmth.themis.business.cache.RedisKeyHelper;
|
|
|
|
+import com.qmth.themis.business.cache.bean.ExamStudentAnswerCacheBean;
|
|
import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
|
|
import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
import com.qmth.themis.business.dto.AuthDto;
|
|
import com.qmth.themis.business.dto.AuthDto;
|
|
@@ -134,4 +137,43 @@ public class TEMobileServiceImpl implements TEMobileService {
|
|
ret.setSubIndex(subIndex);
|
|
ret.setSubIndex(subIndex);
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public MobileAnswerSubmitReponseBean answerSubmit(Long studentId, Long recordId, Integer mainNumber, Integer subNumber, Integer subIndex,
|
|
|
|
+ String answer) {
|
|
|
|
+
|
|
|
|
+ // 校验当前登录用户和参数一致性
|
|
|
|
+ if (ExamRecordCacheUtil.getId(recordId) == null) {
|
|
|
|
+ throw new BusinessException("未找到考试记录");
|
|
|
|
+ }
|
|
|
|
+ Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
|
|
|
|
+ ExamStudentCacheBean es = (ExamStudentCacheBean) redisUtil
|
|
|
|
+ .get(RedisKeyHelper.examStudentCacheKey(examStudentId));
|
|
|
|
+ if (es == null) {
|
|
|
|
+ throw new BusinessException("未找到考生");
|
|
|
|
+ }
|
|
|
|
+ if (!studentId.equals(es.getStudentId())) {
|
|
|
|
+ throw new BusinessException("考试记录的学生Id和当前登录用户不一致");
|
|
|
|
+ }
|
|
|
|
+ ExamRecordStatusEnum sta=ExamRecordCacheUtil.getStatus(recordId);
|
|
|
|
+ if(ExamRecordStatusEnum.FINISHED.equals(sta)||ExamRecordStatusEnum.PERSISTED.equals(sta)) {
|
|
|
|
+ throw new BusinessException("该考试已结束");
|
|
|
|
+ }
|
|
|
|
+ ExamStudentAnswerCacheBean answerCache = (ExamStudentAnswerCacheBean) redisUtil.get(
|
|
|
|
+ RedisKeyHelper.examAnswerKey(recordId),
|
|
|
|
+ RedisKeyHelper.examAnswerHashKey(mainNumber, subNumber, subIndex));
|
|
|
|
+ if (answerCache == null) {
|
|
|
|
+ answerCache = new ExamStudentAnswerCacheBean();
|
|
|
|
+ answerCache.setMainNumber(mainNumber);
|
|
|
|
+ answerCache.setSubNumber(subNumber);
|
|
|
|
+ answerCache.setSubIndex(subIndex);
|
|
|
|
+ answerCache.setAnswer(answer);
|
|
|
|
+ }
|
|
|
|
+ // 更新考生作答
|
|
|
|
+ redisUtil.set(RedisKeyHelper.examAnswerKey(recordId),
|
|
|
|
+ RedisKeyHelper.examAnswerHashKey(mainNumber, subNumber, subIndex), answerCache);
|
|
|
|
+ MobileAnswerSubmitReponseBean ret = new MobileAnswerSubmitReponseBean();
|
|
|
|
+ ret.setUpdateTime(new Date().getTime());
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
}
|
|
}
|