CommonSignThreadBiz.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. /**
  2. * @(#)file SignThreadBiz.java
  3. * @(#)author DaeJin Lee
  4. * @(#)version 1.0
  5. * @(#)date Jun 10, 2005
  6. * @(#)since JDK 1.4.2
  7. *
  8. * Copyright (c) www.dcchem.co.kr, Inc.
  9. * All rights reserved.
  10. * This software is the proprietary information of dcchem, Inc.
  11. */
  12. package kr.co.udapsoft.common.commonSign;
  13. import java.sql.Connection;
  14. import kr.co.hsnc.common.base.WAFLogger;
  15. import kr.co.hsnc.common.logger.Logger;
  16. import kr.co.hsnc.common.sql.Row;
  17. import kr.co.hsnc.common.sql.RowImpl;
  18. import kr.co.hsnc.common.sql.RowSet;
  19. import kr.co.hsnc.common.sql.RowSetImpl;
  20. import kr.co.hsnc.common.sql.WAFConnection;
  21. import kr.co.hsnc.common.sql.WAFConnectionImpl;
  22. import kr.co.hsnc.common.sql.WAFSQLException;
  23. import kr.co.hsnc.common.sql.persistent.Persistent;
  24. import kr.co.hsnc.common.sql.persistent.PersistentImpl;
  25. import kr.co.hsnc.common.sql.search.Search;
  26. import kr.co.hsnc.common.sql.search.SearchImpl;
  27. import kr.co.hsnc.common.util.ValueObject;
  28. /**
  29. *
  30. * @version 1.0
  31. * @author DaeJin Lee
  32. */
  33. public class CommonSignThreadBiz {
  34. private WAFConnection conn = null;
  35. public CommonSignThreadBiz() {
  36. this.conn = new WAFConnectionImpl();
  37. }
  38. /**
  39. * 전자결재 처리결과 수신 Biz
  40. */
  41. public void doBiz() throws Exception {
  42. try {
  43. RowSet rowSignInterface = getIFSignInfo();
  44. setSign(rowSignInterface);
  45. } catch(Exception se) {
  46. WAFLogger.error(this.getClass().getName() + " --> setInsert() : " + se.getMessage());
  47. WAFLogger.error(se);
  48. throw se;
  49. }
  50. }
  51. private RowSet getIFSignInfo() throws Exception{
  52. Search search = new SearchImpl();
  53. RowSet rowSet = new RowSetImpl();
  54. StringBuffer sqlstr = new StringBuffer();
  55. try {
  56. System.out.println("쓰레드 시작-----------------------");
  57. sqlstr.append(" SELECT SIGN_INTERFACE_ID \n");
  58. sqlstr.append(" ,SIGN_DECI_CLASS \n");
  59. sqlstr.append(" ,APPROVAL_DATE \n");
  60. sqlstr.append(" ,APPROVAL_SABUN \n");
  61. sqlstr.append(" ,APPROVAL_USER \n");
  62. sqlstr.append(" ,SIGN_TYPE \n");
  63. sqlstr.append(" ,KEY_COL1 \n");
  64. sqlstr.append(" ,KEY_COL2 \n");
  65. sqlstr.append(" ,KEY_COL3 \n");
  66. sqlstr.append(" ,KEY_COL4 \n");
  67. sqlstr.append(" ,KEY_COL5 \n");
  68. sqlstr.append(" ,ATTR_1 \n");
  69. sqlstr.append(" ,ATTR_2 \n");
  70. sqlstr.append(" ,ATTR_3 \n");
  71. sqlstr.append(" ,ATTR_4 \n");
  72. sqlstr.append(" ,ATTR_5 \n");
  73. sqlstr.append(" ,DOC_ID \n");
  74. sqlstr.append(" ,SIGN_CLASS_CD \n");
  75. sqlstr.append(" ,B.ACCT_ID \n");
  76. sqlstr.append(" ,B.PSOSO AS DEPT_CD \n");
  77. sqlstr.append(" ,GET_DEPT_NM(B.PSOSO) AS DEPT_NM \n");
  78. sqlstr.append(" ,B.DEPART_DEPT_CD AS ACC_DEPT_CD \n");
  79. sqlstr.append(" ,B.DEPART_DEPT_NM AS ACC_DEPT_NM \n");
  80. sqlstr.append(" FROM SIGN001T A \n");
  81. sqlstr.append(" ,PUB0120T B \n");
  82. sqlstr.append(" WHERE ATTR_6 = 0 \n");
  83. sqlstr.append(" AND SIGN_DECI_CLASS IN ('12','13','14','22','23','24','25') \n");
  84. sqlstr.append(" AND A.APPROVAL_SABUN = B.USER_SABUN(+) \n");
  85. search.setStatement(sqlstr.toString());
  86. rowSet = search.execute();
  87. System.out.println("rowSet = "+rowSet.size());
  88. System.out.println("쓰레드 종료-----------------------");
  89. }
  90. catch(WAFSQLException se) {
  91. Logger.err.println("SQL : \n" + se.getStatement());
  92. Logger.err.println("PARAM : \n" + se.getParameter());
  93. throw se;
  94. }
  95. finally {
  96. if( rowSet == null ) rowSet = new RowSetImpl();
  97. return rowSet;
  98. }
  99. }
  100. private void setSign(RowSet rowSignInterface){
  101. String driverName = "";
  102. String str_doc_state = "";
  103. Row row = new RowImpl();
  104. System.out.println("rowSignInterface.size() = "+rowSignInterface.size());
  105. for ( int i = 0 ; i < rowSignInterface.size() ; i ++ ) {
  106. row = rowSignInterface.getRow(i);
  107. try {
  108. conn.begin();
  109. if( row.get("SIGN_CLASS_CD").equals("") ) {
  110. Logger.err.println("SIGN_CLASS_CD 정보가 없습니다..\\n");
  111. continue;
  112. }
  113. // 결재진행상태 값을 가져온다.
  114. str_doc_state = row.get("SIGN_DECI_CLASS");
  115. System.out.println("str_doc_state = "+str_doc_state);
  116. // 상태별 Call 처리
  117. try {
  118. ValueObject signDoc = new ValueObject();
  119. signDoc.set("SIGN_INTERFACE_ID", row.get("SIGN_INTERFACE_ID"));
  120. signDoc.set("SIGN_DECI_CLASS", row.get("SIGN_DECI_CLASS"));
  121. signDoc.set("APPROVAL_DATE", row.get("APPROVAL_DATE"));
  122. signDoc.set("APPROVAL_SABUN", row.get("APPROVAL_SABUN"));
  123. signDoc.set("APPROVAL_USER", row.get("APPROVAL_USER"));
  124. signDoc.set("SIGN_TYPE", row.get("SIGN_TYPE"));
  125. signDoc.set("KEY_COL1", row.get("KEY_COL1"));
  126. signDoc.set("KEY_COL2", row.get("KEY_COL2"));
  127. signDoc.set("KEY_COL3", row.get("KEY_COL3"));
  128. signDoc.set("KEY_COL4", row.get("KEY_COL4"));
  129. signDoc.set("KEY_COL5", row.get("KEY_COL5"));
  130. signDoc.set("ATTR_1", row.get("ATTR_1"));
  131. signDoc.set("ATTR_2", row.get("ATTR_2"));
  132. signDoc.set("ATTR_3", row.get("ATTR_3"));
  133. signDoc.set("ATTR_4", row.get("ATTR_4"));
  134. signDoc.set("ATTR_5", row.get("ATTR_5"));
  135. signDoc.set("ACCT_TYPE", row.get("ATTR_5"));
  136. signDoc.set("DOC_ID", row.get("DOC_ID"));
  137. signDoc.set("SIGN_CLASS_CD", row.get("SIGN_CLASS_CD"));
  138. signDoc.set("ACCT_ID", row.get("ACCT_ID"));
  139. signDoc.set("DEPT_CD", row.get("DEPT_CD"));
  140. signDoc.set("DEPT_NM", row.get("DEPT_NM"));
  141. signDoc.set("ACC_DEPT_CD", row.get("ACC_DEPT_CD"));
  142. signDoc.set("ACC_DEPT_NM", row.get("ACC_DEPT_NM"));
  143. driverName = getSignDriverName(row.get("SIGN_CLASS_CD"));
  144. System.out.println("driverName = "+driverName);
  145. if(!"".equals(driverName)){
  146. CommonSignInterface driver = CommonSignManager.createSignDriver(driverName);
  147. if ( str_doc_state.equals("12") || str_doc_state.equals("13") ){ // 1차 반려
  148. driver.doFirstRejectSign(conn.getConnection(), signDoc);
  149. } else if ( str_doc_state.equals("14") ){ // 1차 결제 완료
  150. driver.doFirstFinishSign(conn.getConnection(), signDoc);
  151. } else if ( str_doc_state.equals("22") || str_doc_state.equals("23") ){ // 2차 결제 반려
  152. //driver.doRejectSign(conn.getConnection(), signDoc); 2017.04.27 수신부서에서 반려,회수하는 경우는 GW내 결재진행이므로 주석처리.
  153. } else if ( str_doc_state.equals("25")){ // 2차 결제 반려
  154. driver.doRejectSign(conn.getConnection(), signDoc);
  155. } else if ( str_doc_state.equals("24") ){ // 완료
  156. driver.doFinishSign(conn.getConnection(), signDoc);
  157. }
  158. // 전자구매의 결재 인터페이스 테이블의 정보를 수정한다.
  159. updateSign001t(conn.getConnection(), signDoc);
  160. }
  161. }
  162. catch(Exception e) {
  163. Logger.err.println(driverName + ".doXxxxSign() 실행중 오류가 발생 했습니다.\\n" + e.getMessage());
  164. conn.setRollback();
  165. throw e;
  166. }
  167. }
  168. catch(Exception e) {
  169. Logger.err.println("doBiz() 실행중 오류가 발생 했습니다.\\n" + e.getMessage());
  170. conn.setRollback();
  171. }
  172. finally {
  173. conn.end();
  174. }
  175. }
  176. }
  177. /**
  178. * SIGN001T 상태값을 업데이트해준다.
  179. * @param connection
  180. * @param valueObject
  181. * @throws Exception
  182. */
  183. public void updateSign001t(Connection connection, ValueObject vo) throws Exception {
  184. Persistent persistent = new PersistentImpl(connection);
  185. StringBuffer sqlstr = null;
  186. try {
  187. sqlstr = new StringBuffer();
  188. sqlstr.append(" UPDATE SIGN001T SET \n");
  189. sqlstr.append(" ATTR_6 = 1 \n");
  190. sqlstr.append(" WHERE SIGN_INTERFACE_ID = ? \n");
  191. persistent.setStatement(sqlstr.toString());
  192. persistent.addParameter(vo.get("SIGN_INTERFACE_ID"));
  193. persistent.execute();
  194. }
  195. catch(Exception e) {
  196. WAFLogger.error(this.getClass().getName() + " --> updateSign001t() : " + e.getMessage());
  197. WAFLogger.error("SQL : " + sqlstr);
  198. WAFLogger.error(e);
  199. throw e;
  200. }
  201. }
  202. public String getSignDriverName(String signClassCd) throws Exception{
  203. Search search = new SearchImpl();
  204. RowSet rowSet = new RowSetImpl();
  205. StringBuffer sqlStr = new StringBuffer();
  206. String rtnStr = "";
  207. try {
  208. sqlStr.append(" SELECT DETAILSORTNM AS DRIVER_NAME \n");
  209. sqlStr.append(" FROM EBID_COM911T \n");
  210. sqlStr.append(" WHERE BASECD = 'DRAFT' \n");
  211. sqlStr.append(" AND DETAILNM = ? \n");
  212. search.setStatement(sqlStr.toString());
  213. search.addParameter(signClassCd);
  214. rowSet = search.execute();
  215. if( rowSet != null && rowSet.size() > 0 ) {
  216. rtnStr = rowSet.getRow(0).get("DRIVER_NAME");
  217. }
  218. }catch(WAFSQLException se) {
  219. Logger.err.println("SQL : \n" + se.getStatement());
  220. Logger.err.println("PARAM : \n" + se.getParameter());
  221. throw se;
  222. }finally {
  223. if( rowSet == null ) rowSet = new RowSetImpl();
  224. return rtnStr;
  225. }
  226. }
  227. }