H事件超过24小时报错
This commit is contained in:
parent
6013997d31
commit
528479f777
|
|
@ -13,6 +13,7 @@ import org.jeecg.common.exception.JeecgBootException;
|
|||
import org.jeecg.common.properties.DiffusionProperties;
|
||||
import org.jeecg.common.properties.EventServerProperties;
|
||||
import org.jeecg.common.properties.SystemStorageProperties;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.common.util.NcUtil;
|
||||
import org.jeecg.diffusion.service.DiffusionDataService;
|
||||
import org.jeecg.diffusion.vo.DiffusionResultVO;
|
||||
|
|
@ -32,7 +33,9 @@ import ucar.nc2.dataset.NetcdfDataset;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -51,18 +54,36 @@ public class DiffusionDataServiceImpl implements DiffusionDataService {
|
|||
@Override
|
||||
public DiffusionResultVO getDiffusionResult(String enginId, int hour, int layer) {
|
||||
Engineering engineering = engineeringMapper.selectById(enginId);
|
||||
Wrf wrf = wrfMapper.selectOne(new LambdaQueryWrapper<Wrf>().eq(Wrf::getEnginId,enginId));
|
||||
String wrfFilePath = baseAPIService.buildEngineeringFilePath(eventServerProperties.getResultFilePrefix() ,engineering.getCreateBy(), engineering.getEngineeringName());
|
||||
String cmaqFilePath = baseAPIService.buildEngineeringFilePath(eventServerProperties.getResultFilePrefix() ,engineering.getCreateBy(), engineering.getEngineeringName());
|
||||
Wrf wrf = wrfMapper.selectOne(new LambdaQueryWrapper<Wrf>().eq(Wrf::getEnginId, enginId));
|
||||
String wrfFilePath = baseAPIService.buildEngineeringFilePath(eventServerProperties.getResultFilePrefix(), engineering.getCreateBy(), engineering.getEngineeringName());
|
||||
String cmaqFilePath = baseAPIService.buildEngineeringFilePath(eventServerProperties.getResultFilePrefix(), engineering.getCreateBy(), engineering.getEngineeringName());
|
||||
|
||||
// 处理hour大于等于24的情况
|
||||
int actualHour = hour % 24;
|
||||
int daysToAdd = hour / 24;
|
||||
Date startTimeDate = null;
|
||||
try {
|
||||
startTimeDate = DateUtils.parseDate(wrf.getStartTime(),"yyyy-MM-dd HH:mm:ss");
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
try (NetcdfFile wrfNcFile = getWrfNetcdfFile(wrfFilePath, wrf.getStartTime());
|
||||
NetcdfFile cmaqNcFile = getCmaqNetcdfFile(cmaqFilePath, wrf.getStartTime());){
|
||||
// 如果hour大于等于24,需要调整日期
|
||||
if (daysToAdd > 0) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(startTimeDate);
|
||||
calendar.add(Calendar.DAY_OF_MONTH, daysToAdd);
|
||||
startTimeDate = calendar.getTime();
|
||||
}
|
||||
|
||||
String startTime = DateUtils.formatDate(startTimeDate, "yyyy-MM-dd HH:mm:ss");
|
||||
try (NetcdfFile wrfNcFile = getWrfNetcdfFile(wrfFilePath, startTime);
|
||||
NetcdfFile cmaqNcFile = getCmaqNetcdfFile(cmaqFilePath, startTime)) {
|
||||
DiffusionResultVO diffusionResultVO = new DiffusionResultVO();
|
||||
|
||||
List<List<Double>> values = NcUtil.get2DNCByName(cmaqNcFile, "CO", layer, hour);
|
||||
List<List<Double>> xlats = NcUtil.get2DNCByName(wrfNcFile, "XLAT", layer, hour);
|
||||
List<List<Double>> xlons = NcUtil.get2DNCByName(wrfNcFile, "XLONG", layer, hour);
|
||||
List<List<Double>> values = NcUtil.get2DNCByName(cmaqNcFile, "CO", layer, actualHour);
|
||||
List<List<Double>> xlats = NcUtil.get2DNCByName(wrfNcFile, "XLAT", layer, actualHour);
|
||||
List<List<Double>> xlons = NcUtil.get2DNCByName(wrfNcFile, "XLONG", layer, actualHour);
|
||||
getDataInfo(xlats, xlons, values, 1, diffusionResultVO);
|
||||
diffusionResultVO.setSn(values.size());
|
||||
diffusionResultVO.setWe(values.get(0).size());
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user