/**
 * @(#)file    ScrchInfoBiz.java
 * @(#)author  Son Hyung Min 
 * @(#)version 1.0
 * @(#)date    2014-06-23
 * @(#)since   JDK 1.4.2
 */
package kr.co.udapsoft.ebid.buyer.bid.outside.biz;




import oracle.toplink.internal.ox.StrBuffer;
import kr.co.hsnc.common.base.WAFMessages;
import kr.co.hsnc.common.sql.Row;
import kr.co.hsnc.common.sql.RowSet;
import kr.co.hsnc.common.sql.RowSetImpl;
import kr.co.hsnc.common.sql.WAFSQLException;
import kr.co.hsnc.common.sql.search.Search;
import kr.co.hsnc.common.sql.search.SearchImpl;
import kr.co.hsnc.common.sql.util.RowSetUtility;
import kr.co.hsnc.common.util.ValueObject;
import kr.co.udapsoft.common.sender.MessageSend;

import com.udapsoft.waf.common.util.StringUtils;
import com.udapsoft.waf.system.Biz;
import com.udapsoft.waf.system.HandlerStorage;

import kr.co.udapsoft.common.sender.MessageSend;
   
public class ScrchInfoBiz extends Biz {

	public ScrchInfoBiz(HandlerStorage storage) {
		super(storage);
	}

	public void doBiz() throws Exception {
		boolean success = true;
		if(storage.compareEvent("CHK")){
			if(params.get("BID_APP_NO").isEmpty())
				success = signidentify(params.get("signClass"),params.get("BID_NO"),params.get("BID_DEG"));
			storage.setSuccess(success);
		}else if(storage.compareEvent("CHK2")){
			if(params.get("BID_APP_NO").isEmpty())
				success = signidentify(params.get("signClass"),params.get("BID_NO"),params.get("BID_DEG"),params.get("VENDOR_CD"));
			storage.setSuccess(success);
		}
	}
	
	/**
	 * 견적 대상 업체 를 검색하여 리턴
	 * @param Params
	 * @return
	 */
	public RowSet bid_supp_info(ValueObject param, String event) {

		Search search = new SearchImpl();
        RowSet rowSet = new RowSetImpl();
        
     //   String sqlstr = "";
        StrBuffer sqlstr = new StrBuffer();
        try{ 
        	sqlstr.append("	SELECT MAX(CHARGE_NAME) AS CHARGE_NAME					\n");
        	sqlstr.append("	      ,MAX(CHARGE_EMAIL) AS CHARGE_EMAIL  				\n");
        	sqlstr.append("	      ,MAX(CHAGE_HP) AS CHAGE_HP				    	\n");
        	sqlstr.append("	      ,MAX(VENDOR_NAME) AS VENDOR_NAME 					\n");
			sqlstr.append("	  FROM BID_SUPP											\n");
			sqlstr.append("	 WHERE BID_NO = ?										\n");
			sqlstr.append("	   AND SITEPARTI_YN = 'Y'								\n");
			//2017.08.16 유찰,취소 인경우 전체차수 협력업체 발송
			if(!"FORM_CANCEL_UPDATE".equals(event) && !"FORM_ING_CANCEL_UPDATE".equals(event) ){
				sqlstr.append("	AND BID_DEG = ?										\n");
			}
			if(!param.get("VENDOR_CD").isEmpty()){
				sqlstr.append("	AND VENDOR_CD = ?									\n");
			}
			sqlstr.append("	GROUP BY VENDOR_CD										\n");
			
			
			search.setStatement(sqlstr.toString());
			search.addParameter(param.get("BID_NO"));
			if(!"FORM_CANCEL_UPDATE".equals(event)&& !"FORM_ING_CANCEL_UPDATE".equals(event)){
				search.addParameter(param.get("BID_DEG"));
			}
			if(!param.get("VENDOR_CD").isEmpty()){
				search.addParameter(param.get("VENDOR_CD"));
			}
			search.setStatement(sqlstr.toString());
			System.out.println(sqlstr.toString());
            rowSet = search.execute();
        }
        catch (WAFSQLException se) {
            super.doException(se);
            this.storage.setSuccess(false);  
            this.storage.setMessage(se.getMessage());
            storage.setDetailMessage(se);
        }
        finally {    
            if(rowSet == null){
            	rowSet = new RowSetImpl();
            }
        }
        return rowSet;
	}
	
