From 89244932c6185cd39e9a9f8aa8bf3acf99329335 Mon Sep 17 00:00:00 2001
From: panlinlin <648540858@qq.com>
Date: 星期日, 11 四月 2021 15:00:52 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/wvp-28181-2.0' into wvp-28181-2.0
---
src/main/java/com/genersoft/iot/vmp/vmanager/platform/PlatformController.java | 109 +++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 87 insertions(+), 22 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/platform/PlatformController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/platform/PlatformController.java
index 152fa5d..834c00b 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/platform/PlatformController.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/platform/PlatformController.java
@@ -5,7 +5,10 @@
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.vmanager.platform.bean.ChannelReduce;
+import com.genersoft.iot.vmp.vmanager.platform.bean.UpdateChannelParam;
import com.github.pagehelper.PageInfo;
+import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -15,16 +18,20 @@
import org.springframework.web.bind.annotation.*;
import com.genersoft.iot.vmp.conf.SipConfig;
-
+/**
+ * 绾ц仈骞冲彴绠$悊
+ */
+@Api("绾ц仈骞冲彴绠$悊")
@CrossOrigin
@RestController
-@RequestMapping("/api")
+@RequestMapping("/api/platform")
public class PlatformController {
private final static Logger logger = LoggerFactory.getLogger(PlatformController.class);
@Autowired
private IVideoManagerStorager storager;
+
@Autowired
private IRedisCatchStorage redisCatchStorage;
@@ -34,7 +41,7 @@
@Autowired
private SipConfig sipConfig;
- @GetMapping("/platforms/serverconfig")
+ @GetMapping("/server_config")
public ResponseEntity<JSONObject> serverConfig() {
JSONObject result = new JSONObject();
result.put("deviceIp", sipConfig.getSipIp());
@@ -44,7 +51,7 @@
return new ResponseEntity<>(result, HttpStatus.OK);
}
- @GetMapping("/platforms/{count}/{page}")
+ @GetMapping("/query/{count}/{page}")
public PageInfo<ParentPlatform> platforms(@PathVariable int page, @PathVariable int count){
if (logger.isDebugEnabled()) {
@@ -53,12 +60,12 @@
return storager.queryParentPlatformList(page, count);
}
- @RequestMapping("/platforms/save")
+ @PostMapping("/save")
@ResponseBody
public ResponseEntity<String> savePlatform(@RequestBody ParentPlatform parentPlatform){
if (logger.isDebugEnabled()) {
- logger.debug("鏌ヨ鎵�鏈変笂绾ц澶嘇PI璋冪敤");
+ logger.debug("淇濆瓨涓婄骇骞冲彴淇℃伅API璋冪敤");
}
if (StringUtils.isEmpty(parentPlatform.getName())
||StringUtils.isEmpty(parentPlatform.getServerGBId())
@@ -75,40 +82,51 @@
}
// TODO 妫�鏌ユ槸鍚﹀凡缁忓瓨鍦�,涓旀敞鍐屾垚鍔�, 濡傛灉娉ㄥ唽鎴愬姛,闇�瑕佸厛娉ㄩ攢涔嬪墠鍐�,淇敼骞舵敞鍐�
+ // ParentPlatform parentPlatformOld = storager.queryParentPlatById(parentPlatform.getDeviceGBId());
+ ParentPlatform parentPlatformOld = storager.queryParentPlatById(parentPlatform.getServerGBId());
+
boolean updateResult = storager.updateParentPlatform(parentPlatform);
if (updateResult) {
- commanderForPlatform.register(parentPlatform);
+ // 淇濆瓨鏃跺惎鐢ㄥ氨鍙戦�佹敞鍐�
+ if (parentPlatform.isEnable()) {
+ // 鍙淇濆瓨灏卞彂閫佹敞鍐�
+ commanderForPlatform.register(parentPlatform);
+ } else if (parentPlatformOld != null && parentPlatformOld.isEnable() && !parentPlatform.isEnable()){ // 鍏抽棴鍚敤鏃舵敞閿�
+ commanderForPlatform.unregister(parentPlatform, null, null);
+ }
+
return new ResponseEntity<>("success", HttpStatus.OK);
- }else {
+ } else {
return new ResponseEntity<>("fail", HttpStatus.OK);
}
}
- @RequestMapping("/platforms/delete")
+ @DeleteMapping("/delete/{serverGBId}")
@ResponseBody
- public ResponseEntity<String> deletePlatform(@RequestBody ParentPlatform parentPlatform){
+ public ResponseEntity<String> deletePlatform(@PathVariable String serverGBId){
if (logger.isDebugEnabled()) {
- logger.debug("鏌ヨ鎵�鏈変笂绾ц澶嘇PI璋冪敤");
+ logger.debug("鍒犻櫎涓婄骇骞冲彴API璋冪敤");
}
- if (StringUtils.isEmpty(parentPlatform.getDeviceGBId())
+ if (StringUtils.isEmpty(serverGBId)
){
return new ResponseEntity<>("missing parameters", HttpStatus.BAD_REQUEST);
}
-
- // 鍙戦�佺绾挎秷鎭�,
+ ParentPlatform parentPlatform = storager.queryParentPlatById(serverGBId);
+ if (parentPlatform == null) return new ResponseEntity<>("fail", HttpStatus.OK);
+ // 鍙戦�佺绾挎秷鎭�,鏃犺鏄惁鎴愬姛閮藉垹闄ょ紦瀛�
commanderForPlatform.unregister(parentPlatform, (event -> {
// 娓呯┖redis缂撳瓨
- redisCatchStorage.delPlatformCatchInfo(parentPlatform.getDeviceGBId());
- redisCatchStorage.delPlatformKeepalive(parentPlatform.getDeviceGBId());
- redisCatchStorage.delPlatformRegister(parentPlatform.getDeviceGBId());
+ redisCatchStorage.delPlatformCatchInfo(parentPlatform.getServerGBId());
+ redisCatchStorage.delPlatformKeepalive(parentPlatform.getServerGBId());
+ redisCatchStorage.delPlatformRegister(parentPlatform.getServerGBId());
}), (event -> {
// 娓呯┖redis缂撳瓨
- redisCatchStorage.delPlatformCatchInfo(parentPlatform.getDeviceGBId());
- redisCatchStorage.delPlatformKeepalive(parentPlatform.getDeviceGBId());
- redisCatchStorage.delPlatformRegister(parentPlatform.getDeviceGBId());
+ redisCatchStorage.delPlatformCatchInfo(parentPlatform.getServerGBId());
+ redisCatchStorage.delPlatformKeepalive(parentPlatform.getServerGBId());
+ redisCatchStorage.delPlatformRegister(parentPlatform.getServerGBId());
}));
boolean deleteResult = storager.deleteParentPlatform(parentPlatform);
@@ -121,16 +139,63 @@
}
}
- @RequestMapping("/platforms/exit/{deviceGbId}")
+ @GetMapping("/exit/{deviceGbId}")
@ResponseBody
public ResponseEntity<String> exitPlatform(@PathVariable String deviceGbId){
if (logger.isDebugEnabled()) {
- logger.debug("鏌ヨ鎵�鏈変笂绾ц澶嘇PI璋冪敤");
+ logger.debug("鏌ヨ涓婄骇骞冲彴鏄惁瀛樺湪API璋冪敤锛�" + deviceGbId);
}
ParentPlatform parentPlatform = storager.queryParentPlatById(deviceGbId);
return new ResponseEntity<>(String.valueOf(parentPlatform != null), HttpStatus.OK);
}
+ @GetMapping("/channel_list")
+ @ResponseBody
+ public PageInfo<ChannelReduce> channelList(int page, int count,
+ @RequestParam(required = false) String platformId,
+ @RequestParam(required = false) String query,
+ @RequestParam(required = false) Boolean online,
+ @RequestParam(required = false) Boolean choosed,
+ @RequestParam(required = false) Boolean channelType){
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("鏌ヨ鎵�鏈夋墍鏈夐�氶亾API璋冪敤");
+ }
+ PageInfo<ChannelReduce> channelReduces = null;
+ if (platformId != null ) {
+ channelReduces = storager.queryAllChannelList(page, count, query, online, channelType, platformId, choosed);
+ }else {
+ channelReduces = storager.queryAllChannelList(page, count, query, online, channelType, null, false);
+ }
+
+ return channelReduces;
+ }
+
+
+ @PostMapping("/update_channel_for_gb")
+ @ResponseBody
+ public ResponseEntity<String> updateChannelForGB(@RequestBody UpdateChannelParam param){
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("缁欎笂绾у钩鍙版坊鍔犲浗鏍囬�氶亾API璋冪敤");
+ }
+ int result = storager.updateChannelForGB(param.getPlatformId(), param.getChannelReduces());
+
+ return new ResponseEntity<>(String.valueOf(result > 0), HttpStatus.OK);
+ }
+
+ @DeleteMapping("/del_channel_for_gb")
+ @ResponseBody
+ public ResponseEntity<String> delChannelForGB(@RequestBody UpdateChannelParam param){
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("缁欎笂绾у钩鍙板垹闄ゅ浗鏍囬�氶亾API璋冪敤");
+ }
+ int result = storager.delChannelForGB(param.getPlatformId(), param.getChannelReduces());
+
+ return new ResponseEntity<>(String.valueOf(result > 0), HttpStatus.OK);
+ }
+
}
--
Gitblit v1.8.0