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