From 7f2db96ac1d2c5cfbdae077806d17999bbd333c2 Mon Sep 17 00:00:00 2001 From: lin <648540858@qq.com> Date: Tue, 27 Jan 2026 17:04:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=9B=BD=E6=A0=87=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E6=95=B0=E6=8D=AE=E5=BA=93=E7=8A=B6=E6=80=81=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E5=8A=9F=E8=83=BD=EF=BC=8C=E4=BC=98=E5=8C=96=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E7=8A=B6=E6=80=81=E5=A4=84=E7=90=86=E5=92=8C=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E4=BD=8D=E7=BD=AE=E8=AE=A2=E9=98=85=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../genersoft/iot/vmp/conf/UserSetting.java | 7 +++++ .../service/impl/DeviceServiceImpl.java | 26 +++++++++++++++++++ .../deviceStatus/DeviceStatusManager.java | 3 --- ...tifyRequestForMobilePositionProcessor.java | 2 +- .../cmd/CatalogResponseMessageHandler.java | 2 +- web/src/views/device/list.vue | 2 +- 6 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java index 77beba74a..c4023cfc4 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java @@ -219,4 +219,11 @@ public class UserSetting { */ private boolean useAliasForGroupSync = false; + /** + * 对于识别为设备的国标设备的,是否默认开启位置订阅 + */ + private boolean subscribeMobilePosition = false; + + + } 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 c94d0ceb0..c703aec61 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 @@ -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 allDeviceIds = deviceStatusManager.getAll(); if (!allDeviceIds.isEmpty()) { @@ -210,6 +219,7 @@ public class DeviceServiceImpl implements IDeviceService, CommandLineRunner { } } } + } private void offlineByIds(List 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()); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/task/deviceStatus/DeviceStatusManager.java b/src/main/java/com/genersoft/iot/vmp/gb28181/task/deviceStatus/DeviceStatusManager.java index 291bcd534..7d74f14a0 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/task/deviceStatus/DeviceStatusManager.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/task/deviceStatus/DeviceStatusManager.java @@ -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); }); - } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForMobilePositionProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForMobilePositionProcessor.java index 24dc3e56f..d27434434 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForMobilePositionProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForMobilePositionProcessor.java @@ -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"); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java index 75ce45dfd..d616e7da2 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java @@ -174,7 +174,7 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp } else { catalogDataCatch.setChannelSyncEnd(deviceId, finalSn, null); } - }).start(); + }); } } } diff --git a/web/src/views/device/list.vue b/web/src/views/device/list.vue index ac27d53b1..9a890aaf1 100755 --- a/web/src/views/device/list.vue +++ b/web/src/views/device/list.vue @@ -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)