PrepaymentCompletedSignDriver.java 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019
  1. /**
  2. * @(#)file PrepaymentCompletedSignDriver.java
  3. * @(#)author OK
  4. * @(#)version 1.0
  5. * @(#)date 2014-09-25
  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.logger.Logger;
  22. import kr.co.hsnc.common.sql.Row;
  23. import kr.co.hsnc.common.sql.RowSet;
  24. import kr.co.hsnc.common.sql.RowSetImpl;
  25. import kr.co.hsnc.common.sql.WAFSQLException;
  26. import kr.co.hsnc.common.sql.persistent.Persistent;
  27. import kr.co.hsnc.common.sql.persistent.PersistentImpl;
  28. import kr.co.hsnc.common.sql.search.Search;
  29. import kr.co.hsnc.common.sql.search.SearchImpl;
  30. import kr.co.hsnc.common.sql.util.RowSetUtility;
  31. import kr.co.hsnc.common.util.StringUtil;
  32. import kr.co.hsnc.common.util.ValueObject;
  33. import kr.co.udapsoft.common.commonSign.CommonSignInterface;
  34. import kr.co.udapsoft.common.commonSign.util.SACDOCreatePDF7;
  35. import kr.co.udapsoft.common.commonSign.util.SACDOCreatePDF8;
  36. import weblogic.jdbc.vendor.oracle.OracleThinBlob;
  37. public class PrepaymentCompletedSignDriver implements CommonSignInterface {
  38. /**
  39. *
  40. */
  41. public PrepaymentCompletedSignDriver() {
  42. super();
  43. }
  44. /*
  45. * (non-Javadoc)
  46. * @see kr.co.udap.ehr.common.sign.SignInterface#doCallSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  47. */
  48. public void doCallSign(Connection connection, ValueObject signDoc) throws Exception {
  49. System.out.println("1");
  50. }
  51. /*
  52. * (non-Javadoc)
  53. * @see kr.co.udap.ehr.common.sign.SignInterface#doStartSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  54. */
  55. public void doStartSign(Connection connection, ValueObject signDoc) throws Exception {
  56. System.out.println("2");
  57. }
  58. /*
  59. * (non-Javadoc)
  60. * @see kr.co.udap.ehr.common.sign.SignInterface#doFirstFinishSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  61. */
  62. public void doFirstFinishSign(Connection connection, ValueObject signDoc) throws Exception {
  63. System.out.println("4");
  64. /* 운영에 반영할때는 변경해야함*/
  65. RowSet signUserInfo = getIFSignUser(signDoc.get("DOC_ID"));
  66. for ( int j = 0 ; j < signUserInfo.size() ; j ++ ) {
  67. ValueObject signUser = new ValueObject();
  68. signUser.set("SIGN_SEQ", ""+(j+1));
  69. signUser.set("DOC_ID", signDoc.get("DOC_ID"));
  70. signUser.set("APPROVAL_DATE", signUserInfo.getRow(j).get("PROCESSDATE"));
  71. signUser.set("APPROVAL_SABUN", signUserInfo.getRow(j).get("SABUN"));
  72. signUser.set("APPROVAL_USER", signUserInfo.getRow(j).get("APRMEMBERNAME"));
  73. signUser.set("A_POSITION", signUserInfo.getRow(j).get("APRMEMBERJOBTITLE"));
  74. signUser.set("SIGN_RESULT", signUserInfo.getRow(j).get("APRSTATE"));
  75. signUser.set("SIGN_TYPE", signDoc.get("SIGN_TYPE"));
  76. signUser.set("ACCT_TYPE", signDoc.get("ACCT_TYPE"));
  77. signUser.set("SLIP_DEPT", signDoc.get("KEY_COL2"));
  78. signUser.set("ACCSLIP_NO", "");
  79. signUser.set("SLIP_DT", signDoc.get("KEY_COL4"));
  80. signUser.set("SLIP_NO", signDoc.get("KEY_COL5"));
  81. insertSign002t(connection, signUser);
  82. }
  83. updateSUB1040T(connection, signDoc);
  84. }
  85. /*
  86. * (non-Javadoc)
  87. * @see kr.co.udap.ehr.common.sign.SignInterface#doFinishSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  88. */
  89. public void doFinishSign(Connection connection, ValueObject signDoc) throws Exception {
  90. System.out.println("4");
  91. /* 운영에 반영할때는 변경해야함*/
  92. RowSet signUserInfo = getIFSignUser(signDoc.get("DOC_ID"));
  93. for ( int j = 0 ; j < signUserInfo.size() ; j ++ ) {
  94. ValueObject signUser = new ValueObject();
  95. signUser.set("SIGN_SEQ", ""+(j+1));
  96. signUser.set("DOC_ID", signDoc.get("DOC_ID"));
  97. signUser.set("APPROVAL_DATE", signUserInfo.getRow(j).get("PROCESSDATE"));
  98. signUser.set("APPROVAL_SABUN", signUserInfo.getRow(j).get("SABUN"));
  99. signUser.set("APPROVAL_USER", signUserInfo.getRow(j).get("APRMEMBERNAME"));
  100. signUser.set("A_POSITION", signUserInfo.getRow(j).get("APRMEMBERJOBTITLE"));
  101. signUser.set("SIGN_RESULT", signUserInfo.getRow(j).get("APRSTATE"));
  102. signUser.set("SIGN_TYPE", signDoc.get("SIGN_TYPE"));
  103. signUser.set("ACCT_TYPE", signDoc.get("ACCT_TYPE"));
  104. signUser.set("SLIP_DEPT", signDoc.get("KEY_COL2"));
  105. signUser.set("ACCSLIP_NO", "");
  106. signUser.set("SLIP_DT", signDoc.get("KEY_COL4"));
  107. signUser.set("SLIP_NO", signDoc.get("KEY_COL5"));
  108. insertSign002t(connection, signUser);
  109. }
  110. updateSUB1040T(connection, signDoc);
  111. }
  112. /*
  113. * (non-Javadoc)
  114. * @see kr.co.udap.ehr.common.sign.SignInterface#doRejectSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  115. */
  116. public void doFirstRejectSign(Connection connection, ValueObject signDoc) throws Exception {
  117. System.out.println("5");
  118. updateSUB1040T(connection, signDoc);
  119. }
  120. /*
  121. * (non-Javadoc)
  122. * @see kr.co.udap.ehr.common.sign.SignInterface#doRejectSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  123. */
  124. public void doRejectSign(Connection connection, ValueObject signDoc) throws Exception {
  125. System.out.println("6");
  126. updateSUB1040T(connection, signDoc);
  127. }
  128. /*
  129. * (non-Javadoc)
  130. * @see kr.co.udap.ehr.common.sign.SignInterface#doCancelSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  131. */
  132. public void doCancelSign(Connection connection, ValueObject signDoc) throws Exception {
  133. }
  134. private RowSet getIFSignUser(String docId) throws Exception{
  135. Search search = new SearchImpl();
  136. search.setDSName("jdbc/gwsql");
  137. RowSet rowSet = new RowSetImpl();
  138. StringBuffer sqlstr = new StringBuffer();
  139. try {
  140. sqlstr.append(" SELECT APRSTATE \n");
  141. sqlstr.append(" ,REPLACE(APRMEMBERID,SUBSTRING(APRMEMBERID,1,4),'') AS SABUN \n");
  142. sqlstr.append(" ,APRMEMBERNAME \n");
  143. sqlstr.append(" ,APRMEMBERJOBTITLE \n");
  144. sqlstr.append(" ,APRMEMBERDEPTNAME \n");
  145. sqlstr.append(" ,REPLACE(CONVERT(VARCHAR(10),PROCESSDATE,120),'-','') AS PROCESSDATE \n");
  146. sqlstr.append(" FROM TBENDAPRLINEINFO \n");
  147. sqlstr.append(" WHERE APRTYPE = 'A03001' \n");
  148. sqlstr.append(" AND DOCID = '"+docId+"' \n");
  149. sqlstr.append(" ORDER BY APRMEMBERSN \n");
  150. search.setStatement(sqlstr.toString());
  151. rowSet = search.execute();
  152. System.out.println(sqlstr.toString());
  153. }
  154. catch(WAFSQLException se) {
  155. Logger.err.println("SQL : \n" + se.getStatement());
  156. Logger.err.println("PARAM : \n" + se.getParameter());
  157. throw se;
  158. }
  159. finally {
  160. if( rowSet == null ) rowSet = new RowSetImpl();
  161. return rowSet;
  162. }
  163. }
  164. public void insertSign002t(Connection connection, ValueObject vo) throws Exception {
  165. Persistent persistent = new PersistentImpl(connection);
  166. StringBuffer sqlstr = null;
  167. try {
  168. sqlstr = new StringBuffer();
  169. sqlstr.append(" INSERT INTO SIGN002T \n");
  170. sqlstr.append(" (SIGN_HIS_ID \n");
  171. sqlstr.append(" ,SIGN_SEQ \n");
  172. sqlstr.append(" ,DOC_ID \n");
  173. sqlstr.append(" ,APPROVAL_DATE \n");
  174. sqlstr.append(" ,APPROVAL_SABUN \n");
  175. sqlstr.append(" ,APPROVAL_USER \n");
  176. sqlstr.append(" ,A_POSITION \n");
  177. sqlstr.append(" ,SIGN_RESULT \n");
  178. sqlstr.append(" ,SLIP_DEPT \n");
  179. sqlstr.append(" ,SLIP_DT \n");
  180. sqlstr.append(" ,SLIP_NO \n");
  181. sqlstr.append(" ,SIGN_TYPE \n");
  182. sqlstr.append(" ,COMON_DCR \n");
  183. sqlstr.append(" ) VALUES \n");
  184. sqlstr.append(" ( \n");
  185. sqlstr.append(" SIGN002T_S.NEXTVAL \n");
  186. sqlstr.append(" ,? \n");
  187. sqlstr.append(" ,? \n");
  188. sqlstr.append(" ,TO_DATE(?,'YYYYMMDD') \n");
  189. sqlstr.append(" ,? \n");
  190. sqlstr.append(" ,? \n");
  191. sqlstr.append(" ,? \n");
  192. sqlstr.append(" ,? \n");
  193. sqlstr.append(" ,? \n");
  194. sqlstr.append(" ,? \n");
  195. sqlstr.append(" ,? \n");
  196. sqlstr.append(" ,1 \n");
  197. sqlstr.append(" ,2 \n");
  198. sqlstr.append(" ) \n");
  199. persistent.setStatement(sqlstr.toString());
  200. persistent.addParameter(vo.get("SIGN_SEQ"));
  201. persistent.addParameter(vo.get("DOC_ID"));
  202. persistent.addParameter(vo.get("APPROVAL_DATE"));
  203. persistent.addParameter(vo.get("APPROVAL_SABUN"));
  204. persistent.addParameter(vo.get("APPROVAL_USER"));
  205. persistent.addParameter(vo.get("A_POSITION"));
  206. persistent.addParameter(vo.get("SIGN_RESULT"));
  207. persistent.addParameter(vo.get("SLIP_DEPT"));
  208. persistent.addParameter(vo.get("SLIP_DT"));
  209. persistent.addParameter(vo.get("SLIP_NO"));
  210. persistent.execute();
  211. }
  212. catch(Exception e) {
  213. WAFLogger.error(this.getClass().getName() + " --> insertSign002t() : " + e.getMessage());
  214. WAFLogger.error("SQL : " + sqlstr);
  215. WAFLogger.error(e);
  216. throw e;
  217. }
  218. }
  219. public void updateSUB1040T(Connection connection, ValueObject vo) throws Exception {
  220. Persistent persistent = new PersistentImpl(connection);
  221. Persistent persistent1 = new PersistentImpl(connection);
  222. StringBuffer sqlstr = null;
  223. StringBuffer sqlstr1 = null;
  224. try {
  225. sqlstr = new StringBuffer();
  226. sqlstr1 = new StringBuffer(); //2018.05.18준공평가에 따라 상태값 변경
  227. sqlstr.append(" UPDATE SUB1040T \n");
  228. sqlstr.append(" SET STATUS_CD = ? \n");
  229. sqlstr.append(" , UPD_DATE = SYSDATE \n");
  230. sqlstr.append(" WHERE ACMP_ID = ? \n");
  231. persistent.setStatement(sqlstr.toString());
  232. int complete = 0;
  233. if ( vo.get("SIGN_DECI_CLASS").equals("24") || vo.get("SIGN_DECI_CLASS").equals("14") ) {
  234. persistent.addParameter("10"); // 완료
  235. } else {
  236. persistent.addParameter("91"); // 반려
  237. complete = 1;
  238. }
  239. persistent.addParameter(vo.get("KEY_COL1"));
  240. persistent.execute();
  241. if(complete == 0){
  242. //2018.05.18준공평가 완료이면 거래처 상태값 변경
  243. sqlstr1.append(" MERGE \n");
  244. sqlstr1.append(" INTO SUPP_INFO A \n");
  245. sqlstr1.append(" USING (SELECT A1.CORP_ID,DECODE(A1.ITEM_STD_CD, 'C', '91', 'D', '99', 'X') STS \n");
  246. sqlstr1.append(" FROM SUPP_APPR A1 \n");
  247. sqlstr1.append(" ,SUB1040T B1 \n");
  248. sqlstr1.append(" WHERE A1.CONT_ID = B1.SUB_CONT_ID \n");
  249. sqlstr1.append(" AND B1.ACMP_ID IN (?) \n");
  250. sqlstr1.append(" AND A1.DOC_CD IN (12,16) ) B \n");
  251. sqlstr1.append(" ON (A.CORP_ID = B.CORP_ID \n");
  252. sqlstr1.append(" AND A.JOB_DIV = 'O' \n");
  253. sqlstr1.append(" AND B.STS IN ('91', '99') \n");
  254. sqlstr1.append(" AND A.STATUS IN ('02', '03')) \n");
  255. sqlstr1.append(" WHEN MATCHED THEN \n");
  256. sqlstr1.append(" UPDATE \n");
  257. sqlstr1.append(" SET A.STATUS = '91' \n");
  258. sqlstr1.append(" ,A.CAN_DT = SYSDATE \n");
  259. sqlstr1.append(" ,A.BAN_BID = DECODE(B.STS, '91', ADD_MONTHS(SYSDATE,12) , '99', TO_DATE('9999-12-31')) \n");
  260. sqlstr1.append(" ,A.UPD_DATE = SYSDATE \n");
  261. persistent1.setStatement(sqlstr1.toString());
  262. persistent1.addParameter(vo.get("KEY_COL1"));
  263. persistent1.execute();
  264. //대급지급 신청서(준공) 전표집계
  265. prepaymentComplete1(connection, vo);
  266. }
  267. } catch(Exception e) {
  268. WAFLogger.error(this.getClass().getName() + " --> updateSUB1040T() : " + e.getMessage());
  269. WAFLogger.error("SQL : " + sqlstr);
  270. WAFLogger.error(e);
  271. throw e;
  272. }
  273. }
  274. public void prepaymentComplete1(Connection connection, ValueObject vo) throws Exception {
  275. Search search = new SearchImpl();
  276. RowSet listRowSet = null;
  277. StringBuffer sql = new StringBuffer();
  278. ValueObject selectResult = new ValueObject();
  279. try {
  280. /* 2015-02-23 정승우 2017.5.19 준공기성은 외주팀. 회계팀 요청사항.
  281. * 증빙번호에 들어갈 사용자 정보 변경
  282. * 준공시 계약담당자가 증빙번호에 들어가도록 변경
  283. * */
  284. sql.append("SELECT B.DEPT_CD \n");
  285. sql.append(" ,A.CON_CHARGE_ID as ACCT_ID \n");
  286. sql.append(" ,B.ACMP_ID \n");
  287. sql.append("FROM SUB1000T A, \n");
  288. sql.append(" SUB1040T B \n");
  289. sql.append("WHERE A.SUB_CONT_ID = B.SUB_CONT_ID \n");
  290. sql.append("AND B.ACMP_ID = "+vo.get("KEY_COL1")+" \n");
  291. search.setStatement(sql.toString());
  292. listRowSet = search.execute();
  293. selectResult = RowSetUtility.getValueObject(listRowSet.getRow(0));
  294. doJipge(connection, selectResult);
  295. RowSet result = getListRow(connection, selectResult);
  296. String acctId = selectResult.get("ACCT_ID");
  297. for( int i = 0 ; i < result.size() ; i++ ) {
  298. Row row = result.getRow(i);
  299. //외주기성고 PDF작성
  300. prcDoc020t(connection, row.get("TMPSLIP_ID"), acctId, selectResult.get("ACMP_ID"), row.get("END_YN"));
  301. }
  302. }catch(Exception e) {
  303. WAFLogger.error(this.getClass().getName() + " --> prepaymentMiddle() : " + e.getMessage());
  304. //WAFLogger.error("SQL : " + sqlstr);
  305. WAFLogger.error(e);
  306. throw e;
  307. }
  308. }
  309. public RowSet getListRow(Connection connection, ValueObject vo) throws Exception {
  310. Persistent persistent_c = null;
  311. Search search = new SearchImpl();
  312. RowSet listRowSet = null;
  313. StringBuffer sql = new StringBuffer();
  314. try {
  315. persistent_c = new PersistentImpl(connection);
  316. sql.append(" SELECT MAIN.ACMP_ID -- 기성ID \n");
  317. sql.append(" , '' CHK -- \n");
  318. sql.append(" , MAIN.TMPSLIP_ID -- 외주기성전표 ID \n");
  319. sql.append(" , TO_CHAR(MAIN.PROOFDATE, 'YYYY-MM-DD') PROOFDATE -- 거래일자 \n");
  320. sql.append(" , MAIN.DEPT_CD -- 현장코드 \n");
  321. sql.append(" , CONTRACT.DEPT_NAME -- 현장명 \n");
  322. sql.append(" , CONTRACT.CON_DOC_NO -- 외주계약번호 \n");
  323. sql.append(" , CONTRACT.BUILD_NAME -- 계약명 \n");
  324. sql.append(" , MAIN.DCERTI_NO -- 사업자번호 \n");
  325. sql.append(" , SUBVENDOR.CORP_KOR -- 사업자명 \n");
  326. sql.append(" , SUBVENDOR.CORP_ID -- 협력업체_ID \n");
  327. sql.append(" , MAIN.PREREQTFLG -- 선급/기성구분 \n");
  328. sql.append(" , MAIN.ACMP_NO -- 기성차수 \n");
  329. sql.append(" , MAIN.PROOF_CLASS -- 증빙구분 \n");
  330. sql.append(" , MAIN.ORDACCDESC -- 적요 \n");
  331. sql.append(" , MAIN.CON_CUR_CD -- 계약통화 \n");
  332. sql.append(" , MAIN.SUPPLY_AMT -- 공급가 \n");
  333. sql.append(" , MAIN.SURTAX_AMT -- 부가세 \n");
  334. sql.append(" , MAIN.SUPPLY_AMT + MAIN.SURTAX_AMT REQ_AMT -- 합계 \n");
  335. sql.append(" , CONTRACT.CON_CHARGE_ID -- 담당자 ID \n");
  336. sql.append(" , CONTRACT.CON_CHARGE_NAME -- 담당자 명 \n");
  337. sql.append(" , MAIN.DEALR_CD -- 거래처코드 \n");
  338. sql.append(" , MAIN.PAYITEM -- PAY ITEM \n");
  339. sql.append(" , MAIN.COSTCODE -- COST CODE \n");
  340. sql.append(" , MAIN.COSTTYPE -- COST TYPE \n");
  341. sql.append(" , MAIN.ACC_CLASS -- 계정구분 \n");
  342. sql.append(" , MAIN.PAY_GROUP -- PAY_GROUP \n");
  343. sql.append(" , MAIN.PAYMENT_TERMS -- PAYMENT_TERMS \n");
  344. sql.append(" , MAIN.TMPSLIP_DEPT -- 작성부서 \n");
  345. sql.append(" , MAIN.TMPSLIP_DT -- 작성일자 \n");
  346. sql.append(" , MAIN.TMPSLIP_NO -- 작성번호 \n");
  347. sql.append(" , MAIN.TMPSLIP_YN -- 전표생성유무 \n");
  348. sql.append(" , MAIN.SLIP_YN -- 결의서작성유무 \n");
  349. sql.append(" , MAIN.PREPAY_ID -- 선급ID \n");
  350. sql.append(" , ACMP.CON_CORP_ID -- 계약업체 ID \n");
  351. sql.append(" , ACMP.ACMP_YYYYMM -- 기성년월 \n");
  352. sql.append(" , ACMP.ACMP_NO CHASU -- 차수 \n");
  353. sql.append(" , ACMP.TAX_METHOD_CD \n");
  354. sql.append(" , CONTRACT.SUB_CONT_ID -- 외주게약서 ID \n");
  355. sql.append(" , CASE \n");//2017.08.03 잔여선급금 0일때 준공.
  356. sql.append(" WHEN ACMP.TOT_FUND_AMT >= ACMP.CON_SUPPLY_AMT AND (ACMP.TOT_PAY_DEDUCT_RATE = 100 OR ACMP.TOT_PAY_DEDUCT_RATE = 0) THEN 'J' \n");
  357. sql.append(" ELSE 'K' \n");
  358. sql.append(" END END_YN \n");
  359. sql.append(" \n");
  360. sql.append(" FROM SUB1050T MAIN -- << 집계 >> \n");
  361. sql.append(" LEFT OUTER JOIN SUB1040T ACMP -- << 기성내역 >> \n");
  362. sql.append(" ON MAIN.ACMP_ID = ACMP.ACMP_ID \n");
  363. sql.append(" LEFT OUTER JOIN SUB1020T SUBVENDOR -- << 계약업체 >> \n");
  364. sql.append(" ON ACMP.CON_CORP_ID = SUBVENDOR.CON_CORP_ID \n");
  365. sql.append(" LEFT OUTER JOIN SUB2000T CONTRACT -- << 계약서 >> \n");
  366. sql.append(" ON ACMP.SUB_CONT_ID = CONTRACT.SUB_CONT_ID \n");
  367. sql.append(" AND ACMP.MOD_NO = CONTRACT.MOD_NO \n");
  368. sql.append(" WHERE PREREQTFLG IN ('ACMP', 'PREPAY_DED') -- PREPAY:선급, ACMP:기성, PREPAY_DED: 선급금공제 \n");
  369. sql.append(" AND MAIN.ACMP_ID = "+vo.get("ACMP_ID")+" \n");
  370. sql.append(" ORDER BY PROOFDATE desc, MAIN.ACMP_ID, DEPT_NAME, CON_DOC_NO, CORP_KOR, MAIN.PREREQTFLG \n");
  371. System.out.println(sql.toString());
  372. //search.setStatement(sql.toString());
  373. //listRowSet = search.execute();
  374. //selectResult = RowSetUtility.getValueObject(search.execute().getRow(0));
  375. persistent_c.setStatement(sql.toString());
  376. listRowSet = persistent_c.query();
  377. //selectResult = RowSetUtility.getValueObject(listRowSet.getRow(0));
  378. } catch(Exception e) {
  379. WAFLogger.error(this.getClass().getName() + " --> getListRowSet() : \n" + e.getMessage());
  380. WAFLogger.error("SQL : " + search.getStatement());
  381. WAFLogger.error(e);
  382. } finally {
  383. if( listRowSet == null ) listRowSet = new RowSetImpl();
  384. }
  385. return listRowSet;
  386. }
  387. private void doJipge(Connection connection, ValueObject vo) throws Exception {
  388. Persistent persistent = new PersistentImpl(connection);
  389. Persistent persistent2 = new PersistentImpl(connection);
  390. Persistent persistent3 = new PersistentImpl(connection);
  391. Persistent persistent4 = new PersistentImpl(connection);
  392. Persistent persistent_u = new PersistentImpl(connection);
  393. StringBuffer sql = new StringBuffer();
  394. StringBuffer sql2 = new StringBuffer();
  395. StringBuffer sql3 = new StringBuffer();
  396. StringBuffer sql4 = new StringBuffer();
  397. StringBuffer sql_u = new StringBuffer();
  398. prepareSql(sql);
  399. prepareSql2(sql2);
  400. prepareSql3(sql3);
  401. prepareSql4(sql4);
  402. updateSql(sql_u);
  403. persistent.setStatement(sql.toString());
  404. persistent2.setStatement(sql2.toString());
  405. persistent3.setStatement(sql3.toString());
  406. persistent4.setStatement(sql4.toString());
  407. persistent_u.setStatement(sql_u.toString());
  408. try {
  409. //ValueObject user = storage.getUser();
  410. RowSet rs = getListRowSet(connection, vo);
  411. if(rs.size() > 0){
  412. for(int i = 0; rs.size() > i; i++){
  413. // 기성집계 과세
  414. persistent.addParameter(vo.get("ACCT_ID"));
  415. persistent.addParameter(rs.getRow(i).get("ACMP_ID"));
  416. persistent.execute();
  417. persistent.clearParameters();
  418. // 선급금 공제 집계 과세 (선급금공제금액이 있는 놈만 집계)
  419. persistent2.addParameter(vo.get("ACCT_ID"));
  420. persistent2.addParameter(rs.getRow(i).get("ACMP_ID"));
  421. persistent2.execute();
  422. persistent2.clearParameters();
  423. // 기성집계 면세
  424. persistent3.addParameter(vo.get("ACCT_ID"));
  425. persistent3.addParameter(rs.getRow(i).get("ACMP_ID"));
  426. persistent3.execute();
  427. persistent3.clearParameters();
  428. // 선급금 공제 집계 면세 (선급금공제금액이 있는 놈만 집계)
  429. persistent4.addParameter(vo.get("ACCT_ID"));
  430. persistent4.addParameter(rs.getRow(i).get("ACMP_ID"));
  431. persistent4.execute();
  432. persistent4.clearParameters();
  433. // 전표집계유무 상태값 변경
  434. persistent_u.addParameter(rs.getRow(i).get("ACMP_ID"));
  435. persistent_u.execute();
  436. persistent_u.clearParameters();
  437. }
  438. }
  439. } catch(Exception e) {
  440. WAFLogger.error(this.getClass().getName() + " --> doJipge() : " + e.getMessage());
  441. WAFLogger.error(e);
  442. throw e;
  443. }
  444. }
  445. //면세
  446. private void prepareSql(StringBuffer sql) {
  447. 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");
  448. sql.append(" SELECT SUB1050T_S.NEXTVAL -- ID \n");
  449. sql.append(" , A.TAX_DY -- 기성일자 \n");
  450. sql.append(" , A.DEPT_CD -- 현장코드 \n");
  451. sql.append(" , 'ACMP' -- 선급기성구분 (ACMP= 기성) \n");
  452. sql.append(" , A.ACMP_NO -- 기성차수 \n");
  453. sql.append(" , DECODE(B.PROOF_CD,'21','26', B.PROOF_CD) -- 증빙구분 \n");
  454. sql.append(" , A.TAX_DY || ' 외주기성전표 - ' || A.ACMP_NO \n");
  455. sql.append(" || ' (' || BUILD_NAME || ') ' -- 적요 \n");
  456. sql.append(" , A.REQU_SUPPLY_NAMT -- 면세 \n");
  457. sql.append(" , 0 -- 면세보증금 \n");
  458. sql.append(" , F_GET_DEALR_CD_EBID(C.CORP_ID) AS DEALR_CD -- 거래처코드 \n");
  459. sql.append(" , F_GET_DEALR_NO_EBID(C.CORP_ID) AS DCERTI_NO -- 사업자번호 \n");
  460. sql.append(" , TO_DATE(A.TAX_DY, 'YYYY-MM-DD') -- 세금계산서일자 \n");
  461. sql.append(" , 'Y' -- 전자계약여부 \n");
  462. sql.append(" , B.PAY_ITEM -- PAY_ITEM \n");
  463. sql.append(" , B.COST_CODE -- COST_CODE \n");
  464. sql.append(" , B.COST_TYPE -- COST_TYPE \n");
  465. sql.append(" , B.ACCT_GB -- 계정구분 (=분개유형 ) \n");
  466. sql.append(" , B.PAY_GROUP -- PAY_GROUP \n");
  467. sql.append(" , B.PAYMENT_TERMS -- PAYMENT_TERMS \n");
  468. sql.append(" , NULL -- 작성부서 \n");
  469. sql.append(" , NULL -- 작성일자 \n");
  470. sql.append(" , NULL -- 작성번호 \n");
  471. sql.append(" , 'N' -- 전표생성유무 \n");
  472. sql.append(" , 'N' -- 결의서작성유무 \n");
  473. sql.append(" , B.CON_CUR_CD -- 계약통화 \n");
  474. sql.append(" , A.ACMP_ID -- 기성ID \n");
  475. sql.append(" , NULL -- 선급ID \n");
  476. sql.append(" , ? -- 등록자 \n");
  477. sql.append(" , SYSDATE -- 등록일시 \n");
  478. sql.append(" , NULL -- 수정자 \n");
  479. sql.append(" , NULL -- 수정일시 \n");
  480. sql.append(" , C.CORP_ID -- 협력업체ID \n");
  481. sql.append(" , 'N' -- 면과세 구분 \n");
  482. sql.append(" FROM SUB1040T A -- << 기성내역 >> \n");
  483. sql.append(" ,SUB2000T B -- << 계약서 >> \n");
  484. sql.append(" ,SUB1020T C -- << 업체 >> \n");
  485. sql.append(" WHERE A.SUB_CONT_ID = B.SUB_CONT_ID \n");
  486. sql.append(" AND A.MOD_NO = B.MOD_NO \n");
  487. sql.append(" AND A.SUB_CONT_ID = C.SUB_CONT_ID \n");
  488. sql.append(" AND A.ACMP_ID = ? \n");
  489. sql.append(" AND A.REQU_SUPPLY_NAMT > 0 -- 면세금액이 있음 \n");
  490. sql.append(" AND A.STATUS_CD = '10' -- 결제완료된 내역 \n");
  491. System.out.println(sql.toString());
  492. }
  493. private void prepareSql2(StringBuffer sql) {
  494. 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");
  495. sql.append(" SELECT SUB1050T_S.NEXTVAL -- ID \n");
  496. sql.append(" , A.TAX_DY -- 기성일자 \n");
  497. sql.append(" , A.DEPT_CD -- 현장코드 \n");
  498. sql.append(" , 'PREPAY_DED' -- 선급기성구분 (ACMP= 기성) \n");
  499. sql.append(" , A.ACMP_NO -- 기성차수 \n");
  500. sql.append(" ,'Z99' -- 증빙구분 \n");
  501. sql.append(" , A.TAX_DY || ' 외주선급공제전표 - ' || A.ACMP_NO \n");
  502. sql.append(" || ' (' || BUILD_NAME || ') ' -- 적요 \n");
  503. sql.append(" , A.PAY_DEDUCT_NAMT -- 선급공제금_면세 \n");
  504. sql.append(" , 0 -- 부가세 \n");
  505. sql.append(" , F_GET_DEALR_CD_EBID(C.CORP_ID) AS DEALR_CD -- 거래처코드 \n");
  506. sql.append(" , F_GET_DEALR_NO_EBID(C.CORP_ID) AS DCERTI_NO -- 사업자번호 \n");
  507. sql.append(" , TO_DATE(A.TAX_DY, 'YYYY-MM-DD') -- 세금계산서일자 \n");
  508. sql.append(" , 'Y' -- 전자계약여부 \n");
  509. sql.append(" , B.PAY_ITEM -- PAY_ITEM \n");
  510. sql.append(" , B.COST_CODE -- COST_CODE \n");
  511. sql.append(" , B.COST_TYPE -- COST_TYPE \n");
  512. sql.append(" , B.ACCT_GB -- 계정구분 (=분개유형 ) \n");
  513. sql.append(" , CASE E.AC_UNIT_CD WHEN '10' THEN '22' \n");
  514. sql.append(" ELSE '21' \n");
  515. sql.append(" END -- PAY_GROUP \n");
  516. sql.append(" , B.PAYMENT_TERMS -- PAYMENT_TERMS \n");
  517. sql.append(" , NULL -- 작성부서 \n");
  518. sql.append(" , NULL -- 작성일자 \n");
  519. sql.append(" , NULL -- 작성번호 \n");
  520. sql.append(" , 'N' -- 전표생성유무 \n");
  521. sql.append(" , 'N' -- 결의서작성유무 \n");
  522. sql.append(" , B.CON_CUR_CD -- 계약통화 \n");
  523. sql.append(" , A.ACMP_ID -- 기성ID \n");
  524. sql.append(" , NULL -- 선급ID \n");
  525. sql.append(" , ? -- 등록자 \n");
  526. sql.append(" , SYSDATE -- 등록일시 \n");
  527. sql.append(" , NULL -- 수정자 \n");
  528. sql.append(" , NULL -- 수정일시 \n");
  529. sql.append(" , C.CORP_ID -- 협력업체ID \n");
  530. sql.append(" , 'N' -- 면과세구분 \n");
  531. sql.append(" FROM SUB1040T A -- << 기성내역 >> \n");
  532. sql.append(" ,SUB2000T B -- << 계약서 >> \n");
  533. sql.append(" ,SUB1020T C -- << 업체 >> \n");
  534. sql.append(" ,ETEC_ERPIF.ACZ10100 E -- << 사업부 >> \n");
  535. sql.append(" WHERE A.SUB_CONT_ID = B.SUB_CONT_ID \n");
  536. sql.append(" AND A.MOD_NO = B.MOD_NO \n");
  537. sql.append(" AND A.SUB_CONT_ID = C.SUB_CONT_ID \n");
  538. sql.append(" AND A.ACMP_ID = ? \n");
  539. sql.append(" AND A.PAY_DEDUCT_NAMT > 0 -- 선급공제액_면세금액이 있음 \n");
  540. sql.append(" AND A.DEPT_CD = E.DEPT_CD \n");
  541. sql.append(" AND A.STATUS_CD = '10' -- 결제완료된 내역 \n");
  542. System.out.println(sql.toString());
  543. }
  544. private void prepareSql3(StringBuffer sql) {
  545. 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");
  546. sql.append(" SELECT SUB1050T_S.NEXTVAL -- ID \n");
  547. sql.append(" , A.TAX_DY -- 기성일자 \n");
  548. sql.append(" , A.DEPT_CD -- 현장코드 \n");
  549. sql.append(" , 'ACMP' -- 선급기성구분 (ACMP= 기성) \n");
  550. sql.append(" , A.ACMP_NO -- 기성차수 \n");
  551. sql.append(" , B.PROOF_CD -- 증빙구분 \n");
  552. sql.append(" , A.TAX_DY || ' 외주기성전표 - ' || A.ACMP_NO \n");
  553. sql.append(" || ' (' || BUILD_NAME || ') ' -- 적요 \n");
  554. sql.append(" , A.REQU_SUPPLY_TAMT -- 과세 \n");
  555. sql.append(" , A.REQU_SURTAX_AMT -- 과세보증금 \n");
  556. sql.append(" , F_GET_DEALR_CD_EBID(C.CORP_ID) AS DEALR_CD -- 거래처코드 \n");
  557. sql.append(" , F_GET_DEALR_NO_EBID(C.CORP_ID) AS DCERTI_NO -- 사업자번호 \n");
  558. sql.append(" , TO_DATE(A.TAX_DY, 'YYYY-MM-DD') -- 세금계산서일자 \n");
  559. sql.append(" , 'Y' -- 전자계약여부 \n");
  560. sql.append(" , B.PAY_ITEM -- PAY_ITEM \n");
  561. sql.append(" , B.COST_CODE -- COST_CODE \n");
  562. sql.append(" , B.COST_TYPE -- COST_TYPE \n");
  563. sql.append(" , B.ACCT_GB -- 계정구분 (=분개유형 ) \n");
  564. sql.append(" , B.PAY_GROUP -- PAY_GROUP \n");
  565. sql.append(" , B.PAYMENT_TERMS -- PAYMENT_TERMS \n");
  566. sql.append(" , NULL -- 작성부서 \n");
  567. sql.append(" , NULL -- 작성일자 \n");
  568. sql.append(" , NULL -- 작성번호 \n");
  569. sql.append(" , 'N' -- 전표생성유무 \n");
  570. sql.append(" , 'N' -- 결의서작성유무 \n");
  571. sql.append(" , B.CON_CUR_CD -- 계약통화 \n");
  572. sql.append(" , A.ACMP_ID -- 기성ID \n");
  573. sql.append(" , NULL -- 선급ID \n");
  574. sql.append(" , ? -- 등록자 \n");
  575. sql.append(" , SYSDATE -- 등록일시 \n");
  576. sql.append(" , NULL -- 수정자 \n");
  577. sql.append(" , NULL -- 수정일시 \n");
  578. sql.append(" , C.CORP_ID -- 협력업체ID \n");
  579. sql.append(" , 'T' -- 면과세구분 \n");
  580. sql.append(" FROM SUB1040T A -- << 기성내역 >> \n");
  581. sql.append(" ,SUB2000T B -- << 계약서 >> \n");
  582. sql.append(" ,SUB1020T C -- << 업체 >> \n");
  583. sql.append(" WHERE A.SUB_CONT_ID = B.SUB_CONT_ID \n");
  584. sql.append(" AND A.MOD_NO = B.MOD_NO \n");
  585. sql.append(" AND A.SUB_CONT_ID = C.SUB_CONT_ID \n");
  586. sql.append(" AND A.ACMP_ID = ? \n");
  587. sql.append(" AND A.REQU_SUPPLY_TAMT > 0 -- 과세금액이 있음 \n");
  588. sql.append(" AND A.STATUS_CD = '10' -- 결제완료된 내역 \n");
  589. System.out.println(sql.toString());
  590. }
  591. private void prepareSql4(StringBuffer sql) {
  592. 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");
  593. sql.append(" SELECT SUB1050T_S.NEXTVAL -- ID \n");
  594. sql.append(" , A.TAX_DY -- 기성일자 \n");
  595. sql.append(" , A.DEPT_CD -- 현장코드 \n");
  596. sql.append(" , 'PREPAY_DED' -- 선급기성구분 (ACMP= 기성) \n");
  597. sql.append(" , A.ACMP_NO -- 기성차수 \n");
  598. sql.append(" ,'Z99' -- 증빙구분 \n");
  599. sql.append(" , A.TAX_DY || ' 외주선급공제전표 - ' || A.ACMP_NO \n");
  600. sql.append(" || ' (' || BUILD_NAME || ') ' -- 적요 \n");
  601. sql.append(" , A.PAY_DEDUCT_TAMT -- 선급공제금_과세 \n");
  602. sql.append(" , 0 -- 부가세 \n");
  603. sql.append(" , F_GET_DEALR_CD_EBID(C.CORP_ID) AS DEALR_CD -- 거래처코드 \n");
  604. sql.append(" , F_GET_DEALR_NO_EBID(C.CORP_ID) -- 사업자번호 \n");
  605. sql.append(" , TO_DATE(A.TAX_DY, 'YYYY-MM-DD') -- 세금계산서일자 \n");
  606. sql.append(" , 'Y' -- 전자계약여부 \n");
  607. sql.append(" , B.PAY_ITEM -- PAY_ITEM \n");
  608. sql.append(" , B.COST_CODE -- COST_CODE \n");
  609. sql.append(" , B.COST_TYPE -- COST_TYPE \n");
  610. sql.append(" , B.ACCT_GB -- 계정구분 (=분개유형 ) \n");
  611. sql.append(" , CASE E.AC_UNIT_CD WHEN '10' THEN '22' \n");
  612. sql.append(" ELSE '21' \n");
  613. sql.append(" END -- PAY_GROUP \n");
  614. sql.append(" , B.PAYMENT_TERMS -- PAYMENT_TERMS \n");
  615. sql.append(" , NULL -- 작성부서 \n");
  616. sql.append(" , NULL -- 작성일자 \n");
  617. sql.append(" , NULL -- 작성번호 \n");
  618. sql.append(" , 'N' -- 전표생성유무 \n");
  619. sql.append(" , 'N' -- 결의서작성유무 \n");
  620. sql.append(" , B.CON_CUR_CD -- 계약통화 \n");
  621. sql.append(" , A.ACMP_ID -- 기성ID \n");
  622. sql.append(" , NULL -- 선급ID \n");
  623. sql.append(" , ? -- 등록자 \n");
  624. sql.append(" , SYSDATE -- 등록일시 \n");
  625. sql.append(" , NULL -- 수정자 \n");
  626. sql.append(" , NULL -- 수정일시 \n");
  627. sql.append(" , C.CORP_ID -- 협력업체ID \n");
  628. sql.append(" , 'T' -- 면과세구분 \n");
  629. sql.append(" FROM SUB1040T A -- << 기성내역 >> \n");
  630. sql.append(" ,SUB2000T B -- << 계약서 >> \n");
  631. sql.append(" ,SUB1020T C -- << 업체 >> \n");
  632. sql.append(" ,ETEC_ERPIF.ACZ10100 E -- << 사업부 >> \n");
  633. sql.append(" WHERE A.SUB_CONT_ID = B.SUB_CONT_ID \n");
  634. sql.append(" AND A.MOD_NO = B.MOD_NO \n");
  635. sql.append(" AND A.SUB_CONT_ID = C.SUB_CONT_ID \n");
  636. sql.append(" AND A.ACMP_ID = ? \n");
  637. sql.append(" AND A.PAY_DEDUCT_TAMT > 0 -- 선급공제액_과세금액이 있음 \n");
  638. sql.append(" AND A.DEPT_CD = E.DEPT_CD \n");
  639. sql.append(" AND A.STATUS_CD = '10' -- 결제완료된 내역 \n");
  640. System.out.println(sql.toString());
  641. }
  642. private void updateSql(StringBuffer sql){
  643. sql.append(" UPDATE SUB1040T SET TRANS_CD = 'Y' \n");
  644. sql.append(" WHERE ACMP_ID = ? \n");
  645. sql.append(" AND STATUS_CD = '10' \n");
  646. }
  647. private RowSet getListRowSet(Connection connection, ValueObject vo) throws Exception {
  648. RowSet listRowSet = null;
  649. StringBuffer sql = new StringBuffer();
  650. Persistent persistent_c = null;
  651. ValueObject row = null;
  652. try {
  653. persistent_c = new PersistentImpl(connection);
  654. sql.append(" SELECT MAIN.ACMP_ID -- 기성아이디 \n");
  655. sql.append(" FROM SUB1040T MAIN -- << 기성내역 >> \n");
  656. sql.append(" WHERE MAIN.DEPT_CD = ? \n");
  657. sql.append(" AND MAIN.TRANS_CD = 'N' \n");
  658. sql.append(" AND MAIN.STATUS_CD = '10' \n");
  659. sql.append(" AND MAIN.ACMP_ID = ? \n");
  660. System.out.println(sql.toString());
  661. persistent_c.setStatement(sql.toString());
  662. persistent_c.addParameter(vo.get("dept_cd"));
  663. persistent_c.addParameter(vo.get("ACMP_ID"));
  664. listRowSet = persistent_c.query();
  665. } catch(Exception e) {
  666. WAFLogger.error(this.getClass().getName() + " --> getListRowSet() : \n" + e.getMessage());
  667. WAFLogger.error("SQL : " + sql.toString());
  668. WAFLogger.error(e);
  669. throw e;
  670. } finally {
  671. if( listRowSet == null ) listRowSet = new RowSetImpl();
  672. }
  673. return listRowSet;
  674. }
  675. private void prcDoc020t(Connection con, String tmpslipID, String userID, String acmp_id, String endYn) throws Exception {
  676. String strResult = null;
  677. String strFileName = null;
  678. String message = "";
  679. String SPStateMent = "";
  680. CallableStatement cs = null;
  681. String arrDocNm [] = {"외주기성고 계산서"};
  682. String arrProofGu [] = {"12"};
  683. //WAFLogger.debug("\n\t #################### params = [\n"+ params +"\n");
  684. try {
  685. // 증빙정보 생성 프로시저
  686. // - 외주 기성고 계산서만 새로 생성해야만 한다.
  687. SPStateMent = "{call SAC_DOCUMENTATIVE.prc_subinvoicebiz2(?, ?, ?, ?, ?)}";
  688. cs = con.prepareCall(SPStateMent);
  689. // 라인당, 기성고계산서 한라인만 생성.
  690. for(int iCount=0; iCount<arrDocNm.length; iCount++) {
  691. int i = 1;
  692. cs.setString(i++, tmpslipID);
  693. cs.setInt(i++, Integer.parseInt(userID));
  694. cs.setString(i++, arrDocNm[iCount]);
  695. cs.setString(i++, arrProofGu[iCount]);
  696. cs.registerOutParameter(i++, Types.VARCHAR);
  697. cs.execute();
  698. strResult = cs.getString(5);
  699. if(endYn.equals("J")){ //준공
  700. /*// 입력된 증빙데이터 라인을 기준으로 실제 증빙을 */
  701. String arrKeys[] = strResult.split("@"); // proof_dept, proofdate, proof_no, proof_seq
  702. OutputStream outputStream = getOS(con, arrKeys[0], arrKeys[1], arrKeys[2], Integer.parseInt(arrKeys[3]));
  703. // 기성고 계산서 PDF 생성
  704. SACDOCreatePDF7 sacDOCreatePDF7 = new SACDOCreatePDF7();
  705. sacDOCreatePDF7.doBiz1(con, outputStream, acmp_id, null);
  706. }else{ //중도
  707. /*// 입력된 증빙데이터 라인을 기준으로 실제 증빙을 */
  708. String arrKeys[] = strResult.split("@"); // proof_dept, proofdate, proof_no, proof_seq
  709. OutputStream outputStream = getOS(con, arrKeys[0], arrKeys[1], arrKeys[2], Integer.parseInt(arrKeys[3]));
  710. // 기성고 계산서 PDF 생성
  711. SACDOCreatePDF8 sacDOCreatePDF8 = new SACDOCreatePDF8();
  712. sacDOCreatePDF8.doBiz1(con, outputStream, acmp_id, null);
  713. }
  714. }
  715. // 라인당, 기성고계산서 한라인만 생성. - 종료
  716. }
  717. catch(Exception e) {
  718. //super.doException(e);
  719. message = this.getClass().getName() + "\n" + e.getMessage();
  720. message = StringUtil.replace(message, "\"", "");
  721. //storage.setDetailMessage(message);
  722. throw e;
  723. }
  724. finally{
  725. try {
  726. if (cs != null) cs.close();
  727. }
  728. catch (Exception ex_close) {
  729. WAFLogger.error(ex_close);
  730. }
  731. }
  732. }
  733. public static OutputStream getOS(Connection con, String proof_dept, String proof_dt, String proof_no,
  734. int proof_seq) throws Exception {
  735. OutputStream outputStream = null;
  736. PreparedStatement pstmt = null;
  737. ResultSet resultSet = null;
  738. Statement stmt = null;
  739. try {
  740. String strSQL = "SELECT photo "
  741. + " FROM DOC021T "
  742. + " WHERE proof_dept = '"+ proof_dept +"'"
  743. + " AND TO_CHAR (proofdate, 'yyyymmdd') = '"+ proof_dt +"' "
  744. + " AND proof_no = " + proof_no
  745. + " AND proof_seq = "+ proof_seq
  746. + " AND proc_gu = '30' "
  747. + " FOR UPDATE";
  748. pstmt = con.prepareStatement(strSQL);
  749. resultSet = pstmt.executeQuery();
  750. if (resultSet.next()) {
  751. OracleThinBlob blob = (OracleThinBlob)resultSet.getBlob(1);
  752. outputStream = blob.getBinaryOutputStream();
  753. } else {
  754. throw new Exception("증빙화일을 저장할 레코드가 존재하지 않습니다.");
  755. }
  756. } catch (Exception e) {
  757. WAFLogger.error(e);
  758. } finally {
  759. if( stmt != null ) stmt.close();
  760. resultSet.close();
  761. pstmt.close();
  762. return outputStream;
  763. }
  764. }
  765. /** 전표 생성 Procedure( SUB_INVOICE_CREATE) 수행
  766. * @throws Exception
  767. */
  768. private void SUB_INVOICE_CREATE(Connection con, String tmpslipID, String userID, String acc_dept_cd, String slipNo) throws Exception {
  769. String message = "";
  770. String SPStateMent = "";
  771. CallableStatement cs = null;
  772. try {
  773. SPStateMent = "{call SUB_INVOICE_CREATE1(?, ?, ?, ?)}";
  774. cs = con.prepareCall(SPStateMent);
  775. cs.setString(1, tmpslipID); // 외주기성 전표ID(SUB1050T)
  776. cs.setString(2, userID); // USER ID
  777. cs.setString(3, acc_dept_cd); // 전표생성자 귀속부서 코드(대변)
  778. cs.setString(4, slipNo);
  779. cs.execute();
  780. } catch(Exception e) {
  781. //WAFLogger.error(this.getClass().getName() +" -->" + SPStateMent+ " : \n" + e.getMessage());
  782. //WAFLogger.error(e);
  783. message = this.getClass().getName() + "." + SPStateMent + " : \n" + e.getMessage();
  784. message = StringUtil.replace(message, "\"", "");
  785. //storage.setDetailMessage(message);
  786. throw e;
  787. } finally{
  788. try {
  789. if (cs != null) cs.close();
  790. } catch (Exception ex_close) {
  791. WAFLogger.error(ex_close);
  792. }
  793. }
  794. }
  795. public void createSMbill(Connection con, String prp_req_id, String userID, String payreqId, String batchId) throws Exception {
  796. String message = "";
  797. String SPStateMent = "";
  798. CallableStatement cs = null;
  799. try {
  800. SPStateMent = "{call PUR_BILL_CREATE5(?,?,?,?)}"; //준공
  801. cs = con.prepareCall(SPStateMent);
  802. cs.setString(1, prp_req_id); // 가불금 ID
  803. cs.setString(2, userID); // USER ID
  804. cs.setString(3, payreqId);
  805. cs.setString(4, batchId);
  806. cs.execute();
  807. } catch(Exception e) {
  808. WAFLogger.error(this.getClass().getName() +" -->" + SPStateMent+ " : \n" + e.getMessage());
  809. WAFLogger.error(e);
  810. message = this.getClass().getName() + "." + SPStateMent + " : \n" + e.getMessage();
  811. message = StringUtil.replace(message, "\"", "");
  812. //storage.setDetailMessage(message);
  813. throw e;
  814. } finally{
  815. try {
  816. if (cs != null) cs.close();
  817. } catch (Exception ex_close) {
  818. WAFLogger.error(ex_close);
  819. }
  820. }
  821. }
  822. public String getBatchId() throws Exception {
  823. Search search = new SearchImpl();
  824. RowSet rowSet = new RowSetImpl();
  825. String sqlstr = "";
  826. ValueObject row = null;
  827. String resultId = "";
  828. try{
  829. sqlstr = " SELECT TO_CHAR(SYSTIMESTAMP, 'YYYYMMDDHH24MISS') AS BATCH_ID FROM DUAL \n";
  830. System.out.println(sqlstr);
  831. search.setStatement(sqlstr);
  832. rowSet = search.execute();
  833. row = RowSetUtility.getValueObject(rowSet.getRow(0));
  834. resultId = row.get("BATCH_ID");
  835. }catch(Exception e){
  836. WAFLogger.error(this.getClass().getName() + " --> getBatchId() : " + e.getMessage());
  837. WAFLogger.error("SQL : " + sqlstr);
  838. WAFLogger.error(e);
  839. throw e;
  840. }finally{
  841. if(row == null) row = new ValueObject();
  842. }
  843. return resultId;
  844. }
  845. }