main
MonHun 2024-02-11 22:12:10 +09:00
commit d63e4d0c7e
26 changed files with 1388 additions and 0 deletions

4
README.md 100644
View File

@ -0,0 +1,4 @@
### Spring Boot Starter + Mybatis + Tibero 연동
#### EAI데이터 수신 확인후 UEAI의 프로시져 콜

Binary file not shown.

Binary file not shown.

Binary file not shown.

81
pom.xml 100644
View File

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.8</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>kr.gmtc.gw</groupId>
<artifactId>eyegw</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>EyeGW_EaiIf</name>
<description>Spring Boot Mybatis + Tibero</description>
<repositories>
<repository>
<id>local-repository</id>
<name>local-repository</name>
<url>file:${basedir}/lib</url>
</repository>
</repositories>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>kr.gmt.so</groupId>
<artifactId>state-spring-boot-starter</artifactId>
<version>1.0.3</version>
<scope>system</scope>
<systemPath>${basedir}/lib/state-spring-boot-starter-1.0.3.jar</systemPath>
</dependency>
<dependency>
<groupId>com.tmax.tibero</groupId>
<artifactId>tibero-jdbc</artifactId>
<version>7</version>
<scope>system</scope>
<systemPath>${basedir}/lib/tibero-jdbc-7.0.0.jar</systemPath>
</dependency>
<dependency>
<groupId>ipworks.local</groupId>
<artifactId>ipworks-local-1.0.0</artifactId>
<scope>system</scope>
<version>1.0.0</version>
<systemPath>${basedir}/lib/ipworks-local-1.0.0.jar</systemPath>
</dependency>
</dependencies>
<build>
<finalName>EyeGW_EaiIf</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,116 @@
package kr.gmtc.gw.comp.thread;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import kr.gmtc.gw.comp.thread.handler.CustomThreadOnTerminate;
import kr.gmtc.gw.comp.thread.handler.CustomThreadWork;
public class CustomThread extends Thread{
/* 대기시간 없음 */
public static final long NO_SLEEP = 0;
/* 1밀리 초 */
public static final long SLEEP_MILLI_SEC = 1;
/* 1초 */
public static final long SLEEP_SECOND = 1000;
/* 30초 */
public static final long SLEEP_HALF_MINIUTE = 30000;
/* 1분 */
public static final long SLEEP_MINIUTE = 60000;
public final String controllClassName;
public final long repeatMiliSec;
public final CustomThreadWork definedWork;
public final CustomThreadOnTerminate definedTerminate;
public final Logger logger;
private boolean running;
/**
* .<br>
* {@link Thread#sleep(long)} .<br>
* sleep <br>
* {@link #gracefulStop()}
* @param threadName
* @param controllClass , this
* @param repeatMiliSec Sleep ( ), 0
* @param definedWork
* @param definedTerminate
* @param autoStart
*/
public CustomThread(String threadName, Object controllClass, long repeatMiliSec,
CustomThreadWork definedWork, CustomThreadOnTerminate definedTerminate, boolean autoStart) {
if (definedWork == null) {
throw new IllegalArgumentException("[CustomThread] - definedWork is null.");
}
this.definedWork = definedWork;
this.definedTerminate = definedTerminate;
this.controllClassName = controllClass == null ? "" : controllClass.getClass().getSimpleName();
this.repeatMiliSec = repeatMiliSec > 0 ? repeatMiliSec : 0;
this.logger = LoggerFactory.getLogger(CustomThread.class);
this.running = false;
setName(threadName);
setDaemon(true);
if (autoStart) {
this.start();
}
}
@Override
public void run() {
logger.info("[CustomThread-"+getName()+"] Started.");
while ( this.running && !this.isInterrupted()) {
try {
try {
this.definedWork.work();
} finally {
if (this.repeatMiliSec > 0) {
Thread.sleep(this.repeatMiliSec);
}
}
} catch(InterruptedException e) { // 인터럽트 수신시 종료
logger.error("[CustomThread-"+getName()+"] Interrupted. "+ e.toString());
Thread.currentThread().interrupt();
break;
} catch(Exception e) { // 처리되지 않은 예외 로깅, 예외에 의한 무한루프에 주의
logger.error("[CustomThread-"+getName()+"] " + e.toString() + ":" + e.getStackTrace()[0] );
}
}
if(this.definedTerminate != null) {
this.definedTerminate.onTerminate();
}
logger.error("[CustomThread-"+ getName()+"] Stoped.");
}
@Override
public String toString() {
return "CustomThread [controllClass=" + this.controllClassName + ", threadName=" + getName() +
", runnig=" + this.running + ", alive=" + isAlive()+ ", repeatMiliSec=" + this.repeatMiliSec +
", definedTerminate=" + (this.definedTerminate == null ? "no" : "yes") + "]";
}
@Override
public synchronized void start() {
this.running = true;
super.start();
}
/**
* , .
*/
public void gracefulStop() {
this.running = false;
}
}

