123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327 |
- package com.its.op.global;
- import com.its.op.dao.repository.its.code.TbCmmnCdRepository;
- import com.its.op.dto.its.code.TbCmmnCdDto;
- import com.its.op.entity.its.code.TbCmmnCd;
- import lombok.AllArgsConstructor;
- import lombok.Getter;
- import lombok.RequiredArgsConstructor;
- import lombok.ToString;
- import lombok.extern.slf4j.Slf4j;
- import org.apache.commons.lang.StringUtils;
- import org.springframework.stereotype.Component;
- import javax.annotation.PostConstruct;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.concurrent.ConcurrentHashMap;
- @Slf4j
- @RequiredArgsConstructor
- @Getter
- @Component
- public class CmmnCdManager {
- private final TbCmmnCdRepository repo;
- //private final TbSectGradClsfRepository sectGradClsfRepository;
- // 소통정보 결측 소통등급 코드
- public static final String MISS_SPED_GRAD = "LTC0";
- // 돌발상황 출처 유형
- public static final String INCD_ORGN_IST1 = "IST1"; //운영자
- public static final String INCD_ORGN_IST2 = "IST2"; //제보
- public static final String INCD_ORGN_IST3 = "IST3"; //연계기관
- public static final String INCD_ORGN_IST4 = "IST4"; //OBE
- public static final String INCD_ORGN_IST5 = "IST5"; //도로교통공단
- public static final String INCD_ORGN_IST6 = "IST6"; //자동돌발검지
- public static final String INCD_ORGN_IST7 = "IST7"; //기타
- // 돌발상황 진행 단계 유형
- public static final String INCD_PRGR_STEP_ISS1 = "ISS1"; //접수/미확인
- public static final String INCD_PRGR_STEP_ISS2 = "ISS2"; //진행
- public static final String INCD_PRGR_STEP_ISS3 = "ISS3"; //종료
- public static final String INCD_PRGR_STEP_ISS4 = "ISS4"; //오보
- // 돌발상황관리 코드
- public static final String INCD_CODE_IST = "IST"; //돌발상황 원본 코드 : IST
- public static final String INCD_CODE_LTCU = "LTCU"; //소통 등급 코드 : LTCU
- public static final String INCD_CODE_ICM = "ICM"; //돌발상황 확인 방법 코드 : ICM
- public static final String INCD_CODE_IDTU = "IDTU"; //돌발상황 유형 분류 코드 : IDTU
- public static final String INCD_CODE_ACTU = "ACTU"; //돌발상황 유형 코드 : ACTU, CRTU, EVTU, WETU 중 하나 // 사고
- public static final String INCD_CODE_CRTU = "CRTU"; //돌발상황 유형 코드 : ACTU, CRTU, EVTU, WETU 중 하나 // 공사
- public static final String INCD_CODE_EVTU = "EVTU"; //돌발상황 유형 코드 : ACTU, CRTU, EVTU, WETU 중 하나 // 행사
- public static final String INCD_CODE_WETU = "WETU"; //돌발상황 유형 코드 : ACTU, CRTU, EVTU, WETU 중 하나 // 기상
- public static final String INCD_CODE_SRLU = "SRLU"; //돌발상황 심각도 코드 : SRLU
- public static final String INCD_CODE_PRTU = "PRTU"; //통행 제한 유형 코드 : PRTU
- public static final String INCD_CODE_RSL = "RSL"; //대응 수준 코드 : RSL
- public static final String INCD_CODE_ISS = "ISS"; //돌발상황 진행 단계 코드 : ISS
- public static final String INCD_CODE_DFW = "DFW"; //기상 코드 : DFW
- public static final String INCD_CODE_VIT = "VIT"; //VMS 돌발 유형 코드 : VIT
- public static final String INCD_CODE_IDT = "IDT"; //VMS 돌발 유형 세부 코드 : IDT
- public static final String INCD_CODE_EDT = "EDT"; //VMS 돌발 유형 세부 코드 : EDT
- public static final String INCD_CODE_VRT = "VRT"; //VMS 돌발 통제 코드 : VRT
- // 코드
- private static final String defUnknownCode = "X";
- public static final String defUnknownDesc = "UNKNOWN";
- public static final String defUnknownEtcDesc = "기타";
- public static final String EDTN_CD = "EDI"; // 편집모드
- public static final String DAY_TYPE_CD = "DTW"; // 요일유형
- public static final String SYST_STTS_CD = "SPS"; // 프로세스 상태
- public static final String CMTR_GRAD_CD = "LTC"; // 소통등급
- public static final String PRCN_SORC = "CST"; // 가공소스
- public static final String ADJS_SORC = "MCS"; // 보정소스
- public static final String NODE_TYPE = "NDT"; // 노드유형
- public static final String ROAD_USE = "RDU"; // 도로사용여부
- public static final String ROAD_RANK = "RDR"; // 도로등급
- public static final String ROAD_TYPE = "RDT"; // 도로유형
- public static final String MULTI_LINK = "MLT"; // 중용구간
- public static final String LINK_CONNECT = "CTR"; // 연결로
- public static final String REST_VEH = "PLV"; // 통행제한차량
- public static final String SECT_GRAD_CD = "SRT"; // 구간 등급 코드
- public static final String DRCT_CD = "IFD"; // 방향 코드
- public static final String HLDY_DAY_CD = "LHT"; // 휴일유형코드
- public static final String CNCT_INTN_TYPE_CD = "COT"; // 연계기관유형코드
- public static final String VEH_TYPE = "RCT"; // DSRC OBU 차종
- public static final String OBU_KIND = "OBU"; // OBU 종류
- public static final String STTS_UNKNOWN = "-";
- public static final String CMNC_STTS_NORMAL = "CMS0";
- public static final String CMNC_STTS_ERROR = "CMS1";
- public static final String CMNC_STTS_ERROR_DT = "19700101000000";
- public static final String CMNC_STTS_CD = "CMS"; // 통신상태코드
- public static final String MODL_STTS_CD = "MOS"; // 모듈상태
- public static final String PWER_STTS_CD = "PWS"; // 전원상태
- public static final String DOOR_STTS_CD = "CDS"; // 도어상태
- public static final String FAN_STTS_CD = "PAS"; // 팬상태
- public static final String HETR_STTS_CD = "HTS"; // 히터상태
- public static final String VIDEO_INPUT_CD = "VDI"; // VIDEO Input 상태
- public static final String CCTV_TYPE_CD = "CCTVT"; // CCTV 유형 코드
- public static final String DTCT_TYPE_CD = "DTT"; // 검지기유형
- //public static final String DTCT_TYPE_CD = "ACD"; // 검지기방향
- public static final String VMS_USAG_TYPE_CD = "VUT"; // VMS 용도 유형 코드
- public static final String VMS_TYPE_CD = "VMP"; // VMS 유형 코드
- public static final String REPT_CNGS_CD = "RCS"; // 반복정체 원본 코드
- public static final String FCLT_TYPE_CD = "FTC"; // 시설물 유형 코드
- public static final String FCLT_FAIL_TYPE_CD = "FFA"; // 시설물 장애 유형 코드
- // 시설물 관리
- public static final String FMS_CLASS = "FMS"; // 시설물 대분류
- public static final String FMS_FMITS = "FMITS"; // ITS 시설물
- public static final String FMS_FMSCRS = "FMSCRS"; // 스마트 교차로
- public static final String FMS_FMCNTR = "FMCNTR"; // 센터장비
- public static final String FMS_FMSIG = "FMSIG"; // 신호시설물
- public static final String FMS_WSTEP = "WSTEP"; // 사업단계
- public static final String FMS_FMSTP = "FMSTP"; // 시설물 구분
- public static final String FMS_FSTEP = "FSTEP"; // 시설물 장애진행상태구분
- public static final String FMS_FREG = "FREG"; // 시설물 장애등록구분
- public static final String FMS_FLVL = "FLVL"; // 시설물 장애등급구분
- public static final String FMS_FWTHR = "FWTHR"; // 시설물 장애발생시 날씨
- public static final String FMS_FMSG = "FMSG"; // 사용자 메지시 종류
- private static ConcurrentHashMap<String, HashMap<String, Code>> codes = new ConcurrentHashMap<>();
- @PostConstruct
- void init() {
- load();
- }
- public void load() {
- List<TbCmmnCd> codeList = this.repo.findAll();
- for (TbCmmnCd entity : codeList) {
- TbCmmnCdDto cd = entity.toDto();
- HashMap<String, Code> codeMap = codes.get(cd.getCmmnClsfCd());
- if (codeMap == null) {
- codeMap = new HashMap<>();
- codeMap.put(cd.getCmmnCd(), new Code(cd.getCmmnCd(), cd.getCmmnCdKorNm(), cd.getCmmnDescEnglNm()));
- codes.put(cd.getCmmnClsfCd(), codeMap);
- }
- else {
- codeMap.put(cd.getCmmnCd(), new Code(cd.getCmmnCd(), cd.getCmmnCdKorNm(), cd.getCmmnDescEnglNm()));
- }
- }
- }
- public List<TbCmmnCd> reload() {
- ConcurrentHashMap<String, HashMap<String, Code>> tempMap = new ConcurrentHashMap<>();
- List<TbCmmnCd> codeList = this.repo.findAll();
- for (TbCmmnCd entity : codeList) {
- TbCmmnCdDto cd = entity.toDto();
- HashMap<String, Code> codeMap = tempMap.get(cd.getCmmnClsfCd());
- if (codeMap == null) {
- codeMap = new HashMap<>();
- codeMap.put(cd.getCmmnCd(), new Code(cd.getCmmnCd(), cd.getCmmnCdKorNm(), cd.getCmmnDescEnglNm()));
- tempMap.put(cd.getCmmnClsfCd(), codeMap);
- }
- else {
- codeMap.put(cd.getCmmnCd(), new Code(cd.getCmmnCd(), cd.getCmmnCdKorNm(), cd.getCmmnDescEnglNm()));
- }
- }
- codes = tempMap;
- return codeList;
- }
- public void refresh(List<TbCmmnCdDto> codeList) {
- if (codeList == null) {
- return;
- }
- ConcurrentHashMap<String, HashMap<String, Code>> tempMap = new ConcurrentHashMap<>();
- for (TbCmmnCdDto cd : codeList) {
- HashMap<String, Code> codeMap = tempMap.get(cd.getCmmnClsfCd());
- if (codeMap == null) {
- codeMap = new HashMap<>();
- codeMap.put(cd.getCmmnCd(), new Code(cd.getCmmnCd(), cd.getCmmnCdKorNm(), cd.getCmmnDescEnglNm()));
- tempMap.put(cd.getCmmnClsfCd(), codeMap);
- }
- else {
- codeMap.put(cd.getCmmnCd(), new Code(cd.getCmmnCd(), cd.getCmmnCdKorNm(), cd.getCmmnDescEnglNm()));
- }
- }
- codes = tempMap;
- }
- public void merge(TbCmmnCdDto cd) {
- if (cd == null) {
- return;
- }
- HashMap<String, Code> codeMap = codes.get(cd.getCmmnClsfCd());
- if (codeMap == null) {
- HashMap<String, Code> codeMap_ = new HashMap<>();
- codeMap_.put(cd.getCmmnCd(), new Code(cd.getCmmnCd(), cd.getCmmnCdKorNm(), cd.getCmmnDescEnglNm()));
- codes.put(cd.getCmmnClsfCd(), codeMap_);
- }
- else {
- codeMap.put(cd.getCmmnCd(), new Code(cd.getCmmnCd(), cd.getCmmnCdKorNm(), cd.getCmmnDescEnglNm()));
- }
- }
- public void remove(String cmmnClsfCd, String cmmnCd) {
- HashMap<String, Code> codeMap = codes.get(cmmnClsfCd);
- if (codeMap != null) {
- codeMap.remove(cmmnCd);
- }
- }
- public void update(String cmmnClsfCd, List<TbCmmnCdDto> result) {
- if (result == null) {
- return;
- }
- HashMap<String, Code> codeMap = new HashMap<>();
- for (TbCmmnCdDto cd : result) {
- codeMap.put(cd.getCmmnCd(), new Code(cd.getCmmnCd(), cd.getCmmnCdKorNm(), cd.getCmmnDescEnglNm()));
- }
- codes.put(cmmnClsfCd, codeMap);
- }
- public static String getCodeDesc(String CMMN_CLSF_CD, String CMMN_CD) {
- HashMap<String, Code> codeMap = codes.get(CMMN_CLSF_CD);
- if (codeMap != null) {
- Code code = codeMap.get(CMMN_CD);
- if (code != null) {
- return "[" + CMMN_CD + "] " + code.getDesc();
- }
- }
- return "[" + CMMN_CD + "] " + defUnknownDesc;
- }
- public static String getCodeDescShort(String CMMN_CLSF_CD, String CMMN_CD) {
- HashMap<String, Code> codeMap = codes.get(CMMN_CLSF_CD);
- if (codeMap != null) {
- Code code = codeMap.get(CMMN_CD);
- if (code != null) {
- return code.getDesc();
- }
- }
- return defUnknownDesc;
- }
- public static String getCodeEtcDescShort(String CMMN_CLSF_CD, String CMMN_CD) {
- HashMap<String, Code> codeMap = codes.get(CMMN_CLSF_CD);
- if (codeMap != null) {
- Code code = codeMap.get(CMMN_CD);
- if (code != null) {
- return code.getDesc();
- }
- }
- return defUnknownEtcDesc;
- }
- public static String getFcltGroupNm(String FCLT_TYPE) {
- HashMap<String, Code> codeMap = codes.get(FMS_CLASS);
- if (codeMap != null) {
- for (String key : codeMap.keySet()) {
- HashMap<String, Code> subCodeMap = codes.get(key);
- for (String subKey : subCodeMap.keySet()) {
- if (subKey.equals(FCLT_TYPE)) {
- return codeMap.get(key).getDesc();
- }
- }
- }
- }
- return defUnknownDesc;
- }
- public static String getFcltTypeNm(String FCLT_TYPE) {
- HashMap<String, Code> codeMap = codes.get(FMS_CLASS);
- if (codeMap != null) {
- for (String key : codeMap.keySet()) {
- HashMap<String, Code> subCodeMap = codes.get(key);
- for (Map.Entry<String, Code> e: subCodeMap.entrySet()) {
- if (e.getKey().equals(FCLT_TYPE)) {
- return e.getValue().getDesc();
- }
- }
- // for (String subKey : subCodeMap.keySet()) {
- // if (subKey.equals(FCLT_TYPE)) {
- // return subCodeMap.get(subKey).getDesc();
- // }
- // }
- }
- }
- return defUnknownDesc;
- }
- public static String getWeatherCode(String CMMN_CD_KOR_NM) {
- HashMap<String, Code> codeMap = codes.get(CmmnCdManager.INCD_CODE_DFW);
- if (codeMap != null) {
- for (Map.Entry<String, Code> e: codeMap.entrySet()) {
- Code code = e.getValue();
- if (StringUtils.equals(code.getDesc(), CMMN_CD_KOR_NM)) {
- return code.getCode();
- }
- }
- // for (String key : codeMap.keySet()) {
- // Code code = codeMap.get(key);
- // if (StringUtils.equals(code.getDesc(), CMMN_CD_KOR_NM)) {
- // return code.getCode();
- // }
- // }
- }
- return "NB0";
- }
- @Getter
- @ToString
- @AllArgsConstructor
- public static class Code {
- private String code;
- private String desc;
- private String englDesc;
- }
- }
|