package com.iailab.module.shasteel.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运行完成"); } }