From d0bab53dee28eb004e874f87927b0954420ee2b7 Mon Sep 17 00:00:00 2001 From: zq Date: Tue, 23 Dec 2025 14:43:17 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=8A=A5=E8=A1=A8-=E6=94=B6?= =?UTF-8?q?=E7=9B=8A=E6=8A=A5=E8=A1=A8=EF=BC=9A=E7=BB=9F=E4=B8=80=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E7=94=B5=E8=A1=A8=E5=B0=96=E3=80=81=E5=B3=B0?= =?UTF-8?q?=E3=80=81=E5=B9=B3=E3=80=81=E8=B0=B7=E5=B7=AE=E5=80=BC=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E4=B9=98=E4=BB=A5=E5=AF=B9=E5=BA=94=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E7=94=B5=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/domain/vo/AmmeterStatisListVo.java | 18 +++--- .../impl/EmsStatsReportServiceImpl.java | 57 ++++++------------- 2 files changed, 25 insertions(+), 50 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterStatisListVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterStatisListVo.java index 405e144..d53917c 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterStatisListVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterStatisListVo.java @@ -11,7 +11,7 @@ public class AmmeterStatisListVo { /** 类别 */ private String dataTime; - private String timePart; +// private String timePart; /** 组合有功-总 (kWh) */ private BigDecimal activeTotalKwh = BigDecimal.ZERO; @@ -53,14 +53,14 @@ public class AmmeterStatisListVo { public void setDataTime(String dataTime) { this.dataTime = dataTime; } - - public String getTimePart() { - return timePart; - } - - public void setTimePart(String timePart) { - this.timePart = timePart; - } +// +// public String getTimePart() { +// return timePart; +// } +// +// public void setTimePart(String timePart) { +// this.timePart = timePart; +// } public BigDecimal getActiveTotalKwh() { return activeTotalKwh; diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index 2cf1a3e..d190306 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -1,7 +1,6 @@ package com.xzzn.ems.service.impl; import com.xzzn.common.enums.CostType; -import com.xzzn.common.enums.SiteEnum; import com.xzzn.common.utils.DateUtils; import com.xzzn.ems.domain.EmsAmmeterData; import com.xzzn.ems.domain.vo.AmmeterRevenueStatisListVo; @@ -345,65 +344,41 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService @Override public List getAmmeterRevenueDataResult(StatisAmmeterDateRequest requestVo) { String siteId = requestVo.getSiteId(); - String startTime = DateUtils.getDayBeginString(requestVo.getStartTime()); - String endTime = DateUtils.getDayEndString(requestVo.getEndTime()); List resultList = new ArrayList<>(); - List dataList = new ArrayList<>(); //查询电价配置 List priceConfigList = emsEnergyPriceConfigMapper.getConfigListByTimeFrame(siteId, requestVo.getStartTime(), requestVo.getEndTime()); if (CollectionUtils.isEmpty(priceConfigList)){ return Collections.emptyList(); } //查询电表数据 - if (SiteEnum.FX.getCode().equals(siteId)) { - dataList = emsAmmeterDataMapper.selectHourlyAmmeterData(siteId, startTime, endTime); - } else { - // 其他站点暂时默认与电动所内部一致处理,按天查询数据 - dataList = emsAmmeterDataMapper.selectDailyAmmeterData(siteId, startTime, endTime); - } + List dataList = this.getAmmeterDataResult(requestVo); if (CollectionUtils.isEmpty(dataList)) { return Collections.emptyList(); } Map> priceConfigMap = priceConfigList.stream().collect(Collectors.groupingBy(EnergyPriceConfigVo::getYearMonth)); - Map> ammeterMap = dataList.stream().collect(Collectors.groupingBy(AmmeterStatisListVo::getDataTime)); - List dateList = generateTargetDates(requestVo.getStartTime(), requestVo.getEndTime()); - dateList.forEach(date -> { - String dateTime = date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); - List priceConfigs = priceConfigMap.get(dateTime.substring(0, 7)); - List ammeterStatisListVos = ammeterMap.get(dateTime); - resultList.add(calculateDailyBill(siteId, dateTime, ammeterStatisListVos, priceConfigs)); + dataList.forEach(ammeter -> { + List priceConfigs = priceConfigMap.get(ammeter.getDataTime().substring(0, 7)); + resultList.add(calculateDailyBill(ammeter, priceConfigs)); }); return resultList; } - public static AmmeterRevenueStatisListVo calculateDailyBill(String siteId, String dateTime, List ammeterList, List priceList) { + public static AmmeterRevenueStatisListVo calculateDailyBill(AmmeterStatisListVo ammeter, List priceList) { AmmeterRevenueStatisListVo ammeterRevenue = new AmmeterRevenueStatisListVo(); - ammeterRevenue.setDataTime(dateTime); - if (CollectionUtils.isEmpty(ammeterList) || CollectionUtils.isEmpty(priceList)) { + ammeterRevenue.setDataTime(ammeter.getDataTime()); + if (CollectionUtils.isEmpty(priceList)) { return ammeterRevenue; } - if (SiteEnum.FX.getCode().equals(siteId)) { - for (AmmeterStatisListVo ammeter : ammeterList) { - for (EnergyPriceConfigVo priceConfig : priceList) { - if (isInTimeRange(priceConfig.getStartTime(), priceConfig.getEndTime(), ammeter.getTimePart())) { - calculateByCostType(ammeter, priceConfig, ammeterRevenue); - } - } - } - } else { - // 其他站点暂时默认与电动所内部一致处理,按天计算逻辑 - AmmeterStatisListVo ammeter = ammeterList.get(0); - EnergyPriceConfigVo price = priceList.get(0); - ammeterRevenue.setActivePeakPrice(ammeter.getActivePeakKwh().multiply(price.getPeak())); - ammeterRevenue.setActiveHighPrice(ammeter.getActiveHighKwh().multiply(price.getHigh())); - ammeterRevenue.setActiveFlatPrice(ammeter.getActiveFlatKwh().multiply(price.getFlat())); - ammeterRevenue.setActiveValleyPrice(ammeter.getActiveValleyKwh().multiply(price.getValley())); - ammeterRevenue.setReActivePeakPrice(ammeter.getReActivePeakKwh().multiply(price.getPeak())); - ammeterRevenue.setReActiveHighPrice(ammeter.getReActiveHighKwh().multiply(price.getHigh())); - ammeterRevenue.setReActiveFlatPrice(ammeter.getReActiveFlatKwh().multiply(price.getFlat())); - ammeterRevenue.setReActiveValleyPrice(ammeter.getReActiveValleyKwh().multiply(price.getValley())); - } + EnergyPriceConfigVo price = priceList.get(0); + ammeterRevenue.setActivePeakPrice(ammeter.getActivePeakKwh().multiply(price.getPeak())); + ammeterRevenue.setActiveHighPrice(ammeter.getActiveHighKwh().multiply(price.getHigh())); + ammeterRevenue.setActiveFlatPrice(ammeter.getActiveFlatKwh().multiply(price.getFlat())); + ammeterRevenue.setActiveValleyPrice(ammeter.getActiveValleyKwh().multiply(price.getValley())); + ammeterRevenue.setReActivePeakPrice(ammeter.getReActivePeakKwh().multiply(price.getPeak())); + ammeterRevenue.setReActiveHighPrice(ammeter.getReActiveHighKwh().multiply(price.getHigh())); + ammeterRevenue.setReActiveFlatPrice(ammeter.getReActiveFlatKwh().multiply(price.getFlat())); + ammeterRevenue.setReActiveValleyPrice(ammeter.getReActiveValleyKwh().multiply(price.getValley())); ammeterRevenue.setActiveTotalPrice(ammeterRevenue.getActivePeakPrice().add(ammeterRevenue.getActiveHighPrice()).add(ammeterRevenue.getActiveFlatPrice()).add(ammeterRevenue.getActiveValleyPrice())); ammeterRevenue.setReActiveTotalPrice(ammeterRevenue.getReActivePeakPrice().add(ammeterRevenue.getReActiveHighPrice()).add(ammeterRevenue.getReActiveFlatPrice()).add(ammeterRevenue.getReActiveValleyPrice())); return ammeterRevenue;