|
|
@@ -4,8 +4,10 @@ import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.github.microservice.dataConfig.IotTtlConfig;
|
|
|
import com.github.microservice.net.ResultContent;
|
|
|
+import com.zhongshu.iot.server.core.dao.mqtt.DeviceInfoDao;
|
|
|
import com.zhongshu.iot.server.core.domain.iot.IotMain;
|
|
|
import com.zhongshu.iot.server.core.domain.iot.message.OperationMessageResult;
|
|
|
+import com.zhongshu.iot.server.core.service.device.GateWayManagerService;
|
|
|
import com.zhongshu.iot.server.core.util.DateUtils;
|
|
|
import com.zhongshu.iot.server.core.util.mqtt.mqttConfig.client.MQClient;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -25,6 +27,12 @@ public class IotFreshService {
|
|
|
@Autowired
|
|
|
private MQClient mqClient;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private DeviceInfoDao deviceInfoDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private GateWayManagerService gateWayManagerService;
|
|
|
+
|
|
|
/**
|
|
|
* 发送页面刷新消息
|
|
|
* @param messageResult
|
|
|
@@ -37,11 +45,13 @@ public class IotFreshService {
|
|
|
String iotThingId = messageResult.getIotThingId();
|
|
|
String deviceId = messageResult.getDeviceId();
|
|
|
String messageId = messageResult.getMessageId();
|
|
|
- String topic = String.format("/page/fresh/%s", iotThingId);
|
|
|
+ String topicDevice = String.format("/page/fresh/message/%s", deviceId);
|
|
|
|
|
|
JSONObject data = new JSONObject();
|
|
|
data.set("iotThingId", iotThingId);
|
|
|
data.set("deviceId", deviceId);
|
|
|
+ data.set("gateWayId", messageResult.getGateWayId());
|
|
|
+ data.set("mqttUserName", messageResult.getMqttUserName());
|
|
|
IotMain iotMain = messageResult.getIotMain();
|
|
|
if (iotMain != null) {
|
|
|
data.set("functionType", iotMain.getFunctionType());
|
|
|
@@ -54,7 +64,7 @@ public class IotFreshService {
|
|
|
jsonObject.set("time", System.currentTimeMillis());
|
|
|
jsonObject.set("ttl", IotTtlConfig.MQTT_TIME_OUT_TTL);
|
|
|
jsonObject.set("issued", Boolean.TRUE);
|
|
|
- mqClient.sendObject(topic, JSONUtil.toJsonStr(jsonObject), messageId);
|
|
|
+ mqClient.sendObject(topicDevice, JSONUtil.toJsonStr(jsonObject), messageId);
|
|
|
log.info("sendPageFreshMessage: {}", jsonObject.toString());
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|