From d7c1023e9d387710c4505a1732260b8c017e7643 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Sun, 20 Oct 2024 08:13:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=A1=8C=E6=94=BF=E5=8C=BA?= =?UTF-8?q?=E5=88=92=E6=9C=AA=E6=8F=92=E5=85=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/IPlatformChannelService.java | 2 ++ .../service/impl/GbChannelServiceImpl.java | 1 + .../impl/PlatformChannelServiceImpl.java | 31 +++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlatformChannelService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlatformChannelService.java index c862b665..f6a584df 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlatformChannelService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlatformChannelService.java @@ -45,4 +45,6 @@ public interface IPlatformChannelService { List queryPlatFormListByChannelDeviceId(Integer channelId, List platforms); CommonGBChannel queryChannelByPlatformIdAndChannelId(Integer platformId, Integer channelId); + + void checkRegionAdd(List channelList); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java index 62be902b..a7ff3c7a 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java @@ -414,6 +414,7 @@ public class GbChannelServiceImpl implements IGbChannelService { int result = commonGBChannelMapper.updateRegion(civilCode, channelList); // 发送通知 if (result > 0) { + platformChannelService.checkRegionAdd(channelList); try { // 发送catalog eventPublisher.catalogEventPublish(null, channelList, CatalogEvent.UPDATE); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java index 54b43ae6..b90f67af 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java @@ -7,6 +7,7 @@ import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; import com.genersoft.iot.vmp.gb28181.service.IPlatformChannelService; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; +import com.genersoft.iot.vmp.jt1078.proc.request.Re; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; @@ -505,6 +506,36 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService { } } + @Override + public void checkRegionAdd(List channelList) { + List channelIds = new ArrayList<>(); + channelList.stream().forEach(commonGBChannel -> { + channelIds.add(commonGBChannel.getGbId()); + }); + List platformList = platformChannelMapper.queryPlatFormListByChannelList(channelIds); + if (platformList.isEmpty()) { + return; + } + for (Platform platform : platformList) { + + Set addRegion = getRegionNotShareByChannelList(channelList, platform.getId()); + List channelListForEvent = new ArrayList<>(); + if (!addRegion.isEmpty()) { + for (Region region : addRegion) { + channelListForEvent.add(0, CommonGBChannel.build(region)); + } + platformChannelMapper.addPlatformRegion(new ArrayList<>(addRegion), platform.getId()); + // 发送消息 + try { + // 发送catalog + eventPublisher.catalogEventPublish(platform.getId(), channelListForEvent, CatalogEvent.ADD); + } catch (Exception e) { + log.warn("[移除关联通道] 发送失败,数量:{}", channelList.size(), e); + } + } + } + } + @Override public List queryPlatFormListByChannelDeviceId(Integer channelId, List platforms) { return platformChannelMapper.queryPlatFormListForGBWithGBId(channelId, platforms);