648540858
2022-10-18 1af77ab5f7c11a4b3d59c1989b51b9fca29679ce
src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java
@@ -1,13 +1,19 @@
package com.genersoft.iot.vmp.web.gb28181;
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.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.sip.InvalidArgumentException;
import javax.sip.SipException;
import java.text.ParseException;
/**
 * API兼容:设备控制
@@ -35,7 +41,7 @@
     * @return
     */
    @RequestMapping(value = "/ptz")
    private JSONObject list(String serial,String command,
    private void list(String serial,String command,
                            @RequestParam(required = false)Integer channel,
                            @RequestParam(required = false)String code,
                            @RequestParam(required = false)Integer speed){
@@ -48,9 +54,7 @@
        if (speed == null) {speed = 0;}
        Device device = storager.queryVideoDevice(serial);
        if (device == null) {
            JSONObject result = new JSONObject();
            result.put("error","device[ " + serial + " ]未找到");
            return result;
            throw new ControllerException(ErrorCode.ERROR100.getCode(), "device[ " + serial + " ]未找到");
        }
        int cmdCode = 0;
        switch (command){
@@ -91,7 +95,11 @@
                break;
        }
        // 默认值 50
        cmder.frontEndCmd(device, code, cmdCode, speed, speed, speed);
        return null;
        try {
            cmder.frontEndCmd(device, code, cmdCode, speed, speed, speed);
        } catch (SipException | InvalidArgumentException | ParseException e) {
            logger.error("[命令发送失败] 云台控制: {}", e.getMessage());
            throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
        }
    }
}