main
MonHun 2024-04-27 17:09:57 +09:00
parent d9d9fe10af
commit b8f1d00a87
18 changed files with 404 additions and 605 deletions

View File

@ -1,22 +1,35 @@
package kr.gmtc.gw.comp.rest.vo; package kr.gmtc.gw.comp.rest.vo;
import kr.gmtc.gw.standstatus.vo.StandSttusVO; import kr.gmtc.gw.standstatus.vo.AiAnalyzeStandSttus;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@Getter @Getter
@Setter @Setter
public class RestServiceData extends StandSttusVO { public class RestServiceData {
private String cctv_id;
private String stand_no;
private String clsgn;
private String schdul_id;
private String ac_reg_no;
private String aircraft_sttus_ty;
private AiAnalyzeStandSttus aiStandSttus;
private String cctv_ip; private String cctv_ip;
private String clsgn;
RestServiceData(){} RestServiceData(){
this.aiStandSttus = new AiAnalyzeStandSttus();
}
public RestServiceData(String stand_no, String cctv_id){ public RestServiceData(String stand_no, String cctv_id){
this.setStand_no(stand_no); this.setStand_no(stand_no);
this.setCctv_id(cctv_id); this.setCctv_id(cctv_id);
this.setStand_sttus_ty("0"); this.setAircraft_sttus_ty("0");
this.aiStandSttus = new AiAnalyzeStandSttus();
} }

View File

@ -104,6 +104,12 @@ public class CustomThread extends Thread{
super.start(); super.start();
} }
public synchronized void start(int priority) {
setPriority(priority);
this.start();
}
/** /**
* , . * , .
*/ */

View File

@ -6,67 +6,78 @@ import java.util.Date;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Map; import java.util.Map;
import java.util.Queue; import java.util.Queue;
import java.util.concurrent.LinkedBlockingQueue;
import javax.annotation.Resource;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import kr.gmtc.gw.comp.rest.vo.RestServiceData; import kr.gmtc.gw.comp.rest.vo.RestServiceData;
import kr.gmtc.gw.comp.thread.CustomThread; import kr.gmtc.gw.comp.thread.CustomThread;
import kr.gmtc.gw.standstatus.config.QueueManageBean;
import kr.gmtc.gw.standstatus.database.datasource2.IcSelectDao; import kr.gmtc.gw.standstatus.database.datasource2.IcSelectDao;
import kr.gmtc.gw.standstatus.database.dto.DataLoadDTO; import kr.gmtc.gw.standstatus.database.dto.DataLoadDTO;
import kr.gmtc.gw.standstatus.database.dto.DataLoadHashMap; import kr.gmtc.gw.standstatus.database.dto.DataLoadHashMap;
import kr.gmtc.gw.standstatus.service.DataLoadService;
import kr.gmtc.gw.standstatus.vo.AiAnalyzeStandSttus; import kr.gmtc.gw.standstatus.vo.AiAnalyzeStandSttus;
import kr.gmtc.gw.standstatus.vo.AlarmMsgVO; import kr.gmtc.gw.standstatus.vo.AlarmMsgVO;
import kr.gmtc.gw.standstatus.vo.AlarmTargetVO; import kr.gmtc.gw.standstatus.vo.AlarmTargetVO;
import kr.gmtc.gw.standstatus.vo.AlarmVO; import kr.gmtc.gw.standstatus.vo.AlarmVO;
import kr.gmtc.gw.standstatus.vo.AreaVO; import kr.gmtc.gw.standstatus.vo.AreaVO;
@Component // @Component
@DependsOn(value = {"serviceList"}) // @DependsOn(value = {"serviceList"})
public class AnalysisAlarmStatus { public class AnalysisAlarmStatus {
private Logger logger; private Logger logger;
Queue<AlarmMsgVO> alamMsgQ;
LinkedList<AlarmMsgVO> alamEndChkList;
@Autowired
private IcSelectDao icSelectDao;
private final ObjectMapper objMapper = new ObjectMapper(); private final ObjectMapper objMapper = new ObjectMapper();
@Resource(name = "dataLoadDTO")
private DataLoadDTO dto; private DataLoadDTO dto;
private QueueManageBean queMB;
@Resource(name = "serviceList") // Queue<AlarmMsgVO> qAlamMsg;
private Map<Integer, LinkedList<RestServiceData>> serviceList; // LinkedList<AlarmMsgVO> alamEndChkList;
private LinkedBlockingQueue<AlarmMsgVO> qAlamMsg;
private LinkedList<RestServiceData> serviceList;
private LinkedList<AlarmMsgVO> alamEndChkList;
private LinkedList<RestServiceData> standSttusList; private LinkedList<RestServiceData> standSttusList;
private DataLoadService ds;
// private Map<Integer, LinkedList<RestServiceData>> serviceList;
private CustomThread cThread_Analyze_Alarm_Start; private CustomThread cThread_Analyze_Alarm_Start;
private CustomThread cThread_Analyze_Alarm_End; private CustomThread cThread_Analyze_Alarm_End;
public AnalysisAlarmStatus(Queue<AlarmMsgVO> alamMsgQ, LinkedList<AlarmMsgVO> alamEndChkList){
public AnalysisAlarmStatus(){}
public AnalysisAlarmStatus(DataLoadDTO dataLoadDTO, QueueManageBean queMB, DataLoadService ds){
logger = LoggerFactory.getLogger(this.getClass()); logger = LoggerFactory.getLogger(this.getClass());
this.alamMsgQ = alamMsgQ; this.dto = dataLoadDTO;
this.alamEndChkList = alamEndChkList; this.queMB = queMB;
this.qAlamMsg = queMB.getQAlamMsg();
this.serviceList = queMB.getServiceList();
this.ds = ds;
alamEndChkList = new LinkedList<AlarmMsgVO>();
cThread_Analyze_Alarm_Start = new CustomThread("analysisAlarmStart", this, CustomThread.NO_SLEEP, this::analysis_Stand_sttus_alarm_start, null, false); cThread_Analyze_Alarm_Start = new CustomThread("analysisAlarmStart", this, CustomThread.NO_SLEEP, this::analysis_Stand_sttus_alarm_start, null, false);
cThread_Analyze_Alarm_End = new CustomThread("analysisAlarmEnd", this, CustomThread.NO_SLEEP, this::analysis_Stand_sttus_alarm_end, null, false); cThread_Analyze_Alarm_End = new CustomThread("analysisAlarmEnd", this, CustomThread.NO_SLEEP, this::analysis_Stand_sttus_alarm_end, null, false);
start();
} }
private void start(){ public void start(){
cThread_Analyze_Alarm_Start.start(); cThread_Analyze_Alarm_Start.start();
cThread_Analyze_Alarm_End.start(); cThread_Analyze_Alarm_End.start();
@ -77,7 +88,7 @@ public class AnalysisAlarmStatus {
// 주기장 알림 상황 분석(상황시작) // 주기장 알림 상황 분석(상황시작)
public void analysis_Stand_sttus_alarm_start() throws InterruptedException{ public void analysis_Stand_sttus_alarm_start() throws InterruptedException{
if(serviceList == null || serviceList.size() == 0 || dto == null || dto.getDb_FltDep().size() == 0 ) { if(serviceList.size() == 0 || dto.getDb_FltDep().size() == 0 ) {
Thread.sleep(1000); Thread.sleep(1000);
return; return;
@ -100,7 +111,7 @@ public class AnalysisAlarmStatus {
} }
standSttusList = serviceList.get(0); standSttusList = serviceList;
for(int idx=0; idx<standSttusList.size(); idx++ ){ for(int idx=0; idx<standSttusList.size(); idx++ ){
AiAnalyzeStandSttus aiss = standSttusList.get(idx).getAiStandSttus(); AiAnalyzeStandSttus aiss = standSttusList.get(idx).getAiStandSttus();
@ -108,7 +119,7 @@ public class AnalysisAlarmStatus {
String sStandNo = standSttusList.get(idx).getStand_no(); String sStandNo = standSttusList.get(idx).getStand_no();
String sClsgn = standSttusList.get(idx).getClsgn(); String sClsgn = standSttusList.get(idx).getClsgn();
if(aiss.getPad_clear().equals("N") && standSttusList.get(idx).getStand_sttus_ty().equals("5") ){ if(aiss.getPad_clear().equals("N") && standSttusList.get(idx).getAircraft_sttus_ty().equals("5") ){
setAlarmMsg(sStandNo, sClsgn, "2", "Red-Zone내에 다른 차량 또는 사물이 있습니다."); setAlarmMsg(sStandNo, sClsgn, "2", "Red-Zone내에 다른 차량 또는 사물이 있습니다.");
@ -142,7 +153,7 @@ public class AnalysisAlarmStatus {
alarmMsg.setTrgt_id1(sClsgn); alarmMsg.setTrgt_id1(sClsgn);
alarmMsg.setAnals_msg(sAlarmMsg); alarmMsg.setAnals_msg(sAlarmMsg);
alarmMsg.setStart_end("Start"); alarmMsg.setStart_end("Start");
alamMsgQ.offer(alarmMsg); qAlamMsg.offer(alarmMsg);
} }
@ -181,7 +192,7 @@ public class AnalysisAlarmStatus {
ChkCnt++; ChkCnt++;
if(!mapDep.get("PDC_ISUE_TM").equals("")){ if(!mapDep.get("PDC_ISUE_TM").equals("")){
chkAlarm.setStart_end("End"); chkAlarm.setStart_end("End");
alamMsgQ.offer(chkAlarm); qAlamMsg.offer(chkAlarm);
alamEndChkList.remove(idx); alamEndChkList.remove(idx);
} }
@ -200,7 +211,7 @@ public class AnalysisAlarmStatus {
ChkCnt++; ChkCnt++;
if(aiss.getPad_clear().equals("Y")){ if(aiss.getPad_clear().equals("Y")){
chkAlarm.setStart_end("End"); chkAlarm.setStart_end("End");
alamMsgQ.offer(chkAlarm); qAlamMsg.offer(chkAlarm);
alamEndChkList.remove(idx); alamEndChkList.remove(idx);
} }
} }
@ -213,7 +224,7 @@ public class AnalysisAlarmStatus {
if(ChkCnt == 0){ if(ChkCnt == 0){
chkAlarm.setStart_end("End"); chkAlarm.setStart_end("End");
alamMsgQ.offer(chkAlarm); qAlamMsg.offer(chkAlarm);
alamEndChkList.remove(idx); alamEndChkList.remove(idx);
} }
@ -250,13 +261,13 @@ public class AnalysisAlarmStatus {
try { try {
for (int idx=0; idx<alamMsgQ.size();idx++){ for (int idx=0; idx<qAlamMsg.size();idx++){
AlarmMsgVO alarmMsg = alamMsgQ.poll(); AlarmMsgVO alarmMsg = qAlamMsg.poll();
AlarmVO aVo = new AlarmVO(); AlarmVO aVo = new AlarmVO();
aVo.setAnals_id(MakeAnalsId()); aVo.setAnals_id(ds.MakeAnalsId());
aVo.setAnals_dt(sdf.format(now)); aVo.setAnals_dt(sdf.format(now));
aVo.setAnals_ty(alarmMsg.getAnals_ty()); aVo.setAnals_ty(alarmMsg.getAnals_ty());
aVo.setStart_end(alarmMsg.getStart_end()); aVo.setStart_end(alarmMsg.getStart_end());
@ -296,17 +307,7 @@ public class AnalysisAlarmStatus {
} }
/*
(yyyy)+(mm)+(dd)+(hh24)+(mi)+(ss)+()+SEQ(000~999)
)20230607153520123001
*/
public String MakeAnalsId() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
Date now = new Date();
int seq = icSelectDao.getAnalsIdSeq();
String nSeq = String.format("%03d", seq);
return sdf.format(now) + nSeq;
}
} }

View File

@ -3,6 +3,7 @@ package kr.gmtc.gw.standstatus.component;
import java.time.Duration; import java.time.Duration;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedList; import java.util.LinkedList;
@ -19,6 +20,7 @@ import org.slf4j.LoggerFactory;
import kr.gmt.so.state.StateManager; import kr.gmt.so.state.StateManager;
import kr.gmtc.gw.comp.rest.vo.RestServiceData; import kr.gmtc.gw.comp.rest.vo.RestServiceData;
import kr.gmtc.gw.comp.thread.CustomThread; import kr.gmtc.gw.comp.thread.CustomThread;
import kr.gmtc.gw.standstatus.config.QueueManageBean;
import kr.gmtc.gw.standstatus.database.dto.DataLoadDTO; import kr.gmtc.gw.standstatus.database.dto.DataLoadDTO;
import kr.gmtc.gw.standstatus.database.dto.DataLoadHashMap; import kr.gmtc.gw.standstatus.database.dto.DataLoadHashMap;
import kr.gmtc.gw.standstatus.kafka.vo.AiVideoMetaData; import kr.gmtc.gw.standstatus.kafka.vo.AiVideoMetaData;
@ -29,7 +31,7 @@ public class AnalysisStandStatus {
private final Logger logger = LoggerFactory.getLogger(this.getClass()); private final Logger logger = LoggerFactory.getLogger(this.getClass());
private CustomThread cThread_Make_Map_StandSttus; private CustomThread cThread_Analyze_VideoMeta;
private CustomThread cThread_Analyze_StandSttus; private CustomThread cThread_Analyze_StandSttus;
private CustomThread cThread_Maping_CctvIDStandNo; private CustomThread cThread_Maping_CctvIDStandNo;
@ -39,41 +41,33 @@ public class AnalysisStandStatus {
LocalDateTime dt; LocalDateTime dt;
LinkedBlockingQueue<AiVideoMetaData> recvVideoQ;
private DataLoadDTO dto; private DataLoadDTO dto;
Map<Integer, LinkedList<RestServiceData>> serviceList; private QueueManageBean queMB;
private Integer scvQcount; private LinkedBlockingQueue<ArrayList<AiVideoMetaData>> qRecvVideo;
Queue<AlarmMsgVO> alamMsgQ; private LinkedList<RestServiceData> serviceList;
HashMap<String, String> testStandStsMap;
HashMap<String, String[]> testStandStsMapAI; public AnalysisStandStatus(DataLoadDTO dataLoadDTO, QueueManageBean queMB){
public AnalysisStandStatus(LinkedBlockingQueue<AiVideoMetaData> recvVideoQ, DataLoadDTO dataLoadDTO, Map<Integer,
LinkedList<RestServiceData>> serviceList, Queue<AlarmMsgVO> alamMsgQ,
HashMap<String, String> testStandStsMap,
HashMap<String, String[]> testStandStsMapAI
){
this.recvVideoQ =recvVideoQ;
this.dto = dataLoadDTO; this.dto = dataLoadDTO;
this.serviceList = serviceList; this.queMB = queMB;
this.alamMsgQ = alamMsgQ;
this.testStandStsMap = testStandStsMap;
this.testStandStsMapAI = testStandStsMapAI;
initialize(); initialize();
} }
public void initialize() { public void initialize() {
qRecvVideo = queMB.getQRecvVideo();
serviceList = queMB.getServiceList();
map_stand_sttus = new LinkedHashMap<String, RestServiceData>();
try { try {
cThread_Maping_CctvIDStandNo = new CustomThread("mapingCctvStand", this, CustomThread.NO_SLEEP, this::init_map_stand_sttus, null, false); cThread_Maping_CctvIDStandNo = new CustomThread("mapingCctvStand", this, CustomThread.NO_SLEEP, this::init_map_stand_sttus, null, false);
cThread_Make_Map_StandSttus = new CustomThread("makeMapStandSttus", this, CustomThread.NO_SLEEP, this::analysis_Ai_Video_Meta, null, false); cThread_Analyze_VideoMeta = new CustomThread("makeMapStandSttus", this, CustomThread.NO_SLEEP, this::analysis_Ai_Video_Meta, null, false);
cThread_Analyze_StandSttus = new CustomThread("analysisStandSttus", this, CustomThread.NO_SLEEP, this::analysis_Stand_Sttus, null, false); cThread_Analyze_StandSttus = new CustomThread("analysisStandSttus", this, CustomThread.NO_SLEEP, this::analysis_Stand_Sttus, null, false);
map_stand_sttus = new LinkedHashMap<String, RestServiceData>();
} catch (Exception e) { } catch (Exception e) {
logger.error("Start Fail: "+ e.toString()); logger.error("Start Fail: "+ e.toString());
} }
@ -82,10 +76,9 @@ public class AnalysisStandStatus {
public void start() { public void start() {
try { try {
cThread_Maping_CctvIDStandNo.start(); cThread_Maping_CctvIDStandNo.start(Thread.MAX_PRIORITY);
//cThread_Make_Map_StandSttus.start(); cThread_Analyze_VideoMeta.start(Thread.NORM_PRIORITY);
cThread_Analyze_StandSttus.start(); cThread_Analyze_StandSttus.start(Thread.MIN_PRIORITY);
} catch (Exception e) { } catch (Exception e) {
logger.error("Start Fail: "+ e); logger.error("Start Fail: "+ e);
@ -93,57 +86,16 @@ public class AnalysisStandStatus {
} }
////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
* Kafka AI Video Meta()
* Param : cctv List, AI Meta Data
* Return : LinkedHashMap Map_Stand_sttus
*/
private void analysis_Ai_Video_Meta() throws InterruptedException{
if(dto.getDb_CctvList().size() == 0 || recvVideoQ.size() == 0 || map_stand_sttus == null ||map_stand_sttus.size() == 0) {
Thread.sleep(3000);
return ;
}
AiAnalyzeStandSttus aiStandSttus;
int queSize = recvVideoQ.size();
for(int idx = 0; idx<queSize; idx++){
AiVideoMetaData lcData = recvVideoQ.poll();
aiStandSttus = new AiAnalyzeStandSttus();
aiStandSttus.setArcft_stand(lcData.getArcrft_yn());
aiStandSttus.setBrdg_cnnctd(lcData.getBrdg_cnnctd());
aiStandSttus.setCrg_dr_opnd(lcData.getCrg_dr_opnd());
aiStandSttus.setPad_clear(lcData.getPad_clear());
aiStandSttus.setTwng_cr_cnnctd(lcData.getTwng_cr_cnnctd());
map_stand_sttus.get(lcData.getCc_id()).setAiStandSttus(aiStandSttus);
// 주기장 항공기 상태 초기화
map_stand_sttus.get(lcData.getCc_id()).setStand_sttus_ty("0");
}
// Thread.sleep(300);
}
private void init_map_stand_sttus() throws InterruptedException{ private void init_map_stand_sttus() throws InterruptedException{
if(dto.getDb_CctvList() == null ) { if(dto.getDb_CctvList() == null || dto.getDb_CctvList().size() <= 0 ) {
Thread.sleep(3000); Thread.sleep(3000);
return ; return ;
} }
String sCctv, sStandNo; String sCctv, sStandNo;
//map_stand_sttus = new LinkedHashMap<String, RestServiceData>();
for(DataLoadHashMap cctv : dto.getDb_CctvList()){ for(DataLoadHashMap cctv : dto.getDb_CctvList()){
sStandNo = cctv.getItemString("STAND_NO"); sStandNo = cctv.getItemString("STAND_NO");
@ -163,6 +115,81 @@ public class AnalysisStandStatus {
Thread.sleep(1000 * (60 * 10)); // 10분 Thread.sleep(1000 * (60 * 10)); // 10분
} }
/*
* Kafka AI Video Meta()
* Param : cctv List, AI Meta Data
* Return : LinkedHashMap Map_Stand_sttus
*/
private void analysis_Ai_Video_Meta() throws InterruptedException{
if(dto.getDb_CctvList().size() == 0 || qRecvVideo.size() == 0 || map_stand_sttus.size() == 0) {
Thread.sleep(3000);
return ;
}
AiAnalyzeStandSttus aiStandSttus;
int queSize = qRecvVideo.size();
for(int idx = 0; idx<queSize; idx++){
//AiVideoMetaData lcData = qRecvVideo.poll();
//AiVideoMetaData lcData = qRecvVideo.take();
List<AiVideoMetaData> lcDataList = qRecvVideo.take();
for( AiVideoMetaData lcData : lcDataList ){
if(lcData.getCc_id().equals("123")){
String adsf = "adf";
}
aiStandSttus = new AiAnalyzeStandSttus();
aiStandSttus.setArcft_stand(lcData.getArcrft_yn());
aiStandSttus.setBrdg_cnnctd(lcData.getBrdg_cnnctd());
aiStandSttus.setCrg_dr_opnd(lcData.getCrg_dr_opnd());
aiStandSttus.setPad_clear(lcData.getPad_clear());
aiStandSttus.setTwng_cr_cnnctd(lcData.getTwng_cr_cnnctd());
map_stand_sttus.get(lcData.getCc_id()).setAiStandSttus(aiStandSttus);
}
// 주기장 항공기 상태 초기화
//map_stand_sttus.get(lcData.getCc_id()).setAircraft_sttus_ty("0");
}
Thread.sleep(300);
}
private void analysis_Stand_Sttus() throws InterruptedException {
if(qRecvVideo.size() == 0){
// logger.info("AI Video Mata Data(Kafka) 수신 대기");
Thread.sleep(3000);
return ;
}
// AI 주기장 상황 분석 매핑
//analysis_Ai_Video_Meta();
// 항공기 운항 상태 체크 - 도착 스케줄
analysis_Stand_Sttus_Arr();
// 항공기 운항 상태 체크 - 출발 스케줄
analysis_Stand_Sttus_Dep();
// 서비스큐 데이터 적재
store_Service_Data();
Thread.sleep(300);
}
private int analysis_Stand_Sttus_Arr() { private int analysis_Stand_Sttus_Arr() {
if(map_stand_sttus.size() == 0 || dto.getDb_FltArr().size() == 0) return 0; if(map_stand_sttus.size() == 0 || dto.getDb_FltArr().size() == 0) return 0;
@ -208,7 +235,10 @@ public class AnalysisStandStatus {
} }
map_stand_sttus.get(sCctv).setClsgn(_mfltarr.getItemString("CLSGN")); map_stand_sttus.get(sCctv).setClsgn(_mfltarr.getItemString("CLSGN"));
map_stand_sttus.get(sCctv).setStand_sttus_ty(sSttusCD); map_stand_sttus.get(sCctv).setAircraft_sttus_ty(sSttusCD);
map_stand_sttus.get(sCctv).setSchdul_id(_mfltarr.getItemString("SCHDUL_ID"));
map_stand_sttus.get(sCctv).setAc_reg_no(_mfltarr.getItemString("AC_REG_NO"));
// logger.info("ARR --- StandNo:"+sStandNo + "|" + "cctv:" +sCctv + "|" + "CallSign:"+fltarr.get("CLSGN") + " ["+fltarr.toString()+"]"); // logger.info("ARR --- StandNo:"+sStandNo + "|" + "cctv:" +sCctv + "|" + "CallSign:"+fltarr.get("CLSGN") + " ["+fltarr.toString()+"]");
} }
@ -275,6 +305,10 @@ public class AnalysisStandStatus {
continue; continue;
} }
if(sCctv.equals("107")){
String asdf = "asdfasdf";
}
String sRecvTime = _mfltdep.getItemString("EXP_STAND_OFF_DT"); String sRecvTime = _mfltdep.getItemString("EXP_STAND_OFF_DT");
sRecvTime = sRecvTime.concat("00.000"); sRecvTime = sRecvTime.concat("00.000");
dt = LocalDateTime.parse(sRecvTime, df_Pattern); dt = LocalDateTime.parse(sRecvTime, df_Pattern);
@ -316,7 +350,10 @@ public class AnalysisStandStatus {
// } // }
map_stand_sttus.get(sCctv).setClsgn(_mfltdep.getItemString("CLSGN")); map_stand_sttus.get(sCctv).setClsgn(_mfltdep.getItemString("CLSGN"));
map_stand_sttus.get(sCctv).setStand_sttus_ty(sSttusCD); map_stand_sttus.get(sCctv).setAircraft_sttus_ty(sSttusCD);
map_stand_sttus.get(sCctv).setSchdul_id(_mfltdep.getItemString("SCHDUL_ID"));
map_stand_sttus.get(sCctv).setAc_reg_no(_mfltdep.getItemString("AC_REG_NO"));
// logger.info("DEP --- StandNo:"+sStandNo + "|" + "cctv:" +sCctv + "|" + "CallSign:"+fltdep.get("CLSGN") + " ["+fltdep.toString()+"]"); // logger.info("DEP --- StandNo:"+sStandNo + "|" + "cctv:" +sCctv + "|" + "CallSign:"+fltdep.get("CLSGN") + " ["+fltdep.toString()+"]");
} }
@ -327,77 +364,7 @@ public class AnalysisStandStatus {
return idx; return idx;
} }
private void analysis_Stand_Sttus() throws InterruptedException {
if(recvVideoQ.size() == 0){
// logger.info("AI Video Mata Data(Kafka) 수신 대기");
Thread.sleep(3000);
return ;
}
analysis_Ai_Video_Meta();
int anaCnt;
analysis_Stand_Sttus_Arr();
analysis_Stand_Sttus_Dep();
// test Map의 주기장 번호가 있을때
if(testStandStsMap.size() > 0){
for( String testStand : testStandStsMap.keySet()){
String sCctvID = findCctvID(testStand);
if(!sCctvID.equals("")){
map_stand_sttus.get(sCctvID).setStand_sttus_ty("1");
map_stand_sttus.get(sCctvID).setStand_sttus_ty(testStandStsMap.get(testStand));
}
}
}
if(testStandStsMapAI.size() > 0){
for( String testStand : testStandStsMapAI.keySet()){
String sCctvID = findCctvID(testStand);
if(!sCctvID.equals("")){
AiAnalyzeStandSttus aists = new AiAnalyzeStandSttus();
String[] arrTestSts = testStandStsMapAI.get(testStand);
aists.setArcft_stand(arrTestSts[0]);
aists.setBrdg_cnnctd(arrTestSts[1]);
aists.setCrg_dr_opnd(arrTestSts[2]);
aists.setPad_clear(arrTestSts[3]);
aists.setTwng_cr_cnnctd(arrTestSts[4]);
map_stand_sttus.get(sCctvID).setAiStandSttus(aists);
}
}
}
// 서비스큐 데이터 적재
store_Service_Data();
Thread.sleep(300);
}
private void store_Service_Data(){ private void store_Service_Data(){
@ -405,10 +372,13 @@ public class AnalysisStandStatus {
LinkedList<RestServiceData> valueList = new LinkedList<RestServiceData>(map_stand_sttus.values()); LinkedList<RestServiceData> valueList = new LinkedList<RestServiceData>(map_stand_sttus.values());
for(int qi=0; qi<scvQcount; qi++) { // for(int qi=0; qi<scvQcount; qi++) {
serviceList.get(qi).clear(); // serviceList.get(qi).clear();
serviceList.get(qi).addAll(valueList); // serviceList.get(qi).addAll(valueList);
} // }
serviceList.clear();
serviceList.addAll(valueList);
} }
@ -429,8 +399,4 @@ public class AnalysisStandStatus {
///////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////
public void setScvQcount(Integer scvQcount){
this.scvQcount = scvQcount;
}
} }

View File

@ -1,29 +1,32 @@
package kr.gmtc.gw.standstatus.config; package kr.gmtc.gw.standstatus.config;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Map; import java.util.Map;
import java.util.Queue;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
import kr.gmtc.gw.comp.rest.vo.RestServiceData; import kr.gmtc.gw.comp.rest.vo.RestServiceData;
import kr.gmtc.gw.standstatus.kafka.vo.AiVideoMetaData; import kr.gmtc.gw.standstatus.kafka.vo.AiVideoMetaData;
import kr.gmtc.gw.standstatus.vo.AlarmMsgVO; import kr.gmtc.gw.standstatus.vo.AlarmMsgVO;
import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@Setter @Setter
@Getter
public class QueueManageBean { public class QueueManageBean {
private LinkedBlockingQueue<AiVideoMetaData> recvVideoQ; private LinkedBlockingQueue<ArrayList<AiVideoMetaData>> qRecvVideo;
private Queue<AlarmMsgVO> alamMsgQ; private LinkedBlockingQueue<AlarmMsgVO> qAlamMsg;
private Map<Integer, LinkedList<RestServiceData>> serviceList; //private Map<Integer, LinkedList<RestServiceData>> mapServiceLists;
private boolean serviceRunnig; private LinkedList<RestServiceData> serviceList;
private boolean bThredRunnig;
public QueueManageBean(){ public QueueManageBean(){
this.recvVideoQ = new LinkedBlockingQueue<AiVideoMetaData>(); this.qRecvVideo = new LinkedBlockingQueue<ArrayList<AiVideoMetaData>>(100000);
this.alamMsgQ = new LinkedBlockingQueue<AlarmMsgVO>(); this.qAlamMsg = new LinkedBlockingQueue<AlarmMsgVO>(100000);
this.serviceList = new HashMap<Integer, LinkedList<RestServiceData>>(); this.serviceList = new LinkedList<RestServiceData>();
this.serviceRunnig = false; this.bThredRunnig = false;
} }
} }

View File

@ -19,7 +19,7 @@ import java.util.Map;
import java.util.Queue; import java.util.Queue;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
@Configuration("ServiceConfig") //@Configuration("ServiceConfig")
public class ServiceConfig { public class ServiceConfig {
@Value("${root}") @Value("${root}")

View File

@ -1,10 +1,7 @@
package kr.gmtc.gw.standstatus.controller; package kr.gmtc.gw.standstatus.controller;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.LinkedBlockingQueue;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -13,7 +10,6 @@ import org.slf4j.LoggerFactory;
import org.slf4j.Marker; import org.slf4j.Marker;
import org.slf4j.MarkerFactory; import org.slf4j.MarkerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.event.ApplicationReadyEvent; import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener; import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextClosedEvent; import org.springframework.context.event.ContextClosedEvent;
@ -21,18 +17,15 @@ import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import kr.gmt.so.state.StateManager;
import kr.gmtc.gw.comp.rest.ServiceQueManager; import kr.gmtc.gw.comp.rest.ServiceQueManager;
import kr.gmtc.gw.comp.rest.vo.RestServiceData;
import kr.gmtc.gw.comp.thread.CustomThread; import kr.gmtc.gw.comp.thread.CustomThread;
import kr.gmtc.gw.standstatus.component.AnalysisAlarmStatus;
import kr.gmtc.gw.standstatus.component.AnalysisStandStatus; import kr.gmtc.gw.standstatus.component.AnalysisStandStatus;
import kr.gmtc.gw.standstatus.config.QueueManageBean; import kr.gmtc.gw.standstatus.config.QueueManageBean;
import kr.gmtc.gw.standstatus.database.datasource1.CmSelectDao; import kr.gmtc.gw.standstatus.database.datasource1.CmSelectDao;
import kr.gmtc.gw.standstatus.database.datasource2.IcSelectDao; import kr.gmtc.gw.standstatus.database.datasource2.IcSelectDao;
import kr.gmtc.gw.standstatus.database.dto.DataLoadDTO; import kr.gmtc.gw.standstatus.database.dto.DataLoadDTO;
import kr.gmtc.gw.standstatus.kafka.vo.AiVideoMetaData;
import kr.gmtc.gw.standstatus.service.DataLoadService; import kr.gmtc.gw.standstatus.service.DataLoadService;
import kr.gmtc.gw.standstatus.vo.AlarmMsgVO;
@Component("controller") @Component("controller")
public class MainController implements ApplicationListener<ContextClosedEvent> { public class MainController implements ApplicationListener<ContextClosedEvent> {
@ -41,53 +34,62 @@ public class MainController implements ApplicationListener<ContextClosedEvent> {
private ServiceQueManager serviceQueManager; private ServiceQueManager serviceQueManager;
private List<CustomThread> listCustomThreads;
@Resource(name = "cmSelectDao") //@Resource(name = "cmSelectDao")
@Autowired
private CmSelectDao cmSelectDao; private CmSelectDao cmSelectDao;
@Resource(name = "icSelectDao")
@Autowired
private IcSelectDao icSelectDao; private IcSelectDao icSelectDao;
@Resource(name = "dataLoadDTO") @Autowired
private DataLoadDTO dataLoadDTO; private DataLoadDTO dataLoadDTO;
// @Resource(name = "queueManageBean")
// private QueueManageBean queBean;
@Resource(name = "recvVideoQ") @Autowired
LinkedBlockingQueue<AiVideoMetaData> recvVideoQ; private QueueManageBean queMB;
@Resource(name = "serviceList")
Map<Integer, LinkedList<RestServiceData>> serviceList;
@Resource(name = "alamMsgQ")
Queue<AlarmMsgVO> alamMsgQ;
@Resource(name = "serviceRunnig")
private boolean serviceRunnig = false;
@Value("${rest.service.queueCount}") // @Resource(name = "recvVideoQ")
private Integer scvQcount; // LinkedBlockingQueue<AiVideoMetaData> recvVideoQ;
@Value("${rest.service.clearQ.maxCount}") // @Resource(name = "serviceList")
private Integer scvQmaxCount; // Map<Integer, LinkedList<RestServiceData>> serviceList;
@Value("${rest.service.clearQ.diffTime}") // @Resource(name = "alamMsgQ")
private Integer scvQdiffTime; // Queue<AlarmMsgVO> alamMsgQ;
@Value("${rest.service.clearQ.clearTime}") // @Resource(name = "serviceRunnig")
private Integer scvQclearTime; // private boolean serviceRunnig = false;
@Resource(name = "testStandStsMap") // @Resource(name = "alamEndChkList")
HashMap<String, String> testStandStsMap; // LinkedList<AlarmMsgVO> alamEndChkList;
@Resource(name = "testStandStsMapAI") // @Value("${rest.service.queueCount}")
HashMap<String, String[]> testStandStsMapAI; // private Integer scvQcount;
// @Value("${rest.service.clearQ.maxCount}")
// private Integer scvQmaxCount;
// @Value("${rest.service.clearQ.diffTime}")
// private Integer scvQdiffTime;
// @Value("${rest.service.clearQ.clearTime}")
// private Integer scvQclearTime;
// @Resource(name = "testStandStsMap")
// HashMap<String, String> testStandStsMap;
// @Resource(name = "testStandStsMapAI")
// HashMap<String, String[]> testStandStsMapAI;
private DataLoadService dataLoadService; private DataLoadService dataLoadService;
private AnalysisStandStatus analysisStatusService; private AnalysisStandStatus analysisStatusService;
private AnalysisAlarmStatus analysisAlarmStatus;
////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -101,35 +103,43 @@ public class MainController implements ApplicationListener<ContextClosedEvent> {
logger.info(interesting, "MarkerTest"); logger.info(interesting, "MarkerTest");
serviceQueManager = new ServiceQueManager(serviceList, serviceRunnig); // serviceQueManager = new ServiceQueManager(serviceList, serviceRunnig);
serviceQueManager.setScvQclearTime(scvQclearTime); // serviceQueManager.setScvQclearTime(scvQclearTime);
serviceQueManager.setScvQcount(scvQcount); // serviceQueManager.setScvQcount(scvQcount);
serviceQueManager.setScvQdiffTime(scvQdiffTime); // serviceQueManager.setScvQdiffTime(scvQdiffTime);
serviceQueManager.setScvQmaxCount(scvQmaxCount); // serviceQueManager.setScvQmaxCount(scvQmaxCount);
dataLoadService = new DataLoadService(dataLoadDTO, cmSelectDao, icSelectDao); dataLoadService = new DataLoadService(dataLoadDTO, cmSelectDao, icSelectDao);
dataLoadService.start();
analysisStatusService = new AnalysisStandStatus(dataLoadDTO, queMB);
analysisAlarmStatus = new AnalysisAlarmStatus(dataLoadDTO, queMB, dataLoadService);
analysisStatusService = new AnalysisStandStatus(recvVideoQ, dataLoadDTO, serviceList, alamMsgQ, testStandStsMap, testStandStsMapAI);
analysisStatusService.setScvQcount(scvQcount);
} catch (Exception e) { } catch (Exception e) {
logger.error("Start Fail: "+ e.toString()); logger.error("Start Fail: "+ e.toString());
} }
} }
@Order(4) @Order(4)
@EventListener(ApplicationReadyEvent.class) @EventListener(ApplicationReadyEvent.class)
public void start() { public void start() {
try { try {
serviceQueManager.start(); // serviceQueManager.start();
// serviceQueManager.join(); // serviceQueManager.join();
dataLoadService.start(); // Thread.sleep(2000);
Thread.sleep(2000);
analysisStatusService.start(); analysisStatusService.start();
// Thread.sleep(2000);
analysisAlarmStatus.start();
} catch (Exception e) { } catch (Exception e) {
logger.error("Start Fail: "+ e); logger.error("Start Fail: "+ e);
} }
@ -145,11 +155,19 @@ public class MainController implements ApplicationListener<ContextClosedEvent> {
////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
private void logging_Que() { public void setDataLoadDTO(DataLoadDTO dataLoadDTO) {
this.dataLoadDTO = dataLoadDTO;
// logger.info("Que size:" + recvVideoQ.size());
// recvVideoQ.clear();
} }
public void setCmSelectDao(CmSelectDao cmSelectDao) {
this.cmSelectDao = cmSelectDao;
}
public void setIcSelectDao(IcSelectDao icSelectDao) {
this.icSelectDao = icSelectDao;
}
public void setQueMB(QueueManageBean queMB) {
this.queMB = queMB;
}
} }

View File

@ -1,227 +0,0 @@
package kr.gmtc.gw.standstatus.controller;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
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.Value;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import kr.gmtc.gw.comp.rest.vo.RestServiceHeader;
import kr.gmtc.gw.comp.rest.vo.RestServiceVO;
import kr.gmtc.gw.comp.rest.vo.RestServiceData;
import kr.gmtc.gw.standstatus.utils.CmmnUtil;
@RestController
public class StandSttusServiceController {
protected Logger logger;
protected ObjectMapper mapper;
@Resource(name = "serviceList")
public Map<Integer, LinkedList<RestServiceData>> serviceList;
@Resource(name = "serviceRunnig")
private boolean serviceRunnig = false;
@Value("${rest.service.queueCount}")
private Integer scvQcount;
@Value("${rest.service.serviceCount}")
private Integer scvDatacount;
@Resource(name = "testStandStsMap")
HashMap<String, String> testStandStsMap;
@Resource(name = "testStandStsMapAI")
HashMap<String, String[]> testStandStsMapAI;
private RestServiceVO restServiceVO;
DateTimeFormatter dfPattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
public StandSttusServiceController(){
logger = LoggerFactory.getLogger(this.getClass());
mapper = new ObjectMapper();
}
@GetMapping(value = "/getStandStatus/{qid}", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> getASDE( @PathVariable Integer qid) {
int qidx = qid -1;
String sRetJsonData = "";
synchronized(serviceList.get(qidx)){
sRetJsonData = makeServiceData(qidx, serviceList.get(qidx));
}
return ResponseEntity.ok(sRetJsonData);
}
private String makeServiceData(int queIdx, Queue<RestServiceData> procQue){
String sendCode, sendMsg ;
RestServiceHeader jsonHeader = new RestServiceHeader();
List<RestServiceData> jsonData = new ArrayList<RestServiceData>();
sendCode = "200";
sendMsg = "----------------------------------------------------------------------------------------------------";
restServiceVO = new RestServiceVO();
int qTotalSize = procQue.size();
int qSize = qTotalSize;
if(qSize > scvDatacount) qSize = scvDatacount;
if(queIdx > scvQcount -1 || queIdx < 0) {
sendCode = "Err-01";
sendMsg = "할당되지 않은 큐를 지정했습니다.";
logger.error(sendMsg);
}else {
//if(procQue.peek() == null) {
if(qSize <= 0) {
sendCode = "200";
sendMsg = "전송할 데이터 없음.";
// logger.error("procQue size" + " / " + procQue.size());
}else{
serviceRunnig = true;
while (qSize > 0 ) {
RestServiceData data = procQue.poll();
if( data != null){
jsonData.add(data);
}
qSize--;
}
serviceRunnig = false ;
}
}
jsonHeader.setResult_code(sendCode);
jsonHeader.setResult_msg(sendMsg);
restServiceVO.setHeader(jsonHeader);
if (sendCode.equals("200")) {
restServiceVO.setData(jsonData);
logger.info("Que["+(queIdx + 1)+"] service count :" + jsonData.size() + "/" + qTotalSize);
}
String sRetJsonData = "";
try {
sRetJsonData = mapper.writeValueAsString(restServiceVO);
} catch (JsonProcessingException e) {
logger.error("[AsdeServiceController] makeServiceData-JsonProcessingException : " + CmmnUtil.getStatckTrace(e));
}
return sRetJsonData;
}
@RequestMapping(value={"setStandSts/{stadNo}/{sid}"}, method=RequestMethod.GET)
public String setStandSts(@PathVariable String stadNo, @PathVariable String sid) throws Exception {
String sStandNo, sSID ;
String retValue = "";
sStandNo = stadNo;
sSID = sid;
if(Integer.parseInt(sSID) < 1 || Integer.parseInt(sSID) > 8) {
retValue = "Err: 주기장 상태의 범위는 1 ~ 6까지 입니다." ;
return retValue;
}
testStandStsMap.put(sStandNo, sSID);
for ( String stand : testStandStsMap.keySet() ) {
retValue = retValue + "StandNO : " + stand +", Status : " + testStandStsMap.get(stand) + " <br>" ;
}
//gateStatusService.gateStatusSchedule();
return retValue;
}
@RequestMapping(value={"setStandStsAI/{stadNo}/{sid}/{sAiSts}"}, method=RequestMethod.GET)
public String setStandStsAI(@PathVariable String stadNo, @PathVariable String sid, @PathVariable String[] sAiSts) throws Exception {
String sStandNo, sSID ;
String retValue = "";
String[] arrAiSts = {"N", "N", "N", "Y", "N"};
sStandNo = stadNo;
sSID = sid;
if(sid.equals("0")){
}else{
if(Integer.parseInt(sSID) < 1 || Integer.parseInt(sSID) > 8) {
retValue = "Err: 주기장 상태의 범위는 1 ~ 6까지 입니다." ;
return retValue;
}
testStandStsMap.put(sStandNo, sSID);
for ( String stand : testStandStsMap.keySet() ) {
retValue = retValue + "StandNO : " + stand +", Status : " + testStandStsMap.get(stand) + " <br>" ;
}
}
if(sAiSts == null ) sAiSts = arrAiSts;
testStandStsMapAI.put(sStandNo, sAiSts);
for ( String stand : testStandStsMapAI.keySet() ) {
retValue = retValue + "AI Status StandNO : " + stand +", Status : " + Arrays.deepToString( testStandStsMapAI.get(stand)) + " <br>" ;
}
//gateStatusService.gateStatusSchedule();
return retValue;
}
@GetMapping("/setTestClear")
public String getStandStatus() throws Exception {
testStandStsMap.clear();
testStandStsMapAI.clear();
//gateStatusService.gateStatusSchedule();
return "Test Map Clear.";
}
}

View File

@ -1,5 +1,6 @@
package kr.gmtc.gw.standstatus.database.dto; package kr.gmtc.gw.standstatus.database.dto;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import lombok.Getter; import lombok.Getter;
@ -15,4 +16,13 @@ public class DataLoadDTO {
private List<DataLoadHashMap> db_CMMN_CT019; private List<DataLoadHashMap> db_CMMN_CT019;
private List<DataLoadHashMap> db_CMMN_CT038; private List<DataLoadHashMap> db_CMMN_CT038;
public DataLoadDTO() {
this.db_CctvList = new ArrayList<DataLoadHashMap>();
this.db_FltDep = new ArrayList<DataLoadHashMap>();
this.db_FltArr = new ArrayList<DataLoadHashMap>();
this.db_CMMN_CT019 = new ArrayList<DataLoadHashMap>();
this.db_CMMN_CT038 = new ArrayList<DataLoadHashMap>();
}
} }

View File

@ -2,6 +2,7 @@ package kr.gmtc.gw.standstatus.kafka.consummer;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -16,6 +17,7 @@ import org.springframework.stereotype.Service;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import kr.gmt.so.state.StateManager; import kr.gmt.so.state.StateManager;
import kr.gmtc.gw.standstatus.config.QueueManageBean;
import kr.gmtc.gw.standstatus.kafka.vo.AiVideoMetaData; import kr.gmtc.gw.standstatus.kafka.vo.AiVideoMetaData;
import kr.gmtc.gw.standstatus.kafka.vo.KafkaRequestVo; import kr.gmtc.gw.standstatus.kafka.vo.KafkaRequestVo;
@ -25,8 +27,12 @@ public class KafkaMessageListener {
private final Logger logger = LoggerFactory.getLogger(this.getClass()); private final Logger logger = LoggerFactory.getLogger(this.getClass());
private final ObjectMapper objMapper = new ObjectMapper(); private final ObjectMapper objMapper = new ObjectMapper();
@Resource(name = "recvVideoQ") // @Resource(name = "recvVideoQ")
LinkedBlockingQueue<AiVideoMetaData> recvVideoQ; // LinkedBlockingQueue<AiVideoMetaData> recvVideoQ;
@Resource(name = "queueManageBean")
private QueueManageBean queMB;
@Autowired @Autowired
private StateManager stateMgr; private StateManager stateMgr;
@ -40,7 +46,8 @@ public class KafkaMessageListener {
if (message != null) { if (message != null) {
KafkaRequestVo vo = objMapper.readValue(message, KafkaRequestVo.class); KafkaRequestVo vo = objMapper.readValue(message, KafkaRequestVo.class);
recvVideoQ.add(vo.getData()); //recvVideoQ.add(vo.getData());
queMB.getQRecvVideo().offer((ArrayList<AiVideoMetaData>) vo.getData());
} }
} catch(Exception e) { } catch(Exception e) {

View File

@ -20,6 +20,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import kr.gmt.so.state.StateManager; import kr.gmt.so.state.StateManager;
import kr.gmtc.gw.comp.rest.vo.RestServiceData; import kr.gmtc.gw.comp.rest.vo.RestServiceData;
import kr.gmtc.gw.standstatus.config.QueueManageBean;
import kr.gmtc.gw.standstatus.kafka.vo.KafkaServiceData; import kr.gmtc.gw.standstatus.kafka.vo.KafkaServiceData;
import kr.gmtc.gw.standstatus.kafka.vo.KafkaServiceVO; import kr.gmtc.gw.standstatus.kafka.vo.KafkaServiceVO;
import kr.gmtc.gw.standstatus.kafka.vo.ResponsHeader; import kr.gmtc.gw.standstatus.kafka.vo.ResponsHeader;
@ -32,8 +33,22 @@ public class KafkaProduceStandSttus {
@Autowired @Autowired
private KafkaTemplate<String, String> kafkaTemplateString; private KafkaTemplate<String, String> kafkaTemplateString;
@Resource(name = "serviceList") // @Resource(name = "serviceList")
public Map<Integer, LinkedList<RestServiceData>> serviceList; // public Map<Integer, LinkedList<RestServiceData>> serviceList;
@Resource(name = "queueManageBean")
private QueueManageBean queMB;
private boolean sendRunnig = false;
public boolean isSendRunnig() {
return sendRunnig;
}
public void setSendRunnig(boolean sendRunnig) {
this.sendRunnig = sendRunnig;
}
@Value("${kafka.message.topic.send.sttus}") @Value("${kafka.message.topic.send.sttus}")
private String topicStandSttus; private String topicStandSttus;
@ -58,10 +73,10 @@ public class KafkaProduceStandSttus {
if(stateMgr.isActive()){ if(stateMgr.isActive()){
logger.info("************************** serviceList Count : " + serviceList.get(2).size()); logger.info("************************** serviceList Count : " + queMB.getServiceList().size());
if(serviceList.get(2).size() > 0){ if(queMB.getServiceList().size() > 0){
sRetJsonData = makeServiceData(serviceList.get(2)); sRetJsonData = makeServiceData(queMB.getServiceList());
} }
if(sRetJsonData != null && !sRetJsonData.equals("")){ if(sRetJsonData != null && !sRetJsonData.equals("")){
@ -88,8 +103,10 @@ public class KafkaProduceStandSttus {
KafkaServiceData cnvData = new KafkaServiceData(); KafkaServiceData cnvData = new KafkaServiceData();
cnvData.setStand_no(data.getStand_no()); cnvData.setStand_no(data.getStand_no());
cnvData.setClsgn(data.getClsgn()); cnvData.setClsgn(data.getClsgn());
cnvData.setSchdul_id(data.getSchdul_id());
cnvData.setAc_reg_no(data.getAc_reg_no());
cnvData.setStand_sttus_ty(data.getAiStandSttus()); cnvData.setStand_sttus_ty(data.getAiStandSttus());
cnvData.setAircraft_sttus_ty(data.getStand_sttus_ty()); cnvData.setAircraft_sttus_ty(data.getAircraft_sttus_ty());
jsonData.add(cnvData); jsonData.add(cnvData);
} }

View File

@ -24,7 +24,7 @@ import kr.gmtc.gw.standstatus.component.AnalysisAlarmStatus;
import kr.gmtc.gw.standstatus.vo.AlarmMsgVO; import kr.gmtc.gw.standstatus.vo.AlarmMsgVO;
@Component //@Component
public class KafkaProduceSttusAlaram { public class KafkaProduceSttusAlaram {
protected Logger logger; protected Logger logger;
@ -34,9 +34,6 @@ public class KafkaProduceSttusAlaram {
@Autowired @Autowired
private AnalysisAlarmStatus makeAlamMsgService; private AnalysisAlarmStatus makeAlamMsgService;
@Resource(name = "serviceList")
public Map<Integer, LinkedList<RestServiceData>> serviceList;
@Value("${kafka.message.topic.send.alarm}") @Value("${kafka.message.topic.send.alarm}")
private String topicStandSttus; private String topicStandSttus;
@ -53,10 +50,13 @@ public class KafkaProduceSttusAlaram {
@Resource(name = "alamMsgQ") @Resource(name = "alamMsgQ")
Queue<AlarmMsgVO> alamMsgQ; Queue<AlarmMsgVO> alamMsgQ;
@Resource(name = "serviceRunnig")
private boolean serviceRunnig = false;
@Scheduled(fixedDelay = 1000, initialDelay = 1000) @Scheduled(fixedDelay = 1000, initialDelay = 1000)
public void sendMessage() { public void sendMessage() {
if(stateMgr.isActive()){ if(stateMgr.isActive() && serviceRunnig){
logger.info("************************** alamMsgQ Count : " + alamMsgQ.size()); logger.info("************************** alamMsgQ Count : " + alamMsgQ.size());
@ -72,4 +72,21 @@ public class KafkaProduceSttusAlaram {
} }
public Queue<AlarmMsgVO> getAlamMsgQ() {
return alamMsgQ;
}
public void setAlamMsgQ(Queue<AlarmMsgVO> alamMsgQ) {
this.alamMsgQ = alamMsgQ;
}
public boolean isServiceRunnig() {
return serviceRunnig;
}
public void setServiceRunnig(boolean serviceRunnig) {
this.serviceRunnig = serviceRunnig;
}
} }

View File

@ -1,5 +1,8 @@
package kr.gmtc.gw.standstatus.kafka.vo; package kr.gmtc.gw.standstatus.kafka.vo;
import java.util.ArrayList;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@ -15,6 +18,10 @@ public class KafkaRequestVo {
private ResponsHeader header; private ResponsHeader header;
@JsonProperty("data") @JsonProperty("data")
private AiVideoMetaData data; private List<AiVideoMetaData> data;
public KafkaRequestVo(){
this.data = new ArrayList<AiVideoMetaData>();
}
} }

View File

@ -11,7 +11,9 @@ public class KafkaServiceData {
private String stand_no; private String stand_no;
private String clsgn; private String clsgn;
private AiAnalyzeStandSttus stand_sttus_ty; private String schdul_id;
private String ac_reg_no;
private String aircraft_sttus_ty; private String aircraft_sttus_ty;
private AiAnalyzeStandSttus stand_sttus_ty;
} }

View File

@ -1,5 +1,8 @@
package kr.gmtc.gw.standstatus.service; package kr.gmtc.gw.standstatus.service;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -24,6 +27,9 @@ public class DataLoadService {
// @Resource(name = "icSelectDao") // @Resource(name = "icSelectDao")
private IcSelectDao icSelectDao; private IcSelectDao icSelectDao;
private CustomThread threadLoadCctvList; private CustomThread threadLoadCctvList;
private CustomThread threadLoadFlt; private CustomThread threadLoadFlt;
@ -40,11 +46,13 @@ public class DataLoadService {
} }
public void initialize() { public void initialize() {
try { try {
threadLoadCctvList = new CustomThread("loadCctvList", this, CustomThread.NO_SLEEP, this::loadCctvList, null, false); threadLoadCctvList = new CustomThread("loadCctvList", this, 600000, this::loadCctvList, null, false);
threadLoadFlt = new CustomThread("loadArcftFlt", this, CustomThread.NO_SLEEP, this::loadArcftFltSchedule, null, false); threadLoadFlt = new CustomThread("loadArcftFlt", this, 30000, this::loadArcftFltSchedule, null, false);
} catch (Exception e) { } catch (Exception e) {
// logger.writeLevelLog("[MainController] Prepare Fail " + e.getMessage(), LogLevelType.LOG_ERROR, "AllLog"); // logger.writeLevelLog("[MainController] Prepare Fail " + e.getMessage(), LogLevelType.LOG_ERROR, "AllLog");
@ -67,7 +75,7 @@ public class DataLoadService {
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
private void loadCctvList() throws InterruptedException{ private void loadCctvList(){
List<DataLoadHashMap> db_CctvList = cmSelectDao.selectCctv_List(); List<DataLoadHashMap> db_CctvList = cmSelectDao.selectCctv_List();
@ -78,7 +86,7 @@ public class DataLoadService {
logger.info("cctv load Count:" + db_CctvList.size()); logger.info("cctv load Count:" + db_CctvList.size());
} }
Thread.sleep(600000); // Thread.sleep(600000);
} }
@ -87,7 +95,23 @@ public class DataLoadService {
dataLoadDTO.setDb_FltDep(icSelectDao.select_flt_dep()); dataLoadDTO.setDb_FltDep(icSelectDao.select_flt_dep());
dataLoadDTO.setDb_FltArr(icSelectDao.select_flt_arr()); dataLoadDTO.setDb_FltArr(icSelectDao.select_flt_arr());
Thread.sleep(30000); //Thread.sleep(30000);
} }
public IcSelectDao getIcSelectDao() {
return icSelectDao;
}
/*
(yyyy)+(mm)+(dd)+(hh24)+(mi)+(ss)+()+SEQ(000~999)
)20230607153520123001
*/
public String MakeAnalsId() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
Date now = new Date();
int seq = icSelectDao.getAnalsIdSeq();
String nSeq = String.format("%03d", seq);
return sdf.format(now) + nSeq;
}
} }

View File

@ -1,25 +0,0 @@
package kr.gmtc.gw.standstatus.vo;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class StandSttusVO {
private String cctv_id;
private String stand_no;
private AiAnalyzeStandSttus aiStandSttus;
private String stand_sttus_ty;
public StandSttusVO(){
this.aiStandSttus = new AiAnalyzeStandSttus();
}
public StandSttusVO(String stand_no, String cctv_id){
this.stand_no = stand_no;
this.cctv_id = cctv_id;
this.aiStandSttus = new AiAnalyzeStandSttus();
}
}

View File

@ -2,8 +2,7 @@ spring:
profiles: profiles:
active: default active: default
group: group:
default: default: winTest
- winTest
--- ---
spring: spring:
@ -14,43 +13,6 @@ spring:
server: server:
port: 18083 port: 18083
rest:
service:
queueCount: 3
serviceCount: 5000
clearQ:
maxCount: 20000 # 1만건
diffTime: 10000 # 10 sec
clearTime: 60000 # milli-Sec, 1분
state:
# 공통코드 CT001의 코드 6자리
id: IC0302 # 주기장 상태 분석
# 1:Primary, 2:Secondary
type: Primary
---
spring:
config:
activate:
on-profile: real
root: /home/gmt/app/EyeGW_AsdeRecv
state:
# 공통코드 CT001의 코드 6자리
id: IC0302 # 주기장 상태 분석
# 1:Primary, 2:Secondary
type: Primary
---
spring:
config:
activate:
on-profile: winTest
root: D:\Workspace\Odroid_repository\EyeGW_Dev
state: state:
# 공통코드 CT001의 코드 6자리 # 공통코드 CT001의 코드 6자리
id: IC0302 # 주기장 상태 분석 id: IC0302 # 주기장 상태 분석
@ -86,40 +48,38 @@ kafka:
send: send:
sttus: ic.analyze.stand.status sttus: ic.analyze.stand.status
alarm: ic.analyze.alarm alarm: ic.analyze.alarm
--- ---
spring: spring:
config: config:
activate: activate:
on-profile: devServer on-profile: real
root: D:\Workspace\Odroid_repository\EyeGW_Dev state:
# 공통코드 CT001의 코드 6자리
id: IC0302 # 주기장 상태 분석
# 1:Primary, 2:Secondary
type: Primary
database: # on-profile: real... END
db1: ---
datasource: spring:
driver-class-name: com.tmax.tibero.jdbc.TbDriver config:
jdbcUrl: jdbc:tibero:thin:@118.220.143.174:18629:SACP_T_DB activate:
username: ucm on-profile: winTest
password: ucm
db2: state:
datasource: # 공통코드 CT001의 코드 6자리
driver-class-name: com.tmax.tibero.jdbc.TbDriver id: TEST01 # 주기장 상태 분석
jdbcUrl: jdbc:tibero:thin:@118.220.143.174:18629:SACP_T_DB # 1:Primary, 2:Secondary
username: uic type: Primary
password: uic
kafka: kafka:
settings:
bootstrapAddress: 118.220.143.175:9091,118.220.143.176:9091,118.220.143.176:9092
consumer:
group-id: EyeANA_StandStatus
producer:
key-serializer: org.apache.kafka.common.serialization.StringSerializer
value-serializer: org.springframework.kafka.support.serializer.JsonSerializer
message: message:
topic: topic:
recv: recv:
video: ai.analyze.video video: ai.analyze.video
send: send:
sttus: ic.analyze.stand.status sttus: ic.analyze.stand.status_test
alarm: ic.analyze.alarm alarm: ic.analyze.alarm_test
# on-profile: winTest... END

View File

@ -90,10 +90,10 @@
<appender-ref ref="FILE"/> <appender-ref ref="FILE"/>
</logger> </logger>
<logger name="kr.gmt.so" level="INFO"> <!-- <logger name="kr.gmt.so" level="INFO">
<appender-ref ref="CONSOLE"/> <appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/> <appender-ref ref="FILE"/>
</logger> </logger> -->
<!-- <logger name="kr.gmtc.comp.status" level="TRACE"> <!-- <logger name="kr.gmtc.comp.status" level="TRACE">
<appender-ref ref="CONSOLE"/> <appender-ref ref="CONSOLE"/>