统计报表-收益报表:统一逻辑,电表尖、峰、平、谷差值直接乘以对应类型电价

This commit is contained in:
zq
2025-12-23 14:43:17 +08:00
parent 289fbc4d3a
commit d0bab53dee
2 changed files with 25 additions and 50 deletions

View File

@ -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;

View File

@ -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,55 +344,32 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService
@Override
public List<AmmeterRevenueStatisListVo> getAmmeterRevenueDataResult(StatisAmmeterDateRequest requestVo) {
String siteId = requestVo.getSiteId();
String startTime = DateUtils.getDayBeginString(requestVo.getStartTime());
String endTime = DateUtils.getDayEndString(requestVo.getEndTime());
List<AmmeterRevenueStatisListVo> resultList = new ArrayList<>();
List<AmmeterStatisListVo> dataList = new ArrayList<>();
//查询电价配置
List<EnergyPriceConfigVo> 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<AmmeterStatisListVo> dataList = this.getAmmeterDataResult(requestVo);
if (CollectionUtils.isEmpty(dataList)) {
return Collections.emptyList();
}
Map<String, List<EnergyPriceConfigVo>> priceConfigMap = priceConfigList.stream().collect(Collectors.groupingBy(EnergyPriceConfigVo::getYearMonth));
Map<String, List<AmmeterStatisListVo>> ammeterMap = dataList.stream().collect(Collectors.groupingBy(AmmeterStatisListVo::getDataTime));
List<LocalDate> dateList = generateTargetDates(requestVo.getStartTime(), requestVo.getEndTime());
dateList.forEach(date -> {
String dateTime = date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
List<EnergyPriceConfigVo> priceConfigs = priceConfigMap.get(dateTime.substring(0, 7));
List<AmmeterStatisListVo> ammeterStatisListVos = ammeterMap.get(dateTime);
resultList.add(calculateDailyBill(siteId, dateTime, ammeterStatisListVos, priceConfigs));
dataList.forEach(ammeter -> {
List<EnergyPriceConfigVo> priceConfigs = priceConfigMap.get(ammeter.getDataTime().substring(0, 7));
resultList.add(calculateDailyBill(ammeter, priceConfigs));
});
return resultList;
}
public static AmmeterRevenueStatisListVo calculateDailyBill(String siteId, String dateTime, List<AmmeterStatisListVo> ammeterList, List<EnergyPriceConfigVo> priceList) {
public static AmmeterRevenueStatisListVo calculateDailyBill(AmmeterStatisListVo ammeter, List<EnergyPriceConfigVo> 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()));
@ -403,7 +379,6 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService
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;