|
@@ -3,14 +3,7 @@ package com.qmth.themis.business.service.impl;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.Comparator;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
-import java.util.UUID;
|
|
|
+import java.util.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
@@ -42,6 +35,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;
|
|
@@ -85,7 +79,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
|
|
|
|
@Resource
|
|
|
TOeExamRecordService toeExamRecordService;
|
|
|
-
|
|
|
+
|
|
|
@Resource
|
|
|
TEExamStudentService examStudentService;
|
|
|
|
|
@@ -125,6 +119,16 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
|
if (Objects.nonNull(list) && list.size() > 0) {
|
|
|
list.forEach(s -> {
|
|
|
List<TEExamActivityDto> teExamActivityList = teExamActivityService.getWaitingExam(studentId, s.getId(), s.getExamActivityId());
|
|
|
+ teExamActivityList.forEach(v -> {
|
|
|
+ String[] longs = v.getInProcessLivenessFixedRangeStr().split(",");
|
|
|
+ List inProcessLivenessFixedRange = new ArrayList();
|
|
|
+ for (int i = 0; i < longs.length; i++) {
|
|
|
+ Long l = Long.valueOf(longs[i]);
|
|
|
+ inProcessLivenessFixedRange.add(l);
|
|
|
+ }
|
|
|
+ v.setInProcessLivenessFixedRange(inProcessLivenessFixedRange);
|
|
|
+ v.setMonitorVideoSource(Arrays.asList(v.getMonitorVideoSourceStr()));
|
|
|
+ });
|
|
|
s.setActivities(teExamActivityList);
|
|
|
});
|
|
|
}
|
|
@@ -142,24 +146,27 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
|
// }
|
|
|
|
|
|
/**
|
|
|
- *开始候考
|
|
|
+ * 开始候考
|
|
|
*/
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public ExamPrepareBean prepare(Long studentId, Long examStudentId) {
|
|
|
- ExamPrepareBean ret = null;
|
|
|
ExamStudentCacheBean es = null;
|
|
|
es = (ExamStudentCacheBean) redisUtil.get(RedisKeyHelper.examStudentCacheKey(examStudentId));
|
|
|
if (es == null) {
|
|
|
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,7 +236,9 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
|
redisUtil.set(RedisKeyHelper.examStudentCacheKey(examStudentId), es);
|
|
|
//更新场次-考试记录缓存
|
|
|
ExamActivityRecordCacheUtil.setExamRecordStatus(activityId, recordId, ExamRecordCacheUtil.getStatus(recordId));
|
|
|
- return ret;
|
|
|
+ teStudentCacheDto.setUnFinishedRecordId(recordId);
|
|
|
+ redisUtil.setStudent(studentId, teStudentCacheDto, null, null);
|
|
|
+ return prepare;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -249,7 +258,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *开始候考
|
|
|
+ * 开始候考
|
|
|
*/
|
|
|
@Override
|
|
|
public ExamStartBean start(Long studentId, Long recordId) {
|
|
@@ -303,7 +312,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *上传个人试卷结构
|
|
|
+ * 上传个人试卷结构
|
|
|
*/
|
|
|
@Override
|
|
|
public Long studentPaperStruct(Long studentId, Long recordId, String content) {
|
|
@@ -331,7 +340,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *提交作答结果
|
|
|
+ * 提交作答结果
|
|
|
*/
|
|
|
@Override
|
|
|
public Long answerSubmit(Long studentId, Long recordId, Integer mainNumber, Integer subNumber, Integer subIndex,
|
|
@@ -381,7 +390,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *更新音频剩余播放次数
|
|
|
+ * 更新音频剩余播放次数
|
|
|
*/
|
|
|
@Override
|
|
|
public Integer audioLeftPlayCountSubmit(Long studentId, Long recordId, String key, Integer count) {
|
|
@@ -407,7 +416,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *文件上传
|
|
|
+ * 文件上传
|
|
|
*/
|
|
|
@Override
|
|
|
public ExamFileUploadBean fileUpload(Long studentId, Long recordId, MultipartFile file, String suffix, String md5) {
|
|
@@ -457,7 +466,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *断点恢复
|
|
|
+ * 断点恢复
|
|
|
*/
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@Override
|
|
@@ -510,7 +519,9 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
- /**作答排序
|
|
|
+ /**
|
|
|
+ * 作答排序
|
|
|
+ *
|
|
|
* @param answers
|
|
|
* @return
|
|
|
*/
|
|
@@ -550,7 +561,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *结束考试
|
|
|
+ * 结束考试
|
|
|
*/
|
|
|
@Override
|
|
|
public ExamFinishBean finish(Long studentId, Long recordId, String type, Integer durationSeconds) {
|
|
@@ -581,6 +592,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;
|
|
|
}
|
|
|
|
|
@@ -598,31 +613,31 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *查询交卷结果
|
|
|
+ * 查询交卷结果
|
|
|
*/
|
|
|
@Override
|
|
|
public ExamResultBean result(Long recordId) {
|
|
|
- ExamResultBean ret = new ExamResultBean();
|
|
|
- TOeExamRecord er=null;
|
|
|
+ ExamResultBean ret = new ExamResultBean();
|
|
|
+ TOeExamRecord er = null;
|
|
|
if (ExamRecordCacheUtil.getId(recordId) == null) {
|
|
|
- er=toeExamRecordService.getById(recordId);
|
|
|
- if(er==null) {
|
|
|
- throw new BusinessException("未找到考试记录");
|
|
|
- }
|
|
|
- ret.setDurationSeconds(er.getDurationSeconds());
|
|
|
- ret.setFinishTime(er.getFinishTime().getTime());
|
|
|
- ret.setFinishType(er.getFinishType());
|
|
|
- ret.setObjectiveScore(er.getObjectiveScore());
|
|
|
- }else {
|
|
|
- ret.setDurationSeconds(ExamRecordCacheUtil.getDurationSeconds(recordId));
|
|
|
- ret.setFinishTime(ExamRecordCacheUtil.getFinishTime(recordId));
|
|
|
- ret.setFinishType(ExamRecordCacheUtil.getFinishType(recordId));
|
|
|
- ret.setObjectiveScore(ExamRecordCacheUtil.getObjectiveScore(recordId));
|
|
|
+ er = toeExamRecordService.getById(recordId);
|
|
|
+ if (er == null) {
|
|
|
+ throw new BusinessException("未找到考试记录");
|
|
|
+ }
|
|
|
+ ret.setDurationSeconds(er.getDurationSeconds());
|
|
|
+ ret.setFinishTime(er.getFinishTime().getTime());
|
|
|
+ ret.setFinishType(er.getFinishType());
|
|
|
+ ret.setObjectiveScore(er.getObjectiveScore());
|
|
|
+ } else {
|
|
|
+ ret.setDurationSeconds(ExamRecordCacheUtil.getDurationSeconds(recordId));
|
|
|
+ ret.setFinishTime(ExamRecordCacheUtil.getFinishTime(recordId));
|
|
|
+ ret.setFinishType(ExamRecordCacheUtil.getFinishType(recordId));
|
|
|
+ ret.setObjectiveScore(ExamRecordCacheUtil.getObjectiveScore(recordId));
|
|
|
}
|
|
|
|
|
|
//TODO
|
|
|
ret.setReviewResult("");
|
|
|
return ret;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|