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



import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import oracle.toplink.internal.ox.StrBuffer;
import kr.co.hsnc.common.base.WAFLogger;
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.persistent.Persistent;
import kr.co.hsnc.common.sql.persistent.PersistentImpl;
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.code.CommCodeManager;
import kr.co.udapsoft.common.sender.MessageSend;
import kr.co.udapsoft.ebid.buyer.common.file.FileManager;
import kr.co.udapsoft.ebid.buyer.sycs.user.biz.UserCommon;

import com.udapsoft.modular.web.ibsheet7.IBSheet7Factory;
import com.udapsoft.modular.web.ibsheet7.util.IBSheet7Utils;
import com.udapsoft.waf.system.Biz;
import com.udapsoft.waf.system.HandlerStorage;

   
public class BidIngBiz extends Biz {

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

	public void doBiz() throws Exception {
        ValueObject user = new ValueObject();
		
		if(storage.compareEvent("SHEET_SELECT")){
			params.set("sheet1", getBoardList(params));
			storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
		}else if(storage.compareEvent("FORM_SELECT")){//견적의뢰
	            user = getOrderReqeustValueObject();
	            storage.addValueObject("Order", user);
	            /**		파일 목록 조회			 **/
		        storage.addValueObject(user.get("DOC_ETC_IN"), getfilelist(user.get("DOC_ETC_IN"),params.get("DEMANDED_ID"),user.get("DOC_ETC_IN")));
		        storage.addValueObject(user.get("DOC_ETC_OUT"), getfilelist(user.get("DOC_ETC_OUT"),params.get("DEMANDED_ID"),user.get("DOC_ETC_OUT")));
		        
		        storage.addValueObject("SIGN_INFO", getSignInfo(params.get("DEMANDED_ID")));
		}else if(storage.compareEvent("FORM_SELECT_SITE")){//견적의뢰
            user = getOrderReqeustValueObject2(params.get("DEMANDED_ID"));
            storage.addValueObject("Order", user);
            /**		파일 목록 조회			 **/
	        storage.addValueObject(user.get("DOC_ETC_IN"), getfilelist(user.get("DOC_ETC_IN"),params.get("DEMANDED_ID"),user.get("DOC_ETC_IN")));
	        storage.addValueObject(user.get("DOC_ETC_OUT"), getfilelist(user.get("DOC_ETC_OUT"),params.get("DEMANDED_ID"),user.get("DOC_ETC_OUT")));
		}else if(storage.compareEvent("GET_CORP_LIST")){
			 params.set("sheet1", getCorpList(params.get("DEMANDED_ID")));
	         storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
		}else if(storage.compareEvent("GET_ITEM_LIST")){
			 params.set("sheet2", geitemList(params));
	         storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
		}else if(storage.compareEvent("EXAM_REQUEST_FORM")){
			updateRequest();	//개찰요청구분
            
	     	ValueObject email_info = email_info(params);
	     	//2020.05.13 개찰자와 구매담당자가 다른 경우 메일발송
	     	if(!email_info.get("E_MAIL").isEmpty() && !email_info.get("E_MAIL").equals(email_info.get("PUR_EMAIL"))){
				MessageSend messageSend = new MessageSend(storage);
	     		StringBuffer mailtitle = new StringBuffer();
	     		StringBuffer mailtitlein = new StringBuffer();
	            StringBuffer mailContent = new StringBuffer();
	 			mailtitle.append("[견적개찰]"+ email_info.get("DEPT_NM") + ", " +email_info.get("DEMANDED_TITLE")+" 개찰요청");
	        	mailtitlein.append("* 견적서 개찰 요청 메일입니다.");
	         	mailContent.append("다음의 입찰 건에 대해 견적서 접수 및 기술검토가 완료되어 개찰 요청 드립니다.<br>");
	         	mailContent.append("전자조달 시스템에 로그인하시어 "+'"'+"견적서 개찰"+'"'+" 메뉴에서 확인 바랍니다. ");
	         	mailContent.append("<font style='width:auto; font-size:12px; line-height:18px; padding:5px; text-align:left;'>");
	         	mailContent.append("<br>");
	         	mailContent.append("1.프로젝트 : " + email_info.get("DEPT_NM") + "<br>");
	         	mailContent.append("2.입 찰 명 : " + email_info.get("BID_MASTER_NM") + " ( " + email_info.get("BID_NO") +" )<br>");
	         	mailContent.append("3.실행예산 : " + email_info.get("CURRENCY_GB")+" " + email_info.get("ACT_AMT") + "<br>");
	         	mailContent.append("4.구매구분 : " +email_info.get("DEMANDED_KIND_NM")+"<br>");
	         	mailContent.append("5.담 당 자 : " +email_info.get("GRADE_NAME")+" "+ email_info.get("USER_NAME") +" (사내번호 : " + email_info.get("TEL_NO") + ")<br>");
	         	mailContent.append("</font>");
	         	mailContent.append("<font style='width:auto; font-size:14px; line-height:18px; padding:5px; text-align:left;'>");
	         	mailContent.append("<a href='http://ebid.sgcenc.co.kr/bid/purchase/BidOpenList.screen'>개찰 바로가기</a>");
	         	mailContent.append("</font>");
	         	messageSend.sendEmail(email_info.get("E_MAIL"), "partner@sgc.co.kr", mailtitle.toString(), mailtitlein.toString(), mailContent,"N");
	     	}
		}else{
			user = getSiteInfo();
            storage.addValueObject("Order", user);
		}
		
	}
	
	private ValueObject getfilelist(String filegb,String id,String returnid){
		ValueObject vo = new ValueObject();
		RowSet rowSet = FileManager.getFileList(filegb, id);
		String str="";
	        for(int i=0;i<rowSet.size();i++){
	        	Row row=rowSet.getRow(i);
	        	str += (i+1)+" : "+row.get("FILE_NAME")+" ("+ row.get("FILE_SIZE")+")";
	        	if(i+1!=rowSet.size()){
	        		str +="\r\n";
	        	}
	        }
	        vo.set(returnid, str);
		return vo;
	}

