PaymentBuyPrepaySignDriver.java 68 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625
  1. /**
  2. * @(#)file PaymentBuyPrepaySignDriver.java
  3. * @(#)author Ok seung hyun
  4. * @(#)version 1.0
  5. * @(#)date 2014-09-13
  6. * @(#)since JDK 1.6.21
  7. *
  8. * Copyright (c) www.udapsoft.co.kr, Inc.
  9. */
  10. package kr.co.udapsoft.common.commonSign.driver;
  11. import java.io.OutputStream;
  12. import java.sql.CallableStatement;
  13. import java.sql.Connection;
  14. import java.sql.PreparedStatement;
  15. import java.sql.ResultSet;
  16. import java.sql.Statement;
  17. import java.sql.Types;
  18. import com.udapsoft.waf.system.HandlerStorage;
  19. import kr.co.hsnc.common.base.WAFLogger;
  20. import kr.co.hsnc.common.config.WAFConfig;
  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.common.sender.MessageSend;
  35. import kr.co.udapsoft.ebid.buyer.bid.purchase.biz.InterfacePurERPiU;
  36. import weblogic.jdbc.vendor.oracle.OracleThinBlob;
  37. /**
  38. * getPur1030t
  39. * @version 1.0
  40. * @author Beomgeun Lee
  41. */
  42. public class PaymentBuyPrepaySignDriver implements CommonSignInterface {
  43. /**
  44. * 테슽 파일
  45. *
  46. */
  47. public PaymentBuyPrepaySignDriver() {
  48. super();
  49. }
  50. /*
  51. * (non-Javadoc)
  52. * @see kr.co.udap.ehr.common.sign.SignInterface#doCallSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  53. */
  54. public void doCallSign(Connection connection, ValueObject signDoc) throws Exception {
  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. }
  62. /*
  63. * (non-Javadoc)
  64. * @see kr.co.udap.ehr.common.sign.SignInterface#doFirstFinishSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  65. */
  66. public void doFirstFinishSign(Connection connection, ValueObject signDoc) throws Exception {
  67. System.out.println("3");
  68. /* 운영에 반영할때는 변경해야함 */
  69. RowSet signUserInfo = getIFSignUser(signDoc.get("DOC_ID"));
  70. // 2020.02.17 결재정보가 없는 경우 예외처리
  71. if(signUserInfo.size() == 0){
  72. throw new Exception("결재정보가 없습니다.");
  73. }
  74. for ( int j = 0 ; j < signUserInfo.size() ; j ++ ) {
  75. ValueObject signUser = new ValueObject();
  76. signUser.set("SIGN_SEQ", ""+(j+1));
  77. signUser.set("DOC_ID", signDoc.get("DOC_ID"));
  78. signUser.set("APPROVAL_DATE", signUserInfo.getRow(j).get("PROCESSDATE"));
  79. signUser.set("APPROVAL_SABUN", signUserInfo.getRow(j).get("SABUN"));
  80. signUser.set("APPROVAL_USER", signUserInfo.getRow(j).get("APRMEMBERNAME"));
  81. signUser.set("A_POSITION", signUserInfo.getRow(j).get("APRMEMBERJOBTITLE"));
  82. signUser.set("SIGN_RESULT", signUserInfo.getRow(j).get("APRSTATE"));
  83. signUser.set("SIGN_TYPE", signDoc.get("SIGN_TYPE"));
  84. signUser.set("ACCT_TYPE", signDoc.get("ACCT_TYPE"));
  85. if( signDoc.get("SIGN_TYPE").equals("2") ){
  86. signUser.set("SLIP_DEPT", "");
  87. signUser.set("ACCSLIP_NO", signDoc.get("KEY_COL1"));
  88. }else {
  89. signUser.set("SLIP_DEPT", signDoc.get("KEY_COL3"));
  90. signUser.set("ACCSLIP_NO", "");
  91. }
  92. signUser.set("SLIP_DT", signDoc.get("KEY_COL4"));
  93. signUser.set("SLIP_NO", signDoc.get("KEY_COL5"));
  94. insertSign002t(connection, signUser);
  95. }
  96. updatePur1030t(connection, signDoc, signUserInfo);
  97. }
  98. /*
  99. * (non-Javadoc)
  100. * @see kr.co.udap.ehr.common.sign.SignInterface#doFinishSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  101. */
  102. public void doFinishSign(Connection connection, ValueObject signDoc) throws Exception {
  103. System.out.println("4");
  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 doFirstRejectSign(Connection connection, ValueObject signDoc) throws Exception {
  110. updatePur1030t(connection, signDoc, new RowSetImpl());
  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 doRejectSign(Connection connection, ValueObject signDoc) throws Exception {
  117. updatePur1030t(connection, signDoc, new RowSetImpl());
  118. }
  119. /*
  120. * (non-Javadoc)
  121. * @see kr.co.udap.ehr.common.sign.SignInterface#doCancelSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  122. */
  123. public void doCancelSign(Connection connection, ValueObject signDoc) throws Exception {
  124. System.out.println("5");
  125. }
  126. private RowSet getIFSignUser(String docId) throws Exception{
  127. Search search = new SearchImpl();
  128. search.setDSName("jdbc/gwsql");
  129. RowSet rowSet = new RowSetImpl();
  130. StringBuffer sqlstr = new StringBuffer();
  131. try {
  132. sqlstr.append(" SELECT APRSTATE \n");
  133. sqlstr.append(" ,REPLACE(APRMEMBERID,SUBSTRING(APRMEMBERID,1,4),'') AS SABUN \n");
  134. sqlstr.append(" ,APRMEMBERNAME \n");
  135. sqlstr.append(" ,APRMEMBERJOBTITLE \n");
  136. sqlstr.append(" ,APRMEMBERDEPTNAME \n");
  137. sqlstr.append(" ,REPLACE(CONVERT(VARCHAR(10),PROCESSDATE,120),'-','') AS PROCESSDATE \n");
  138. sqlstr.append(" FROM TBENDAPRLINEINFO \n");
  139. sqlstr.append(" WHERE APRTYPE = 'A03001' \n");
  140. sqlstr.append(" AND DOCID = '"+docId+"' \n");
  141. sqlstr.append(" ORDER BY APRMEMBERSN \n");
  142. search.setStatement(sqlstr.toString());
  143. rowSet = search.execute();
  144. System.out.println(sqlstr.toString());
  145. }
  146. catch(WAFSQLException se) {
  147. Logger.err.println("SQL : \n" + se.getStatement());
  148. Logger.err.println("PARAM : \n" + se.getParameter());
  149. throw se;
  150. }
  151. finally {
  152. if( rowSet == null ) rowSet = new RowSetImpl();
  153. }
  154. return rowSet;
  155. }
  156. public void insertSign002t(Connection connection, ValueObject vo) throws Exception {
  157. Persistent persistent = new PersistentImpl(connection);
  158. StringBuffer sqlstr = null;
  159. try {
  160. sqlstr = new StringBuffer();
  161. sqlstr.append(" INSERT INTO SIGN002T \n");
  162. sqlstr.append(" (SIGN_HIS_ID \n");
  163. sqlstr.append(" ,SIGN_SEQ \n");
  164. sqlstr.append(" ,DOC_ID \n");
  165. sqlstr.append(" ,APPROVAL_DATE \n");
  166. sqlstr.append(" ,APPROVAL_SABUN \n");
  167. sqlstr.append(" ,APPROVAL_USER \n");
  168. sqlstr.append(" ,A_POSITION \n");
  169. sqlstr.append(" ,SIGN_RESULT \n");
  170. sqlstr.append(" ,SLIP_DEPT \n");
  171. sqlstr.append(" ,SLIP_DT \n");
  172. sqlstr.append(" ,SLIP_NO \n");
  173. sqlstr.append(" ,SIGN_TYPE \n");
  174. sqlstr.append(" ,COMON_DCR \n");
  175. sqlstr.append(" ) VALUES \n");
  176. sqlstr.append(" ( \n");
  177. sqlstr.append(" SIGN002T_S.NEXTVAL \n");
  178. sqlstr.append(" ,? \n");
  179. sqlstr.append(" ,? \n");
  180. sqlstr.append(" ,TO_DATE(?,'YYYYMMDD') \n");
  181. sqlstr.append(" ,? \n");
  182. sqlstr.append(" ,? \n");
  183. sqlstr.append(" ,? \n");
  184. sqlstr.append(" ,? \n");
  185. sqlstr.append(" ,? \n");
  186. sqlstr.append(" ,? \n");
  187. sqlstr.append(" ,? \n");
  188. sqlstr.append(" ,1 \n");
  189. sqlstr.append(" ,2 \n");
  190. sqlstr.append(" ) \n");
  191. System.out.println(sqlstr.toString());
  192. System.out.println("=>"+vo.get("SIGN_SEQ"));
  193. System.out.println("=>"+vo.get("DOC_ID"));
  194. System.out.println("=>"+vo.get("APPROVAL_DATE"));
  195. System.out.println("=>"+vo.get("APPROVAL_SABUN"));
  196. System.out.println("=>"+vo.get("APPROVAL_USER"));
  197. System.out.println("=>"+vo.get("A_POSITION"));
  198. System.out.println("=>"+vo.get("SIGN_RESULT"));
  199. System.out.println("=>"+vo.get("SLIP_DEPT"));
  200. System.out.println("=>"+vo.get("SLIP_DT"));
  201. System.out.println("=>"+vo.get("SLIP_NO"));
  202. persistent.setStatement(sqlstr.toString());
  203. persistent.addParameter(vo.get("SIGN_SEQ"));
  204. persistent.addParameter(vo.get("DOC_ID"));
  205. persistent.addParameter(vo.get("APPROVAL_DATE"));
  206. persistent.addParameter(vo.get("APPROVAL_SABUN"));
  207. persistent.addParameter(vo.get("APPROVAL_USER"));
  208. persistent.addParameter(vo.get("A_POSITION"));
  209. persistent.addParameter(vo.get("SIGN_RESULT"));
  210. persistent.addParameter(vo.get("SLIP_DEPT"));
  211. persistent.addParameter(vo.get("SLIP_DT"));
  212. persistent.addParameter(vo.get("SLIP_NO"));
  213. persistent.execute();
  214. }
  215. catch(Exception e) {
  216. WAFLogger.error(this.getClass().getName() + " --> updateSac01001() : " + e.getMessage());
  217. WAFLogger.error("SQL : " + sqlstr);
  218. WAFLogger.error(e);
  219. throw e;
  220. }
  221. }
  222. public void updatePur1030t(Connection connection, ValueObject vo, RowSet signUserInfo) throws Exception {
  223. Persistent persistent = new PersistentImpl(connection);
  224. Persistent persistent1 = new PersistentImpl(connection);
  225. StringBuffer sqlstr = null;
  226. StringBuffer sqlstr1 = null;
  227. try {
  228. sqlstr = new StringBuffer();
  229. sqlstr1 = new StringBuffer();
  230. String status = "";
  231. int complete = 0;
  232. sqlstr.append(" SELECT REQ_DIV_CD \n"); //신청구분코드(1:신청, 2:부분신청, 3:포기)
  233. sqlstr.append(" FROM PUR1030T \n");
  234. sqlstr.append(" WHERE PREPAY_ID = ? \n");
  235. persistent.setStatement(sqlstr.toString());
  236. persistent.addParameter(vo.get("KEY_COL2"));
  237. String div = RowSetUtility.getValueObject(persistent.query().getRow(0)).get("REQ_DIV_CD");
  238. if(vo.get("SIGN_DECI_CLASS").equals("14")){
  239. status = "10"; //구매 선급완료
  240. if("3".equals(div)){
  241. status = "11"; //구매 포기완료
  242. }
  243. }else {
  244. status = "91"; //구배 선급반려
  245. complete = 1;
  246. }
  247. //구매)선급내역에 상태값 변경
  248. sqlstr1.append(" UPDATE PUR1030T SET \n");
  249. sqlstr1.append(" PREPAY_PROC_GB = ? \n");
  250. sqlstr1.append(" WHERE PREPAY_ID = ? \n");
  251. persistent1.setStatement(sqlstr1.toString());
  252. persistent1.addParameter(status);
  253. persistent1.addParameter(vo.get("KEY_COL2"));
  254. persistent1.execute();
  255. ValueObject getPur1030tData = getPur1030t(vo.get("KEY_COL1"), vo.get("KEY_COL2"), vo.get("SIGN_INTERFACE_ID"));
  256. if(getPur1030tData.get("CHG_DIV_CD").equals("")){ //2019.05.10 신규=NULL, 추가='Y'
  257. if(!"3".equals(div)){ //신청, 부분신청
  258. //전표집계처리
  259. if(complete == 0){
  260. //ValueObject pur1030tData = getPur1030t(vo.get("KEY_COL1"), vo.get("KEY_COL2"), vo.get("SIGN_INTERFACE_ID"));
  261. getPur1030tData.set("slipNo", vo.get("KEY_COL5"));
  262. getPur1030tData.set("DOC_ID", vo.get("DOC_ID"));
  263. getPayJipge(connection, getPur1030tData, signUserInfo);
  264. }
  265. }else{//포기
  266. //ValueObject pur1030tData = getPur1030t(vo.get("KEY_COL1"), vo.get("KEY_COL2"), vo.get("SIGN_INTERFACE_ID"));
  267. updatePayPlan(connection, getPur1030tData);
  268. }
  269. }else{ //2018.07.27 추가 선급금
  270. if(!"3".equals(div)){ //신청, 부분신청
  271. //전표집계처리
  272. if(complete == 0){
  273. //ValueObject pur1030tData = getPur1030t(vo.get("KEY_COL1"), vo.get("KEY_COL2"), vo.get("SIGN_INTERFACE_ID"));
  274. getPur1030tData.set("slipNo", vo.get("KEY_COL5"));
  275. getPur1030tData.set("DOC_ID", vo.get("DOC_ID"));
  276. getPayJipgeTybeB(connection, getPur1030tData, signUserInfo); //추가된 선급금 cont_pur_payplan insert
  277. }
  278. }else{ //포기
  279. //2019.05.10 추가선급금 포기는 아무일 없음.
  280. //ValueObject pur1030tData = getPur1030t(vo.get("KEY_COL2"), vo.get("SIGN_INTERFACE_ID"));
  281. }
  282. }
  283. //2018.08.02 메일발송 전표발행 완료후
  284. if(vo.get("SIGN_DECI_CLASS").equals("14")){
  285. Send(vo.get("KEY_COL1"));
  286. }
  287. }
  288. catch(Exception e) {
  289. WAFLogger.error(this.getClass().getName() + " --> updatePur1030t() : " + e.getMessage());
  290. WAFLogger.error("SQL : " + sqlstr);
  291. WAFLogger.error(e);
  292. throw e;
  293. }
  294. }
  295. /** 전표 생성 Procedure( PUR_INVOICE_CREATE) 수행
  296. * @throws Exception
  297. */
  298. public void callPurInvoiceCreate(Connection con, String prp_req_id, String userID, String slipNo) throws Exception {
  299. String message = "";
  300. String SPStateMent = "";
  301. CallableStatement cs = null;
  302. try {
  303. SPStateMent = "{call PUR_INVOICE_CREATE1(?,?,?)}";
  304. cs = con.prepareCall(SPStateMent);
  305. cs.setString(1, prp_req_id);
  306. cs.setString(2, userID);
  307. cs.setString(3, slipNo);
  308. cs.execute();
  309. } catch(Exception e) {
  310. WAFLogger.error(this.getClass().getName() +" -->" + SPStateMent+ " : \n" + e.getMessage());
  311. WAFLogger.error(e);
  312. message = this.getClass().getName() + "." + SPStateMent + " : \n" + e.getMessage();
  313. message = StringUtil.replace(message, "\"", "");
  314. //storage.setDetailMessage(message);
  315. throw e;
  316. } finally{
  317. try {
  318. if (cs != null) cs.close();
  319. } catch (Exception ex_close) {
  320. WAFLogger.error(ex_close);
  321. }
  322. }
  323. }
  324. public void createSMbill(Connection con, String prp_req_id, String userID, String payreqId, String ordDesc, String batchId) throws Exception {
  325. String message = "";
  326. String SPStateMent = "";
  327. CallableStatement cs = null;
  328. try {
  329. SPStateMent = "{call PUR_BILL_CREATE1(?,?,?,?,?)}";
  330. cs = con.prepareCall(SPStateMent);
  331. cs.setString(1, prp_req_id); // 가불금 ID
  332. cs.setString(2, userID); // USER ID
  333. cs.setString(3, payreqId);
  334. cs.setString(4, ordDesc.substring(10));
  335. cs.setString(5, batchId);
  336. cs.execute();
  337. } catch(Exception e) {
  338. WAFLogger.error(this.getClass().getName() +" -->" + SPStateMent+ " : \n" + e.getMessage());
  339. WAFLogger.error(e);
  340. message = this.getClass().getName() + "." + SPStateMent + " : \n" + e.getMessage();
  341. message = StringUtil.replace(message, "\"", "");
  342. //storage.setDetailMessage(message);
  343. throw e;
  344. } finally{
  345. try {
  346. if (cs != null) cs.close();
  347. } catch (Exception ex_close) {
  348. WAFLogger.error(ex_close);
  349. }
  350. }
  351. }
  352. //집계처리
  353. public boolean getPayJipge(Connection connection, ValueObject vo, RowSet signUserInfo) throws Exception {
  354. Persistent persistent_i = null;
  355. Persistent persistent_i_p = null;
  356. Persistent persistent_u = null;
  357. Persistent persistent_u01 = null;
  358. String sqlstr_i = "";
  359. String sqlstr_i_p = "";
  360. String sqlstr_u = "";
  361. String sqlstr_u01 = "";
  362. try{
  363. persistent_i = new PersistentImpl(connection);
  364. persistent_i_p = new PersistentImpl(connection);
  365. persistent_u = new PersistentImpl(connection);
  366. persistent_u01 = new PersistentImpl(connection);
  367. int jip_count = getPayJipgeCount(connection, vo).getInt("jip_count");
  368. sqlstr_i = " INSERT INTO PUR1040T ( \n" +
  369. " TMPSLIP_ID -- 자재대금ID \n" +
  370. " ,DEPT_CD -- 현장코드 \n" +
  371. " ,PREPAY_GB -- 선급입고구분 \n" +
  372. " ,ENTER_DT -- 거래일자 \n" +
  373. " ,PROOF_CD -- 증빙코드 \n" +
  374. " ,ORD_DESC -- 적요 \n" +
  375. " ,MAT_AMT -- 구매금액 \n" +
  376. " ,MAT_SUPPLY_AMT -- 공급가액 \n" +
  377. " ,MAT_SURTAX_AMT -- 부가세 \n" +
  378. " ,PREPAY_SUB_AMT -- 선급금공제액 \n" +
  379. " ,DEALR_CD -- 거래처코드 \n" +
  380. " ,DCERTI_NO -- 사업자번호 \n" +
  381. " ,TAX_DATE -- 세금계산서일자 \n" +
  382. " ,ELECTAX_YN -- 전자세금계산서여부 \n" +
  383. " ,PAYITEM -- PAY ITEM \n" +
  384. " ,COSTCODE -- COST CODE \n" +
  385. " ,COSTTYPE -- COST TYPE \n" +
  386. " ,PAY_GROUP -- PAY_GROUP \n" +
  387. " ,PAYMENT_TERMS -- PAYMENT_TERMS \n" +
  388. " ,TMPNATFLG -- 계정구분 \n" +
  389. " ,TMPSLIP_YN -- 전표생성유무 \n" +
  390. " ,SLIP_YN -- 결의서작성유무 \n" +
  391. " ,CURRENCY_GB -- 통화구분 \n" +
  392. " ,PUR_CONT_ID -- 발주계약ID \n" +
  393. " ,PREPAY_ID -- 선급내역ID \n" +
  394. " ,CRE_BY -- 등록자 \n" +
  395. " ,CRE_DATE -- 등록일시 \n" +
  396. " ) \n" +
  397. " VALUES ( \n" +
  398. " ? \n" +
  399. " ,? -- 현장코드 \n" +
  400. " ,? -- 선급입고구분 \n" +
  401. " ,TO_DATE(?, 'YYYYMMDD') -- 거래일자 \n" +
  402. " ,? -- 증빙코드 \n" +
  403. " ,? -- 적요 \n" +
  404. " ,? -- 구매금액 \n" +
  405. " ,? -- 공급가액 \n" +
  406. " ,? -- 부가세 \n" +
  407. " ,? -- 선급금공제액 \n" +
  408. " ,? -- 거래처코드 \n" +
  409. " ,? -- 사업자번호 \n" +
  410. " ,TO_DATE(?, 'YYYYMMDD') -- 세금계산서일자 \n" +
  411. " ,'Y' -- 전자세금계산서여부 \n" +
  412. " ,? -- PAY ITEM \n" +
  413. " ,? -- COST CODE \n" +
  414. " ,? -- COST TYPE \n" +
  415. " ,? -- PAY_GROUP \n" +
  416. " ,? -- PAYMENT_TERMS \n" +
  417. " ,? -- 계정구분 \n" +
  418. " ,? -- 전표생성유무 \n" +
  419. " ,? -- 결의서작성유무 \n" +
  420. " ,? -- 통화구분 \n" +
  421. " ,? -- 발주계약ID \n" +
  422. " ,? -- 지급신청ID \n" +
  423. " ,? -- 등록자 \n" +
  424. " ,SYSDATE ) \n" ;
  425. sqlstr_i_p = " INSERT INTO PUR1040T ( \n" +
  426. " TMPSLIP_ID -- 자재대금ID \n" +
  427. " ,DEPT_CD -- 현장코드 \n" +
  428. " ,PREPAY_GB -- 선급입고구분 \n" +
  429. " ,ENTER_DT -- 거래일자 \n" +
  430. " ,PROOF_CD -- 증빙코드 \n" +
  431. " ,ORD_DESC -- 적요 \n" +
  432. " ,MAT_AMT -- 구매금액 \n" +
  433. " ,MAT_SUPPLY_AMT -- 공급가액 \n" +
  434. " ,MAT_SURTAX_AMT -- 부가세 \n" +
  435. " ,PREPAY_SUB_AMT -- 선급금공제액 \n" +
  436. " ,DEALR_CD -- 거래처코드 \n" +
  437. " ,DCERTI_NO -- 사업자번호 \n" +
  438. " ,TAX_DATE -- 세금계산서일자 \n" +
  439. " ,ELECTAX_YN -- 전자세금계산서여부 \n" +
  440. " ,PAYITEM -- PAY ITEM \n" +
  441. " ,COSTCODE -- COST CODE \n" +
  442. " ,COSTTYPE -- COST TYPE \n" +
  443. " ,PAY_GROUP -- PAY_GROUP \n" +
  444. " ,PAYMENT_TERMS -- PAYMENT_TERMS \n" +
  445. " ,TMPNATFLG -- 계정구분 \n" +
  446. " ,TMPSLIP_YN -- 전표생성유무 \n" +
  447. " ,SLIP_YN -- 결의서작성유무 \n" +
  448. " ,CURRENCY_GB -- 통화구분 \n" +
  449. " ,PUR_CONT_ID -- 발주계약ID \n" +
  450. " ,PREPAY_ID -- 선급내역ID \n" +
  451. " ,CRE_BY -- 등록자 \n" +
  452. " ,CRE_DATE -- 등록일시 \n" +
  453. " ) \n" +
  454. " VALUES ( \n" +
  455. " ? \n" +
  456. " ,? -- 현장코드 \n" +
  457. " ,? -- 선급입고구분 \n" +
  458. " ,TO_DATE(?, 'YYYYMMDD') -- 거래일자 \n" +
  459. " ,? -- 증빙코드 \n" +
  460. " ,? -- 적요 \n" +
  461. " ,? -- 구매금액 \n" +
  462. " ,? -- 공급가액 \n" +
  463. " ,? -- 부가세 \n" +
  464. " ,? -- 선급금공제액 \n" +
  465. " ,? -- 거래처코드 \n" +
  466. " ,? -- 사업자번호 \n" +
  467. " ,TO_DATE(?, 'YYYYMMDD') -- 세금계산서일자 \n" +
  468. " ,'Y' -- 전자세금계산서여부 \n" +
  469. " ,? -- PAY ITEM \n" +
  470. " ,? -- COST CODE \n" +
  471. " ,? -- COST TYPE \n" +
  472. " ,? -- PAY_GROUP \n" +
  473. " ,? -- PAYMENT_TERMS \n" +
  474. " ,? -- 계정구분 \n" +
  475. " ,? -- 전표생성유무 \n" +
  476. " ,? -- 결의서작성유무 \n" +
  477. " ,? -- 통화구분 \n" +
  478. " ,? -- 발주계약ID \n" +
  479. " ,? -- 지급신청ID \n" +
  480. " ,? -- 등록자 \n" +
  481. " ,SYSDATE ) \n" ;
  482. sqlstr_u = " UPDATE CONT_PUR_PAYPLAN SET PAY_SUPPLY_AMT = ? WHERE PUR_CONT_MOD_ID = ? AND PAY_SEQ = ? ";
  483. sqlstr_u01 = " UPDATE CONT_PUR_PAYPLAN SET PAY_SUPPLY_AMT = ? WHERE PUR_CONT_MOD_ID = ? AND PAY_SEQ = ? AND PAY_DIV_CD = '01'";
  484. RowSet rowSet = getPayReqList(connection, vo);
  485. persistent_i.setStatement(sqlstr_i);
  486. persistent_i_p.setStatement(sqlstr_i_p);
  487. persistent_u.setStatement(sqlstr_u);
  488. persistent_u01.setStatement(sqlstr_u01);
  489. String pay_group = "";
  490. String payment_term = "";
  491. String pay_item = "";
  492. String cost_code = "";
  493. String cost_type = "";
  494. String billDiv = "";
  495. if(jip_count > 0){
  496. ValueObject contPurPnalData01 = getContPurPayplan01(vo.get("PUR_CONT_MOD_ID"));
  497. ValueObject contPurPnalDataMax = getContPurPayplanMax(vo.get("PUR_CONT_MOD_ID"));
  498. if(rowSet.size() > 0){
  499. for(int i = 0; rowSet.size() > i; i++){
  500. if(contPurPnalData01.size() > 0){
  501. double paySuppluAmt01 = contPurPnalData01.getDouble("PAY_SUPPLY_AMT");
  502. double curReqAmt = rowSet.getRow(i).getDouble("R_P_S_A");
  503. double paySuppluAmtMax = contPurPnalDataMax.getDouble("PAY_SUPPLY_AMT");
  504. double culSuppluAmt = paySuppluAmt01 - curReqAmt;
  505. if(culSuppluAmt != 0){
  506. paySuppluAmtMax = paySuppluAmtMax + culSuppluAmt;
  507. persistent_u.addParameter(paySuppluAmtMax);
  508. persistent_u.addParameter(vo.get("PUR_CONT_MOD_ID"));
  509. persistent_u.addParameter(contPurPnalDataMax.get("PAY_SEQ"));
  510. System.out.println(sqlstr_u);
  511. persistent_u.execute();
  512. persistent_u.clearParameters();
  513. persistent_u01.addParameter(curReqAmt);
  514. persistent_u01.addParameter(vo.get("PUR_CONT_MOD_ID"));
  515. persistent_u01.addParameter(contPurPnalDataMax.get("MINPAY_SEQ"));
  516. System.out.println(sqlstr_u01);
  517. persistent_u01.execute();
  518. persistent_u01.clearParameters();
  519. }
  520. }
  521. //자재대금ID
  522. String tmpslipId_i = getTmpslipId();
  523. pay_group = rowSet.getRow(i).get("PAY_GROUP");
  524. payment_term = rowSet.getRow(i).get("PAYMENT_TERMS");
  525. pay_item = rowSet.getRow(i).get("PAY_ITEM");
  526. cost_code = rowSet.getRow(i).get("COST_CODE");
  527. cost_type = rowSet.getRow(i).get("COST_TYPE");
  528. persistent_i.addParameter(tmpslipId_i);
  529. persistent_i.addParameter(rowSet.getRow(i).get("DEPT_CD"));
  530. persistent_i.addParameter(rowSet.getRow(i).get("PREPAY_GB"));
  531. persistent_i.addParameter(rowSet.getRow(i).get("REQ_DATE")); //거래일자
  532. persistent_i.addParameter(rowSet.getRow(i).get("GUA_GB")); //증빙
  533. persistent_i.addParameter(rowSet.getRow(i).get("ORD_DESC")); //적요
  534. persistent_i.addParameter(rowSet.getRow(i).get("REQ_PREPAY_AMT")); //구매금액
  535. persistent_i.addParameter(rowSet.getRow(i).get("REQ_PREPAY_SUPPLY_AMT")); //공급가액
  536. persistent_i.addParameter(rowSet.getRow(i).get("REQ_PREPAY_SURTAX_AMT")); //부가세
  537. persistent_i.addParameter(0); //선급공제액
  538. persistent_i.addParameter(rowSet.getRow(i).get("CORP_ID"));
  539. persistent_i.addParameter(rowSet.getRow(i).get("CORP_REG_NO")); //사업자번호
  540. persistent_i.addParameter(rowSet.getRow(i).get("REQ_DATE")); //세금계산서일자
  541. persistent_i.addParameter(pay_item);
  542. persistent_i.addParameter(cost_code);
  543. persistent_i.addParameter(cost_type);
  544. persistent_i.addParameter(pay_group);
  545. persistent_i.addParameter(payment_term);
  546. persistent_i.addParameter(rowSet.getRow(i).get("ACCT_GB")); //분개구분
  547. persistent_i.addParameter("N"); //전표생성유무
  548. persistent_i.addParameter("N"); //결의서작성유무
  549. persistent_i.addParameter(rowSet.getRow(i).get("CURRENCY_GB"));
  550. persistent_i.addParameter(rowSet.getRow(i).get("PUR_CONT_ID"));
  551. persistent_i.addParameter(rowSet.getRow(i).get("PAYREQ_ID"));
  552. persistent_i.addParameter(vo.getInt("USERID"));
  553. persistent_i.execute();
  554. persistent_i.clearParameters();
  555. //증빙생성
  556. prcDoc020t(connection, tmpslipId_i, vo.getInt("USERID"), tmpslipId_i, "0");
  557. //전표생성프로시저호출
  558. //callPurInvoiceCreate(connection, tmpslipId_i, vo.get("USERID"), vo.get("slipNo"));
  559. if(rowSet.getRow(i).get("TAX_METHOD_CD").equals("1")){ //역발행(SGC이앤씨 발행)일때 발행
  560. billDiv = "1";
  561. //세금계산서 발행
  562. //createSMbill(connection, tmpslipId_i, vo.get("USERID"), rowSet.getRow(i).get("PAYREQ_ID"), rowSet.getRow(i).get("ORD_DESC"), batchId);
  563. }
  564. //세금계산서 번호업테이트
  565. //update1040tConId(connection, tmpslipId_i, rowSet.getRow(i).get("PAYREQ_ID"));
  566. }
  567. }
  568. String paySeq = getErpPaySeq(vo.get("YY_PREPAY"));
  569. vo.set("NO_PREPAY", paySeq);
  570. try {
  571. InterfacePurERPiU.insertPrepayInfo(vo, signUserInfo);
  572. }catch(Exception e) {
  573. connection.rollback();
  574. throw new Exception("ERPIU insert Error"+e.getMessage());
  575. }
  576. if(billDiv.equals("1")){
  577. connection.commit();
  578. //세금계산서 역발행 요청
  579. //apProcess(connection, batchId);
  580. }
  581. }else{
  582. //storage.setMessage("집계할수 있는 내용이 없습니다.");
  583. return false;
  584. }
  585. return true;
  586. } catch(Exception e) {
  587. WAFLogger.error(this.getClass().getName() + " --> updatePur1030t() : " + e.getMessage());
  588. WAFLogger.error(e);
  589. throw e;
  590. //return false;
  591. }
  592. }
  593. //집계처리
  594. public boolean getPayJipgeTybeB(Connection connection, ValueObject vo, RowSet signUserInfo) throws Exception {
  595. Persistent persistent_i = null;
  596. Persistent persistent_i_p = null;
  597. String sqlstr_i = "";
  598. String sqlstr_i_p = "";
  599. try{
  600. persistent_i = new PersistentImpl(connection);
  601. persistent_i_p = new PersistentImpl(connection);
  602. int jip_count = getPayJipgeCount(connection, vo).getInt("jip_count");
  603. sqlstr_i = " INSERT INTO PUR1040T ( \n" +
  604. " TMPSLIP_ID -- 자재대금ID \n" +
  605. " ,DEPT_CD -- 현장코드 \n" +
  606. " ,PREPAY_GB -- 선급입고구분 \n" +
  607. " ,ENTER_DT -- 거래일자 \n" +
  608. " ,PROOF_CD -- 증빙코드 \n" +
  609. " ,ORD_DESC -- 적요 \n" +
  610. " ,MAT_AMT -- 구매금액 \n" +
  611. " ,MAT_SUPPLY_AMT -- 공급가액 \n" +
  612. " ,MAT_SURTAX_AMT -- 부가세 \n" +
  613. " ,PREPAY_SUB_AMT -- 선급금공제액 \n" +
  614. " ,DEALR_CD -- 거래처코드 \n" +
  615. " ,DCERTI_NO -- 사업자번호 \n" +
  616. " ,TAX_DATE -- 세금계산서일자 \n" +
  617. " ,ELECTAX_YN -- 전자세금계산서여부 \n" +
  618. " ,PAYITEM -- PAY ITEM \n" +
  619. " ,COSTCODE -- COST CODE \n" +
  620. " ,COSTTYPE -- COST TYPE \n" +
  621. " ,PAY_GROUP -- PAY_GROUP \n" +
  622. " ,PAYMENT_TERMS -- PAYMENT_TERMS \n" +
  623. " ,TMPNATFLG -- 계정구분 \n" +
  624. " ,TMPSLIP_YN -- 전표생성유무 \n" +
  625. " ,SLIP_YN -- 결의서작성유무 \n" +
  626. " ,CURRENCY_GB -- 통화구분 \n" +
  627. " ,PUR_CONT_ID -- 발주계약ID \n" +
  628. " ,PREPAY_ID -- 선급내역ID \n" +
  629. " ,CRE_BY -- 등록자 \n" +
  630. " ,CRE_DATE -- 등록일시 \n" +
  631. " ) \n" +
  632. " VALUES ( \n" +
  633. " ? \n" +
  634. " ,? -- 현장코드 \n" +
  635. " ,? -- 선급입고구분 \n" +
  636. " ,TO_DATE(?, 'YYYYMMDD') -- 거래일자 \n" +
  637. " ,? -- 증빙코드 \n" +
  638. " ,? -- 적요 \n" +
  639. " ,? -- 구매금액 \n" +
  640. " ,? -- 공급가액 \n" +
  641. " ,? -- 부가세 \n" +
  642. " ,? -- 선급금공제액 \n" +
  643. " ,? -- 거래처코드 \n" +
  644. " ,? -- 사업자번호 \n" +
  645. " ,TO_DATE(?, 'YYYYMMDD') -- 세금계산서일자 \n" +
  646. " ,'Y' -- 전자세금계산서여부 \n" +
  647. " ,? -- PAY ITEM \n" +
  648. " ,? -- COST CODE \n" +
  649. " ,? -- COST TYPE \n" +
  650. " ,? -- PAY_GROUP \n" +
  651. " ,? -- PAYMENT_TERMS \n" +
  652. " ,? -- 계정구분 \n" +
  653. " ,? -- 전표생성유무 \n" +
  654. " ,? -- 결의서작성유무 \n" +
  655. " ,? -- 통화구분 \n" +
  656. " ,? -- 발주계약ID \n" +
  657. " ,? -- 지급신청ID \n" +
  658. " ,? -- 등록자 \n" +
  659. " ,SYSDATE ) \n" ;
  660. sqlstr_i_p = " INSERT INTO PUR1040T ( \n" +
  661. " TMPSLIP_ID -- 자재대금ID \n" +
  662. " ,DEPT_CD -- 현장코드 \n" +
  663. " ,PREPAY_GB -- 선급입고구분 \n" +
  664. " ,ENTER_DT -- 거래일자 \n" +
  665. " ,PROOF_CD -- 증빙코드 \n" +
  666. " ,ORD_DESC -- 적요 \n" +
  667. " ,MAT_AMT -- 구매금액 \n" +
  668. " ,MAT_SUPPLY_AMT -- 공급가액 \n" +
  669. " ,MAT_SURTAX_AMT -- 부가세 \n" +
  670. " ,PREPAY_SUB_AMT -- 선급금공제액 \n" +
  671. " ,DEALR_CD -- 거래처코드 \n" +
  672. " ,DCERTI_NO -- 사업자번호 \n" +
  673. " ,TAX_DATE -- 세금계산서일자 \n" +
  674. " ,ELECTAX_YN -- 전자세금계산서여부 \n" +
  675. " ,PAYITEM -- PAY ITEM \n" +
  676. " ,COSTCODE -- COST CODE \n" +
  677. " ,COSTTYPE -- COST TYPE \n" +
  678. " ,PAY_GROUP -- PAY_GROUP \n" +
  679. " ,PAYMENT_TERMS -- PAYMENT_TERMS \n" +
  680. " ,TMPNATFLG -- 계정구분 \n" +
  681. " ,TMPSLIP_YN -- 전표생성유무 \n" +
  682. " ,SLIP_YN -- 결의서작성유무 \n" +
  683. " ,CURRENCY_GB -- 통화구분 \n" +
  684. " ,PUR_CONT_ID -- 발주계약ID \n" +
  685. " ,PREPAY_ID -- 선급내역ID \n" +
  686. " ,CRE_BY -- 등록자 \n" +
  687. " ,CRE_DATE -- 등록일시 \n" +
  688. " ) \n" +
  689. " VALUES ( \n" +
  690. " ? \n" +
  691. " ,? -- 현장코드 \n" +
  692. " ,? -- 선급입고구분 \n" +
  693. " ,TO_DATE(?, 'YYYYMMDD') -- 거래일자 \n" +
  694. " ,? -- 증빙코드 \n" +
  695. " ,? -- 적요 \n" +
  696. " ,? -- 구매금액 \n" +
  697. " ,? -- 공급가액 \n" +
  698. " ,? -- 부가세 \n" +
  699. " ,? -- 선급금공제액 \n" +
  700. " ,? -- 거래처코드 \n" +
  701. " ,? -- 사업자번호 \n" +
  702. " ,TO_DATE(?, 'YYYYMMDD') -- 세금계산서일자 \n" +
  703. " ,'Y' -- 전자세금계산서여부 \n" +
  704. " ,? -- PAY ITEM \n" +
  705. " ,? -- COST CODE \n" +
  706. " ,? -- COST TYPE \n" +
  707. " ,? -- PAY_GROUP \n" +
  708. " ,? -- PAYMENT_TERMS \n" +
  709. " ,? -- 계정구분 \n" +
  710. " ,? -- 전표생성유무 \n" +
  711. " ,? -- 결의서작성유무 \n" +
  712. " ,? -- 통화구분 \n" +
  713. " ,? -- 발주계약ID \n" +
  714. " ,? -- 지급신청ID \n" +
  715. " ,? -- 등록자 \n" +
  716. " ,SYSDATE ) \n" ;
  717. RowSet rowSet = getPayReqList(connection, vo);
  718. persistent_i.setStatement(sqlstr_i);
  719. persistent_i_p.setStatement(sqlstr_i_p);
  720. String pay_group = "";
  721. String payment_term = "";
  722. String pay_item = "";
  723. String cost_code = "";
  724. String cost_type = "";
  725. if(jip_count > 0){
  726. if(rowSet.size() > 0){
  727. for(int i = 0; rowSet.size() > i; i++){
  728. if(vo.get("PAY_DIV").equals("2")){
  729. savePlanData(connection,vo, rowSet.getRow(i).get("REQ_PREPAY_SUPPLY_AMT"));//insert cont_pur_payplan
  730. }
  731. //자재대금ID
  732. String tmpslipId_i = getTmpslipId();
  733. pay_group = rowSet.getRow(i).get("PAY_GROUP");
  734. payment_term = rowSet.getRow(i).get("PAYMENT_TERMS");
  735. pay_item = rowSet.getRow(i).get("PAY_ITEM");
  736. cost_code = rowSet.getRow(i).get("COST_CODE");
  737. cost_type = rowSet.getRow(i).get("COST_TYPE");
  738. persistent_i.addParameter(tmpslipId_i);
  739. persistent_i.addParameter(rowSet.getRow(i).get("DEPT_CD"));
  740. persistent_i.addParameter(rowSet.getRow(i).get("PREPAY_GB"));
  741. persistent_i.addParameter(rowSet.getRow(i).get("REQ_DATE")); //거래일자
  742. persistent_i.addParameter(rowSet.getRow(i).get("GUA_GB")); //증빙
  743. persistent_i.addParameter(rowSet.getRow(i).get("ORD_DESC")); //적요
  744. persistent_i.addParameter(rowSet.getRow(i).get("REQ_PREPAY_AMT")); //구매금액
  745. persistent_i.addParameter(rowSet.getRow(i).get("REQ_PREPAY_SUPPLY_AMT")); //공급가액
  746. persistent_i.addParameter(rowSet.getRow(i).get("REQ_PREPAY_SURTAX_AMT")); //부가세
  747. persistent_i.addParameter(0); //선급공제액
  748. persistent_i.addParameter(rowSet.getRow(i).get("CORP_ID"));
  749. persistent_i.addParameter(rowSet.getRow(i).get("CORP_REG_NO")); //사업자번호
  750. persistent_i.addParameter(rowSet.getRow(i).get("REQ_DATE")); //세금계산서일자
  751. persistent_i.addParameter(pay_item);
  752. persistent_i.addParameter(cost_code);
  753. persistent_i.addParameter(cost_type);
  754. persistent_i.addParameter(pay_group);
  755. persistent_i.addParameter(payment_term);
  756. persistent_i.addParameter(rowSet.getRow(i).get("ACCT_GB")); //분개구분
  757. persistent_i.addParameter("N"); //전표생성유무
  758. persistent_i.addParameter("N"); //결의서작성유무
  759. persistent_i.addParameter(rowSet.getRow(i).get("CURRENCY_GB"));
  760. persistent_i.addParameter(rowSet.getRow(i).get("PUR_CONT_ID"));
  761. persistent_i.addParameter(rowSet.getRow(i).get("PAYREQ_ID"));
  762. persistent_i.addParameter(vo.getInt("USERID"));
  763. persistent_i.execute();
  764. persistent_i.clearParameters();
  765. //증빙생성
  766. prcDoc020t(connection, tmpslipId_i, vo.getInt("USERID"), tmpslipId_i, "0");
  767. //전표생성프로시저호출
  768. //callPurInvoiceCreate(connection, tmpslipId_i, vo.get("USERID"), vo.get("slipNo"));
  769. //세금계산서 번호업테이트
  770. //update1040tConId(connection, tmpslipId_i, rowSet.getRow(i).get("PAYREQ_ID"));
  771. }
  772. }
  773. String paySeq = getErpPaySeq(vo.get("YY_PREPAY"));
  774. vo.set("NO_PREPAY", paySeq);
  775. try {
  776. InterfacePurERPiU.insertPrepayInfo(vo, signUserInfo);
  777. }catch(Exception e) {
  778. connection.rollback();
  779. throw new Exception("ERPIU insert Error"+e.getMessage());
  780. }
  781. }else{
  782. //storage.setMessage("집계할수 있는 내용이 없습니다.");
  783. return false;
  784. }
  785. return true;
  786. } catch(Exception e) {
  787. WAFLogger.error(this.getClass().getName() + " --> updatePur1030t() : " + e.getMessage());
  788. WAFLogger.error(e);
  789. throw e;
  790. //return false;
  791. }
  792. }
  793. public void prcDoc020t(Connection con, String tmpslipID, int userID, String tempslip_id, String prepay_sub_amt) throws Exception {
  794. String strResult = null;
  795. String SPStateMent = "";
  796. CallableStatement cs = null;
  797. String arrDocNm [] = {"자재 계산서"};
  798. String arrProofGu [] = {"30"};
  799. //WAFLogger.debug("\n\t #################### params = [\n"+ params +"\n");
  800. try {
  801. // 증빙정보 생성 프로시저
  802. // - 자재 계산서만 새로 생성해야만 한다.
  803. SPStateMent = "{call SAC_DOCUMENTATIVE.prc_purinvoicebiz3(?, ?, ?, ?, ?)}";
  804. cs = con.prepareCall(SPStateMent);
  805. // 라인당, 기성고계산서 한라인만 생성.
  806. for(int iCount=0; iCount<arrDocNm.length; iCount++) {
  807. int i = 1;
  808. cs.setString(i++, tmpslipID);
  809. cs.setString(i++, arrProofGu[iCount]);
  810. cs.setInt(i++, userID);
  811. cs.setString(i++, prepay_sub_amt);
  812. cs.registerOutParameter(i++, Types.VARCHAR);
  813. cs.execute();
  814. strResult = cs.getString(5);
  815. // 입력된 증빙데이터 라인을 기준으로 실제 증빙을
  816. String arrKeys[] = strResult.split("@"); // proof_dept, proofdate, proof_no, proof_seq
  817. OutputStream outputStream = getOS(con, arrKeys[0], arrKeys[1], arrKeys[2], Integer.parseInt(arrKeys[3]));
  818. // 기성고 계산서 PDF 생성
  819. SACDOCreatePDF4 sacDOCreatePDF4 = new SACDOCreatePDF4();
  820. sacDOCreatePDF4.doBizBuyPre(con, outputStream, tmpslipID, null);
  821. //sacDOCreatePDF4.doBizBuyPre1(con, outputStream, tmpslipID, null);
  822. }
  823. // 라인당, 기성고계산서 한라인만 생성. - 종료
  824. }
  825. catch(Exception e) {
  826. WAFLogger.error(e);
  827. throw e;
  828. }
  829. finally{
  830. try {
  831. if (cs != null) cs.close();
  832. }
  833. catch (Exception ex_close) {
  834. WAFLogger.error(ex_close);
  835. }
  836. }
  837. }
  838. /* 증빙 스트림 Select !~ */
  839. public static OutputStream getOS(Connection con, String proof_dept, String proof_dt, String proof_no,
  840. int proof_seq) throws Exception {
  841. OutputStream outputStream = null;
  842. PreparedStatement pstmt = null;
  843. ResultSet resultSet = null;
  844. Statement stmt = null;
  845. try {
  846. String strSQL = "SELECT photo "
  847. + " FROM DOC021T "
  848. + " WHERE proof_dept = '"+ proof_dept +"'"
  849. + " AND TO_CHAR (proofdate, 'yyyymmdd') = '"+ proof_dt +"' "
  850. + " AND proof_no = " + proof_no
  851. + " AND proof_seq = "+ proof_seq
  852. + " AND proc_gu = '30' "
  853. + " FOR UPDATE";
  854. pstmt = con.prepareStatement(strSQL);
  855. resultSet = pstmt.executeQuery();
  856. if (resultSet.next()) {
  857. OracleThinBlob blob = (OracleThinBlob)resultSet.getBlob(1);
  858. outputStream = blob.getBinaryOutputStream();
  859. } else {
  860. throw new Exception("증빙화일을 저장할 레코드가 존재하지 않습니다.");
  861. }
  862. } catch (Exception e) {
  863. WAFLogger.error(e);
  864. } finally {
  865. if( stmt != null ) stmt.close();
  866. resultSet.close();
  867. pstmt.close();
  868. return outputStream;
  869. }
  870. }
  871. /**
  872. * 집계 가능한 내용 갯수
  873. * @param
  874. * @return ValueObject
  875. */
  876. public ValueObject getPayJipgeCount(Connection connection, ValueObject vo) throws Exception {
  877. Persistent persistent_c = null;
  878. //ValueObject resultVo = new ValueObject();
  879. ValueObject row = null;
  880. String sqlstr = "";
  881. try{
  882. persistent_c = new PersistentImpl(connection);
  883. sqlstr = " SELECT COUNT(*) JIP_COUNT \n" +
  884. " FROM PUR1030T A ,PUR2000T B \n" +
  885. " WHERE A.PUR_CONT_MOD_ID = B.PUR_CONT_MOD_ID \n" +
  886. " AND A.PREPAY_PROC_GB = '10' \n" +
  887. " AND A.PREPAY_ID = '"+vo.get("PREPAY_ID")+"' \n";
  888. persistent_c.setStatement(sqlstr);
  889. System.out.println(sqlstr);
  890. row = RowSetUtility.getValueObject(persistent_c.query().getRow(0));
  891. vo.set("jip_count", row.get("JIP_COUNT"));
  892. }catch(Exception e){
  893. WAFLogger.error(this.getClass().getName() + " --> getSeq() : " + e.getMessage());
  894. // System.out.println(e.getMessage());
  895. WAFLogger.error(e);
  896. throw e;
  897. }finally{
  898. if(vo == null) vo = new ValueObject();
  899. }
  900. return vo;
  901. }
  902. private RowSet getPayReqList(Connection connection, ValueObject params) throws Exception {
  903. RowSet rowSet = new RowSetImpl();
  904. String sqlstr = "";
  905. Persistent persistent_c = null;
  906. try{
  907. persistent_c = new PersistentImpl(connection);
  908. sqlstr = " SELECT A.PREPAY_ID \n" +
  909. " ,B.DEPT_CD DEPT_CD -- 현장코드 \n" + // 2015.9.10 Mapping Dept변경 (원B.DEPT_CD)
  910. " ,'1' AS PREPAY_GB --선급입고구분 \n" +
  911. " ,TO_CHAR(A.PREPAY_DATE, 'YYYYMMDD') ORD_CON_DATE --거래일자 \n" +
  912. " ,B.GUA_GB GUA_GB --증빙코드 \n" +
  913. " ,CASE WHEN (SELECT AC_UNIT_CD FROM ETEC_ERPIF.ACZ10100 WHERE DEPT_CD = B.DEPT_CD ) = '10' THEN '21' \n" +
  914. " WHEN (SELECT AC_UNIT_CD FROM ETEC_ERPIF.ACZ10100 WHERE DEPT_CD = B.DEPT_CD ) <> '10' THEN '22' \n" +
  915. " ELSE B.PAY_GROUP \n" +
  916. " END PAY_GROUP --선급금PAY_GROUP \n" +
  917. " ,B.PAYMENT_TERMS PAYMENT_TERMS --PAYMENT_TERMS \n" +
  918. " ,F_GET_REMARK_DATE(A.PREPAY_DATE) || ' 선급금(' || TO_NUMBER(A.PREPAY_NO) || '차) ' || B.CST_DOC_NAME AS ORD_DESC \n" +
  919. " ,B.ORD_AMT ORD_AMT --구매금액 \n" +
  920. " ,A.PREPAY_SUPPLY_AMT ORD_SUPPLY_AMT --부가세 \n" +
  921. " ,A.PREPAY_SURTAX_AMT CUR_REQ_VATAMT --부가세 \n" +
  922. " ,F_GET_DEALR_CD_EBID(C.CORP_ID) CORP_ID --거래처코드 \n" +
  923. " ,F_GET_DEALR_NO_EBID(C.CORP_ID) CORP_REG_NO --사업자번호 \n" +
  924. " ,B.PAY_ITEM AS PAY_ITEM \n" +
  925. " ,B.COST_TYPE AS COST_TYPE \n" +
  926. " ,B.COST_CODE AS COST_CODE \n" +
  927. " ,B.CURRENCY_GB CURRENCY_GB --통화구분 \n" +
  928. " ,A.PUR_CONT_ID PUR_CONT_ID --발주계약ID \n" +
  929. " ,A.PREPAY_ID PAYREQ_ID --선급신청ID \n" +
  930. " ,A.TAX_DY as REQ_DATE -- 작성일자 \n" +
  931. " ,B.CON_GB -- 계약구분 \n" +
  932. " ,B.ACCT_GB -- 분개구분 \n" +
  933. " ,B.ELEC_CON_YN -- 전자계약여부 \n" +
  934. " ,A.REQ_PREPAY_AMT AS REQ_PREPAY_AMT \n" +
  935. " ,A.REQ_PREPAY_SUPPLY_AMT AS REQ_PREPAY_SUPPLY_AMT \n" +
  936. " ,A.REQ_PREPAY_SURTAX_AMT AS REQ_PREPAY_SURTAX_AMT \n" +
  937. " ,1182 AS CUR_PAYING_AMT -- 금회지급예정액 \n" +
  938. " ,A.PREPAY_SUPPLY_AMT AS CUR_REQ_AMT -- 금회청구액 \n" +
  939. " ,A.REQ_PREPAY_SUPPLY_AMT AS R_P_S_A \n" +
  940. " ,A.TAX_METHOD_CD \n" +
  941. " FROM PUR1030T A, PUR2000T B, SUPP_INFO C \n" +
  942. " WHERE 1=1 \n" +
  943. " AND A.PUR_CONT_MOD_ID = B.PUR_CONT_MOD_ID \n" +
  944. " AND B.CORP_ID = C.CORP_ID \n" +
  945. " AND A.PREPAY_PROC_GB = '10' \n" +
  946. " AND A.PREPAY_ID = '"+params.get("PREPAY_ID")+"' \n"
  947. ;
  948. System.out.println(sqlstr);
  949. persistent_c.setStatement(sqlstr);
  950. rowSet = persistent_c.query();
  951. }catch (WAFSQLException se) {
  952. WAFLogger.error(this.getClass().getName() + " --> updatePur1030t() : " + se.getMessage());
  953. WAFLogger.error("SQL : " + sqlstr);
  954. WAFLogger.error(se);
  955. throw se;
  956. }
  957. finally {
  958. if(rowSet == null){
  959. rowSet = new RowSetImpl();
  960. }
  961. }
  962. return rowSet;
  963. }
  964. public ValueObject getPur1030t(String purContModId, String prepayId, String signInterfaceId) throws Exception {
  965. Search search = new SearchImpl();
  966. RowSet rowSet = new RowSetImpl();
  967. StringBuffer sqlstr = new StringBuffer();
  968. ValueObject row = null;
  969. try{
  970. sqlstr.append("SELECT B.PUR_CONT_ID \n");
  971. sqlstr.append(" ,B.PUR_CONT_MOD_ID \n");
  972. sqlstr.append(" ,( \n");
  973. sqlstr.append(" SELECT MAX(PAY_SEQ) \n");
  974. sqlstr.append(" FROM CONT_PUR_PAYPLAN \n");
  975. sqlstr.append(" WHERE PAY_DIV_CD = '01' \n");
  976. sqlstr.append(" AND PUR_CONT_ID = B.PUR_CONT_ID \n");
  977. sqlstr.append(" AND PUR_CONT_MOD_ID = B.PUR_CONT_MOD_ID \n");
  978. sqlstr.append(" ) AS PAY_SEQ \n");
  979. sqlstr.append(" ,B.PREPAY_ID \n");
  980. sqlstr.append(" ,A.DEPT_CD \n");
  981. sqlstr.append(" ,B.CHG_DIV_CD \n");
  982. sqlstr.append(" ,A.PAY_DIV \n");
  983. sqlstr.append(" ,TO_CHAR(TO_DATE(B.TAX_DY, 'YYYYMMDD'), 'YYYY-MM') AS P_ENTER_DT \n");
  984. sqlstr.append(" ,F.CRE_BY AS USERID \n");
  985. sqlstr.append(" ,TO_CHAR(PREPAY_DATE,'YYYY') AS YY_PREPAY \n");
  986. sqlstr.append(" ,'' AS NO_PREPAY \n");
  987. sqlstr.append(" ,'001' AS SQ_PREPAY \n");
  988. sqlstr.append(" ,'"+WAFConfig.get("waf.erp.cdCompany")+"' AS CD_COMPANY \n");
  989. sqlstr.append(" ,NVL(C.ERP_SITE_CD,A.DEPT_CD) AS CD_SITE \n");
  990. sqlstr.append(" ,'01' AS WM_CM00308 \n");
  991. sqlstr.append(" ,TO_CHAR(PREPAY_DATE,'YYYYMMDD') AS DT_PREPAY \n");
  992. sqlstr.append(" ,'01' AS WM_CM00301 \n");
  993. sqlstr.append(" ,A.ERP_NO_ECUT AS NO_ECUT \n");
  994. sqlstr.append(" ,TO_CHAR(A.CST_DATE,'YYYYMM') AS YM_ECUT \n");
  995. sqlstr.append(" ,E.ERP_CD_COOP AS CD_COOP \n");
  996. sqlstr.append(" ,REPLACE(E.DCERTI_NO,'-','') AS NO_COMPANY \n");
  997. sqlstr.append(" ,NVL(B.REQ_PREPAY_SUPPLY_AMT,0)*F_GET_EXCHANGE_RATE(B.PREPAY_DATE,A.CURRENCY_GB,'KRW') AS AMT_PREPAY \n");//2019.03.07
  998. sqlstr.append(" ,NVL(B.REQ_PREPAY_SURTAX_AMT,0)*F_GET_EXCHANGE_RATE(B.PREPAY_DATE,A.CURRENCY_GB,'KRW') AS VAT_PREPAY \n");//2019.03.07
  999. sqlstr.append(" ,TO_CHAR(B.CRE_DATE,'YYYYMMDD') AS DT_REQU \n");
  1000. sqlstr.append(" ,GET_USER_NM(B.CRE_BY) AS NM_REQU \n");
  1001. sqlstr.append(" ,TO_CHAR(F.CRE_DATE,'YYYYMMDD') AS DT_CONFIRM \n");
  1002. sqlstr.append(" ,GET_USER_NM(F.CRE_BY) AS NM_CONFIRM \n");
  1003. sqlstr.append(" ,PREPAY_DESC AS DESC_PREPAY \n");
  1004. sqlstr.append(" ,(SELECT USER_SABUN FROM PUB0120T WHERE ACCT_ID = B.CRE_BY) AS ID_INSERT \n");
  1005. sqlstr.append(" ,TO_CHAR(B.CRE_DATE,'YYYYMMDD') AS DTS_INSERT \n");
  1006. sqlstr.append(" ,NVL(G.CHG_CODE10,A.CURRENCY_GB) AS CURR_SOUR \n");
  1007. sqlstr.append(" ,F_GET_EXCHANGE_RATE(B.PREPAY_DATE,A.CURRENCY_GB,'KRW') AS UNT_CURR \n"); //EXCHANGE AS 2019.03.07
  1008. sqlstr.append(" ,NVL(B.REQ_PREPAY_SUPPLY_AMT,0) AS SAMT_CURR_PREPAY \n");
  1009. sqlstr.append(" ,NVL(B.REQ_PREPAY_SURTAX_AMT,0) AS VAMT_CURR_PREPAY \n");
  1010. sqlstr.append(" ,'Y' AS YN_BAN \n");
  1011. sqlstr.append(" ,DECODE(B.TAX_METHOD_CD,'1','0','2') AS YN_ISS \n");
  1012. //2019.07.29 ERP 자동분개를 위한 계정코드
  1013. sqlstr.append(" ,CASE WHEN A.CURRENCY_GB = 'KRW' THEN \n");
  1014. sqlstr.append(" CASE WHEN NVL(B.SUPP_DIRECT_YN,'') = 'Y' THEN NVL(J.CHG_CODE12, '') \n");
  1015. sqlstr.append(" ELSE NVL(J.CHG_CODE10, '') \n");
  1016. sqlstr.append(" END \n");
  1017. sqlstr.append(" ELSE CASE WHEN NVL(B.SUPP_DIRECT_YN,'') = 'Y' THEN NVL(J.CHG_CODE13, '') \n");
  1018. sqlstr.append(" ELSE NVL(J.CHG_CODE11, '') \n");
  1019. sqlstr.append(" END \n");
  1020. sqlstr.append(" END AS CD_COST_TRADE \n");
  1021. sqlstr.append("FROM PUR2000T A \n");
  1022. sqlstr.append(" ,PUR1030T B \n");
  1023. sqlstr.append(" ,ETEC_ERPIF.SITE_MAPPING C \n");
  1024. sqlstr.append(" ,CONT_PUR_SUPP D \n");
  1025. sqlstr.append(" ,ETEC_ERPIF.ACZ10800 E \n");
  1026. sqlstr.append(" ,( \n");
  1027. sqlstr.append(" SELECT CRE_BY, CRE_DATE \n");
  1028. sqlstr.append(" FROM SIGN001T \n");
  1029. sqlstr.append(" WHERE SIGN_INTERFACE_ID = "+signInterfaceId+" \n");
  1030. sqlstr.append(" ) F \n");
  1031. sqlstr.append(" ,( \n");
  1032. sqlstr.append(" SELECT DETAILCD, CHG_CODE10 \n");
  1033. sqlstr.append(" FROM EBID_COM911T \n");
  1034. sqlstr.append(" WHERE BASECD = '911' \n");
  1035. sqlstr.append(" ) G \n");
  1036. //sqlstr.append(" ,BID_SUPP H \n");2019.03.07
  1037. sqlstr.append(" ,SUPP_INFO I \n");
  1038. sqlstr.append(" ,(SELECT DETAILCD, CHG_CODE10, CHG_CODE11, CHG_CODE12, CHG_CODE13 FROM EBID_COM911T WHERE BASECD = 'PUR-ACCT_GB' ) J \n");
  1039. sqlstr.append("WHERE A.PUR_CONT_ID = B.PUR_CONT_ID \n");
  1040. sqlstr.append("AND A.PUR_CONT_MOD_ID = B.PUR_CONT_MOD_ID \n");
  1041. sqlstr.append("AND A.DEPT_CD = C.EBID_SITE_CD(+) \n");
  1042. sqlstr.append("AND A.PUR_CONT_MOD_ID = D.PUR_CONT_MOD_ID \n");
  1043. sqlstr.append("AND D.CORP_ID != 0 \n");
  1044. sqlstr.append("AND D.CORP_ID = I.CORP_ID \n");
  1045. sqlstr.append("AND REPLACE(I.CORP_REG_NO,'-','') = REPLACE(E.DCERTI_NO,'-','') \n");
  1046. sqlstr.append("AND E.ADDITEM20 = 'P' \n"); //2019.02.26
  1047. sqlstr.append("AND A.CURRENCY_GB = G.DETAILCD(+) \n");
  1048. //sqlstr.append("AND A.BID_NO = H.BID_NO \n");//2019.02.26
  1049. //sqlstr.append("AND A.BID_DEG = H.BID_DEG \n");//2019.02.26
  1050. //sqlstr.append("AND D.CORP_ID = TO_NUMBER(H.VENDOR_CD) \n");//2019.02.26
  1051. sqlstr.append("AND A.ACCT_GB = J.DETAILCD(+) \n");
  1052. sqlstr.append("AND B.PREPAY_ID = "+prepayId+" \n");
  1053. sqlstr.append("AND B.PUR_CONT_MOD_ID = "+purContModId+" \n");
  1054. System.out.println(sqlstr.toString());
  1055. search.setStatement(sqlstr.toString());
  1056. rowSet = search.execute();
  1057. row = RowSetUtility.getValueObject(rowSet.getRow(0));
  1058. }catch(Exception e){
  1059. WAFLogger.error(this.getClass().getName() + " --> getPur1030t() : " + e.getMessage());
  1060. WAFLogger.error("SQL : " + sqlstr);
  1061. WAFLogger.error(e);
  1062. throw e;
  1063. }finally{
  1064. if(row == null) row = new ValueObject();
  1065. }
  1066. return row;
  1067. }
  1068. public ValueObject getContPurPayplanMax(String purContModId) throws Exception {
  1069. Search search = new SearchImpl();
  1070. RowSet rowSet = new RowSetImpl();
  1071. String sqlstr = "";
  1072. ValueObject row = null;
  1073. try{
  1074. sqlstr = " SELECT B.PAY_SUPPLY_AMT , A.PAY_SEQ, A.MINPAY_SEQ \n" +
  1075. " FROM ( \n" +
  1076. " SELECT PUR_CONT_MOD_ID, MIN(PAY_SEQ) AS MINPAY_SEQ, MAX(PAY_SEQ) AS PAY_SEQ, MAX(PAY_SUPPLY_AMT) AS PAY_SUPPLY_AMT \n" +
  1077. " FROM CONT_PUR_PAYPLAN \n" +
  1078. " WHERE 1=1 \n" +
  1079. " AND PUR_CONT_MOD_ID = '"+purContModId+"' \n" +
  1080. " GROUP BY PUR_CONT_MOD_ID \n" +
  1081. " ) A, \n" +
  1082. " CONT_PUR_PAYPLAN B \n" +
  1083. " WHERE A.PUR_CONT_MOD_ID = B.PUR_CONT_MOD_ID \n" +
  1084. " AND A.PAY_SEQ = B.PAY_SEQ \n"
  1085. ;
  1086. System.out.println(sqlstr);
  1087. search.setStatement(sqlstr);
  1088. rowSet = search.execute();
  1089. if(rowSet.size() > 0){
  1090. row = RowSetUtility.getValueObject(rowSet.getRow(0));
  1091. }
  1092. }catch(Exception e){
  1093. WAFLogger.error(this.getClass().getName() + " --> getContPurPayplanMax() : " + e.getMessage());
  1094. WAFLogger.error("SQL : " + sqlstr);
  1095. WAFLogger.error(e);
  1096. throw e;
  1097. }finally{
  1098. if(row == null) row = new ValueObject();
  1099. }
  1100. return row;
  1101. }
  1102. public ValueObject getContPurPayplan01(String purContModId) throws Exception {
  1103. Search search = new SearchImpl();
  1104. RowSet rowSet = new RowSetImpl();
  1105. String sqlstr = "";
  1106. ValueObject row = null;
  1107. try{
  1108. sqlstr =" SELECT PUR_CONT_MOD_ID, PAY_SEQ, PUR_CONT_ID, PAY_SUPPLY_AMT, GUAR_YN, WARR_GUBUN, VP_YN, PAY_DIV_CD, PAYREQ_ID, PAY_YN \n" +
  1109. " FROM CONT_PUR_PAYPLAN \n" +
  1110. " WHERE PAY_DIV_CD = '01' \n" +
  1111. " AND PUR_CONT_MOD_ID = '"+purContModId+"' \n"
  1112. ;
  1113. System.out.println(sqlstr);
  1114. search.setStatement(sqlstr);
  1115. rowSet = search.execute();
  1116. if(rowSet.size() > 0){
  1117. row = RowSetUtility.getValueObject(rowSet.getRow(0));
  1118. }
  1119. }catch(Exception e){
  1120. WAFLogger.error(this.getClass().getName() + " --> getContPurPayplan() : " + e.getMessage());
  1121. WAFLogger.error("SQL : " + sqlstr);
  1122. WAFLogger.error(e);
  1123. throw e;
  1124. }finally{
  1125. if(row == null) row = new ValueObject();
  1126. }
  1127. return row;
  1128. }
  1129. public String getTmpslipId() throws Exception {
  1130. Search search = new SearchImpl();
  1131. RowSet rowSet = new RowSetImpl();
  1132. String sqlstr = "";
  1133. ValueObject row = null;
  1134. String resultId = "";
  1135. try{
  1136. sqlstr = " SELECT PUR1040T_S.NEXTVAL AS TMPSLIP_ID FROM DUAL \n";
  1137. System.out.println(sqlstr);
  1138. search.setStatement(sqlstr);
  1139. rowSet = search.execute();
  1140. row = RowSetUtility.getValueObject(rowSet.getRow(0));
  1141. resultId = row.get("TMPSLIP_ID");
  1142. }catch(Exception e){
  1143. WAFLogger.error(this.getClass().getName() + " --> updatePur1030t() : " + e.getMessage());
  1144. WAFLogger.error("SQL : " + sqlstr);
  1145. WAFLogger.error(e);
  1146. throw e;
  1147. }finally{
  1148. if(row == null) row = new ValueObject();
  1149. }
  1150. return resultId;
  1151. }
  1152. public String getBatchId() throws Exception {
  1153. Search search = new SearchImpl();
  1154. RowSet rowSet = new RowSetImpl();
  1155. String sqlstr = "";
  1156. ValueObject row = null;
  1157. String resultId = "";
  1158. try{
  1159. sqlstr = " SELECT TO_CHAR(SYSTIMESTAMP, 'YYYYMMDDHH24MISS') AS BATCH_ID FROM DUAL \n";
  1160. System.out.println(sqlstr);
  1161. search.setStatement(sqlstr);
  1162. rowSet = search.execute();
  1163. row = RowSetUtility.getValueObject(rowSet.getRow(0));
  1164. resultId = row.get("BATCH_ID");
  1165. }catch(Exception e){
  1166. WAFLogger.error(this.getClass().getName() + " --> getBatchId() : " + e.getMessage());
  1167. WAFLogger.error("SQL : " + sqlstr);
  1168. WAFLogger.error(e);
  1169. throw e;
  1170. }finally{
  1171. if(row == null) row = new ValueObject();
  1172. }
  1173. return resultId;
  1174. }
  1175. /**
  1176. * 대금이 선급금일시 pay_group, payment_terms 변경
  1177. * @param
  1178. * @return ValueObject
  1179. */
  1180. public ValueObject getPayGroup(Connection connection, String dept_cd) throws Exception {
  1181. Persistent persistent_c = null;
  1182. ValueObject vo = new ValueObject();
  1183. ValueObject row = null;
  1184. String sqlstr = "";
  1185. try{
  1186. persistent_c = new PersistentImpl(connection);
  1187. sqlstr += " SELECT \n"
  1188. + " DETAILCD \n"
  1189. + " ,DETAILNM \n"
  1190. + " FROM COM911T \n"
  1191. + " WHERE BASECD = '005' \n"
  1192. + " AND CHG_CODE04 = CASE \n"
  1193. + " WHEN (SELECT AC_UNIT_CD FROM ETEC_ERPIF.ACZ10100 WHERE DEPT_CD = '"+dept_cd+"' ) = '60' THEN '60' \n"
  1194. + " WHEN (SELECT AC_UNIT_CD FROM ETEC_ERPIF.ACZ10100 WHERE DEPT_CD = '"+dept_cd+"' ) <> '10' THEN '20' \n"
  1195. + " ELSE '10' END || '_C' \n" ;
  1196. persistent_c.setStatement(sqlstr);
  1197. System.out.println(sqlstr);
  1198. row = RowSetUtility.getValueObject(persistent_c.query().getRow(0));
  1199. vo.set("DETAILCD", row.get("DETAILCD"));
  1200. }catch(Exception e){
  1201. WAFLogger.error(this.getClass().getName() + " --> getSeq() : " + e.getMessage());
  1202. // System.out.println(e.getMessage());
  1203. WAFLogger.error(e);
  1204. throw e;
  1205. }finally{
  1206. if(vo == null) vo = new ValueObject();
  1207. }
  1208. return vo;
  1209. }
  1210. public void updatePayPlan(Connection con, ValueObject vo) throws Exception {
  1211. Persistent persistent = new PersistentImpl(con);
  1212. StringBuffer sqlstr = null;
  1213. try {
  1214. sqlstr = new StringBuffer();
  1215. //구매)선급내역에 상태값 변경
  1216. sqlstr.append(" UPDATE CONT_PUR_PAYPLAN SET \n");
  1217. sqlstr.append(" PAY_YN = 'N', \n");
  1218. sqlstr.append(" PAY_SUPPLY_AMT = '0' \n");
  1219. sqlstr.append(" WHERE PUR_CONT_ID = ? AND PAY_DIV_CD = '01' \n");
  1220. persistent.setStatement(sqlstr.toString());
  1221. persistent.addParameter(vo.get("PUR_CONT_ID"));
  1222. persistent.execute();
  1223. }catch(Exception e) {
  1224. WAFLogger.error(this.getClass().getName() + " --> updatePayPlan() : " + e.getMessage());
  1225. WAFLogger.error("SQL : " + sqlstr);
  1226. WAFLogger.error(e);
  1227. throw e;
  1228. }
  1229. }
  1230. /**
  1231. * 대금계획 추가
  1232. * @param connection
  1233. * @param valueObject
  1234. * @throws Exception
  1235. */
  1236. public boolean savePlanData(Connection connection, ValueObject vo, String amt) throws Exception {
  1237. Persistent persistent = new PersistentImpl(connection);
  1238. StringBuffer sql = new StringBuffer();
  1239. try {
  1240. sql.append(" INSERT \n ");
  1241. sql.append(" INTO CONT_PUR_PAYPLAN \n ");
  1242. sql.append(" ( \n ");
  1243. sql.append(" PUR_CONT_MOD_ID \n ");
  1244. sql.append(" ,PAY_SEQ \n ");
  1245. sql.append(" ,PUR_CONT_ID \n ");
  1246. sql.append(" ,PAY_SUPPLY_AMT \n ");
  1247. sql.append(" ,PAY_DIV_CD \n ");
  1248. sql.append(" ,PAY_YN \n ");
  1249. sql.append(" ,CRE_BY \n ");
  1250. sql.append(" ,CRE_DATE \n ");
  1251. sql.append(" ) \n ");
  1252. sql.append(" VALUES \n ");
  1253. sql.append(" ( ? \n "); //pur_cont_mod_id
  1254. sql.append(" , (select nvl(max(pay_seq), 0) + 1 from CONT_PUR_PAYPLAN where PUR_CONT_MOD_ID = ?) \n "); //pay_seq
  1255. sql.append(" , ? \n "); //pur_cont_id
  1256. sql.append(" , ? \n "); //pay_supply_amt
  1257. sql.append(" , '01' \n "); //pay_div_cd
  1258. sql.append(" , 'Y' \n "); //pay_yn
  1259. sql.append(" , '99996' \n ");
  1260. sql.append(" , SYSDATE \n ");
  1261. sql.append(" ) \n ");
  1262. //WAFLogger.debug("DDDDDDDDDDDDDDDD" + sqlParams.get("PUR_CONT_MOD_ID"));
  1263. persistent.setStatement(sql.toString());
  1264. int paramIdx = 1;
  1265. persistent.addParameter(vo.get("PUR_CONT_MOD_ID"));
  1266. persistent.addParameter(vo.get("PUR_CONT_MOD_ID"));
  1267. persistent.addParameter(vo.get("PUR_CONT_ID"));
  1268. persistent.addParameter(amt);
  1269. persistent.execute();
  1270. return true;
  1271. }
  1272. catch(Exception e) {
  1273. WAFLogger.error(this.getClass().getName() + " --> savePlanData() : " + e.getMessage());
  1274. WAFLogger.error("SQL : " + sql);
  1275. WAFLogger.error(e);
  1276. throw e;
  1277. }
  1278. }
  1279. //20115.10.6 선급완료후 email발송
  1280. public void Send(String PUR_CONT_MOD_ID) throws Exception {
  1281. HandlerStorage Stroage = new HandlerStorage();
  1282. MessageSend messageSend = new MessageSend(Stroage);
  1283. RowSet rsUserInfo = getUserInfo(PUR_CONT_MOD_ID);
  1284. boolean email = false;
  1285. StringBuffer mailtitle = new StringBuffer();
  1286. StringBuffer mailtitlein = new StringBuffer();
  1287. StringBuffer mailContent = new StringBuffer();
  1288. if( rsUserInfo.size() > 0 && !rsUserInfo.getRow(0).get("MAT_MAIL").isEmpty()){
  1289. mailtitle.append("* 선급금 신청 되었습니다.");
  1290. mailtitlein.append("* 선급금 신청 되었습니다.");
  1291. mailContent.append("<font style='width:auto; font-size:12px; line-height:18px; text-align:left;'>");
  1292. mailContent.append("선급금 신청 되었습니다. ");
  1293. mailContent.append("경영정보의 전표마감 현황 확인 바랍니다. <br>");
  1294. mailContent.append("1. 현 장: (" + rsUserInfo.getRow(0).get("DEPT_CD") + ")" + rsUserInfo.getRow(0).get("DEPT_NAME") + " <br>");
  1295. mailContent.append("2. 계약번호: " + rsUserInfo.getRow(0).get("CONT_NO") + " <br>");
  1296. mailContent.append("3. 계 약 명: " + rsUserInfo.getRow(0).get("CONT_NAME") + " <br>");
  1297. mailContent.append("<br>");
  1298. mailContent.append("</font>");
  1299. email = true;
  1300. if(email){ //구매팀, 회계팀
  1301. messageSend.sendEmail(rsUserInfo.getRow(0).get("MAT_MAIL"), "partner@sgc.co.kr", mailtitle.toString(), mailtitlein.toString(), mailContent, "N");
  1302. messageSend.sendEmail(rsUserInfo.getRow(0).get("ACT_MAIL1"), "partner@sgc.co.kr", mailtitle.toString(), mailtitlein.toString(), mailContent, "N");
  1303. if (!rsUserInfo.getRow(0).get("ACT_MAIL2").equals("NA") ){
  1304. messageSend.sendEmail(rsUserInfo.getRow(0).get("ACT_MAIL2"), "partner@sgc.co.kr", mailtitle.toString(), mailtitlein.toString(), mailContent, "N");
  1305. }
  1306. }
  1307. }
  1308. }
  1309. //2015.10.6 구매, 회계 담당자 정보
  1310. private RowSet getUserInfo(String PUR_CONT_MOD_ID) throws Exception{
  1311. Search search = new SearchImpl();
  1312. RowSet rowSet = new RowSetImpl();
  1313. StringBuffer sqlstr = new StringBuffer();
  1314. try {
  1315. sqlstr.append(" SELECT B.EMAIL MAT_MAIL \n");
  1316. sqlstr.append(" ,NVL(D.CHG_CODE08, 'NA') ACT_MAIL1 \n");
  1317. sqlstr.append(" ,NVL(D.CHG_CODE09, 'NA') ACT_MAIL2 \n");
  1318. sqlstr.append(" ,A.DEPT_CD DEPT_CD \n");
  1319. sqlstr.append(" ,A.DEPT_NAME DEPT_NAME \n");
  1320. sqlstr.append(" ,A.ORD_DOC_NO CONT_NO \n");
  1321. sqlstr.append(" ,A.CST_DOC_NAME CONT_NAME \n");
  1322. sqlstr.append(" FROM PUR2000T A \n");
  1323. sqlstr.append(" ,CONT_PUR_SUPP B \n");
  1324. sqlstr.append(" ,ETEC_ERPIF.ACZ10100 C \n");
  1325. sqlstr.append(" ,EBID_COM911T D \n");
  1326. sqlstr.append(" WHERE A.PUR_CONT_MOD_ID = B.PUR_CONT_MOD_ID \n");
  1327. sqlstr.append(" AND A.DEPT_CD = C.DEPT_CD \n");
  1328. sqlstr.append(" AND C.AC_UNIT_CD = D.DETAILCD \n");
  1329. sqlstr.append(" AND D.BASECD = '101' \n");
  1330. sqlstr.append(" AND A.PUR_CONT_MOD_ID = '" + PUR_CONT_MOD_ID + "' \n");
  1331. sqlstr.append(" AND B.SIGN_SEQ = 1 \n");
  1332. search.setStatement(sqlstr.toString());
  1333. rowSet = search.execute();
  1334. }
  1335. catch(WAFSQLException se) {
  1336. Logger.err.println("SQL : \n" + se.getStatement());
  1337. Logger.err.println("PARAM : \n" + se.getParameter());
  1338. throw se;
  1339. }
  1340. finally {
  1341. if( rowSet == null ) rowSet = new RowSetImpl();
  1342. return rowSet;
  1343. }
  1344. }
  1345. public String getErpPaySeq(String YY_PREPAY) throws Exception {
  1346. Search search = new SearchImpl();
  1347. RowSet rowSet = new RowSetImpl();
  1348. StringBuffer sqlstr = new StringBuffer();
  1349. String rtnStr = "";
  1350. try{
  1351. sqlstr.append("SELECT TO_CHAR(NVL(MAX(TO_NUMBER(NO_PREPAY)),0)+1,'FM00000') AS NO_PREPAY \n");
  1352. sqlstr.append("FROM WM_E_EXECUTE_PREPAY@ERPIU \n");
  1353. sqlstr.append("WHERE YY_PREPAY = '"+YY_PREPAY+"' \n");
  1354. System.out.println(sqlstr.toString());
  1355. search.setStatement(sqlstr.toString());
  1356. rowSet = search.execute();
  1357. if( rowSet != null ) {
  1358. rtnStr = rowSet.getRow(0).get("NO_PREPAY");
  1359. }
  1360. }catch(Exception e){
  1361. WAFLogger.error(this.getClass().getName() + " --> getErpPaySeq() : " + e.getMessage());
  1362. WAFLogger.error("SQL : " + sqlstr);
  1363. WAFLogger.error(e);
  1364. throw e;
  1365. }
  1366. return rtnStr;
  1367. }
  1368. }