CommonMailThreadBiz.java 67 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020
  1. /**
  2. * @(#)file SignThreadBiz.java
  3. * @(#)author DaeJin Lee
  4. * @(#)version 1.0
  5. * @(#)date Jun 10, 2005
  6. * @(#)since JDK 1.4.2
  7. *
  8. * Copyright (c) www.dcchem.co.kr, Inc.
  9. * All rights reserved.
  10. * This software is the proprietary information of dcchem, Inc.
  11. */
  12. package kr.co.udapsoft.common.commonSign;
  13. import java.sql.Connection;
  14. import kr.co.hsnc.common.base.WAFLogger;
  15. import kr.co.hsnc.common.logger.Logger;
  16. import kr.co.hsnc.common.sql.Row;
  17. import kr.co.hsnc.common.sql.RowImpl;
  18. import kr.co.hsnc.common.sql.RowSet;
  19. import kr.co.hsnc.common.sql.RowSetImpl;
  20. import kr.co.hsnc.common.sql.WAFConnection;
  21. import kr.co.hsnc.common.sql.WAFConnectionImpl;
  22. import kr.co.hsnc.common.sql.WAFSQLException;
  23. import kr.co.hsnc.common.sql.persistent.Persistent;
  24. import kr.co.hsnc.common.sql.persistent.PersistentImpl;
  25. import kr.co.hsnc.common.sql.search.Search;
  26. import kr.co.hsnc.common.sql.search.SearchImpl;
  27. import kr.co.hsnc.common.util.ValueObject;
  28. import java.text.SimpleDateFormat;
  29. import java.util.Date;
  30. import kr.co.udapsoft.common.sender.MessageSend;
  31. import com.udapsoft.waf.system.HandlerStorage;
  32. import oracle.toplink.internal.ox.StrBuffer;
  33. /**
  34. *
  35. * @version 1.0
  36. * @author DaeJin Lee
  37. */
  38. public class CommonMailThreadBiz {
  39. private WAFConnection conn = null;
  40. public CommonMailThreadBiz() {
  41. this.conn = new WAFConnectionImpl();
  42. }
  43. /**
  44. * 전자결재 처리결과 수신 Biz
  45. */
  46. public void doBiz() throws Exception {
  47. try {
  48. long time = System.currentTimeMillis();
  49. SimpleDateFormat dayTime = new SimpleDateFormat("HHmm");
  50. String str = dayTime.format(new Date(time));
  51. if (str.equals("0800") || str.equals("0801")){ //오전08시 실행.
  52. try{
  53. RowSet rowTread = getBidThread();
  54. sendBidMail(rowTread); //당일 마감입찰
  55. RowSet rowCont = getContThread();
  56. sendContMail(rowCont); //계약 20일 초과 하도급미발행
  57. //2019.11.29 추가 Start
  58. //RowSet rowPurContEnd = getPurContEndThread();
  59. //sendContEndMail(rowPurContEnd); //구매계약 만료 30일전 알림
  60. RowSet rowOutContEnd = getOutContEndThread();
  61. sendContEndMail(rowOutContEnd); //외주계약 만료 30일전 알림
  62. //2019.11.29 추가 End
  63. }
  64. catch(Exception se){
  65. WAFLogger.error(this.getClass().getName() + " --> 입찰마감오류() : " + se.getMessage());
  66. WAFLogger.error(se);
  67. throw se;
  68. }
  69. }
  70. try{
  71. conn.begin();
  72. //구매변경계약 업데이트
  73. Row row = new RowImpl();
  74. String maxPurContid = new String();
  75. RowSet rowChgTread = getChgContThread();
  76. for ( int i = 0 ; i < rowChgTread.size() ; i ++ ) {
  77. row = rowChgTread.getRow(i); //구매 변경계약 PUR2000T로 INSERT
  78. maxPurContid = getMaxPurCntId();
  79. addChangeContItem(conn.getConnection(), row.get("DEMANDED_ID"), maxPurContid, row.get("PUR_CONT_MOD_ID")); //변경계약 아이템 저장
  80. addChangeContPur(conn.getConnection(), row.get("DEMANDED_ID"), maxPurContid, row.get("PUR_CONT_MOD_ID") ); //변경 계약 추가
  81. addChangeContSupport(conn.getConnection(), row.get("PUR_CONT_MOD_ID"), maxPurContid, row.get("PUR_CONT_MOD_ID")); //변경 계약 업체추가
  82. }
  83. RowSet rowMail = getMailThread(); //발주의뢰, 변경계약 메일알림
  84. sendMail(rowMail);
  85. updateMail(conn.getConnection(), rowMail);
  86. }
  87. catch(Exception se){
  88. WAFLogger.error(this.getClass().getName() + " --> doBiz() : " + se.getMessage());
  89. WAFLogger.error(se);
  90. conn.setRollback();
  91. throw se;
  92. } finally {
  93. conn.end();
  94. }
  95. } catch(Exception se) {
  96. WAFLogger.error(this.getClass().getName() + " --> setInsert() : " + se.getMessage());
  97. WAFLogger.error(se);
  98. throw se;
  99. }
  100. }
  101. private RowSet getBidThread() throws Exception{
  102. Search search = new SearchImpl();
  103. RowSet rowSet = new RowSetImpl();
  104. StringBuffer sqlstr = new StringBuffer();
  105. try {
  106. //개찰알림메일
  107. sqlstr.append(" SELECT A.DEPT_CD \n");
  108. sqlstr.append(" ,A.DEPT_NM \n");
  109. sqlstr.append(" ,A.BID_MASTER_NM \n");
  110. sqlstr.append(" ,A.BID_NO \n");
  111. sqlstr.append(" ,A.BID_DEG \n");
  112. sqlstr.append(" ,TO_CHAR(A.BID_TO_DT , 'YYYY-MM-DD HH24:MI') BID_TO_DT \n");
  113. sqlstr.append(" ,A.PUREMPNO \n");
  114. sqlstr.append(" ,B.USER_SABUN \n");
  115. sqlstr.append(" ,B.USER_NAME \n");
  116. sqlstr.append(" ,B.HAND_TEL_NO \n");
  117. sqlstr.append(" ,B.E_MAIL \n");
  118. sqlstr.append(" ,A.OPEN_EMPNM \n");
  119. sqlstr.append(" FROM BID_MASTER A \n");
  120. sqlstr.append(" ,PUB0120T B \n");
  121. sqlstr.append(" WHERE A.PUREMPNO = B.ACCT_ID \n");
  122. sqlstr.append(" AND A.ONBID_YN = 'Y' \n");
  123. sqlstr.append(" AND A.STATUS_CD = '04' \n");
  124. sqlstr.append(" AND DEMANDED_KIND != 'O' \n");
  125. sqlstr.append(" AND TO_CHAR(BID_TO_DT, 'YYYYMMDD') = TO_CHAR(SYSDATE, 'YYYYMMDD') \n");
  126. search.setStatement(sqlstr.toString());
  127. rowSet = search.execute();
  128. }
  129. catch(WAFSQLException se) {
  130. Logger.err.println("SQL : \n" + se.getStatement());
  131. Logger.err.println("PARAM : \n" + se.getParameter());
  132. throw se;
  133. }
  134. finally {
  135. if( rowSet == null ) rowSet = new RowSetImpl();
  136. return rowSet;
  137. }
  138. }
  139. private RowSet getContThread() throws Exception{
  140. Search search = new SearchImpl();
  141. RowSet rowSet = new RowSetImpl();
  142. StringBuffer sqlstr = new StringBuffer();
  143. try {
  144. //하도급 지급보증 발급. 계약일로 부터 20일 .
  145. sqlstr.append("SELECT A.DEPT_CD \n");
  146. sqlstr.append(" ,A.DEPT_NAME \n");
  147. sqlstr.append(" ,A.ORD_DOC_NO \n");
  148. sqlstr.append(" ,A.CST_DOC_NAME \n");
  149. sqlstr.append(" ,TO_CHAR(A.ORD_CON_DATE, 'YYYY-MM-DD') ORD_CON_DATE \n");
  150. sqlstr.append(" ,A.CON_CHARGE_ID \n");
  151. sqlstr.append(" ,B.USER_NAME \n");
  152. sqlstr.append(" ,B.HAND_TEL_NO \n");
  153. sqlstr.append(" ,B.E_MAIL \n");
  154. sqlstr.append(" ,C.VENDCD \n");
  155. sqlstr.append(" ,C.MEMBER_NAME \n");
  156. sqlstr.append(" ,D.PUR_CONT_MOD_ID \n");
  157. sqlstr.append(" FROM PUR2000T A \n");
  158. sqlstr.append(" ,PUB0120T B \n");
  159. sqlstr.append(" ,CONT_PUR_SUPP C \n");
  160. sqlstr.append(" ,CONT_PUR_WARR D \n");
  161. sqlstr.append(" WHERE A.CON_CHARGE_ID = B.ACCT_ID \n");
  162. sqlstr.append(" AND A.PUR_CONT_MOD_ID = C.PUR_CONT_MOD_ID \n");
  163. sqlstr.append(" AND A.PUR_CONT_MOD_ID = D.PUR_CONT_MOD_ID(+) \n");
  164. sqlstr.append(" AND A.STATUS_CD = '50' \n");
  165. sqlstr.append(" AND A.TEMPLATE_CD = '15' \n");
  166. sqlstr.append(" AND C.SIGN_SEQ = 2 \n");
  167. sqlstr.append(" AND D.WARR_GUBUN(+) = '2' \n");
  168. sqlstr.append(" AND D.PUR_CONT_MOD_ID IS NULL \n");
  169. sqlstr.append(" AND TO_DATE(A.ORD_CON_DATE) + 19 > SYSDATE \n");//계약일 20일이후 부터 . 금액제한 확인
  170. search.setStatement(sqlstr.toString());
  171. rowSet = search.execute();
  172. }
  173. catch(WAFSQLException se) {
  174. Logger.err.println("SQL : \n" + se.getStatement());
  175. Logger.err.println("PARAM : \n" + se.getParameter());
  176. throw se;
  177. }
  178. finally {
  179. if( rowSet == null ) rowSet = new RowSetImpl();
  180. return rowSet;
  181. }
  182. }
  183. private RowSet getMailThread() throws Exception{
  184. Search search = new SearchImpl();
  185. RowSet rowSet = new RowSetImpl();
  186. StringBuffer sqlstr = new StringBuffer();
  187. try {
  188. //발주의뢰, 변경계약 메일발송
  189. sqlstr.append("SELECT A.MAIL_ID --발주의뢰 \n");
  190. sqlstr.append(" ,A.SEND_GB \n");
  191. sqlstr.append(" ,GET_DEPT_NM(B.DEPT_CD) DEPT_NM \n");
  192. sqlstr.append(" ,B.DEMANDED_NO DEM_NO \n");
  193. sqlstr.append(" ,B.DEMANDED_TITLE DEM_TITLE \n");
  194. sqlstr.append(" ,A.ACCT_ID \n");
  195. sqlstr.append(" ,A.ADDR E_MAIL \n");
  196. sqlstr.append(" FROM T_MAIL A \n");
  197. sqlstr.append(" ,PMM_DEMANDED_REQUEST B \n");
  198. sqlstr.append(" WHERE A.DEM_ID = B.DEMANDED_ID \n");
  199. sqlstr.append(" AND A.ATTR_1 = 0 \n");
  200. sqlstr.append(" AND A.SEND_GB = 'ORD' \n");
  201. sqlstr.append(" UNION ALL --외주변경 \n");
  202. sqlstr.append("SELECT A.MAIL_ID \n");
  203. sqlstr.append(" ,A.SEND_GB \n");
  204. sqlstr.append(" ,B.DEPT_NAME DEPT_NM \n");
  205. sqlstr.append(" ,B.CON_DOC_NO DEM_NO \n");
  206. sqlstr.append(" ,B.BUILD_NAME DEM_TITLE \n");
  207. sqlstr.append(" ,A.ACCT_ID \n");
  208. sqlstr.append(" ,A.ADDR E_MAIL \n");
  209. sqlstr.append(" FROM T_MAIL A \n");
  210. sqlstr.append(" ,SUB2000T B \n");
  211. sqlstr.append(" WHERE A.DEM_ID = B.SUB_CONT_MOD_ID \n");
  212. sqlstr.append(" AND A.ATTR_1 = 0 \n");
  213. sqlstr.append(" AND A.SEND_GB = 'OCHG' \n");
  214. sqlstr.append(" UNION ALL --구매변경 \n");
  215. sqlstr.append("SELECT A.MAIL_ID \n");
  216. sqlstr.append(" ,A.SEND_GB \n");
  217. sqlstr.append(" ,C.DEPT_NAME DEPT_NM \n");
  218. sqlstr.append(" ,C.ORD_DOC_NO DEM_NO \n");
  219. sqlstr.append(" ,C.CST_DOC_NAME DEM_TITLE \n");
  220. sqlstr.append(" ,D.ACCT_ID \n");
  221. sqlstr.append(" ,D.E_MAIL E_MAIL \n");
  222. sqlstr.append(" FROM T_MAIL A \n");
  223. sqlstr.append(" ,PMM_DEMANDED_REQUEST B \n");
  224. sqlstr.append(" ,PUR1000T C \n");
  225. sqlstr.append(" ,PUB0120T D \n");
  226. sqlstr.append(" WHERE A.DEM_ID = B.DEMANDED_ID \n");
  227. sqlstr.append(" AND B.DEMANDED_NO = C.REQ_DOC_NO \n");
  228. sqlstr.append(" AND C.CON_CHARGE_ID = D.ACCT_ID \n");
  229. sqlstr.append(" AND A.ATTR_1 = 0 \n");
  230. sqlstr.append(" AND A.SEND_GB = 'PCHG' \n");
  231. search.setStatement(sqlstr.toString());
  232. rowSet = search.execute();
  233. }
  234. catch(WAFSQLException se) {
  235. Logger.err.println("SQL : \n" + se.getStatement());
  236. Logger.err.println("PARAM : \n" + se.getParameter());
  237. throw se;
  238. }
  239. finally {
  240. if( rowSet == null ) rowSet = new RowSetImpl();
  241. return rowSet;
  242. }
  243. }
  244. private void updateMail(Connection connection,RowSet rowTread) throws Exception{
  245. Persistent persistent = new PersistentImpl(connection);
  246. StringBuffer sqlstr = new StringBuffer();
  247. Row row = new RowImpl();
  248. try {
  249. sqlstr.append("UPDATE T_MAIL \n");
  250. sqlstr.append(" SET ATTR_1 = 1 \n");
  251. sqlstr.append(" ,UPD_DATE = SYSDATE \n");
  252. sqlstr.append(" WHERE MAIL_ID = ? \n");
  253. persistent.setStatement(sqlstr.toString());
  254. for ( int i = 0 ; i < rowTread.size() ; i ++ ) {
  255. row = rowTread.getRow(i);
  256. persistent.addParameter(row.get("MAIL_ID"));
  257. persistent.execute();
  258. persistent.clearParameters();
  259. }
  260. }
  261. catch(WAFSQLException se) {
  262. Logger.err.println("SQL : \n" + se.getStatement());
  263. Logger.err.println("PARAM : \n" + se.getParameter());
  264. throw se;
  265. }
  266. }
  267. private void sendBidMail(RowSet rowTread) throws Exception{
  268. try {
  269. HandlerStorage Stroage = new HandlerStorage();
  270. MessageSend messageSend = new MessageSend(Stroage);
  271. StringBuffer mailtitle = new StringBuffer();
  272. StringBuffer mailtitlein = new StringBuffer();
  273. StringBuffer mailContent = new StringBuffer();
  274. Row row = new RowImpl();
  275. mailtitle.append("*[알림]금일 입찰마감 안내입니다. ");
  276. mailtitlein.append("*[알림]금일 입찰마감 안내입니다. ");
  277. for ( int i = 0 ; i < rowTread.size() ; i ++ ) {
  278. row = rowTread.getRow(i);
  279. mailContent.append("<font style='width:auto; font-size:12px; line-height:18px; text-align:left;'>");
  280. mailContent.append("금일 입찰이 마감되니 확인 후 조치하여 주시기 바랍니다.<br>");
  281. mailContent.append("<br>");
  282. mailContent.append("프로젝트: " + row.get("DEPT_NM") + " <br>");
  283. mailContent.append("입찰번호: " + row.get("BID_NO") + "-" + row.get("BID_DEG") + " <br>");
  284. mailContent.append("입찰명: " + row.get("BID_MASTER_NM") + " <br>");
  285. mailContent.append("마감시간: " + row.get("BID_TO_DT") + " <br>");
  286. mailContent.append("<br>");
  287. mailContent.append("</font>");
  288. if (row.get("E_MAIL").length() > 4 ){
  289. messageSend.sendEmail( row.get("E_MAIL"), "partner@sgc.co.kr", mailtitle.toString(), mailtitlein.toString(), mailContent, "N");
  290. }
  291. mailContent = new StringBuffer();
  292. }
  293. }
  294. catch(Exception e) {
  295. Logger.err.println("CommonMailThreadBiz.sendBidMail() 실행중 오류가 발생 했습니다.\\n" + e.getMessage());
  296. throw e;
  297. }
  298. }
  299. private void sendContMail(RowSet rowTread){
  300. try {
  301. HandlerStorage Stroage = new HandlerStorage();
  302. MessageSend messageSend = new MessageSend(Stroage);
  303. StringBuffer mailtitle = new StringBuffer();
  304. StringBuffer mailtitlein = new StringBuffer();
  305. StringBuffer mailContent = new StringBuffer();
  306. Row row = new RowImpl();
  307. mailtitle.append("*[알림]하도급 지급보증 발급을 처리해 주십시요.");
  308. mailtitlein.append("*[알림]하도급 지급보증 발급을 처리해 주십시요.");
  309. for ( int i = 0 ; i < rowTread.size() ; i ++ ) {
  310. row = rowTread.getRow(i);
  311. mailContent.append("<font style='width:auto; font-size:12px; line-height:18px; text-align:left;'>");
  312. mailContent.append("건설공사 표준하도급 계약이후 하도급지급보증 발급이 처리되지 않았습니다. 확인 후 조치하여 주시기 바랍니다.<br>");
  313. mailContent.append("<br>");
  314. mailContent.append("프로젝트: " + row.get("DEPT_NAME") + " <br>");
  315. mailContent.append("계약번호: " + row.get("ORD_DOC_NO") + " <br>");
  316. mailContent.append("계약명: " + row.get("CST_DOC_NAME") + " <br>");
  317. mailContent.append("거래처: " + row.get("MEMBER_NAME") + " <br>");
  318. mailContent.append("계약일자: " + row.get("ORD_CON_DATE") + " <br>");
  319. mailContent.append(row.get("E_MAIL"));
  320. mailContent.append("<br>");
  321. mailContent.append("</font>");
  322. if (row.get("E_MAIL").length() > 4 ){
  323. messageSend.sendEmail( row.get("E_MAIL"), "partner@sgc.co.kr", mailtitle.toString(), mailtitlein.toString(), mailContent, "N");
  324. }
  325. mailContent = new StringBuffer();
  326. }
  327. }
  328. catch(Exception e) {
  329. Logger.err.println("doBiz() 실행중 오류가 발생 했습니다.\\n" + e.getMessage());
  330. }
  331. }
  332. private void sendMail(RowSet rowTread){
  333. try {
  334. HandlerStorage Stroage = new HandlerStorage();
  335. MessageSend messageSend = new MessageSend(Stroage);
  336. StringBuffer mailtitle = new StringBuffer();
  337. StringBuffer mailtitlein = new StringBuffer();
  338. StringBuffer mailContent = new StringBuffer();
  339. Row row = new RowImpl();
  340. for ( int i = 0 ; i < rowTread.size() ; i ++ ) {
  341. row = new RowImpl();
  342. row = rowTread.getRow(i);
  343. if (row.get("SEND_GB").equals("ORD")){
  344. mailtitle.append("*[알림]발주의뢰가 등록 되었습니다. ");
  345. mailtitlein.append("*[알림]발주의뢰가 등록 되었습니다. ");
  346. row = rowTread.getRow(i);
  347. mailContent.append("<font style='width:auto; font-size:12px; line-height:18px; text-align:left;'>");
  348. mailContent.append("발주의뢰가 등록되었습니다. <br>");
  349. mailContent.append("<br>");
  350. mailContent.append("프로젝트: " + row.get("DEPT_NM") + " <br>");
  351. mailContent.append("발주의뢰번호: " + row.get("DEM_NO") + " <br>");
  352. mailContent.append("발주의뢰명: " + row.get("DEM_TITLE") + " <br>");
  353. mailContent.append("전자조달시스템의 발주의뢰 접수 확인 바랍니다. <br>");
  354. mailContent.append("<br>");
  355. mailContent.append("</font>");
  356. if (row.get("E_MAIL").length() > 4 ){
  357. messageSend.sendEmail( row.get("E_MAIL"), "partner@sgc.co.kr", mailtitle.toString(), mailtitlein.toString(), mailContent, "N");
  358. }
  359. mailContent = new StringBuffer();
  360. mailtitle = new StringBuffer();
  361. mailtitlein = new StringBuffer();
  362. }else if(row.get("SEND_GB").equals("PCHG")){
  363. mailtitle.append("*[알림]변경계약이 등록 되었습니다. ");
  364. mailtitlein.append("*[알림]변경계약이 등록 되었습니다. ");
  365. row = rowTread.getRow(i);
  366. mailContent.append("<font style='width:auto; font-size:12px; line-height:18px; text-align:left;'>");
  367. mailContent.append("변경계약 요청건이 있습니다. <br>");
  368. mailContent.append("<br>");
  369. mailContent.append("프로젝트: " + row.get("DEPT_NM") + " <br>");
  370. mailContent.append("계약번호: " + row.get("DEM_NO") + " <br>");
  371. mailContent.append("계약명: " + row.get("DEM_TITLE") + " <br>");
  372. mailContent.append("전자조달시스템의 변경계약접수 확인 바랍니다. <br>");
  373. mailContent.append("<br>");
  374. mailContent.append("</font>");
  375. if (row.get("E_MAIL").length() > 4 ){
  376. messageSend.sendEmail( row.get("E_MAIL"), "partner@sgc.co.kr", mailtitle.toString(), mailtitlein.toString(), mailContent, "N");
  377. }
  378. mailContent = new StringBuffer();
  379. mailtitle = new StringBuffer();
  380. mailtitlein = new StringBuffer();
  381. }else if(row.get("SEND_GB").equals("OCHG")){
  382. mailtitle.append("*[알림]변경계약이 등록 되었습니다. ");
  383. mailtitlein.append("*[알림]변경계약이 등록 되었습니다. ");
  384. row = rowTread.getRow(i);
  385. mailContent.append("<font style='width:auto; font-size:12px; line-height:18px; text-align:left;'>");
  386. mailContent.append("변경계약 요청건이 있습니다. <br>");
  387. mailContent.append("<br>");
  388. mailContent.append("프로젝트: " + row.get("DEPT_NM") + " <br>");
  389. mailContent.append("계약번호: " + row.get("DEM_NO") + " <br>");
  390. mailContent.append("계약명: " + row.get("DEM_TITLE") + " <br>");
  391. mailContent.append("전자조달시스템의 변경계약접수 확인 바랍니다. <br>");
  392. mailContent.append("<br>");
  393. mailContent.append("</font>");
  394. if (row.get("E_MAIL").length() > 4 ){
  395. messageSend.sendEmail( row.get("E_MAIL"), "partner@sgc.co.kr", mailtitle.toString(), mailtitlein.toString(), mailContent, "N");
  396. }
  397. mailContent = new StringBuffer();
  398. mailtitle = new StringBuffer();
  399. mailtitlein = new StringBuffer();
  400. }
  401. }
  402. }
  403. catch(Exception e) {
  404. Logger.err.println("doBiz() 실행중 오류가 발생 했습니다.\\n" + e.getMessage());
  405. }
  406. }
  407. private RowSet getChgContThread() throws Exception{
  408. Search search = new SearchImpl();
  409. RowSet rowSet = new RowSetImpl();
  410. StringBuffer sqlstr = new StringBuffer();
  411. try {
  412. //구매변경계약
  413. sqlstr.append(" SELECT A.DEM_ID DEMANDED_ID \n");
  414. sqlstr.append(" ,MAX(C.PUR_CONT_MOD_ID) PUR_CONT_MOD_ID \n");
  415. sqlstr.append(" FROM T_MAIL A \n");
  416. sqlstr.append(" ,PMM_DEMANDED_REQUEST B \n");
  417. sqlstr.append(" ,PUR2000T C \n");
  418. sqlstr.append(" WHERE A.DEM_ID = B.DEMANDED_ID \n");
  419. sqlstr.append(" AND B.DEMANDED_NO = C.REQ_DOC_NO \n");
  420. sqlstr.append(" AND A.SEND_GB = 'PCHG' \n");
  421. sqlstr.append(" AND A.ATTR_1 = 0 \n");
  422. sqlstr.append(" AND C.STATUS_CD = '50' \n");
  423. sqlstr.append(" AND NVL(DIV_PO_YN,'N') != 'Y' \n"); //단가계약 아닌자료
  424. sqlstr.append(" GROUP BY A.DEM_ID \n");
  425. //단가계약 추가 2019.04.15
  426. sqlstr.append(" UNION ALL \n");
  427. sqlstr.append(" SELECT MAX(A.DEM_ID) DEMANDED_ID \n");
  428. sqlstr.append(" ,MAX(C.PUR_CONT_MOD_ID) PUR_CONT_MOD_ID \n");
  429. sqlstr.append(" FROM T_MAIL A \n");
  430. sqlstr.append(" ,PMM_DEMANDED_REQUEST B \n");
  431. sqlstr.append(" ,PUR2000T C \n");
  432. sqlstr.append(" WHERE A.DEM_ID = B.DEMANDED_ID \n");
  433. sqlstr.append(" AND B.DEMANDED_NO = C.REQ_DOC_NO \n");
  434. sqlstr.append(" AND A.SEND_GB = 'PCHG' \n");
  435. sqlstr.append(" AND A.ATTR_1 = 0 \n");
  436. sqlstr.append(" AND C.STATUS_CD = '50' \n");
  437. sqlstr.append(" AND DIV_PO_YN = 'Y' \n"); //단가계약 자료
  438. sqlstr.append(" GROUP BY C.PUR_CONT_ID \n");
  439. search.setStatement(sqlstr.toString());
  440. rowSet = search.execute();
  441. }
  442. catch(WAFSQLException se) {
  443. Logger.err.println("SQL : \n" + se.getStatement());
  444. Logger.err.println("PARAM : \n" + se.getParameter());
  445. throw se;
  446. }
  447. finally {
  448. if( rowSet == null ) rowSet = new RowSetImpl();
  449. return rowSet;
  450. }
  451. }
  452. private String getMaxPurCntId() {
  453. Search search = new SearchImpl();
  454. String sqlstr = "";
  455. try {
  456. sqlstr = "SELECT PUR2000T_S.NEXTVAL AS MAX_PUR_CONT_MOD_ID \n"
  457. + " FROM DUAL\n";
  458. search.setStatement(sqlstr);
  459. return search.execute().getRow(0).get("MAX_PUR_CONT_MOD_ID");
  460. }
  461. catch(Exception e) {
  462. WAFLogger.error(this.getClass().getName() + " --> getMaxPurCntId() : " + e.getMessage());
  463. WAFLogger.error("SQL : " + search.getStatement());
  464. WAFLogger.error(e);
  465. return null;
  466. }
  467. }
  468. public boolean addChangeContPur(Connection connection, String DEMANDED_ID, String maxPurContid, String prePurContid) throws Exception {
  469. Persistent persistent = new PersistentImpl(connection);
  470. StrBuffer sqlstr = new StrBuffer();
  471. try {
  472. sqlstr.append(" INSERT INTO PUR2000T \n");
  473. sqlstr.append(" ( PUR_CONT_MOD_ID \n");
  474. sqlstr.append(" , PUR_CONT_ID \n");
  475. sqlstr.append(" , MOD_NO \n");
  476. sqlstr.append(" , MOD_GB \n");
  477. sqlstr.append(" , MOD_RSN \n");
  478. sqlstr.append(" , MOD_REQ_DATE \n");
  479. sqlstr.append(" , MOD_CORP_RSN \n");
  480. sqlstr.append(" , DEPT_CD \n");
  481. sqlstr.append(" , DEPT_NAME \n");
  482. sqlstr.append(" , CON_GB \n");
  483. sqlstr.append(" , ORD_DOC_NO \n");
  484. sqlstr.append(" , CST_DOC_NAME \n");
  485. sqlstr.append(" , REQ_DEPT_CD \n");
  486. sqlstr.append(" , REQ_DATE \n");
  487. sqlstr.append(" , REQ_USERID \n");
  488. sqlstr.append(" , REQ_USERNM \n");
  489. sqlstr.append(" , REQ_DOC_NO \n");
  490. sqlstr.append(" , CST_DATE \n");
  491. sqlstr.append(" , CON_IN_DATE \n");
  492. sqlstr.append(" , ELEC_CON_YN \n");
  493. sqlstr.append(" , ORD_CON_DATE \n");
  494. sqlstr.append(" , PAY_COND_GB \n");
  495. sqlstr.append(" , PAY_CONTENT \n");
  496. sqlstr.append(" , LEAD_COND_GB \n");
  497. sqlstr.append(" , LEAD_PLACE \n");
  498. sqlstr.append(" , CORP_ID \n");
  499. sqlstr.append(" , ORD_START_DATE \n");
  500. sqlstr.append(" , ORD_END_DATE \n");
  501. sqlstr.append(" , ORD_SEND_DATE \n");
  502. sqlstr.append(" , ORD_AMT \n");
  503. sqlstr.append(" , ORD_SUPPLY_AMT \n");
  504. sqlstr.append(" , ORD_SURTAX_AMT \n");
  505. sqlstr.append(" , PREPAY_AMT \n");
  506. sqlstr.append(" , MID_AMT \n");
  507. sqlstr.append(" , RMDR_AMT \n");
  508. sqlstr.append(" , PREPAY_EXE_YN \n");
  509. sqlstr.append(" , PREPAY_GUAR_AMT \n");
  510. sqlstr.append(" , CON_GUAR_AMT_RATE \n");
  511. sqlstr.append(" , CON_GUAR_AMT \n");
  512. sqlstr.append(" , CON_GUAR_TERM \n");
  513. sqlstr.append(" , DEF_GUAR_AMT_RATE \n");
  514. sqlstr.append(" , DEF_GUAR_AMT \n");
  515. sqlstr.append(" , DEF_GUAR_TERMS \n");
  516. sqlstr.append(" , DEF_GUAR_TERMS_TXT \n");
  517. sqlstr.append(" , DEF_GUAR_TERMS2 \n");
  518. sqlstr.append(" , DEF_GUAR_TERMS_TXT2 \n");
  519. sqlstr.append(" , DEL_RATE_GB \n");
  520. sqlstr.append(" , CON_CHARGE_ID \n");
  521. sqlstr.append(" , CON_CHARGE_NAME \n");
  522. sqlstr.append(" , CON_DISPLAY_TXT \n");
  523. sqlstr.append(" , ADD_FILE_KIND \n");
  524. sqlstr.append(" , CORP_SIGN_DATE \n");
  525. sqlstr.append(" , COMPANY_SIGN_DATE \n");
  526. sqlstr.append(" , ENT_CLS_YN \n");
  527. sqlstr.append(" , PAY_GROUP \n");
  528. sqlstr.append(" , PAYMENT_TERMS \n");
  529. sqlstr.append(" , ACCT_GB \n");
  530. sqlstr.append(" , GUA_GB \n");
  531. sqlstr.append(" , CURRENCY_GB \n");
  532. sqlstr.append(" , PAY_ITEM \n");
  533. sqlstr.append(" , COST_CODE \n");
  534. sqlstr.append(" , COST_TYPE \n");
  535. sqlstr.append(" , ONSHORE_CD \n");
  536. sqlstr.append(" , CONTRACTID \n");
  537. sqlstr.append(" , G_ID \n");
  538. sqlstr.append(" , P_ID \n");
  539. sqlstr.append(" , PREPAY_AMT_RATE \n");
  540. sqlstr.append(" , PREPAY_PAYMENT_NM \n");
  541. sqlstr.append(" , MID_AMT_RATE \n");
  542. sqlstr.append(" , MID_PAYMENT_NM \n");
  543. sqlstr.append(" , MID_PAYMENT_TXT \n");
  544. sqlstr.append(" , RMDR_AMT_RATE \n");
  545. sqlstr.append(" , RMDR_PAYMENT_NM \n");
  546. sqlstr.append(" , RMDR_PAYMENT_TXT \n");
  547. sqlstr.append(" , PREPAY_GUAR_AMT_RATE \n");
  548. sqlstr.append(" , OVERSEA_GB \n");
  549. sqlstr.append(" , PUR_LIST_GB \n");
  550. sqlstr.append(" , CON_RUN_STS \n");
  551. sqlstr.append(" , BID_NO \n");
  552. sqlstr.append(" , BID_DEG \n");
  553. sqlstr.append(" , STATUS_CD \n");
  554. sqlstr.append(" , TEMPLATE_CD \n");
  555. sqlstr.append(" , MODI_REQ_REASON \n");
  556. sqlstr.append(" , MODI_REQ_DT \n");
  557. sqlstr.append(" , CON_CLS_YN \n");
  558. sqlstr.append(" , PAY_DIV \n");
  559. sqlstr.append(" , DEM_ID \n");
  560. sqlstr.append(" , IN_SPE_INFO \n");
  561. sqlstr.append(" , IN_CHG_INFO \n");
  562. sqlstr.append(" , FRST_CON_AMT \n");
  563. sqlstr.append(" , FRST_EXE_AMT \n");
  564. sqlstr.append(" , CHG_CON_AMT \n");
  565. sqlstr.append(" , CHG_EXE_AMT \n");
  566. sqlstr.append(" , CRE_BY \n");
  567. sqlstr.append(" , CRE_DATE \n");
  568. sqlstr.append(" , DIV_PO_YN ,ERP_NO_ECUT ) \n"); //2019.04.26 신용길부장님 요청. 같은계약은 ERP_NO_ECUT동일하게.
  569. sqlstr.append(" SELECT ? \n");
  570. sqlstr.append(" , A.PUR_CONT_ID \n");
  571. sqlstr.append(" , MOD_NO + 1 \n");
  572. sqlstr.append(" , B.MOD_GB \n");
  573. sqlstr.append(" , NULL \n");
  574. sqlstr.append(" , NULL \n");
  575. sqlstr.append(" , NULL \n");
  576. sqlstr.append(" , A.DEPT_CD \n");
  577. sqlstr.append(" , A.DEPT_NAME \n");
  578. sqlstr.append(" , A.CON_GB \n");
  579. sqlstr.append(" , A.ORD_DOC_NO \n");
  580. sqlstr.append(" , A.CST_DOC_NAME \n");
  581. sqlstr.append(" , A.REQ_DEPT_CD \n");
  582. sqlstr.append(" , A.REQ_DATE \n");
  583. sqlstr.append(" , A.REQ_USERID \n");
  584. sqlstr.append(" , A.REQ_USERNM \n");
  585. sqlstr.append(" , A.REQ_DOC_NO \n");
  586. sqlstr.append(" , A.CST_DATE \n");
  587. sqlstr.append(" , A.CON_IN_DATE \n");
  588. sqlstr.append(" , A.ELEC_CON_YN \n");
  589. sqlstr.append(" , A.ORD_CON_DATE \n");
  590. sqlstr.append(" , A.PAY_COND_GB \n");
  591. sqlstr.append(" , A.PAY_CONTENT \n");
  592. sqlstr.append(" , A.LEAD_COND_GB \n");
  593. sqlstr.append(" , A.LEAD_PLACE \n");
  594. sqlstr.append(" , A.CORP_ID \n");
  595. sqlstr.append(" , A.ORD_START_DATE \n");
  596. sqlstr.append(" , TO_DATE(B.AFT_CONT_DATE,'YYYYMMDD') AS ORD_END_DATE \n");
  597. sqlstr.append(" , A.ORD_SEND_DATE \n");
  598. sqlstr.append(" , CASE WHEN A.ORD_SURTAX_AMT > 0 THEN SUM_ITEM_AMT + TRUNC(SUM_ITEM_AMT / 10, F_GET_CURRENCY_DIGIT(A.CURRENCY_GB)) -- 발주계약금액 \n");
  599. sqlstr.append(" ELSE SUM_ITEM_AMT END ORD_AMT -- 발주계약금액 \n");
  600. sqlstr.append(" , SUM_ITEM_AMT \n");
  601. sqlstr.append(" , CASE WHEN A.ORD_SURTAX_AMT > 0 THEN TRUNC(SUM_ITEM_AMT / 10,F_GET_CURRENCY_DIGIT(A.CURRENCY_GB)) -- 부가세 \n");
  602. sqlstr.append(" ELSE 0 END ORD_SURTAX_AMT -- 부가세 \n");
  603. sqlstr.append(" ,TRUNC(SUM_ITEM_AMT * (PREPAY_AMT_RATE / 100), F_GET_CURRENCY_DIGIT(A.CURRENCY_GB)) PREPAY_AMT -- 선급금 \n");
  604. sqlstr.append(" ,TRUNC(SUM_ITEM_AMT * (MID_AMT_RATE / 100),F_GET_CURRENCY_DIGIT(A.CURRENCY_GB)) MID_AMT -- 중도금 \n");
  605. sqlstr.append(" ,TRUNC(SUM_ITEM_AMT * (RMDR_AMT_RATE / 100),F_GET_CURRENCY_DIGIT(A.CURRENCY_GB)) RMDR_AMT -- 잔금 \n");
  606. sqlstr.append(" , A.PREPAY_EXE_YN \n");
  607. sqlstr.append(" , A.PREPAY_GUAR_AMT \n");
  608. sqlstr.append(" , A.CON_GUAR_AMT_RATE \n");
  609. sqlstr.append(" , A.CON_GUAR_AMT \n");
  610. sqlstr.append(" , A.CON_GUAR_TERM \n");
  611. sqlstr.append(" , A.DEF_GUAR_AMT_RATE \n");
  612. sqlstr.append(" , A.DEF_GUAR_AMT \n");
  613. sqlstr.append(" , A.DEF_GUAR_TERMS \n");
  614. sqlstr.append(" , A.DEF_GUAR_TERMS_TXT \n");
  615. sqlstr.append(" , A.DEF_GUAR_TERMS2 \n");
  616. sqlstr.append(" , A.DEF_GUAR_TERMS_TXT2 \n");
  617. sqlstr.append(" , A.DEL_RATE_GB \n");
  618. sqlstr.append(" , A.CON_CHARGE_ID \n");
  619. sqlstr.append(" , A.CON_CHARGE_NAME \n");
  620. sqlstr.append(" , A.CON_DISPLAY_TXT \n");
  621. sqlstr.append(" , A.ADD_FILE_KIND \n");
  622. sqlstr.append(" , A.CORP_SIGN_DATE \n");
  623. sqlstr.append(" , A.COMPANY_SIGN_DATE \n");
  624. sqlstr.append(" , A.ENT_CLS_YN \n");
  625. sqlstr.append(" , A.PAY_GROUP \n");
  626. sqlstr.append(" , A.PAYMENT_TERMS \n");
  627. sqlstr.append(" , A.ACCT_GB \n");
  628. sqlstr.append(" , A.GUA_GB \n");
  629. sqlstr.append(" , A.CURRENCY_GB \n");
  630. sqlstr.append(" , A.PAY_ITEM \n");
  631. sqlstr.append(" , A.COST_CODE \n");
  632. sqlstr.append(" , A.COST_TYPE \n");
  633. sqlstr.append(" , A.ONSHORE_CD \n");
  634. sqlstr.append(" , A.CONTRACTID \n");
  635. sqlstr.append(" , A.G_ID \n");
  636. sqlstr.append(" , A.P_ID \n");
  637. sqlstr.append(" , A.PREPAY_AMT_RATE \n");
  638. sqlstr.append(" , A.PREPAY_PAYMENT_NM \n");
  639. sqlstr.append(" , A.MID_AMT_RATE \n");
  640. sqlstr.append(" , A.MID_PAYMENT_NM \n");
  641. sqlstr.append(" , A.MID_PAYMENT_TXT \n");
  642. sqlstr.append(" , A.RMDR_AMT_RATE \n");
  643. sqlstr.append(" , A.RMDR_PAYMENT_NM \n");
  644. sqlstr.append(" , A.RMDR_PAYMENT_TXT \n");
  645. sqlstr.append(" , A.PREPAY_GUAR_AMT_RATE \n");
  646. sqlstr.append(" , A.OVERSEA_GB \n");
  647. sqlstr.append(" , A.PUR_LIST_GB \n");
  648. sqlstr.append(" , A.CON_RUN_STS \n");
  649. sqlstr.append(" , A.BID_NO \n");
  650. sqlstr.append(" , A.BID_DEG \n");
  651. sqlstr.append(" , '00' \n");
  652. sqlstr.append(" , NULL \n");
  653. sqlstr.append(" , A.MODI_REQ_REASON \n");
  654. sqlstr.append(" , A.MODI_REQ_DT \n");
  655. sqlstr.append(" , 1 \n");
  656. sqlstr.append(" , A.PAY_DIV \n");
  657. sqlstr.append(" , B.DEMANDED_ID \n");
  658. sqlstr.append(" , B.P_REMARK \n");
  659. sqlstr.append(" , B.S_REMARK \n");
  660. sqlstr.append(" , A.CHG_CON_AMT \n");
  661. sqlstr.append(" , B.BEF_BUG_AMT \n");
  662. sqlstr.append(" , A.CHG_CON_AMT \n");
  663. sqlstr.append(" , B.AFT_BUG_AMT \n");
  664. sqlstr.append(" , '11111' \n");
  665. sqlstr.append(" , SYSDATE \n");
  666. sqlstr.append(" , A.DIV_PO_YN,A.ERP_NO_ECUT \n");
  667. sqlstr.append(" FROM PUR2000T A \n");
  668. sqlstr.append(" , PMM_DEMANDED_REQUEST B \n");
  669. sqlstr.append(" , ( SELECT PUR_CONT_MOD_ID \n");
  670. sqlstr.append(" , SUM(ITEM_AMT) AS SUM_ITEM_AMT \n");
  671. sqlstr.append(" FROM CONT_PUR_ITEM \n");
  672. sqlstr.append(" WHERE PUR_CONT_MOD_ID = ? \n");
  673. sqlstr.append(" GROUP BY PUR_CONT_MOD_ID ) C \n");
  674. sqlstr.append(" WHERE A.REQ_DOC_NO = B.DEMANDED_NO \n");
  675. sqlstr.append(" AND A.PUR_CONT_MOD_ID = ? \n");
  676. sqlstr.append(" AND B.DEMANDED_ID = ? \n");
  677. persistent.setStatement(sqlstr.toString());
  678. persistent.addParameter(maxPurContid);
  679. persistent.addParameter(prePurContid);
  680. persistent.addParameter(prePurContid);
  681. persistent.addParameter(DEMANDED_ID);
  682. //System.out.println(sqlstr.toString());
  683. persistent.execute();
  684. return true;
  685. }
  686. catch(Exception e) {
  687. WAFLogger.error(this.getClass().getName() + " --> addChangeContPur() : " + e.getMessage());
  688. WAFLogger.error("SQL : " + sqlstr);
  689. WAFLogger.error(e);
  690. throw e;
  691. }
  692. }
  693. public boolean addChangeContSupport(Connection connection, String PUR_CONT_MOD_ID, String maxPurContid, String prePurContid ) throws Exception {
  694. //WAFLogger.debug("valueObject : " + valueObject);
  695. Persistent persistent = new PersistentImpl(connection);
  696. StrBuffer sqlstr = new StrBuffer();
  697. try {
  698. sqlstr.append("INSERT INTO CONT_PUR_SUPP \n");
  699. sqlstr.append(" ( PUR_CONT_MOD_ID \n");
  700. sqlstr.append(" , CORP_ID \n");
  701. sqlstr.append(" , SIGN_SEQ \n");
  702. sqlstr.append(" , VENDCD \n");
  703. sqlstr.append(" , MEMBER_NAME \n");
  704. sqlstr.append(" , BOSS_NAME \n");
  705. sqlstr.append(" , POST_CODE \n");
  706. sqlstr.append(" , ADDRESS \n");
  707. sqlstr.append(" , TEL_NUM \n");
  708. sqlstr.append(" , MEMBER_SLNO \n");
  709. sqlstr.append(" , USER_NAME \n");
  710. sqlstr.append(" , DIVISION \n");
  711. sqlstr.append(" , POSITION \n");
  712. sqlstr.append(" , HP \n");
  713. sqlstr.append(" , EMAIL \n");
  714. sqlstr.append(" , CRE_BY \n");
  715. sqlstr.append(" , CRE_DATE ) \n");
  716. sqlstr.append("SELECT ? \n");
  717. sqlstr.append(" , A.CORP_ID \n");
  718. sqlstr.append(" , A.SIGN_SEQ \n");
  719. sqlstr.append(" , A.VENDCD \n");
  720. sqlstr.append(" , DECODE(SIGN_SEQ, 2, NVL(B.CORP_KOR, A.MEMBER_NAME), C.CORP_KOR) AS MEMBER_NAME \n");
  721. sqlstr.append(" , DECODE(SIGN_SEQ, 2, NVL(B.REP_NAME, A.BOSS_NAME), C.REP_NAME) AS BOSS_NAME \n");
  722. sqlstr.append(" , DECODE(SIGN_SEQ, 2, NVL(B.POST_NO, A.POST_CODE), C.POST_NO) AS POST_CODE \n");
  723. sqlstr.append(" , DECODE(SIGN_SEQ, 2, NVL(B.ADDRESS, A.ADDRESS), C.ADDRESS) AS ADDRESS \n");
  724. sqlstr.append(" , DECODE(SIGN_SEQ, 2, NVL(B.CORP_TEL, A.TEL_NUM), A.TEL_NUM) AS TEL_NUM \n");
  725. sqlstr.append(" , DECODE(SIGN_SEQ, 2, NVL(B.COPR_NO, A.MEMBER_SLNO), C.COPR_NO) AS MEMBER_SLNO \n");
  726. sqlstr.append(" , A.USER_NAME \n");
  727. sqlstr.append(" , A.DIVISION \n");
  728. sqlstr.append(" , A.POSITION \n");
  729. sqlstr.append(" , A.HP \n");
  730. sqlstr.append(" , A.EMAIL \n");
  731. sqlstr.append(" , '11111' \n");
  732. sqlstr.append(" , SYSDATE \n");
  733. sqlstr.append(" FROM CONT_PUR_SUPP A, SUPP_INFO B , HEAD_OFFICE_INFO C \n");
  734. sqlstr.append(" WHERE A.CORP_ID = B.CORP_ID (+) \n");
  735. sqlstr.append(" AND A.PUR_CONT_MOD_ID= ? \n");
  736. persistent.setStatement(sqlstr.toString());
  737. persistent.addParameter(maxPurContid);
  738. persistent.addParameter(PUR_CONT_MOD_ID);
  739. persistent.execute();
  740. return true;
  741. }
  742. catch(Exception e) {
  743. WAFLogger.error(this.getClass().getName() + " --> addChangeContSupport() : " + e.getMessage());
  744. WAFLogger.error("SQL : " + sqlstr);
  745. WAFLogger.error(e);
  746. throw e;
  747. }
  748. }
  749. /**
  750. * 변경 계약 업체 정보 추가
  751. * @param connection
  752. * @param valueObject
  753. * @throws Exception
  754. */
  755. public boolean addChangeContItem(Connection connection, String demanded_id, String maxPurContid, String prePurContid) throws Exception {
  756. //WAFLogger.debug("valueObject : " + valueObject);
  757. Persistent persistent = new PersistentImpl(connection);
  758. StrBuffer sqlstr = new StrBuffer();
  759. try {
  760. sqlstr.append("INSERT INTO CONT_PUR_ITEM \n");
  761. sqlstr.append(" ( PUR_CONT_MOD_ID \n");
  762. sqlstr.append(" , MATERIAL_CD \n");
  763. sqlstr.append(" , PUR_CONT_ID \n");
  764. sqlstr.append(" , ITEM_NAME \n");
  765. sqlstr.append(" , ITEM_SPEC \n");
  766. sqlstr.append(" , ITEM_UNIT \n");
  767. sqlstr.append(" , ITEM_QTY \n");
  768. sqlstr.append(" , ITEM_PRICE \n");
  769. sqlstr.append(" , ITEM_AMT \n");
  770. sqlstr.append(" , CRE_BY \n");
  771. sqlstr.append(" , CRE_DATE \n");
  772. sqlstr.append(" ) \n");
  773. sqlstr.append("SELECT ? \n");
  774. sqlstr.append(" , B.MATERIAL_CD \n");
  775. sqlstr.append(" , C.PUR_CONT_ID \n");
  776. sqlstr.append(" , D.MATERIAL_NAME AS ITEM_NAME \n");
  777. sqlstr.append(" , D.MATERIAL_SPEC AS ITEM_SPEC \n");
  778. sqlstr.append(" , D.UNIT_KIND AS ITEM_UNIT \n");
  779. sqlstr.append(" , DEMANDED_QTY \n");
  780. sqlstr.append(" , DEMANDED_PRI \n");
  781. sqlstr.append(" , DEMANDED_AMT \n");
  782. sqlstr.append(" , '11111' \n");
  783. sqlstr.append(" , SYSDATE \n");
  784. sqlstr.append(" FROM PMM_DEMANDED_REQUEST A \n");
  785. sqlstr.append(" , PMM_DEMANDED_ITEM B \n");
  786. sqlstr.append(" , PUR2000T C \n");
  787. sqlstr.append(" , PMM_COMM_MATERIAL_MASTER D \n");
  788. sqlstr.append(" ,(SELECT MAX(A1.PUR_CONT_MOD_ID) PUR_CONT_MOD_ID \n");
  789. sqlstr.append(" FROM PUR2000T A1, PMM_DEMANDED_REQUEST B1 \n");
  790. sqlstr.append(" WHERE A1.REQ_DOC_NO = B1.DEMANDED_NO \n");
  791. sqlstr.append(" AND A1.STATUS_CD = '50' \n");
  792. sqlstr.append(" AND B1.DEMANDED_ID = ? ) E \n");
  793. sqlstr.append(" WHERE A.DEMANDED_ID = B.DEMANDED_ID \n");
  794. sqlstr.append(" AND A.DEMANDED_NO = C.REQ_DOC_NO \n");
  795. sqlstr.append(" AND C.PUR_CONT_MOD_ID = E.PUR_CONT_MOD_ID \n");
  796. sqlstr.append(" AND B.MATERIAL_CD = D.MATERIAL_CD \n");
  797. sqlstr.append(" AND A.DEMANDED_ID= ? \n");
  798. persistent.setStatement(sqlstr.toString());
  799. persistent.addParameter(maxPurContid);
  800. persistent.addParameter(demanded_id);
  801. persistent.addParameter(demanded_id);
  802. persistent.execute();
  803. return true;
  804. }
  805. catch(Exception e) {
  806. WAFLogger.error(this.getClass().getName() + " --> addChangeContItem() : " + e.getMessage());
  807. WAFLogger.error("SQL : " + sqlstr);
  808. WAFLogger.error(e);
  809. throw e;
  810. }
  811. }
  812. private RowSet getPurContEndThread() throws Exception{
  813. Search search = new SearchImpl();
  814. RowSet rowSet = new RowSetImpl();
  815. StringBuffer sqlstr = new StringBuffer();
  816. try {
  817. sqlstr.append(" -- 프로젝트명, 계약번호, 계약명, 거래처, 계약기간 \n");
  818. sqlstr.append(" SELECT A.CON_DOC_NO \n");
  819. sqlstr.append(" , A.DEPT_NAME \n");
  820. sqlstr.append(" , A.BUILD_NAME \n");
  821. sqlstr.append(" , A.END_WORK_DATE \n");
  822. sqlstr.append(" , B.MEMBER_NAME \n");
  823. sqlstr.append(" , C.E_MAIL \n");
  824. sqlstr.append(" FROM ( \n");
  825. sqlstr.append(" SELECT A.PUR_CONT_MOD_ID \n");
  826. sqlstr.append(" ,A.REQ_USERID \n");
  827. sqlstr.append(" ,A.ORD_DOC_NO AS CON_DOC_NO \n");
  828. sqlstr.append(" ,A.DEPT_NAME \n");
  829. sqlstr.append(" ,A.CST_DOC_NAME AS BUILD_NAME \n");
  830. sqlstr.append(" ,'~ ' || TO_CHAR(A.ORD_END_DATE, 'YYYY-MM-DD') AS END_WORK_DATE \n");
  831. sqlstr.append(" FROM PUR2000T A \n");
  832. sqlstr.append(" , (SELECT PUR_CONT_ID, MAX(MOD_NO) AS MOD_NO \n");
  833. sqlstr.append(" FROM PUR2000T \n");
  834. sqlstr.append(" WHERE STATUS_CD = '50' \n");
  835. sqlstr.append(" AND PUR_CONT_ID IN (SELECT PUR_CONT_ID FROM PUR2000T WHERE TEMPLATE_CD = '15') -- 건설공사 표준하도급계약서 \n");
  836. sqlstr.append(" GROUP BY PUR_CONT_ID) B \n");
  837. sqlstr.append(" WHERE A.PUR_CONT_ID = B.PUR_CONT_ID \n");
  838. sqlstr.append(" AND A.MOD_NO = B.MOD_NO \n");
  839. sqlstr.append(" AND A.STATUS_CD = '50' -- 계약완료 \n");
  840. sqlstr.append(" AND TO_CHAR(A.ORD_END_DATE, 'YYYY-MM-DD') = TO_CHAR(SYSDATE + 30, 'YYYY-MM-DD')-- 30일 이후 종료 계약 \n");
  841. sqlstr.append(" ) A, CONT_PUR_SUPP B, PUB0120T C \n");
  842. sqlstr.append(" WHERE A.PUR_CONT_MOD_ID = B.PUR_CONT_MOD_ID \n");
  843. sqlstr.append(" AND B.SIGN_SEQ = 2 \n");
  844. sqlstr.append(" AND A.REQ_USERID = C.ACCT_ID \n");
  845. search.setStatement(sqlstr.toString());
  846. rowSet = search.execute();
  847. }
  848. catch(WAFSQLException se) {
  849. Logger.err.println("SQL : \n" + se.getStatement());
  850. Logger.err.println("PARAM : \n" + se.getParameter());
  851. throw se;
  852. }
  853. finally {
  854. if( rowSet == null ) rowSet = new RowSetImpl();
  855. return rowSet;
  856. }
  857. }
  858. private RowSet getOutContEndThread() throws Exception{
  859. Search search = new SearchImpl();
  860. RowSet rowSet = new RowSetImpl();
  861. StringBuffer sqlstr = new StringBuffer();
  862. try {
  863. sqlstr.append(" -- 프로젝트명, 계약번호, 계약명, 거래처, 계약기간 \n");
  864. sqlstr.append(" SELECT A.CON_DOC_NO \n");
  865. sqlstr.append(" , A.DEPT_NAME \n");
  866. sqlstr.append(" , A.BUILD_NAME \n");
  867. sqlstr.append(" , A.END_WORK_DATE \n");
  868. sqlstr.append(" , B.MEMBER_NAME \n");
  869. sqlstr.append(" , C.E_MAIL \n");
  870. sqlstr.append(" FROM ( \n");
  871. sqlstr.append(" SELECT A.SUB_CONT_MOD_ID \n");
  872. sqlstr.append(" ,A.REQ_USERID \n");
  873. sqlstr.append(" ,A.CON_DOC_NO \n");
  874. sqlstr.append(" ,A.DEPT_NAME \n");
  875. sqlstr.append(" ,A.BUILD_NAME \n");
  876. sqlstr.append(" ,'~ ' || TO_CHAR(A.END_WORK_DATE, 'YYYY-MM-DD') AS END_WORK_DATE \n");
  877. sqlstr.append(" FROM SUB2000T A \n");
  878. sqlstr.append(" , (SELECT SUB_CONT_ID, MAX(MOD_NO) AS MOD_NO \n");
  879. sqlstr.append(" FROM SUB2000T \n");
  880. sqlstr.append(" WHERE STATUS_CD = '50' \n");
  881. sqlstr.append(" GROUP BY SUB_CONT_ID) B \n");
  882. sqlstr.append(" WHERE A.SUB_CONT_ID = B.SUB_CONT_ID \n");
  883. sqlstr.append(" AND A.MOD_NO = B.MOD_NO \n");
  884. sqlstr.append(" AND A.STATUS_CD = '50' -- 계약완료 \n");
  885. sqlstr.append(" AND TO_CHAR(A.END_WORK_DATE, 'YYYY-MM-DD') = TO_CHAR(SYSDATE + 30, 'YYYY-MM-DD')-- 30일 이후 종료 계약 \n");
  886. sqlstr.append(" ) A, CONT_OUT_SUPP B, PUB0120T C \n");
  887. sqlstr.append(" WHERE A.SUB_CONT_MOD_ID = B.SUB_CONT_MOD_ID \n");
  888. sqlstr.append(" AND B.SIGN_SEQ = 2 \n");
  889. sqlstr.append(" AND A.REQ_USERID = C.ACCT_ID \n");
  890. search.setStatement(sqlstr.toString());
  891. rowSet = search.execute();
  892. }
  893. catch(WAFSQLException se) {
  894. Logger.err.println("SQL : \n" + se.getStatement());
  895. Logger.err.println("PARAM : \n" + se.getParameter());
  896. throw se;
  897. }
  898. finally {
  899. if( rowSet == null ) rowSet = new RowSetImpl();
  900. return rowSet;
  901. }
  902. }
  903. private void sendContEndMail(RowSet rowTread){
  904. try {
  905. HandlerStorage Stroage = new HandlerStorage();
  906. MessageSend messageSend = new MessageSend(Stroage);
  907. StringBuffer mailtitle = new StringBuffer();
  908. StringBuffer mailtitlein = new StringBuffer();
  909. StringBuffer mailContent = new StringBuffer();
  910. Row row = new RowImpl();
  911. mailtitle.append("*[알림]계약기간 만료 예정");
  912. mailtitlein.append("*[알림]계약기간 만료 예정");
  913. for ( int i = 0 ; i < rowTread.size() ; i ++ ) {
  914. row = rowTread.getRow(i);
  915. mailContent.append("<font style='width:auto; font-size:12px; line-height:18px; text-align:left;'>");
  916. mailContent.append("다음 하도급 계약의 계약기간이 30일 후 만료 예정이오니 ERP에서 변경계약을 요청하시기 바랍니다.<br>");
  917. mailContent.append("<br>");
  918. mailContent.append("1.프로젝트: " + row.get("DEPT_NAME") + " <br>");
  919. mailContent.append("2.계약번호: " + row.get("CON_DOC_NO") + " <br>");
  920. mailContent.append("3.계약명: " + row.get("BUILD_NAME") + " <br>");
  921. mailContent.append("4.계약기간: " + row.get("END_WORK_DATE") + " <br>");
  922. mailContent.append("5.계약업체: " + row.get("MEMBER_NAME") + " <br>");
  923. mailContent.append("6.비고: <br>");
  924. mailContent.append("&nbsp;1)계약기간 만료일에 준공 예정일 경우 해당 없음. <br>");
  925. mailContent.append("&nbsp;2)계약기간이 유효한 계약만 기성 신청가능하므로 실제 준공 예상 시점까지 계약기간 연장 필요. <br>");
  926. mailContent.append("&nbsp;3)eTEC Standard에 따라 변경 계약에 필요한 자료를 ERP에 첨부 후 변경계약 요청. <br>");
  927. mailContent.append("<br>");
  928. mailContent.append("</font>");
  929. if (row.get("E_MAIL").length() > 4 ){
  930. messageSend.sendEmail( row.get("E_MAIL"), "partner@sgc.co.kr", mailtitle.toString(), mailtitlein.toString(), mailContent, "NO_LINK");
  931. }
  932. mailContent = new StringBuffer();
  933. }
  934. }
  935. catch(Exception e) {
  936. Logger.err.println("doBiz() 실행중 오류가 발생 했습니다.\\n" + e.getMessage());
  937. }
  938. }
  939. }