From 46d8078a0978123a53066c9189fbfbd183856cf1 Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Wed, 15 May 2024 11:13:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=EF=BC=9A=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E6=9C=88=E6=8A=A5=E5=8F=91=E7=94=B5=E9=87=8F=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/MainSystemMonitoringServiceImpl.java | 1 + .../service/impl/OperStationMonthReportServiceImpl.java | 15 ++++++++++----- .../java/com/hnac/hzims/operational/util/ObjectUtils.java | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainSystemMonitoringServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainSystemMonitoringServiceImpl.java index ea01dee..171d8bc 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainSystemMonitoringServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainSystemMonitoringServiceImpl.java @@ -1360,6 +1360,7 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer String currentMon = TimeUtils.getMon(year, mon); Integer count=0; Map> powerMapThree = (Map>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA); + log.info("Redis近三年发电量数据查询:"+powerMapThree); for (Map.Entry> deviceMap : powerMapThree.entrySet()) { for (StationEntity stationEntity : stationEntityList) { if (stationEntity.getId().equals(deviceMap.getKey())) { diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/OperStationMonthReportServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/OperStationMonthReportServiceImpl.java index 7e7de11..4ea709d 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/OperStationMonthReportServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/OperStationMonthReportServiceImpl.java @@ -344,16 +344,19 @@ public class OperStationMonthReportServiceImpl implements IOperStationMonthRepor Integer currentYear = calendar.get(Calendar.YEAR); if (year>currentYear-3) { mainSystemMonitoringService.getElectricSituationByRedis(yearAndMonth, reportVOS, stationEntityList); + log.info("电站发电情况"+reportVOS.toString()); }else { stationEntityList.forEach(stationEntity -> { List stationReportVOList = mainSystemMonitoringService.getElectricSituationV2(yearAndMonth, stationEntity.getCode()); reportVOS.addAll(stationReportVOList); }); + log.info("电站发电情况"+reportVOS.toString()); } getSumStationRunReport(reportVOS); stationReportAllVo.setStationReportVOList(reportVOS); + log.info("电站发电量总览"+reportVOS.toString()); }catch (Exception e){ - log.error("", e); + log.error("getStationMonthReportV2电站发电量报错", e); System.out.println(e); }finally { countDownLatch.countDown(); @@ -523,11 +526,12 @@ public class OperStationMonthReportServiceImpl implements IOperStationMonthRepor stationRunReportVO.setStationName("合计"); if (CollectionUtil.isNotEmpty(reportVOS)){ double sumPowerMonPlan = reportVOS.stream().mapToDouble(StationRunReportVO::getPowerMonPlan).sum(); - stationRunReportVO.setPowerMonPlan(sumPowerMonPlan); + stationRunReportVO.setPowerMonPlan(new BigDecimal(sumPowerMonPlan).setScale(2,BigDecimal.ROUND_UP).doubleValue()); double sumFinishPowerMon = reportVOS.stream().map(StationRunReportVO::getFinishPowerMon).mapToDouble(s -> Double.valueOf(s)).sum(); - stationRunReportVO.setFinishPowerMon(String.valueOf(sumFinishPowerMon)); + stationRunReportVO.setFinishPowerMon(new BigDecimal(sumFinishPowerMon).setScale(2,BigDecimal.ROUND_UP).toString()); if (!ObjectUtils.isEmpty(sumPowerMonPlan)) { - BigDecimal powerMonRate = new BigDecimal(sumFinishPowerMon).divide(new BigDecimal(sumPowerMonPlan)).setScale(2, BigDecimal.ROUND_UP); + BigDecimal powerMonRate = new BigDecimal(sumFinishPowerMon).divide(new BigDecimal(sumPowerMonPlan),4,BigDecimal.ROUND_UP) + .multiply(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_UP); stationRunReportVO.setPowerMonRate(String.valueOf(powerMonRate)); }else { stationRunReportVO.setPowerMonRate("0.0"); @@ -537,7 +541,8 @@ public class OperStationMonthReportServiceImpl implements IOperStationMonthRepor double sumFinishPowerYear = reportVOS.stream().map(StationRunReportVO::getFinishPowerYear).mapToDouble(s -> Double.valueOf(s)).sum(); stationRunReportVO.setFinishPowerYear(String.valueOf(sumFinishPowerYear)); if (!ObjectUtils.isEmpty(sumPowerYearPlan)){ - BigDecimal powerYearRate = new BigDecimal(sumFinishPowerYear).divide(new BigDecimal(sumPowerYearPlan)).setScale(2, BigDecimal.ROUND_UP); + BigDecimal powerYearRate = new BigDecimal(sumFinishPowerYear).divide(new BigDecimal(sumPowerYearPlan),4,BigDecimal.ROUND_UP) + .multiply(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_UP); stationRunReportVO.setPowerYearRate(String.valueOf(powerYearRate)); }else { stationRunReportVO.setPowerYearRate("0.0"); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/ObjectUtils.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/ObjectUtils.java index 341e2d5..cd140eb 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/ObjectUtils.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/ObjectUtils.java @@ -85,7 +85,7 @@ public class ObjectUtils { public static BigDecimal objDivide(String s){ BigDecimal bigDecimal = new BigDecimal(s); - BigDecimal res = bigDecimal.divide(new BigDecimal(10000)).setScale(2, BigDecimal.ROUND_UP); + BigDecimal res = bigDecimal.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP).setScale(2, BigDecimal.ROUND_UP); return res; } }