| | |
| | | package com.fzzy.gateway.hx2023.service; |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.fzzy.api.data.GatewayDeviceProtocol; |
| | | import com.fzzy.gateway.GatewayUtils; |
| | | import com.fzzy.gateway.api.GatewayRemoteManager; |
| | | import com.fzzy.gateway.data.BaseReqData; |
| | | import com.fzzy.gateway.data.BaseResp; |
| | | import com.fzzy.gateway.entity.GatewayDevice; |
| | | import com.fzzy.gateway.hx2023.ScConstant; |
| | | import com.fzzy.gateway.hx2023.data.CloudSendData; |
| | | import com.fzzy.gateway.data.BaseReqData; |
| | | import com.fzzy.mqtt.MqttGatewayService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | |
| | | @Resource |
| | | private GatewayRemoteManager gatewayRemoteManager; |
| | | @Resource |
| | | private MqttGatewayService mqttGatewayService; |
| | | |
| | | |
| | | /** |
| | |
| | | * |
| | | * @param message |
| | | */ |
| | | public void onReceiveMessage(String topic,String message) { |
| | | public void onReceiveMessage(String topic, String message) { |
| | | |
| | | try { |
| | | CloudSendData cloudSendData = JSONObject.parseObject(message, CloudSendData.class); |
| | |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | log.error("--------执行异常-----{}",e); |
| | | log.error("--------执行异常-----{}", e); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | BaseReqData syncReqData = new BaseReqData(); |
| | | syncReqData.setDeviceId(deviceId); |
| | | syncReqData.setProductId(device.getProductId()); |
| | | syncReqData.setDeviceName(device.getDeviceName()); |
| | | syncReqData.setMessageId(cloudSendData.getMessageId()); |
| | | syncReqData.setMessageType(cloudSendData.getMessageType()); |
| | | syncReqData.setFunctionId(cloudSendData.getFunctionId()); |
| | | syncReqData.setAutoReplay(true); |
| | | syncReqData.setDevice(device); |
| | | |
| | | |
| | | //TODO --->>暂时返回测试数据 |
| | | |
| | | //BaseResp resp = gatewayRemoteManager.getSyncGrainService(device.getSyncProtocol()).syncGrain(syncReqData); |
| | | |
| | | BaseResp resp = gatewayRemoteManager.getGatewayTestService(device.getPushProtocol()).testGrain(syncReqData); |
| | | BaseResp resp; |
| | | if (GatewayDeviceProtocol.DEVICE_TEST.getCode().equals(device.getSyncProtocol())) { |
| | | resp = gatewayRemoteManager.getGatewayTestService(device.getPushProtocol()).testGrain(syncReqData); |
| | | } else { |
| | | syncReqData.setAutoReplay(false); |
| | | resp = gatewayRemoteManager.getSyncGrainService(device.getSyncProtocol()).syncGrain(syncReqData); |
| | | } |
| | | |
| | | //自动推送 |
| | | if (200 == resp.getCode() && syncReqData.isAutoReplay()) { |