vince
2024-07-03 69e8acc5dd1f760eb60e914472c151bfa8126a52
src/main/java/com/fzzy/protocol/bhzn/analysis/AnalysisService.java
@@ -201,13 +201,13 @@
        int sumNum = cableData.getSumNum();
        // 根据层行列获取指定长度
        int start = 0;
        int start = (Integer.valueOf(device.getCableStart()) - 1) *  cableData.getCableZ()  * 4;
        int len = 4 * sumNum;
        log.info("分机------>>>平台:返回粮情完整信息,分机={}", device.getDeviceName());
        String strPoints = grainStr.substring(start, start + len);
        log.info("strPoints = "+ strPoints);
        // 将粮情解析成数组
        List<Double> temps = new ArrayList<>();
        double tempValue;
@@ -278,7 +278,7 @@
        int cableY = cableData.getCableY();
        int sumNum = temps.size();
            log.info("temps:" + temps.toString());
        //数据封装
        GrainData grain = new GrainData();
        grain.setMessageId(ScConstant.getMessageId());
@@ -346,7 +346,7 @@
        outPut.setTemperature(temperature);
        outPut.setAvgTemperature(NumberUtil.keepPrecision((sumT / sumNum), 1) + "");
        outPut.setMinTemperature(min + "");
        outPut.setMaxTemperature(min + "");
        outPut.setMaxTemperature(max + "");
        JSONObject properties = new JSONObject();
@@ -376,7 +376,7 @@
            weatherStation.setId(device.getDeviceId());
        }
        weatherStation.setAirPressure(weather.getPressure());
        weatherStation.setHumidity(weather.getHumidity());
        weatherStation.setHumidity(weather.getHumidity().replaceAll("%",""));
        weatherStation.setPm(weather.getAir_pm25());
        weatherStation.setRadiation("0");
        weatherStation.setRainfallAmount(weather.getWea());
@@ -392,7 +392,7 @@
        grain.setProperties(properties);
        reqData.setData(JSONObject.toJSONString(grain));
        doPushGrain(reqData);
        doPushGrain(reqData,grain);
    }
    /**
@@ -521,7 +521,7 @@
            weatherStation.setId(device.getDeviceId());
        }
        weatherStation.setAirPressure(weather.getPressure());
        weatherStation.setHumidity(weather.getHumidity());
        weatherStation.setHumidity(weather.getHumidity().replaceAll("%",""));
        weatherStation.setPm(weather.getAir_pm25());
        weatherStation.setRadiation("0");
        weatherStation.setRainfallAmount(weather.getWea());
@@ -537,10 +537,10 @@
        reqData.setData(JSONObject.toJSONString(grain));
        doPushGrain(reqData);
        doPushGrain(reqData,grain);
    }
    private void doPushGrain(BaseReqData reqData) {
    private void doPushGrain(BaseReqData reqData,GrainData grainData) {
        GatewayDeviceReportService reportService = gatewayRemoteManager.getDeviceReportService(reqData.getDevice().getPushProtocol());
        if (null == reportService) {
@@ -548,6 +548,8 @@
            return;
        }
        reportService.reportGrainData(reqData);
        reqData.setData(reportService.grainData2GatewayApiInfoKafka(grainData,reqData.getDevice()).getData());
        reportService.reportGrainDataByKafka(reqData);
    }