From af8b1c438979d4ff355c4b1c8bfd4a17ed7ad4d2 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Wed, 29 May 2024 14:28:49 +0800 Subject: [PATCH] =?UTF-8?q?#=E6=B0=B4=E7=94=B5=E7=AB=99=E6=9C=88=E6=8A=A5?= =?UTF-8?q?=E5=8F=91=E7=94=B5=E9=87=8F=E5=B0=8F=E6=95=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../report/service/impl/RunMonthServiceImpl.java | 53 +++++++++++++++++----- 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java index fe5149c..60c6d4d 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java @@ -110,19 +110,30 @@ public class RunMonthServiceImpl extends BaseServiceImpl run = JSONObject.parseObject(entity.getRunData(),new TypeReference>(){}); - if(CollectionUtil.isEmpty(run)){ + List runs = JSONObject.parseObject(entity.getRunData(),new TypeReference>(){}); + if(CollectionUtil.isEmpty(runs)){ return data; } - double monSumGenerate = run.stream().mapToDouble(RunDataVo::getGenerate).sum(); - double monSumPlan = run.stream().mapToDouble(RunDataVo::getPlan).sum(); + // 保留两位小数 + data.setRunData(JSONObject.toJSONString(runs.stream().map(run->{ + // 月发电量 + run.setGenerate(BigDecimal.valueOf(run.getGenerate()).setScale(2, RoundingMode.HALF_UP).doubleValue()); + // 年发电量 + run.setGenerateYear(BigDecimal.valueOf(run.getGenerateYear()).setScale(2, RoundingMode.HALF_UP).doubleValue()); + return run; + }).collect(Collectors.toList()))); + + // 月发电量完成率 + double monSumGenerate = runs.stream().mapToDouble(RunDataVo::getGenerate).sum(); + double monSumPlan = runs.stream().mapToDouble(RunDataVo::getPlan).sum(); data.setMonSumGenerate(monSumGenerate); data.setMonSumPlan(monSumPlan); if(Math.abs(monSumGenerate) > 0 && Math.abs(monSumPlan) > 0){ data.setMonRate(BigDecimal.valueOf(monSumGenerate / monSumPlan * 100L).setScale(2, RoundingMode.HALF_UP).doubleValue()); } - double yearSumGenerate = run.stream().mapToDouble(RunDataVo::getGenerateYear).sum(); - double yearSumPlan = run.stream().mapToDouble(RunDataVo::getPlanYear).sum(); + // 年发电量完成率 + double yearSumGenerate = runs.stream().mapToDouble(RunDataVo::getGenerateYear).sum(); + double yearSumPlan = runs.stream().mapToDouble(RunDataVo::getPlanYear).sum(); data.setYearSumGenerate(yearSumGenerate); data.setYearSumPlan(yearSumPlan); if(Math.abs(yearSumGenerate) > 0 && Math.abs(yearSumPlan) > 0){ @@ -131,7 +142,6 @@ public class RunMonthServiceImpl extends BaseServiceImpl runs = JSONObject.parseObject(data.getRunData(),new TypeReference>(){}); + if(CollectionUtil.isNotEmpty(runs)){ + // 保留两位小数 + data.setRunData(JSONObject.toJSONString(runs.stream().map(run->{ + // 月发电量 + run.setGenerate(BigDecimal.valueOf(run.getGenerate()).setScale(2, RoundingMode.HALF_UP).doubleValue()); + // 年发电量 + run.setGenerateYear(BigDecimal.valueOf(run.getGenerateYear()).setScale(2, RoundingMode.HALF_UP).doubleValue()); + return run; + }).collect(Collectors.toList()))); + } // 创建Excel文件 // 表头、sheet页、文件名 String headerName = data.getStationName() + "运行月报(" + mon + ")"; @@ -211,7 +232,15 @@ public class RunMonthServiceImpl extends BaseServiceImpl runDatas = new ArrayList<>(); + List curveEcharts = new ArrayList<>(); + for (RideDeviceVo device : devices){ + // 运行数据 + runDatas.add(this.runData(station.getCode(),device,plans,start,end)); + // 月度运行曲线 + curveEcharts.add(this.curveData(device,start,end)); + } + /*CountDownLatch countDownLatch = new CountDownLatch(devices.size()); List runDatas = new CopyOnWriteArrayList<>(); List curveEcharts = new CopyOnWriteArrayList<>(); for (RideDeviceVo device : devices){ @@ -220,8 +249,8 @@ public class RunMonthServiceImpl extends BaseServiceImpl