0310海宁预警优化
This commit is contained in:
@@ -30,6 +30,7 @@ import java.time.temporal.TemporalAdjusters;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
@@ -200,11 +201,22 @@ public class WorkRecordServiceImpl implements WorkRecordService {
|
||||
|
||||
/**
|
||||
* 获取预警类型及各类型预警数量
|
||||
* 每天首次查询存储到redis里
|
||||
* 每天首次查询存储到redis里,后面都从redis读取
|
||||
*/
|
||||
@Override
|
||||
public List<WarnInfoVO> getAlterTypes() {
|
||||
String headId = SecurityUtils.getHeadId();
|
||||
String redisKey = alterTypeRedisKey + headId;
|
||||
|
||||
// 先从 redis 获取缓存
|
||||
if (redisCache.hasKey(redisKey)) {
|
||||
List<WarnInfoVO> cachedList = redisCache.getCacheObject(redisKey);
|
||||
if (cachedList != null && !cachedList.isEmpty()) {
|
||||
log.debug("从 redis 获取预警类型缓存, headId: {}", headId);
|
||||
return cachedList;
|
||||
}
|
||||
}
|
||||
|
||||
String username = SecurityUtils.getUsername();
|
||||
|
||||
// 先查询预警类型列表
|
||||
@@ -220,6 +232,10 @@ 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());
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
|
||||
@@ -169,7 +169,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and alter_type = #{alterType}
|
||||
</if>
|
||||
</where>
|
||||
order by create_time desc, status asc
|
||||
order by status asc, create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectAlterTypesByHeadId" resultType="String">
|
||||
|
||||
@@ -284,7 +284,7 @@ export default {
|
||||
recordRead({ id: item.id }).then(res => {
|
||||
if (res.code === 200) {
|
||||
this.$toast("已读成功");
|
||||
this.queryList();
|
||||
this.onRefresh();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user