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

This commit is contained in:
zq
2025-12-23 15:43:53 +08:00
parent eb6f44dd93
commit 4f43b043ac
3 changed files with 48 additions and 16 deletions

View File

@ -1,11 +1,13 @@
package com.xzzn.ems.mapper;
import com.xzzn.ems.domain.EmsDailyEnergyData;
import com.xzzn.ems.domain.vo.AmmeterRevenueStatisListVo;
import com.xzzn.ems.domain.vo.AmmeterStatisListVo;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import com.xzzn.ems.domain.EmsDailyEnergyData;
import com.xzzn.ems.domain.vo.AmmeterStatisListVo;
import org.apache.ibatis.annotations.Param;
/**
@ -74,4 +76,6 @@ public interface EmsDailyEnergyDataMapper
public BigDecimal getLastTotalRevenue(String siteId);
// fx-获取实时总收益和当日实时收益
public Map<String, BigDecimal> getRealTimeRevenue(String siteId);
public List<AmmeterRevenueStatisListVo> getRevenueDataBySiteId(@Param("siteId") String siteId, @Param("startTime") String startTime, @Param("endTime") String endTime);
}

View File

@ -343,22 +343,14 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService
@Override
public List<AmmeterRevenueStatisListVo> getAmmeterRevenueDataResult(StatisAmmeterDateRequest requestVo) {
String siteId = requestVo.getSiteId();
List<AmmeterRevenueStatisListVo> resultList = new ArrayList<>();
//查询电表数据
List<AmmeterStatisListVo> dataList = this.getAmmeterDataResult(requestVo);
if (CollectionUtils.isEmpty(dataList)) {
List<AmmeterRevenueStatisListVo> resultList = emsDailyEnergyDataMapper.getRevenueDataBySiteId(requestVo.getSiteId(),requestVo.getStartTime(),requestVo.getEndTime());
if (CollectionUtils.isEmpty(resultList)) {
return Collections.emptyList();
}
//查询电价配置
List<EnergyPriceConfigVo> priceConfigList = emsEnergyPriceConfigMapper.getConfigListByTimeFrame(siteId, requestVo.getStartTime(), requestVo.getEndTime());
if (CollectionUtils.isEmpty(priceConfigList)){
return Collections.emptyList();
}
Map<String, List<EnergyPriceConfigVo>> priceConfigMap = priceConfigList.stream().collect(Collectors.groupingBy(EnergyPriceConfigVo::getYearMonth));
dataList.forEach(ammeter -> {
List<EnergyPriceConfigVo> priceConfigs = priceConfigMap.get(ammeter.getDataTime().substring(0, 7));
resultList.add(calculateDailyBill(ammeter, priceConfigs));
//计算每天总收益
resultList.forEach(ammeterRevenue -> {
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 resultList;

View File

@ -232,4 +232,40 @@
where t.site_id = #{siteId}
order by t.data_date desc limit 1
</select>
<select id="getRevenueDataBySiteId" resultType="com.xzzn.ems.domain.vo.AmmeterRevenueStatisListVo">
select
t.data_date as dataTime,
t.peak_charge_diff * pc.peak as activePeakPrice,
t.peak_discharge_diff * pc.peak as reActivePeakPrice,
t.high_charge_diff * pc.high as activeHighPrice,
t.high_discharge_diff * pc.high as reActiveHighPrice,
t.flat_charge_diff * pc.flat as activeFlatPrice,
t.flat_discharge_diff * pc.flat as reActiveFlatPrice,
t.valley_charge_diff * pc.valley as activeValleyPrice,
t.valley_discharge_diff * pc.valley as reActiveValleyPrice
from ems_daily_energy_data t
left join (
select
id, site_id, peak, high, flat, valley,
CONCAT(year, '-', LPAD(month, 2, '0')) as yearMonth
from ems_energy_price_config
where 1=1
<if test="siteId != null">
and site_id = #{siteId}
</if>
order by year, month
) pc on pc.yearMonth = DATE_FORMAT(t.data_date, '%Y-%m')
where 1=1
<if test="siteId != null">
and t.site_id = #{siteId}
</if>
<if test="startTime != null">
and t.data_date &gt;= #{startTime}
</if>
<if test="endTime != null">
and t.data_date &lt;= #{endTime}
</if>
</select>
</mapper>