|
@@ -608,24 +608,25 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 设置当天考试缓存
|
|
|
+ * 设置当前考试缓存
|
|
|
*/
|
|
|
@Override
|
|
|
- public void setTodayExamListCache() {
|
|
|
+ public void setCurrentExamListCache() {
|
|
|
try {
|
|
|
Date now = new Date();
|
|
|
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- String today = sdf1.format(now);
|
|
|
+ String current = sdf1.format(now);
|
|
|
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- Long startTime = sdf2.parse(today + " 00:00:00").getTime();
|
|
|
- Long endTime = sdf2.parse(today + " 23:59:59").getTime();
|
|
|
+ Long startTime = sdf2.parse(current + " 00:00:00").getTime();
|
|
|
+ Long endTime = sdf2.parse(current + " 23:59:59").getTime();
|
|
|
+ //todo 联合teexam表查一次(enable为true),暂定1小时刷新一次,取缓存时不判断enable状态,不做删除缓存操作
|
|
|
List<TEExamActivity> teExamActivityList = teExamActivityService.list(new QueryWrapper<TEExamActivity>().lambda()
|
|
|
.and(w -> w.ge(TEExamActivity::getStartTime, startTime).le(TEExamActivity::getStartTime, endTime))
|
|
|
.or(w -> w.le(TEExamActivity::getStartTime, startTime).ge(TEExamActivity::getFinishTime, endTime))
|
|
|
.eq(TEExamActivity::getEnable, 1));
|
|
|
//统计当天00:00:00~23:59:59可以进行的考试批次、场次、考场编码信息
|
|
|
if (!CollectionUtils.isEmpty(teExamActivityList)) {
|
|
|
- LinkedMultiValueMap<Long, ExamListBean> todayExamListMap = new LinkedMultiValueMap<>();//考试批次、场次集合/考场编码集合
|
|
|
+ LinkedMultiValueMap<Long, ExamListBean> currentExamListMap = new LinkedMultiValueMap<>();//考试批次、场次集合/考场编码集合
|
|
|
Map<Long, Set<Long>> examActivityIdMap = new HashMap<>();//考试批次id,场次id集合
|
|
|
Map<Long, Set<String>> roomCodeMap = new HashMap<>();//考试场次id,考场编码集合
|
|
|
for (TEExamActivity t : teExamActivityList) {
|
|
@@ -648,11 +649,11 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
|
|
|
examActivityIdMap.forEach((k, v) -> {
|
|
|
for (Long l : v) {
|
|
|
String s = StringUtils.join(roomCodeMap.get(l)).replaceAll("\\[", "").replaceAll("\\]", "");
|
|
|
- todayExamListMap.add(k, new ExamListBean(l, s));
|
|
|
+ currentExamListMap.add(k, new ExamListBean(l, s));
|
|
|
}
|
|
|
});
|
|
|
- todayExamListMap.forEach((k, v) -> {
|
|
|
- redisUtil.set(SystemConstant.TODAY_EXAM_LIST_MAP_CACHE, k.toString(), v);
|
|
|
+ currentExamListMap.forEach((k, v) -> {
|
|
|
+ redisUtil.set(SystemConstant.CURRENT_EXAM_LIST_MAP_CACHE, k.toString(), v);
|
|
|
});
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
@@ -661,13 +662,13 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 获取当天考试列表缓存
|
|
|
+ * 获取当前考试列表缓存
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public Map<String, List<ExamListBean>> getTodayExamListCache() {
|
|
|
- return redisUtil.getHashEntries(SystemConstant.TODAY_EXAM_LIST_MAP_CACHE);
|
|
|
+ public Map<String, List<ExamListBean>> getCurrentExamListCache() {
|
|
|
+ return redisUtil.getHashEntries(SystemConstant.CURRENT_EXAM_LIST_MAP_CACHE);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -676,6 +677,7 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
|
|
|
@Override
|
|
|
public void setOrgExamListCache() {
|
|
|
//查询考试场次结束时间大于当前时间的所有考试
|
|
|
+ //todo 和产品确认待考天数大于N天显示(和上个版本一致),或者重列待考天数逻辑,联合teexam表查一次
|
|
|
List<TEExamActivity> teExamActivityList = teExamActivityService.list(new QueryWrapper<TEExamActivity>().lambda().gt(TEExamActivity::getFinishTime, System.currentTimeMillis()).eq(TEExamActivity::getEnable, 1));
|
|
|
if (!CollectionUtils.isEmpty(teExamActivityList)) {
|
|
|
Map<Long, Set<Long>> orgMap = new HashMap<>();//机构id,考试批次id集合
|
|
@@ -799,33 +801,33 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 获取当天考试列表缓存
|
|
|
+ * 获取当前考试列表缓存
|
|
|
*
|
|
|
* @param examId
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<ExamListBean> getTodayExamListCache(String examId) {
|
|
|
- Map<String, List<ExamListBean>> map = this.getTodayExamListCache();
|
|
|
+ public List<ExamListBean> getCurrentExamListCache(String examId) {
|
|
|
+ Map<String, List<ExamListBean>> map = this.getCurrentExamListCache();
|
|
|
return !CollectionUtils.isEmpty(map) ? map.get(examId) : null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 更新当天考试缓存
|
|
|
+ * 更新当前考试缓存
|
|
|
*
|
|
|
* @param examId
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public void updateTodayExamListCache(String examId, Long examActivityId) {
|
|
|
+ public void updateCurrentExamListCache(String examId, Long examActivityId) {
|
|
|
List<TEExamStudent> teExamStudentList = teExamStudentService.list(new QueryWrapper<TEExamStudent>().lambda().eq(TEExamStudent::getExamId, Long.parseLong(examId)).eq(TEExamStudent::getExamActivityId, examActivityId));
|
|
|
if (!CollectionUtils.isEmpty(teExamStudentList)) {
|
|
|
Set<String> roomCodeSet = teExamStudentList.stream().map(s -> s.getRoomCode()).collect(Collectors.toSet());
|
|
|
- this.removeTodayExamListCache(examId, examActivityId);
|
|
|
- List<ExamListBean> examListBeanList = this.getTodayExamListCache(examId);
|
|
|
+ this.removeCurrentExamListCache(examId, examActivityId);
|
|
|
+ List<ExamListBean> examListBeanList = this.getCurrentExamListCache(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));
|
|
|
+ redisUtil.set(SystemConstant.CURRENT_EXAM_LIST_MAP_CACHE, examId, new LinkedList<>(copyOnWriteArrayList));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -835,8 +837,8 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
|
|
|
* @param examId
|
|
|
*/
|
|
|
@Override
|
|
|
- public void removeTodayExamListCache(String examId) {
|
|
|
- redisUtil.delete(SystemConstant.TODAY_EXAM_LIST_MAP_CACHE, examId);
|
|
|
+ public void removeCurrentExamListCache(String examId) {
|
|
|
+ redisUtil.delete(SystemConstant.CURRENT_EXAM_LIST_MAP_CACHE, examId);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -846,8 +848,8 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
|
|
|
* @param examActivityId
|
|
|
*/
|
|
|
@Override
|
|
|
- public void removeTodayExamListCache(String examId, Long examActivityId) {
|
|
|
- List<ExamListBean> examListBeanList = this.getTodayExamListCache(examId);
|
|
|
+ public void removeCurrentExamListCache(String examId, Long examActivityId) {
|
|
|
+ List<ExamListBean> examListBeanList = this.getCurrentExamListCache(examId);
|
|
|
if (!CollectionUtils.isEmpty(examListBeanList)) {
|
|
|
CopyOnWriteArrayList<ExamListBean> copyOnWriteArrayList = new CopyOnWriteArrayList(examListBeanList);
|
|
|
for (ExamListBean e : copyOnWriteArrayList) {
|
|
@@ -857,9 +859,9 @@ public class ThemisCacheServiceImpl implements ThemisCacheService {
|
|
|
}
|
|
|
}
|
|
|
if (!CollectionUtils.isEmpty(copyOnWriteArrayList)) {
|
|
|
- redisUtil.set(SystemConstant.TODAY_EXAM_LIST_MAP_CACHE, examId, new LinkedList<>(copyOnWriteArrayList));
|
|
|
+ redisUtil.set(SystemConstant.CURRENT_EXAM_LIST_MAP_CACHE, examId, new LinkedList<>(copyOnWriteArrayList));
|
|
|
} else {
|
|
|
- this.removeTodayExamListCache(examId);
|
|
|
+ this.removeCurrentExamListCache(examId);
|
|
|
}
|
|
|
}
|
|
|
}
|