From c3ec70d2bd1ebd2421d2fa3e85c1ac43e2322ea6 Mon Sep 17 00:00:00 2001
From: zhangnaisong <2434969829@qq.com>
Date: 星期一, 22 七月 2024 14:44:52 +0800
Subject: [PATCH] 电子围栏加入类型提交

---
 ard-work/src/main/java/com/ruoyi/utils/mqtt/MqttConsumerCallback.java |   45 +++++++++++++++++++++++++++++++++++----------
 1 files changed, 35 insertions(+), 10 deletions(-)

diff --git a/ard-work/src/main/java/com/ruoyi/utils/mqtt/MqttConsumerCallback.java b/ard-work/src/main/java/com/ruoyi/utils/mqtt/MqttConsumerCallback.java
index f7bdf58..f89b53d 100644
--- a/ard-work/src/main/java/com/ruoyi/utils/mqtt/MqttConsumerCallback.java
+++ b/ard-work/src/main/java/com/ruoyi/utils/mqtt/MqttConsumerCallback.java
@@ -1,7 +1,10 @@
 package com.ruoyi.utils.mqtt;
 
-import com.ruoyi.alarm.globalAlarm.service.impl.GlobalAlarmServiceImpl;
+import com.ruoyi.alarm.global.service.impl.GlobalAlarmServiceImpl;
+import com.ruoyi.alarm.radar.service.ArdRadarService;
 import com.ruoyi.common.utils.spring.SpringUtils;
+import com.ruoyi.statistical.service.StatisticalService;
+import com.ruoyi.storage.minio.service.IStorageMinioEventService;
 import lombok.extern.slf4j.Slf4j;
 import org.eclipse.paho.client.mqttv3.*;
 
@@ -35,14 +38,13 @@
      */
     @Override
     public void connectionLost(Throwable cause) {
-        log.info("MQTT杩炴帴鏂紑锛屽彂璧烽噸杩�......");
+//        log.info("MQTT杩炴帴鏂紑锛屽彂璧烽噸杩�......");
         while (!client.isConnected()) {
             try {
-
-                Thread.sleep(5000);
+                Thread.sleep(10000);
                 if (null != client && !client.isConnected()) {
                     client.reconnect();
-                    log.error("灏濊瘯閲嶆柊杩炴帴");
+//                    log.error("灏濊瘯閲嶆柊杩炴帴");
                 } else {
                     client.connect(options);
                     log.error("灏濊瘯寤虹珛鏂拌繛鎺�");
@@ -69,12 +71,35 @@
     public void messageArrived(String topic, MqttMessage message) {
         try {
             // subscribe鍚庡緱鍒扮殑娑堟伅浼氭墽琛屽埌杩欓噷闈�
-            log.info("鎺ユ敹娑堟伅 銆愪富棰樸��:" + topic + " 銆愬唴瀹广��:" + new String(message.getPayload()));
+            log.debug("鎺ユ敹娑堟伅 銆愪富棰樸��:" + topic + " 銆愬唴瀹广��:" + new String(message.getPayload(), StandardCharsets.UTF_8));
             //杩涜涓氬姟澶勭悊(鎺ユ敹鎶ヨ鏁版嵁)
             GlobalAlarmServiceImpl globalAlarmService = SpringUtils.getBean(GlobalAlarmServiceImpl.class);
             globalAlarmService.receiveAlarm(topic, new String(message.getPayload(), StandardCharsets.UTF_8));
+            if (topic.equals("minioEvent"))
+            {
+                IStorageMinioEventService storageMinioEventService = SpringUtils.getBean(IStorageMinioEventService.class);
+                storageMinioEventService.parseStorageMinioEvent(new String(message.getPayload(), StandardCharsets.UTF_8));
+            }
+            if (topic.equals("radarWellData"))
+            {
+//                System.out.println(new String(message.getPayload(), StandardCharsets.UTF_8));
+                StatisticalService statisticalService = SpringUtils.getBean(StatisticalService.class);
+                statisticalService.data(new String(message.getPayload(), StandardCharsets.UTF_8));
+            }
+            //鎺ユ敹闆疯揪寮哄埗寮曞鏁版嵁
+            if (topic.equals("radarForceGuide"))
+            {
+                ArdRadarService ardRadarService = SpringUtils.getBean(ArdRadarService.class);
+                ardRadarService.forceGuide(new String(message.getPayload(), StandardCharsets.UTF_8));
+            }
+            //鎺ユ敹闆疯揪寮曞杩借釜鏁版嵁
+            if (topic.equals("radarFollowGuide"))
+            {
+                ArdRadarService ardRadarService = SpringUtils.getBean(ArdRadarService.class);
+                ardRadarService.followGuide(new String(message.getPayload(), StandardCharsets.UTF_8));
+            }
         } catch (Exception e) {
-            log.info("澶勭悊mqtt娑堟伅寮傚父:" + e);
+            log.debug("澶勭悊mqtt娑堟伅寮傚父:" + e);
         }
     }
 
@@ -87,10 +112,10 @@
             if (null != topic && null != qos) {
                 if (client.isConnected()) {
                     client.subscribe(topic, qos);
-                    log.info("mqtt杩炴帴鎴愬姛锛屽鎴风ID锛�" + PropertiesUtil.MQTT_CLIENT_ID);
-                    log.info("--璁㈤槄涓婚:锛�" + Arrays.toString(topic));
+//                    log.info("mqtt杩炴帴鎴愬姛" );
+//                    log.info("璁㈤槄涓婚:" + Arrays.toString(topic));
                 } else {
-                    log.info("mqtt杩炴帴澶辫触锛屽鎴风ID锛�" + PropertiesUtil.MQTT_CLIENT_ID);
+                    log.info("mqtt杩炴帴澶辫触");
                 }
             }
         } catch (Exception e) {

--
Gitblit v1.9.3