Commit bf29656d authored by ZWT's avatar ZWT

feat[零碳项目]: 松原演示

[
1.统计分析-井组监控页功能开发,开发井组生产详情接口,完成接口冒烟测试并编写线上接口文档生成接口用例;
2.统计分析-井组监控页功能开发,开发井口实时信息接口,完成接口冒烟测试并编写线上接口文档生成接口用例;
3.统计分析-井组监控页功能开发,开发光伏电站发电详情接口,完成接口冒烟测试并编写线上接口文档生成接口用例;
]
parent b1162e62
......@@ -810,6 +810,81 @@ public class EnergyConsumptionAnalysisService {
/*------------------------------ 井组监控 ------------------------------*/
/**
* 光伏电站发电详情
*
* @param context 上下文
* @param input 输入
* @return {@link XListResult }<{@link GetPowerGenerationDetailsOutput }>
*/
@XText("井组监控--光伏电站发电详情")
@XApiGet(anonymous = true)
public XListResult<GetPowerGenerationDetailsOutput> powerGenerationDetails(XContext context, GetEnergyConsumptionAnalysisInput input) {
List<DynamicQueryBasePowerLinePlantViewOutput> plantList = this.getPowerLinePlantViewList(context, DynamicQueryBasePowerLinePlantInput.builder()
.ouIds(this.getOrgIdsByPath(context, input.getOuId()))
.build());
Map<Date, BigDecimal> nowMap;
Map<Date, BigDecimal> lastMap;
Map<String, BigDecimal> collect = Collections.emptyMap();
DateTime begin = DateUtil.beginOfMonth(DateUtil.date());
DateTime end = DateUtil.endOfMonth(begin);
//电站名称列表有值再查
if (CollUtil.isNotEmpty(plantList)) {
List<String> stationNameList = new ArrayList<>(plantList.size());
List<String> stationIdList = new ArrayList<>(plantList.size());
for (DynamicQueryBasePowerLinePlantViewOutput plant : plantList) {
stationNameList.add(plant.getStationName());
stationIdList.add(plant.getPlantId());
}
String oilFieldCode = ServiceUtil.getOilFieldCode(context);
//查本期实际发电量
nowMap = this.getPowerMap(context, begin, end, stationNameList, 1, oilFieldCode, null);
//查同期实际发电量
DateTime offset = DateUtil.offset(begin, DateField.YEAR, -1);
lastMap = this.getPowerMap(context, offset, DateUtil.endOfMonth(offset), stationNameList, 1, oilFieldCode, null);
//查预测功率
PlantPredictedPowerShortTermMapper shortTermMapper = context.getBean(PlantPredictedPowerShortTermMapper.class);
List<PlantPredictedPowerShortTermEnt> shortTermList = shortTermMapper.selectList(new QueryWrapper<PlantPredictedPowerShortTermEnt>()
.select("IFNULL( ROUND( SUM( power ), 2 ), 0 ) AS power", "DATE_FORMAT( data_date, '%Y-%m-%d 00:00:00' ) AS data_date")
.groupBy("DATE_FORMAT( data_date, '%Y-%m-%d 00:00:00' )")
.lambda()
.between(PlantPredictedPowerShortTermEnt::getDataDate, begin, end)
.in(PlantPredictedPowerShortTermEnt::getPlantId, stationIdList)
);
if (CollUtil.isNotEmpty(shortTermList)) {
collect = shortTermList.stream()
.collect(Collectors.toMap(PlantPredictedPowerShortTermEnt::getDataDate, PlantPredictedPowerShortTermEnt::getPower));
}
} else {
nowMap = Collections.emptyMap();
lastMap = Collections.emptyMap();
}
List<DateTime> rangeToList = DateUtil.rangeToList(begin, end, DateField.DAY_OF_YEAR);
List<GetPowerGenerationDetailsOutput> outputs = new ArrayList<>(rangeToList.size());
//封装数据
BigDecimal powerGeneration;
BigDecimal lastPowerGeneration;
for (DateTime dateTime : rangeToList) {
if (nowMap.containsKey(dateTime)) {
powerGeneration = nowMap.get(dateTime).setScale(2, RoundingMode.HALF_UP);
} else {
powerGeneration = BigDecimal.ZERO;
}
if (lastMap.containsKey(DateUtil.offset(dateTime, DateField.YEAR, -1))) {
lastPowerGeneration = lastMap.get(dateTime).setScale(2, RoundingMode.HALF_UP);
} else {
lastPowerGeneration = BigDecimal.ZERO;
}
outputs.add(GetPowerGenerationDetailsOutput.builder()
.dateFormat(dateTime.toString())
.powerGeneration(powerGeneration)
.lastPowerGeneration(lastPowerGeneration)
.predictedPower(collect.getOrDefault(dateTime.toString(), BigDecimal.ZERO))
.build());
}
return XListResult.success(outputs);
}
/**
* 井组生产情况
*
......
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/07/26
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class GetPowerGenerationDetailsOutput {
@XText("日期")
private String dateFormat;
@XText("本期发电量(kWh)")
private BigDecimal powerGeneration;
@XText("同期发电量(kWh)")
private BigDecimal lastPowerGeneration;
@XText("预测发电量(kWh)")
private BigDecimal predictedPower;
}
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