Commit 8d08fccc authored by ZWT's avatar ZWT

feat(能源管理系统): 测试问题修复

1.修改间开制度管理-长期/中长期间开优化定时任务,解决未设置区间的井口不展示时间区间问题;
2.开发间开制度管理-校准周期模块,间开制度跟踪接口,完成接口冒烟测试,并生成接口文档;
3.修改间开制度管理-短期间开模块,短期间开制度详情接口,解决井口间开时间段展示异常问题;
4.开发间开制度管理-校准周期模块,井口生产情况分页列表接口,创建测试数据表,添加模拟数据,生成映射类,完成接口冒烟测试,并生成接口文档;
5.开发统计分析-用能曲线模块,发电列表接口;
6.修改统计分析-用能曲线模块,发电列表接口,添加计算生产负荷逻辑,修改光伏电站Cloud模块查询电站列表接口,增加电站ID集合查询条件,添加接口文档,并完成接口冒烟测试;

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent 167cf779
package pps.core.prediction.service; package pps.core.prediction.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import pps.cloud.base.service.BasePhotovoltaicPlantCloudService;
import pps.cloud.base.service.IBasePowerLineCloudService;
import pps.cloud.base.service.data.base_photovoltaic_plant.GetBasePhotovoltaicPlantCloudInput;
import pps.cloud.base.service.data.base_photovoltaic_plant.GetBasePhotovoltaicPlantCloudOutput;
import pps.cloud.base.service.data.base_power_line_plant.DynamicQueryBasePowerLinePlantInput;
import pps.cloud.base.service.data.base_power_line_plant.DynamicQueryBasePowerLinePlantOutput;
import pps.core.common.constant.BusinessConstant;
import pps.core.common.utils.BaseUtils;
import pps.core.prediction.entity.PlantPredictedPowerDataEnt;
import pps.core.prediction.entity.PlantPredictedPowerLongTermDataEnt;
import pps.core.prediction.mapper.PlantPredictedPowerDataMapper;
import pps.core.prediction.mapper.PlantPredictedPowerLongTermDataMapper;
import pps.core.prediction.service.data.energy_consumption_analysis.GetEnergyConsumptionAnalysisInput;
import pps.core.prediction.service.data.energy_consumption_analysis.GetEnergyConsumptionAnalysisOutput;
import xstartup.annotation.XService; import xstartup.annotation.XService;
import xstartup.annotation.XText; import xstartup.annotation.XText;
import xstartup.base.XContext;
import xstartup.base.util.XCopyUtils;
import xstartup.data.XListResult;
import xstartup.feature.api.annotation.XApiAnonymous;
import xstartup.feature.api.annotation.XApiGet;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
/** /**
* 能耗分析模块(测试用) * 能耗分析模块(测试用)
...@@ -44,141 +14,6 @@ import java.util.stream.Collectors; ...@@ -44,141 +14,6 @@ import java.util.stream.Collectors;
@XService @XService
public class EnergyConsumptionAnalysisService { public class EnergyConsumptionAnalysisService {
/**
* 能耗分析--发电列表
*
* @param context 上下文
* @param input 输入
* @return {@link XListResult}<{@link GetEnergyConsumptionAnalysisOutput}>
*/
@XText("能耗分析--发电列表")
@XApiAnonymous
@XApiGet
public XListResult<GetEnergyConsumptionAnalysisOutput> queryEnergyConsumptionAnalysisList(XContext context, GetEnergyConsumptionAnalysisInput input) {
//通过线路ID查光伏电站
List<DynamicQueryBasePowerLinePlantOutput> plantListByLineIds = this.getPowerLinePlantListByLineIds(context, CollUtil.newArrayList(input.getLineId()));
List powerGenerationList = null;
List<String> plantIdList = null;
if (CollUtil.isNotEmpty(plantListByLineIds)) {
plantIdList = plantListByLineIds.stream()
.map(DynamicQueryBasePowerLinePlantOutput::getPlantId)
.collect(Collectors.toList());
//取当前时间
DateTime date = DateUtil.date();
PlantPredictedPowerDataMapper powerDataMapper;
switch (input.getDateType()) {
case 0:
powerDataMapper = context.getBean(PlantPredictedPowerDataMapper.class);
powerGenerationList = powerDataMapper.selectList(new QueryWrapper<PlantPredictedPowerDataEnt>()
.select("hour_time",
"SUM( power ) AS power")
.lambda()
.eq(PlantPredictedPowerDataEnt::getYearTime, String.valueOf(date.year()))
.eq(PlantPredictedPowerDataEnt::getMonthTime, BaseUtils.getMonthString(date.month() + 1))
.eq(PlantPredictedPowerDataEnt::getDayTime, String.valueOf(date.dayOfMonth()))
.in(PlantPredictedPowerDataEnt::getPlantId, plantIdList)
.groupBy(PlantPredictedPowerDataEnt::getHourTime)
.orderByAsc(PlantPredictedPowerDataEnt::getHourTime)
);
break;
case 1:
powerDataMapper = context.getBean(PlantPredictedPowerDataMapper.class);
powerGenerationList = powerDataMapper.selectList(new QueryWrapper<PlantPredictedPowerDataEnt>()
.select("hour_time",
"SUM( power ) AS power")
.lambda()
.in(PlantPredictedPowerDataEnt::getPlantId, plantIdList)
.between(PlantPredictedPowerDataEnt::getDataDate,
date.toString(BusinessConstant.DATE_FORMAT_DAY),
DateUtil.offsetDay(date, 7).toString(BusinessConstant.DATE_FORMAT_DAY))
.groupBy(PlantPredictedPowerDataEnt::getHourTime)
.orderByAsc(PlantPredictedPowerDataEnt::getHourTime)
);
break;
case 2:
PlantPredictedPowerLongTermDataMapper longTermDataMapper = context.getBean(PlantPredictedPowerLongTermDataMapper.class);
powerGenerationList = longTermDataMapper.selectList(new QueryWrapper<PlantPredictedPowerLongTermDataEnt>()
.select("hour_time",
"SUM( power ) AS power")
.lambda()
.in(PlantPredictedPowerLongTermDataEnt::getPlantId, plantIdList)
.between(PlantPredictedPowerLongTermDataEnt::getDataDate,
date.toString(BusinessConstant.DATE_FORMAT_DAY),
DateUtil.offsetDay(date, 30).toString(BusinessConstant.DATE_FORMAT_DAY))
.groupBy(PlantPredictedPowerLongTermDataEnt::getHourTime)
.orderByAsc(PlantPredictedPowerLongTermDataEnt::getHourTime)
);
break;
default:
}
}
List<GetEnergyConsumptionAnalysisOutput> outputList = new ArrayList<>(0);
if (CollUtil.isNotEmpty(powerGenerationList)) {
XCopyUtils.copyList(powerGenerationList, outputList, GetEnergyConsumptionAnalysisOutput.class);
//有发电量说明有电站ID,查电站详情
List<GetBasePhotovoltaicPlantCloudOutput> plantList = this.getPhotovoltaicPlantByPlantIds(context, plantIdList);
Optional<BigDecimal> reduce = plantList.stream()
.map(GetBasePhotovoltaicPlantCloudOutput::getTotalPower)
.reduce(BigDecimal::add);
if (reduce.isPresent()) {
//负荷率=实际发电量/理论最大发电量x100%
BigDecimal maximumPowerGeneration = reduce.get();
BigDecimal power;
BigDecimal oneHundred = new BigDecimal(100);
for (GetEnergyConsumptionAnalysisOutput output : outputList) {
power = output.getPower();
if (Objects.isNull(power) ||
power.compareTo(BigDecimal.ZERO) <= BusinessConstant.ZERO ||
maximumPowerGeneration.compareTo(BigDecimal.ZERO) == BusinessConstant.ZERO
) {
output.setProductionLoad(BigDecimal.ZERO);
continue;
}
//计算负荷
output.setProductionLoad(
power.divide(maximumPowerGeneration, 4, BigDecimal.ROUND_HALF_UP)
.multiply(oneHundred)
);
}
}
}
return XListResult.success(outputList);
}
/*-----------------------------------private-----------------------------------*/ /*-----------------------------------private-----------------------------------*/
/**
* 按线路ID集合获取电站列表
*
* @param context 上下文
* @param lineIds 线路ID
* @return {@link List}<{@link DynamicQueryBasePowerLinePlantOutput}>
*/
private List<DynamicQueryBasePowerLinePlantOutput> getPowerLinePlantListByLineIds(XContext context, List<String> lineIds) {
IBasePowerLineCloudService cloudService = context.getBean(IBasePowerLineCloudService.class);
XListResult<DynamicQueryBasePowerLinePlantOutput> result = cloudService.queryPowerLinePlantListByParam(context,
DynamicQueryBasePowerLinePlantInput.builder()
.lineIds(lineIds)
.build()
);
result.throwIfFail();
return result.getResult();
}
/**
* 获取光伏发电厂
*
* @param context 上下文
* @param plantIds 植物id
* @return {@link List}<{@link GetBasePhotovoltaicPlantCloudOutput}>
*/
private List<GetBasePhotovoltaicPlantCloudOutput> getPhotovoltaicPlantByPlantIds(XContext context, List<String> plantIds) {
BasePhotovoltaicPlantCloudService cloudService = context.getBean(BasePhotovoltaicPlantCloudService.class);
XListResult<GetBasePhotovoltaicPlantCloudOutput> result = cloudService.getBasePhotovoltaicPlantList(context,
GetBasePhotovoltaicPlantCloudInput.builder()
.plantIds(plantIds)
.build());
result.throwIfFail();
return result.getResult();
}
} }
package pps.core.prediction.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import pps.cloud.base.service.BasePhotovoltaicPlantCloudService;
import pps.cloud.base.service.IBasePowerLineCloudService;
import pps.cloud.base.service.data.base_photovoltaic_plant.GetBasePhotovoltaicPlantCloudInput;
import pps.cloud.base.service.data.base_photovoltaic_plant.GetBasePhotovoltaicPlantCloudOutput;
import pps.cloud.base.service.data.base_power_line_plant.DynamicQueryBasePowerLinePlantInput;
import pps.cloud.base.service.data.base_power_line_plant.DynamicQueryBasePowerLinePlantOutput;
import pps.core.common.constant.BusinessConstant;
import pps.core.common.utils.BaseUtils;
import pps.core.prediction.entity.PlantPredictedPowerDataEnt;
import pps.core.prediction.entity.PlantPredictedPowerLongTermDataEnt;
import pps.core.prediction.mapper.PlantPredictedPowerDataMapper;
import pps.core.prediction.mapper.PlantPredictedPowerLongTermDataMapper;
import pps.core.prediction.service.data.energy_consumption_curve.GetEnergyConsumptionCurveInput;
import pps.core.prediction.service.data.energy_consumption_curve.GetEnergyConsumptionCurveOutput;
import xstartup.annotation.XService;
import xstartup.annotation.XText;
import xstartup.base.XContext;
import xstartup.base.util.XCopyUtils;
import xstartup.data.XListResult;
import xstartup.feature.api.annotation.XApiAnonymous;
import xstartup.feature.api.annotation.XApiGet;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* 用能曲线模块(测试用)
* todo: 模拟测试用,后续替换
*
* @author ZWT
* @date 2023/09/27 15:57
*/
@XText("用能曲线模块")
@XService
public class EnergyConsumptionCurveService {
/**
* 用能曲线--发电列表
*
* @param context 上下文
* @param input 输入
* @return {@link XListResult}<{@link GetEnergyConsumptionCurveOutput}>
*/
@XText("用能曲线--发电列表")
@XApiAnonymous
@XApiGet
public XListResult<GetEnergyConsumptionCurveOutput> queryEnergyConsumptionAnalysisList(XContext context, GetEnergyConsumptionCurveInput input) {
//通过线路ID查光伏电站
List<DynamicQueryBasePowerLinePlantOutput> plantListByLineIds = this.getPowerLinePlantListByLineIds(context, CollUtil.newArrayList(input.getLineId()));
List powerGenerationList = null;
List<String> plantIdList = null;
if (CollUtil.isNotEmpty(plantListByLineIds)) {
plantIdList = plantListByLineIds.stream()
.map(DynamicQueryBasePowerLinePlantOutput::getPlantId)
.collect(Collectors.toList());
//取当前时间
DateTime date = DateUtil.date();
PlantPredictedPowerDataMapper powerDataMapper;
switch (input.getDateType()) {
case 0:
powerDataMapper = context.getBean(PlantPredictedPowerDataMapper.class);
powerGenerationList = powerDataMapper.selectList(new QueryWrapper<PlantPredictedPowerDataEnt>()
.select("hour_time",
"SUM( power ) AS power")
.lambda()
.eq(PlantPredictedPowerDataEnt::getYearTime, String.valueOf(date.year()))
.eq(PlantPredictedPowerDataEnt::getMonthTime, BaseUtils.getMonthString(date.month() + 1))
.eq(PlantPredictedPowerDataEnt::getDayTime, String.valueOf(date.dayOfMonth()))
.in(PlantPredictedPowerDataEnt::getPlantId, plantIdList)
.groupBy(PlantPredictedPowerDataEnt::getHourTime)
.orderByAsc(PlantPredictedPowerDataEnt::getHourTime)
);
break;
case 1:
powerDataMapper = context.getBean(PlantPredictedPowerDataMapper.class);
powerGenerationList = powerDataMapper.selectList(new QueryWrapper<PlantPredictedPowerDataEnt>()
.select("hour_time",
"SUM( power ) AS power")
.lambda()
.in(PlantPredictedPowerDataEnt::getPlantId, plantIdList)
.between(PlantPredictedPowerDataEnt::getDataDate,
date.toString(BusinessConstant.DATE_FORMAT_DAY),
DateUtil.offsetDay(date, 7).toString(BusinessConstant.DATE_FORMAT_DAY))
.groupBy(PlantPredictedPowerDataEnt::getHourTime)
.orderByAsc(PlantPredictedPowerDataEnt::getHourTime)
);
break;
case 2:
PlantPredictedPowerLongTermDataMapper longTermDataMapper = context.getBean(PlantPredictedPowerLongTermDataMapper.class);
powerGenerationList = longTermDataMapper.selectList(new QueryWrapper<PlantPredictedPowerLongTermDataEnt>()
.select("hour_time",
"SUM( power ) AS power")
.lambda()
.in(PlantPredictedPowerLongTermDataEnt::getPlantId, plantIdList)
.between(PlantPredictedPowerLongTermDataEnt::getDataDate,
date.toString(BusinessConstant.DATE_FORMAT_DAY),
DateUtil.offsetDay(date, 30).toString(BusinessConstant.DATE_FORMAT_DAY))
.groupBy(PlantPredictedPowerLongTermDataEnt::getHourTime)
.orderByAsc(PlantPredictedPowerLongTermDataEnt::getHourTime)
);
break;
default:
}
}
List<GetEnergyConsumptionCurveOutput> outputList = new ArrayList<>(0);
if (CollUtil.isNotEmpty(powerGenerationList)) {
XCopyUtils.copyList(powerGenerationList, outputList, GetEnergyConsumptionCurveOutput.class);
//有发电量说明有电站ID,查电站详情
List<GetBasePhotovoltaicPlantCloudOutput> plantList = this.getPhotovoltaicPlantByPlantIds(context, plantIdList);
Optional<BigDecimal> reduce = plantList.stream()
.map(GetBasePhotovoltaicPlantCloudOutput::getTotalPower)
.reduce(BigDecimal::add);
if (reduce.isPresent()) {
//负荷率=实际发电量/理论最大发电量x100%
BigDecimal maximumPowerGeneration = reduce.get();
BigDecimal power;
BigDecimal oneHundred = new BigDecimal(100);
for (GetEnergyConsumptionCurveOutput output : outputList) {
power = output.getPower();
if (Objects.isNull(power) ||
power.compareTo(BigDecimal.ZERO) <= BusinessConstant.ZERO ||
maximumPowerGeneration.compareTo(BigDecimal.ZERO) == BusinessConstant.ZERO
) {
output.setProductionLoad(BigDecimal.ZERO);
continue;
}
//计算负荷
output.setProductionLoad(
power.divide(maximumPowerGeneration, 4, BigDecimal.ROUND_HALF_UP)
.multiply(oneHundred)
);
}
}
}
return XListResult.success(outputList);
}
/*-----------------------------------private-----------------------------------*/
/**
* 按线路ID集合获取电站列表
*
* @param context 上下文
* @param lineIds 线路ID
* @return {@link List}<{@link DynamicQueryBasePowerLinePlantOutput}>
*/
private List<DynamicQueryBasePowerLinePlantOutput> getPowerLinePlantListByLineIds(XContext context, List<String> lineIds) {
IBasePowerLineCloudService cloudService = context.getBean(IBasePowerLineCloudService.class);
XListResult<DynamicQueryBasePowerLinePlantOutput> result = cloudService.queryPowerLinePlantListByParam(context,
DynamicQueryBasePowerLinePlantInput.builder()
.lineIds(lineIds)
.build()
);
result.throwIfFail();
return result.getResult();
}
/**
* 获取光伏发电厂
*
* @param context 上下文
* @param plantIds 植物id
* @return {@link List}<{@link GetBasePhotovoltaicPlantCloudOutput}>
*/
private List<GetBasePhotovoltaicPlantCloudOutput> getPhotovoltaicPlantByPlantIds(XContext context, List<String> plantIds) {
BasePhotovoltaicPlantCloudService cloudService = context.getBean(BasePhotovoltaicPlantCloudService.class);
XListResult<GetBasePhotovoltaicPlantCloudOutput> result = cloudService.getBasePhotovoltaicPlantList(context,
GetBasePhotovoltaicPlantCloudInput.builder()
.plantIds(plantIds)
.build());
result.throwIfFail();
return result.getResult();
}
}
package pps.core.prediction.service.data.energy_consumption_analysis; package pps.core.prediction.service.data.energy_consumption_curve;
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
...@@ -9,7 +9,7 @@ import lombok.NoArgsConstructor; ...@@ -9,7 +9,7 @@ import lombok.NoArgsConstructor;
import xstartup.annotation.XText; import xstartup.annotation.XText;
/** /**
* 储能预测电量数据(模拟数据测试用) * 用能曲线(模拟数据测试用)
* *
* @author ZWT * @author ZWT
* @date 2023/09/20 * @date 2023/09/20
...@@ -18,7 +18,7 @@ import xstartup.annotation.XText; ...@@ -18,7 +18,7 @@ import xstartup.annotation.XText;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@Builder @Builder
public class GetEnergyConsumptionAnalysisInput { public class GetEnergyConsumptionCurveInput {
@NotBlank(message = "缺少线路ID") @NotBlank(message = "缺少线路ID")
@XText("线路ID") @XText("线路ID")
......
package pps.core.prediction.service.data.energy_consumption_analysis; package pps.core.prediction.service.data.energy_consumption_curve;
import lombok.Data; import lombok.Data;
import xstartup.annotation.XText; import xstartup.annotation.XText;
...@@ -6,13 +6,13 @@ import xstartup.annotation.XText; ...@@ -6,13 +6,13 @@ import xstartup.annotation.XText;
import java.math.BigDecimal; import java.math.BigDecimal;
/** /**
* 储能预测电量数据(模拟数据测试用) * 用能曲线(模拟数据测试用)
* *
* @author ZWT * @author ZWT
* @date 2023/09/20 * @date 2023/09/20
*/ */
@Data @Data
public class GetEnergyConsumptionAnalysisOutput { public class GetEnergyConsumptionCurveOutput {
@XText("时") @XText("时")
private String hourTime; private String hourTime;
......
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