|
@@ -186,33 +186,33 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|
|
|
|
// try {
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
- // 获取考生信息
|
|
|
- ExamStudentEntity examStudentEntity = examStudentRepo.findByExamStudentId(examStudentId);
|
|
|
+ // 获取原始考生信息
|
|
|
+ ExamStudentEntity originalExamStudent = examStudentRepo.findByExamStudentId(examStudentId);
|
|
|
if (log.isDebugEnabled()) {
|
|
|
log.debug("1 获取考生信息耗时:" + (System.currentTimeMillis() - startTime) + " ms");
|
|
|
}
|
|
|
- if (examStudentEntity == null) {
|
|
|
+ if (originalExamStudent == null) {
|
|
|
throw new StatusException("ExamControlServiceImpl-startExam-exception", "考生不存在");
|
|
|
}
|
|
|
- if (examStudentEntity.getStudentId().longValue() != user.getUserId().longValue()) {
|
|
|
+ if (originalExamStudent.getStudentId().longValue() != user.getUserId().longValue()) {
|
|
|
throw new StatusException("ExamControlServiceImpl-startExam-exception", "考生与当前用户不吻合");
|
|
|
}
|
|
|
// 检查redis session
|
|
|
ExamSessionInfo examSessionInfo = examSessionInfoService
|
|
|
- .getExamSessionInfo(examStudentEntity.getStudentId());
|
|
|
+ .getExamSessionInfo(originalExamStudent.getStudentId());
|
|
|
if (examSessionInfo != null) {
|
|
|
throw new StatusException("ExamControlServiceImpl-startExam-exception", "已经有考试中的科目");
|
|
|
}
|
|
|
// 检查并获取考试信息
|
|
|
startTime = System.currentTimeMillis();
|
|
|
- ExamBean examBean = checkExam(examStudentEntity);
|
|
|
+ ExamBean examBean = checkExam(originalExamStudent);
|
|
|
if (log.isDebugEnabled()) {
|
|
|
log.debug("2 检查并获取考试信息耗时:" + (System.currentTimeMillis() - startTime) + " ms");
|
|
|
}
|
|
|
|
|
|
// 检查并获取课程信息
|
|
|
startTime = System.currentTimeMillis();
|
|
|
- CourseBean courseBean = checkCourse(examStudentEntity);
|
|
|
+ CourseBean courseBean = checkCourse(originalExamStudent);
|
|
|
if (log.isDebugEnabled()) {
|
|
|
log.debug("3 检查并获取课程信息耗时:" + (System.currentTimeMillis() - startTime) + " ms");
|
|
|
}
|
|
@@ -222,20 +222,20 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|
|
|
|
//获取题库调卷规则
|
|
|
ExtractConfigCacheBean extractConfig = CacheHelper.getExtractConfig(
|
|
|
- examStudentEntity.getExamId(), courseBean.getCode());
|
|
|
+ originalExamStudent.getExamId(), courseBean.getCode());
|
|
|
//随机生成试卷
|
|
|
Map<String, String> paperTypeMaps = getExamPaperByProbability(extractConfig.getDetails());
|
|
|
if (paperTypeMaps.isEmpty()) {
|
|
|
throw new StatusException("100001", "生成试卷失败");
|
|
|
}
|
|
|
|
|
|
- String paperId = paperTypeMaps.get(examStudentEntity.getPaperType());
|
|
|
+ String paperId = paperTypeMaps.get(originalExamStudent.getPaperType());
|
|
|
if (StringUtils.isEmpty(paperId)) {
|
|
|
throw new StatusException("100002", "获取试卷失败");
|
|
|
}
|
|
|
//生成试卷结构
|
|
|
- ExtractConfigPaperCacheBean extractConfigPaper = CacheHelper.getExtractConfigPaper(examStudentEntity.getExamId(),
|
|
|
- courseBean.getCode(), examStudentEntity.getPaperType(), paperId);
|
|
|
+ ExtractConfigPaperCacheBean extractConfigPaper = CacheHelper.getExtractConfigPaper(originalExamStudent.getExamId(),
|
|
|
+ courseBean.getCode(), originalExamStudent.getPaperType(), paperId);
|
|
|
if (log.isDebugEnabled()) {
|
|
|
log.debug("4 获取题库试卷结构耗时:" + (System.currentTimeMillis() - startTime) + " ms");
|
|
|
}
|
|
@@ -258,17 +258,23 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|
|
|
|
// 更新考生信息
|
|
|
startTime = System.currentTimeMillis();
|
|
|
- examStudentEntity = examStudentService.updateExamStudentByStartExam(examStudentEntity, examBean);
|
|
|
+ examStudentService.updateExamStudentByStartExam(originalExamStudent.getId(),
|
|
|
+ originalExamStudent.getIsReExamine(), originalExamStudent.getReExamineCompleted(),
|
|
|
+ originalExamStudent.getNormalExamTimes(), examBean);
|
|
|
if (log.isDebugEnabled()) {
|
|
|
log.debug("7 更新考生信息耗时:" + (System.currentTimeMillis() - startTime) + " ms");
|
|
|
}
|
|
|
+ //获取更新完以后的考试记录实体
|
|
|
+ ExamStudentEntity newExamStudent = GlobalHelper.getEntity(examStudentRepo, originalExamStudent.getId(), ExamStudentEntity.class);
|
|
|
|
|
|
// 生成考试记录
|
|
|
startTime = System.currentTimeMillis();
|
|
|
- ExamRecordEntity examRecord = examRecordService.createExamRecord(examStudentEntity, examBean, courseBean,
|
|
|
+ ExamRecordEntity examRecord = examRecordService.createExamRecord(newExamStudent, examBean, courseBean,
|
|
|
paperId, examRecordPaperStruct.getId());
|
|
|
ExamRecordDataEntity examRecordData = examRecordDataService.createExamRecordData(examRecord,
|
|
|
- examStudentEntity, examBean, extractConfigPaper.getDefaultPaper().getFullyObjective());
|
|
|
+ newExamStudent.getNormalExamTimes(), examBean.getExamTimes(), originalExamStudent.getIsReExamine(),
|
|
|
+ extractConfigPaper.getDefaultPaper().getFullyObjective());
|
|
|
+
|
|
|
//生成进行中的考试记录
|
|
|
examRecordDataService.createExamingRecord(examRecord.getId(), examRecordData.getId(),
|
|
|
examRecord.getStudentId(), examRecord.getExamType());
|
|
@@ -296,7 +302,7 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|
// 创建考试会话
|
|
|
startTime = System.currentTimeMillis();
|
|
|
|
|
|
- initializeExamRecordSession(examStudentEntity, examRecordData, examBean);
|
|
|
+ initializeExamRecordSession(newExamStudent, examRecordData, examBean);
|
|
|
if (log.isDebugEnabled()) {
|
|
|
log.debug("11 创建考试会话耗时:" + (System.currentTimeMillis() - startTime) + " ms");
|
|
|
}
|
|
@@ -304,7 +310,7 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|
if (log.isDebugEnabled()) {
|
|
|
log.debug("12 合计 耗时:" + (System.currentTimeMillis() - st) + " ms");
|
|
|
}
|
|
|
- return buildStartExamInfo(examRecordData.getId(), examStudentEntity, examBean, courseBean);
|
|
|
+ return buildStartExamInfo(examRecordData.getId(), newExamStudent, examBean, courseBean);
|
|
|
// } finally {
|
|
|
//
|
|
|
// }
|
|
@@ -689,10 +695,10 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|
//系统在请求结束后会,自动释放锁,无需手动解锁
|
|
|
SequenceLockHelper.getLock(sequenceLockKey);
|
|
|
|
|
|
- //如果当前考试记录状态不为考试中,则直接返回
|
|
|
- if (examRecordData.getExamRecordStatus() != ExamRecordStatus.EXAM_ING) {
|
|
|
- return;
|
|
|
- }
|
|
|
+// //如果当前考试记录状态不为考试中,则直接返回
|
|
|
+// if (examRecordData.getExamRecordStatus() != ExamRecordStatus.EXAM_ING) {
|
|
|
+// return;
|
|
|
+// }
|
|
|
long st = System.currentTimeMillis();
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
|
|
@@ -932,7 +938,6 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|
examSessionInfoService.deleteExamSessionInfo(studentId);
|
|
|
ExamRecordDataEntity examRecordDataEntity = GlobalHelper.getEntity(examRecordDataRepo,
|
|
|
examingRecord.getExamRecordDataId(), ExamRecordDataEntity.class);
|
|
|
- handInExam(examRecordDataEntity, HandInExamType.AUTO);
|
|
|
delayHandInExamIfLocked(examRecordDataEntity);
|
|
|
return null;
|
|
|
}
|
|
@@ -940,7 +945,8 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 如果有序列化锁,则延迟交卷
|
|
|
+ * 如果有序列化锁,则延迟交卷
|
|
|
+ *
|
|
|
* @param examRecordData
|
|
|
* @return
|
|
|
*/
|
|
@@ -978,10 +984,10 @@ public class ExamControlServiceImpl implements ExamControlService {
|
|
|
ExamRecordDataEntity examRecordData = GlobalHelper.getEntity(examRecordDataRepo, examingRecord.getExamRecordDataId(), ExamRecordDataEntity.class);
|
|
|
|
|
|
//只有考试状态为考试中,系统才需要执行交卷动作,因为有可能已经手动交卷,所以这里再做一次判断
|
|
|
- if (examRecordData.getExamRecordStatus() == ExamRecordStatus.EXAM_ING) {
|
|
|
- cleanExamRecordTaskLog.debug("[CLEAN_EXAMING_RECORD_" + examRecordData.getId() + "]状态为进行中考试,执行交卷[handInExam],.");
|
|
|
- handInExam(examRecordData, HandInExamType.AUTO);
|
|
|
- }
|
|
|
+// if (examRecordData.getExamRecordStatus() == ExamRecordStatus.EXAM_ING) {
|
|
|
+ cleanExamRecordTaskLog.debug("[CLEAN_EXAMING_RECORD_" + examRecordData.getId() + "]状态为进行中考试,执行交卷[handInExam],.");
|
|
|
+ handInExam(examRecordData, HandInExamType.AUTO);
|
|
|
+// }
|
|
|
|
|
|
cleanExamRecordTaskLog.debug("[CLEAN_EXAMING_RECORD_" + examRecordData.getId() + "]考试记录交卷完成.");
|
|
|
}
|