|
@@ -1,10 +1,19 @@
|
|
|
package com.qmth.themis.business.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.qmth.themis.business.cache.bean.ExamActivityCacheBean;
|
|
|
import com.qmth.themis.business.dao.TEExamSummaryMapper;
|
|
|
import com.qmth.themis.business.entity.TEExamSummary;
|
|
|
+import com.qmth.themis.business.enums.ExamSummaryEnum;
|
|
|
+import com.qmth.themis.business.service.TEExamActivityService;
|
|
|
import com.qmth.themis.business.service.TEExamSummaryService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.StringJoiner;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -17,4 +26,110 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
public class TEExamSummaryServiceImpl extends ServiceImpl<TEExamSummaryMapper, TEExamSummary> implements TEExamSummaryService {
|
|
|
|
|
|
+ @Resource
|
|
|
+ TEExamActivityService teExamActivityService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 统计考试信息
|
|
|
+ *
|
|
|
+ * @param examId
|
|
|
+ * @param examActivityId
|
|
|
+ * @param roomCodeSet
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void examSummary(Long examId, Long examActivityId, Set<String> roomCodeSet) {
|
|
|
+ for (String s : roomCodeSet) {
|
|
|
+ TEExamSummary teExamSummary = this.baseMapper.examSummary(examId, examActivityId, s);
|
|
|
+ if (Objects.nonNull(teExamSummary)) {
|
|
|
+ teExamSummary.setExamId(examId);
|
|
|
+ teExamSummary.setExamActivityId(examActivityId);
|
|
|
+ teExamSummary.setRoomCode(s);
|
|
|
+ ExamActivityCacheBean examActivityCacheBean = teExamActivityService.getExamActivityCacheBean(examActivityId);
|
|
|
+ //当考试场次开始时间已过且未结束考试,当前侯考数设为0,缺考数设为侯考数
|
|
|
+ long timestamp = System.currentTimeMillis();
|
|
|
+ if (teExamSummary.getPrepareCount().intValue() > 0) {//侯考
|
|
|
+ teExamSummary.setAbsentCount(teExamSummary.getTotalCount() - teExamSummary.getPrepareCount());
|
|
|
+ }
|
|
|
+ //考试中
|
|
|
+ if (examActivityCacheBean.getStartTime().longValue() <= timestamp
|
|
|
+ && examActivityCacheBean.getFinishTime().longValue() > timestamp) {
|
|
|
+ teExamSummary.setPrepareCount(0);
|
|
|
+ teExamSummary.setAbsentCount(teExamSummary.getTotalCount() - teExamSummary.getExamCount());
|
|
|
+ }//交卷
|
|
|
+ else if (examActivityCacheBean.getFinishTime().longValue() <= timestamp) {//当考试场次结束时间已过,缺考=全部应考-已完成考试
|
|
|
+ teExamSummary.setAbsentCount(teExamSummary.getTotalCount() - teExamSummary.getFinishCount());
|
|
|
+ }
|
|
|
+ int count = this.baseMapper.selectExamSummaryCount(examId, examActivityId, s);
|
|
|
+ StringJoiner stringJoinerFieldName = new StringJoiner(",");
|
|
|
+ StringJoiner stringJoinerFieldValue = new StringJoiner(",");
|
|
|
+ ExamSummaryEnum[] examSummaryEnums = ExamSummaryEnum.values();
|
|
|
+ if (count == 0) {
|
|
|
+ for (int i = 0; i < examSummaryEnums.length; i++) {
|
|
|
+ stringJoinerFieldName.add(examSummaryEnums[i].getCode());
|
|
|
+ }
|
|
|
+ stringJoinerFieldValue.add("'" + teExamSummary.getExamId() + "'")
|
|
|
+ .add("'" + teExamSummary.getExamActivityId() + "'")
|
|
|
+ .add("'" + teExamSummary.getRoomCode() + "'")
|
|
|
+ .add(teExamSummary.getTotalCount() + "")
|
|
|
+ .add(teExamSummary.getPrepareCount() + "")
|
|
|
+ .add(teExamSummary.getExamCount() + "")
|
|
|
+ .add(teExamSummary.getFinishCount() + "")
|
|
|
+ .add(teExamSummary.getAbsentCount() + "")
|
|
|
+ .add(teExamSummary.getOnlineCount() + "")
|
|
|
+ .add(teExamSummary.getOfflineCount() + "")
|
|
|
+ .add(teExamSummary.getMonitorStopCount() + "")
|
|
|
+ .add(teExamSummary.getWarningCount() + "")
|
|
|
+ .add(teExamSummary.getWarningUnread() + "")
|
|
|
+ .add(teExamSummary.getWarningMultipleFaceCount() + "")
|
|
|
+ .add(teExamSummary.getExceptionCount() + "");
|
|
|
+ this.baseMapper.saveExamSummary(stringJoinerFieldName.toString(), stringJoinerFieldValue.toString());
|
|
|
+ } else {
|
|
|
+ for (int i = 0; i < examSummaryEnums.length; i++) {
|
|
|
+ switch (examSummaryEnums[i]) {
|
|
|
+ case totalCount:
|
|
|
+ stringJoinerFieldValue.add(examSummaryEnums[i].getCode() + "=" + teExamSummary.getTotalCount());
|
|
|
+ break;
|
|
|
+ case prepareCount:
|
|
|
+ stringJoinerFieldValue.add(examSummaryEnums[i].getCode() + "=" + teExamSummary.getPrepareCount());
|
|
|
+ break;
|
|
|
+ case examCount:
|
|
|
+ stringJoinerFieldValue.add(examSummaryEnums[i].getCode() + "=" + teExamSummary.getExamCount());
|
|
|
+ break;
|
|
|
+ case finishCount:
|
|
|
+ stringJoinerFieldValue.add(examSummaryEnums[i].getCode() + "=" + teExamSummary.getFinishCount());
|
|
|
+ break;
|
|
|
+ case absentCount:
|
|
|
+ stringJoinerFieldValue.add(examSummaryEnums[i].getCode() + "=" + teExamSummary.getAbsentCount());
|
|
|
+ break;
|
|
|
+ case onlineCount:
|
|
|
+ stringJoinerFieldValue.add(examSummaryEnums[i].getCode() + "=" + teExamSummary.getOnlineCount());
|
|
|
+ break;
|
|
|
+ case offlineCount:
|
|
|
+ stringJoinerFieldValue.add(examSummaryEnums[i].getCode() + "=" + teExamSummary.getOfflineCount());
|
|
|
+ break;
|
|
|
+ case monitorStopCount:
|
|
|
+ stringJoinerFieldValue.add(examSummaryEnums[i].getCode() + "=" + teExamSummary.getMonitorStopCount());
|
|
|
+ break;
|
|
|
+ case warningCount:
|
|
|
+ stringJoinerFieldValue.add(examSummaryEnums[i].getCode() + "=" + teExamSummary.getWarningCount());
|
|
|
+ break;
|
|
|
+ case warningUnread:
|
|
|
+ stringJoinerFieldValue.add(examSummaryEnums[i].getCode() + "=" + teExamSummary.getWarningUnread());
|
|
|
+ break;
|
|
|
+ case warningMultipleFaceCount:
|
|
|
+ stringJoinerFieldValue.add(examSummaryEnums[i].getCode() + "=" + teExamSummary.getWarningMultipleFaceCount());
|
|
|
+ break;
|
|
|
+ case exceptionCount:
|
|
|
+ stringJoinerFieldValue.add(examSummaryEnums[i].getCode() + "=" + teExamSummary.getExceptionCount());
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.baseMapper.updateExamSummary(examId, examActivityId, s, stringJoinerFieldValue.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|