/**
 * @(#)file    SUBHDChgContractListBiz.java
 * @(#)author  cutePrettyKara
 * @(#)version 1.0
 * @(#)date    2011.11.04
 *
 * Copyright (c) 2002-2003 www.hwenc.com, Inc.  
 * All rights reserved.
 * This software is the proprietary information of hwenc, Inc.
 */
package kr.co.udapsoft.ebid.buyer.bid.outside.biz;


import java.sql.Connection;

import kr.co.hsnc.common.base.WAFLogger;
import kr.co.hsnc.common.sql.Row;
import kr.co.hsnc.common.sql.RowSet;
import kr.co.hsnc.common.sql.RowSetImpl;
import kr.co.hsnc.common.sql.WAFSQLException;
import kr.co.hsnc.common.sql.persistent.Persistent;
import kr.co.hsnc.common.sql.persistent.PersistentImpl;
import kr.co.hsnc.common.sql.search.Search;
import kr.co.hsnc.common.sql.search.SearchImpl;
import kr.co.hsnc.common.sql.util.RowSetUtility;
import kr.co.hsnc.common.util.ValueObject;
import kr.co.udapsoft.common.sheet.SheetData;
import kr.co.udapsoft.common.sheet.SheetFactory;
import kr.co.udapsoft.common.sheet.SheetTD;
import kr.co.udapsoft.common.sheet.SheetTDUtil;
import kr.co.udapsoft.common.sheet.SheetTR;
import oracle.toplink.internal.ox.StrBuffer;

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


/**
 * 외주관리 - 외주변경계약서 작성 (갑)
 */

public class ReBidChkSignBiz extends Biz {
   public ReBidChkSignBiz(HandlerStorage storage) {
        super(storage);        
    }

    public void doBiz() throws Exception {
        
       if(storage.compareEvent("SIGN_CHECK")){
	       	ValueObject info = getSignCheck(params.get("BID_NO"),params.getInt("BID_DEG"));
	       	storage.addValueObject("VALUEOBJECT",info);
       }
    }

    

	private ValueObject getSignCheck(String bidNo , int bidDeg) {

		Search search = new SearchImpl();
        RowSet rowSet = new RowSetImpl();
        ValueObject valueobject = null;
        StrBuffer sqlstr = new StrBuffer();
        try{
			sqlstr.append("			   SELECT COUNT(*) AS CNT											\n");
			sqlstr.append("			   FROM SIGN001T       								\n");
			sqlstr.append("			   WHERE SIGN_CLASS_CD = 'ebid_orebqD'       								\n");
			sqlstr.append("			   AND ATTR_6 ='0'                 								\n");
			sqlstr.append("			   AND KEY_COL1 = '"+bidNo+"'                								\n");
			sqlstr.append("			   AND KEY_COL2 = '"+bidDeg+"'                								\n");
	        
				search.setStatement(sqlstr.toString());
	            rowSet = search.execute();

            
            if( rowSet != null && rowSet.size() > 0 ){
            	valueobject = RowSetUtility.getValueObject(rowSet.getRow(0));
            }
            	
        }
        catch(WAFSQLException se) {
        	super.doException(se);
            this.storage.setSuccess(false);
            this.storage.setMessage(se.getMessage());
            storage.setDetailMessage(se);
            //WAFLogger.debug(sqlstr.toString());
            //WAFLogger.debug("WAFSQLException : " + se.getMessage());
        }
        finally {

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