|
@@ -1,7 +1,9 @@
|
|
|
package com.qmth.exam.reserve.cache.impl;
|
|
|
|
|
|
+import com.qmth.exam.reserve.bean.applytask.CurrentApplyTaskVO;
|
|
|
import com.qmth.exam.reserve.cache.CacheConstants;
|
|
|
import com.qmth.exam.reserve.cache.RedisClient;
|
|
|
+import com.qmth.exam.reserve.service.ApplyTaskService;
|
|
|
import com.qmth.exam.reserve.service.ExamSiteService;
|
|
|
import com.qmth.exam.reserve.service.StudentApplyService;
|
|
|
import com.qmth.exam.reserve.service.StudentService;
|
|
@@ -21,6 +23,9 @@ public class ApplyTaskCacheService implements CacheConstants {
|
|
|
@Autowired
|
|
|
private RedisClient redisClient;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ApplyTaskService applyTaskService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ExamSiteService examSiteService;
|
|
|
|
|
@@ -30,6 +35,27 @@ public class ApplyTaskCacheService implements CacheConstants {
|
|
|
@Autowired
|
|
|
private StudentApplyService studentApplyService;
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取当前启用的预约任务缓存
|
|
|
+ */
|
|
|
+ public CurrentApplyTaskVO currentApplyTask(Long orgId) {
|
|
|
+ String cacheKey = String.format(CACHE_CURRENT_APPLY_TASK, orgId);
|
|
|
+ CurrentApplyTaskVO value = redisClient.get(cacheKey, CurrentApplyTaskVO.class);
|
|
|
+ if (value != null) {
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+
|
|
|
+ value = applyTaskService.currentApplyTask(orgId);
|
|
|
+ if (value == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ redisClient.set(cacheKey, value, 3, TimeUnit.HOURS);
|
|
|
+ log.info("{} = id:{} name:{}", cacheKey, value.getTaskId(), value.getTaskName());
|
|
|
+
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取某考生的“允许预约时段次数”
|
|
|
*/
|
|
@@ -48,16 +74,15 @@ public class ApplyTaskCacheService implements CacheConstants {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 获取某考点某时段的“可预约总量”
|
|
|
+ * 获取某考点的“可预约总量”
|
|
|
*/
|
|
|
- public int getApplyTotalCount(Long examSiteId, Long timePeriodId) {
|
|
|
- String cacheKey = String.format(CACHE_APPLY_TOTAL, examSiteId, timePeriodId);
|
|
|
+ public int getApplyTotalCount(Long examSiteId) {
|
|
|
+ String cacheKey = String.format(CACHE_APPLY_TOTAL, examSiteId);
|
|
|
Integer value = redisClient.get(cacheKey, Integer.class);
|
|
|
if (value != null) {
|
|
|
return value;
|
|
|
}
|
|
|
|
|
|
- // 当前考点当前时段容量 = 当前考点总容量
|
|
|
value = examSiteService.countExamSiteCapacityById(examSiteId);
|
|
|
redisClient.set(cacheKey, value, 3, TimeUnit.HOURS);
|
|
|
log.info("{} = {}", cacheKey, value);
|