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 d92a06aa3..7e3188ce1 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 @@ -237,91 +237,7 @@ public class HistoryResultServiceImpl implements HistoryResultService { objectListData.add(list); } - ; - //下面代码稳定后可删除 - /* List aList = harmonicHistoryDataList.stream() - .filter(temp -> temp.getPhasicType().equalsIgnoreCase(InfluxDBTableConstant.PHASE_TYPE_A)) - .collect(Collectors.toList()); - List bList = harmonicHistoryDataList.stream() - .filter(temp -> temp.getPhasicType().equalsIgnoreCase(InfluxDBTableConstant.PHASE_TYPE_B)) - .collect(Collectors.toList()); - List cList = harmonicHistoryDataList.stream() - .filter(temp -> temp.getPhasicType().equalsIgnoreCase(InfluxDBTableConstant.PHASE_TYPE_C)) - .collect(Collectors.toList()); - - int maxSize = Math.max(aList.size(), Math.max(bList.size(), cList.size())); - if (maxSize == aList.size()) { - time = aList.stream() - .map(temp -> PubUtils.instantToDate(temp.getTime())) - .collect(Collectors.toList()); - } else if (maxSize == bList.size()) { - time = bList.stream() - .map(temp -> PubUtils.instantToDate(temp.getTime())) - .collect(Collectors.toList()); - } else { - time = cList.stream() - .map(temp -> PubUtils.instantToDate(temp.getTime())) - .collect(Collectors.toList()); - } - - - aValue = aList.stream() - .map(temp -> BigDecimal.valueOf(temp.getAValue()).setScale(4, RoundingMode.HALF_UP).floatValue()) - .collect(Collectors.toList()); - bValue = bList.stream() - .map(temp -> BigDecimal.valueOf(temp.getAValue()).setScale(4, RoundingMode.HALF_UP).floatValue()) - .collect(Collectors.toList()); - cValue = cList.stream() - .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)); - 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 = 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.setMaxValue(maxI); historyDataResultVO.setMinValue(minI); historyDataResultVO.setTopLimit(queryResultLimitVO.getTopLimit()); @@ -529,6 +445,7 @@ public class HistoryResultServiceImpl implements HistoryResultService { targetName = "基波电压幅值"; sql = "SELECT time as time, v_1 as aValue ," + InfluxDBTableConstant.PHASIC_TYPE + " FROM data_harmrate_v WHERE " + stringBuilder + " and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') order by time asc tz('Asia/Shanghai');"; + unit.add(pqsDeviceUnit.getPhaseVoltage()); } else { targetName = "谐波电压含有率"; sql = "SELECT time as time, v_" + number + " as aValue ," + InfluxDBTableConstant.PHASIC_TYPE + " FROM data_harmrate_v WHERE " + stringBuilder + @@ -536,6 +453,7 @@ public class HistoryResultServiceImpl implements HistoryResultService { if (number < 26) { topLimit = PubUtils.getValueByMethod(overlimit, "getUharm", number); } + unit.add("%"); } if (ptType == 0) { phasicType.add("A相"); @@ -546,7 +464,7 @@ public class HistoryResultServiceImpl implements HistoryResultService { phasicType.add("BC相"); phasicType.add("CA相"); } - unit.add("%"); + break; case 41: @@ -555,15 +473,18 @@ public class HistoryResultServiceImpl implements HistoryResultService { targetName = "谐波电流幅值"; sql = "SELECT time as time, i_1 as aValue ," + InfluxDBTableConstant.PHASIC_TYPE + " FROM data_harmrate_i WHERE " + stringBuilder + " and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') order by time asc tz('Asia/Shanghai');"; + + unit.add("A"); } else { targetName = "谐波电流含有率"; sql = "SELECT time as time, i_" + number + " as aValue ," + InfluxDBTableConstant.PHASIC_TYPE + " FROM data_harmrate_i WHERE " + stringBuilder + " and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') order by time asc tz('Asia/Shanghai');"; + unit.add("%"); } phasicType.add("A相"); phasicType.add("B相"); phasicType.add("C相"); - unit.add("%"); + break; case 42: