河北算法调整
This commit is contained in:
@@ -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<DataPlt> 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<DataPlt> 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<DataPlt> 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<DataPlt> 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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user