PrebqSignDriver.java 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. /**
  2. * @(#)file PoDeciSignDriver.java
  3. * @(#)author Lee beomgeun
  4. * @(#)version 1.0
  5. * @(#)date Aug 1, 2005
  6. * @(#)since JDK 1.4.2
  7. *
  8. * Copyright (c) www.dcchem.co.kr, Inc.
  9. * All rights reserved.
  10. * This software is the proprietary information of dcchem, Inc.
  11. */
  12. package kr.co.udapsoft.common.commonSign.driver;
  13. import java.sql.CallableStatement;
  14. import java.sql.Connection;
  15. import com.udapsoft.waf.system.HandlerStorage;
  16. import kr.co.hsnc.common.base.WAFLogger;
  17. import kr.co.hsnc.common.logger.Logger;
  18. import kr.co.hsnc.common.sql.Row;
  19. import kr.co.hsnc.common.sql.RowSet;
  20. import kr.co.hsnc.common.sql.RowSetImpl;
  21. import kr.co.hsnc.common.sql.WAFSQLException;
  22. import kr.co.hsnc.common.sql.persistent.Persistent;
  23. import kr.co.hsnc.common.sql.persistent.PersistentImpl;
  24. import kr.co.hsnc.common.sql.search.Search;
  25. import kr.co.hsnc.common.sql.search.SearchImpl;
  26. import kr.co.hsnc.common.sql.util.RowSetUtility;
  27. import kr.co.hsnc.common.util.ValueObject;
  28. import kr.co.udapsoft.common.commonSign.CommonSignInterface;
  29. import kr.co.udapsoft.common.sender.MessageSend;
  30. import oracle.toplink.internal.ox.StrBuffer;
  31. /**
  32. *
  33. * @version 1.0
  34. * @author Beomgeun Lee
  35. */
  36. public class PrebqSignDriver implements CommonSignInterface {
  37. /**
  38. * 테슽 파일
  39. *
  40. */
  41. public PrebqSignDriver() {
  42. super();
  43. }
  44. /*
  45. * (non-Javadoc)
  46. * @see kr.co.udap.ehr.common.sign.SignInterface#doCallSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  47. */
  48. public void doCallSign(Connection connection, ValueObject signDoc) throws Exception {
  49. }
  50. /*
  51. * (non-Javadoc)
  52. * @see kr.co.udap.ehr.common.sign.SignInterface#doStartSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  53. */
  54. public void doStartSign(Connection connection, ValueObject signDoc) throws Exception {
  55. System.out.println("!!doStartSign");
  56. }
  57. /*
  58. * (non-Javadoc)
  59. * @see kr.co.udap.ehr.common.sign.SignInterface#doFirstFinishSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  60. */
  61. public void doFirstFinishSign(Connection connection, ValueObject signDoc) throws Exception {
  62. boolean success = true;
  63. System.out.println("!!doFirstFinishSign");
  64. System.out.println("### 결재 Strart");
  65. updateStatus(connection, signDoc);
  66. ValueObject vo = getDemanded_kind(connection, signDoc);
  67. if(success){
  68. if("Y".equals(vo.get("ONBID_YN"))){
  69. Send(signDoc,"10");
  70. }
  71. //BID_SUPP 견적대상업 체
  72. if("Y".equals(vo.get("TBE_FLAG"))){
  73. callTbeSave(connection,signDoc);
  74. }
  75. }
  76. System.out.println("### 결재 End");
  77. }
  78. /*
  79. * (non-Javadoc)
  80. * @see kr.co.udap.ehr.common.sign.SignInterface#doFinishSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  81. */
  82. public void doFinishSign(Connection connection, ValueObject signDoc) throws Exception {
  83. System.out.println("!!doFinishSign");
  84. }
  85. /*
  86. * (non-Javadoc)
  87. * @see kr.co.udap.ehr.common.sign.SignInterface#doRejectSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  88. */
  89. public void doFirstRejectSign(Connection connection, ValueObject signDoc) throws Exception {
  90. System.out.println("!!반려");
  91. updateStatus(connection, signDoc);
  92. }
  93. /*
  94. * (non-Javadoc)
  95. * @see kr.co.udap.ehr.common.sign.SignInterface#doRejectSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  96. */
  97. public void doRejectSign(Connection connection, ValueObject signDoc) throws Exception {
  98. System.out.println("!!doRejectSign");
  99. }
  100. /*
  101. * (non-Javadoc)
  102. * @see kr.co.udap.ehr.common.sign.SignInterface#doCancelSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  103. */
  104. public void doCancelSign(Connection connection, ValueObject signDoc) throws Exception {
  105. }
  106. /**
  107. * SAC01001 상태값을 업데이트해준다.
  108. * @param connection
  109. * @param valueObject
  110. * @throws Exception
  111. */
  112. public void updateStatus(Connection connection, ValueObject vo) throws Exception {
  113. Persistent persistent = new PersistentImpl(connection);
  114. StringBuffer sqlstr = new StringBuffer();
  115. try {
  116. String status = "";
  117. if(vo.get("SIGN_TYPE").equals("1")){
  118. if(vo.get("SIGN_DECI_CLASS").equals("14")){
  119. status = "04";
  120. }else {
  121. status = "30";
  122. }
  123. }
  124. sqlstr.append(" UPDATE BID_MASTER SET \n");
  125. sqlstr.append(" STATUS_CD = ? \n");
  126. sqlstr.append(" WHERE BID_NO = ? \n");
  127. sqlstr.append(" AND BID_DEG = ? \n");
  128. persistent.setStatement(sqlstr.toString());
  129. persistent.addParameter(status);
  130. persistent.addParameter(vo.get("KEY_COL1"));
  131. persistent.addParameter(vo.get("KEY_COL2"));
  132. persistent.execute();
  133. persistent.clearParameters();
  134. }
  135. catch(Exception e) {
  136. WAFLogger.error(this.getClass().getName() + " --> updateStatus() : " + e.getMessage());
  137. WAFLogger.error(e);
  138. throw e;
  139. }
  140. }
  141. public void Send(ValueObject params, String event) throws Exception {
  142. HandlerStorage Stroage = new HandlerStorage();
  143. MessageSend messageSend = new MessageSend(Stroage);
  144. RowSet SuppInfo = bid_supp_info(params);
  145. ValueObject bid_Master = bid_Master_info(params);
  146. for(int i=0;i < SuppInfo.size();i++){
  147. Row row = SuppInfo.getRow(i);
  148. if(!row.get("CHARGE_EMAIL").isEmpty()){
  149. boolean email = false;
  150. StringBuffer mailtitle = new StringBuffer();
  151. StringBuffer mailtitlein = new StringBuffer();
  152. StringBuffer mailContent = new StringBuffer();
  153. mailtitle.append("* 재 입찰 요청에 대한 공지 메일입니다.");
  154. mailtitlein.append("* 재 입찰 요청에 대한 공지 메일입니다.");
  155. mailContent.append(row.get("VENDOR_NAME")+"님께 아래와 같은 내용으로 견적서 제출을 요청드립니다.<br>협력업체포탈시스템에 접속하시어 견적서작성바랍니다.<br>견적서제출시 법인공인증서가 필요합니다.<br>");
  156. mailContent.append("<font style='width:auto; font-size:12px; line-height:18px; padding:5px; text-align:left;'>");
  157. mailContent.append("<br>");
  158. mailContent.append("1.프로젝트 : " + bid_Master.get("DEPT_NM") + "<br>");
  159. mailContent.append("2.공고번호 : " + bid_Master.get("BID_NO") + "<br>");
  160. mailContent.append("3.공고건명 : " + bid_Master.get("BID_MASTER_NM") + "<br>");
  161. mailContent.append("4.견적마감일시 : " + bid_Master.get("BID_TO_DT_NM") + "<br>");
  162. mailContent.append("5.입찰담당자 : " +bid_Master.get("BUSEO_NM")+" / "+ bid_Master.get("USER_NAME") +" (연락처 : " + bid_Master.get("PO_EMPNM") + ", 이메일 : " + bid_Master.get("E_MAIL") + ")<br>");
  163. mailContent.append("</font>");
  164. email = true;
  165. if(email){
  166. messageSend.sendEmail(row.get("CHARGE_EMAIL"), "partner@sgc.co.kr", mailtitle.toString(), mailtitlein.toString(), mailContent);
  167. }
  168. }
  169. if(!row.get("CHAGE_HP").isEmpty()){
  170. String smsContent = "재입찰서 제출바랍니다.'||CHR(13)||CHR(10)||'협력업체포탈시스템에 접속/확인바랍니다.'||CHR(13)||CHR(10)||'SGC이앤씨(주)";
  171. String from_phon_no = bid_Master.get("PO_EMPNM").replace("-", "");
  172. String to_phon_no = row.get("CHAGE_HP").replace("-", "");
  173. if(!smsContent.isEmpty()){
  174. messageSend.sendSMS(to_phon_no,from_phon_no, bid_Master.get("ACCT_ID"), smsContent); //2015.9.21 재입찰. 입찰담당자
  175. }
  176. }
  177. }
  178. }
  179. /**
  180. * 견적 대상 업체 를 검색하여 리턴
  181. * @param Params
  182. * @return
  183. */
  184. public RowSet bid_supp_info(ValueObject param) {
  185. Search search = new SearchImpl();
  186. RowSet rowSet = new RowSetImpl();
  187. // String sqlstr = "";
  188. StrBuffer sqlstr = new StrBuffer();
  189. try{
  190. sqlstr.append(" SELECT CHARGE_NAME,CHARGE_EMAIL,CHAGE_HP,VENDOR_NAME \n");
  191. sqlstr.append(" FROM BID_SUPP \n");
  192. sqlstr.append(" WHERE BID_NO = ? \n");
  193. sqlstr.append(" AND BID_DEG = ? \n");
  194. search.setStatement(sqlstr.toString());
  195. search.addParameter(param.get("KEY_COL1"));
  196. search.addParameter(param.get("KEY_COL2"));
  197. search.setStatement(sqlstr.toString());
  198. rowSet = search.execute();
  199. }
  200. catch (WAFSQLException se) {
  201. Logger.err.println("SQL : \n" + se.getStatement());
  202. Logger.err.println("PARAM : \n" + se.getParameter());
  203. }
  204. finally {
  205. if(rowSet == null){
  206. rowSet = new RowSetImpl();
  207. }
  208. }
  209. System.out.println("### rowSet size : " + rowSet.size());
  210. return rowSet;
  211. }
  212. /**
  213. * 발주의뢰(외주) 접수를 검색하여 리턴
  214. * @param Params
  215. * @return
  216. */
  217. public ValueObject bid_Master_info(ValueObject param) {
  218. Search search = new SearchImpl();
  219. ValueObject valueobject = null;
  220. RowSet rowSet = new RowSetImpl();
  221. StrBuffer sqlstr = new StrBuffer();
  222. try{
  223. sqlstr.append(" SELECT A.BID_NO, \n");
  224. sqlstr.append(" TO_CHAR(A.BID_TO_DT,'YYYY-MM-DD HH24:MI') AS BID_TO_DT_NM, \n");
  225. sqlstr.append(" A.PO_EMPNM, \n");
  226. sqlstr.append(" A.DEPT_CD, \n");
  227. sqlstr.append(" A.DEPT_NM, \n");
  228. sqlstr.append(" A.BID_MASTER_NM, \n");
  229. sqlstr.append(" B.USER_NAME, \n");
  230. sqlstr.append(" B.E_MAIL, \n");
  231. sqlstr.append(" (SELECT ACCT_ID FROM PUB0120T WHERE USER_SABUN = B.USER_SABUN) AS ACCT_ID, \n");
  232. sqlstr.append(" (SELECT ACC_DEPT_NM FROM PUB0120T WHERE USER_SABUN = B.USER_SABUN) AS BUSEO_NM \n");
  233. sqlstr.append(" FROM BID_MASTER A, PUB0120T B \n");
  234. sqlstr.append(" WHERE A.PUREMPNO = B.ACCT_ID \n");
  235. sqlstr.append(" AND A.BID_NO = ? \n");
  236. sqlstr.append(" AND A.BID_DEG = ? \n");
  237. search.setStatement(sqlstr.toString());
  238. search.addParameter(param.get("KEY_COL1"));
  239. search.addParameter(param.get("KEY_COL2"));
  240. search.setStatement(sqlstr.toString());
  241. rowSet = search.execute();
  242. if( rowSet != null && rowSet.size() > 0 ){
  243. valueobject = RowSetUtility.getValueObject(rowSet.getRow(0));
  244. }
  245. }
  246. catch (WAFSQLException se) {
  247. Logger.err.println("SQL : \n" + se.getStatement());
  248. Logger.err.println("PARAM : \n" + se.getParameter());
  249. }
  250. return valueobject;
  251. }
  252. private ValueObject getDemanded_kind(Connection connection, ValueObject vo) throws Exception{
  253. Search search = new SearchImpl();
  254. RowSet rowSet = new RowSetImpl();
  255. ValueObject valueobject = null;
  256. StringBuffer sqlstr = new StringBuffer();
  257. try {
  258. sqlstr.append(" SELECT DEMANDED_KIND,STATUS_CD,ONBID_YN, TBE_FLAG \n");
  259. sqlstr.append(" FROM BID_MASTER \n");
  260. sqlstr.append(" WHERE BID_NO = ? \n");
  261. sqlstr.append(" AND BID_DEG = ? \n");
  262. search.setStatement(sqlstr.toString());
  263. search.addParameter(vo.get("KEY_COL1"));
  264. search.addParameter(vo.get("KEY_COL2"));
  265. rowSet = search.execute();
  266. if (rowSet.size() > 0) {
  267. valueobject = RowSetUtility.getValueObject(search.execute().getRow(0));
  268. }
  269. }
  270. catch(WAFSQLException se) {
  271. Logger.err.println("SQL : \n" + se.getStatement());
  272. Logger.err.println("PARAM : \n" + se.getParameter());
  273. throw se;
  274. }
  275. finally {
  276. if (valueobject == null)
  277. valueobject = new ValueObject();
  278. return valueobject;
  279. }
  280. }
  281. /**
  282. * 계약 완료 데이터 이동 처리
  283. * @param connection
  284. * @param valueObject
  285. * @throws Exception
  286. */
  287. public void callTbeSave(Connection connection, ValueObject valueObject) throws Exception {
  288. CallableStatement cs = null;
  289. ValueObject rtnVo = new ValueObject();
  290. String sqlStr = "";
  291. try {
  292. sqlStr = "{call SP_RE_BID_TO_TBE(?, ?, ?,?)}";
  293. //WAFLogger.debug("SQL : " + sqlStr);
  294. cs = connection.prepareCall(sqlStr);
  295. cs.setString(1, valueObject.get("KEY_COL1"));
  296. cs.setInt(2, valueObject.getInt("KEY_COL2"));
  297. cs.registerOutParameter(3, java.sql.Types.VARCHAR);
  298. cs.registerOutParameter(4, java.sql.Types.VARCHAR);
  299. cs.execute();
  300. }
  301. catch(Exception e) {
  302. WAFLogger.error(this.getClass().getName() + " --> callTbeSave() : " + e.getMessage());
  303. WAFLogger.error("SQL : " + e.getMessage());
  304. WAFLogger.error(e);
  305. throw e;
  306. }
  307. }
  308. }