View File

@ -0,0 +1,6 @@
package kr.gmtc.gw.comp.thread.handler;
@FunctionalInterface
public interface CustomThreadOnTerminate {
public void onTerminate();
}

View File

@ -0,0 +1,6 @@
package kr.gmtc.gw.comp.thread.handler;
@FunctionalInterface
public interface CustomThreadWork {
public void work() throws Exception;
}

View File

@ -0,0 +1,13 @@
package kr.gmtc.gw.eyegw;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class EyeGWApplication {
public static void main(String[] args) {
SpringApplication.run(EyeGWApplication.class, args);
}
}

View File

@ -0,0 +1,54 @@
package kr.gmtc.gw.eyegw.config;
import javax.sql.DataSource;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
@Configuration
@MapperScan(value = "kr.gmtc.gw.eyegw.db1", sqlSessionFactoryRef = "factory")
public class DataSourceConfigDB1 {
@Primary
@Bean(name = "datasource")
@ConfigurationProperties(prefix = "database.db1.datasource")
public DataSource dataSource() {
return DataSourceBuilder.create().build();
}
@Primary
@Bean(name = "factory")
public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
SqlSessionFactoryBean sqlSessionFactory = new SqlSessionFactoryBean();
sqlSessionFactory.setDataSource(dataSource);
Resource[] res = new PathMatchingResourcePatternResolver().getResources("classpath:mapper/DB1/*.xml");
sqlSessionFactory.setMapperLocations(res);
return sqlSessionFactory.getObject();
}
@Primary
@Bean(name="SqlSessionTemplate")
public SqlSessionTemplate sqlSessionTemplate(SqlSessionFactory sqlSessionFactory) throws Exception{
return new SqlSessionTemplate(sqlSessionFactory);
}
@Primary
@Bean
public DataSourceTransactionManager ATransactionManager(DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
}

View File

