|
@@ -1,11 +1,13 @@
|
|
package com.qmth.themis.business.service.impl;
|
|
package com.qmth.themis.business.service.impl;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.qmth.themis.business.bean.admin.OrgSummaryBean;
|
|
import com.qmth.themis.business.bean.admin.OrgSummaryBean;
|
|
import com.qmth.themis.business.cache.bean.ExamCacheBean;
|
|
import com.qmth.themis.business.cache.bean.ExamCacheBean;
|
|
import com.qmth.themis.business.dao.TEOrgSummaryMapper;
|
|
import com.qmth.themis.business.dao.TEOrgSummaryMapper;
|
|
import com.qmth.themis.business.entity.TBOrg;
|
|
import com.qmth.themis.business.entity.TBOrg;
|
|
|
|
+import com.qmth.themis.business.entity.TEExam;
|
|
import com.qmth.themis.business.entity.TEExamSummary;
|
|
import com.qmth.themis.business.entity.TEExamSummary;
|
|
import com.qmth.themis.business.entity.TEOrgSummary;
|
|
import com.qmth.themis.business.entity.TEOrgSummary;
|
|
import com.qmth.themis.business.service.TEExamService;
|
|
import com.qmth.themis.business.service.TEExamService;
|
|
@@ -17,7 +19,9 @@ import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -48,9 +52,8 @@ public class TEOrgSummaryServiceImpl extends ServiceImpl<TEOrgSummaryMapper, TEO
|
|
@Override
|
|
@Override
|
|
public void orgSummary(Long orgId, List<Long> examIdSet) {
|
|
public void orgSummary(Long orgId, List<Long> examIdSet) {
|
|
if (orgId.longValue() == 0) {//全局机构
|
|
if (orgId.longValue() == 0) {//全局机构
|
|
- OrgSummaryBean orgSummaryBean = this.baseMapper.orgSummary(orgId, examIdSet);
|
|
|
|
- TEOrgSummary teOrgSummary = new TEOrgSummary(orgId, orgSummaryBean);
|
|
|
|
- teOrgSummaryService.saveOrUpdate(teOrgSummary);
|
|
|
|
|
|
+ OrgSummaryBean orgSummaryBean = this.baseMapper.orgSummary(orgId, examIdSet, false);
|
|
|
|
+ this.updateOrgSummary(orgId, orgSummaryBean.getOnlineCount(), orgSummaryBean.getExamCount());
|
|
} else {
|
|
} else {
|
|
LinkedMultiValueMap<Long, Long> orgExamIdMap = new LinkedMultiValueMap<>();
|
|
LinkedMultiValueMap<Long, Long> orgExamIdMap = new LinkedMultiValueMap<>();
|
|
boolean reloadDb = false;
|
|
boolean reloadDb = false;
|
|
@@ -67,9 +70,8 @@ public class TEOrgSummaryServiceImpl extends ServiceImpl<TEOrgSummaryMapper, TEO
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (reloadDb) {//没有该批次的考试统计缓存信息,则从数据库取数据
|
|
if (reloadDb) {//没有该批次的考试统计缓存信息,则从数据库取数据
|
|
- OrgSummaryBean orgSummaryBean = this.baseMapper.orgSummary(orgId, examIdSet);
|
|
|
|
- TEOrgSummary teOrgSummary = new TEOrgSummary(orgId, orgSummaryBean);
|
|
|
|
- teOrgSummaryService.saveOrUpdate(teOrgSummary);
|
|
|
|
|
|
+ OrgSummaryBean orgSummaryBean = this.baseMapper.orgSummary(orgId, examIdSet, false);
|
|
|
|
+ this.updateOrgSummary(orgId, orgSummaryBean.getOnlineCount(), orgSummaryBean.getExamCount());
|
|
} else {
|
|
} else {
|
|
orgExamIdMap.forEach((k, v) -> {//从考试批次缓存信息里拿取在线人数、考试人数、完成考生数
|
|
orgExamIdMap.forEach((k, v) -> {//从考试批次缓存信息里拿取在线人数、考试人数、完成考生数
|
|
Integer onlineCount = 0, examCount = 0;
|
|
Integer onlineCount = 0, examCount = 0;
|
|
@@ -80,17 +82,37 @@ public class TEOrgSummaryServiceImpl extends ServiceImpl<TEOrgSummaryMapper, TEO
|
|
examCount = examCount + t.getExamCount();
|
|
examCount = examCount + t.getExamCount();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- UpdateWrapper<TEOrgSummary> teOrgSummaryUpdateWrapper = new UpdateWrapper<>();
|
|
|
|
- teOrgSummaryUpdateWrapper.lambda().set(TEOrgSummary::getOnlineCount, onlineCount)
|
|
|
|
- .set(TEOrgSummary::getExamCount, examCount)
|
|
|
|
- .eq(TEOrgSummary::getOrgId, orgId);
|
|
|
|
- teOrgSummaryService.update(teOrgSummaryUpdateWrapper);
|
|
|
|
|
|
+ this.updateOrgSummary(orgId, onlineCount, examCount);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
themisCacheService.updateOrgSummaryCache(orgId);
|
|
themisCacheService.updateOrgSummaryCache(orgId);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 根据机构id统计信息
|
|
|
|
+ *
|
|
|
|
+ * @param orgId
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public void orgSummary(Long orgId) {
|
|
|
|
+ List<Long> examIdSet = null;
|
|
|
|
+ if (orgId.longValue() != 0) {//全局机构
|
|
|
|
+ List<TEExam> teExamList = teExamService.list(new QueryWrapper<TEExam>().lambda().eq(TEExam::getOrgId, orgId));
|
|
|
|
+ if (!CollectionUtils.isEmpty(teExamList)) {
|
|
|
|
+ examIdSet = teExamList.stream().map(s -> s.getId()).collect(Collectors.toList());
|
|
|
|
+ } else {
|
|
|
|
+ examIdSet = Arrays.asList(-1L);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ OrgSummaryBean orgSummaryBean = this.baseMapper.orgSummary(orgId, examIdSet, true);
|
|
|
|
+ Integer finishStudentCount = this.baseMapper.orgSummaryByFinishStudentCount(orgId, examIdSet);
|
|
|
|
+ orgSummaryBean.setFinishStudentCount(finishStudentCount);
|
|
|
|
+ TEOrgSummary teOrgSummary = new TEOrgSummary(orgId, orgSummaryBean);
|
|
|
|
+ teOrgSummaryService.save(teOrgSummary);
|
|
|
|
+ themisCacheService.updateOrgSummaryCache(orgId);
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 更新全局机构考试完成数量和考生完成数量
|
|
* 更新全局机构考试完成数量和考生完成数量
|
|
*
|
|
*
|
|
@@ -102,4 +124,20 @@ public class TEOrgSummaryServiceImpl extends ServiceImpl<TEOrgSummaryMapper, TEO
|
|
public void updateOrgZeroSummary(Long orgId, Integer finishStudentCount) {
|
|
public void updateOrgZeroSummary(Long orgId, Integer finishStudentCount) {
|
|
this.baseMapper.updateOrgZeroSummary(orgId, finishStudentCount);
|
|
this.baseMapper.updateOrgZeroSummary(orgId, finishStudentCount);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据机构id更新在线和考试人数
|
|
|
|
+ *
|
|
|
|
+ * @param orgId
|
|
|
|
+ * @param onlineCount
|
|
|
|
+ * @param examCount
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public void updateOrgSummary(Long orgId, Integer onlineCount, Integer examCount) {
|
|
|
|
+ UpdateWrapper<TEOrgSummary> teOrgSummaryUpdateWrapper = new UpdateWrapper<>();
|
|
|
|
+ teOrgSummaryUpdateWrapper.lambda().set(TEOrgSummary::getOnlineCount, onlineCount)
|
|
|
|
+ .set(TEOrgSummary::getExamCount, examCount)
|
|
|
|
+ .eq(TEOrgSummary::getOrgId, orgId);
|
|
|
|
+ teOrgSummaryService.update(teOrgSummaryUpdateWrapper);
|
|
|
|
+ }
|
|
}
|
|
}
|