From b6688baef1092c3776636f8667b590a6f2251909 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期二, 15 十二月 2020 10:41:21 +0800
Subject: [PATCH] Merge pull request #10 from lawrencehj/master

---
 src/main/java/com/genersoft/iot/vmp/storager/redis/VideoManagerRedisStoragerImpl.java |   32 ++++++++++++++++++++++++++++----
 1 files changed, 28 insertions(+), 4 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 7c3a2fc..fe7b8e6 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
@@ -276,6 +276,7 @@
 		PageResult pageResult = new PageResult<Device>();
 		pageResult.setPage(page);
 		pageResult.setCount(count);
+		Device device = null;
 
 		if (deviceIds == null || deviceIds.length == 0) {
 
@@ -284,11 +285,21 @@
 			pageResult.setTotal(deviceIdList.size());
 			int maxCount = (page + 1)* count;
 			for (int i = page * count; i < (pageResult.getTotal() > maxCount ? maxCount : pageResult.getTotal() ); i++) {
-				devices.add((Device)redis.get((String)deviceIdList.get(i)));
+				// devices.add((Device)redis.get((String)deviceIdList.get(i)));
+				device =(Device)redis.get((String)deviceIdList.get(i));
+				if (redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX+device.getDeviceId()).size() == 0){
+					// outline(device.getDeviceId());
+				}
+				devices.add(device);
 			}
 		} else {
 			for (int i = 0; i < deviceIds.length; i++) {
-				devices.add((Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceIds[i]));
+				// devices.add((Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceIds[i]));
+				device = (Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceIds[i]);
+				if (redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX+device.getDeviceId()).size() == 0){
+					// outline(device.getDeviceId());
+				}
+				devices.add(device);
 			}
 		}
 		pageResult.setData(devices);
@@ -304,16 +315,25 @@
 	@Override
 	public List<Device> queryVideoDeviceList(String[] deviceIds) {
 		List<Device> devices = new ArrayList<>();
+		Device device = null;
 
 		if (deviceIds == null || deviceIds.length == 0) {
 //			List<Object> deviceIdList = redis.keys(VideoManagerConstants.DEVICE_PREFIX+"*");
 			List<Object> deviceIdList = redis.scan(VideoManagerConstants.DEVICE_PREFIX+"*");
 			for (int i = 0; i < deviceIdList.size(); i++) {
-				devices.add((Device)redis.get((String)deviceIdList.get(i)));
+				device =(Device)redis.get((String)deviceIdList.get(i));
+				if (redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX+device.getDeviceId()).size() == 0){
+					outline(device.getDeviceId());
+				}
+				devices.add(device);
 			}
 		} else {
 			for (int i = 0; i < deviceIds.length; i++) {
-				devices.add((Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceIds[i]));
+				device = (Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceIds[i]);
+				if (redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX+device.getDeviceId()).size() == 0){
+					outline(device.getDeviceId());
+				}
+				devices.add(device);
 			}
 		}
 		return devices;
@@ -534,6 +554,10 @@
 		List<Object> playLeys = redis.scan(String.format("%S_*_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX,
 				deviceId,
 				code));
+		if (playLeys == null || playLeys.size() == 0) {
+			playLeys = redis.scan(String.format("%S_*_*_%s", VideoManagerConstants.PLAY_BLACK_PREFIX,
+				deviceId));
+		}
 		if (playLeys == null || playLeys.size() == 0) return null;
 		return (StreamInfo)redis.get(playLeys.get(0).toString());
 	}

--
Gitblit v1.8.0