@ -0,0 +1,50 @@
package kr.gmtc.gw.eyegw.config;
import javax.sql.DataSource;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
@Configuration
@MapperScan(value = "kr.gmtc.gw.eyegw.db2", sqlSessionFactoryRef = "factory2")
public class DataSourceConfigDB2 {
@Bean(name = "datasource2")
@ConfigurationProperties(prefix = "database.db2.datasource")
public DataSource dataSource2() {
return DataSourceBuilder.create().build();
}
@Bean(name = "factory2")
public SqlSessionFactory sqlSessionFactory2(@Qualifier("datasource2") DataSource dataSource) throws Exception {
SqlSessionFactoryBean sqlSessionFactory = new SqlSessionFactoryBean();
sqlSessionFactory.setDataSource(dataSource);
Resource[] res = new PathMatchingResourcePatternResolver().getResources("classpath:mapper/DB2/*.xml");
sqlSessionFactory.setMapperLocations(res);
return sqlSessionFactory.getObject();
}
@Bean(name="SqlSessionTemplate2")
public SqlSessionTemplate sqlSessionTemplate2(SqlSessionFactory sqlSessionFactory) throws Exception{
return new SqlSessionTemplate(sqlSessionFactory);
}
// DataSource 에서 Transaction 관리를 위한 Manager 클래스 등록
@Bean
public DataSourceTransactionManager BTransactionManager(@Qualifier("datasource2") DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
}

View File

@ -0,0 +1,23 @@
package kr.gmtc.gw.eyegw.config;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration("ServiceConfig")
public class ServiceConfig {
@Bean(name = "statusReportQ")
public HashMap<Integer, Queue<String>> statusReportQ(){
return new LinkedHashMap<Integer, Queue<String>>();
}
@Bean(name = "serviceRunnig")
public boolean serviceRunnig(){
return false;
}
}

View File

@ -0,0 +1,383 @@
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;
@Component("controller")
public class MainController 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 void systemError() {
// // logger.writeLevelLog("-- FAIL TO STARTUP --", LogLevelType.LOG_ERROR, "AllLog");
// System.exit(1);
// }
/**
* <br>
* Spring Bean , logger
*/
public MainController(EaiProcService eaiProcService, EaiIfCheckService eaiIfCheckService) {
this.eaiProcService = eaiProcService;
this.eaiProcService = eaiProcService;
this.eaiIfCheckService = eaiIfCheckService;
}
/**
* (1)<br>
*
*/
@Order(0)
@EventListener(ApplicationReadyEvent.class)
public void initialize() {
try {
// 업무 스래드(프로시저 호출)
listCustomThreads = new ArrayList<CustomThread>();
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_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_Gam", this, procCallInterval, this::callThread_Gam, 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);
} 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();
eaiProcService.callProcArtsArr();
Duration diff = Duration.between(dt_before, LocalDateTime.now());
logger.info("callProcArtsArr Call " + sCnt + "건 " + diff.toMillis() + "msec");
}
// 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();
eaiProcService.callProcArtsDep();
Duration diff = Duration.between(dt_before, LocalDateTime.now());
logger.info("callProcArtsDep Call " + sCnt + "건 " + diff.toMillis() + "msec");
}
// 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();
eaiProcService.callProcAcdmArr();
Duration diff = Duration.between(dt_before, LocalDateTime.now());
logger.info("callProcAcdmArr Call " + sCnt + "건 " + diff.toMillis() + "msec");
}
// 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();
eaiProcService.callProcAcdmDep();
Duration diff = Duration.between(dt_before, LocalDateTime.now());
logger.info("callProcAcdmDep Call " + sCnt + "건 " + diff.toMillis() + "msec");
}
// 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();
eaiProcService.callProcGam();
Duration diff = Duration.between(dt_before, LocalDateTime.now());
logger.info("callProcGam Call " + sCnt + "건 " + diff.toMillis() + "msec");
}
// 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();
eaiProcService.callProcAmos();
Duration diff = Duration.between(dt_before, LocalDateTime.now());
logger.info("callProcAmos Call " + sCnt + "건 " + diff.toMillis() + "msec");
}
// 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();
eaiProcService.callProcNotam();
Duration diff = Duration.between(dt_before, LocalDateTime.now());
logger.info("callProcNotam Call " + sCnt + "건 " + diff.toMillis() + "msec");
}
// Thread.sleep(3000);
}
}

View File

@ -0,0 +1,91 @@
package kr.gmtc.gw.eyegw.controller;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component("systemCheckManager")
public class SystemCheckManager {
private final Logger logger = LoggerFactory.getLogger("scLogger");
private ScheduledExecutorService scheduler;
@Value("${sc.schduler.initialDelay:3}")
private int initialDelay;
@Value("${sc.schduler.fixedDelay:1}")
private int fixedDelay;
private final int REST_CNT = 10;
private int ErrorCnt = REST_CNT;
private String ErrorMsg = "";
private int WarnCnt = REST_CNT;
private String WarnMsg = "";
@PostConstruct
private void initialize() {
CreateSchedules();
}
private void CreateSchedules() {
scheduler = Executors.newScheduledThreadPool(1);
Runnable ReconnTask = () -> {
if(ErrorCnt < REST_CNT) {
ErrorCnt++;
logger.error("ERROR|" + ErrorMsg);
}
else if(WarnCnt < REST_CNT) {
WarnCnt++;
logger.warn("WARN|" + WarnMsg);
}
else {
logger.info("NORAML|Heartbeat");
}
};
scheduler.scheduleAtFixedRate(ReconnTask, initialDelay, fixedDelay, TimeUnit.SECONDS);
}
public void error (String Msg) {
logger.error("ERROR|" + Msg);
ErrorCnt = 0;
ErrorMsg = Msg;
}
public void warn(String Msg) {
if(ErrorCnt >= REST_CNT)
logger.warn("WARN|" + Msg);
WarnCnt = 5;
WarnMsg = Msg;
}
public void info (String Msg) {
logger.info("NORMAL|" + Msg);
}
@PreDestroy
public void finalize() {
try {
scheduler.shutdown();
scheduler.awaitTermination(100, TimeUnit.MILLISECONDS);
} catch (Exception e) {
logger.error("", e);
}
}
}

