From 1983b8b0a705995665dffadf709afd03239c5950 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期二, 22 十一月 2022 12:55:29 +0800
Subject: [PATCH] 国标级联->选择通道支持移除目前下所有以及全部添加到目录下

---
 src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java |   31 ++++++++++++++++++++++++++-----
 1 files changed, 26 insertions(+), 5 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 3bd8aec..40b65c3 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
@@ -10,8 +10,7 @@
 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.service.IPlatformService;
+import com.genersoft.iot.vmp.service.*;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import com.genersoft.iot.vmp.utils.DateUtil;
@@ -71,6 +70,12 @@
 
 	@Autowired
 	private IPlatformService platformService;
+
+	@Autowired
+	private IDeviceChannelService deviceChannelService;
+
+	@Autowired
+	private IGbStreamService gbStreamService;
 
     /**
      * 鑾峰彇鍥芥爣鏈嶅姟鐨勯厤缃�
@@ -379,7 +384,16 @@
         if (logger.isDebugEnabled()) {
             logger.debug("缁欎笂绾у钩鍙版坊鍔犲浗鏍囬�氶亾API璋冪敤");
         }
-        int result = platformChannelService.updateChannelForGB(param.getPlatformId(), param.getChannelReduces(), param.getCatalogId());
+        int result = 0;
+        if (param.getChannelReduces() == null || param.getChannelReduces().size() == 0) {
+            if (param.isAll()) {
+                logger.info("[鍥芥爣绾ц仈]娣诲姞鎵�鏈夐�氶亾鍒颁笂绾у钩鍙帮紝 {}", param.getPlatformId());
+                List<ChannelReduce> allChannelForDevice = deviceChannelService.queryAllChannelList(param.getPlatformId());
+                result = platformChannelService.updateChannelForGB(param.getPlatformId(), allChannelForDevice, param.getCatalogId());
+            }
+        }else {
+            result = platformChannelService.updateChannelForGB(param.getPlatformId(), param.getChannelReduces(), param.getCatalogId());
+        }
         if (result <= 0) {
             throw new ControllerException(ErrorCode.ERROR100);
         }
@@ -399,8 +413,15 @@
         if (logger.isDebugEnabled()) {
             logger.debug("缁欎笂绾у钩鍙板垹闄ゅ浗鏍囬�氶亾API璋冪敤");
         }
-        int result = storager.delChannelForGB(param.getPlatformId(), param.getChannelReduces());
-
+        int result = 0;
+        if (param.getChannelReduces() == null || param.getChannelReduces().size() == 0) {
+            if (param.isAll()) {
+                logger.info("[鍥芥爣绾ц仈]绉婚櫎鎵�鏈夐�氶亾锛屼笂绾у钩鍙帮紝 {}", param.getPlatformId());
+                result = platformChannelService.delAllChannelForGB(param.getPlatformId(), param.getCatalogId());
+            }
+        }else {
+            result = storager.delChannelForGB(param.getPlatformId(), param.getChannelReduces());
+        }
         if (result <= 0) {
             throw new ControllerException(ErrorCode.ERROR100);
         }

--
Gitblit v1.8.0