Commit 7439c39d authored by ZWT's avatar ZWT

feat(零碳): 长庆

1.修改极短期间开预测定时任务逻辑,解决优化后部分优化结果时间段过短问题;
2.修改心知天气气象数据获取及接收定时任务,解决天气数据通过邮件下载后,部分数据精度丢失问题;
3.修改首页各个接口逻辑,对小数类型字段进行处理,修改首页接口,增加小时保留两位四舍五入逻辑,同时解决线路详情接口部分查询逻辑报错问题;
4.能耗分析模块,能耗概览接口修改,修改查询逻辑,修改数据获取逻辑及绿电占比计算逻辑;
5.能耗分析模块,消纳曲线用电趋势接口修改,修改查询逻辑,修改数据获取逻辑及绿电占比计算逻辑;
6.能耗分析模块,用电详情接口修改,修改查询逻辑,修改数据获取逻辑及绿电占比计算逻辑;

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent 6be71d8e
...@@ -16,7 +16,6 @@ import pps.cloud.system.service.data.GetSysOrganizationViewOutput; ...@@ -16,7 +16,6 @@ import pps.cloud.system.service.data.GetSysOrganizationViewOutput;
import pps.core.prediction.entity.EnergyConsumptionAnalysisEnt; import pps.core.prediction.entity.EnergyConsumptionAnalysisEnt;
import pps.core.prediction.entity.ThirdDailyAccumulationUpdateEnt; import pps.core.prediction.entity.ThirdDailyAccumulationUpdateEnt;
import pps.core.prediction.enums.BusinessError; import pps.core.prediction.enums.BusinessError;
import pps.core.prediction.mapper.EnergyConsumptionAnalysisMapper;
import pps.core.prediction.mapper.ThirdDailyAccumulationUpdateMapper; import pps.core.prediction.mapper.ThirdDailyAccumulationUpdateMapper;
import pps.core.prediction.service.data.energy_consumption_analysis.*; import pps.core.prediction.service.data.energy_consumption_analysis.*;
import xstartup.annotation.XService; import xstartup.annotation.XService;
...@@ -136,19 +135,19 @@ public class EnergyConsumptionAnalysisService { ...@@ -136,19 +135,19 @@ public class EnergyConsumptionAnalysisService {
@XApiGet @XApiGet
public XPageResult<QueryEnergyConsumptionAnalysisViewOutput> queryEnergyConsumptionAnalysisView(XContext context, QueryEnergyConsumptionAnalysisPageInput input) { public XPageResult<QueryEnergyConsumptionAnalysisViewOutput> queryEnergyConsumptionAnalysisView(XContext context, QueryEnergyConsumptionAnalysisPageInput input) {
List<QueryEnergyConsumptionAnalysisViewOutput> outputs = new ArrayList<>(input.getLimit()); List<QueryEnergyConsumptionAnalysisViewOutput> outputs = new ArrayList<>(input.getLimit());
List<EnergyConsumptionAnalysisEnt> list; List<ThirdDailyAccumulationUpdateEnt> list;
List<DynamicQueryBasePowerLineOutput> lineList = this.getBasePowerLineListByOuIdList(context, this.getOrgIdsByPath(context, input.getOuId())); List<DynamicQueryBasePowerLineOutput> lineList = this.getBasePowerLineListByOuIdList(context, this.getOrgIdsByPath(context, input.getOuId()));
if (CollUtil.isNotEmpty(lineList)) { if (CollUtil.isNotEmpty(lineList)) {
Map<String, String> lineMap = lineList.stream() List<String> lineNameList = lineList.stream()
.collect(Collectors.toMap(DynamicQueryBasePowerLineOutput::getId, DynamicQueryBasePowerLineOutput::getLineName)); .map(DynamicQueryBasePowerLineOutput::getLineName)
Set<String> lineIds = lineMap.keySet(); .collect(Collectors.toList());
PageHelper.startPage(input.getPage(), input.getLimit()); PageHelper.startPage(input.getPage(), input.getLimit());
input.getBetweenDate(); input.getBetweenDate();
EnergyConsumptionAnalysisMapper mapper = context.getBean(EnergyConsumptionAnalysisMapper.class); ThirdDailyAccumulationUpdateMapper mapper = context.getBean(ThirdDailyAccumulationUpdateMapper.class);
Date startTime = input.getStartTime(); Date startTime = input.getStartTime();
Date endTime = input.getEndTime(); Date endTime = input.getEndTime();
//查本期数据 //查本期数据
list = mapper.selectList(this.getQueryWrapper4Page(lineIds, startTime, endTime)); list = mapper.selectList(this.getQueryWrapper4Page(lineNameList, startTime, endTime));
if (CollUtil.isNotEmpty(list)) { if (CollUtil.isNotEmpty(list)) {
PageHelper.clearPage(); PageHelper.clearPage();
//查上期数据 //查上期数据
...@@ -169,34 +168,40 @@ public class EnergyConsumptionAnalysisService { ...@@ -169,34 +168,40 @@ public class EnergyConsumptionAnalysisService {
default: default:
throw new XServiceException(BusinessError.DateTypeError); throw new XServiceException(BusinessError.DateTypeError);
} }
List<EnergyConsumptionAnalysisEnt> periodList = mapper.selectList(this.getQueryWrapper4Page(lineIds, startTime, endTime)); List<ThirdDailyAccumulationUpdateEnt> periodList = mapper.selectList(this.getQueryWrapper4Page(lineNameList, startTime, endTime));
if (CollUtil.isNotEmpty(periodList)) { if (CollUtil.isNotEmpty(periodList)) {
for (EnergyConsumptionAnalysisEnt ent : list) { for (ThirdDailyAccumulationUpdateEnt ent : list) {
EnergyConsumptionAnalysisEnt period = Optional.ofNullable(CollUtil.findOne(periodList, x -> CharSequenceUtil.equals(ent.getLineId(), x.getLineId()))) EnergyConsumptionAnalysisEnt period;
.orElse(EnergyConsumptionAnalysisEnt.builder() ThirdDailyAccumulationUpdateEnt one = CollUtil.findOne(periodList, x -> CharSequenceUtil.equals(ent.getStationName(), x.getStationName()));
if (Objects.isNull(one)) {
period = EnergyConsumptionAnalysisEnt.builder()
.powerConsumption(BigDecimal.ZERO) .powerConsumption(BigDecimal.ZERO)
.powerGeneration(BigDecimal.ZERO) .powerGeneration(BigDecimal.ZERO)
.build()); .build();
} else {
period = EnergyConsumptionAnalysisEnt.builder()
.powerConsumption(one.getDailyElectricityConsumption())
.powerGeneration(one.getPhotovoltaicPower())
.build();
}
outputs.add(QueryEnergyConsumptionAnalysisViewOutput.builder() outputs.add(QueryEnergyConsumptionAnalysisViewOutput.builder()
.lineId(ent.getLineId()) .lineName(ent.getStationName())
.lineName(lineMap.get(ent.getLineId())) .powerGeneration(ent.getPhotovoltaicPower())
.powerGeneration(ent.getPowerGeneration()) .generationCycleRatio(this.getCycleRatio(ent.getPhotovoltaicPower(), period.getPowerGeneration()))
.generationCycleRatio(this.getCycleRatio(ent.getPowerGeneration(), period.getPowerGeneration())) .powerConsumption(ent.getDailyElectricityConsumption())
.powerConsumption(ent.getPowerConsumption()) .consumptionCycleRatio(this.getCycleRatio(ent.getDailyElectricityConsumption(), period.getPowerConsumption()))
.consumptionCycleRatio(this.getCycleRatio(ent.getPowerConsumption(), period.getPowerConsumption())) .absorptionRate(this.getAbsorptionRate(ent.getInPlaceConsumption(), ent.getDailyElectricityConsumption()))
.absorptionRate(this.getAbsorptionRate(ent.getPowerGeneration(), ent.getPowerConsumption()))
.build()); .build());
} }
} else { } else {
for (EnergyConsumptionAnalysisEnt ent : list) { for (ThirdDailyAccumulationUpdateEnt ent : list) {
outputs.add(QueryEnergyConsumptionAnalysisViewOutput.builder() outputs.add(QueryEnergyConsumptionAnalysisViewOutput.builder()
.lineId(ent.getLineId()) .lineName(ent.getStationName())
.lineName(lineMap.get(ent.getLineId())) .powerGeneration(ent.getPhotovoltaicPower())
.powerGeneration(ent.getPowerGeneration())
.generationCycleRatio(BigDecimal.ZERO) .generationCycleRatio(BigDecimal.ZERO)
.powerConsumption(ent.getPowerConsumption()) .powerConsumption(ent.getDailyElectricityConsumption())
.consumptionCycleRatio(BigDecimal.ZERO) .consumptionCycleRatio(BigDecimal.ZERO)
.absorptionRate(this.getAbsorptionRate(ent.getPowerGeneration(), ent.getPowerConsumption())) .absorptionRate(this.getAbsorptionRate(ent.getInPlaceConsumption(), ent.getDailyElectricityConsumption()))
.build()); .build());
} }
} }
...@@ -204,7 +209,7 @@ public class EnergyConsumptionAnalysisService { ...@@ -204,7 +209,7 @@ public class EnergyConsumptionAnalysisService {
} else { } else {
list = new ArrayList<>(0); list = new ArrayList<>(0);
} }
PageInfo<EnergyConsumptionAnalysisEnt> pageInfo = new PageInfo<>(list); PageInfo<ThirdDailyAccumulationUpdateEnt> pageInfo = new PageInfo<>(list);
return XPageResult.success(outputs, input, pageInfo.getTotal()); return XPageResult.success(outputs, input, pageInfo.getTotal());
} }
...@@ -213,21 +218,23 @@ public class EnergyConsumptionAnalysisService { ...@@ -213,21 +218,23 @@ public class EnergyConsumptionAnalysisService {
/** /**
* 分页功能封装查询条件 * 分页功能封装查询条件
* *
* @param lineIds 线路ID * @param lineNames 线路名称
* @param startTime 开始时间 * @param startTime 开始时间
* @param endTime 结束时间 * @param endTime 结束时间
* @return {@link LambdaQueryWrapper}<{@link EnergyConsumptionAnalysisEnt}> * @return {@link LambdaQueryWrapper}<{@link EnergyConsumptionAnalysisEnt}>
*/ */
private LambdaQueryWrapper<EnergyConsumptionAnalysisEnt> getQueryWrapper4Page(Collection<String> lineIds, Date startTime, Date endTime) { private LambdaQueryWrapper<ThirdDailyAccumulationUpdateEnt> getQueryWrapper4Page(Collection<String> lineNames, Date startTime, Date endTime) {
return new QueryWrapper<EnergyConsumptionAnalysisEnt>() return new QueryWrapper<ThirdDailyAccumulationUpdateEnt>()
.select("IFNULL( SUM( power_generation ), 0 ) AS power_generation", .select("IFNULL( SUM( photovoltaic_power ), 0 ) AS photovoltaic_power",
"IFNULL( SUM( power_consumption ), 0 ) AS power_consumption", "IFNULL( SUM( daily_electricity_consumption ), 0 ) AS daily_electricity_consumption",
"line_id") "IFNULL( SUM( daily_liquid_production ), 0 ) AS daily_liquid_production",
"IFNULL( SUM( in_place_consumption ), 0 ) AS in_place_consumption",
"station_name")
.lambda() .lambda()
.in(EnergyConsumptionAnalysisEnt::getLineId, lineIds) .in(ThirdDailyAccumulationUpdateEnt::getStationName, lineNames)
.between(EnergyConsumptionAnalysisEnt::getDataDate, startTime, endTime) .between(ThirdDailyAccumulationUpdateEnt::getCreateDate, startTime, endTime)
.groupBy(EnergyConsumptionAnalysisEnt::getLineId) .groupBy(ThirdDailyAccumulationUpdateEnt::getStationName)
.orderByAsc(EnergyConsumptionAnalysisEnt::getPowerGeneration); .orderByAsc(ThirdDailyAccumulationUpdateEnt::getPhotovoltaicPower);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment