优化洪水预测错误提示

master
chenxiwang 2024-08-28 10:58:08 +08:00
parent 18b01cd459
commit 1bc5a7615b
2 changed files with 15 additions and 4 deletions

View File

@ -83,7 +83,7 @@ public class ForecastResultsController {
@Operation(summary = "获取人工交互洪水预报结果")
@PostMapping("/getHumanForecastResult")
public R<ForecastProject> getHumanForecastResult(@RequestBody ForecastTask forecastTask) throws Exception {
public R<ForecastProject> getHumanForecastResult(@RequestBody ForecastTask forecastTask) {
ForecastProject forecastProject = new ForecastProject();
List<ForecastResultVo> voList = service.getHumanForecastResult(forecastTask);
forecastProject.setType("2");

View File

@ -112,7 +112,7 @@ public class ForecastResultsService extends ServiceImpl<ForecastResultsMapper, F
* @auther: cxw
* @date: 2024-07-31, , 11:09:24
*/
public List<ForecastResultVo> getHumanForecastResult(ForecastTask forecastTask) throws Exception {
public List<ForecastResultVo> getHumanForecastResult(ForecastTask forecastTask) {
// 当前时间整点,作为获取雨量数据历史、预测分隔点
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.MINUTE, 0);
@ -120,8 +120,13 @@ public class ForecastResultsService extends ServiceImpl<ForecastResultsMapper, F
calendar.set(Calendar.MILLISECOND, 0);
Date nowHourTime = calendar.getTime();
forecastTask.setNowTime(nowHourTime);
List<ForecastResultVo> voList = excuteForecast(forecastTask);
voList.sort(Comparator.comparing(ForecastResultVo::getTm));
List<ForecastResultVo> voList = null;
try {
voList = excuteForecast(forecastTask);
voList.sort(Comparator.comparing(ForecastResultVo::getTm));
} catch (Exception e) {
throw new IllegalArgumentException("数据异常!");
}
return voList;
}
@ -221,10 +226,16 @@ public class ForecastResultsService extends ServiceImpl<ForecastResultsMapper, F
if (CollectionUtils.isNotEmpty(filterList)) {
retMap = reorganizePptnRData(filterList, dt, period[0], period[1]);
}
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));
double[] PList = pForecastList.stream().mapToDouble(Double::parseDouble).toArray();
// 预测执行