From 9bf87971e7dc6e0bccc0cf9a2301e9c89f9a0ba6 Mon Sep 17 00:00:00 2001 From: panlinlin <648540858@qq.com> Date: 星期四, 07 一月 2021 14:56:10 +0800 Subject: [PATCH] 完成向上级联->启动时自动注册 --- src/main/java/com/genersoft/iot/vmp/vmanager/ptz/PtzController.java | 50 ++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/ptz/PtzController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/ptz/PtzController.java index bc9792e..4c41e16 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/ptz/PtzController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/ptz/PtzController.java @@ -5,8 +5,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -14,6 +15,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +@CrossOrigin @RestController @RequestMapping("/api") public class PtzController { @@ -27,25 +29,45 @@ private IVideoManagerStorager storager; /*** - * http://localhost:8080/api/ptz/34020000001320000002_34020000001320000008?leftRight=1&upDown=0&inOut=0&moveSpeed=50&zoomSpeed=0 - * @param deviceId - * @param channelId - * @param leftRight - * @param upDown - * @param inOut - * @param moveSpeed - * @param zoomSpeed - * @return + * 浜戝彴鎺у埗 + * @param deviceId 璁惧id + * @param channelId 閫氶亾id + * @param cmdCode 鎸囦护鐮� + * @param horizonSpeed 姘村钩绉诲姩閫熷害 + * @param verticalSpeed 鍨傜洿绉诲姩閫熷害 + * @param zoomSpeed 缂╂斁閫熷害 + * @return String 鎺у埗缁撴灉 */ - @GetMapping("/ptz/{deviceId}_{channelId}") - public ResponseEntity<String> ptz(@PathVariable String deviceId,@PathVariable String channelId,int leftRight, int upDown, int inOut, int moveSpeed, int zoomSpeed){ + @PostMapping("/ptz/{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璋冪敤锛宒eviceId锛�%s 锛宑hannelId锛�%s 锛宭eftRight锛�%d 锛寀pDown锛�%d 锛宨nOut锛�%d 锛宮oveSpeed锛�%d 锛寊oomSpeed锛�%d",deviceId, channelId, leftRight, upDown, inOut, moveSpeed, zoomSpeed)); + logger.debug(String.format("璁惧浜戝彴鎺у埗 API璋冪敤锛宒eviceId锛�%s 锛宑hannelId锛�%s 锛宑mdCode锛�%d 锛宧orizonSpeed锛�%d 锛寁erticalSpeed锛�%d 锛寊oomSpeed锛�%d",deviceId, channelId, cmdCode, horizonSpeed, verticalSpeed, zoomSpeed)); } Device device = storager.queryVideoDevice(deviceId); - cmder.ptzCmd(device, channelId, leftRight, upDown, inOut, moveSpeed, zoomSpeed); + cmder.frontEndCmd(device, channelId, cmdCode, horizonSpeed, verticalSpeed, zoomSpeed); + return new ResponseEntity<String>("success",HttpStatus.OK); + } + // public ResponseEntity<String> ptz(@PathVariable String deviceId,@PathVariable String channelId,int leftRight, int upDown, int inOut, int moveSpeed, int zoomSpeed){ + + // if (logger.isDebugEnabled()) { + // logger.debug(String.format("璁惧浜戝彴鎺у埗 API璋冪敤锛宒eviceId锛�%s 锛宑hannelId锛�%s 锛宭eftRight锛�%d 锛寀pDown锛�%d 锛宨nOut锛�%d 锛宮oveSpeed锛�%d 锛寊oomSpeed锛�%d",deviceId, channelId, leftRight, upDown, inOut, moveSpeed, zoomSpeed)); + // } + // Device device = storager.queryVideoDevice(deviceId); + + // cmder.ptzCmd(device, channelId, leftRight, upDown, inOut, moveSpeed, zoomSpeed); + // return new ResponseEntity<String>("success",HttpStatus.OK); + // } + @PostMapping("/frontEndCommand/{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璋冪敤锛宒eviceId锛�%s 锛宑hannelId锛�%s 锛宑mdCode锛�%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); } } -- Gitblit v1.8.0