Commit 62668cb2 authored by ZWT's avatar ZWT

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

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

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent d3a26ae6
...@@ -120,62 +120,19 @@ public class EnergyConsumptionAnalysisService { ...@@ -120,62 +120,19 @@ public class EnergyConsumptionAnalysisService {
input.getBetweenDate(); input.getBetweenDate();
DateTime endTime = DateUtil.offsetDay(input.getEndTime(), 1); DateTime endTime = DateUtil.offsetDay(input.getEndTime(), 1);
//用电功率 //用电功率
Map<Date, BigDecimal> avgMap; Map<Date, BigDecimal> avgMap = this.queryPowerConsumptionHour(context,
List<DynamicQueryBasePowerLineWellheadViewOutput> wellheadList = this.getPowerLineWellheadList(context, wellheadInput); this.getPowerLineWellheadList(context, wellheadInput),
if (CollUtil.isNotEmpty(wellheadList)) { input.getStartTime(),
ThirdWellAvgActivePowerViewMapper mapper = context.getBean(ThirdWellAvgActivePowerViewMapper.class); endTime
avgMap = mapper.selectPowerConsumptionHour(ThirdWellAvgActivePowerView.builder() );
.wellNumbers(wellheadList.stream()
.map(DynamicQueryBasePowerLineWellheadViewOutput::getWellNumber)
.collect(Collectors.toList()))
.startTime(input.getStartTime())
.endTime(endTime)
.build())
.stream()
.collect(Collectors.toMap(ThirdWellAvgActivePowerView::getInputTime, ThirdWellAvgActivePowerView::getAvgActivePower));
} else {
avgMap = Collections.emptyMap();
}
//发电功率 //发电功率
Map<Date, BigDecimal> powerMap; Map<Date, BigDecimal> powerMap = this.queryGeneratedPowerHour(context,
List<DynamicQueryBasePowerLinePlantViewOutput> plantList = this.getPowerLinePlantViewList(context, plantInput); this.getPowerLinePlantViewList(context, plantInput),
if (CollUtil.isNotEmpty(plantList)) { input.getStartTime(),
ThirdActivePowerViewMapper dailyUpdateMapper = context.getBean(ThirdActivePowerViewMapper.class); endTime
powerMap = dailyUpdateMapper.selectGeneratedPowerHour(ThirdActivePowerView.builder() );
.stationNames(plantList.stream()
.map(DynamicQueryBasePowerLinePlantViewOutput::getStationName)
.collect(Collectors.toList()))
.startTime(input.getStartTime())
.endTime(endTime)
.build())
.stream()
.collect(Collectors.toMap(ThirdActivePowerView::getCreateDate, ThirdActivePowerView::getPhotovoltaicPower));
} else {
powerMap = Collections.emptyMap();
}
//封装数据 //封装数据
List<DateTime> rangeToList = DateUtil.rangeToList(input.getStartTime(), input.getEndTime(), DateField.HOUR_OF_DAY); return XListResult.success(this.setPowerAnalyseList(avgMap, powerMap, input.getStartTime(), input.getEndTime()));
List<GetPowerAnalyseOutput> outputs = new ArrayList<>(rangeToList.size());
BigDecimal powerConsumption;
BigDecimal powerGeneration;
for (DateTime dateTime : rangeToList) {
if (avgMap.containsKey(dateTime)) {
powerConsumption = avgMap.get(dateTime).setScale(2, RoundingMode.HALF_UP);
} else {
powerConsumption = BigDecimal.ZERO;
}
if (powerMap.containsKey(dateTime)) {
powerGeneration = powerMap.get(dateTime).setScale(2, RoundingMode.HALF_UP);
} else {
powerGeneration = BigDecimal.ZERO;
}
outputs.add(GetPowerAnalyseOutput.builder()
.dateFormat(dateTime.toString())
.powerConsumption(powerConsumption)
.powerGeneration(powerGeneration)
.build());
}
return XListResult.success(outputs);
} }
/** /**
...@@ -306,6 +263,39 @@ public class EnergyConsumptionAnalysisService { ...@@ -306,6 +263,39 @@ public class EnergyConsumptionAnalysisService {
return XSingleResult.success(output); return XSingleResult.success(output);
} }
/**
* 本日用电对比
*
* @param context 上下文
* @param input 输入
* @return {@link XListResult }<{@link GetPowerAnalyseOutput }>
*/
@XText("井场实时分析--本日用电对比")
@XApiGet
public XListResult<GetPowerAnalyseOutput> electricityConsumptionContrast(XContext context, GetEnergyConsumptionAnalysisInput input) {
List<String> orgIds = this.getOrgIdsByPath(context, input.getOuId());
DateTime today = DateUtil.beginOfDay(DateUtil.date());
DateTime tomorrow = DateUtil.beginOfDay(DateUtil.tomorrow());
//用电功率
Map<Date, BigDecimal> avgMap = this.queryPowerConsumptionHour(context,
this.getPowerLineWellheadList(context, DynamicQueryBasePowerLineWellheadInput.builder()
.ouIds(orgIds)
.build()),
today,
tomorrow
);
//发电功率
Map<Date, BigDecimal> powerMap = this.queryGeneratedPowerHour(context,
this.getPowerLinePlantViewList(context, DynamicQueryBasePowerLinePlantInput.builder()
.ouIds(orgIds)
.build()),
today,
tomorrow
);
//封装数据
return XListResult.success(this.setPowerAnalyseList(avgMap, powerMap, today, tomorrow));
}
/*------------------------------ 能耗分析(废弃) ------------------------------*/ /*------------------------------ 能耗分析(废弃) ------------------------------*/
/** /**
...@@ -648,4 +638,95 @@ public class EnergyConsumptionAnalysisService { ...@@ -648,4 +638,95 @@ public class EnergyConsumptionAnalysisService {
result.throwIfFail(); result.throwIfFail();
return result.getResult(); return result.getResult();
} }
/**
* 查询用电功率
*
* @param context 上下文
* @param wellheadList 井口一览表
* @param startTime 开始时间
* @param endTime 结束时间
* @return {@link Map }<{@link Date }, {@link BigDecimal }>
*/
private Map<Date, BigDecimal> queryPowerConsumptionHour(XContext context, List<DynamicQueryBasePowerLineWellheadViewOutput> wellheadList, Date startTime, Date endTime) {
Map<Date, BigDecimal> avgMap;
if (CollUtil.isNotEmpty(wellheadList)) {
ThirdWellAvgActivePowerViewMapper mapper = context.getBean(ThirdWellAvgActivePowerViewMapper.class);
avgMap = mapper.selectPowerConsumptionHour(ThirdWellAvgActivePowerView.builder()
.wellNumbers(wellheadList.stream()
.map(DynamicQueryBasePowerLineWellheadViewOutput::getWellNumber)
.collect(Collectors.toList()))
.startTime(startTime)
.endTime(endTime)
.build())
.stream()
.collect(Collectors.toMap(ThirdWellAvgActivePowerView::getInputTime, ThirdWellAvgActivePowerView::getAvgActivePower));
} else {
avgMap = Collections.emptyMap();
}
return avgMap;
}
/**
* 查询发电功率
*
* @param context 上下文
* @param plantList 工厂清单
* @param startTime 开始时间
* @param endTime 结束时间
* @return {@link Map }<{@link Date }, {@link BigDecimal }>
*/
private Map<Date, BigDecimal> queryGeneratedPowerHour(XContext context, List<DynamicQueryBasePowerLinePlantViewOutput> plantList, Date startTime, Date endTime) {
Map<Date, BigDecimal> powerMap;
if (CollUtil.isNotEmpty(plantList)) {
ThirdActivePowerViewMapper dailyUpdateMapper = context.getBean(ThirdActivePowerViewMapper.class);
powerMap = dailyUpdateMapper.selectGeneratedPowerHour(ThirdActivePowerView.builder()
.stationNames(plantList.stream()
.map(DynamicQueryBasePowerLinePlantViewOutput::getStationName)
.collect(Collectors.toList()))
.startTime(startTime)
.endTime(endTime)
.build())
.stream()
.collect(Collectors.toMap(ThirdActivePowerView::getCreateDate, ThirdActivePowerView::getPhotovoltaicPower));
} else {
powerMap = Collections.emptyMap();
}
return powerMap;
}
/**
* 设置功率分析列表
*
* @param avgMap 平均地图
* @param powerMap 功率图
* @param startTime 开始时间
* @param endTime 结束时间
* @return {@link List }<{@link GetPowerAnalyseOutput }>
*/
private List<GetPowerAnalyseOutput> setPowerAnalyseList(Map<Date, BigDecimal> avgMap, Map<Date, BigDecimal> powerMap, Date startTime, Date endTime) {
//封装数据
List<DateTime> rangeToList = DateUtil.rangeToList(startTime, endTime, DateField.HOUR_OF_DAY);
List<GetPowerAnalyseOutput> outputs = new ArrayList<>(rangeToList.size());
BigDecimal powerConsumption;
BigDecimal powerGeneration;
for (DateTime dateTime : rangeToList) {
if (avgMap.containsKey(dateTime)) {
powerConsumption = avgMap.get(dateTime).setScale(2, RoundingMode.HALF_UP);
} else {
powerConsumption = BigDecimal.ZERO;
}
if (powerMap.containsKey(dateTime)) {
powerGeneration = powerMap.get(dateTime).setScale(2, RoundingMode.HALF_UP);
} else {
powerGeneration = BigDecimal.ZERO;
}
outputs.add(GetPowerAnalyseOutput.builder()
.dateFormat(dateTime.toString())
.powerConsumption(powerConsumption)
.powerGeneration(powerGeneration)
.build());
}
return outputs;
}
} }
...@@ -24,9 +24,9 @@ public class GetPowerAnalyseOutput { ...@@ -24,9 +24,9 @@ public class GetPowerAnalyseOutput {
@XText("日期") @XText("日期")
private String dateFormat; private String dateFormat;
@XText("发电(kWh)") @XText("发电功率(kWh)")
private BigDecimal powerGeneration; private BigDecimal powerGeneration;
@XText("用电(kWh)") @XText("用电功率(kWh)")
private BigDecimal powerConsumption; private BigDecimal powerConsumption;
} }
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