vince
2023-11-09 bf57ab9e4db58dbee018268dd8b593ee564bc7ee
src/main/java/com/fzzy/gateway/service/GatewayDeviceService2.java
@@ -11,9 +11,11 @@
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;
@@ -31,7 +33,7 @@
    @Resource
    private GatewayRemoteManager gatewayRemoteManager;
    @Resource
    private MqttPublishService publishService;
    private MqttGatewayService publishService;
    public List<GatewayDevice> listAll() {
        Sort sort = new Sort(Sort.Direction.ASC, "deviceId");
@@ -86,6 +88,7 @@
    @Expose
    public String ajaxTestGrain2(GatewayDevice data) {
        SyncReqData reqData = new SyncReqData();
        reqData.setDevice(data);
        reqData.setAutoReplay(true);
@@ -98,6 +101,10 @@
            return "ERROR:当前设备非粮情设备不支持当前操作";
        }
        if(StringUtils.isEmpty(data.getCableRule())){
            return "ERROR:当前设备没有配置布线规则,无法执行";
        }
        BaseResp resp = gatewayRemoteManager.getSyncGrainService(data.getSyncProtocol()).syncGrain2(reqData);
        //自动推送
@@ -105,10 +112,13 @@
            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:执行完成";
    }