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