洪水预报优化

master
cxw 2024-10-18 14:45:26 +08:00
parent 978ef94780
commit 49cef18716
1 changed files with 30 additions and 20 deletions

View File

@ -406,32 +406,36 @@ public class ForecastResultsService extends ServiceImpl<ForecastResultsMapper, F
tm = eightSdf.format(now);
}
tm = tm.replaceAll(" ", "").replaceAll("-", "");
List<RainGrib2Layer> gribList = forecastService.getGribData(tm, false);
//24小时每个网格的总量
List<RainGrib2Layer> total = gribList.stream().filter(o -> o.getTmRange().getInterval() == 24).collect(Collectors.toList());
//24小时每个网格的逐小时雨量
List<RainGrib2Layer> detail = gribList.stream().filter(o -> o.getTmRange().getInterval() == 1).collect(Collectors.toList());
try {
List<RainGrib2Layer> gribList = forecastService.getGribData(tm, false);
//24小时每个网格的总量
List<RainGrib2Layer> total = gribList.stream().filter(o -> o.getTmRange().getInterval() == 24).collect(Collectors.toList());
//24小时每个网格的逐小时雨量
List<RainGrib2Layer> detail = gribList.stream().filter(o -> o.getTmRange().getInterval() == 1).collect(Collectors.toList());
// ForeRainVo vo = new ForeRainVo();
// vo.setStcd(stcd);
// vo.setLgtd(stStbprpB.getLgtd());
// vo.setLttd(stStbprpB.getLttd());
// List<ForeRainTimeVo> data = forecastService.getData(vo, total, detail);
// 2024-10-14 改为获取水库整个面的降雨
ForeRainStatVo vo = new ForeRainStatVo();
String[] paramValue = forecastUseparam.getParamValue().split(",");// x1,y1,x2,y2
vo.setGeom(buildRectangleGeoJson(Double.parseDouble(paramValue[0]), Double.parseDouble(paramValue[1]), Double.parseDouble(paramValue[2]), Double.parseDouble(paramValue[3])));
List<ForeRainTimeVo> data = forecastService.getAreaData(vo, total, detail);
if (CollectionUtils.isNotEmpty(data)) {
for (ForeRainTimeVo foreRainTimeVo : data) {
// 只取当前时间之后的数据
if(foreRainTimeVo.getTm().compareTo(now) > 0){
StPptnR stPptnR = new StPptnR();
stPptnR.setStcd(stcd);
stPptnR.setTm(foreRainTimeVo.getTm());
stPptnR.setDrp(foreRainTimeVo.getDrp().toString());
pptnRFutureList.add(stPptnR);
// 2024-10-14 改为获取水库整个面的降雨
ForeRainStatVo vo = new ForeRainStatVo();
String[] paramValue = forecastUseparam.getParamValue().split(",");// x1,y1,x2,y2
vo.setGeom(buildRectangleGeoJson(Double.parseDouble(paramValue[0]), Double.parseDouble(paramValue[1]), Double.parseDouble(paramValue[2]), Double.parseDouble(paramValue[3]), total.get(0)));
List<ForeRainTimeVo> data = forecastService.getAreaData(vo, total, detail);
if (CollectionUtils.isNotEmpty(data)) {
for (ForeRainTimeVo foreRainTimeVo : data) {
// 只取当前时间之后的数据
if(foreRainTimeVo.getTm().compareTo(now) > 0){
StPptnR stPptnR = new StPptnR();
stPptnR.setStcd(stcd);
stPptnR.setTm(foreRainTimeVo.getTm());
stPptnR.setDrp(foreRainTimeVo.getDrp().toString());
pptnRFutureList.add(stPptnR);
}
}
}
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
return pptnRFutureList;
}
@ -683,7 +687,13 @@ public class ForecastResultsService extends ServiceImpl<ForecastResultsMapper, F
}
}
public static String buildRectangleGeoJson(double x1, double y1, double x2, double y2) {
public static String buildRectangleGeoJson(double x1, double y1, double x2, double y2, RainGrib2Layer layer) {
// x1,y1和x2,y2的间隔必须要大于网格的最小长宽才能相交
BigDecimal dh = layer.getDh();// 单位高度
BigDecimal dw = layer.getDw();// 单位宽度
if(dw.compareTo(BigDecimal.valueOf(x2 - x1)) > 0 || dh.compareTo(BigDecimal.valueOf(y2 - y1)) > 0){
throw new IllegalArgumentException("Geom参数区域范围不足预测降雨网格最小单位");
}
// 校验数据是否在最大允许范围(预测降雨所划定区域)
Double x11 = ForecastService.x1;
Double y11 = ForecastService.y1;