/**
 *
 * @(#)author  [ok]
 * @(#)version 1.0
 * @(#)date    2014. 06. 23
 * @(#)since   JDK 1.7.2
 *
 * Copyright (c) www.udapsoft.co.kr, Inc.
 * All rights reserved.
 * This software is the proprietary information of udapsoft, Inc.
 */
 package kr.co.udapsoft.ebid.portal.payment.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.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.util.ValueObject;




import kr.co.udapsoft.ebid.buyer.sycs.user.biz.UserCommon;

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

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

	public void doBiz() throws Exception {

		System.out.println("협력업체포탈 선급금 신청_외주 데이터 조회");
		
		if(storage.compareEvent("GET_DATA")){	//데이터 조회
			params.set("sheet1", getPrePaymentList(params));
			storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
		}
	}

    /**
     *@param ValueObject
     *@return RowSet
     *기   능 : 선급금 신청 데이터 조회
     *@author OK
     *@version 2014. 6. 23.
     *@since JDK1.7
     */
    public RowSet getPrePaymentList(ValueObject Params) {
        Search search = new SearchImpl();
        RowSet listRowSet = null;
        String sqlstr = "";
        
        try {
        	sqlstr += " SELECT 			  								  	\n"
        			+ "     A.SUB_CONT_MOD_ID,                			  	\n"
        			+ "     A.SUB_CONT_ID,               		            \n"
        			+ "     A.CON_DOC_NO,        	                        \n"
        			+ "     A.MOD_NO,             	                        \n"
        			+ "     A.MOD_GB,                 	                    \n"
        			+ "     A.MOD_CON_RSN,                                  \n"
        			+ "     A.MOD_REQ_DATE,                                 \n"
        			+ "     A.MOD_CORP_RSN,                                 \n"
        			+ "     A.DEPT_CD,                                      \n"
        			+ "     A.DEPT_NAME,                                    \n"
        			+ "     A.CON_GB,                                       \n"
        			+ "     A.DEALER_NM,                                    \n"
        			+ "     A.BUILD_NAME,                                   \n"
        			+ "     A.UND_CON_NAME,                                 \n"
        			+ "     A.SUB_UND_CON_NAME,                             \n"
        			+ "     A.WORK_KIND_CD,                                 \n"
        			+ "     A.ELEC_CON_YN,                                  \n"
        			+ "     A.REQ_DEPT_CD,                                  \n"
        			+ "     A.REQ_DATE,                                     \n"
        			+ "     A.REQ_USERID,                                   \n"
        			+ "     A.REQ_USERNM,                                   \n"
        			+ "     A.REQ_DOC_NO,                                   \n"
        			+ "     A.CST_DATE,                                     \n"
        			+ "     A.CON_IN_DATE,                                  \n"
        			+ "     A.CON_DATE,                                     \n"
        			+ "     A.PAY_COND_GB,                                  \n"
        			+ "     A.PAY_WAY_CASH,                                 \n"
        			+ "     A.PAY_CONTENT,                                  \n"
        			+ "     A.START_WORK_DATE,                              \n"
        			+ "     A.END_WORK_DATE,                                \n"
        			+ "     A.WORK_PLACE,                                   \n"
        			+ "     A.PAY_WAY_BILL,                                 \n"
        			+ "     A.CON_AMT,                                      \n"
        			+ "     A.CON_SUPPLY_AMT,                               \n"
        			+ "     A.CON_SUPPLY_TAMT,                              \n"
        			+ "     A.CON_SUPPLY_NAMT,                              \n"
        			+ "     A.CON_SURTAX_AMT,                               \n"
        			+ "     A.LABOR_AMT,                                    \n"
        			+ "     A.PREPAY_AMT,                                   \n"
        			+ "     A.PREPAY_SUPPLY_AMT,                            \n"
        			+ "     A.PREPAY_SUPPLY_TAMT,                           \n"
        			+ "     A.PREPAY_SUPPLY_NAMT,                           \n"
        			+ "     A.PREPAY_SURTAX_AMT,                            \n"
        			+ "     A.CON_EST_GUAR_RATE,                            \n"
        			+ "     A.CON_EST_GUAR_AMT,                             \n"
        			+ "     A.CON_GUAR_TERM,                                \n"
        			+ "     A.DEF_EST_GUAR_RATE,                            \n"
        			+ "     A.DEF_GUAR_AMT,                                 \n"
        			+ "     A.DEF_EST_TERM,                                 \n"
        			+ "     A.DELAY_RATE,                                   \n"
        			+ "     A.LABOR_GUAR_JOIN_AMT_GB,                       \n"
        			+ "     A.CON_SPE_TXT,                                  \n"
        			+ "     A.ADD_FILE_KIND,                                \n"
        			+ "     A.CON_CHARGE_ID,                                \n"
        			+ "     A.CON_CHARGE_NAME,                              \n"
        			+ "     A.CORP_SIGN_DATE,                               \n"
        			+ "     A.COMPANY_SIGN_DATE,                            \n"
        			+ "     A.PAY_GROUP,                                    \n"
        			+ "     A.PAYMENT_TERMS,                                \n"
        			+ "     A.ACCT_GB,                                      \n"
        			+ "     A.PROOF_CD,                                     \n"
        			+ "     A.CON_CLS_YN,                                   \n"
        			+ "     A.CON_CUR_CD,                                   \n"
        			+ "     A.CON_EXCHANGE_DATE,                            \n"
        			+ "     A.CON_WON_RATE,                                 \n"
        			+ "     A.PAY_ITEM,                                     \n"
        			+ "     A.COST_CODE,                                    \n"
        			+ "     A.COST_TYPE,                                    \n"
        			+ "     A.CONTRACTID,                                   \n"
        			+ "     A.G_ID,                                         \n"
        			+ "     A.P_ID,                                         \n"
        			+ "     A.TEMPLATE_CD,                                  \n"
        			+ "     A.CONT_HASH,                                    \n"
        			+ "     A.CONT_HTML,                                    \n"
        			+ "     A.TRUE_RANDOM,                                  \n"
        			+ "     A.CRE_BY,                                       \n"
        			+ "     A.CRE_DATE,                                     \n"
        			+ "     A.UPD_BY,                                       \n"
        			+ "     A.UPD_DATE,                                      \n"
        			+ "     TO_CHAR(A.START_WORK_DATE, 'YYYY-MM-DD') || '~' || TO_CHAR(A.END_WORK_DATE, 'YYYY-MM-DD') AS START_END_WORK_DATE,     \n"
        			+ "     NVL(B.STATUS_CD, '00') AS STATUS_CD,            \n"
        			+ "     NVL(B.REQ_PREPAY_AMT, 0) AS REQ_PREPAY_AMT,     \n"
        			+ "     NVL(B.REQ_DIV_CD, '1') AS REQ_DIV_CD	        \n"
        			+ " FROM SUB2000T A, PREPAY_OUT B                       \n"
        			+ " WHERE A.SUB_CONT_MOD_ID = B.SUB_CONT_MOD_ID(+)         \n";
        	
        	if(!"".equals(params.get("buildName"))){
        		sqlstr += " AND UPPER(A.BUILD_NAME) LIKE UPPER('%" + params.get("buildName") + "%')	\n";
        	}
        	if(!"".equals(params.get("detailcd"))){
        		sqlstr += " AND B.STATUS_CD = '"+Params.get("detailcd")+"'							\n";
        	}
            
            sqlstr += " ORDER BY SUB_CONT_MOD_ID  													\n" ; 
            search.setStatement(sqlstr);
            System.out.println(sqlstr);
            listRowSet = search.execute();
           
        }
        catch(Exception e) {
            WAFLogger.error(this.getClass().getName() + " --> getPrePaymentList() : " + e.getMessage());
            WAFLogger.error("SQL : " + search.getStatement());
            WAFLogger.error(e);
            return null;
        }
        finally {

            if( listRowSet == null ) listRowSet = new RowSetImpl();
            return listRowSet;
        }
    }
}
