From e752dbd1a7fdfbb2063c59470b41a8e5dd546c3d Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 16 Mar 2022 10:12:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=A8=E6=B5=81=E5=85=B3?= =?UTF-8?q?=E8=81=94=E5=B9=B3=E5=8F=B0=E7=9A=84bug=20again?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/gb28181/bean/SubscribeHolder.java | 5 +++++ .../iot/vmp/media/zlm/ZLMMediaListManager.java | 15 +++++++++------ .../iot/vmp/storager/dao/GbStreamMapper.java | 13 +++++++++++++ .../storager/impl/VideoManagerStoragerImpl.java | 2 +- .../gb28181/platform/PlatformController.java | 3 ++- 5 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java index 287c2a0a..62a45d5a 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java @@ -46,4 +46,9 @@ public class SubscribeHolder { } return platforms; } + + public void removeAllSubscribe(String platformId) { + mobilePositionMap.remove(platformId); + catalogMap.remove(platformId); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java index a4f7815e..fa4aa35f 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java @@ -128,7 +128,7 @@ public class ZLMMediaListManager { if (gbStreams.size() > 0) { for (GbStream gbStream : gbStreams) { // 出现使用相同国标Id的视频流时,使用新流替换旧流, - if (queryKey != null) { + if (queryKey != null && gbStream.getApp().equals(mediaItem.getApp())) { Matcher matcherForStream = pattern.matcher(gbStream.getStream()); String queryKeyForStream = null; if (matcherForStream.find()) { //此处find()每次被调用后,会偏移到下一个匹配 @@ -144,12 +144,15 @@ public class ZLMMediaListManager { } } } - StreamProxyItem streamProxyItem = gbStreamMapper.selectOne(transform.getApp(), transform.getStream()); - if (streamProxyItem != null) { - transform.setGbStreamId(streamProxyItem.getGbStreamId()); - transform.setPlatformId(streamProxyItem.getPlatformId()); - transform.setCatalogId(streamProxyItem.getCatalogId()); + // StreamProxyItem streamProxyItem = gbStreamMapper.selectOne(transform.getApp(), transform.getStream()); + List gbStreamList = gbStreamMapper.selectByGBId(transform.getGbId()); + if (gbStreamList != null && gbStreamList.size() == 1) { + transform.setGbStreamId(gbStreamList.get(0).getGbStreamId()); + transform.setPlatformId(gbStreamList.get(0).getPlatformId()); + transform.setCatalogId(gbStreamList.get(0).getCatalogId()); + transform.setGbId(gbStreamList.get(0).getGbId()); gbStreamMapper.update(transform); + streamPushMapper.del(gbStreamList.get(0).getApp(), gbStreamList.get(0).getStream()); }else { transform.setCreateStamp(System.currentTimeMillis()); gbStreamMapper.add(transform); diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java index b430ebb0..4ed0a0c2 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java @@ -33,6 +33,19 @@ public interface GbStreamMapper { "mediaServerId=#{mediaServerId}," + "status=${status} " + "WHERE app=#{app} AND stream=#{stream}") + int updateByallAndStream(GbStream gbStream); + + @Update("UPDATE gb_stream " + + "SET app=#{app}," + + "stream=#{stream}," + + "gbId=#{gbId}," + + "name=#{name}," + + "streamType=#{streamType}," + + "longitude=#{longitude}, " + + "latitude=#{latitude}," + + "mediaServerId=#{mediaServerId}," + + "status=${status} " + + "WHERE gbStreamId=#{gbStreamId}") int update(GbStream gbStream); @Delete("DELETE FROM gb_stream WHERE app=#{app} AND stream=#{stream}") 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 e1ccf9a2..158a163e 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 @@ -772,7 +772,7 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { try { if (streamProxyMapper.update(streamProxyItem) > 0) { if (!StringUtils.isEmpty(streamProxyItem.getGbId())) { - if (gbStreamMapper.update(streamProxyItem) > 0) { + if (gbStreamMapper.updateByallAndStream(streamProxyItem) > 0) { //事务回滚 dataSourceTransactionManager.rollback(transactionStatus); return false; diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java index c3435fd1..878e77c5 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java @@ -305,6 +305,8 @@ public class PlatformController { // 停止发送位置订阅定时任务 String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() + "_MobilePosition_" + parentPlatform.getServerGBId(); dynamicTask.stop(key); + // 删除缓存的订阅信息 + subscribeHolder.removeAllSubscribe(parentPlatform.getServerGBId()); if (deleteResult) { return new ResponseEntity<>("success", HttpStatus.OK); } else { @@ -341,7 +343,6 @@ public class PlatformController { * @param platformId 上级平台ID * @param query 查询内容 * @param online 是否在线 - * @param choosed 是否已选中 * @param channelType 通道类型 * @return */