From 76d8aa5377d3f60500f97200be99f31c0c385203 Mon Sep 17 00:00:00 2001 From: Lawrence <1934378145@qq.com> Date: Sat, 7 Nov 2020 22:02:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=AE=BE=E5=A4=87=E5=9C=A8?= =?UTF-8?q?=E7=BA=BF=E7=A6=BB=E7=BA=BF=E5=88=A4=E6=96=AD=E7=9A=84=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../redis/VideoManagerRedisStoragerImpl.java | 28 ++++++++++++++++--- 1 file changed, 24 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 7c3a2fc8..765dc82a 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 @@ public class VideoManagerRedisStoragerImpl implements IVideoManagerStorager { PageResult pageResult = new PageResult(); pageResult.setPage(page); pageResult.setCount(count); + Device device = null; if (deviceIds == null || deviceIds.length == 0) { @@ -284,11 +285,21 @@ public class VideoManagerRedisStoragerImpl implements IVideoManagerStorager { 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 @@ public class VideoManagerRedisStoragerImpl implements IVideoManagerStorager { @Override public List queryVideoDeviceList(String[] deviceIds) { List devices = new ArrayList<>(); + Device device = null; if (deviceIds == null || deviceIds.length == 0) { // List deviceIdList = redis.keys(VideoManagerConstants.DEVICE_PREFIX+"*"); List 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;