Commit 95d367702a208914ce797122377a1d4ad2ab4c23
1 parent
6dbc7a68
增加启动时清理redis中错误zlm数据
Showing
2 changed files
with
10 additions
and
1 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java
| @@ -298,6 +298,7 @@ public class XmlUtil { | @@ -298,6 +298,7 @@ public class XmlUtil { | ||
| 298 | }else { | 298 | }else { |
| 299 | deviceChannel.setParentId(parentId); | 299 | deviceChannel.setParentId(parentId); |
| 300 | } | 300 | } |
| 301 | + // 兼容设备通道信息中自己为自己父节点的情况 | ||
| 301 | if (deviceChannel.getParentId().equals(deviceChannel.getChannelId())) { | 302 | if (deviceChannel.getParentId().equals(deviceChannel.getChannelId())) { |
| 302 | deviceChannel.setParentId(null); | 303 | deviceChannel.setParentId(null); |
| 303 | } | 304 | } |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java
| @@ -80,6 +80,7 @@ public class ZLMRunner implements CommandLineRunner { | @@ -80,6 +80,7 @@ public class ZLMRunner implements CommandLineRunner { | ||
| 80 | 80 | ||
| 81 | // 获取所有的zlm, 并开启主动连接 | 81 | // 获取所有的zlm, 并开启主动连接 |
| 82 | List<MediaServerItem> all = mediaServerService.getAllFromDatabase(); | 82 | List<MediaServerItem> all = mediaServerService.getAllFromDatabase(); |
| 83 | + Map<String, MediaServerItem> allMap = new HashMap<>(); | ||
| 83 | mediaServerService.updateVmServer(all); | 84 | mediaServerService.updateVmServer(all); |
| 84 | if (all.size() == 0) { | 85 | if (all.size() == 0) { |
| 85 | all.add(mediaConfig.getMediaSerItem()); | 86 | all.add(mediaConfig.getMediaSerItem()); |
| @@ -90,6 +91,7 @@ public class ZLMRunner implements CommandLineRunner { | @@ -90,6 +91,7 @@ public class ZLMRunner implements CommandLineRunner { | ||
| 90 | } | 91 | } |
| 91 | startGetMedia.put(mediaServerItem.getId(), true); | 92 | startGetMedia.put(mediaServerItem.getId(), true); |
| 92 | connectZlmServer(mediaServerItem); | 93 | connectZlmServer(mediaServerItem); |
| 94 | + allMap.put(mediaServerItem.getId(), mediaServerItem); | ||
| 93 | } | 95 | } |
| 94 | String taskKey = "zlm-connect-timeout"; | 96 | String taskKey = "zlm-connect-timeout"; |
| 95 | dynamicTask.startDelay(taskKey, ()->{ | 97 | dynamicTask.startDelay(taskKey, ()->{ |
| @@ -100,7 +102,13 @@ public class ZLMRunner implements CommandLineRunner { | @@ -100,7 +102,13 @@ public class ZLMRunner implements CommandLineRunner { | ||
| 100 | } | 102 | } |
| 101 | startGetMedia = null; | 103 | startGetMedia = null; |
| 102 | } | 104 | } |
| 103 | - // TODO 清理数据库中与redis不匹配的zlm | 105 | + // 获取redis中所有的zlm |
| 106 | + List<MediaServerItem> allInRedis = mediaServerService.getAll(); | ||
| 107 | + for (MediaServerItem mediaServerItem : allInRedis) { | ||
| 108 | + if (!allMap.containsKey(mediaServerItem.getId())) { | ||
| 109 | + mediaServerService.delete(mediaServerItem.getId()); | ||
| 110 | + } | ||
| 111 | + } | ||
| 104 | }, 60 * 1000 ); | 112 | }, 60 * 1000 ); |
| 105 | } | 113 | } |
| 106 | 114 |