From c0ddfbbfa207c4fadc2eeed17b9e95844b812430 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Tue, 27 Feb 2024 16:33:03 +0800 Subject: [PATCH] =?UTF-8?q?#=E5=85=89=E4=BC=8F=E6=95=B0=E6=8D=AEbug?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operation/home/impl/RealTargetServiceImpl.java | 6 ++++ .../main/service/impl/PhotovoltaicServiceImpl.java | 38 ++++++++++++---------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java index 21a72c7..70bd210 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java @@ -447,6 +447,9 @@ public class RealTargetServiceImpl implements RealTargetService { real.setState(this.getPhotovoltaicState(device, map)); // 容量 real.setCapacity(device.getInstalledCapacity()); + if(MapUtils.isEmpty(device.getPoint())){ + return real; + } // 发电量 real.setGenerate(this.getSignageValue(device, map, HomePageConstant.PV_GENERATION_CAPACITY)); // 功率 @@ -585,6 +588,9 @@ public class RealTargetServiceImpl implements RealTargetService { // 接入站点设备统计 devices.forEach(device -> { PhotovoltaicTargetVo target = new PhotovoltaicTargetVo(); + if(MapUtils.isEmpty(device.getPoint())){ + return; + } target.setDeptId(device.getCreateDept()); target.setDeviceCode(device.getEmCode()); target.setDeviceName(device.getName()); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java index 65d58b8..ad6829c 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java @@ -698,7 +698,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { // 容量 kpi.setInstalledCapacity(reals.stream().mapToDouble(PhotovoltaicRealVo::getCapacity).sum()); // 负荷 - kpi.setLoad(reals.stream().mapToDouble(PhotovoltaicRealVo::getLoad).sum()); + kpi.setLoad(reals.stream().filter(o-> !ObjectUtil.isEmpty(o.getLoad())).mapToDouble(PhotovoltaicRealVo::getLoad).sum()); } } // 指标数据 @@ -945,7 +945,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { subordinate.setStationCount((long) entry.getValue().size()); subordinate.setStationUseCount(reals.stream().filter(device -> device.getState() == 1).map(PhotovoltaicRealVo::getDeptId).distinct().count()); subordinate.setCapacity(reals.stream().mapToDouble(PhotovoltaicRealVo::getCapacity).sum()); - subordinate.setLoad(reals.stream().mapToDouble(PhotovoltaicRealVo::getLoad).sum()); + subordinate.setLoad(reals.stream().filter(o-> !ObjectUtil.isEmpty(o.getLoad())).mapToDouble(PhotovoltaicRealVo::getLoad).sum()); } // 区域/站点 设备指标数据 if (deviceTargets != null) { @@ -1514,31 +1514,35 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { return; } // 容量 - photovoltaic.setCapacity(photovoltaic.getDevices().stream().mapToDouble(PhotovoltaicDeviceVo::getCapacity).sum()); + photovoltaic.setCapacity(photovoltaic.getDevices().stream().filter(o->!ObjectUtil.isEmpty(o.getCapacity())).mapToDouble(PhotovoltaicDeviceVo::getCapacity).sum()); // 总发电量 - photovoltaic.setGenerate(photovoltaic.getDevices().stream().mapToDouble(PhotovoltaicDeviceVo::getGenerate).sum()); - // 收益 - photovoltaic.setIncome(photovoltaic.getGenerate() * 0.34); + photovoltaic.setGenerate(photovoltaic.getDevices().stream().filter(o->!ObjectUtil.isEmpty(o.getGenerate())).mapToDouble(PhotovoltaicDeviceVo::getGenerate).sum()); + // // 收益 + if(ObjectUtil.isEmpty(photovoltaic.getGenerate())){ + photovoltaic.setIncome(0.0); + }else{ + photovoltaic.setIncome(photovoltaic.getGenerate() * 0.34); + } // 年发电量 - photovoltaic.setGenerateYear(photovoltaic.getDevices().stream().mapToDouble(PhotovoltaicDeviceVo::getGenerateYear).sum()); + photovoltaic.setGenerateYear(photovoltaic.getDevices().stream().filter(o->!ObjectUtil.isEmpty(o.getGenerateYear())).mapToDouble(PhotovoltaicDeviceVo::getGenerateYear).sum()); // 月发电量 - photovoltaic.setGenerateMon(photovoltaic.getDevices().stream().mapToDouble(PhotovoltaicDeviceVo::getGenerateMon).sum()); + photovoltaic.setGenerateMon(photovoltaic.getDevices().stream().filter(o->!ObjectUtil.isEmpty(o.getGenerateMon())).mapToDouble(PhotovoltaicDeviceVo::getGenerateMon).sum()); // 日发电量 - photovoltaic.setGenerateDay(photovoltaic.getDevices().stream().mapToDouble(PhotovoltaicDeviceVo::getGenerateDay).sum()); + photovoltaic.setGenerateDay(photovoltaic.getDevices().stream().filter(o->!ObjectUtil.isEmpty(o.getGenerateDay())).mapToDouble(PhotovoltaicDeviceVo::getGenerateDay).sum()); // 功率 - photovoltaic.setLoad(photovoltaic.getDevices().stream().mapToDouble(PhotovoltaicDeviceVo::getLoad).sum()); - double generationDay = photovoltaic.getDevices().stream().mapToDouble(PhotovoltaicDeviceVo::getGenerateDay).sum(); - double generationYesterday = photovoltaic.getDevices().stream().mapToDouble(PhotovoltaicDeviceVo::getGenerationYesterday).sum(); + photovoltaic.setLoad(photovoltaic.getDevices().stream().filter(o->!ObjectUtil.isEmpty(o.getLoad())).mapToDouble(PhotovoltaicDeviceVo::getLoad).sum()); + double generationDay = photovoltaic.getDevices().stream().filter(o->!ObjectUtil.isEmpty(o.getGenerateDay())).mapToDouble(PhotovoltaicDeviceVo::getGenerateDay).sum(); + double generationYesterday = photovoltaic.getDevices().stream().filter(o->!ObjectUtil.isEmpty(o.getGenerationYesterday())).mapToDouble(PhotovoltaicDeviceVo::getGenerationYesterday).sum(); // 环比发电量 - if (Math.abs(generationDay) <= 0 || Math.abs(generationYesterday) <= 0) { + if (ObjectUtil.isEmpty(generationDay) || ObjectUtil.isEmpty(generationYesterday) || Math.abs(generationDay) <= 0 || Math.abs(generationYesterday) <= 0) { photovoltaic.setGenerateDayRatio(0.0); } else { photovoltaic.setGenerateDayRatio(BigDecimal.valueOf((generationDay - generationYesterday) / generationYesterday * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); } - double load = photovoltaic.getDevices().stream().mapToDouble(PhotovoltaicDeviceVo::getLoad).sum(); - double lastLoad = photovoltaic.getDevices().stream().mapToDouble(PhotovoltaicDeviceVo::getLastLoad).sum(); + double load = photovoltaic.getDevices().stream().filter(o->!ObjectUtil.isEmpty(o.getLoad())).mapToDouble(PhotovoltaicDeviceVo::getLoad).sum(); + double lastLoad = photovoltaic.getDevices().stream().filter(o->!ObjectUtil.isEmpty(o.getLastLoad())).mapToDouble(PhotovoltaicDeviceVo::getLastLoad).sum(); // 环比功率 - if (Math.abs(load) <= 0 || Math.abs(lastLoad) <= 0) { + if (ObjectUtil.isEmpty(load) || ObjectUtil.isEmpty(lastLoad) || Math.abs(load) <= 0 || Math.abs(lastLoad) <= 0) { photovoltaic.setLoadRatio(0.0); } else { photovoltaic.setLoadRatio(BigDecimal.valueOf((load - lastLoad) / lastLoad * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); @@ -1709,7 +1713,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { // 串流电压12 item.setSe_voltage_twelve(mateReals.get(0).getSe_voltage_twelve()); // 环比功率 - if (Math.abs(mateReals.get(0).getLoad()) <= 0 || mateReals.get(0).getLastLoad() <= 0) { + if (ObjectUtil.isEmpty(mateReals.get(0).getLoad()) || ObjectUtil.isEmpty(mateReals.get(0).getLastLoad()) || Math.abs(mateReals.get(0).getLoad()) <= 0 || mateReals.get(0).getLastLoad() <= 0) { item.setLoadRatio(0.0); } else { item.setLoadRatio(BigDecimal.valueOf((mateReals.get(0).getLoad() - mateReals.get(0).getLastLoad()) / mateReals.get(0).getLastLoad() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());