国标级联通道共享重构完善

pull/1642/head
648540858 2024-08-26 17:16:04 +08:00
parent 5216e9723c
commit c45bf5d6af
5 changed files with 274 additions and 39 deletions

View File

@ -507,6 +507,55 @@ public interface CommonGBChannelMapper {
List<CommonGBChannel> queryShareChannelByParentId(@Param("parentId") String parentId, @Param("platformId") Integer platformId);
@Select("select\n" +
" wdc.id as gb_id,\n" +
" wdc.device_db_id as gb_device_db_id,\n" +
" wdc.stream_push_id,\n" +
" wdc.stream_proxy_id,\n" +
" wdc.create_time,\n" +
" wdc.update_time,\n" +
" coalesce(wpgc.device_id, wdc.gb_device_id, wdc.device_id) as gb_device_id,\n" +
" coalesce(wpgc.name, wdc.gb_name, wdc.name) as gb_name,\n" +
" coalesce(wpgc.manufacturer, wdc.gb_manufacturer, wdc.manufacturer) as gb_manufacturer,\n" +
" coalesce(wpgc.model, wdc.gb_model, wdc.model) as gb_model,\n" +
" coalesce(wpgc.owner, wdc.gb_owner, wdc.owner) as gb_owner,\n" +
" coalesce(wpgc.civil_code, wdc.gb_civil_code, wdc.civil_code) as gb_civil_code,\n" +
" coalesce(wpgc.block, wdc.gb_block, wdc.block) as gb_block,\n" +
" coalesce(wpgc.address, wdc.gb_address, wdc.address) as gb_address,\n" +
" coalesce(wpgc.parental, wdc.gb_parental, wdc.parental) as gb_parental,\n" +
" coalesce(wpgc.parent_id, wdc.gb_parent_id, wdc.parent_id) as gb_parent_id,\n" +
" coalesce(wpgc.safety_way, wdc.gb_safety_way, wdc.safety_way) as gb_safety_way,\n" +
" coalesce(wpgc.register_way, wdc.gb_register_way, wdc.register_way) as gb_register_way,\n" +
" coalesce(wpgc.cert_num, wdc.gb_cert_num, wdc.cert_num) as gb_cert_num,\n" +
" coalesce(wpgc.certifiable, wdc.gb_certifiable, wdc.certifiable) as gb_certifiable,\n" +
" coalesce(wpgc.err_code, wdc.gb_err_code, wdc.err_code) as gb_err_code,\n" +
" coalesce(wpgc.end_time, wdc.gb_end_time, wdc.end_time) as gb_end_time,\n" +
" coalesce(wpgc.secrecy, wdc.gb_secrecy, wdc.secrecy) as gb_secrecy,\n" +
" coalesce(wpgc.ip_address, wdc.gb_ip_address, wdc.ip_address) as gb_ip_address,\n" +
" coalesce(wpgc.port, wdc.gb_port, wdc.port) as gb_port,\n" +
" coalesce(wpgc.password, wdc.gb_password, wdc.password) as gb_password,\n" +
" coalesce(wpgc.status, wdc.gb_status, wdc.status) as gb_status,\n" +
" coalesce(wpgc.longitude, wdc.gb_longitude, wdc.longitude) as gb_longitude,\n" +
" coalesce(wpgc.latitude, wdc.gb_latitude, wdc.latitude) as gb_latitude,\n" +
" coalesce(wpgc.ptz_type, wdc.gb_ptz_type, wdc.ptz_type) as gb_ptz_type,\n" +
" coalesce(wpgc.position_type, wdc.gb_position_type, wdc.position_type) as gb_position_type,\n" +
" coalesce(wpgc.room_type, wdc.gb_room_type, wdc.room_type) as gb_room_type,\n" +
" coalesce(wpgc.use_type, wdc.gb_use_type, wdc.use_type) as gb_use_type,\n" +
" coalesce(wpgc.supply_light_type, wdc.gb_supply_light_type, wdc.supply_light_type) as gb_supply_light_type,\n" +
" coalesce(wpgc.direction_type, wdc.gb_direction_type, wdc.direction_type) as gb_direction_type,\n" +
" coalesce(wpgc.resolution, wdc.gb_resolution, wdc.resolution) as gb_resolution,\n" +
" coalesce(wpgc.business_group_id, wdc.gb_business_group_id, wdc.business_group_id) as gb_business_group_id,\n" +
" coalesce(wpgc.download_speed, wdc.gb_download_speed, wdc.download_speed) as gb_download_speed,\n" +
" coalesce(wpgc.svc_space_support_mod, wdc.gb_svc_space_support_mod, wdc.svc_space_support_mod) as gb_svc_space_support_mod,\n" +
" coalesce(wpgc.svc_time_support_mode, wdc.gb_svc_time_support_mode, wdc.svc_time_support_mode) as gb_svc_time_support_mode\n" +
" from wvp_device_channel wdc" +
" left join wvp_platform_channel wpgc on wdc.id = wpgc.device_channel_id " +
" where wpgc.platform_id = #{platformId} and coalesce(wpgc.civil_code, wdc.gb_civil_code, wdc.civil_code) = #{civilCode}"
)
List<CommonGBChannel> queryShareChannelByCivilCode(@Param("civilCode") String civilCode, @Param("platformId") Integer platformId);
@Update(value = {" <script>" +
" UPDATE wvp_device_channel " +
" SET gb_civil_code = #{civilCode}" +

View File

@ -165,7 +165,7 @@ public interface GroupMapper {
" where wpg.platform_id is null and wcg.device_id in " +
" <foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.gbParentId}</foreach>" +
" </script>")
Set<Group> queryNotShareForPlatformByChannelList(List<CommonGBChannel> channelList, @Param("platformId") Integer platformId);
Set<Group> queryNotShareGroupForPlatformByChannelList(List<CommonGBChannel> channelList, @Param("platformId") Integer platformId);
@Select(" <script>" +
" SELECT * " +
@ -174,7 +174,8 @@ public interface GroupMapper {
" where wpg.platform_id IS NULL and wcg.id in " +
" <foreach collection='allGroup' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" +
" </script>")
Set<Group> queryNotShareForPlatformByGroupList(Set<Group> allGroup, @Param("platformId") Integer platformId);
Set<Group> queryNotShareGroupForPlatformByGroupList(Set<Group> allGroup, @Param("platformId") Integer platformId);
@Select(" <script>" +
" SELECT " +
@ -182,7 +183,8 @@ public interface GroupMapper {
" from wvp_common_group " +
" where device_id in " +
" <foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.gbParentId}</foreach>" +
" </script>")
" order by id " +
"</script>")
Set<Group> queryByChannelList(List<CommonGBChannel> channelList);
@Update(" <script>" +

View File

@ -134,7 +134,7 @@ public interface PlatformChannelMapper {
" coalesce(wpgc.manufacturer, wdc.gb_manufacturer, wdc.manufacturer) as gb_manufacturer,\n" +
" coalesce(wpgc.model, wdc.gb_model, wdc.model) as gb_model,\n" +
" coalesce(wpgc.owner, wdc.gb_owner, wdc.owner) as gb_owner,\n" +
" coalesce(wpgc.civil_code, wdc.gb_civil_code, wdc.civil_code),\n" +
" coalesce(wpgc.civil_code, wdc.gb_civil_code, wdc.civil_code) as gb_civil_code,\n" +
" coalesce(wpgc.block, wdc.gb_block, wdc.block) as gb_block,\n" +
" coalesce(wpgc.address, wdc.gb_address, wdc.address) as gb_address,\n" +
" coalesce(wpgc.parental, wdc.gb_parental, wdc.parental) as gb_parental,\n" +
@ -190,7 +190,7 @@ public interface PlatformChannelMapper {
" coalesce(wpgc.manufacturer, wdc.gb_manufacturer, wdc.manufacturer) as gb_manufacturer,\n" +
" coalesce(wpgc.model, wdc.gb_model, wdc.model) as gb_model,\n" +
" coalesce(wpgc.owner, wdc.gb_owner, wdc.owner) as gb_owner,\n" +
" coalesce(wpgc.civil_code, wdc.gb_civil_code, wdc.civil_code),\n" +
" coalesce(wpgc.civil_code, wdc.gb_civil_code, wdc.civil_code) as gb_civil_code,\n" +
" coalesce(wpgc.block, wdc.gb_block, wdc.block) as gb_block,\n" +
" coalesce(wpgc.address, wdc.gb_address, wdc.address) as gb_address,\n" +
" coalesce(wpgc.parental, wdc.gb_parental, wdc.parental) as gb_parental,\n" +
@ -240,7 +240,7 @@ public interface PlatformChannelMapper {
" coalesce(wpgc.manufacturer, wdc.gb_manufacturer, wdc.manufacturer) as gb_manufacturer,\n" +
" coalesce(wpgc.model, wdc.gb_model, wdc.model) as gb_model,\n" +
" coalesce(wpgc.owner, wdc.gb_owner, wdc.owner) as gb_owner,\n" +
" coalesce(wpgc.civil_code, wdc.gb_civil_code, wdc.civil_code),\n" +
" coalesce(wpgc.civil_code, wdc.gb_civil_code, wdc.civil_code) as gb_civil_code,\n" +
" coalesce(wpgc.block, wdc.gb_block, wdc.block) as gb_block,\n" +
" coalesce(wpgc.address, wdc.gb_address, wdc.address) as gb_address,\n" +
" coalesce(wpgc.parental, wdc.gb_parental, wdc.parental) as gb_parental,\n" +
@ -291,7 +291,7 @@ public interface PlatformChannelMapper {
" coalesce(wpgc.manufacturer, wdc.gb_manufacturer, wdc.manufacturer) as gb_manufacturer,\n" +
" coalesce(wpgc.model, wdc.gb_model, wdc.model) as gb_model,\n" +
" coalesce(wpgc.owner, wdc.gb_owner, wdc.owner) as gb_owner,\n" +
" coalesce(wpgc.civil_code, wdc.gb_civil_code, wdc.civil_code),\n" +
" coalesce(wpgc.civil_code, wdc.gb_civil_code, wdc.civil_code) as gb_civil_code,\n" +
" coalesce(wpgc.block, wdc.gb_block, wdc.block) as gb_block,\n" +
" coalesce(wpgc.address, wdc.gb_address, wdc.address) as gb_address,\n" +
" coalesce(wpgc.parental, wdc.gb_parental, wdc.parental) as gb_parental,\n" +
@ -349,6 +349,14 @@ public interface PlatformChannelMapper {
"</script>")
int addPlatformGroup(List<Group> groupListNotShare, @Param("platformId") Integer platformId);
@Insert("<script> "+
"INSERT INTO wvp_platform_region (platform_id, region_id) VALUES " +
"<foreach collection='regionListNotShare' item='item' separator=','>" +
" (#{platformId}, #{item.id} )" +
"</foreach>" +
"</script>")
int addPlatformRegion(List<Region> regionListNotShare, @Param("platformId") Integer platformId);
@Delete("<script> "+
"DELETE from wvp_platform_group WHERE platform_id=#{platformId} AND group_id in" +
"<foreach collection='groupList' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" +
@ -360,6 +368,11 @@ public interface PlatformChannelMapper {
"</script>")
void removePlatformGroupById(@Param("id") int id, @Param("platformId") Integer platformId);
@Delete("<script> "+
"DELETE from wvp_platform_region WHERE platform_id=#{platformId} AND region_id =#{id}" +
"</script>")
void removePlatformRegionById(@Param("id") int id, @Param("platformId") Integer platformId);
@Select(" <script>" +
" SELECT wcg.* " +
" from wvp_common_group wcg" +
@ -368,12 +381,29 @@ public interface PlatformChannelMapper {
" </script>")
Set<Group> queryShareChildrenGroup(@Param("parentId") String parentId, @Param("platformId") Integer platformId);
@Select(" <script>" +
" SELECT wcr.* " +
" from wvp_common_region wcr" +
" left join wvp_platform_region wpr on wpr.region_id = wcr.id and wpr.platform_id = #{platformId}" +
" where wpr.platform_id IS NOT NULL and wcr.parent_device_id = #{parentId} " +
" </script>")
Set<Region> queryShareChildrenRegion(@Param("parentId") String parentId, @Param("platformId") Integer platformId);
@Select(" <script>" +
" SELECT wcg.* " +
" from wvp_common_group wcg" +
" left join wvp_platform_group wpg on wpg.group_id = wcg.id and wpg.platform_id = #{platformId}" +
" where wpg.platform_id is not null and wcg.parent_device_id in " +
"<foreach collection='groupSet' item='item' open='(' separator=',' close=')' > #{item.deviceId}</foreach>" +
" where wpg.platform_id is not null and wcg.id in " +
"<foreach collection='groupSet' item='item' open='(' separator=',' close=')' > #{item.parentId}</foreach>" +
" </script>")
Set<Group> queryShareParentGroupByGroupSet(Set<Group> groupSet, @Param("platformId") Integer platformId);
@Select(" <script>" +
" SELECT wcr.* " +
" from wvp_common_region wcr" +
" left join wvp_platform_region wpr on wpr.region_id = wcr.id and wpr.platform_id = #{platformId}" +
" where wpr.platform_id is not null and wcr.id in " +
"<foreach collection='regionSet' item='item' open='(' separator=',' close=')' > #{item.parentId}</foreach>" +
" </script>")
Set<Region> queryShareParentRegionByRegionSet(Set<Region> regionSet, @Param("platformId") Integer platformId);
}

View File

@ -1,6 +1,7 @@
package com.genersoft.iot.vmp.gb28181.dao;
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.gb28181.bean.Group;
import com.genersoft.iot.vmp.gb28181.bean.Region;
import com.genersoft.iot.vmp.gb28181.bean.RegionTree;
import org.apache.ibatis.annotations.*;
@ -123,4 +124,42 @@ public interface RegionMapper {
@Select("SELECT * from wvp_common_region WHERE device_id = #{deviceId} ")
Region queryByDeviceId(@Param("deviceId") String deviceId);
@Select(" <script>" +
" SELECT " +
" * " +
" from wvp_common_region " +
" where id in " +
" <foreach collection='regionSet' item='item' open='(' separator=',' close=')' > #{item.parentId}</foreach>" +
" </script>")
Set<Region> queryParentInChannelList(Set<Region> regionSet);
@Select(" <script>" +
" SELECT " +
" * " +
" from wvp_common_region " +
" where device_id in " +
" <foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.gbCivilCode}</foreach>" +
" order by id " +
"</script>")
Set<Region> queryByChannelList(List<CommonGBChannel> channelList);
@Select(" <script>" +
" SELECT * " +
" from wvp_common_region wcr" +
" left join wvp_platform_region wpr on wpr.region_id = wcr.id and wpr.platform_id = #{platformId}" +
" where wpr.platform_id is null and wcr.device_id in " +
" <foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.gbCivilCode}</foreach>" +
" </script>")
Set<Region> queryNotShareRegionForPlatformByChannelList(List<CommonGBChannel> channelList, @Param("platformId") Integer platformId);
@Select(" <script>" +
" SELECT * " +
" from wvp_common_region wcr" +
" left join wvp_platform_region wpr on wpr.region_id = wcr.id and wpr.platform_id = #{platformId}" +
" where wpr.platform_id IS NULL and wcr.id in " +
" <foreach collection='allRegion' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" +
" </script>")
Set<Region> queryNotShareRegionForPlatformByRegionList(Set<Region> allRegion, @Param("platformId") Integer platformId);
}

View File

@ -4,9 +4,11 @@ import com.baomidou.dynamic.datasource.annotation.DS;
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.gb28181.bean.Group;
import com.genersoft.iot.vmp.gb28181.bean.PlatformChannel;
import com.genersoft.iot.vmp.gb28181.bean.Region;
import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper;
import com.genersoft.iot.vmp.gb28181.dao.GroupMapper;
import com.genersoft.iot.vmp.gb28181.dao.PlatformChannelMapper;
import com.genersoft.iot.vmp.gb28181.dao.RegionMapper;
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;
@ -18,10 +20,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import java.beans.Transient;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
/**
* @author lin
@ -40,6 +39,10 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
@Autowired
private GroupMapper groupMapper;
@Autowired
private RegionMapper regionMapper;
@Autowired
private CommonGBChannelMapper commonGBChannelMapper;
@ -58,15 +61,30 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
Assert.notEmpty(channelListNotShare, "所有通道已共享");
int result = platformChannelMapper.addChannels(platformId, channelListNotShare);
if (result > 0) {
// 查询通道相关的分组信息是否共享,如果没共享就添加
Set<Group> groupListNotShare = getGroupNotShareByChannelList(channelListNotShare, platformId);
int addGroupResult = platformChannelMapper.addPlatformGroup(new ArrayList<>(groupListNotShare), platformId);
if (addGroupResult > 0) {
for (Group group : groupListNotShare) {
// 分组信息排序时需要将顶层排在最后
channelListNotShare.add(0, CommonGBChannel.build(group));
// 查询通道相关的行政区划信息是否共享,如果没共享就添加
Set<Region> regionListNotShare = getRegionNotShareByChannelList(channelListNotShare, platformId);
if (!regionListNotShare.isEmpty()) {
int addGroupResult = platformChannelMapper.addPlatformRegion(new ArrayList<>(regionListNotShare), platformId);
if (addGroupResult > 0) {
for (Region region : regionListNotShare) {
// 分组信息排序时需要将顶层排在最后
channelListNotShare.add(0, CommonGBChannel.build(region));
}
}
}
// 查询通道相关的分组信息是否共享,如果没共享就添加
Set<Group> groupListNotShare = getGroupNotShareByChannelList(channelListNotShare, platformId);
if (!groupListNotShare.isEmpty()) {
int addGroupResult = platformChannelMapper.addPlatformGroup(new ArrayList<>(groupListNotShare), platformId);
if (addGroupResult > 0) {
for (Group group : groupListNotShare) {
// 分组信息排序时需要将顶层排在最后
channelListNotShare.add(0, CommonGBChannel.build(group));
}
}
}
// 发送消息
try {
// 发送catalog
@ -83,35 +101,56 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
*/
private Set<Group> getGroupNotShareByChannelList(List<CommonGBChannel> channelList, Integer platformId) {
// 获取分组中未分享的节点
Set<Group> groupList = groupMapper.queryNotShareForPlatformByChannelList(channelList, platformId);
Set<Group> groupList = groupMapper.queryNotShareGroupForPlatformByChannelList(channelList, platformId);
// 获取这些节点的所有父节点
if (groupList.isEmpty()) {
return new HashSet<>();
}
Set<Group> allGroup = getAllGroup(groupList);
allGroup.addAll(groupList);
// 获取全部节点中未分享的
return groupMapper.queryNotShareForPlatformByGroupList(allGroup, platformId);
return groupMapper.queryNotShareGroupForPlatformByGroupList(allGroup, platformId);
}
/**
* 使
*/
private Set<Region> getRegionNotShareByChannelList(List<CommonGBChannel> channelList, Integer platformId) {
// 获取分组中未分享的节点
Set<Region> regionSet = regionMapper.queryNotShareRegionForPlatformByChannelList(channelList, platformId);
// 获取这些节点的所有父节点
if (regionSet.isEmpty()) {
return new HashSet<>();
}
Set<Region> allRegion = getAllRegion(regionSet);
allRegion.addAll(regionSet);
// 获取全部节点中未分享的
return regionMapper.queryNotShareRegionForPlatformByRegionList(allRegion, platformId);
}
/**
*
*/
private Set<Group> deleteEmptyGroup(Set<Group> groupSet, Integer platformId) {
for (Group group : groupSet) {
Iterator<Group> iterator = groupSet.iterator();
while (iterator.hasNext()) {
Group group = iterator.next();
// groupSet 为当前通道直接使用的分组,如果已经没有子分组与其他的通道,则可以移除
// 获取分组子节点
Set<Group> children = platformChannelMapper.queryShareChildrenGroup(group.getDeviceId(), platformId);
if (!children.isEmpty()) {
groupSet.remove(group);
iterator.remove();
continue;
}
// 获取分组关联的通道
List<CommonGBChannel> channelList = commonGBChannelMapper.queryShareChannelByParentId(group.getDeviceId(), platformId);
if (!channelList.isEmpty()) {
groupSet.remove(group);
iterator.remove();
continue;
}
platformChannelMapper.removePlatformGroupById(group.getId(), platformId);
}
// 如果空了,说明没有通道需要处理了
if (groupSet.isEmpty()) {
return new HashSet<>();
}
@ -125,15 +164,46 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
}
}
/**
*
*/
private Set<Region> deleteEmptyRegion(Set<Region> regionSet, Integer platformId) {
Iterator<Region> iterator = regionSet.iterator();
while (iterator.hasNext()) {
Region region = iterator.next();
// groupSet 为当前通道直接使用的分组,如果已经没有子分组与其他的通道,则可以移除
// 获取分组子节点
Set<Region> children = platformChannelMapper.queryShareChildrenRegion(region.getDeviceId(), platformId);
if (!children.isEmpty()) {
iterator.remove();
continue;
}
// 获取分组关联的通道
List<CommonGBChannel> channelList = commonGBChannelMapper.queryShareChannelByCivilCode(region.getDeviceId(), platformId);
if (!channelList.isEmpty()) {
iterator.remove();
continue;
}
platformChannelMapper.removePlatformRegionById(region.getId(), platformId);
}
// 如果空了,说明没有通道需要处理了
if (regionSet.isEmpty()) {
return new HashSet<>();
}
Set<Region> parent = platformChannelMapper.queryShareParentRegionByRegionSet(regionSet, platformId);
if (parent.isEmpty()) {
return regionSet;
}else {
Set<Region> parentGroupSet = deleteEmptyRegion(parent, platformId);
regionSet.addAll(parentGroupSet);
return regionSet;
}
}
private Set<Group> getAllGroup(Set<Group> groupList ) {
if (groupList.isEmpty()) {
return new HashSet<>();
}
for (Group group : groupList) {
if (group.getParentDeviceId() == null) {
}
}
Set<Group> channelList = groupMapper.queryParentInChannelList(groupList);
if (channelList.isEmpty()) {
return channelList;
@ -143,6 +213,20 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
return channelList;
}
private Set<Region> getAllRegion(Set<Region> regionSet ) {
if (regionSet.isEmpty()) {
return new HashSet<>();
}
Set<Region> channelList = regionMapper.queryParentInChannelList(regionSet);
if (channelList.isEmpty()) {
return channelList;
}
Set<Region> allParentRegion = getAllRegion(channelList);
channelList.addAll(allParentRegion);
return channelList;
}
@Override
@Transient
public int addChannels(Integer platformId, List<Integer> channelIds) {
@ -150,6 +234,18 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
Assert.notEmpty(channelListNotShare, "通道已共享");
int result = platformChannelMapper.addChannels(platformId, channelListNotShare);
if (result > 0) {
// 查询通道相关的行政区划信息是否共享,如果没共享就添加
Set<Region> regionListNotShare = getRegionNotShareByChannelList(channelListNotShare, platformId);
if (!regionListNotShare.isEmpty()) {
int addGroupResult = platformChannelMapper.addPlatformRegion(new ArrayList<>(regionListNotShare), platformId);
if (addGroupResult > 0) {
for (Region region : regionListNotShare) {
// 分组信息排序时需要将顶层排在最后
channelListNotShare.add(0, CommonGBChannel.build(region));
}
}
}
// 查询通道相关的分组信息是否共享,如果没共享就添加
Set<Group> groupListNotShare = getGroupNotShareByChannelList(channelListNotShare, platformId);
if (!groupListNotShare.isEmpty()) {
@ -175,36 +271,55 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
@Override
public int removeAllChannel(Integer platformId) {
List<CommonGBChannel> channelListNotShare = platformChannelMapper.queryNotShare(platformId, null);
Assert.notEmpty(channelListNotShare, "未共享任何通道");
int result = platformChannelMapper.removeChannels(platformId, channelListNotShare);
List<CommonGBChannel> channelListShare = platformChannelMapper.queryShare(platformId, null);
Assert.notEmpty(channelListShare, "未共享任何通道");
int result = platformChannelMapper.removeChannels(platformId, channelListShare);
if (result > 0) {
// 查询通道相关的分组信息是否共享,如果没共享就添加
Set<Group> groupSet = groupMapper.queryByChannelList(channelListNotShare);
// 查询通道相关的分组信息
Set<Region> regionSet = regionMapper.queryByChannelList(channelListShare);
Set<Region> deleteRegion = deleteEmptyRegion(regionSet, platformId);
if (!deleteRegion.isEmpty()) {
for (Region region : deleteRegion) {
channelListShare.add(0, CommonGBChannel.build(region));
}
}
// 查询通道相关的分组信息
Set<Group> groupSet = groupMapper.queryByChannelList(channelListShare);
Set<Group> deleteGroup = deleteEmptyGroup(groupSet, platformId);
if (!deleteGroup.isEmpty()) {
for (Group group : deleteGroup) {
channelListNotShare.add(0, CommonGBChannel.build(group));
channelListShare.add(0, CommonGBChannel.build(group));
}
}
// 发送消息
try {
// 发送catalog
eventPublisher.catalogEventPublish(platformId, channelListNotShare, CatalogEvent.DEL);
eventPublisher.catalogEventPublish(platformId, channelListShare, CatalogEvent.DEL);
} catch (Exception e) {
log.warn("[移除全部关联通道] 发送失败,数量:{}", channelListNotShare.size(), e);
log.warn("[移除全部关联通道] 发送失败,数量:{}", channelListShare.size(), e);
}
}
return result;
}
@Override
@Transient
public int removeChannels(Integer platformId, List<Integer> channelIds) {
List<CommonGBChannel> channelList = platformChannelMapper.queryShare(platformId, channelIds);
Assert.notEmpty(channelList, "所选通道未共享");
int result = platformChannelMapper.removeChannels(platformId, channelList);
if (result > 0) {
// 查询通道相关的分组信息是否共享,如果没共享就添加
// 查询通道相关的分组信息
Set<Region> regionSet = regionMapper.queryByChannelList(channelList);
Set<Region> deleteRegion = deleteEmptyRegion(regionSet, platformId);
if (!deleteRegion.isEmpty()) {
for (Region region : deleteRegion) {
channelList.add(0, CommonGBChannel.build(region));
}
}
// 查询通道相关的分组信息
Set<Group> groupSet = groupMapper.queryByChannelList(channelList);
Set<Group> deleteGroup = deleteEmptyGroup(groupSet, platformId);
if (!deleteGroup.isEmpty()) {