From ca1cd80f97c33a641c0d45b0fe9468a71be8975a Mon Sep 17 00:00:00 2001 From: hekaiyu <13673834656@163.com> Date: Thu, 11 Dec 2025 16:36:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=80=E4=B8=AApython?= =?UTF-8?q?=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/common/properties/T1hDownloadProperties.java | 5 +++++ .../main/java/org/jeecg/common/util/ExecutePyUtils.java | 3 ++- .../src/main/java/org/jeecg/job/DownloadT1hJob.java | 7 +++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/T1hDownloadProperties.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/T1hDownloadProperties.java index 874a07b..9eb0246 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/T1hDownloadProperties.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/T1hDownloadProperties.java @@ -9,6 +9,11 @@ import org.springframework.stereotype.Component; @ConfigurationProperties(prefix = "t1h-download") public class T1hDownloadProperties { + /** + * python环境路径 + */ + private String pythonPath; + /** * 下载T1H的Py脚本路径 */ diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ExecutePyUtils.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ExecutePyUtils.java index 24e2a35..13df902 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ExecutePyUtils.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ExecutePyUtils.java @@ -24,7 +24,8 @@ public class ExecutePyUtils { processWatch.start(); Process process = null; try { - + System.out.println("执行命令: " + String.join(" ", processBuilder.command())); + System.out.println("工作目录: " + processBuilder.directory()); process = processBuilder.start(); // 异步处理输出流 diff --git a/jeecg-module-weather/src/main/java/org/jeecg/job/DownloadT1hJob.java b/jeecg-module-weather/src/main/java/org/jeecg/job/DownloadT1hJob.java index 8b8ec6d..464a5fd 100644 --- a/jeecg-module-weather/src/main/java/org/jeecg/job/DownloadT1hJob.java +++ b/jeecg-module-weather/src/main/java/org/jeecg/job/DownloadT1hJob.java @@ -86,7 +86,7 @@ public class DownloadT1hJob { List forecastTimes = generateForecastTimes(); ProcessBuilder processBuilder = new ProcessBuilder( - systemStorageProperties.getAiModelsPath() + File.separator + "python3 ", + t1hDownloadProperties.getPythonPath(), getPythonScriptPath(t1hDownloadProperties.getMergeT1hPy()), "--indir", getFullPath(t1hDownloadProperties.getT1hPath(), baseTime), "--output_dir", getFullPath(systemStorageProperties.getT1h(), baseTime), @@ -94,7 +94,7 @@ public class DownloadT1hJob { "--forecast_times", String.join(",", forecastTimes), "--base_date", baseTime ); - processBuilder.directory(new File(systemStorageProperties.getRootPath())); + ExecutePyUtils.executePythonProcess(processBuilder, "文件合并"); } @@ -127,7 +127,6 @@ public class DownloadT1hJob { log.info("执行Python脚本: {}", Arrays.toString(command)); ProcessBuilder processBuilder = new ProcessBuilder(command); - processBuilder.directory(new File(systemStorageProperties.getRootPath())); ExecutePyUtils.executePythonProcess(processBuilder, String.format("元素%s预报时长%s下载", element, forecastHours)); } @@ -137,7 +136,7 @@ public class DownloadT1hJob { */ private String[] buildPythonCommand(String element, String baseTime, String forecastHours) { return new String[]{ - systemStorageProperties.getAiModelsPath() + File.separator + "python3 ", + t1hDownloadProperties.getPythonPath(), getPythonScriptPath(t1hDownloadProperties.getDownloadT1hPy()), "--base-time", baseTime, "--element", element,