|
|
|
|
@ -8,25 +8,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.gunshi.algorithm.RrainfallForecast;
|
|
|
|
|
import com.gunshi.algorithm.RunoffService;
|
|
|
|
|
import com.gunshi.model.vo.FloodAlgorithemVo;
|
|
|
|
|
import com.gunshi.project.hsz.service.*;
|
|
|
|
|
import com.gunshi.project.hsz.entity.vo.ForeRainStatVo;
|
|
|
|
|
import com.gunshi.project.hsz.entity.vo.ForeRainTimeVo;
|
|
|
|
|
import com.gunshi.project.hsz.entity.vo.ForecastResultVo;
|
|
|
|
|
import com.gunshi.project.hsz.grb.RainGrib2Layer;
|
|
|
|
|
import com.gunshi.project.hsz.mapper.ForecastResultsMapper;
|
|
|
|
|
import com.gunshi.project.hsz.model.AttResBase;
|
|
|
|
|
import com.gunshi.project.hsz.model.ForecastPa;
|
|
|
|
|
import com.gunshi.project.hsz.model.ForecastProject;
|
|
|
|
|
import com.gunshi.project.hsz.model.ForecastResults;
|
|
|
|
|
import com.gunshi.project.hsz.model.ForecastTask;
|
|
|
|
|
import com.gunshi.project.hsz.model.ForecastU;
|
|
|
|
|
import com.gunshi.project.hsz.model.ForecastUseparam;
|
|
|
|
|
import com.gunshi.project.hsz.model.StPptnR;
|
|
|
|
|
import com.gunshi.project.hsz.model.StPptnRAverage;
|
|
|
|
|
import com.gunshi.project.hsz.model.StRsvrR;
|
|
|
|
|
import com.gunshi.project.hsz.model.StStbprpB;
|
|
|
|
|
import com.gunshi.project.hsz.model.StZqrlB;
|
|
|
|
|
import com.gunshi.project.hsz.model.StZvarlB;
|
|
|
|
|
import com.gunshi.project.hsz.model.*;
|
|
|
|
|
import com.gunshi.project.hsz.util.DataHandleUtil;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
@ -45,7 +32,6 @@ import java.util.Date;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
import java.util.function.Function;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@ -171,6 +157,28 @@ public class ForecastResultsService extends ServiceImpl<ForecastResultsMapper, F
|
|
|
|
|
List<StPptnR> pptnRFutureList = new ArrayList<>();
|
|
|
|
|
QueryWrapper<StPptnR> qwExisted = new QueryWrapper<>();
|
|
|
|
|
Boolean isHaveFuturePPtn = true;
|
|
|
|
|
// 檀树岗修改:实测降雨查询表数据,预测降雨使用geom参数。最后按时间算数平均
|
|
|
|
|
// for(StStbprpB b : stbs){
|
|
|
|
|
// String stcd = b.getStcd();
|
|
|
|
|
// // 如果结束时间在当前时间之前,降雨序列从历史降雨表获取
|
|
|
|
|
// if (endTime.compareTo(nowHourTime) <= 0) {
|
|
|
|
|
// qwExisted = new QueryWrapper<StPptnR>().eq("stcd", stcd).ge("tm", startTime).le("tm", endTime).orderBy(true, true, "tm");
|
|
|
|
|
// } else {
|
|
|
|
|
// qwExisted = new QueryWrapper<StPptnR>().eq("stcd", stcd).ge("tm", startTime).le("tm", nowHourTime).orderBy(true, true, "tm");
|
|
|
|
|
// try {
|
|
|
|
|
// // 获取预报数据
|
|
|
|
|
// pptnRFutureList = getForecastDrpData(nowHourTime, stcd);
|
|
|
|
|
// } catch (IllegalArgumentException e) {
|
|
|
|
|
// if(stcd.equals(attResBase.getStcd())){
|
|
|
|
|
// isHaveFuturePPtn = false;
|
|
|
|
|
// }
|
|
|
|
|
// log.error("该时间无预报数据");
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// List<StPptnR> pptnRExistedList = stPptnRService.list(qwExisted);
|
|
|
|
|
// pptnRAllList.addAll(pptnRExistedList);
|
|
|
|
|
// pptnRAllList.addAll(pptnRFutureList);
|
|
|
|
|
// }
|
|
|
|
|
if (endTime.compareTo(nowHourTime) <= 0) {
|
|
|
|
|
qwExisted = new QueryWrapper<StPptnR>().in("stcd", stbs.stream().map(StStbprpB::getStcd).toArray(String[]::new)).ge("tm", startTime).le("tm", endTime).orderBy(true, true, "tm");
|
|
|
|
|
} else {
|
|
|
|
|
@ -271,7 +279,7 @@ public class ForecastResultsService extends ServiceImpl<ForecastResultsMapper, F
|
|
|
|
|
Date[] period = periods.get(k);
|
|
|
|
|
Calendar calNew = Calendar.getInstance();
|
|
|
|
|
calNew.setTime(period[0]);
|
|
|
|
|
// 根据每段时间的开始时间,如果在08点05分前,则采用前一天的pa值计算
|
|
|
|
|
// 根据每段时间的开始时间,如果在08点前,则采用前一天的pa值计算
|
|
|
|
|
if (isBeforeEightAM(period[0])) {
|
|
|
|
|
// 将日期往前推一天
|
|
|
|
|
calNew.add(Calendar.DATE, -1);
|
|
|
|
|
@ -406,7 +414,297 @@ public class ForecastResultsService extends ServiceImpl<ForecastResultsMapper, F
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<Map<String, Object>> excuteForecastDebug(ForecastTask forecastTask) throws Exception {
|
|
|
|
|
List<ForecastResultVo> voList = new ArrayList<>();
|
|
|
|
|
// 获取配置参数
|
|
|
|
|
List<ForecastUseparam> paramList = forecastUseparamService.list(new QueryWrapper<ForecastUseparam>().isNotNull("param_code").isNotNull("param_value"));
|
|
|
|
|
if (CollectionUtils.isEmpty(paramList)) {
|
|
|
|
|
throw new IllegalArgumentException("温馨提示:当前洪水预报所依赖的数据尚不完整,请检查入参是否缺失。");
|
|
|
|
|
}
|
|
|
|
|
// 获取系统当前的水库站编码、汛限水位
|
|
|
|
|
AttResBase attResBase = attResBaseService.getOne(new QueryWrapper<>());
|
|
|
|
|
// 多站点水库面雨量
|
|
|
|
|
// List<StStbprpB> stbs = stStbprpBService.list(new QueryWrapper<StStbprpB>().eq("res_code", attResBase.getResCode()));
|
|
|
|
|
// 单站点
|
|
|
|
|
List<StStbprpB> stbs = stStbprpBService.list(new QueryWrapper<StStbprpB>().eq("stcd", attResBase.getStcd()));
|
|
|
|
|
if (CollectionUtils.isEmpty(stbs)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
Date nowHourTime = forecastTask.getNowTime();
|
|
|
|
|
Date startTime = forecastTask.getStartTime();
|
|
|
|
|
Date endTime = forecastTask.getEndTime();
|
|
|
|
|
// 获取整个时间线的降雨数据
|
|
|
|
|
List<StPptnR> pptnRAllList = new ArrayList<>();
|
|
|
|
|
List<StPptnR> pptnRFutureList = new ArrayList<>();
|
|
|
|
|
QueryWrapper<StPptnR> qwExisted = new QueryWrapper<>();
|
|
|
|
|
Boolean isHaveFuturePPtn = true;
|
|
|
|
|
// 檀树岗修改:实测降雨查询表数据,预测降雨使用geom参数。最后按时间算数平均
|
|
|
|
|
// for(StStbprpB b : stbs){
|
|
|
|
|
// String stcd = b.getStcd();
|
|
|
|
|
// // 如果结束时间在当前时间之前,降雨序列从历史降雨表获取
|
|
|
|
|
// if (endTime.compareTo(nowHourTime) <= 0) {
|
|
|
|
|
// qwExisted = new QueryWrapper<StPptnR>().eq("stcd", stcd).ge("tm", startTime).le("tm", endTime).orderBy(true, true, "tm");
|
|
|
|
|
// } else {
|
|
|
|
|
// qwExisted = new QueryWrapper<StPptnR>().eq("stcd", stcd).ge("tm", startTime).le("tm", nowHourTime).orderBy(true, true, "tm");
|
|
|
|
|
// try {
|
|
|
|
|
// // 获取预报数据
|
|
|
|
|
// pptnRFutureList = getForecastDrpData(nowHourTime, stcd);
|
|
|
|
|
// } catch (IllegalArgumentException e) {
|
|
|
|
|
// if(stcd.equals(attResBase.getStcd())){
|
|
|
|
|
// isHaveFuturePPtn = false;
|
|
|
|
|
// }
|
|
|
|
|
// log.error("该时间无预报数据");
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// List<StPptnR> pptnRExistedList = stPptnRService.list(qwExisted);
|
|
|
|
|
// pptnRAllList.addAll(pptnRExistedList);
|
|
|
|
|
// pptnRAllList.addAll(pptnRFutureList);
|
|
|
|
|
// }
|
|
|
|
|
if (endTime.compareTo(nowHourTime) <= 0) {
|
|
|
|
|
qwExisted = new QueryWrapper<StPptnR>().in("stcd", stbs.stream().map(StStbprpB::getStcd).toArray(String[]::new)).ge("tm", startTime).le("tm", endTime).orderBy(true, true, "tm");
|
|
|
|
|
} else {
|
|
|
|
|
qwExisted = new QueryWrapper<StPptnR>().in("stcd", stbs.stream().map(StStbprpB::getStcd).toArray(String[]::new)).ge("tm", startTime).le("tm", nowHourTime).orderBy(true, true, "tm");
|
|
|
|
|
// 获取预报数据
|
|
|
|
|
try {
|
|
|
|
|
pptnRFutureList = getForecastDrpData(nowHourTime, attResBase.getStcd());
|
|
|
|
|
if(CollectionUtils.isEmpty(pptnRFutureList)) {
|
|
|
|
|
isHaveFuturePPtn = false;
|
|
|
|
|
log.error("该时间无预报数据");
|
|
|
|
|
}
|
|
|
|
|
} catch (IllegalArgumentException e) {
|
|
|
|
|
isHaveFuturePPtn = false;
|
|
|
|
|
log.error("该时间无预报数据");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
List<StPptnR> pptnRExistedList = stPptnRService.list(qwExisted);
|
|
|
|
|
pptnRAllList.addAll(pptnRExistedList);
|
|
|
|
|
pptnRAllList.addAll(pptnRFutureList);
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(pptnRAllList)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
// 多站点面雨量结果list
|
|
|
|
|
List<StPptnR> polyPptnRList = pptnRAllList.stream()
|
|
|
|
|
.collect(Collectors.groupingBy(
|
|
|
|
|
StPptnR::getTm,
|
|
|
|
|
Collectors.mapping(
|
|
|
|
|
pptn -> Double.parseDouble(pptn.getDrp()), // 将String转换为double
|
|
|
|
|
Collectors.averagingDouble(d -> d) // 计算平均值
|
|
|
|
|
)
|
|
|
|
|
))
|
|
|
|
|
.entrySet().stream()
|
|
|
|
|
.map(entry -> new StPptnRAverage(entry.getKey(), String.valueOf(entry.getValue())))
|
|
|
|
|
.sorted(Comparator.comparing(StPptnRAverage::getTm))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
double dt = 0.0;
|
|
|
|
|
double Wm = 0.0;
|
|
|
|
|
double qOther = 0.0;
|
|
|
|
|
Map<String, String> paramMap = paramList.stream().collect(Collectors.toMap(ForecastUseparam::getParamCode, ForecastUseparam::getParamValue, (existing, replacement) -> existing));
|
|
|
|
|
if (paramMap.get("dt").isEmpty()) {
|
|
|
|
|
throw new IllegalArgumentException("温馨提示:当前洪水预报所依赖的数据尚不完整,请检查时间单元△T是否缺失。");
|
|
|
|
|
}
|
|
|
|
|
if (paramMap.get("Im").isEmpty()) {
|
|
|
|
|
throw new IllegalArgumentException("温馨提示:当前洪水预报所依赖的数据尚不完整,请检查最大初损值Im是否缺失。");
|
|
|
|
|
}
|
|
|
|
|
if (!paramMap.get("qOther").isEmpty()) {
|
|
|
|
|
qOther = Double.parseDouble(paramMap.get("qOther"));
|
|
|
|
|
}
|
|
|
|
|
dt = Double.parseDouble(paramMap.get("dt"));
|
|
|
|
|
// dt = Double.parseDouble("1.0");
|
|
|
|
|
Wm = Double.parseDouble(paramMap.get("Im"));
|
|
|
|
|
List<ForecastU> uList = forecastUService.list();
|
|
|
|
|
if (CollectionUtils.isEmpty(uList)) {
|
|
|
|
|
throw new IllegalArgumentException("温馨提示:当前洪水预报所依赖的数据尚不完整,请检查U(I)单位线是否缺失。");
|
|
|
|
|
}
|
|
|
|
|
// 每小时的单位径流量,单位m³/s
|
|
|
|
|
double[] u = uList.stream().mapToDouble(forecastU -> forecastU.getUValue().doubleValue()).toArray();
|
|
|
|
|
// 根据开始结束时间查询pa
|
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
|
|
cal.setTime(startTime);
|
|
|
|
|
// 将日期往前推一天
|
|
|
|
|
cal.add(Calendar.DATE, -1);
|
|
|
|
|
List<ForecastPa> paList = forecastPaService.list(new QueryWrapper<ForecastPa>().eq("stcd", attResBase.getStcd()).ge("tm", sdfDay.format(cal.getTime())).le("tm", sdfDay.format(endTime)));
|
|
|
|
|
if (CollectionUtils.isEmpty(paList)) {
|
|
|
|
|
throw new IllegalArgumentException("温馨提示:当前洪水预报所依赖的数据尚不完整,请检查每日土壤含水量Pa是否缺失。");
|
|
|
|
|
}
|
|
|
|
|
Map<String, ForecastPa> paMap = paList.stream().collect(Collectors.toMap(ForecastPa::getTm, entity -> entity, (existing, replacement) -> existing));
|
|
|
|
|
// 获取预测开始时间前的最后水库水位
|
|
|
|
|
double H1 = 0.0;// 初始水库水位,可以根据H1->V1,H1->q1得到初始的水库库容和下泄流量
|
|
|
|
|
StRsvrR rsvrR = stRsvrRService.getOne(new QueryWrapper<StRsvrR>().eq("stcd", attResBase.getStcd()).le("tm", startTime).orderBy(true, false, "tm").last("limit 1"));
|
|
|
|
|
if (ObjectUtils.isEmpty(rsvrR)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
H1 = Double.parseDouble(rsvrR.getRz());
|
|
|
|
|
// 泄流量
|
|
|
|
|
List<StZqrlB> stZqrlBList = stZqrlBService.list(new QueryWrapper<StZqrlB>().eq("stcd", attResBase.getStcd()).orderBy(true, true, "z"));
|
|
|
|
|
// 库容曲线
|
|
|
|
|
List<StZvarlB> zvarlBS = stZvarlBService.list(new QueryWrapper<StZvarlB>().eq("stcd", attResBase.getStcd()).orderBy(true, true, "rz"));
|
|
|
|
|
// 水位历史数据
|
|
|
|
|
List<StRsvrR> rsvrRRealList = stRsvrRService.list(new QueryWrapper<StRsvrR>().eq("stcd", attResBase.getStcd()).ge("tm", startTime).le("tm", endTime));
|
|
|
|
|
List<StRsvrR> resultList = reorganizeRsvrRData(rsvrRRealList, dt);
|
|
|
|
|
List<Date[]> periods = splitByDay8To8(startTime, endTime);
|
|
|
|
|
// v:累计降雨
|
|
|
|
|
BigDecimal vValue = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal vSum = BigDecimal.ZERO;
|
|
|
|
|
// Rsum:累计径流深
|
|
|
|
|
BigDecimal Rsum = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal Psum = BigDecimal.ZERO;
|
|
|
|
|
List<Map<String, Object>> res = new ArrayList<>();
|
|
|
|
|
// 存储最后u的长度-1个r值
|
|
|
|
|
for (int k = 0; k < periods.size(); k++) {
|
|
|
|
|
Date[] period = periods.get(k);
|
|
|
|
|
Calendar calNew = Calendar.getInstance();
|
|
|
|
|
calNew.setTime(period[0]);
|
|
|
|
|
// 根据每段时间的开始时间,如果在08点前,则采用前一天的pa值计算
|
|
|
|
|
if (isBeforeEightAM(period[0])) {
|
|
|
|
|
// 将日期往前推一天
|
|
|
|
|
calNew.add(Calendar.DATE, -1);
|
|
|
|
|
}
|
|
|
|
|
ForecastPa forecastPa = paMap.get(sdfDay.format(calNew.getTime()));
|
|
|
|
|
if (ObjectUtils.isEmpty(forecastPa)) {
|
|
|
|
|
continue;
|
|
|
|
|
// throw new IllegalArgumentException("温馨提示:当前洪水预报所依赖的数据尚不完整,请检查每日土壤含水量Pa、K值是否缺失。");
|
|
|
|
|
}
|
|
|
|
|
// 根据降雨数据,按照△t的颗粒度,均分
|
|
|
|
|
// 筛选时间段内的降雨数据。不包前但包后
|
|
|
|
|
List<StPptnR> filterList = polyPptnRList.stream().filter(e -> e.getTm().compareTo(period[0]) >= 0).filter(e -> e.getTm().compareTo(period[1]) <= 0).collect(Collectors.toList());
|
|
|
|
|
Map<String, List<StPptnR>> retMap = new HashMap<>();
|
|
|
|
|
if (CollectionUtils.isNotEmpty(filterList)) {
|
|
|
|
|
retMap = reorganizePptnRData(filterList, dt, period[0], period[1], nowHourTime, isHaveFuturePPtn);
|
|
|
|
|
}
|
|
|
|
|
if (ObjectUtils.isEmpty(retMap.get("listForForecast"))) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
List<String> pForecastList = retMap.get("listForForecast").stream().map(s -> s.getDrp()).collect(Collectors.toList());
|
|
|
|
|
if (pForecastList.size() == 0) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (ObjectUtils.isEmpty(retMap.get("listForReal"))) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
Map<String, String> pRealMap = retMap.get("listForReal").stream().collect(Collectors.toMap(pptnR -> sdfMinute.format(pptnR.getTm()), StPptnR::getDrp, (existing, replacement) -> existing));
|
|
|
|
|
double[] PList = pForecastList.stream().mapToDouble(Double::parseDouble).toArray();
|
|
|
|
|
vSum = vSum.add(vValue);
|
|
|
|
|
vValue = BigDecimal.ZERO;
|
|
|
|
|
for (double value : PList) {
|
|
|
|
|
BigDecimal bd = BigDecimal.valueOf(value);
|
|
|
|
|
// 累加到总和中
|
|
|
|
|
vValue = vValue.add(bd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 存储上一次的径流深r,最开始默认全部为0
|
|
|
|
|
List<Double> lastRArr = new ArrayList<>();
|
|
|
|
|
for (int i = 0; i < u.length - 1; i++) {
|
|
|
|
|
lastRArr.add(0.0); // 填充初始值
|
|
|
|
|
}
|
|
|
|
|
// 从后往前遍历不定长的实体列表
|
|
|
|
|
for (int i = voList.size() - 1; i >= 0; i--) {
|
|
|
|
|
int index = lastRArr.size() - 1 - (voList.size() - 1 - i);
|
|
|
|
|
lastRArr.set(index, voList.get(i).getR().doubleValue());
|
|
|
|
|
if(index <= 0){
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 预测执行
|
|
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
|
|
map.put("in period" + k, sdf.format(period[0]));
|
|
|
|
|
map.put("in K" + k, forecastPa.getK().doubleValue());
|
|
|
|
|
map.put("in pa0" + k, forecastPa.getPa0().doubleValue());
|
|
|
|
|
map.put("in Wm" + k, Wm);
|
|
|
|
|
map.put("in pt0" + k, forecastPa.getPt0().doubleValue());
|
|
|
|
|
map.put("in H1" + k, H1);
|
|
|
|
|
map.put("in dt" + k, dt);
|
|
|
|
|
map.put("in pa" + k, forecastPa.getPa().doubleValue());
|
|
|
|
|
map.put("in PList" + k, PList);
|
|
|
|
|
map.put("in u" + k, u);
|
|
|
|
|
map.put("in stcd" + k, attResBase.getStcd());
|
|
|
|
|
map.put("in qOther" + k, qOther);
|
|
|
|
|
map.put("in vSum" + k, vSum.doubleValue());
|
|
|
|
|
map.put("in Rsum" + k, Rsum.doubleValue());
|
|
|
|
|
map.put("in lastRArr" + k, lastRArr);
|
|
|
|
|
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, attResBase.getStcd(), qOther, vSum.doubleValue(), Rsum.doubleValue(), lastRArr);
|
|
|
|
|
map.put("out res" + k, forecastVoList);
|
|
|
|
|
res.add(map);
|
|
|
|
|
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());
|
|
|
|
|
Map<String, String> realRsvrMap = realRsvrList.stream().collect(Collectors.toMap(rsvr -> sdfMinute.format(rsvr.getTm()), StRsvrR::getRz, (existing, replacement) -> existing));
|
|
|
|
|
forecastVoList = forecastVoList.subList(0, PList.length + 1);
|
|
|
|
|
// 去除预测出来的最后一条与第二次实际的相同时间的数据
|
|
|
|
|
if (voList.size() > 0 && voList.get(voList.size() - 1).getTm().equals(forecastVoList.get(0).getDateStr())) {
|
|
|
|
|
voList.remove(voList.size() - 1);
|
|
|
|
|
}
|
|
|
|
|
for (int j = 0; j < forecastVoList.size(); j++) {
|
|
|
|
|
FloodAlgorithemVo floodAlgorithemVo = forecastVoList.get(j);
|
|
|
|
|
// dt不同,预测结果的条数不同(跟new_q参数有关)
|
|
|
|
|
if (floodAlgorithemVo.getDateStr().substring(0, 15).compareTo(sdfMinute.format(period[1])) > 0) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
String dateStr = floodAlgorithemVo.getDateStr();
|
|
|
|
|
ForecastResultVo resultVo = new ForecastResultVo();
|
|
|
|
|
resultVo.setTm(dateStr);
|
|
|
|
|
resultVo.setYcRkQValue(floodAlgorithemVo.getRq());// 预测入库流量
|
|
|
|
|
// resultVo.setRealRkQValue();// 暂无真实入库流量
|
|
|
|
|
resultVo.setYcCkQValue(floodAlgorithemVo.getCq());// 预测出库流量
|
|
|
|
|
resultVo.setYcSwHValue(floodAlgorithemVo.getKh());// 预测水库水位
|
|
|
|
|
H1 = resultVo.getYcSwHValue().doubleValue();// 以预测水位作为下一次预测段起始值
|
|
|
|
|
String dateMinuteStr = dateStr.substring(0, dateStr.length() - 3);// 年月日 时分
|
|
|
|
|
if (realRsvrMap.containsKey(dateMinuteStr)) {
|
|
|
|
|
BigDecimal realSwHValue = new BigDecimal(realRsvrMap.get(dateMinuteStr));// 根据时间取更准确
|
|
|
|
|
resultVo.setRealSwHValue(realSwHValue);// 真实水库水位
|
|
|
|
|
calculateCap(zvarlBS, resultVo, realSwHValue);// 有真实水位就用真实水位算(作为实测库容)
|
|
|
|
|
resultVo.setSwHDValue(resultVo.getYcSwHValue().subtract(resultVo.getRealSwHValue()));// 预测与真实水位差
|
|
|
|
|
// 注释:修复跨8点时的陡升陡降
|
|
|
|
|
// H1 = realSwHValue.doubleValue();// 如果有真实水位,将最后一条的真实水位作为下一次预测段的初始水位
|
|
|
|
|
// 真实出库流量=真实水库水位与泄流量曲线差值法
|
|
|
|
|
if (realSwHValue != null && CollectionUtils.isNotEmpty(stZqrlBList)) {
|
|
|
|
|
BigDecimal maxZ = stZqrlBList.stream().max(Comparator.comparing(StZqrlB::getZ)).get().getZ();
|
|
|
|
|
BigDecimal minZ = stZqrlBList.stream().min(Comparator.comparing(StZqrlB::getZ)).get().getZ();
|
|
|
|
|
if (realSwHValue.compareTo(minZ) < 0 || realSwHValue.compareTo(maxZ) > 0) {
|
|
|
|
|
resultVo.setRealCkQValue(BigDecimal.ZERO);// 真实出库流量
|
|
|
|
|
} else {
|
|
|
|
|
Map<BigDecimal, BigDecimal> stZvalMap = stZqrlBList.stream().collect(Collectors.toMap(StZqrlB::getZ, StZqrlB::getQ, (existing, replacement) -> existing));
|
|
|
|
|
List<BigDecimal> list = stZqrlBList.stream().map(StZqrlB::getZ).collect(Collectors.toList());
|
|
|
|
|
resultVo.setRealCkQValue(DataHandleUtil.calcData(realSwHValue, stZvalMap, list));// 真实出库流量
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 没有真实水位就用预测水位算(作为预测库容)
|
|
|
|
|
calculateCap(zvarlBS, resultVo, resultVo.getYcSwHValue());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String pRealDrp = "0.0";
|
|
|
|
|
if (pRealMap.containsKey(dateMinuteStr)) {
|
|
|
|
|
pRealDrp = pRealMap.get(dateMinuteStr);
|
|
|
|
|
}
|
|
|
|
|
BigDecimal drp = new BigDecimal(pRealDrp);// 根据时间取更准确
|
|
|
|
|
if (drp.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
|
|
resultVo.setDrp(BigDecimal.ZERO);
|
|
|
|
|
} else {
|
|
|
|
|
resultVo.setDrp(drp);
|
|
|
|
|
}
|
|
|
|
|
Psum = Psum.add(resultVo.getDrp());
|
|
|
|
|
resultVo.setPSum(Psum);
|
|
|
|
|
Date dateTm = sdf.parse(floodAlgorithemVo.getDateStr());
|
|
|
|
|
resultVo.setIspreDrp(dateTm.compareTo(nowHourTime) <= 0 ? "0" : "1");// 0:真实 1:预测
|
|
|
|
|
resultVo.setR(floodAlgorithemVo.getR());
|
|
|
|
|
if (resultVo.getR() != null) {
|
|
|
|
|
Rsum = Rsum.add(resultVo.getR());
|
|
|
|
|
} else {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
resultVo.setRSum(Rsum);
|
|
|
|
|
resultVo.setFlLowLimLev(attResBase.getFlLowLimLev());
|
|
|
|
|
resultVo.setCurrentYdgdyjz(MapUtil.get(paramMap, "ydgdyjz", BigDecimal.class, BigDecimal.ZERO));
|
|
|
|
|
resultVo.setPa(floodAlgorithemVo.getPa());
|
|
|
|
|
voList.add(resultVo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @description: 根据水位计算库容
|
|
|
|
|
@ -498,10 +796,10 @@ public class ForecastResultsService extends ServiceImpl<ForecastResultsMapper, F
|
|
|
|
|
* @auther: cxw
|
|
|
|
|
*/
|
|
|
|
|
private List<StRsvrR> reorganizeRsvrRData(List<StRsvrR> rsvrRRealList, double dt) {
|
|
|
|
|
//TODO 只保留整小时的数据(这里得看监测时间来分析,檀树岗是整点记录,目前我观测到的黑石咀的是每小时过5分钟记录一次 比如08:05:00 ~ 09:05:00
|
|
|
|
|
// 只保留整小时的数据
|
|
|
|
|
rsvrRRealList = rsvrRRealList.stream().filter(entity -> {
|
|
|
|
|
Date date = entity.getTm();
|
|
|
|
|
return date.getMinutes() ==0 && date.getSeconds() == 0;
|
|
|
|
|
return date.getMinutes() == 0 && date.getSeconds() == 0;
|
|
|
|
|
}).collect(Collectors.toMap(
|
|
|
|
|
e -> e.getStcd() + "_" + e.getTm(), // 使用属性组合作为键
|
|
|
|
|
Function.identity(),
|
|
|
|
|
@ -642,7 +940,7 @@ public class ForecastResultsService extends ServiceImpl<ForecastResultsMapper, F
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @description: 将两个时间按照早八点五分分割成多段
|
|
|
|
|
* @description: 将两个时间按照早八点分割成多段
|
|
|
|
|
* @param startDate
|
|
|
|
|
* @param endDate
|
|
|
|
|
* @return: java.util.List<java.util.Date[]>
|
|
|
|
|
@ -675,7 +973,7 @@ public class ForecastResultsService extends ServiceImpl<ForecastResultsMapper, F
|
|
|
|
|
cal.add(Calendar.DAY_OF_MONTH, 1); // 移到下一天
|
|
|
|
|
}
|
|
|
|
|
cal.set(Calendar.HOUR_OF_DAY, 8);
|
|
|
|
|
cal.set(Calendar.MINUTE, 5);
|
|
|
|
|
cal.set(Calendar.MINUTE, 0);
|
|
|
|
|
cal.set(Calendar.SECOND, 0);
|
|
|
|
|
cal.set(Calendar.MILLISECOND, 0);
|
|
|
|
|
Date currentEnd = cal.getTime();
|
|
|
|
|
@ -816,4 +1114,21 @@ public class ForecastResultsService extends ServiceImpl<ForecastResultsMapper, F
|
|
|
|
|
return jsonBuilder.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Map<String, Object>> getHumanForecastResultDebug(ForecastTask forecastTask) {
|
|
|
|
|
// 当前时间整点,作为获取雨量数据历史、预测分隔点
|
|
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
|
|
calendar.set(Calendar.MINUTE, 0);
|
|
|
|
|
calendar.set(Calendar.SECOND, 0);
|
|
|
|
|
calendar.set(Calendar.MILLISECOND, 0);
|
|
|
|
|
Date nowHourTime = calendar.getTime();
|
|
|
|
|
forecastTask.setNowTime(nowHourTime);
|
|
|
|
|
List<Map<String, Object>> maps;
|
|
|
|
|
try {
|
|
|
|
|
maps = excuteForecastDebug(forecastTask);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
throw new IllegalArgumentException(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
return maps;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|