|
@@ -3,20 +3,14 @@ package com.zy.bms.service.impl;
|
|
|
import com.zy.bms.common.Constant;
|
|
|
import com.zy.bms.config.mqtt.MqttGateway;
|
|
|
import com.zy.bms.entity.DeviceBase;
|
|
|
-import com.zy.bms.entity.lp.LpInfoState;
|
|
|
import com.zy.bms.handler.WebSocketHandler;
|
|
|
import com.zy.bms.pojo.dto.MqttDTO;
|
|
|
-import com.zy.bms.pojo.io.set.AlarmIO;
|
|
|
-import com.zy.bms.pojo.io.set.NtripIO;
|
|
|
-import com.zy.bms.pojo.io.set.SetIO;
|
|
|
-import com.zy.bms.pojo.io.set.TcpIO;
|
|
|
+import com.zy.bms.pojo.io.set.*;
|
|
|
import com.zy.bms.service.IPostMqttMsgService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* 向设备发送协议消息 服务类
|
|
@@ -55,19 +49,33 @@ public class PostMqttMsgServiceImpl implements IPostMqttMsgService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void getDeviceLocalSet(String openNum) {
|
|
|
+ public void requestLocalSetUbi(String openNum) {
|
|
|
MqttDTO mqttDTO = new MqttDTO(Constant.M.UBI_GET_SET_INFO);
|
|
|
mqttDTO.put("getset", "getset");
|
|
|
sendMqttMessage(Constant.TOPIC.DEVICE_CLIENT + openNum, mqttDTO.json());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void updateDeviceInfoLp(String openNum, BigDecimal wakeInt, Integer thresh) {
|
|
|
- MqttDTO mqttDTO = new MqttDTO(Constant.M.LP_UPDATE_DEVICE_INFO);
|
|
|
+ public void setWakeAndThreshLp(String openNum, BigDecimal wakeInt, Integer thresh) {
|
|
|
+ MqttDTO mqttDTO = new MqttDTO(Constant.M.LP_SET_LOCAL_INFO);
|
|
|
mqttDTO.put("setf", "true").put("wakeint", wakeInt).put("thresh", thresh);
|
|
|
sendMqttMessage(Constant.TOPIC.DEVICE_CLIENT_LP + openNum, mqttDTO.json());
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void requestHeartbeatUbi(String openNum) {
|
|
|
+ MqttDTO mqttDTO = new MqttDTO(Constant.M.UBI_REQUEST_HEARTBEAT);
|
|
|
+ mqttDTO.put("fun", "gethearbeat");
|
|
|
+ sendMqttMessage(Constant.TOPIC.DEVICE_CLIENT + openNum, mqttDTO.json());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void requestBuzzingUbi(String openNum) {
|
|
|
+ MqttDTO mqttDTO = new MqttDTO(Constant.M.UBI_REQUEST_HEARTBEAT);
|
|
|
+ mqttDTO.put("fun", "buzzerring");
|
|
|
+ sendMqttMessage(Constant.TOPIC.DEVICE_CLIENT + openNum, mqttDTO.json());
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 发送Mqtt 消息
|
|
|
*
|
|
@@ -78,7 +86,7 @@ public class PostMqttMsgServiceImpl implements IPostMqttMsgService {
|
|
|
// 1. 发送 MQTT 协议消息
|
|
|
mqttGateway.sendMsgToMqtt(payload, topic);
|
|
|
// 2. 存储消息日志
|
|
|
- mqttLogService.saveSend(Constant.TOPIC.REGISTER_CLIENT, payload);
|
|
|
+ mqttLogService.saveSend(topic, payload);
|
|
|
// 3. 消息同步转发至webSocket
|
|
|
webSocketHandler.massMessage(Constant.splitOpenNum(topic), payload);
|
|
|
}
|