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