OrebqSignDriver.java 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  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 OrebqSignDriver implements CommonSignInterface {
  37. /**
  38. * 테슽 파일
  39. *
  40. */
  41. public OrebqSignDriver() {
  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. //success = saveProc(connection,signDoc);
  66. updateStatus(connection, signDoc);
  67. ValueObject vo = getDemanded_kind(connection, signDoc);
  68. if(success){
  69. if("Y".equals(vo.get("ONBID_YN"))){
  70. Send(signDoc,"10");
  71. }
  72. //BID_SUPP 견적대상업 체
  73. if("Y".equals(vo.get("TBE_FLAG"))){
  74. callTbeSave(connection,signDoc);
  75. }
  76. }
  77. System.out.println("### 결재 End");
  78. }
  79. /*
  80. * (non-Javadoc)
  81. * @see kr.co.udap.ehr.common.sign.SignInterface#doFinishSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  82. */
  83. public void doFinishSign(Connection connection, ValueObject signDoc) throws Exception {
  84. System.out.println("!!doFinishSign");
  85. }
  86. /*
  87. * (non-Javadoc)
  88. * @see kr.co.udap.ehr.common.sign.SignInterface#doRejectSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  89. */
  90. public void doFirstRejectSign(Connection connection, ValueObject signDoc) throws Exception {
  91. System.out.println("!!반려");
  92. updateStatus(connection, signDoc);
  93. }
  94. /*
  95. * (non-Javadoc)
  96. * @see kr.co.udap.ehr.common.sign.SignInterface#doRejectSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  97. */
  98. public void doRejectSign(Connection connection, ValueObject signDoc) throws Exception {
  99. System.out.println("!!doRejectSign");
  100. }
  101. /*
  102. * (non-Javadoc)
  103. * @see kr.co.udap.ehr.common.sign.SignInterface#doCancelSign(java.sql.Connection, com.udapsoft.common.util.ValueObject)
  104. */
  105. public void doCancelSign(Connection connection, ValueObject signDoc) throws Exception {
  106. }
  107. /**
  108. * SAC01001 상태값을 업데이트해준다.
  109. * @param connection
  110. * @param valueObject
  111. * @throws Exception
  112. */
  113. public void updateStatus(Connection connection, ValueObject vo) throws Exception {
  114. Persistent persistent = new PersistentImpl(connection);
  115. StringBuffer sqlstr = new StringBuffer();
  116. try {
  117. String status = "";
  118. if(vo.get("SIGN_TYPE").equals("1")){
  119. if(vo.get("SIGN_DECI_CLASS").equals("14")){
  120. status = "04";
  121. }else {
  122. status = "30";
  123. }
  124. }
  125. sqlstr.append(" UPDATE BID_MASTER SET \n");
  126. sqlstr.append(" STATUS_CD = DECODE(?,'30','30',DECODE(SITEDESC_FLAG, 'Y', '03', '04')) \n"); //2018.07.06 현설추가
  127. sqlstr.append(" WHERE BID_NO = ? \n");
  128. sqlstr.append(" AND BID_DEG = ? \n");
  129. persistent.setStatement(sqlstr.toString());
  130. persistent.addParameter(status);
  131. persistent.addParameter(vo.get("KEY_COL1"));
  132. persistent.addParameter(vo.get("KEY_COL2"));
  133. persistent.execute();
  134. persistent.clearParameters();
  135. }
  136. catch(Exception e) {
  137. WAFLogger.error(this.getClass().getName() + " --> updateStatus() : " + e.getMessage());
  138. WAFLogger.error(e);
  139. throw e;
  140. }
  141. }
  142. /**
  143. * SP_BID_TO_PURCONT 프로시저 호출
  144. * @param connection
  145. * @param valueObject
  146. * @throws Exception
  147. */
  148. public boolean saveProc(Connection connection, ValueObject vo) throws Exception {
  149. ValueObject rtnVo = new ValueObject();
  150. CallableStatement cs = null;
  151. String pssql = "";
  152. try{
  153. pssql = "{call SP_RE_BID_TO_TBE(?,?,?,?)}";
  154. cs = connection.prepareCall(pssql);
  155. cs.setString(1, vo.get("KEY_COL1"));
  156. cs.setString(2, vo.get("KEY_COL2"));
  157. cs.registerOutParameter(3, java.sql.Types.VARCHAR);
  158. cs.registerOutParameter(4, java.sql.Types.VARCHAR);
  159. cs.execute();
  160. rtnVo.set("OUT_SUCCESS_CD",cs.getString(3));
  161. rtnVo.set("OUT_MESSAGE",cs.getString(4));
  162. System.out.println("CODE : " + cs.getString(3));
  163. System.out.println("MSG : " + cs.getString(4));
  164. if("N".equals(cs.getString(3))){
  165. throw new Exception(cs.getString(4));
  166. }
  167. return true;
  168. }
  169. catch(Exception e) {
  170. WAFLogger.error(this.getClass().getName() + " --> saveProc() : " + e.getMessage());
  171. WAFLogger.error(e);
  172. return false;
  173. }
  174. }
  175. public void Send(ValueObject params, String event) throws Exception {
  176. HandlerStorage Stroage = new HandlerStorage();
  177. MessageSend messageSend = new MessageSend(Stroage);
  178. RowSet SuppInfo = bid_supp_info(params); //2018.07.06 재입찰 현설여부 추가
  179. ValueObject bid_Master = bid_Master_info(params);
  180. for(int i=0;i < SuppInfo.size();i++){
  181. Row row = SuppInfo.getRow(i);
  182. if(!row.get("CHARGE_EMAIL").isEmpty()){
  183. boolean email = false;
  184. StringBuffer mailtitle = new StringBuffer();
  185. StringBuffer mailtitlein = new StringBuffer();
  186. StringBuffer mailContent = new StringBuffer();
  187. //2018.07.06 재입찰 현설여부 추가
  188. if (bid_Master.get("SITEDESC_FLAG").equals("Y")){
  189. mailtitle.append("* 재 현장설명회에 대한 공지 메일입니다.");
  190. mailtitlein.append("* 재 현장설명회에 대한 공지 메일입니다.");
  191. mailContent.append(row.get("VENDOR_NAME")+"님께 아래와 같은 내용으로 현장설명회 참석을 요청드립니다.<br>협력업체포탈시스템에 접속하시어 현장설명회 내용 확인 후 참석의사를 입력해 주시기바랍니다.<br>");
  192. mailContent.append("<font style='width:auto; font-size:12px; line-height:18px; padding:5px; text-align:left;'>");
  193. mailContent.append("<br>");
  194. mailContent.append("1.프로젝트 : " + bid_Master.get("DEPT_NM") + "<br>");
  195. mailContent.append("2.공고번호 : " + bid_Master.get("BID_NO") + "<br>");
  196. mailContent.append("3.공고건명 : " + bid_Master.get("BID_MASTER_NM") + "<br>");
  197. mailContent.append("4.현설일시 : " + bid_Master.get("SITEDESCDATE_NM") + "<br>");
  198. mailContent.append("5.현설장소 : " + bid_Master.get("SITEDESCPLACE") + "<br>");
  199. mailContent.append("6.현설담당자 : " +bid_Master.get("SITEDESC_BUSEO_NM")+" / "+ bid_Master.get("SITEDESC_CRG_NM") +" (연락처 : " + bid_Master.get("SITEDESCTELNO") + ", 이메일 : " + bid_Master.get("SITEDESCEMAIL") +")<br>");
  200. mailContent.append("7.입찰담당자 : " +bid_Master.get("BUSEO_NM")+" / "+ bid_Master.get("USER_NAME") +" (연락처 : " + bid_Master.get("PO_EMPNM") + ", 이메일 : " + bid_Master.get("E_MAIL") +")<br>");
  201. mailContent.append("</font>");
  202. }else{
  203. mailtitle.append("* 재 입찰 요청에 대한 공지 메일입니다.");
  204. mailtitlein.append("* 재 입찰 요청에 대한 공지 메일입니다.");
  205. mailContent.append(row.get("VENDOR_NAME")+"님께 아래와 같은 내용으로 견적서 제출을 요청드립니다.<br>협력업체포탈시스템에 접속하시어 견적서작성바랍니다.<br>견적서제출시 법인공인증서가 필요합니다.<br>");
  206. mailContent.append("<font style='width:auto; font-size:12px; line-height:18px; padding:5px; text-align:left;'>");
  207. mailContent.append("<br>");
  208. mailContent.append("1.프로젝트 : " + bid_Master.get("DEPT_NM") + "<br>");
  209. mailContent.append("2.공고번호 : " + bid_Master.get("BID_NO") + "<br>");
  210. mailContent.append("3.공고건명 : " + bid_Master.get("BID_MASTER_NM") + "<br>");
  211. mailContent.append("4.견적마감일시 : " + bid_Master.get("BID_TO_DT_NM") + "<br>");
  212. mailContent.append("5.입찰담당자 : " +bid_Master.get("BUSEO_NM")+" / "+ bid_Master.get("USER_NAME") +" (연락처 : " + bid_Master.get("PO_EMPNM") + ", 이메일 : " + bid_Master.get("E_MAIL") + ")<br>");
  213. mailContent.append("</font>");
  214. }
  215. email = true;
  216. if(email){
  217. messageSend.sendEmail(row.get("CHARGE_EMAIL"), "partner@sgc.co.kr", mailtitle.toString(), mailtitlein.toString(), mailContent);
  218. }
  219. }
  220. if(!row.get("CHAGE_HP").isEmpty()){
  221. String smsContent = "재입찰서 제출바랍니다.'||CHR(13)||CHR(10)||'협력업체포탈시스템에 접속/확인바랍니다.'||CHR(13)||CHR(10)||'SGC이앤씨(주)";
  222. if (bid_Master.get("SITEDESC_FLAG").equals("Y")){
  223. smsContent = "현장설명회 공지'||CHR(13)||CHR(10)||'협력업체포탈시스템에 접속/확인바랍니다.'||CHR(13)||CHR(10)||'SGC이앤씨(주)";
  224. }
  225. String from_phon_no = bid_Master.get("PO_EMPNM").replace("-", "");
  226. String to_phon_no = row.get("CHAGE_HP").replace("-", "");
  227. if(!smsContent.isEmpty()){
  228. messageSend.sendSMS(to_phon_no,from_phon_no, "", smsContent); //2015.9.21 재입찰. 입찰담당자
  229. }
  230. }
  231. }
  232. }
  233. /**
  234. * 견적 대상 업체 를 검색하여 리턴
  235. * @param Params
  236. * @return
  237. */
  238. public RowSet bid_supp_info(ValueObject param) {
  239. Search search = new SearchImpl();
  240. RowSet rowSet = new RowSetImpl();
  241. // String sqlstr = "";
  242. StrBuffer sqlstr = new StrBuffer();
  243. try{
  244. sqlstr.append(" SELECT CHARGE_NAME,CHARGE_EMAIL,CHAGE_HP,VENDOR_NAME \n");
  245. sqlstr.append(" FROM BID_SUPP \n");
  246. sqlstr.append(" WHERE BID_NO = ? \n");
  247. sqlstr.append(" AND BID_DEG = ? \n");
  248. search.setStatement(sqlstr.toString());
  249. search.addParameter(param.get("KEY_COL1"));
  250. search.addParameter(param.get("KEY_COL2"));
  251. search.setStatement(sqlstr.toString());
  252. rowSet = search.execute();
  253. }
  254. catch (WAFSQLException se) {
  255. Logger.err.println("SQL : \n" + se.getStatement());
  256. Logger.err.println("PARAM : \n" + se.getParameter());
  257. }
  258. finally {
  259. if(rowSet == null){
  260. rowSet = new RowSetImpl();
  261. }
  262. }
  263. System.out.println("### rowSet size : " + rowSet.size());
  264. return rowSet;
  265. }
  266. /**
  267. * 발주의뢰(외주) 접수를 검색하여 리턴
  268. * @param Params
  269. * @return
  270. */
  271. public ValueObject bid_Master_info(ValueObject param) {
  272. Search search = new SearchImpl();
  273. ValueObject valueobject = null;
  274. RowSet rowSet = new RowSetImpl();
  275. StrBuffer sqlstr = new StrBuffer();
  276. try{
  277. sqlstr.append(" SELECT A.BID_NO, \n");
  278. sqlstr.append(" TO_CHAR(A.BID_TO_DT,'YYYY-MM-DD HH24:MI') AS BID_TO_DT_NM, \n");
  279. sqlstr.append(" A.PO_EMPNM, \n");
  280. sqlstr.append(" A.DEPT_CD, \n");
  281. sqlstr.append(" A.DEPT_NM, \n");
  282. sqlstr.append(" A.BID_MASTER_NM, \n");
  283. sqlstr.append(" B.USER_NAME, \n");//입찰담당자
  284. sqlstr.append(" B.E_MAIL, \n");//입찰담당자EMAIL
  285. sqlstr.append(" B.DEPART_DEPT_NM AS BUSEO_NM, \n");//입찰담당자 부서
  286. sqlstr.append(" A.SITEDESC_FLAG, \n");//현설여부
  287. sqlstr.append(" TO_CHAR(A.SITEDESCDATE,'YYYY-MM-DD HH24:MI') AS SITEDESCDATE_NM, \n");//현설일시
  288. sqlstr.append(" A.SITEDESCPLACE, \n");//현설장소
  289. sqlstr.append(" A.SITEDESCTELNO, \n");//현설연락처
  290. sqlstr.append(" A.SITEDESCEMAIL, \n");//현설EMAIL
  291. sqlstr.append(" C.DEPART_DEPT_NM AS SITEDESC_BUSEO_NM, \n");//현설담당자부서
  292. sqlstr.append(" NVL(A.SITEDESC_CRG_NM,C.USER_NAME) AS SITEDESC_CRG_NM \n");//현설담당자 명
  293. sqlstr.append(" FROM BID_MASTER A \n");
  294. sqlstr.append(" ,PUB0120T B \n");//입찰
  295. sqlstr.append(" ,PUB0120T C \n");//현설
  296. sqlstr.append(" WHERE A.PUREMPNO = B.ACCT_ID \n");
  297. sqlstr.append(" AND A.SITEDESCCHRGPRSNID = C.ACCT_ID(+) \n");//현설담당 DEPART_DEPT_NM
  298. sqlstr.append(" AND A.BID_NO = ? \n");
  299. sqlstr.append(" AND A.BID_DEG = ? \n");
  300. search.setStatement(sqlstr.toString());
  301. search.addParameter(param.get("KEY_COL1"));
  302. search.addParameter(param.get("KEY_COL2"));
  303. search.setStatement(sqlstr.toString());
  304. rowSet = search.execute();
  305. if( rowSet != null && rowSet.size() > 0 ){
  306. valueobject = RowSetUtility.getValueObject(rowSet.getRow(0));
  307. }
  308. }
  309. catch (WAFSQLException se) {
  310. Logger.err.println("SQL : \n" + se.getStatement());
  311. Logger.err.println("PARAM : \n" + se.getParameter());
  312. }
  313. return valueobject;
  314. }
  315. private ValueObject getDemanded_kind(Connection connection, ValueObject vo) throws Exception{
  316. Search search = new SearchImpl();
  317. RowSet rowSet = new RowSetImpl();
  318. ValueObject valueobject = null;
  319. StringBuffer sqlstr = new StringBuffer();
  320. try {
  321. sqlstr.append(" SELECT DEMANDED_KIND,STATUS_CD,ONBID_YN, TBE_FLAG \n");
  322. sqlstr.append(" FROM BID_MASTER \n");
  323. sqlstr.append(" WHERE BID_NO = ? \n");
  324. sqlstr.append(" AND BID_DEG = ? \n");
  325. search.setStatement(sqlstr.toString());
  326. search.addParameter(vo.get("KEY_COL1"));
  327. search.addParameter(vo.get("KEY_COL2"));
  328. rowSet = search.execute();
  329. if (rowSet.size() > 0) {
  330. valueobject = RowSetUtility.getValueObject(search.execute().getRow(0));
  331. }
  332. }
  333. catch(WAFSQLException se) {
  334. Logger.err.println("SQL : \n" + se.getStatement());
  335. Logger.err.println("PARAM : \n" + se.getParameter());
  336. throw se;
  337. }
  338. finally {
  339. if (valueobject == null)
  340. valueobject = new ValueObject();
  341. return valueobject;
  342. }
  343. }
  344. /**
  345. * 계약 완료 데이터 이동 처리
  346. * @param connection
  347. * @param valueObject
  348. * @throws Exception
  349. */
  350. public void callTbeSave(Connection connection, ValueObject valueObject) throws Exception {
  351. CallableStatement cs = null;
  352. ValueObject rtnVo = new ValueObject();
  353. String sqlStr = "";
  354. try {
  355. sqlStr = "{call SP_RE_BID_TO_TBE(?, ?, ?,?)}";
  356. //WAFLogger.debug("SQL : " + sqlStr);
  357. cs = connection.prepareCall(sqlStr);
  358. cs.setString(1, valueObject.get("KEY_COL1"));
  359. cs.setInt(2, valueObject.getInt("KEY_COL2"));
  360. cs.registerOutParameter(3, java.sql.Types.VARCHAR);
  361. cs.registerOutParameter(4, java.sql.Types.VARCHAR);
  362. cs.execute();
  363. }
  364. catch(Exception e) {
  365. WAFLogger.error(this.getClass().getName() + " --> callTbeSave() : " + e.getMessage());
  366. WAFLogger.error("SQL : " + e.getMessage());
  367. WAFLogger.error(e);
  368. throw e;
  369. }
  370. }
  371. }