View File

@ -0,0 +1,19 @@
package kr.gmtc.gw.eyegw.db1;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import java.util.HashMap;
import java.util.List;
@Mapper
//@Repository
public interface EaiIfCheckMapper {
List<HashMap<String, Object>> selectAarsArr();
List<HashMap<String, Object>> selectAarsDep();
List<HashMap<String, Object>> selectAcdmArr();
List<HashMap<String, Object>> selectAcdmDep();
List<HashMap<String, Object>> selectGAM();
List<HashMap<String, Object>> selectAMOS();
List<HashMap<String, Object>> selectNOTAM();
}

View File

@ -0,0 +1,43 @@
package kr.gmtc.gw.eyegw.db1;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
@Service
public class EaiIfCheckService {
private EaiIfCheckMapper checkMapper;
public EaiIfCheckService(EaiIfCheckMapper checkMapper){
this.checkMapper = checkMapper;
}
public List<HashMap<String, Object>> getArtsArr() {
return checkMapper.selectAarsArr();
}
public List<HashMap<String, Object>> getArtsDep() {
return checkMapper.selectAarsDep();
}
public List<HashMap<String, Object>> getAcdmArr() {
return checkMapper.selectAcdmArr();
}
public List<HashMap<String, Object>> getAcdmDep() {
return checkMapper.selectAcdmDep();
}
public List<HashMap<String, Object>> getGam() {
return checkMapper.selectGAM();
}
public List<HashMap<String, Object>> getAmos() {
return checkMapper.selectAMOS();
}
public List<HashMap<String, Object>> getNotam() {
return checkMapper.selectNOTAM();
}
}

View File

@ -0,0 +1,16 @@
package kr.gmtc.gw.eyegw.db1;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface EaiProcMapper {
void callProcArtsArr();
void callProcArtsDep();
void callProcAcdmArr();
void callProcAcdmDep();
void callProcGam();
void callProcAmos();
void callProcNotam();
}

View File

@ -0,0 +1,55 @@
package kr.gmtc.gw.eyegw.db1;
import org.springframework.stereotype.Service;
@Service
public class EaiProcService {
private EaiProcMapper ueaiProcMapper;
public EaiProcService(EaiProcMapper ueaiProcMapper){
this.ueaiProcMapper = ueaiProcMapper;
}
public void callProcArtsArr() {
ueaiProcMapper.callProcArtsArr();
}
public void callProcArtsDep() {
ueaiProcMapper.callProcArtsDep();
}
public void callProcAcdmArr() {
ueaiProcMapper.callProcAcdmArr();
}
public void callProcAcdmDep() {
ueaiProcMapper.callProcAcdmDep();
}
public void callProcGam() {
ueaiProcMapper.callProcGam();
}
public void callProcAmos() {
ueaiProcMapper.callProcAmos();
}
public void callProcNotam() {
ueaiProcMapper.callProcNotam();
}
}

View File

@ -0,0 +1,16 @@
package kr.gmtc.gw.eyegw.db2;
import java.util.HashMap;
import java.util.Map;
//@Mapper
//@Repository
public interface UicProcMapper {
//List<HashMap<String, Object>> callProc();
HashMap<String, String> callProcTest(Map map);
// void callProcArtsArr();
// void callProcArtsDep();
// void callProcAcdmArr();
// void callProcAcdmDep();
// void callProcGam();
}

View File

