/**
 *
 * @(#)author  [ok]
 * @(#)version 1.0
 * @(#)date    2014. 06. 18
 * @(#)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.buyer.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.sql.util.RowSetUtility;
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 AdvencePaymentViewBiz extends Biz {
	

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

	public void doBiz() throws Exception {

		WAFLogger.debug("협력업체포탈 보증정보 데이터 조회");
		
		if(storage.compareEvent("GET_DATA")){
			//보증정보
			ValueObject contOutWarr = getContOutWarr(params);
			storage.addValueObject("VALUEOBJECT", contOutWarr);
		}
	}

    /**
     *@param ValueObject
     *@return ValueObject
     *기   능 : 외주계약 보증정보 데이터 조회
     *@author OK
     *@version 2014. 6. 23.
     *@since JDK1.7
     */
    public ValueObject getContOutWarr(ValueObject Params) {
        Search search = new SearchImpl();
        RowSet listRowSet = null;
        String sqlstr = "";
        ValueObject rowObject = null;
        
        try {
        	
        	sqlstr += " SELECT                              \n"
    				+ "    SUB_CONT_ID,                     \n"
    				+ "    WARR_GUBUN,                      \n"
    				+ "    WARR_SEQ,                        \n"
    				+ "    WARR_WAMT,                       \n"
    				+ "    WARR_WRATE,                      \n"
    				+ "    WARR_KAMT1,                      \n"
    				+ "    WARR_KAMT2,                      \n"
    				+ "    WARR_COMMSN,                     \n"
    				+ "    WARR_KCLS,                       \n"
    				+ "    WARR_SDATE,                      \n"
    				+ "    WARR_EDATE,                      \n"
    				+ "    TO_CHAR(TO_DATE(WARR_SDATE,'YYYYMMDD'),'YYYY-MM-DD') ||' ~ '|| TO_CHAR(TO_DATE(WARR_EDATE,'YYYYMMDD'),'YYYY-MM-DD') AS WARR_SDATE_EDATE,                \n"
    				+ "    WARR_WGNO,                       \n"
    				+ "    WARR_GOFFICE,                    \n"
    				+ "    WARR_GJIJUM,                     \n"
    				+ "    WARR_GTEL,                       \n"
    				+ "    WARR_GMAN,                       \n"
    				+ "    WARR_HEADCONF,                   \n"
    				+ "    WARR_GREM,                       \n"
    				+ "    WARR_INDAY,                      \n"
    				+ "    WARR_INUSR,                      \n"
    				+ "    WARR_UPDAY,                      \n"
    				+ "    WARR_UPUSR,                      \n"
    				+ "    GUAR_ONOFF_YN,                   \n"
    				+ "    GUAR_ORGAN_CODE,                 \n"
    				+ "    CAUSECODE,                       \n"
    				+ "    TO_CHAR(TO_DATE(PAPERDATE,'YYYYMMDD'),'YYYY-MM-DD') AS PAPERDATE,                       \n"
    				+ "    REJECTMENT,                      \n"
    				+ "    EXEMPTMENT,                      \n"
    				+ "    ACCDOCSTATUS,                    \n"
    				+ "    ACCDOC_SEQ,                      \n"
    				+ "    GRTREQNO,                        \n"
    				+ "    YEARINSUREYN,                    \n"
    				+ "    REQDATE,                         \n"
    				+ "    GUAR_STATUS,                     \n"
    				+ "    BOND_SEQ,                        \n"
    				+ "    CONTSEQ,                         \n"
    				+ "    GUARRATEGBNCODE,                 \n"
    				+ "    LONGGBN,                         \n"
    				+ "    CONTTYPE,                        \n"
    				+ "    ORDEROWNER,                      \n"
    				+ "    CONTAMT,                         \n"
    				+ "    CONTDATE,                        \n"
    				+ "    CONTSTARTDATE,                   \n"
    				+ "    CONTCLOSEDATE,                   \n"
    				+ "    PREPAYREFYN,                     \n"
    				+ "    EXIISTREFYN,                     \n"
    				+ "    TRADESIGNYN,                     \n"
    				+ "    TRADESIGNDATE,                   \n"
    				+ "    CONTCHECKDATE,                   \n"
    				+ "    CONTEXISTENCEAMT,                \n"
    				+ "    PJTID,                           \n"
    				+ "    PAYMETHOD,                       \n"
    				+ "    CONTORGBNCODE,                   \n"
    				+ "    GUAR_CONTAMT,                    \n"
    				+ "    FILETITLE,                       \n"
    				+ "    FILE_NAME,                       \n"
    				+ "    FILEEXT,                         \n"
    				+ "    FILESIZE,                        \n"
    				+ "    EXFILETITLE,                     \n"
    				+ "    EXFILENAME,                      \n"
    				+ "    DEPNM,                           \n"
    				+ "    POSITION,                        \n"
    				+ "    EMPNM,                           \n"
    				+ "    HPNO,                            \n"
    				+ "    TELNO,                           \n"
    				+ "    EMAIL,                           \n"
    				+ "    ITEMDOC,                         \n"
    				+ "    ITEMEXT,                         \n"
    				+ "    ITEMPATH,                        \n"
    				+ "    CONTORDERNO                      \n"
    				+ " FROM CONT_OUT_WARR                  \n"
    				+ " WHERE 1=1			                \n";
        	
        	sqlstr += " AND SUB_CONT_ID = '"+ params.get("selectSubContModId") +"'	\n";
        	sqlstr += " AND WARR_GUBUN = '1'										\n";	//선급금보증
        	sqlstr += " AND WARR_SEQ = '1'											\n";	//일련번호
        	
            search.setStatement(sqlstr);
            WAFLogger.debug(sqlstr);
            listRowSet = search.execute();
            if(listRowSet.size() != 0){
            	rowObject = RowSetUtility.getValueObject(listRowSet.getRow(0));
            }
            
        }
        catch(Exception e) {
            WAFLogger.error(this.getClass().getName() + " --> getContOutWarr() : " + e.getMessage());
            WAFLogger.error("SQL : " + search.getStatement());
            WAFLogger.error(e);
            return null;
        }
        finally {

            if( rowObject == null ) rowObject = new ValueObject();
            return rowObject;
        }
    }  
}
