From d6af8db1870c88fbc46574a3e5a6e8fc18a07c87 Mon Sep 17 00:00:00 2001 From: tyty Date: Thu, 7 Dec 2023 18:14:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B0=B4=E7=94=B5=E7=AB=99?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E6=9C=88=E6=8A=A5=E5=AF=BC=E5=87=BA=E7=B2=BE?= =?UTF-8?q?=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/service/impl/AreaMonthReportServiceImpl.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java index 0a84df8..d3eb8c2 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java @@ -685,24 +685,26 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { //今年发电量 powerYear=value.entrySet().stream().filter(s->listByYear.contains(s.getKey())).map(s->BigDecimal.valueOf(s.getValue())).reduce(BigDecimal.ZERO, BigDecimal::add); //转换单位kwh-》万Kwh - powerYear=powerYear.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP); + powerYear=powerYear.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP).setScale(2,BigDecimal.ROUND_UP); powerYearBefore=value.entrySet().stream().filter(s->listByYearBefore.contains(s.getKey())).map(s->BigDecimal.valueOf(s.getValue())).reduce(BigDecimal.ZERO, BigDecimal::add); - powerYearBefore=powerYearBefore.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP); + powerYearBefore=powerYearBefore.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP).setScale(2,BigDecimal.ROUND_UP); powerMonth=value.entrySet().stream().filter(s->monStart.equals(s.getKey())).map(s->BigDecimal.valueOf(s.getValue())).reduce(BigDecimal.ZERO, BigDecimal::add); - powerMonth=powerMonth.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP); + powerMonth=powerMonth.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP).setScale(2,BigDecimal.ROUND_UP); powerMonthBefore=value.entrySet().stream().filter(s->monStartMonBefore.equals(s.getKey())).map(s->BigDecimal.valueOf(s.getValue())).reduce(BigDecimal.ZERO, BigDecimal::add); - powerMonthBefore=powerMonthBefore.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP); + powerMonthBefore=powerMonthBefore.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP).setScale(2,BigDecimal.ROUND_UP); powerMonthYearBefore=value.entrySet().stream().filter(s->monStartYearBefore.equals(s.getKey())).map(s->BigDecimal.valueOf(s.getValue())).reduce(BigDecimal.ZERO, BigDecimal::add); - powerMonthYearBefore=powerMonthYearBefore.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP); + powerMonthYearBefore=powerMonthYearBefore.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP).setScale(2,BigDecimal.ROUND_UP).setScale(2,BigDecimal.ROUND_UP); powerVo.setPowerYear(powerYear.doubleValue()); powerVo.setPowerYearBefore(powerYearBefore.doubleValue()); BigDecimal yearPercentage = new BigDecimal(0); BigDecimal planPercentage = new BigDecimal(0); if (powerYearBefore.compareTo(BigDecimal.ZERO) != 0) { yearPercentage = (powerYear.subtract(powerYearBefore)).divide(powerYearBefore, 2, BigDecimal.ROUND_UP); + yearPercentage.setScale(2, BigDecimal.ROUND_UP); } if (BigDecimal.valueOf(planGeneration).compareTo(BigDecimal.ZERO) != 0) { planPercentage = powerYear.divide(BigDecimal.valueOf(planGeneration), 2, BigDecimal.ROUND_UP); + planPercentage.setScale(2, BigDecimal.ROUND_UP); } powerVo.setPlanPercentage(planPercentage.doubleValue()); powerVo.setPowerYearPercentage(yearPercentage.doubleValue()); @@ -712,6 +714,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { BigDecimal monPercentage = new BigDecimal(0); if (powerMonthYearBefore.compareTo(BigDecimal.ZERO) != 0) { monPercentage = (powerMonth.subtract(powerMonthYearBefore)).divide(powerMonthYearBefore, 2, BigDecimal.ROUND_UP); + monPercentage.setScale(2, BigDecimal.ROUND_UP); } powerVo.setPowerMonPercentage(monPercentage.doubleValue()); powerPercentageVoList.add(powerVo);