Commit 40ece192fe8b7c2df8599a71daeda422083c5a47
1 parent
e5b18760
修复WVP作为下级平台接收设备告警消息后上报上级平台的问题
Showing
5 changed files
with
27 additions
and
28 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/bean/AlarmChannelMessage.java
| 1 | package com.genersoft.iot.vmp.gb28181.bean; | 1 | package com.genersoft.iot.vmp.gb28181.bean; |
| 2 | 2 | ||
| 3 | +import lombok.Data; | ||
| 4 | + | ||
| 3 | /** | 5 | /** |
| 4 | * 通过redis分发报警消息 | 6 | * 通过redis分发报警消息 |
| 5 | */ | 7 | */ |
| 8 | +@Data | ||
| 6 | public class AlarmChannelMessage { | 9 | public class AlarmChannelMessage { |
| 7 | /** | 10 | /** |
| 8 | * 国标编号 | 11 | * 国标编号 |
| 9 | */ | 12 | */ |
| 10 | private String gbId; | 13 | private String gbId; |
| 11 | - | ||
| 12 | /** | 14 | /** |
| 13 | * 报警编号 | 15 | * 报警编号 |
| 14 | */ | 16 | */ |
| 15 | private int alarmSn; | 17 | private int alarmSn; |
| 16 | - | 18 | + /** |
| 19 | + * 告警类型 | ||
| 20 | + */ | ||
| 21 | + private int alarmType; | ||
| 17 | 22 | ||
| 18 | /** | 23 | /** |
| 19 | * 报警描述 | 24 | * 报警描述 |
| 20 | */ | 25 | */ |
| 21 | private String alarmDescription; | 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,4 +37,18 @@ public enum DeviceAlarmMethod { | ||
| 37 | public int getVal() { | 37 | public int getVal() { |
| 38 | return val; | 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,11 +181,13 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme | ||
| 181 | } | 181 | } |
| 182 | } | 182 | } |
| 183 | logger.info("[收到报警通知]内容:{}", JSON.toJSONString(deviceAlarm)); | 183 | logger.info("[收到报警通知]内容:{}", JSON.toJSONString(deviceAlarm)); |
| 184 | - if ("7".equals(deviceAlarm.getAlarmMethod()) ) { | 184 | + if (DeviceAlarmMethod.typeOf(Integer.parseInt(deviceAlarm.getAlarmMethod())) !=null) { |
| 185 | // 发送给平台的报警信息。 发送redis通知 | 185 | // 发送给平台的报警信息。 发送redis通知 |
| 186 | + logger.info("[发送给平台的报警信息]内容:{}", JSONObject.toJSONString(deviceAlarm)); | ||
| 186 | AlarmChannelMessage alarmChannelMessage = new AlarmChannelMessage(); | 187 | AlarmChannelMessage alarmChannelMessage = new AlarmChannelMessage(); |
| 187 | alarmChannelMessage.setAlarmSn(Integer.parseInt(deviceAlarm.getAlarmMethod())); | 188 | alarmChannelMessage.setAlarmSn(Integer.parseInt(deviceAlarm.getAlarmMethod())); |
| 188 | alarmChannelMessage.setAlarmDescription(deviceAlarm.getAlarmDescription()); | 189 | alarmChannelMessage.setAlarmDescription(deviceAlarm.getAlarmDescription()); |
| 190 | + alarmChannelMessage.setAlarmType(Integer.parseInt(deviceAlarm.getAlarmType())); | ||
| 189 | alarmChannelMessage.setGbId(channelId); | 191 | alarmChannelMessage.setGbId(channelId); |
| 190 | redisCatchStorage.sendAlarmMsg(alarmChannelMessage); | 192 | redisCatchStorage.sendAlarmMsg(alarmChannelMessage); |
| 191 | continue; | 193 | continue; |
| @@ -264,6 +266,7 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme | @@ -264,6 +266,7 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme | ||
| 264 | alarmChannelMessage.setAlarmSn(Integer.parseInt(deviceAlarm.getAlarmMethod())); | 266 | alarmChannelMessage.setAlarmSn(Integer.parseInt(deviceAlarm.getAlarmMethod())); |
| 265 | alarmChannelMessage.setAlarmDescription(deviceAlarm.getAlarmDescription()); | 267 | alarmChannelMessage.setAlarmDescription(deviceAlarm.getAlarmDescription()); |
| 266 | alarmChannelMessage.setGbId(channelId); | 268 | alarmChannelMessage.setGbId(channelId); |
| 269 | + alarmChannelMessage.setAlarmType(Integer.parseInt(deviceAlarm.getAlarmType())); | ||
| 267 | redisCatchStorage.sendAlarmMsg(alarmChannelMessage); | 270 | redisCatchStorage.sendAlarmMsg(alarmChannelMessage); |
| 268 | return; | 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,9 +67,9 @@ public class RedisAlarmMsgListener implements MessageListener { | ||
| 67 | deviceAlarm.setChannelId(gbId); | 67 | deviceAlarm.setChannelId(gbId); |
| 68 | deviceAlarm.setAlarmDescription(alarmChannelMessage.getAlarmDescription()); | 68 | deviceAlarm.setAlarmDescription(alarmChannelMessage.getAlarmDescription()); |
| 69 | deviceAlarm.setAlarmMethod("" + alarmChannelMessage.getAlarmSn()); | 69 | deviceAlarm.setAlarmMethod("" + alarmChannelMessage.getAlarmSn()); |
| 70 | + deviceAlarm.setAlarmType("" + alarmChannelMessage.getAlarmType()); | ||
| 70 | deviceAlarm.setAlarmPriority("1"); | 71 | deviceAlarm.setAlarmPriority("1"); |
| 71 | deviceAlarm.setAlarmTime(DateUtil.getNowForISO8601()); | 72 | deviceAlarm.setAlarmTime(DateUtil.getNowForISO8601()); |
| 72 | - deviceAlarm.setAlarmType("1"); | ||
| 73 | deviceAlarm.setLongitude(0); | 73 | deviceAlarm.setLongitude(0); |
| 74 | deviceAlarm.setLatitude(0); | 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,7 +827,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { | ||
| 827 | 827 | ||
| 828 | @Override | 828 | @Override |
| 829 | public void sendAlarmMsg(AlarmChannelMessage msg) { | 829 | public void sendAlarmMsg(AlarmChannelMessage msg) { |
| 830 | - String key = VideoManagerConstants.VM_MSG_SUBSCRIBE_ALARM; | 830 | + String key = VideoManagerConstants.VM_MSG_SUBSCRIBE_ALARM_RECEIVE; |
| 831 | logger.info("[redis发送通知] 报警{}: {}", key, JSON.toJSON(msg)); | 831 | logger.info("[redis发送通知] 报警{}: {}", key, JSON.toJSON(msg)); |
| 832 | RedisUtil.convertAndSend(key, (JSONObject)JSON.toJSON(msg)); | 832 | RedisUtil.convertAndSend(key, (JSONObject)JSON.toJSON(msg)); |
| 833 | } | 833 | } |