bug修改

This commit is contained in:
hekaiyu 2025-12-17 12:29:48 +08:00
parent ae748f6051
commit af58b31fa6
5 changed files with 16 additions and 10 deletions

View File

@ -49,6 +49,11 @@ public class T1hDownloadProperties {
*/
private String t1hPath;
/**
* 合并T1H的文件目录
*/
private String t1hNcPath;
/**
* T1H下载Key
*/

View File

@ -112,8 +112,8 @@ public class WeatherDataController {
@AutoLog(value = "气象预测-气象预览")
@Operation(summary = "气象预测-气象预览")
@GetMapping(value = "getWeatherDataPreview")
public Result<?> getWeatherDataPreview(String weatherId,Integer weatherType, String timeBatch) {
return Result.OK(weatherDataService.getWeatherDataPreview(weatherId, weatherType,timeBatch));
public Result<?> getWeatherDataPreview(String weatherId,Integer weatherType) {
return Result.OK(weatherDataService.getWeatherDataPreview(weatherId, weatherType));
}
/**

View File

@ -54,6 +54,7 @@ public class DownloadT1hJob {
reformat(baseTime);
// 合并后删除原始文件
Arrays.stream(new File(getFullPath(t1hDownloadProperties.getT1hPath(), baseTime)).listFiles()).filter(File::isFile).forEach(File::delete);
Arrays.stream(new File(getFullPath(t1hDownloadProperties.getT1hNcPath(), baseTime)).listFiles()).filter(File::isFile).forEach(File::delete);
// 更新气象文件信息
saveWeatherData(baseTime);
log.info("T1H文件下载任务执行完成");
@ -90,7 +91,7 @@ public class DownloadT1hJob {
t1hDownloadProperties.getPythonPath(),
getPythonScriptPath(t1hDownloadProperties.getMergeT1hPy()),
"--indir", getFullPath(t1hDownloadProperties.getT1hPath(), baseTime),
"--output_dir", getFullPath(t1hDownloadProperties.getT1hPath(), baseTime),
"--output_dir", getFullPath(t1hDownloadProperties.getT1hNcPath(), baseTime),
"--variables", String.join(",", variables),
"--forecast_times", String.join(",", forecastTimes),
"--base_date", baseTime
@ -109,7 +110,7 @@ public class DownloadT1hJob {
getPythonScriptPath(t1hDownloadProperties.getReformatPy()),
"--ini_dir", getPythonScriptPath(t1hDownloadProperties.getScriptPath()),
"--output_dir", getFullPath(systemStorageProperties.getT1h(), baseTime),
"--cra_dir", getFullPath(t1hDownloadProperties.getT1hPath(), baseTime),
"--cra_dir", getFullPath(t1hDownloadProperties.getT1hNcPath(), baseTime),
"--start_date", getStartTime(),
"--end_date", getEndTime(),
"--var_table", getPythonScriptPath(t1hDownloadProperties.getLookupFileName())
@ -120,8 +121,8 @@ public class DownloadT1hJob {
private void saveWeatherData(String baseTime){
//删除一个月前的文件
LocalDateTime oneMonthAgo = LocalDateTime.now().minusMonths(1);
List<WeatherData> weatherDatas = weatherDataService.list(new LambdaQueryWrapper<WeatherData>().lt(WeatherData::getDataStartTime, oneMonthAgo));
String timeBatch = LocalDateTime.now().minusMonths(1).format(DATE_FORMATTER) + "00";
List<WeatherData> weatherDatas = weatherDataService.list(new LambdaQueryWrapper<WeatherData>().eq(WeatherData::getTimeBatch, timeBatch));
// 遍历删除文件
weatherDatas.forEach(data -> {
if (data.getFilePath() != null && !data.getFilePath().isEmpty()) {
@ -132,7 +133,7 @@ public class DownloadT1hJob {
}
});
// 删除数据库记录
weatherDataService.remove(new LambdaQueryWrapper<WeatherData>().eq(WeatherData::getDataSource, WeatherDataSourceEnum.T1H.getKey()));
weatherDataService.remove(new LambdaQueryWrapper<WeatherData>().eq(WeatherData::getTimeBatch, timeBatch));
// 读取目录文件信息
List<WeatherData> weatherFileInfos = readFolderFiles(baseTime);
//保存文件信息

View File

@ -12,7 +12,7 @@ import java.util.List;
public interface WeatherDataService extends IService<WeatherData> {
WeatherResultVO getWeatherData(Integer dataType, Integer weatherType, String timeBatch, LocalDateTime startTime, int hour);
WeatherResultVO getWeatherDataPreview(String weatherId, Integer weatherType, String timeBatch);
WeatherResultVO getWeatherDataPreview(String weatherId, Integer weatherType);
WindDataLineVO getDataLine(Integer dataType, String timeBatch, LocalDateTime startTime, LocalDateTime endTime, double longitude, double latitude);
List<WindRoseData> getWindRose(Integer dataType, String timeBatch, LocalDateTime startTime, LocalDateTime endTime,double longitude, double latitude);

View File

@ -104,7 +104,7 @@ public class WeatherDataServiceImpl extends ServiceImpl<WeatherDataMapper, Weath
* @return 天气数据列表
*/
@Override
public WeatherResultVO getWeatherDataPreview(String weatherId, Integer weatherType, String timeBatch) {
public WeatherResultVO getWeatherDataPreview(String weatherId, Integer weatherType) {
Objects.requireNonNull(weatherId, "天气数据ID不能为空");
WeatherData weatherData = this.baseMapper.selectById(weatherId);
Integer dataType = weatherData.getDataSource();
@ -119,7 +119,7 @@ public class WeatherDataServiceImpl extends ServiceImpl<WeatherDataMapper, Weath
} else if (WeatherDataSourceEnum.FNL.getKey() == dataType){
return processWeatherData(weatherType, null, targetTime, WeatherDataSourceEnum.FNL);
} else if (WeatherDataSourceEnum.T1H.getKey() == dataType){
return processWeatherData(weatherType, timeBatch, targetTime, WeatherDataSourceEnum.T1H);
return processWeatherData(weatherType, null, targetTime, WeatherDataSourceEnum.T1H);
}
} catch (JeecgBootException e) {
throw e;