Просмотр исходного кода

修复WVP作为下级平台接收设备告警消息后上报上级平台的问题

gaofw189 2 лет назад
Родитель
Сommit
40ece192fe

+ 7 - 25
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;
-    }
 }

+ 14 - 0
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;
+    }
 }

+ 4 - 1
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;
         }

+ 1 - 1
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);
 

+ 1 - 1
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));
     }