mirror of
https://gitee.com/pan648540858/wvp-GB28181-pro.git
synced 2026-05-24 22:17:49 +08:00
通道编辑修复分组路径显示异常,支持行政区划路径显示
This commit is contained in:
parent
033db1925c
commit
a97a1113cf
@ -22,6 +22,7 @@ import javax.sip.InvalidArgumentException;
|
|||||||
import javax.sip.SipException;
|
import javax.sip.SipException;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author lin
|
* @author lin
|
||||||
@ -62,16 +63,24 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
|||||||
@EventListener
|
@EventListener
|
||||||
public void onApplicationEvent(ChannelEvent event) {
|
public void onApplicationEvent(ChannelEvent event) {
|
||||||
if (event.getChannels().isEmpty()) {
|
if (event.getChannels().isEmpty()) {
|
||||||
|
log.info("[国标级联-处理通道变化事件] 通道数量为空");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
String deviceIds = event.getChannels().stream().map(CommonGBChannel::getGbDeviceId).collect(Collectors.joining());
|
||||||
|
log.info("[国标级联-处理通道变化事件] 类型: {}, 通道: {}", event.getMessageType(), deviceIds);
|
||||||
// 获取通道所关联的平台
|
// 获取通道所关联的平台
|
||||||
List<Platform> allPlatform = platformMapper.queryByServerId(userSetting.getServerId());
|
List<Platform> allPlatform = platformMapper.queryByServerId(userSetting.getServerId());
|
||||||
|
if (allPlatform.isEmpty()) {
|
||||||
|
log.info("[国标级联-处理通道变化事件] 没有关联的平台");
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 获取所用订阅
|
// 获取所用订阅
|
||||||
List<String> platforms = subscribeHolder.getAllCatalogSubscribePlatform(allPlatform);
|
List<String> platforms = subscribeHolder.getAllCatalogSubscribePlatform(allPlatform);
|
||||||
|
|
||||||
Map<String, List<Platform>> platformMap = new HashMap<>();
|
Map<String, List<Platform>> platformMap = new HashMap<>();
|
||||||
Map<String, CommonGBChannel> channelMap = new HashMap<>();
|
Map<String, CommonGBChannel> channelMap = new HashMap<>();
|
||||||
if (platforms.isEmpty()) {
|
if (platforms.isEmpty()) {
|
||||||
|
log.info("[国标级联-处理通道变化事件] 没有关联的平台的目录订阅");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (CommonGBChannel deviceChannel : event.getChannels()) {
|
for (CommonGBChannel deviceChannel : event.getChannels()) {
|
||||||
@ -81,6 +90,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
|||||||
channelMap.put(deviceChannel.getGbDeviceId(), deviceChannel);
|
channelMap.put(deviceChannel.getGbDeviceId(), deviceChannel);
|
||||||
}
|
}
|
||||||
if (platformMap.isEmpty()) {
|
if (platformMap.isEmpty()) {
|
||||||
|
log.info("[国标级联-处理通道变化事件] 开启订阅的平台都没有关联通道: {}", deviceIds);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (event.getMessageType()) {
|
switch (event.getMessageType()) {
|
||||||
@ -147,13 +157,16 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
|||||||
|
|
||||||
@EventListener
|
@EventListener
|
||||||
public void onApplicationEvent(CatalogEvent event) {
|
public void onApplicationEvent(CatalogEvent event) {
|
||||||
log.info("[Catalog事件: {}]通道数量: {}", event.getType(), event.getChannels().size());
|
String deviceIds = event.getChannels().stream().map(CommonGBChannel::getGbDeviceId).collect(Collectors.joining());
|
||||||
|
log.info("[Catalog事件: {}] 通道: {}", event.getType(), deviceIds);
|
||||||
Platform platform = event.getPlatform();
|
Platform platform = event.getPlatform();
|
||||||
if (platform == null || platform.getServerGBId() == null) {
|
if (platform == null || platform.getServerGBId() == null) {
|
||||||
|
log.info("[Catalog事件: {}] 缺少通道或通道数据异常: {}", event.getType(), deviceIds);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SubscribeInfo subscribe = subscribeHolder.getCatalogSubscribe(platform.getServerGBId());
|
SubscribeInfo subscribe = subscribeHolder.getCatalogSubscribe(platform.getServerGBId());
|
||||||
if (subscribe == null) {
|
if (subscribe == null) {
|
||||||
|
log.info("[Catalog事件: {}] 平台未被目录订阅,取消发送: {}", event.getType(), deviceIds);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (event.getType()) {
|
switch (event.getType()) {
|
||||||
@ -165,7 +178,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
|||||||
channels.addAll(event.getChannels());
|
channels.addAll(event.getChannels());
|
||||||
}
|
}
|
||||||
if (!channels.isEmpty()) {
|
if (!channels.isEmpty()) {
|
||||||
log.info("[Catalog事件: {}]平台:{},影响通道{}个", event.getType(), platform.getServerGBId(), channels.size());
|
log.info("[Catalog事件: {}]平台:{},影响通道{}", event.getType(), platform.getServerGBId(), deviceIds);
|
||||||
try {
|
try {
|
||||||
sipCommanderFroPlatform.sendNotifyForCatalogOther(event.getType(), platform, channels, subscribe, null);
|
sipCommanderFroPlatform.sendNotifyForCatalogOther(event.getType(), platform, channels, subscribe, null);
|
||||||
} catch (InvalidArgumentException | ParseException | NoSuchFieldException | SipException |
|
} catch (InvalidArgumentException | ParseException | NoSuchFieldException | SipException |
|
||||||
@ -185,7 +198,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
|||||||
deviceChannelList.addAll(event.getChannels());
|
deviceChannelList.addAll(event.getChannels());
|
||||||
}
|
}
|
||||||
if (!deviceChannelList.isEmpty()) {
|
if (!deviceChannelList.isEmpty()) {
|
||||||
log.info("[Catalog事件: {}]平台:{},影响通道{}个", event.getType(), platform.getServerGBId(), deviceChannelList.size());
|
log.info("[Catalog事件: {}]平台:{},影响通道{}", event.getType(), platform.getServerGBId(), deviceIds);
|
||||||
try {
|
try {
|
||||||
sipCommanderFroPlatform.sendNotifyForCatalogAddOrUpdate(event.getType(), platform, deviceChannelList, subscribe, null);
|
sipCommanderFroPlatform.sendNotifyForCatalogAddOrUpdate(event.getType(), platform, deviceChannelList, subscribe, null);
|
||||||
} catch (InvalidArgumentException | ParseException | NoSuchFieldException | SipException |
|
} catch (InvalidArgumentException | ParseException | NoSuchFieldException | SipException |
|
||||||
@ -460,35 +473,40 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
|||||||
public int removeChannelList(Integer platformId, List<CommonGBChannel> channelList) {
|
public int removeChannelList(Integer platformId, List<CommonGBChannel> channelList) {
|
||||||
Platform platform = platformMapper.query(platformId);
|
Platform platform = platformMapper.query(platformId);
|
||||||
if (platform == null) {
|
if (platform == null) {
|
||||||
|
log.info("[移除关联通道] 平台{}未查询到", platformId);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
String deviceIds = channelList.stream().map(CommonGBChannel::getGbDeviceId).collect(Collectors.joining());
|
||||||
|
log.info("[移除关联通道] 上级平台: {}, 通道: {}", platform.getServerGBId(), deviceIds);
|
||||||
int result = platformChannelMapper.removeChannelsWithPlatform(platformId, channelList);
|
int result = platformChannelMapper.removeChannelsWithPlatform(platformId, channelList);
|
||||||
if (result > 0) {
|
if (result <= 0) {
|
||||||
// 查询通道相关的分组信息
|
log.info("[移除关联通道] 平台{}未关联通道: {}", platformId, deviceIds);
|
||||||
Set<Region> regionSet = regionMapper.queryByChannelList(channelList);
|
return 0;
|
||||||
Set<Region> deleteRegion = deleteEmptyRegion(regionSet, platformId);
|
}
|
||||||
if (!deleteRegion.isEmpty()) {
|
// 查询通道相关的分组信息
|
||||||
for (Region region : deleteRegion) {
|
Set<Region> regionSet = regionMapper.queryByChannelList(channelList);
|
||||||
channelList.add(0, CommonGBChannel.build(region));
|
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> groupSet = groupMapper.queryByChannelList(channelList);
|
||||||
Set<Group> deleteGroup = deleteEmptyGroup(groupSet, platformId);
|
Set<Group> deleteGroup = deleteEmptyGroup(groupSet, platformId);
|
||||||
if (!deleteGroup.isEmpty()) {
|
if (!deleteGroup.isEmpty()) {
|
||||||
for (Group group : deleteGroup) {
|
for (Group group : deleteGroup) {
|
||||||
channelList.add(0, CommonGBChannel.build(group));
|
channelList.add(0, CommonGBChannel.build(group));
|
||||||
}
|
|
||||||
}
|
|
||||||
// 发送消息
|
|
||||||
try {
|
|
||||||
// 发送catalog
|
|
||||||
eventPublisher.catalogEventPublish(platform, channelList, CatalogEvent.DEL);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.warn("[移除关联通道] 发送失败,数量:{}", channelList.size(), e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 发送消息
|
||||||
|
try {
|
||||||
|
// 发送catalog
|
||||||
|
eventPublisher.catalogEventPublish(platform, channelList, CatalogEvent.DEL);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("[移除关联通道] 发送失败,数量:{}", channelList.size(), e);
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -497,6 +515,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
|||||||
public int removeChannels(Integer platformId, List<Integer> channelIds) {
|
public int removeChannels(Integer platformId, List<Integer> channelIds) {
|
||||||
List<CommonGBChannel> channelList = platformChannelMapper.queryShare(platformId, channelIds);
|
List<CommonGBChannel> channelList = platformChannelMapper.queryShare(platformId, channelIds);
|
||||||
if (channelList.isEmpty()) {
|
if (channelList.isEmpty()) {
|
||||||
|
log.info("[移除通道] 通道列表为空");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return removeChannelList(platformId, channelList);
|
return removeChannelList(platformId, channelList);
|
||||||
@ -507,6 +526,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
|||||||
public void removeChannels(List<Integer> ids) {
|
public void removeChannels(List<Integer> ids) {
|
||||||
List<Platform> platformList = platformChannelMapper.queryPlatFormListByChannelList(ids);
|
List<Platform> platformList = platformChannelMapper.queryPlatFormListByChannelList(ids);
|
||||||
if (platformList.isEmpty()) {
|
if (platformList.isEmpty()) {
|
||||||
|
log.info("[移除多个通道] 未查询到通道关联的平台");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -520,6 +540,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
|||||||
public void removeChannel(int channelId) {
|
public void removeChannel(int channelId) {
|
||||||
List<Platform> platformList = platformChannelMapper.queryPlatFormListByChannelId(channelId);
|
List<Platform> platformList = platformChannelMapper.queryPlatFormListByChannelId(channelId);
|
||||||
if (platformList.isEmpty()) {
|
if (platformList.isEmpty()) {
|
||||||
|
log.info("[移除多个通道] 未查询到通道:{} 关联的平台", channelId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (Platform platform : platformList) {
|
for (Platform platform : platformList) {
|
||||||
@ -532,6 +553,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
|||||||
@Override
|
@Override
|
||||||
public List<CommonGBChannel> queryByPlatform(Platform platform) {
|
public List<CommonGBChannel> queryByPlatform(Platform platform) {
|
||||||
if (platform == null) {
|
if (platform == null) {
|
||||||
|
log.info("[查询通道所属平台] 平台参数为NULL");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<CommonGBChannel> commonGBChannelList = commonGBChannelMapper.queryWithPlatform(platform.getId());
|
List<CommonGBChannel> commonGBChannelList = commonGBChannelMapper.queryWithPlatform(platform.getId());
|
||||||
@ -570,6 +592,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
|||||||
Assert.notNull(platform, "平台不存在");
|
Assert.notNull(platform, "平台不存在");
|
||||||
List<CommonGBChannel> channelList = queryByPlatform(platform);
|
List<CommonGBChannel> channelList = queryByPlatform(platform);
|
||||||
if (channelList.isEmpty()){
|
if (channelList.isEmpty()){
|
||||||
|
log.info("[推送通道] 平台:{} 未查询到通道信息", platform.getServerGBId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SubscribeInfo subscribeInfo = SubscribeInfo.buildSimulated(platform.getServerGBId(), platform.getServerIp());
|
SubscribeInfo subscribeInfo = SubscribeInfo.buildSimulated(platform.getServerGBId(), platform.getServerIp());
|
||||||
@ -608,6 +631,8 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
|||||||
// 获取关联这些通道的平台
|
// 获取关联这些通道的平台
|
||||||
List<Platform> platformList = platformChannelMapper.queryPlatFormListByChannelList(channelIds);
|
List<Platform> platformList = platformChannelMapper.queryPlatFormListByChannelList(channelIds);
|
||||||
if (platformList.isEmpty()) {
|
if (platformList.isEmpty()) {
|
||||||
|
String deviceIds = channelList.stream().map(CommonGBChannel::getGbDeviceId).collect(Collectors.joining());
|
||||||
|
log.info("[获取关联这些通道的平台] 未查询到通道关联的平台, 通道如下 {}", deviceIds);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (Platform platform : platformList) {
|
for (Platform platform : platformList) {
|
||||||
@ -646,6 +671,8 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
|||||||
// 获取关联这些通道的平台
|
// 获取关联这些通道的平台
|
||||||
List<Platform> platformList = platformChannelMapper.queryPlatFormListByChannelList(channelIds);
|
List<Platform> platformList = platformChannelMapper.queryPlatFormListByChannelList(channelIds);
|
||||||
if (platformList.isEmpty()) {
|
if (platformList.isEmpty()) {
|
||||||
|
String deviceIds = channelList.stream().map(CommonGBChannel::getGbDeviceId).collect(Collectors.joining());
|
||||||
|
log.info("[获取关联这些通道的平台] 未查询到通道关联的平台, 通道如下 {}", deviceIds);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (Platform platform : platformList) {
|
for (Platform platform : platformList) {
|
||||||
@ -683,6 +710,8 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
|||||||
});
|
});
|
||||||
List<Platform> platformList = platformChannelMapper.queryPlatFormListByChannelList(channelIds);
|
List<Platform> platformList = platformChannelMapper.queryPlatFormListByChannelList(channelIds);
|
||||||
if (platformList.isEmpty()) {
|
if (platformList.isEmpty()) {
|
||||||
|
String deviceIds = channelList.stream().map(CommonGBChannel::getGbDeviceId).collect(Collectors.joining());
|
||||||
|
log.info("[获取关联这些通道的平台] 未查询到通道关联的平台, 通道如下 {}", deviceIds);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (Platform platform : platformList) {
|
for (Platform platform : platformList) {
|
||||||
@ -714,6 +743,8 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
|||||||
});
|
});
|
||||||
List<Platform> platformList = platformChannelMapper.queryPlatFormListByChannelList(channelIds);
|
List<Platform> platformList = platformChannelMapper.queryPlatFormListByChannelList(channelIds);
|
||||||
if (platformList.isEmpty()) {
|
if (platformList.isEmpty()) {
|
||||||
|
String deviceIds = channelList.stream().map(CommonGBChannel::getGbDeviceId).collect(Collectors.joining());
|
||||||
|
log.info("[获取关联这些通道的平台] 未查询到通道关联的平台, 通道如下 {}", deviceIds);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (Platform platform : platformList) {
|
for (Platform platform : platformList) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user