@ -0,0 +1,62 @@
package kr.gmtc.gw.eyegw.db2;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
@Service
public class UicProcService {
private UicProcMapper uICProcMapper;
public UicProcService(UicProcMapper uICProcMapper){
this.uICProcMapper = uICProcMapper;
}
public String callProcTest(String sParam1, String sParam2, String iParam3) {
Map paramMap = new HashMap<String, Object>();
String sRetValue = null;
paramMap.put("ar_param1", String.valueOf(sParam1));
paramMap.put("ar_param2", String.valueOf(sParam2));
paramMap.put("ar_param3", String.valueOf(iParam3));
uICProcMapper.callProcTest(paramMap);
sRetValue = (String) paramMap.get("ret_value");
return sRetValue;
}
// public void callProcArtsArr() {
// uICProcMapper.callProcArtsArr();
// }
// public void callProcArtsDep() {
// uICProcMapper.callProcArtsDep();
// }
// public void callProcAcdmArr() {
// uICProcMapper.callProcAcdmArr();
// }
// public void callProcAcdmDep() {
// uICProcMapper.callProcAcdmDep();
// }
// public void callProcGam() {
// uICProcMapper.callProcGam();
// }
}

View File

@ -0,0 +1,69 @@
spring:
profiles:
active: default
group:
default:
- winTest
---
spring:
config:
activate:
on-profile: default
database:
db1:
datasource:
driver-class-name: com.tmax.tibero.jdbc.TbDriver
jdbcUrl: jdbc:tibero:thin:@10.200.31.1:8629:sacp
username: ueai
password: ueai
db2:
datasource:
driver-class-name: com.tmax.tibero.jdbc.TbDriver
jdbcUrl: jdbc:tibero:thin:@10.200.31.1:8629:sacp
username: uic
password: uic
state:
# 공통코드 CT001의 코드 6자리
id: LK0302 # IFToDB
# 1:Primary, 2:Secondary
type: Primary
---
spring:
config:
activate:
on-profile: real
server:
port: 18089
# root: /home/gmt/app/...
settings:
interval:
proc:
call: 10000
chk:
thread: 30000
---
spring:
config:
activate:
on-profile: winTest
server:
port: 18089
settings:
interval:
proc:
call: 10000
chk:
thread: 30000
# root: D:\Workspace\...

