Commit 40ece192fe8b7c2df8599a71daeda422083c5a47

Authored by gaofw189
1 parent e5b18760

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

src/main/java/com/genersoft/iot/vmp/gb28181/bean/AlarmChannelMessage.java
1 1 package com.genersoft.iot.vmp.gb28181.bean;
2 2  
  3 +import lombok.Data;
  4 +
3 5 /**
4 6 * 通过redis分发报警消息
5 7 */
  8 +@Data
6 9 public class AlarmChannelMessage {
7 10 /**
8 11 * 国标编号
9 12 */
10 13 private String gbId;
11   -
12 14 /**
13 15 * 报警编号
14 16 */
15 17 private int alarmSn;
16   -
  18 + /**
  19 + * 告警类型
  20 + */
  21 + private int alarmType;
17 22  
18 23 /**
19 24 * 报警描述
20 25 */
21 26 private String alarmDescription;
22 27  
23   - public String getGbId() {
24   - return gbId;
25   - }
26   -
27   - public void setGbId(String gbId) {
28   - this.gbId = gbId;
29   - }
30   -
31   - public int getAlarmSn() {
32   - return alarmSn;
33   - }
34   -
35   - public void setAlarmSn(int alarmSn) {
36   - this.alarmSn = alarmSn;
37   - }
38   -
39   - public String getAlarmDescription() {
40   - return alarmDescription;
41   - }
42   -
43   - public void setAlarmDescription(String alarmDescription) {
44   - this.alarmDescription = alarmDescription;
45   - }
46 28 }
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceAlarmMethod.java
... ... @@ -37,4 +37,18 @@ public enum DeviceAlarmMethod {
37 37 public int getVal() {
38 38 return val;
39 39 }
  40 +
  41 + /**
  42 + * 查询是否匹配类型
  43 + * @param code
  44 + * @return
  45 + */
  46 + public static DeviceAlarmMethod typeOf(int code) {
  47 + for (DeviceAlarmMethod item : DeviceAlarmMethod.values()) {
  48 + if (code==item.getVal()) {
  49 + return item;
  50 + }
  51 + }
  52 + return null;
  53 + }
40 54 }
... ...
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
181 181 }
182 182 }
183 183 logger.info("[收到报警通知]内容:{}", JSON.toJSONString(deviceAlarm));
184   - if ("7".equals(deviceAlarm.getAlarmMethod()) ) {
  184 + if (DeviceAlarmMethod.typeOf(Integer.parseInt(deviceAlarm.getAlarmMethod())) !=null) {
185 185 // 发送给平台的报警信息。 发送redis通知
  186 + logger.info("[发送给平台的报警信息]内容:{}", JSONObject.toJSONString(deviceAlarm));
186 187 AlarmChannelMessage alarmChannelMessage = new AlarmChannelMessage();
187 188 alarmChannelMessage.setAlarmSn(Integer.parseInt(deviceAlarm.getAlarmMethod()));
188 189 alarmChannelMessage.setAlarmDescription(deviceAlarm.getAlarmDescription());
  190 + alarmChannelMessage.setAlarmType(Integer.parseInt(deviceAlarm.getAlarmType()));
189 191 alarmChannelMessage.setGbId(channelId);
190 192 redisCatchStorage.sendAlarmMsg(alarmChannelMessage);
191 193 continue;
... ... @@ -264,6 +266,7 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme
264 266 alarmChannelMessage.setAlarmSn(Integer.parseInt(deviceAlarm.getAlarmMethod()));
265 267 alarmChannelMessage.setAlarmDescription(deviceAlarm.getAlarmDescription());
266 268 alarmChannelMessage.setGbId(channelId);
  269 + alarmChannelMessage.setAlarmType(Integer.parseInt(deviceAlarm.getAlarmType()));
267 270 redisCatchStorage.sendAlarmMsg(alarmChannelMessage);
268 271 return;
269 272 }
... ...
src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java
... ... @@ -67,9 +67,9 @@ public class RedisAlarmMsgListener implements MessageListener {
67 67 deviceAlarm.setChannelId(gbId);
68 68 deviceAlarm.setAlarmDescription(alarmChannelMessage.getAlarmDescription());
69 69 deviceAlarm.setAlarmMethod("" + alarmChannelMessage.getAlarmSn());
  70 + deviceAlarm.setAlarmType("" + alarmChannelMessage.getAlarmType());
70 71 deviceAlarm.setAlarmPriority("1");
71 72 deviceAlarm.setAlarmTime(DateUtil.getNowForISO8601());
72   - deviceAlarm.setAlarmType("1");
73 73 deviceAlarm.setLongitude(0);
74 74 deviceAlarm.setLatitude(0);
75 75  
... ...
src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
... ... @@ -827,7 +827,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
827 827  
828 828 @Override
829 829 public void sendAlarmMsg(AlarmChannelMessage msg) {
830   - String key = VideoManagerConstants.VM_MSG_SUBSCRIBE_ALARM;
  830 + String key = VideoManagerConstants.VM_MSG_SUBSCRIBE_ALARM_RECEIVE;
831 831 logger.info("[redis发送通知] 报警{}: {}", key, JSON.toJSON(msg));
832 832 RedisUtil.convertAndSend(key, (JSONObject)JSON.toJSON(msg));
833 833 }
... ...