	/**
	 * 발주의뢰(외주) 접수를 검색하여 리턴
	 * @param Params
	 * @return
	 */
	private RowSet getBoardList(ValueObject param) {

		Search search = new SearchImpl();
        RowSet rowSet = new RowSetImpl();
        
     //   String sqlstr = "";
        StrBuffer sqlstr = new StrBuffer();
        try{ 
        	sqlstr.append(" SELECT A.BID_DEG																															\n");
        	sqlstr.append("      , B.DEPT_NM																																\n");
        	sqlstr.append("      , A.BID_NO																																\n");
        	sqlstr.append("      , A.DEMANDED_TITLE																													\n");
        	sqlstr.append("      , A.BID_MASTER_NM																													\n");
        	sqlstr.append("      , A.ONBID_YN																															\n");
        	sqlstr.append("      , TO_CHAR(A.REQUEST_DATE,'YYYY-MM-DD') AS REQUEST_DATE														\n");
        	sqlstr.append("      , TO_CHAR(A.RECEIPT_DATE,'YYYY-MM-DD') AS RECEIPT_DATE															\n");
        	sqlstr.append("      , A.STATUS_CD 																															\n");
        	sqlstr.append("      , F_GET_CODE_NAME('BID_STATUS_CD',STATUS_CD) AS STATUS_NM													\n");
        	sqlstr.append("      , A.DEMANDED_ID		 																												\n");
        	sqlstr.append("   FROM BID_MASTER A	, ACZ10100V B																									\n");
        	sqlstr.append("   WHERE A.DEPT_CD = B.DEPT_CD																										\n");
        	sqlstr.append("   AND A.STATUS_CD IN ('00','01','02')																							\n");
        	if(!param.get("P_DEPT_CD").isEmpty())
        		sqlstr.append("   AND A.DEPT_CD = '"+param.get("P_DEPT_CD")+"'																											\n");
        	if(!param.get("p_demanded_title").isEmpty())
        		sqlstr.append("   AND A.DEMANDED_TITLE LIKE '%'|| '"+param.get("p_demanded_title")+"' ||'%'																						\n");
        	if(!param.get("P_DEMANDED_FROM_DT").isEmpty())
        		sqlstr.append("   AND A.REQUEST_DATE >  TO_DATE('"+param.get("P_DEMANDED_FROM_DT")+"'||'000000','YYYY-MM-DDHH24MISS') 					\n");
        	if(!param.get("P_DEMANDED_TO_DT").isEmpty())
        		sqlstr.append("   AND A.REQUEST_DATE < TO_DATE('"+param.get("P_DEMANDED_TO_DT")+"'||'235959','YYYY-MM-DDHH24MISS') 						\n");
        	if(!param.get("P_RCEIPT_FROM_DT").isEmpty())
        		sqlstr.append("   AND A.RECEIPT_DATE  >  TO_DATE('"+param.get("P_RCEIPT_FROM_DT")+"'||'000000','YYYY-MM-DDHH24MISS')							\n");
        	if(!param.get("P_RCEIPT_TO_DT").isEmpty())
        		sqlstr.append("   AND A.RECEIPT_DATE  <  TO_DATE('"+param.get("P_RCEIPT_TO_DT")+"'||'235959','YYYY-MM-DDHH24MISS')								\n");
        	if(!param.get("P_DEMANDED_STATUS").isEmpty())
        		sqlstr.append("   AND A.STATUS_CD = '"+param.get("P_DEMANDED_STATUS")+"'																						\n");
			search.setStatement(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
	 */
	private ValueObject getOrderReqeustValueObject() {

		Search search = new SearchImpl();
        RowSet rowSet = new RowSetImpl();
        ValueObject valueobject = null;
     //   String sqlstr = "";
        StrBuffer sqlstr = new StrBuffer();
        try{
               sqlstr.append("       SELECT TO_CHAR(TO_DATE(A.DEMANDED_DATE,'YYYYMMDD'),'YYYY-MM-DD') AS DEMANDED_DATE,                                        \n");
		       sqlstr.append("       A.DEMANDED_TITLE,                                        \n");
		       sqlstr.append("       A.DEMANDED_KIND,                                        \n");
		       sqlstr.append("       F_GET_CODE_NAME('911',A.CURRENCY_GB) AS CURRENCY_GB_NM,                                        \n");
		       sqlstr.append("       A.CURRENCY_GB,                                        \n");
		       sqlstr.append("       A.DEPT_CD,                                        \n");
		       sqlstr.append("       A.EMP_NO,                                        \n");
		       sqlstr.append("       GET_USER_BUSEO_NM(A.EMP_NO) AS BUSEO_NM,                                          \n");
		       sqlstr.append("       A.DELIVERY_CONDITION,                                        \n");
		       sqlstr.append("       A.CRE_BY,                                        \n");
		       sqlstr.append("       A.CRE_DATE,                                        \n");
		       sqlstr.append("       A.UPD_BY,                                        \n");
		       sqlstr.append("       A.UPD_DATE,                                        \n");
		       sqlstr.append("       A.DEMANDED_NO,                                        \n");
		       sqlstr.append("       A.BID_APP_DATE,                                        \n");
		       sqlstr.append("       A.BID_APP_NO,                                        \n");
		       sqlstr.append("       A.PAY_ITEM,                                        \n");
		       sqlstr.append("       F_GET_PAY_ITEM_VIEW(A.PAY_ITEM,A.COST_CODE,A.COST_TYPE,A.DEPT_CD) AS PAY_ITEM_NM,                \n");
		       sqlstr.append("       A.COST_CODE,                                        \n");
		       sqlstr.append("       A.COST_TYPE,                                        \n");
		       sqlstr.append("       TO_CHAR(A.RECEIPT_DATE,'YYYY-MM-DD') AS RECEIPT_DATE,                                        \n");
		       sqlstr.append("       DECODE(A.SITEDESC_FLAG,'Y','예','N','아니오','') AS SITEDESC_FLAG,                                        \n");
		       sqlstr.append("       A.SITEDESCCHRGPRSNID,                                        \n");
		       sqlstr.append("       F_GET_USER_NM(A.SITEDESCCHRGPRSNID) AS SITEDESCCHRGPRSNNM,                                        \n");
		       sqlstr.append("       A.SITEDESCTELNO,                                        \n");
		       sqlstr.append("       TO_CHAR(A.SITEDESCDATE,'YYYY-MM-DD HH24:MI') AS SITEDESCDATE,                                        \n");
		       sqlstr.append("       TO_CHAR(A.SITEDESCDATE,'YYYY-MM-DD') AS SITEDESCDT,                                        \n");
		       sqlstr.append("       A.SITEDESCPLACE,                                        \n");
		       sqlstr.append("       A.SITEDESCEMAIL,                                        \n");
		       sqlstr.append("       A.PUREMPNO,                                        \n");
		       sqlstr.append("       F_GET_USER_NM(A.PUREMPNO) AS PUREMPNM,                                        \n");
		       sqlstr.append("       A.INNER_REMARKS,                                        \n");
		       sqlstr.append("       A.TBE_FLAG,                                        \n");
		       sqlstr.append("       DECODE(A.TBE_FLAG,'Y','예','N','아니오','') AS TBE_FLAG_NM,                   \n");
		       sqlstr.append("       A.OUTER_REMARKS,                                        \n");
		       sqlstr.append("       A.DEMANDED_ID,                                        \n");
		       sqlstr.append("       TO_CHAR(A.REQUEST_DATE,'YYYY-MM-DD') AS REQUEST_DATE,                                        \n");
		       sqlstr.append("       A.ATT_ID,                                        \n");
		       sqlstr.append("       A.BID_NO,                                        \n");
		       sqlstr.append("       A.BID_DEG,                                        \n");
		       sqlstr.append("       F_GET_CODE_NAME('ONBID',ONBID_YN) AS ONBID_YN,                                       \n");
		       sqlstr.append("       F_GET_CODE_NAME('CMPT_CD',A.CMPT_CD) AS CMPT_NM,                                        \n");
		       sqlstr.append("       A.CMPT_CD,                                        \n");
		       sqlstr.append("       F_GET_CODE_NAME('SUCC_CD',A.SUCC_CD) AS SUCC_NM,                                        \n");
		       sqlstr.append("       A.SUCC_CD,                                        \n");
		       sqlstr.append("       TO_CHAR(TO_DATE(A.NOTI_DY,'YYYYMMDD'),'YYYY-MM-DD') AS NOTI_DY,                                        \n");
		       sqlstr.append("       A.SITEDESC_CRG_NM,                                        \n");
		       sqlstr.append("       TO_CHAR(A.BID_FROM_DT,'YYYY-MM-DD HH24:MI') AS BID_FROM_DT,                                        \n");
		       sqlstr.append("       TO_CHAR(A.BID_TO_DT,'YYYY-MM-DD HH24:MI') AS BID_TO_DT,                                        \n");
		       sqlstr.append("       A.PO_EMPNM,                                        \n");
		       sqlstr.append("       A.OPEN_EMPNM,                                        \n");
		       sqlstr.append("       A.OPEN_EMPID,                                        \n");
		       sqlstr.append("       TO_CHAR(TO_DATE(A.DELI_FROM_DY,'YYYYMMDD'),'YYYY-MM-DD') AS DELI_FROM_DY,                                        \n");
		       sqlstr.append("       TO_CHAR(TO_DATE(A.DELI_TO_DY,'YYYYMMDD'),'YYYY-MM-DD') AS DELI_TO_DY,                                        \n");
		       sqlstr.append("       A.DELIVERY_PLACE,                                        \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.DEPT_NM,                                        \n");
		       sqlstr.append("       A.REQ_DEPT_CD,                                        \n");
		       sqlstr.append("       A.REQ_DEPT_NM,                                        \n");
		       sqlstr.append("       A.EMP_NM,                                        \n");
		       sqlstr.append("       A.STATUS_CD,                                        \n");
		       sqlstr.append("       F_GET_CODE_NAME('BID_STATUS_CD',A.STATUS_CD) AS STATUS_NM,                                      \n");    
		       sqlstr.append("       A.OPEN_DT,                                        \n");
		       sqlstr.append("       A.CONT_APP_DATE,                                        \n");
		       sqlstr.append("       A.CONT_APP_NO,                                        \n");
		       sqlstr.append("       A.CONT_AMT,                                        \n");
		       sqlstr.append("       A.ACT_AMT,                                        \n");
		       sqlstr.append("       A.PUR_AMT,                                        \n");  //2015.02.27 구매외주예산추가 mklee
		       sqlstr.append("       A.ACT_RATE,                                        \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.CURRENCY_GB_YN,                                        \n");
		       sqlstr.append("       A.DELIVERY_CONDITION_YN,                                        \n");
		       //sqlstr.append("       A.EXCHANGE                                        \n");
		       sqlstr.append("       TO_CHAR(B.SUPP_REQ_DY,'YYYY-MM-DD') AS SUPP_REQ_DY,                                        \n");
		       sqlstr.append("       B.EVAL_EMPNM,                                        \n");
		       sqlstr.append("       B.EVAL_EMPID,                                        \n");
		       sqlstr.append("       A.OUT_ITEM_CD,                                        \n");
		       sqlstr.append("       GET_OUT_ITEM_NM(A.OUT_ITEM_CD) AS OUT_ITEM_NM,						\n");
		       sqlstr.append("       A.PBC_DEFECT_CONDI,			\n");
		       sqlstr.append("       A.CBC_DERECT_TERM_CD,			\n");
		       sqlstr.append("       F_GET_CODE_NAME('CBC_DERECT_TERM_CD',A.CBC_DERECT_TERM_CD) AS CBC_DERECT_TERM_NM,			\n");
		       sqlstr.append("       A.CBC_DEFECT_DAY,				\n");
		       sqlstr.append("       A.PBC_DEFECT_CONDI2,			\n");
		       sqlstr.append("       A.CBC_DERECT_TERM_CD2,			\n");
		       sqlstr.append("       A.CBC_DEFECT_DAY2,				\n");
		       sqlstr.append("       A.WARR_RATE,				\n");
		       sqlstr.append("       A.WARR_CONDI,				\n");
		       sqlstr.append("       A.CONTFUL_RATE,				\n");
		       sqlstr.append("       A.CONTFUL_CONDI,			\n");
		       sqlstr.append("       A.PBC_FRSTGUAR_RATE,			\n");
		       sqlstr.append("       A.PBC_FRSTGUAR_CONDI,			\n");
		       sqlstr.append("       A.PBC_REST_RATE,				\n");
		       sqlstr.append("       A.PBC_REST_CONDI,				\n");
		       sqlstr.append("       A.CPC_MID_RATE,				\n");
		       sqlstr.append("       A.PBC_MID_CONDI,				\n");
		       sqlstr.append("       A.CBC_FIRST_RATE,				\n");
		       sqlstr.append("       A.PBC_FIRST_CONDI,			\n");
		       sqlstr.append("       A.CBC_DAMAGE_RATE,			\n");
		       sqlstr.append("       A.CBC_DAMAGE_MAXRATE,			\n");
		       sqlstr.append("       F_GET_CODE_NAME('LIQ_DMG_CD', A.CBC_DAMAGE_CD) AS CBC_DAMAGE_NM,			\n");
		       sqlstr.append("       A.PBC_OPTION_COMMENT,			\n");
		       sqlstr.append("       A.PBC_OPTION_YN,				\n");
		       sqlstr.append("       A.PBC_FEE_YN,				\n");
		       sqlstr.append("       A.DELIVERY_CONDITION,			\n");
		       sqlstr.append("       F_GET_CODE_NAME('PUR_LEAD_GB',A.DELIVERY_CONDITION) AS DELIVERY_CONDITION_NM,			\n");
		       sqlstr.append("       A.DELIVERY_CONDITION_YN,			\n");
		       sqlstr.append("       A.PBC_LANDTRAN_YN,			\n");
		       sqlstr.append("       A.PBC_PACK_YN,				\n");
		       sqlstr.append("       A.PBC_DOC_YN,				\n");
		       sqlstr.append("       A.PBC_TEST_YN,				\n");
		       sqlstr.append("       A.PBC_SPETOOL_YN,				\n");
		       sqlstr.append("       A.PBC_COMMISS_YN,				\n");
		       sqlstr.append("       A.PBC_INSTALL_YN,				\n");
		       sqlstr.append("       A.PBC_CBE_TYPE_CD,			\n");
		       sqlstr.append("       A.REBID_REASON,								\n"); //2015.3.3 재입찰사유 입력 mklee
		       sqlstr.append("       A.REBID_OUTREASON,								\n"); //2015.3.19 재입찰 외부 입력 CHJ
		       sqlstr.append("      (SELECT COUNT(*) AS CNT FROM BID_SUPP S WHERE S.BID_NO = A.BID_NO AND S.BID_DEG = A.BID_DEG AND S.ESTI_SIGNDATA IS NOT NULL) AS MODIFY_CNT,		\n");
		       sqlstr.append("       A.DIV_PO_YN,						\n");
		       sqlstr.append("       A.MATERIAL_GB,						\n");
		       sqlstr.append("       A.MAIN_PR_CONTENTS,				\n");
		       sqlstr.append("       A.BID_SUPP_SELECT_REASON			\n");
		       sqlstr.append("        FROM BID_MASTER A  , TBE_INFO B                                      \n");
		       sqlstr.append("       WHERE A.BID_NO = '"+params.get("BID_NO")+"'							\n");
		       sqlstr.append("       AND A.BID_DEG = '"+params.get("BID_DEG")+"'							\n");
		       sqlstr.append("       AND A.BID_NO = B.BID_NO(+)							\n");
			   sqlstr.append("       AND A.BID_DEG = B.BID_DEG(+)							\n");
			   sqlstr.append("  	  AND A.DEMANDED_KIND IN ('C','P','B')	       																									\n");
        	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);
        }
        finally {

        	if( valueobject == null ) valueobject = new ValueObject();
            return valueobject;
        }
	}
	
	/**
	 * 발주의뢰(외주) 접수 상세를 검색하여 리턴
	 * @param Params
	 * @return
	 */
	private ValueObject getOrderReqeustValueObject2(String DEMANDED_ID) {

		Search search = new SearchImpl();
        RowSet rowSet = new RowSetImpl();
        ValueObject valueobject = null;
     //   String sqlstr = "";
        StrBuffer sqlstr = new StrBuffer();
        try{
            	sqlstr.append("       SELECT TO_CHAR(TO_DATE(A.DEMANDED_DATE,'YYYYMMDD'),'YYYY-MM-DD') AS DEMANDED_DATE,                                        \n");
		       sqlstr.append("       A.DEMANDED_TITLE,                                        \n");
		       sqlstr.append("       A.DEMANDED_KIND,                                        \n");
		       sqlstr.append("       A.CURRENCY_GB,                                        \n");
		       sqlstr.append("       A.DEPT_CD,                                        \n");
		       sqlstr.append("       A.EMP_NO,                                        \n");
		       sqlstr.append("       GET_USER_BUSEO_NM(A.EMP_NO) AS BUSEO_NM,                                          \n");
		       sqlstr.append("       A.DELIVERY_CONDITION,                                        \n");
		       sqlstr.append("       A.CRE_BY,                                        \n");
		       sqlstr.append("       A.CRE_DATE,                                        \n");
		       sqlstr.append("       A.UPD_BY,                                        \n");
		       sqlstr.append("       A.UPD_DATE,                                        \n");
		       sqlstr.append("       A.DEMANDED_NO,                                        \n");
		       sqlstr.append("       A.BID_APP_DATE,                                        \n");
		       sqlstr.append("       A.BID_APP_NO,                                        \n");
		       sqlstr.append("       A.PAY_ITEM,                                        \n");
		       sqlstr.append("       F_GET_PAY_ITEM_VIEW(A.PAY_ITEM,A.COST_CODE,A.COST_TYPE,A.DEPT_CD) AS PAY_ITEM_NM,                \n");
		       sqlstr.append("       A.COST_CODE,                                        \n");
		       sqlstr.append("       A.COST_TYPE,                                        \n");
		       sqlstr.append("       TO_CHAR(A.RECEIPT_DATE,'YYYY-MM-DD') AS RECEIPT_DATE,                                        \n");
		       sqlstr.append("       DECODE(A.SITEDESC_FLAG,'Y','예','N','아니오','') AS SITEDESC_FLAG,                                    \n");
		       sqlstr.append("       A.SITEDESCCHRGPRSNID,                                        \n");
		       sqlstr.append("       F_GET_USER_NM(A.SITEDESCCHRGPRSNID) AS SITEDESCCHRGPRSNNM,                                        \n");
		       sqlstr.append("       A.SITEDESCTELNO,                                        \n");
		       sqlstr.append("       TO_CHAR(A.SITEDESCDATE,'YYYY-MM-DD HH24:MI') AS SITEDESCDATE,                                        \n");
		       sqlstr.append("       TO_CHAR(A.SITEDESCDATE,'YYYY-MM-DD') AS SITEDESCDT,                                        \n");
		       sqlstr.append("       A.SITEDESCPLACE,                                        \n");
		       sqlstr.append("       A.SITEDESCEMAIL,                                        \n");
		       sqlstr.append("       A.PUREMPNO,                                        \n");
		       sqlstr.append("       F_GET_USER_NM(A.PUREMPNO) AS PUREMPNM,                                        \n");
		       sqlstr.append("       A.INNER_REMARKS,                                        \n");
		       sqlstr.append("       A.TBE_FLAG,                                    	   \n");
		       sqlstr.append("       A.OUTER_REMARKS,                                        \n");
		       sqlstr.append("       A.DEMANDED_ID,                                        \n");
		       sqlstr.append("       TO_CHAR(A.REQUEST_DATE,'YYYY-MM-DD') AS REQUEST_DATE,                                       \n");
		       sqlstr.append("       A.ATT_ID,                                        \n");
		       sqlstr.append("       A.BID_NO,                                        \n");
		       sqlstr.append("       A.BID_DEG,                                        \n");
		       sqlstr.append("       F_GET_CODE_NAME('ONBID',ONBID_YN) AS ONBID_YN,                                       \n");
		       sqlstr.append("       F_GET_CODE_NAME('CMPT_CD',A.CMPT_CD) AS CMPT_NM,                                        \n");
		       sqlstr.append("       A.CMPT_CD,                                        \n");
		       sqlstr.append("       F_GET_CODE_NAME('SUCC_CD',A.SUCC_CD) AS SUCC_NM,                                        \n");
		       sqlstr.append("       A.SUCC_CD,                                        \n");
		       sqlstr.append("       TO_CHAR(TO_DATE(A.NOTI_DY,'YYYYMMDD'),'YYYY-MM-DD') AS NOTI_DY,                                        \n");
		       sqlstr.append("       A.SITEDESC_CRG_NM,                                        \n");
		       sqlstr.append("       TO_CHAR(A.BID_FROM_DT,'YYYY-MM-DD') AS BID_FROM_DT,                                        \n");
		       sqlstr.append("       TO_CHAR(A.BID_FROM_DT,'HH24') AS BID_FROM_HH,                                        \n");
		       sqlstr.append("       TO_CHAR(A.BID_FROM_DT,'MI') AS BID_FROM_MI,                                        \n");
		       sqlstr.append("       TO_CHAR(A.BID_TO_DT,'YYYY-MM-DD') AS BID_TO_DT,                                        \n");
		       sqlstr.append("       TO_CHAR(A.BID_TO_DT,'HH24') AS BID_TO_HH,                                        \n");
		       sqlstr.append("       TO_CHAR(A.BID_TO_DT,'MI') AS BID_TO_MI,                                        \n");
		       sqlstr.append("       A.PO_EMPNM,                                        \n");
		       sqlstr.append("       A.OPEN_EMPNM,                                        \n");
		       sqlstr.append("       A.OPEN_EMPID,                                        \n");
		       sqlstr.append("       TO_CHAR(TO_DATE(A.DELI_FROM_DY,'YYYYMMDD'),'YYYY-MM-DD') AS DELI_FROM_DY,                                        \n");
		       sqlstr.append("       TO_CHAR(TO_DATE(A.DELI_TO_DY,'YYYYMMDD'),'YYYY-MM-DD') AS DELI_TO_DY,                                        \n");
		       sqlstr.append("       A.DELIVERY_PLACE,                                        \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.DEPT_NM,                                        \n");
		       sqlstr.append("       A.REQ_DEPT_CD,                                        \n");
		       sqlstr.append("       A.REQ_DEPT_NM,                                        \n");
		       sqlstr.append("       A.EMP_NM,                                        \n");
		       sqlstr.append("       A.STATUS_CD,                                        \n");
		       sqlstr.append("       F_GET_CODE_NAME('BID_STATUS_CD',A.STATUS_CD) AS STATUS_NM,                                        \n");
		       sqlstr.append("       A.OPEN_DT,                                        \n");
		       sqlstr.append("       A.CONT_APP_DATE,                                        \n");
		       sqlstr.append("       A.CONT_APP_NO,                                        \n");
		       sqlstr.append("       A.CONT_AMT,                                        \n");
		       sqlstr.append("       A.ACT_AMT,                                        \n");
		       sqlstr.append("       A.PUR_AMT,                                        \n");  //2015.02.27 구매외주예산추가 mklee
		       sqlstr.append("       A.ACT_RATE,                                        \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.CURRENCY_GB_YN,                                        \n");
		       sqlstr.append("       A.DELIVERY_CONDITION_YN,                                        \n");
		       //sqlstr.append("       A.EXCHANGE                                        \n");
		       sqlstr.append("       TO_CHAR(B.SUPP_REQ_DY,'YYYY-MM-DD') AS SUPP_REQ_DY,                                        \n");
		       sqlstr.append("       B.EVAL_EMPNM,                                        \n");
		       sqlstr.append("       B.EVAL_EMPID,                                        \n");
		       sqlstr.append("       A.OUT_ITEM_CD,                                        \n");
		       sqlstr.append("       GET_OUT_ITEM_NM(A.OUT_ITEM_CD) AS OUT_ITEM_NM,						\n");
		       sqlstr.append("       A.PBC_DEFECT_CONDI,			\n");
		       sqlstr.append("       A.CBC_DERECT_TERM_CD,			\n");
		       sqlstr.append("       A.CBC_DEFECT_DAY,				\n");
		       sqlstr.append("       A.PBC_DEFECT_CONDI2,			\n");
		       sqlstr.append("       A.CBC_DERECT_TERM_CD2,			\n");
		       sqlstr.append("       A.CBC_DEFECT_DAY2,				\n");
		       sqlstr.append("       A.WARR_RATE,				\n");
		       sqlstr.append("       A.WARR_CONDI,				\n");
		       sqlstr.append("       A.CONTFUL_RATE,				\n");
		       sqlstr.append("       A.CONTFUL_CONDI,			\n");
		       sqlstr.append("       A.PBC_FRSTGUAR_RATE,			\n");
		       sqlstr.append("       A.PBC_FRSTGUAR_CONDI,			\n");
		       sqlstr.append("       A.PBC_REST_RATE,				\n");
		       sqlstr.append("       A.PBC_REST_CONDI,				\n");
		       sqlstr.append("       A.CPC_MID_RATE,				\n");
		       sqlstr.append("       A.PBC_MID_CONDI,				\n");
		       sqlstr.append("       A.CBC_FIRST_RATE,				\n");
		       sqlstr.append("       A.PBC_FIRST_CONDI,			\n");
		       sqlstr.append("       A.CBC_DAMAGE_RATE,			\n");
		       sqlstr.append("       A.CBC_DAMAGE_MAXRATE,			\n");
		       sqlstr.append("       A.PBC_OPTION_COMMENT,			\n");
		       sqlstr.append("       A.PBC_OPTION_YN,				\n");
		       sqlstr.append("       A.PBC_FEE_YN,				\n");
		       sqlstr.append("       A.DELIVERY_CONDITION,			\n");
		       sqlstr.append("       A.DELIVERY_CONDITION_YN,			\n");
		       sqlstr.append("       A.PBC_LANDTRAN_YN,			\n");
		       sqlstr.append("       A.PBC_PACK_YN,				\n");
		       sqlstr.append("       A.PBC_DOC_YN,				\n");
		       sqlstr.append("       A.PBC_TEST_YN,				\n");
		       sqlstr.append("       A.PBC_SPETOOL_YN,				\n");
		       sqlstr.append("       A.PBC_COMMISS_YN,				\n");
		       sqlstr.append("       A.PBC_INSTALL_YN,				\n");
		       sqlstr.append("       A.PBC_CBE_TYPE_CD,			\n");
		       sqlstr.append("       A.MATERIAL_GB,						\n");
		       sqlstr.append("       A.DIV_PO_YN,						\n");
		       sqlstr.append("       A.MAIN_PR_CONTENTS,				\n");
		       sqlstr.append("       A.BID_SUPP_SELECT_REASON			\n");
		       sqlstr.append("        FROM BID_MASTER A  , TBE_INFO B                                      \n");
		       sqlstr.append("       WHERE A.DEMANDED_ID = '"+DEMANDED_ID+"'							\n");
		       sqlstr.append("       AND A.BID_NO = '"+params.get("BID_NO")+"'							\n");
		       sqlstr.append("       AND A.BID_DEG = '"+params.get("BID_DEG")+"'							\n");
		       sqlstr.append("       AND A.BID_NO = B.BID_NO(+)							\n");
			   sqlstr.append("       AND A.BID_DEG = B.BID_DEG(+)							\n");
			   sqlstr.append(" 	  AND A.DEMANDED_KIND IN ('C','P','B')	       																									\n");

        	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);
        }
        finally {

        	if( valueobject == null ) valueobject = new ValueObject();
            return valueobject;
        }
	}
	
	/**
	 * 발주의뢰(외주) 접수 상세 / 견적대상업체 를 검색하여 리턴
	 * @param Params
	 * @return
	 */
	private RowSet getCorpList(String DEMANDED_ID) {

		Search search = new SearchImpl();
        RowSet rowSet = new RowSetImpl();
        
     //   String sqlstr = "";
        StrBuffer sqlstr = new StrBuffer();
        try{
        	sqlstr.append(" SELECT A.BID_NO,										\n");
        	sqlstr.append("        A.BID_DEG,											\n");
        	sqlstr.append("        A.VENDOR_CD,										\n");
        	sqlstr.append("        A.VENDOR_NO,										\n");
        	sqlstr.append("        A.VENDOR_NAME,									\n");
        	sqlstr.append("        A.REPRE_NO,										\n");
        	sqlstr.append("        A.CHARGE_NAME,									\n");
        	sqlstr.append("        A.CHAGE_HP,										\n");
        	sqlstr.append("        A.CHARGE_EMAIL,									\n");
        	sqlstr.append("        A.CURRENCY_GB,									\n");
        	sqlstr.append("        A.EXCHANGE,										\n");
        	sqlstr.append("        A.DELIVERY_CONDITION,						\n");
        	sqlstr.append("        A.SITEPARTI_YN,									\n");
        	sqlstr.append("        NVL(A.SITE_ATTEND_YN,'NULL') AS SITE_ATTEND_YN,					\n");
        	sqlstr.append("        A.SITE_ATTEND_REASON,						\n");
        	sqlstr.append("        A.TBEAPPR_YN,									\n");
        	sqlstr.append("        A.TBEEVALUATE_YN,								\n");
        	sqlstr.append("        A.CERT_DN,											\n");
        	sqlstr.append("        A.ESTI_SIGNDATA,								\n");
        	sqlstr.append("        DECODE(A.BID_RNNC_DT,NULL,DECODE(A.SIGN_DT,'','미제출',TO_CHAR(A.SIGN_DT,'YYYY-MM-DD HH24:MI:SS')),'입찰포기 ('||TO_CHAR(A.BID_RNNC_DT,'YYYY-MM-DD HH24:MI:SS')||')') AS SIGN_DT,				\n");
        	sqlstr.append("        A.ATT_ID,											\n");
        	sqlstr.append("        A.RECM_DEPT_ID,									\n");
        	sqlstr.append("        A.RECM_DEPT_NM,								\n");
        	sqlstr.append("        A.RECM_EMPID,									\n");
        	sqlstr.append("        A.RECOMMEND_REASON,						\n");
        	sqlstr.append("        A.ESTI_TOT_AMT,								\n");
        	sqlstr.append("        A.WON_ESTI_TOT_AMT,						\n");
        	sqlstr.append("        A.SUCC_YN,										\n");
        	sqlstr.append("        A.FIB_REASON,									\n");
        	sqlstr.append("        A.CRE_BY,											\n");
        	sqlstr.append("        A.CRE_DATE,										\n");
        	sqlstr.append("        A.UPD_BY,											\n");
        	sqlstr.append("        A.UPD_DATE,										\n");
        	sqlstr.append("        F_GET_CODE_NAME('TBE_EVAL', B.EVAL_RESULT ) AS TBE_STATUS             										\n");
        	sqlstr.append("        ,C.CORP_TEL             										\n");
        	sqlstr.append("        ,A.SECRET_YN             										\n");
        	sqlstr.append("        ,A.MORAL_YN             										\n");
        	sqlstr.append("        ,A.INDUSTRY_YN             										\n");
        	sqlstr.append("        ,DECODE(A.SECRET_YN,'Y',TO_CHAR(A.SECRET_YN_DY,'YYYY-MM-DD HH24:MI:SS'),'미확인') AS SECRET_YN_DY             										\n");
        	sqlstr.append("        ,DECODE(A.MORAL_YN,'Y',TO_CHAR(A.MORAL_YN_DY,'YYYY-MM-DD HH24:MI:SS'),'미확인') AS MORAL_YN_DY             										\n");
        	sqlstr.append("        ,DECODE(A.INDUSTRY_YN,'Y',TO_CHAR(A.INDUSTRY_YN_DY,'YYYY-MM-DD HH24:MI:SS'),'미확인') AS INDUSTRY_YN_DY             										\n");
        	sqlstr.append("        ,DECODE(A.ROLES_YN,'Y',TO_CHAR(A.ROLES_YN_DY,'YYYY-MM-DD HH24:MI:SS'),'미확인') AS ROLES_YN_DY             										\n");
        	sqlstr.append("        ,DECODE(A.PRICESYS_YN,'Y',TO_CHAR(A.PRICESYS_YN_DY,'YYYY-MM-DD HH24:MI:SS'),'미확인') AS PRICESYS_YN_DY             										\n");
        	sqlstr.append("   FROM BID_SUPP A										\n");
        	sqlstr.append("      , TBE_SUPP B 										\n");
        	sqlstr.append("      , SUPP_INFO C 										\n");
        	sqlstr.append("    WHERE A.VENDOR_CD = B.VENDOR_CD(+) 									\n");
        	sqlstr.append("   AND A.BID_NO = B.BID_NO(+)											\n");
        	sqlstr.append("    AND A.BID_DEG = B.BID_DEG(+)										\n");
        	sqlstr.append("    AND A.VENDOR_CD = C.CORP_ID											\n");
        	sqlstr.append(" AND A.BID_NO = '"+params.get("BID_NO")+"'	\n");
        	sqlstr.append(" AND A.BID_DEG = '"+params.get("BID_DEG")+"'		\n");
        	
        	if(("Y".equals(params.get("SITEDESC_FLAG")) || "예".equals(params.get("SITEDESC_FLAG")))&&"Y".equals(params.get("SITEPARTI_YN")))
        		sqlstr.append(" AND A.SITEPARTI_YN = 'Y'							\n");
			sqlstr.append(" ORDER BY A.SIGN_DT DESC NULLS LAST								\n");
			search.setStatement(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
	 */
	private RowSet geitemList(ValueObject param) {
		Search search = new SearchImpl();
        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.MATERIAL_CD,          \n");
        	sqlstr.append("           TO_CHAR(TO_DATE(A.REQUEST_DATE,'YYYYMMDD'),'YYYY-MM-DD') AS REQUEST_DATE,          \n");
        	sqlstr.append("           A.CONT_UNIT_AMT,          \n");
        	sqlstr.append("           A.ACT_UNIT_AMT,          \n");
        	sqlstr.append("           A.DEMANDED_PRI,          \n");
        	sqlstr.append("           A.DEMANDED_QTY,          \n");
        	sqlstr.append("           B.MATERIAL_SPEC AS STD,          \n");
        	sqlstr.append("           B.MATERIAL_NAME,          \n");
        	sqlstr.append("           F_GET_UNIT_KIND_NAME(A.MATERIAL_CD) AS UNIT_KIND          \n");
        	sqlstr.append("      FROM BID_ITEM A , PMM_COMM_MATERIAL_MASTER B          \n");
        	sqlstr.append("      WHERE A.MATERIAL_CD = B.MATERIAL_CD          \n");
        	sqlstr.append("        AND A.BID_NO = ?																														\n");
        	sqlstr.append("        AND A.BID_DEG = ?																														\n");	
        	sqlstr.append("        ORDER BY A.MATERIAL_CD																												\n");
			search.setStatement(sqlstr.toString());
			search.addParameter(param.get("BID_NO"));
			search.addParameter(param.get("BID_DEG"));
            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
	 */
	private ValueObject getSiteInfo() {

		Search search = new SearchImpl();
        RowSet rowSet = new RowSetImpl();
        ValueObject valueobject = null;
     //   String sqlstr = "";
        StrBuffer sqlstr = new StrBuffer();
        try{
        	sqlstr.append(" 	 SELECT SITE_ATTEND_REASON 							\n");
			sqlstr.append(" 	   FROM BID_SUPP 											\n");
			sqlstr.append(" 	  WHERE BID_NO = ?											\n");
			sqlstr.append(" 	  AND BID_DEG = ?											\n");
			sqlstr.append(" 	  AND VENDOR_CD = ?										\n");
        	search.setStatement(sqlstr.toString());
        	search.addParameter(params.get("BID_NO"));
        	search.addParameter(params.get("BID_DEG"));
        	search.addParameter(params.get("VENDOR_CD"));
            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);
        }
        finally {

        	if( valueobject == null ) valueobject = new ValueObject();
            return valueobject;
        }
	}
	
	/**
	 * 이메일 정보 
	 * @param Params
	 * @return
	 */
	public ValueObject email_info(ValueObject param) {

		Search search = new SearchImpl();
		 ValueObject valueobject = null;
		RowSet rowSet = new RowSetImpl();
        
        StrBuffer sqlstr = new StrBuffer();
        try{ 
        	
        	
        	sqlstr.append("		SELECT B.E_MAIL                                                                         \n");
        	sqlstr.append("		     , B.USER_NAME  AS OPEN_EMPNM                                                     	\n");
        	sqlstr.append("		     , A.DEPT_NM                                                                       	\n");
        	sqlstr.append("		     , A.DEMANDED_TITLE                                                                	\n");
        	sqlstr.append("		     , A.DEMANDED_NO                                                                   	\n");
        	sqlstr.append("		     , F_GET_D_CURRENCY(A.ACT_AMT, F_GET_CURRENCY_DIGIT('KRW')) AS ACT_AMT              \n");
        	sqlstr.append("		     , 'KRW' AS CURRENCY_GB                                                            	\n");
        	sqlstr.append("		     ,  DECODE(A.DEMANDED_KIND , 'O', '외주' , '구매') AS DEMANDED_KIND_NM              	\n");
        	sqlstr.append("		     ,  C.USER_NAME                                                                     \n");
        	sqlstr.append("		     ,  C.GRADE_NAME                                                                    \n");
        	sqlstr.append("		     ,  C.TEL_NO ,  A.BID_NO, A.BID_MASTER_NM                                           \n");
        	sqlstr.append("		     ,  C.E_MAIL AS PUR_EMAIL                                                           \n");
        	sqlstr.append("		FROM    BID_MASTER A                                                                    \n");
        	sqlstr.append("		   ,    PUB0120T  B                                                                    	\n");
        	sqlstr.append("		   ,    PUB0120T C                                                                     	\n");
        	sqlstr.append("		WHERE A.OPEN_EMPID  = B.ACCT_ID                                                         \n");
        	sqlstr.append("		AND   A.PUREMPNO = C.ACCT_ID                                                            \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;
	}
	
	/**
	 * 발주의뢰 결재 정보 조회
	 * @param DEMANDED_ID
	 * @return
	 */
	private ValueObject getSignInfo(String DEMANDED_ID) {

		Search search = new SearchImpl();
        RowSet rowSet = new RowSetImpl();
        ValueObject vo = new ValueObject();
        
     //   String sqlstr = "";
        StrBuffer sqlstr = new StrBuffer();
        try{
        	sqlstr.append("SELECT DEMANDED_ID, SIGN_CLASS_CD, DOC_ID, YEAR, SIGN_DECI_CLASS, APPROVAL_DATE, APPROVAL_SABUN, APPROVAL_USER                  \n");
        	sqlstr.append("FROM (                                                                                                                    \n");
        	sqlstr.append("          SELECT A.DEMANDED_ID, C.SIGN_CLASS_CD, C.DOC_ID, TO_CHAR(C.CRE_DATE,'YYYYMMDD') YEAR, SIGN_DECI_CLASS, APPROVAL_DATE, APPROVAL_SABUN, APPROVAL_USER  \n");
        	sqlstr.append("          FROM PMM_DEMANDED_REQUEST A, ETECEPC.MR_REQ_PO B, SIGN001T C                                              \n");
        	sqlstr.append("          WHERE A.DEMANDED_ID = B.BUYREQNO                                                      \n");
        	sqlstr.append("          AND B.APPR_ID = C.SIGN_INTERFACE_ID                                                                             \n");
        	sqlstr.append("          AND  C.SIGN_CLASS_CD = 'ebid_mrD'                                                                                    \n");
        	sqlstr.append("          AND C.SIGN_DECI_CLASS IN ( '14', '24')                                                                          \n");
        	sqlstr.append("          UNION ALL                                                                                                       \n");
        	sqlstr.append("          SELECT  A.DEMANDED_ID,  SIGN_CLASS_CD, DOC_ID, TO_CHAR(B.CRE_DATE,'YYYYMMDD') YEAR, SIGN_DECI_CLASS, APPROVAL_DATE, APPROVAL_SABUN, APPROVAL_USER    \n");
        	sqlstr.append("          FROM PMM_DEMANDED_REQUEST A, SIGN001T B                                                                   \n");
        	sqlstr.append("          WHERE  A.DEMANDED_KIND IN ('C', 'P',  'O')                                                                            \n");
        	sqlstr.append("          AND  B.SIGN_CLASS_CD = 'prD'                                                                                    \n");
        	sqlstr.append("          AND B.SIGN_DECI_CLASS IN ( '14', '24')                                                                          \n");
        	sqlstr.append("          AND A.DEMANDED_ID =  REGEXP_REPLACE(B.KEY_COL1,'[^0-9]')                                                                                  \n");
        	sqlstr.append(") A                                                                                                                       \n");
        	sqlstr.append("WHERE 1=1                                                                                                                 \n");
        	sqlstr.append("AND A.DEMANDED_ID = ?                                                                                                     \n");
        	sqlstr.append("ORDER BY DEMANDED_ID                                                                                                      \n");

        	
        	search.setStatement(sqlstr.toString());
        	search.addParameter(DEMANDED_ID);
            rowSet = search.execute();
            if(rowSet.size()>0){
            	vo = RowSetUtility.getValueObject(rowSet.getRow(0));
            }
        }
        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 vo;
	}
	
	
	private boolean update_request(ValueObject params) throws Exception
    {
        
        Persistent persistent = null;
        StringBuffer sqlstr = new StringBuffer();
        
        
        try{
            
            persistent = new PersistentImpl(super.conn.getConnection());
            
            sqlstr.append("             UPDATE BID_MASTER SET                   \n");
            sqlstr.append("                   OPEN_CONFIRM_YN  = 'Y'              \n");
            sqlstr.append("  			WHERE BID_NO = ?						\n");
			sqlstr.append(" 			AND BID_DEG = ?					\n");
            
    
            persistent.setStatement(sqlstr.toString());
            persistent.addParameter(params.get("BID_NO"));
            persistent.addParameter(params.get("BID_DEG"));            
            persistent.execute();
            persistent.clearParameters();
            
            return true;
            
            
        } catch(Exception e) {
        	//System.out.println("e===>" +e);
            e.printStackTrace();
            return false;            
        }
    }
	
	private void updateRequest(){
		boolean success = false;
     	
   	 try 
       {
           conn.begin();
           
           success=update_request(params); 
           
         //System.out.println(success);
           
       } catch (Exception e) {
       	//System.out.println("update_data e======>" + e);
           e.printStackTrace();
           conn.setRollback();
       } finally {
           conn.end();
       }
   	 if(success == true)
       {
           String message = "등록성공";
           ValueObject errMsg = new ValueObject();
           errMsg.set("errMsg", message);
           storage.addValueObject("VALUEOBJECT", errMsg);
       }
       
       super.storage.setSuccess(success);
	}
}