|
@@ -1,6 +1,5 @@
|
|
|
package com.qmth.themis.business.service.impl;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.qmth.themis.business.bean.admin.ExamListBean;
|
|
|
import com.qmth.themis.business.cache.bean.ExamCacheBean;
|
|
@@ -11,11 +10,11 @@ import com.qmth.themis.business.dto.cache.TEStudentCacheDto;
|
|
|
import com.qmth.themis.business.entity.*;
|
|
|
import com.qmth.themis.business.enums.RoleEnum;
|
|
|
import com.qmth.themis.business.service.*;
|
|
|
-import com.qmth.themis.business.util.JacksonUtil;
|
|
|
import com.qmth.themis.business.util.RedisUtil;
|
|
|
import com.qmth.themis.common.enums.ExceptionResultEnum;
|
|
|
import com.qmth.themis.common.exception.BusinessException;
|
|
|
import com.qmth.themis.common.util.GsonUtil;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.cache.CacheManager;
|
|
@@ -623,7 +622,7 @@ 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));
|
|
|
//统计当天00:00:00~23:59:59可以进行的考试批次、场次、考场编码信息
|
|
|
if (!CollectionUtils.isEmpty(teExamActivityList)) {
|
|
|
- LinkedMultiValueMap<Long, String> examActivityMap = new LinkedMultiValueMap<>();
|
|
|
+ LinkedMultiValueMap<Long, ExamListBean> examActivityMap = new LinkedMultiValueMap<>();
|
|
|
Map<Long, Set<Long>> examActivityIdMap = new HashMap<>();//考试批次id,场次id集合
|
|
|
Map<Long, Set<String>> roomCodeMap = new HashMap<>();//考试场次id,考场编码集合
|
|
|
for (TEExamActivity t : teExamActivityList) {
|
|
@@ -645,7 +644,8 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
|
|
|
}
|
|
|
examActivityIdMap.forEach((k, v) -> {
|
|
|
for (Long l : v) {
|
|
|
- examActivityMap.add(k, JacksonUtil.parseJson(new ExamListBean(l, roomCodeMap.get(l))));
|
|
|
+ String s = StringUtils.join(roomCodeMap.get(l)).replaceAll("\\[", "").replaceAll("\\]", "");
|
|
|
+ examActivityMap.add(k, new ExamListBean(l, s));
|
|
|
}
|
|
|
});
|
|
|
examActivityMap.forEach((k, v) -> {
|
|
@@ -717,11 +717,7 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
|
|
|
@Override
|
|
|
public Set<Long> getOrgExamListCache(String orgId, String examId) {
|
|
|
Map<String, Set<Long>> map = redisUtil.getHashEntries(SystemConstant.ORG_EXAM_LIST_MAP_CACHE + orgId);
|
|
|
- if (!CollectionUtils.isEmpty(map)) {
|
|
|
- return map.get(examId);
|
|
|
- } else {
|
|
|
- return null;
|
|
|
- }
|
|
|
+ return !CollectionUtils.isEmpty(map) ? map.get(examId) : null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -798,14 +794,9 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- 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;
|
|
|
+ public List<ExamListBean> getTodayExamListCache(String examId) {
|
|
|
+ Map<String, List<ExamListBean>> map = redisUtil.getHashEntries(SystemConstant.TODAY_EXAM_LIST_MAP_CACHE);
|
|
|
+ return !CollectionUtils.isEmpty(map) ? map.get(examId) : null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -820,19 +811,9 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
|
|
|
if (!CollectionUtils.isEmpty(teExamStudentList)) {
|
|
|
Set<String> roomCodeSet = teExamStudentList.stream().map(s -> s.getRoomCode()).collect(Collectors.toSet());
|
|
|
this.removeTodayExamListCache(examId, examActivityId);
|
|
|
- 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));
|
|
|
- }
|
|
|
- } else {
|
|
|
- CopyOnWriteArrayList<String> copyOnWriteArrayList = new CopyOnWriteArrayList();
|
|
|
- copyOnWriteArrayList.add(JacksonUtil.parseJson(new ExamListBean(examActivityId, null)));
|
|
|
+ List<ExamListBean> examListBeanList = this.getTodayExamListCache(examId);
|
|
|
+ CopyOnWriteArrayList<ExamListBean> copyOnWriteArrayList = !CollectionUtils.isEmpty(examListBeanList) ? new CopyOnWriteArrayList(examListBeanList) : new CopyOnWriteArrayList();
|
|
|
+ copyOnWriteArrayList.add(new ExamListBean(examActivityId, StringUtils.join(roomCodeSet).replaceAll("\\[", "").replaceAll("\\]", "")));
|
|
|
redisUtil.set(SystemConstant.TODAY_EXAM_LIST_MAP_CACHE, examId, new LinkedList<>(copyOnWriteArrayList));
|
|
|
}
|
|
|
}
|
|
@@ -855,26 +836,20 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
|
|
|
*/
|
|
|
@Override
|
|
|
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);
|
|
|
- }
|
|
|
+ List<ExamListBean> examListBeanList = this.getTodayExamListCache(examId);
|
|
|
+ if (!CollectionUtils.isEmpty(examListBeanList)) {
|
|
|
+ CopyOnWriteArrayList<ExamListBean> copyOnWriteArrayList = new CopyOnWriteArrayList(examListBeanList);
|
|
|
+ for (ExamListBean e : copyOnWriteArrayList) {
|
|
|
+ if (e.getExamActivityId().longValue() == examActivityId.longValue()) {
|
|
|
+ copyOnWriteArrayList.remove(e);
|
|
|
+ break;
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(copyOnWriteArrayList)) {
|
|
|
+ redisUtil.set(SystemConstant.TODAY_EXAM_LIST_MAP_CACHE, examId, new LinkedList<>(copyOnWriteArrayList));
|
|
|
+ } else {
|
|
|
+ this.removeTodayExamListCache(examId);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|