[国标级联] 优化catalog推送代码

This commit is contained in:
648540858
2025-01-03 15:10:02 +08:00
parent b37c0e264c
commit cb7c41c3c1
7 changed files with 43 additions and 47 deletions

View File

@@ -7,10 +7,7 @@ import com.genersoft.iot.vmp.common.InviteSessionType;
import com.genersoft.iot.vmp.common.enums.ChannelDataType;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.GbCode;
import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.controller.bean.ChannelReduce;
import com.genersoft.iot.vmp.gb28181.dao.DeviceChannelMapper;
import com.genersoft.iot.vmp.gb28181.dao.DeviceMapper;
@@ -507,10 +504,10 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
deviceChannel.setHasAudio(channelInDb.isHasAudio());
deviceChannel.setId(channelInDb.getId());
if (channelInDb.getStatus() != null && channelInDb.getStatus().equalsIgnoreCase(deviceChannel.getStatus())){
List<Integer> ids = platformChannelMapper.queryParentPlatformByChannelId(deviceChannel.getDeviceId());
if (!CollectionUtils.isEmpty(ids)){
ids.forEach(platformId->{
eventPublisher.catalogEventPublish(platformId, deviceChannel, deviceChannel.getStatus().equals("ON")? CatalogEvent.ON:CatalogEvent.OFF);
List<Platform> platformList = platformChannelMapper.queryParentPlatformByChannelId(deviceChannel.getDeviceId());
if (!CollectionUtils.isEmpty(platformList)){
platformList.forEach(platform->{
eventPublisher.catalogEventPublish(platform, deviceChannel, deviceChannel.getStatus().equals("ON")? CatalogEvent.ON:CatalogEvent.OFF);
});
}
}

View File

@@ -209,7 +209,7 @@ public class GroupServiceImpl implements IGroupService {
for (Platform platform : platformList) {
try {
// 发送catalog
eventPublisher.catalogEventPublish(platform.getId(), channel, CatalogEvent.DEL);
eventPublisher.catalogEventPublish(platform, channel, CatalogEvent.DEL);
}catch (Exception e) {
log.warn("[业务分组/虚拟组织删除] 发送失败,{}", groupForDelete.getDeviceId(), e);
}

View File

@@ -215,6 +215,10 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
@Transactional
public int addChannelList(Integer platformId, List<CommonGBChannel> channelList) {
Platform platform = platformMapper.query(platformId);
if (platform == null) {
return 0;
}
int result = platformChannelMapper.addChannels(platformId, channelList);
if (result > 0) {
// 查询通道相关的行政区划信息是否共享,如果没共享就添加
@@ -244,7 +248,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
// 发送消息
try {
// 发送catalog
eventPublisher.catalogEventPublish(platformId, channelList, CatalogEvent.ADD);
eventPublisher.catalogEventPublish(platform, channelList, CatalogEvent.ADD);
} catch (Exception e) {
log.warn("[关联通道] 发送失败,数量:{}", channelList.size(), e);
}
@@ -254,6 +258,11 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
@Override
public int removeAllChannel(Integer platformId) {
Platform platform = platformMapper.query(platformId);
if (platform == null) {
return 0;
}
List<CommonGBChannel> channelListShare = platformChannelMapper.queryShare(platformId, null);
Assert.notEmpty(channelListShare, "未共享任何通道");
int result = platformChannelMapper.removeChannelsWithPlatform(platformId, channelListShare);
@@ -278,7 +287,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
// 发送消息
try {
// 发送catalog
eventPublisher.catalogEventPublish(platformId, channelListShare, CatalogEvent.DEL);
eventPublisher.catalogEventPublish(platform, channelListShare, CatalogEvent.DEL);
} catch (Exception e) {
log.warn("[移除全部关联通道] 发送失败,数量:{}", channelListShare.size(), e);
}
@@ -302,6 +311,10 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
@Transactional
public int removeChannelList(Integer platformId, List<CommonGBChannel> channelList) {
Platform platform = platformMapper.query(platformId);
if (platform == null) {
return 0;
}
int result = platformChannelMapper.removeChannelsWithPlatform(platformId, channelList);
if (result > 0) {
// 查询通道相关的分组信息
@@ -324,7 +337,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
// 发送消息
try {
// 发送catalog
eventPublisher.catalogEventPublish(platformId, channelList, CatalogEvent.DEL);
eventPublisher.catalogEventPublish(platform, channelList, CatalogEvent.DEL);
} catch (Exception e) {
log.warn("[移除关联通道] 发送失败,数量:{}", channelList.size(), e);
}
@@ -425,11 +438,12 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
@Override
public void updateCustomChannel(PlatformChannel channel) {
platformChannelMapper.updateCustomChannel(channel);
Platform platform = platformMapper.query(channel.getPlatformId());
CommonGBChannel commonGBChannel = platformChannelMapper.queryShareChannel(channel.getPlatformId(), channel.getGbId());
// 发送消息
try {
// 发送catalog
eventPublisher.catalogEventPublish(channel.getPlatformId(), commonGBChannel, CatalogEvent.UPDATE);
eventPublisher.catalogEventPublish(platform, commonGBChannel, CatalogEvent.UPDATE);
} catch (Exception e) {
log.warn("[自定义通道信息] 发送失败, 平台ID {} 通道: {}{}", channel.getPlatformId(),
channel.getGbName(), channel.getId(), e);
@@ -468,7 +482,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
// 发送消息
try {
// 发送catalog
eventPublisher.catalogEventPublish(platform.getId(), channelListForEvent, CatalogEvent.DEL);
eventPublisher.catalogEventPublish(platform, channelListForEvent, CatalogEvent.DEL);
} catch (Exception e) {
log.warn("[移除关联通道] 发送失败,数量:{}", channelList.size(), e);
}
@@ -506,7 +520,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
// 发送消息
try {
// 发送catalog
eventPublisher.catalogEventPublish(platform.getId(), channelListForEvent, CatalogEvent.DEL);
eventPublisher.catalogEventPublish(platform, channelListForEvent, CatalogEvent.DEL);
} catch (Exception e) {
log.warn("[移除关联通道] 发送失败,数量:{}", channelList.size(), e);
}
@@ -537,7 +551,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
// 发送消息
try {
// 发送catalog
eventPublisher.catalogEventPublish(platform.getId(), channelListForEvent, CatalogEvent.ADD);
eventPublisher.catalogEventPublish(platform, channelListForEvent, CatalogEvent.ADD);
} catch (Exception e) {
log.warn("[移除关联通道] 发送失败,数量:{}", channelList.size(), e);
}
@@ -567,7 +581,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
// 发送消息
try {
// 发送catalog
eventPublisher.catalogEventPublish(platform.getId(), channelListForEvent, CatalogEvent.ADD);
eventPublisher.catalogEventPublish(platform, channelListForEvent, CatalogEvent.ADD);
} catch (Exception e) {
log.warn("[移除关联通道] 发送失败,数量:{}", channelList.size(), e);
}