|
@@ -1,23 +1,24 @@
|
|
|
package com.qmth.themis.business.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
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.dao.TEExamSummaryMapper;
|
|
|
import com.qmth.themis.business.entity.TEExamSummary;
|
|
|
-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.util.UidUtil;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.Date;
|
|
|
import java.util.Objects;
|
|
|
import java.util.Set;
|
|
|
|
|
@@ -31,6 +32,7 @@ import java.util.Set;
|
|
|
*/
|
|
|
@Service
|
|
|
public class TEExamSummaryServiceImpl extends ServiceImpl<TEExamSummaryMapper, TEExamSummary> implements TEExamSummaryService {
|
|
|
+ private final static Logger log = LoggerFactory.getLogger(TEExamSummaryServiceImpl.class);
|
|
|
|
|
|
@Resource
|
|
|
TEExamActivityService teExamActivityService;
|
|
@@ -38,9 +40,6 @@ public class TEExamSummaryServiceImpl extends ServiceImpl<TEExamSummaryMapper, T
|
|
|
@Resource
|
|
|
ThemisCacheService themisCacheService;
|
|
|
|
|
|
- @Resource
|
|
|
- TEExamService teExamService;
|
|
|
-
|
|
|
/**
|
|
|
* 统计考试信息
|
|
|
*
|
|
@@ -72,22 +71,25 @@ public class TEExamSummaryServiceImpl extends ServiceImpl<TEExamSummaryMapper, T
|
|
|
teExamSummary.setExamId(examId);
|
|
|
teExamSummary.setExamActivityId(examActivityId);
|
|
|
teExamSummary.setRoomCode(s);
|
|
|
- ExamCacheBean examCacheBean = teExamService.getExamCacheBean(examId);
|
|
|
ExamActivityCacheBean ac = teExamActivityService.getExamActivityCacheBean(examActivityId);
|
|
|
- //换算开始时间和结束时间
|
|
|
- Long startTime = ac.getStartTime() - (ac.getPrepareSeconds() * 1000), endTime = ac.getFinishTime() + SystemConstant.FINISH_DELAY_TIME;
|
|
|
- //当考试场次开始时间已过且未结束考试,当前侯考数设为0,缺考数设为侯考数
|
|
|
+ //换算开始时间、侯考时间、结束时间
|
|
|
+ Long startTime = ac.getStartTime() - (ac.getPrepareSeconds() * 1000);
|
|
|
+ Integer openingSecondsTemp = ac.getOpeningSeconds();
|
|
|
+ openingSecondsTemp = Objects.nonNull(openingSecondsTemp) && openingSecondsTemp.intValue() == 0 ? SystemConstant.DEFAULT_OPENING_SECONDS : openingSecondsTemp;
|
|
|
+ Long finalPrepareTime = ac.getStartTime() + (openingSecondsTemp * 1000);
|
|
|
+ Long endTime = ac.getFinishTime() + SystemConstant.FINISH_DELAY_TIME;//交卷时间加5分钟,后台交卷可能未完成
|
|
|
long timestamp = System.currentTimeMillis();
|
|
|
- if (teExamSummary.getPrepareCount().intValue() > 0) {//侯考
|
|
|
+ if (startTime <= timestamp || teExamSummary.getPrepareCount().intValue() > 0) {//侯考
|
|
|
teExamSummary.setAbsentCount(teExamSummary.getTotalCount() - teExamSummary.getPrepareCount());
|
|
|
}
|
|
|
- //考试中
|
|
|
- if (ExamModeEnum.TOGETHER.equals(examCacheBean.getMode()) && startTime <= timestamp && endTime >= timestamp) {
|
|
|
+ log.info("examSummary examId:{},examActivityId:{},startTime:{},finalPrepareTime:{},endTime:{}", examId, ac.getId(), DateUtil.format(new Date(startTime), "yyyy-MM-dd HH:mm:ss"), DateUtil.format(new Date(finalPrepareTime), "yyyy-MM-dd HH:mm:ss"), DateUtil.format(new Date(endTime), "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ //最后侯考时间已过且未结束考试,当前侯考数设为0
|
|
|
+ if (finalPrepareTime >= timestamp) {
|
|
|
teExamSummary.setPrepareCount(0);
|
|
|
}//交卷
|
|
|
- else if (endTime <= timestamp) {//当考试场次结束时间已过,缺考=全部应考-已完成考试
|
|
|
+ else if (endTime <= timestamp) {//当考试场次结束时间已过,缺考=全部应考-已完成考试
|
|
|
teExamSummary.setAbsentCount(teExamSummary.getTotalCount() - teExamSummary.getFinishCount());
|
|
|
- } else {
|
|
|
+ } else {//否则缺考=全部应考-考试中-已完成考试
|
|
|
teExamSummary.setAbsentCount(teExamSummary.getTotalCount() - teExamSummary.getExamCount() - teExamSummary.getFinishCount());
|
|
|
}
|
|
|
TEExamSummary teExamSummaryDb = this.getOne(new QueryWrapper<TEExamSummary>().lambda()
|