优化预报接口、优化配置参数功能
parent
6e0b120ec6
commit
bae7a0ea9f
|
|
@ -79,7 +79,7 @@ public class ForecastUseparam extends GenericPageParams implements Serializable
|
||||||
/**
|
/**
|
||||||
* 参数描述
|
* 参数描述
|
||||||
*/
|
*/
|
||||||
@TableField(value="param_remarks")
|
@TableField(value="param_desc")
|
||||||
@Schema(description="参数描述")
|
@Schema(description="参数描述")
|
||||||
@Size(max = 255,message = "参数描述最大长度要小于 255")
|
@Size(max = 255,message = "参数描述最大长度要小于 255")
|
||||||
private String paramDesc;
|
private String paramDesc;
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ import com.gunshi.project.xyt.grb.RainGrib2Layer;
|
||||||
import com.gunshi.project.xyt.mapper.ForecastResultsMapper;
|
import com.gunshi.project.xyt.mapper.ForecastResultsMapper;
|
||||||
import com.gunshi.project.xyt.model.AttResBase;
|
import com.gunshi.project.xyt.model.AttResBase;
|
||||||
import com.gunshi.project.xyt.model.ForecastPa;
|
import com.gunshi.project.xyt.model.ForecastPa;
|
||||||
import com.gunshi.project.xyt.model.ForecastTask;
|
|
||||||
import com.gunshi.project.xyt.model.ForecastResults;
|
import com.gunshi.project.xyt.model.ForecastResults;
|
||||||
|
import com.gunshi.project.xyt.model.ForecastTask;
|
||||||
import com.gunshi.project.xyt.model.ForecastU;
|
import com.gunshi.project.xyt.model.ForecastU;
|
||||||
import com.gunshi.project.xyt.model.ForecastUseparam;
|
import com.gunshi.project.xyt.model.ForecastUseparam;
|
||||||
import com.gunshi.project.xyt.model.StPptnR;
|
import com.gunshi.project.xyt.model.StPptnR;
|
||||||
|
|
@ -145,7 +145,7 @@ public class ForecastResultsService extends ServiceImpl<ForecastResultsMapper, F
|
||||||
pptnRAllList.addAll(pptnRExistedList);
|
pptnRAllList.addAll(pptnRExistedList);
|
||||||
pptnRAllList.addAll(pptnRFutureList);
|
pptnRAllList.addAll(pptnRFutureList);
|
||||||
// 获取配置参数
|
// 获取配置参数
|
||||||
List<ForecastUseparam> paramList = forecastUseparamService.list();
|
List<ForecastUseparam> paramList = forecastUseparamService.list(new QueryWrapper<ForecastUseparam>().isNotNull("param_code").isNotNull("param_value"));
|
||||||
List<ForecastU> uList = forecastUService.list();
|
List<ForecastU> uList = forecastUService.list();
|
||||||
if (CollectionUtils.isEmpty(paramList) || CollectionUtils.isEmpty(uList) || CollectionUtils.isEmpty(pptnRAllList)) {
|
if (CollectionUtils.isEmpty(paramList) || CollectionUtils.isEmpty(uList) || CollectionUtils.isEmpty(pptnRAllList)) {
|
||||||
return voList;
|
return voList;
|
||||||
|
|
@ -181,6 +181,9 @@ public class ForecastResultsService extends ServiceImpl<ForecastResultsMapper, F
|
||||||
AttResBase attResBase = attResBaseService.getOne(new QueryWrapper<>());
|
AttResBase attResBase = attResBaseService.getOne(new QueryWrapper<>());
|
||||||
// 泄流量
|
// 泄流量
|
||||||
List<StZqrlB> stZqrlBList = stZqrlBService.list(new QueryWrapper<StZqrlB>().eq("stcd", "716153201"));
|
List<StZqrlB> stZqrlBList = stZqrlBService.list(new QueryWrapper<StZqrlB>().eq("stcd", "716153201"));
|
||||||
|
// 水位历史数据
|
||||||
|
List<StRsvrR> rsvrRRealList = stRsvrRService.list(new QueryWrapper<StRsvrR>().eq("stcd", "716153201").ge("tm", startTime).le("tm", endTime));
|
||||||
|
List<StRsvrR> resultList = reorganizeRsvrRData(rsvrRRealList, dt);
|
||||||
List<Date[]> periods = splitByDay8To8(startTime, endTime);
|
List<Date[]> periods = splitByDay8To8(startTime, endTime);
|
||||||
for (Date[] period : periods) {
|
for (Date[] period : periods) {
|
||||||
// 根据每段时间的开始时间,如果在08点前,则采用前一天的pa值计算
|
// 根据每段时间的开始时间,如果在08点前,则采用前一天的pa值计算
|
||||||
|
|
@ -195,10 +198,10 @@ public class ForecastResultsService extends ServiceImpl<ForecastResultsMapper, F
|
||||||
// 筛选时间段内的降雨数据。第一个条件:时间大于等开始时间;第二个条件:时间小于等于结束时间(不包前但包后,比如从8点开始,就要拆下一个时间:9点的数据)
|
// 筛选时间段内的降雨数据。第一个条件:时间大于等开始时间;第二个条件:时间小于等于结束时间(不包前但包后,比如从8点开始,就要拆下一个时间:9点的数据)
|
||||||
List<StPptnR> filterList = pptnRAllList.stream().filter(e -> e.getTm().compareTo(period[0]) >= 0).filter(e -> e.getTm().compareTo(period[1]) <= 0).collect(Collectors.toList());
|
List<StPptnR> filterList = pptnRAllList.stream().filter(e -> e.getTm().compareTo(period[0]) >= 0).filter(e -> e.getTm().compareTo(period[1]) <= 0).collect(Collectors.toList());
|
||||||
// 从第二条数据开始
|
// 从第二条数据开始
|
||||||
for (int i = 1; i <= filterList.size(); i++) {
|
for (int i = 1; i < filterList.size(); i++) {
|
||||||
|
StPptnR stPptnRLast = filterList.get(i - 1);
|
||||||
StPptnR stPptnR = filterList.get(i);
|
StPptnR stPptnR = filterList.get(i);
|
||||||
String drp = stPptnR.getDrp();
|
String drp = stPptnR.getDrp();
|
||||||
StPptnR stPptnRLast = filterList.get(i - 1);
|
|
||||||
// 两条数据的小时差
|
// 两条数据的小时差
|
||||||
double diffHours = dateHourDifference(stPptnRLast.getTm(), stPptnR.getTm());
|
double diffHours = dateHourDifference(stPptnRLast.getTm(), stPptnR.getTm());
|
||||||
// 两条数据间需要增补几条
|
// 两条数据间需要增补几条
|
||||||
|
|
@ -209,13 +212,12 @@ public class ForecastResultsService extends ServiceImpl<ForecastResultsMapper, F
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
double[] PList = pResultList.stream().mapToDouble(Double::parseDouble).toArray();
|
double[] PList = pResultList.stream().mapToDouble(Double::parseDouble).toArray();
|
||||||
// 水位历史数据
|
|
||||||
List<StRsvrR> rsvrRRealList = stRsvrRService.list(new QueryWrapper<StRsvrR>().eq("stcd", "716153201").ge("tm", period[0]).le("tm", period[1]));
|
|
||||||
rsvrRRealList = reorganizeRsvrRData(rsvrRRealList, dt);
|
|
||||||
// 预测执行
|
// 预测执行
|
||||||
List<FloodAlgorithemVo> forecastVoList = RrainfallForecast.getData(sdf.format(period[0]), forecastPa.getK().doubleValue(), forecastPa.getPa0().doubleValue(), Wm, forecastPa.getPt0().doubleValue(), H1, dt,
|
List<FloodAlgorithemVo> forecastVoList = RrainfallForecast.getData(sdf.format(period[0]), forecastPa.getK().doubleValue(), forecastPa.getPa0().doubleValue(), Wm, forecastPa.getPt0().doubleValue(), H1, dt,
|
||||||
forecastPa.getPa().doubleValue(), PList, u, "716153201");
|
forecastPa.getPa().doubleValue(), PList, u, "716153201");
|
||||||
if (CollectionUtils.isNotEmpty(forecastVoList)) {
|
if (CollectionUtils.isNotEmpty(forecastVoList)) {
|
||||||
|
// 筛选同时段的真实水位数据
|
||||||
|
List<StRsvrR> realRsvrList = resultList.stream().filter(item -> item.getTm().compareTo(period[0]) >=0 && item.getTm().compareTo(period[1]) <=0).collect(Collectors.toList());
|
||||||
forecastVoList = forecastVoList.subList(0, PList.length);
|
forecastVoList = forecastVoList.subList(0, PList.length);
|
||||||
for (int j = 0; j < forecastVoList.size(); j++) {
|
for (int j = 0; j < forecastVoList.size(); j++) {
|
||||||
FloodAlgorithemVo floodAlgorithemVo = forecastVoList.get(j);
|
FloodAlgorithemVo floodAlgorithemVo = forecastVoList.get(j);
|
||||||
|
|
@ -226,8 +228,8 @@ public class ForecastResultsService extends ServiceImpl<ForecastResultsMapper, F
|
||||||
resultVo.setYcCkQValue(floodAlgorithemVo.getCq());// 预测出库流量
|
resultVo.setYcCkQValue(floodAlgorithemVo.getCq());// 预测出库流量
|
||||||
resultVo.setYcSwHValue(floodAlgorithemVo.getKh());// 预测水库水位
|
resultVo.setYcSwHValue(floodAlgorithemVo.getKh());// 预测水库水位
|
||||||
H1 = resultVo.getYcSwHValue().doubleValue();// 先以预测水位作为下一次预测段起始值
|
H1 = resultVo.getYcSwHValue().doubleValue();// 先以预测水位作为下一次预测段起始值
|
||||||
if (j < rsvrRRealList.size()) {
|
if (j < realRsvrList.size()) {
|
||||||
BigDecimal realSwHValue = new BigDecimal(rsvrRRealList.get(j).getRz());
|
BigDecimal realSwHValue = new BigDecimal(realRsvrList.get(j).getRz());
|
||||||
resultVo.setRealSwHValue(realSwHValue);// 真实水库水位
|
resultVo.setRealSwHValue(realSwHValue);// 真实水库水位
|
||||||
H1 = realSwHValue.doubleValue();// 如果有真实水位,将最后一条的真实水位作为下一次预测段的初始水位
|
H1 = realSwHValue.doubleValue();// 如果有真实水位,将最后一条的真实水位作为下一次预测段的初始水位
|
||||||
// 真实出库流量=真实水库水位与泄流量曲线差值法
|
// 真实出库流量=真实水库水位与泄流量曲线差值法
|
||||||
|
|
@ -334,13 +336,14 @@ public class ForecastResultsService extends ServiceImpl<ForecastResultsMapper, F
|
||||||
// 两条数据的小时差
|
// 两条数据的小时差
|
||||||
double diffHours = dateHourDifference(stRsvrR.getTm(), stRsvrRNext.getTm());
|
double diffHours = dateHourDifference(stRsvrR.getTm(), stRsvrRNext.getTm());
|
||||||
int floorNum = (int) Math.floor(diffHours / dt);
|
int floorNum = (int) Math.floor(diffHours / dt);
|
||||||
BigDecimal meanDifference = new BigDecimal(stRsvrRNext.getRz()).subtract(new BigDecimal(drp)).divide(new BigDecimal(floorNum), BigDecimal.ROUND_HALF_UP, 2);
|
BigDecimal meanDifference = new BigDecimal(stRsvrRNext.getRz()).subtract(new BigDecimal(drp)).divide(new BigDecimal(floorNum), BigDecimal.ROUND_HALF_UP, 3);
|
||||||
for (int j = 1; j < floorNum; j++) {
|
for (int j = 1; j < floorNum; j++) {
|
||||||
// 增补出的数据
|
// 增补出的数据
|
||||||
StRsvrR suppleStRsvrR = new StRsvrR();
|
StRsvrR suppleStRsvrR = new StRsvrR();
|
||||||
BigDecimal add = new BigDecimal(drp).add(meanDifference.multiply(new BigDecimal(j))).setScale(2, BigDecimal.ROUND_HALF_UP);
|
BigDecimal add = new BigDecimal(drp).add(meanDifference.multiply(new BigDecimal(j))).setScale(3, BigDecimal.ROUND_HALF_UP);
|
||||||
try {
|
try {
|
||||||
suppleStRsvrR.setTm(sdf.parse(RunoffService.calc(sdf.format(tm), hours, minutes, true)));
|
tm = sdf.parse(RunoffService.calc(sdf.format(tm), hours, minutes, true));
|
||||||
|
suppleStRsvrR.setTm(tm);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ public class PaDataTask {
|
||||||
calendar.setTime(new Date());
|
calendar.setTime(new Date());
|
||||||
Date nowTime = calendar.getTime();
|
Date nowTime = calendar.getTime();
|
||||||
// 获取配置参数
|
// 获取配置参数
|
||||||
List<ForecastUseparam> paramList = forecastUseparamService.list();
|
List<ForecastUseparam> paramList = forecastUseparamService.list(new QueryWrapper<ForecastUseparam>().isNotNull("param_code").isNotNull("param_value"));
|
||||||
List<ForecastK> kList = forecastKService.list();
|
List<ForecastK> kList = forecastKService.list();
|
||||||
// 获取最新pa
|
// 获取最新pa
|
||||||
ForecastPa forecastPaLast = forecastPaService.getOne(new QueryWrapper<ForecastPa>().orderBy(true, false, "tm").last("limit 1"));
|
ForecastPa forecastPaLast = forecastPaService.getOne(new QueryWrapper<ForecastPa>().orderBy(true, false, "tm").last("limit 1"));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue