From a5fa8b3b273c810dbf1a952fc4453dd55f42611b Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Tue, 20 Aug 2024 15:38:13 +0800 Subject: [PATCH] =?UTF-8?q?#=E9=A6=96=E9=A1=B5=E6=8E=A5=E5=8F=A3=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../homePage/hydroelectric/vo/HydroelectricDeviceVo.java | 2 +- .../homePage/hydroelectric/vo/HydroelectricPowerRainVo.java | 2 +- .../homePage/service/impl/HydroelectricServiceImpl.java | 11 +++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java index f3ce2b7..ec21858 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.operational.homePage.Hydroelectric.vo; +package com.hnac.hzims.operational.homePage.hydroelectric.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java index a2aae0e..2fcb5e3 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.operational.homePage.Hydroelectric.vo; +package com.hnac.hzims.operational.homePage.hydroelectric.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java index cbec557..b0a24f1 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java @@ -721,7 +721,9 @@ public class HydroelectricServiceImpl implements HydroelectricService { private List stationPowerRains(List devices, List> rains) { List generates = new ArrayList<>(); devices.forEach(device->{ - generates.addAll(device.getGenerates()); + if(CollectionUtil.isNotEmpty(device.getGenerates())){ + generates.addAll(device.getGenerates()); + } }); Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DAY_OF_MONTH,-1); @@ -737,7 +739,12 @@ public class HydroelectricServiceImpl implements HydroelectricService { // 日期 powerRain.setDate(DateUtil.format(calendar.getTime(),"yyyy-MM-dd")); // 发电量 - powerRain.setGenerate(generates.stream().filter(o-> powerRain.getDate().equals(o.getDate())).mapToDouble(HydroelectricDeviceGenerateVo::getGenerate).sum()); + if(CollectionUtil.isEmpty(generates)){ + powerRain.setGenerate(0.0); + }else{ + powerRain.setGenerate(generates.stream().filter(o-> powerRain.getDate().equals(o.getDate())).mapToDouble(HydroelectricDeviceGenerateVo::getGenerate).sum()); + + } // 降雨量 if(CollectionUtil.isNotEmpty(rains)){ powerRain.setRain(rains.stream().mapToDouble(map->{