From 0688bb91d25935b28d06283c8a40d71a22efd2e8 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Mon, 29 Jan 2024 20:48:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vmp/common/enums/DeviceControlType.java | 2 +- .../gb28181/GB28181ResourceServiceImpl.java | 21 ++++++++++++ .../cmd/DeviceControlQueryMessageHandler.java | 33 ++----------------- .../iot/vmp/service/IResourceService.java | 5 +++ 4 files changed, 30 insertions(+), 31 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/common/enums/DeviceControlType.java b/src/main/java/com/genersoft/iot/vmp/common/enums/DeviceControlType.java index 02202d89..ec38b7f9 100644 --- a/src/main/java/com/genersoft/iot/vmp/common/enums/DeviceControlType.java +++ b/src/main/java/com/genersoft/iot/vmp/common/enums/DeviceControlType.java @@ -31,7 +31,7 @@ public enum DeviceControlType { /** * 告警控制 */ - ALARM("AlarmCmd","告警控制"), + ALARM("AlarmCmd","报警复位"), /** * 强制关键帧 */ diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/GB28181ResourceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/GB28181ResourceServiceImpl.java index ec19918c..013af5a7 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/GB28181ResourceServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/GB28181ResourceServiceImpl.java @@ -123,6 +123,27 @@ public class GB28181ResourceServiceImpl implements IResourceService { return false; } + @Override + public void resetAlarm(CommonGbChannel commonGbChannel, Integer alarmMethod, Integer alarmType) { + CheckCommonGbChannelResult checkResult = checkCommonGbChannel(commonGbChannel); + + if (checkResult.errorMsg != null) { + logger.warn("[资源类-国标28181] 报警处理失败: {}", checkResult.errorMsg); + return; + } + if (checkResult.device == null || checkResult.channel == null) { + logger.warn("[资源类-国标28181] 报警处理失败: 设备获取失败"); + return; + } + try { + commander.alarmCmd(checkResult.device, alarmMethod, alarmType, + errorResult -> onError(request, errorResult), + okResult -> onOk(request, okResult)); + } catch (InvalidArgumentException | SipException | ParseException e) { + logger.error("[命令发送失败]: ", e); + } + } + @Override public void streamOffline(String app, String streamId) { // TODO diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java index b21fa345..2cb3c9b7 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java @@ -258,7 +258,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent } /** - * 处理告警消息*** + * 处理告警消息 */ private void handleAlarmCmd(CommonGbChannel commonGbChannel, Element rootElement, SIPRequest request) { IResourceService resourceService = resourceServiceMap.get(commonGbChannel.getType()); @@ -289,36 +289,9 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent } } - logger.info("\r\n[报警]: alarmMethod: {} alarmType: {}", alarmMethod, alarmType); + logger.info("\r\n[报警复位]: alarmMethod: {} alarmType: {}", alarmMethod, alarmType); - resourceService.ptzControl(commonGbChannel, ptzCommand); - - - - //告警方法 - Integer alarmMethod = null; - //告警类型 - Integer alarmType = null; - List info = rootElement.elements("Info"); - if (info != null) { - for (Element element : info) { - String alarmMethodStr = getText(element, "AlarmMethod"); - if (alarmMethodStr != null) { - alarmMethod = Integer.parseInt(alarmMethodStr); - } - String alarmTypeStr = getText(element, "AlarmType"); - if (alarmTypeStr != null) { - alarmType = Integer.parseInt(alarmTypeStr); - } - } - } - try { - cmder.alarmCmd(device, alarmMethod, alarmType, - errorResult -> onError(request, errorResult), - okResult -> onOk(request, okResult)); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 告警消息: {}", e.getMessage()); - } + resourceService.resetAlarm(commonGbChannel, alarmMethod, alarmType); } /** diff --git a/src/main/java/com/genersoft/iot/vmp/service/IResourceService.java b/src/main/java/com/genersoft/iot/vmp/service/IResourceService.java index 365ecc2b..7ea10305 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IResourceService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IResourceService.java @@ -46,4 +46,9 @@ public interface IResourceService { * 录像下载 */ void startDownload(CommonGbChannel channel, Long startTime, Long stopTime, Integer downloadSpeed, IResourcePlayCallback playCallback); + + /** + * 报警复位 + */ + void resetAlarm(CommonGbChannel commonGbChannel, Integer alarmMethod, Integer alarmType); }