	/**
	 * 발주의뢰(외주) 접수를 검색하여 리턴
	 * @param Params
	 * @return
	 */
	public ValueObject bid_Master_info(ValueObject param) {

		Search search = new SearchImpl();
		 ValueObject valueobject = null;
		RowSet rowSet = new RowSetImpl();
        
        StrBuffer sqlstr = new StrBuffer();
        try{ 
        	sqlstr.append("	SELECT A.BID_NO, 			\n");
        	sqlstr.append("	    A.BID_DEG,			\n");
        	sqlstr.append("	    A.DEMANDED_ID,			\n");
        	sqlstr.append("	    A.DEMANDED_NO,			\n");
        	sqlstr.append("	    A.DEPT_CD,			\n");
        	sqlstr.append("	    A.DEPT_NM,			\n");
        	sqlstr.append("	    A.DEMANDED_TITLE,			\n");
        	sqlstr.append("	    A.DEMANDED_KIND,			\n");
        	sqlstr.append("	    A.DEMANDED_DATE,			\n");
        	sqlstr.append("	    A.REQUEST_DATE,			\n");
        	sqlstr.append("	    A.REQ_DEPT_CD,			\n");
        	sqlstr.append("	    A.REQ_DEPT_NM,			\n");
        	sqlstr.append("	    A.EMP_NO,			\n");
        	sqlstr.append("	    A.EMP_NM,			\n");
        	sqlstr.append("	    A.PAY_ITEM,			\n");
        	sqlstr.append("	    A.COST_CODE,			\n");
        	sqlstr.append("	    A.COST_TYPE,			\n");
        	sqlstr.append("	    A.CONT_AMT,			\n");
        	sqlstr.append("	    A.ACT_AMT,			\n");
        	sqlstr.append("	    A.ACT_RATE,			\n");
        	sqlstr.append("	    A.RECEIPT_DATE,			\n");
        	sqlstr.append("	    A.ONBID_YN,			\n");
        	sqlstr.append("	    A.CMPT_CD,			\n");
        	sqlstr.append("	    A.SUCC_CD,			\n");
        	sqlstr.append("	    A.NOTI_DY,			\n");
        	sqlstr.append("	    A.SITEDESC_FLAG,			\n");
        	sqlstr.append("	    A.SITEDESCCHRGPRSNID,			\n");
        	sqlstr.append("	    A.SITEDESC_CRG_NM,			\n");
        	sqlstr.append("	    A.SITEDESCTELNO,			\n");
        	sqlstr.append("	    A.SITEDESCEMAIL,			\n");
        	sqlstr.append("	    A.SITEDESCDATE,			\n");
        	sqlstr.append("	    A.SITEDESCPLACE,			\n");
        	sqlstr.append("	    A.BID_FROM_DT,			\n");
        	sqlstr.append("	    A.BID_TO_DT,			\n");
        	sqlstr.append("	    TO_CHAR(A.BID_TO_DT,'YYYY-MM-DD HH24:MI') AS BID_TO_DT_NM,			\n");
        	sqlstr.append("	    A.PUREMPNO,			\n");
        	sqlstr.append("	    A.PO_EMPNM,			\n");
        	sqlstr.append("	    A.OPEN_EMPNM,			\n");
        	sqlstr.append("	    A.OPEN_EMPID,			\n");
        	sqlstr.append("	    A.OPEN_DT,			\n");
        	sqlstr.append("	    A.TBE_FLAG,			\n");
        	sqlstr.append("	    A.DELIVERY_CONDITION,			\n");
        	sqlstr.append("	    A.DELIVERY_PLACE,			\n");
        	sqlstr.append("	    A.INNER_REMARKS,			\n");
        	sqlstr.append("	    A.OUTER_REMARKS,			\n");
        	sqlstr.append("	    A.ATT_ID,			\n");
        	sqlstr.append("	    A.BID_APP_DATE,			\n");
        	sqlstr.append("	    A.BID_APP_NO,			\n");
        	sqlstr.append("	    A.CONT_APP_DATE,			\n");
        	sqlstr.append("	    A.CONT_APP_NO,			\n");
        	sqlstr.append("	    A.DOC_ETC_IN,			\n");
        	sqlstr.append("	    A.DOC_ETC_OUT,			\n");
        	sqlstr.append("	    A.BID_MASTER_NM,			\n");
        	sqlstr.append("	    A.POSTPONE_REASON,			\n");
        	sqlstr.append("	    A.CANCEL_REASON,			\n");
        	sqlstr.append("	    A.MODIFY_REASON,			\n");
        	sqlstr.append("	    A.FIB_REASON,			\n");
        	sqlstr.append("	    A.OUT_ITEM_CD,			\n");
        	sqlstr.append("	    A.STATUS_CD,			\n");
        	sqlstr.append("	    A.DIV_PO_YN,			\n");
        	sqlstr.append("	    A.CURRENCY_GB,			\n");
        	sqlstr.append("	    A.CURRENCY_GB_YN,			\n");
        	sqlstr.append("	    A.PBC_CBE_TYPE_CD,			\n");
        	sqlstr.append("	    A.PBC_INSTALL_YN,			\n");
        	sqlstr.append("	    A.PBC_COMMISS_YN,			\n");
        	sqlstr.append("	    A.PBC_SPETOOL_YN,			\n");
        	sqlstr.append("	    A.PBC_TEST_YN,			\n");
        	sqlstr.append("	    A.PBC_DOC_YN,			\n");
        	sqlstr.append("	    A.PBC_PACK_YN,			\n");
        	sqlstr.append("	    A.PBC_LANDTRAN_YN,			\n");
        	sqlstr.append("	    A.DELIVERY_CONDITION_YN,			\n");
        	sqlstr.append("	    A.PBC_FEE_YN,			\n");
        	sqlstr.append("	    A.PBC_OPTION_COMMENT,			\n");
        	sqlstr.append("	    A.PBC_OPTION_YN,			\n");
        	sqlstr.append("	    A.PAY_CON_RATE,			\n");
        	sqlstr.append("	    A.CBC_DAMAGE_RATE,			\n");
        	sqlstr.append("	    A.CBC_DAMAGE_MAXRATE,			\n");
        	sqlstr.append("	    A.CBC_FIRST_RATE,			\n");
        	sqlstr.append("	    A.PBC_FIRST_CONDI,			\n");
        	sqlstr.append("	    A.CPC_MID_RATE,			\n");
        	sqlstr.append("	    A.PBC_MID_CONDI,			\n");
        	sqlstr.append("	    A.PBC_REST_RATE,			\n");
        	sqlstr.append("	    A.PBC_REST_CONDI,			\n");
        	sqlstr.append("	    A.PBC_FRSTGUAR_RATE,			\n");
        	sqlstr.append("	    A.PBC_FRSTGUAR_CONDI,			\n");
        	sqlstr.append("	    A.CONTFUL_RATE,			\n");
        	sqlstr.append("	    A.CONTFUL_CONDI,			\n");
        	sqlstr.append("	    A.WARR_RATE,			\n");
        	sqlstr.append("	    A.WARR_CONDI,			\n");
        	sqlstr.append("	    A.PBC_DEFECT_CONDI,			\n");
        	sqlstr.append("	    A.CBC_DEFECT_DAY,			\n");
        	sqlstr.append("	    A.CBC_DERECT_TERM_CD,			\n");
        	sqlstr.append("	    A.DELI_FROM_DY,			\n");
        	sqlstr.append("	    A.DELI_TO_DY,			\n");
        	sqlstr.append("	    A.OBC_CONT_TYPE_CD,			\n");
        	sqlstr.append("	    A.OBC_FRST_CASH_RATE,			\n");
        	sqlstr.append("	    A.OBC_MID_CASH_RATE,			\n");
        	sqlstr.append("	    A.OBC_MID_BILL_RATE,			\n");
        	sqlstr.append("	    A.OBC_FIN_CASH_RATE,			\n");
        	sqlstr.append("	    A.OBC_FIN_BILL_RATE,			\n");
        	sqlstr.append("	    A.OBC_FRST_CONDI,			\n");
        	sqlstr.append("	    A.OBC_MID_PAYDAY,			\n");
        	sqlstr.append("	    A.OBC_FIN_PAYDAY,			\n");
        	sqlstr.append("	    A.OBC_FRST_CNT_CONDI,			\n");
        	sqlstr.append("	    A.OBC_MID_REQ_MONTH,			\n");
        	sqlstr.append("	    A.OBC_MID_CNT,			\n");
        	sqlstr.append("	    A.OBC_FIN_CONDI,			\n");
        	sqlstr.append("	    A.OBC_EMP_RATE,			\n");
        	sqlstr.append("	    A.OBC_EMP_YN,			\n");
        	sqlstr.append("	    A.OBC_PENSION_RATE,			\n");
        	sqlstr.append("	    A.OBC_PENSION_YN,			\n");
        	sqlstr.append("	    A.OBC_HEALTH_RATE,			\n");
        	sqlstr.append("	    A.OBC_HEALTH_YN,			\n");
        	sqlstr.append("	    A.OBC_ELDER_RATE,			\n");
        	sqlstr.append("	    A.OBC_ELDER_YN,			\n");
        	sqlstr.append("	    A.OBC_WORK_RATE,			\n");
        	sqlstr.append("	    A.OBC_WORK_YN,			\n");
        	sqlstr.append("	    A.OBC_RESIGN_RATE,			\n");
        	sqlstr.append("	    A.OBC_RESIGN_YN,			\n");
        	sqlstr.append("	    A.OBC_SAFE_RATE,			\n");
        	sqlstr.append("	    A.OBC_SAFE_YN,			\n");
        	sqlstr.append("	    A.OBC_ENV_RATE,			\n");
        	sqlstr.append("	    A.OBC_ENV_YN,			\n");
        	sqlstr.append("	    A.OBC_SITE_RATE,			\n");
        	sqlstr.append("	    A.OBC_SITE_YN,			\n");
        	sqlstr.append("	    A.OBC_DUTY_RATE,			\n");
        	sqlstr.append("	    A.OBC_DUTY_YN,			\n");
        	sqlstr.append("	    A.OBC_WARR_YN,			\n");
        	sqlstr.append("	    A.PAY_DIV,			\n");
        	sqlstr.append("	    A.MATERIAL_GB,			\n");
        	sqlstr.append("	    A.DELI_START_DT,			\n");
        	sqlstr.append("	    A.DELI_END_DT,			\n");
        	sqlstr.append("	    A.DELI_END_PLACE,			\n");
        	sqlstr.append("	    A.KRW_APPR_YN,			\n");
        	sqlstr.append("	    B.USER_NAME,			\n");
        	sqlstr.append("	    B.E_MAIL,			\n");
        	sqlstr.append("	    B.ACC_DEPT_NM AS BUSEO_NM,		\n");
        	sqlstr.append("	    C.EVAL_EMPNM,			\n");
        	sqlstr.append("	    C.EVAL_TEL,			\n");
        	sqlstr.append("	    C.EVAL_EMAIL,			\n");
        	sqlstr.append("	    (SELECT ACC_DEPT_NM FROM PUB0120T WHERE ACCT_ID = C.EVAL_EMPID) AS TBE_BUSEO_NM			\n");
        	sqlstr.append("	FROM BID_MASTER A, PUB0120T B , TBE_INFO C  	\n");
			sqlstr.append("	WHERE A.PUREMPNO = B.ACCT_ID						\n");
			sqlstr.append("	AND A.BID_NO = C.BID_NO(+)								\n");
			sqlstr.append("	AND A.BID_DEG = C.BID_DEG(+)							\n");
			sqlstr.append("	AND A.BID_NO = ?											\n");
			sqlstr.append("	AND A.BID_DEG = ?											\n");
			search.setStatement(sqlstr.toString());
			search.addParameter(param.get("BID_NO"));
			search.addParameter(param.get("BID_DEG"));
			search.setStatement(sqlstr.toString());
            rowSet = search.execute();
            if( rowSet != null && rowSet.size() > 0 ){
            	valueobject = RowSetUtility.getValueObject(rowSet.getRow(0));
            }
        }
        catch (WAFSQLException se) {
            super.doException(se);
            this.storage.setSuccess(false);  
            this.storage.setMessage(se.getMessage());
            storage.setDetailMessage(se);
        }
        return valueobject;
	}
	public void Send(ValueObject params, String event) throws Exception {
		Send(params,event,"");
	}
	
