main
MonHun 2024-07-14 12:40:48 +09:00
parent ceab861975
commit fcaf5832d5
12 changed files with 715 additions and 229 deletions

View File

@ -2,7 +2,9 @@ package kr.gmtc.gw.eyegw;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
@EnableScheduling
@SpringBootApplication @SpringBootApplication
public class EyeGWApplication { public class EyeGWApplication {

View File

@ -38,33 +38,13 @@ public class MainController implements ApplicationListener<ContextClosedEvent> {
@Resource(name = "ServiceConfig") @Resource(name = "ServiceConfig")
private ServiceConfig serviceConfig; private ServiceConfig serviceConfig;
// DB //
/**
* DB1 Connection<br>
* application.yml db.db1.use true <br>
* db.db1.use false (Bean )
* @see DB1Connection
*/
// @Resource(name = "DB1Connection")
// private DB1Connection db1Connection;
private EaiIfCheckService eaiIfCheckService; private EaiIfCheckService eaiIfCheckService;
private EaiProcService eaiProcService; private EaiProcService eaiProcService;
// DB //
// 업무처리 // // 업무처리 //
/** 업무 처리 스레드 */ /** 업무 처리 스레드 */
private List<CustomThread> listCustomThreads; private List<CustomThread> 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; private CustomThread chkThreadStatus;
@Value("${settings.interval.proc.call}") @Value("${settings.interval.proc.call}")
@ -73,12 +53,13 @@ public class MainController implements ApplicationListener<ContextClosedEvent> {
@Value("${settings.interval.chk.thread}") @Value("${settings.interval.chk.thread}")
private int chkThreadInterval; private int chkThreadInterval;
DateTimeFormatter dfPattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"); DateTimeFormatter dfPattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
private static final Logger logger = LoggerFactory.getLogger(MainController.class); private static final Logger logger = LoggerFactory.getLogger(MainController.class);
@Autowired
private SchedulController sch;
@Autowired @Autowired
private StateManager stateMgr; private StateManager stateMgr;
@ -86,12 +67,6 @@ public class MainController implements ApplicationListener<ContextClosedEvent> {
private IntrfcRecvStatsManager recvStatsMgr; private IntrfcRecvStatsManager recvStatsMgr;
/** 초기화 실패 시 프로그램 종료 */
// private void systemError() {
// // logger.writeLevelLog("-- FAIL TO STARTUP --", LogLevelType.LOG_ERROR, "AllLog");
// System.exit(1);
// }
/** /**
* <br> * <br>
* Spring Bean , logger * Spring Bean , logger
@ -99,7 +74,6 @@ public class MainController implements ApplicationListener<ContextClosedEvent> {
public MainController(EaiProcService eaiProcService, EaiIfCheckService eaiIfCheckService) { public MainController(EaiProcService eaiProcService, EaiIfCheckService eaiIfCheckService) {
this.eaiProcService = eaiProcService; this.eaiProcService = eaiProcService;
this.eaiProcService = eaiProcService;
this.eaiIfCheckService = eaiIfCheckService; this.eaiIfCheckService = eaiIfCheckService;
} }
@ -118,16 +92,12 @@ public class MainController implements ApplicationListener<ContextClosedEvent> {
// 업무 스래드(프로시저 호출) // 업무 스래드(프로시저 호출)
listCustomThreads = new ArrayList<CustomThread>(); listCustomThreads = new ArrayList<CustomThread>();
listCustomThreads.add(new CustomThread("callThread_Gam", this, procCallInterval, this::callThread_Gam, null, false)); listCustomThreads.add(new CustomThread("CallProc_AllFltSchdul", this, procCallInterval, this::CallProc_AllFltSchdul, null, false));
listCustomThreads.add(new CustomThread("callThread_AcdmArr", this, procCallInterval, this::callThread_AcdmArr, null, false)); listCustomThreads.add(new CustomThread("CallProc_Amos", this, procCallInterval, this::CallProc_Amos, null, false));
listCustomThreads.add(new CustomThread("callThread_AcdmDep", this, procCallInterval, this::callThread_AcdmDep, null, false)); listCustomThreads.add(new CustomThread("CallProc_Notam", this, procCallInterval, this::CallProc_Notam, 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));
// 이중화 체크 및 업무스래드 체크 // 이중화 체크 및 업무스래드 체크
chkThreadStatus = new CustomThread("chkThreadStatus", this, procCallInterval, this::chkThreadStatus, null, false); chkThreadStatus = new CustomThread("chkThreadStatus", this, 3000, this::chkThreadStatus, null, false);
} catch (Exception e) { } catch (Exception e) {
logger.error("MainContoller-Thread create fail"); logger.error("MainContoller-Thread create fail");
@ -173,27 +143,36 @@ public class MainController implements ApplicationListener<ContextClosedEvent> {
} }
private void chkThreadStatus(){ private void chkThreadStatus() throws InterruptedException{
stateMgr.updateState(); stateMgr.updateState();
boolean running = true; boolean running = true;
boolean swNewStatus = stateMgr.isActive(); boolean swNewStatus = stateMgr.isActive();
// 이중화 Active / Standby 상태 변경 체크 // Active 상태로 변경된경우
if(swBeforeStatus != swNewStatus){ 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();
}
if(swNewStatus){
for(CustomThread ct : listCustomThreads ) ct.start();
}else { }else {
for(CustomThread ct : listCustomThreads ) ct.gracefulStop();
}
}
// 해당 프로그램이 Active일때 Thread Interrupt 유무 체크 // 해당 프로그램이 Active일때 Thread Interrupt 유무 체크
if(swNewStatus){ if(swNewStatus){
for(CustomThread ct : listCustomThreads ){ for(CustomThread ct : listCustomThreads ){
if(ct.isInterrupted()){ if(ct.isInterrupted()){
running = false; running = false;
@ -202,15 +181,21 @@ public class MainController implements ApplicationListener<ContextClosedEvent> {
} }
if(running){ if(running){
stateMgr.updateState(SystemState.Normal); stateMgr.updateState(SystemState.Normal);
for(CustomThread ct : listCustomThreads ){
if(ct.getState() == Thread.State.NEW) ct.start();
}
}else{ }else{
stateMgr.updateState(SystemState.Error); stateMgr.updateState(SystemState.Error);
} }
}
} }
swBeforeStatus = stateMgr.isActive(); swBeforeStatus = swNewStatus;
// logger.info("swBeforeStatus : " + swBeforeStatus);
} }
@ -232,11 +217,12 @@ public class MainController implements ApplicationListener<ContextClosedEvent> {
* while .<br> * while .<br>
* {@link CustomThread} * {@link CustomThread}
*/ */
private void callThread_ArtsArr() throws InterruptedException {
private void CallProc_AllFltSchdul() throws InterruptedException {
// if(!running) return ; // if(!running) return ;
List<HashMap<String, Object>> dataCnt = eaiIfCheckService.getArtsArr(); List<HashMap<String, Object>> dataCnt = eaiIfCheckService.selectAllFltSchdul();
String sCnt = String.valueOf(dataCnt.get(0).get("DATA_CNT")); String sCnt = String.valueOf(dataCnt.get(0).get("DATA_CNT"));
@ -246,148 +232,44 @@ public class MainController implements ApplicationListener<ContextClosedEvent> {
Map<String, Object> paramMap = new HashMap<>(); Map<String, Object> paramMap = new HashMap<>();
paramMap.put("ar_dt", "%"); paramMap.put("ret_msg", "%");
paramMap.put("ret_minDt", "");
paramMap.put("ret_procCnt", 0);
//DB 프로시져 Call eaiProcService.callProcAll(paramMap);
eaiProcService.callProcArtsArr(paramMap);
Duration diff = Duration.between(dt_before, LocalDateTime.now()); Duration diff = Duration.between(dt_before, LocalDateTime.now());
logger.info("callProcArtsArr Call " + sCnt + "건 " + diff.toMillis() + "msec"); logger.info("항공기 운항 스케줄 " + sCnt + "건 " + diff.toMillis() + "msec");
// 수신(처리) 건수 집계 -> ELK전송용 // 수신(처리) 건수 집계 -> ELK전송용
recvStatsMgr.writeStatsLog_KST((String) paramMap.get("ret_minDt"), "103", "ARTS_ARR", (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); for(String retMsgRow : strMsgList){
String[] strMsgFields = retMsgRow.split("\\,");
String strIntrvcId = strMsgFields[0];
String strIntrvcMn = sch.getMapLogCode().get(strMsgFields[0]);
String strIntrvcIfDt = strMsgFields[1];
String strIntrvcCnt = strMsgFields[2];
recvStatsMgr.writeStatsLog_KST(strIntrvcIfDt, strIntrvcId, strIntrvcMn, Integer.parseInt(strIntrvcCnt), 0);
} }
private void callThread_ArtsDep() throws InterruptedException {
// if(!running) return ;
List<HashMap<String, Object>> dataCnt = eaiIfCheckService.getArtsDep();
String sCnt = String.valueOf(dataCnt.get(0).get("DATA_CNT"));
if( Integer.parseInt(sCnt) > 0 ) {
LocalDateTime dt_before = LocalDateTime.now();
Map<String, Object> 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<HashMap<String, Object>> dataCnt = eaiIfCheckService.getAcdmArr();
String sCnt = String.valueOf(dataCnt.get(0).get("DATA_CNT"));
if( Integer.parseInt(sCnt) > 0 ) {
LocalDateTime dt_before = LocalDateTime.now();
Map<String, Object> 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); // Thread.sleep(3000);
} }
private void callThread_AcdmDep() throws InterruptedException { private void CallProc_Amos() throws InterruptedException {
// if(!running) return ;
List<HashMap<String, Object>> dataCnt = eaiIfCheckService.getAcdmDep();
String sCnt = String.valueOf(dataCnt.get(0).get("DATA_CNT"));
if( Integer.parseInt(sCnt) > 0 ) {
LocalDateTime dt_before = LocalDateTime.now();
Map<String, Object> 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<HashMap<String, Object>> dataCnt = eaiIfCheckService.getGam();
String sCnt = String.valueOf(dataCnt.get(0).get("DATA_CNT"));
if( Integer.parseInt(sCnt) > 0 ) {
LocalDateTime dt_before = LocalDateTime.now();
Map<String, Object> 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 ; // if(!running) return ;
@ -408,7 +290,7 @@ public class MainController implements ApplicationListener<ContextClosedEvent> {
eaiProcService.callProcAmos(paramMap); eaiProcService.callProcAmos(paramMap);
Duration diff = Duration.between(dt_before, LocalDateTime.now()); Duration diff = Duration.between(dt_before, LocalDateTime.now());
logger.info("callProcAmos Call " + sCnt + "건 " + diff.toMillis() + "msec"); logger.info("활주로 기상정보 " + sCnt + "건 " + diff.toMillis() + "msec");
// 수신(처리) 건수 집계 -> ELK전송용 // 수신(처리) 건수 집계 -> ELK전송용
recvStatsMgr.writeStatsLog_KST((String) paramMap.get("ret_minDt"), "106", "AMOS", (int) paramMap.get("ret_procCnt"), 0); 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<ContextClosedEvent> {
// Thread.sleep(3000); // Thread.sleep(3000);
} }
private void callThread_Notam() throws InterruptedException { private void CallProc_Notam() throws InterruptedException {
// if(!running) return ; // if(!running) return ;
@ -438,7 +320,7 @@ public class MainController implements ApplicationListener<ContextClosedEvent> {
eaiProcService.callProcNotam(paramMap); eaiProcService.callProcNotam(paramMap);
Duration diff = Duration.between(dt_before, LocalDateTime.now()); Duration diff = Duration.between(dt_before, LocalDateTime.now());
logger.info("callProcNotam Call " + sCnt + "건 " + diff.toMillis() + "msec"); logger.info("NOTAM " + sCnt + "건 " + diff.toMillis() + "msec");
// 수신(처리) 건수 집계 -> ELK전송용 // 수신(처리) 건수 집계 -> ELK전송용
recvStatsMgr.writeStatsLog_KST((String) paramMap.get("ret_minDt"), "107", "NOTAM", (int) paramMap.get("ret_procCnt"), 0); 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<ContextClosedEvent> {
// Thread.sleep(3000); // Thread.sleep(3000);
} }
} }

View File

@ -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<ContextClosedEvent> {
// 프레임 워크 구성요소 //
/** 서비스 설정, {@code application.properties} */
@Resource(name = "ServiceConfig")
private ServiceConfig serviceConfig;
// DB //
/**
* DB1 Connection<br>
* application.yml db.db1.use true <br>
* db.db1.use false (Bean )
* @see DB1Connection
*/
// @Resource(name = "DB1Connection")
// private DB1Connection db1Connection;
private EaiIfCheckService eaiIfCheckService;
private EaiProcService eaiProcService;
// DB //
// 업무처리 //
/** 업무 처리 스레드 */
private List<CustomThread> 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);
// }
/**
* <br>
* Spring Bean , logger
*/
public MainController_Old(EaiProcService eaiProcService, EaiIfCheckService eaiIfCheckService) {
this.eaiProcService = eaiProcService;
this.eaiProcService = eaiProcService;
this.eaiIfCheckService = eaiIfCheckService;
}
/**
* (1)<br>
*
*/
@Order(0)
@EventListener(ApplicationReadyEvent.class)
public void initialize() {
try {
recvStatsMgr = new IntrfcRecvStatsManager();
// 업무 스래드(프로시저 호출)
listCustomThreads = new ArrayList<CustomThread>();
// 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)<br>
*
*/
@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 ======================");
}
/**
* <br>
* while .<br>
* {@link CustomThread}
*/
private void callThread_ArtsArr() throws InterruptedException {
// if(!running) return ;
List<HashMap<String, Object>> dataCnt = eaiIfCheckService.getArtsArr();
String sCnt = String.valueOf(dataCnt.get(0).get("DATA_CNT"));
if( Integer.parseInt(sCnt) > 0 ) {
LocalDateTime dt_before = LocalDateTime.now();
Map<String, Object> 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<HashMap<String, Object>> dataCnt = eaiIfCheckService.getArtsDep();
String sCnt = String.valueOf(dataCnt.get(0).get("DATA_CNT"));
if( Integer.parseInt(sCnt) > 0 ) {
LocalDateTime dt_before = LocalDateTime.now();
Map<String, Object> 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<HashMap<String, Object>> dataCnt = eaiIfCheckService.getAcdmArr();
String sCnt = String.valueOf(dataCnt.get(0).get("DATA_CNT"));
if( Integer.parseInt(sCnt) > 0 ) {
LocalDateTime dt_before = LocalDateTime.now();
Map<String, Object> 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<HashMap<String, Object>> dataCnt = eaiIfCheckService.getAcdmDep();
String sCnt = String.valueOf(dataCnt.get(0).get("DATA_CNT"));
if( Integer.parseInt(sCnt) > 0 ) {
LocalDateTime dt_before = LocalDateTime.now();
Map<String, Object> 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<HashMap<String, Object>> dataCnt = eaiIfCheckService.getGam();
String sCnt = String.valueOf(dataCnt.get(0).get("DATA_CNT"));
if( Integer.parseInt(sCnt) > 0 ) {
LocalDateTime dt_before = LocalDateTime.now();
Map<String, Object> 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<HashMap<String, Object>> dataCnt = eaiIfCheckService.getAmos();
String sCnt = String.valueOf(dataCnt.get(0).get("DATA_CNT"));
if( Integer.parseInt(sCnt) > 0 ) {
LocalDateTime dt_before = LocalDateTime.now();
Map<String, Object> 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<HashMap<String, Object>> dataCnt = eaiIfCheckService.getNotam();
String sCnt = String.valueOf(dataCnt.get(0).get("DATA_CNT"));
if( Integer.parseInt(sCnt) > 0 ) {
LocalDateTime dt_before = LocalDateTime.now();
Map<String, Object> 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<String, Object> 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);
}
}

View File

@ -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<String, String> mapLogCode;
public SchedulController(EaiIfCheckService checkService, EaiProcService eaiProcService){
this.checkService = checkService;
this.eaiProcService = eaiProcService;
}
@Scheduled(cron = "${settings.cmmnCd.cron}")
public void selectCmmnCd(){
mapLogCode = new ConcurrentHashMap<String, String>();
List<HashMap<String, Object>> 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<String, Object> 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<String, String> getMapLogCode() {
return mapLogCode;
}
public void setMapLogCode(Map<String, String> mapLogCode) {
this.mapLogCode = mapLogCode;
}
}

View File

@ -14,6 +14,10 @@ public interface EaiIfCheckMapper {
List<HashMap<String, Object>> selectAcdmArr(); List<HashMap<String, Object>> selectAcdmArr();
List<HashMap<String, Object>> selectAcdmDep(); List<HashMap<String, Object>> selectAcdmDep();
List<HashMap<String, Object>> selectGAM(); List<HashMap<String, Object>> selectGAM();
List<HashMap<String, Object>> selectAllFltSchdul();
List<HashMap<String, Object>> selectAMOS(); List<HashMap<String, Object>> selectAMOS();
List<HashMap<String, Object>> selectNOTAM(); List<HashMap<String, Object>> selectNOTAM();
List<HashMap<String, Object>> selectLogCode();
} }

View File

@ -32,6 +32,12 @@ public class EaiIfCheckService {
return checkMapper.selectGAM(); return checkMapper.selectGAM();
} }
////////////////////////////////////////////////////////////
public List<HashMap<String, Object>> selectAllFltSchdul() {
return checkMapper.selectAllFltSchdul();
}
public List<HashMap<String, Object>> getAmos() { public List<HashMap<String, Object>> getAmos() {
return checkMapper.selectAMOS(); return checkMapper.selectAMOS();
} }
@ -40,4 +46,8 @@ public class EaiIfCheckService {
return checkMapper.selectNOTAM(); return checkMapper.selectNOTAM();
} }
public List<HashMap<String, Object>> selectLogCode() {
return checkMapper.selectLogCode();
}
} }

View File

@ -16,4 +16,6 @@ public interface EaiProcMapper {
void callProcAmos(Map<String, Object> parameterMap); void callProcAmos(Map<String, Object> parameterMap);
void callProcNotam(Map<String, Object> parameterMap); void callProcNotam(Map<String, Object> parameterMap);
void callProcAll(Map<String, Object> parameterMap); void callProcAll(Map<String, Object> parameterMap);
void callProcOldDataDelete(Map<String, Object> parameterMap);
} }

View File

@ -60,4 +60,10 @@ public class EaiProcService {
} }
public void callProcOldDataDelete(Map<String, Object> parameterMap) {
ueaiProcMapper.callProcOldDataDelete(parameterMap);
}
} }

View File

@ -27,9 +27,10 @@ database:
state: state:
# 공통코드 CT001의 코드 6자리 # 공통코드 CT001의 코드 6자리
id: LK0309 # IFToDB id: LK0302 # IFToDB
# 1:Primary, 2:Secondary # 1:Primary, 2:Secondary
type: Primary type: Secondary
DisplayLog: true
--- ---
spring: spring:
@ -48,6 +49,11 @@ settings:
call: 10000 call: 10000
chk: chk:
thread: 30000 thread: 30000
cmmnCd:
cron: 0 0/10 * * * * # 공통 코드 10분 마다 조회
delete:
save-days: 90 # 90일 이전 데이터 삭제
cron: 0 0 03 * * * # 매일 새벽 3시 수행
--- ---
spring: spring:
@ -64,6 +70,10 @@ settings:
call: 10000 call: 10000
chk: chk:
thread: 30000 thread: 30000
# root: D:\Workspace\... cmmnCd:
cron: 0 0/10 * * * ? # 공통 코드 10분 마다 조회
delete:
save-days: 90 # 90일 이전 데이터 삭제
cron: 0 0 03 * * * # 매일 새벽 3시 수행

View File

@ -114,15 +114,15 @@
</appender> </appender>
<!-- 로그 전역 세팅 --> <!-- 로그 전역 세팅 -->
<!-- <root level="${LOG_LEVEL}"> <root level="${LOG_LEVEL}">
<appender-ref ref="CONSOLE"/> <appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/> <appender-ref ref="FILE"/>
</root> --> </root>
<logger name="kr.gmtc.gw" level="INFO"> <!-- <logger name="kr.gmtc.gw" level="INFO">
<appender-ref ref="CONSOLE"/> <appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/> <appender-ref ref="FILE"/>
</logger> </logger> -->
<logger name="STATS" level="INFO"> <logger name="STATS" level="INFO">
<!-- <appender-ref ref="CONSOLE"/> --> <!-- <appender-ref ref="CONSOLE"/> -->

View File

@ -3,32 +3,52 @@
<mapper namespace="kr.gmtc.gw.eyegw.db1.EaiIfCheckMapper"> <mapper namespace="kr.gmtc.gw.eyegw.db1.EaiIfCheckMapper">
<select id="selectAarsArr" resultType="hashMap"> <select id="selectAarsArr" resultType="hashMap">
select count(*) as data_cnt from ueai.EAI_ELECSTRIPARRARTS_RCV where deal_stat = 'S'; select count(*) as data_cnt from ueai.EAI_ELECSTRIPARRARTS_RCV where deal_stat = 'S'
</select> </select>
<select id="selectAarsDep" resultType="hashMap"> <select id="selectAarsDep" resultType="hashMap">
select count(*) as data_cnt from ueai.EAI_ELECSTRIPDEPARTS_RCV where deal_stat = 'S'; select count(*) as data_cnt from ueai.EAI_ELECSTRIPDEPARTS_RCV where deal_stat = 'S'
</select> </select>
<select id="selectAcdmArr" resultType="hashMap"> <select id="selectAcdmArr" resultType="hashMap">
select count(*) as data_cnt from ueai.EAI_FLTACDMMLSTNARR_RCV where deal_stat = 'S'; select count(*) as data_cnt from ueai.EAI_FLTACDMMLSTNARR_RCV where deal_stat = 'S'
</select> </select>
<select id="selectAcdmDep" resultType="hashMap"> <select id="selectAcdmDep" resultType="hashMap">
select count(*) as data_cnt from ueai.EAI_FLTACDMMLSTNDEP_RCV where deal_stat = 'S'; select count(*) as data_cnt from ueai.EAI_FLTACDMMLSTNDEP_RCV where deal_stat = 'S'
</select> </select>
<select id="selectGAM" resultType="hashMap"> <select id="selectGAM" resultType="hashMap">
select count(*) as data_cnt from ueai.EAI_GRDACMVT_RCV where deal_stat = 'S'; select count(*) as data_cnt from ueai.EAI_GRDACMVT_RCV where deal_stat = 'S'
</select>
<select id="selectAllFltSchdul" resultType="hashMap">
select count(*) as data_cnt
from (
select DATEANDTIME from ueai.EAI_ELECSTRIPARRARTS_RCV where DEAL_STAT = 'S' union all
select DATEANDTIME from ueai.EAI_ELECSTRIPDEPARTS_RCV where DEAL_STAT = 'S' union all
select DATEANDTIME from ueai.EAI_FLTACDMMLSTNARR_RCV where DEAL_STAT = 'S' union all
select DATEANDTIME from ueai.EAI_FLTACDMMLSTNDEP_RCV where DEAL_STAT = 'S' union all
select DATEANDTIME from ueai.EAI_GRDACMVT_RCV where DEAL_STAT = 'S'
)
</select> </select>
<select id="selectAMOS" resultType="hashMap"> <select id="selectAMOS" resultType="hashMap">
select count(*) as data_cnt from ueai.EAI_AWOS_RCV where deal_stat = 'S' and dateandtime >= '20231001000000.000'; select count(*) as data_cnt from ueai.EAI_AWOS_RCV where deal_stat = 'S' and dateandtime >= '20231001000000.000'
</select> </select>
<select id="selectNOTAM" resultType="hashMap"> <select id="selectNOTAM" resultType="hashMap">
select count(*) as data_cnt from UEAI.EAI_AFTNFLTINFO_RCV where deal_stat = 'S'; select count(*) as data_cnt from UEAI.EAI_AFTNFLTINFO_RCV where deal_stat = 'S'
</select>
<select id="selectLogCode" resultType="hashMap">
select cd_id as cd, CD_REF1 as cd_nm
from ucm.SACP_CMMN_CD
where CD_TY_ID = 'CT033'
and UPPER_CD = 'EAI'
order by cd_id
</select> </select>

View File

@ -4,7 +4,7 @@
<select id="callProcAmos" parameterType="hashmap" statementType="CALLABLE" resultType="hashmap"> <select id="callProcAmos" parameterType="hashmap" statementType="CALLABLE" resultType="hashmap">
<![CDATA[ <![CDATA[
call PROC_EAI_INTRFC_AMOS_NEW( call PROC_EAI_INTRFC_AMOS(
#{ar_dt, mode=IN, jdbcType=VARCHAR} #{ar_dt, mode=IN, jdbcType=VARCHAR}
,#{ret_minDt, mode=OUT, jdbcType=VARCHAR} ,#{ret_minDt, mode=OUT, jdbcType=VARCHAR}
,#{ret_procCnt, mode=OUT, jdbcType=INTEGER} ,#{ret_procCnt, mode=OUT, jdbcType=INTEGER}
@ -14,7 +14,7 @@
<select id="callProcNotam" parameterType="hashmap" statementType="CALLABLE" resultType="hashmap"> <select id="callProcNotam" parameterType="hashmap" statementType="CALLABLE" resultType="hashmap">
<![CDATA[ <![CDATA[
call PROC_EAI_INTRFC_AFTNFLTINFO_RCV_NEW( call PROC_EAI_INTRFC_AFTNFLTINFO_RCV(
#{ar_dt, mode=IN, jdbcType=VARCHAR} #{ar_dt, mode=IN, jdbcType=VARCHAR}
,#{ret_minDt, mode=OUT, jdbcType=VARCHAR} ,#{ret_minDt, mode=OUT, jdbcType=VARCHAR}
,#{ret_procCnt, mode=OUT, jdbcType=INTEGER} ,#{ret_procCnt, mode=OUT, jdbcType=INTEGER}
@ -24,7 +24,7 @@
<select id="callProcArtsArr" parameterType="hashmap" statementType="CALLABLE" resultType="hashmap"> <select id="callProcArtsArr" parameterType="hashmap" statementType="CALLABLE" resultType="hashmap">
<![CDATA[ <![CDATA[
call PROC_EAI_INTRFC_ARTS_ARR_NEW( call PROC_EAI_INTRFC_ARTS_ARR(
#{ar_dt, mode=IN, jdbcType=VARCHAR} #{ar_dt, mode=IN, jdbcType=VARCHAR}
,#{ret_minDt, mode=OUT, jdbcType=VARCHAR} ,#{ret_minDt, mode=OUT, jdbcType=VARCHAR}
,#{ret_procCnt, mode=OUT, jdbcType=INTEGER} ,#{ret_procCnt, mode=OUT, jdbcType=INTEGER}
@ -34,7 +34,7 @@
<select id="callProcArtsDep" parameterType="hashmap" statementType="CALLABLE" resultType="hashmap"> <select id="callProcArtsDep" parameterType="hashmap" statementType="CALLABLE" resultType="hashmap">
<![CDATA[ <![CDATA[
call PROC_EAI_INTRFC_ARTS_DEP_NEW( call PROC_EAI_INTRFC_ARTS_DEP(
#{ar_dt, mode=IN, jdbcType=VARCHAR} #{ar_dt, mode=IN, jdbcType=VARCHAR}
,#{ret_minDt, mode=OUT, jdbcType=VARCHAR} ,#{ret_minDt, mode=OUT, jdbcType=VARCHAR}
,#{ret_procCnt, mode=OUT, jdbcType=INTEGER} ,#{ret_procCnt, mode=OUT, jdbcType=INTEGER}
@ -44,7 +44,7 @@
<select id="callProcAcdmArr" parameterType="hashmap" statementType="CALLABLE" resultType="hashmap"> <select id="callProcAcdmArr" parameterType="hashmap" statementType="CALLABLE" resultType="hashmap">
<![CDATA[ <![CDATA[
call PROC_EAI_INTRFC_ACDM_ARR_NEW( call PROC_EAI_INTRFC_ACDM_ARR(
#{ar_dt, mode=IN, jdbcType=VARCHAR} #{ar_dt, mode=IN, jdbcType=VARCHAR}
,#{ret_minDt, mode=OUT, jdbcType=VARCHAR} ,#{ret_minDt, mode=OUT, jdbcType=VARCHAR}
,#{ret_procCnt, mode=OUT, jdbcType=INTEGER} ,#{ret_procCnt, mode=OUT, jdbcType=INTEGER}
@ -54,7 +54,7 @@
<select id="callProcAcdmDep" parameterType="hashmap" statementType="CALLABLE" resultType="hashmap"> <select id="callProcAcdmDep" parameterType="hashmap" statementType="CALLABLE" resultType="hashmap">
<![CDATA[ <![CDATA[
call PROC_EAI_INTRFC_ACDM_DEP_NEW( call PROC_EAI_INTRFC_ACDM_DEP(
#{ar_dt, mode=IN, jdbcType=VARCHAR} #{ar_dt, mode=IN, jdbcType=VARCHAR}
,#{ret_minDt, mode=OUT, jdbcType=VARCHAR} ,#{ret_minDt, mode=OUT, jdbcType=VARCHAR}
,#{ret_procCnt, mode=OUT, jdbcType=INTEGER} ,#{ret_procCnt, mode=OUT, jdbcType=INTEGER}
@ -64,7 +64,7 @@
<select id="callProcGam" parameterType="hashmap" statementType="CALLABLE" resultType="hashmap"> <select id="callProcGam" parameterType="hashmap" statementType="CALLABLE" resultType="hashmap">
<![CDATA[ <![CDATA[
call PROC_EAI_INTRFC_GAM_NEW( call PROC_EAI_INTRFC_GAM(
#{ar_dt, mode=IN, jdbcType=VARCHAR} #{ar_dt, mode=IN, jdbcType=VARCHAR}
,#{ret_minDt, mode=OUT, jdbcType=VARCHAR} ,#{ret_minDt, mode=OUT, jdbcType=VARCHAR}
,#{ret_procCnt, mode=OUT, jdbcType=INTEGER} ,#{ret_procCnt, mode=OUT, jdbcType=INTEGER}
@ -75,12 +75,16 @@
<select id="callProcAll" parameterType="hashmap" statementType="CALLABLE" resultType="hashmap"> <select id="callProcAll" parameterType="hashmap" statementType="CALLABLE" resultType="hashmap">
<![CDATA[ <![CDATA[
call PROC_EAI_INTRFC_ALL( call PROC_EAI_INTRFC_ALL(
#{ret_minDt, mode=OUT, jdbcType=VARCHAR} #{ret_msg, mode=OUT, jdbcType=VARCHAR}
,#{ret_arts_arr_cnt, mode=OUT, jdbcType=INTEGER} )
,#{ret_arts_dep_cnt, mode=OUT, jdbcType=INTEGER} ]]>
,#{ret_acdm_arr_cnt, mode=OUT, jdbcType=INTEGER} </select>
,#{ret_acdm_dep_cnt, mode=OUT, jdbcType=INTEGER}
,#{ret_gam_cnt, mode=OUT, jdbcType=INTEGER} <select id="callProcOldDataDelete" parameterType="hashmap" statementType="CALLABLE" resultType="hashmap">
<![CDATA[
call PROC_EAI_INTRFC_DATA_DELETE(
#{ar_days, mode=IN, jdbcType=INTEGER}
,#{ret_proc_msg, mode=OUT, jdbcType=VARCHAR}
) )
]]> ]]>
</select> </select>