فهرست منبع

add 媒体设备云台控制

18339543638 3 سال پیش
والد
کامیت
93d0ad2993

+ 4 - 3
jetlinks-manager/media-manager/src/main/java/org/jetlinks/community/media/controller/MediaDeviceController.java

@@ -196,14 +196,15 @@ public class MediaDeviceController implements ReactiveServiceCrudController<Medi
      * @return String 控制结果
      */
     @Operation(summary = "云台控制")
-    @PostMapping("/{deviceId}/{channelId}/_ptz/{command}/{speed}")
-    public Mono<Void> ptz(@PathVariable("deviceId") String deviceId, @PathVariable("channelId") String channelId, @PathVariable("command") String command, @PathVariable("speed") int speed){
+    @PostMapping({"/{deviceId}/{channelId}/_ptz/{command}/{speed}","/{deviceId}/{channelId}/_ptz/{command}"})
+    public Mono<Void> ptz(@PathVariable("deviceId") String deviceId, @PathVariable("channelId") String channelId, @PathVariable(value = "command",required = false) String command, @PathVariable(value = "speed",required = false) Integer speedParameter){
        return  mediaDeviceService.findById(deviceId)
            .switchIfEmpty(Mono.error(new BusinessException("设备已注销")))
             .flatMap(device->{
                 if(device.getState()==DeviceState.offline){
                     return Mono.error(new BusinessException("设备已下线"));
                 }
+                Integer speed=Optional.ofNullable(speedParameter).orElse(0);
                 int cmdCode = 0;
                 //orizonSpeed	水平移动速度
                 int horizonSpeed=0;
@@ -211,7 +212,7 @@ public class MediaDeviceController implements ReactiveServiceCrudController<Medi
                 int verticalSpeed=0;
                 //zoomSpeed	    缩放速度
                 int zoomSpeed=0;
-                switch (command){
+                switch (command.toLowerCase()){
                     case "left":
                         cmdCode = 2;
                         horizonSpeed=speed;