From be42a35ecacf4436eb517ae652befd36b8231182 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期一, 12 十月 2020 10:11:24 +0800
Subject: [PATCH] 修复子节点显示错误

---
 src/main/java/com/genersoft/iot/vmp/storager/redis/VideoManagerRedisStoragerImpl.java |   23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/storager/redis/VideoManagerRedisStoragerImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/redis/VideoManagerRedisStoragerImpl.java
index e1411ab..1acd15c 100644
--- a/src/main/java/com/genersoft/iot/vmp/storager/redis/VideoManagerRedisStoragerImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/storager/redis/VideoManagerRedisStoragerImpl.java
@@ -80,11 +80,10 @@
 		String channelId = channel.getChannelId();
 		HashMap<String, HashSet<String>> channelMap = deviceMap.get(deviceId);
 		if (channelMap == null) return;
-
 		// 浣滀负鐖惰澶�, 纭畾鑷繁鐨勫瓙鑺傜偣鏁�
 		if (channelMap.get(channelId) == null) {
 			channelMap.put(channelId, new HashSet<String>());
-		}else if (channelMap.get(channelId).size()> 0) {
+		}else if (channelMap.get(channelId).size() > 0) {
 			channel.setSubCount(channelMap.get(channelId).size());
 		}
 
@@ -107,7 +106,7 @@
 		if (!StringUtils.isEmpty(parentId)) {
 
 			if (channelMap.get(parentId) == null) {
-				channelMap.put(parentId, new HashSet<>());
+				channelMap.put(parentId, new HashSet<String>());
 			}
 			channelMap.get(parentId).add(channelId);
 
@@ -399,19 +398,29 @@
 				for (int i = 0; i < deviceChannelList.size(); i++) {
 					String key = (String)deviceChannelList.get(i);
 					String[] s = key.split("_");
-					String channelId = s[3];
+					String channelId = s[3].split(":")[0];
 					HashSet<String> subChannel = channelMap.get(channelId);
 					if (subChannel == null) {
 						subChannel = new HashSet<>();
 					}
-					if (s.length > 4) {
-						subChannel.add(s[4]);
+					if (!"null".equals(s[6])) {
+						subChannel.add(s[6]);
 					}
 					channelMap.put(channelId, subChannel);
-					System.out.println();
 				}
 			}
 			deviceMap.put(device.getDeviceId(),channelMap);
 		}
 	}
+
+	@Override
+	public void cleanChannelsForDevice(String deviceId) {
+		List<DeviceChannel> result = new ArrayList<>();
+		List<Object> deviceChannelList = redis.keys(VideoManagerConstants.CACHEKEY_PREFIX + deviceId + "_" + "*");
+		if (deviceChannelList != null && deviceChannelList.size() > 0 ) {
+			for (int i = 0; i < deviceChannelList.size(); i++) {
+				redis.del((String)deviceChannelList.get(i));
+			}
+		}
+	}
 }

--
Gitblit v1.8.0