/**
 * @(#)file    CommMatlCodeSectListBiz
 * @(#)author  lsm
 * @(#)version 1.0
 * @(#)date    2014. 3. 5
 * @(#)since   JDK1.4.1
 *
 * 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.sycs.common.biz;

import com.udapsoft.modular.web.ibsheet7.IBSheet7Factory;
import com.udapsoft.modular.web.ibsheet7.util.IBSheet7Utils;
import com.udapsoft.waf.common.ui.HTMLMaker;
import kr.co.udapsoft.ebid.buyer.sycs.security.biz.SYSRightCommon;
import com.udapsoft.waf.system.Biz;
import com.udapsoft.waf.system.HandlerStorage;
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;
public class CommGongCodeSectListBiz extends Biz {
	
	public CommGongCodeSectListBiz(HandlerStorage storage) {

        super(storage);        
    }
    public void doBiz() throws Exception {

    	String kindCode[] = null;
    	
    	String depth = params.get("depth");
    	String item_cd = params.get("item_cd");
        
        params.set("sheet1", getMatlCodeSectList(params));
        storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
              
        WAFLogger.debug(storage.getObject("ibsheet7Data"));
    }
  	
    private RowSet getMatlCodeSectList(ValueObject Params) throws Exception{
        Search search = new SearchImpl();
        RowSet rowSet = new RowSetImpl();
        String sqlstr = "";
        try {        	
        	
        	sqlstr += "    SELECT ITEM_CD,																\n"
        			+"		      TRIM(ITEM_NAME) AS ITEM_NAME											\n"
					+"		 FROM OUT_ITEM			                                                	\n"
					+"		WHERE DEPTH = '3'           											    \n";
						if(!params.get("item_cd").equals(""))
		            	{
							sqlstr+="		 	AND ITEM_CD LIKE 	?									\n";
		            	}
						
			 sqlstr+="		 	AND (ITEM_NAME  LIKE '%' || ? || '%'		OR 	ITEM_CD LIKE '%' || ? || '%')		\n"
					+"		 	ORDER BY ITEM_CD ASC																\n";
        	
        	
            search.setStatement(sqlstr);
            if(!params.get("item_cd").equals(""))
        	{
        		search.addParameter(params.get("ITEM_CD") + '%');
        	}
        	search.addParameter(params.get("pgm_name2"));
            search.addParameter(params.get("pgm_name2"));
            
            
            System.out.println(sqlstr);
            System.out.println(search.getParameters());
            rowSet = search.execute();

        }
        catch(Exception e) {

        	WAFLogger.error(this.getClass().getName() + " --> getSystemRowSet() : " + e.getMessage());
        	WAFLogger.error("SQL : " + search.getStatement());
        	WAFLogger.error(e);
            return null;
        }
        finally {    
        	 if(rowSet == null) rowSet = new RowSetImpl();
             return rowSet;
        }
	}
}
