From 394c40d8bb29b8e40fc7978ea638f1592b03d617 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期四, 08 九月 2022 16:42:46 +0800
Subject: [PATCH] 修复目录订阅的状态异常
---
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java | 130 +++++++++++++++++-------------------------
1 files changed, 53 insertions(+), 77 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java
index 4db11e3..fe363a6 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java
@@ -8,28 +8,30 @@
package com.genersoft.iot.vmp.vmanager.gb28181.device;
import com.alibaba.fastjson.JSONObject;
+import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
+import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
+import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult;
import java.util.UUID;
-@Api(tags = "鍥芥爣璁惧鎺у埗")
+@Tag(name = "鍥芥爣璁惧鎺у埗")
@CrossOrigin
@RestController
@RequestMapping("/api/device/control")
@@ -51,25 +53,17 @@
*
* @param deviceId 璁惧ID
*/
- @ApiOperation("杩滅▼鍚姩鎺у埗鍛戒护")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "deviceId", value ="璁惧ID", required = true, dataTypeClass = String.class),
- })
+ @Operation(summary = "杩滅▼鍚姩鎺у埗鍛戒护")
+ @Parameter(name = "deviceId", description = "璁惧鍥芥爣缂栧彿", required = true)
@GetMapping("/teleboot/{deviceId}")
- public ResponseEntity<String> teleBootApi(@PathVariable String deviceId) {
+ public void teleBootApi(@PathVariable String deviceId) {
if (logger.isDebugEnabled()) {
logger.debug("璁惧杩滅▼鍚姩API璋冪敤");
}
Device device = storager.queryVideoDevice(deviceId);
- boolean sucsess = cmder.teleBootCmd(device);
- if (sucsess) {
- JSONObject json = new JSONObject();
- json.put("DeviceID", deviceId);
- json.put("Result", "OK");
- return new ResponseEntity<>(json.toJSONString(), HttpStatus.OK);
- } else {
- logger.warn("璁惧杩滅▼鍚姩API璋冪敤澶辫触锛�");
- return new ResponseEntity<String>("璁惧杩滅▼鍚姩API璋冪敤澶辫触锛�", HttpStatus.INTERNAL_SERVER_ERROR);
+ if (!cmder.teleBootCmd(device)) {
+ logger.warn("璁惧杩滅▼鍚姩API璋冪敤澶辫触锛�");
+ throw new ControllerException(ErrorCode.ERROR100);
}
}
@@ -80,13 +74,10 @@
* @param recordCmdStr Record锛氭墜鍔ㄥ綍鍍忥紝StopRecord锛氬仠姝㈡墜鍔ㄥ綍鍍�
* @param channelId 閫氶亾缂栫爜锛堝彲閫夛級
*/
- @ApiOperation("褰曞儚鎺у埗鍛戒护")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "deviceId", value ="璁惧ID", required = true, dataTypeClass = String.class),
- @ApiImplicitParam(name = "channelId", value ="閫氶亾缂栫爜" ,dataTypeClass = String.class),
- @ApiImplicitParam(name = "recordCmdStr", value ="鍛戒护锛� 鍙�夊�硷細Record锛堟墜鍔ㄥ綍鍍忥級锛孲topRecord锛堝仠姝㈡墜鍔ㄥ綍鍍忥級",
- required = true ,dataTypeClass = String.class),
- })
+ @Operation(summary = "褰曞儚鎺у埗")
+ @Parameter(name = "deviceId", description = "璁惧鍥芥爣缂栧彿", required = true)
+ @Parameter(name = "channelId", description = "閫氶亾鍥芥爣缂栧彿", required = true)
+ @Parameter(name = "recordCmdStr", description = "鍛戒护锛� 鍙�夊�硷細Record锛堟墜鍔ㄥ綍鍍忥級锛孲topRecord锛堝仠姝㈡墜鍔ㄥ綍鍍忥級", required = true)
@GetMapping("/record/{deviceId}/{recordCmdStr}")
public DeferredResult<ResponseEntity<String>> recordApi(@PathVariable String deviceId,
@PathVariable String recordCmdStr, String channelId) {
@@ -127,13 +118,10 @@
* @param deviceId 璁惧ID
* @param guardCmdStr SetGuard锛氬竷闃诧紝ResetGuard锛氭挙闃�
*/
- @ApiOperation("甯冮槻/鎾ら槻鍛戒护")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "deviceId", value = "璁惧ID", required = true, dataTypeClass = String.class),
- @ApiImplicitParam(name = "channelId", value ="閫氶亾缂栫爜" ,dataTypeClass = String.class),
- @ApiImplicitParam(name = "guardCmdStr", value ="鍛戒护锛� 鍙�夊�硷細SetGuard锛堝竷闃诧級锛孯esetGuard锛堟挙闃诧級", required = true,
- dataTypeClass = String.class)
- })
+ @Operation(summary = "甯冮槻/鎾ら槻鍛戒护")
+ @Parameter(name = "deviceId", description = "璁惧鍥芥爣缂栧彿", required = true)
+ @Parameter(name = "channelId", description = "閫氶亾鍥芥爣缂栧彿", required = true)
+ @Parameter(name = "guardCmdStr", description = "鍛戒护锛� 鍙�夊�硷細SetGuard锛堝竷闃诧級锛孯esetGuard锛堟挙闃诧級", required = true)
@GetMapping("/guard/{deviceId}/{guardCmdStr}")
public DeferredResult<ResponseEntity<String>> guardApi(@PathVariable String deviceId, String channelId, @PathVariable String guardCmdStr) {
if (logger.isDebugEnabled()) {
@@ -171,13 +159,11 @@
* @param alarmMethod 鎶ヨ鏂瑰紡锛堝彲閫夛級
* @param alarmType 鎶ヨ绫诲瀷锛堝彲閫夛級
*/
- @ApiOperation("鎶ヨ澶嶄綅")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "deviceId", value = "璁惧ID", required = true, dataTypeClass = String.class),
- @ApiImplicitParam(name = "channelId", value ="閫氶亾缂栫爜" ,dataTypeClass = String.class),
- @ApiImplicitParam(name = "alarmMethod", value ="鎶ヨ鏂瑰紡", dataTypeClass = String.class),
- @ApiImplicitParam(name = "alarmType", value ="鎶ヨ绫诲瀷", dataTypeClass = String.class),
- })
+ @Operation(summary = "鎶ヨ澶嶄綅")
+ @Parameter(name = "deviceId", description = "璁惧鍥芥爣缂栧彿", required = true)
+ @Parameter(name = "channelId", description = "閫氶亾鍥芥爣缂栧彿", required = true)
+ @Parameter(name = "alarmMethod", description = "鎶ヨ鏂瑰紡")
+ @Parameter(name = "alarmType", description = "鎶ヨ绫诲瀷")
@GetMapping("/reset_alarm/{deviceId}")
public DeferredResult<ResponseEntity<String>> resetAlarmApi(@PathVariable String deviceId, String channelId,
@RequestParam(required = false) String alarmMethod,
@@ -215,11 +201,9 @@
* @param deviceId 璁惧ID
* @param channelId 閫氶亾ID
*/
- @ApiOperation("寮哄埗鍏抽敭甯�")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "deviceId", value = "璁惧ID", required = true, dataTypeClass = String.class),
- @ApiImplicitParam(name = "channelId", value ="閫氶亾ID", required = true, dataTypeClass = String.class),
- })
+ @Operation(summary = "寮哄埗鍏抽敭甯�")
+ @Parameter(name = "deviceId", description = "璁惧鍥芥爣缂栧彿", required = true)
+ @Parameter(name = "channelId", description = "閫氶亾鍥芥爣缂栧彿")
@GetMapping("/i_frame/{deviceId}")
public ResponseEntity<String> iFrame(@PathVariable String deviceId,
@RequestParam(required = false) String channelId) {
@@ -249,15 +233,12 @@
* @param presetIndex 璋冪敤棰勭疆浣嶇紪鍙凤紙鍙�夛級
* @param channelId 閫氶亾缂栫爜锛堝彲閫夛級
*/
- @ApiOperation("鐪嬪畧浣嶆帶鍒�")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "deviceId", value = "璁惧ID", required = true, dataTypeClass = String.class),
- @ApiImplicitParam(name = "channelId", value ="閫氶亾缂栫爜" ,dataTypeClass = String.class),
- @ApiImplicitParam(name = "enabled", value = "鏄惁寮�鍚湅瀹堜綅 1:寮�鍚�,0:鍏抽棴", required = true, dataTypeClass = String.class),
- @ApiImplicitParam(name = "resetTime", value = "鑷姩褰掍綅鏃堕棿闂撮殧", dataTypeClass = String.class),
- @ApiImplicitParam(name = "presetIndex", value = "璋冪敤棰勭疆浣嶇紪鍙�", dataTypeClass = String.class),
- @ApiImplicitParam(name = "channelId", value ="閫氶亾ID", dataTypeClass = String.class),
- })
+ @Operation(summary = "鐪嬪畧浣嶆帶鍒�")
+ @Parameter(name = "deviceId", description = "璁惧鍥芥爣缂栧彿", required = true)
+ @Parameter(name = "channelId", description = "閫氶亾鍥芥爣缂栧彿", required = true)
+ @Parameter(name = "enabled", description = "鏄惁寮�鍚湅瀹堜綅 1:寮�鍚�,0:鍏抽棴", required = true)
+ @Parameter(name = "presetIndex", description = "璋冪敤棰勭疆浣嶇紪鍙�")
+ @Parameter(name = "resetTime", description = "鑷姩褰掍綅鏃堕棿闂撮殧")
@GetMapping("/home_position/{deviceId}/{enabled}")
public DeferredResult<ResponseEntity<String>> homePositionApi(@PathVariable String deviceId,
@PathVariable String enabled,
@@ -267,7 +248,7 @@
if (logger.isDebugEnabled()) {
logger.debug("鎶ヨ澶嶄綅API璋冪敤");
}
- String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + (StringUtils.isEmpty(channelId) ? deviceId : channelId);
+ String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + (ObjectUtils.isEmpty(channelId) ? deviceId : channelId);
String uuid = UUID.randomUUID().toString();
Device device = storager.queryVideoDevice(deviceId);
cmder.homePositionCmd(device, channelId, enabled, resetTime, presetIndex, event -> {
@@ -307,17 +288,14 @@
* @param lengthy 鎷夋瀹藉害鍍忕礌鍊�
* @return
*/
- @ApiOperation("鎷夋鏀惧ぇ")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "deviceId", value = "璁惧ID", required = true, dataTypeClass = String.class),
- @ApiImplicitParam(name = "channelId", value = "閫氶亾ID", dataTypeClass = String.class),
- @ApiImplicitParam(name = "length", value = "鎾斁绐楀彛闀垮害鍍忕礌鍊�", required = true, dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "width", value = "鎾斁绐楀彛瀹藉害鍍忕礌鍊�", required = true, dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "midpointx", value = "鎷夋涓績鐨勬í杞村潗鏍囧儚绱犲��", required = true, dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "midpointy", value = "鎷夋涓績鐨勭旱杞村潗鏍囧儚绱犲��", required = true, dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "lengthx", value = "鎷夋闀垮害鍍忕礌鍊�", required = true, dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "lengthy", value = "鎷夋瀹藉害鍍忕礌鍊�", required = true, dataTypeClass = Integer.class),
- })
+ @Operation(summary = "鎷夋鏀惧ぇ")
+ @Parameter(name = "deviceId", description = "璁惧鍥芥爣缂栧彿", required = true)
+ @Parameter(name = "channelId", description = "閫氶亾鍥芥爣缂栧彿", required = true)
+ @Parameter(name = "length", description = "鎾斁绐楀彛闀垮害鍍忕礌鍊�", required = true)
+ @Parameter(name = "midpointx", description = "鎷夋涓績鐨勬í杞村潗鏍囧儚绱犲��", required = true)
+ @Parameter(name = "midpointy", description = "鎷夋涓績鐨勭旱杞村潗鏍囧儚绱犲��", required = true)
+ @Parameter(name = "lengthx", description = "鎷夋闀垮害鍍忕礌鍊�", required = true)
+ @Parameter(name = "lengthy", description = "lengthy", required = true)
@GetMapping("drag_zoom/zoom_in")
public ResponseEntity<String> dragZoomIn(@RequestParam String deviceId,
@RequestParam(required = false) String channelId,
@@ -356,17 +334,15 @@
* @param lengthy 鎷夋瀹藉害鍍忕礌鍊�
* @return
*/
- @ApiOperation("鎷夋缂╁皬")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "deviceId", value = "璁惧ID", required = true, dataTypeClass = String.class),
- @ApiImplicitParam(name = "channelId", value = "閫氶亾ID", dataTypeClass = String.class),
- @ApiImplicitParam(name = "length", value = "鎾斁绐楀彛闀垮害鍍忕礌鍊�", required = true, dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "width", value = "鎾斁绐楀彛瀹藉害鍍忕礌鍊�", required = true, dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "midpointx", value = "鎷夋涓績鐨勬í杞村潗鏍囧儚绱犲��", required = true, dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "midpointy", value = "鎷夋涓績鐨勭旱杞村潗鏍囧儚绱犲��", required = true, dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "lengthx", value = "鎷夋闀垮害鍍忕礌鍊�", required = true, dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "lengthy", value = "鎷夋瀹藉害鍍忕礌鍊�", required = true, dataTypeClass = Integer.class),
- })
+ @Operation(summary = "鎷夋鏀惧ぇ")
+ @Parameter(name = "deviceId", description = "璁惧鍥芥爣缂栧彿", required = true)
+ @Parameter(name = "channelId", description = "閫氶亾鍥芥爣缂栧彿")
+ @Parameter(name = "length", description = "鎾斁绐楀彛闀垮害鍍忕礌鍊�", required = true)
+ @Parameter(name = "width", description = "鎷夋涓績鐨勬í杞村潗鏍囧儚绱犲��", required = true)
+ @Parameter(name = "midpointx", description = "鎷夋涓績鐨勬í杞村潗鏍囧儚绱犲��", required = true)
+ @Parameter(name = "midpointy", description = "鎷夋涓績鐨勭旱杞村潗鏍囧儚绱犲��", required = true)
+ @Parameter(name = "lengthx", description = "鎷夋闀垮害鍍忕礌鍊�", required = true)
+ @Parameter(name = "lengthy", description = "鎷夋瀹藉害鍍忕礌鍊�", required = true)
@GetMapping("/drag_zoom/zoom_out")
public ResponseEntity<String> dragZoomOut(@RequestParam String deviceId,
@RequestParam(required = false) String channelId,
--
Gitblit v1.8.0