From 67507e64b28469e4548597e5e5bdb0c9b50d45bd Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Fri, 22 Dec 2023 18:09:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=A2=84=E7=BD=AE=E4=BD=8D?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/gb28181/bean/PresetItem.java | 10 ++--- .../vmp/gb28181/session/PresetDataCatch.java | 4 +- .../PresetQueryResponseMessageHandler.java | 4 +- .../vmanager/gb28181/ptz/PtzController.java | 40 +++++++++++++++++++ 4 files changed, 47 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PresetItem.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PresetItem.java index 60acf668..bc6001bd 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PresetItem.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PresetItem.java @@ -2,15 +2,15 @@ package com.genersoft.iot.vmp.gb28181.bean; public class PresetItem { - private int presetID; + private int presetId; private String presetName; - public int getPresetID() { - return presetID; + public int getPresetId() { + return presetId; } - public void setPresetID(int presetID) { - this.presetID = presetID; + public void setPresetId(int presetID) { + this.presetId = presetID; } public String getPresetName() { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/session/PresetDataCatch.java b/src/main/java/com/genersoft/iot/vmp/gb28181/session/PresetDataCatch.java index a1c7ee2b..d5310286 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/session/PresetDataCatch.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/session/PresetDataCatch.java @@ -3,8 +3,6 @@ package com.genersoft.iot.vmp.gb28181.session; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; -import com.genersoft.iot.vmp.service.IDeviceChannelService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -64,7 +62,7 @@ public class PresetDataCatch { } if (!presetItemList.isEmpty()) { for (PresetItem presetItem : presetItemList) { - presetData.getPresetItems().put(presetItem.getPresetID(), presetItem); + presetData.getPresetItems().put(presetItem.getPresetId(), presetItem); } } // presetData.getPresetItems().sort((a, b) ->{ diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/PresetQueryResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/PresetQueryResponseMessageHandler.java index 6d0430d2..3a8427d3 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/PresetQueryResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/PresetQueryResponseMessageHandler.java @@ -1,6 +1,5 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd; -import com.genersoft.iot.vmp.gb28181.bean.PresetQuerySipReq; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.session.PresetDataCatch; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; @@ -8,7 +7,6 @@ import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; -import com.genersoft.iot.vmp.gb28181.utils.SipUtils; import gov.nist.javax.sip.message.SIPRequest; import org.dom4j.DocumentException; import org.dom4j.Element; @@ -118,7 +116,7 @@ public class PresetQueryResponseMessageHandler extends SIPRequestProcessorParent String name = itemOne.getName(); String textTrim = itemOne.getTextTrim(); if ("PresetID".equalsIgnoreCase(name)) { - presetItem.setPresetID(Integer.parseInt(textTrim)); + presetItem.setPresetId(Integer.parseInt(textTrim)); } else { presetItem.setPresetName(textTrim); } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java index 4717146d..6c3e2df3 100755 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java @@ -12,6 +12,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; import com.genersoft.iot.vmp.gb28181.utils.SipUtils; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; +import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; @@ -154,6 +155,9 @@ public class PtzController { logger.debug("设备预置位查询API调用"); } Device device = storager.queryVideoDevice(deviceId); + if (device == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), deviceId + "不存在"); + } int sn = SipUtils.getNewSn(); String msgId = sn + ""; String key = DeferredResultHolder.CALLBACK_CMD_PRESETQUERY + sn; @@ -187,4 +191,40 @@ public class PtzController { } return result; } + @Operation(summary = "预置位控制") + @Parameter(name = "deviceId", description = "设备国标编号", required = true) + @Parameter(name = "channelId", description = "通道国标编号", required = true) + @Parameter(name = "command", description = "控制指令 允许值: set, goto, delete", required = true) + @Parameter(name = "presetId", description = "预置位编号", required = true) + @GetMapping("/preset/control/{deviceId}/{channelId}") + public void presetControlApi(@PathVariable String deviceId, @PathVariable String channelId, + String command, int presetId) { + if (logger.isDebugEnabled()) { + logger.debug("设备预置位控制API调用"); + } + Device device = storager.queryVideoDevice(deviceId); + if (device == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), deviceId + "不存在"); + } + int cmdCode = 0; + switch (command){ + case "set": + cmdCode = 129; + break; + case "goto": + cmdCode = 130; + break; + case "delete": + cmdCode = 131; + break; + default: + break; + } + try { + cmder.frontEndCmd(device, channelId, cmdCode, 0, presetId, 2); + } catch (SipException | InvalidArgumentException | ParseException e) { + logger.error("[命令发送失败] 云台控制: {}", e.getMessage()); + throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); + } + } }