View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="30 seconds">
<property name="PATH_SEPARATOR" value="/"/>
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
<!-- 로그 파일이 저장될 경로 -->
<property name="LOG_PATH" value=".${PATH_SEPARATOR}logs"/>
<!-- 로그 파일 이름 -->
<property name="LOG_FILE_NAME" value="trace"/>
<!-- 로그 출력 패턴 -->
<property name="LOG_PATTERN" value="[%d{yyyy-MM-dd HH:mm:ss.SSS}] %highlight([%.-1level]) %clr([%-40.40(%class{0}.%method)]){cyan} %msg%n"/>
<property name="FILE_LOG_PATTERN" value="[%d{yyyy-MM-dd HH:mm:ss.SSS}][%.-1level][%-40.40(%class{0}.%method)] %msg%n"/>
<!-- 로그 레벨 -->
<!--
1) ERROR : 오류 메시지 표시
2) WARN : 경고성 메시지 표시
3) INFO : 정보성 메시지 표시
4) DEBUG : 디버깅하기 위한 메시지 표시
5) TRACE : Debug보다 훨씬 상세한 메시지 표시
-->
<property name="LOG_LEVEL" value="INFO"/>
<!-- CONSOLE에 로그 출력 세팅 -->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>${LOG_PATTERN}</pattern>
</layout>
</appender>
<!-- File에 로그 출력 세팅 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 로그파일은 Info부터 저장한다!! -->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<!-- <level>INFO</level> -->
<level>INFO</level>
</filter>
<!-- 파일 경로 설정 -->
<file>${LOG_PATH}${PATH_SEPARATOR}${LOG_FILE_NAME}.log</file>
<!-- 출력패턴 설정-->
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>${FILE_LOG_PATTERN}</pattern>
</layout>
<!-- Rolling 정책 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- .gz,.zip 등을 넣으면 자동 일자별 로그파일 압축 -->
<fileNamePattern>${LOG_PATH}${PATH_SEPARATOR}%d{yyyyMM,aux}${PATH_SEPARATOR}%d{yyyyMMdd}.log</fileNamePattern>
<!-- 로그파일 최대 보관주기, fileNamePattern 에 따라 일별, 월별, 년별-->
<maxHistory>10</maxHistory>
<!-- 아카이브 최대 용량 maxHistory 이후에 적용됨 -->
<totalSizeCap>100mb</totalSizeCap>
<!-- 시작시 정책 적용 여부 -->
<CleanHistoryOnStart>true</CleanHistoryOnStart>
</rollingPolicy>
</appender>
<!-- 비동기 파일(FILE)
includeCallerData: fasle, 비동기 로깅에서도 Method Name 및 Line Number 등 위치 정보를 출력하게 해주는 옵션
queueSize: 기본값은 256, Log4j2와 동일하게 1024로 설정
neverBlock: false(기본값)면 로그 발생시 Queue에 넣을 공간이 없으면 빈 공간이 생길 때 까지 블락킹 상태로 기다리며, 로그를 유실하지 않는다.
discardingThreshold: Queue에 남은 용량이 {해당 설정값 n}%이하가 되면, WARN 미만 로그가 유실되기 시작한다.
- 기본 값은 20이며, Queue 남은 용량이 20%이하가 되면 로그 유실이 발생한다.
- 0으로 세팅하면 Queue에 쌓인 로그를 드랍하지 않는다.
-->
<appender name="FILE-ASYNC" class="ch.qos.logback.classic.AsyncAppender">
<appender-ref ref="FILE" />
<includeCallerData>false</includeCallerData>
<discardingThreshold>0</discardingThreshold>
<queueSize>1024</queueSize>
<neverBlock>true</neverBlock>
</appender>
<!-- SystemCheck 로그 출력 세팅 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -->
<appender name="FILE_SC" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>systemcheck${file.separator}sc.log</file>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS}|%msg%n</pattern>
</layout>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>systemcheck${file.separator}%d{yyyyMM,aux}${file.separator}%d{yyyyMMdd}.log</fileNamePattern>
<maxHistory>10</maxHistory>
<totalSizeCap>500mb</totalSizeCap>
<CleanHistoryOnStart>true</CleanHistoryOnStart>
</rollingPolicy>
</appender>
<logger name="scLogger">
<!-- <appender-ref ref="CONSOLE"/> -->
<appender-ref ref="FILE_SC"/>
</logger>
<!-- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -->
<!-- 로그 전역 세팅 -->
<root level="${LOG_LEVEL}">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</root>
<!-- <logger name="kr.gmtc.gw" level="INFO">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</logger>
<logger name="kr.gmt.so" level="INFO">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</logger> -->
<!-- <logger name="kr.gmtc.comp.status" level="TRACE">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</logger> -->
</configuration>

