From 0c02434f560eb22df67ec8040b8675820dd7c3ca Mon Sep 17 00:00:00 2001 From: tyty Date: Fri, 17 Nov 2023 16:53:07 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java index 4c6ca69..5c12f53 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java @@ -1549,7 +1549,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl Date: Mon, 20 Nov 2023 09:01:37 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E9=9B=86=E4=B8=AD=E7=9B=91=E6=8E=A7?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=BA=90-video?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hnac/hzims/alarm/mqtt/MqttConfig.java | 7 ++++ .../hnac/hzims/alarm/mqtt/VideoMqttConsumer.java | 40 ++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/VideoMqttConsumer.java diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java index 860785f..facb306 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java @@ -3,6 +3,7 @@ package com.hnac.hzims.alarm.mqtt; import com.hnac.hzinfo.subscribe.AnalysisSubscribe; import com.hnac.hzinfo.subscribe.DroolsSoeSubscribe; import com.hnac.hzinfo.subscribe.HZ3000SoeSubscribe; +import com.hnac.hzinfo.subscribe.SoeSubscribe; import lombok.extern.slf4j.Slf4j; import org.eclipse.paho.client.mqttv3.MqttAsyncClient; import org.eclipse.paho.client.mqttv3.MqttException; @@ -27,6 +28,8 @@ public class MqttConfig { DroolsMqttConsumer droolsMqttConsumer; @Autowired HZ300MqttConsumer hz300MqttConsumer; + @Autowired + VideoMqttConsumer videoMqttConsumer; @Value("${hzims.mqtt.url}") private String mqtt_fdp_url; @Value("${hzims.mqtt.group}") @@ -61,6 +64,10 @@ public class MqttConfig { HZ3000SoeSubscribe hz3000SoeSubscribe = new HZ3000SoeSubscribe(); MqttAsyncClient hz3000Client = hz3000SoeSubscribe.subscribe(mqttConfig, Collections.singletonList("#"), hz300MqttConsumer); log.info(hz3000Client.toString()); + //视频 + SoeSubscribe subscribe = new SoeSubscribe(); + MqttAsyncClient videoClient = subscribe.subscribe(mqttConfig, Collections.singletonList("#"), videoMqttConsumer); + log.info(videoClient.toString()); }catch (MqttException e){ log.error(e.toString()) ; } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/VideoMqttConsumer.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/VideoMqttConsumer.java new file mode 100644 index 0000000..e42bfa3 --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/VideoMqttConsumer.java @@ -0,0 +1,40 @@ +package com.hnac.hzims.alarm.mqtt; + +import com.alibaba.fastjson.JSONObject; +import com.hnac.hzims.alarm.entity.AlarmEntity; +import com.hnac.hzims.alarm.handle.service.VideoAlarmService; +import com.hnac.hzims.alarm.monitor.service.AlarmSaveService; +import com.hnac.hzinfo.subscribe.SubscribeCallBack; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +/** + * + * @Author: ty + */ + +@Service +@Slf4j +public class VideoMqttConsumer implements SubscribeCallBack { + @Autowired + private VideoAlarmService videoAlarmService; + @Autowired + private AlarmSaveService alarmSaveService; + @Override + public void onMessage(Map data) { + System.out.println("监听到消息"+data.toString()); + String s = JSONObject.toJSONString(data); + //消费代码 + List alarmEntities = videoAlarmService.receiveMessage(s); + //统一数据处理 + try { + alarmSaveService.save(alarmEntities); + }catch (Exception e){ + log.error("HZ3000告警数据处理报错(HZ300Alarm):"+e); + } + } +}