|
@@ -3,11 +3,9 @@ package com.qmth.themis.task.quartz;
|
|
import com.qmth.themis.business.cache.bean.ExamActivityCacheBean;
|
|
import com.qmth.themis.business.cache.bean.ExamActivityCacheBean;
|
|
import com.qmth.themis.business.cache.bean.ExamCacheBean;
|
|
import com.qmth.themis.business.cache.bean.ExamCacheBean;
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
|
|
+import com.qmth.themis.business.entity.TBOrg;
|
|
import com.qmth.themis.business.enums.ExamModeEnum;
|
|
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 com.qmth.themis.business.service.*;
|
|
import org.quartz.JobExecutionContext;
|
|
import org.quartz.JobExecutionContext;
|
|
import org.quartz.JobExecutionException;
|
|
import org.quartz.JobExecutionException;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
@@ -15,6 +13,7 @@ import org.slf4j.LoggerFactory;
|
|
import org.springframework.scheduling.quartz.QuartzJobBean;
|
|
import org.springframework.scheduling.quartz.QuartzJobBean;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
+import org.springframework.util.LinkedMultiValueMap;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -44,17 +43,26 @@ public class ExamSummaryJob extends QuartzJobBean {
|
|
@Resource
|
|
@Resource
|
|
TEExamActivityService teExamActivityService;
|
|
TEExamActivityService teExamActivityService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ TEOrgSummaryService teOrgSummaryService;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
|
|
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
|
|
log.info("ExamSummaryJob进来了,context:{}", context);
|
|
log.info("ExamSummaryJob进来了,context:{}", context);
|
|
|
|
+ //获取当天考试列表
|
|
Set<Long> examIdSet = themisCacheService.getTodayExamListCache();
|
|
Set<Long> examIdSet = themisCacheService.getTodayExamListCache();
|
|
if (!CollectionUtils.isEmpty(examIdSet)) {
|
|
if (!CollectionUtils.isEmpty(examIdSet)) {
|
|
|
|
+ LinkedMultiValueMap<Long, Long> orgExamIdMap = new LinkedMultiValueMap<>();
|
|
for (Long l : examIdSet) {
|
|
for (Long l : examIdSet) {
|
|
ExamCacheBean examCacheBean = teExamService.getExamCacheBean(l);
|
|
ExamCacheBean examCacheBean = teExamService.getExamCacheBean(l);
|
|
|
|
+ //不在考试时间范围内或者禁用,则删除当前考试批次id,更新缓存
|
|
if (examCacheBean.getEnable().intValue() == 0 || examCacheBean.getEndTime().longValue() <= System.currentTimeMillis()) {
|
|
if (examCacheBean.getEnable().intValue() == 0 || examCacheBean.getEndTime().longValue() <= System.currentTimeMillis()) {
|
|
themisCacheService.removeTodayExamCache(l.toString());
|
|
themisCacheService.removeTodayExamCache(l.toString());
|
|
themisCacheService.removeTodayExamListCache(l);
|
|
themisCacheService.removeTodayExamListCache(l);
|
|
}
|
|
}
|
|
|
|
+ TBOrg tbOrg = themisCacheService.addOrgCache(examCacheBean.getOrgId());
|
|
|
|
+ orgExamIdMap.add(tbOrg.getId(), l);
|
|
|
|
+
|
|
Map<String, Set<String>> map = themisCacheService.getTodayExamCache(l.toString());
|
|
Map<String, Set<String>> map = themisCacheService.getTodayExamCache(l.toString());
|
|
if (!CollectionUtils.isEmpty(map)) {
|
|
if (!CollectionUtils.isEmpty(map)) {
|
|
map.forEach((k, v) -> {
|
|
map.forEach((k, v) -> {
|
|
@@ -64,15 +72,16 @@ public class ExamSummaryJob extends QuartzJobBean {
|
|
if (ExamModeEnum.ANYTIME.equals(examCacheBean.getMode())) {
|
|
if (ExamModeEnum.ANYTIME.equals(examCacheBean.getMode())) {
|
|
startTime = ac.getStartTime() - (ac.getPrepareSeconds() * 1000);
|
|
startTime = ac.getStartTime() - (ac.getPrepareSeconds() * 1000);
|
|
endTime = ac.getFinishTime();
|
|
endTime = ac.getFinishTime();
|
|
- endTime = endTime + (1000 * 60 * 5);//额外加5分钟,有可能后台交卷未完成
|
|
|
|
|
|
+ endTime = endTime + SystemConstant.FINISH_DELAY_TIME;//额外加5分钟,有可能后台交卷未完成
|
|
} else {
|
|
} else {
|
|
startTime = ac.getStartTime() - (ac.getPrepareSeconds() * 1000);
|
|
startTime = ac.getStartTime() - (ac.getPrepareSeconds() * 1000);
|
|
Integer openingSecondsTemp = ac.getOpeningSeconds();
|
|
Integer openingSecondsTemp = ac.getOpeningSeconds();
|
|
openingSecondsTemp = Objects.nonNull(openingSecondsTemp) && openingSecondsTemp.intValue() == 0 ? SystemConstant.DEFAULT_OPENING_SECONDS : openingSecondsTemp;
|
|
openingSecondsTemp = Objects.nonNull(openingSecondsTemp) && openingSecondsTemp.intValue() == 0 ? SystemConstant.DEFAULT_OPENING_SECONDS : openingSecondsTemp;
|
|
endTime = ac.getStartTime() + (openingSecondsTemp * 1000);
|
|
endTime = ac.getStartTime() + (openingSecondsTemp * 1000);
|
|
- endTime = endTime + (1000 * 60 * 5);//额外加5分钟,有可能后台交卷未完成
|
|
|
|
|
|
+ endTime = endTime + SystemConstant.FINISH_DELAY_TIME;//额外加5分钟,有可能后台交卷未完成
|
|
}
|
|
}
|
|
long timestamp = System.currentTimeMillis();
|
|
long timestamp = System.currentTimeMillis();
|
|
|
|
+ //当考试场次开始时间和场次结束时间在范围内,则统计,否则删除考试批次缓存列表,考试批次统计缓存信息
|
|
if (ac.getEnable().intValue() == 1 && startTime <= timestamp && endTime >= timestamp) {
|
|
if (ac.getEnable().intValue() == 1 && startTime <= timestamp && endTime >= timestamp) {
|
|
teExamSummaryService.examSummary(l, Long.parseLong(k), v);
|
|
teExamSummaryService.examSummary(l, Long.parseLong(k), v);
|
|
} else {
|
|
} else {
|
|
@@ -84,6 +93,10 @@ public class ExamSummaryJob extends QuartzJobBean {
|
|
themisCacheService.removeTodayExamListCache(l);
|
|
themisCacheService.removeTodayExamListCache(l);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ //统计机构信息
|
|
|
|
+ orgExamIdMap.forEach((k, v) -> {
|
|
|
|
+ teOrgSummaryService.orgSummary(k, v);
|
|
|
|
+ });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|