Commit c7c81177 authored by ZWT's avatar ZWT

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

1.开发统计分析-能耗分析模块,绿电消纳列表接口,修改光伏电站Cloud模块查询电站列表接口,增加组织ID集合查询条件,添加接口文档,并完成接口冒烟测试;
2.开发统计分析-能耗分析模块,电量使用趋势列表接口,添加接口文档,并完成接口冒烟测试;
3.统计分析模块抽取基类,将公用方法移入基类;
4.开发统计分析-能耗分析模块,数据概览接口,添加接口文档,并完成接口冒烟测试;
5.修改统计分析-能耗分析/发电曲线模块光伏发电查询接口逻辑,增加自定义时间段入参,修改代码处理逻辑,完成接口冒烟测试;

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent 2db9495c
......@@ -58,7 +58,8 @@ public class EnergyConsumptionAnalysisService extends StatisticAnalysisBaseServi
powerGenerationList = super.getPhotovoltaicPowerGeneration(context, input.getDateType(),
photovoltaicPlantList.stream()
.map(GetBasePhotovoltaicPlantCloudOutput::getId)
.collect(Collectors.toList())
.collect(Collectors.toList()),
input.getStartTime(), input.getEndTime()
);
}
List<GetEnergyConsumptionAnalysisOutput> outputList = new ArrayList<>(0);
......@@ -109,7 +110,8 @@ public class EnergyConsumptionAnalysisService extends StatisticAnalysisBaseServi
powerGenerationList = super.getPhotovoltaicPowerGeneration(context, input.getDateType(),
photovoltaicPlantList.stream()
.map(GetBasePhotovoltaicPlantCloudOutput::getId)
.collect(Collectors.toList())
.collect(Collectors.toList()),
input.getStartTime(), input.getEndTime()
);
}
List<GetEnergyConsumptionAnalysisOutput> powerList = new ArrayList<>(0);
......
......@@ -54,7 +54,7 @@ public class EnergyConsumptionCurveService extends StatisticAnalysisBaseService
plantIdList = plantListByLineIds.stream()
.map(DynamicQueryBasePowerLinePlantOutput::getPlantId)
.collect(Collectors.toList());
powerGenerationList = super.getPhotovoltaicPowerGeneration(context, input.getDateType(), plantIdList);
powerGenerationList = super.getPhotovoltaicPowerGeneration(context, input.getDateType(), plantIdList, input.getStartTime(), input.getEndTime());
}
List<GetEnergyConsumptionCurveOutput> outputList = new ArrayList<>(0);
if (CollUtil.isNotEmpty(powerGenerationList)) {
......
package pps.core.prediction.service;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import pps.cloud.base.service.BasePhotovoltaicPlantCloudService;
......@@ -18,7 +19,9 @@ import pps.core.prediction.mapper.PlantPredictedPowerLongTermDataMapper;
import xstartup.base.XContext;
import xstartup.data.XListResult;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
......@@ -35,16 +38,18 @@ public class StatisticAnalysisBaseService {
* @param context 上下文
* @param dateType 日期类型
* @param plantIdList 工厂id列表
* @param startTime 开始时间
* @param endTime 结束时间
* @return {@link List}
*/
public List getPhotovoltaicPowerGeneration(XContext context, Integer dateType, List<String> plantIdList) {
public List getPhotovoltaicPowerGeneration(XContext context, Integer dateType,
List<String> plantIdList, Date startTime, Date endTime) {
List powerGenerationList = null;
//取当前时间
DateTime date = DateUtil.date();
PlantPredictedPowerDataMapper powerDataMapper;
DateTime date = DateUtil.beginOfDay(DateUtil.date());
switch (dateType) {
case 0:
powerDataMapper = context.getBean(PlantPredictedPowerDataMapper.class);
PlantPredictedPowerDataMapper powerDataMapper = context.getBean(PlantPredictedPowerDataMapper.class);
powerGenerationList = powerDataMapper.selectList(new QueryWrapper<PlantPredictedPowerDataEnt>()
.select("hour_time",
"SUM( power ) AS power")
......@@ -58,32 +63,33 @@ public class StatisticAnalysisBaseService {
);
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)
);
powerGenerationList = this.getPlantPredictedPowerList(context, plantIdList,
date.toString(BusinessConstant.DATE_FORMAT_DAY),
DateUtil.offsetDay(date, 7).toString(BusinessConstant.DATE_FORMAT_DAY));
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)
);
powerGenerationList = this.getPlantPredictedPowerLongList(context, plantIdList,
date.toString(BusinessConstant.DATE_FORMAT_DAY),
DateUtil.offsetDay(date, 30).toString(BusinessConstant.DATE_FORMAT_DAY));
break;
case 3:
//判断当前时间距当前时间是否大于30天
if (Objects.isNull(startTime) || Objects.isNull(endTime)) {
return null;
}
int between = (int) date.between(endTime, DateUnit.DAY);
//判断结束时间是否大于当前时间30天以后
if (endTime.compareTo(date) >= 0 && between >= 30) {
//长期预测
powerGenerationList = this.getPlantPredictedPowerLongList(context, plantIdList,
DateUtil.date(startTime).toString(BusinessConstant.DATE_FORMAT_DAY),
DateUtil.date(endTime).toString(BusinessConstant.DATE_FORMAT_DAY));
} else {
//短期
powerGenerationList = this.getPlantPredictedPowerList(context, plantIdList,
DateUtil.date(startTime).toString(BusinessConstant.DATE_FORMAT_DAY),
DateUtil.date(endTime).toString(BusinessConstant.DATE_FORMAT_DAY));
}
break;
default:
}
......@@ -122,4 +128,51 @@ public class StatisticAnalysisBaseService {
return result.getResult();
}
/*-----------------------------------private-----------------------------------*/
/**
* 获取短期预测结果
*
* @param context 上下文
* @param plantIdList 工厂id列表
* @param startTime 开始时间
* @param endTime 结束时间
* @return {@link List}<{@link PlantPredictedPowerDataEnt}>
*/
private List<PlantPredictedPowerDataEnt> getPlantPredictedPowerList(XContext context, List<String> plantIdList,
String startTime, String endTime) {
PlantPredictedPowerDataMapper powerDataMapper = context.getBean(PlantPredictedPowerDataMapper.class);
return powerDataMapper.selectList(new QueryWrapper<PlantPredictedPowerDataEnt>()
.select("hour_time",
"SUM( power ) AS power")
.lambda()
.in(PlantPredictedPowerDataEnt::getPlantId, plantIdList)
.between(PlantPredictedPowerDataEnt::getDataDate, startTime, endTime)
.groupBy(PlantPredictedPowerDataEnt::getHourTime)
.orderByAsc(PlantPredictedPowerDataEnt::getHourTime)
);
}
/**
* 获取长期预测结果
*
* @param context 上下文
* @param plantIdList 工厂id列表
* @param startTime 开始时间
* @param endTime 结束时间
* @return {@link List}<{@link PlantPredictedPowerLongTermDataEnt}>
*/
private List<PlantPredictedPowerLongTermDataEnt> getPlantPredictedPowerLongList(XContext context, List<String> plantIdList,
String startTime, String endTime) {
PlantPredictedPowerLongTermDataMapper longTermDataMapper = context.getBean(PlantPredictedPowerLongTermDataMapper.class);
return longTermDataMapper.selectList(new QueryWrapper<PlantPredictedPowerLongTermDataEnt>()
.select("hour_time",
"SUM( power ) AS power")
.lambda()
.in(PlantPredictedPowerLongTermDataEnt::getPlantId, plantIdList)
.between(PlantPredictedPowerLongTermDataEnt::getDataDate, startTime, endTime)
.groupBy(PlantPredictedPowerLongTermDataEnt::getHourTime)
.orderByAsc(PlantPredictedPowerLongTermDataEnt::getHourTime)
);
}
}
......@@ -8,6 +8,8 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import xstartup.annotation.XText;
import java.util.Date;
/**
* 能耗分析(模拟数据测试用)
*
......@@ -25,6 +27,12 @@ public class GetEnergyConsumptionAnalysisInput {
private String ouId;
@NotNull(message = "缺少日期类型")
@XText("日期类型(0_今日,1_近7天,2_近30天)")
@XText("日期类型(0_今日,1_近7天,2_近30天,3_自定义)")
private Integer dateType;
@XText("自定义开始时间")
private Date startTime;
@XText("自定义结束时间")
private Date endTime;
}
......@@ -8,6 +8,8 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import xstartup.annotation.XText;
import java.util.Date;
/**
* 用能曲线(模拟数据测试用)
*
......@@ -25,6 +27,12 @@ public class GetEnergyConsumptionCurveInput {
private String lineId;
@NotNull(message = "缺少日期类型")
@XText("日期类型(0_今日,1_近7天,2_近30天)")
@XText("日期类型(0_今日,1_近7天,2_近30天,3_自定义)")
private Integer dateType;
@XText("开始时间")
private Date startTime;
@XText("结束时间")
private Date endTime;
}
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