	public void Send(ValueObject params, String event, String vendor_cd) throws Exception {
		MessageSend messageSend = new MessageSend(storage);
		if(!vendor_cd.isEmpty())
			params.set("VENDOR_CD", vendor_cd);
		
     	RowSet SuppInfo = bid_supp_info(params, event);
     	ValueObject bid_Master = bid_Master_info(params);
     	for(int i=0;i < SuppInfo.size();i++){
     		Row row = SuppInfo.getRow(i);
     		if(!row.get("CHARGE_EMAIL").isEmpty()){
     			boolean email = false;
         		StringBuffer mailtitle = new StringBuffer();
         		StringBuffer mailtitlein = new StringBuffer();
                StringBuffer mailContent = new StringBuffer();
                if("COMPLETION".equals(event)&& bid_Master.get("BID_DEG").equals("1")){//견적의뢰
                	mailtitle.append("* 입찰서 제출요청에 대한 공지 메일입니다.");
                    mailtitlein.append("* 입찰서 제출요청에 대한 공지 메일입니다.");
                 	mailContent.append(row.get("VENDOR_NAME")+"님께 아래와 같은 내용으로 입찰서 제출을 요청드립니다.<br>협력업체포탈시스템에 접속하시어 입찰서 작성 및 제출바랍니다.<br>입찰서 제출시 법인공인증서가 필요합니다.<br>");
                 	mailContent.append("<font style='width:auto; font-size:12px; line-height:18px; padding:5px; text-align:left;'>");
                 	mailContent.append("<br>");
                 	mailContent.append("1.프로젝트 : " + bid_Master.get("DEPT_NM") + "<br>");
                 	mailContent.append("2.공고번호 : " + bid_Master.get("BID_NO") + "<br>");
                 	mailContent.append("3.공고건명 : " + bid_Master.get("BID_MASTER_NM") + "<br>");
                 	mailContent.append("4.견적마감일시 : " + bid_Master.get("BID_TO_DT_NM") + "<br>");
                 	mailContent.append("5.입찰담당자 : " +bid_Master.get("BUSEO_NM")+" / "+ bid_Master.get("USER_NAME") +" (연락처 : " + bid_Master.get("PO_EMPNM") + ", 이메일 : " + bid_Master.get("E_MAIL") + ")<br>");
                 	mailContent.append("</font>");
                	email = true;
                }else if("COMPLETION".equals(event) && !bid_Master.get("BID_DEG").equals("1")){//재입찰  RE_BID_SAVE
                	mailtitle.append("* 재 입찰 요청에 대한 공지 메일입니다.");
                    mailtitlein.append("* 재 입찰 요청에 대한 공지 메일입니다.");
                 	mailContent.append(row.get("VENDOR_NAME")+"님께 아래와 같은 내용으로 견적서 제출을 요청드립니다.<br>협력업체포탈시스템에 접속하시어 견적서작성바랍니다.<br>견적서제출시 법인공인증서가 필요합니다.<br>");
                 	mailContent.append("<font style='width:auto; font-size:12px; line-height:18px; padding:5px; text-align:left;'>");
                 	mailContent.append("<br>");
                 	mailContent.append("1.프로젝트 : " + bid_Master.get("DEPT_NM") + "<br>");
                 	mailContent.append("2.공고번호 : " + bid_Master.get("BID_NO") + "<br>");
                 	mailContent.append("3.공고건명 : " + bid_Master.get("BID_MASTER_NM") + "<br>");
                 	mailContent.append("4.견적마감일시 : " + bid_Master.get("BID_TO_DT_NM") + "<br>");
                 	mailContent.append("5.입찰담당자 : " +bid_Master.get("BUSEO_NM")+" / "+ bid_Master.get("USER_NAME") +" (연락처 : " + bid_Master.get("PO_EMPNM") + ", 이메일 : " + bid_Master.get("E_MAIL") + ")<br>");
                 	mailContent.append("</font>");
                	email = true;
         		}else if("FORM_ING_CANCEL_UPDATE".equals(event)){//취소
         			mailtitle.append("* 입찰 취소 에 대한 공지 메일입니다.");
                    mailtitlein.append("* 입찰 취소 에 대한 공지 메일입니다.");
                 	mailContent.append(row.get("VENDOR_NAME")+"님께 안내드린 입찰건이 아래와 같은 내용으로 취소되었음을 알려드립니다.<br>");
                 	mailContent.append("<font style='width:auto; font-size:12px; line-height:18px; padding:5px; text-align:left;'>");
                 	mailContent.append("<br>");
                 	mailContent.append("1.프로젝트 : " + bid_Master.get("DEPT_NM") + "<br>");
                 	mailContent.append("2.공고번호 : " + bid_Master.get("BID_NO") + "<br>");
                 	mailContent.append("3.공고건명 : " + bid_Master.get("BID_MASTER_NM") + "<br>");
                 	mailContent.append("4.입찰 취소 사유 : " + StringUtils.cvtHTML(bid_Master.get("CANCEL_REASON")) + "<br>");
                 	mailContent.append("5.입찰담당자 : " +bid_Master.get("BUSEO_NM")+" / "+ bid_Master.get("USER_NAME") +" (연락처 : " + bid_Master.get("PO_EMPNM") + ", 이메일 : " + bid_Master.get("E_MAIL") + ")<br>");
                 	mailContent.append("</font>");
                 	email = true;
         		}else if("FORM_POSTPONE_UPDATE".equals(event)){//연기
         			if("Y".equals(params.get("DELAY_NOTI_YN"))){//공지여부가 Y인경우만 발송
	         			mailtitle.append("* 입찰  마감시간 변경에 대한 공지 메일입니다.");
	                    mailtitlein.append("* 입찰 마감시간 변경에 대한 공지 메일입니다.");
	                  	mailContent.append(row.get("VENDOR_NAME")+"님께 안내드린 입찰건의 입찰서 제출마감시간이 변경되었음을 알려드립니다.<br>");
	                  	mailContent.append("<font style='width:auto; font-size:12px; line-height:18px; padding:5px; text-align:left;'>");
	                  	mailContent.append("<br>");
	                  	mailContent.append("1.프로젝트 : " + bid_Master.get("DEPT_NM") + "<br>");
	                  	mailContent.append("2.공고번호 : " + bid_Master.get("BID_NO") + "<br>");
	                  	mailContent.append("3.공고건명 : " + bid_Master.get("BID_MASTER_NM") + "<br>");
	                  	mailContent.append("4.변경 입찰 마감일시 : " + bid_Master.get("BID_TO_DT_NM") + "<br>");
	                  	mailContent.append("5.변경 사유 : " + StringUtils.cvtHTML(bid_Master.get("POSTPONE_REASON")) + "<br>");
	                  	mailContent.append("6.입찰담당자 : " +bid_Master.get("BUSEO_NM")+" / "+ bid_Master.get("USER_NAME") +" (연락처 : " + bid_Master.get("PO_EMPNM") + ", 이메일 : " + bid_Master.get("E_MAIL") + ")<br>");
	                  	mailContent.append("</font>");
	                  	email = true;
         			}
     			}else if("FORM_CANCEL_UPDATE".equals(event)){//유찰
     				mailtitle.append("* 참여하신 입찰의 유찰 공지 메일입니다.");
                	mailtitlein.append("* 참여하신 입찰의 유찰 공지 메일입니다.");
	             	mailContent.append(row.get("VENDOR_NAME")+"님이 참여한 입찰건이 아래와 같은 내용으로 유찰되었음을 알려드립니다.<br>");
	             	mailContent.append("<font style='width:auto; font-size:12px; line-height:18px; padding:5px; text-align:left;'>");
	             	mailContent.append("<br>");
	             	mailContent.append("1.프로젝트 : " + bid_Master.get("DEPT_NM") + "<br>");
	             	mailContent.append("2.공고번호 : " + bid_Master.get("BID_NO") + "<br>");
	             	mailContent.append("3.공고건명 : " + bid_Master.get("BID_MASTER_NM") + "<br>");
	             	mailContent.append("4.유찰 사유 : " + StringUtils.cvtHTML(bid_Master.get("FIB_REASON")) + "<br>");
	             	mailContent.append("5.입찰담당자 : " +bid_Master.get("BUSEO_NM")+" / "+ bid_Master.get("USER_NAME") +" (연락처 : " + bid_Master.get("PO_EMPNM") + ", 이메일 : " + bid_Master.get("E_MAIL") + ")<br>");
	             	mailContent.append("</font>");
	             	email = true;
     			}else if("FILE_REQUEST".equals(event)){//TBE문서 제출 요청
     				mailtitle.append("* 기술심사 문서 제출에 대한 요청 메일입니다.");
                	mailtitlein.append("* 기술심사 문서 제출에 대한 요청 메일입니다.");
	             	mailContent.append(row.get("VENDOR_NAME")+"님께 안내드린 입찰건에 대한 기술문서 제출(첨부)를 요청드립니다.<br>");
	             	mailContent.append("<font style='width:auto; font-size:12px; line-height:18px; padding:5px; text-align:left;'>");
	             	mailContent.append("<br>");
	             	mailContent.append("1.프로젝트 : " + bid_Master.get("DEPT_NM") + "<br>");
	             	mailContent.append("2.공고번호 : " + bid_Master.get("BID_NO") + "<br>");
	             	mailContent.append("3.공고건명 : " + bid_Master.get("BID_MASTER_NM") + "<br>");
	             	mailContent.append("4.TBE담당자 : " +bid_Master.get("BUSEO_NM")+" / "+ bid_Master.get("EVAL_EMPNM") +" (연락처 : " + bid_Master.get("EVAL_TEL") + ", 이메일 : " + bid_Master.get("EVAL_EMAIL") + ")<br>");
	             	mailContent.append("</font>");
     				email = true;
         		}else if("MOD_UPDATE".equals(event)){
         			mailtitle.append("* 입찰관련 정정사항이 발생되어 알려드립니다.");
                	mailtitlein.append("* 입찰관련 정정사항이 발생되어 알려드립니다.");
	             	mailContent.append(row.get("VENDOR_NAME")+"님께 알려드린 입찰건이 아래와 같은 내용으로 정정되었음을 알려드립니다.<br>");
	             	mailContent.append("<font style='width:auto; font-size:12px; line-height:18px; padding:5px; text-align:left;'>");
	             	mailContent.append("<br>");
	             	mailContent.append("1.공고번호 : " + bid_Master.get("BID_NO") + "<br>");
	             	mailContent.append("2.공고건명 : " + bid_Master.get("BID_MASTER_NM") + "<br>");
	             	mailContent.append("3.입찰담당자 : " +bid_Master.get("BUSEO_NM")+" / "+ bid_Master.get("USER_NAME") +" (연락처 : " + bid_Master.get("PO_EMPNM") + ", 이메일 : " + bid_Master.get("E_MAIL") + ")<br>");
	             	mailContent.append("4.정정 사유 : " + StringUtils.cvtHTML(bid_Master.get("MODIFY_REASON")) + "<br>");
	             	mailContent.append("</font>");
	             	email = true;
         		}
                if(email){
                	messageSend.sendEmail(row.get("CHARGE_EMAIL"), "partner@sgc.co.kr", mailtitle.toString(), mailtitlein.toString(), mailContent);
                }
     		}
     		if(!row.get("CHAGE_HP").isEmpty()){
         		String smsContent = "";
         		if("COMPLETION".equals(event)){//견적의뢰
         			smsContent = WAFMessages.getMessage("Submit.Estimate.request");
         		}else if("RE_BID_SAVE".equals(event)){//재입찰
         			smsContent = WAFMessages.getMessage("Submit.ReEstimate.request");
         		}else if("FORM_ING_CANCEL_UPDATE".equals(event)){//취소
         			smsContent = WAFMessages.getMessage("Cancellation.Guide");
         		}else if("FORM_POSTPONE_UPDATE".equals(event)){//연기
         			if("Y".equals(params.get("DELAY_NOTI_YN"))){//공지여부가 Y인경우만 발송
         				smsContent = WAFMessages.getMessage("Change.Estimate.Submission");
         			}
     			}else if("FORM_CANCEL_UPDATE".equals(event)){//유찰
         			smsContent = WAFMessages.getMessage("failure.Bid.Guide");
     			}else if("FILE_REQUEST".equals(event)){//TBE문서 제출 요청
         			smsContent = WAFMessages.getMessage("Tech.Document.Request");
         		}else if("MOD_UPDATE".equals(event)){//정정
         			smsContent = "입찰정정공고안내'||CHR(13)||CHR(10)||'협력업체포탈시스템에 접속/확인바랍니다.'||CHR(13)||CHR(10)||'SGC이앤씨(주)";
         		}

	            
	            String re_phon_no = row.get("CHAGE_HP").replace("-", ""); //받는사람  row.get("CHAGE_HP").replace("-", "");
	            if(!smsContent.isEmpty()){
	            	messageSend.sendSMS(re_phon_no,bid_Master.get("PO_EMPNM").replace("-", ""), storage.getUser().get("ACCT_ID"), smsContent); //2015.9.21 입찰담당자 전화번호 BID_MASTER.PO_EMPNM 
	            }
     		}
     	}
	}
	
