From 95d367702a208914ce797122377a1d4ad2ab4c23 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 19 Oct 2022 16:25:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=90=AF=E5=8A=A8=E6=97=B6?= =?UTF-8?q?=E6=B8=85=E7=90=86redis=E4=B8=AD=E9=94=99=E8=AF=AFzlm=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java | 1 + .../com/genersoft/iot/vmp/media/zlm/ZLMRunner.java | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java index 08922436..7a519171 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java @@ -298,6 +298,7 @@ public class XmlUtil { }else { deviceChannel.setParentId(parentId); } + // 兼容设备通道信息中自己为自己父节点的情况 if (deviceChannel.getParentId().equals(deviceChannel.getChannelId())) { deviceChannel.setParentId(null); } diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java index 3dfb1678..195315ab 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java @@ -80,6 +80,7 @@ public class ZLMRunner implements CommandLineRunner { // 获取所有的zlm, 并开启主动连接 List all = mediaServerService.getAllFromDatabase(); + Map allMap = new HashMap<>(); mediaServerService.updateVmServer(all); if (all.size() == 0) { all.add(mediaConfig.getMediaSerItem()); @@ -90,6 +91,7 @@ public class ZLMRunner implements CommandLineRunner { } startGetMedia.put(mediaServerItem.getId(), true); connectZlmServer(mediaServerItem); + allMap.put(mediaServerItem.getId(), mediaServerItem); } String taskKey = "zlm-connect-timeout"; dynamicTask.startDelay(taskKey, ()->{ @@ -100,7 +102,13 @@ public class ZLMRunner implements CommandLineRunner { } startGetMedia = null; } - // TODO 清理数据库中与redis不匹配的zlm + // 获取redis中所有的zlm + List allInRedis = mediaServerService.getAll(); + for (MediaServerItem mediaServerItem : allInRedis) { + if (!allMap.containsKey(mediaServerItem.getId())) { + mediaServerService.delete(mediaServerItem.getId()); + } + } }, 60 * 1000 ); }