|
@@ -1,18 +1,17 @@
|
|
package com.qmth.themis.task.quartz.service.impl;
|
|
package com.qmth.themis.task.quartz.service.impl;
|
|
|
|
|
|
-import com.qmth.themis.business.cache.ExamActivityRecordCacheUtil;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.qmth.themis.business.cache.ExamRecordCacheUtil;
|
|
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.ExamActivityCacheBean;
|
|
-import com.qmth.themis.business.cache.bean.ExamActivityRecordCacheBean;
|
|
|
|
import com.qmth.themis.business.cache.bean.ExamCacheBean;
|
|
import com.qmth.themis.business.cache.bean.ExamCacheBean;
|
|
import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
|
|
import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
|
|
|
|
+import com.qmth.themis.business.entity.TOeExamRecord;
|
|
import com.qmth.themis.business.enums.ExamRecordStatusEnum;
|
|
import com.qmth.themis.business.enums.ExamRecordStatusEnum;
|
|
import com.qmth.themis.business.enums.FinishTypeEnum;
|
|
import com.qmth.themis.business.enums.FinishTypeEnum;
|
|
import com.qmth.themis.business.service.TEExamActivityService;
|
|
import com.qmth.themis.business.service.TEExamActivityService;
|
|
import com.qmth.themis.business.service.TEExamService;
|
|
import com.qmth.themis.business.service.TEExamService;
|
|
import com.qmth.themis.business.service.TEExamStudentService;
|
|
import com.qmth.themis.business.service.TEExamStudentService;
|
|
-import com.qmth.themis.business.util.RedisUtil;
|
|
|
|
|
|
+import com.qmth.themis.business.service.TOeExamRecordService;
|
|
import com.qmth.themis.task.quartz.service.QuartzLogicService;
|
|
import com.qmth.themis.task.quartz.service.QuartzLogicService;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -20,7 +19,7 @@ import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
-import java.util.Map;
|
|
|
|
|
|
+import java.util.List;
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -41,10 +40,10 @@ public class QuartzLogicServiceImpl implements QuartzLogicService {
|
|
TEExamService teExamService;
|
|
TEExamService teExamService;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
- RedisUtil redisUtil;
|
|
|
|
|
|
+ TEExamStudentService teExamStudentService;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
- TEExamStudentService teExamStudentService;
|
|
|
|
|
|
+ TOeExamRecordService tOeExamRecordService;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 考试场次quartz逻辑
|
|
* 考试场次quartz逻辑
|
|
@@ -60,22 +59,25 @@ public class QuartzLogicServiceImpl implements QuartzLogicService {
|
|
ExamCacheBean examCacheBean = teExamService.getExamCacheBean(examActivityCacheBean.getExamId());
|
|
ExamCacheBean examCacheBean = teExamService.getExamCacheBean(examActivityCacheBean.getExamId());
|
|
if (Objects.nonNull(examCacheBean) && examCacheBean.getEnable() == 1 && Objects.nonNull(examActivityCacheBean) && examActivityCacheBean.getEnable() == 1) {
|
|
if (Objects.nonNull(examCacheBean) && examCacheBean.getEnable() == 1 && Objects.nonNull(examActivityCacheBean) && examActivityCacheBean.getEnable() == 1) {
|
|
Integer forceFinish = examCacheBean.getForceFinish();
|
|
Integer forceFinish = examCacheBean.getForceFinish();
|
|
- Map<String, Object> objectMap = redisUtil.getHashEntries(RedisKeyHelper.examActivityRecordCacheKey(examActivityCacheBean.getId()));
|
|
|
|
|
|
+ QueryWrapper<TOeExamRecord> tOeExamRecordQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ tOeExamRecordQueryWrapper.lambda().eq(TOeExamRecord::getExamActivityId, examActivityCacheBean.getId());
|
|
|
|
+ List<TOeExamRecord> examRecordList = tOeExamRecordService.list(tOeExamRecordQueryWrapper);
|
|
|
|
+// Map<String, Object> objectMap = redisUtil.getHashEntries(RedisKeyHelper.examActivityRecordCacheKey(examActivityCacheBean.getId()));
|
|
if (Objects.nonNull(forceFinish) && forceFinish.intValue() == 1) {//强制收卷
|
|
if (Objects.nonNull(forceFinish) && forceFinish.intValue() == 1) {//强制收卷
|
|
- if (Objects.nonNull(objectMap) && objectMap.size() > 0) {
|
|
|
|
- objectMap.forEach((k, v) -> {
|
|
|
|
- ExamActivityRecordCacheBean examActivityRecordCacheBean = (ExamActivityRecordCacheBean) v;
|
|
|
|
- ExamRecordStatusEnum examRecordStatusEnum = examActivityRecordCacheBean.getStatus();
|
|
|
|
|
|
+ if (Objects.nonNull(examRecordList) && examRecordList.size() > 0) {
|
|
|
|
+ examRecordList.forEach(s -> {
|
|
|
|
+// ExamActivityRecordCacheBean examActivityRecordCacheBean = (ExamActivityRecordCacheBean) v;
|
|
|
|
+ ExamRecordStatusEnum examRecordStatusEnum = s.getStatus();
|
|
//获取该考试批次下所有未交卷的考生的考试记录
|
|
//获取该考试批次下所有未交卷的考生的考试记录
|
|
if (Objects.nonNull(examRecordStatusEnum) && !Objects.equals(ExamRecordStatusEnum.FINISHED, examRecordStatusEnum) && !Objects.equals(ExamRecordStatusEnum.PERSISTED, examRecordStatusEnum)) {
|
|
if (Objects.nonNull(examRecordStatusEnum) && !Objects.equals(ExamRecordStatusEnum.FINISHED, examRecordStatusEnum) && !Objects.equals(ExamRecordStatusEnum.PERSISTED, examRecordStatusEnum)) {
|
|
- Long recordId = Long.parseLong(k);
|
|
|
|
- Long recordEndTime = ExamRecordCacheUtil.getEndTime(recordId);
|
|
|
|
|
|
+// Long recordId = Long.parseLong(k);
|
|
|
|
+ Long recordEndTime = s.getEndTime();
|
|
if (Objects.nonNull(examActivityCacheBean.getFinishTime()) && Objects.nonNull(recordEndTime) && examActivityCacheBean.getFinishTime().longValue() == recordEndTime.longValue()) {
|
|
if (Objects.nonNull(examActivityCacheBean.getFinishTime()) && Objects.nonNull(recordEndTime) && examActivityCacheBean.getFinishTime().longValue() == recordEndTime.longValue()) {
|
|
- Integer durationSeconds = ExamRecordCacheUtil.getDurationSeconds(recordId);
|
|
|
|
- Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
|
|
|
|
|
|
+ Integer durationSeconds = s.getDurationSeconds();
|
|
|
|
+ Long examStudentId = s.getExamStudentId();
|
|
ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
|
|
ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
|
|
//交卷
|
|
//交卷
|
|
- teExamService.finish(examStudentCacheBean.getStudentId(), Long.parseLong(k), FinishTypeEnum.AUTO.name(), durationSeconds);
|
|
|
|
|
|
+ teExamService.finish(examStudentCacheBean.getStudentId(), s.getId(), FinishTypeEnum.AUTO.name(), durationSeconds);
|
|
// 清除缓存
|
|
// 清除缓存
|
|
// ExamActivityRecordCacheUtil.removeActivityRecordCache(ExamRecordCacheUtil.getExamActivityId(recordId), recordId);
|
|
// ExamActivityRecordCacheUtil.removeActivityRecordCache(ExamRecordCacheUtil.getExamActivityId(recordId), recordId);
|
|
}
|
|
}
|
|
@@ -83,20 +85,18 @@ public class QuartzLogicServiceImpl implements QuartzLogicService {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- if (Objects.nonNull(objectMap) && objectMap.size() > 0) {
|
|
|
|
- objectMap.forEach((k, v) -> {
|
|
|
|
- ExamActivityRecordCacheBean examActivityRecordCacheBean = (ExamActivityRecordCacheBean) v;
|
|
|
|
- ExamRecordStatusEnum examRecordStatusEnum = examActivityRecordCacheBean.getStatus();
|
|
|
|
|
|
+ if (Objects.nonNull(examRecordList) && examRecordList.size() > 0) {
|
|
|
|
+ examRecordList.forEach(s -> {
|
|
|
|
+ ExamRecordStatusEnum examRecordStatusEnum = s.getStatus();
|
|
//获取该考试批次下所有未交卷的考生的考试记录
|
|
//获取该考试批次下所有未交卷的考生的考试记录
|
|
if (Objects.nonNull(examRecordStatusEnum) && !Objects.equals(ExamRecordStatusEnum.FINISHED, examRecordStatusEnum) && !Objects.equals(ExamRecordStatusEnum.PERSISTED, examRecordStatusEnum) && !Objects.equals(ExamRecordStatusEnum.ANSWERING, examRecordStatusEnum)) {
|
|
if (Objects.nonNull(examRecordStatusEnum) && !Objects.equals(ExamRecordStatusEnum.FINISHED, examRecordStatusEnum) && !Objects.equals(ExamRecordStatusEnum.PERSISTED, examRecordStatusEnum) && !Objects.equals(ExamRecordStatusEnum.ANSWERING, examRecordStatusEnum)) {
|
|
- Long recordId = Long.parseLong(k);
|
|
|
|
- Long recordEndTime = ExamRecordCacheUtil.getEndTime(recordId);
|
|
|
|
|
|
+ Long recordEndTime = s.getEndTime();
|
|
if (Objects.nonNull(examActivityCacheBean.getFinishTime()) && Objects.nonNull(recordEndTime) && examActivityCacheBean.getFinishTime().longValue() == recordEndTime.longValue()) {
|
|
if (Objects.nonNull(examActivityCacheBean.getFinishTime()) && Objects.nonNull(recordEndTime) && examActivityCacheBean.getFinishTime().longValue() == recordEndTime.longValue()) {
|
|
- Integer durationSeconds = ExamRecordCacheUtil.getDurationSeconds(recordId);
|
|
|
|
- Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
|
|
|
|
|
|
+ Integer durationSeconds = s.getDurationSeconds();
|
|
|
|
+ Long examStudentId = s.getExamStudentId();
|
|
ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
|
|
ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
|
|
//交卷
|
|
//交卷
|
|
- teExamService.finish(examStudentCacheBean.getStudentId(), Long.parseLong(k), FinishTypeEnum.AUTO.name(), durationSeconds);
|
|
|
|
|
|
+ teExamService.finish(examStudentCacheBean.getStudentId(), s.getId(), FinishTypeEnum.AUTO.name(), durationSeconds);
|
|
// 清除缓存
|
|
// 清除缓存
|
|
// ExamActivityRecordCacheUtil.removeActivityRecordCache(ExamRecordCacheUtil.getExamActivityId(recordId), recordId);
|
|
// ExamActivityRecordCacheUtil.removeActivityRecordCache(ExamRecordCacheUtil.getExamActivityId(recordId), recordId);
|
|
}
|
|
}
|