From d52795fc5de0b6ed748cd2ef217dcd1371e4b8e9 Mon Sep 17 00:00:00 2001 From: jiazx0107@163.com <jiazx0107@163.com> Date: 星期五, 10 十一月 2023 01:06:13 +0800 Subject: [PATCH] 重新调整代码结构和实现方式 --- src/main/java/com/fzzy/gateway/hx2023/service/OnReceiveMqttService.java | 26 ++++++++++---------------- 1 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/fzzy/gateway/hx2023/service/OnReceiveMqttService.java b/src/main/java/com/fzzy/gateway/hx2023/service/OnReceiveMqttService.java index f2eed2f..5957fe6 100644 --- a/src/main/java/com/fzzy/gateway/hx2023/service/OnReceiveMqttService.java +++ b/src/main/java/com/fzzy/gateway/hx2023/service/OnReceiveMqttService.java @@ -7,10 +7,8 @@ import com.fzzy.gateway.entity.GatewayDevice; import com.fzzy.gateway.hx2023.ScConstant; import com.fzzy.gateway.hx2023.data.CloudSendData; -import com.fzzy.gateway.hx2023.data.SyncReqData; +import com.fzzy.gateway.data.BaseReqData; import com.fzzy.mqtt.MqttGatewayService; -import com.fzzy.mqtt.MqttProviderConfig; -import com.fzzy.mqtt.MqttPublishService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -39,9 +37,7 @@ try { CloudSendData cloudSendData = JSONObject.parseObject(message, CloudSendData.class); - String functionId = cloudSendData.getFunctionId(); - //绮儏閲囬泦 if (ScConstant.FUNCTION_getTAndRHInfo.equals(functionId)) { getTAndRHInfo(cloudSendData); @@ -59,7 +55,7 @@ GatewayDevice device = GatewayUtils.getCacheByDeviceId(deviceId); - SyncReqData syncReqData = new SyncReqData(); + BaseReqData syncReqData = new BaseReqData(); syncReqData.setDeviceId(deviceId); syncReqData.setMessageId(cloudSendData.getMessageId()); syncReqData.setMessageType(cloudSendData.getMessageType()); @@ -67,19 +63,17 @@ syncReqData.setAutoReplay(true); syncReqData.setDevice(device); - BaseResp resp = gatewayRemoteManager.getSyncGrainService(device.getSyncProtocol()).syncGrain2(syncReqData); + + //TODO --->>鏆傛椂杩斿洖娴嬭瘯鏁版嵁 + + //BaseResp resp = gatewayRemoteManager.getSyncGrainService(device.getSyncProtocol()).syncGrain(syncReqData); + + BaseResp resp = gatewayRemoteManager.getGatewayTestService(device.getPushProtocol()).testGrain(syncReqData); //鑷姩鎺ㄩ�� if (200 == resp.getCode() && syncReqData.isAutoReplay()) { - String topic = ScConstant.TOPIC_REPORT; - - topic = topic.replace("${productId}", device.getProductId()).replace("${deviceId}", device.getDeviceId()); - - mqttGatewayService.publishMqttWithTopic(resp.getData(), topic); - - log.info("----------------------------鎺ㄩ�丮QTT淇℃伅---------------------------"); - log.info("-----TOPIC-----{}",topic); - log.info("-----Message-----{}",resp.getData()); + syncReqData.setData(resp.getData()); + gatewayRemoteManager.getDeviceReportService(device.getPushProtocol()).reportGrainData(syncReqData); } } } -- Gitblit v1.9.3