CommCodeManager.java 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. /**
  2. * @(#)file CommCodeManager.java
  3. * @(#)author chj
  4. * @(#)version 1.0
  5. * @(#)date 2014-06-24
  6. * @(#)since JDK1.6
  7. *
  8. * Copyright (c) www.udapsoft.co.kr, Inc.
  9. */
  10. package kr.co.udapsoft.common.code;
  11. import kr.co.hsnc.common.base.WAFLogger;
  12. import kr.co.hsnc.common.sql.Row;
  13. import kr.co.hsnc.common.sql.RowImpl;
  14. import kr.co.hsnc.common.sql.RowSet;
  15. import kr.co.hsnc.common.sql.RowSetImpl;
  16. import kr.co.hsnc.common.sql.search.Search;
  17. import kr.co.hsnc.common.sql.search.SearchImpl;
  18. import kr.co.hsnc.common.util.ValueObject;
  19. import com.udapsoft.waf.common.ui.HTMLMaker;
  20. /**
  21. * 공통코드 DB 접근 Beans.
  22. *
  23. *
  24. * @version 1.0 2003-05-29
  25. * @author DaeJin Lee
  26. */
  27. public class CommCodeManager {
  28. private static String D_TABLE = "EBID_COM911T";
  29. /**
  30. * Select 태그 Method
  31. * @param group_cd 검색 조건
  32. * @param inputName Select name
  33. * @param sytleStr Select style
  34. * @param defaultOption Option Default Value
  35. * @param selectedValue Option Selected Value
  36. * @param eventStr
  37. * @return
  38. * @throws Exception
  39. */
  40. public static String getSelectCodeList(String group_cd, String inputName, String sytleStr, String defaultOption, String selectedValue) throws Exception {
  41. return getSelectCodeList(group_cd, inputName, sytleStr, defaultOption, selectedValue, 10, "");
  42. }
  43. public static String getSelectCodeList(String group_cd, String inputName, String sytleStr, String defaultOption, String selectedValue, String eventStr) throws Exception {
  44. return getSelectCodeList(group_cd, inputName, sytleStr, defaultOption, selectedValue, 10, eventStr);
  45. }
  46. public static String getSelectCodeSearchList(String group_cd, String inputName, String sytleStr, String defaultOption, String selectedValue, String Search) throws Exception {
  47. return getSelectCodeList5(group_cd, inputName, sytleStr, defaultOption, selectedValue, 10, Search , "");
  48. }
  49. public static String getSelectCodeSearchList(String group_cd, String inputName, String sytleStr, String defaultOption, String selectedValue, String Search,String range) throws Exception {
  50. return getSelectCodeList5(group_cd, inputName, sytleStr, defaultOption, selectedValue, 10, Search, range);
  51. }
  52. /**
  53. * Select 태그 Method
  54. * @param group_cd 검색 조건
  55. * @param inputName Select name
  56. * @param sytleStr Select style
  57. * @param defaultOption Option Default Value
  58. * @param selectedValue Option Selected Value
  59. * @param eventStr
  60. * @return code name
  61. * @throws Exception
  62. */
  63. public static String getSelectCodeList2(String group_cd, String inputName, String sytleStr, String defaultOption, String selectedValue, String eventStr) throws Exception {
  64. return getSelectCodeList2(group_cd, inputName, sytleStr, defaultOption, selectedValue, 10, eventStr);
  65. }
  66. public static String getSelectCodeList3(String group_cd, String inputName, String sytleStr, String defaultOption, String selectedValue, String eventStr) throws Exception {
  67. return getSelectCodeList3(group_cd, inputName, sytleStr, defaultOption, selectedValue, 10, eventStr);
  68. }
  69. public static String getSelectCodeList4(String group_cd, String inputName, String sytleStr, String defaultOption, String selectedValue, String eventStr) throws Exception {
  70. return getSelectCodeList4(group_cd, inputName, sytleStr, defaultOption, selectedValue, 10, eventStr);
  71. }
  72. public static String getSelectCodeList(String group_cd, String inputName, String sytleStr, String defaultOption, String selectedValue, int size, String eventStr) throws Exception {
  73. return getSelectCodeList(group_cd, inputName, sytleStr, defaultOption, selectedValue, size, eventStr, "");
  74. }
  75. public static String getSelectCodeList2(String group_cd, String inputName, String sytleStr, String defaultOption, String selectedValue, int size, String eventStr) throws Exception {
  76. return getSelectCodeList2(group_cd, inputName, sytleStr, defaultOption, selectedValue, size, eventStr, "");
  77. }
  78. public static String getSelectCodeList3(String group_cd, String inputName, String sytleStr, String defaultOption, String selectedValue, int size, String eventStr) throws Exception {
  79. return getSelectCodeList3(group_cd, inputName, sytleStr, defaultOption, selectedValue, size, eventStr, "");
  80. }
  81. public static String getSelectCodeList4(String group_cd, String inputName, String sytleStr, String defaultOption, String selectedValue, int size, String eventStr) throws Exception {
  82. return getSelectCodeList4(group_cd, inputName, sytleStr, defaultOption, selectedValue, size, eventStr, "");
  83. }
  84. /**
  85. * 파라미터로 받은 공통코드의 코드목록을 select.js를 이용하는 HTML SELECT Tag로 리턴한다.
  86. * @param group_cd : 공통코드
  87. * @param inputName : SELECT Tag의 'name' 속성명
  88. * @return <code>String</code>
  89. * @throws Exception
  90. *
  91. */
  92. public static String getSelectCodeList(String group_cd, String inputName, String sytleStr, String defaultOption, String selectedValue, int size, String eventStr, String strClassNm) throws Exception {
  93. ValueObject rowObject = null;
  94. CommCodeManager commCodeManager = new CommCodeManager();
  95. RowSet commCodeRowSet = commCodeManager.getCodeRowSet(group_cd);
  96. /*
  97. * 수정. 황선재
  98. * 수정사항 : eventStr 인자 제거
  99. */
  100. return HTMLMaker.getSelectTag(commCodeRowSet, "CODE", "NAME", inputName, sytleStr, defaultOption, selectedValue, size, strClassNm, eventStr);
  101. }
  102. /**
  103. * 파라미터로 받은 공통코드의 코드목록을 select.js를 이용하는 HTML SELECT Tag로 리턴한다.
  104. * @param group_cd : 공통코드
  105. * @param inputName : SELECT Tag의 'code' 속성명
  106. * @return <code>String</code>
  107. * @throws Exception
  108. */
  109. public static String getSelectCodeList2(String group_cd, String inputName, String sytleStr, String defaultOption, String selectedValue, int size, String eventStr, String strClassNm) throws Exception {
  110. ValueObject rowObject = null;
  111. CommCodeManager commCodeManager = new CommCodeManager();
  112. RowSet commCodeRowSet = commCodeManager.getCodeRowSet2(group_cd);
  113. /*
  114. * 수정. 황선재
  115. * 수정사항 : eventStr 인자 제거
  116. */
  117. return HTMLMaker.getSelectTag2(commCodeRowSet, "CODE", "NAME", inputName, sytleStr, defaultOption, selectedValue, size, strClassNm);
  118. }
  119. /**
  120. * 파라미터로 받은 공통코드의 코드목록을 select.js를 이용하는 HTML SELECT Tag로 리턴한다.
  121. * @param group_cd : 공통코드
  122. * @param inputName : SELECT Tag의 'code' 속성명
  123. * @return <code>String</code>
  124. * @throws Exception
  125. */
  126. public static String getSelectCodeList3(String group_cd, String inputName, String sytleStr, String defaultOption, String selectedValue, int size, String eventStr, String strClassNm) throws Exception {
  127. ValueObject rowObject = null;
  128. CommCodeManager commCodeManager = new CommCodeManager();
  129. RowSet commCodeRowSet = commCodeManager.getCodeRowSet(group_cd);
  130. /*
  131. * 수정. 황선재
  132. * 수정사항 : eventStr 인자 제거
  133. */
  134. return HTMLMaker.getSelectTag(commCodeRowSet, "NAME", "NAME", inputName, sytleStr, defaultOption, selectedValue, size, strClassNm);
  135. }
  136. /**
  137. * 파라미터로 받은 공통코드의 코드목록을 select.js를 이용하는 HTML SELECT Tag로 리턴한다.
  138. * @param group_cd : 공통코드
  139. * @param inputName : SELECT Tag의 'code' 속성명
  140. * @return <code>String</code>
  141. * @throws Exception
  142. */
  143. public static String getSelectCodeList4(String group_cd, String inputName, String sytleStr, String defaultOption, String selectedValue, int size, String eventStr, String strClassNm) throws Exception {
  144. ValueObject rowObject = null;
  145. CommCodeManager commCodeManager = new CommCodeManager();
  146. RowSet commCodeRowSet = commCodeManager.getCodeRowSet3(group_cd);
  147. /*
  148. * 수정. 황선재
  149. * 수정사항 : eventStr 인자 제거
  150. */
  151. return HTMLMaker.getSelectTag(commCodeRowSet, "CODE", "NAME", inputName, sytleStr, defaultOption, selectedValue, size, strClassNm);
  152. }
  153. /**
  154. * 파라미터로 받은 공통코드의 코드목록을 select.js를 이용하는 HTML SELECT Tag로 리턴한다.
  155. * @param group_cd : 공통코드
  156. * @param inputName : SELECT Tag의 'name' 속성명
  157. * @return <code>String</code>
  158. * @throws Exception
  159. *
  160. */
  161. public static String getSelectCodeList5(String group_cd, String inputName, String sytleStr, String defaultOption, String selectedValue, int size, String Search, String range) throws Exception {
  162. ValueObject rowObject = null;
  163. CommCodeManager commCodeManager = new CommCodeManager();
  164. /**
  165. * Search : 쿼리에 검색 조건을 추가 합니다.
  166. * range : 정렬 방식을 추가 합니다.
  167. */
  168. RowSet commCodeRowSet = commCodeManager.getSearchCodeRowSet(group_cd,Search,range);
  169. return HTMLMaker.getSelectTag(commCodeRowSet, "CODE", "NAME", inputName, sytleStr, defaultOption, selectedValue, size, "", "");
  170. }
  171. /**
  172. * 파라미터로 받은 공통코드의 코드목록을 리턴한다.
  173. * @param commCode 공통코드
  174. * @return <code>RowSet</code>
  175. * @throws Exception
  176. */
  177. public static RowSet getCodeRowsetStatic(String group_cd){
  178. CommCodeManager commCodeManager = new CommCodeManager();
  179. RowSet commCodeRowSet = commCodeManager.getCodeRowSet(group_cd);
  180. return commCodeRowSet;
  181. }
  182. public RowSet getCodeRowSet(String group_cd) {
  183. Search search = new SearchImpl();
  184. RowSet rowSet = null;
  185. String sqlstr = "";
  186. try {
  187. sqlstr = " SELECT DETAILCD AS CODE ,DETAILNM AS NAME, SORT_NO AS SEQ \n"
  188. + " FROM " + D_TABLE + " \n"
  189. + " WHERE BASECD = ? \n"
  190. + " ORDER BY SORT_NO \n";
  191. search.setStatement(sqlstr);
  192. search.addParameter(group_cd);
  193. rowSet = search.execute();
  194. }
  195. catch(Exception e) {
  196. WAFLogger.error(this.getClass().getName() + " --> getCodeRowSet() : " + e.getMessage());
  197. WAFLogger.error("SQL : " + search.getStatement());
  198. WAFLogger.error(e);
  199. }
  200. finally {
  201. if( rowSet == null ) rowSet = new RowSetImpl();
  202. }
  203. return rowSet;
  204. }
  205. public RowSet getSearchCodeRowSet(String group_cd, String search_terms, String range) {
  206. Search search = new SearchImpl();
  207. RowSet rowSet = null;
  208. if(range=="")range = "SORT_NO";
  209. String sqlstr = "";
  210. try {
  211. sqlstr = " SELECT DETAILCD AS CODE ,DETAILNM AS NAME, SORT_NO AS SEQ \n"
  212. + " FROM " + D_TABLE + " \n"
  213. + " WHERE BASECD = ? \n"
  214. + search_terms
  215. + " ORDER BY "+range+" \n";
  216. search.setStatement(sqlstr);
  217. search.addParameter(group_cd);
  218. rowSet = search.execute();
  219. }
  220. catch(Exception e) {
  221. WAFLogger.error(this.getClass().getName() + " --> getCodeRowSet() : " + e.getMessage());
  222. WAFLogger.error("SQL : " + search.getStatement());
  223. WAFLogger.error(e);
  224. }
  225. finally {
  226. if( rowSet == null ) rowSet = new RowSetImpl();
  227. }
  228. return rowSet;
  229. }
  230. /**
  231. * 파라미터로 받은 공통코드의 코드목록을 리턴한다.
  232. * @param commCode 공통코드
  233. * @return <code>RowSet</code>
  234. * @throws Exception
  235. */
  236. public static RowSet getCodeRowsetStatic(String group_cd, String column, String code){
  237. CommCodeManager commCodeManager = new CommCodeManager();
  238. RowSet commCodeRowSet = commCodeManager.getCodeRowSet(group_cd, column, code);
  239. return commCodeRowSet;
  240. }
  241. public RowSet getCodeRowSet(String group_cd, String column, String code) {
  242. Search search = new SearchImpl();
  243. RowSet rowSet = null;
  244. String sqlstr = "";
  245. try {
  246. sqlstr = " SELECT DETAILCD, DETAILNM, CHG_CODE01, CHG_CODE02, CHG_CODE03, CHG_CODE04, CHG_CODE05, CHG_CODE06, REMARK, SORT_NO, DETAILSORTNM \n"
  247. + " FROM " + D_TABLE + " \n"
  248. + " WHERE BASECD = ? \n"
  249. + " AND "+column+" = ? \n"
  250. + " ORDER BY SORT_NO \n";
  251. search.setStatement(sqlstr);
  252. search.addParameter(group_cd);
  253. search.addParameter(code);
  254. rowSet = search.execute();
  255. }
  256. catch(Exception e) {
  257. WAFLogger.error(this.getClass().getName() + " --> getCodeRowSet() : " + e.getMessage());
  258. WAFLogger.error("SQL : " + search.getStatement());
  259. WAFLogger.error(e);
  260. }
  261. finally {
  262. if( rowSet == null ) rowSet = new RowSetImpl();
  263. }
  264. return rowSet;
  265. }
  266. /**
  267. * 파라미터로 받은 공통코드의 코드목록을 리턴한다.
  268. * @param commCode 공통코드
  269. * @return <code>RowSet</code>
  270. * @throws Exception
  271. */
  272. public RowSet getCodeRowSet2(String group_cd) {
  273. Search search = new SearchImpl();
  274. RowSet rowSet = null;
  275. String sqlstr = "";
  276. try {
  277. sqlstr = " SELECT DETAILCD AS CODE ,DETAILCD||': '||DETAILNM as name \n"
  278. + " FROM " + D_TABLE + " \n"
  279. + " WHERE BASECD = ? \n"
  280. + " ORDER BY SORT_NO \n";
  281. search.setStatement(sqlstr);
  282. search.addParameter(group_cd);
  283. rowSet = search.execute();
  284. }
  285. catch(Exception e) {
  286. WAFLogger.error(this.getClass().getName() + " --> getCodeRowSet() : " + e.getMessage());
  287. WAFLogger.error("SQL : " + search.getStatement());
  288. WAFLogger.error(e);
  289. }
  290. finally {
  291. if( rowSet == null ) rowSet = new RowSetImpl();
  292. return rowSet;
  293. }
  294. }
  295. /**
  296. * 파라미터로 받은 공통코드의 코드목록을 리턴한다.
  297. * @param commCode 공통코드
  298. * @return <code>RowSet</code>
  299. * @throws Exception
  300. */
  301. public RowSet getCodeRowSet3(String group_cd) {
  302. Search search = new SearchImpl();
  303. RowSet rowSet = null;
  304. String sqlstr = "";
  305. try {
  306. sqlstr = " SELECT DETAILNM || ';' || DETAILCD AS CODE, DETAILNM AS NAME \n"
  307. + " FROM " + D_TABLE + " \n"
  308. + " WHERE BASECD = ? \n"
  309. + " ORDER BY SORT_NO \n";
  310. search.setStatement(sqlstr);
  311. search.addParameter(group_cd);
  312. rowSet = search.execute();
  313. }
  314. catch(Exception e) {
  315. WAFLogger.error(this.getClass().getName() + " --> getCodeRowSet() : " + e.getMessage());
  316. WAFLogger.error("SQL : " + search.getStatement());
  317. WAFLogger.error(e);
  318. }
  319. finally {
  320. if( rowSet == null ) rowSet = new RowSetImpl();
  321. return rowSet;
  322. }
  323. }
  324. /**
  325. * 정렬방법 RowSet을 리턴
  326. * @return
  327. */
  328. public static RowSet getSortMethodRowSet() {
  329. String[] SORT_METHOD = {"순번", "코드명", "한글명", "영문명", "등록일시"};
  330. RowSet rowSet = new RowSetImpl();
  331. for( int i = 0 ; i < SORT_METHOD.length ; i++ ) {
  332. Row row = new RowImpl();
  333. row.addColumn("SEQ" , Integer.toString(i + 1));
  334. row.addColumn("NAME", SORT_METHOD[i]);
  335. rowSet.addRow(row);
  336. }
  337. return rowSet;
  338. }
  339. /**
  340. *
  341. * @param commCode
  342. * @return RowSet
  343. * @throws Exception
  344. */
  345. public static RowSet getCodeList(String commCode) throws Exception {
  346. CommCodeManager commCodeManager = new CommCodeManager();
  347. return commCodeManager.getCodeRowSet(commCode);
  348. }
  349. /**
  350. * 결재 후처리할 클레스를 넘겨준다.
  351. * @param signGB
  352. * @return Sign After Control Class
  353. * @throws Exception
  354. */
  355. public static String getSignClass(String signGB) throws Exception {
  356. CommCodeManager commCodeManager = new CommCodeManager();
  357. return commCodeManager.getSignAfterClass(signGB);
  358. }
  359. /**
  360. * 결재 후처리할 클레스를 넘겨준다.
  361. * @param signGB
  362. * @return
  363. */
  364. private String getSignAfterClass(String signGB) {
  365. Search search = new SearchImpl();
  366. RowSet rowSet = null;
  367. String sqlstr = "";
  368. String ret_val = "";
  369. try {
  370. sqlstr = " SELECT DETAILNM AS NAME \n"
  371. + " FROM " + D_TABLE + " \n"
  372. + " WHERE BASECD = 'DRAFT' \n"
  373. + " AND DETAILCD = ? \n";
  374. search.setStatement(sqlstr);
  375. search.addParameter(signGB);
  376. rowSet = search.execute();
  377. if(rowSet.size() > 0){
  378. ret_val = rowSet.getRow(0).get("NAME");
  379. }
  380. }
  381. catch(Exception e) {
  382. WAFLogger.error(this.getClass().getName() + " --> getCodeRowSet() : " + e.getMessage());
  383. WAFLogger.error("SQL : " + search.getStatement());
  384. WAFLogger.error(e);
  385. }
  386. return ret_val;
  387. }
  388. }