From 7d669f74ecd401bef48ca2782d186100a0e5ab74 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Sun, 20 Oct 2024 14:55:00 +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=E7=A7=BB=E9=99=A4=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gb28181/dao/PlatformChannelMapper.java | 8 ++++ .../service/IPlatformChannelService.java | 7 ++-- .../service/impl/GbChannelServiceImpl.java | 11 +++++ .../impl/PlatformChannelServiceImpl.java | 42 +++++++++++++++++-- 4 files changed, 60 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformChannelMapper.java index 3311a249..d23eec4b 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformChannelMapper.java @@ -540,4 +540,12 @@ public interface PlatformChannelMapper { " ") Set queryShareGroup(@Param("platformId") Integer platformId); + @Select(" ") + Set queryShareRegion(Integer id); } 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 f6a584df..e03e0907 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 @@ -1,9 +1,6 @@ package com.genersoft.iot.vmp.gb28181.service; -import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; -import com.genersoft.iot.vmp.gb28181.bean.Group; -import com.genersoft.iot.vmp.gb28181.bean.Platform; -import com.genersoft.iot.vmp.gb28181.bean.PlatformChannel; +import com.genersoft.iot.vmp.gb28181.bean.*; import com.github.pagehelper.PageInfo; import java.util.List; @@ -47,4 +44,6 @@ public interface IPlatformChannelService { CommonGBChannel queryChannelByPlatformIdAndChannelId(Integer platformId, Integer channelId); void checkRegionAdd(List channelList); + + void checkRegionRemove(List channelList, List regionList); } 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 a7ff3c7a..0abf38ac 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 @@ -442,6 +442,14 @@ public class GbChannelServiceImpl implements IGbChannelService { throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在"); } int result = commonGBChannelMapper.removeCivilCodeByChannels(channelList); + Region region = regionMapper.queryByDeviceId(civilCode); + if (region == null) { + platformChannelService.checkRegionRemove(channelList, null); + }else { + List regionList = new ArrayList<>(); + regionList.add(region); + platformChannelService.checkRegionRemove(channelList, regionList); + } // TODO 发送通知 // if (result > 0) { // try { @@ -460,6 +468,8 @@ public class GbChannelServiceImpl implements IGbChannelService { throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在"); } int result = commonGBChannelMapper.removeCivilCodeByChannels(channelList); + + platformChannelService.checkRegionRemove(channelList, null); // TODO 发送通知 // if (result > 0) { // try { @@ -499,6 +509,7 @@ public class GbChannelServiceImpl implements IGbChannelService { throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在"); } int result = commonGBChannelMapper.removeCivilCodeByChannels(channelList); + platformChannelService.checkRegionRemove(channelList, null); } @Override 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 b90f67af..71ca0988 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 @@ -52,8 +52,6 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService { private ISIPCommanderForPlatform sipCommanderFroPlatform; - - @Override public PageInfo queryChannelList(int page, int count, String query, Integer channelType, Boolean online, Integer platformId, Boolean hasShare) { PageHelper.startPage(page, count); @@ -94,8 +92,6 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService { return regionMapper.queryNotShareRegionForPlatformByRegionList(allRegion, platformId); } - - /** * 移除空的共享,并返回移除的分组 */ @@ -474,6 +470,44 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService { } } + @Override + @Transactional + public void checkRegionRemove(List channelList, List regionList) { + 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 regionSet; + if (regionList == null || regionList.isEmpty()) { + regionSet = platformChannelMapper.queryShareRegion(platform.getId()); + }else { + regionSet = new HashSet<>(regionList); + } + // 清理空的分组并发送消息 + Set deleteRegion = deleteEmptyRegion(regionSet, platform.getId()); + + List channelListForEvent = new ArrayList<>(); + if (!deleteRegion.isEmpty()) { + for (Region region : deleteRegion) { + channelListForEvent.add(0, CommonGBChannel.build(region)); + } + } + // 发送消息 + try { + // 发送catalog + eventPublisher.catalogEventPublish(platform.getId(), channelListForEvent, CatalogEvent.DEL); + } catch (Exception e) { + log.warn("[移除关联通道] 发送失败,数量:{}", channelList.size(), e); + } + } + } + @Override @Transactional public void checkGroupAdd(List channelList) {