From 6495040bbda5308c86e852ad1b080097bfa916a9 Mon Sep 17 00:00:00 2001 From: vince <757871790@qq.com> Date: 星期三, 09 七月 2025 09:22:17 +0800 Subject: [PATCH] 优化粮温检测 --- src/main/java/com/fzzy/protocol/bhzn/v01/analysis/AnalysisService.java | 66 +++++++++++++++++++++----------- 1 files changed, 43 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/fzzy/protocol/bhzn/v01/analysis/AnalysisService.java b/src/main/java/com/fzzy/protocol/bhzn/v01/analysis/AnalysisService.java index 575fc67..cf2db68 100644 --- a/src/main/java/com/fzzy/protocol/bhzn/v01/analysis/AnalysisService.java +++ b/src/main/java/com/fzzy/protocol/bhzn/v01/analysis/AnalysisService.java @@ -278,7 +278,7 @@ int cableY = cableData.getCableY(); int cableX = cableData.getCableX(); - int sumNum = temps.size(); + int sumNum = 0; //鏁版嵁灏佽 GrainData grain = new GrainData(); @@ -319,16 +319,26 @@ temperature.add(new GrainTemp(cableNum + "", z + "", curTemp + "", position + "")); //姹傛渶澶ф渶灏忓�� - if (curTemp < -900) { - sumNum--; - } else { +// if (curTemp < -900) { +// sumNum--; +// } else { +// sumT += curTemp; +// if (curTemp > max) { +// max = curTemp; +// } +// if (curTemp < min) { +// min = curTemp; +// } +// } + if (curTemp > max && curTemp < 40) { + max = curTemp; + } + if (curTemp < min && curTemp > 3) { + min = curTemp; + } + if(curTemp > 3 && curTemp < 40){ sumT += curTemp; - if (curTemp > max) { - max = curTemp; - } - if (curTemp < min) { - min = curTemp; - } + sumNum++; } } @@ -347,7 +357,7 @@ outPut.setTemperature(temperature); outPut.setAvgTemperature(NumberUtil.keepPrecision((sumT / sumNum), 1) + ""); outPut.setMinTemperature(min + ""); - outPut.setMaxTemperature(min + ""); + outPut.setMaxTemperature(max + ""); JSONObject properties = new JSONObject(); @@ -413,7 +423,7 @@ GrainOutPut outPut = new GrainOutPut(); - double max = ReMessageBuilder.MAX_TEMP, min = ReMessageBuilder.MIN_TEMP, sumT = 0.0, sumNum = cableData.getSumNum(); + double max = ReMessageBuilder.MAX_TEMP, min = ReMessageBuilder.MIN_TEMP, sumT = 0.0, sumNum = 0; List<GrainTemp> temperature = new ArrayList<>(); //鏍瑰彿 @@ -435,16 +445,26 @@ temperature.add(new GrainTemp(cableNum + "", z + "", curTemp + "", position + "")); //姹傛渶澶ф渶灏忓�� - if (curTemp < -900) { - sumNum--; - } else { +// if (curTemp < -900) { +// sumNum--; +// } else { +// sumT += curTemp; +// if (curTemp > max) { +// max = curTemp; +// } +// if (curTemp < min) { +// min = curTemp; +// } +// } + if (curTemp > max && curTemp < 40) { + max = curTemp; + } + if (curTemp < min && curTemp > 3) { + min = curTemp; + } + if(curTemp > 3 && curTemp < 40){ sumT += curTemp; - if (curTemp > max) { - max = curTemp; - } - if (curTemp < min) { - min = curTemp; - } + sumNum++; } } @@ -480,13 +500,13 @@ weatherStation.setMessageId(ScConstant.getMessageId()); weatherStation.setMessgeId(weatherStation.getMessageId()); - if (null != gatewayDeviceWeather) { + if (null != gatewayDeviceWeather) { weatherStation.setId(gatewayDeviceWeather.getDeviceId()); } else { 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()); -- Gitblit v1.9.3