PaymentBuySignDriver.java 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180
  1. /**
  2. * @(#)file PoDeciSignDriver.java
  3. * @(#)author Lee beomgeun
  4. * @(#)version 1.0
  5. * @(#)date Aug 1, 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.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.logger.Logger;
  22. import kr.co.hsnc.common.sql.RowSet;
  23. import kr.co.hsnc.common.sql.RowSetImpl;
  24. import kr.co.hsnc.common.sql.WAFSQLException;
  25. import kr.co.hsnc.common.sql.persistent.Persistent;
  26. import kr.co.hsnc.common.sql.persistent.PersistentImpl;
  27. import kr.co.hsnc.common.sql.search.Search;
  28. import kr.co.hsnc.common.sql.search.SearchImpl;
  29. import kr.co.hsnc.common.sql.util.RowSetUtility;
  30. import kr.co.hsnc.common.util.StringUtil;
  31. import kr.co.hsnc.common.util.ValueObject;
  32. import kr.co.udapsoft.common.commonSign.CommonSignInterface;
  33. import kr.co.udapsoft.common.commonSign.util.SACDOCreatePDF4;
  34. import kr.co.udapsoft.ebid.buyer.bid.purchase.biz.InterfacePurERPiU;
  35. import weblogic.jdbc.vendor.oracle.OracleThinBlob;
  36. /**
  37. *
  38. * @version 1.0
  39. * @author Beomgeun Lee
  40. */
  41. public class PaymentBuySignDriver implements CommonSignInterface {
  42. /**
  43. * 테슽 파일
  44. *
  45. */
  46. public PaymentBuySignDriver() {
  47. super();
  48. }
  49. /*
  50. * (non-Javadoc)
  51. * @see kr.co.udap.ehr.common.sign.SignInterface#doCallSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  52. */
  53. public void doCallSign(Connection connection, ValueObject signDoc) throws Exception {
  54. System.out.println("1");
  55. }
  56. /*
  57. * (non-Javadoc)
  58. * @see kr.co.udap.ehr.common.sign.SignInterface#doStartSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  59. */
  60. public void doStartSign(Connection connection, ValueObject signDoc) throws Exception {
  61. System.out.println("2");
  62. }
  63. /*
  64. * (non-Javadoc)
  65. * @see kr.co.udap.ehr.common.sign.SignInterface#doFirstFinishSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  66. */
  67. public void doFirstFinishSign(Connection connection, ValueObject signDoc) throws Exception {
  68. System.out.println("3");
  69. /* 운영에 반영할때는 변경해야함*/
  70. RowSet signUserInfo = getIFSignUser(signDoc.get("DOC_ID"));
  71. // 2020.02.17 결재정보가 없는 경우 예외처리
  72. if(signUserInfo.size() == 0){
  73. throw new Exception("결재정보가 없습니다.");
  74. }
  75. for ( int j = 0 ; j < signUserInfo.size() ; j ++ ) {
  76. ValueObject signUser = new ValueObject();
  77. signUser.set("SIGN_SEQ", ""+(j+1));
  78. signUser.set("DOC_ID", signDoc.get("DOC_ID"));
  79. signUser.set("APPROVAL_DATE", signUserInfo.getRow(j).get("PROCESSDATE"));
  80. signUser.set("APPROVAL_SABUN", signUserInfo.getRow(j).get("SABUN"));
  81. signUser.set("APPROVAL_USER", signUserInfo.getRow(j).get("APRMEMBERNAME"));
  82. signUser.set("A_POSITION", signUserInfo.getRow(j).get("APRMEMBERJOBTITLE"));
  83. signUser.set("SIGN_RESULT", signUserInfo.getRow(j).get("APRSTATE"));
  84. signUser.set("SIGN_TYPE", signDoc.get("SIGN_TYPE"));
  85. signUser.set("ACCT_TYPE", signDoc.get("ACCT_TYPE"));
  86. signUser.set("SLIP_DEPT", signDoc.get("KEY_COL3"));
  87. signUser.set("ACCSLIP_NO", "");
  88. signUser.set("SLIP_DT", signDoc.get("KEY_COL4"));
  89. signUser.set("SLIP_NO", signDoc.get("KEY_COL5"));
  90. insertSign002t(connection, signUser);
  91. }
  92. updatePur1100t(connection, signDoc, signUserInfo);
  93. }
  94. /*
  95. * (non-Javadoc)
  96. * @see kr.co.udap.ehr.common.sign.SignInterface#doFinishSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  97. */
  98. public void doFinishSign(Connection connection, ValueObject signDoc) throws Exception {
  99. System.out.println("4");
  100. }
  101. /*
  102. * (non-Javadoc)
  103. * @see kr.co.udap.ehr.common.sign.SignInterface#doRejectSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  104. */
  105. public void doFirstRejectSign(Connection connection, ValueObject signDoc) throws Exception {
  106. updatePur1100t(connection, signDoc, new RowSetImpl());
  107. }
  108. /*
  109. * (non-Javadoc)
  110. * @see kr.co.udap.ehr.common.sign.SignInterface#doRejectSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  111. */
  112. public void doRejectSign(Connection connection, ValueObject signDoc) throws Exception {
  113. updatePur1100t(connection, signDoc, new RowSetImpl());
  114. }
  115. /*
  116. * (non-Javadoc)
  117. * @see kr.co.udap.ehr.common.sign.SignInterface#doCancelSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  118. */
  119. public void doCancelSign(Connection connection, ValueObject signDoc) throws Exception {
  120. System.out.println("5");
  121. }
  122. private RowSet getIFSignUser(String docId) throws Exception{
  123. Search search = new SearchImpl();
  124. search.setDSName("jdbc/gwsql");
  125. RowSet rowSet = new RowSetImpl();
  126. StringBuffer sqlstr = new StringBuffer();
  127. try {
  128. sqlstr.append(" SELECT APRSTATE \n");
  129. sqlstr.append(" ,REPLACE(APRMEMBERID,SUBSTRING(APRMEMBERID,1,4),'') AS SABUN \n");
  130. sqlstr.append(" ,APRMEMBERNAME \n");
  131. sqlstr.append(" ,APRMEMBERJOBTITLE \n");
  132. sqlstr.append(" ,APRMEMBERDEPTNAME \n");
  133. sqlstr.append(" ,REPLACE(CONVERT(VARCHAR(10),PROCESSDATE,120),'-','') AS PROCESSDATE \n");
  134. sqlstr.append(" FROM TBENDAPRLINEINFO \n");
  135. sqlstr.append(" WHERE APRTYPE = 'A03001' \n");
  136. sqlstr.append(" AND DOCID = '"+docId+"' \n");
  137. sqlstr.append(" ORDER BY APRMEMBERSN \n");
  138. search.setStatement(sqlstr.toString());
  139. rowSet = search.execute();
  140. System.out.println(sqlstr.toString());
  141. }
  142. catch(WAFSQLException se) {
  143. Logger.err.println("SQL : \n" + se.getStatement());
  144. Logger.err.println("PARAM : \n" + se.getParameter());
  145. throw se;
  146. }
  147. finally {
  148. if( rowSet == null ) rowSet = new RowSetImpl();
  149. }
  150. return rowSet;
  151. }
  152. public void insertSign002t(Connection connection, ValueObject vo) throws Exception {
  153. Persistent persistent = new PersistentImpl(connection);
  154. StringBuffer sqlstr = null;
  155. try {
  156. sqlstr = new StringBuffer();
  157. sqlstr.append(" INSERT INTO SIGN002T \n");
  158. sqlstr.append(" (SIGN_HIS_ID \n");
  159. sqlstr.append(" ,SIGN_SEQ \n");
  160. sqlstr.append(" ,DOC_ID \n");
  161. sqlstr.append(" ,APPROVAL_DATE \n");
  162. sqlstr.append(" ,APPROVAL_SABUN \n");
  163. sqlstr.append(" ,APPROVAL_USER \n");
  164. sqlstr.append(" ,A_POSITION \n");
  165. sqlstr.append(" ,SIGN_RESULT \n");
  166. sqlstr.append(" ,SLIP_DEPT \n");
  167. sqlstr.append(" ,SLIP_DT \n");
  168. sqlstr.append(" ,SLIP_NO \n");
  169. sqlstr.append(" ,SIGN_TYPE \n");
  170. sqlstr.append(" ,COMON_DCR \n");
  171. sqlstr.append(" ) VALUES \n");
  172. sqlstr.append(" ( \n");
  173. sqlstr.append(" SIGN002T_S.NEXTVAL \n");
  174. sqlstr.append(" ,? \n");
  175. sqlstr.append(" ,? \n");
  176. sqlstr.append(" ,TO_DATE(?,'YYYYMMDD') \n");
  177. sqlstr.append(" ,? \n");
  178. sqlstr.append(" ,? \n");
  179. sqlstr.append(" ,? \n");
  180. sqlstr.append(" ,? \n");
  181. sqlstr.append(" ,? \n");
  182. sqlstr.append(" ,? \n");
  183. sqlstr.append(" ,? \n");
  184. sqlstr.append(" ,1 \n");
  185. sqlstr.append(" ,2 \n");
  186. sqlstr.append(" ) \n");
  187. System.out.println(sqlstr.toString());
  188. System.out.println("=>"+vo.get("SIGN_SEQ"));
  189. System.out.println("=>"+vo.get("DOC_ID"));
  190. System.out.println("=>"+vo.get("APPROVAL_DATE"));
  191. System.out.println("=>"+vo.get("APPROVAL_SABUN"));
  192. System.out.println("=>"+vo.get("APPROVAL_USER"));
  193. System.out.println("=>"+vo.get("A_POSITION"));
  194. System.out.println("=>"+vo.get("SIGN_RESULT"));
  195. System.out.println("=>"+vo.get("SLIP_DEPT"));
  196. System.out.println("=>"+vo.get("SLIP_DT"));
  197. System.out.println("=>"+vo.get("SLIP_NO"));
  198. persistent.setStatement(sqlstr.toString());
  199. persistent.addParameter(vo.get("SIGN_SEQ"));
  200. persistent.addParameter(vo.get("DOC_ID"));
  201. persistent.addParameter(vo.get("APPROVAL_DATE"));
  202. persistent.addParameter(vo.get("APPROVAL_SABUN"));
  203. persistent.addParameter(vo.get("APPROVAL_USER"));
  204. persistent.addParameter(vo.get("A_POSITION"));
  205. persistent.addParameter(vo.get("SIGN_RESULT"));
  206. persistent.addParameter(vo.get("SLIP_DEPT"));
  207. persistent.addParameter(vo.get("SLIP_DT"));
  208. persistent.addParameter(vo.get("SLIP_NO"));
  209. persistent.execute();
  210. }
  211. catch(Exception e) {
  212. WAFLogger.error(this.getClass().getName() + " --> updateSac01001() : " + e.getMessage());
  213. WAFLogger.error("SQL : " + sqlstr);
  214. WAFLogger.error(e);
  215. throw e;
  216. }
  217. }
  218. public void updatePur1100t(Connection connection, ValueObject vo, RowSet signUserInfo) throws Exception {
  219. Persistent persistent1 = new PersistentImpl(connection);
  220. StringBuffer sqlstr = null;
  221. StringBuffer sqlstr1 = null;
  222. try {
  223. sqlstr = new StringBuffer();
  224. sqlstr1 = new StringBuffer();
  225. String status = "";
  226. int complete = 0;
  227. if(vo.get("SIGN_DECI_CLASS").equals("14")){
  228. status = "10"; //완료
  229. }else {
  230. status = "99"; //반려
  231. complete = 1;
  232. }
  233. sqlstr1.append(" UPDATE PUR1100T SET \n");
  234. sqlstr1.append(" REQ_STATUS = ? \n");
  235. sqlstr1.append(" WHERE PAYREQ_ID = ? \n");
  236. persistent1.setStatement(sqlstr1.toString());
  237. persistent1.addParameter(status);
  238. persistent1.addParameter(vo.get("KEY_COL2"));
  239. persistent1.execute();
  240. //전표집계처리
  241. if(complete == 0){
  242. ValueObject pur1100tData = getPur1100t(vo.get("KEY_COL2"), vo.get("APPROVAL_SABUN"));
  243. pur1100tData.set("slipNo", vo.get("KEY_COL5"));
  244. pur1100tData.set("DOC_ID", vo.get("DOC_ID"));
  245. //업체평가 상태값 처리
  246. updateAppr(connection, pur1100tData);
  247. getPayJipge(connection, pur1100tData, signUserInfo);
  248. }
  249. }
  250. catch(Exception e) {
  251. WAFLogger.error(this.getClass().getName() + " --> updatePur1100t() : " + e.getMessage());
  252. WAFLogger.error("SQL : " + sqlstr);
  253. WAFLogger.error(e);
  254. throw e;
  255. }
  256. }
  257. /** 전표 생성 Procedure( PUR_INVOICE_CREATE) 수행
  258. * @throws Exception
  259. */
  260. public void callPurInvoiceCreate(Connection con, String prp_req_id, String userID, String slipNo) throws Exception {
  261. String message = "";
  262. String SPStateMent = "";
  263. CallableStatement cs = null;
  264. try {
  265. SPStateMent = "{call PUR_INVOICE_CREATE2(?,?,?)}";
  266. cs = con.prepareCall(SPStateMent);
  267. cs.setString(1, prp_req_id); // 가불금 ID
  268. cs.setString(2, userID); // USER ID
  269. cs.setString(3, slipNo); // USER ID
  270. cs.execute();
  271. } catch(Exception e) {
  272. WAFLogger.error(this.getClass().getName() +" -->" + SPStateMent+ " : \n" + e.getMessage());
  273. WAFLogger.error(e);
  274. message = this.getClass().getName() + "." + SPStateMent + " : \n" + e.getMessage();
  275. message = StringUtil.replace(message, "\"", "");
  276. //storage.setDetailMessage(message);
  277. throw e;
  278. } finally{
  279. try {
  280. if (cs != null) cs.close();
  281. } catch (Exception ex_close) {
  282. WAFLogger.error(ex_close);
  283. }
  284. }
  285. }
  286. public void createSMbill(Connection con, String prp_req_id, String userID, String payreqId, String ordDesc, String batchId) throws Exception {
  287. String message = "";
  288. String SPStateMent = "";
  289. CallableStatement cs = null;
  290. try {
  291. SPStateMent = "{call PUR_BILL_CREATE2(?,?,?,?,?)}";
  292. cs = con.prepareCall(SPStateMent);
  293. cs.setString(1, prp_req_id); // 가불금 ID
  294. cs.setString(2, userID); // USER ID
  295. cs.setString(3, payreqId);
  296. cs.setString(4, ordDesc.substring(10));
  297. cs.setString(5, batchId);
  298. cs.execute();
  299. } catch(Exception e) {
  300. WAFLogger.error(this.getClass().getName() +" -->" + SPStateMent+ " : \n" + e.getMessage());
  301. WAFLogger.error(e);
  302. message = this.getClass().getName() + "." + SPStateMent + " : \n" + e.getMessage();
  303. message = StringUtil.replace(message, "\"", "");
  304. //storage.setDetailMessage(message);
  305. throw e;
  306. } finally{
  307. try {
  308. if (cs != null) cs.close();
  309. } catch (Exception ex_close) {
  310. WAFLogger.error(ex_close);
  311. }
  312. }
  313. }
  314. //집계처리
  315. public boolean getPayJipge(Connection connection, ValueObject vo, RowSet signUserInfo) throws Exception {
  316. Persistent persistent_i = null;
  317. Persistent persistent_i_p = null;
  318. Persistent persistent_u = null;
  319. String sqlstr_i = "";
  320. String sqlstr_i_p = "";
  321. String sqlstr_u = "";
  322. try{
  323. persistent_i = new PersistentImpl(connection);
  324. persistent_i_p = new PersistentImpl(connection);
  325. persistent_u = new PersistentImpl(connection);
  326. int jip_count = getPayJipgeCount(connection, vo).getInt("jip_count");
  327. sqlstr_i = " INSERT INTO PUR1040T ( \n" +
  328. " TMPSLIP_ID -- 자재대금ID \n" +
  329. " ,DEPT_CD -- 현장코드 \n" +
  330. " ,PREPAY_GB -- 선급입고구분 \n" +
  331. " ,ENTER_DT -- 거래일자 \n" +
  332. " ,PROOF_CD -- 증빙코드 \n" +
  333. " ,ORD_DESC -- 적요 \n" +
  334. " ,MAT_AMT -- 구매금액 \n" +
  335. " ,MAT_SUPPLY_AMT -- 공급가액 \n" +
  336. " ,MAT_SURTAX_AMT -- 부가세 \n" +
  337. " ,PREPAY_SUB_AMT -- 선급금공제액 \n" +
  338. " ,DEALR_CD -- 거래처코드 \n" +
  339. " ,DCERTI_NO -- 사업자번호 \n" +
  340. " ,TAX_DATE -- 세금계산서일자 \n" +
  341. " ,ELECTAX_YN -- 전자세금계산서여부 \n" +
  342. " ,PAYITEM -- PAY ITEM \n" +
  343. " ,COSTCODE -- COST CODE \n" +
  344. " ,COSTTYPE -- COST TYPE \n" +
  345. " ,PAY_GROUP -- PAY_GROUP \n" +
  346. " ,PAYMENT_TERMS -- PAYMENT_TERMS \n" +
  347. " ,TMPNATFLG -- 계정구분 \n" +
  348. " ,TMPSLIP_YN -- 전표생성유무 \n" +
  349. " ,SLIP_YN -- 결의서작성유무 \n" +
  350. " ,CURRENCY_GB -- 통화구분 \n" +
  351. " ,PUR_CONT_ID -- 발주계약ID \n" +
  352. " ,PAYREQ_ID -- 지급신청ID \n" +
  353. " ,CRE_BY -- 등록자 \n" +
  354. " ,CRE_DATE -- 등록일시 \n" +
  355. " ) \n" +
  356. " VALUES ( \n" +
  357. " ? \n" +
  358. " ,? -- 현장코드 \n" +
  359. " ,? -- 선급입고구분 \n" +
  360. " ,TO_DATE(?, 'YYYYMMDD') -- 거래일자 \n" +
  361. " ,? -- 증빙코드 \n" +
  362. " ,? -- 적요 \n" +
  363. " ,? -- 구매금액 \n" +
  364. " ,? -- 공급가액 \n" +
  365. " ,? -- 부가세 \n" +
  366. " ,? -- 선급금공제액 \n" +
  367. " ,? -- 거래처코드 \n" +
  368. " ,? -- 사업자번호 \n" +
  369. " ,TO_DATE(?, 'YYYYMMDD') -- 세금계산서일자 \n" +
  370. " ,'Y' -- 전자세금계산서여부 \n" +
  371. " ,? -- PAY ITEM \n" +
  372. " ,? -- COST CODE \n" +
  373. " ,? -- COST TYPE \n" +
  374. " ,? -- PAY_GROUP \n" +
  375. " ,? -- PAYMENT_TERMS \n" +
  376. " ,? -- 계정구분 \n" +
  377. " ,? -- 전표생성유무 \n" +
  378. " ,? -- 결의서작성유무 \n" +
  379. " ,? -- 통화구분 \n" +
  380. " ,? -- 발주계약ID \n" +
  381. " ,? -- 지급신청ID \n" +
  382. " ,? -- 등록자 \n" +
  383. " ,SYSDATE ) \n" ;
  384. sqlstr_i_p = " INSERT INTO PUR1040T ( \n" +
  385. " TMPSLIP_ID -- 자재대금ID \n" +
  386. " ,DEPT_CD -- 현장코드 \n" +
  387. " ,PREPAY_GB -- 선급입고구분 \n" +
  388. " ,ENTER_DT -- 거래일자 \n" +
  389. " ,PROOF_CD -- 증빙코드 \n" +
  390. " ,ORD_DESC -- 적요 \n" +
  391. " ,MAT_AMT -- 구매금액 \n" +
  392. " ,MAT_SUPPLY_AMT -- 공급가액 \n" +
  393. " ,MAT_SURTAX_AMT -- 부가세 \n" +
  394. " ,PREPAY_SUB_AMT -- 선급금공제액 \n" +
  395. " ,DEALR_CD -- 거래처코드 \n" +
  396. " ,DCERTI_NO -- 사업자번호 \n" +
  397. " ,TAX_DATE -- 세금계산서일자 \n" +
  398. " ,ELECTAX_YN -- 전자세금계산서여부 \n" +
  399. " ,PAYITEM -- PAY ITEM \n" +
  400. " ,COSTCODE -- COST CODE \n" +
  401. " ,COSTTYPE -- COST TYPE \n" +
  402. " ,PAY_GROUP -- PAY_GROUP \n" +
  403. " ,PAYMENT_TERMS -- PAYMENT_TERMS \n" +
  404. " ,TMPNATFLG -- 계정구분 \n" +
  405. " ,TMPSLIP_YN -- 전표생성유무 \n" +
  406. " ,SLIP_YN -- 결의서작성유무 \n" +
  407. " ,CURRENCY_GB -- 통화구분 \n" +
  408. " ,PUR_CONT_ID -- 발주계약ID \n" +
  409. " ,PAYREQ_ID -- 지급신청ID \n" +
  410. " ,CRE_BY -- 등록자 \n" +
  411. " ,CRE_DATE -- 등록일시 \n" +
  412. " ) \n" +
  413. " VALUES ( \n" +
  414. " ? \n" +
  415. " ,? -- 현장코드 \n" +
  416. " ,? -- 선급입고구분 \n" +
  417. " ,TO_DATE(?, 'YYYYMMDD') -- 거래일자 \n" +
  418. " ,? -- 증빙코드 \n" +
  419. " ,? -- 적요 \n" +
  420. " ,? -- 구매금액 \n" +
  421. " ,? -- 공급가액 \n" +
  422. " ,? -- 부가세 \n" + //2015.9.11 불공제일때 선급공제 부가세 입력.
  423. " ,? -- 선급금공제액 \n" +
  424. " ,? -- 거래처코드 \n" +
  425. " ,? -- 사업자번호 \n" +
  426. " ,TO_DATE(?, 'YYYYMMDD') -- 세금계산서일자 \n" +
  427. " ,'Y' -- 전자세금계산서여부 \n" +
  428. " ,? -- PAY ITEM \n" +
  429. " ,? -- COST CODE \n" +
  430. " ,? -- COST TYPE \n" +
  431. " ,? -- PAY_GROUP \n" +
  432. " ,? -- PAYMENT_TERMS \n" +
  433. " ,? -- 계정구분 \n" +
  434. " ,? -- 전표생성유무 \n" +
  435. " ,? -- 결의서작성유무 \n" +
  436. " ,? -- 통화구분 \n" +
  437. " ,? -- 발주계약ID \n" +
  438. " ,? -- 지급신청ID \n" +
  439. " ,? -- 등록자 \n" +
  440. " ,SYSDATE ) \n" ;
  441. sqlstr_u = " UPDATE PUR1100T SET TRANS_CD = 'Y' WHERE PAYREQ_ID = ? ";
  442. RowSet rowSet = getPayReqList(connection, vo);
  443. RowSet preRowSet = getPayPreList(connection, vo);
  444. persistent_i.setStatement(sqlstr_i);
  445. persistent_i_p.setStatement(sqlstr_i_p);
  446. persistent_u.setStatement(sqlstr_u);
  447. String pay_group = "";
  448. String payment_term = "";
  449. String pay_item = "";
  450. String cost_code = "";
  451. String cost_type = "";
  452. String billDiv = "";
  453. String PAYREQ_ID = ""; //2018.08.02
  454. String PAYREQ_YN = "N";
  455. if(jip_count > 0){
  456. //선급공제액 전표집계
  457. if(preRowSet.size() > 0){
  458. for(int j = 0; j < preRowSet.size(); j++){
  459. //자재대금ID
  460. String tmpslipId_i_p = getTmpslipId();
  461. persistent_i_p.addParameter(tmpslipId_i_p);
  462. persistent_i_p.addParameter(preRowSet.getRow(j).get("DEPT_CD"));
  463. persistent_i_p.addParameter(preRowSet.getRow(j).get("PREPAY_GB"));
  464. persistent_i_p.addParameter(preRowSet.getRow(j).get("REQ_DATE")); //거래일자
  465. persistent_i_p.addParameter(preRowSet.getRow(j).get("GUA_GB")); //증빙
  466. persistent_i_p.addParameter(preRowSet.getRow(j).get("ORD_DESC")); //적요
  467. persistent_i_p.addParameter(0); //구매금액
  468. persistent_i_p.addParameter(0); //공급가액
  469. persistent_i_p.addParameter(0); //부가세 2015.9.11 불공제일때 선급 부가세 입력
  470. persistent_i_p.addParameter(preRowSet.getRow(j).get("CUR_PREPAY_DEDUCTAMT")); //선급공제액
  471. persistent_i_p.addParameter(preRowSet.getRow(j).get("CORP_ID"));
  472. persistent_i_p.addParameter(preRowSet.getRow(j).get("CORP_REG_NO")); //사업자번호
  473. persistent_i_p.addParameter(preRowSet.getRow(j).get("REQ_DATE")); //세금계산서일자
  474. persistent_i_p.addParameter(preRowSet.getRow(j).get("PAY_ITEM"));
  475. persistent_i_p.addParameter(preRowSet.getRow(j).get("COST_CODE"));
  476. persistent_i_p.addParameter(preRowSet.getRow(j).get("COST_TYPE"));
  477. persistent_i_p.addParameter(preRowSet.getRow(j).get("PAY_GROUP"));
  478. persistent_i_p.addParameter(preRowSet.getRow(j).get("PAYMENT_TERMS"));
  479. persistent_i_p.addParameter(preRowSet.getRow(j).get("ACCT_GB")); //계정구분
  480. persistent_i_p.addParameter("N"); //전표생성유무
  481. persistent_i_p.addParameter("N"); //결의서작성유무
  482. persistent_i_p.addParameter(preRowSet.getRow(j).get("CURRENCY_GB"));
  483. persistent_i_p.addParameter(preRowSet.getRow(j).get("PUR_CONT_ID"));
  484. persistent_i_p.addParameter(preRowSet.getRow(j).get("PAYREQ_ID"));
  485. persistent_i_p.addParameter(vo.getInt("USERID"));
  486. persistent_i_p.execute();
  487. persistent_i_p.clearParameters();
  488. //2018.8.2 청구금액없이 선급반제만 처리하는 경우 오류발생
  489. PAYREQ_ID = preRowSet.getRow(j).get("PAYREQ_ID");
  490. //증빙생성
  491. prcDoc020t(connection, tmpslipId_i_p, vo.getInt("USERID"), tmpslipId_i_p, preRowSet.getRow(j).get("CUR_PREPAY_DEDUCTAMT"));
  492. }
  493. }
  494. if(rowSet.size() > 0){
  495. for(int i = 0; rowSet.size() > i; i++){
  496. //자재대금ID
  497. String tmpslipId_i = getTmpslipId();
  498. pay_group = rowSet.getRow(i).get("PAY_GROUP");
  499. payment_term = rowSet.getRow(i).get("PAYMENT_TERMS");
  500. pay_item = rowSet.getRow(i).get("PAY_ITEM");
  501. cost_code = rowSet.getRow(i).get("COST_CODE");
  502. cost_type = rowSet.getRow(i).get("COST_TYPE");
  503. persistent_i.addParameter(tmpslipId_i);
  504. persistent_i.addParameter(rowSet.getRow(i).get("DEPT_CD"));
  505. persistent_i.addParameter(rowSet.getRow(i).get("PREPAY_GB"));
  506. persistent_i.addParameter(rowSet.getRow(i).get("REQ_DATE")); //거래일자
  507. persistent_i.addParameter(rowSet.getRow(i).get("GUA_GB")); //증빙
  508. persistent_i.addParameter(rowSet.getRow(i).get("ORD_DESC")); //적요
  509. persistent_i.addParameter(rowSet.getRow(i).get("CUR_REQ_APPLYAMT")); //구매금액
  510. persistent_i.addParameter(rowSet.getRow(i).get("CUR_REQ_AMT")); //공급가액
  511. persistent_i.addParameter(rowSet.getRow(i).get("CUR_REQ_VATAMT")); //부가세
  512. persistent_i.addParameter(0); //선급공제액
  513. persistent_i.addParameter(rowSet.getRow(i).get("CORP_ID"));
  514. persistent_i.addParameter(rowSet.getRow(i).get("CORP_REG_NO")); //사업자번호
  515. persistent_i.addParameter(rowSet.getRow(i).get("REQ_DATE")); //세금계산서일자
  516. persistent_i.addParameter(pay_item);
  517. persistent_i.addParameter(cost_code);
  518. persistent_i.addParameter(cost_type);
  519. persistent_i.addParameter(pay_group);
  520. persistent_i.addParameter(payment_term);
  521. persistent_i.addParameter(rowSet.getRow(i).get("ACCT_GB")); //계정구분
  522. persistent_i.addParameter("N"); //전표생성유무
  523. persistent_i.addParameter("N"); //결의서작성유무
  524. persistent_i.addParameter(rowSet.getRow(i).get("CURRENCY_GB"));
  525. persistent_i.addParameter(rowSet.getRow(i).get("PUR_CONT_ID"));
  526. persistent_i.addParameter(rowSet.getRow(i).get("PAYREQ_ID"));
  527. persistent_i.addParameter(vo.getInt("USERID"));
  528. persistent_i.execute();
  529. persistent_i.clearParameters();
  530. //2018.8.2 청구금액없이 선급반제만 처리하는 경우 오류발생
  531. PAYREQ_YN = "Y";
  532. persistent_u.addParameter(rowSet.getRow(i).get("PAYREQ_ID"));//2018.08.02
  533. persistent_u.execute();
  534. persistent_u.clearParameters();
  535. //증빙생성
  536. prcDoc020t(connection, tmpslipId_i, vo.getInt("USERID"), tmpslipId_i, "0");
  537. }
  538. }
  539. //2018.8.2 청구금액없이 선급반제만 처리하는 경우 오류발생
  540. if(PAYREQ_YN.equals("N")){
  541. persistent_u.addParameter(PAYREQ_ID);//2018.08.02
  542. persistent_u.execute();
  543. persistent_u.clearParameters();
  544. }
  545. try {
  546. if(vo.get("PAY_DIV").equals("1")) {
  547. InterfacePurERPiU.updateErpIuItem(vo, signUserInfo);
  548. }else {
  549. InterfacePurERPiU.updateErpIuInstall(vo, signUserInfo);
  550. }
  551. }catch(Exception e) {
  552. connection.rollback();
  553. throw new Exception("ERPIU insert Error : "+e.getMessage());
  554. }
  555. }else{
  556. return false;
  557. }
  558. return true;
  559. } catch(Exception e) {
  560. WAFLogger.error(this.getClass().getName() + " --> updatePur1100t() : " + e.getMessage());
  561. WAFLogger.error(e);
  562. throw e;
  563. }
  564. }
  565. public void prcDoc020t(Connection con, String tmpslipID, int userID, String tempslip_id, String prepay_sub_amt) throws Exception {
  566. String strResult = null;
  567. //String strFileName = null;
  568. //String message = "";
  569. String SPStateMent = "";
  570. CallableStatement cs = null;
  571. String arrDocNm [] = {"자재 계산서"};
  572. String arrProofGu [] = {"30"};
  573. //WAFLogger.debug("\n\t #################### params = [\n"+ params +"\n");
  574. try {
  575. // 증빙정보 생성 프로시저
  576. // - 자재 계산서만 새로 생성해야만 한다.
  577. SPStateMent = "{call SAC_DOCUMENTATIVE.prc_purinvoicebiz3(?, ?, ?, ?, ?)}";
  578. cs = con.prepareCall(SPStateMent);
  579. // 라인당, 기성고계산서 한라인만 생성.
  580. for(int iCount=0; iCount<arrDocNm.length; iCount++) {
  581. int i = 1;
  582. cs.setString(i++, tmpslipID);
  583. cs.setString(i++, arrProofGu[iCount]);
  584. cs.setInt(i++, userID);
  585. cs.setString(i++, prepay_sub_amt);
  586. cs.registerOutParameter(i++, Types.VARCHAR);
  587. cs.execute();
  588. strResult = cs.getString(5);
  589. // 입력된 증빙데이터 라인을 기준으로 실제 증빙을
  590. String arrKeys[] = strResult.split("@"); // proof_dept, proofdate, proof_no, proof_seq
  591. OutputStream outputStream = getOS(con, arrKeys[0], arrKeys[1], arrKeys[2], Integer.parseInt(arrKeys[3]));
  592. // 기성고 계산서 PDF 생성
  593. SACDOCreatePDF4 sacDOCreatePDF4 = new SACDOCreatePDF4();
  594. sacDOCreatePDF4.doBiz1(con, outputStream, tmpslipID, null);
  595. }
  596. // 라인당, 기성고계산서 한라인만 생성. - 종료
  597. }
  598. catch(Exception e) {
  599. WAFLogger.error(e);
  600. throw e;
  601. }
  602. finally{
  603. try {
  604. if (cs != null) cs.close();
  605. }
  606. catch (Exception ex_close) {
  607. WAFLogger.error(ex_close);
  608. }
  609. }
  610. }
  611. /* 증빙 스트림 Select !~ */
  612. public static OutputStream getOS(Connection con, String proof_dept, String proof_dt, String proof_no,
  613. int proof_seq) throws Exception {
  614. OutputStream outputStream = null;
  615. PreparedStatement pstmt = null;
  616. ResultSet resultSet = null;
  617. Statement stmt = null;
  618. try {
  619. String strSQL = "SELECT photo "
  620. + " FROM DOC021T "
  621. + " WHERE proof_dept = '"+ proof_dept +"'"
  622. + " AND TO_CHAR (proofdate, 'yyyymmdd') = '"+ proof_dt +"' "
  623. + " AND proof_no = " + proof_no
  624. + " AND proof_seq = "+ proof_seq
  625. + " AND proc_gu = '30' "
  626. + " FOR UPDATE";
  627. pstmt = con.prepareStatement(strSQL);
  628. resultSet = pstmt.executeQuery();
  629. if (resultSet.next()) {
  630. OracleThinBlob blob = (OracleThinBlob)resultSet.getBlob(1);
  631. outputStream = blob.getBinaryOutputStream();
  632. } else {
  633. throw new Exception("증빙화일을 저장할 레코드가 존재하지 않습니다.");
  634. }
  635. } catch (Exception e) {
  636. WAFLogger.error(e);
  637. } finally {
  638. if( stmt != null ) stmt.close();
  639. resultSet.close();
  640. pstmt.close();
  641. return outputStream;
  642. }
  643. }
  644. /**
  645. * 집계 가능한 내용 갯수
  646. * @param
  647. * @return ValueObject
  648. */
  649. public ValueObject getPayJipgeCount(Connection connection, ValueObject vo) throws Exception {
  650. Persistent persistent_c = null;
  651. //ValueObject resultVo = new ValueObject();
  652. ValueObject row = null;
  653. String sqlstr = "";
  654. try{
  655. persistent_c = new PersistentImpl(connection);
  656. sqlstr = " SELECT COUNT(*) JIP_COUNT \n" +
  657. " FROM PUR1100T A ,PUR1000T B \n" +
  658. " WHERE A.PUR_CONT_ID = B.PUR_CONT_ID \n" +
  659. " AND B.DEPT_CD = '"+vo.get("dept_cd")+"' \n" +
  660. " AND A.REQ_STATUS = '10' \n" +
  661. " AND TO_CHAR(A.REQ_DATE, 'YYYY-MM') = '"+vo.get("p_enter_dt")+"' \n" +
  662. " AND A.TRANS_CD = 'N' \n";
  663. persistent_c.setStatement(sqlstr);
  664. System.out.println(sqlstr);
  665. row = RowSetUtility.getValueObject(persistent_c.query().getRow(0));
  666. vo.set("jip_count", row.get("JIP_COUNT"));
  667. }catch(Exception e){
  668. WAFLogger.error(this.getClass().getName() + " --> getSeq() : " + e.getMessage());
  669. // System.out.println(e.getMessage());
  670. WAFLogger.error(e);
  671. throw e;
  672. }finally{
  673. if(vo == null) vo = new ValueObject();
  674. }
  675. return vo;
  676. }
  677. private RowSet getPayReqList(Connection connection, ValueObject params) throws Exception {
  678. RowSet rowSet = new RowSetImpl();
  679. String sqlstr = "";
  680. Persistent persistent_c = null;
  681. try{
  682. persistent_c = new PersistentImpl(connection);
  683. sqlstr = " SELECT \n" +
  684. " B.DEPT_CD DEPT_CD --현장코드 \n" +
  685. " , '2' AS PREPAY_GB --선급입고구분 \n" +
  686. " ,TO_CHAR(B.ORD_CON_DATE, 'YYYYMMDD') ORD_CON_DATE --거래일자 \n" +
  687. " ,A.GUA_GB GUA_GB --증빙코드 \n" +
  688. " ,CASE WHEN A.DEPOSIT_CD = '1' AND (SELECT AC_UNIT_CD \n" +
  689. " FROM ETEC_ERPIF.ACZ10100 \n" +
  690. " WHERE DEPT_CD = B.DEPT_CD ) = '10' \n" +
  691. " THEN '21' \n" +
  692. " WHEN A.DEPOSIT_CD = '1' AND (SELECT AC_UNIT_CD \n" +
  693. " FROM ETEC_ERPIF.ACZ10100 \n" +
  694. " WHERE DEPT_CD = B.DEPT_CD ) <> '10' \n" +
  695. " THEN '22' \n" +
  696. " ELSE A.PAY_GROUP \n" +
  697. " END PAY_GROUP --선급금PAY_GROUP \n" +
  698. " ,A.PAYMENT_TERMS PAYMENT_TERMS --PAYMENT_TERMS \n" +
  699. " ,CASE WHEN A.DEPOSIT_CD = 1 THEN \n" +
  700. " F_GET_REMARK_DATE(TO_DATE(A.TAX_DY , 'YYYYMMDD')) || ' 선급금(' || TO_NUMBER(A.DEPOSIT_SEQ) || '차) ' || B.CST_DOC_NAME \n" +
  701. " WHEN A.DEPOSIT_CD = 2 THEN \n" +
  702. " F_GET_REMARK_DATE(TO_DATE(A.TAX_DY , 'YYYYMMDD')) || ' 중도금(' || TO_NUMBER(A.DEPOSIT_SEQ ) || '차) ' || B.CST_DOC_NAME \n" +
  703. " ELSE F_GET_REMARK_DATE(TO_DATE(A.TAX_DY , 'YYYYMMDD')) || ' 잔금(' || TO_NUMBER(A.DEPOSIT_SEQ ) || '차) ' || B.CST_DOC_NAME END \n" +
  704. " AS ORD_DESC \n" +
  705. " ,B.ORD_AMT ORD_AMT --구매금액 \n" +
  706. " ,B.ORD_SUPPLY_AMT ORD_SUPPLY_AMT --공급가액 \n" +
  707. " ,A.CUR_REQ_VATAMT CUR_REQ_VATAMT --부가세 \n" +
  708. " ,F_GET_DEALR_CD_EBID(B.CORP_ID) CORP_ID --거래처코드 \n" +
  709. " ,F_GET_DEALR_NO_EBID(B.CORP_ID) CORP_REG_NO --사업자번호 \n" +
  710. " ,B.PAY_ITEM AS PAY_ITEM \n" +
  711. " ,B.COST_TYPE AS COST_TYPE \n" +
  712. " ,B.COST_CODE AS COST_CODE \n" +
  713. " ,B.CURRENCY_GB CURRENCY_GB --통화구분 \n" +
  714. " ,A.PUR_CONT_ID PUR_CONT_ID --발주계약ID \n" +
  715. " ,A.PAYREQ_ID PAYREQ_ID --지급신청ID \n" +
  716. " ,A.TAX_DY as REQ_DATE -- 작성일자 \n" +
  717. " ,B.CON_GB -- 계약구분 \n" +
  718. " ,B.ELEC_CON_YN -- 전자계약여부 \n" +
  719. " ,A.CUR_PREPAY_APPLYAMT AS CUR_PREPAY_DEDUCTAMT -- 금회선급공제 공급가액 \n" +
  720. " ,A.CUR_REQ_AMT + A.CUR_REQ_VATAMT CUR_REQ_APPLYAMT -- 금회청구공급가액 \n" +
  721. " ,A.CUR_PAYING_AMT -- 금회지급예정액 \n" +
  722. " ,A.CUR_REQ_AMT -- 금회청구액 \n" +
  723. " ,A.ACCT_GB --분계유형 \n" +
  724. " ,A.TAX_METHOD_CD \n" +
  725. " FROM PUR1100T A \n" +
  726. " LEFT OUTER JOIN PUR1000T B ON A.PUR_CONT_ID = B.PUR_CONT_ID \n" +
  727. " LEFT OUTER JOIN SUPP_INFO C ON B.CORP_ID = C.CORP_ID \n" +
  728. " WHERE B.DEPT_CD = '"+params.get("dept_cd")+"' \n" +
  729. " AND A.TRANS_CD = 'N' \n" +
  730. " AND A.REQ_STATUS = '10' \n" +
  731. " AND C.JOB_DIV = 'P' \n" +
  732. " AND TO_CHAR(TO_DATE(A.TAX_DY, 'YYYY-MM-DD'), 'YYYY-MM') = '"+params.get("p_enter_dt")+"' \n" +
  733. " AND A.CUR_REQ_AMT > 0 \n" ; //2017.04.28추가. 금회청구액 >0경우만 전표발생. 0원전표 금지.
  734. System.out.println(sqlstr);
  735. persistent_c.setStatement(sqlstr);
  736. rowSet = persistent_c.query();
  737. }catch (WAFSQLException se) {
  738. WAFLogger.error(this.getClass().getName() + " --> updatePur1100t() : " + se.getMessage());
  739. WAFLogger.error("SQL : " + sqlstr);
  740. WAFLogger.error(se);
  741. throw se;
  742. }
  743. finally {
  744. if(rowSet == null){
  745. rowSet = new RowSetImpl();
  746. }
  747. }
  748. return rowSet;
  749. }
  750. private RowSet getPayPreList(Connection connection, ValueObject params) throws Exception{
  751. RowSet rowSet = new RowSetImpl();
  752. String sqlstr = "";
  753. Persistent persistent_c = null;
  754. //ValueObject user = storage.getUser();
  755. try{
  756. persistent_c = new PersistentImpl(connection);
  757. sqlstr = " SELECT \n" +
  758. " B.DEPT_CD DEPT_CD --현장코드 \n" +
  759. " ,'2' AS PREPAY_GB --선급입고구분 \n" +
  760. " ,TO_CHAR(B.ORD_CON_DATE, 'YYYYMMDD') ORD_CON_DATE --거래일자 \n" +
  761. " ,A.GUA_GB GUA_GB --증빙코드 \n" +
  762. " ,A.PAY_GROUP PAY_GROUP --PAY_GROUP \n" +
  763. " ,A.PAYMENT_TERMS PAYMENT_TERMS --PAYMENT_TERMS \n" +
  764. " ,CASE WHEN A.DEPOSIT_CD = '1' THEN \n" +
  765. " F_GET_REMARK_DATE(TO_DATE(A.TAX_DY , 'YYYYMMDD')) || ' 선급금(' || TO_NUMBER(A.DEPOSIT_SEQ) || '차) ' || B.CST_DOC_NAME \n" +
  766. " WHEN A.DEPOSIT_CD = '2' THEN \n" +
  767. " F_GET_REMARK_DATE(TO_DATE(A.TAX_DY , 'YYYYMMDD')) || ' 중도금선급공제(' || TO_NUMBER(A.DEPOSIT_SEQ ) || '차) ' || B.CST_DOC_NAME \n" +
  768. " ELSE F_GET_REMARK_DATE(TO_DATE(A.TAX_DY , 'YYYYMMDD')) || ' 잔금(' || TO_NUMBER(A.DEPOSIT_SEQ ) || '차) ' || B.CST_DOC_NAME END \n" +
  769. " AS ORD_DESC --적요 \n" +
  770. " ,B.ORD_AMT ORD_AMT --구매금액 \n" +
  771. " ,B.ORD_SUPPLY_AMT ORD_SUPPLY_AMT --공급가액 \n" +
  772. " ,A.CUR_REQ_VATAMT CUR_REQ_VATAMT --부가세 \n" +
  773. " ,F_GET_DEALR_CD_EBID(B.CORP_ID) CORP_ID --거래처코드 \n" +
  774. " ,F_GET_DEALR_NO_EBID(B.CORP_ID) CORP_REG_NO --사업자번호 \n" +
  775. " ,B.PAY_ITEM AS PAY_ITEM \n" +
  776. " ,B.COST_TYPE AS COST_TYPE \n" +
  777. " ,B.COST_CODE AS COST_CODE \n" +
  778. " ,B.CURRENCY_GB CURRENCY_GB --통화구분 \n" +
  779. " ,A.PUR_CONT_ID PUR_CONT_ID --발주계약ID \n" +
  780. " ,A.PAYREQ_ID PAYREQ_ID --지급신청ID \n" +
  781. " ,A.TAX_DY as REQ_DATE -- 작성일자 \n" +
  782. " ,B.CON_GB -- 계약구분 \n" +
  783. " ,B.ELEC_CON_YN -- 전자계약여부 \n" +
  784. " ,A.CUR_PREPAY_APPLYAMT AS CUR_PREPAY_DEDUCTAMT -- 금회선급공제 공급가액 \n" +
  785. " ,A.CUR_PREPAY_VAT AS CUR_PREPAY_VAT -- 금회선급공제 vat 2015.9.11 선급공제 부가세 추가 \n" +
  786. " ,A.CUR_REQ_APPLYAMT -- 금회청구공급가액 \n" +
  787. " ,A.CUR_PAYING_AMT -- 금회지급예정액 \n" +
  788. " ,A.CUR_REQ_AMT -- 금회청구액 \n" +
  789. " ,A.ACCT_GB --분계유형 \n" +
  790. " FROM PUR1100T A \n" +
  791. " LEFT OUTER JOIN PUR1000T B ON A.PUR_CONT_ID = B.PUR_CONT_ID \n" +
  792. " LEFT OUTER JOIN SUPP_INFO C ON B.CORP_ID = C.CORP_ID \n" +
  793. " WHERE B.DEPT_CD = '"+params.get("dept_cd")+"' \n" +
  794. " AND A.TRANS_CD = 'N' \n" +
  795. " AND A.REQ_STATUS = '10' \n" +
  796. " AND C.JOB_DIV = 'P' \n" +
  797. " AND TO_CHAR(TO_DATE(A.TAX_DY, 'YYYY-MM-DD'), 'YYYY-MM') = '"+params.get("p_enter_dt")+"' \n"+
  798. " AND A.CUR_PREPAY_DEDUCTAMT > 0 \n";
  799. System.out.println(sqlstr);
  800. persistent_c.setStatement(sqlstr);
  801. rowSet = persistent_c.query();
  802. }catch (WAFSQLException se) {
  803. WAFLogger.error(this.getClass().getName() + " --> updatePur1100t() : " + se.getMessage());
  804. WAFLogger.error("SQL : " + sqlstr);
  805. WAFLogger.error(se);
  806. throw se;
  807. }
  808. finally {
  809. if(rowSet == null){
  810. rowSet = new RowSetImpl();
  811. }
  812. }
  813. return rowSet;
  814. }
  815. public ValueObject getPur1100t(String payreqId, String appSabun) throws Exception {
  816. Search search = new SearchImpl();
  817. RowSet rowSet = new RowSetImpl();
  818. String sqlstr = "";
  819. ValueObject row = null;
  820. try{
  821. sqlstr = " SELECT \n "
  822. +" A.DEPT_CD, --현장코드 \n "
  823. +" B.PUR_CONT_ID, \n "
  824. +" B.PAYREQ_ID, \n "
  825. +" B.PAY_DIV, \n "
  826. +" TO_CHAR(TO_DATE(B.TAX_DY,'yyyymmdd'), 'YYYY-MM') as P_ENTER_DT, \n "
  827. +" (SELECT MAX(ACCT_ID) FROM PUB0120T A \n "
  828. +" WHERE USER_SABUN = '"+appSabun+"') AS USERID, \n "
  829. +" D.ARR_ID, \n "
  830. +" A.CORP_ID \n "
  831. +" ,TO_CHAR(SYSDATE,'YYYYMMDD') AS DT_CHECK_APP \n "
  832. +" ,(SELECT MAX(USER_NAME) FROM PUB0120T WHERE USER_SABUN = '"+appSabun+"') AS NM_CHECK_APP \n "
  833. +" ,'"+appSabun+"' AS ID_CHECK_APP \n "
  834. //2019.04.03 신용길부장님 수정요청
  835. +" ,ROUND(B.CUR_ACMP_APPLYAMT * NVL(B.CUR_ACMP_EXCRATE,1),0) AS SAMT_BUILT \n "
  836. +" ,ROUND(B.CUR_ACMP_VAT * NVL(B.CUR_ACMP_EXCRATE,1),0) AS VAMT_BUILT \n "
  837. +" ,ROUND((B.CUR_ACMP_APPLYAMT + B.CUR_ACMP_VAT ) * NVL(B.CUR_ACMP_EXCRATE,1),0) AS AMT_BUILT \n "
  838. +" ,ROUND(B.CUR_PREPAY_APPLYAMT * NVL(B.CUR_ACMP_EXCRATE,1),0) AS SAMT_DEDUCT \n "
  839. +" ,ROUND(B.CUR_PREPAY_VAT * NVL(B.CUR_ACMP_EXCRATE,1),0) AS VAMT_DEDUCT \n "
  840. +" ,ROUND((B.CUR_PREPAY_APPLYAMT + B.CUR_PREPAY_VAT) * NVL(B.CUR_ACMP_EXCRATE,1),0) AS AMT_DEDUCT \n "
  841. +" ,B.CUR_ACMP_APPLYAMT AS SAMT_BUILT_CURR \n "
  842. +" ,B.CUR_ACMP_VAT AS VAMT_BUILT_CURR \n "
  843. +" ,(B.CUR_ACMP_APPLYAMT + B.CUR_ACMP_VAT ) AS AMT_BUILT_CURR \n "
  844. +" ,B.CUR_PREPAY_APPLYAMT AS SAMT_DEDUCT_CURR \n "
  845. +" ,B.CUR_PREPAY_VAT AS VAMT_DEDUCT_CURR \n "
  846. +" ,B.CUR_PREPAY_APPLYAMT + B.CUR_PREPAY_VAT AS AMT_DEDUCT_CURR \n "
  847. +" ,DECODE(B.TAX_METHOD_CD,'1','0','2') AS YN_ISS \n "
  848. +" ,B.TAX_DY AS DT_BUILT \n "
  849. +" ,B.TAX_DY AS DT_STRG_IN \n "
  850. +" ,NVL(B.CUR_ACMP_EXCRATE,1) AS UNT_CURR \n "
  851. //2019.07.29 ERP 자동분개를 위한 계정코드
  852. +" ,CASE WHEN A.CURRENCY_GB = 'KRW' THEN \n"
  853. +" CASE WHEN NVL(B.SUPP_DIRECT_YN,'') = 'Y' THEN NVL(E.CHG_CODE16, '') \n"
  854. +" ELSE NVL(E.CHG_CODE14, '') \n"
  855. +" END \n"
  856. +" ELSE CASE WHEN NVL(B.SUPP_DIRECT_YN,'') = 'Y' THEN NVL(E.CHG_CODE17, '') \n"
  857. +" ELSE NVL(E.CHG_CODE15, '') \n"
  858. +" END \n"
  859. +" END AS CD_COST_TRADE \n"
  860. +" FROM PUR1000T A, PUR1100T B, SUPP_APPR D, (SELECT DETAILCD, CHG_CODE14, CHG_CODE15, CHG_CODE16, CHG_CODE17 FROM EBID_COM911T WHERE BASECD = 'PUR-ACCT_GB' ) E \n "
  861. +" WHERE A.PUR_CONT_ID = B.PUR_CONT_ID \n "
  862. +" AND A.ORD_DOC_NO = D.ORD_DOC_NO(+) \n "
  863. +" AND A.CORP_ID = D.CORP_ID(+) \n "
  864. +" AND A.ACCT_GB = E.DETAILCD(+) \n "
  865. +" AND B.PAYREQ_ID = '"+payreqId+"' \n ";
  866. //2019.04.03 신용길부장님 수정요청
  867. //+" ,B.CUR_PREPAY_APPLYAMT AS SAMT_DEDUCT \n "
  868. //+" ,B.CUR_PREPAY_VAT AS VAMT_DEDUCT \n "
  869. //+" ,(B.CUR_PREPAY_APPLYAMT + B.CUR_PREPAY_VAT) AS AMT_DEDUCT \n "
  870. // +" ,(B.CUR_REQ_AMT+B.CUR_REQ_VATAMT) * NVL(B.CUR_ACMP_EXCRATE,1) AS AMT_BUILT \n "
  871. //+" ,B.CUR_REQ_AMT * NVL(B.CUR_ACMP_EXCRATE,1) AS SAMT_BUILT \n "
  872. //+" ,B.CUR_REQ_VATAMT * NVL(B.CUR_ACMP_EXCRATE,1) AS VAMT_BUILT \n "
  873. //+" ,(B.CUR_REQ_AMT+B.CUR_REQ_VATAMT) AS AMT_BUILT_CURR \n "
  874. //+" ,B.CUR_REQ_AMT AS SAMT_BUILT_CURR \n "
  875. //+" ,B.CUR_REQ_VATAMT AS VAMT_BUILT_CURR \n "
  876. System.out.println(sqlstr);
  877. search.setStatement(sqlstr);
  878. rowSet = search.execute();
  879. row = RowSetUtility.getValueObject(rowSet.getRow(0));
  880. }catch(Exception e){
  881. WAFLogger.error(this.getClass().getName() + " --> getPur1100t() : " + e.getMessage());
  882. WAFLogger.error("SQL : " + sqlstr);
  883. WAFLogger.error(e);
  884. throw e;
  885. }finally{
  886. if(row == null) row = new ValueObject();
  887. }
  888. return row;
  889. }
  890. public String getTmpslipId() throws Exception {
  891. Search search = new SearchImpl();
  892. RowSet rowSet = new RowSetImpl();
  893. String sqlstr = "";
  894. ValueObject row = null;
  895. String resultId = "";
  896. try{
  897. sqlstr = " SELECT PUR1040T_S.NEXTVAL AS TMPSLIP_ID FROM DUAL \n";
  898. System.out.println(sqlstr);
  899. search.setStatement(sqlstr);
  900. rowSet = search.execute();
  901. row = RowSetUtility.getValueObject(rowSet.getRow(0));
  902. resultId = row.get("TMPSLIP_ID");
  903. }catch(Exception e){
  904. WAFLogger.error(this.getClass().getName() + " --> updatePur1100t() : " + e.getMessage());
  905. WAFLogger.error("SQL : " + sqlstr);
  906. WAFLogger.error(e);
  907. throw e;
  908. }finally{
  909. if(row == null) row = new ValueObject();
  910. }
  911. return resultId;
  912. }
  913. /**
  914. * 대금이 선급금일시 pay_group, payment_terms 변경
  915. * @param
  916. * @return ValueObject
  917. */
  918. public ValueObject getPayGroup(Connection connection, String dept_cd) throws Exception {
  919. Persistent persistent_c = null;
  920. ValueObject vo = new ValueObject();
  921. ValueObject row = null;
  922. String sqlstr = "";
  923. try{
  924. persistent_c = new PersistentImpl(connection);
  925. sqlstr += " SELECT \n"
  926. + " DETAILCD \n"
  927. + " ,DETAILNM \n"
  928. + " FROM COM911T \n"
  929. + " WHERE BASECD = '005' \n"
  930. + " AND CHG_CODE04 = CASE \n"
  931. + " WHEN (SELECT AC_UNIT_CD FROM ETEC_ERPIF.ACZ10100 WHERE DEPT_CD = '"+dept_cd+"' ) = '60' THEN '60' \n"
  932. + " WHEN (SELECT AC_UNIT_CD FROM ETEC_ERPIF.ACZ10100 WHERE DEPT_CD = '"+dept_cd+"' ) <> '10' THEN '20' \n"
  933. + " ELSE '10' END || '_C' \n" ;
  934. persistent_c.setStatement(sqlstr);
  935. System.out.println(sqlstr);
  936. row = RowSetUtility.getValueObject(persistent_c.query().getRow(0));
  937. vo.set("DETAILCD", row.get("DETAILCD"));
  938. }catch(Exception e){
  939. WAFLogger.error(this.getClass().getName() + " --> getSeq() : " + e.getMessage());
  940. // System.out.println(e.getMessage());
  941. WAFLogger.error(e);
  942. throw e;
  943. }finally{
  944. if(vo == null) vo = new ValueObject();
  945. }
  946. return vo;
  947. }
  948. private void updateAppr(Connection connection, ValueObject pur1100tData) throws Exception {
  949. Persistent persistent = new PersistentImpl(connection);
  950. StringBuffer sqlstr = null;
  951. try {
  952. sqlstr = new StringBuffer();
  953. String status = "02";
  954. sqlstr.append(" UPDATE SUPP_APPR SET \n");
  955. sqlstr.append(" REGU_STATUS_CD = '02' \n");
  956. sqlstr.append(" WHERE CORP_ID = ? \n");
  957. sqlstr.append(" AND ARR_ID = ? \n");
  958. persistent.setStatement(sqlstr.toString());
  959. persistent.addParameter(pur1100tData.get("CORP_ID"));
  960. persistent.addParameter(pur1100tData.get("ARR_ID"));
  961. persistent.execute();
  962. }
  963. catch(Exception e) {
  964. WAFLogger.error(this.getClass().getName() + " --> updateAppr() : " + e.getMessage());
  965. WAFLogger.error("SQL : " + sqlstr);
  966. WAFLogger.error(e);
  967. throw e;
  968. }
  969. }
  970. }