From 0ac27b03ffd13370e2beec83ce7cb394091ae889 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 12 Jun 2024 11:10:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AE=BE=E5=A4=87=E4=B8=8A?= =?UTF-8?q?=E7=BA=BF=E5=88=A4=E6=96=AD=E5=8F=8C=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E5=A4=A7=E5=8D=8E=E6=B3=A8=E5=86=8C=E5=90=8E?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E5=8F=91=E9=80=81=E6=B3=A8=E5=86=8C=E7=9A=84?= =?UTF-8?q?=E8=AE=BE=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/genersoft/iot/vmp/conf/UserSetting.java | 10 ++++++++++ .../notify/cmd/KeepaliveNotifyMessageHandler.java | 12 ++++++++---- src/main/resources/all-application.yml | 4 ++++ 3 files changed, 22 insertions(+), 4 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 96253d6e..cce91459 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java @@ -74,6 +74,8 @@ public class UserSetting { private boolean registerKeepIntDialog = false; + private int gbDeviceOnline = 0; + public Boolean getSavePositionHistory() { return savePositionHistory; } @@ -325,4 +327,12 @@ public class UserSetting { public void setDocEnable(Boolean docEnable) { this.docEnable = docEnable; } + + public int getGbDeviceOnline() { + return gbDeviceOnline; + } + + public void setGbDeviceOnline(int gbDeviceOnline) { + this.gbDeviceOnline = gbDeviceOnline; + } } 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 034e24f9..bfc42f5a 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 @@ -62,7 +62,10 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp } SIPRequest request = (SIPRequest) evt.getRequest(); logger.info("[收到心跳] device: {}, callId: {}", device.getDeviceId(), request.getCallIdHeader().getCallId()); - + if (userSetting.getGbDeviceOnline() == 0 && !device.isOnLine()) { + logger.warn("[收到心跳] 设备离线,心跳不进行回复, device: {}, callId: {}", device.getDeviceId(), request.getCallIdHeader().getCallId()); + return; + } // 回复200 OK try { responseAck(request, Response.OK); @@ -101,9 +104,10 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp if (device.isOnLine()) { deviceService.updateDevice(device); }else { - // 对于已经离线的设备判断他的注册是否已经过期 - if (!deviceService.expire(device)){ - device.setOnLine(false); + if (userSetting.getGbDeviceOnline() == 1) { + // 对于已经离线的设备判断他的注册是否已经过期 + device.setOnLine(true); + device.setRegisterTime(DateUtil.getNow()); deviceService.online(device, null); } } diff --git a/src/main/resources/all-application.yml b/src/main/resources/all-application.yml index f2fd504a..ef5b244c 100644 --- a/src/main/resources/all-application.yml +++ b/src/main/resources/all-application.yml @@ -247,6 +247,10 @@ user-settings: allowed-origins: - http://localhost:8008 - http://192.168.1.3:8008 + # 国标设备离线后的上线策略, + # 0: 国标标准实现,设备离线后不回复心跳,知道设备重新注册上线, + # 1: 对于离线设备,收到心跳就把设备设置为上线,并更新注册时间为上次这次心跳的时间。防止过期时间判断u异常 + gb-device-online: 0 # 关闭在线文档(生产环境建议关闭) springdoc: