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 ); }