/**
 * @(#)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 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.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.ebid.buyer.common.file.FileManager;
import oracle.toplink.internal.ox.StrBuffer;

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

   
public class BidResolutionBiz extends Biz {

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

	public void doBiz() throws Exception {
        ValueObject user = new ValueObject();
        ValueObject vendor = new ValueObject();
        ValueObject merge = new ValueObject();
		
		if(storage.compareEvent("GET_ITEM_LIST")){
			params.set("sheet1", getItemList(params));
			storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
		}else if(storage.compareEvent("FORM_SELECT")){//견적의뢰
	            user = getOrderReqeustValueObject();
	            vendor = getOrderVendorValueObject();
	            merge = getOrderMergeValueObject();
	            storage.addValueObject("Order", user);
	            storage.addValueObject("Vendor", vendor);
	            storage.addValueObject("Merge", merge);
	            /**		파일 목록 조회			 **/
		        storage.addValueObject(user.get("DOC_ETC_IN"), getfilelist(user.get("DOC_ETC_IN"),user.get("DEMANDED_ID"),user.get("DOC_ETC_IN")));
		        storage.addValueObject(user.get("DOC_ETC_OUT"), getfilelist(user.get("DOC_ETC_OUT"),user.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 suppinfo = getSuppInfo(params.get("BID_NO"), params.get("BID_DEG"), params.get("VENDOR_CD"));	//입찰 업체 정보 조회
	            storage.addValueObject("suppinfo", suppinfo);
		}else if(storage.compareEvent("GET_REPORT_EMP_LIST")){
			 params.set("sheet3", getReportEmpList(params));
	         storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
		}
		
		if(!storage.compareEvent("SHEET_SELECT")){
			if(!params.get("FILE_GB").isEmpty())
				storage.addValueObject(params.get("FILE_GB"), getfilelist(params.get("FILE_GB"),params.get("DEMANDED_ID"),params.get("FILE_GB")));
		}
	}
	
	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 getItemList(ValueObject param) {

		Search search = new SearchImpl();
        RowSet rowSet = new RowSetImpl();
        
     //   String sqlstr = "";
        StrBuffer sqlstr = new StrBuffer();
        try{ 

        	sqlstr.append("					SELECT B.MATERIAL_CD                                                                                                              	\n");
        	sqlstr.append("					     , F_GET_MATERIAL_NAME(B.MATERIAL_CD) AS MATERIAL_NAME                                                                        	\n");
        	sqlstr.append("					     , F_GET_MATL_SPEC_NAME(B.MATERIAL_CD) AS MATERIAL_SPEC                                                                       	\n");
        	sqlstr.append("					     , F_GET_UNIT_KIND_NAME(B.MATERIAL_CD) AS UNIT_KIND_NM                                                                        	\n");
        	sqlstr.append("					     , B.QTY                                                                                                                      	\n");
        	sqlstr.append("					     , B.SELECT_QTY                                                                                                               	\n");
        	sqlstr.append("					     , F_GET_D_CURRENCY( NVL(B.UNIT_COST,0) , F_GET_CURRENCY_DIGIT(A.CURRENCY_GB)) AS UNIT_COST                                                                                                                 	\n");
        	sqlstr.append("					     , F_GET_D_CURRENCY(NVL(B.SELECT_QTY,0) * NVL(B.UNIT_COST,0) , F_GET_CURRENCY_DIGIT(A.CURRENCY_GB)) AS SELECT_AMT                	\n");
        	sqlstr.append("					FROM BID_SUPP  A                                                                                                                  	\n");
        	sqlstr.append("					   , BID_SUPP_ESTI B                                                                                                              	\n");
        	sqlstr.append("					WHERE 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 = '"+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   B.SELECT_QTY > 0																												\n");
        	
        	sqlstr.append("   ORDER BY B.MATERIAL_CD 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("       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("       TO_CHAR(TBE_FIN_DT,'YYYY-MM-DD') AS TBE_FIN_DT,				\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.CURRENCY_GB_YN,													\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.KRW_APPR_YN,				\n");
		       sqlstr.append("       A.DIV_PO_YN	,					\n");
		       sqlstr.append("       A.OPEN_OPINION	,					\n");  //2015.3.30 개찰의견 추가 		       
		       sqlstr.append("       A.CON_REMARK	,					\n");
		       //sqlstr.append("       NVL(C.CHK6,'A') FOREIGN_CHK	,					\n");//외국환추가 2016.5.11
		       //sqlstr.append("       DECODE(NVL(C.CHK6,'N'), 'Y', '예', 'N', '아니요') FOREIGN_NM	,					\n");
		       sqlstr.append("       DECODE(A.DIV_CONT_YN,'Y',  '분할발주', '아니요') AS DIV_CONT_NM	,					\n");
		       sqlstr.append("       (SELECT COUNT(*) FROM PMM_DEMANDED_REQUEST WHERE DEMANDED_NO = A.DEMANDED_NO AND PR_TYPE = '20' and demanded_status in ('3', '4') AND NVL(EBID_STATUS_CD,'01') = '01')	AS FOR_PO,					\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");//외국환추가 2016.5.11,  BID_FOREIGN_CHK C  
		       sqlstr.append("       WHERE 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 A.BID_NO = '"+params.get("BID_NO")+"'	 	\n");
			   sqlstr.append("         AND A.BID_DEG = '"+params.get("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;
        }
	}

	/**업체 입찰 조건 가져오기
	 * @return
	 */
	private ValueObject getOrderVendorValueObject() {
		
		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',C.CURRENCY_GB) AS CURRENCY_GB_NM,                                                                          \n");
			sqlstr.append("	       DECODE(A.CURRENCY_GB_YN,'N',A.CURRENCY_GB,NVL(C.CURRENCY_GB,A.CURRENCY_GB)) AS CURRENCY_GB,                                      \n"); //Y->N변경 20156.5.23 
			sqlstr.append("	       NVL((SELECT CHG_CODE01 FROM EBID_COM911T WHERE BASECD = '911' AND DETAILCD =c.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("	       NVL(C.DELIVERY_CONDITION,A.DELIVERY_CONDITION) AS 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.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.ACT_RATE,                                                                                                                      \n");
			sqlstr.append("	       A.PUR_AMT,                                                                                                                       \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("	       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_FRSTGUAR_RATE,                                                                                                             \n");
			sqlstr.append("	       A.PBC_FRSTGUAR_CONDI,                                                                                                            \n");
			sqlstr.append("	       A.PBC_REST_RATE AS PBC_REST_RATE_MAIN,                                                                                           \n");
			sqlstr.append("	       A.PBC_REST_CONDI AS PBC_REST_CONDI_MAIN,                                                                                         \n");
			sqlstr.append("	       A.CPC_MID_RATE AS CPC_MID_RATE_MAIN,                                                                                             \n");
			sqlstr.append("	       A.PBC_MID_CONDI AS PBC_MID_CONDI_MAIN,                                                                                           \n");
			sqlstr.append("	       A.CBC_FIRST_RATE AS CBC_FIRST_RATE_MAIN,                                                                                         \n");
			sqlstr.append("	       A.PBC_FIRST_CONDI AS PBC_FIRST_CONDI_MAIN,                                                                                       \n");
			sqlstr.append("	       C.PBC_REST_RATE,                                                                                                                 \n");
			sqlstr.append("	       C.PBC_REST_CONDI,                                                                                                                \n");
			sqlstr.append("	       C.CPC_MID_RATE,                                                                                                                  \n");
			sqlstr.append("	       C.PBC_MID_CONDI,                                                                                                                 \n");
			sqlstr.append("	       C.CBC_FIRST_RATE,                                                                                                                \n");
			sqlstr.append("	       C.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("	       F_GET_CODE_NAME('PUR_LEAD_GB',C.DELIVERY_CONDITION) AS DELIVERY_CONDITION_NM,                                                    \n");
			sqlstr.append("	       C.DELIVERY_CONDITION_YN,                                                                                                         \n");
			sqlstr.append("	       A.PBC_CBE_TYPE_CD,                                                                                                               \n");
			sqlstr.append("	       A.DIV_PO_YN,                                                                                                                     \n");
			sqlstr.append("	       C.INSTALL_YN,                                                                                                                    \n");
			sqlstr.append("	       C.COMMISS_YN,                                                                                                                    \n");
			sqlstr.append("	       C.SPETOOL_YN,                                                                                                                    \n");
			sqlstr.append("	       C.TEST_YN,                                                                                                                       \n");
			sqlstr.append("	       C.DOC_YN,                                                                                                                        \n");
			sqlstr.append("	       C.PACK_YN,                                                                                                                       \n");
			sqlstr.append("	       C.LANDTRAN_YN,                                                                                                                   \n");
			sqlstr.append("	       C.FEE_NOTI,                                                                                                                      \n");
			sqlstr.append("	       C.OPTION_NOTI,                                                                                                                   \n");
			sqlstr.append("	       C.QUOT_NO,                                                                                                                       \n");
			sqlstr.append("	       C.PAYCONDI_YN,                                                                                                                   \n");
			sqlstr.append("	       C.PAYCONDI_NOT_NOTI,                                                                                                             \n");
			sqlstr.append("	       C.CONTFUL_YN,                                                                                                                    \n");
			sqlstr.append("	       C.CONTFUL_NOT_NOTI,                                                                                                              \n");
			sqlstr.append("	       C.FRSTGUAR_YN,                                                                                                                   \n");
			sqlstr.append("	       C.FRSTGUAR_NOT_NOTI,                                                                                                             \n");
			sqlstr.append("	       C.WARR_YN,                                                                                                                       \n");
			sqlstr.append("	       C.WARR_NOT_NOTI,                                                                                                                 \n");
			sqlstr.append("	       C.DEFECT_YN,                                                                                                                     \n");
			sqlstr.append("	       C.DEFECT_NOT_NOTI,                                                                                                               \n");
			sqlstr.append("	       C.BID_CONDI_NOTI,                                                                                                                \n");
			sqlstr.append("	       E.CHARGE_NAME,                                                                                                                \n");
			sqlstr.append("	       DECODE(DIV_CONT_YN , 'Y', E.SELECT_TOT_AMT , E.ESTI_TOT_AMT) AS SELECT_TOT_AMT,                                                                                                                \n");
			sqlstr.append("	       DECODE(DIV_CONT_YN , 'Y', E.WON_SELECT_TOT_AMT , E.WON_ESTI_TOT_AMT) AS WON_SELECT_TOT_AMT,                                                                                                                \n");
			sqlstr.append("	       E.PUR_AMT,                                                                                                                \n");
			sqlstr.append("	       E.CONT_AMT,                                                                                                                \n");
			sqlstr.append("	       E.ACT_AMT,                                                                                                                \n");
			sqlstr.append("	       E.CON_REMARK,                                                                                                                \n");
			sqlstr.append("	       E.CONFIRM_YN,                                                                                                                \n");
			sqlstr.append("	       E.BID_STATUS_CD,                                                                                                                \n");
			sqlstr.append("	       E.CONF_NO,                                                                                                                \n");
			sqlstr.append("	       '"+params.get("VENDOR_CD")+"' AS VENDOR_CD,                                                                                                            \n");
			sqlstr.append("	       NVL(E.ATT_ID+1,1) AS ATT_ID,                                                                                                     \n");
			sqlstr.append("	       NVL(E.FILE_GB,'INQ_'||'16053'||TO_CHAR(SYSDATE,'YYYYMMDD')||A.DEMANDED_ID) AS FILE_GB,                                           \n");
			sqlstr.append("	       NVL(D.CORP_REG_NO,(SELECT CORP_REG_NO FROM SUPP_INFO WHERE CORP_ID = '"+params.get("VENDOR_CD")+"')) AS CORP_REG_NO,                                   \n");
			sqlstr.append("	       NVL(D.CORP_KOR,(SELECT CORP_KOR FROM SUPP_INFO WHERE CORP_ID = '"+params.get("VENDOR_CD")+"')) AS CORP_KOR,                                            \n");
			sqlstr.append("	       NVL(D.REP_NAME,(SELECT REP_NAME FROM SUPP_INFO WHERE CORP_ID = '"+params.get("VENDOR_CD")+"')) AS REP_NAME,                                            \n");
			sqlstr.append("	       (select count(*) from bid_supp where BID_NO = '"+params.get("BID_NO")+"' and bid_deg = '"+params.get("BID_DEG")+"') as BID_SUPP_CNT                                           \n");
			sqlstr.append("	        FROM BID_MASTER A  , TBE_INFO B, BID_PUR_CONDI C, SUPP_INFO D, BID_SUPP E                                                       \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.BID_NO = E.BID_NO                                                                                                          \n");
			sqlstr.append("	       AND A.BID_DEG = E.BID_DEG                                                                                                        \n");
			sqlstr.append("	       AND E.VENDOR_CD = '"+params.get("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 C.VENDOR_CD = D.CORP_ID(+)                                                                                                   \n");
			sqlstr.append("	       AND C.VENDOR_CD(+) = '"+params.get("VENDOR_CD")+"'                                                                               \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 getOrderMergeValueObject() {

		Search search = new SearchImpl();
        RowSet rowSet = new RowSetImpl();
        ValueObject valueobject = null;
     //   String sqlstr = "";
        StrBuffer sqlstr = new StrBuffer();
        try{
        	
        	
        	
        		
        	sqlstr.append("	SELECT BID_NO                                     					\n");
        	sqlstr.append("       ,     BID_DEG                               					\n");
        	sqlstr.append("       ,     VENDOR_CD                             					\n");
        	sqlstr.append("       ,     BID_CONDI_NOTI                       					\n");
        	sqlstr.append("       ,     CBC_DAMAGE_RATE                       					\n");
        	sqlstr.append("       ,     CBC_DAMAGE_MAXRATE                    					\n");
        	sqlstr.append("       ,     CBC_FIRST_RATE                        					\n");
        	sqlstr.append("       ,     PBC_FIRST_CONDI                       					\n");
        	sqlstr.append("       ,     CPC_MID_RATE                          					\n");
        	sqlstr.append("       ,     PBC_MID_CONDI                         					\n");
        	sqlstr.append("       ,     PBC_REST_RATE                         					\n");
        	sqlstr.append("       ,     PBC_REST_CONDI                        					\n");
        	sqlstr.append("       ,     FRSTGUAR_YN                           					\n");
        	sqlstr.append("       ,     PBC_FRSTGUAR_RATE                     					\n");
        	sqlstr.append("       ,     PBC_FRSTGUAR_CONDI                    					\n");
        	sqlstr.append("       ,     FRSTGUAR_NOT_NOTI                     					\n");
        	sqlstr.append("       ,     CONTFUL_YN                            					\n");
        	sqlstr.append("       ,     CONTFUL_RATE                          					\n");
        	sqlstr.append("       ,     CONTFUL_CONDI                         					\n");
        	sqlstr.append("       ,     CONTFUL_NOT_NOTI                      					\n");
        	sqlstr.append("       ,     WARR_YN                               					\n");
        	sqlstr.append("       ,     WARR_RATE                             					\n");
        	sqlstr.append("       ,     WARR_CONDI                            					\n");
        	sqlstr.append("       ,     WARR_NOT_NOTI                         					\n");
        	sqlstr.append("       ,     DEFECT_YN                             					\n");
        	sqlstr.append("       ,     PBC_DEFECT_CONDI                      					\n");
        	sqlstr.append("       ,     CBC_DEFECT_DAY                        					\n");
        	sqlstr.append("       ,     CBC_DERECT_TERM_CD                    					\n");
        	sqlstr.append("       ,     PBC_DEFECT_CONDI2                     					\n");
        	sqlstr.append("       ,     CBC_DEFECT_DAY2                       					\n");
        	sqlstr.append("       ,     CBC_DERECT_TERM_CD2                   					\n");
        	sqlstr.append("       ,     DEFECT_NOT_NOTI                       					\n");
        	sqlstr.append("       ,     TO_CHAR(TO_DATE(DELI_FROM_DY,'YYYYMMDD'),'YYYY-MM-DD')  DELI_FROM_DY                       					\n");
        	sqlstr.append("       ,     TO_CHAR(TO_DATE(DELI_TO_DY,'YYYYMMDD'),'YYYY-MM-DD')  DELI_TO_DY                       					\n");
        	sqlstr.append("       ,		F_GET_CODE_NAME('LIQ_DMG_CD', CBC_DAMAGE_CD) AS CBC_DAMAGE_NM			\n");
        	sqlstr.append("       ,		CBC_DAMAGE_CD											\n");
        	sqlstr.append("  FROM BID_PUR_ORDER                     					\n");
        	sqlstr.append("  WHERE BID_NO =   '"+params.get("BID_NO")+"'                	    \n");
        	sqlstr.append("  AND      BID_DEG = '"+params.get("BID_DEG")+"'                 	\n");
        	sqlstr.append("  AND      VENDOR_CD = 	'"+params.get("VENDOR_CD")+"'  				\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 DEMANDED_ID
	 * @return
	 */
	private ValueObject getSignInfo(String DEMANDED_ID) {

		Search search = new SearchImpl();
        RowSet rowSet = new RowSetImpl();
        ValueObject vo = new ValueObject();
        
        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;
	}
	
    /** 첨부서류조회 
     * @return
     * @throws Exception
     */
    public 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(" 	   'PUR_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 = 'PUR_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(+) = 'PUR_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 = 'PUR_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 = 'PUR_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 = 'PUR_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;
    }
    
    public ValueObject getSuppInfo(String sign_bid_no,String sign_bid_deg, String sign_vendor_cd) {
		Search search = new SearchImpl();
        RowSet rowSet = new RowSetImpl();
        ValueObject vo = new ValueObject();
        
    	StrBuffer sqlstr = new StrBuffer();
    	try {
    		sqlstr.append("SELECT A.VENDOR_NAME																													\n");
			sqlstr.append(",A.BID_NO																																		\n");
			sqlstr.append(",A.BID_DEG																																		\n");
			sqlstr.append(",A.VENDOR_CD																																	\n");
			sqlstr.append(",A.ESTI_TOT_AMT																															\n");
			sqlstr.append(",A.FILE_GB																																		\n");
			sqlstr.append(",C.DEMANDED_ID																																\n");
			sqlstr.append(",C.DIV_PO_YN																																	\n");
			sqlstr.append("FROM BID_SUPP A																															\n");
			sqlstr.append(", SUPP_INFO B																																	\n");
			sqlstr.append(", BID_MASTER C																																\n");
			sqlstr.append("WHERE A.VENDOR_CD = B.CORP_ID(+)																									\n");
			sqlstr.append("AND A.BID_NO = C.BID_NO																													\n");
			sqlstr.append("AND A.BID_DEG = C.BID_DEG																												\n");
			sqlstr.append("AND A.BID_NO = '"+sign_bid_no+"'																											\n");
			sqlstr.append("AND A.BID_DEG = '"+sign_bid_deg+"'																										\n");
			sqlstr.append("AND A.VENDOR_CD = '"+sign_vendor_cd+"'																										\n");
			sqlstr.append("AND A.SUCC_YN = 'Y'																										\n");
    		search.setStatement(sqlstr.toString());
    		rowSet = search.execute();
    		
            if(rowSet.size()>0){
            	vo = RowSetUtility.getValueObject(rowSet.getRow(0));
            }
    	}
    	catch(Exception e) {
    		WAFLogger.error(this.getClass().getName() + " --> getSuppInfo() : " + e.getMessage());
    		WAFLogger.error("SQL : " + search.getStatement());
    		WAFLogger.error(e);
    	}
        finally {    
        	if( vo == null ) vo = new ValueObject();
            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;
	}
}