From 8c34b295d02aaf717d7c16ea7f185500a08d825b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=A8=E6=9C=A8c?= <857448963@qq.com> Date: Wed, 18 Oct 2023 16:14:36 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B6=8B=E5=8A=BF=E5=9B=BEbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/HistoryResultServiceImpl.java | 54 ++++++++++++++----- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/HistoryResultServiceImpl.java b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/HistoryResultServiceImpl.java index 19ee557ba..daace674e 100644 --- a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/HistoryResultServiceImpl.java +++ b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/HistoryResultServiceImpl.java @@ -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 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 list = Arrays.asList(aValueMin, bValueMin, cValueMin, aValueMax, bValueMax, cValueMax); + Optional min = list.stream() + .filter(Objects::nonNull) // 过滤掉null值 + .min(Float::compareTo); + if (min.isPresent()) { + historyDataResultVO.setMinValue(min.get()); + } + + Optional 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相");