From 02108af2f4a80fc351f588984a31f6f105a737cc Mon Sep 17 00:00:00 2001 From: Lawrence <1934378145@qq.com> Date: Wed, 20 Jan 2021 20:25:44 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E7=BA=A7=E8=81=94?= =?UTF-8?q?=E9=80=9A=E9=81=93=E9=80=89=E6=8B=A9=E7=BC=96=E8=BE=91=E5=85=B3?= =?UTF-8?q?=E8=81=94=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web_src/src/components/ParentPlatformList.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_src/src/components/ParentPlatformList.vue b/web_src/src/components/ParentPlatformList.vue index 37b8b8f7..298504ba 100644 --- a/web_src/src/components/ParentPlatformList.vue +++ b/web_src/src/components/ParentPlatformList.vue @@ -137,7 +137,7 @@ export default { }); }, chooseChannel: function(platform) { - this.$refs.chooseChannelDialog.openDialog(platform.deviceGBId, ()=>{ + this.$refs.chooseChannelDialog.openDialog(platform.serverGBId, ()=>{ this.initData() }) }, From 867e937805313ff9671ef4eb63909904cf7eac16 Mon Sep 17 00:00:00 2001 From: Lawrence <1934378145@qq.com> Date: Wed, 20 Jan 2021 20:27:25 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=89=8D=E7=AB=AFNotify?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web_src/src/main.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/web_src/src/main.js b/web_src/src/main.js index 6f88c2a9..ae2baeef 100644 --- a/web_src/src/main.js +++ b/web_src/src/main.js @@ -9,10 +9,13 @@ import VueCookies from 'vue-cookies'; import echarts from 'echarts'; import VueClipboard from 'vue-clipboard2' +import { Notification } from 'element-ui'; + Vue.use(VueClipboard) Vue.use(ElementUI); Vue.use(VueCookies); Vue.prototype.$axios = axios; +Vue.prototype.$notify = Notification; axios.defaults.baseURL = (process.env.NODE_ENV === 'development') ? process.env.BASE_API : ""; From 8e9579f2535577c00a953da91da5ce637bef5285 Mon Sep 17 00:00:00 2001 From: Lawrence <1934378145@qq.com> Date: Wed, 20 Jan 2021 20:39:57 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E6=8A=A5=E8=AD=A6=E4=BA=8B=E4=BB=B6=E5=93=8D=E5=BA=94=E3=80=81?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E5=92=8C=E4=BF=A1=E6=81=AF=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/gb28181/bean/DeviceAlarm.java | 10 ++-- .../iot/vmp/gb28181/event/EventPublisher.java | 14 +++++- .../vmp/gb28181/event/alarm/AlarmEvent.java | 26 ++++++++++ .../event/alarm/AlarmEventListener.java | 47 +++++++++++++++++++ .../request/impl/MessageRequestProcessor.java | 40 ++++++++++++---- 5 files changed, 122 insertions(+), 15 deletions(-) create mode 100644 src/main/java/com/genersoft/iot/vmp/gb28181/event/alarm/AlarmEvent.java create mode 100644 src/main/java/com/genersoft/iot/vmp/gb28181/event/alarm/AlarmEventListener.java diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceAlarm.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceAlarm.java index d91a1c7f..35cb6bf4 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceAlarm.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceAlarm.java @@ -11,7 +11,7 @@ public class DeviceAlarm { /** * 报警级别, 1为一级警情, 2为二级警情, 3为三级警情, 4为四级 警情- */ - private String alarmPriorit; + private String alarmPriority; /** * 报警方式 , 1为电话报警, 2为设备报警, 3为短信报警, 4为 GPS报警, 5为视频报警, 6为设备故障报警, @@ -53,12 +53,12 @@ public class DeviceAlarm { this.deviceId = deviceId; } - public String getAlarmPriorit() { - return alarmPriorit; + public String getAlarmPriority() { + return alarmPriority; } - public void setAlarmPriorit(String alarmPriorit) { - this.alarmPriorit = alarmPriorit; + public void setAlarmPriority(String alarmPriority) { + this.alarmPriority = alarmPriority; } public String getAlarmMethod() { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java index 29f859dc..c796a4aa 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java @@ -6,6 +6,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Component; +import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm; +import com.genersoft.iot.vmp.gb28181.event.alarm.AlarmEvent; import com.genersoft.iot.vmp.gb28181.event.offline.OfflineEvent; import com.genersoft.iot.vmp.gb28181.event.online.OnlineEvent; @@ -52,5 +54,15 @@ public class EventPublisher { PlatformNotRegisterEvent platformNotRegisterEvent = new PlatformNotRegisterEvent(this); platformNotRegisterEvent.setPlatformGbID(platformGbId); applicationEventPublisher.publishEvent(platformNotRegisterEvent); - } + } + + /** + * 设备报警事件 + * @param deviceAlarm + */ + public void deviceAlarmEventPublish(DeviceAlarm deviceAlarm) { + AlarmEvent alarmEvent = new AlarmEvent(this); + alarmEvent.setAlarmInfo(deviceAlarm); + applicationEventPublisher.publishEvent(alarmEvent); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/alarm/AlarmEvent.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/alarm/AlarmEvent.java new file mode 100644 index 00000000..fecc8b1b --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/alarm/AlarmEvent.java @@ -0,0 +1,26 @@ +package com.genersoft.iot.vmp.gb28181.event.alarm; + +import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm; +import org.springframework.context.ApplicationEvent; + +/** + * @description: 报警事件 + * @author: lawrencehj + * @data: 2021-01-20 + */ + +public class AlarmEvent extends ApplicationEvent { + public AlarmEvent(Object source) { + super(source); + } + + private DeviceAlarm deviceAlarm; + + public DeviceAlarm getAlarmInfo() { + return deviceAlarm; + } + + public void setAlarmInfo(DeviceAlarm deviceAlarm) { + this.deviceAlarm = deviceAlarm; + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/alarm/AlarmEventListener.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/alarm/AlarmEventListener.java new file mode 100644 index 00000000..1b2f6723 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/alarm/AlarmEventListener.java @@ -0,0 +1,47 @@ +package com.genersoft.iot.vmp.gb28181.event.alarm; + +import org.springframework.context.ApplicationListener; +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; +import java.io.IOException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @description: 报警事件监听 + * @author: lawrencehj + * @data: 2021-01-20 + */ + +@Component +public class AlarmEventListener implements ApplicationListener { + + private final static Logger logger = LoggerFactory.getLogger(AlarmEventListener.class); + + private static SseEmitter emitter = new SseEmitter(); + + public void addSseEmitters(SseEmitter sseEmitter) { + emitter = sseEmitter; + } + + @Override + public void onApplicationEvent(AlarmEvent event) { + if (logger.isDebugEnabled()) { + logger.debug("设备报警事件触发,deviceId:" + event.getAlarmInfo().getDeviceId() + ", " + + event.getAlarmInfo().getAlarmDescription()); + } + try { + String msg = "设备编码: " + event.getAlarmInfo().getDeviceId() + "" + + "
报警描述: " + event.getAlarmInfo().getAlarmDescription() + "" + + "
报警时间: " + event.getAlarmInfo().getAlarmTime() + "" + + "
定位经度: " + event.getAlarmInfo().getLongitude() + "" + + "
定位纬度: " + event.getAlarmInfo().getLatitude() + ""; + emitter.send(msg); + } catch (IOException e) { + if (logger.isDebugEnabled()) { + logger.debug("SSE 通道已关闭"); + } + // e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java index 06c4d686..22ed34a0 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java @@ -174,7 +174,7 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { SipUri uri = (SipUri) address.getURI(); String platformId = uri.getUser(); // if (deviceListElement == null) { // 存在DeviceList则为响应 catalog, 不存在DeviceList则为查询请求 - if (name == "Query") { // 区分是Response——查询响应,还是Query——查询请求 + if (name.equalsIgnoreCase("Query")) { // 区分是Response——查询响应,还是Query——查询请求 // TODO 后续将代码拆分 ParentPlatform parentPlatform = storager.queryParentPlatById(platformId); if (parentPlatform == null) { @@ -324,19 +324,41 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { // storager.queryChannel(deviceId) return; } - device.setName(XmlUtil.getText(rootElement, "DeviceName")); - device.setManufacturer(XmlUtil.getText(rootElement, "Manufacturer")); - device.setModel(XmlUtil.getText(rootElement, "Model")); - device.setFirmware(XmlUtil.getText(rootElement, "Firmware")); - if (StringUtils.isEmpty(device.getStreamMode())) { - device.setStreamMode("UDP"); + + DeviceAlarm deviceAlarm = new DeviceAlarm(); + deviceAlarm.setDeviceId(deviceId); + deviceAlarm.setAlarmPriority(XmlUtil.getText(rootElement, "AlarmPriority")); + deviceAlarm.setAlarmMethod(XmlUtil.getText(rootElement, "AlarmMethod")); + deviceAlarm.setAlarmTime(XmlUtil.getText(rootElement, "AlarmTime")); + if (XmlUtil.getText(rootElement, "AlarmDescription") == null) { + deviceAlarm.setAlarmDescription(""); + } else { + deviceAlarm.setAlarmDescription(XmlUtil.getText(rootElement, "AlarmDescription")); } - storager.updateDevice(device); + if (XmlUtil.getText(rootElement, "Longitude") == null || XmlUtil.getText(rootElement, "Longitude") == "") { + deviceAlarm.setLongitude(0.00); + } else { + deviceAlarm.setLongitude(Double.parseDouble(XmlUtil.getText(rootElement, "Longitude"))); + } + if (XmlUtil.getText(rootElement, "Latitude") == null || XmlUtil.getText(rootElement, "Latitude") =="") { + deviceAlarm.setLatitude(0.00); + } else { + deviceAlarm.setLatitude(Double.parseDouble(XmlUtil.getText(rootElement, "Latitude"))); + } + + // device.setName(XmlUtil.getText(rootElement, "DeviceName")); + // device.setManufacturer(XmlUtil.getText(rootElement, "Manufacturer")); + // device.setModel(XmlUtil.getText(rootElement, "Model")); + // device.setFirmware(XmlUtil.getText(rootElement, "Firmware")); + // if (StringUtils.isEmpty(device.getStreamMode())) { + // device.setStreamMode("UDP"); + // } + // storager.updateDevice(device); //cmder.catalogQuery(device, null); // 回复200 OK responseAck(evt); if (offLineDetector.isOnline(deviceId)) { - publisher.onlineEventPublish(deviceId, VideoManagerConstants.EVENT_ONLINE_KEEPLIVE); + publisher.deviceAlarmEventPublish(deviceAlarm); } } catch (DocumentException | SipException | InvalidArgumentException | ParseException e) { // } catch (DocumentException e) { From 1488b50c1d763a4a3f379632ec698173c4aa8c1c Mon Sep 17 00:00:00 2001 From: Lawrence <1934378145@qq.com> Date: Wed, 20 Jan 2021 20:41:24 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8A=A5=E8=AD=A6?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=8E=A8=E9=80=81=E8=AF=B7=E6=B1=82=E5=92=8C?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E9=80=9A=E7=9F=A5=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web_src/src/components/UiHeader.vue | 58 +++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/web_src/src/components/UiHeader.vue b/web_src/src/components/UiHeader.vue index fa57b263..17a6880b 100644 --- a/web_src/src/components/UiHeader.vue +++ b/web_src/src/components/UiHeader.vue @@ -3,7 +3,8 @@ 控制台 设备列表 - 国标级联 + 国标级联 + 退出 @@ -12,14 +13,63 @@ From ea787fdcba6418f6d2f44e26a8a29988662d2c9b Mon Sep 17 00:00:00 2001 From: Lawrence <1934378145@qq.com> Date: Wed, 20 Jan 2021 20:42:58 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0SSE=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E6=8E=A8=E9=80=81=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vmanager/SEEController/SEEController.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/main/java/com/genersoft/iot/vmp/vmanager/SEEController/SEEController.java diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/SEEController/SEEController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/SEEController/SEEController.java new file mode 100644 index 00000000..689b967b --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/SEEController/SEEController.java @@ -0,0 +1,32 @@ +package com.genersoft.iot.vmp.vmanager.SEEController; + +import com.genersoft.iot.vmp.gb28181.event.alarm.AlarmEventListener; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; + +/** + * @description: SSE推送 + * @author: lawrencehj + * @data: 2021-01-20 + */ + +@Controller +@RequestMapping("/api") +public class SEEController { + @Autowired + AlarmEventListener alarmEventListener; + + //设置响应 + @RequestMapping("/emit") + public SseEmitter emit() { + SseEmitter sseEmitter = new SseEmitter(0L); + try { + alarmEventListener.addSseEmitters(sseEmitter); + }catch (Exception e){ + sseEmitter.completeWithError(e); + } + return sseEmitter; + } +} From d7a0468788d31024b21ef68a4f2fb883299bfa65 Mon Sep 17 00:00:00 2001 From: Lawrence <1934378145@qq.com> Date: Wed, 20 Jan 2021 20:43:40 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5e5eb542..929e85ef 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,8 @@ https://gitee.com/18010473990/wvp-GB28181.git 16. 支持直接输出RTSP、RTMP、HTTP-FLV、Websocket-FLV、HLS多种协议流地址 17. 支持国标网络校时 18. 支持公网部署, 支持wvp与zlm分开部署 -19. 支持播放h265, g.711格式的流(需要将closeWaitRTPInfo设为false). +19. 支持播放h265, g.711格式的流(需要将closeWaitRTPInfo设为false) +20. 报警信息处理,支持向前端推送报警信息 # 2.0 支持特性 - [ ] 国标通道向上级联