/**
 * @(#)file    
 * @(#)author  
 * @(#)version 1.0
 * @(#)date    
 * @(#)since   JDK 1.4.2
 */
package kr.co.udapsoft.ebid.supplier.portal.result.biz;


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;


public class PurResultContPopupBiz extends Biz {

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

	public void doBiz() throws Exception {
        ValueObject SearchInfo = new ValueObject();
        SearchInfo = getSearchCont(params);
	    storage.addValueObject("SearchInfo", SearchInfo);
	}
	
	
	
	 /**
     * 저장된 계약서 조회 
	 * @param 
	 * @param 
	 * @return RowSet 
	 */
	public ValueObject getSearchCont(ValueObject param){
		Search search = new SearchImpl();
        RowSet rowSet = new RowSetImpl();
        ValueObject valueobject = null;
        StrBuffer sqlstr = new StrBuffer();
        try{
        	sqlstr.append(" 		        SELECT 	\n");
        	sqlstr.append(" 		            ORD_DOC_NO CON_DOC_NO			\n");
        	sqlstr.append(" 		            , CST_DOC_NAME BUILD_NAME		\n");
        	sqlstr.append(" 		            , FLOOR(NVL(ORD_AMT,0)/1000)	CON_AMT		\n");
        	sqlstr.append(" 		            , FLOOR(NVL(PREPAY_AMT,0)/1000) 	PREPAY_AMT	\n");
        	sqlstr.append(" 		        FROM PUR2000T A, CONT_PUR_SUPP B	\n");
        	sqlstr.append(" 		        WHERE A.PUR_CONT_MOD_ID=B.PUR_CONT_MOD_ID 	\n");
        	sqlstr.append(" 		            AND A.PUR_CONT_MOD_ID = '"+ param.get("purContModId") +"' 	\n");
        	sqlstr.append(" 		            AND B.SIGN_SEQ='2'	\n");

			search.setStatement(sqlstr.toString());
            rowSet = search.execute();
            
            if( rowSet != null && rowSet.size() > 0 ){
            	valueobject = RowSetUtility.getValueObject(rowSet.getRow(0));
            }
            	
        }
        catch(WAFSQLException se) {
            this.storage.setSuccess(false);
            se.printStackTrace();
            throw se;
        }
        finally {

        	if( valueobject == null ) valueobject = new ValueObject();
        	//System.out.println("### valueobject size : " + valueobject.size());
            return valueobject;
        }
	}
}