趋势图bug

This commit is contained in:
2023-10-18 16:14:36 +08:00
parent 736ad700a6
commit 8c34b295d0

View File

@@ -216,23 +216,53 @@ public class HistoryResultServiceImpl implements HistoryResultService {
.map(temp -> BigDecimal.valueOf(temp.getAValue()).setScale(4, RoundingMode.HALF_UP).floatValue())
.collect(Collectors.toList());
//组装二维数组
boolean flagA = true,flagB = true,flagC =true;
if(CollectionUtil.isEmpty(aValue)){
flagA = false;
}
if(CollectionUtil.isEmpty(bValue)){
flagB = false;
}
if(CollectionUtil.isEmpty(cValue)){
flagC = false;
}
for (int i = 0; i < time.size(); i++) {
List<Object> objects = new ArrayList<>();
//指定
objects.add(time.get(i));
objects.add(aValue.get(i));
objects.add(bValue.get(i));
objects.add(cValue.get(i));
if(flagA){
objects.add(aValue.get(i));
}
if(flagB) {
objects.add(bValue.get(i));
}
if(flagC) {
objects.add(cValue.get(i));
}
objectListData.add(objects);
}
Float aValueMin = Collections.min(aValue);
Float bValueMin = Collections.min(bValue);
Float cValueMin = Collections.min(cValue);
Float aValueMax = Collections.max(aValue);
Float bValueMax = Collections.max(bValue);
Float cValueMax = Collections.max(cValue);
historyDataResultVO.setMinValue((aValueMin < bValueMin) ? ((aValueMin < cValueMin) ? aValueMin : cValueMin) : ((bValueMin < cValueMin) ? bValueMin : cValueMin));
historyDataResultVO.setMaxValue(aValueMax > bValueMax ? (aValueMax > cValueMax ? aValueMax : bValueMax) : (bValueMax > cValueMax ? bValueMax : cValueMax));
Float aValueMin = CollectionUtil.isEmpty(aValue) ? null : Collections.min(aValue);
Float bValueMin = CollectionUtil.isEmpty(bValue) ? null : Collections.min(bValue);
Float cValueMin = CollectionUtil.isEmpty(cValue) ? null : Collections.min(cValue);
Float aValueMax = CollectionUtil.isEmpty(aValue) ? null : Collections.max(aValue);
Float bValueMax = CollectionUtil.isEmpty(bValue) ? null : Collections.max(bValue);
Float cValueMax = CollectionUtil.isEmpty(cValue) ? null : Collections.max(cValue);
List<Float> list = Arrays.asList(aValueMin, bValueMin, cValueMin, aValueMax, bValueMax, cValueMax);
Optional<Float> min = list.stream()
.filter(Objects::nonNull) // 过滤掉null值
.min(Float::compareTo);
if (min.isPresent()) {
historyDataResultVO.setMinValue(min.get());
}
Optional<Float> max = list.stream()
.filter(Objects::nonNull) // 过滤掉null值
.max(Float::compareTo);
if (min.isPresent()) {
historyDataResultVO.setMaxValue(max.get());
}
historyDataResultVO.setTopLimit(queryResultLimitVO.getTopLimit());
historyDataResultVO.setLowerLimit(queryResultLimitVO.getLowerLimit());
historyDataResultVO.setValue(objectListData);
@@ -309,7 +339,7 @@ public class HistoryResultServiceImpl implements HistoryResultService {
case 11:
//线电压有效值
sql = "SELECT time as time, rms_lvr as aValue ," + InfluxDBTableConstant.PHASIC_TYPE + " FROM data_v WHERE " + stringBuilder +
" and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') group by phasic_type order by time asc tz('Asia/Shanghai');";
" and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') group by phasic_type order by time asc tz('Asia/Shanghai');";
phasicType.add("AB相");
phasicType.add("BC相");
phasicType.add("CA相");