Commit 5088ae21 authored by ZWT's avatar ZWT

feat(零碳): 长庆演示系统新增功能

1.能耗分析模块功能重构,新增今日/昨日/同期电量统计查询接口,添加线上接口文档并完成接口冒烟测试同时添加用例;
2.能耗分析模块功能重构,新增今日天气查询接口,添加线上接口文档并完成接口冒烟测试同时添加用例;
3.能耗分析模块功能重构,新增井场用能分析查询接口,添加线上接口文档并完成接口冒烟测试同时添加用例;
4.能耗分析模块功能重构,新增井场发电趋势查询接口,添加线上接口文档并完成接口冒烟测试同时添加用例;
5.能耗分析模块功能重构,新增井场实时监控查询接口,添加线上接口文档并完成接口冒烟测试同时添加用例;
6.能耗分析模块功能重构,新增本日用电对比查询接口,添加线上接口文档并完成接口冒烟测试同时添加用例;
7.能耗分析模块功能重构,新增发电详情查询接口,添加线上接口文档并完成接口冒烟测试同时添加用例;

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent 62668cb2
...@@ -197,6 +197,114 @@ public class EnergyConsumptionAnalysisService { ...@@ -197,6 +197,114 @@ public class EnergyConsumptionAnalysisService {
/*------------------------------ 井场实时分析 ------------------------------*/ /*------------------------------ 井场实时分析 ------------------------------*/
/**
* 发电详情
*
* @param context 上下文
* @param input 输入
* @return {@link XSingleResult }<{@link GetPowerGenerationDetailOutput }>
*/
@XText("井场实时分析--发电详情")
@XApiGet
public XSingleResult<GetPowerGenerationDetailOutput> powerGenerationDetail(XContext context, GetEnergyConsumptionAnalysisInput input) {
//光伏装机总量(kWh)
BigDecimal photovoltaicPower = BigDecimal.ZERO;
//发电功率(kWh)
BigDecimal powerGeneration;
//累计发电量(kWh)
BigDecimal accumulatePowerGeneration;
//就地消纳电量(KWh)
BigDecimal inPlaceConsumption;
//井场额定功率
BigDecimal operatingLoad = BigDecimal.ZERO;
//开井数量
Integer openWellNumber;
//日累计产液量(m³)
BigDecimal dailyLiquidProduction;
//日累计用电量(KW·h)
BigDecimal dailyElectricityConsumption;
//上网电量
BigDecimal avoidPeakRate;
//用电功率(kWh)
BigDecimal powerConsumption;
//绿电占比
BigDecimal greenElectricityRate;
List<String> orgIds = this.getOrgIdsByPath(context, input.getOuId());
List<DynamicQueryBasePowerLinePlantViewOutput> plantList = this.getPowerLinePlantViewList(context, DynamicQueryBasePowerLinePlantInput.builder()
.ouIds(orgIds)
.build());
Set<String> plantSet = new HashSet<>(plantList.size());
for (DynamicQueryBasePowerLinePlantViewOutput plant : plantList) {
photovoltaicPower.add(plant.getTotalPower());
plantSet.add(plant.getStationName());
}
DateTime today = DateUtil.beginOfDay(DateUtil.date());
//累计发电
ThirdDailyAccumulationUpdateMapper analysisMapper = context.getBean(ThirdDailyAccumulationUpdateMapper.class);
ThirdDailyAccumulationUpdateEnt analysisEnt = analysisMapper.selectOne(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")
.lambda()
.eq(ThirdDailyAccumulationUpdateEnt::getSaveDate, today)
.in(ThirdDailyAccumulationUpdateEnt::getStationName, plantSet)
);
accumulatePowerGeneration = analysisEnt.getPhotovoltaicPower();
inPlaceConsumption = analysisEnt.getInPlaceConsumption();
dailyLiquidProduction = analysisEnt.getDailyLiquidProduction();
dailyElectricityConsumption = analysisEnt.getDailyElectricityConsumption();
greenElectricityRate = this.getAbsorptionRate(analysisEnt.getInPlaceConsumption(), analysisEnt.getDailyElectricityConsumption());
avoidPeakRate = this.divide(analysisEnt.getPhotovoltaicPower(), analysisEnt.getInPlaceConsumption());
//发电功率
ThirdActivePowerDailyUpdateMapper activeMapper = context.getBean(ThirdActivePowerDailyUpdateMapper.class);
ThirdActivePowerDailyUpdateEnt activeEnt = activeMapper.selectOne(new QueryWrapper<ThirdActivePowerDailyUpdateEnt>()
.select("IFNULL( SUM( photovoltaic_power ), 0 ) AS photovoltaic_power")
.lambda()
.eq(ThirdActivePowerDailyUpdateEnt::getSaveDate, today)
.in(ThirdActivePowerDailyUpdateEnt::getStationName, plantSet)
);
powerGeneration = activeEnt.getPhotovoltaicPower();
List<DynamicQueryBasePowerLineWellheadViewOutput> wellheadList = this.getPowerLineWellheadList(context, DynamicQueryBasePowerLineWellheadInput.builder()
.ouIds(orgIds)
.build());
Set<String> wellSet = new HashSet<>(wellheadList.size());
for (DynamicQueryBasePowerLineWellheadViewOutput well : wellheadList) {
operatingLoad.add(well.getRatedPower());
wellSet.add(well.getWellNumber());
}
//用电功率
ThirdWellAvgActivePowerMapper avgMapper = context.getBean(ThirdWellAvgActivePowerMapper.class);
ThirdWellAvgActivePowerEnt activePowerEnt = avgMapper.selectOne(new QueryWrapper<ThirdWellAvgActivePowerEnt>()
.select("IFNULL( SUM( avg_active_power ), 0 ) AS avg_active_power")
.lambda()
.in(ThirdWellAvgActivePowerEnt::getWellNumber, wellSet)
.apply("DATE(input_time) = {0}", today)
);
powerConsumption = activePowerEnt.getAvgActivePower();
//开井数量
ThirdCurrentWellConditionMapper mapper = context.getBean(ThirdCurrentWellConditionMapper.class);
List<ThirdCurrentWellConditionEnt> list = mapper.selectList(new LambdaQueryWrapper<ThirdCurrentWellConditionEnt>()
.in(ThirdCurrentWellConditionEnt::getWellNumber, wellSet)
);
openWellNumber = (int) list.stream()
.filter(l -> CharSequenceUtil.equals(l.getWellStatus(), "开井"))
.count();
return XSingleResult.success(GetPowerGenerationDetailOutput.builder()
.photovoltaicPower(photovoltaicPower)
.powerGeneration(powerGeneration)
.accumulatePowerGeneration(accumulatePowerGeneration)
.inPlaceConsumption(inPlaceConsumption)
.operatingLoad(operatingLoad)
.openWellNumber(openWellNumber)
.dailyLiquidProduction(dailyLiquidProduction)
.dailyElectricityConsumption(dailyElectricityConsumption)
.avoidPeakRate(avoidPeakRate)
.powerConsumption(powerConsumption)
.greenElectricityRate(greenElectricityRate)
.build());
}
/** /**
* 井场实时监控 * 井场实时监控
* *
...@@ -496,6 +604,23 @@ public class EnergyConsumptionAnalysisService { ...@@ -496,6 +604,23 @@ public class EnergyConsumptionAnalysisService {
.orderByAsc(ThirdDailyAccumulationUpdateEnt::getPhotovoltaicPower); .orderByAsc(ThirdDailyAccumulationUpdateEnt::getPhotovoltaicPower);
} }
/**
* 除法
*
* @param one 一
* @param two 二
* @return {@link BigDecimal }
*/
private BigDecimal divide(BigDecimal one, BigDecimal two) {
BigDecimal result;
if (two.compareTo(BigDecimal.ZERO) > 0) {
result = one.divide(two, 2, RoundingMode.HALF_UP);
} else {
result = BigDecimal.ZERO;
}
return result;
}
/** /**
* 获取消纳率 * 获取消纳率
* 消纳率:就地消纳量/累计用电*100% * 消纳率:就地消纳量/累计用电*100%
......
package pps.core.prediction.service.data.energy_consumption_analysis;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import xstartup.annotation.XText;
import java.math.BigDecimal;
/**
* 获取发电细节输出
*
* @author ZWT
* @date 2024/05/22
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class GetPowerGenerationDetailOutput {
@XText("光伏装机总量(kWh)")
private BigDecimal photovoltaicPower;
@XText("发电功率(kWh)")
private BigDecimal powerGeneration;
@XText("累计发电量(kWh)")
private BigDecimal accumulatePowerGeneration;
@XText("就地消纳电量(KWh)")
private BigDecimal inPlaceConsumption;
@XText("井场额定功率")
private BigDecimal operatingLoad;
@XText("开井数量")
private Integer openWellNumber;
@XText("日累计产液量(m³)")
private BigDecimal dailyLiquidProduction;
@XText("日累计用电量(KW·h)")
private BigDecimal dailyElectricityConsumption;
@XText("上网电量")
private BigDecimal avoidPeakRate;
@XText("用电功率(kWh)")
private BigDecimal powerConsumption;
@XText("绿电占比")
private BigDecimal greenElectricityRate;
}
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