diff --git a/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/service/majornetwork/impl/StatationStatServiceImpl.java b/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/service/majornetwork/impl/StatationStatServiceImpl.java index 0316580ce..960f306b1 100644 --- a/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/service/majornetwork/impl/StatationStatServiceImpl.java +++ b/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/service/majornetwork/impl/StatationStatServiceImpl.java @@ -363,7 +363,7 @@ public class StatationStatServiceImpl extends ServiceImpl getStatationStatList(String orgID) { - if(StrUtil.isBlank(orgID)){ + if (StrUtil.isBlank(orgID)) { throw new BusinessException(PmsDeviceResponseEnum.NO_ID_ORG); } List deptInfos = deptFeignClient.getDeptDescendantIndexes(orgID, Stream.of(0, 1).collect(Collectors.toList())).getData(); @@ -376,7 +376,7 @@ public class StatationStatServiceImpl extends ServiceImpl getStatationStatCurve(String subID,String voltageLevel,Integer type) { + public List getStatationStatCurve(String subID, String voltageLevel, Integer type) { List curves = new ArrayList<>(); if (StrUtil.isBlank(subID)) { throw new BusinessException(PmsDeviceResponseEnum.NO_ID_STATION); @@ -384,21 +384,23 @@ public class StatationStatServiceImpl extends ServiceImpl list = iMonitorService.list(new LambdaQueryWrapper() .eq(Monitor::getPowerrId, subID) - .eq(Monitor::getVoltageLevel,voltageLevel) + .eq(Monitor::getVoltageLevel, voltageLevel) ); - if (CollUtil.isEmpty(list)) { -// String lineId = list.get(0).getLineId(); - addCurves(null,type,curves); + if (CollUtil.isNotEmpty(list)) { + String lineId = list.get(0).getLineId(); + addCurves(lineId, type, curves); - }else { + } else { List disMonitorAllList = distributionMonitorMapper.getDisMonitorAllList(subID, 1); List disMonitors = disMonitorAllList.stream().filter(x -> x.equals(voltageLevel)).collect(Collectors.toList()); - if(CollUtil.isNotEmpty(disMonitors)){ + if (CollUtil.isNotEmpty(disMonitors)) { String monitorId = disMonitors.get(0).getMonitorId(); - addCurves(monitorId,type,curves); + addCurves(monitorId, type, curves); } } - curves.sort(Comparator.comparing(r -> r.getTime())); + if(CollUtil.isNotEmpty(curves)){ + curves.sort(Comparator.comparing(r -> r.getTime())); + } return curves; } @@ -429,35 +431,36 @@ public class StatationStatServiceImpl extends ServiceImpl addCurves(String LineID,Integer type,List curves){ - if(type==0){ + private List addCurves(String LineID, Integer type, List curves) { + if (type == 0) { List dataV = iDataVService.getHarmonicDataV(LineID, DateUtil.beginOfDay(DateUtil.date()).toString() , DateUtil.endOfDay(DateUtil.date()).toString()); - if(CollUtil.isNotEmpty(dataV)){ + if (CollUtil.isNotEmpty(dataV)) { Map collect = dataV.stream().collect(Collectors.toMap(DataV::getTime, DataV::getVThd, (c1, c2) -> c1 > c2 ? c1 : c2)); - collect.forEach((key,value)->{ - StatationStatVO.Curve curve =new StatationStatVO.Curve(); + collect.forEach((key, value) -> { + StatationStatVO.Curve curve = new StatationStatVO.Curve(); curve.setTime(Date.from(key)); - curve.setNum( BigDecimal.valueOf(value).setScale(3, RoundingMode.HALF_UP)); + curve.setNum(BigDecimal.valueOf(value).setScale(3, RoundingMode.HALF_UP)); curves.add(curve); }); } - }else{ + } else { List dataHarmPowerP = dataHarmPowerPService.getHarmonicPowerP(LineID, DateUtil.beginOfDay(DateUtil.date()).toString() , DateUtil.endOfDay(DateUtil.date()).toString()); - if(CollUtil.isNotEmpty(dataHarmPowerP)){ + if (CollUtil.isNotEmpty(dataHarmPowerP)) { Map dataHarmPowerPMap = dataHarmPowerP.stream().collect(Collectors.toMap(DataHarmPowerP::getTime, DataHarmPowerP::getP, (c1, c2) -> c1 > c2 ? c1 : c2)); - dataHarmPowerPMap.forEach((key,value)->{ - StatationStatVO.Curve curve =new StatationStatVO.Curve(); + dataHarmPowerPMap.forEach((key, value) -> { + StatationStatVO.Curve curve = new StatationStatVO.Curve(); curve.setTime(Date.from(key)); - curve.setNum( BigDecimal.valueOf(value).setScale(3, RoundingMode.HALF_UP)); + curve.setNum(BigDecimal.valueOf(value).setScale(3, RoundingMode.HALF_UP)); curves.add(curve); }); }