mirror of
https://gitee.com/pan648540858/wvp-GB28181-pro.git
synced 2026-06-10 21:57:50 +08:00
添加国标设备数据库状态检查功能,优化设备状态处理和移动位置订阅逻辑
This commit is contained in:
parent
2bdced8b9c
commit
7f2db96ac1
@ -219,4 +219,11 @@ public class UserSetting {
|
||||
*/
|
||||
private boolean useAliasForGroupSync = false;
|
||||
|
||||
/**
|
||||
* 对于识别为设备的国标设备的,是否默认开启位置订阅
|
||||
*/
|
||||
private boolean subscribeMobilePosition = false;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -150,6 +150,15 @@ public class DeviceServiceImpl implements IDeviceService, CommandLineRunner {
|
||||
|
||||
// 重置 cseq 计数
|
||||
redisCatchStorage.resetAllCSEQ();
|
||||
// 处理设备状态
|
||||
dbStatusCheck();
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据库状态检查, 每6小时检查一次
|
||||
*/
|
||||
@Scheduled(fixedDelay = 6, initialDelay = 6, timeUnit = TimeUnit.HOURS)
|
||||
public void dbStatusCheck(){
|
||||
// 处理设备状态
|
||||
Set<String> allDeviceIds = deviceStatusManager.getAll();
|
||||
if (!allDeviceIds.isEmpty()) {
|
||||
@ -210,6 +219,7 @@ public class DeviceServiceImpl implements IDeviceService, CommandLineRunner {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void offlineByIds(List<Device> offlineDevices) {
|
||||
@ -318,6 +328,14 @@ public class DeviceServiceImpl implements IDeviceService, CommandLineRunner {
|
||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||
log.error("[命令发送失败] 查询设备信息: {}", e.getMessage());
|
||||
}
|
||||
// 上线添加订阅
|
||||
if (userSetting.isSubscribeMobilePosition() && isDevice(device.getDeviceId())) {
|
||||
// 开启订阅
|
||||
device.setSubscribeCycleForMobilePosition(60);
|
||||
device.setMobilePositionSubmissionInterval(5);
|
||||
addMobilePositionSubscribe(device, null);
|
||||
}
|
||||
|
||||
sync(device);
|
||||
}else {
|
||||
device.setServerId(userSetting.getServerId());
|
||||
@ -346,6 +364,13 @@ public class DeviceServiceImpl implements IDeviceService, CommandLineRunner {
|
||||
}
|
||||
if (device.getSubscribeCycleForMobilePosition() > 0 && !subscribeTaskRunner.containsKey(SubscribeTaskForMobilPosition.getKey(device))) {
|
||||
addMobilePositionSubscribe(device, null);
|
||||
}else{
|
||||
if (userSetting.isSubscribeMobilePosition() && isDevice(device.getDeviceId())) {
|
||||
// 开启订阅
|
||||
device.setSubscribeCycleForMobilePosition(60);
|
||||
device.setMobilePositionSubmissionInterval(5);
|
||||
addMobilePositionSubscribe(device, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (userSetting.getDeviceStatusNotify()) {
|
||||
@ -361,6 +386,7 @@ public class DeviceServiceImpl implements IDeviceService, CommandLineRunner {
|
||||
sync(device);
|
||||
}
|
||||
}
|
||||
|
||||
// 设备状态任务添加
|
||||
long expiresTime = Math.min(device.getExpires(), device.getHeartBeatInterval() * device.getHeartBeatCount()) * 1000L;
|
||||
deviceStatusManager.add(device.getDeviceId(), expiresTime + System.currentTimeMillis());
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package com.genersoft.iot.vmp.gb28181.task.deviceStatus;
|
||||
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -13,7 +12,6 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.lang.Thread;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@ -56,7 +54,6 @@ public class DeviceStatusManager {
|
||||
// 发送 Spring 异步事件
|
||||
eventPublisher.deviceOfflineEventPublish(expiredIds);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -159,7 +159,7 @@ public class NotifyRequestForMobilePositionProcessor extends SIPRequestProcessor
|
||||
continue;
|
||||
}
|
||||
|
||||
log.info("[收到移动位置订阅通知]:{}/{}->{}.{}, 时间: {}", mobilePosition.getDeviceId(), mobilePosition.getChannelId(),
|
||||
log.info("[收到移动位置订阅通知]:{}/{}->{}.{}, 时间: {}", mobilePosition.getDeviceId(), mobilePosition.getChannelDeviceId(),
|
||||
mobilePosition.getLongitude(), mobilePosition.getLatitude(), System.currentTimeMillis() - startTime);
|
||||
mobilePosition.setReportSource("Mobile Position");
|
||||
|
||||
|
||||
@ -174,7 +174,7 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
|
||||
} else {
|
||||
catalogDataCatch.setChannelSyncEnd(deviceId, finalSn, null);
|
||||
}
|
||||
}).start();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -467,7 +467,7 @@ export default {
|
||||
})
|
||||
},
|
||||
getKeepaliveTimeStatistics: function(deviceId) {
|
||||
this.$refs.timeStatistics.openDialog('心跳时间统计', 'device/getKeepaliveTimeStatistics', deviceId, 10)
|
||||
this.$refs.timeStatistics.openDialog('心跳时间统计', 'device/getKeepaliveTimeStatistics', deviceId, 60)
|
||||
},
|
||||
getRegisterTimeStatistics: function(deviceId) {
|
||||
this.$refs.timeStatistics.openDialog('注册时间统计', 'device/getRegisterTimeStatistics', deviceId, 10)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user