jiazx0107@163.com
2023-12-14 8435cf1d25d07b09e2a9937d39bed1c1a422e4f0
src/main/java/com/fzzy/protocol/weightyh/MessageConsumer.java
@@ -1,5 +1,6 @@
package com.fzzy.protocol.weightyh;
import com.fzzy.api.data.GatewayDeviceType;
import com.fzzy.api.utils.BytesUtil;
import com.fzzy.api.utils.SpringUtil;
import com.fzzy.gateway.GatewayUtils;
@@ -35,7 +36,7 @@
     */
    public void analysisInfo(String ip, Integer port, byte[] bytes) {
        String strMsg = BytesUtil.bytesToString(bytes);
        //log.debug("开始解析地磅返回信息=" + strMsg);
        if (strMsg.length() < 22) {
            return;
        }
@@ -56,12 +57,11 @@
        //最终重量结果
        double weigh = Double.valueOf(w) / d;
        log.debug("WEIGHT-MESSAGE=" + strMsg);
        log.debug("----------地磅称重数值解析------{}", weigh);
        //当前地磅协议不支持传递SN,使用局域网IP作为SN
        String sn = ip;
        //根据信息获取设备
        GatewayDevice device = GatewayUtils.getCacheByDeviceSn(sn);
@@ -83,7 +83,10 @@
        reqData.setProductId(device.getProductId());
        reqData.setDeviceName(device.getDeviceName());
        reqData.setWeight(weigh);
        gatewayRemoteManager.getDeviceReportService(device.getPushProtocol()).reportWeightData(reqData);
        if (weigh > 0) {
            gatewayRemoteManager.getDeviceReportService(device.getPushProtocol()).reportWeightData(reqData);
        }
    }
    /**