修复时间统计列表处理逻辑并增强心跳记录更新的异常处理

This commit is contained in:
lin 2026-03-30 14:28:52 +08:00
parent 2b090bbf23
commit 0dc297bf02
2 changed files with 10 additions and 4 deletions

View File

@ -1307,7 +1307,9 @@ public class DeviceServiceImpl implements IDeviceService, CommandLineRunner {
}
timeStatisticsList.add(timeStatistics);
}
if (timeStatisticsList.size() > count) {
// 第一个数据由于没有上一个时间戳无法计算时间差去掉
timeStatisticsList.removeFirst();
if (timeStatisticsList.size() - 1 > count) {
timeStatisticsList = timeStatisticsList.subList(timeStatisticsList.size() - count, timeStatisticsList.size());
}
return timeStatisticsList;

View File

@ -94,9 +94,13 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
}
@Scheduled(fixedDelay = 10, timeUnit = TimeUnit.SECONDS)
public void executeUpdateDeviceList() {
if (!taskQueue.isEmpty()) {
redisCatchStorage.updateDeviceKeepaliveTimeStamp(taskQueue.stream().toList());
taskQueue.clear();
try {
if (!taskQueue.isEmpty()) {
redisCatchStorage.updateDeviceKeepaliveTimeStamp(taskQueue.stream().toList());
taskQueue.clear();
}
} catch (Exception e) {
log.error("[定时任务] 更新心跳记录 执行异常", e);
}
}