vince
2023-11-08 397738b8c9cc5d5d89a962b1b5073fe201ebe680
src/main/java/com/fzzy/gateway/service/GatewayDeviceService.java
@@ -1,5 +1,6 @@
package com.fzzy.gateway.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.bstek.dorado.annotation.DataProvider;
import com.bstek.dorado.annotation.DataResolver;
@@ -18,6 +19,7 @@
import com.fzzy.gateway.hx2023.websocket.WebSocketDeviceReport;
import com.fzzy.gateway.service.repository.GatewayDeviceRep;
import com.fzzy.mqtt.MqttPublishService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
@@ -45,7 +47,7 @@
    @Resource
    private GatewayRemoteManager gatewayRemoteManager;
    @Resource
    private WebSocketDeviceReport webSocketDeviceReport;
    private MqttPublishService mqttPublishService;
    /**
     * gatewayDeviceService#listAll
     *
@@ -125,8 +127,9 @@
     * @return
     */
    @Expose
    public String ajaxTestWeight(Map<String, Object> parameter) {
        double weigh = (double) parameter.get("weight");
    public String ajaxTestWeight() {
        //double weigh = (double) parameter.get("weight");
        double weigh = Double.parseDouble("3500.0");
        List<GatewayDevice> devices = listAll();
        if(devices == null || devices.size()<= 0){
            return "没有设备";
@@ -135,6 +138,8 @@
       if(weights == null || weights.size()<= 0){
           return "没有获取到地磅设备";
       }
        String topic = "/device/hx-weigh-big-01/91511424746940066Y001_91511424746940066Y0010000_002_004_002_001/message/property/report";
        for (GatewayDevice device: weights) {
            WebSocketPacket packet = new WebSocketPacket();
@@ -161,8 +166,8 @@
            packet.setTimestamp(System.currentTimeMillis());
            webSocketDeviceReport.sendByPacket(packet);
            topic = "/device/hx-weigh-big-01/"+device.getDeviceId()+"/message/property/report";
            mqttPublishService.publishMsg(topic, JSON.toJSONString(packet));
        }
        return "SUCCESS";
    }