View File

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!--로그 파일 저장 위치-->
<property name="LOGS_PATH" value="./logs"/>
<!-- 프로파일 지정 : application-dev.properties 파일 생성, -Dspring.profiles.active=dev 옵션으로 실행 -->
<!-- <springProfile name="dev"> -->
<!-- <property name="LOGS_PATH" value="./logs/dev"/> -->
<!-- </springProfile> -->
<property name="LOG_PATTERN" value="%magenta([%d{yyyy-MM-dd HH:mm:ss.SSS}]) %highlight(%-5level) %cyan([%15.15thread]) %boldYellow(%-40.40logger{37}) - %msg%n" />
<property name="FILE_LOG_PATTERN" value="[%d{yyyy-MM-dd HH:mm:ss.SSS}] %-5level [%15.15thread] %-40.40logger{37} - %msg%n" />
<!-- 실제 로그를 출력 방법 (함수) -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<appender name="DAILY_ROLLING_FILE_APPENDER" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOGS_PATH}/logback.log</file>
<encoder>
<pattern>${FILE_LOG_PATTERN}</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${LOGS_PATH}/logback.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 100MB -->
<maxFileSize>5MB</maxFileSize>
<!-- kb, mb, gb -->
</timeBasedFileNamingAndTriggeringPolicy>
<maxHistory>30</maxHistory>
</rollingPolicy>
</appender>
<!-- 출력 방식 정의, (패키지 단위 지정, appender 지정) -->
<!-- level=OFF : log 안남김 -->
<logger name="kr.gmtc.eyegw" level="INFO">
<appender-ref ref="DAILY_ROLLING_FILE_APPENDER" />
</logger>
<!-- 전체 logback 에 대한 default 설정 -->
<root level="INFO">
<appender-ref ref="STDOUT" />
<appender-ref ref="DAILY_ROLLING_FILE_APPENDER" />
</root>
</configuration>

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="kr.gmtc.gw.eyegw.db1.EaiIfCheckMapper">
<select id="selectAarsArr" resultType="hashMap">
select count(*) as data_cnt from ueai.EAI_ELECSTRIPARRARTS_RCV where deal_stat = 'S';
</select>
<select id="selectAarsDep" resultType="hashMap">
select count(*) as data_cnt from ueai.EAI_ELECSTRIPDEPARTS_RCV where deal_stat = 'S';
</select>
<select id="selectAcdmArr" resultType="hashMap">
select count(*) as data_cnt from ueai.EAI_FLTACDMMLSTNARR_RCV where deal_stat = 'S';
</select>
<select id="selectAcdmDep" resultType="hashMap">
select count(*) as data_cnt from ueai.EAI_FLTACDMMLSTNDEP_RCV where deal_stat = 'S';
</select>
<select id="selectGAM" resultType="hashMap">
select count(*) as data_cnt from ueai.EAI_GRDACMVT_RCV where deal_stat = 'S';
</select>
<select id="selectAMOS" resultType="hashMap">
select count(*) as data_cnt from ueai.EAI_AWOS_RCV where deal_stat = 'S' and dateandtime >= '20231001000000.000';
</select>
<select id="selectNOTAM" resultType="hashMap">
select count(*) as data_cnt from UEAI.EAI_AFTNFLTINFO_RCV where deal_stat = 'S';
</select>
</mapper>

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="kr.gmtc.gw.eyegw.db1.EaiProcMapper">
<select id="callProcAmos" parameterType="hashmap" statementType="CALLABLE" resultType="hashmap">
<![CDATA[
call PROC_EAI_INTRFC_AMOS()
]]>
</select>
<select id="callProcNotam" parameterType="hashmap" statementType="CALLABLE" resultType="hashmap">
<![CDATA[
call PROC_EAI_INTRFC_AFTNFLTINFO_RCV()
]]>
</select>
<select id="callProcArtsArr" parameterType="hashmap" statementType="CALLABLE" resultType="hashmap">
<![CDATA[
call PROC_EAI_INTRFC_ARTS_ARR()
]]>
</select>
<select id="callProcArtsDep" parameterType="hashmap" statementType="CALLABLE" resultType="hashmap">
<![CDATA[
call PROC_EAI_INTRFC_ARTS_DEP()
]]>
</select>
<select id="callProcAcdmArr" parameterType="hashmap" statementType="CALLABLE" resultType="hashmap">
<![CDATA[
call PROC_EAI_INTRFC_ACDM_ARR()
]]>
</select>
<select id="callProcAcdmDep" parameterType="hashmap" statementType="CALLABLE" resultType="hashmap">
<![CDATA[
call PROC_EAI_INTRFC_ACDM_DEP()
]]>
</select>
<select id="callProcGam" parameterType="hashmap" statementType="CALLABLE" resultType="hashmap">
<![CDATA[
call PROC_EAI_INTRFC_GAM()
]]>
</select>
</mapper>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="kr.gmtc.gw.eyegw.db2.UicProcMapper">
<select id="callProcTest" parameterType="hashmap" statementType="CALLABLE" resultType="hashmap">
<![CDATA[
call PROC_Mybatis_Call_Test(
#{ar_param1, mode=IN, jdbcType=VARCHAR},
#{ar_param2, mode=IN, jdbcType=VARCHAR},
#{ar_param3, mode=IN, jdbcType=VARCHAR},
#{ret_value, mode=OUT, jdbcType=VARCHAR}
)
]]>
</select>
</mapper>