From fcaf5832d5889d81467a48f229538f36fb9bd27a Mon Sep 17 00:00:00 2001 From: MonHun Date: Sun, 14 Jul 2024 12:40:48 +0900 Subject: [PATCH] win 0712 --- .../kr/gmtc/gw/eyegw/EyeGWApplication.java | 2 + .../gw/eyegw/controller/MainController.java | 274 +++------- .../eyegw/controller/MainController_Old.java | 470 ++++++++++++++++++ .../eyegw/controller/SchedulController.java | 78 +++ .../gmtc/gw/eyegw/db1/EaiIfCheckMapper.java | 4 + .../gmtc/gw/eyegw/db1/EaiIfCheckService.java | 10 + .../kr/gmtc/gw/eyegw/db1/EaiProcMapper.java | 2 + .../kr/gmtc/gw/eyegw/db1/EaiProcService.java | 6 + src/main/resources/application.yml | 24 +- src/main/resources/logback-spring.xml | 8 +- .../resources/mapper/DB1/eai_if_check.xml | 34 +- src/main/resources/mapper/DB1/eai_proc.xml | 32 +- 12 files changed, 715 insertions(+), 229 deletions(-) create mode 100644 src/main/java/kr/gmtc/gw/eyegw/controller/MainController_Old.java create mode 100644 src/main/java/kr/gmtc/gw/eyegw/controller/SchedulController.java diff --git a/src/main/java/kr/gmtc/gw/eyegw/EyeGWApplication.java b/src/main/java/kr/gmtc/gw/eyegw/EyeGWApplication.java index 3c2be60..80d7f96 100644 --- a/src/main/java/kr/gmtc/gw/eyegw/EyeGWApplication.java +++ b/src/main/java/kr/gmtc/gw/eyegw/EyeGWApplication.java @@ -2,7 +2,9 @@ package kr.gmtc.gw.eyegw; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.scheduling.annotation.EnableScheduling; +@EnableScheduling @SpringBootApplication public class EyeGWApplication { diff --git a/src/main/java/kr/gmtc/gw/eyegw/controller/MainController.java b/src/main/java/kr/gmtc/gw/eyegw/controller/MainController.java index cbeb60a..7511fa5 100644 --- a/src/main/java/kr/gmtc/gw/eyegw/controller/MainController.java +++ b/src/main/java/kr/gmtc/gw/eyegw/controller/MainController.java @@ -38,33 +38,13 @@ public class MainController implements ApplicationListener { @Resource(name = "ServiceConfig") private ServiceConfig serviceConfig; - // DB // - /** - * DB1 Connection
- * application.yml에 db.db1.use가 true로 설정되어야 사용가능
- * db.db1.use가 false일 경우 주석처리 (Bean 런타임 에러 발생) - * @see DB1Connection - */ -// @Resource(name = "DB1Connection") -// private DB1Connection db1Connection; - private EaiIfCheckService eaiIfCheckService; private EaiProcService eaiProcService; - - // DB // - - // 업무처리 // /** 업무 처리 스레드 */ private List listCustomThreads; - // private CustomThread callThread_ArtsArr; - // private CustomThread callThread_ArtsDep; - // private CustomThread callThread_AcdmArr; - // private CustomThread callThread_AcdmDep; - // private CustomThread callThread_Gam; - // private CustomThread callThread_Amos; - // private CustomThread callThread_Notam; + private CustomThread chkThreadStatus; @Value("${settings.interval.proc.call}") @@ -73,12 +53,13 @@ public class MainController implements ApplicationListener { @Value("${settings.interval.chk.thread}") private int chkThreadInterval; - DateTimeFormatter dfPattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"); - private static final Logger logger = LoggerFactory.getLogger(MainController.class); + @Autowired + private SchedulController sch; + @Autowired private StateManager stateMgr; @@ -86,12 +67,6 @@ public class MainController implements ApplicationListener { private IntrfcRecvStatsManager recvStatsMgr; - /** 초기화 실패 시 프로그램 종료 */ -// private void systemError() { -// // logger.writeLevelLog("-- FAIL TO STARTUP --", LogLevelType.LOG_ERROR, "AllLog"); -// System.exit(1); -// } - /** * 수정 금지
* Spring Bean 객체 생성, logger 초기화 @@ -99,7 +74,6 @@ public class MainController implements ApplicationListener { public MainController(EaiProcService eaiProcService, EaiIfCheckService eaiIfCheckService) { this.eaiProcService = eaiProcService; - this.eaiProcService = eaiProcService; this.eaiIfCheckService = eaiIfCheckService; } @@ -117,17 +91,13 @@ public class MainController implements ApplicationListener { // 업무 스래드(프로시저 호출) listCustomThreads = new ArrayList(); - - listCustomThreads.add(new CustomThread("callThread_Gam", this, procCallInterval, this::callThread_Gam, null, false)); - listCustomThreads.add(new CustomThread("callThread_AcdmArr", this, procCallInterval, this::callThread_AcdmArr, null, false)); - listCustomThreads.add(new CustomThread("callThread_AcdmDep", this, procCallInterval, this::callThread_AcdmDep, null, false)); - listCustomThreads.add(new CustomThread("callThread_ArtsArr", this, procCallInterval, this::callThread_ArtsArr, null, false)); - listCustomThreads.add(new CustomThread("callThread_ArtsDep", this, procCallInterval, this::callThread_ArtsDep, null, false)); - listCustomThreads.add(new CustomThread("callThread_Amos", this, procCallInterval, this::callThread_Amos, null, false)); - listCustomThreads.add(new CustomThread("callThread_Notam", this, procCallInterval, this::callThread_Notam, null, false)); + + listCustomThreads.add(new CustomThread("CallProc_AllFltSchdul", this, procCallInterval, this::CallProc_AllFltSchdul, null, false)); + listCustomThreads.add(new CustomThread("CallProc_Amos", this, procCallInterval, this::CallProc_Amos, null, false)); + listCustomThreads.add(new CustomThread("CallProc_Notam", this, procCallInterval, this::CallProc_Notam, null, false)); // 이중화 체크 및 업무스래드 체크 - chkThreadStatus = new CustomThread("chkThreadStatus", this, procCallInterval, this::chkThreadStatus, null, false); + chkThreadStatus = new CustomThread("chkThreadStatus", this, 3000, this::chkThreadStatus, null, false); } catch (Exception e) { logger.error("MainContoller-Thread create fail"); @@ -173,44 +143,59 @@ public class MainController implements ApplicationListener { } - private void chkThreadStatus(){ + private void chkThreadStatus() throws InterruptedException{ stateMgr.updateState(); boolean running = true; boolean swNewStatus = stateMgr.isActive(); - // 이중화 Active / Standby 상태 변경 체크 - if(swBeforeStatus != swNewStatus){ + // Active 상태로 변경된경우 + if(swNewStatus && !swBeforeStatus){ + logger.info("SW상태 변경됨[Active] 스레드 시작."); + for(CustomThread ct : listCustomThreads ) { + + ct.start(); + + } + + // Standby 상태로 변경된경우 + }else if(!swNewStatus && swBeforeStatus){ + logger.info("SW상태 변경됨[Standby] 스레드 중지."); + + for(CustomThread ct : listCustomThreads ) { + ct.gracefulStop(); + ct.interrupt(); + } + + }else { + + // 해당 프로그램이 Active일때 Thread Interrupt 유무 체크 if(swNewStatus){ - for(CustomThread ct : listCustomThreads ) ct.start(); - }else{ - for(CustomThread ct : listCustomThreads ) ct.gracefulStop(); - } - - } - - // 해당 프로그램이 Active일때 Thread Interrupt 유무 체크 - if(swNewStatus){ - - for(CustomThread ct : listCustomThreads ){ - if(ct.isInterrupted()){ - running = false; - break; + for(CustomThread ct : listCustomThreads ){ + if(ct.isInterrupted()){ + running = false; + break; + } + } + + if(running){ + + stateMgr.updateState(SystemState.Normal); + + for(CustomThread ct : listCustomThreads ){ + if(ct.getState() == Thread.State.NEW) ct.start(); + } + + }else{ + stateMgr.updateState(SystemState.Error); } - } - if(running){ - stateMgr.updateState(SystemState.Normal); - }else{ - stateMgr.updateState(SystemState.Error); } } - swBeforeStatus = stateMgr.isActive(); - - // logger.info("swBeforeStatus : " + swBeforeStatus); + swBeforeStatus = swNewStatus; } @@ -232,43 +217,12 @@ public class MainController implements ApplicationListener { * 자동으로 무한반복 하므로 내부에 while문 필요 없음.
* 예외처리를 하지 않을 경우 {@link CustomThread} 내부에서 로그 처리 */ - private void callThread_ArtsArr() throws InterruptedException { - - // if(!running) return ; - - List> dataCnt = eaiIfCheckService.getArtsArr(); - - String sCnt = String.valueOf(dataCnt.get(0).get("DATA_CNT")); - - if( Integer.parseInt(sCnt) > 0 ) { - - LocalDateTime dt_before = LocalDateTime.now(); - - Map paramMap = new HashMap<>(); - - paramMap.put("ar_dt", "%"); - paramMap.put("ret_minDt", ""); - paramMap.put("ret_procCnt", 0); - - //DB 프로시져 Call - eaiProcService.callProcArtsArr(paramMap); - - Duration diff = Duration.between(dt_before, LocalDateTime.now()); - logger.info("callProcArtsArr Call " + sCnt + "건 " + diff.toMillis() + "msec"); - - // 수신(처리) 건수 집계 -> ELK전송용 - recvStatsMgr.writeStatsLog_KST((String) paramMap.get("ret_minDt"), "103", "ARTS_ARR", (int) paramMap.get("ret_procCnt"), 0); - } - - // Thread.sleep(3000); - - } - private void callThread_ArtsDep() throws InterruptedException { + private void CallProc_AllFltSchdul() throws InterruptedException { // if(!running) return ; - List> dataCnt = eaiIfCheckService.getArtsDep(); + List> dataCnt = eaiIfCheckService.selectAllFltSchdul(); String sCnt = String.valueOf(dataCnt.get(0).get("DATA_CNT")); @@ -278,116 +232,44 @@ public class MainController implements ApplicationListener { Map paramMap = new HashMap<>(); - paramMap.put("ar_dt", "%"); - paramMap.put("ret_minDt", ""); - paramMap.put("ret_procCnt", 0); + paramMap.put("ret_msg", "%"); - eaiProcService.callProcArtsDep(paramMap); + eaiProcService.callProcAll(paramMap); Duration diff = Duration.between(dt_before, LocalDateTime.now()); - logger.info("callProcArtsDep Call " + sCnt + "건 " + diff.toMillis() + "msec"); + logger.info("항공기 운항 스케줄 " + sCnt + "건 " + diff.toMillis() + "msec"); // 수신(처리) 건수 집계 -> ELK전송용 - recvStatsMgr.writeStatsLog_KST((String) paramMap.get("ret_minDt"), "104", "ARTS_DEP", (int) paramMap.get("ret_procCnt"), 0); + String strRetMsg = (String) paramMap.get("ret_msg"); + + if(strRetMsg == null ) return; + + String[] strMsgList = strRetMsg.split("\\^"); + + //areaList.forEach(area -> mapTaxiway.put(area.getId(), area)); + + if(sch.getMapLogCode() == null ){ + sch.selectCmmnCd(); + } - } - - // Thread.sleep(3000); - - } - - private void callThread_AcdmArr() throws InterruptedException { - - // if(!running) return ; + for(String retMsgRow : strMsgList){ - List> dataCnt = eaiIfCheckService.getAcdmArr(); + String[] strMsgFields = retMsgRow.split("\\,"); + String strIntrvcId = strMsgFields[0]; + String strIntrvcMn = sch.getMapLogCode().get(strMsgFields[0]); + String strIntrvcIfDt = strMsgFields[1]; + String strIntrvcCnt = strMsgFields[2]; - String sCnt = String.valueOf(dataCnt.get(0).get("DATA_CNT")); - - if( Integer.parseInt(sCnt) > 0 ) { - - LocalDateTime dt_before = LocalDateTime.now(); - - Map paramMap = new HashMap<>(); + recvStatsMgr.writeStatsLog_KST(strIntrvcIfDt, strIntrvcId, strIntrvcMn, Integer.parseInt(strIntrvcCnt), 0); - paramMap.put("ar_dt", "%"); - paramMap.put("ret_minDt", ""); - paramMap.put("ret_procCnt", 0); + } - eaiProcService.callProcAcdmArr(paramMap); - - Duration diff = Duration.between(dt_before, LocalDateTime.now()); - logger.info("callProcAcdmArr Call " + sCnt + "건 " + diff.toMillis() + "msec"); - - // 수신(처리) 건수 집계 -> ELK전송용 - recvStatsMgr.writeStatsLog_KST((String) paramMap.get("ret_minDt"), "101", "ACDM_ARR", (int) paramMap.get("ret_procCnt"), 0); } // Thread.sleep(3000); } - private void callThread_AcdmDep() throws InterruptedException { - - // if(!running) return ; - - List> dataCnt = eaiIfCheckService.getAcdmDep(); - - String sCnt = String.valueOf(dataCnt.get(0).get("DATA_CNT")); - - if( Integer.parseInt(sCnt) > 0 ) { - - LocalDateTime dt_before = LocalDateTime.now(); - - Map paramMap = new HashMap<>(); - - paramMap.put("ar_dt", "%"); - paramMap.put("ret_minDt", ""); - paramMap.put("ret_procCnt", 0); - - eaiProcService.callProcAcdmDep(paramMap); - - Duration diff = Duration.between(dt_before, LocalDateTime.now()); - logger.info("callProcAcdmDep Call " + sCnt + "건 " + diff.toMillis() + "msec"); - - // 수신(처리) 건수 집계 -> ELK전송용 - recvStatsMgr.writeStatsLog_KST((String) paramMap.get("ret_minDt"), "102", "ACDM_DEP", (int) paramMap.get("ret_procCnt"), 0); - } - - // Thread.sleep(3000); - } - - private void callThread_Gam() throws InterruptedException { - - // if(!running) return ; - - List> dataCnt = eaiIfCheckService.getGam(); - - String sCnt = String.valueOf(dataCnt.get(0).get("DATA_CNT")); - - if( Integer.parseInt(sCnt) > 0 ) { - - LocalDateTime dt_before = LocalDateTime.now(); - - Map paramMap = new HashMap<>(); - - paramMap.put("ar_dt", "%"); - paramMap.put("ret_minDt", ""); - paramMap.put("ret_procCnt", 0); - - eaiProcService.callProcGam(paramMap); - - Duration diff = Duration.between(dt_before, LocalDateTime.now()); - logger.info("callProcGam Call " + sCnt + "건 " + diff.toMillis() + "msec"); - - // 수신(처리) 건수 집계 -> ELK전송용 - recvStatsMgr.writeStatsLog_KST((String) paramMap.get("ret_minDt"), "105", "GAM", (int) paramMap.get("ret_procCnt"), 0); - } - - // Thread.sleep(3000); - } - - - private void callThread_Amos() throws InterruptedException { + private void CallProc_Amos() throws InterruptedException { // if(!running) return ; @@ -408,7 +290,7 @@ public class MainController implements ApplicationListener { eaiProcService.callProcAmos(paramMap); Duration diff = Duration.between(dt_before, LocalDateTime.now()); - logger.info("callProcAmos Call " + sCnt + "건 " + diff.toMillis() + "msec"); + logger.info("활주로 기상정보 " + sCnt + "건 " + diff.toMillis() + "msec"); // 수신(처리) 건수 집계 -> ELK전송용 recvStatsMgr.writeStatsLog_KST((String) paramMap.get("ret_minDt"), "106", "AMOS", (int) paramMap.get("ret_procCnt"), 0); @@ -417,7 +299,7 @@ public class MainController implements ApplicationListener { // Thread.sleep(3000); } - private void callThread_Notam() throws InterruptedException { + private void CallProc_Notam() throws InterruptedException { // if(!running) return ; @@ -438,7 +320,7 @@ public class MainController implements ApplicationListener { eaiProcService.callProcNotam(paramMap); Duration diff = Duration.between(dt_before, LocalDateTime.now()); - logger.info("callProcNotam Call " + sCnt + "건 " + diff.toMillis() + "msec"); + logger.info("NOTAM " + sCnt + "건 " + diff.toMillis() + "msec"); // 수신(처리) 건수 집계 -> ELK전송용 recvStatsMgr.writeStatsLog_KST((String) paramMap.get("ret_minDt"), "107", "NOTAM", (int) paramMap.get("ret_procCnt"), 0); @@ -447,6 +329,4 @@ public class MainController implements ApplicationListener { // Thread.sleep(3000); } - - } diff --git a/src/main/java/kr/gmtc/gw/eyegw/controller/MainController_Old.java b/src/main/java/kr/gmtc/gw/eyegw/controller/MainController_Old.java new file mode 100644 index 0000000..caeb856 --- /dev/null +++ b/src/main/java/kr/gmtc/gw/eyegw/controller/MainController_Old.java @@ -0,0 +1,470 @@ +package kr.gmtc.gw.eyegw.controller; + +import java.time.Duration; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Queue; + +import javax.annotation.Resource; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.context.ApplicationListener; +import org.springframework.context.event.ContextClosedEvent; +import org.springframework.context.event.EventListener; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; + +import kr.gmt.so.state.StateManager; +import kr.gmt.so.state.model.SystemState; +import kr.gmtc.gw.comp.thread.CustomThread; +import kr.gmtc.gw.eyegw.config.ServiceConfig; +import kr.gmtc.gw.eyegw.db1.EaiIfCheckService; +import kr.gmtc.gw.eyegw.db1.EaiProcService; +import kr.gmtc.gw.eyegw.satats.IntrfcRecvStatsManager; + +// @Component("controller") +public class MainController_Old implements ApplicationListener { + + // 프레임 워크 구성요소 // + /** 서비스 설정, {@code application.properties} */ + @Resource(name = "ServiceConfig") + private ServiceConfig serviceConfig; + + // DB // + /** + * DB1 Connection
+ * application.yml에 db.db1.use가 true로 설정되어야 사용가능
+ * db.db1.use가 false일 경우 주석처리 (Bean 런타임 에러 발생) + * @see DB1Connection + */ +// @Resource(name = "DB1Connection") +// private DB1Connection db1Connection; + + private EaiIfCheckService eaiIfCheckService; + private EaiProcService eaiProcService; + + // DB // + + + + // 업무처리 // + /** 업무 처리 스레드 */ + private List listCustomThreads; + // private CustomThread callThread_ArtsArr; + // private CustomThread callThread_ArtsDep; + // private CustomThread callThread_AcdmArr; + // private CustomThread callThread_AcdmDep; + // private CustomThread callThread_Gam; + // private CustomThread callThread_Amos; + // private CustomThread callThread_Notam; + private CustomThread chkThreadStatus; + + @Value("${settings.interval.proc.call}") + private int procCallInterval; + + @Value("${settings.interval.chk.thread}") + private int chkThreadInterval; + + + DateTimeFormatter dfPattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"); + + + private static final Logger logger = LoggerFactory.getLogger(MainController.class); + + @Autowired + private StateManager stateMgr; + + private boolean swBeforeStatus = true; + + private IntrfcRecvStatsManager recvStatsMgr; + + /** 초기화 실패 시 프로그램 종료 */ +// private void systemError() { +// // logger.writeLevelLog("-- FAIL TO STARTUP --", LogLevelType.LOG_ERROR, "AllLog"); +// System.exit(1); +// } + + /** + * 수정 금지
+ * Spring Bean 객체 생성, logger 초기화 + */ + public MainController_Old(EaiProcService eaiProcService, EaiIfCheckService eaiIfCheckService) { + + this.eaiProcService = eaiProcService; + this.eaiProcService = eaiProcService; + this.eaiIfCheckService = eaiIfCheckService; + + } + + /** + * 실행 (1순위)
+ * 프로그램 초기화 + */ + @Order(0) + @EventListener(ApplicationReadyEvent.class) + public void initialize() { + try { + + recvStatsMgr = new IntrfcRecvStatsManager(); + + // 업무 스래드(프로시저 호출) + listCustomThreads = new ArrayList(); + + // listCustomThreads.add(new CustomThread("callThread_Gam", this, procCallInterval, this::callThread_Gam, null, false)); + // listCustomThreads.add(new CustomThread("callThread_AcdmArr", this, procCallInterval, this::callThread_AcdmArr, null, false)); + // listCustomThreads.add(new CustomThread("callThread_AcdmDep", this, procCallInterval, this::callThread_AcdmDep, null, false)); + // listCustomThreads.add(new CustomThread("callThread_ArtsArr", this, procCallInterval, this::callThread_ArtsArr, null, false)); + // listCustomThreads.add(new CustomThread("callThread_ArtsDep", this, procCallInterval, this::callThread_ArtsDep, null, false)); + // listCustomThreads.add(new CustomThread("callThread_Amos", this, procCallInterval, this::callThread_Amos, null, false)); + // listCustomThreads.add(new CustomThread("callThread_Notam", this, procCallInterval, this::callThread_Notam, null, false)); + listCustomThreads.add(new CustomThread("callThread_dataDelete", this, procCallInterval, this::callThread_dataDelete, null, false)); + + // 이중화 체크 및 업무스래드 체크 + chkThreadStatus = new CustomThread("chkThreadStatus", this, procCallInterval, this::chkThreadStatus, null, false); + + } catch (Exception e) { + logger.error("MainContoller-Thread create fail"); + System.exit(1); + } + } + + /** + * 실행 (2순위)
+ * 프로그램 실행 + */ + @Order(1) + @EventListener(ApplicationReadyEvent.class) + public void start() { + try { + + logger.info("MainContoller-Thread start"); + + for(CustomThread ct : listCustomThreads ){ + ct.start(); + } + + chkThreadStatus.start(); + + stateMgr.updateState(); + + } catch (Exception e) { + logger.error("MainContoller-Thread start fail"); + System.exit(1); + } + } + + + /** 종료 처리 */ + public void stop() { + + for(CustomThread ct : listCustomThreads ){ + ct.gracefulStop(); + } + + chkThreadStatus.gracefulStop(); + + } + + + private void chkThreadStatus(){ + + stateMgr.updateState(); + + boolean running = true; + boolean swNewStatus = stateMgr.isActive(); + + // 이중화 Active / Standby 상태 변경 체크 + if(swBeforeStatus != swNewStatus){ + + if(swNewStatus){ + for(CustomThread ct : listCustomThreads ) ct.start(); + }else{ + for(CustomThread ct : listCustomThreads ) ct.gracefulStop(); + } + + } + + // 해당 프로그램이 Active일때 Thread Interrupt 유무 체크 + if(swNewStatus){ + + for(CustomThread ct : listCustomThreads ){ + if(ct.isInterrupted()){ + running = false; + break; + } + } + + if(running){ + stateMgr.updateState(SystemState.Normal); + }else{ + stateMgr.updateState(SystemState.Error); + } + } + + swBeforeStatus = stateMgr.isActive(); + + // logger.info("swBeforeStatus : " + swBeforeStatus); + + } + + + + /** 종료 이벤트 (강제종료시 수행 안됨) */ + public void onApplicationEvent(ContextClosedEvent event) { + + stateMgr.updateState(SystemState.Stop); + for(CustomThread ct : listCustomThreads ) ct.gracefulStop(); + chkThreadStatus.gracefulStop(); + + logger.info("====================== SYSTEM STOPED ======================"); + } + + + /** + * 업무 로직
+ * 자동으로 무한반복 하므로 내부에 while문 필요 없음.
+ * 예외처리를 하지 않을 경우 {@link CustomThread} 내부에서 로그 처리 + */ + private void callThread_ArtsArr() throws InterruptedException { + + // if(!running) return ; + + List> dataCnt = eaiIfCheckService.getArtsArr(); + + String sCnt = String.valueOf(dataCnt.get(0).get("DATA_CNT")); + + if( Integer.parseInt(sCnt) > 0 ) { + + LocalDateTime dt_before = LocalDateTime.now(); + + Map paramMap = new HashMap<>(); + + paramMap.put("ar_dt", "%"); + paramMap.put("ret_minDt", ""); + paramMap.put("ret_procCnt", 0); + + //DB 프로시져 Call + eaiProcService.callProcArtsArr(paramMap); + + Duration diff = Duration.between(dt_before, LocalDateTime.now()); + logger.info("callProcArtsArr Call " + sCnt + "건 " + diff.toMillis() + "msec"); + + // 수신(처리) 건수 집계 -> ELK전송용 + + } + + // Thread.sleep(3000); + + } + + private void callThread_ArtsDep() throws InterruptedException { + + // if(!running) return ; + + List> dataCnt = eaiIfCheckService.getArtsDep(); + + String sCnt = String.valueOf(dataCnt.get(0).get("DATA_CNT")); + + if( Integer.parseInt(sCnt) > 0 ) { + + LocalDateTime dt_before = LocalDateTime.now(); + + Map paramMap = new HashMap<>(); + + paramMap.put("ar_dt", "%"); + paramMap.put("ret_minDt", ""); + paramMap.put("ret_procCnt", 0); + + eaiProcService.callProcArtsDep(paramMap); + + Duration diff = Duration.between(dt_before, LocalDateTime.now()); + logger.info("callProcArtsDep Call " + sCnt + "건 " + diff.toMillis() + "msec"); + + // 수신(처리) 건수 집계 -> ELK전송용 + recvStatsMgr.writeStatsLog_KST((String) paramMap.get("ret_minDt"), "104", "ARTS_DEP", (int) paramMap.get("ret_procCnt"), 0); + + } + + // Thread.sleep(3000); + + } + + private void callThread_AcdmArr() throws InterruptedException { + + // if(!running) return ; + + List> dataCnt = eaiIfCheckService.getAcdmArr(); + + String sCnt = String.valueOf(dataCnt.get(0).get("DATA_CNT")); + + if( Integer.parseInt(sCnt) > 0 ) { + + LocalDateTime dt_before = LocalDateTime.now(); + + Map paramMap = new HashMap<>(); + + paramMap.put("ar_dt", "%"); + paramMap.put("ret_minDt", ""); + paramMap.put("ret_procCnt", 0); + + eaiProcService.callProcAcdmArr(paramMap); + + Duration diff = Duration.between(dt_before, LocalDateTime.now()); + logger.info("callProcAcdmArr Call " + sCnt + "건 " + diff.toMillis() + "msec"); + + // 수신(처리) 건수 집계 -> ELK전송용 + recvStatsMgr.writeStatsLog_KST((String) paramMap.get("ret_minDt"), "101", "ACDM_ARR", (int) paramMap.get("ret_procCnt"), 0); + } + + // Thread.sleep(3000); + } + + private void callThread_AcdmDep() throws InterruptedException { + + // if(!running) return ; + + List> dataCnt = eaiIfCheckService.getAcdmDep(); + + String sCnt = String.valueOf(dataCnt.get(0).get("DATA_CNT")); + + if( Integer.parseInt(sCnt) > 0 ) { + + LocalDateTime dt_before = LocalDateTime.now(); + + Map paramMap = new HashMap<>(); + + paramMap.put("ar_dt", "%"); + paramMap.put("ret_minDt", ""); + paramMap.put("ret_procCnt", 0); + + eaiProcService.callProcAcdmDep(paramMap); + + Duration diff = Duration.between(dt_before, LocalDateTime.now()); + logger.info("callProcAcdmDep Call " + sCnt + "건 " + diff.toMillis() + "msec"); + + // 수신(처리) 건수 집계 -> ELK전송용 + recvStatsMgr.writeStatsLog_KST((String) paramMap.get("ret_minDt"), "102", "ACDM_DEP", (int) paramMap.get("ret_procCnt"), 0); + } + + // Thread.sleep(3000); + } + + private void callThread_Gam() throws InterruptedException { + + // if(!running) return ; + + List> dataCnt = eaiIfCheckService.getGam(); + + String sCnt = String.valueOf(dataCnt.get(0).get("DATA_CNT")); + + if( Integer.parseInt(sCnt) > 0 ) { + + LocalDateTime dt_before = LocalDateTime.now(); + + Map paramMap = new HashMap<>(); + + paramMap.put("ar_dt", "%"); + paramMap.put("ret_minDt", ""); + paramMap.put("ret_procCnt", 0); + + eaiProcService.callProcGam(paramMap); + + Duration diff = Duration.between(dt_before, LocalDateTime.now()); + logger.info("callProcGam Call " + sCnt + "건 " + diff.toMillis() + "msec"); + + // 수신(처리) 건수 집계 -> ELK전송용 + recvStatsMgr.writeStatsLog_KST((String) paramMap.get("ret_minDt"), "105", "GAM", (int) paramMap.get("ret_procCnt"), 0); + } + + // Thread.sleep(3000); + } + + + private void callThread_Amos() throws InterruptedException { + + // if(!running) return ; + + List> dataCnt = eaiIfCheckService.getAmos(); + + String sCnt = String.valueOf(dataCnt.get(0).get("DATA_CNT")); + + if( Integer.parseInt(sCnt) > 0 ) { + + LocalDateTime dt_before = LocalDateTime.now(); + + Map paramMap = new HashMap<>(); + + paramMap.put("ar_dt", "%"); + paramMap.put("ret_minDt", ""); + paramMap.put("ret_procCnt", 0); + + eaiProcService.callProcAmos(paramMap); + + Duration diff = Duration.between(dt_before, LocalDateTime.now()); + logger.info("callProcAmos Call " + sCnt + "건 " + diff.toMillis() + "msec"); + + // 수신(처리) 건수 집계 -> ELK전송용 + recvStatsMgr.writeStatsLog_KST((String) paramMap.get("ret_minDt"), "106", "AMOS", (int) paramMap.get("ret_procCnt"), 0); + } + + // Thread.sleep(3000); + } + + private void callThread_Notam() throws InterruptedException { + + // if(!running) return ; + + List> dataCnt = eaiIfCheckService.getNotam(); + + String sCnt = String.valueOf(dataCnt.get(0).get("DATA_CNT")); + + if( Integer.parseInt(sCnt) > 0 ) { + + LocalDateTime dt_before = LocalDateTime.now(); + + Map paramMap = new HashMap<>(); + + paramMap.put("ar_dt", "%"); + paramMap.put("ret_minDt", ""); + paramMap.put("ret_procCnt", 0); + + eaiProcService.callProcNotam(paramMap); + + Duration diff = Duration.between(dt_before, LocalDateTime.now()); + logger.info("callProcNotam Call " + sCnt + "건 " + diff.toMillis() + "msec"); + + // 수신(처리) 건수 집계 -> ELK전송용 + recvStatsMgr.writeStatsLog_KST((String) paramMap.get("ret_minDt"), "107", "NOTAM", (int) paramMap.get("ret_procCnt"), 0); + } + + // Thread.sleep(3000); + } + + + private void callThread_dataDelete() throws InterruptedException { + + Map paramMap = new HashMap<>(); + + paramMap.put("ar_days", 90); + paramMap.put("ret_proc_msg", ""); + + eaiProcService.callProcOldDataDelete(paramMap); + + String sProcMsg = (String) paramMap.get("ret_proc_msg"); + + logger.info("callProcOldDataDelete Call : " + sProcMsg); + + + } + + + +} diff --git a/src/main/java/kr/gmtc/gw/eyegw/controller/SchedulController.java b/src/main/java/kr/gmtc/gw/eyegw/controller/SchedulController.java new file mode 100644 index 0000000..ad3ad45 --- /dev/null +++ b/src/main/java/kr/gmtc/gw/eyegw/controller/SchedulController.java @@ -0,0 +1,78 @@ +package kr.gmtc.gw.eyegw.controller; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import kr.gmtc.gw.eyegw.db1.EaiIfCheckService; +import kr.gmtc.gw.eyegw.db1.EaiProcService; + +@Component +public class SchedulController { + + private EaiIfCheckService checkService; + private EaiProcService eaiProcService; + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Value("${settings.delete.save-days}") + private int dataSaveDays = 120; + + + private Map mapLogCode; + + + public SchedulController(EaiIfCheckService checkService, EaiProcService eaiProcService){ + this.checkService = checkService; + this.eaiProcService = eaiProcService; + } + + @Scheduled(cron = "${settings.cmmnCd.cron}") + public void selectCmmnCd(){ + + mapLogCode = new ConcurrentHashMap(); + + List> logList = checkService.selectLogCode(); + + logger.info("로그유형코드(CT033) " +logList.size()+ "건 조회 완료."); + + logList.forEach(codes -> mapLogCode.put( (String) codes.get("CD"), (String) codes.get("CD_NM") ) ); + + } + + @Scheduled(cron = "${settings.delete.cron}") + private void callThread_dataDelete() throws InterruptedException { + + Map paramMap = new HashMap<>(); + + paramMap.put("ar_days", dataSaveDays); + paramMap.put("ret_proc_msg", ""); + + eaiProcService.callProcOldDataDelete(paramMap); + + String sProcMsg = (String) paramMap.get("ret_proc_msg"); + + logger.info("callProcOldDataDelete Call : " + sProcMsg); + + + } + + public Map getMapLogCode() { + return mapLogCode; + } + + public void setMapLogCode(Map mapLogCode) { + this.mapLogCode = mapLogCode; + } + + + +} diff --git a/src/main/java/kr/gmtc/gw/eyegw/db1/EaiIfCheckMapper.java b/src/main/java/kr/gmtc/gw/eyegw/db1/EaiIfCheckMapper.java index 1f330fc..0855003 100644 --- a/src/main/java/kr/gmtc/gw/eyegw/db1/EaiIfCheckMapper.java +++ b/src/main/java/kr/gmtc/gw/eyegw/db1/EaiIfCheckMapper.java @@ -14,6 +14,10 @@ public interface EaiIfCheckMapper { List> selectAcdmArr(); List> selectAcdmDep(); List> selectGAM(); + + List> selectAllFltSchdul(); List> selectAMOS(); List> selectNOTAM(); + + List> selectLogCode(); } diff --git a/src/main/java/kr/gmtc/gw/eyegw/db1/EaiIfCheckService.java b/src/main/java/kr/gmtc/gw/eyegw/db1/EaiIfCheckService.java index c1bac5f..59a90c5 100644 --- a/src/main/java/kr/gmtc/gw/eyegw/db1/EaiIfCheckService.java +++ b/src/main/java/kr/gmtc/gw/eyegw/db1/EaiIfCheckService.java @@ -31,6 +31,12 @@ public class EaiIfCheckService { public List> getGam() { return checkMapper.selectGAM(); } + + //////////////////////////////////////////////////////////// + + public List> selectAllFltSchdul() { + return checkMapper.selectAllFltSchdul(); + } public List> getAmos() { return checkMapper.selectAMOS(); @@ -39,5 +45,9 @@ public class EaiIfCheckService { public List> getNotam() { return checkMapper.selectNOTAM(); } + + public List> selectLogCode() { + return checkMapper.selectLogCode(); + } } diff --git a/src/main/java/kr/gmtc/gw/eyegw/db1/EaiProcMapper.java b/src/main/java/kr/gmtc/gw/eyegw/db1/EaiProcMapper.java index 918f8ea..4fb3c25 100644 --- a/src/main/java/kr/gmtc/gw/eyegw/db1/EaiProcMapper.java +++ b/src/main/java/kr/gmtc/gw/eyegw/db1/EaiProcMapper.java @@ -16,4 +16,6 @@ public interface EaiProcMapper { void callProcAmos(Map parameterMap); void callProcNotam(Map parameterMap); void callProcAll(Map parameterMap); + + void callProcOldDataDelete(Map parameterMap); } diff --git a/src/main/java/kr/gmtc/gw/eyegw/db1/EaiProcService.java b/src/main/java/kr/gmtc/gw/eyegw/db1/EaiProcService.java index be5187a..4f27862 100644 --- a/src/main/java/kr/gmtc/gw/eyegw/db1/EaiProcService.java +++ b/src/main/java/kr/gmtc/gw/eyegw/db1/EaiProcService.java @@ -59,5 +59,11 @@ public class EaiProcService { ueaiProcMapper.callProcAll(parameterMap); } + + public void callProcOldDataDelete(Map parameterMap) { + + ueaiProcMapper.callProcOldDataDelete(parameterMap); + + } } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index f391467..9365845 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -27,10 +27,11 @@ database: state: # 공통코드 CT001의 코드 6자리 - id: LK0309 # IFToDB + id: LK0302 # IFToDB # 1:Primary, 2:Secondary - type: Primary - + type: Secondary + DisplayLog: true + --- spring: config: @@ -47,8 +48,13 @@ settings: proc: call: 10000 chk: - thread: 30000 - + thread: 30000 + cmmnCd: + cron: 0 0/10 * * * * # 공통 코드 10분 마다 조회 + delete: + save-days: 90 # 90일 이전 데이터 삭제 + cron: 0 0 03 * * * # 매일 새벽 3시 수행 + --- spring: config: @@ -63,7 +69,11 @@ settings: proc: call: 10000 chk: - thread: 30000 -# root: D:\Workspace\... + thread: 30000 + cmmnCd: + cron: 0 0/10 * * * ? # 공통 코드 10분 마다 조회 + delete: + save-days: 90 # 90일 이전 데이터 삭제 + cron: 0 0 03 * * * # 매일 새벽 3시 수행 diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml index 0865f9d..010a82b 100644 --- a/src/main/resources/logback-spring.xml +++ b/src/main/resources/logback-spring.xml @@ -114,15 +114,15 @@ - + - + diff --git a/src/main/resources/mapper/DB1/eai_if_check.xml b/src/main/resources/mapper/DB1/eai_if_check.xml index 8599879..e8ca8c0 100644 --- a/src/main/resources/mapper/DB1/eai_if_check.xml +++ b/src/main/resources/mapper/DB1/eai_if_check.xml @@ -3,34 +3,54 @@ + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/DB1/eai_proc.xml b/src/main/resources/mapper/DB1/eai_proc.xml index 698254a..6803a22 100644 --- a/src/main/resources/mapper/DB1/eai_proc.xml +++ b/src/main/resources/mapper/DB1/eai_proc.xml @@ -4,7 +4,7 @@ - + + +