|
@@ -1,7 +1,8 @@
|
|
package com.qmth.themis.business.service.impl;
|
|
package com.qmth.themis.business.service.impl;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
-import com.qmth.themis.business.bean.admin.ExamActivityTodayBean;
|
|
|
|
|
|
+import com.qmth.themis.business.bean.admin.ExamListBean;
|
|
import com.qmth.themis.business.cache.bean.ExamCacheBean;
|
|
import com.qmth.themis.business.cache.bean.ExamCacheBean;
|
|
import com.qmth.themis.business.constant.SpringContextHolder;
|
|
import com.qmth.themis.business.constant.SpringContextHolder;
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
@@ -10,6 +11,7 @@ import com.qmth.themis.business.dto.cache.TEStudentCacheDto;
|
|
import com.qmth.themis.business.entity.*;
|
|
import com.qmth.themis.business.entity.*;
|
|
import com.qmth.themis.business.enums.RoleEnum;
|
|
import com.qmth.themis.business.enums.RoleEnum;
|
|
import com.qmth.themis.business.service.*;
|
|
import com.qmth.themis.business.service.*;
|
|
|
|
+import com.qmth.themis.business.util.JacksonUtil;
|
|
import com.qmth.themis.business.util.RedisUtil;
|
|
import com.qmth.themis.business.util.RedisUtil;
|
|
import com.qmth.themis.common.enums.ExceptionResultEnum;
|
|
import com.qmth.themis.common.enums.ExceptionResultEnum;
|
|
import com.qmth.themis.common.exception.BusinessException;
|
|
import com.qmth.themis.common.exception.BusinessException;
|
|
@@ -27,6 +29,7 @@ import org.springframework.util.LinkedMultiValueMap;
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.concurrent.CopyOnWriteArrayList;
|
|
import java.util.concurrent.CopyOnWriteArraySet;
|
|
import java.util.concurrent.CopyOnWriteArraySet;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -620,23 +623,34 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
|
|
List<TEExamActivity> teExamActivityList = teExamActivityService.list(new QueryWrapper<TEExamActivity>().lambda().ge(TEExamActivity::getStartTime, startTime).le(TEExamActivity::getStartTime, endTime).eq(TEExamActivity::getEnable, 1));
|
|
List<TEExamActivity> teExamActivityList = teExamActivityService.list(new QueryWrapper<TEExamActivity>().lambda().ge(TEExamActivity::getStartTime, startTime).le(TEExamActivity::getStartTime, endTime).eq(TEExamActivity::getEnable, 1));
|
|
//统计当天00:00:00~23:59:59可以进行的考试批次、场次、考场编码信息
|
|
//统计当天00:00:00~23:59:59可以进行的考试批次、场次、考场编码信息
|
|
if (!CollectionUtils.isEmpty(teExamActivityList)) {
|
|
if (!CollectionUtils.isEmpty(teExamActivityList)) {
|
|
- LinkedMultiValueMap<Long, ExamActivityTodayBean> examActivityMap = new LinkedMultiValueMap<>();
|
|
|
|
|
|
+ LinkedMultiValueMap<Long, String> examActivityMap = new LinkedMultiValueMap<>();
|
|
|
|
+ Map<Long, Set<Long>> examActivityIdMap = new HashMap<>();//考试批次id,场次id集合
|
|
|
|
+ Map<Long, Set<String>> roomCodeMap = new HashMap<>();//考试场次id,考场编码集合
|
|
for (TEExamActivity t : teExamActivityList) {
|
|
for (TEExamActivity t : teExamActivityList) {
|
|
ExamCacheBean examCacheBean = teExamService.getExamCacheBean(t.getExamId());
|
|
ExamCacheBean examCacheBean = teExamService.getExamCacheBean(t.getExamId());
|
|
- if (Objects.nonNull(examCacheBean.getEnable()) && examCacheBean.getEnable().intValue() == 1) {
|
|
|
|
|
|
+ if (Objects.nonNull(examCacheBean.getEnable()) && examCacheBean.getEnable().intValue() == 1 && Objects.nonNull(t.getEnable()) && t.getEnable().intValue() == 1) {
|
|
List<TEExamStudent> teExamStudentList = teExamStudentService.list(new QueryWrapper<TEExamStudent>().lambda().eq(TEExamStudent::getExamId, t.getExamId()).eq(TEExamStudent::getExamActivityId, t.getId()));
|
|
List<TEExamStudent> teExamStudentList = teExamStudentService.list(new QueryWrapper<TEExamStudent>().lambda().eq(TEExamStudent::getExamId, t.getExamId()).eq(TEExamStudent::getExamActivityId, t.getId()));
|
|
if (!CollectionUtils.isEmpty(teExamStudentList)) {
|
|
if (!CollectionUtils.isEmpty(teExamStudentList)) {
|
|
Set<String> roomCodeSet = teExamStudentList.stream().map(s -> s.getRoomCode()).collect(Collectors.toSet());
|
|
Set<String> roomCodeSet = teExamStudentList.stream().map(s -> s.getRoomCode()).collect(Collectors.toSet());
|
|
- examActivityMap.add(t.getExamId(), new ExamActivityTodayBean(t.getId(), roomCodeSet));
|
|
|
|
|
|
+ if (examActivityIdMap.containsKey(t.getExamId())) {
|
|
|
|
+ Set<Long> examActivityIdSet = examActivityIdMap.get(t.getExamId());
|
|
|
|
+ examActivityIdSet.add(t.getId());
|
|
|
|
+ examActivityIdMap.put(t.getExamId(), examActivityIdSet);
|
|
|
|
+ } else {
|
|
|
|
+ examActivityIdMap.put(t.getExamId(), new HashSet<>(Arrays.asList(t.getId())));
|
|
|
|
+ }
|
|
|
|
+ roomCodeMap.put(t.getId(), roomCodeSet);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- examActivityMap.forEach((k, v) -> {
|
|
|
|
- for (ExamActivityTodayBean e : v) {
|
|
|
|
- redisUtil.set(SystemConstant.TODAY_EXAM_MAP_CACHE + k, e.getExamActivityId().toString(), e.getRoomCodeList());
|
|
|
|
- redisUtil.addSet(SystemConstant.TODAY_EXAM_ID_LIST_CACHE, k);
|
|
|
|
|
|
+ examActivityIdMap.forEach((k, v) -> {
|
|
|
|
+ for (Long l : v) {
|
|
|
|
+ examActivityMap.add(k, JacksonUtil.parseJson(new ExamListBean(l, roomCodeMap.get(l))));
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+ examActivityMap.forEach((k, v) -> {
|
|
|
|
+ redisUtil.set(SystemConstant.TODAY_EXAM_LIST_MAP_CACHE, k.toString(), v);
|
|
|
|
+ });
|
|
}
|
|
}
|
|
teOrgSummaryService.orgSummary(0L, null);//统计全局机构信息
|
|
teOrgSummaryService.orgSummary(0L, null);//统计全局机构信息
|
|
teRegionSummaryService.regionSummary();
|
|
teRegionSummaryService.regionSummary();
|
|
@@ -653,8 +667,8 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
|
|
//查询考试场次结束时间大于当前时间的所有考试
|
|
//查询考试场次结束时间大于当前时间的所有考试
|
|
List<TEExamActivity> teExamActivityList = teExamActivityService.list(new QueryWrapper<TEExamActivity>().lambda().gt(TEExamActivity::getFinishTime, System.currentTimeMillis()).eq(TEExamActivity::getEnable, 1));
|
|
List<TEExamActivity> teExamActivityList = teExamActivityService.list(new QueryWrapper<TEExamActivity>().lambda().gt(TEExamActivity::getFinishTime, System.currentTimeMillis()).eq(TEExamActivity::getEnable, 1));
|
|
if (!CollectionUtils.isEmpty(teExamActivityList)) {
|
|
if (!CollectionUtils.isEmpty(teExamActivityList)) {
|
|
- Map<Long, Set<Long>> examMap = new HashMap<>();
|
|
|
|
- Map<Long, Set<Long>> orgMap = new HashMap<>();
|
|
|
|
|
|
+ Map<Long, Set<Long>> examMap = new HashMap<>();//考试批次id,场次id集合
|
|
|
|
+ Map<Long, Set<Long>> orgMap = new HashMap<>();//机构id,考试批次id集合
|
|
for (TEExamActivity t : teExamActivityList) {
|
|
for (TEExamActivity t : teExamActivityList) {
|
|
ExamCacheBean examCacheBean = teExamService.getExamCacheBean(t.getExamId());
|
|
ExamCacheBean examCacheBean = teExamService.getExamCacheBean(t.getExamId());
|
|
if (Objects.nonNull(examCacheBean.getEnable()) && examCacheBean.getEnable().intValue() == 1) {
|
|
if (Objects.nonNull(examCacheBean.getEnable()) && examCacheBean.getEnable().intValue() == 1) {
|
|
@@ -722,6 +736,9 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
|
|
redisUtil.set(SystemConstant.ORG_EXAM_LIST_MAP_CACHE + orgId, examId, new HashSet<>(Arrays.asList(examActivityId)));
|
|
redisUtil.set(SystemConstant.ORG_EXAM_LIST_MAP_CACHE + orgId, examId, new HashSet<>(Arrays.asList(examActivityId)));
|
|
} else {
|
|
} else {
|
|
Set<Long> examActivityIdSet = map.get(examId);
|
|
Set<Long> examActivityIdSet = map.get(examId);
|
|
|
|
+ if (Objects.isNull(examActivityIdSet)) {
|
|
|
|
+ examActivityIdSet = new HashSet<>();
|
|
|
|
+ }
|
|
examActivityIdSet.add(examActivityId);
|
|
examActivityIdSet.add(examActivityId);
|
|
redisUtil.set(SystemConstant.ORG_EXAM_LIST_MAP_CACHE + orgId, examId, examActivityIdSet);
|
|
redisUtil.set(SystemConstant.ORG_EXAM_LIST_MAP_CACHE + orgId, examId, examActivityIdSet);
|
|
}
|
|
}
|
|
@@ -781,8 +798,14 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public Map<String, Set<String>> getTodayExamListCache(String examId) {
|
|
|
|
- return redisUtil.getHashEntries(SystemConstant.TODAY_EXAM_MAP_CACHE + examId);
|
|
|
|
|
|
+ public Map<String, List<String>> getTodayExamListCache(String examId) {
|
|
|
|
+ Map<String, List<String>> examActityIdMap = null;
|
|
|
|
+ Map<String, List<String>> map = redisUtil.getHashEntries(SystemConstant.TODAY_EXAM_LIST_MAP_CACHE);
|
|
|
|
+ if (!CollectionUtils.isEmpty(map) && Objects.nonNull(map.get(examId))) {
|
|
|
|
+ examActityIdMap = new HashMap<>();
|
|
|
|
+ examActityIdMap.put(examId, map.get(examId));
|
|
|
|
+ }
|
|
|
|
+ return examActityIdMap;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -792,12 +815,21 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public void updateTodayExamListCache(String examId, String examActivityId) {
|
|
|
|
|
|
+ public void updateTodayExamListCache(String examId, Long examActivityId) {
|
|
List<TEExamStudent> teExamStudentList = teExamStudentService.list(new QueryWrapper<TEExamStudent>().lambda().eq(TEExamStudent::getExamId, Long.parseLong(examId)).eq(TEExamStudent::getExamActivityId, examActivityId));
|
|
List<TEExamStudent> teExamStudentList = teExamStudentService.list(new QueryWrapper<TEExamStudent>().lambda().eq(TEExamStudent::getExamId, Long.parseLong(examId)).eq(TEExamStudent::getExamActivityId, examActivityId));
|
|
if (!CollectionUtils.isEmpty(teExamStudentList)) {
|
|
if (!CollectionUtils.isEmpty(teExamStudentList)) {
|
|
Set<String> roomCodeSet = teExamStudentList.stream().map(s -> s.getRoomCode()).collect(Collectors.toSet());
|
|
Set<String> roomCodeSet = teExamStudentList.stream().map(s -> s.getRoomCode()).collect(Collectors.toSet());
|
|
this.removeTodayExamListCache(examId, examActivityId);
|
|
this.removeTodayExamListCache(examId, examActivityId);
|
|
- redisUtil.set(SystemConstant.TODAY_EXAM_MAP_CACHE + examId, examActivityId, roomCodeSet);
|
|
|
|
|
|
+ Map<String, List<String>> map = this.getTodayExamListCache(examId);
|
|
|
|
+ if (!CollectionUtils.isEmpty(map)) {
|
|
|
|
+ CopyOnWriteArrayList<String> copyOnWriteArrayList = new CopyOnWriteArrayList(map.values());
|
|
|
|
+ copyOnWriteArrayList.add(JacksonUtil.parseJson(new ExamListBean(examActivityId, roomCodeSet)));
|
|
|
|
+ redisUtil.set(SystemConstant.TODAY_EXAM_LIST_MAP_CACHE, examId, new LinkedList<>(copyOnWriteArrayList));
|
|
|
|
+ } else {
|
|
|
|
+ CopyOnWriteArrayList<String> copyOnWriteArrayList = new CopyOnWriteArrayList();
|
|
|
|
+ copyOnWriteArrayList.add(JacksonUtil.parseJson(new ExamListBean(examActivityId, roomCodeSet)));
|
|
|
|
+ redisUtil.set(SystemConstant.TODAY_EXAM_LIST_MAP_CACHE, examId, new LinkedList<>(copyOnWriteArrayList));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -808,7 +840,7 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public void removeTodayExamListCache(String examId) {
|
|
public void removeTodayExamListCache(String examId) {
|
|
- redisUtil.delete(SystemConstant.TODAY_EXAM_MAP_CACHE + examId);
|
|
|
|
|
|
+ redisUtil.delete(SystemConstant.TODAY_EXAM_LIST_MAP_CACHE, examId);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -818,38 +850,28 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
|
|
* @param examActivityId
|
|
* @param examActivityId
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public void removeTodayExamListCache(String examId, String examActivityId) {
|
|
|
|
- redisUtil.delete(SystemConstant.TODAY_EXAM_MAP_CACHE + examId, examActivityId);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 获取当天考试列表缓存
|
|
|
|
- *
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- @Override
|
|
|
|
- public Set<Long> getTodayExamIdListCache() {
|
|
|
|
- return redisUtil.getSet(SystemConstant.TODAY_EXAM_ID_LIST_CACHE);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 更新当天考试列表缓存
|
|
|
|
- *
|
|
|
|
- * @param examId
|
|
|
|
- */
|
|
|
|
- @Override
|
|
|
|
- public void updateTodayExamIdListCache(Long examId) {
|
|
|
|
- redisUtil.addSet(SystemConstant.TODAY_EXAM_ID_LIST_CACHE, examId);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 删除当天考试列表缓存
|
|
|
|
- *
|
|
|
|
- * @param examId
|
|
|
|
- */
|
|
|
|
- @Override
|
|
|
|
- public void removeTodayExamIdListCache(Long examId) {
|
|
|
|
- redisUtil.removeSet(SystemConstant.TODAY_EXAM_ID_LIST_CACHE, examId);
|
|
|
|
|
|
+ public void removeTodayExamListCache(String examId, Long examActivityId) {
|
|
|
|
+ Map<String, List<String>> map = this.getTodayExamListCache(examId);
|
|
|
|
+ if (!CollectionUtils.isEmpty(map)) {
|
|
|
|
+ map.forEach((k, v) -> {
|
|
|
|
+ if (!CollectionUtils.isEmpty(v)) {
|
|
|
|
+ CopyOnWriteArrayList<String> copyOnWriteArrayList = new CopyOnWriteArrayList(v);
|
|
|
|
+ for (String s : copyOnWriteArrayList) {
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(s);
|
|
|
|
+ Long examActivityIdJs = jsonObject.getLong(SystemConstant.EXAM_ACTIVITY_ID);
|
|
|
|
+ if (examActivityIdJs.longValue() == examActivityId.longValue()) {
|
|
|
|
+ copyOnWriteArrayList.remove(s);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!CollectionUtils.isEmpty(copyOnWriteArrayList)) {
|
|
|
|
+ redisUtil.set(SystemConstant.TODAY_EXAM_LIST_MAP_CACHE, k, new LinkedList<>(copyOnWriteArrayList));
|
|
|
|
+ } else {
|
|
|
|
+ this.removeTodayExamListCache(examId);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -871,9 +893,7 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
|
|
}
|
|
}
|
|
List<TEExamSummary> teExamSummaryList = teExamSummaryService.list(teExamSummaryQueryWrapper);
|
|
List<TEExamSummary> teExamSummaryList = teExamSummaryService.list(teExamSummaryQueryWrapper);
|
|
if (CollectionUtils.isEmpty(teExamSummaryList)) {
|
|
if (CollectionUtils.isEmpty(teExamSummaryList)) {
|
|
- if (Objects.nonNull(examActivityId) && Objects.nonNull(roomCode)) {
|
|
|
|
- teExamSummaryService.examSummary(examId, examActivityId, new HashSet<>(Arrays.asList(roomCode)));
|
|
|
|
- }
|
|
|
|
|
|
+ teExamSummaryService.examSummary(examId, examActivityId, Objects.nonNull(roomCode) ? new HashSet<>(Arrays.asList(roomCode)) : null);
|
|
teExamSummaryList = teExamSummaryService.list(teExamSummaryQueryWrapper);
|
|
teExamSummaryList = teExamSummaryService.list(teExamSummaryQueryWrapper);
|
|
}
|
|
}
|
|
return teExamSummaryList;
|
|
return teExamSummaryList;
|