|
@@ -3,13 +3,17 @@ package com.qmth.themis.task.quartz.service.impl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.qmth.themis.business.cache.ExamRecordCacheUtil;
|
|
|
import com.qmth.themis.business.cache.RedisKeyHelper;
|
|
|
+import com.qmth.themis.business.cache.bean.ExamCacheBean;
|
|
|
import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
|
|
|
import com.qmth.themis.business.entity.TEExamActivity;
|
|
|
+import com.qmth.themis.business.entity.TOeExamRecord;
|
|
|
import com.qmth.themis.business.enums.ExamRecordStatusEnum;
|
|
|
import com.qmth.themis.business.enums.FinishTypeEnum;
|
|
|
import com.qmth.themis.business.service.TEExamActivityService;
|
|
|
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.threadPool.MyThreadPool;
|
|
|
import com.qmth.themis.business.util.RedisUtil;
|
|
|
import com.qmth.themis.task.quartz.service.QuartzLogicService;
|
|
|
import org.slf4j.Logger;
|
|
@@ -44,6 +48,9 @@ public class QuartzLogicServiceImpl implements QuartzLogicService {
|
|
|
@Resource
|
|
|
TEExamStudentService teExamStudentService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ TOeExamRecordService tOeExamRecordService;
|
|
|
+
|
|
|
/**
|
|
|
* 考试场次quartz逻辑
|
|
|
*
|
|
@@ -57,21 +64,52 @@ public class QuartzLogicServiceImpl implements QuartzLogicService {
|
|
|
QueryWrapper<TEExamActivity> teExamActivityQueryWrapper = new QueryWrapper<>();
|
|
|
teExamActivityQueryWrapper.lambda().eq(TEExamActivity::getCode, strings[1]);
|
|
|
TEExamActivity teExamActivity = teExamActivityService.getOne(teExamActivityQueryWrapper);
|
|
|
- if (Objects.nonNull(teExamActivity) && teExamActivity.getEnable() == 1) {
|
|
|
- Map<String, Object> objectMap = redisUtil.getHashEntries(RedisKeyHelper.examActivityRecordCacheKey(teExamActivity.getId()));
|
|
|
- if (Objects.nonNull(objectMap) && objectMap.size() > 0) {
|
|
|
- objectMap.forEach((k, v) -> {
|
|
|
- ExamRecordStatusEnum examRecordStatusEnum = (ExamRecordStatusEnum) v;
|
|
|
- //获取该考试批次下所有未交卷的考生的考试记录
|
|
|
- if (Objects.nonNull(examRecordStatusEnum) && !Objects.equals(ExamRecordStatusEnum.FINISHED, examRecordStatusEnum)) {
|
|
|
- Long recordId = Long.parseLong(k);
|
|
|
- Integer durationSeconds = ExamRecordCacheUtil.getDurationSeconds(recordId);
|
|
|
- Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
|
|
|
- ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
|
|
|
- //交卷
|
|
|
- teExamService.finish(examStudentCacheBean.getStudentId(), Long.parseLong(k), FinishTypeEnum.AUTO.name(), durationSeconds);
|
|
|
+ ExamCacheBean examCacheBean = teExamService.getExamCacheBean(teExamActivity.getExamId());
|
|
|
+ if (Objects.nonNull(examCacheBean) && examCacheBean.getEnable() == 1 && Objects.nonNull(teExamActivity) && teExamActivity.getEnable() == 1) {
|
|
|
+ Integer forceFinish = examCacheBean.getForceFinish();
|
|
|
+ if (Objects.nonNull(forceFinish) && forceFinish.intValue() == 1) {//强制收卷
|
|
|
+ Map<String, Object> objectMap = redisUtil.getHashEntries(RedisKeyHelper.examActivityRecordCacheKey(teExamActivity.getId()));
|
|
|
+ if (Objects.nonNull(objectMap) && objectMap.size() > 0) {
|
|
|
+ objectMap.forEach((k, v) -> {
|
|
|
+ ExamRecordStatusEnum examRecordStatusEnum = (ExamRecordStatusEnum) v;
|
|
|
+ //获取该考试批次下所有未交卷的考生的考试记录
|
|
|
+ if (Objects.nonNull(examRecordStatusEnum) && !Objects.equals(ExamRecordStatusEnum.FINISHED, examRecordStatusEnum)) {
|
|
|
+ Long recordId = Long.parseLong(k);
|
|
|
+ Integer durationSeconds = ExamRecordCacheUtil.getDurationSeconds(recordId);
|
|
|
+ Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
|
|
|
+ ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
|
|
|
+ //交卷
|
|
|
+ teExamService.finish(examStudentCacheBean.getStudentId(), Long.parseLong(k), FinishTypeEnum.AUTO.name(), durationSeconds);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Map<String, Object> objectMap = redisUtil.getHashEntries(RedisKeyHelper.examActivityRecordCacheKey(teExamActivity.getId()));
|
|
|
+ if (Objects.nonNull(objectMap) && objectMap.size() > 0) {
|
|
|
+ objectMap.forEach((k, v) -> {
|
|
|
+ ExamRecordStatusEnum examRecordStatusEnum = (ExamRecordStatusEnum) v;
|
|
|
+ //获取该考试批次下所有未交卷的考生的考试记录
|
|
|
+ if (Objects.nonNull(examRecordStatusEnum) && (!Objects.equals(ExamRecordStatusEnum.FINISHED, examRecordStatusEnum) && !Objects.equals(ExamRecordStatusEnum.ANSWERING, examRecordStatusEnum))) {
|
|
|
+ Long recordId = Long.parseLong(k);
|
|
|
+ Integer durationSeconds = ExamRecordCacheUtil.getDurationSeconds(recordId);
|
|
|
+ Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
|
|
|
+ ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
|
|
|
+ //交卷
|
|
|
+ teExamService.finish(examStudentCacheBean.getStudentId(), Long.parseLong(k), FinishTypeEnum.AUTO.name(), durationSeconds);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ TOeExamRecord tOeExamRecord = tOeExamRecordService.findOneByExamId(teExamActivity.getId(), ExamRecordStatusEnum.ANSWERING);
|
|
|
+ if (Objects.nonNull(tOeExamRecord)) {
|
|
|
+ try {
|
|
|
+ Thread.sleep(1000 * 60 * 15);//等15分钟再次检查
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
- });
|
|
|
+ execExamActivityJobLogic(key);
|
|
|
+ } else {
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|