用能空调代码提交 终端相关代码修改

This commit is contained in:
2022-07-01 09:17:51 +08:00
parent 7affd72b1d
commit 76ea96e316
38 changed files with 575 additions and 108 deletions

View File

@@ -1,5 +1,6 @@
package com.njcn.energy.handler;
import cn.hutool.json.JSONObject;
import com.alibaba.nacos.shaded.com.google.gson.Gson;
import com.github.tocrhz.mqtt.annotation.MqttSubscribe;
import com.github.tocrhz.mqtt.annotation.NamedValue;
@@ -15,11 +16,15 @@ import com.njcn.energy.pojo.po.EleLogs;
import com.njcn.energy.service.IEleLogsService;
import com.njcn.energy.service.IModelService;
import com.njcn.redis.utils.RedisUtil;
import io.swagger.models.auth.In;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSON;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import java.nio.charset.StandardCharsets;
@@ -37,7 +42,7 @@ import java.util.concurrent.TimeUnit;
*/
@Slf4j
@Component
@AllArgsConstructor
@RequiredArgsConstructor
public class MqttMessageHandler {
private final MqttPublisher publisher;
@@ -48,6 +53,18 @@ public class MqttMessageHandler {
private final IEleLogsService eleLogsService;
@Value("${mqtt.client-id}")
private String clientId;
/**
* 用于记录错误指令发送次数,默认发送三次停止
* @author cdf
* @date 2022/6/28
*/
private Integer mqttSendCount = 0;
private String mqttJsonMsg;
private String mqttSendTopic;
// /**
// * 设备注册
// */
@@ -179,11 +196,8 @@ public class MqttMessageHandler {
// }
@MqttSubscribe(value = "/platform/devack/#",qos = 1)
public void airOperation(String topic, MqttMessage message, @Payload String payload){
System.out.println(message.toString());
}
}