From 3227dcd082454a1bf85ee623b8d62bbd47d10420 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期二, 28 三月 2023 17:56:43 +0800 Subject: [PATCH] 添加兼容接口预置位添加调用删除,列表查询 --- src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 52 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java index 6f2fe54..286c8d5 100644 --- a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java +++ b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java @@ -1,6 +1,5 @@ package com.genersoft.iot.vmp.web.gb28181; -import com.alibaba.fastjson2.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; @@ -9,7 +8,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; import javax.sip.InvalidArgumentException; import javax.sip.SipException; @@ -102,4 +103,53 @@ throw new ControllerException(ErrorCode.ERROR100.getCode(), "鍛戒护鍙戦�佸け璐�: " + e.getMessage()); } } + + /** + * 璁惧鎺у埗 - 棰勭疆浣嶆帶鍒� + * @param serial 璁惧缂栧彿 + * @param code 閫氶亾缂栧彿,閫氳繃 /api/v1/device/channellist 鑾峰彇鐨� ChannelList.ID, 璇ュ弬鏁板拰 channel 浜岄�変竴浼犻�掑嵆鍙� + * @param channel 閫氶亾搴忓彿, 榛樿鍊�: 1 + * @param command 鎺у埗鎸囦护 鍏佽鍊�: set, goto, remove + * @param preset 棰勭疆浣嶇紪鍙�(1~255) + * @param name 棰勭疆浣嶅悕绉�, command=set 鏃舵湁鏁� + * @return + */ + @RequestMapping(value = "/preset") + private void list(String serial,String command, + @RequestParam(required = false)Integer channel, + @RequestParam(required = false)String code, + @RequestParam(required = false)String name, + @RequestParam(required = false)Integer preset){ + + if (logger.isDebugEnabled()) { + logger.debug("妯℃嫙鎺ュ彛> 棰勭疆浣嶆帶鍒� API璋冪敤锛宒eviceId锛歿} 锛宑hannelId锛歿} 锛宑ommand锛歿} 锛宯ame锛歿} 锛宲reset锛歿} ", + serial, code, command, name, preset); + } + + if (channel == null) {channel = 0;} + Device device = storager.queryVideoDevice(serial); + if (device == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "device[ " + serial + " ]鏈壘鍒�"); + } + int cmdCode = 0; + switch (command){ + case "set": + cmdCode = 129; + break; + case "goto": + cmdCode = 130; + break; + case "remove": + cmdCode = 131; + break; + default: + break; + } + try { + cmder.frontEndCmd(device, code, cmdCode, 0, preset, 0); + } catch (SipException | InvalidArgumentException | ParseException e) { + logger.error("[鍛戒护鍙戦�佸け璐 棰勭疆浣嶆帶鍒�: {}", e.getMessage()); + throw new ControllerException(ErrorCode.ERROR100.getCode(), "鍛戒护鍙戦�佸け璐�: " + e.getMessage()); + } + } } -- Gitblit v1.8.0