| | |
| | | import com.fzzy.gateway.hx2023.ScConstant; |
| | | import com.fzzy.gateway.hx2023.data.SyncReqData; |
| | | import com.fzzy.gateway.service.repository.GatewayDeviceRep; |
| | | import com.fzzy.mqtt.MqttGatewayService; |
| | | import com.fzzy.mqtt.MqttProviderConfig; |
| | | import com.fzzy.mqtt.MqttPublishService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.data.domain.Sort; |
| | | import org.springframework.stereotype.Component; |
| | |
| | | @Resource |
| | | private GatewayRemoteManager gatewayRemoteManager; |
| | | @Resource |
| | | private MqttPublishService publishService; |
| | | private MqttGatewayService publishService; |
| | | |
| | | public List<GatewayDevice> listAll() { |
| | | Sort sort = new Sort(Sort.Direction.ASC, "deviceId"); |
| | |
| | | @Expose |
| | | public String ajaxTestGrain2(GatewayDevice data) { |
| | | |
| | | |
| | | SyncReqData reqData = new SyncReqData(); |
| | | reqData.setDevice(data); |
| | | reqData.setAutoReplay(true); |
| | |
| | | return "ERROR:当前设备非粮情设备不支持当前操作"; |
| | | } |
| | | |
| | | if(StringUtils.isEmpty(data.getCableRule())){ |
| | | return "ERROR:当前设备没有配置布线规则,无法执行"; |
| | | } |
| | | |
| | | BaseResp resp = gatewayRemoteManager.getSyncGrainService(data.getSyncProtocol()).syncGrain2(reqData); |
| | | |
| | | //自动推送 |
| | |
| | | String topic = ScConstant.TOPIC_REPORT; |
| | | topic = topic.replace("${productId}", data.getProductId()).replace("${deviceId}", data.getDeviceId()); |
| | | |
| | | publishService.publishMsg(topic, resp.getData()); |
| | | } |
| | | publishService.publishMqttWithTopic(resp.getData(),topic); |
| | | |
| | | log.info("=======手动测试粮情推送==========={}", resp.getData()); |
| | | log.info("----------------------------手动推送MQTT粮情信息---------------------------"); |
| | | log.info("-----TOPIC-----{}",topic); |
| | | log.info("-----Message-----{}",resp.getData()); |
| | | |
| | | } |
| | | |
| | | return "SUCCESS:执行完成"; |
| | | } |