/**
 * @(#)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.outside.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.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 SuccessBidBiz extends Biz {

	public SuccessBidBiz(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")));
		        
	            RowSet getFileListRowSet = getFileListRowSet(params.get("BID_NO"),params.get("BID_DEG"));
	            storage.addRowSet("getFileListRowSet", getFileListRowSet);
	            
	            ValueObject bidmaster = getBidMaster(params.get("BID_NO"),params.get("BID_DEG"));	//입찰 정보 조회
	            storage.addValueObject("bidmaster", bidmaster);		        
		}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("VENDOR_INFO_SELECT")){
			user = getOrderReqeustValueObject();
            storage.addValueObject("Order", user);
            storage.addValueObject(params.get("FILE_GB"), getfilelist(params.get("FILE_GB"),params.get("DEMANDED_ID"),params.get("FILE_GB")));
		}else if(storage.compareEvent("VENDOR_SHEET_SELECT")){
			params.set("sheet1", geitemList(params));
			storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
		}else if(storage.compareEvent("")){
			user = getOrderReqeustSuppValueObject();
            storage.addValueObject("Order", user);
		}else if(storage.compareEvent("PO_CHECK")){
			ValueObject info = getPoCheck(params.get("CONF_NO").trim().toUpperCase());
			storage.addValueObject("VALUEOBJECT",info);
		}else if(storage.compareEvent("GET_ATTACHFILE")){
			//첨부파일
			ValueObject AttachFile = getfilelist("AttachFile");
	        storage.addValueObject("VALUEOBJECT", AttachFile);
        }else if(storage.compareEvent("GET_REPORT_EMP_LIST")){
			 params.set("sheet3", getReportEmpList(params));
	         storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
		}
		
	}
	
	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.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',A.STATUS_CD) AS STATUS_NM												\n");
        	sqlstr.append("      , A.DEMANDED_ID		 																												\n");
        	sqlstr.append("      , TO_CHAR(A.OPEN_DT,'YYYY-MM-DD HH24:MI') AS OPEN_DT															\n");
        	sqlstr.append("      , A.OPEN_EMPNM		 																												\n");
        	sqlstr.append("      , TO_CHAR(C.TBE_FIN_DT,'YYYY-MM-DD HH24:MI') AS TBE_FIN_DT													\n");
        	sqlstr.append("   FROM BID_MASTER A	, ACZ10100V B	 , TBE_INFO C																				\n");
        	sqlstr.append("   WHERE A.DEPT_CD = B.DEPT_CD																										\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.STATUS_CD IN ('04','05','06','07','95')																								\n");
        	sqlstr.append("   AND A.DEMANDED_KIND = 'O'																											\n");
        	sqlstr.append("   AND A.OPEN_DT IS NOT NULL																											\n");
        	// 현장
        	if(!"".equals(params.get("P_DEPT_CD"))) {
        		sqlstr.append(" AND A.DEPT_CD = ? 																												\n");
    			search.addParameter(params.get("P_DEPT_CD"));
        	}
        	if(!param.get("P_BID_MASTER_NM").isEmpty())
        		sqlstr.append("   AND UPPER(A.BID_MASTER_NM) LIKE '%'|| '"+param.get("P_BID_MASTER_NM").toUpperCase()+"' ||'%'																	\n");
        	if(!param.get("P_DEMANDED_FROM_DT").isEmpty() && !param.get("P_DEMANDED_TO_DT").isEmpty())
        		sqlstr.append("   AND A.REQUEST_DATE BETWEEN  '"+param.get("P_DEMANDED_FROM_DT")+"' AND '"+param.get("P_DEMANDED_TO_DT")+"'		\n");
        	if(!param.get("P_RCEIPT_FROM_DT").isEmpty() && !param.get("P_RCEIPT_TO_DT").isEmpty())
        		sqlstr.append("   AND A.REQUEST_DATE BETWEEN  '"+param.get("P_RCEIPT_FROM_DT")+"' AND '"+param.get("P_RCEIPT_TO_DT")+"'					\n");
        	if(!param.get("P_DEMANDED_STATUS").isEmpty())
        		sqlstr.append("   AND A.STATUS_CD = '"+param.get("P_DEMANDED_STATUS")+"'																						\n");
        	sqlstr.append("   ORDER BY OPEN_DT DESC 																								\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("       NVL((SELECT CHG_CODE01 FROM EBID_COM911T WHERE BASECD = '911' AND DETAILCD =A.CURRENCY_GB),0) AS PointCount,        \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("       A.ONBID_YN,                                       \n");
		       sqlstr.append("       F_GET_CODE_NAME('ONBID',ONBID_YN) AS ONBID_YN_NM,                                       \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.ACT_RATE,                                        \n");
		       sqlstr.append("       A.PUR_AMT,                                        \n");  //2015.3.2 외주예산추가 MKLEE
		       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.OPEN_OPINION,                                        \n");  //2015.3.30 개찰의견 
		       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("       B.EVAL_TEL,                                    																					    \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("       F_GET_CODE_NAME('CONT_TYPE',A.OBC_CONT_TYPE_CD) AS OBC_CONT_TYPE_NM,							\n");
		       sqlstr.append("       A.OBC_FRST_CASH_RATE,																										\n");
		       sqlstr.append("       A.OBC_FRST_CONDI,																												\n");
		       sqlstr.append("       A.OBC_FRST_CNT_CONDI,																										\n");
		       sqlstr.append("       A.OBC_MID_CASH_RATE,																											\n");
		       sqlstr.append("       A.OBC_MID_BILL_RATE,																											\n");
		       sqlstr.append("       A.OBC_MID_PAYDAY,																												\n");
		       sqlstr.append("       A.OBC_MID_REQ_MONTH,																											\n");
		       sqlstr.append("       A.OBC_MID_CNT,																													\n");
		       sqlstr.append("       A.OBC_FIN_CASH_RATE,																											\n");
		       sqlstr.append("       A.OBC_FIN_BILL_RATE,																											\n");
		       sqlstr.append("       A.OBC_FIN_PAYDAY,																												\n");
		       sqlstr.append("       A.OBC_FIN_CONDI,																													\n");
		       sqlstr.append("       A.CBC_FIRST_RATE,																												\n");
		       sqlstr.append("       A.CONTFUL_RATE,																													\n");
		       sqlstr.append("       A.WARR_RATE,																														\n");
		       sqlstr.append("       A.CBC_DEFECT_DAY,																												\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.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("       TO_CHAR(TBE_FIN_DT,'YYYY-MM-DD') AS TBE_FIN_DT,														\n");
		       sqlstr.append("       A.OBC_FRST_CONT_RATE,																								\n");
		       sqlstr.append("       A.CPC_MID_RATE,																											\n");
		       sqlstr.append("       A.PBC_REST_RATE,																											\n");
		       sqlstr.append("       A.MODIFY_REASON,																											\n");
		       sqlstr.append("       A.OBC_IND_YN,																											\n");
		       sqlstr.append("       A.REBID_REASON,																											\n");
		       sqlstr.append("       A.REBID_OUTREASON,																											\n");
		       sqlstr.append("       A.OBC_MID_BILL_DATE,																											\n");
		       sqlstr.append("       A.CONF_NO,																											\n");
		       sqlstr.append("       TO_CHAR(TO_DATE(A.DELI_START_DT),'YYYY-MM-DD') AS DELI_START_DT,																											\n");
		       sqlstr.append("       TO_CHAR(TO_DATE(A.DELI_END_DT),'YYYY-MM-DD') AS DELI_END_DT,																											\n");
		       sqlstr.append("       A.MAIN_PR_CONTENTS,																											\n");
		       sqlstr.append("       A.BID_SUPP_SELECT_REASON,																											\n");
		       sqlstr.append("       NVL(B.TOT_FILE_GB, 'TBE_TOT' || A.BID_NO || A.BID_DEG) AS TOT_FILE_GB,			\n");
		       sqlstr.append("       A.PO_PRC,																											\n");
		       sqlstr.append("       A.RES_PRC																											\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_DIV = 'O'							\n");   * 청구구분 O 인거 
        	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("        DECODE(B.CURRENCY_GB,'KRW',1,A.EXCHANGE) AS EXCHANGE,										\n");
        	sqlstr.append("        A.DELIVERY_CONDITION,						\n");
        	sqlstr.append("        DECODE((SELECT SITEDESC_FLAG FROM BID_MASTER WHERE BID_NO = A.BID_NO AND BID_DEG = A.BID_DEG),'Y',A.SITEPARTI_YN,'Y') AS SITEPARTI_YN,			\n");
        	sqlstr.append("        NVL(A.SITE_ATTEND_YN,'NULL') AS SITE_ATTEND_YN,					\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.SIGN_DT,'','미제출',TO_CHAR(A.SIGN_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("        CASE WHEN A.SITEPARTI_YN = 'Y' AND ESTI_TOT_AMT > 0 THEN F_GET_D_CURRENCY(A.ESTI_TOT_AMT,F_GET_CURRENCY_DIGIT(E.CURRENCY_GB))												\n");
        	sqlstr.append("       			WHEN (SELECT ONBID_YN FROM  BID_MASTER WHERE BID_NO = A.BID_NO AND BID_DEG = A.BID_DEG) = 'N' AND A.ESTI_TOT_AMT > 0 THEN F_GET_D_CURRENCY(A.ESTI_TOT_AMT,F_GET_CURRENCY_DIGIT(E.CURRENCY_GB))			\n");
			sqlstr.append("       			WHEN ESTI_TOT_AMT IS NULL AND RNNC_REASON IS NULL AND (SELECT ONBID_YN FROM BID_MASTER WHERE BID_NO = A.BID_NO AND BID_DEG = A.BID_DEG) = 'N' THEN '견적서작성'			\n");
			sqlstr.append("       			WHEN ESTI_TOT_AMT IS NULL AND RNNC_REASON IS NULL  THEN '미참여'																									\n");
			sqlstr.append("       			WHEN (SELECT DIV_PO_YN FROM  BID_MASTER WHERE BID_NO = A.BID_NO AND BID_DEG = A.BID_DEG) ='Y' THEN '단가계약'									\n");
			sqlstr.append("       			WHEN RNNC_SIGNDATA IS NOT NULL THEN '입찰포기('||TO_CHAR(BID_RNNC_DT,'YYYY-MM-DD HH24:MI')||')'														\n");
			sqlstr.append("        		ELSE F_GET_D_CURRENCY(A.ESTI_TOT_AMT,F_GET_CURRENCY_DIGIT(E.CURRENCY_GB)) END AS ESTI_TOT_AMT,																						\n");
			sqlstr.append("        CASE WHEN A.ESTI_TOT_AMT = -1 THEN 0			\n");
			sqlstr.append("        ELSE DECODE(NVL(E.PUR_AMT, 0),0,0,ROUND(((A.ESTI_TOT_AMT * NVL(A.EXCHANGE, '1')) /E.PUR_AMT * 100),1)) END  AS ESTI_TOT_RATE, 			\n"); //외주예산대비 2015.3.2 MKLEE
			sqlstr.append("        A.ESTI_TOT_AMT ESTI_TOT_AMT_I,									\n");
        	sqlstr.append("        DECODE(B.CURRENCY_GB,'KRW',F_GET_D_CURRENCY(A.ESTI_TOT_AMT,F_GET_CURRENCY_DIGIT(E.CURRENCY_GB)),A.WON_ESTI_TOT_AMT) AS WON_ESTI_TOT_AMT,						\n");
        	sqlstr.append("        A.BID_RNNC_DT,									\n");
        	sqlstr.append("        A.BID_RNNC_ID,									\n");
        	sqlstr.append("        A.BID_RNNC_NM,									\n");
        	sqlstr.append("        A.RNNC_REASON,									\n");
        	sqlstr.append("        A.SUCC_YN,										\n");
        	sqlstr.append("        DECODE(A.SUCC_YN,'Y','1','0') AS SUCC_YN_CK,												\n");
        	sqlstr.append("        A.FIB_REASON,									\n");
        	sqlstr.append("        DECODE(DISQ_REASON,NULL,'[등록]','[수정]') AS DISQ_YN,									\n");
        	sqlstr.append("        A.FILE_GB,											\n");
        	sqlstr.append("        A.DISQ_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("        B.CURRENCY_GB_YN,								\n");
        	sqlstr.append("        E.CURRENCY_GB,									\n");//2015.10.26 B->A로 변경 
        	sqlstr.append("        F_GET_CODE_NAME('CURRENCY_GB',B.CURRENCY_GB) AS CURRENCY_GB_NM,			\n");
        	sqlstr.append("        B.INSTALL_YN,										\n");
        	sqlstr.append("        B.COMMISS_YN,									\n");
        	sqlstr.append("        B.SPETOOL_YN,									\n");
        	sqlstr.append("        B.TEST_YN,											\n");
        	sqlstr.append("        B.DOC_YN,											\n");
        	sqlstr.append("        B.PACK_YN,											\n");
        	sqlstr.append("        B.LANDTRAN_YN,									\n");
        	sqlstr.append("        B.DELIVERY_CONDITION_YN,					\n");
        	sqlstr.append("        B.DELIVERY_CONDITION,						\n");
        	sqlstr.append("        B.FEE_NOTI,										\n");
        	sqlstr.append("        B.OPTION_NOTI,									\n");
        	sqlstr.append("        B.QUOT_NO,										\n");
        	sqlstr.append("        B.PAYCONDI_YN,									\n");
        	sqlstr.append("        B.PAYCONDI_NOT_NOTI,						\n");
        	sqlstr.append("        B.CONTFUL_YN,									\n");
        	sqlstr.append("        B.CONTFUL_NOT_NOTI,							\n");
        	sqlstr.append("        B.FRSTGUAR_YN,									\n");
        	sqlstr.append("        B.FRSTGUAR_NOT_NOTI,						\n");
        	sqlstr.append("        B.WARR_YN,										\n");
        	sqlstr.append("        B.WARR_NOT_NOTI,								\n");
        	sqlstr.append("        B.DEFECT_YN,										\n");
        	sqlstr.append("        B.DEFECT_NOT_NOTI,							\n");
        	sqlstr.append("        B.BID_CONDI_NOTI,								\n");
        	sqlstr.append("        DECODE(D.STATUS_CD,'10',F_GET_CODE_NAME('TBE_EVAL',C.EVAL_RESULT),'') AS EVAL_RESULT_NM,								\n");
        	sqlstr.append("        DECODE(D.STATUS_CD,'10',C.EVAL_RESULT,DECODE(E.ONBID_YN,'Y','',C.EVAL_RESULT))	AS EVAL_RESULT,								\n");
        	sqlstr.append("        DECODE(C.STATUS_CD,'','N','Y') AS TBE_YN,						\n");
        	sqlstr.append("        NVL(F.CORP_TEL,'') AS CORP_TEL									\n");
        	sqlstr.append("   FROM BID_SUPP A, BID_PUR_CONDI B, TBE_SUPP C, TBE_INFO D, BID_MASTER E, SUPP_INFO F	\n");
        	sqlstr.append(" WHERE A.BID_NO = E.BID_NO					\n");
        	sqlstr.append(" AND A.BID_DEG = E.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.VENDOR_CD = B.VENDOR_CD(+)			\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.VENDOR_CD = C.VENDOR_CD(+)			\n");
        	sqlstr.append(" AND A.BID_NO  = D.BID_NO(+)					\n");
        	sqlstr.append(" AND A.BID_DEG = D.BID_DEG(+)				\n");
        	sqlstr.append(" AND A.VENDOR_CD = F.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");
        	sqlstr.append(" ORDER BY SUCC_YN DESC NULLS LAST, TBEAPPR_YN DESC NULLS LAST, A.ESTI_TOT_AMT ASC 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 NVL(F_GET_OUT_ITEM_NAME(SUBSTR(B.MATERIAL_CD,0,4)),'직접비') AS DEPTH1							\n");
        	sqlstr.append("      , A.MATERIAL_CD																								\n");
        	sqlstr.append("      , NVL(A.ITEM_NAME, B.ITEM_NAME) ITEM_NAME																									\n");
        	sqlstr.append("      , SUBSTR(A.MATERIAL_CD,0,6) AS PARENT_LEVEL	                                       	\n");
        	sqlstr.append("      , DECODE(B.PARENT_LEVEL,'R','',A.DEMANDED_QTY || '/'||A.STD) AS ITEMS					\n");
        	sqlstr.append("      , F_GET_D_CURRENCY(C.UNIT_COST ,F_GET_CURRENCY_DIGIT(D.CURRENCY_GB)) AS UNIT_COST 																									\n");
        	sqlstr.append("      , F_GET_D_CURRENCY(C.MAT_COST ,F_GET_CURRENCY_DIGIT(D.CURRENCY_GB)) AS MAT_COST 																									\n");
        	sqlstr.append("      , F_GET_D_CURRENCY(C.LAB_COST ,F_GET_CURRENCY_DIGIT(D.CURRENCY_GB)) AS LAB_COST 																									\n");
        	sqlstr.append("      , C.BASIS_CALCU 																								\n");
        	sqlstr.append("      , C.NOTI 																											\n");
        	sqlstr.append("      , A.DEMANDED_QTY AS QTY 																				\n");
        	sqlstr.append("   FROM BID_ITEM A 																									\n");
        	sqlstr.append("      , BID_OUT_ITEM_MASTER B 																					\n");
        	sqlstr.append("      , BID_SUPP_ESTI C 																							\n");
        	sqlstr.append("      , BID_MASTER D 																								\n");
        	sqlstr.append("  WHERE A.MATERIAL_CD=B.MATERIAL_CD(+)																		\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.MATERIAL_CD = C.MATERIAL_CD(+)															\n");
        	sqlstr.append("        AND A.BID_NO=D.BID_NO(+) 																				\n");
        	sqlstr.append("        AND A.BID_DEG=D.BID_DEG(+)																			\n");
        	sqlstr.append("        AND VENDOR_CD(+) = ?																						\n");
        	sqlstr.append("        AND A.BID_NO = ? 																							\n");
        	sqlstr.append("        AND A.BID_DEG = ?																							\n");
        	sqlstr.append(" ORDER BY MATERIAL_CD 																							\n");
			search.setStatement(sqlstr.toString());
			search.addParameter(param.get("VENDOR_CD"));
			search.addParameter(param.get("BID_NO"));
			search.addParameter(param.get("BID_DEG"));
			
			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
	 */
	private ValueObject getOrderReqeustSuppValueObject() {

		Search search = new SearchImpl();
        RowSet rowSet = new RowSetImpl();
        ValueObject valueobject = null;
     //   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("       NVL((SELECT CHG_CODE01 FROM EBID_COM911T WHERE BASECD = '911' AND DETAILCD =(SELECT CURRENCY_GB FROM BID_MASTER WHERE BID_NO = A.BID_NO AND BID_DEG = A.BID_DEG)),0) AS PointCount,        \n");
			sqlstr.append("       A.EXCHANGE,                         \n");
			sqlstr.append("       A.DELIVERY_CONDITION,                         \n");
			sqlstr.append("       A.SITEPARTI_YN,                         \n");
			sqlstr.append("       A.SITE_ATTEND_YN,                         \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("       TO_CHAR(A.SIGN_DT,'YYYY-MM-DD HH24:MI:SS') AS SIGN_DT,                         \n");
			sqlstr.append("       A.ATT_ID,                         \n");
			sqlstr.append("       A.FILE_GB,                         \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("       F_GET_D_CURRENCY(A.ESTI_TOT_AMT,F_GET_CURRENCY_DIGIT((SELECT CURRENCY_GB FROM BID_MASTER WHERE BID_NO = A.BID_NO AND BID_DEG = A.BID_DEG))) AS ESTI_TOT_AMT,                         \n");
			sqlstr.append("       A.WON_ESTI_TOT_AMT,                         \n");
			sqlstr.append("       A.SELECT_TOT_AMT,                         \n");
			sqlstr.append("       A.SUCC_YN,                         \n");
			sqlstr.append("       A.DISQ_REASON,                         \n");
			sqlstr.append("       A.FIB_REASON,                         \n");
			sqlstr.append("       A.BID_RNNC_ID,                         \n");
			sqlstr.append("       A.BID_RNNC_NM,                         \n");
			sqlstr.append("       A.BID_RNNC_DT,                         \n");
			sqlstr.append("       A.RNNC_REASON,                         \n");
			sqlstr.append("       A.RNNC_SIGNDATA,                         \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.SITE_ATTEND_REASON                         \n");
			sqlstr.append("       FROM BID_SUPP A               		          \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.VENDOR_CD = '"+params.get("VENDOR_CD")+"'					\n");
			   
		     //  sqlstr.append("       AND A.DEMANDED_DIV = 'O'							\n");   * 청구구분 O 인거 
        	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 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 ValueObject getPoCheck(String confNo) {

		Search search = new SearchImpl();
        RowSet rowSet = new RowSetImpl();
        ValueObject valueobject = null;
        StrBuffer sqlstr = new StrBuffer();
        try{
			sqlstr.append("			   SELECT COUNT(*) AS CNT											\n");
			sqlstr.append("			   FROM SUB2000T      								\n");
			sqlstr.append("			   WHERE UPPER(CON_DOC_NO) = '"+confNo+"'      								\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);
            //WAFLogger.debug(sqlstr.toString());
            //WAFLogger.debug("WAFSQLException : " + se.getMessage());
        }
        finally {

        	if( valueobject == null ) valueobject = new ValueObject();
        	//WAFLogger.debug("### valueobject size : " + valueobject.size());
            return valueobject;
        }
	}

    /** 첨부서류조회 
     * @return
     * @throws Exception
     */
	private RowSet getFileListRowSet(String bidNo, String bidDeg) throws Exception {
        Search search = new SearchImpl();
        RowSet listRowSet = null;
        StringBuffer sqlstr = new StringBuffer();
        try {

        	sqlstr.append(" SELECT DISTINCT  \n");
        	sqlstr.append("        A.DETAILCD,						 \n");
        	sqlstr.append(" 	   A.DETAILNM,								 \n");
        	sqlstr.append(" 	   A.DETAILSORTNM,							 \n");
        	sqlstr.append(" 	   B.ID AS DOC_CD,							 \n");
        	sqlstr.append(" 	   'SUB_SUCCESSFILE_GB_" + bidNo + "_" + bidDeg + "' AS FILE_GB,	 \n");
        	sqlstr.append(" 	   NVL(B.ID, TO_NUMBER(A.DETAILCD)) AS ID,	 \n");
        	sqlstr.append(" 	   A.CHG_CODE02 AS EDIT_YN	 \n");
        	sqlstr.append("	FROM EBID_COM911T A, PUB0510T B					 \n");
        	sqlstr.append("	WHERE A.BASECD = 'SUB_SUCCESSFILE_GB'	 \n");
        	sqlstr.append("	AND A.CHG_CODE01 = 'Y'			 \n");
        	sqlstr.append("	AND A.DETAILCD = B.ID(+)						 \n");
        	sqlstr.append("	AND B.FILE_GB(+) = 'SUB_SUCCESSFILE_GB_" + bidNo + "_" + bidDeg + "'	 \n");
        	sqlstr.append("UNION ALL \n");
        	sqlstr.append("-- TBE 자료 \n");
        	sqlstr.append("SELECT DISTINCT \n");
        	sqlstr.append("       C.DETAILCD,         \n");
        	sqlstr.append("       C.DETAILNM, \n");
        	sqlstr.append("       C.DETAILSORTNM,  \n");
        	sqlstr.append("       B.ID AS DOC_CD,        \n");
        	sqlstr.append(" 	  A.TOT_FILE_GB AS FILE_GB,	 \n");
        	sqlstr.append(" 	  NVL(B.ID, A.DEMANDED_ID) AS ID,	 \n");
        	sqlstr.append(" 	  C.CHG_CODE02 AS EDIT_YN	 \n");
        	sqlstr.append("  FROM (     \n");
        	sqlstr.append("         SELECT A.DEMANDED_ID, NVL(B.TOT_FILE_GB, 'TBE_TOT" + bidNo + bidDeg + "') AS TOT_FILE_GB, '110' AS DETAILCD \n");
        	sqlstr.append("           FROM BID_MASTER A, TBE_INFO B  \n");
        	sqlstr.append("           WHERE A.BID_NO = '" + bidNo + "'					 \n");
        	sqlstr.append("             AND A.BID_DEG = '" + bidDeg + "'				 \n");
        	sqlstr.append("             AND A.BID_NO = B.BID_NO(+)						 \n");
        	sqlstr.append("             AND A.BID_DEG = B.BID_DEG(+)    \n");
        	sqlstr.append("       ) A, PUB0510T B, EBID_COM911T C     \n");
        	sqlstr.append(" WHERE A.DEMANDED_ID = B.ID(+) \n");
        	sqlstr.append("   AND A.TOT_FILE_GB = B.FILE_GB(+)    	 \n");
        	sqlstr.append("	  AND C.BASECD = 'SUB_SUCCESSFILE_GB'	 \n");
        	sqlstr.append("	  AND A.DETAILCD = C.DETAILCD    		 \n");
        	sqlstr.append("UNION ALL \n");
        	sqlstr.append("SELECT DETAILCD, \n");
        	sqlstr.append("       DETAILNM, \n");
        	sqlstr.append("       DETAILSORTNM,  \n");
        	sqlstr.append("       TO_NUMBER(DETAILCD) AS DOC_CD, \n");
        	sqlstr.append(" 	  '' AS FILE_GB,	 \n");
        	sqlstr.append(" 	  TO_NUMBER(DETAILCD) AS ID,	 \n");
        	sqlstr.append(" 	  CHG_CODE02 AS EDIT_YN	 \n");
        	sqlstr.append("  FROM EBID_COM911T      \n");
        	sqlstr.append("	WHERE BASECD = 'SUB_SUCCESSFILE_GB'	 \n");
        	sqlstr.append("	  AND DETAILCD = '130'			 \n");        	
        	sqlstr.append("UNION ALL \n");
        	sqlstr.append("-- 외부자료     \n");
        	sqlstr.append("SELECT DISTINCT  \n");
        	sqlstr.append("       C.DETAILCD, \n");
        	sqlstr.append("       C.DETAILNM, \n");
        	sqlstr.append("       C.DETAILSORTNM,  \n");
        	sqlstr.append("       B.ID AS DOC_CD,  \n");
        	sqlstr.append(" 	  A.DOC_ETC_OUT AS FILE_GB,	 \n");
        	sqlstr.append(" 	  NVL(B.ID, A.DEMANDED_ID) AS ID,	 \n");
        	sqlstr.append(" 	  C.CHG_CODE02 AS EDIT_YN	 \n");
        	sqlstr.append("  FROM BID_MASTER A, PUB0510T B, EBID_COM911T C  \n");
        	sqlstr.append("  WHERE A.BID_NO = '" + bidNo + "'		 \n");
        	sqlstr.append("    AND A.BID_DEG = '" + bidDeg + "'		 \n");
        	sqlstr.append("    AND A.DEMANDED_ID = B.ID(+) \n");
        	sqlstr.append("    AND A.DOC_ETC_OUT = B.FILE_GB(+)      \n");
        	sqlstr.append("	   AND C.BASECD = 'SUB_SUCCESSFILE_GB'	 \n");
        	sqlstr.append("	   AND C.DETAILCD = '160'       		 \n");
        	sqlstr.append("ORDER BY DETAILCD \n");
    		
            search.setStatement(sqlstr.toString());
            
            listRowSet = search.execute();
            WAFLogger.debug(sqlstr.toString());

        } catch(Exception e) {
            WAFLogger.error(this.getClass().getName() + " --> getListRowSet() : \n" + e.getMessage());
            WAFLogger.error("SQL : " + search.getStatement());
            WAFLogger.error(e);
            
        } finally {
            if( listRowSet == null ) listRowSet = new RowSetImpl();
           
        }
        
        return listRowSet;
    }
    
    private ValueObject getBidMaster(String sign_bid_no,String sign_bid_deg) {
        Search search = new SearchImpl();
        RowSet listRowSet = null;
        StrBuffer sqlstr = new StrBuffer();
        ValueObject rowObject = null;
        
        try {
        	sqlstr.append("SELECT (SELECT DEPART_DEPT_NM FROM PUB0120T WHERE ACCT_ID = A.EMP_NO) AS DEPART_DEPT_NM	--요청부서			\n");
			sqlstr.append("       ,F_GET_USER_NM('"+params.get("ACCT_ID")+"')  AS CRE_NAME --작성자				\n");
			sqlstr.append("       ,TO_CHAR(SYSDATE,'YYYY-MM-DD') AS CRE_DT --작성일				\n");
			sqlstr.append("       ,(select REPLACE(ORDER_COMP_NM,'T_','') from ETEC_ERPIF.ACZ10100 WHERE DEPT_CD = A.DEPT_CD) DEALER_NM -- 발주처				\n");
			sqlstr.append("       ,(SELECT DEPT_NM FROM ETEC_ERPIF.ACZ10100 WHERE DEPT_CD = A.DEPT_CD) AS DEPT_NM -- pjt명				\n");
			sqlstr.append("       ,A.SITEDESCDATE -- 현장설명 예정일				\n");
			sqlstr.append("       ,A.SITEDESCPLACE -- 현장설명 장소				\n");
			sqlstr.append("       ,A.BID_MASTER_NM  -- 계약명				\n");
			sqlstr.append("       ,A.BID_NO -- 발주의뢰번호				\n");
			sqlstr.append("       ,A.BID_DEG -- 차수				\n");
			sqlstr.append("       ,A.DEPT_CD -- 현장코드																																		\n");
			//sqlstr.append("       ,REPLACE(A.BID_NO,'INQ','PO') AS CONF_NO -- 계약번호				\n");
			sqlstr.append("       ,A.CONF_NO AS CONF_NO -- 계약번호				\n");  //2015.11.17수정 
			sqlstr.append("       ,F_GET_CODE_NAME('ONBID',A.ONBID_YN)||'/'||F_GET_CODE_NAME('CMPT_CD',A.CMPT_CD) AS BID_TYPE-- 입찰방식				\n");
			sqlstr.append("       ,A.ACT_AMT -- 예산금액				\n");
			sqlstr.append("       ,F_GET_HANGUL(A.ACT_AMT) AS ACT_AMT_NM -- 예산금액				\n");
			//sqlstr.append("       ,A.ACT_RATE -- 예산금액				\n");
			sqlstr.append("       ,A.CONT_AMT -- 예산금액				\n");
			sqlstr.append("       ,F_GET_HANGUL(A.CONT_AMT) AS CONT_AMT_NM -- 예산금액				\n");
			sqlstr.append("       ,A.DELIVERY_PLACE -- 현장위치				\n");
			sqlstr.append("       ,DECODE(DIV_PO_YN,'Y','',DECODE(A.ACT_AMT,'0',' ',REPLACE(TRIM(TO_CHAR(((B.ESTI_TOT_AMT*NVL(B.EXCHANGE, 1))/A.ACT_AMT * 100),'999,999,999.99')),'.00',''))) AS ACT_RATE-- 예산금액				\n");
			sqlstr.append("       ,DECODE(DIV_PO_YN,'Y','',DECODE(A.CONT_AMT,'0',' ',REPLACE(TRIM(TO_CHAR(((B.ESTI_TOT_AMT*NVL(B.EXCHANGE, 1))/A.CONT_AMT * 100),'999,999,999.99')),'.00',''))) AS CONT_RATE-- 예산금액				\n");
			sqlstr.append("       ,F_GET_CODE_NAME('PUR_LEAD_GB',A.DELIVERY_CONDITION) AS DELIVERY_CONDITION -- 인도조건			\n");
			sqlstr.append("       ,F_GET_CODE_NAME('PAY_DIV',A.PAY_DIV) AS PAY_DIV -- 계약범위			\n");
			sqlstr.append("       ,TO_CHAR(A.BID_TO_DT,'YYYY-MM-DD') AS BID_TO_DT --입찰마감일				\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("       ,TO_CHAR(TO_DATE(A.DELI_START_DT,'YYYYMMDD'),'YYYY-MM-DD') AS DELI_START_DT			\n");
			sqlstr.append("       ,TO_CHAR(TO_DATE(A.DELI_END_DT,'YYYYMMDD'),'YYYY-MM-DD')	AS DELI_END_DT			\n");
			sqlstr.append("       ,F_GET_CODE_NAME('PUR_LEAD_GB',A.DELIVERY_CONDITION) AS DELIVERY_CONDITION_NM --납품조건				\n");
			sqlstr.append("       ,DECODE(A.CBC_FIRST_RATE,'','',A.CBC_FIRST_RATE||'%') || A.PBC_FIRST_CONDI AS FIRST_AMT-- 선급금				\n");
			sqlstr.append("       ,DECODE(A.CPC_MID_RATE,'','',A.CPC_MID_RATE||'%') || A.PBC_MID_CONDI AS MID_AMT -- 중도금				\n");
			sqlstr.append("       ,DECODE(A.PBC_REST_RATE,'','',A.PBC_REST_RATE||'%') || A.PBC_REST_CONDI AS REST_AMT-- 잔금				\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("       ,F_GET_CODE_NAME('CBC_DERECT_TERM_CD',A.CBC_DERECT_TERM_CD)  AS CBC_DERECT_TERM_NM	--하자보증기간	\n");
			sqlstr.append("       ,A.CPC_MID_RATE			\n");
			sqlstr.append("       ,A.OBC_MID_PAYDAY			\n");
			sqlstr.append("       ,A.OBC_MID_CASH_RATE			\n");
			sqlstr.append("       ,A.OBC_MID_BILL_RATE			\n");
			sqlstr.append("       ,A.OBC_FIN_PAYDAY			\n");
			sqlstr.append("       ,A.OBC_FIN_CASH_RATE			\n");
			sqlstr.append("       ,A.OBC_FIN_BILL_RATE			\n");
			sqlstr.append("       ,A.OBC_FRST_CONT_RATE			\n");
			sqlstr.append("       ,A.PBC_REST_RATE			\n");
			sqlstr.append("       ,A.INNER_REMARKS			\n");
			sqlstr.append("       ,A.DOC_ETC_IN					\n");
			sqlstr.append("       ,A.OUTER_REMARKS			\n");
			sqlstr.append("       ,A.DOC_ETC_OUT				\n");
			sqlstr.append("       ,A.DEMANDED_ID				\n");
			sqlstr.append("       ,A.CMPT_CD						\n");
			sqlstr.append("       ,A.DELI_END_PLACE						\n");
			sqlstr.append("       ,B.FILE_GB						\n");
			sqlstr.append("       ,C.TOT_FILE_GB						\n");
			sqlstr.append("       ,(SELECT wmsys.wm_concat(VENDOR_NAME) CONCAT FROM BID_SUPP WHERE SUCC_YN = 'Y' AND BID_NO = A.BID_NO AND BID_DEG = A.BID_DEG	GROUP BY BID_NO,BID_DEG) AS VENDOR_NAME \n");
			sqlstr.append("       ,DECODE(A.CURRENCY_GB,'KRW','',T.CHG_CODE02) ||F_GET_D_CURRENCY(B.ESTI_TOT_AMT,F_GET_CURRENCY_DIGIT(NVL(A.CURRENCY_GB,'KRW'))) AS ESTI_TOT_AMT																		\n");
			sqlstr.append("       ,F_GET_HANGUL2(B.ESTI_TOT_AMT) AS ESTI_TOT_AMT_NM				\n");
			sqlstr.append("       ,B.VENDOR_CD				\n");
			sqlstr.append("       ,CHG_CODE02																															\n");
			sqlstr.append("       ,CHG_CODE06																															\n");
			sqlstr.append("		  ,A.CURRENCY_GB																														\n");
			sqlstr.append("		  ,F_GET_D_CURRENCY(NVL(WON_ESTI_TOT_AMT,0),0)   AS WON_ESTI_TOT_AMT																	\n");
			sqlstr.append("		  ,F_GET_HANGUL2(NVL(WON_ESTI_TOT_AMT,0)) AS WON_ESTI_AMT_NM																			\n");
			sqlstr.append("		  ,DECODE(DIV_PO_YN,'Y','',DECODE(A.ACT_AMT,'0',' ',REPLACE(TRIM(TO_CHAR((A.ACT_AMT - (B.ESTI_TOT_AMT*NVL(B.EXCHANGE, 1))),'999,999,999.99')),'.00',''))) AS ACT_SAVINGS    \n");
			sqlstr.append("       ,A.MAIN_PR_CONTENTS																															\n");			
			sqlstr.append("  FROM BID_MASTER A , BID_SUPP B , TBE_INFO C , EBID_COM911T T		\n");
			sqlstr.append("  WHERE A.BID_NO = '" + sign_bid_no + "'					\n");
			sqlstr.append("    AND A.BID_DEG = '" + sign_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.BID_NO = C.BID_NO(+)									\n");
			sqlstr.append("    AND A.BID_DEG = C.BID_DEG(+)								\n");
			sqlstr.append("    AND B.SUCC_YN = 'Y'										\n");
			sqlstr.append("    AND T.BASECD = '911'										\n");
			sqlstr.append("    AND T.DETAILCD = A.CURRENCY_GB						\n");
            search.setStatement(sqlstr.toString());
            listRowSet = search.execute();
            
            if(listRowSet.size() != 0){
            	rowObject = RowSetUtility.getValueObject(listRowSet.getRow(0));
            }
        }
        catch(Exception e) {
            WAFLogger.error(this.getClass().getName() + " --> getBidMaster() : " + e.getMessage());
            WAFLogger.error("SQL : " + search.getStatement());
            WAFLogger.error(e);
            return null;
        }
        finally {
            if( rowObject == null ) rowObject = new ValueObject();
            return rowObject;
        }
    }
    
	private ValueObject getfilelist(String returnid){
		ValueObject vo = new ValueObject();
		String str="";
		
		RowSet totRow = new RowSetImpl();
		RowSet rowSet = FileManager.getFileList("SUB_SUCCESSFILE_GB_" + params.get("BID_NO") + "_" + params.get("BID_DEG"), "");
        for(int i=0;i<rowSet.size();i++){
        	totRow.addRow(rowSet.getRow(i));   	
        }

        //TBE 자료
        rowSet = FileManager.getFileList(params.get("TOT_FILE_GB"), params.get("DEMANDED_ID"));
        for(int i=0;i<rowSet.size();i++){
        	totRow.addRow(rowSet.getRow(i));
        }
        
        //외부 자료
        rowSet = FileManager.getFileList(params.get("DOC_ETC_OUT"), params.get("DEMANDED_ID"));
        for(int i=0;i<rowSet.size();i++){
        	totRow.addRow(rowSet.getRow(i));
        }
        
        for(int i=0;i<totRow.size();i++){
        	Row row=totRow.getRow(i);
        	str += (i+1)+" : "+row.get("FILE_NAME")+" ("+ row.get("FILE_SIZE")+")";
        	if(i+1!=totRow.size()){
        		str +="\r\n";
        	}        	
        }
        
        vo.set(returnid, str);
        
		return vo;
	}	    
	
    
	/**
	 * 보고자 리스트 조회
	 * @param Params
	 * @return
	 */
	private RowSet getReportEmpList(ValueObject param) {
		Search search = new SearchImpl();
        RowSet rowSet = new RowSetImpl();
        StrBuffer sqlstr = new StrBuffer();
        try{
        	sqlstr.append("    SELECT A.EMP_ID AS ACCT_ID,  \n");
        	sqlstr.append("           A.USER_NAME AS USER_NAME,  \n");
        	sqlstr.append("           A.GRADE_NAME AS GRADE_NAME,  \n");
        	sqlstr.append("           A.DEPART_DEPT_NM AS BUSEO_NAME  \n");
        	sqlstr.append("      FROM BID_DECIDE_MAIL_LIST A \n");
        	sqlstr.append("      WHERE A.BID_NO = ? \n");
        	sqlstr.append("        AND A.BID_DEG = ? \n");
        	sqlstr.append("      ORDER BY A.OPEN_NO \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;
	}	
}