|
@@ -1,5 +1,11 @@
|
|
|
package com.qmth.themis.task.quartz;
|
|
|
|
|
|
+import com.qmth.themis.business.cache.bean.ExamActivityCacheBean;
|
|
|
+import com.qmth.themis.business.cache.bean.ExamCacheBean;
|
|
|
+import com.qmth.themis.business.constant.SystemConstant;
|
|
|
+import com.qmth.themis.business.enums.ExamModeEnum;
|
|
|
+import com.qmth.themis.business.service.TEExamActivityService;
|
|
|
+import com.qmth.themis.business.service.TEExamService;
|
|
|
import com.qmth.themis.business.service.TEExamSummaryService;
|
|
|
import com.qmth.themis.business.service.ThemisCacheService;
|
|
|
import org.quartz.JobExecutionContext;
|
|
@@ -12,6 +18,7 @@ import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
import java.util.Set;
|
|
|
|
|
|
/**
|
|
@@ -31,16 +38,51 @@ public class ExamSummaryJob extends QuartzJobBean {
|
|
|
@Resource
|
|
|
TEExamSummaryService teExamSummaryService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ TEExamService teExamService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ TEExamActivityService teExamActivityService;
|
|
|
+
|
|
|
@Override
|
|
|
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
|
|
|
log.info("ExamSummaryJob进来了,context:{}", context);
|
|
|
Set<Long> examIdSet = themisCacheService.getTodayExamListCache();
|
|
|
if (!CollectionUtils.isEmpty(examIdSet)) {
|
|
|
for (Long l : examIdSet) {
|
|
|
+ ExamCacheBean examCacheBean = teExamService.getExamCacheBean(l);
|
|
|
+ if (examCacheBean.getEnable().intValue() == 0 || examCacheBean.getEndTime().longValue() <= System.currentTimeMillis()) {
|
|
|
+ themisCacheService.removeTodayExamCache(l.toString());
|
|
|
+ themisCacheService.removeTodayExamListCache(l);
|
|
|
+ }
|
|
|
Map<String, Set<String>> map = themisCacheService.getTodayExamCache(l.toString());
|
|
|
- map.forEach((k, v) -> {
|
|
|
- teExamSummaryService.examSummary(l, Long.parseLong(k), v);
|
|
|
- });
|
|
|
+ if (!CollectionUtils.isEmpty(map)) {
|
|
|
+ map.forEach((k, v) -> {
|
|
|
+ //换算开始时间和结束时间
|
|
|
+ Long startTime = null, endTime = null;
|
|
|
+ ExamActivityCacheBean ac = teExamActivityService.getExamActivityCacheBean(Long.parseLong(k));
|
|
|
+ if (ExamModeEnum.ANYTIME.equals(examCacheBean.getMode())) {
|
|
|
+ startTime = ac.getStartTime() - (ac.getPrepareSeconds() * 1000);
|
|
|
+ endTime = ac.getFinishTime();
|
|
|
+ endTime = endTime + (1000 * 60 * 5);//额外加5分钟,有可能后台交卷未完成
|
|
|
+ } else {
|
|
|
+ startTime = ac.getStartTime() - (ac.getPrepareSeconds() * 1000);
|
|
|
+ Integer openingSecondsTemp = ac.getOpeningSeconds();
|
|
|
+ openingSecondsTemp = Objects.nonNull(openingSecondsTemp) && openingSecondsTemp.intValue() == 0 ? SystemConstant.DEFAULT_OPENING_SECONDS : openingSecondsTemp;
|
|
|
+ endTime = ac.getStartTime() + (openingSecondsTemp * 1000);
|
|
|
+ endTime = endTime + (1000 * 60 * 5);//额外加5分钟,有可能后台交卷未完成
|
|
|
+ }
|
|
|
+ long timestamp = System.currentTimeMillis();
|
|
|
+ if (ac.getEnable().intValue() == 1 && startTime <= timestamp && endTime >= timestamp) {
|
|
|
+ teExamSummaryService.examSummary(l, Long.parseLong(k), v);
|
|
|
+ } else {
|
|
|
+ themisCacheService.removeTodayExamCache(l.toString(), k);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ themisCacheService.removeTodayExamCache(l.toString());
|
|
|
+ themisCacheService.removeTodayExamListCache(l);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|