From 12252fcd9c792b8b1802f624703c2d36f272bbad Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期一, 10 三月 2025 13:15:24 +0800 Subject: [PATCH] 定时重启model --- ansteel-biz/src/main/java/com/iailab/module/ansteel/job/task/RestartIailabModelServiceTask.java | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 43 insertions(+), 0 deletions(-) diff --git a/ansteel-biz/src/main/java/com/iailab/module/ansteel/job/task/RestartIailabModelServiceTask.java b/ansteel-biz/src/main/java/com/iailab/module/ansteel/job/task/RestartIailabModelServiceTask.java new file mode 100644 index 0000000..dfcccdd --- /dev/null +++ b/ansteel-biz/src/main/java/com/iailab/module/ansteel/job/task/RestartIailabModelServiceTask.java @@ -0,0 +1,43 @@ +package com.iailab.module.ansteel.job.task; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +/** + * 30 0 4 * * ? + * + * @author PanZhibao + * @Description + * @createTime 2025年03月09日 + */ +@Component("restartIailabModelServiceTask") +public class RestartIailabModelServiceTask implements ITask { + + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Override + public void run(String params) { + logger.info("RestartIailabModelServiceTask定时任务正在执行,参数为:{}", params); + try { + String command = "cmd /c start D:\\iailab\\RestartIailabModelService.bat"; + Process process = Runtime.getRuntime().exec(command); + BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); + String line; + while ((line = reader.readLine()) != null) { + System.out.println(line); + } + process.waitFor(); + } catch (IOException e) { + e.printStackTrace(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + logger.info("RestartIailabModelServiceTask运行完成"); + + } +} \ No newline at end of file -- Gitblit v1.9.3