Commit 4752bda0 authored by ZWT's avatar ZWT

feat(吉林演示): 松原

1.基础信息配置模块创建风资源历史数据表和风资源预测数据表,同时生成对应代码;
2.修改天气数据获取处理定时任务,修改光伏预测数据插入逻辑,同时增加风资源数据插入逻辑,完成功能测试;
3.开发风资源预测中期10天预测接口,完成接口冒烟测试并添加线上接口文档同时生成接口用例;
4.开发风资源预测中期3天预测接口,完成接口冒烟测试并添加线上接口文档同时生成接口用例;
5.开发风资源预测超短期4小时预测接口,完成接口冒烟测试并添加线上接口文档同时生成接口用例;
6.修改天气数据获取定时任务,解决风资源数据入库重复并且时间没有补齐的问题;
7.修改基础信息配置风电站配置模块详情接口,增加字段,添加回显地区逻辑,完成接口冒烟测试并修改接口文档;
8.修改系统关联模块代码,修改部分代码sql注入问题;

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent 7015ebb9
...@@ -3,15 +3,7 @@ package com.fasterxml.uuid.impl; ...@@ -3,15 +3,7 @@ package com.fasterxml.uuid.impl;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/**
* Wrapper we (only) need to support CLI usage (see {@link com.fasterxml.uuid.Jug}
* wherein we do not actually have logger package included; in which case we
* will print warning(s) out to {@code System.err}.
* For normal embedded usage no benefits, except if someone forgot their SLF4j API
* package. :)
*
* @since 4.1
*/
public class LoggerFacade { public class LoggerFacade {
private final Class<?> _forClass; private final Class<?> _forClass;
......
package pps.core.common.mybatis; package pps.core.common.mybatis;
import cn.hutool.core.lang.UUID;
import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator; import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator;
import pps.core.common.utils.UUIDHelper;
public class MyIDGenerator extends DefaultIdentifierGenerator { public class MyIDGenerator extends DefaultIdentifierGenerator {
@Override @Override
public String nextUUID(Object entity) { public String nextUUID(Object entity) {
return UUIDHelper.newUUID().replace("-", ""); return UUID.randomUUID(true).toString(true);
} }
} }
\ No newline at end of file
package pps.core.common.utils;
import com.fasterxml.uuid.Generators;
import com.fasterxml.uuid.NoArgGenerator;
import java.security.SecureRandom;
import java.util.UUID;
public class UUIDHelper {
private static final NoArgGenerator noArgGenerator = Generators.timeBasedEpochGenerator(new SecureRandom());
public static String newUUID() {
UUID uuid = noArgGenerator.generate();
return uuid.toString();
}
}
\ No newline at end of file
...@@ -19,6 +19,7 @@ import xstartup.feature.api.annotation.XApiPost; ...@@ -19,6 +19,7 @@ import xstartup.feature.api.annotation.XApiPost;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -38,7 +39,7 @@ public class WindPredictionFutureService { ...@@ -38,7 +39,7 @@ public class WindPredictionFutureService {
* @param input 输入 * @param input 输入
* @return {@link XListResult }<{@link GetWindPredictionFutureOutput }> * @return {@link XListResult }<{@link GetWindPredictionFutureOutput }>
*/ */
@XApiPost(anonymous = true) @XApiPost
@XText("中期10天预测") @XText("中期10天预测")
public XListResult<GetWindPredictionFutureOutput> getMidTerm10DayList(XContext context, GetWindPredictionFutureInput input) { public XListResult<GetWindPredictionFutureOutput> getMidTerm10DayList(XContext context, GetWindPredictionFutureInput input) {
return XListResult.success(getPredictedPowerOutput(context, input.getDataTime(), input.getStationId(), 10)); return XListResult.success(getPredictedPowerOutput(context, input.getDataTime(), input.getStationId(), 10));
...@@ -51,7 +52,7 @@ public class WindPredictionFutureService { ...@@ -51,7 +52,7 @@ public class WindPredictionFutureService {
* @param input 输入 * @param input 输入
* @return {@link XListResult }<{@link GetWindPredictionFutureOutput }> * @return {@link XListResult }<{@link GetWindPredictionFutureOutput }>
*/ */
@XApiPost(anonymous = true) @XApiPost
@XText("中期3天预测") @XText("中期3天预测")
public XListResult<GetWindPredictionFutureOutput> getMidTerm3DayList(XContext context, GetWindPredictionFutureInput input) { public XListResult<GetWindPredictionFutureOutput> getMidTerm3DayList(XContext context, GetWindPredictionFutureInput input) {
return XListResult.success(getPredictedPowerOutput(context, input.getDataTime(), input.getStationId(), 3)); return XListResult.success(getPredictedPowerOutput(context, input.getDataTime(), input.getStationId(), 3));
...@@ -64,7 +65,7 @@ public class WindPredictionFutureService { ...@@ -64,7 +65,7 @@ public class WindPredictionFutureService {
* @param input 输入 * @param input 输入
* @return {@link XListResult }<{@link GetWindPredictionFutureOutput }> * @return {@link XListResult }<{@link GetWindPredictionFutureOutput }>
*/ */
@XApiPost(anonymous = true) @XApiPost
@XText("短期4小时预测") @XText("短期4小时预测")
public XListResult<GetWindPredictionFutureOutput> getShortTerm4HourList(XContext context, GetWindPredictionFutureInput input) { public XListResult<GetWindPredictionFutureOutput> getShortTerm4HourList(XContext context, GetWindPredictionFutureInput input) {
DateTime now = DateUtil.date(); DateTime now = DateUtil.date();
...@@ -82,27 +83,14 @@ public class WindPredictionFutureService { ...@@ -82,27 +83,14 @@ public class WindPredictionFutureService {
DateTime beginTime = DateUtil.offsetMinute(day, -1441); DateTime beginTime = DateUtil.offsetMinute(day, -1441);
DateTime endTime = DateUtil.offsetHour(day, 4); DateTime endTime = DateUtil.offsetHour(day, 4);
//查预测功率 //查预测功率
WindPredictionFutureMapper mapper = context.getBean(WindPredictionFutureMapper.class); Map<Date, WindPredictionFutureEnt> predictedMap = this.getPredictedMap(context, input.getStationId(), beginTime, endTime);
List<WindPredictionFutureEnt> predictedList = mapper.selectList(new QueryWrapper<WindPredictionFutureEnt>()
.select("data_time", "IFNULL( predicted_power, 0 ) AS predicted_power")
.lambda()
.eq(WindPredictionFutureEnt::getStationId, input.getStationId())
.between(WindPredictionFutureEnt::getDataTime, beginTime, endTime)
.groupBy(WindPredictionFutureEnt::getDataTime, WindPredictionFutureEnt::getPredictedPower)
.orderByAsc(WindPredictionFutureEnt::getDataTime)
);
Map<Date, BigDecimal> predictedMap;
if (CollUtil.isNotEmpty(predictedList)) {
predictedMap = predictedList.stream()
.collect(Collectors.toMap(WindPredictionFutureEnt::getDataTime, WindPredictionFutureEnt::getPredictedPower));
} else {
predictedMap = Collections.emptyMap();
}
//查实际功率 //查实际功率
Map<Date, BigDecimal> powerMap = Collections.emptyMap(); Map<Date, BigDecimal> powerMap = Collections.emptyMap();
return XListResult.success(getPowerOutput(DateUtil.offsetDay(day, -1), endTime, betweenDay, now, predictedMap, powerMap)); return XListResult.success(getPowerOutput(DateUtil.offsetDay(day, -1), endTime, betweenDay, now, predictedMap, powerMap));
} }
/*-----------------------------------private-----------------------------------*/
/** /**
* 获得预测功率输出 * 获得预测功率输出
* *
...@@ -112,7 +100,7 @@ public class WindPredictionFutureService { ...@@ -112,7 +100,7 @@ public class WindPredictionFutureService {
* @param offsetDay 补偿日 * @param offsetDay 补偿日
* @return {@link List }<{@link GetWindPredictionFutureOutput }> * @return {@link List }<{@link GetWindPredictionFutureOutput }>
*/ */
public List<GetWindPredictionFutureOutput> getPredictedPowerOutput(XContext context, String inputTimeStr, String stationId, int offsetDay) { private List<GetWindPredictionFutureOutput> getPredictedPowerOutput(XContext context, String inputTimeStr, String stationId, int offsetDay) {
//判断是否需要启用演示配置 //判断是否需要启用演示配置
DateTime date = DateUtil.date(); DateTime date = DateUtil.date();
DateTime inputTime; DateTime inputTime;
...@@ -128,22 +116,7 @@ public class WindPredictionFutureService { ...@@ -128,22 +116,7 @@ public class WindPredictionFutureService {
DateTime beginTime = DateUtil.offsetMinute(day, -1); DateTime beginTime = DateUtil.offsetMinute(day, -1);
DateTime endTime = DateUtil.offsetDay(day, offsetDay); DateTime endTime = DateUtil.offsetDay(day, offsetDay);
//查预测功率 //查预测功率
WindPredictionFutureMapper mapper = context.getBean(WindPredictionFutureMapper.class); Map<Date, WindPredictionFutureEnt> predictedMap = this.getPredictedMap(context, stationId, beginTime, endTime);
List<WindPredictionFutureEnt> predictedList = mapper.selectList(new QueryWrapper<WindPredictionFutureEnt>()
.select("data_time", "IFNULL( predicted_power, 0 ) AS predicted_power")
.lambda()
.eq(WindPredictionFutureEnt::getStationId, stationId)
.between(WindPredictionFutureEnt::getDataTime, beginTime, endTime)
.groupBy(WindPredictionFutureEnt::getDataTime, WindPredictionFutureEnt::getPredictedPower)
.orderByAsc(WindPredictionFutureEnt::getDataTime)
);
Map<Date, BigDecimal> predictedMap;
if (CollUtil.isNotEmpty(predictedList)) {
predictedMap = predictedList.stream()
.collect(Collectors.toMap(WindPredictionFutureEnt::getDataTime, WindPredictionFutureEnt::getPredictedPower));
} else {
predictedMap = Collections.emptyMap();
}
//查实际功率 //查实际功率
// Map<Date, BigDecimal> powerMap = getActivePowerMap15(context, stationId, beginTime, showTime); // Map<Date, BigDecimal> powerMap = getActivePowerMap15(context, stationId, beginTime, showTime);
Map<Date, BigDecimal> powerMap = Collections.emptyMap(); Map<Date, BigDecimal> powerMap = Collections.emptyMap();
...@@ -161,13 +134,14 @@ public class WindPredictionFutureService { ...@@ -161,13 +134,14 @@ public class WindPredictionFutureService {
* @param powerMap 功率图 * @param powerMap 功率图
* @return {@link List }<{@link GetWindPredictionFutureOutput }> * @return {@link List }<{@link GetWindPredictionFutureOutput }>
*/ */
public List<GetWindPredictionFutureOutput> getPowerOutput(DateTime beginTime, DateTime endTime, int betweenDay, Date now, private List<GetWindPredictionFutureOutput> getPowerOutput(DateTime beginTime, DateTime endTime, int betweenDay, Date now,
Map<Date, BigDecimal> predictedMap, Map<Date, BigDecimal> powerMap) { Map<Date, WindPredictionFutureEnt> predictedMap, Map<Date, BigDecimal> powerMap) {
//取时间范围 //取时间范围
List<DateTime> rangeToList = DateUtil.rangeToList(beginTime, endTime, DateField.MINUTE, 15); List<DateTime> rangeToList = DateUtil.rangeToList(beginTime, endTime, DateField.MINUTE, 15);
GetWindPredictionFutureOutput output; GetWindPredictionFutureOutput output;
List<GetWindPredictionFutureOutput> outputs = new ArrayList<>(rangeToList.size()); List<GetWindPredictionFutureOutput> outputs = new ArrayList<>(rangeToList.size());
Date dataDate; Date dataDate;
WindPredictionFutureEnt windPredictionFutureEnt;
for (DateTime dateTime : rangeToList) { for (DateTime dateTime : rangeToList) {
output = new GetWindPredictionFutureOutput(); output = new GetWindPredictionFutureOutput();
//时间偏移 //时间偏移
...@@ -178,7 +152,12 @@ public class WindPredictionFutureService { ...@@ -178,7 +152,12 @@ public class WindPredictionFutureService {
} }
output.setDataTime(dataDate); output.setDataTime(dataDate);
//匹配预测发电量 //匹配预测发电量
output.setPredictedPower(predictedMap.getOrDefault(dateTime, BigDecimal.ZERO)); if (predictedMap.containsKey(dataDate)) {
windPredictionFutureEnt = predictedMap.get(dataDate);
output.setPredictedPower(windPredictionFutureEnt.getPredictedPower());
output.setActualWindSpeed(windPredictionFutureEnt.getActualWindSpeed());
output.setWindSpeed(windPredictionFutureEnt.getWindSpeed());
}
//匹配实际发电量 //匹配实际发电量
if (DateUtil.compare(dataDate, now) > 0) { if (DateUtil.compare(dataDate, now) > 0) {
output.setActualPower(null); output.setActualPower(null);
...@@ -189,4 +168,35 @@ public class WindPredictionFutureService { ...@@ -189,4 +168,35 @@ public class WindPredictionFutureService {
} }
return outputs; return outputs;
} }
/**
* 获取预测数据
*
* @param context 上下文
* @param stationId 站点id
* @param beginTime 开始时间
* @param endTime 结束时间
* @return {@link Map }<{@link Date }, {@link WindPredictionFutureEnt }>
*/
private Map<Date, WindPredictionFutureEnt> getPredictedMap(XContext context, String stationId, DateTime beginTime, DateTime endTime) {
WindPredictionFutureMapper mapper = context.getBean(WindPredictionFutureMapper.class);
List<WindPredictionFutureEnt> predictedList = mapper.selectList(new QueryWrapper<WindPredictionFutureEnt>()
.select("data_time", "IFNULL( predicted_power, 0 ) AS predicted_power", "actual_wind_speed", "wind_speed")
.lambda()
.eq(WindPredictionFutureEnt::getStationId, stationId)
.between(WindPredictionFutureEnt::getDataTime, beginTime, endTime)
.groupBy(WindPredictionFutureEnt::getDataTime, WindPredictionFutureEnt::getPredictedPower
, WindPredictionFutureEnt::getActualWindSpeed, WindPredictionFutureEnt::getWindSpeed)
.orderByAsc(WindPredictionFutureEnt::getDataTime)
);
Map<Date, WindPredictionFutureEnt> predictedMap;
if (CollUtil.isNotEmpty(predictedList)) {
predictedMap = predictedList.stream()
.collect(Collectors.toMap(WindPredictionFutureEnt::getDataTime, Function.identity()));
} else {
predictedMap = Collections.emptyMap();
}
return predictedMap;
}
} }
...@@ -23,4 +23,10 @@ public class GetWindPredictionFutureOutput { ...@@ -23,4 +23,10 @@ public class GetWindPredictionFutureOutput {
@XText("预测功率(kw)") @XText("预测功率(kw)")
private BigDecimal predictedPower; private BigDecimal predictedPower;
@XText("实际风速(m/s)")
private BigDecimal actualWindSpeed;
@XText("预报风速(m/s)")
private BigDecimal windSpeed;
} }
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