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