|
|
@@ -6,6 +6,9 @@ import com.google.gson.JsonObject;
|
|
|
import com.zhongshu.card.client.model.mqtt.SendMessageModel;
|
|
|
import com.zhongshu.card.client.ret.ResultContent;
|
|
|
import com.zhongshu.card.server.core.dao.org.UserCountDao;
|
|
|
+import com.zhongshu.card.server.core.iotCenter.ApiRequestService;
|
|
|
+import com.zhongshu.card.server.core.iotCenter.apiConf.APIResponseModel;
|
|
|
+import com.zhongshu.card.server.core.iotCenter.conf.IotCenterAPIConfig;
|
|
|
import com.zhongshu.card.server.core.service.base.RedisService;
|
|
|
import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
import com.zhongshu.card.server.core.service.mqtt.mqttConfig.client.MQClient;
|
|
|
@@ -20,6 +23,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.jms.annotation.JmsListener;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
import java.util.UUID;
|
|
|
|
|
|
/**
|
|
|
@@ -39,6 +44,9 @@ public class MqttServiceImpl extends SuperService {
|
|
|
@Autowired
|
|
|
MQClient mqClient;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ ApiRequestService apiRequestService;
|
|
|
+
|
|
|
/**
|
|
|
* 发送指令
|
|
|
*
|
|
|
@@ -53,12 +61,23 @@ public class MqttServiceImpl extends SuperService {
|
|
|
jsonObject.addProperty("data", param.getMessage());
|
|
|
jsonObject.addProperty("time", DateUtils.paresTime(System.currentTimeMillis(), DateUtils.patternyyyySSS));
|
|
|
jsonObject.addProperty("ttl", 10 * 1000);
|
|
|
- mqClient.sendObject(param.getTopic(), jsonObject.toString());
|
|
|
+// mqClient.sendObject(param.getTopic(), jsonObject.toString());
|
|
|
log.info("mqtt msg 发送成功");
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
msg = "发送失败: " + e.getMessage();
|
|
|
}
|
|
|
+
|
|
|
+ Map<String, Object> data = new HashMap<>();
|
|
|
+ data.put("topic", "v1/23");
|
|
|
+ data.put("message", "测试");
|
|
|
+
|
|
|
+ APIResponseModel resultContent = apiRequestService.sendIotCenterAPI(
|
|
|
+ IotCenterAPIConfig.sendMessage, data);
|
|
|
+ if (resultContent.isSuccess()) {
|
|
|
+
|
|
|
+ }
|
|
|
+ log.info("是否成功: {} {}", resultContent.isSuccess(), resultContent.getContent());
|
|
|
return ResultContent.buildSuccess(msg);
|
|
|
}
|
|
|
|