	public static boolean signidentify(String signClassCd,String key_col1,String key_col2) throws Exception {
		return signidentify(signClassCd,key_col1,key_col2, "");
	}
	
	public static boolean signidentify(String signClassCd,String key_col1,String key_col2, String key_col3) throws Exception {
		Search search = new SearchImpl(); 
	 	RowSet rowSet = new RowSetImpl();
	 	StringBuffer sqlstr = new StringBuffer();
	 	String rtnStr = "";
	 	try {
	 		sqlstr.append(" SELECT  COUNT(*) AS CNT                                                                   	\n");
	 		sqlstr.append(" FROM    SIGN001T                                                                     	\n");
	 		sqlstr.append("	WHERE SIGN_CLASS_CD = '"+signClassCd+"'												\n");
	 		if(!key_col1.isEmpty())
	 			sqlstr.append("	AND KEY_COL1 = '"+key_col1+"'	 														\n");
	 		if(!key_col2.isEmpty())
	 			sqlstr.append("	AND KEY_COL2 = '"+key_col2+"'	 														\n");
	 		if(!key_col3.isEmpty())
	 			sqlstr.append("	AND KEY_COL3 = '"+key_col3+"'	 														\n");
	 		sqlstr.append("	AND ATTR_6  = '0'  																				\n");
	 		search.setStatement(sqlstr);
	 		rowSet = search.execute();
	 		if(rowSet != null && rowSet.size() > 0 ) {
	 			rtnStr = rowSet.getRow(0).get("CNT");
	 		}
	 		if( !"0".equals(rtnStr) ){
	 			return false;
	        }
	 	}catch(Exception e){
	 		return false;
	 	}
	 	return true;
	}
}