From 2b2efb59a61a54b398f8f6c9263f37d41c18e65c Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 11 Jan 2024 14:56:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A4=9A=E4=B8=AA=E6=8E=A8?= =?UTF-8?q?=E6=B5=81=E6=8E=A8=E9=80=81=E5=88=B0=E4=B8=8A=E7=BA=A7=E6=98=AF?= =?UTF-8?q?=E4=B8=8D=E5=AE=8C=E6=95=B4=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B9=B3=E5=8F=B0=E6=B3=A8=E9=94=80=E6=97=B6?= =?UTF-8?q?=E4=B8=8D=E5=88=A0=E9=99=A4=E8=87=AA=E5=B7=B1=E6=A8=A1=E6=8B=9F?= =?UTF-8?q?=E7=9A=84=E8=AE=A2=E9=98=85=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subscribe/catalog/CatalogEventLister.java | 8 ++++---- .../transmit/cmd/impl/SIPCommanderFroPlatform.java | 7 ++++--- .../iot/vmp/service/impl/PlatformServiceImpl.java | 14 +++++++++++--- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java index 0448cd20..557563ee 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java @@ -148,13 +148,13 @@ public class CatalogEventLister implements ApplicationListener { if (event.getDeviceChannels() != null) { deviceChannelList.addAll(event.getDeviceChannels()); } - if (event.getGbStreams() != null && event.getGbStreams().size() > 0){ + if (event.getGbStreams() != null && !event.getGbStreams().isEmpty()){ for (GbStream gbStream : event.getGbStreams()) { deviceChannelList.add( gbStreamService.getDeviceChannelListByStreamWithStatus(gbStream, gbStream.getCatalogId(), parentPlatform)); } } - if (deviceChannelList.size() > 0) { + if (!deviceChannelList.isEmpty()) { logger.info("[Catalog事件: {}]平台:{},影响通道{}个", event.getType(), event.getPlatformId(), deviceChannelList.size()); try { sipCommanderFroPlatform.sendNotifyForCatalogAddOrUpdate(event.getType(), parentPlatform, deviceChannelList, subscribe, null); @@ -163,10 +163,10 @@ public class CatalogEventLister implements ApplicationListener { logger.error("[命令发送失败] 国标级联 Catalog通知: {}", e.getMessage()); } } - }else if (parentPlatformMap.keySet().size() > 0) { + }else if (!parentPlatformMap.keySet().isEmpty()) { for (String gbId : parentPlatformMap.keySet()) { List parentPlatforms = parentPlatformMap.get(gbId); - if (parentPlatforms != null && parentPlatforms.size() > 0) { + if (parentPlatforms != null && !parentPlatforms.isEmpty()) { for (ParentPlatform platform : parentPlatforms) { SubscribeInfo subscribeInfo = subscribeHolder.getCatalogSubscribe(platform.getServerGBId()); if (subscribeInfo == null) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java index ecbdccab..07fb78ca 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java @@ -557,7 +557,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { @Override public void sendNotifyForCatalogAddOrUpdate(String type, ParentPlatform parentPlatform, List deviceChannels, SubscribeInfo subscribeInfo, Integer index) throws InvalidArgumentException, ParseException, NoSuchFieldException, SipException, IllegalAccessException { - if (parentPlatform == null || deviceChannels == null || deviceChannels.size() == 0 || subscribeInfo == null) { + if (parentPlatform == null || deviceChannels == null || deviceChannels.isEmpty() || subscribeInfo == null) { return; } if (index == null) { @@ -575,6 +575,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { Integer finalIndex = index; String catalogXmlContent = getCatalogXmlContentForCatalogAddOrUpdate(parentPlatform, channels, deviceChannels.size(), type, subscribeInfo); + logger.info("[发送NOTIFY通知]类型: {},发送数量: {}", type, channels.size()); sendNotify(parentPlatform, catalogXmlContent, subscribeInfo, eventResult -> { logger.error("发送NOTIFY通知消息失败。错误:{} {}", eventResult.statusCode, eventResult.msg); }, (eventResult -> { @@ -610,9 +611,9 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { .append("Catalog\r\n") .append("" + (int) ((Math.random() * 9 + 1) * 100000) + "\r\n") .append("" + parentPlatform.getDeviceGBId() + "\r\n") - .append(""+ channels.size() +"\r\n") + .append(""+ sumNum +"\r\n") .append("\r\n"); - if (channels.size() > 0) { + if (!channels.isEmpty()) { for (DeviceChannel channel : channels) { if (parentPlatform.getServerGBId().equals(channel.getParentId())) { channel.setParentId(parentPlatform.getDeviceGBId()); diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java index ce044867..22b11abe 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java @@ -266,6 +266,7 @@ public class PlatformServiceImpl implements IPlatformService { } if (parentPlatform.isAutoPushChannel()) { if (subscribeHolder.getCatalogSubscribe(parentPlatform.getServerGBId()) == null) { + logger.info("[国标级联]:{}, 添加自动通道推送模拟订阅信息", parentPlatform.getServerGBId()); addSimulatedSubscribeInfo(parentPlatform); } }else { @@ -343,9 +344,16 @@ public class PlatformServiceImpl implements IPlatformService { // 清除心跳任务 dynamicTask.stop(keepaliveTaskKey); } - // 停止目录订阅回复 - logger.info("[平台离线] {}, 停止订阅回复", parentPlatform.getServerGBId()); - subscribeHolder.removeAllSubscribe(parentPlatform.getServerGBId()); + // 停止订阅回复 + SubscribeInfo catalogSubscribe = subscribeHolder.getCatalogSubscribe(parentPlatform.getServerGBId()); + if (catalogSubscribe != null) { + if (catalogSubscribe.getExpires() > 0) { + logger.info("[平台离线] {}, 停止目录订阅回复", parentPlatform.getServerGBId()); + subscribeHolder.removeCatalogSubscribe(parentPlatform.getServerGBId()); + } + } + logger.info("[平台离线] {}, 停止移动位置订阅回复", parentPlatform.getServerGBId()); + subscribeHolder.removeMobilePositionSubscribe(parentPlatform.getServerGBId()); // 发起定时自动重新注册 if (!stopRegister) { // 设置为60秒自动尝试重新注册