From 2c3c716607011f618ca9910eebdf33e7b6fcdf51 Mon Sep 17 00:00:00 2001 From: wr <1754607820@qq.com> Date: Thu, 26 Feb 2026 15:41:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B2=B3=E5=8C=97=E7=AE=97=E6=B3=95=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mysql/Impl/line/DayDataServiceImpl.java | 45 ++++++++++++------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/harmonic/service/mysql/Impl/line/DayDataServiceImpl.java b/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/harmonic/service/mysql/Impl/line/DayDataServiceImpl.java index a64fc18db..569375b8a 100644 --- a/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/harmonic/service/mysql/Impl/line/DayDataServiceImpl.java +++ b/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/harmonic/service/mysql/Impl/line/DayDataServiceImpl.java @@ -1,5 +1,6 @@ package com.njcn.prepare.harmonic.service.mysql.Impl.line; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.LocalDateTimeUtil; @@ -26,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; /** @@ -1851,10 +1853,12 @@ public class DayDataServiceImpl implements DayDataService { .groupBy(DataPlt::getLineId, DataPlt::getPhaseType, DataPlt::getQualityFlag, DataPlt::getValueType) .between(DataPlt::getTime, startTime, endTime); List result1 = dataPltMapper.getStatisticsByWraper(influxQueryWrapper); - result1.forEach(item -> { - item.setValueType(InfluxDbSqlConstant.MIN); - }); - result.addAll(result1); + if(CollUtil.isNotEmpty(result1)){ + result1.sort(Comparator.comparing(DataPlt::getPlt)); + DataPlt dataPlt = result1.get(0); + dataPlt.setValueType(InfluxDbSqlConstant.MIN); + result.add(dataPlt); + } //最大值 InfluxQueryWrapper influxQueryWrapper2 = new InfluxQueryWrapper(DataPlt.class); influxQueryWrapper2.regular(DataPlt::getLineId, lineIndex) @@ -1862,10 +1866,13 @@ public class DayDataServiceImpl implements DayDataService { .groupBy(DataPlt::getLineId, DataPlt::getPhaseType, DataPlt::getQualityFlag, DataPlt::getValueType) .between(DataPlt::getTime, startTime, endTime); List result2 = dataPltMapper.getStatisticsByWraper(influxQueryWrapper2); - result2.forEach(item -> { - item.setValueType(InfluxDbSqlConstant.MAX); - }); - result.addAll(result2); + if(CollUtil.isNotEmpty(result2)){ + result2.sort(Comparator.comparing(DataPlt::getPlt).reversed()); + DataPlt dataPlt = result2.get(0); + dataPlt.setValueType(InfluxDbSqlConstant.MAX); + result.add(dataPlt); + } + //平均值 InfluxQueryWrapper influxQueryWrapper3 = new InfluxQueryWrapper(DataPlt.class); influxQueryWrapper3.regular(DataPlt::getLineId, lineIndex) @@ -1873,10 +1880,14 @@ public class DayDataServiceImpl implements DayDataService { .groupBy(DataPlt::getLineId, DataPlt::getPhaseType, DataPlt::getQualityFlag, DataPlt::getValueType) .between(DataPlt::getTime, startTime, endTime); List result3 = dataPltMapper.getStatisticsByWraper(influxQueryWrapper3); - result3.forEach(item -> { - item.setValueType(InfluxDbSqlConstant.AVG_WEB); - }); - result.addAll(result3); + if(CollUtil.isNotEmpty(result3)){ + double asDouble = result3.stream().mapToDouble(DataPlt::getPlt).average().getAsDouble(); + DataPlt dataPlt = result3.get(0); + dataPlt.setValueType(InfluxDbSqlConstant.AVG_WEB); + dataPlt.setPlt(asDouble); + result.add(dataPlt); + } + //CP95(取平均值的CP95值) InfluxQueryWrapper influxQueryWrapper4 = new InfluxQueryWrapper(DataPlt.class); influxQueryWrapper4.regular(DataPlt::getLineId, lineIndex) @@ -1884,10 +1895,12 @@ public class DayDataServiceImpl implements DayDataService { .groupBy(DataPlt::getLineId, DataPlt::getPhaseType, DataPlt::getQualityFlag, DataPlt::getValueType) .between(DataPlt::getTime, startTime, endTime); List result4 = dataPltMapper.getStatisticsByWraper(influxQueryWrapper4); - result4.forEach(item -> { - item.setValueType(InfluxDbSqlConstant.CP95); - }); - result.addAll(result4); + if(CollUtil.isNotEmpty(result4)){ + result4.sort(Comparator.comparing(DataPlt::getPlt).reversed()); + DataPlt dataPlt = result4.get(0); + dataPlt.setValueType(InfluxDbSqlConstant.CP95); + result.add(dataPlt); + } return result; }