From 1553b39b4547418774ab2bd6da72f75bfd14b972 Mon Sep 17 00:00:00 2001 From: 648540858 <456panlinlin> Date: 星期二, 29 三月 2022 10:04:28 +0800 Subject: [PATCH] 修复级联的国标通道无经纬度问题 --- src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java | 63 +++++++++++++++++++++++-------- 1 files changed, 46 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java index 08f4b26..cd8141f 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java @@ -14,6 +14,7 @@ import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorager; import com.genersoft.iot.vmp.storager.dao.*; +import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo; import com.genersoft.iot.vmp.utils.node.ForestNodeMerger; import com.genersoft.iot.vmp.vmanager.bean.DeviceChannelTree; import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; @@ -41,7 +42,7 @@ @Component public class VideoManagerStoragerImpl implements IVideoManagerStorager { - private Logger logger = LoggerFactory.getLogger(VideoManagerStoragerImpl.class); + private final Logger logger = LoggerFactory.getLogger(VideoManagerStoragerImpl.class); @Autowired EventPublisher eventPublisher; @@ -140,6 +141,7 @@ String now = this.format.format(System.currentTimeMillis()); device.setUpdateTime(now); Device deviceByDeviceId = deviceMapper.getDeviceByDeviceId(device.getDeviceId()); + device.setCharset(device.getCharset().toUpperCase()); if (deviceByDeviceId == null) { device.setCreateTime(now); redisCatchStorage.updateDevice(device); @@ -170,6 +172,7 @@ }else { deviceChannelMapper.update(channel); } + deviceChannelMapper.updateChannelSubCount(deviceId,channel.getParentId()); } @Override @@ -283,7 +286,8 @@ logger.debug("[鐩綍鏌ヨ]鏀跺埌鐨勬暟鎹瓨鍦ㄩ噸澶嶏細 {}" , stringBuilder); } try { - int cleanChannelsResult = deviceChannelMapper.cleanChannelsByDeviceId(deviceId); +// int cleanChannelsResult = deviceChannelMapper.cleanChannelsByDeviceId(deviceId); + int cleanChannelsResult = deviceChannelMapper.cleanChannelsNotInList(deviceId, channels); int limitCount = 300; boolean result = cleanChannelsResult < 0; if (!result && channels.size() > 0) { @@ -540,7 +544,7 @@ if (parentPlatformCatch == null) { // serverGBId 宸插彉鍖� ParentPlatform parentPlatById = platformMapper.getParentPlatById(parentPlatform.getId()); // 浣跨敤鏃х殑鏌ュ嚭缂撳瓨ID - parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatById.getServerGBId()); + parentPlatformCatch = new ParentPlatformCatch(); parentPlatformCatch.setId(parentPlatform.getServerGBId()); redisCatchStorage.delPlatformCatchInfo(parentPlatById.getServerGBId()); } @@ -608,9 +612,9 @@ } @Override - public List<ChannelReduce> queryChannelListInParentPlatform(String platformId) { + public List<DeviceChannelInPlatform> queryChannelListInParentPlatform(String platformId) { - return deviceChannelMapper.queryChannelListInAll(null, null, null, platformId, platformId); + return deviceChannelMapper.queryChannelByPlatformId(platformId); } @Override @@ -660,8 +664,16 @@ @Override public DeviceChannel queryChannelInParentPlatform(String platformId, String channelId) { - DeviceChannel channel = platformChannelMapper.queryChannelInParentPlatform(platformId, channelId); - return channel; + List<DeviceChannel> channels = platformChannelMapper.queryChannelInParentPlatform(platformId, channelId); + if (channels.size() > 1) { + // 鍑虹幇闀垮害澶т簬0鐨勬椂鍊欒偗瀹氭槸鍥芥爣閫氶亾鐨処D閲嶅浜� + logger.warn("鍥芥爣ID瀛樺湪閲嶅锛歿}", channelId); + } + if (channels.size() == 0) { + return null; + }else { + return channels.get(0); + } } @Override @@ -678,8 +690,18 @@ @Override public Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId) { - Device device = platformChannelMapper.queryVideoDeviceByPlatformIdAndChannelId(platformId, channelId); - return device; + List<Device> devices = platformChannelMapper.queryVideoDeviceByPlatformIdAndChannelId(platformId, channelId); + if (devices.size() > 1) { + // 鍑虹幇闀垮害澶т簬0鐨勬椂鍊欒偗瀹氭槸鍥芥爣閫氶亾鐨処D閲嶅浜� + logger.warn("鍥芥爣ID瀛樺湪閲嶅锛歿}", channelId); + } + if (devices.size() == 0) { + return null; + }else { + return devices.get(0); + } + + } /** @@ -716,7 +738,7 @@ try { if (streamProxyMapper.add(streamProxyItem) > 0) { if (!StringUtils.isEmpty(streamProxyItem.getGbId())) { - if (gbStreamMapper.add(streamProxyItem) <= 0) { + if (gbStreamMapper.add(streamProxyItem) < 0) { //浜嬪姟鍥炴粴 dataSourceTransactionManager.rollback(transactionStatus); return false; @@ -751,7 +773,7 @@ try { if (streamProxyMapper.update(streamProxyItem) > 0) { if (!StringUtils.isEmpty(streamProxyItem.getGbId())) { - if (gbStreamMapper.update(streamProxyItem) > 0) { + if (gbStreamMapper.updateByAppAndStream(streamProxyItem) == 0) { //浜嬪姟鍥炴粴 dataSourceTransactionManager.rollback(transactionStatus); return false; @@ -864,12 +886,11 @@ List<ParentPlatform> parentPlatforms = parentPlatformMapper.selectAllAhareAllLiveStream(); if (parentPlatforms.size() > 0) { for (ParentPlatform parentPlatform : parentPlatforms) { - streamPushItem.setCatalogId(parentPlatform.getCatalogId()); - streamPushItem.setPlatformId(parentPlatform.getServerGBId()); - String stream = streamPushItem.getStream(); - StreamProxyItem streamProxyItems = platformGbStreamMapper.selectOne(streamPushItem.getApp(), stream, + StreamProxyItem streamProxyItem = platformGbStreamMapper.selectOne(streamPushItem.getApp(), streamPushItem.getStream(), parentPlatform.getServerGBId()); - if (streamProxyItems == null) { + if (streamProxyItem == null) { + streamPushItem.setCatalogId(parentPlatform.getCatalogId()); + streamPushItem.setPlatformId(parentPlatform.getServerGBId()); platformGbStreamMapper.add(streamPushItem); eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), streamPushItem, CatalogEvent.ADD); } @@ -1062,7 +1083,7 @@ deviceChannel.setParentId(catalog.getParentId()); deviceChannel.setRegisterWay(1); // 琛屾斂鍖哄垝搴旇鏄疍omain鐨勫墠鍏綅 - deviceChannel.setCivilCode(sipConfig.getDomain().substring(0, sipConfig.getDomain().length() - 2)); + deviceChannel.setCivilCode(parentPlatByServerGBId.getDeviceGBId().substring(0,6)); deviceChannel.setModel("live"); deviceChannel.setOwner("wvp-pro"); deviceChannel.setSecrecy("0"); @@ -1081,6 +1102,9 @@ @Override public List<ParentPlatform> queryPlatFormListForStreamWithGBId(String app, String stream, List<String> platforms) { + if (platforms == null || platforms.size() == 0) { + return new ArrayList<>(); + } return platformGbStreamMapper.queryPlatFormListForGBWithGBId(app, stream, platforms); } @@ -1104,4 +1128,9 @@ public PlatformCatalog queryDefaultCatalogInPlatform(String platformId) { return catalogMapper.selectDefaultByPlatFormId(platformId); } + + @Override + public List<ChannelSourceInfo> getChannelSource(String platformId, String gbId) { + return platformMapper.getChannelSource(platformId, gbId); + } } -- Gitblit v1.8.0