|
@@ -2,6 +2,7 @@ package com.usky.cdi.service.impl;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+<<<<<<< Updated upstream
|
|
|
// import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
|
// import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
|
|
import com.usky.cdi.service.config.mqtt.MqttOutConfig;
|
|
import com.usky.cdi.service.config.mqtt.MqttOutConfig;
|
|
|
import com.usky.cdi.service.mqtt.MqttConnectionTool;
|
|
import com.usky.cdi.service.mqtt.MqttConnectionTool;
|
|
@@ -9,12 +10,27 @@ import com.usky.cdi.service.util.SnowflakeIdGenerator;
|
|
|
import com.usky.cdi.service.vo.alarm.AlarmMessageVO;
|
|
import com.usky.cdi.service.vo.alarm.AlarmMessageVO;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+=======
|
|
|
|
|
+import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
|
|
|
|
+import com.usky.cdi.service.config.mqtt.MqttOutConfig;
|
|
|
|
|
+import com.usky.cdi.service.util.SnowflakeIdGenerator;
|
|
|
|
|
+import com.usky.cdi.service.vo.alarm.AlarmMessage1VO;
|
|
|
|
|
+import com.usky.cdi.service.vo.alarm.AlarmMessageVO;
|
|
|
|
|
+import com.usky.cdi.service.vo.base.FloorPlaneVO;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+>>>>>>> Stashed changes
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
|
+<<<<<<< Updated upstream
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
|
|
+=======
|
|
|
|
|
+import java.nio.file.Files;
|
|
|
|
|
+import java.nio.file.Paths;
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
|
+>>>>>>> Stashed changes
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
@@ -27,10 +43,16 @@ import java.util.HashMap;
|
|
|
*/
|
|
*/
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
@Service
|
|
@Service
|
|
|
|
|
+<<<<<<< Updated upstream
|
|
|
public class AlarmDataTransferService {
|
|
public class AlarmDataTransferService {
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private MqttConnectionTool mqttConnectionTool;
|
|
private MqttConnectionTool mqttConnectionTool;
|
|
|
|
|
+=======
|
|
|
|
|
+@ConditionalOnProperty(prefix = "mqtt", value = {"enabled"}, havingValue = "true")
|
|
|
|
|
+public class AlarmDataTransferService {
|
|
|
|
|
+
|
|
|
|
|
+>>>>>>> Stashed changes
|
|
|
@Resource
|
|
@Resource
|
|
|
private MqttOutConfig.MqttGateway mqttGateway;
|
|
private MqttOutConfig.MqttGateway mqttGateway;
|
|
|
|
|
|
|
@@ -39,9 +61,14 @@ public class AlarmDataTransferService {
|
|
|
|
|
|
|
|
public AlarmDataTransferService() {
|
|
public AlarmDataTransferService() {
|
|
|
// 使用默认的workerId和datacenterId,实际项目中可以从配置读取
|
|
// 使用默认的workerId和datacenterId,实际项目中可以从配置读取
|
|
|
|
|
+<<<<<<< Updated upstream
|
|
|
this.idGenerator = new SnowflakeIdGenerator(3L, 3L);
|
|
this.idGenerator = new SnowflakeIdGenerator(3L, 3L);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+=======
|
|
|
|
|
+ this.idGenerator = new SnowflakeIdGenerator(1L, 1L);
|
|
|
|
|
+ }
|
|
|
|
|
+>>>>>>> Stashed changes
|
|
|
/**
|
|
/**
|
|
|
* 获取当前时间字符串
|
|
* 获取当前时间字符串
|
|
|
*/
|
|
*/
|
|
@@ -69,10 +96,17 @@ public class AlarmDataTransferService {
|
|
|
vo.setDataPacketID(generateDataPacketID());
|
|
vo.setDataPacketID(generateDataPacketID());
|
|
|
}
|
|
}
|
|
|
if (vo.getPublishTime() == null) {
|
|
if (vo.getPublishTime() == null) {
|
|
|
|
|
+<<<<<<< Updated upstream
|
|
|
vo.setPublishTime(LocalDateTime.now());
|
|
vo.setPublishTime(LocalDateTime.now());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// HashMap<String, Object> map = new HashMap<>();
|
|
// HashMap<String, Object> map = new HashMap<>();
|
|
|
|
|
+=======
|
|
|
|
|
+ vo.setPublishTime(getCurrentTime());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
|
|
+>>>>>>> Stashed changes
|
|
|
// map.put("dataPacketID", vo.getDataPacketID());
|
|
// map.put("dataPacketID", vo.getDataPacketID());
|
|
|
// map.put("engineeringID", vo.getEngineeringID());
|
|
// map.put("engineeringID", vo.getEngineeringID());
|
|
|
// map.put("floor", vo.getFloor());
|
|
// map.put("floor", vo.getFloor());
|
|
@@ -83,6 +117,7 @@ public class AlarmDataTransferService {
|
|
|
// map.put("filePixHeight", vo.getFilePixHeight());
|
|
// map.put("filePixHeight", vo.getFilePixHeight());
|
|
|
// map.put("floorFile", imageBytes);
|
|
// map.put("floorFile", imageBytes);
|
|
|
// map.put("publishTime", vo.getPublishTime());
|
|
// map.put("publishTime", vo.getPublishTime());
|
|
|
|
|
+<<<<<<< Updated upstream
|
|
|
// Gson gson = new Gson();
|
|
// Gson gson = new Gson();
|
|
|
JSONObject jsonObject = (JSONObject) JSON.toJSON(vo);
|
|
JSONObject jsonObject = (JSONObject) JSON.toJSON(vo);
|
|
|
String json = jsonObject.toJSONString();
|
|
String json = jsonObject.toJSONString();
|
|
@@ -90,6 +125,14 @@ public class AlarmDataTransferService {
|
|
|
MqttConnectionTool.MqttGateway IQeIRyXG = mqttConnectionTool.connectOrRefresh("3101070011", "5RqhJ7VG");
|
|
MqttConnectionTool.MqttGateway IQeIRyXG = mqttConnectionTool.connectOrRefresh("3101070011", "5RqhJ7VG");
|
|
|
String topic = "alarm/message";
|
|
String topic = "alarm/message";
|
|
|
IQeIRyXG.sendToMqtt(topic, json);
|
|
IQeIRyXG.sendToMqtt(topic, json);
|
|
|
|
|
+=======
|
|
|
|
|
+ Gson gson = new Gson();
|
|
|
|
|
+ JSONObject jsonObject = (JSONObject) JSON.toJSON(vo);
|
|
|
|
|
+ String json = jsonObject.toJSONString();
|
|
|
|
|
+ System.out.println(json);
|
|
|
|
|
+ String topic = "alarm/message";
|
|
|
|
|
+ mqttGateway.sendToMqtt(topic, json);
|
|
|
|
|
+>>>>>>> Stashed changes
|
|
|
|
|
|
|
|
return true;
|
|
return true;
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -105,15 +148,23 @@ public class AlarmDataTransferService {
|
|
|
* @param vo 楼层平面图信息
|
|
* @param vo 楼层平面图信息
|
|
|
* @return 是否发送成功
|
|
* @return 是否发送成功
|
|
|
*/
|
|
*/
|
|
|
|
|
+<<<<<<< Updated upstream
|
|
|
public boolean sendAlarmMessage1(AlarmMessageVO vo) {
|
|
public boolean sendAlarmMessage1(AlarmMessageVO vo) {
|
|
|
MqttConnectionTool.MqttGateway IQeIRyXG = mqttConnectionTool.connectOrRefresh("3101070011", "5RqhJ7VG");
|
|
MqttConnectionTool.MqttGateway IQeIRyXG = mqttConnectionTool.connectOrRefresh("3101070011", "5RqhJ7VG");
|
|
|
|
|
|
|
|
|
|
+=======
|
|
|
|
|
+ public boolean sendAlarmMessage1(AlarmMessage1VO vo) {
|
|
|
|
|
+>>>>>>> Stashed changes
|
|
|
try {
|
|
try {
|
|
|
if (vo.getDataPacketID() == null) {
|
|
if (vo.getDataPacketID() == null) {
|
|
|
vo.setDataPacketID(generateDataPacketID());
|
|
vo.setDataPacketID(generateDataPacketID());
|
|
|
}
|
|
}
|
|
|
if (vo.getPublishTime() == null) {
|
|
if (vo.getPublishTime() == null) {
|
|
|
|
|
+<<<<<<< Updated upstream
|
|
|
vo.setPublishTime(LocalDateTime.now());
|
|
vo.setPublishTime(LocalDateTime.now());
|
|
|
|
|
+=======
|
|
|
|
|
+ vo.setPublishTime(getCurrentTime());
|
|
|
|
|
+>>>>>>> Stashed changes
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
@@ -127,6 +178,7 @@ public class AlarmDataTransferService {
|
|
|
// map.put("filePixHeight", vo.getFilePixHeight());
|
|
// map.put("filePixHeight", vo.getFilePixHeight());
|
|
|
// map.put("floorFile", imageBytes);
|
|
// map.put("floorFile", imageBytes);
|
|
|
// map.put("publishTime", vo.getPublishTime());
|
|
// map.put("publishTime", vo.getPublishTime());
|
|
|
|
|
+<<<<<<< Updated upstream
|
|
|
// Gson gson = new Gson();
|
|
// Gson gson = new Gson();
|
|
|
JSONObject jsonObject = (JSONObject) JSON.toJSON(vo);
|
|
JSONObject jsonObject = (JSONObject) JSON.toJSON(vo);
|
|
|
String json = jsonObject.toJSONString();
|
|
String json = jsonObject.toJSONString();
|
|
@@ -156,6 +208,14 @@ public class AlarmDataTransferService {
|
|
|
MqttConnectionTool.MqttGateway IQeIRyXG = mqttConnectionTool.connectOrRefresh("3101070011", "5RqhJ7VG");
|
|
MqttConnectionTool.MqttGateway IQeIRyXG = mqttConnectionTool.connectOrRefresh("3101070011", "5RqhJ7VG");
|
|
|
String topic = "alarm/message";
|
|
String topic = "alarm/message";
|
|
|
IQeIRyXG.sendToMqtt(topic, json);
|
|
IQeIRyXG.sendToMqtt(topic, json);
|
|
|
|
|
+=======
|
|
|
|
|
+ Gson gson = new Gson();
|
|
|
|
|
+ JSONObject jsonObject = (JSONObject) JSON.toJSON(vo);
|
|
|
|
|
+ String json = jsonObject.toJSONString();
|
|
|
|
|
+ System.out.println(json);
|
|
|
|
|
+ String topic = "alarm/message";
|
|
|
|
|
+ mqttGateway.sendToMqtt(topic, json);
|
|
|
|
|
+>>>>>>> Stashed changes
|
|
|
|
|
|
|
|
return true;
|
|
return true;
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -163,6 +223,7 @@ public class AlarmDataTransferService {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+<<<<<<< Updated upstream
|
|
|
|
|
|
|
|
public boolean sendEngineeringBase(AlarmMessageVO vo) {
|
|
public boolean sendEngineeringBase(AlarmMessageVO vo) {
|
|
|
try {
|
|
try {
|
|
@@ -187,4 +248,6 @@ public class AlarmDataTransferService {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+=======
|
|
|
|
|
+>>>>>>> Stashed changes
|
|
|
}
|
|
}
|