/**
 * @(#)file    PreRequestSignBiz.java
 * @(#)author  OK
 * @(#)version 1.0
 *
 * Copyright (c) www.udapsoft.co.kr, Inc.
 */
package kr.co.udapsoft.ebid.buyer.bid.purchase.biz;

import kr.co.hsnc.common.base.WAFLogger;
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 oracle.toplink.internal.ox.StrBuffer;

import com.udapsoft.waf.system.Biz;
import com.udapsoft.waf.system.HandlerStorage;


/**
 * 
 * @version 1.0
 */
public class BidSuccessSignBiz extends Biz {
	BidCommonBiz BidCommonBiz = new BidCommonBiz(storage);
	public BidSuccessSignBiz(HandlerStorage storage) {
		super(storage);
	}

    public void doBiz() throws Exception {
		
		ValueObject vo = new ValueObject();
		//RowSet suppinfo = null;
		
		vo = getBidMaster(params.get("sign_bid_no"),params.get("sign_bid_deg"), params.get("sign_vendor_cd"));	//입찰 정보 조회
		//suppinfo = getSuppInfo(params.get("sign_bid_no"),params.get("sign_bid_deg"), params.get("sign_vendor_cd"));	//입찰 업체 정보 조회

		//String doctitle = "-"+vo.get("BID_MASTER_NM")+vo.get("DEPT_NM");
		//2015.8.10 조재윤과장 요청. 타이틀 순서변경
		String doctitle = "["+vo.get("DEPT_NM")+"]" + vo.get("BID_MASTER_NM");
        vo.set("doctitle", doctitle);
        vo.set("AMT_HIDDEN", params.get("AMT_HIDDEN"));  //2015.12.30
      
        storage.addValueObject(vo.get("DOC_ETC_IN"), BidCommonBiz.getfilelist(vo.get("DOC_ETC_IN"),vo.get("DEMANDED_ID"),vo.get("DOC_ETC_IN")));
        storage.addValueObject(vo.get("DOC_ETC_OUT"), BidCommonBiz.getfilelist(vo.get("DOC_ETC_OUT"),vo.get("DEMANDED_ID"),vo.get("DOC_ETC_OUT")));
        storage.addValueObject(vo.get("TOT_FILE_GB"), BidCommonBiz.getfilelist(vo.get("TOT_FILE_GB"),vo.get("DEMANDED_ID"),vo.get("TOT_FILE_GB")));
		
		storage.addValueObject("bidmaster", vo);
        //storage.addRowSet("suppinfo", suppinfo);
        storage.addValueObject("SIGN_INFO", getSignInfo(vo.get("DEMANDED_ID")));
        
        RowSet getFileListRowSet = getFileListRowSet(params.get("sign_bid_no"), params.get("sign_bid_deg"));
        storage.addRowSet("getFileListRowSet", getFileListRowSet);
        
        ValueObject suppinfo = getSuppInfo(params.get("sign_bid_no"), params.get("sign_bid_deg"), params.get("sign_vendor_cd"));	//입찰 업체 정보 조회
        storage.addValueObject("suppinfo", suppinfo);
   }

