PrepaymentSignDriver.java 61 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879
  1. /**
  2. * @(#)file PrepaymentMiddleSignDriver.java
  3. * @(#)author OK
  4. * @(#)version 1.0
  5. * @(#)date 2014-09-15
  6. * @(#)since JDK 1.6.21
  7. *
  8. * Copyright (c) www.udapsoft.co.kr, Inc.
  9. * 대급지급신청서(중도) 처리 드라이브
  10. *
  11. */
  12. package kr.co.udapsoft.common.commonSign.driver;
  13. import java.io.OutputStream;
  14. import java.sql.CallableStatement;
  15. import java.sql.Connection;
  16. import java.sql.PreparedStatement;
  17. import java.sql.ResultSet;
  18. import java.sql.Statement;
  19. import java.sql.Types;
  20. import kr.co.hsnc.common.base.WAFLogger;
  21. import kr.co.hsnc.common.config.WAFConfig;
  22. import kr.co.hsnc.common.logger.Logger;
  23. import kr.co.hsnc.common.sql.Row;
  24. import kr.co.hsnc.common.sql.RowSet;
  25. import kr.co.hsnc.common.sql.RowSetImpl;
  26. import kr.co.hsnc.common.sql.WAFSQLException;
  27. import kr.co.hsnc.common.sql.persistent.Persistent;
  28. import kr.co.hsnc.common.sql.persistent.PersistentImpl;
  29. import kr.co.hsnc.common.sql.search.Search;
  30. import kr.co.hsnc.common.sql.search.SearchImpl;
  31. import kr.co.hsnc.common.sql.util.RowSetUtility;
  32. import kr.co.hsnc.common.util.StringUtil;
  33. import kr.co.hsnc.common.util.ValueObject;
  34. import kr.co.udapsoft.common.commonSign.CommonSignInterface;
  35. import kr.co.udapsoft.common.commonSign.util.SACDOCreatePDF6;
  36. import kr.co.udapsoft.ebid.buyer.bid.outside.biz.InterfaceOutERPiU;
  37. import weblogic.jdbc.vendor.oracle.OracleThinBlob;
  38. public class PrepaymentSignDriver implements CommonSignInterface {
  39. /**
  40. *
  41. */
  42. public PrepaymentSignDriver() {
  43. super();
  44. }
  45. /*
  46. * (non-Javadoc)
  47. * @see kr.co.udap.ehr.common.sign.SignInterface#doCallSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  48. */
  49. public void doCallSign(Connection connection, ValueObject signDoc) throws Exception {
  50. System.out.println("1");
  51. }
  52. /*
  53. * (non-Javadoc)
  54. * @see kr.co.udap.ehr.common.sign.SignInterface#doStartSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  55. */
  56. public void doStartSign(Connection connection, ValueObject signDoc) throws Exception {
  57. System.out.println("2");
  58. }
  59. /*
  60. * (non-Javadoc)
  61. * @see kr.co.udap.ehr.common.sign.SignInterface#doFirstFinishSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  62. */
  63. public void doFirstFinishSign(Connection connection, ValueObject signDoc) throws Exception {
  64. System.out.println("3");
  65. /* 운영에 반영할때는 변경해야함*/
  66. RowSet signUserInfo = getIFSignUser(signDoc.get("DOC_ID"));
  67. // 2020.02.17 결재정보가 없는 경우 예외처리
  68. if(signUserInfo.size() == 0){
  69. throw new Exception("결재정보가 없습니다.");
  70. }
  71. for ( int j = 0 ; j < signUserInfo.size() ; j ++ ) {
  72. ValueObject signUser = new ValueObject();
  73. signUser.set("SIGN_SEQ", ""+(j+1));
  74. signUser.set("DOC_ID", signDoc.get("DOC_ID"));
  75. signUser.set("APPROVAL_DATE", signUserInfo.getRow(j).get("PROCESSDATE"));
  76. signUser.set("APPROVAL_SABUN", signUserInfo.getRow(j).get("SABUN"));
  77. signUser.set("APPROVAL_USER", signUserInfo.getRow(j).get("APRMEMBERNAME"));
  78. signUser.set("A_POSITION", signUserInfo.getRow(j).get("APRMEMBERJOBTITLE"));
  79. signUser.set("SIGN_RESULT", signUserInfo.getRow(j).get("APRSTATE"));
  80. signUser.set("SIGN_TYPE", signDoc.get("SIGN_TYPE"));
  81. signUser.set("ACCT_TYPE", signDoc.get("ACCT_TYPE"));
  82. signUser.set("SLIP_DEPT", signDoc.get("KEY_COL3"));
  83. //signUser.set("ACC_SLIP_NO", acctSlipNo);
  84. signUser.set("ACCSLIP_NO", "");
  85. signUser.set("SLIP_DT", signDoc.get("KEY_COL4"));
  86. signUser.set("SLIP_NO", signDoc.get("KEY_COL5"));
  87. insertSign002t(connection, signUser);
  88. }
  89. updateSUB1030T(connection, signDoc, signUserInfo);
  90. }
  91. /*
  92. * (non-Javadoc)
  93. * @see kr.co.udap.ehr.common.sign.SignInterface#doFinishSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  94. */
  95. public void doFinishSign(Connection connection, ValueObject signDoc) throws Exception {
  96. System.out.println("4");
  97. }
  98. /*
  99. * (non-Javadoc)
  100. * @see kr.co.udap.ehr.common.sign.SignInterface#doRejectSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  101. */
  102. public void doFirstRejectSign(Connection connection, ValueObject signDoc) throws Exception {
  103. updateSUB1030T(connection, signDoc, new RowSetImpl());
  104. }
  105. /*
  106. * (non-Javadoc)
  107. * @see kr.co.udap.ehr.common.sign.SignInterface#doRejectSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  108. */
  109. public void doRejectSign(Connection connection, ValueObject signDoc) throws Exception {
  110. //u pdateSUB1040T(connection, signDoc);
  111. }
  112. /*
  113. * (non-Javadoc)
  114. * @see kr.co.udap.ehr.common.sign.SignInterface#doCancelSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  115. */
  116. public void doCancelSign(Connection connection, ValueObject signDoc) throws Exception {
  117. }
  118. private RowSet getIFSignUser(String docId) throws Exception{
  119. Search search = new SearchImpl();
  120. search.setDSName("jdbc/gwsql");
  121. RowSet rowSet = new RowSetImpl();
  122. StringBuffer sqlstr = new StringBuffer();
  123. try {
  124. sqlstr.append(" SELECT APRSTATE \n");
  125. sqlstr.append(" ,REPLACE(APRMEMBERID,SUBSTRING(APRMEMBERID,1,4),'') AS SABUN \n");
  126. sqlstr.append(" ,APRMEMBERNAME \n");
  127. sqlstr.append(" ,APRMEMBERJOBTITLE \n");
  128. sqlstr.append(" ,APRMEMBERDEPTNAME \n");
  129. sqlstr.append(" ,REPLACE(CONVERT(VARCHAR(10),PROCESSDATE,120),'-','') AS PROCESSDATE \n");
  130. sqlstr.append(" FROM TBENDAPRLINEINFO \n");
  131. sqlstr.append(" WHERE APRTYPE = 'A03001' \n");
  132. sqlstr.append(" AND DOCID = '"+docId+"' \n");
  133. sqlstr.append(" ORDER BY APRMEMBERSN \n");
  134. search.setStatement(sqlstr.toString());
  135. rowSet = search.execute();
  136. System.out.println(sqlstr.toString());
  137. return rowSet;
  138. }catch(WAFSQLException se) {
  139. Logger.err.println("SQL : \n" + se.getStatement());
  140. Logger.err.println("PARAM : \n" + se.getParameter());
  141. throw se;
  142. }
  143. }
  144. public void insertSign002t(Connection connection, ValueObject vo) throws Exception {
  145. Persistent persistent = new PersistentImpl(connection);
  146. StringBuffer sqlstr = null;
  147. try {
  148. sqlstr = new StringBuffer();
  149. sqlstr.append(" INSERT INTO SIGN002T \n");
  150. sqlstr.append(" (SIGN_HIS_ID \n");
  151. sqlstr.append(" ,SIGN_SEQ \n");
  152. sqlstr.append(" ,DOC_ID \n");
  153. sqlstr.append(" ,APPROVAL_DATE \n");
  154. sqlstr.append(" ,APPROVAL_SABUN \n");
  155. sqlstr.append(" ,APPROVAL_USER \n");
  156. sqlstr.append(" ,A_POSITION \n");
  157. sqlstr.append(" ,SIGN_RESULT \n");
  158. sqlstr.append(" ,SLIP_DEPT \n");
  159. sqlstr.append(" ,SLIP_DT \n");
  160. sqlstr.append(" ,SLIP_NO \n");
  161. sqlstr.append(" ,SIGN_TYPE \n");
  162. sqlstr.append(" ,COMON_DCR \n");
  163. //sqlstr.append(" ,ACC_SLIP_NO \n");
  164. sqlstr.append(" ) VALUES \n");
  165. sqlstr.append(" ( \n");
  166. sqlstr.append(" SIGN002T_S.NEXTVAL \n");
  167. sqlstr.append(" ,? \n");
  168. sqlstr.append(" ,? \n");
  169. sqlstr.append(" ,TO_DATE(?,'YYYYMMDD') \n");
  170. sqlstr.append(" ,? \n");
  171. sqlstr.append(" ,? \n");
  172. sqlstr.append(" ,? \n");
  173. sqlstr.append(" ,? \n");
  174. sqlstr.append(" ,? \n");
  175. sqlstr.append(" ,? \n");
  176. sqlstr.append(" ,? \n");
  177. sqlstr.append(" ,1 \n");
  178. sqlstr.append(" ,2 \n");
  179. //sqlstr.append(" ,? \n");
  180. sqlstr.append(" ) \n");
  181. persistent.setStatement(sqlstr.toString());
  182. persistent.addParameter(vo.get("SIGN_SEQ"));
  183. persistent.addParameter(vo.get("DOC_ID"));
  184. persistent.addParameter(vo.get("APPROVAL_DATE"));
  185. persistent.addParameter(vo.get("APPROVAL_SABUN"));
  186. persistent.addParameter(vo.get("APPROVAL_USER"));
  187. persistent.addParameter(vo.get("A_POSITION"));
  188. persistent.addParameter(vo.get("SIGN_RESULT"));
  189. persistent.addParameter(vo.get("SLIP_DEPT"));
  190. persistent.addParameter(vo.get("SLIP_DT"));
  191. persistent.addParameter(vo.get("SLIP_NO"));
  192. //persistent.addParameter(vo.get("ACC_SLIP_NO"));
  193. persistent.execute();
  194. }
  195. catch(Exception e) {
  196. WAFLogger.error(this.getClass().getName() + " --> insertSign002t() : " + e.getMessage());
  197. WAFLogger.error("SQL : " + sqlstr);
  198. WAFLogger.error(e);
  199. throw e;
  200. }
  201. }
  202. public void updateSUB1030T(Connection connection, ValueObject vo, RowSet signUserInfo) throws Exception {
  203. Persistent persistent = new PersistentImpl(connection);
  204. Persistent persistent1 = new PersistentImpl(connection);
  205. StringBuffer sqlstr = null;
  206. StringBuffer sqlstr1 = null;
  207. try {
  208. sqlstr = new StringBuffer();
  209. sqlstr1 = new StringBuffer();
  210. String status = "";
  211. sqlstr1.append(" SELECT REQ_DIV_CD \n");
  212. sqlstr1.append(" FROM SUB1030T \n");
  213. sqlstr1.append(" WHERE PREPAY_ID = ? \n");
  214. persistent1.setStatement(sqlstr1.toString());
  215. persistent1.addParameter(vo.get("KEY_COL2"));
  216. String div = RowSetUtility.getValueObject(persistent1.query().getRow(0)).get("REQ_DIV_CD");
  217. sqlstr.append(" UPDATE SUB1030T \n");
  218. sqlstr.append(" SET STATUS_CD = ? \n");
  219. sqlstr.append(" , UPD_DATE = SYSDATE \n");
  220. sqlstr.append(" WHERE PREPAY_ID IN (?) \n");
  221. persistent.setStatement(sqlstr.toString());
  222. int complete = 0;
  223. if ( vo.get("SIGN_DECI_CLASS").equals("14")) {
  224. status = "10"; // 완료
  225. if("3".equals(div)){
  226. status = "21"; //구매 포기완료
  227. }
  228. } else {
  229. //persistent.addParameter("91"); // 반려
  230. status = "91";
  231. complete = 1;
  232. }
  233. persistent.addParameter(status);
  234. persistent.addParameter(vo.get("KEY_COL2"));
  235. persistent.execute();
  236. if(!"3".equals(div)){
  237. //전표집계처리
  238. if(complete == 0){
  239. //외주 선급금 전표집계
  240. //선급금포기각서 첨부파일 복사처리
  241. //doSendCCSFile(connection, "SUPP_PREPAYMENTS_GIVEUP", vo.get("KEY_COL2"));
  242. //
  243. //doSendCCSFile(connection, "SUPP_PREPAYMENTS_BILLING", vo.get("KEY_COL2"));
  244. //
  245. //doSendCCSFile(connection, "SUPP_TAX_BILL", vo.get("KEY_COL2"));
  246. //
  247. //doSendCCSFile(connection, "INVOICE", vo.get("KEY_COL2"));
  248. prepaymentJipge(connection, vo, signUserInfo);
  249. }
  250. }
  251. }
  252. catch(Exception e) {
  253. WAFLogger.error(this.getClass().getName() + " --> updateSUB1030T() : " + e.getMessage());
  254. WAFLogger.error("SQL : " + sqlstr);
  255. WAFLogger.error(e);
  256. throw e;
  257. }
  258. }
  259. public void prepaymentJipge(Connection connection, ValueObject vo, RowSet signUserInfo) throws Exception {
  260. Search search = new SearchImpl();
  261. RowSet listRowSet = null;
  262. StringBuffer sql = new StringBuffer();
  263. ValueObject selectResult = new ValueObject();
  264. try {
  265. sql.append(" SELECT A.DEPT_CD \n");
  266. sql.append(" ,B.SUB_CONT_ID \n");
  267. sql.append(" ,A.SUB_CONT_MOD_ID \n");
  268. sql.append(" ,A.ERP_NO_CONT \n");
  269. sql.append(" ,A.ERP_SQ_CONT \n");
  270. sql.append(" ,B.PREPAY_ID \n");
  271. sql.append(" ,TO_CHAR(TO_DATE(B.TAX_DY,'YYYYMMDD'), 'YYYY-MM') AS P_ENTER_DT \n");
  272. sql.append(" ,(SELECT A.USER_SABUN FROM PUB0120T A WHERE ACCT_ID = C.CRE_BY) AS USER_SABUN \n");
  273. sql.append(" ,(SELECT A.USER_NAME FROM PUB0120T A WHERE ACCT_ID = C.CRE_BY) AS USER_NAME \n");
  274. sql.append(" ,C.CRE_BY AS ACCT_ID \n");
  275. sql.append(" ,C.CRE_DATE AS REQ_DATE \n");
  276. sql.append(" ,TO_CHAR(SYSDATE,'YYYYMMDD') AS APPLY_DATE \n");
  277. sql.append(" ,TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS') AS DTS_INSERT \n");
  278. sql.append(" ,B.TAX_METHOD_CD AS TAX_METHOD_CD \n");
  279. sql.append(" ,'"+WAFConfig.get("waf.erp.cdCompany")+"' AS CD_COMPANY \n");
  280. sql.append(" ,NVL(D.ERP_SITE_CD,A.DEPT_CD) AS CD_SITE \n");
  281. sql.append(" ,'01' AS CD_CM00215 \n");
  282. sql.append(" ,A.ERP_NO_CONT AS NO_CONT \n");
  283. sql.append(" ,A.ERP_SQ_CONT AS SQ_CONT \n");
  284. sql.append(" ,TO_CHAR(B.PREPAY_DATE,'YYYYMMDD') AS DT_PREPAY \n");
  285. sql.append(" ,FLOOR(B.REQ_PREPAY_SUPPLY_TAMT * F_GET_EXCHANGE_RATE(B.PREPAY_DATE,B.CON_CUR_CD,'KRW')) AS AMT_PREPAY \n");
  286. sql.append(" ,FLOOR(DECODE(A.PROOF_CD,'Z99',0,B.REQ_PREPAY_SURTAX_AMT) * F_GET_EXCHANGE_RATE(B.PREPAY_DATE,B.CON_CUR_CD,'KRW')) AS VAT_PREPAY \n");
  287. sql.append(" ,FLOOR(B.REQ_PREPAY_SUPPLY_NAMT * F_GET_EXCHANGE_RATE(B.PREPAY_DATE,B.CON_CUR_CD,'KRW')) AS FAMT_PREPAY \n");
  288. sql.append(" ,(SELECT CHG_CODE10 FROM EBID_COM911T WHERE BASECD = '911' AND DETAILCD = B.CON_CUR_CD) AS CURR_SOUR \n");
  289. sql.append(" ,DECODE(B.CON_CUR_CD,'KRW',NULL,F_GET_EXCHANGE_RATE(B.PREPAY_DATE,B.CON_CUR_CD,'KRW')) AS UNT_CURR \n");
  290. sql.append(" ,DECODE(B.CON_CUR_CD,'KRW',NULL,B.REQ_PREPAY_SUPPLY_TAMT) AS AMT_CURR \n");
  291. sql.append(" ,DECODE(B.CON_CUR_CD,'KRW',NULL,DECODE(A.PROOF_CD,'Z99',0,B.REQ_PREPAY_SURTAX_AMT)) AS VAMT_CURR \n");
  292. sql.append(" ,DECODE(B.CON_CUR_CD,'KRW',NULL,B.REQ_PREPAY_SUPPLY_NAMT) AS FAMT_CURR \n");
  293. sql.append(" ,'Y' AS YN_BAN \n");
  294. sql.append(" ,NVL(E.CHG_CODE10,B.CON_CUR_CD) AS CD_EXCH \n");
  295. sql.append(" ,DECODE(B.CON_CUR_CD,'KRW',NULL,F_GET_EXCHANGE_RATE(B.PREPAY_DATE,B.CON_CUR_CD,'KRW')) AS RT_EXCH \n");
  296. sql.append(" ,DECODE(B.CON_CUR_CD,'KRW',NULL,F_GET_EXCHANGE_DATE(B.PREPAY_DATE,B.CON_CUR_CD,'KRW')) AS DT_EXCH \n");
  297. sql.append(" ,DECODE(B.TAX_METHOD_CD,'1','0','2') AS YN_ISS \n");
  298. //2019.07.29 ERP 자동분개를 위한 계정코드
  299. sql.append(" ,CASE WHEN A.CON_CUR_CD = 'KRW' THEN NVL(F.CHG_CODE10, '') \n");
  300. sql.append(" ELSE NVL(F.CHG_CODE11, '') \n");
  301. sql.append(" END AS CD_COST_TRADE \n");
  302. sql.append(" FROM SUB2000T A \n");
  303. sql.append(" ,SUB1030T B \n");
  304. sql.append(" ,( \n");
  305. sql.append(" SELECT MAX(SIGN_INTERFACE_ID) \n");
  306. sql.append(" ,MAX(KEY_COL2) AS KEY_COL2 \n");
  307. sql.append(" ,MAX(CRE_BY) AS CRE_BY \n");
  308. sql.append(" ,MAX(TO_CHAR(CRE_DATE,'YYYYMMDD')) AS CRE_DATE \n");
  309. sql.append(" FROM SIGN001T \n");
  310. sql.append(" WHERE KEY_COL2 = '"+vo.get("KEY_COL2")+"' \n");
  311. sql.append(" AND SIGN_CLASS_CD = 'ebid_oprpyD' \n");
  312. sql.append(" GROUP BY KEY_COL2 \n");
  313. sql.append(" ) C \n");
  314. sql.append(" ,ETEC_ERPIF.SITE_MAPPING D \n");
  315. sql.append(" ,(SELECT DETAILCD, CHG_CODE10 FROM EBID_COM911T WHERE BASECD = '911') E \n");
  316. sql.append(",(SELECT DETAILCD, CHG_CODE10, CHG_CODE11, CHG_CODE12, CHG_CODE13 FROM EBID_COM911T WHERE BASECD = 'SUB_ACCT_GB' ) F \n");
  317. sql.append(" WHERE A.SUB_CONT_MOD_ID = B.SUB_CONT_MOD_ID \n");
  318. sql.append(" AND B.PREPAY_ID = C.KEY_COL2 \n");
  319. sql.append(" AND A.DEPT_CD = D.EBID_SITE_CD(+) \n");
  320. sql.append(" AND B.CON_CUR_CD = E.DETAILCD(+) \n");
  321. sql.append(" AND A.ACCT_GB = F.DETAILCD(+) \n");
  322. sql.append(" AND B.PREPAY_ID = '"+vo.get("KEY_COL2")+"' \n");
  323. search.setStatement(sql.toString());
  324. //search.addParameter(vo.get("KEY_COL3"));
  325. listRowSet = search.execute();
  326. selectResult = RowSetUtility.getValueObject(listRowSet.getRow(0));
  327. doJipge(connection, selectResult);
  328. String userId = selectResult.get("ACCT_ID");
  329. RowSet result = getListRow1(connection, selectResult);
  330. for( int i = 0 ; i < result.size() ; i++ ) {
  331. Row row = result.getRow(i);
  332. //외주선급금 PDF작성
  333. preInvoiceDoc020t(connection, row.get("TMPSLIP_ID"), userId);
  334. }
  335. boolean erpSucc = false;
  336. selectResult.set("DOC_ID",vo.get("DOC_ID"));
  337. String sqPrepay = getSqPrepay(selectResult);
  338. selectResult.set("SQ_PREPAY", sqPrepay);
  339. erpSucc = InterfaceOutERPiU.insertPrepayInfo(selectResult, signUserInfo);
  340. if(!erpSucc) {
  341. connection.rollback();
  342. throw new Exception("ERPIU insert Error");
  343. }
  344. }
  345. catch(Exception e) {
  346. WAFLogger.error(this.getClass().getName() + " --> prepaymentMiddle() : " + e.getMessage());
  347. //WAFLogger.error("SQL : " + sqlstr);
  348. WAFLogger.error(e);
  349. throw e;
  350. }
  351. }
  352. public ValueObject getListRow(Connection connection, ValueObject vo) throws Exception {
  353. Persistent pSelect = null;
  354. StringBuffer sql = new StringBuffer();
  355. ValueObject selectResult = new ValueObject();
  356. try {
  357. pSelect = new PersistentImpl(connection);
  358. sql.append(" SELECT MAIN.TMPSLIP_ID -- 외주기성전표 ID \n");
  359. sql.append(" , TO_CHAR(MAIN.PROOFDATE, 'YYYY-MM-DD') PROOFDATE -- 거래일자 \n");
  360. sql.append(" , MAIN.DEPT_CD -- 현장코드 \n");
  361. sql.append(" , CONTRACT.DEPT_NAME -- 현장명 \n");
  362. sql.append(" , CONTRACT.CON_DOC_NO -- 외주계약번호 \n");
  363. sql.append(" , CONTRACT.BUILD_NAME -- 계약명 \n");
  364. sql.append(" , MAIN.DCERTI_NO -- 사업자번호 \n");
  365. sql.append(" , SUBVENDOR.CORP_KOR -- 사업자명 \n");
  366. sql.append(" , SUBVENDOR.CORP_ID -- 협력업체_ID \n");
  367. sql.append(" , MAIN.PREREQTFLG -- 선급/기성구분 \n");
  368. sql.append(" , MAIN.ACMP_NO -- 기성차수 \n");
  369. sql.append(" , MAIN.PROOF_CLASS -- 증빙구분 \n");
  370. sql.append(" , MAIN.ORDACCDESC -- 적요 \n");
  371. sql.append(" , MAIN.CON_CUR_CD -- 계약통화 \n");
  372. sql.append(" , MAIN.SUPPLY_AMT -- 공급가 \n");
  373. sql.append(" , MAIN.SURTAX_AMT -- 부가세 \n");
  374. sql.append(" , MAIN.SUPPLY_AMT + MAIN.SURTAX_AMT REQ_AMT -- 청구금액 \n");
  375. sql.append(" , CONTRACT.CON_CHARGE_ID -- 담당자 ID \n");
  376. sql.append(" , CONTRACT.CON_CHARGE_NAME -- 담당자 명 \n");
  377. sql.append(" , MAIN.DEALR_CD -- 거래처코드 \n");
  378. sql.append(" , MAIN.PAYITEM -- PAY ITEM \n");
  379. sql.append(" , MAIN.COSTCODE -- COST CODE \n");
  380. sql.append(" , MAIN.COSTTYPE -- COST TYPE \n");
  381. sql.append(" , MAIN.ACC_CLASS -- 계정구분 \n");
  382. sql.append(" , MAIN.PAY_GROUP -- PAY_GROUP \n");
  383. sql.append(" , MAIN.PAYMENT_TERMS -- PAYMENT_TERMS \n");
  384. sql.append(" , MAIN.TMPSLIP_DEPT -- 작성부서 \n");
  385. sql.append(" , MAIN.TMPSLIP_DT -- 작성일자 \n");
  386. sql.append(" , MAIN.TMPSLIP_NO -- 작성번호 \n");
  387. sql.append(" , MAIN.TMPSLIP_YN -- 전표생성유무 \n");
  388. sql.append(" , MAIN.SLIP_YN -- 결의서작성유무 \n");
  389. sql.append(" , MAIN.ACMP_ID -- 기성ID \n");
  390. sql.append(" , MAIN.PREPAY_ID -- 선급ID \n");
  391. sql.append(" , PREPAY.CON_CORP_ID -- 계약업체 ID \n");
  392. sql.append(" , CONTRACT.SUB_CONT_ID -- 외주게약서 ID \n");
  393. sql.append(" , CASE \n");
  394. sql.append(" WHEN (SLIP.STATUS_CD = '1') AND (SLIP.RETURN_CD = 'Y') THEN '-1' \n");
  395. sql.append(" ELSE SLIP.STATUS_CD \n");
  396. sql.append(" END STATUS_CD \n");
  397. sql.append(" \n");
  398. sql.append(" FROM SUB1050T MAIN \n");
  399. sql.append(" , SUB1030T PREPAY \n");
  400. sql.append(" , SUB1020T SUBVENDOR \n");
  401. sql.append(" , SUB1000T CONTRACT \n");
  402. sql.append(" , SAC01001 SLIP \n");
  403. sql.append(" WHERE PREREQTFLG = 'PREPAY' \n");
  404. sql.append(" AND MAIN.PREPAY_ID = PREPAY.PREPAY_ID \n");
  405. sql.append(" AND PREPAY.CON_CORP_ID = SUBVENDOR.CON_CORP_ID \n");
  406. sql.append(" AND PREPAY.SUB_CONT_ID = CONTRACT.SUB_CONT_ID \n");
  407. sql.append(" AND MAIN.TMPSLIP_DEPT = SLIP.TMPSLIP_DEPT(+) \n");
  408. sql.append(" AND MAIN.TMPSLIP_DT = SLIP.TMPSLIP_DT(+) \n");
  409. sql.append(" AND MAIN.TMPSLIP_NO = SLIP.TMPSLIP_NO(+) \n");
  410. sql.append(" AND SUBVENDOR.MAIN_CORP = 'Y' \n");
  411. sql.append(" AND MAIN.PREPAY_ID = "+vo.get("PREPAY_ID")+" \n");
  412. sql.append(" ORDER BY PROOFDATE desc, DEPT_NAME, CON_DOC_NO, CORP_KOR \n");
  413. System.out.println(sql.toString());
  414. pSelect.setStatement(sql.toString());
  415. selectResult = RowSetUtility.getValueObject(pSelect.query().getRow(0));
  416. } catch(Exception e) {
  417. WAFLogger.error(this.getClass().getName() + " --> getListRow() : \n" + e.getMessage());
  418. //WAFLogger.error("SQL : " + search.getStatement());
  419. WAFLogger.error(e);
  420. } finally {
  421. if( selectResult == null ) selectResult = new ValueObject();
  422. }
  423. return selectResult;
  424. }
  425. public RowSet getListRow1(Connection connection, ValueObject vo) throws Exception {
  426. Persistent pSelect = null;
  427. StringBuffer sql = new StringBuffer();
  428. RowSet resultRowset = null;
  429. try {
  430. pSelect = new PersistentImpl(connection);
  431. sql.append(" SELECT MAIN.TMPSLIP_ID -- 외주기성전표 ID \n");
  432. sql.append(" , TO_CHAR(MAIN.PROOFDATE, 'YYYY-MM-DD') PROOFDATE -- 거래일자 \n");
  433. sql.append(" , MAIN.DEPT_CD -- 현장코드 \n");
  434. sql.append(" , CONTRACT.DEPT_NAME -- 현장명 \n");
  435. sql.append(" , CONTRACT.CON_DOC_NO -- 외주계약번호 \n");
  436. sql.append(" , CONTRACT.BUILD_NAME -- 계약명 \n");
  437. sql.append(" , MAIN.DCERTI_NO -- 사업자번호 \n");
  438. sql.append(" , SUBVENDOR.CORP_KOR -- 사업자명 \n");
  439. sql.append(" , SUBVENDOR.CORP_ID -- 협력업체_ID \n");
  440. sql.append(" , MAIN.PREREQTFLG -- 선급/기성구분 \n");
  441. sql.append(" , MAIN.ACMP_NO -- 기성차수 \n");
  442. sql.append(" , MAIN.PROOF_CLASS -- 증빙구분 \n");
  443. sql.append(" , MAIN.ORDACCDESC -- 적요 \n");
  444. sql.append(" , MAIN.CON_CUR_CD -- 계약통화 \n");
  445. sql.append(" , MAIN.SUPPLY_AMT -- 공급가 \n");
  446. sql.append(" , MAIN.SURTAX_AMT -- 부가세 \n");
  447. sql.append(" , MAIN.SUPPLY_AMT + MAIN.SURTAX_AMT REQ_AMT -- 청구금액 \n");
  448. sql.append(" , CONTRACT.CON_CHARGE_ID -- 담당자 ID \n");
  449. sql.append(" , CONTRACT.CON_CHARGE_NAME -- 담당자 명 \n");
  450. sql.append(" , MAIN.DEALR_CD -- 거래처코드 \n");
  451. sql.append(" , MAIN.PAYITEM -- PAY ITEM \n");
  452. sql.append(" , MAIN.COSTCODE -- COST CODE \n");
  453. sql.append(" , MAIN.COSTTYPE -- COST TYPE \n");
  454. sql.append(" , MAIN.ACC_CLASS -- 계정구분 \n");
  455. sql.append(" , MAIN.PAY_GROUP -- PAY_GROUP \n");
  456. sql.append(" , MAIN.PAYMENT_TERMS -- PAYMENT_TERMS \n");
  457. sql.append(" , MAIN.TMPSLIP_DEPT -- 작성부서 \n");
  458. sql.append(" , MAIN.TMPSLIP_DT -- 작성일자 \n");
  459. sql.append(" , MAIN.TMPSLIP_NO -- 작성번호 \n");
  460. sql.append(" , MAIN.TMPSLIP_YN -- 전표생성유무 \n");
  461. sql.append(" , MAIN.SLIP_YN -- 결의서작성유무 \n");
  462. sql.append(" , MAIN.ACMP_ID -- 기성ID \n");
  463. sql.append(" , MAIN.PREPAY_ID -- 선급ID \n");
  464. sql.append(" , PREPAY.CON_CORP_ID -- 계약업체 ID \n");
  465. sql.append(" , CONTRACT.SUB_CONT_ID -- 외주게약서 ID \n");
  466. //sql.append(" , CASE \n");
  467. //sql.append(" WHEN (SLIP.STATUS_CD = '1') AND (SLIP.RETURN_CD = 'Y') THEN '-1' \n");
  468. //sql.append(" ELSE SLIP.STATUS_CD \n");
  469. //sql.append(" END STATUS_CD \n");
  470. sql.append(" \n");
  471. sql.append(" FROM SUB1050T MAIN \n");
  472. sql.append(" , SUB1030T PREPAY \n");
  473. sql.append(" , SUB1020T SUBVENDOR \n");
  474. sql.append(" , SUB1000T CONTRACT \n");
  475. //sql.append(" , SAC01001 SLIP \n");
  476. sql.append(" WHERE PREREQTFLG = 'PREPAY' \n");
  477. sql.append(" AND MAIN.PREPAY_ID = PREPAY.PREPAY_ID \n");
  478. sql.append(" AND PREPAY.CON_CORP_ID = SUBVENDOR.CON_CORP_ID \n");
  479. sql.append(" AND PREPAY.SUB_CONT_ID = CONTRACT.SUB_CONT_ID \n");
  480. //sql.append(" AND MAIN.TMPSLIP_DEPT = SLIP.TMPSLIP_DEPT(+) \n");
  481. //sql.append(" AND MAIN.TMPSLIP_DT = SLIP.TMPSLIP_DT(+) \n");
  482. //sql.append(" AND MAIN.TMPSLIP_NO = SLIP.TMPSLIP_NO(+) \n");
  483. sql.append(" AND SUBVENDOR.MAIN_CORP = 'Y' \n");
  484. sql.append(" AND MAIN.PREPAY_ID = "+vo.get("PREPAY_ID")+" \n");
  485. //sql.append(" AND SLIP.STATUS_cd IS null \n");
  486. sql.append(" AND MAIN.TMPSLIP_YN = 'N' \n");
  487. sql.append(" ORDER BY PROOFDATE desc, DEPT_NAME, CON_DOC_NO, CORP_KOR \n");
  488. System.out.println(sql.toString());
  489. pSelect.setStatement(sql.toString());
  490. //selectResult = RowSetUtility.getValueObject(pSelect.query().getRow(0));
  491. resultRowset = pSelect.query();
  492. } catch(Exception e) {
  493. WAFLogger.error(this.getClass().getName() + " --> getListRow() : \n" + e.getMessage());
  494. //WAFLogger.error("SQL : " + search.getStatement());
  495. WAFLogger.error(e);
  496. } finally {
  497. if( resultRowset == null ) resultRowset = null;
  498. }
  499. return resultRowset;
  500. }
  501. private void doJipge(Connection connection, ValueObject vo) throws Exception {
  502. Persistent persistent = new PersistentImpl(connection);
  503. StringBuffer sql = new StringBuffer();
  504. prepareSql(sql);
  505. persistent.setStatement(sql.toString());
  506. try {
  507. //ValueObject user = storage.getUser();
  508. persistent.addParameter(vo.get("ACCT_ID"));
  509. persistent.addParameter(vo.get("dept_cd"));
  510. persistent.addParameter(vo.get("PREPAY_ID"));
  511. persistent.addParameter(vo.get("ACCT_ID"));
  512. persistent.addParameter(vo.get("dept_cd"));
  513. persistent.addParameter(vo.get("PREPAY_ID"));
  514. System.out.println("1="+vo.get("ACCT_ID"));
  515. System.out.println("2="+vo.get("dept_cd"));
  516. System.out.println("3="+vo.get("PREPAY_ID"));
  517. System.out.println("4="+vo.get("ACCT_ID"));
  518. System.out.println("5="+vo.get("dept_cd"));
  519. System.out.println("6="+vo.get("PREPAY_ID"));
  520. persistent.execute();
  521. persistent.clearParameters();
  522. } catch(Exception e) {
  523. WAFLogger.error(this.getClass().getName() + " --> doJipge() : " + e.getMessage());
  524. WAFLogger.error(e);
  525. throw e;
  526. }
  527. }
  528. //면세
  529. private void prepareSql(StringBuffer sql) {
  530. sql.append(" INSERT INTO SUB1050T(TMPSLIP_ID, PROOFDATE, DEPT_CD, PREREQTFLG, ACMP_NO, PROOF_CLASS, ORDACCDESC, SUPPLY_AMT, SURTAX_AMT, DEALR_CD, DCERTI_NO, TAX_DATE, ELECTAX_YN, PAYITEM, COSTCODE, COSTTYPE, ACC_CLASS, PAY_GROUP, PAYMENT_TERMS, TMPSLIP_DEPT, TMPSLIP_DT, TMPSLIP_NO, TMPSLIP_YN, SLIP_YN, CON_CUR_CD, ACMP_ID, PREPAY_ID, CRE_BY, CRE_DATE, UPD_BY, UPD_DATE, CORP_ID, TAX_GB) \n");
  531. sql.append(" SELECT SUB1050T_S.NEXTVAL , A.* \n");
  532. sql.append(" FROM ( \n");
  533. sql.append(" SELECT TO_DATE(MAIN.TAX_DY,'YYYYMMDD') AS PROOFDATE \n");
  534. sql.append(" , F_GET_R_DEPT_CD(CONTRACT.DEPT_CD) DEPT_CD --2015.11.5 본코드 대체 \n");
  535. sql.append(" , 'PREPAY' PREREQTFLG \n");
  536. sql.append(" , 0 ACMP_NO \n");
  537. sql.append(" , CONTRACT.PROOF_CD PROOF_CLASS \n");
  538. sql.append(" , TO_CHAR(MAIN.PREPAY_DATE, 'YYMMDD') || ' 외주선급전표(' || CONTRACT.BUILD_NAME || ')' ORDACCDESC \n");
  539. sql.append(" , MAIN.REQ_PREPAY_SUPPLY_TAMT SUPPLY_AMT \n");
  540. sql.append(" , MAIN.REQ_PREPAY_SURTAX_AMT SURTAX_AMT \n");
  541. sql.append(" , F_GET_DEALR_CD_EBID(SUBVENDOR.CORP_ID) DEALR_CD \n");
  542. sql.append(" , F_GET_DEALR_NO_EBID(SUBVENDOR.CORP_ID) DCERTI_NO \n");
  543. sql.append(" , TO_DATE(MAIN.TAX_DY,'YYYYMMDD') AS TAX_DATE \n");
  544. sql.append(" , 'Y' ELECTAX_YN \n");
  545. sql.append(" , CONTRACT.PAY_ITEM PAYITEM \n");
  546. sql.append(" , CONTRACT.COST_CODE COSTCODE \n");
  547. sql.append(" , CONTRACT.COST_TYPE COSTTYPE \n");
  548. sql.append(" , CONTRACT.ACCT_GB ACC_CLASS \n");
  549. sql.append(" , CASE SAUP.AC_UNIT_CD \n");
  550. sql.append(" WHEN '10' THEN '22' \n");
  551. sql.append(" ELSE '21' \n");
  552. sql.append(" END PAY_GROUP \n");
  553. sql.append(" , CONTRACT.PAYMENT_TERMS PAYMENT_TERMS \n");
  554. sql.append(" , NULL TMPSLIP_DEPT \n");
  555. sql.append(" , NULL TMPSLIP_DT \n");
  556. sql.append(" , NULL TMPSLIP_NO \n");
  557. sql.append(" , 'N' TMPSLIP_YN \n");
  558. sql.append(" , 'N' SLIP_YN \n");
  559. sql.append(" , MAIN.CON_CUR_CD CON_CUR_CD \n");
  560. sql.append(" , NULL ACMP_ID \n");
  561. sql.append(" , MAIN.PREPAY_ID PREPAY_ID \n");
  562. sql.append(" , ? CRE_BY \n");
  563. sql.append(" , SYSDATE CRE_DATE \n");
  564. sql.append(" , NULL UPD_BY \n");
  565. sql.append(" , NULL UPD_DATE \n");
  566. sql.append(" , SUBVENDOR.CORP_ID CORP_ID \n");
  567. sql.append(" , 'T' TAX_GB \n");
  568. sql.append(" FROM SUB1030T MAIN \n");
  569. sql.append(" , SUB1020T SUBVENDOR \n");
  570. sql.append(" , SUB1000T CONTRACT \n");
  571. sql.append(" , ETEC_ERPIF.ACZ10100 SAUP \n");
  572. sql.append(" WHERE 1=1 \n");
  573. sql.append(" AND MAIN.CON_CORP_ID = SUBVENDOR.CON_CORP_ID \n");
  574. sql.append(" AND MAIN.SUB_CONT_ID = CONTRACT.SUB_CONT_ID \n");
  575. sql.append(" AND CONTRACT.DEPT_CD = SAUP.DEPT_CD \n");
  576. sql.append(" AND SUBVENDOR.MAIN_CORP = 'Y' \n");
  577. sql.append(" AND CONTRACT.DEPT_CD = ? \n");
  578. sql.append(" AND MAIN.STATUS_CD = '10' \n");
  579. sql.append(" AND MAIN.PREPAY_ID = ? \n");
  580. sql.append(" AND MAIN.PREPAY_SUPPLY_TAMT > 0 \n");
  581. sql.append(" UNION ALL \n");
  582. sql.append(" SELECT TO_DATE(MAIN.TAX_DY,'YYYYMMDD') AS PROOFDATE \n");
  583. sql.append(" , F_GET_R_DEPT_CD(CONTRACT.DEPT_CD ) DEPT_CD --2015.11.5 본코드대체 \n");
  584. sql.append(" , 'PREPAY' PREREQTFLG \n");
  585. sql.append(" , 0 ACMP_NO \n");
  586. sql.append(" , DECODE(CONTRACT.PROOF_CD,'21','26', CONTRACT.PROOF_CD) PROOF_CLASS \n");
  587. sql.append(" , TO_CHAR(MAIN.PREPAY_DATE, 'YYMMDD') || ' 외주선급전표(' || CONTRACT.BUILD_NAME || ')' ORDACCDESC \n");
  588. sql.append(" , MAIN.REQ_PREPAY_SUPPLY_NAMT SUPPLY_AMT \n");
  589. sql.append(" , 0 SURTAX_AMT \n");
  590. sql.append(" , F_GET_DEALR_CD_EBID(SUBVENDOR.CORP_ID) DEALR_CD \n");
  591. sql.append(" , F_GET_DEALR_NO_EBID(SUBVENDOR.CORP_ID) DCERTI_NO \n");
  592. sql.append(" , TO_DATE(MAIN.TAX_DY,'YYYYMMDD') AS TAX_DATE \n");
  593. sql.append(" , 'Y' ELECTAX_YN \n");
  594. sql.append(" , CONTRACT.PAY_ITEM PAYITEM \n");
  595. sql.append(" , CONTRACT.COST_CODE COSTCODE \n");
  596. sql.append(" , CONTRACT.COST_TYPE COSTTYPE \n");
  597. sql.append(" , CONTRACT.ACCT_GB ACC_CLASS \n");
  598. sql.append(" , CASE SAUP.AC_UNIT_CD \n");
  599. sql.append(" WHEN '10' THEN '22' \n");
  600. sql.append(" ELSE '21' \n");
  601. sql.append(" END PAY_GROUP \n");
  602. sql.append(" , CONTRACT.PAYMENT_TERMS PAYMENT_TERMS \n");
  603. sql.append(" , NULL TMPSLIP_DEPT \n");
  604. sql.append(" , NULL TMPSLIP_DT \n");
  605. sql.append(" , NULL TMPSLIP_NO \n");
  606. sql.append(" , 'N' TMPSLIP_YN \n");
  607. sql.append(" , 'N' SLIP_YN \n");
  608. sql.append(" , MAIN.CON_CUR_CD CON_CUR_CD \n");
  609. sql.append(" , NULL ACMP_ID \n");
  610. sql.append(" , MAIN.PREPAY_ID PREPAY_ID \n");
  611. sql.append(" , ? CRE_BY \n");
  612. sql.append(" , SYSDATE CRE_DATE \n");
  613. sql.append(" , NULL UPD_BY \n");
  614. sql.append(" , NULL UPD_DATE \n");
  615. sql.append(" , SUBVENDOR.CORP_ID CORP_ID \n");
  616. sql.append(" , 'N' TAX_GB \n");
  617. sql.append(" FROM SUB1030T MAIN \n");
  618. sql.append(" , SUB1020T SUBVENDOR \n");
  619. sql.append(" , SUB1000T CONTRACT \n");
  620. sql.append(" , ETEC_ERPIF.ACZ10100 SAUP \n");
  621. sql.append(" WHERE 1=1 \n");
  622. sql.append(" AND MAIN.CON_CORP_ID = SUBVENDOR.CON_CORP_ID \n");
  623. sql.append(" AND MAIN.SUB_CONT_ID = CONTRACT.SUB_CONT_ID \n");
  624. sql.append(" AND CONTRACT.DEPT_CD = SAUP.DEPT_CD \n");
  625. sql.append(" AND SUBVENDOR.MAIN_CORP = 'Y' \n");
  626. sql.append(" AND CONTRACT.DEPT_CD = ? \n");
  627. sql.append(" AND MAIN.STATUS_CD = '10' \n");
  628. sql.append(" AND MAIN.PREPAY_ID = ? \n");
  629. sql.append(" AND MAIN.PREPAY_SUPPLY_NAMT > 0 \n");
  630. sql.append(" ) A \n");
  631. sql.append(" \n");
  632. System.out.println(sql.toString());
  633. }
  634. private void preInvoiceDoc020t(Connection con, String tmpslipID, String userID) throws Exception {
  635. String strResult = null;
  636. String message = "";
  637. String SPStateMent = "";
  638. CallableStatement cs = null;
  639. String arrDocNm [] = {"외주선급금계산서"};
  640. String arrProofGu [] = {"18"};
  641. //WAFLogger.debug("\n\t #################### params = [\n"+ params +"\n");
  642. try {
  643. // 증빙정보 생성 프로시저
  644. // - 외주 기성고 계산서만 새로 생성해야만 한다.
  645. SPStateMent = "{call SAC_DOCUMENTATIVE.prc_subinvoicebiz4TypeA(?, ?, ?, ?, ?)}";
  646. cs = con.prepareCall(SPStateMent);
  647. // 라인당, 기성고계산서 한라인만 생성.
  648. for(int iCount=0; iCount<arrDocNm.length; iCount++) {
  649. int i = 1;
  650. cs.setString(i++, tmpslipID);
  651. cs.setInt(i++, Integer.parseInt(userID));
  652. cs.setString(i++, arrDocNm[iCount]);
  653. cs.setString(i++, arrProofGu[iCount]);
  654. cs.registerOutParameter(i++, Types.VARCHAR);
  655. cs.execute();
  656. strResult = cs.getString(5);
  657. // 입력된 증빙데이터 라인을 기준으로 실제 증빙을
  658. String arrKeys[] = strResult.split("@"); // proof_dept, proofdate, proof_no, proof_seq
  659. OutputStream outputStream = getOS(con, arrKeys[0], arrKeys[1], arrKeys[2], Integer.parseInt(arrKeys[3]));
  660. // 기성고 계산서 PDF 생성
  661. SACDOCreatePDF6 sacDOCreatePDF6 = new SACDOCreatePDF6();
  662. sacDOCreatePDF6.doBiz1(con, outputStream, tmpslipID , null);
  663. }
  664. // 라인당, 기성고계산서 한라인만 생성. - 종료
  665. }
  666. catch(Exception e) {
  667. //super.doException(e);
  668. message = this.getClass().getName() + "\n" + e.getMessage();
  669. message = StringUtil.replace(message, "\"", "");
  670. //storage.setDetailMessage(message);
  671. throw e;
  672. }
  673. finally{
  674. try {
  675. if (cs != null) cs.close();
  676. }
  677. catch (Exception ex_close) {
  678. WAFLogger.error(ex_close);
  679. }
  680. }
  681. }
  682. public static OutputStream getOS(Connection con, String proof_dept, String proof_dt, String proof_no,
  683. int proof_seq) throws Exception {
  684. OutputStream outputStream = null;
  685. PreparedStatement pstmt = null;
  686. ResultSet resultSet = null;
  687. Statement stmt = null;
  688. try {
  689. String strSQL = "SELECT photo "
  690. + " FROM DOC021T "
  691. + " WHERE proof_dept = '"+ proof_dept +"'"
  692. + " AND TO_CHAR (proofdate, 'yyyymmdd') = '"+ proof_dt +"' "
  693. + " AND proof_no = " + proof_no
  694. + " AND proof_seq = "+ proof_seq
  695. + " AND proc_gu = '30' "
  696. + " FOR UPDATE";
  697. pstmt = con.prepareStatement(strSQL);
  698. resultSet = pstmt.executeQuery();
  699. if (resultSet.next()) {
  700. OracleThinBlob blob = (OracleThinBlob)resultSet.getBlob(1);
  701. outputStream = blob.getBinaryOutputStream();
  702. } else {
  703. throw new Exception("증빙파일을 저장할 레코드가 존재하지 않습니다.");
  704. }
  705. } catch (Exception e) {
  706. WAFLogger.error(e);
  707. } finally {
  708. if( stmt != null ) stmt.close();
  709. resultSet.close();
  710. pstmt.close();
  711. return outputStream;
  712. }
  713. }
  714. public String getSqPrepay(ValueObject vo) throws Exception {
  715. Search search = new SearchImpl();
  716. RowSet rowSet = new RowSetImpl();
  717. String sqPrepay = "";
  718. StringBuffer sqlstr = new StringBuffer();
  719. try {
  720. sqlstr.append("SELECT TO_CHAR(NVL(MAX(SQ_PREPAY),0) + 1,'FM000') AS SQ_PREPAY \n");
  721. sqlstr.append("FROM WC_O_PREPAY@ERPIU \n");
  722. sqlstr.append("WHERE CD_COMPANY = ? \n");
  723. sqlstr.append("AND CD_SITE = ? \n");
  724. sqlstr.append("AND CD_CM00215 = ? \n");
  725. sqlstr.append("AND NO_CONT = ? \n");
  726. search.setStatement(sqlstr.toString());
  727. search.addParameter(vo.get("CD_COMPANY"));
  728. search.addParameter(vo.get("CD_SITE"));
  729. search.addParameter(vo.get("CD_CM00215"));
  730. search.addParameter(vo.get("NO_CONT"));
  731. rowSet = search.execute();
  732. if( rowSet != null && rowSet.size() > 0 ) {
  733. sqPrepay = rowSet.getRow(0).get("SQ_PREPAY");
  734. }else {
  735. throw new Exception("ERPIU SQ_PREPAY 채번 실패");
  736. }
  737. return sqPrepay;
  738. } catch(Exception e) {
  739. WAFLogger.error(this.getClass().getName() + " --> getSqPrepay() : \n" + e.getMessage());
  740. //WAFLogger.error("SQL : " + search.getStatement());
  741. WAFLogger.error(e);
  742. throw e;
  743. }
  744. }
  745. }