| | |
| | | import com.fzzy.gateway.hx2023.kafka.KafkaDeviceReportService; |
| | | import com.fzzy.mqtt.MqttGatewayService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | |
| | | GatewayDevice device = reqData.getDevice(); |
| | | |
| | | if (null == reqData.getData()) { |
| | | if (StringUtils.isEmpty(reqData.getData())) { |
| | | WebSocketPacket packet = new WebSocketPacket(); |
| | | WebSocketPacketHeader header = new WebSocketPacketHeader(); |
| | | header.setDeviceName(reqData.getDeviceName()); |
| | |
| | | jsonObject.put("position", device.getPosition()); |
| | | packet.setProperties(jsonObject); |
| | | packet.setTimestamp(System.currentTimeMillis()); |
| | | |
| | | reqData.setData(JSONObject.toJSONString(packet)); |
| | | } |
| | | |
| | | publishService.publishMqttWithTopic(reqData.getData(), topic); |