From 38a1f1d2a75d18278baf1f6cddd4ade98ac0d842 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Fri, 12 Jan 2024 16:44:18 +0800 Subject: [PATCH] =?UTF-8?q?#=E6=B0=B4=E7=94=B5=E7=AB=99=E5=8F=91=E7=94=B5?= =?UTF-8?q?=E9=87=8F=E5=85=B3=E8=81=94=E6=95=B0=E6=8D=AE=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operational/census/service/impl/TargetServiceImpl.java | 2 +- .../operational/fill/service/impl/GenerateServiceImpl.java | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java index 169fe70..a7a0deb 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java @@ -1242,7 +1242,7 @@ public class TargetServiceImpl implements TargetService { detail.setElectric(Double.valueOf(mon.getPower())); return detail; } - detail.setElectric((double) (monMap.get(mon.getStrMonth()) + mon.getPower())); + detail.setElectric((double) (Optional.ofNullable(monMap.get(mon.getStrMonth())).orElse(0f) + mon.getPower())); return detail; }).collect(Collectors.toList()); }else if(HomePageConstant.MON.equals(type)){ diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java index 8ed3a73..cd315be 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java @@ -178,7 +178,12 @@ public class GenerateServiceImpl extends BaseServiceImplrecord.getFillDate().equals(day)).mapToDouble(GenerateEntity::getGenerate).sum()); + double sum = records.stream().filter(record->record.getFillDate().equals(day)).mapToDouble(GenerateEntity::getGenerate).sum(); + if(Math.abs(sum) > 0){ + powerDay.setGenerate((float)sum); + }else{ + powerDay.setGenerate(0f); + } return powerDay; }).collect(Collectors.toList()); } @@ -231,7 +236,12 @@ public class GenerateServiceImpl extends BaseServiceImplo.getFillDate().equals(mon)).mapToDouble(GenerateEntity::getGenerate).sum()); + double sum = format.stream().filter(o->o.getFillDate().equals(mon)).mapToDouble(GenerateEntity::getGenerate).sum(); + if(Math.abs(sum) > 0){ + powerMonth.setPower((float)sum); + }else{ + powerMonth.setPower(0f); + } return powerMonth; }).collect(Collectors.toList()); }