From 50c2a5a72810add4fb9d6000802dcf36399a3b68 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期五, 04 三月 2022 15:36:16 +0800
Subject: [PATCH] Revert "修复回放失败出现脏数据的问题以及添加拉流代理判断错误的问题"

---
 src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java |   35 ++++++++++++++++++++++-------------
 1 files changed, 22 insertions(+), 13 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 91ebd5d..9af6e77 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
@@ -1,5 +1,6 @@
 package com.genersoft.iot.vmp.storager.impl;
 
+import com.genersoft.iot.vmp.common.StreamInfo;
 import com.genersoft.iot.vmp.conf.SipConfig;
 import com.genersoft.iot.vmp.gb28181.bean.*;
 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
@@ -157,7 +158,10 @@
 	public synchronized void updateChannel(String deviceId, DeviceChannel channel) {
 		String channelId = channel.getChannelId();
 		channel.setDeviceId(deviceId);
-		channel.setStreamId(streamSession.getStreamId(deviceId, channel.getChannelId()));
+		StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channelId);
+		if (streamInfo != null) {
+			channel.setStreamId(streamInfo.getStream());
+		}
 		String now = this.format.format(System.currentTimeMillis());
 		channel.setUpdateTime(now);
 		DeviceChannel deviceChannel = deviceChannelMapper.queryChannel(deviceId, channelId);
@@ -179,7 +183,10 @@
 			if (channelList.size() == 0) {
 				for (DeviceChannel channel : channels) {
 					channel.setDeviceId(deviceId);
-					channel.setStreamId(streamSession.getStreamId(deviceId, channel.getChannelId()));
+					StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channel.getChannelId());
+					if (streamInfo != null) {
+						channel.setStreamId(streamInfo.getStream());
+					}
 					String now = this.format.format(System.currentTimeMillis());
 					channel.setUpdateTime(now);
 					channel.setCreateTime(now);
@@ -190,9 +197,11 @@
 					channelsInStore.put(deviceChannel.getChannelId(), deviceChannel);
 				}
 				for (DeviceChannel channel : channels) {
-					String channelId = channel.getChannelId();
 					channel.setDeviceId(deviceId);
-					channel.setStreamId(streamSession.getStreamId(deviceId, channel.getChannelId()));
+					StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channel.getChannelId());
+					if (streamInfo != null) {
+						channel.setStreamId(streamInfo.getStream());
+					}
 					String now = this.format.format(System.currentTimeMillis());
 					channel.setUpdateTime(now);
 					if (channelsInStore.get(channel.getChannelId()) != null) {
@@ -608,19 +617,19 @@
 	@Override
 	public int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces, String catalogId) {
 
-		Map<String, ChannelReduce> deviceAndChannels = new HashMap<>();
+		Map<Integer, ChannelReduce> deviceAndChannels = new HashMap<>();
 		for (ChannelReduce channelReduce : channelReduces) {
 			channelReduce.setCatalogId(catalogId);
-			deviceAndChannels.put(channelReduce.getDeviceId() + "_" + channelReduce.getChannelId(), channelReduce);
+			deviceAndChannels.put(channelReduce.getId(), channelReduce);
 		}
-		List<String> deviceAndChannelList = new ArrayList<>(deviceAndChannels.keySet());
+		List<Integer> deviceAndChannelList = new ArrayList<>(deviceAndChannels.keySet());
 		// 鏌ヨ褰撳墠宸茬粡瀛樺湪鐨�
-		List<String> relatedPlatformchannels = platformChannelMapper.findChannelRelatedPlatform(platformId, deviceAndChannelList);
-		if (relatedPlatformchannels != null) {
-			deviceAndChannelList.removeAll(relatedPlatformchannels);
+		List<Integer> channelIds = platformChannelMapper.findChannelRelatedPlatform(platformId, channelReduces);
+		if (deviceAndChannelList != null) {
+			deviceAndChannelList.removeAll(channelIds);
 		}
-		for (String relatedPlatformchannel : relatedPlatformchannels) {
-			deviceAndChannels.remove(relatedPlatformchannel);
+		for (Integer channelId : channelIds) {
+			deviceAndChannels.remove(channelId);
 		}
 		List<ChannelReduce> channelReducesToAdd = new ArrayList<>(deviceAndChannels.values());
 		// 瀵瑰墿涓嬬殑鏁版嵁杩涜瀛樺偍
@@ -749,7 +758,7 @@
 						return false;
 					}
 				}
-			}else {
+			} else {
 				//浜嬪姟鍥炴粴
 				dataSourceTransactionManager.rollback(transactionStatus);
 				return false;

--
Gitblit v1.8.0