panlinlin
2021-04-11 a004a978fa54779425d7498b4737c970b8c71f7b
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java
File was renamed from src/main/java/com/genersoft/iot/vmp/vmanager/ptz/PtzController.java
@@ -1,5 +1,9 @@
package com.genersoft.iot.vmp.vmanager.ptz;
package com.genersoft.iot.vmp.vmanager.gb28181.ptz;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -17,22 +21,23 @@
import com.genersoft.iot.vmp.gb28181.utils.XmlUtil;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
@Api(tags = "云台控制")
@CrossOrigin
@RestController
@RequestMapping("/api")
@RequestMapping("/api/ptz")
public class PtzController {
   private final static Logger logger = LoggerFactory.getLogger(PtzController.class);
   @Autowired
   private SIPCommander cmder;
   @Autowired
   private IVideoManagerStorager storager;
   @Autowired
   private DeferredResultHolder resultHolder;
   /***
    * 云台控制
    * @param deviceId 设备id
@@ -43,49 +48,54 @@
    * @param zoomSpeed       缩放速度
    * @return String 控制结果
    */
   @PostMapping("/ptz/{deviceId}/{channelId}")
   @ApiOperation("云台控制")
   @ApiImplicitParams({
         @ApiImplicitParam(name = "deviceId", value = "设备ID", dataTypeClass = String.class),
         @ApiImplicitParam(name = "channelId", value = "通道ID", dataTypeClass = String.class),
         @ApiImplicitParam(name = "cmdCode", value = "指令码", dataTypeClass = Integer.class),
         @ApiImplicitParam(name = "horizonSpeed", value = "水平速度", dataTypeClass = Integer.class),
         @ApiImplicitParam(name = "verticalSpeed", value = "垂直速度", dataTypeClass = Integer.class),
         @ApiImplicitParam(name = "zoomSpeed", value = "缩放速度", dataTypeClass = Integer.class),
   })
   @PostMapping("/control/{deviceId}/{channelId}")
   public ResponseEntity<String> ptz(@PathVariable String deviceId,@PathVariable String channelId,int cmdCode, int horizonSpeed, int verticalSpeed, int zoomSpeed){
      if (logger.isDebugEnabled()) {
         logger.debug(String.format("设备云台控制 API调用,deviceId:%s ,channelId:%s ,cmdCode:%d ,horizonSpeed:%d ,verticalSpeed:%d ,zoomSpeed:%d",deviceId, channelId, cmdCode, horizonSpeed, verticalSpeed, zoomSpeed));
      }
      Device device = storager.queryVideoDevice(deviceId);
      cmder.frontEndCmd(device, channelId, cmdCode, horizonSpeed, verticalSpeed, zoomSpeed);
      return new ResponseEntity<String>("success",HttpStatus.OK);
   }
   /**
    * 通用前端控制命令API接口
    *
    * @param deviceId
    * @param channelId
    * @param cmdCode
    * @param parameter1
    * @param parameter2
    * @param combindCode2
    * @return
    */
   @PostMapping("/frontEndCommand/{deviceId}/{channelId}")
   @ApiOperation("通用前端控制命令")
   @ApiImplicitParams({
         @ApiImplicitParam(name = "deviceId", value = "设备ID", dataTypeClass = String.class),
         @ApiImplicitParam(name = "channelId", value = "通道ID", dataTypeClass = String.class),
         @ApiImplicitParam(name = "cmdCode", value = "指令码", dataTypeClass = Integer.class),
         @ApiImplicitParam(name = "parameter1", value = "数据一", dataTypeClass = Integer.class),
         @ApiImplicitParam(name = "parameter2", value = "数据二", dataTypeClass = Integer.class),
         @ApiImplicitParam(name = "combindCode2", value = "组合码二", dataTypeClass = Integer.class),
   })
   @PostMapping("/front_end_command/{deviceId}/{channelId}")
   public ResponseEntity<String> frontEndCommand(@PathVariable String deviceId,@PathVariable String channelId,int cmdCode, int parameter1, int parameter2, int combindCode2){
      if (logger.isDebugEnabled()) {
         logger.debug(String.format("设备云台控制 API调用,deviceId:%s ,channelId:%s ,cmdCode:%d parameter1:%d parameter2:%d",deviceId, channelId, cmdCode, parameter1, parameter2));
      }
      Device device = storager.queryVideoDevice(deviceId);
      cmder.frontEndCmd(device, channelId, cmdCode, parameter1, parameter2, combindCode2);
      return new ResponseEntity<String>("success",HttpStatus.OK);
   }
   /**
    * 预置位查询命令API接口
    *
    * @param deviceId
    * @param channelId
    * @return
    */
   @GetMapping("/presetQuery/{deviceId}/{channelId}")
   @ApiOperation("预置位查询")
   @ApiImplicitParams({
            @ApiImplicitParam(name = "deviceId", value = "设备ID", dataTypeClass = String.class),
            @ApiImplicitParam(name = "channelId", value = "通道ID", dataTypeClass = String.class),
   })
   @GetMapping("/preset/query/{deviceId}/{channelId}")
   public DeferredResult<ResponseEntity<String>> presetQueryApi(@PathVariable String deviceId, @PathVariable String channelId) {
      if (logger.isDebugEnabled()) {
         logger.debug("设备预置位查询API调用");