趋势图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()) .map(temp -> BigDecimal.valueOf(temp.getAValue()).setScale(4, RoundingMode.HALF_UP).floatValue())
.collect(Collectors.toList()); .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++) { for (int i = 0; i < time.size(); i++) {
List<Object> objects = new ArrayList<>(); List<Object> objects = new ArrayList<>();
//指定 //指定
objects.add(time.get(i)); objects.add(time.get(i));
if(flagA){
objects.add(aValue.get(i)); objects.add(aValue.get(i));
}
if(flagB) {
objects.add(bValue.get(i)); objects.add(bValue.get(i));
}
if(flagC) {
objects.add(cValue.get(i)); objects.add(cValue.get(i));
}
objectListData.add(objects); objectListData.add(objects);
} }
Float aValueMin = Collections.min(aValue); Float aValueMin = CollectionUtil.isEmpty(aValue) ? null : Collections.min(aValue);
Float bValueMin = Collections.min(bValue); Float bValueMin = CollectionUtil.isEmpty(bValue) ? null : Collections.min(bValue);
Float cValueMin = Collections.min(cValue); Float cValueMin = CollectionUtil.isEmpty(cValue) ? null : Collections.min(cValue);
Float aValueMax = Collections.max(aValue); Float aValueMax = CollectionUtil.isEmpty(aValue) ? null : Collections.max(aValue);
Float bValueMax = Collections.max(bValue); Float bValueMax = CollectionUtil.isEmpty(bValue) ? null : Collections.max(bValue);
Float cValueMax = Collections.max(cValue); Float cValueMax = CollectionUtil.isEmpty(cValue) ? null : Collections.max(cValue);
historyDataResultVO.setMinValue((aValueMin < bValueMin) ? ((aValueMin < cValueMin) ? aValueMin : cValueMin) : ((bValueMin < cValueMin) ? bValueMin : cValueMin)); List<Float> list = Arrays.asList(aValueMin, bValueMin, cValueMin, aValueMax, bValueMax, cValueMax);
historyDataResultVO.setMaxValue(aValueMax > bValueMax ? (aValueMax > cValueMax ? aValueMax : bValueMax) : (bValueMax > cValueMax ? 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.setTopLimit(queryResultLimitVO.getTopLimit());
historyDataResultVO.setLowerLimit(queryResultLimitVO.getLowerLimit()); historyDataResultVO.setLowerLimit(queryResultLimitVO.getLowerLimit());
historyDataResultVO.setValue(objectListData); historyDataResultVO.setValue(objectListData);