|
@@ -1,56 +1,12 @@
|
|
|
package com.qmth.themis.business.service.impl;
|
|
|
|
|
|
-import java.io.File;
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.InputStream;
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.time.LocalDateTime;
|
|
|
-import java.time.ZoneOffset;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.Comparator;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
-import java.util.UUID;
|
|
|
-
|
|
|
-import javax.annotation.Resource;
|
|
|
-
|
|
|
-import org.apache.commons.codec.digest.DigestUtils;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
-import org.springframework.cache.annotation.CacheEvict;
|
|
|
-import org.springframework.cache.annotation.CachePut;
|
|
|
-import org.springframework.cache.annotation.Cacheable;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
-
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.qmth.themis.business.bean.exam.AnswerSubmitBean;
|
|
|
-import com.qmth.themis.business.bean.exam.AudioLeftPlayCountSubmitBean;
|
|
|
-import com.qmth.themis.business.bean.exam.ExamFileUploadBean;
|
|
|
-import com.qmth.themis.business.bean.exam.ExamFinishBean;
|
|
|
-import com.qmth.themis.business.bean.exam.ExamPrepareBean;
|
|
|
-import com.qmth.themis.business.bean.exam.ExamResultBean;
|
|
|
-import com.qmth.themis.business.bean.exam.ExamResumeBean;
|
|
|
-import com.qmth.themis.business.bean.exam.ExamStartBean;
|
|
|
-import com.qmth.themis.business.bean.exam.StudentPaperStructBean;
|
|
|
+import com.qmth.themis.business.bean.exam.*;
|
|
|
import com.qmth.themis.business.cache.ExamActivityRecordCacheUtil;
|
|
|
import com.qmth.themis.business.cache.ExamRecordCacheUtil;
|
|
|
import com.qmth.themis.business.cache.RedisKeyHelper;
|
|
|
-import com.qmth.themis.business.cache.bean.ExamActivityCacheBean;
|
|
|
-import com.qmth.themis.business.cache.bean.ExamCacheBean;
|
|
|
-import com.qmth.themis.business.cache.bean.ExamCourseCacheBean;
|
|
|
-import com.qmth.themis.business.cache.bean.ExamPaperCacheBean;
|
|
|
-import com.qmth.themis.business.cache.bean.ExamStudentAnswerCacheBean;
|
|
|
-import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
|
|
|
-import com.qmth.themis.business.cache.bean.ExamStudentPaperStructCacheBean;
|
|
|
+import com.qmth.themis.business.cache.bean.*;
|
|
|
import com.qmth.themis.business.config.SystemConfig;
|
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
|
import com.qmth.themis.business.dao.TEExamMapper;
|
|
@@ -63,32 +19,32 @@ import com.qmth.themis.business.entity.TBSession;
|
|
|
import com.qmth.themis.business.entity.TBTaskHistory;
|
|
|
import com.qmth.themis.business.entity.TEExam;
|
|
|
import com.qmth.themis.business.entity.TOeExamRecord;
|
|
|
-import com.qmth.themis.business.enums.EntryAuthenticationPolicyEnum;
|
|
|
-import com.qmth.themis.business.enums.ExamModeEnum;
|
|
|
-import com.qmth.themis.business.enums.ExamRecordStatusEnum;
|
|
|
-import com.qmth.themis.business.enums.FinishExamResultEnum;
|
|
|
-import com.qmth.themis.business.enums.FinishTypeEnum;
|
|
|
-import com.qmth.themis.business.enums.HardwareTestEnum;
|
|
|
-import com.qmth.themis.business.enums.InvigilateVerifyEnum;
|
|
|
-import com.qmth.themis.business.enums.MonitorVideoSourceEnum;
|
|
|
-import com.qmth.themis.business.enums.MqTagEnum;
|
|
|
-import com.qmth.themis.business.enums.MqTopicEnum;
|
|
|
-import com.qmth.themis.business.enums.ReviewResultEnum;
|
|
|
-import com.qmth.themis.business.enums.SystemOperationEnum;
|
|
|
-import com.qmth.themis.business.enums.TaskStatusEnum;
|
|
|
-import com.qmth.themis.business.service.MqDtoService;
|
|
|
-import com.qmth.themis.business.service.TBTaskHistoryService;
|
|
|
-import com.qmth.themis.business.service.TEExamActivityService;
|
|
|
-import com.qmth.themis.business.service.TEExamCourseService;
|
|
|
-import com.qmth.themis.business.service.TEExamPaperService;
|
|
|
-import com.qmth.themis.business.service.TEExamService;
|
|
|
-import com.qmth.themis.business.service.TEExamStudentService;
|
|
|
-import com.qmth.themis.business.service.TOeExamRecordService;
|
|
|
+import com.qmth.themis.business.enums.*;
|
|
|
+import com.qmth.themis.business.service.*;
|
|
|
import com.qmth.themis.business.util.OssUtil;
|
|
|
import com.qmth.themis.business.util.RedisUtil;
|
|
|
import com.qmth.themis.business.util.ServletUtil;
|
|
|
import com.qmth.themis.business.util.TencentYunUtil;
|
|
|
import com.qmth.themis.common.exception.BusinessException;
|
|
|
+import org.apache.commons.codec.digest.DigestUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.cache.annotation.CacheEvict;
|
|
|
+import org.springframework.cache.annotation.CachePut;
|
|
|
+import org.springframework.cache.annotation.Cacheable;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.ZoneOffset;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @Description: 考试批次 服务实现类
|
|
@@ -129,7 +85,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
|
|
|
|
@Resource
|
|
|
TencentYunUtil tencentYunUtil;
|
|
|
-
|
|
|
+
|
|
|
@Resource
|
|
|
private TBTaskHistoryService tbTaskHistoryService;
|
|
|
|
|
@@ -163,10 +119,12 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
|
public List<TEExamDto> getWaitingExam(Long studentId, Long examId, Long orgId) {
|
|
|
List<TEExamDto> list = teExamMapper.getWaitingExam(studentId, examId, orgId);
|
|
|
if (Objects.nonNull(list) && list.size() > 0) {
|
|
|
- ExamCacheBean examCache=getExamCacheBean(examId);
|
|
|
list.forEach(s -> {
|
|
|
List<TEExamActivityDto> teExamActivityList = teExamActivityService.getWaitingExam(studentId, s.getId(), s.getExamActivityId(), s.getMode());
|
|
|
teExamActivityList.forEach(v -> {
|
|
|
+ ExamCacheBean examCache = getExamCacheBean(v.getExamId());
|
|
|
+ ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(v.getExamStudentId());
|
|
|
+ v.setLeftExamCount(examCache.getExamCount() - examStudentCacheBean.getAlreadyExamCount());
|
|
|
if (Objects.nonNull(v.getInProcessLivenessFixedRangeStr())) {
|
|
|
String[] longs = v.getInProcessLivenessFixedRangeStr().trim().replaceAll(" ", "").split(",");
|
|
|
List inProcessLivenessFixedRange = new ArrayList();
|
|
@@ -203,8 +161,6 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
|
} else {
|
|
|
v.setMonitorVideoSource(null);
|
|
|
}
|
|
|
- ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(v.getExamStudentId());
|
|
|
- v.setLeftExamCount(examCache.getExamCount()-examStudentCacheBean.getAlreadyExamCount());
|
|
|
});
|
|
|
s.setActivities(teExamActivityList);
|
|
|
});
|
|
@@ -227,32 +183,32 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
|
if (!studentId.equals(es.getStudentId())) {
|
|
|
throw new BusinessException("考生Id和当前登录用户不一致");
|
|
|
}
|
|
|
- ExamCacheBean examCache=getExamCacheBean(es.getExamId());
|
|
|
+ ExamCacheBean examCache = getExamCacheBean(es.getExamId());
|
|
|
TEStudentCacheDto teStudentCacheDto = (TEStudentCacheDto) redisUtil.getStudent(es.getStudentId());
|
|
|
if (teStudentCacheDto.getUnFinishedRecordId() != null) {
|
|
|
Long recordId = teStudentCacheDto.getUnFinishedRecordId();
|
|
|
- if(examStudentId.equals(ExamRecordCacheUtil.getExamStudentId(recordId))) {//当前考生已存在候考的考试记录
|
|
|
- ExamPaperCacheBean ep = teExamPaperService.getExamPaperCacheBean(ExamRecordCacheUtil.getPaperId(recordId));
|
|
|
- ExamCourseCacheBean ec = teExamCourseService.getExamCourseCacheBean(es.getExamId(), es.getCourseCode());
|
|
|
- ExamPrepareBean prepare = new ExamPrepareBean();
|
|
|
- prepare.setRecordId(recordId);
|
|
|
- prepare.setAudioPlayCount(ep.getAudioPlayCount());
|
|
|
- prepare.setHasAudio((ep.getHasAudio() == null || ep.getHasAudio().intValue() == 0 ? false : true));
|
|
|
- prepare.setObjectiveShuffle(
|
|
|
- (ec.getObjectiveShuffle() == null || ec.getObjectiveShuffle().intValue() == 0 ? false : true));
|
|
|
- prepare.setOptionShuffle(
|
|
|
- (ec.getOptionShuffle() == null || ec.getOptionShuffle().intValue() == 0 ? false : true));
|
|
|
- String paperurl = OssUtil.getUrlForPrivateBucket(systemConfig.getOssEnv(3), ep.getPaperPath());
|
|
|
- String structurl = OssUtil.getUrlForPrivateBucket(systemConfig.getOssEnv(3), ep.getStructPath());
|
|
|
- prepare.setPaperUrl(paperurl);
|
|
|
- prepare.setStructUrl(structurl);
|
|
|
- prepare.setMonitorKey(ExamRecordCacheUtil.getMonitorKey(recordId));
|
|
|
- prepare.setMonitorUserId("s_" + tbSession.getId());
|
|
|
- prepare.setMonitorUserSig(tencentYunUtil.getSign(prepare.getMonitorUserId(), SystemConstant.TENCENT_EXPIRE_TIME));
|
|
|
- return prepare;
|
|
|
+ if (examStudentId.equals(ExamRecordCacheUtil.getExamStudentId(recordId))) {//当前考生已存在候考的考试记录
|
|
|
+ ExamPaperCacheBean ep = teExamPaperService.getExamPaperCacheBean(ExamRecordCacheUtil.getPaperId(recordId));
|
|
|
+ ExamCourseCacheBean ec = teExamCourseService.getExamCourseCacheBean(es.getExamId(), es.getCourseCode());
|
|
|
+ ExamPrepareBean prepare = new ExamPrepareBean();
|
|
|
+ prepare.setRecordId(recordId);
|
|
|
+ prepare.setAudioPlayCount(ep.getAudioPlayCount());
|
|
|
+ prepare.setHasAudio((ep.getHasAudio() == null || ep.getHasAudio().intValue() == 0 ? false : true));
|
|
|
+ prepare.setObjectiveShuffle(
|
|
|
+ (ec.getObjectiveShuffle() == null || ec.getObjectiveShuffle().intValue() == 0 ? false : true));
|
|
|
+ prepare.setOptionShuffle(
|
|
|
+ (ec.getOptionShuffle() == null || ec.getOptionShuffle().intValue() == 0 ? false : true));
|
|
|
+ String paperurl = OssUtil.getUrlForPrivateBucket(systemConfig.getOssEnv(3), ep.getPaperPath());
|
|
|
+ String structurl = OssUtil.getUrlForPrivateBucket(systemConfig.getOssEnv(3), ep.getStructPath());
|
|
|
+ prepare.setPaperUrl(paperurl);
|
|
|
+ prepare.setStructUrl(structurl);
|
|
|
+ prepare.setMonitorKey(ExamRecordCacheUtil.getMonitorKey(recordId));
|
|
|
+ prepare.setMonitorUserId("s_" + tbSession.getId());
|
|
|
+ prepare.setMonitorUserSig(tencentYunUtil.getSign(prepare.getMonitorUserId(), SystemConstant.TENCENT_EXPIRE_TIME));
|
|
|
+ return prepare;
|
|
|
}
|
|
|
}
|
|
|
- if (examCache.getExamCount().intValue()<=es.getAlreadyExamCount().intValue()) {
|
|
|
+ if (examCache.getExamCount().intValue() <= es.getAlreadyExamCount().intValue()) {
|
|
|
throw new BusinessException("没有剩余考试次数");
|
|
|
}
|
|
|
ExamCacheBean exam = getExamCacheBean(es.getExamId());
|
|
@@ -262,16 +218,16 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
|
throw new BusinessException("未找到场次");
|
|
|
}
|
|
|
Date now = new Date();
|
|
|
- if(ExamModeEnum.ANYTIME.equals(exam.getMode())) {
|
|
|
- Long start = ac.getStartTime().getTime() - (ac.getPrepareSeconds() * 1000);
|
|
|
- Long end = ac.getFinishTime().getTime();
|
|
|
- if (now.getTime() < start) {
|
|
|
- throw new BusinessException("没有到允许开考的时间");
|
|
|
- }
|
|
|
- if (now.getTime() > end) {
|
|
|
- throw new BusinessException("允许开考的时间已结束");
|
|
|
- }
|
|
|
- }else {
|
|
|
+ if (ExamModeEnum.ANYTIME.equals(exam.getMode())) {
|
|
|
+ Long start = ac.getStartTime().getTime() - (ac.getPrepareSeconds() * 1000);
|
|
|
+ Long end = ac.getFinishTime().getTime();
|
|
|
+ if (now.getTime() < start) {
|
|
|
+ throw new BusinessException("没有到允许开考的时间");
|
|
|
+ }
|
|
|
+ if (now.getTime() > end) {
|
|
|
+ throw new BusinessException("允许开考的时间已结束");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
Long start = ac.getStartTime().getTime() - (ac.getPrepareSeconds() * 1000);
|
|
|
Long end = ac.getStartTime().getTime() + (ac.getOpeningSeconds() * 1000);
|
|
|
if (now.getTime() < start) {
|
|
@@ -281,7 +237,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
|
throw new BusinessException("允许开考的时间已结束");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
ExamCourseCacheBean ec = teExamCourseService.getExamCourseCacheBean(es.getExamId(), es.getCourseCode());
|
|
|
if (ec == null) {
|
|
|
throw new BusinessException("未找到考试科目");
|
|
@@ -328,7 +284,6 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
|
prepare.setMonitorUserId("s_" + tbSession.getId());
|
|
|
prepare.setMonitorUserSig(tencentYunUtil.getSign(prepare.getMonitorUserId(), SystemConstant.TENCENT_EXPIRE_TIME));
|
|
|
|
|
|
-
|
|
|
// 更新考生缓存
|
|
|
redisUtil.set(RedisKeyHelper.examStudentCacheKey(examStudentId), es);
|
|
|
//更新场次-考试记录缓存
|
|
@@ -395,24 +350,24 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
|
throw new BusinessException("未找到场次");
|
|
|
}
|
|
|
Date now = new Date();
|
|
|
- if(ExamModeEnum.ANYTIME.equals(exam.getMode())) {
|
|
|
- Long start = ac.getStartTime().getTime();
|
|
|
- Long end = ac.getFinishTime().getTime();
|
|
|
- if (now.getTime() < start) {
|
|
|
- throw new BusinessException("没有到允许开考的时间");
|
|
|
- }
|
|
|
- if (now.getTime() > end) {
|
|
|
- throw new BusinessException("允许开考的时间已结束");
|
|
|
- }
|
|
|
- }else {
|
|
|
- Long start = ac.getStartTime().getTime();
|
|
|
- Long end = ac.getStartTime().getTime() + (ac.getOpeningSeconds() * 1000);
|
|
|
- if (now.getTime() < start) {
|
|
|
- throw new BusinessException("没有到允许开考的时间");
|
|
|
- }
|
|
|
- if (now.getTime() > end) {
|
|
|
- throw new BusinessException("允许开考的时间已结束");
|
|
|
- }
|
|
|
+ if (ExamModeEnum.ANYTIME.equals(exam.getMode())) {
|
|
|
+ Long start = ac.getStartTime().getTime();
|
|
|
+ Long end = ac.getFinishTime().getTime();
|
|
|
+ if (now.getTime() < start) {
|
|
|
+ throw new BusinessException("没有到允许开考的时间");
|
|
|
+ }
|
|
|
+ if (now.getTime() > end) {
|
|
|
+ throw new BusinessException("允许开考的时间已结束");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Long start = ac.getStartTime().getTime();
|
|
|
+ Long end = ac.getStartTime().getTime() + (ac.getOpeningSeconds() * 1000);
|
|
|
+ if (now.getTime() < start) {
|
|
|
+ throw new BusinessException("没有到允许开考的时间");
|
|
|
+ }
|
|
|
+ if (now.getTime() > end) {
|
|
|
+ throw new BusinessException("允许开考的时间已结束");
|
|
|
+ }
|
|
|
}
|
|
|
ExamRecordStatusEnum sta = ExamRecordCacheUtil.getStatus(recordId);
|
|
|
if (ExamRecordStatusEnum.FINISHED.equals(sta) || ExamRecordStatusEnum.PERSISTED.equals(sta)) {
|
|
@@ -817,18 +772,18 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
|
}
|
|
|
|
|
|
Map<String, Object> transMap = new HashMap<String, Object>();
|
|
|
- transMap.put("recordId", recordId);
|
|
|
- String level = "10s";
|
|
|
- Integer time = SystemConstant.mqDelayLevel.get(level);
|
|
|
- LocalDateTime dt = LocalDateTime.now();
|
|
|
- dt = dt.plusSeconds(Long.parseLong(level.replace("s", "")));
|
|
|
- Map<String, Object> propMap = new HashMap<String, Object>();
|
|
|
- propMap.put("timeOut", time);
|
|
|
- propMap.put("mqExecTime", dt.toInstant(ZoneOffset.of("+8")).toEpochMilli());
|
|
|
- MqDto mqDto = new MqDto(MqTopicEnum.themisTopic.getCode(), MqTagEnum.EXAM_RECORD_PERSISTED.name(),
|
|
|
- transMap, MqTagEnum.EXAM_RECORD_PERSISTED, recordId.toString(), propMap, recordId.toString());
|
|
|
-
|
|
|
- mqDtoService.assembleSendAsyncDelayMsg(mqDto);
|
|
|
+ transMap.put("recordId", recordId);
|
|
|
+ String level = "10s";
|
|
|
+ Integer time = SystemConstant.mqDelayLevel.get(level);
|
|
|
+ LocalDateTime dt = LocalDateTime.now();
|
|
|
+ dt = dt.plusSeconds(Long.parseLong(level.replace("s", "")));
|
|
|
+ Map<String, Object> propMap = new HashMap<String, Object>();
|
|
|
+ propMap.put("timeOut", time);
|
|
|
+ propMap.put("mqExecTime", dt.toInstant(ZoneOffset.of("+8")).toEpochMilli());
|
|
|
+ MqDto mqDto = new MqDto(MqTopicEnum.themisTopic.getCode(), MqTagEnum.EXAM_RECORD_PERSISTED.name(),
|
|
|
+ transMap, MqTagEnum.EXAM_RECORD_PERSISTED, recordId.toString(), propMap, recordId.toString());
|
|
|
+
|
|
|
+ mqDtoService.assembleSendAsyncDelayMsg(mqDto);
|
|
|
}
|
|
|
|
|
|
@Cacheable(value = "exam", key = "#examId", unless = "#result == null")
|
|
@@ -985,62 +940,64 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
|
}
|
|
|
return ret;
|
|
|
}
|
|
|
-
|
|
|
- /**重新算分
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 重新算分
|
|
|
+ *
|
|
|
* @param examId
|
|
|
* @param taskId
|
|
|
*/
|
|
|
@Override
|
|
|
- public void calculateScore(Long examId,Long taskId) {
|
|
|
- int timeOutSecond=60*5;
|
|
|
- String lockKey = SystemConstant.REDIS_LOCK_CALCULATE_SCORE_PREFIX + examId;
|
|
|
+ public void calculateScore(Long examId, Long taskId) {
|
|
|
+ int timeOutSecond = 60 * 5;
|
|
|
+ String lockKey = SystemConstant.REDIS_LOCK_CALCULATE_SCORE_PREFIX + examId;
|
|
|
Boolean lock = redisUtil.lock(lockKey, timeOutSecond);
|
|
|
if (!lock) {
|
|
|
return;
|
|
|
}
|
|
|
- TBTaskHistory task=null;
|
|
|
- Long recordId=null;
|
|
|
+ TBTaskHistory task = null;
|
|
|
+ Long recordId = null;
|
|
|
try {
|
|
|
- task=tbTaskHistoryService.getById(taskId);
|
|
|
- task.setStatus(TaskStatusEnum.RUNNING);
|
|
|
- tbTaskHistoryService.saveOrUpdate(task);
|
|
|
- Long startId=0L;
|
|
|
- Long index=0L;
|
|
|
- Long total=toeExamRecordService.getCountByExamId(examId);
|
|
|
- if(total>0) {
|
|
|
- for(;;) {
|
|
|
- List<TOeExamRecord> list=toeExamRecordService.getListByExamIdAndStartId(examId, startId);
|
|
|
- if(list==null||list.size()==0) {
|
|
|
- break;
|
|
|
- }
|
|
|
- startId=list.get(list.size()-1).getId();
|
|
|
- for(TOeExamRecord rc:list) {
|
|
|
- index++;
|
|
|
- if(ExamRecordStatusEnum.PERSISTED.equals(rc.getStatus())) {
|
|
|
- recordId=rc.getId();
|
|
|
- toeExamRecordService.calculateScore(rc.getId());
|
|
|
- }
|
|
|
- redisUtil.expire(lockKey, timeOutSecond);
|
|
|
- }
|
|
|
- task.setProgress(getPercentage(index, total));
|
|
|
- tbTaskHistoryService.saveOrUpdate(task);
|
|
|
- }
|
|
|
- }
|
|
|
- task.setSummary("处理成功");
|
|
|
- task.setProgress(100.0);
|
|
|
- task.setStatus(TaskStatusEnum.FINISH);
|
|
|
- task.setFinishTime(new Date());
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("重新算分出错 recordId:"+(recordId==null?"":recordId), e);
|
|
|
- task.setSummary("处理出错");
|
|
|
- task.setStatus(TaskStatusEnum.FINISH);
|
|
|
- task.setFinishTime(new Date());
|
|
|
- } finally {
|
|
|
+ task = tbTaskHistoryService.getById(taskId);
|
|
|
+ task.setStatus(TaskStatusEnum.RUNNING);
|
|
|
+ tbTaskHistoryService.saveOrUpdate(task);
|
|
|
+ Long startId = 0L;
|
|
|
+ Long index = 0L;
|
|
|
+ Long total = toeExamRecordService.getCountByExamId(examId);
|
|
|
+ if (total > 0) {
|
|
|
+ for (; ; ) {
|
|
|
+ List<TOeExamRecord> list = toeExamRecordService.getListByExamIdAndStartId(examId, startId);
|
|
|
+ if (list == null || list.size() == 0) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ startId = list.get(list.size() - 1).getId();
|
|
|
+ for (TOeExamRecord rc : list) {
|
|
|
+ index++;
|
|
|
+ if (ExamRecordStatusEnum.PERSISTED.equals(rc.getStatus())) {
|
|
|
+ recordId = rc.getId();
|
|
|
+ toeExamRecordService.calculateScore(rc.getId());
|
|
|
+ }
|
|
|
+ redisUtil.expire(lockKey, timeOutSecond);
|
|
|
+ }
|
|
|
+ task.setProgress(getPercentage(index, total));
|
|
|
+ tbTaskHistoryService.saveOrUpdate(task);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ task.setSummary("处理成功");
|
|
|
+ task.setProgress(100.0);
|
|
|
+ task.setStatus(TaskStatusEnum.FINISH);
|
|
|
+ task.setFinishTime(new Date());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("重新算分出错 recordId:" + (recordId == null ? "" : recordId), e);
|
|
|
+ task.setSummary("处理出错");
|
|
|
+ task.setStatus(TaskStatusEnum.FINISH);
|
|
|
+ task.setFinishTime(new Date());
|
|
|
+ } finally {
|
|
|
redisUtil.releaseLock(lockKey);
|
|
|
}
|
|
|
- tbTaskHistoryService.saveOrUpdate(task);
|
|
|
+ tbTaskHistoryService.saveOrUpdate(task);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private Double getPercentage(Long a, Long b) {
|
|
|
if (a == null) {
|
|
|
a = 0L;
|