From e31d4d2d3cecab2fb56508c0f5b82d821719e7bb Mon Sep 17 00:00:00 2001
From: zhangzeli <123456>
Date: 星期二, 25 一月 2022 14:39:14 +0800
Subject: [PATCH] bug
---
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/util/MQTT.java | 31 +++++++++++++++++++++++++++++--
1 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/util/MQTT.java b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/util/MQTT.java
index 390c107..db8c882 100644
--- a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/util/MQTT.java
+++ b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/util/MQTT.java
@@ -2,8 +2,10 @@
import cn.exrick.xboot.your.entity.Alarm;
import cn.exrick.xboot.your.entity.Car;
+import cn.exrick.xboot.your.entity.EventLog;
import cn.exrick.xboot.your.service.IAlarmService;
import cn.exrick.xboot.your.service.ICarService;
+import cn.exrick.xboot.your.service.IEventLogService;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
@@ -13,12 +15,18 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import java.awt.*;
+
@Component
public class MQTT {
@Autowired
private IAlarmService iAlarmService;
@Autowired
private ICarService iCarService;
+ @Autowired
+ private HaiKangPost haiKangPost;
+ @Autowired
+ private IEventLogService iEventLogService;
public static void main(String[] args) {
MQTT mqtt = new MQTT();
@@ -26,7 +34,8 @@
}
public void event(String clientid,String userName,String passWord){
- String HOST = "tcp://111.63.178.115:1883";
+ String HOST = "tcp://10.10.101.1:1883";
+ //String HOST = "tcp://111.63.178.115:1883";
String TOPIC = "artemis/event_msa_alarm/5201154049/admin";
int qos = 1;
// String clientid = "28156526";
@@ -51,6 +60,17 @@
client.setCallback(new MqttCallback() {
public void connectionLost(Throwable cause) {
System.out.println("connectionLost");
+ String topicInfo = haiKangPost.getTopicInfo();
+ System.out.println("閲嶈繛-璁㈤槄淇℃伅锛�"+topicInfo);
+ JSONObject jsonObject = JSONUtil.parseObj(topicInfo);
+ if(jsonObject.get("data")!=null){
+ String data = jsonObject.get("data").toString();
+ JSONObject jsonObject2 = JSONUtil.parseObj(data);
+ String clientId = jsonObject2.get("clientId").toString();
+ String userName = jsonObject2.get("userName").toString();
+ String password = jsonObject2.get("password").toString();
+ event(clientId,userName,password);
+ }
}
public void deliveryComplete(IMqttDeliveryToken token) {
@@ -87,6 +107,7 @@
String eventType = jsonObject2.get("eventType").toString();
String vehicleIndexCode = jsonObject2.get("vehicleIndexCode").toString();
String alarmId = jsonObject2.get("alarmId").toString();
+ String alarmTime = jsonObject2.get("alarmTime").toString();
Alarm alarm = new Alarm();
if(eventType.equals("132371")){
@@ -117,8 +138,14 @@
alarm.setCarNo(car.getCarNo());
alarm.setCarUserId(car.getUserId());
alarm.setFollowUserId(car.getFollowUserId());
-
+ alarm.setAlarmTime(alarmTime);
iAlarmService.saveOrUpdate(alarm);
+
+ EventLog eventLog = new EventLog();
+ eventLog.setType(alarm.getType());
+ eventLog.setRefId(alarmId);
+ eventLog.setCarNo(car.getCarNo());
+ iEventLogService.saveOrUpdate(eventLog);
}
}
}
--
Gitblit v1.9.1