CmmnCdManager.java 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. package com.its.op.global;
  2. import com.its.op.dao.repository.its.code.TbCmmnCdRepository;
  3. import com.its.op.dto.its.code.TbCmmnCdDto;
  4. import com.its.op.entity.its.code.TbCmmnCd;
  5. import lombok.AllArgsConstructor;
  6. import lombok.Getter;
  7. import lombok.RequiredArgsConstructor;
  8. import lombok.ToString;
  9. import lombok.extern.slf4j.Slf4j;
  10. import org.apache.commons.lang.StringUtils;
  11. import org.springframework.stereotype.Component;
  12. import javax.annotation.PostConstruct;
  13. import java.util.HashMap;
  14. import java.util.List;
  15. import java.util.concurrent.ConcurrentHashMap;
  16. @Slf4j
  17. @RequiredArgsConstructor
  18. @Getter
  19. @Component
  20. public class CmmnCdManager {
  21. private final TbCmmnCdRepository repo;
  22. //private final TbSectGradClsfRepository sectGradClsfRepository;
  23. // 소통정보 결측 소통등급 코드
  24. public static final String MISS_SPED_GRAD = "LTC0";
  25. // 돌발상황 출처 유형
  26. public static final String INCD_ORGN_IST1 = "IST1"; //운영자
  27. public static final String INCD_ORGN_IST2 = "IST2"; //제보
  28. public static final String INCD_ORGN_IST3 = "IST3"; //연계기관
  29. public static final String INCD_ORGN_IST4 = "IST4"; //OBE
  30. public static final String INCD_ORGN_IST5 = "IST5"; //도로교통공단
  31. public static final String INCD_ORGN_IST6 = "IST6"; //자동돌발검지
  32. public static final String INCD_ORGN_IST7 = "IST7"; //기타
  33. // 돌발상황 진행 단계 유형
  34. public static final String INCD_PRGR_STEP_ISS1 = "ISS1"; //접수/미확인
  35. public static final String INCD_PRGR_STEP_ISS2 = "ISS2"; //진행
  36. public static final String INCD_PRGR_STEP_ISS3 = "ISS3"; //종료
  37. public static final String INCD_PRGR_STEP_ISS4 = "ISS4"; //오보
  38. // 돌발상황관리 코드
  39. public static final String INCD_CODE_IST = "IST"; //돌발상황 원본 코드 : IST
  40. public static final String INCD_CODE_LTCU = "LTCU"; //소통 등급 코드 : LTCU
  41. public static final String INCD_CODE_ICM = "ICM"; //돌발상황 확인 방법 코드 : ICM
  42. public static final String INCD_CODE_IDTU = "IDTU"; //돌발상황 유형 분류 코드 : IDTU
  43. public static final String INCD_CODE_ACTU = "ACTU"; //돌발상황 유형 코드 : ACTU, CRTU, EVTU, WETU 중 하나 // 사고
  44. public static final String INCD_CODE_CRTU = "CRTU"; //돌발상황 유형 코드 : ACTU, CRTU, EVTU, WETU 중 하나 // 공사
  45. public static final String INCD_CODE_EVTU = "EVTU"; //돌발상황 유형 코드 : ACTU, CRTU, EVTU, WETU 중 하나 // 행사
  46. public static final String INCD_CODE_WETU = "WETU"; //돌발상황 유형 코드 : ACTU, CRTU, EVTU, WETU 중 하나 // 기상
  47. public static final String INCD_CODE_SRLU = "SRLU"; //돌발상황 심각도 코드 : SRLU
  48. public static final String INCD_CODE_PRTU = "PRTU"; //통행 제한 유형 코드 : PRTU
  49. public static final String INCD_CODE_RSL = "RSL"; //대응 수준 코드 : RSL
  50. public static final String INCD_CODE_ISS = "ISS"; //돌발상황 진행 단계 코드 : ISS
  51. public static final String INCD_CODE_DFW = "DFW"; //기상 코드 : DFW
  52. public static final String INCD_CODE_VIT = "VIT"; //VMS 돌발 유형 코드 : VIT
  53. public static final String INCD_CODE_IDT = "IDT"; //VMS 돌발 유형 세부 코드 : IDT
  54. public static final String INCD_CODE_EDT = "EDT"; //VMS 돌발 유형 세부 코드 : EDT
  55. public static final String INCD_CODE_VRT = "VRT"; //VMS 돌발 통제 코드 : VRT
  56. // 코드
  57. private static final String defUnknownCode = "X";
  58. public static final String defUnknownDesc = "UNKNOWN";
  59. public static final String EDTN_CD = "EDI"; // 편집모드
  60. public static final String DAY_TYPE_CD = "DTW"; // 요일유형
  61. public static final String SYST_STTS_CD = "SPS"; // 프로세스 상태
  62. public static final String CMTR_GRAD_CD = "LTC"; // 소통등급
  63. public static final String PRCN_SORC = "CST"; // 가공소스
  64. public static final String ADJS_SORC = "MCS"; // 보정소스
  65. public static final String NODE_TYPE = "NDT"; // 노드유형
  66. public static final String ROAD_USE = "RDU"; // 도로사용여부
  67. public static final String ROAD_RANK = "RDR"; // 도로등급
  68. public static final String ROAD_TYPE = "RDT"; // 도로유형
  69. public static final String MULTI_LINK = "MLT"; // 중용구간
  70. public static final String LINK_CONNECT = "CTR"; // 연결로
  71. public static final String REST_VEH = "PLV"; // 통행제한차량
  72. public static final String SECT_GRAD_CD = "SRT"; // 구간 등급 코드
  73. public static final String DRCT_CD = "IFD"; // 방향 코드
  74. public static final String HLDY_DAY_CD = "LHT"; // 휴일유형코드
  75. public static final String CNCT_INTN_TYPE_CD = "COT"; // 연계기관유형코드
  76. public static final String STTS_UNKNOWN = "-";
  77. public static final String CMNC_STTS_NORMAL = "CMS0";
  78. public static final String CMNC_STTS_ERROR = "CMS1";
  79. public static final String CMNC_STTS_ERROR_DT = "19700101000000";
  80. public static final String CMNC_STTS_CD = "CMS"; // 통신상태코드
  81. public static final String MODL_STTS_CD = "MOS"; // 모듈상태
  82. public static final String PWER_STTS_CD = "PWS"; // 전원상태
  83. public static final String DOOR_STTS_CD = "CDS"; // 도어상태
  84. public static final String FAN_STTS_CD = "PAS"; // 팬상태
  85. public static final String HETR_STTS_CD = "HTS"; // 히터상태
  86. public static final String VIDEO_INPUT_CD = "VDI"; // VIDEO Input 상태
  87. public static final String CCTV_TYPE_CD = "CCTVT"; // CCTV 유형 코드
  88. public static final String DTCT_TYPE_CD = "DTT"; // 검지기유형
  89. //public static final String DTCT_TYPE_CD = "ACD"; // 검지기방향
  90. public static final String VMS_USAG_TYPE_CD = "VUT"; // VMS 용도 유형 코드
  91. public static final String VMS_TYPE_CD = "VMP"; // VMS 유형 코드
  92. public static final String REPT_CNGS_CD = "RCS"; // 반복정체 원본 코드
  93. public static final String FCLT_TYPE_CD = "FTC"; // 시설물 유형 코드
  94. public static final String FCLT_FAIL_TYPE_CD = "FFA"; // 시설물 장애 유형 코드
  95. // 시설물 관리
  96. public static final String FMS_CLASS = "FMS"; // 시설물 대분류
  97. public static final String FMS_FMITS = "FMITS"; // ITS 시설물
  98. public static final String FMS_FMSCRS = "FMSCRS"; // 스마트 교차로
  99. public static final String FMS_FMCNTR = "FMCNTR"; // 센터장비
  100. public static final String FMS_FMSIG = "FMSIG"; // 신호시설물
  101. public static final String FMS_WSTEP = "WSTEP"; // 사업단계
  102. public static final String FMS_FMSTP = "FMSTP"; // 시설물 구분
  103. public static final String FMS_FSTEP = "FSTEP"; // 시설물 장애진행상태구분
  104. public static final String FMS_FREG = "FREG"; // 시설물 장애등록구분
  105. public static final String FMS_FLVL = "FLVL"; // 시설물 장애등급구분
  106. public static final String FMS_FWTHR = "FWTHR"; // 시설물 장애발생시 날씨
  107. public static final String FMS_FMSG = "FMSG"; // 사용자 메지시 종류
  108. private static ConcurrentHashMap<String, HashMap<String, Code>> codes = new ConcurrentHashMap<>();
  109. @PostConstruct
  110. void init() {
  111. load();
  112. }
  113. public void load() {
  114. List<TbCmmnCd> codeList = this.repo.findAll();
  115. for (TbCmmnCd entity : codeList) {
  116. TbCmmnCdDto cd = entity.toDto();
  117. HashMap<String, Code> codeMap = codes.get(cd.getCmmnClsfCd());
  118. if (codeMap == null) {
  119. codeMap = new HashMap<>();
  120. codeMap.put(cd.getCmmnCd(), new Code(cd.getCmmnCd(), cd.getCmmnCdKorNm(), cd.getCmmnDescEnglNm()));
  121. codes.put(cd.getCmmnClsfCd(), codeMap);
  122. }
  123. else {
  124. codeMap.put(cd.getCmmnCd(), new Code(cd.getCmmnCd(), cd.getCmmnCdKorNm(), cd.getCmmnDescEnglNm()));
  125. }
  126. }
  127. }
  128. public List<TbCmmnCd> reload() {
  129. ConcurrentHashMap<String, HashMap<String, Code>> tempMap = new ConcurrentHashMap<>();
  130. List<TbCmmnCd> codeList = this.repo.findAll();
  131. for (TbCmmnCd entity : codeList) {
  132. TbCmmnCdDto cd = entity.toDto();
  133. HashMap<String, Code> codeMap = tempMap.get(cd.getCmmnClsfCd());
  134. if (codeMap == null) {
  135. codeMap = new HashMap<>();
  136. codeMap.put(cd.getCmmnCd(), new Code(cd.getCmmnCd(), cd.getCmmnCdKorNm(), cd.getCmmnDescEnglNm()));
  137. tempMap.put(cd.getCmmnClsfCd(), codeMap);
  138. }
  139. else {
  140. codeMap.put(cd.getCmmnCd(), new Code(cd.getCmmnCd(), cd.getCmmnCdKorNm(), cd.getCmmnDescEnglNm()));
  141. }
  142. }
  143. codes = tempMap;
  144. return codeList;
  145. }
  146. public void refresh(List<TbCmmnCdDto> codeList) {
  147. ConcurrentHashMap<String, HashMap<String, Code>> tempMap = new ConcurrentHashMap<>();
  148. for (TbCmmnCdDto cd : codeList) {
  149. HashMap<String, Code> codeMap = tempMap.get(cd.getCmmnClsfCd());
  150. if (codeMap == null) {
  151. codeMap = new HashMap<>();
  152. codeMap.put(cd.getCmmnCd(), new Code(cd.getCmmnCd(), cd.getCmmnCdKorNm(), cd.getCmmnDescEnglNm()));
  153. tempMap.put(cd.getCmmnClsfCd(), codeMap);
  154. }
  155. else {
  156. codeMap.put(cd.getCmmnCd(), new Code(cd.getCmmnCd(), cd.getCmmnCdKorNm(), cd.getCmmnDescEnglNm()));
  157. }
  158. }
  159. codes = tempMap;
  160. }
  161. public void merge(TbCmmnCdDto cd) {
  162. if (cd == null) {
  163. return;
  164. }
  165. HashMap<String, Code> codeMap = codes.get(cd.getCmmnClsfCd());
  166. if (codeMap == null) {
  167. HashMap<String, Code> codeMap_ = new HashMap<>();
  168. codeMap_.put(cd.getCmmnCd(), new Code(cd.getCmmnCd(), cd.getCmmnCdKorNm(), cd.getCmmnDescEnglNm()));
  169. codes.put(cd.getCmmnClsfCd(), codeMap_);
  170. }
  171. else {
  172. codeMap.put(cd.getCmmnCd(), new Code(cd.getCmmnCd(), cd.getCmmnCdKorNm(), cd.getCmmnDescEnglNm()));
  173. }
  174. }
  175. public void remove(String cmmnClsfCd, String cmmnCd) {
  176. HashMap<String, Code> codeMap = codes.get(cmmnClsfCd);
  177. if (codeMap != null) {
  178. codeMap.remove(cmmnCd);
  179. }
  180. }
  181. public void update(String cmmnClsfCd, List<TbCmmnCdDto> result) {
  182. if (result == null) {
  183. return;
  184. }
  185. HashMap<String, Code> codeMap = new HashMap<>();
  186. for (TbCmmnCdDto cd : result) {
  187. codeMap.put(cd.getCmmnCd(), new Code(cd.getCmmnCd(), cd.getCmmnCdKorNm(), cd.getCmmnDescEnglNm()));
  188. }
  189. codes.put(cmmnClsfCd, codeMap);
  190. }
  191. public static String getCodeDesc(String CMMN_CLSF_CD, String CMMN_CD) {
  192. HashMap<String, Code> codeMap = codes.get(CMMN_CLSF_CD);
  193. if (codeMap != null) {
  194. Code code = codeMap.get(CMMN_CD);
  195. if (code != null) {
  196. return "[" + CMMN_CD + "] " + code.getDesc();
  197. }
  198. }
  199. return "[" + CMMN_CD + "] " + defUnknownDesc;
  200. }
  201. public static String getCodeDescShort(String CMMN_CLSF_CD, String CMMN_CD) {
  202. HashMap<String, Code> codeMap = codes.get(CMMN_CLSF_CD);
  203. if (codeMap != null) {
  204. Code code = codeMap.get(CMMN_CD);
  205. if (code != null) {
  206. return code.getDesc();
  207. }
  208. }
  209. return defUnknownDesc;
  210. }
  211. public static String getFcltGroupNm(String FCLT_TYPE) {
  212. HashMap<String, Code> codeMap = codes.get(FMS_CLASS);
  213. if (codeMap != null) {
  214. for (String key : codeMap.keySet()) {
  215. HashMap<String, Code> subCodeMap = codes.get(key);
  216. for (String subKey : subCodeMap.keySet()) {
  217. if (subKey.equals(FCLT_TYPE)) {
  218. return codeMap.get(key).getDesc();
  219. }
  220. }
  221. }
  222. }
  223. return defUnknownDesc;
  224. }
  225. public static String getFcltTypeNm(String FCLT_TYPE) {
  226. HashMap<String, Code> codeMap = codes.get(FMS_CLASS);
  227. if (codeMap != null) {
  228. for (String key : codeMap.keySet()) {
  229. HashMap<String, Code> subCodeMap = codes.get(key);
  230. for (String subKey : subCodeMap.keySet()) {
  231. if (subKey.equals(FCLT_TYPE)) {
  232. return subCodeMap.get(subKey).getDesc();
  233. }
  234. }
  235. }
  236. }
  237. return defUnknownDesc;
  238. }
  239. public static String getWeatherCode(String CMMN_CD_KOR_NM) {
  240. HashMap<String, Code> codeMap = codes.get(CmmnCdManager.INCD_CODE_DFW);
  241. if (codeMap != null) {
  242. for (String key : codeMap.keySet()) {
  243. Code code = codeMap.get(key);
  244. if (StringUtils.equals(code.getDesc(), CMMN_CD_KOR_NM)) {
  245. return code.getCode();
  246. }
  247. }
  248. }
  249. return "NB0";
  250. }
  251. @Getter
  252. @ToString
  253. @AllArgsConstructor
  254. public static class Code {
  255. private String code;
  256. private String desc;
  257. private String englDesc;
  258. }
  259. }