/**
 * @(#)file    SYSInputStandardCodeListDetailBiz.java
 * @(#)author  gyeongmo an
 * @(#)date    2014.08.01
 * @(#)Description: 기준코드 등록
 *
 * Copyright (c) www.udapsoft.co.kr, Inc.
 * All rights reserved.
 */
package kr.co.udapsoft.ebid.buyer.sycs.code.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.util.ValueObject;

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

public class SYSInputStandardCodeListDetailBiz extends Biz {

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

	/* (non-Javadoc)
	 * @see kr.co.hwenc.system.Biz#doBiz()
	 */
	public void doBiz() throws Exception {
		params.set("sheet2", getDetailListRowSet(params));
		storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
	}

	public RowSet getDetailListRowSet(ValueObject Params) throws Exception {               
		Search search = new SearchImpl();
        RowSet rowSet = new RowSetImpl();
        String sqlstr = "";
        try {
        	sqlstr += " SELECT 			          \n"
        			+ "        SORT_NO,           \n"  //순번 추가
        			+ " 	   DETAILCD,          \n"
	                + "        DETAILNM,          \n"
	                + "        DETAILSORTNM,      \n"
	                + "        CHG_CODE01,        \n"
	                + "        CHG_CODE02,        \n"
	                + "        CHG_CODE03,        \n"
	                + "        CHG_CODE04,        \n"
	                + "        CHG_CODE05,        \n"
	                + "        CHG_CODE06,        \n"
	                + "        CHG_CODE07,        \n"
	                + "        CHG_CODE08,        \n"
	                + "        CHG_CODE09,        \n"
	                + "        CHG_CODE10,        \n"
	                + "        CHG_CODE11,        \n"
	                + "        CHG_CODE12,        \n"
	                + "        CHG_CODE13,        \n"
	                + "        CHG_CODE14,        \n"
	                + "        CHG_CODE15,        \n"
	                + "        CHG_CODE16,        \n"
	                + "        CHG_CODE17,        \n"
	                + "        CHG_CODE18,        \n"
	                + "        CHG_CODE19,        \n"
	                + "        CHG_CODE20,        \n"
	                + "        REMARK,            \n"
	                + "        BASECD             \n"
	                + "   FROM EBID_COM911T           \n"
	                + "  WHERE BASECD like '"+ params.get("p_basecd") +"'  \n"
	                + "    AND UPPER(DETAILNM) like '%'||UPPER('"+params.get("DETAILNM")+"')||'%'		\n";
	                if(!"".equals(params.get("CHG_CODE01"))) {
	                	sqlstr += "    AND CHG_CODE01 = '"+params.get("CHG_CODE01")+"'					\n";
	            	}
	                sqlstr += "  ORDER BY SORT_NO        \n" ;
        	search.setStatement(sqlstr);
            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;
        }
    }
}
