| | |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.fzzy.api.data.PushProtocol; |
| | | import com.fzzy.data.ConfigData; |
| | | import com.fzzy.gateway.api.GatewayDeviceReportService; |
| | | import com.fzzy.gateway.data.BaseReqData; |
| | | import com.fzzy.gateway.data.BaseResp; |
| | |
| | | import com.fzzy.gateway.hx2023.data.WeightInfo; |
| | | import com.fzzy.gateway.hx2023.kafka.KafkaDeviceReportService; |
| | | import com.fzzy.mqtt.MqttGatewayService; |
| | | import jdk.nashorn.internal.runtime.regexp.joni.Config; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.springframework.stereotype.Component; |
| | |
| | | private KafkaDeviceReportService kafkaDeviceReportService; |
| | | @Resource |
| | | private MqttGatewayService publishService; |
| | | @Resource |
| | | private ConfigData configData; |
| | | |
| | | @Override |
| | | public String getProtocol() { |
| | |
| | | |
| | | String topic = ScConstant.TOPIC_REPORT; |
| | | topic = topic.replace("${productId}", reqData.getProductId()).replace("${deviceId}", reqData.getDeviceId()); |
| | | |
| | | //如果是测试模式不执行推送 |
| | | if (configData.getActive().indexOf("dev") >= 0) { |
| | | |
| | | log.info("----------------------------推送MQTT粮情信息,注:调试模式不推送---------------------------"); |
| | | log.info("-----TOPIC-----{}", topic); |
| | | log.info("-----Message-----{}", reqData.getData()); |
| | | |
| | | return new BaseResp(); |
| | | } |
| | | |
| | | publishService.publishMqttWithTopic(reqData.getData(), topic); |
| | | |
| | |
| | | @Override |
| | | public BaseResp reportGrainDataByKafka(BaseReqData reqData) { |
| | | String topic = ScConstant.TOPIC_MESSAGE_REPORT; |
| | | //如果是测试模式不执行推送 |
| | | if (configData.getActive().indexOf("dev") >= 0) { |
| | | |
| | | log.info("----------------------------推送KAFKA粮情信息,注:调试模式不推送---------------------------"); |
| | | log.info("-----TOPIC-----{}", topic); |
| | | log.info("-----Message-----{}", reqData.getData()); |
| | | |
| | | return new BaseResp(); |
| | | } |
| | | |
| | | kafkaDeviceReportService.publishWithTopic(reqData.getData(), topic); |
| | | return new BaseResp(); |
| | | } |