0311海宁预警优化
This commit is contained in:
@@ -206,19 +206,18 @@ public class WorkRecordServiceImpl implements WorkRecordService {
|
||||
@Override
|
||||
public List<WarnInfoVO> getAlterTypes() {
|
||||
String headId = SecurityUtils.getHeadId();
|
||||
String redisKey = alterTypeRedisKey + headId;
|
||||
String username = SecurityUtils.getUsername();
|
||||
String redisKey = alterTypeRedisKey + username;
|
||||
|
||||
// 先从 redis 获取缓存
|
||||
if (redisCache.hasKey(redisKey)) {
|
||||
List<WarnInfoVO> cachedList = redisCache.getCacheObject(redisKey);
|
||||
if (cachedList != null && !cachedList.isEmpty()) {
|
||||
log.debug("从 redis 获取预警类型缓存, headId: {}", headId);
|
||||
log.debug("从 redis 获取预警类型缓存, username: {}", username);
|
||||
return cachedList;
|
||||
}
|
||||
}
|
||||
|
||||
String username = SecurityUtils.getUsername();
|
||||
|
||||
// 先查询预警类型列表
|
||||
List<String> alterTypes = workRecordMapper.selectAlterTypesByHeadId(headId);
|
||||
|
||||
@@ -232,9 +231,9 @@ public class WorkRecordServiceImpl implements WorkRecordService {
|
||||
return warnInfoVO;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
// 存入 redis,过期时间 1 天
|
||||
redisCache.setCacheObject(redisKey, resultList, 86400, TimeUnit.SECONDS);
|
||||
log.debug("预警类型数据已存入 redis, headId: {}, 数量: {}", headId, resultList.size());
|
||||
// 存入 redis,过期时间到当天结束
|
||||
redisCache.setCacheObjectToEndDay(redisKey, resultList);
|
||||
log.debug("预警类型数据已存入 redis, username: {}, 数量: {}", username, resultList.size());
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user