匹配新的rediskey前缀

This commit is contained in:
2026-08-14 16:54:32 +08:00
parent 1fe185109b
commit 936dec7beb
6 changed files with 21 additions and 23 deletions
@@ -177,7 +177,7 @@ public class LogBusServiceImpl implements LogBusService {
// 前一天时间
Instant yesterday = CalendarUtils.yesterday();
// 获取前一天的统计数据
Map<Integer, Long> totalMap = getTotalByDay(yesterday);
Map<Integer, Long> totalMap = getTotalByDay(yesterday, true);
if (CollectionUtils.isEmpty(totalMap)) {
return "执行完成,前一天日志统计数据为空";
}
@@ -204,11 +204,12 @@ public class LogBusServiceImpl implements LogBusService {
/**
* 获取指定日期的日志统计数据
*
* @param time 时间
* @param time 时间
* @param deleteKey 删除缓存
* @return 统计数据
*/
@Override
public Map<Integer, Long> getTotalByDay(Instant time) {
public Map<Integer, Long> getTotalByDay(Instant time, boolean deleteKey) {
Map<Integer, Long> result = new HashMap<>(CP_NUM16);
if (Objects.isNull(time)) {
return result;
@@ -221,6 +222,9 @@ public class LogBusServiceImpl implements LogBusService {
// 获取数量
Long count = redisService.get(key, Long.class);
result.put(level.code(), Objects.nonNull(count) ? count : 0L);
if (deleteKey) {
redisService.del(key);
}
}
return result;
}
@@ -45,7 +45,7 @@ public class SysLogTotalServiceImpl implements SysLogTotalService {
/**
* 获取统计信息
* <p>小于今天的数据从数据库获取;包含今天的数据从Redis获取(今天尚未落库)</p>
* 小于今天的数据从数据库获取;包含今天的数据从Redis获取(今天尚未落库)
*
* @param req 统计请求(时间范围)
* @return 统计信息
@@ -71,7 +71,7 @@ public class SysLogTotalServiceImpl implements SysLogTotalService {
long now = System.currentTimeMillis();
if (now >= startTime.toEpochMilli() && now <= endTime.toEpochMilli()) {
Instant day = LocalDate.now().atStartOfDay(ZoneId.systemDefault()).toInstant();
Map<Integer, Long> totalMap = logBusService.getTotalByDay(day);
Map<Integer, Long> totalMap = logBusService.getTotalByDay(day, false);
Long defCount = 0L;
// 今天的数据追加到末尾
list.add(SysLogTotalStatsResp.builder()