Compare commits

...

3 Commits

Author SHA1 Message Date
lin
2bdced8b9c 为心跳历史和注册历史设置过期时间 2026-01-27 14:21:41 +08:00
lin
27b06a84d7 优化心跳和注册时间记录的取值和展示 2026-01-27 12:31:57 +08:00
lin
4067dcf8d1 修复心跳历史记录不全的BUG 2026-01-27 11:16:04 +08:00
3 changed files with 19 additions and 7 deletions

View File

@ -80,8 +80,8 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
device.setLocalIp(request.getLocalAddress().getHostAddress());
}
device.setKeepaliveTimeStamp(System.currentTimeMillis());
taskQueue.add(device);
if (device.isOnLine()) {
taskQueue.add(device);
long expiresTime = Math.min(device.getExpires(), device.getHeartBeatInterval() * device.getHeartBeatCount()) * 1000L;
deviceStatusManager.add(device.getDeviceId(), expiresTime + System.currentTimeMillis());
} else {

View File

@ -561,9 +561,14 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
public Boolean execute(@NonNull RedisOperations operations) {
// 1. 批量添加心跳数据到列表尾部
for (Device device : deviceList) {
operations.opsForList().rightPush(VideoManagerConstants.DEVICE_KEEPALIVE_PREFIX + device.getDeviceId(), device.getKeepaliveTimeStamp());
Duration duration = Duration.ofHours(1);
String key = VideoManagerConstants.DEVICE_KEEPALIVE_PREFIX + device.getDeviceId();
operations.opsForList().rightPush(key, device.getKeepaliveTimeStamp());
// 2. 截取列表只保留最新 100
operations.opsForList().trim((VideoManagerConstants.DEVICE_KEEPALIVE_PREFIX + device.getDeviceId()), -1000, -1);
operations.opsForList().trim(key, -100, -1);
// 为整个列表 Key 设置过期时间核心覆盖式设置每次更新心跳都重置过期时间
operations.expire(key, duration);
}
return true;
}
@ -580,7 +585,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
if (count == null) {
count = 20;
}
return longRedisTemplate.opsForList().range(VideoManagerConstants.DEVICE_KEEPALIVE_PREFIX + deviceId, 0, count + 1);
return longRedisTemplate.opsForList().range(VideoManagerConstants.DEVICE_KEEPALIVE_PREFIX + deviceId, -count - 1, -1);
}
@ -597,9 +602,15 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
public Boolean execute(@NonNull RedisOperations operations) {
// 1. 批量添加心跳数据到列表尾部
for (Device device : deviceList) {
operations.opsForList().rightPush(VideoManagerConstants.DEVICE_REGISTER_PREFIX + device.getDeviceId(), device.getRegisterTimeStamp());
Duration duration = Duration.ofHours(3);
String key = VideoManagerConstants.DEVICE_REGISTER_PREFIX + device.getDeviceId();
operations.opsForList().rightPush(key, device.getRegisterTimeStamp());
// 2. 截取列表只保留最新 100
operations.opsForList().trim((VideoManagerConstants.DEVICE_REGISTER_PREFIX + device.getDeviceId()), -1000, -1);
operations.opsForList().trim(key, -100, -1);
// 为整个列表 Key 设置过期时间核心覆盖式设置每次更新心跳都重置过期时间
operations.expire(key, duration);
}
return true;
}
@ -615,6 +626,6 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
if (count == null) {
count = 20;
}
return longRedisTemplate.opsForList().range(VideoManagerConstants.DEVICE_REGISTER_PREFIX + deviceId, 0, count + 1);
return longRedisTemplate.opsForList().range(VideoManagerConstants.DEVICE_REGISTER_PREFIX + deviceId, -count - 1, -1);
}
}

View File

@ -30,6 +30,7 @@
v-if="viewMode === 'table'"
:data="list"
border
stripe
size="mini"
height="400px"
style="width: 100%;"