From 40ece192fe8b7c2df8599a71daeda422083c5a47 Mon Sep 17 00:00:00 2001 From: gaofw189 Date: Fri, 3 Feb 2023 14:35:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DWVP=E4=BD=9C=E4=B8=BA?= =?UTF-8?q?=E4=B8=8B=E7=BA=A7=E5=B9=B3=E5=8F=B0=E6=8E=A5=E6=94=B6=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E5=91=8A=E8=AD=A6=E6=B6=88=E6=81=AF=E5=90=8E=E4=B8=8A?= =?UTF-8?q?=E6=8A=A5=E4=B8=8A=E7=BA=A7=E5=B9=B3=E5=8F=B0=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vmp/gb28181/bean/AlarmChannelMessage.java | 32 ++++--------------- .../vmp/gb28181/bean/DeviceAlarmMethod.java | 14 ++++++++ .../notify/cmd/AlarmNotifyMessageHandler.java | 5 ++- .../redisMsg/RedisAlarmMsgListener.java | 2 +- .../storager/impl/RedisCatchStorageImpl.java | 2 +- 5 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/AlarmChannelMessage.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/AlarmChannelMessage.java index 96d25c4e..b87a3205 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/AlarmChannelMessage.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/AlarmChannelMessage.java @@ -1,46 +1,28 @@ package com.genersoft.iot.vmp.gb28181.bean; +import lombok.Data; + /** * 通过redis分发报警消息 */ +@Data public class AlarmChannelMessage { /** * 国标编号 */ private String gbId; - /** * 报警编号 */ private int alarmSn; - + /** + * 告警类型 + */ + private int alarmType; /** * 报警描述 */ private String alarmDescription; - public String getGbId() { - return gbId; - } - - public void setGbId(String gbId) { - this.gbId = gbId; - } - - public int getAlarmSn() { - return alarmSn; - } - - public void setAlarmSn(int alarmSn) { - this.alarmSn = alarmSn; - } - - public String getAlarmDescription() { - return alarmDescription; - } - - public void setAlarmDescription(String alarmDescription) { - this.alarmDescription = alarmDescription; - } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceAlarmMethod.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceAlarmMethod.java index ff8761ee..d1fb6db6 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceAlarmMethod.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceAlarmMethod.java @@ -37,4 +37,18 @@ public enum DeviceAlarmMethod { public int getVal() { return val; } + + /** + * 查询是否匹配类型 + * @param code + * @return + */ + public static DeviceAlarmMethod typeOf(int code) { + for (DeviceAlarmMethod item : DeviceAlarmMethod.values()) { + if (code==item.getVal()) { + return item; + } + } + return null; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java index 09a5ffc2..0c1d5d6e 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java @@ -181,11 +181,13 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme } } logger.info("[收到报警通知]内容:{}", JSON.toJSONString(deviceAlarm)); - if ("7".equals(deviceAlarm.getAlarmMethod()) ) { + if (DeviceAlarmMethod.typeOf(Integer.parseInt(deviceAlarm.getAlarmMethod())) !=null) { // 发送给平台的报警信息。 发送redis通知 + logger.info("[发送给平台的报警信息]内容:{}", JSONObject.toJSONString(deviceAlarm)); AlarmChannelMessage alarmChannelMessage = new AlarmChannelMessage(); alarmChannelMessage.setAlarmSn(Integer.parseInt(deviceAlarm.getAlarmMethod())); alarmChannelMessage.setAlarmDescription(deviceAlarm.getAlarmDescription()); + alarmChannelMessage.setAlarmType(Integer.parseInt(deviceAlarm.getAlarmType())); alarmChannelMessage.setGbId(channelId); redisCatchStorage.sendAlarmMsg(alarmChannelMessage); continue; @@ -264,6 +266,7 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme alarmChannelMessage.setAlarmSn(Integer.parseInt(deviceAlarm.getAlarmMethod())); alarmChannelMessage.setAlarmDescription(deviceAlarm.getAlarmDescription()); alarmChannelMessage.setGbId(channelId); + alarmChannelMessage.setAlarmType(Integer.parseInt(deviceAlarm.getAlarmType())); redisCatchStorage.sendAlarmMsg(alarmChannelMessage); return; } diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java index 9bb3bbd2..2e18db39 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java +++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java @@ -67,9 +67,9 @@ public class RedisAlarmMsgListener implements MessageListener { deviceAlarm.setChannelId(gbId); deviceAlarm.setAlarmDescription(alarmChannelMessage.getAlarmDescription()); deviceAlarm.setAlarmMethod("" + alarmChannelMessage.getAlarmSn()); + deviceAlarm.setAlarmType("" + alarmChannelMessage.getAlarmType()); deviceAlarm.setAlarmPriority("1"); deviceAlarm.setAlarmTime(DateUtil.getNowForISO8601()); - deviceAlarm.setAlarmType("1"); deviceAlarm.setLongitude(0); deviceAlarm.setLatitude(0); diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java index 8cf5293b..2ab3e09c 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java @@ -827,7 +827,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @Override public void sendAlarmMsg(AlarmChannelMessage msg) { - String key = VideoManagerConstants.VM_MSG_SUBSCRIBE_ALARM; + String key = VideoManagerConstants.VM_MSG_SUBSCRIBE_ALARM_RECEIVE; logger.info("[redis发送通知] 报警{}: {}", key, JSON.toJSON(msg)); RedisUtil.convertAndSend(key, (JSONObject)JSON.toJSON(msg)); }