ContCodeManager.java 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. /**
  2. * @(#)file ContCodeManager.java
  3. * @(#)author Kim Myung Ho
  4. * @(#)version 1.0
  5. * @(#)date 2014-08-14
  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.RowSet;
  13. import kr.co.hsnc.common.sql.RowSetImpl;
  14. import kr.co.hsnc.common.sql.search.Search;
  15. import kr.co.hsnc.common.sql.search.SearchImpl;
  16. import kr.co.hsnc.common.sql.util.RowSetUtility;
  17. import kr.co.hsnc.common.util.ValueObject;
  18. import com.udapsoft.waf.common.ui.HTMLMaker;
  19. public class ContCodeManager {
  20. public static String getCcsifSelectCodeList(String group_cd, String inputName, String sytleStr, String defaultOption, String selectedValue, String dept_cd, String pay_div) throws Exception {
  21. return getCcsifSelectCodeList(group_cd, inputName, sytleStr, defaultOption, selectedValue, 10, "", null, dept_cd, pay_div);
  22. }
  23. public static String getCcsifSelectCodeList(String group_cd, String inputName, String sytleStr, String defaultOption, String selectedValue, String eventStr, String dept_cd, String pay_div) throws Exception {
  24. return getCcsifSelectCodeList(group_cd, inputName, sytleStr, defaultOption, selectedValue, 10, eventStr, null, dept_cd, pay_div);
  25. }
  26. /**
  27. * 파라미터로 받은 공통코드의 코드목록을 select.js를 이용하는 HTML SELECT Tag로 리턴한다.
  28. * @param group_cd : 공통코드
  29. * @param inputName : SELECT Tag의 'name' 속성명
  30. * @return <code>String</code>
  31. * @throws Exception
  32. *
  33. */
  34. public static String getCcsifSelectCodeList(String group_cd, String inputName, String sytleStr, String defaultOption, String selectedValue, int size, String eventStr, String strClassNm, String dept_cd, String pay_div) throws Exception {
  35. ValueObject rowObject = null;
  36. ContCodeManager contCodeManager = new ContCodeManager();
  37. RowSet commCodeRowSet = contCodeManager.getCodeRowSet(group_cd, dept_cd, pay_div);
  38. return HTMLMaker.getSelectTag(commCodeRowSet, "CODE", "NAME", inputName, sytleStr, defaultOption, selectedValue, size, strClassNm, eventStr);
  39. }
  40. /*
  41. * 증빙구분 : []
  42. */
  43. public static String getProofCdSelectTag(String selId, String style, String eventStr, String defaultOption, String selValue, String chg_code20) {
  44. ContCodeManager contCodeManager = new ContCodeManager();
  45. RowSet rowSet = contCodeManager.getProofCdRowSet(chg_code20);
  46. return HTMLMaker.getSelectTag(rowSet, "CODE", "NAME", selId, style, defaultOption, selValue, rowSet.size(), null, eventStr);
  47. // getSelectTag(rowSet, valueName, dscrName, inputName, sytleStr, defaultOption, selectedValue, size, strClassNm, null);
  48. }
  49. /*
  50. * 증빙구분 : []
  51. */
  52. public static String getProofCdSelectTag(String selId, String style, String eventStr, String defaultOption, String selValue, String chg_code20, String attributes) {
  53. ContCodeManager contCodeManager = new ContCodeManager();
  54. RowSet rowSet = contCodeManager.getProofCdRowSet(chg_code20);
  55. return HTMLMaker.getSelectTag(rowSet, "CODE", "NAME", selId, style, defaultOption, selValue, rowSet.size(), attributes, eventStr);
  56. }
  57. /*
  58. * 사업부에 따른 기성 Pay Group Select Tag 만들기 :
  59. */
  60. public static String getPayGroupSelectTag(String selId, String style, String eventStr, String defaultOption, String selValue, String unitCd) {
  61. ContCodeManager contCodeManager = new ContCodeManager();
  62. RowSet rowSet = contCodeManager.getPayGroupRowSet(unitCd);
  63. return HTMLMaker.getSelectTag(rowSet, "CODE", "NAME", selId, style, defaultOption, selValue, rowSet.size(), null, eventStr);
  64. }
  65. public static String getPayGroupSelectTag(String selId, String style, String eventStr, String defaultOption, String selValue, String unitCd, String attributes) {
  66. ContCodeManager contCodeManager = new ContCodeManager();
  67. RowSet rowSet = contCodeManager.getPayGroupRowSet(unitCd);
  68. return HTMLMaker.getSelectTag(rowSet, "CODE", "NAME", selId, style, defaultOption, selValue, rowSet.size(), attributes, eventStr);
  69. }
  70. /**
  71. * 파라미터로 받은 공통코드의 코드목록을 리턴한다.
  72. * @param commCode 공통코드
  73. * @return <code>RowSet</code>
  74. * @throws Exception
  75. */
  76. public static RowSet getCodeRowsetStatic(String group_cd, String dept_cd, String pay_div){
  77. ContCodeManager contCodeManager = new ContCodeManager();
  78. RowSet commCodeRowSet = contCodeManager.getCodeRowSet(group_cd, dept_cd, pay_div);
  79. return commCodeRowSet;
  80. }
  81. public RowSet getCodeRowSet(String group_cd, String dept_cd, String pay_div) {
  82. Search search = new SearchImpl();
  83. RowSet rowSet = null;
  84. String sqlstr = "";
  85. try {
  86. if(group_cd.equals("SUB_ACCT_GB")){
  87. sqlstr = " SELECT DETAILCD AS CODE ,DETAILNM AS NAME, SORT_NO AS SEQ \n"
  88. + " FROM EBID_COM911T \n"
  89. + " WHERE BASECD = ? \n"
  90. + " ORDER BY SORT_NO \n";
  91. search.setStatement(sqlstr);
  92. search.addParameter(group_cd);
  93. }else{
  94. if(pay_div.equals("1")){
  95. sqlstr = " SELECT DETAILCD AS CODE ,DETAILNM AS NAME, SORT_NO AS SEQ \n"
  96. + " FROM EBID_COM911T \n"
  97. + " WHERE BASECD = ? \n"
  98. + " AND CHG_CODE02 = NVL((SELECT PROC_TYP_GB FROM ETEC_ERPIF.ACZ10100 WHERE DEPT_CD = ?),2) \n"
  99. + " ORDER BY SORT_NO \n";
  100. search.setStatement(sqlstr);
  101. search.addParameter(group_cd);
  102. search.addParameter(dept_cd);
  103. }else{
  104. sqlstr = " SELECT DETAILCD AS CODE ,DETAILNM AS NAME, SORT_NO AS SEQ \n"
  105. + " FROM EBID_COM911T \n"
  106. + " WHERE BASECD = ? \n"
  107. + " AND CHG_CODE02 = 2 \n"
  108. + " ORDER BY SORT_NO \n";
  109. search.setStatement(sqlstr);
  110. search.addParameter(group_cd);
  111. }
  112. }
  113. rowSet = search.execute();
  114. WAFLogger.debug("sql :"+sqlstr);
  115. }
  116. catch(Exception e) {
  117. WAFLogger.error(this.getClass().getName() + " --> getCodeRowSet() : " + e.getMessage());
  118. WAFLogger.error("SQL : " + search.getStatement());
  119. WAFLogger.error(e);
  120. }
  121. finally {
  122. if( rowSet == null ) rowSet = new RowSetImpl();
  123. }
  124. return rowSet;
  125. }
  126. // 증빙구분
  127. public RowSet getProofCdRowSet(String chg_code20) {
  128. Search search = new SearchImpl();
  129. RowSet rowSet = null;
  130. StringBuffer sql = new StringBuffer();
  131. try {
  132. sql.append(" SELECT DETAILCD AS CODE \n");
  133. sql.append(" , DETAILNM AS NAME \n");
  134. sql.append(" , CHG_CODE10 AS VAT_CLASS \n");
  135. sql.append(" FROM EBID_COM911T \n");
  136. //sql.append(" WHERE BASECD = '007' \n");2018.12.17
  137. sql.append(" WHERE BASECD = 'PROOF_CD' \n");
  138. sql.append(" AND CHG_CODE20 = ? \n");
  139. sql.append(" ORDER BY DETAILCD \n");
  140. search.setStatement(sql.toString());
  141. search.addParameter(chg_code20);
  142. rowSet = search.execute();
  143. WAFLogger.debug("sql :"+sql);
  144. } catch(Exception e) {
  145. WAFLogger.error("SQL : " + search.getStatement());
  146. WAFLogger.error(e);
  147. } finally {
  148. if( rowSet == null ) rowSet = new RowSetImpl();
  149. }
  150. return rowSet;
  151. }
  152. // 기성 PAY GROUP
  153. public RowSet getPayGroupRowSet(String unitCd) {
  154. Search search = new SearchImpl();
  155. RowSet rowSet = null;
  156. StringBuffer sql = new StringBuffer();
  157. try {
  158. sql.append(" SELECT DETAILCD AS CODE \n");
  159. sql.append(" , DETAILNM AS NAME \n");
  160. sql.append(" FROM EBID_COM911T \n");
  161. sql.append(" WHERE BASECD = 'ERP_005' \n");
  162. /*sql.append(" WHERE BASECD = '005' \n");2018.12.17
  163. if ("10".equals(unitCd)) { // 생활환경사업부
  164. sql.append(" AND CHG_CODE04 IN ('10', '*') \n");
  165. } else if ("60".equals(unitCd)) { // 발전사업본부
  166. sql.append(" AND CHG_CODE04 IN ('60', '*') \n");
  167. }
  168. else { // 그 외 사업부
  169. sql.append(" AND CHG_CODE04 IN ('20', '*') \n");
  170. }*/
  171. sql.append(" ORDER BY DETAILCD \n");
  172. search.setStatement(sql.toString());
  173. rowSet = search.execute();
  174. WAFLogger.debug("sql :"+sql);
  175. } catch(Exception e) {
  176. WAFLogger.error("SQL : " + search.getStatement());
  177. WAFLogger.error(e);
  178. } finally {
  179. if( rowSet == null ) rowSet = new RowSetImpl();
  180. }
  181. return rowSet;
  182. }
  183. /*
  184. * @return String payment terms JSON표현
  185. */
  186. public String getJSONNotation() {
  187. // 직군(중) 구하기
  188. RowSet payGroup_01 = getPayGroupRowSetSub("01"); // 전도금정산
  189. RowSet payGroup_02 = getPayGroupRowSetSub("02"); // 현금(계산서)
  190. RowSet payGroup_11 = getPayGroupRowSetSub("11"); // 비용정산
  191. RowSet payGroup_21 = getPayGroupRowSetSub("21"); // 선급금
  192. RowSet payGroup_22 = getPayGroupRowSetSub("22"); // 선급금C
  193. RowSet payGroup_23 = getPayGroupRowSetSub("23"); // 선급금D
  194. RowSet payGroup_30 = getPayGroupRowSetSub("30"); // 어음(계산서)
  195. RowSet payGroup_41 = getPayGroupRowSetSub("41"); // 기성
  196. RowSet payGroup_42 = getPayGroupRowSetSub("42"); // 기성C
  197. RowSet payGroup_43 = getPayGroupRowSetSub("43"); // 기성D
  198. RowSet payGroup_55 = getPayGroupRowSetSub("55"); // 공용법인
  199. RowSet payGroup_61 = getPayGroupRowSetSub("61"); // 업무가불
  200. RowSet payGroup_71 = getPayGroupRowSetSub("71"); // LC
  201. RowSet payGroup_72 = getPayGroupRowSetSub("72"); // LC(C)
  202. RowSet payGroup_73 = getPayGroupRowSetSub("73"); // 외화송금
  203. RowSet payGroup_74 = getPayGroupRowSetSub("74"); // LC => 발전
  204. RowSet payGroup_91 = getPayGroupRowSetSub("91"); // 기타
  205. String category = "";
  206. StringBuffer paymentTerms = new StringBuffer();
  207. paymentTerms = getNotation( payGroup_01,
  208. payGroup_02,
  209. payGroup_11,
  210. payGroup_21,
  211. payGroup_22,
  212. payGroup_23,
  213. payGroup_30,
  214. payGroup_41,
  215. payGroup_42,
  216. payGroup_43,
  217. payGroup_55,
  218. payGroup_61,
  219. payGroup_71,
  220. payGroup_72,
  221. payGroup_73,
  222. payGroup_74,
  223. payGroup_91);
  224. category = "{\"paymentTerms\": {" + paymentTerms + "\n\t} \n}";
  225. return category;
  226. }
  227. /*
  228. * @purpose category2 내역 구하기
  229. */
  230. private StringBuffer getNotation( RowSet payGroup_01,
  231. RowSet payGroup_02,
  232. RowSet payGroup_11,
  233. RowSet payGroup_21,
  234. RowSet payGroup_22,
  235. RowSet payGroup_23,
  236. RowSet payGroup_30,
  237. RowSet payGroup_41,
  238. RowSet payGroup_42,
  239. RowSet payGroup_43,
  240. RowSet payGroup_55,
  241. RowSet payGroup_61,
  242. RowSet payGroup_71,
  243. RowSet payGroup_72,
  244. RowSet payGroup_73,
  245. RowSet payGroup_74,
  246. RowSet payGroup_91) {
  247. StringBuffer category2 = new StringBuffer();
  248. ValueObject row = null;
  249. int size = payGroup_01.size();
  250. category2.append("\n\t\"01\":[");
  251. for (int i=0; i<size; i++ ) {
  252. row = RowSetUtility.getValueObject(payGroup_01.getRow(i));
  253. category2.append("\n\t\t{");
  254. category2.append("\"CODE\":\"" + row.get("CODE") + "\" , \"NAME\": \"").append(row.get("NAME")).append("\"}");
  255. if (i != (size-1)) {
  256. category2.append(",");
  257. }
  258. }
  259. category2.append("\n\t],");
  260. size = payGroup_02.size();
  261. category2.append("\n\t\"02\":[");
  262. for (int i=0; i<size; i++ ) {
  263. row = RowSetUtility.getValueObject(payGroup_02.getRow(i));
  264. category2.append("\n\t\t{");
  265. category2.append("\"CODE\":\"" + row.get("CODE") + "\" , \"NAME\": \"").append(row.get("NAME")).append("\"}");
  266. if (i != (size-1)) {
  267. category2.append(",");
  268. }
  269. }
  270. category2.append("\n\t],");
  271. size = payGroup_11.size();
  272. category2.append("\n\t\"11\":[");
  273. for (int i=0; i<size; i++ ) {
  274. row = RowSetUtility.getValueObject(payGroup_11.getRow(i));
  275. category2.append("\n\t\t{");
  276. category2.append("\"CODE\":\"" + row.get("CODE") + "\" , \"NAME\": \"").append(row.get("NAME")).append("\"}");
  277. if (i != (size-1)) {
  278. category2.append(",");
  279. }
  280. }
  281. category2.append("\n\t],");
  282. size = payGroup_21.size();
  283. category2.append("\n\t\"21\":[");
  284. for (int i=0; i<size; i++ ) {
  285. row = RowSetUtility.getValueObject(payGroup_21.getRow(i));
  286. category2.append("\n\t\t{");
  287. category2.append("\"CODE\":\"" + row.get("CODE") + "\" , \"NAME\": \"").append(row.get("NAME")).append("\"}");
  288. if (i != (size-1)) {
  289. category2.append(",");
  290. }
  291. }
  292. category2.append("\n\t],");
  293. size = payGroup_22.size();
  294. category2.append("\n\t\"22\":[");
  295. for (int i=0; i<size; i++ ) {
  296. row = RowSetUtility.getValueObject(payGroup_22.getRow(i));
  297. category2.append("\n\t\t{");
  298. category2.append("\"CODE\":\"" + row.get("CODE") + "\" , \"NAME\": \"").append(row.get("NAME")).append("\"}");
  299. if (i != (size-1)) {
  300. category2.append(",");
  301. }
  302. }
  303. category2.append("\n\t],");
  304. size = payGroup_23.size();
  305. category2.append("\n\t\"23\":[");
  306. for (int i=0; i<size; i++ ) {
  307. row = RowSetUtility.getValueObject(payGroup_23.getRow(i));
  308. category2.append("\n\t\t{");
  309. category2.append("\"CODE\":\"" + row.get("CODE") + "\" , \"NAME\": \"").append(row.get("NAME")).append("\"}");
  310. if (i != (size-1)) {
  311. category2.append(",");
  312. }
  313. }
  314. category2.append("\n\t],");
  315. size = payGroup_30.size();
  316. category2.append("\n\t\"30\":[");
  317. for (int i=0; i<size; i++ ) {
  318. row = RowSetUtility.getValueObject(payGroup_30.getRow(i));
  319. category2.append("\n\t\t{");
  320. category2.append("\"CODE\":\"" + row.get("CODE") + "\" , \"NAME\": \"").append(row.get("NAME")).append("\"}");
  321. if (i != (size-1)) {
  322. category2.append(",");
  323. }
  324. }
  325. category2.append("\n\t],");
  326. size = payGroup_41.size();
  327. category2.append("\n\t\"41\":[");
  328. for (int i=0; i<size; i++ ) {
  329. row = RowSetUtility.getValueObject(payGroup_41.getRow(i));
  330. category2.append("\n\t\t{");
  331. category2.append("\"CODE\":\"" + row.get("CODE") + "\" , \"NAME\": \"").append(row.get("NAME")).append("\"}");
  332. if (i != (size-1)) {
  333. category2.append(",");
  334. }
  335. }
  336. category2.append("\n\t],");
  337. size = payGroup_42.size();
  338. category2.append("\n\t\"42\":[");
  339. for (int i=0; i<size; i++ ) {
  340. row = RowSetUtility.getValueObject(payGroup_42.getRow(i));
  341. category2.append("\n\t\t{");
  342. category2.append("\"CODE\":\"" + row.get("CODE") + "\" , \"NAME\": \"").append(row.get("NAME")).append("\"}");
  343. if (i != (size-1)) {
  344. category2.append(",");
  345. }
  346. }
  347. category2.append("\n\t],");
  348. size = payGroup_43.size();
  349. category2.append("\n\t\"43\":[");
  350. for (int i=0; i<size; i++ ) {
  351. row = RowSetUtility.getValueObject(payGroup_43.getRow(i));
  352. category2.append("\n\t\t{");
  353. category2.append("\"CODE\":\"" + row.get("CODE") + "\" , \"NAME\": \"").append(row.get("NAME")).append("\"}");
  354. if (i != (size-1)) {
  355. category2.append(",");
  356. }
  357. }
  358. category2.append("\n\t],");
  359. size = payGroup_55.size();
  360. category2.append("\n\t\"55\":[");
  361. for (int i=0; i<size; i++ ) {
  362. row = RowSetUtility.getValueObject(payGroup_55.getRow(i));
  363. category2.append("\n\t\t{");
  364. category2.append("\"CODE\":\"" + row.get("CODE") + "\" , \"NAME\": \"").append(row.get("NAME")).append("\"}");
  365. if (i != (size-1)) {
  366. category2.append(",");
  367. }
  368. }
  369. category2.append("\n\t],");
  370. size = payGroup_61.size();
  371. category2.append("\n\t\"61\":[");
  372. for (int i=0; i<size; i++ ) {
  373. row = RowSetUtility.getValueObject(payGroup_61.getRow(i));
  374. category2.append("\n\t\t{");
  375. category2.append("\"CODE\":\"" + row.get("CODE") + "\" , \"NAME\": \"").append(row.get("NAME")).append("\"}");
  376. if (i != (size-1)) {
  377. category2.append(",");
  378. }
  379. }
  380. category2.append("\n\t],");
  381. size = payGroup_71.size();
  382. category2.append("\n\t\"71\":[");
  383. for (int i=0; i<size; i++ ) {
  384. row = RowSetUtility.getValueObject(payGroup_71.getRow(i));
  385. category2.append("\n\t\t{");
  386. category2.append("\"CODE\":\"" + row.get("CODE") + "\" , \"NAME\": \"").append(row.get("NAME")).append("\"}");
  387. if (i != (size-1)) {
  388. category2.append(",");
  389. }
  390. }
  391. category2.append("\n\t],");
  392. size = payGroup_72.size();
  393. category2.append("\n\t\"72\":[");
  394. for (int i=0; i<size; i++ ) {
  395. row = RowSetUtility.getValueObject(payGroup_72.getRow(i));
  396. category2.append("\n\t\t{");
  397. category2.append("\"CODE\":\"" + row.get("CODE") + "\" , \"NAME\": \"").append(row.get("NAME")).append("\"}");
  398. if (i != (size-1)) {
  399. category2.append(",");
  400. }
  401. }
  402. category2.append("\n\t],");
  403. size = payGroup_73.size();
  404. category2.append("\n\t\"73\":[");
  405. for (int i=0; i<size; i++ ) {
  406. row = RowSetUtility.getValueObject(payGroup_73.getRow(i));
  407. category2.append("\n\t\t{");
  408. category2.append("\"CODE\":\"" + row.get("CODE") + "\" , \"NAME\": \"").append(row.get("NAME")).append("\"}");
  409. if (i != (size-1)) {
  410. category2.append(",");
  411. }
  412. }
  413. category2.append("\n\t],");
  414. size = payGroup_74.size();
  415. category2.append("\n\t\"74\":[");
  416. for (int i=0; i<size; i++ ) {
  417. row = RowSetUtility.getValueObject(payGroup_74.getRow(i));
  418. category2.append("\n\t\t{");
  419. category2.append("\"CODE\":\"" + row.get("CODE") + "\" , \"NAME\": \"").append(row.get("NAME")).append("\"}");
  420. if (i != (size-1)) {
  421. category2.append(",");
  422. }
  423. }
  424. category2.append("\n\t],");
  425. size = payGroup_91.size();
  426. category2.append("\n\t\"91\":[");
  427. for (int i=0; i<size; i++ ) {
  428. row = RowSetUtility.getValueObject(payGroup_91.getRow(i));
  429. category2.append("\n\t\t{");
  430. category2.append("\"CODE\":\"" + row.get("CODE") + "\" , \"NAME\": \"").append(row.get("NAME")).append("\"}");
  431. if (i != (size-1)) {
  432. category2.append(",");
  433. }
  434. }
  435. category2.append("\n\t]");
  436. return category2;
  437. }
  438. // 증빙구분
  439. public RowSet getPayGroupRowSetSub(String chg_code01) {
  440. Search search = new SearchImpl();
  441. RowSet rowSet = null;
  442. StringBuffer sql = new StringBuffer();
  443. try {
  444. sql.append(" SELECT CHG_CODE02 AS CODE \n");
  445. sql.append(" , CHG_CODE03 AS NAME \n");
  446. sql.append(" FROM EBID_COM911T \n");
  447. sql.append(" WHERE BASECD = 'ERP_006' \n"); //2018.12.17
  448. sql.append(" AND CHG_CODE01 = ? \n");
  449. sql.append(" ORDER BY DETAILCD \n");
  450. search.setStatement(sql.toString());
  451. search.addParameter(chg_code01);
  452. rowSet = search.execute();
  453. } catch(Exception e) {
  454. WAFLogger.error("SQL : " + search.getStatement());
  455. WAFLogger.error(e);
  456. } finally {
  457. if( rowSet == null ) rowSet = new RowSetImpl();
  458. }
  459. return rowSet;
  460. }
  461. }