|
|
|
|
@ -1,10 +1,15 @@
|
|
|
|
|
package cfs.schd.config;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Calendar;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
@ -18,6 +23,7 @@ import cfs.schd.LocalResidentsCarInfo;
|
|
|
|
|
import cfs.schd.PrpCarInfo;
|
|
|
|
|
import cfs.schd.SendStatusInfo;
|
|
|
|
|
import cfs.schd.dao.SchdDao;
|
|
|
|
|
import cfs.trsmrcv.dao.TrsmrcvDao;
|
|
|
|
|
import cfs.trsmrcv.service.CommCollectServerService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -30,6 +36,9 @@ public class CfsScheduleCron {
|
|
|
|
|
@Resource(name="schdDao")
|
|
|
|
|
private SchdDao schdDao;
|
|
|
|
|
|
|
|
|
|
@Resource(name="trsmrcvDao")
|
|
|
|
|
private TrsmrcvDao trsmrcvDao;
|
|
|
|
|
|
|
|
|
|
@Resource(name="prpCarInfo")
|
|
|
|
|
private PrpCarInfo prpCarInfo;
|
|
|
|
|
|
|
|
|
|
@ -307,7 +316,7 @@ public class CfsScheduleCron {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Scheduled(cron = "0 0 2 5 * *")
|
|
|
|
|
@Scheduled(cron = "0 0 13 * * *")
|
|
|
|
|
public void bringJusoScheduleRun() {
|
|
|
|
|
|
|
|
|
|
String runWAS = schdDao.selectRunWas("BRING_JUSO");
|
|
|
|
|
@ -318,6 +327,72 @@ public class CfsScheduleCron {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//TODO juso.go.kr
|
|
|
|
|
String commandSeq = trsmrcvDao.getCommandSeq("");
|
|
|
|
|
Map<String, String> commandInMap = new HashMap<String,String>();
|
|
|
|
|
commandInMap.put("commandSeq", commandSeq);
|
|
|
|
|
commandInMap.put("sysName", "monitoring");
|
|
|
|
|
commandInMap.put("command", "bringJuso");
|
|
|
|
|
trsmrcvDao.insertCommand(commandInMap);
|
|
|
|
|
|
|
|
|
|
this.shellCmd("/gpta/source-app/cfs/relay_jar/ssh_sh.sh " + "monitoring");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean shellCmd(String cmd) {
|
|
|
|
|
Process process = null;
|
|
|
|
|
Runtime runtime = Runtime.getRuntime();
|
|
|
|
|
StringBuffer successOutput = new StringBuffer();
|
|
|
|
|
StringBuffer errorOutput = new StringBuffer();
|
|
|
|
|
BufferedReader successBufferReader = null;
|
|
|
|
|
BufferedReader errorBufferReader = null;
|
|
|
|
|
String msg = null;
|
|
|
|
|
boolean result = false;
|
|
|
|
|
|
|
|
|
|
logger.info("shellCmd - 1");
|
|
|
|
|
List<String> cmdList = new ArrayList<String>();
|
|
|
|
|
|
|
|
|
|
cmdList.add("/bin/sh");
|
|
|
|
|
cmdList.add("-c");
|
|
|
|
|
|
|
|
|
|
cmdList.add(cmd);
|
|
|
|
|
String[] array = cmdList.toArray(new String[cmdList.size()]);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
process = runtime.exec(array);
|
|
|
|
|
successBufferReader = new BufferedReader(new InputStreamReader(process.getInputStream(), "UTF-8"));
|
|
|
|
|
|
|
|
|
|
while ((msg = successBufferReader.readLine()) != null) {
|
|
|
|
|
successOutput.append(msg + System.getProperty("line.separator"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
errorBufferReader = new BufferedReader(new InputStreamReader(process.getErrorStream(), "UTF-8"));
|
|
|
|
|
while ((msg = errorBufferReader.readLine()) != null) {
|
|
|
|
|
errorOutput.append(msg + System.getProperty("line.separator"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
process.waitFor();
|
|
|
|
|
if (process.exitValue() == 0) {
|
|
|
|
|
result = true;
|
|
|
|
|
} else {
|
|
|
|
|
logger.info("abnormal finish error : " + successOutput.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (errorOutput.toString().length() > 0) {
|
|
|
|
|
logger.info("error : " + errorOutput.toString());
|
|
|
|
|
}
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
logger.info(e.getMessage());
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
logger.info(e.getMessage());
|
|
|
|
|
} finally {
|
|
|
|
|
try {
|
|
|
|
|
process.destroy();
|
|
|
|
|
if (successBufferReader != null) successBufferReader.close();
|
|
|
|
|
if (errorBufferReader != null) errorBufferReader.close();
|
|
|
|
|
|
|
|
|
|
} catch (IOException e1) {
|
|
|
|
|
logger.info(e1.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|