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
/* JUG Java UUID Generator
*
* Copyright (c) 2002- Tatu Saloranta, tatu.saloranta@iki.fi
*
* Licensed under the License specified in the file LICENSE which is
* included with the source code.
* You may not use this file except in compliance with the License.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.fasterxml.uuid;
import com.fasterxml.uuid.impl.*;
import java.io.IOException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Random;
import java.util.UUID;
/**
* Root factory class for constructing UUID generators.
*
* @author tatu
* @since 3.0
*/
public class Generators {
/**
* If no explicit timer (and synchronizer it implicitly uses) is specified,
* we will create and use a single lazily-constructed timer, which uses in-JVM
* synchronization but no external file-based syncing.
*/
protected static UUIDTimer _sharedTimer;
/**
* The hardware address of the egress network interface.
*/
protected static EthernetAddress _egressIfAddr = null;
// // Random-based generation
/**
* Factory method for constructing UUID generator that uses default (shared)
* random number generator for constructing UUIDs according to standard
* method number 4.
*/
public static RandomBasedGenerator randomBasedGenerator() {
return randomBasedGenerator(null);
}
/**
* Factory method for constructing UUID generator that uses specified
* random number generator for constructing UUIDs according to standard
* method number 4.
*/
public static RandomBasedGenerator randomBasedGenerator(Random rnd) {
return new RandomBasedGenerator(rnd);
}
// // Name-based generation
/**
* Factory method for constructing UUID generator that uses specified
* random number generator for constructing UUIDs according to standard
* method number 5, but without using a namespace.
* Digester to use will be SHA-1 as recommened by UUID spec.
*/
public static NameBasedGenerator nameBasedGenerator() {
return nameBasedGenerator(null);
}
/**
* Factory method for constructing UUID generator that uses specified
* random number generator for constructing UUIDs according to standard
* method number 5, with specified namespace (or without one if null
* is specified).
* Digester to use will be SHA-1 as recommened by UUID spec.
*
* @param namespace UUID that represents namespace to use; see
* {@link NameBasedGenerator} for 'standard' namespaces specified by
* UUID specs
*/
public static NameBasedGenerator nameBasedGenerator(UUID namespace) {
return nameBasedGenerator(namespace, null);
}
/**
* Factory method for constructing UUID generator that uses specified
* random number generator for constructing UUIDs according to standard
* method number 3 or 5, with specified namespace (or without one if null
* is specified), using specified digester.
* If digester is passed as null, a SHA-1 digester will be constructed.
*
* @param namespace UUID that represents namespace to use; see
* {@link NameBasedGenerator} for 'standard' namespaces specified by
* UUID specs
* @param digester Digester to use; should be a MD5 or SHA-1 digester.
*/
public static NameBasedGenerator nameBasedGenerator(UUID namespace, MessageDigest digester) {
UUIDType type = null;
if (digester == null) {
try {
digester = MessageDigest.getInstance("SHA-1");
type = UUIDType.NAME_BASED_SHA1;
} catch (NoSuchAlgorithmException nex) {
throw new IllegalArgumentException("Couldn't instantiate SHA-1 MessageDigest instance: " + nex);
}
}
return new NameBasedGenerator(namespace, digester, type);
}
// // Epoch Time+random generation
/**
* Factory method for constructing UUID generator that generates UUID using
* variant 7 (Unix Epoch time+random based).
*/
public static TimeBasedEpochGenerator timeBasedEpochGenerator() {
return timeBasedEpochGenerator(null);
}
/**
* Factory method for constructing UUID generator that generates UUID using
* variant 7 (time+random based), using specified Ethernet address
* as the location part of UUID.
* No additional external synchronization is used.
*/
public static TimeBasedEpochGenerator timeBasedEpochGenerator(Random random) {
return new TimeBasedEpochGenerator(random);
}
// // Time+location-based generation
/**
* Factory method for constructing UUID generator that generates UUID using variant 1
* (time+location based). This method will use the ethernet address of the interface
* that routes to the default gateway. For most simple and common networking configurations
* this will be the most appropriate address to use. The default interface is determined
* by the calling {@link EthernetAddress#fromEgressInterface()}. Note that this will only
* identify the egress interface once: if you have a complex network setup where your
* outbound routes/interfaces may change dynamically, and you want your UUIDs to
* accurately reflect which interface is being actively used, this method is not for you.
*
* @since 4.1
*/
public static TimeBasedGenerator egressTimeBasedGenerator() {
return timeBasedGenerator(egressInterfaceAddress());
}
/**
* Factory method for constructing UUID generator that generates UUID using
* variant 1 (time+location based).
* Since no Ethernet address is passed, a bogus broadcast address will be
* constructed for purpose of UUID generation; usually it is better to
* instead access one of host's NIC addresses using
* {@link EthernetAddress#fromInterface} which will use one of available
* MAC (Ethernet) addresses available.
*/
public static TimeBasedGenerator timeBasedGenerator() {
return timeBasedGenerator(null);
}
/**
* Factory method for constructing UUID generator that generates UUID using
* variant 1 (time+location based), using specified Ethernet address
* as the location part of UUID.
* No additional external synchronization is used.
*/
public static TimeBasedGenerator timeBasedGenerator(EthernetAddress ethernetAddress) {
return timeBasedGenerator(ethernetAddress, (UUIDTimer) null);
}
/**
* Factory method for constructing UUID generator that generates UUID using
* variant 1 (time+location based), using specified Ethernet address
* as the location part of UUID, and specified synchronizer (which may add
* additional restrictions to guarantee system-wide uniqueness).
*
* @param ethernetAddress (optional) MAC address to use; if null, a transient
* random address is generated.
* @see com.fasterxml.uuid.ext.FileBasedTimestampSynchronizer
*/
public static TimeBasedGenerator timeBasedGenerator(EthernetAddress ethernetAddress,
TimestampSynchronizer sync) {
UUIDTimer timer;
try {
timer = new UUIDTimer(new Random(System.currentTimeMillis()), sync);
} catch (IOException e) {
throw new IllegalArgumentException("Failed to create UUIDTimer with specified synchronizer: " + e.getMessage(), e);
}
return timeBasedGenerator(ethernetAddress, timer);
}
/**
* Factory method for constructing UUID generator that generates UUID using
* variant 1 (time+location based), using specified Ethernet address
* as the location part of UUID, and specified {@link UUIDTimer} instance
* (which includes embedded synchronizer that defines synchronization behavior).
*/
public static TimeBasedGenerator timeBasedGenerator(EthernetAddress ethernetAddress,
UUIDTimer timer) {
if (timer == null) {
timer = sharedTimer();
}
return new TimeBasedGenerator(ethernetAddress, timer);
}
// // DB Locality Time+location-based generation
/**
* Factory method for constructing UUID generator that generates UUID using
* variant 6 (time+location based, reordered for DB locality). Since no Ethernet
* address is passed, a bogus broadcast address will be constructed for purpose
* of UUID generation; usually it is better to instead access one of host's NIC
* addresses using {@link EthernetAddress#fromInterface} which will use one of
* available MAC (Ethernet) addresses available.
*/
public static TimeBasedReorderedGenerator timeBasedReorderedGenerator() {
return timeBasedReorderedGenerator(null);
}
/**
* Factory method for constructing UUID generator that generates UUID using
* variant 6 (time+location based, reordered for DB locality), using specified
* Ethernet address as the location part of UUID. No additional external
* synchronization is used.
*/
public static TimeBasedReorderedGenerator timeBasedReorderedGenerator(EthernetAddress ethernetAddress) {
return timeBasedReorderedGenerator(ethernetAddress, (UUIDTimer) null);
}
/**
* Factory method for constructing UUID generator that generates UUID using
* variant 6 (time+location based, reordered for DB locality), using specified
* Ethernet address as the location part of UUID, and specified
* {@link UUIDTimer} instance (which includes embedded synchronizer that defines
* synchronization behavior).
*/
public static TimeBasedReorderedGenerator timeBasedReorderedGenerator(EthernetAddress ethernetAddress,
UUIDTimer timer) {
if (timer == null) {
timer = sharedTimer();
}
return new TimeBasedReorderedGenerator(ethernetAddress, timer);
}
/*
/**********************************************************************
/* Internal methods
/**********************************************************************
*/
private static synchronized UUIDTimer sharedTimer() {
if (_sharedTimer == null) {
try {
_sharedTimer = new UUIDTimer(new java.util.Random(System.currentTimeMillis()), null);
} catch (IOException e) {
throw new IllegalArgumentException("Failed to create UUIDTimer with specified synchronizer: " + e.getMessage(), e);
}
}
return _sharedTimer;
}
private static synchronized EthernetAddress egressInterfaceAddress() {
if (_egressIfAddr == null) {
_egressIfAddr = EthernetAddress.fromEgressInterface();
}
return _egressIfAddr;
}
}
/* JUG Java UUID Generator
*
* Copyright (c) 2002- Tatu Saloranta, tatu.saloranta@iki.fi
*
* Licensed under the License specified in the file LICENSE which is
* included with the source code.
* You may not use this file except in compliance with the License.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.fasterxml.uuid;
import com.fasterxml.uuid.impl.NameBasedGenerator;
import java.io.PrintStream;
import java.security.SecureRandom;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
* Simple command-line interface to UUID generation functionality.
*/
public class Jug {
protected final static HashMap<String, String> TYPES = new HashMap<>();
protected final static HashMap<String, String> OPTIONS = new HashMap<>();
static {
TYPES.put("time-based", "t");
TYPES.put("random-based", "r");
TYPES.put("name-based", "n");
TYPES.put("reordered-time-based", "o"); // Variant 6
TYPES.put("epoch-time-based", "e"); // Variant 7
}
static {
OPTIONS.put("count", "c");
OPTIONS.put("ethernet-address", "e");
OPTIONS.put("help", "h");
OPTIONS.put("namespace", "s");
OPTIONS.put("name", "n");
OPTIONS.put("performance", "p");
OPTIONS.put("verbose", "v");
}
protected static void printUsage() {
String clsName = Jug.class.getName();
System.err.println("Usage: java " + clsName + " [options] type");
System.err.println("Where options are:");
System.err.println(" --count / -c <number>: will generate <number> UUIDs (default: 1)");
System.err.println(" --ethernet-address / -e <ether-address>: defines the ethernet address");
System.err.println(" (in xx:xx:xx:xx:xx:xx notation, usually obtained using 'ifconfig' etc)");
System.err.println(" to use with time-based UUID generation");
System.err.println(" --help / -h: lists the usage (ie. what you see now)");
System.err.println(" --name / -n: specifies");
System.err.println(" o name for name-based UUID generation");
System.err.println(" o 'information' part of tag-URI for tag-URI UUID generation");
System.err.println(" --namespace / -s: specifies");
System.err.println(" o the namespace (DNS or URL) for name-based UUID generation");
System.err.println(" o 'authority' part of tag-URI for tag-URI UUID generation;");
System.err.println(" (fully-qualified domain name, email address)");
System.err.println(" --performance / -p: measure time it takes to generate UUID(s).");
System.err.println(" [note that UUIDs are not printed out unless 'verbose' is also specified]");
System.err.println(" --verbose / -v: lists additional information about UUID generation\n (by default only UUIDs are printed out (to make it usable in scripts)");
System.err.println("And type is one of:");
System.err.println(" time-based / t: generate UUID based on current time and optional\n location information (defined with -e option)");
System.err.println(" random-based / r: generate UUID based on the default secure random number generator");
System.err.println(" name-based / n: generate UUID based on MD5 hash of given String ('name')");
System.err.println(" reordered-time-based / o: generate UUID based on current time and optional\n location information (defined with -e option)");
System.err.println(" epoch-based / e: generate UUID based on current time (as 'epoch') and random number");
}
private static void printMap(Map<String, String> m, PrintStream out, boolean option) {
int i = 0;
int len = m.size();
for (Map.Entry<String, String> en : m.entrySet()) {
if (++i > 1) {
if (i < len) {
out.print(", ");
} else {
out.print(" and ");
}
}
if (option) {
out.print("--");
}
out.print(en.getKey());
out.print(" (");
if (option) {
out.print("-");
}
out.print(en.getValue());
out.print(")");
}
}
public static void main(String[] args) {
if (args.length == 0) {
printUsage();
return;
}
int count = args.length;
String type = args[count - 1];
boolean verbose = false;
int genCount = 1;
String name = null;
String nameSpace = null;
EthernetAddress addr = null;
boolean performance = false;
--count;
// Type we recognize?
String tmp = TYPES.get(type);
if (tmp == null) {
if (!TYPES.containsValue(type)) {
System.err.println("Unrecognized UUID generation type '" +
type + "'; currently available ones are:");
printMap(TYPES, System.err, false);
System.err.println();
System.exit(1);
}
} else {
// Long names get translated to shorter ones:
type = tmp;
}
NoArgGenerator noArgGenerator = null; // random- or time-based
StringArgGenerator nameArgGenerator = null; // name-based
for (int i = 0; i < count; ++i) {
String opt = args[i];
if (opt.isEmpty() || opt.charAt(0) != '-') {
System.err.println("Unrecognized option '" + opt + "' (missing leading hyphen?), exiting.");
System.exit(1);
}
char option = (char) 0;
if (opt.startsWith("--")) {
String o = OPTIONS.get(opt.substring(2));
// Let's translate longer names to simple names:
if (o != null) {
option = o.charAt(0);
}
} else {
if (OPTIONS.containsValue(opt.substring(1))) {
option = opt.charAt(1);
}
}
if (option == (char) 0) {
System.err.println("Unrecognized option '" + opt + "'; exiting.");
System.err.print("[options currently available are: ");
printMap(OPTIONS, System.err, true);
System.err.println("]");
System.exit(1);
}
// K. Now we have one-letter options to handle:
try {
String next;
switch (option) {
case 'c':
// Need a number now:
next = args[++i];
try {
genCount = Integer.parseInt(next);
} catch (NumberFormatException nex) {
System.err.println("Invalid number argument for option '" + opt + "', exiting.");
System.exit(1);
}
if (genCount < 1) {
System.err.println("Invalid number argument for option '" + opt + "'; negative numbers not allowed, ignoring (defaults to 1).");
}
break;
case 'e':
// Need the ethernet address:
next = args[++i];
try {
addr = EthernetAddress.valueOf(next);
} catch (NumberFormatException nex) {
System.err.println("Invalid ethernet address for option '" + opt + "', error: " + nex);
System.exit(1);
}
break;
case 'h':
printUsage();
return;
case 'n':
// Need the name
name = args[++i];
break;
case 'p': // performance:
performance = true;
break;
case 's':
// Need the namespace id
nameSpace = args[++i];
break;
case 'v':
verbose = true;
break;
}
} catch (IndexOutOfBoundsException ie) {
// We get here when an arg is missing...
System.err.println("Missing argument for option '" + opt + "', exiting.");
System.exit(1);
}
} // for (int i = 0....)
/* Ok, args look ok so far. Now to the generation; some args/options
* can't be validated without knowing the type:
*/
char typeC = type.charAt(0);
UUID nsUUID = null;
boolean usesRnd = false;
switch (typeC) {
case 't': // time-based
case 'o': // reordered-time-based (Variant 6)
// 30-Jun-2022, tatu: Is this true? My former self must have had his
// reasons so leaving as is but... odd.
usesRnd = true;
// No address specified? Need a dummy one...
if (addr == null) {
if (verbose) {
System.out.print("(no address specified, generating dummy address: ");
}
addr = EthernetAddress.constructMulticastAddress(new java.util.Random(System.currentTimeMillis()));
if (verbose) {
System.out.print(addr.toString());
System.out.println(")");
}
}
noArgGenerator = (typeC == 't')
? Generators.timeBasedGenerator(addr)
: Generators.timeBasedReorderedGenerator(addr);
break;
case 'r': // random-based
usesRnd = true;
{
SecureRandom r = new SecureRandom();
if (verbose) {
System.out.print("(using secure random generator, info = '" + r.getProvider().getInfo() + "')");
}
noArgGenerator = Generators.randomBasedGenerator(r);
}
break;
case 'e': // epoch-time-based
usesRnd = true;
{
SecureRandom r = new SecureRandom();
if (verbose) {
System.out.print("(using secure random generator, info = '" + r.getProvider().getInfo() + "')");
}
noArgGenerator = Generators.timeBasedEpochGenerator(r);
}
break;
case 'n': // name-based
if (nameSpace == null) {
System.err.println("--name-space (-s) - argument missing when using method that requires it, exiting.");
System.exit(1);
}
if (name == null) {
System.err.println("--name (-n) - argument missing when using method that requires it, exiting.");
System.exit(1);
}
String orig = nameSpace;
nameSpace = nameSpace.toLowerCase();
if (nameSpace.equals("url")) {
nsUUID = NameBasedGenerator.NAMESPACE_URL;
} else if (nameSpace.equals("dns")) {
nsUUID = NameBasedGenerator.NAMESPACE_DNS;
} else {
System.err.println("Unrecognized namespace '" + orig
+ "'; only DNS and URL allowed for name-based generation.");
System.exit(1);
}
nameArgGenerator = Generators.nameBasedGenerator(nsUUID);
break;
}
// When measuring performance, make sure that the random number
// generator is initialized prior to measurements...
long now = 0L;
if (performance) {
// No need to pre-initialize for name-based schemes?
if (usesRnd) {
if (verbose) {
System.out.println("(initializing random number generator before UUID generation so that performance measurements are not skewed due to one-time init costs)");
}
// should initialize by just calling it
noArgGenerator.generate();
if (verbose) {
System.out.println("(random number generator initialized ok)");
}
}
now = System.currentTimeMillis();
}
for (int i = 0; i < genCount; ++i) {
UUID uuid = (nameArgGenerator == null) ?
noArgGenerator.generate() : nameArgGenerator.generate(name); // lgtm [java/dereferenced-value-may-be-null]
if (verbose) {
System.out.print("UUID: ");
}
if (!performance || verbose) {
System.out.println(uuid.toString());
}
} // for (int i = 0; ...)
if (verbose) {
System.out.println("Done.");
}
if (performance) {
now = System.currentTimeMillis() - now;
long avg = (now * 10 + (genCount / 2)) / genCount;
System.out.println("Performance: took " + now + " milliseconds to generate (and print out) " + genCount + " UUIDs; average being " + (avg / 10) + "." + (avg % 10) + " msec.");
}
}
}
\ No newline at end of file
......@@ -3,15 +3,7 @@ package com.fasterxml.uuid.impl;
import org.slf4j.Logger;
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 {
private final Class<?> _forClass;
......
package pps.core.common.mybatis;
import cn.hutool.core.lang.UUID;
import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator;
import pps.core.common.utils.UUIDHelper;
public class MyIDGenerator extends DefaultIdentifierGenerator {
@Override
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;
import java.math.BigDecimal;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
......@@ -38,7 +39,7 @@ public class WindPredictionFutureService {
* @param input 输入
* @return {@link XListResult }<{@link GetWindPredictionFutureOutput }>
*/
@XApiPost(anonymous = true)
@XApiPost
@XText("中期10天预测")
public XListResult<GetWindPredictionFutureOutput> getMidTerm10DayList(XContext context, GetWindPredictionFutureInput input) {
return XListResult.success(getPredictedPowerOutput(context, input.getDataTime(), input.getStationId(), 10));
......@@ -51,7 +52,7 @@ public class WindPredictionFutureService {
* @param input 输入
* @return {@link XListResult }<{@link GetWindPredictionFutureOutput }>
*/
@XApiPost(anonymous = true)
@XApiPost
@XText("中期3天预测")
public XListResult<GetWindPredictionFutureOutput> getMidTerm3DayList(XContext context, GetWindPredictionFutureInput input) {
return XListResult.success(getPredictedPowerOutput(context, input.getDataTime(), input.getStationId(), 3));
......@@ -64,7 +65,7 @@ public class WindPredictionFutureService {
* @param input 输入
* @return {@link XListResult }<{@link GetWindPredictionFutureOutput }>
*/
@XApiPost(anonymous = true)
@XApiPost
@XText("短期4小时预测")
public XListResult<GetWindPredictionFutureOutput> getShortTerm4HourList(XContext context, GetWindPredictionFutureInput input) {
DateTime now = DateUtil.date();
......@@ -82,27 +83,14 @@ public class WindPredictionFutureService {
DateTime beginTime = DateUtil.offsetMinute(day, -1441);
DateTime endTime = DateUtil.offsetHour(day, 4);
//查预测功率
WindPredictionFutureMapper mapper = context.getBean(WindPredictionFutureMapper.class);
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, WindPredictionFutureEnt> predictedMap = this.getPredictedMap(context, input.getStationId(), beginTime, endTime);
//查实际功率
Map<Date, BigDecimal> powerMap = Collections.emptyMap();
return XListResult.success(getPowerOutput(DateUtil.offsetDay(day, -1), endTime, betweenDay, now, predictedMap, powerMap));
}
/*-----------------------------------private-----------------------------------*/
/**
* 获得预测功率输出
*
......@@ -112,7 +100,7 @@ public class WindPredictionFutureService {
* @param offsetDay 补偿日
* @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 inputTime;
......@@ -128,22 +116,7 @@ public class WindPredictionFutureService {
DateTime beginTime = DateUtil.offsetMinute(day, -1);
DateTime endTime = DateUtil.offsetDay(day, offsetDay);
//查预测功率
WindPredictionFutureMapper mapper = context.getBean(WindPredictionFutureMapper.class);
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, WindPredictionFutureEnt> predictedMap = this.getPredictedMap(context, stationId, beginTime, endTime);
//查实际功率
// Map<Date, BigDecimal> powerMap = getActivePowerMap15(context, stationId, beginTime, showTime);
Map<Date, BigDecimal> powerMap = Collections.emptyMap();
......@@ -161,13 +134,14 @@ public class WindPredictionFutureService {
* @param powerMap 功率图
* @return {@link List }<{@link GetWindPredictionFutureOutput }>
*/
public List<GetWindPredictionFutureOutput> getPowerOutput(DateTime beginTime, DateTime endTime, int betweenDay, Date now,
Map<Date, BigDecimal> predictedMap, Map<Date, BigDecimal> powerMap) {
private List<GetWindPredictionFutureOutput> getPowerOutput(DateTime beginTime, DateTime endTime, int betweenDay, Date now,
Map<Date, WindPredictionFutureEnt> predictedMap, Map<Date, BigDecimal> powerMap) {
//取时间范围
List<DateTime> rangeToList = DateUtil.rangeToList(beginTime, endTime, DateField.MINUTE, 15);
GetWindPredictionFutureOutput output;
List<GetWindPredictionFutureOutput> outputs = new ArrayList<>(rangeToList.size());
Date dataDate;
WindPredictionFutureEnt windPredictionFutureEnt;
for (DateTime dateTime : rangeToList) {
output = new GetWindPredictionFutureOutput();
//时间偏移
......@@ -178,7 +152,12 @@ public class WindPredictionFutureService {
}
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) {
output.setActualPower(null);
......@@ -189,4 +168,35 @@ public class WindPredictionFutureService {
}
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 {
@XText("预测功率(kw)")
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