    public ValueObject getBidMaster(String sign_bid_no,String sign_bid_deg, String sign_vendor_cd) {
        Search search = new SearchImpl();
        RowSet listRowSet = null;
        StrBuffer sqlstr = new StrBuffer();
        ValueObject rowObject = null;
        
        try {
        	sqlstr.append("SELECT  * FROM(									\n");
        	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("       ,F_GET_CODE_NAME('ONBID',A.ONBID_YN)||'/'||F_GET_CODE_NAME('CMPT_CD',A.CMPT_CD) AS BID_TYPE-- 입찰방식				\n");
			sqlstr.append("       ,B.ACT_AMT -- 예산금액				\n");
			sqlstr.append("       ,F_GET_HANGUL(B.ACT_AMT) AS ACT_AMT_NM -- 예산금액				\n");
			sqlstr.append("       ,A.ACT_RATE AS ACT_RATE2-- 예산금액				\n");
			sqlstr.append("       ,F_GET_HANGUL(B.CONT_AMT) AS CONT_AMT_NM -- 예산금액				\n");
			sqlstr.append("       ,B.CONT_AMT -- 예산금액				\n");
			sqlstr.append("       ,A.DELIVERY_PLACE -- 현장위치				\n");
			sqlstr.append("		  ,CASE WHEN NVL(B.ESTI_TOT_AMT,0) > 0 AND NVL(B.ACT_AMT,0) > 0 THEN REPLACE(TRIM(TO_CHAR(ROUND(DECODE(DIV_CONT_YN , 'Y' , NVL(B.WON_SELECT_TOT_AMT, SELECT_TOT_AMT ) , NVL(B.WON_ESTI_TOT_AMT, B.ESTI_TOT_AMT)) /B.ACT_AMT * 100,2),'999,999,990.99')),'.00') END    ACT_RATE    \n");
			sqlstr.append("       ,DECODE(B.CONT_AMT,'0',' ',REPLACE(TRIM(TO_CHAR((DECODE(DIV_CONT_YN , 'Y' , NVL(B.WON_SELECT_TOT_AMT, SELECT_TOT_AMT ) , NVL(B.WON_ESTI_TOT_AMT, B.ESTI_TOT_AMT))/B.CONT_AMT * 100),'999,999,990.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(E.DELI_FROM_DY,'YYYYMMDD'),'YYYY-MM-DD')	AS DELI_FROM_DY			\n");
			sqlstr.append("       ,TO_CHAR(TO_DATE(E.DELI_TO_DY,'YYYYMMDD'),'YYYY-MM-DD')	AS DELI_TO_DY			\n");
			sqlstr.append("       ,F_GET_CODE_NAME('PUR_LEAD_GB',A.DELIVERY_CONDITION) AS DELIVERY_CONDITION_NM --납품조건				\n");
			sqlstr.append("       ,DECODE(E.CBC_FIRST_RATE,'','',E.CBC_FIRST_RATE||'%') || E.PBC_FIRST_CONDI AS FIRST_AMT-- 선급금				\n");
			sqlstr.append("       ,DECODE(E.CPC_MID_RATE,'','',E.CPC_MID_RATE||'%') || E.PBC_MID_CONDI AS MID_AMT -- 중도금				\n");
			sqlstr.append("       ,DECODE(E.PBC_REST_RATE,'','',E.PBC_REST_RATE||'%') || E.PBC_REST_CONDI AS REST_AMT-- 잔금				\n");
			sqlstr.append("       ,E.WARR_RATE	--하자보증율		\n");
			sqlstr.append("       ,E.WARR_CONDI	--하자보증율		\n");
			sqlstr.append("       ,E.PBC_DEFECT_CONDI	--하자보증기간		\n");
			sqlstr.append("       ,E.CBC_DEFECT_DAY	--하자보증기간		\n");
			sqlstr.append("       ,E.CBC_DERECT_TERM_CD	--하자보증기간		\n");
			sqlstr.append("       ,E.PBC_DEFECT_CONDI2	--하자보증기간		\n");
			sqlstr.append("       ,E.CBC_DEFECT_DAY2	--하자보증기간		\n");
			sqlstr.append("       ,E.CBC_DERECT_TERM_CD2	--하자보증기간		\n");
			sqlstr.append("       ,F_GET_CODE_NAME('CBC_DERECT_TERM_CD',E.CBC_DERECT_TERM_CD)  AS CBC_DERECT_TERM_NM	--하자보증기간	\n");
			sqlstr.append("       ,F_GET_CODE_NAME('CBC_DERECT_TERM_CD',E.CBC_DERECT_TERM_CD2)  AS CBC_DERECT_TERM_NM2	--하자보증기간	\n");
			sqlstr.append("       ,A.INNER_REMARKS			\n");
			sqlstr.append("       ,B.CON_REMARK			\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.PBC_CBE_TYPE_CD						\n");
			sqlstr.append("       ,A.DELI_END_PLACE						\n");
			sqlstr.append("       ,NVL(A.DIV_PO_YN , 'N') AS DIV_PO_YN						\n");
			sqlstr.append("       ,B.FILE_GB						\n");
			sqlstr.append("       ,C.TOT_FILE_GB						\n");
			sqlstr.append("       ,B.VENDOR_NAME, B.VENDOR_CD						\n");
			sqlstr.append("       , F_GET_D_CURRENCY(DECODE(DIV_CONT_YN , 'Y', NVL(WON_SELECT_TOT_AMT,0), NVL(WON_ESTI_TOT_AMT,0)),0)   AS WON_ESTI_TOT_AMT						\n");
			sqlstr.append("         , F_GET_HANGUL2(DECODE(DIV_CONT_YN , 'Y', NVL(WON_SELECT_TOT_AMT, 0), NVL(WON_ESTI_TOT_AMT,0))) AS WON_ESTI_AMT_NM						\n");
			sqlstr.append("       ,D.CURRENCY_GB						\n");
			sqlstr.append("          ,DECODE(D.CURRENCY_GB,'KRW','',T.CHG_CODE02) ||F_GET_D_CURRENCY(DECODE(DIV_CONT_YN , 'Y' , NVL(SELECT_TOT_AMT,0 ) , NVL(B.ESTI_TOT_AMT,0)),F_GET_CURRENCY_DIGIT(NVL(D.CURRENCY_GB,'KRW'))) AS ESTI_TOT_AMT     																	\n");
			sqlstr.append("        ,F_GET_HANGUL2(DECODE(DIV_CONT_YN , 'Y' , NVL(B.SELECT_TOT_AMT,0 ) , NVL(B.ESTI_TOT_AMT,0))) AS ESTI_TOT_AMT_NM   		\n");
			sqlstr.append("       ,CHG_CODE02																															\n");
			sqlstr.append("       ,CHG_CODE06																															\n");
			sqlstr.append("       ,B.CONF_NO																															\n");
			//sqlstr.append("       ,NVL(F.CHK6, 'A') FOREIGN_CHK																															\n");
			//sqlstr.append("       ,DECODE(NVL(F.CHK6, 'A'), 'N', '아니오', 'Y', '예', '비대상') FOREIGN_NM																															\n");
			sqlstr.append("		  ,CASE WHEN NVL(B.ESTI_TOT_AMT,0) > 0 AND NVL(B.ACT_AMT,0) > 0 THEN REPLACE(TRIM(TO_CHAR(ROUND(B.ACT_AMT - DECODE(DIV_CONT_YN , 'Y' , NVL(B.WON_SELECT_TOT_AMT, SELECT_TOT_AMT ) , NVL(B.WON_ESTI_TOT_AMT, B.ESTI_TOT_AMT)),2),'999,999,999,990.99')),'.00') END AS ACT_SAVINGS    \n");
			sqlstr.append("       ,A.MAIN_PR_CONTENTS																															\n");
			sqlstr.append("       ,A.PO_PRC																															\n");
			sqlstr.append("       ,A.RES_PRC																															\n");
			sqlstr.append("       ,TO_CHAR(TO_DATE(A.CONT_APP_REQ_DATE,'YYYYMMDD'),'YYYY-MM-DD')	AS CONT_APP_REQ_DATE												\n");
			sqlstr.append("  FROM BID_MASTER A , BID_SUPP B , TBE_INFO C , BID_PUR_CONDI D , EBID_COM911T T, BID_PUR_ORDER	E	\n");//, BID_FOREIGN_CHK F
			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.BID_NO = D.BID_NO									\n");
			sqlstr.append("    AND B.BID_DEG = D.BID_DEG								\n");
			sqlstr.append("    AND B.VENDOR_CD = '" + sign_vendor_cd + "'				\n");
			sqlstr.append("    AND B.VENDOR_CD = D.VENDOR_CD						\n");
			sqlstr.append("    AND B.BID_NO = E.BID_NO						\n");
			sqlstr.append("    AND B.BID_DEG = E.BID_DEG						\n");
			sqlstr.append("    AND B.VENDOR_CD = E.VENDOR_CD						\n");
			//sqlstr.append("    AND B.BID_NO = F.BID_NO(+)									\n");
			//sqlstr.append("    AND B.BID_DEG = F.BID_DEG(+)								\n");
			//sqlstr.append("    AND B.VENDOR_CD = F.VENDOR_CD(+)						\n");
			sqlstr.append("    AND B.SUCC_YN = 'Y'										\n");
			sqlstr.append("    AND T.BASECD = '911'										\n");
			sqlstr.append("    AND T.DETAILCD = D.CURRENCY_GB						\n");
			sqlstr.append("    ORDER BY B.ESTI_TOT_AMT DESC)						\n");
			sqlstr.append("    WHERE ROWNUM<=1						\n");
            search.setStatement(sqlstr.toString());
            listRowSet = search.execute();
            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;
        }
    }
    
//    public RowSet getSuppInfo(String sign_bid_no,String sign_bid_deg, String sign_vendor_cd) {
//    	Search search = new SearchImpl();
//    	RowSet listRowSet = null;
//    	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());
//    		listRowSet = search.execute();
//    	}
//    	catch(Exception e) {
//    		WAFLogger.error(this.getClass().getName() + " --> getSuppInfo() : " + e.getMessage());
//    		WAFLogger.error("SQL : " + search.getStatement());
//    		WAFLogger.error(e);
//    		return null;
//    	}
//    	finally {
//    		if( listRowSet == null ) listRowSet = null;
//    		return listRowSet;
//    	}
//    }
    
    /** 첨부서류조회 
     * @return
     * @throws Exception
     */
    public RowSet getfileListRowSet(String payreqId, String code) throws Exception {
        Search search = new SearchImpl();
        RowSet listRowSet = null;
        StringBuffer sql = new StringBuffer();
        try {

    		sql.append("	SELECT distinct A.DETAILCD,								\n");
    		sql.append(" 		   A.DETAILNM,								\n");
    		sql.append(" 		   B.ID AS DOC_CD							\n");
    		sql.append("	FROM EBID_COM911T A, PUB0510T B				\n");
    		sql.append("	WHERE A.BASECD = 'PUR_PAY_FILE'					\n");
    		sql.append("	AND A.DETAILCD = B.ID(+)						\n");
    		sql.append("	AND B.FILE_GB(+) = '"+payreqId+"'				\n");
    		sql.append("	ORDER BY A.DETAILCD								\n");
    		
        	
            search.setStatement(sql.toString());
            
            listRowSet = search.execute();
            WAFLogger.debug(sql.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;
    }
    
    /**
	 * 발주의뢰 결재 정보 조회
	 * @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;
	}
	
    /** 첨부서류조회 
     * @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;
        }        
    }        
}
