河北闪变算法调整

This commit is contained in:
wr
2026-03-02 10:11:01 +08:00
parent d83f0746ac
commit 40b0951756

View File

@@ -1,5 +1,6 @@
package com.njcn.prepare.harmonic.service.mysql.Impl.line; 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.DatePattern;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil; import cn.hutool.core.date.LocalDateTimeUtil;
@@ -26,7 +27,10 @@ import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/** /**
* Description: * Description:
@@ -1851,10 +1855,15 @@ public class DayDataServiceImpl implements DayDataService {
.groupBy(DataPlt::getLineId, DataPlt::getPhaseType, DataPlt::getQualityFlag, DataPlt::getValueType) .groupBy(DataPlt::getLineId, DataPlt::getPhaseType, DataPlt::getQualityFlag, DataPlt::getValueType)
.between(DataPlt::getTime, startTime, endTime); .between(DataPlt::getTime, startTime, endTime);
List<DataPlt> result1 = dataPltMapper.getStatisticsByWraper(influxQueryWrapper); List<DataPlt> result1 = dataPltMapper.getStatisticsByWraper(influxQueryWrapper);
result1.forEach(item -> { if(CollUtil.isNotEmpty(result1)){
item.setValueType(InfluxDbSqlConstant.MIN); Map<String, List<DataPlt>> collect = result1.stream().collect(Collectors.groupingBy(DataPlt::getPhaseType));
}); collect.forEach((key, value) -> {
result.addAll(result1); value.sort(Comparator.comparing(DataPlt::getPlt));
DataPlt dataPlt = value.get(0);
dataPlt.setValueType(InfluxDbSqlConstant.MIN);
result.add(dataPlt);
});
}
//最大值 //最大值
InfluxQueryWrapper influxQueryWrapper2 = new InfluxQueryWrapper(DataPlt.class); InfluxQueryWrapper influxQueryWrapper2 = new InfluxQueryWrapper(DataPlt.class);
influxQueryWrapper2.regular(DataPlt::getLineId, lineIndex) influxQueryWrapper2.regular(DataPlt::getLineId, lineIndex)
@@ -1862,10 +1871,15 @@ public class DayDataServiceImpl implements DayDataService {
.groupBy(DataPlt::getLineId, DataPlt::getPhaseType, DataPlt::getQualityFlag, DataPlt::getValueType) .groupBy(DataPlt::getLineId, DataPlt::getPhaseType, DataPlt::getQualityFlag, DataPlt::getValueType)
.between(DataPlt::getTime, startTime, endTime); .between(DataPlt::getTime, startTime, endTime);
List<DataPlt> result2 = dataPltMapper.getStatisticsByWraper(influxQueryWrapper2); List<DataPlt> result2 = dataPltMapper.getStatisticsByWraper(influxQueryWrapper2);
result2.forEach(item -> { if(CollUtil.isNotEmpty(result2)){
item.setValueType(InfluxDbSqlConstant.MAX); Map<String, List<DataPlt>> collect = result2.stream().collect(Collectors.groupingBy(DataPlt::getPhaseType));
}); collect.forEach((key, value) -> {
result.addAll(result2); value.sort(Comparator.comparing(DataPlt::getPlt).reversed());
DataPlt dataPlt = value.get(0);
dataPlt.setValueType(InfluxDbSqlConstant.MAX);
result.add(dataPlt);
});
}
//平均值 //平均值
InfluxQueryWrapper influxQueryWrapper3 = new InfluxQueryWrapper(DataPlt.class); InfluxQueryWrapper influxQueryWrapper3 = new InfluxQueryWrapper(DataPlt.class);
influxQueryWrapper3.regular(DataPlt::getLineId, lineIndex) influxQueryWrapper3.regular(DataPlt::getLineId, lineIndex)
@@ -1873,10 +1887,16 @@ public class DayDataServiceImpl implements DayDataService {
.groupBy(DataPlt::getLineId, DataPlt::getPhaseType, DataPlt::getQualityFlag, DataPlt::getValueType) .groupBy(DataPlt::getLineId, DataPlt::getPhaseType, DataPlt::getQualityFlag, DataPlt::getValueType)
.between(DataPlt::getTime, startTime, endTime); .between(DataPlt::getTime, startTime, endTime);
List<DataPlt> result3 = dataPltMapper.getStatisticsByWraper(influxQueryWrapper3); List<DataPlt> result3 = dataPltMapper.getStatisticsByWraper(influxQueryWrapper3);
result3.forEach(item -> { if(CollUtil.isNotEmpty(result3)){
item.setValueType(InfluxDbSqlConstant.AVG_WEB); Map<String, List<DataPlt>> collect = result3.stream().collect(Collectors.groupingBy(DataPlt::getPhaseType));
}); collect.forEach((key, value) -> {
result.addAll(result3); double asDouble = value.stream().mapToDouble(DataPlt::getPlt).average().getAsDouble();
DataPlt dataPlt = value.get(0);
dataPlt.setValueType(InfluxDbSqlConstant.AVG_WEB);
dataPlt.setPlt(asDouble);
result.add(dataPlt);
});
}
//CP95(取平均值的CP95值) //CP95(取平均值的CP95值)
InfluxQueryWrapper influxQueryWrapper4 = new InfluxQueryWrapper(DataPlt.class); InfluxQueryWrapper influxQueryWrapper4 = new InfluxQueryWrapper(DataPlt.class);
influxQueryWrapper4.regular(DataPlt::getLineId, lineIndex) influxQueryWrapper4.regular(DataPlt::getLineId, lineIndex)
@@ -1884,10 +1904,15 @@ public class DayDataServiceImpl implements DayDataService {
.groupBy(DataPlt::getLineId, DataPlt::getPhaseType, DataPlt::getQualityFlag, DataPlt::getValueType) .groupBy(DataPlt::getLineId, DataPlt::getPhaseType, DataPlt::getQualityFlag, DataPlt::getValueType)
.between(DataPlt::getTime, startTime, endTime); .between(DataPlt::getTime, startTime, endTime);
List<DataPlt> result4 = dataPltMapper.getStatisticsByWraper(influxQueryWrapper4); List<DataPlt> result4 = dataPltMapper.getStatisticsByWraper(influxQueryWrapper4);
result4.forEach(item -> { if(CollUtil.isNotEmpty(result4)){
item.setValueType(InfluxDbSqlConstant.CP95); Map<String, List<DataPlt>> collect = result4.stream().collect(Collectors.groupingBy(DataPlt::getPhaseType));
}); collect.forEach((key, value) -> {
result.addAll(result4); value.sort(Comparator.comparing(DataPlt::getPlt).reversed());
DataPlt dataPlt = value.get(0);
dataPlt.setValueType(InfluxDbSqlConstant.CP95);
result.add(dataPlt);
});
}
return result; return result;
} }