controller层
@Autowired
private GeelyMqttClient geelyMqttClient;
//mqtt
String mqttRequestJson = MqttRequestFactory.getMqttRequestJson("发送的名称", 发送的数据, "编号");
geelyMqttClient.publish("对接的名称", mqttRequestJson, GeelyMqttClient.QosEnum.QoS0,false);
MqttRequestFactory
import com.alibaba.fastjson.JSON;
import java.util.Date;
/**
* @Description: MqttRequestFactory
* @Author: WBN
* @CreateDate: 2021/5/11 1:08
* @UpdateUser: WBN
* @UpdateDate: 2021/5/11 1:08
* @UpdateRemark: 修改内容
* @Version: 1.0
*/
public final class MqttRequestFactory {
/**
*
* @param methodName 方法名称
* @param body 消息体
* @param deviceNo 设备编号
* @return MqttRequest
*/
public static MqttRequest getMqttRequest(String methodName, Object body, String deviceNo) {