From 28b5cc39d0a2d9939f70b4c980a31d9b27fc1e4c Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期二, 19 七月 2022 14:27:30 +0800
Subject: [PATCH] 修复更新推流状态sql错误

---
 src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java
index ff424a0..8d2278e 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java
@@ -9,8 +9,10 @@
 import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog;
 import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
+import com.genersoft.iot.vmp.service.IPlatformChannelService;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
+import com.genersoft.iot.vmp.utils.DateUtil;
 import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
 import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
 import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.UpdateChannelParam;
@@ -46,6 +48,9 @@
 
     @Autowired
     private IVideoManagerStorage storager;
+
+    @Autowired
+    private IPlatformChannelService platformChannelService;
 
     @Autowired
     private IRedisCatchStorage redisCatchStorage;
@@ -169,6 +174,8 @@
             wvpResult.setMsg("骞冲彴 " + parentPlatform.getServerGBId() + " 宸插瓨鍦�");
             return new ResponseEntity<>(wvpResult, HttpStatus.OK);
         }
+        parentPlatform.setCreateTime(DateUtil.getNow());
+        parentPlatform.setUpdateTime(DateUtil.getNow());
         boolean updateResult = storager.updateParentPlatform(parentPlatform);
 
         if (updateResult) {
@@ -232,7 +239,13 @@
         }
         parentPlatform.setCharacterSet(parentPlatform.getCharacterSet().toUpperCase());
         ParentPlatform parentPlatformOld = storager.queryParentPlatByServerGBId(parentPlatform.getServerGBId());
+        parentPlatform.setUpdateTime(DateUtil.getNow());
+        if (!parentPlatformOld.getTreeType().equals(parentPlatform.getTreeType())) {
+             // 鐩綍缁撴瀯鍙戠敓鍙樺寲锛屾竻绌轰箣鍓嶇殑鍏宠仈鍏崇郴
+             logger.info("淇濆瓨骞冲彴{}鏃跺彂鐜扮洰褰曠粨鏋勫彉鍖栵紝娓呯┖鍏宠仈鍏崇郴", parentPlatform.getDeviceGBId());
+             storager.cleanContentForPlatform(parentPlatform.getServerGBId());
 
+        }
         boolean updateResult = storager.updateParentPlatform(parentPlatform);
 
         if (updateResult) {
@@ -253,6 +266,8 @@
                 }
             } else if (parentPlatformOld != null && parentPlatformOld.isEnable() && !parentPlatform.isEnable()) { // 鍏抽棴鍚敤鏃舵敞閿�
                 commanderForPlatform.unregister(parentPlatformOld, null, null);
+                // 鍋滄璁㈤槄鐩稿叧鐨勫畾鏃朵换鍔�
+                subscribeHolder.removeAllSubscribe(parentPlatform.getServerGBId());
             }
             wvpResult.setCode(0);
             wvpResult.setMsg("success");
@@ -286,7 +301,9 @@
             return new ResponseEntity<>("missing parameters", HttpStatus.BAD_REQUEST);
         }
         ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(serverGBId);
-        if (parentPlatform == null) return new ResponseEntity<>("fail", HttpStatus.OK);
+        if (parentPlatform == null) {
+            return new ResponseEntity<>("fail", HttpStatus.OK);
+        }
         // 鍙戦�佺绾挎秷鎭�,鏃犺鏄惁鎴愬姛閮藉垹闄ょ紦瀛�
         commanderForPlatform.unregister(parentPlatform, (event -> {
             // 娓呯┖redis缂撳瓨
@@ -400,7 +417,7 @@
         if (logger.isDebugEnabled()) {
             logger.debug("缁欎笂绾у钩鍙版坊鍔犲浗鏍囬�氶亾API璋冪敤");
         }
-        int result = storager.updateChannelForGB(param.getPlatformId(), param.getChannelReduces(), param.getCatalogId());
+        int result = platformChannelService.updateChannelForGB(param.getPlatformId(), param.getChannelReduces(), param.getCatalogId());
 
         return new ResponseEntity<>(String.valueOf(result > 0), HttpStatus.OK);
     }
@@ -479,7 +496,6 @@
         }
         PlatformCatalog platformCatalogInStore = storager.getCatalog(platformCatalog.getId());
         WVPResult<List<PlatformCatalog>> result = new WVPResult<>();
-
 
         if (platformCatalogInStore != null) {
             result.setCode(-1);

--
Gitblit v1.8.0