diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java index c9d3969b6..0bc2c8348 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java @@ -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; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java index ec4cabc65..97e7a4ccf 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java @@ -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); } }