1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- package com.gyee.impala.service.task;
- import com.gyee.impala.common.config.GyeeConfig;
- import com.gyee.impala.common.util.JudeSystem;
- import com.gyee.impala.model.master.Casefaultalg;
- import com.gyee.impala.service.master.CasefaultalgService;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.scheduling.annotation.EnableScheduling;
- import org.springframework.scheduling.annotation.Scheduled;
- import org.springframework.stereotype.Service;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.util.List;
- @Service
- @EnableScheduling
- public class BigRisingTask {
- @Autowired
- private CasefaultalgService casefaultalgService;
- /**
- * 保存脚本的位置
- */
- @Autowired
- private GyeeConfig gyeeConfig;
- @Scheduled(cron = "0 0/10 * * * ?")
- // @Scheduled(fixedRate=1000)
- private void getBigRisingTasks() {
- List<Casefaultalg> list = casefaultalgService.getListRemarkIsNull();
- System.out.println(list.size());
- list.stream().forEach(l->{
- System.out.println(l.getId()+"|"+l.getRemark());
- try {
- //组装调用脚本命令
- String name = "grad";
- String cmdPath = gyeeConfig.getDiagnosePath();
- String inst = JudeSystem.isWindows() ? "cmd" : "/bin/sh";
- String c = JudeSystem.isWindows() ? "/c" : "-c";
- String[] cmd = {inst, c, "python " + cmdPath + name + ".py " + l.getId()};
- Process p;
- System.out.println(cmd[0] + " " + cmd[1] + " " + cmd[2]);
- //执行脚本
- p = Runtime.getRuntime().exec(cmd);
- p.waitFor();
- Thread.sleep(100);
- } catch (IOException e) {
- e.printStackTrace();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }finally {
- }
- });
- }
- }
|