도로명주소 갱신 자동화 처리 추가

main
이범준 3 months ago
parent be41ffd433
commit 175e5e9d07

@ -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;
}
}

@ -24,6 +24,7 @@ import cfs.common.util.Result;
import cfs.common.util.ResultSmartPlatform;
import cfs.trsmrcv.dao.TrsmrcvDao;
import cfs.trsmrcv.service.CommCollectServerService;
import cfs.trsmrcv.vo.JusoUpdateResultVO;
@Controller
public class CommHealthCheckController {
@ -112,7 +113,18 @@ public class CommHealthCheckController {
result.put("commandSeq",commandSeq);
result.put("commandType",commandType);
if(commandType.equals("sendMail")){
if(commandType.equals("bringJuso")){
Map<String, String> bringJusoInfo = new HashMap<String,String>();
JusoUpdateResultVO lastData = trsmrcvDao.findLastBuildJusoHist("");
String targetYmd = lastData.getDataDate().replace("-", "");
bringJusoInfo.put("targetYmd", targetYmd);
if(bringJusoInfo == null || bringJusoInfo.isEmpty()){
result.put("res", "OK");
return result;
}
result.put("commandDetail", bringJusoInfo);
} else if(commandType.equals("sendMail")){
Map<String, String> sendMailInfo = trsmrcvDao.selectSendMail(commandSeq);
if(sendMailInfo == null || sendMailInfo.isEmpty()){
result.put("res", "OK");

@ -133,6 +133,23 @@ public class TestController {
return result;
}
@RequestMapping(value="/rest/test/bringJuso.do", method=RequestMethod.POST)
public @ResponseBody Map<String, Object> bringJuso(@RequestBody Map<String,Object> reqMap) throws Exception {
Map result = new HashMap();
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.touchAndWait("monitoring", commandSeq);
result.put("res", "OK");
return result;
}
@RequestMapping(value="/rest/test/sendMail.do", method=RequestMethod.POST)
public @ResponseBody Map<String, Object> sendMail(@RequestBody Map<String,Object> reqMap) throws Exception {
Map result = new HashMap();
@ -202,6 +219,7 @@ public class TestController {
return commandResult;
}
private boolean shellCmd(String cmd) {
Process process = null;
Runtime runtime = Runtime.getRuntime();

Loading…
Cancel
Save