Commit 2b2efb59a61a54b398f8f6c9263f37d41c18e65c

Authored by 648540858
1 parent 29f7a6b6

修复多个推流推送到上级是不完整的问题,修改平台注销时不删除自己模拟的订阅信息

src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java
@@ -148,13 +148,13 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> { @@ -148,13 +148,13 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
148 if (event.getDeviceChannels() != null) { 148 if (event.getDeviceChannels() != null) {
149 deviceChannelList.addAll(event.getDeviceChannels()); 149 deviceChannelList.addAll(event.getDeviceChannels());
150 } 150 }
151 - if (event.getGbStreams() != null && event.getGbStreams().size() > 0){ 151 + if (event.getGbStreams() != null && !event.getGbStreams().isEmpty()){
152 for (GbStream gbStream : event.getGbStreams()) { 152 for (GbStream gbStream : event.getGbStreams()) {
153 deviceChannelList.add( 153 deviceChannelList.add(
154 gbStreamService.getDeviceChannelListByStreamWithStatus(gbStream, gbStream.getCatalogId(), parentPlatform)); 154 gbStreamService.getDeviceChannelListByStreamWithStatus(gbStream, gbStream.getCatalogId(), parentPlatform));
155 } 155 }
156 } 156 }
157 - if (deviceChannelList.size() > 0) { 157 + if (!deviceChannelList.isEmpty()) {
158 logger.info("[Catalog事件: {}]平台:{},影响通道{}个", event.getType(), event.getPlatformId(), deviceChannelList.size()); 158 logger.info("[Catalog事件: {}]平台:{},影响通道{}个", event.getType(), event.getPlatformId(), deviceChannelList.size());
159 try { 159 try {
160 sipCommanderFroPlatform.sendNotifyForCatalogAddOrUpdate(event.getType(), parentPlatform, deviceChannelList, subscribe, null); 160 sipCommanderFroPlatform.sendNotifyForCatalogAddOrUpdate(event.getType(), parentPlatform, deviceChannelList, subscribe, null);
@@ -163,10 +163,10 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> { @@ -163,10 +163,10 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
163 logger.error("[命令发送失败] 国标级联 Catalog通知: {}", e.getMessage()); 163 logger.error("[命令发送失败] 国标级联 Catalog通知: {}", e.getMessage());
164 } 164 }
165 } 165 }
166 - }else if (parentPlatformMap.keySet().size() > 0) { 166 + }else if (!parentPlatformMap.keySet().isEmpty()) {
167 for (String gbId : parentPlatformMap.keySet()) { 167 for (String gbId : parentPlatformMap.keySet()) {
168 List<ParentPlatform> parentPlatforms = parentPlatformMap.get(gbId); 168 List<ParentPlatform> parentPlatforms = parentPlatformMap.get(gbId);
169 - if (parentPlatforms != null && parentPlatforms.size() > 0) { 169 + if (parentPlatforms != null && !parentPlatforms.isEmpty()) {
170 for (ParentPlatform platform : parentPlatforms) { 170 for (ParentPlatform platform : parentPlatforms) {
171 SubscribeInfo subscribeInfo = subscribeHolder.getCatalogSubscribe(platform.getServerGBId()); 171 SubscribeInfo subscribeInfo = subscribeHolder.getCatalogSubscribe(platform.getServerGBId());
172 if (subscribeInfo == null) { 172 if (subscribeInfo == null) {
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
@@ -557,7 +557,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { @@ -557,7 +557,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
557 557
558 @Override 558 @Override
559 public void sendNotifyForCatalogAddOrUpdate(String type, ParentPlatform parentPlatform, List<DeviceChannel> deviceChannels, SubscribeInfo subscribeInfo, Integer index) throws InvalidArgumentException, ParseException, NoSuchFieldException, SipException, IllegalAccessException { 559 public void sendNotifyForCatalogAddOrUpdate(String type, ParentPlatform parentPlatform, List<DeviceChannel> deviceChannels, SubscribeInfo subscribeInfo, Integer index) throws InvalidArgumentException, ParseException, NoSuchFieldException, SipException, IllegalAccessException {
560 - if (parentPlatform == null || deviceChannels == null || deviceChannels.size() == 0 || subscribeInfo == null) { 560 + if (parentPlatform == null || deviceChannels == null || deviceChannels.isEmpty() || subscribeInfo == null) {
561 return; 561 return;
562 } 562 }
563 if (index == null) { 563 if (index == null) {
@@ -575,6 +575,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { @@ -575,6 +575,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
575 Integer finalIndex = index; 575 Integer finalIndex = index;
576 String catalogXmlContent = getCatalogXmlContentForCatalogAddOrUpdate(parentPlatform, channels, 576 String catalogXmlContent = getCatalogXmlContentForCatalogAddOrUpdate(parentPlatform, channels,
577 deviceChannels.size(), type, subscribeInfo); 577 deviceChannels.size(), type, subscribeInfo);
  578 + logger.info("[发送NOTIFY通知]类型: {},发送数量: {}", type, channels.size());
578 sendNotify(parentPlatform, catalogXmlContent, subscribeInfo, eventResult -> { 579 sendNotify(parentPlatform, catalogXmlContent, subscribeInfo, eventResult -> {
579 logger.error("发送NOTIFY通知消息失败。错误:{} {}", eventResult.statusCode, eventResult.msg); 580 logger.error("发送NOTIFY通知消息失败。错误:{} {}", eventResult.statusCode, eventResult.msg);
580 }, (eventResult -> { 581 }, (eventResult -> {
@@ -610,9 +611,9 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { @@ -610,9 +611,9 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
610 .append("<CmdType>Catalog</CmdType>\r\n") 611 .append("<CmdType>Catalog</CmdType>\r\n")
611 .append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n") 612 .append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n")
612 .append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n") 613 .append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n")
613 - .append("<SumNum>"+ channels.size() +"</SumNum>\r\n") 614 + .append("<SumNum>"+ sumNum +"</SumNum>\r\n")
614 .append("<DeviceList Num=\"" + channels.size() + "\">\r\n"); 615 .append("<DeviceList Num=\"" + channels.size() + "\">\r\n");
615 - if (channels.size() > 0) { 616 + if (!channels.isEmpty()) {
616 for (DeviceChannel channel : channels) { 617 for (DeviceChannel channel : channels) {
617 if (parentPlatform.getServerGBId().equals(channel.getParentId())) { 618 if (parentPlatform.getServerGBId().equals(channel.getParentId())) {
618 channel.setParentId(parentPlatform.getDeviceGBId()); 619 channel.setParentId(parentPlatform.getDeviceGBId());
src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java
@@ -266,6 +266,7 @@ public class PlatformServiceImpl implements IPlatformService { @@ -266,6 +266,7 @@ public class PlatformServiceImpl implements IPlatformService {
266 } 266 }
267 if (parentPlatform.isAutoPushChannel()) { 267 if (parentPlatform.isAutoPushChannel()) {
268 if (subscribeHolder.getCatalogSubscribe(parentPlatform.getServerGBId()) == null) { 268 if (subscribeHolder.getCatalogSubscribe(parentPlatform.getServerGBId()) == null) {
  269 + logger.info("[国标级联]:{}, 添加自动通道推送模拟订阅信息", parentPlatform.getServerGBId());
269 addSimulatedSubscribeInfo(parentPlatform); 270 addSimulatedSubscribeInfo(parentPlatform);
270 } 271 }
271 }else { 272 }else {
@@ -343,9 +344,16 @@ public class PlatformServiceImpl implements IPlatformService { @@ -343,9 +344,16 @@ public class PlatformServiceImpl implements IPlatformService {
343 // 清除心跳任务 344 // 清除心跳任务
344 dynamicTask.stop(keepaliveTaskKey); 345 dynamicTask.stop(keepaliveTaskKey);
345 } 346 }
346 - // 停止目录订阅回复  
347 - logger.info("[平台离线] {}, 停止订阅回复", parentPlatform.getServerGBId());  
348 - subscribeHolder.removeAllSubscribe(parentPlatform.getServerGBId()); 347 + // 停止订阅回复
  348 + SubscribeInfo catalogSubscribe = subscribeHolder.getCatalogSubscribe(parentPlatform.getServerGBId());
  349 + if (catalogSubscribe != null) {
  350 + if (catalogSubscribe.getExpires() > 0) {
  351 + logger.info("[平台离线] {}, 停止目录订阅回复", parentPlatform.getServerGBId());
  352 + subscribeHolder.removeCatalogSubscribe(parentPlatform.getServerGBId());
  353 + }
  354 + }
  355 + logger.info("[平台离线] {}, 停止移动位置订阅回复", parentPlatform.getServerGBId());
  356 + subscribeHolder.removeMobilePositionSubscribe(parentPlatform.getServerGBId());
349 // 发起定时自动重新注册 357 // 发起定时自动重新注册
350 if (!stopRegister) { 358 if (!stopRegister) {
351 // 设置为60秒自动尝试重新注册 359 // 设置为60秒自动尝试重新注册