/**
 *
 * @(#)author  [ok]
 * @(#)version 1.0
 * @(#)date    2014. 06. 30
 * @(#)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.Row;
import kr.co.hsnc.common.sql.RowSet;
import kr.co.hsnc.common.sql.RowSetImpl;
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.common.file.FileManager;

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

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

	public void doBiz() throws Exception {

		System.out.println("협력업체포탈 기성신청현황 상세 INIT");
		System.out.println(params.get("selectSubContId"));		//외주계약서ID
		System.out.println(params.get("acmpId"));				//기성ID
		System.out.println(params.get("acmpYyyymm"));			//기성년월
		System.out.println(params.get("conCorpId"));			//계약업체ID
		System.out.println(params.get("acmpNo"));				//기성차수
		
		//신청구분ComboList
		//RowSet rowSet = getPerpayReqDiv();
		//storage.addRowSet("perpayReqDivComboList", rowSet);
		
		//계약 정보, 세금계산서 정보  
		ValueObject prePayment = getPrePayment(params);
		storage.addValueObject("prePayment", prePayment);
		
		//기성정보
		ValueObject acmpData = getAcmpData(params);
		storage.addValueObject("acmpData", acmpData);
		
		//기성검사 첨부파일
	    RowSet acmpFileRow = getAcmpFileRowSet(params.get("acmpId"), "10");
	    //준공검사 첨부파일
	    RowSet compFileRow = getAcmpFileRowSet(params.get("acmpId"), "90");
	    
	    storage.addRowSet("acmpFileRow", acmpFileRow);
	    storage.addRowSet("compFileRow", compFileRow);
		
		//첨부파일
        //storage.addValueObject("PREPAYMENTS_GIVEUP", getfilelist("PREPAYMENTS_GIVEUP",prePayment.get("PREPAY_ID"),"PREPAYMENTS_GIVEUP"));
        //storage.addValueObject("TAX_BILL", getfilelist("TAX_BILL",prePayment.get("PREPAY_ID"),"TAX_BILL"));

		//보증정보
		//ValueObject contOutWarr = getContOutWarr(params);
		//storage.addValueObject("contOutWarr", contOutWarr);
		
		
	}
	
    /**
     * 첨부파일 조회.
	 * @param 
	 * @param 
	 * @return ValueObject
	 */
	private ValueObject getfilelist(String filegb,String id,String returnid){
		ValueObject vo = new ValueObject();
		RowSet rowSet = FileManager.getFileList(filegb, id);
		String str="";
	        for(int i=0;i<rowSet.size();i++){
	        	Row row=rowSet.getRow(i);
	        	str += (i+1)+" : "+row.get("FILE_NAME")+" ("+ row.get("FILE_SIZE")+")";
	        	if(i+1!=rowSet.size()){
	        		str +="\r\n";
	        	}
	        }
	        vo.set(returnid, str);
		return vo;
	}
	
    /**
     * 선급금 신청 신청구분를 조회 한다.
	 * @param 
	 * @param 
	 * @return ValueObject
	 */
	public RowSet getPerpayReqDiv(){

        Search search = new SearchImpl();
        RowSet listRowSet = null;
        String sqlstr = "";
        
        try {
            sqlstr += " SELECT DETAILCD, DETAILNM             	\n"
                    + " FROM EBID_COM911T      					\n"
                    + " WHERE BASECD = 'REG_DIV_CD'     		\n";
             
            search.setStatement(sqlstr);
            listRowSet = search.execute();
			
		}catch(Exception e){
			e.printStackTrace();
		}finally{

			if( listRowSet == null ){
            	listRowSet = new RowSetImpl();
            }
            
			return listRowSet;
		}
	}
	
    /**
     *@param ValueObject
     *@return ValueObject
     *기   능 : 기성신청현황 상세(외주) 계약정보, 세금계산서정보 조회
     *@author OK
     *@version 2014. 6. 30.
     *@since JDK1.7
     */
    public ValueObject getPrePayment(ValueObject Params) {
        Search search = new SearchImpl();
        RowSet listRowSet = null;
        String sqlstr = "";
        ValueObject rowObject = null;
        
        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"
        			+ "     NVL(B.PREPAY_AMT,A.PREPAY_AMT) AS PREPAY_AMT,															                                     \n"
        			+ "     A.PREPAY_SUPPLY_AMT,                            \n"
        			+ "     NVL(B.PREPAY_SUPPLY_TAMT, A.PREPAY_SUPPLY_TAMT) AS SUB_PREPAY_SUPPLY_TAMT,											                         \n"
        			+ "     NVL(B.PREPAY_SUPPLY_NAMT, A.PREPAY_SUPPLY_NAMT) AS SUB_PREPAY_SUPPLY_NAMT, 																	 \n"
        			+ "     NVL(B.PREPAY_SURTAX_AMT, A.PREPAY_SURTAX_AMT) AS SUB_PREPAY_SURTAX_AMT,    																	 \n"
        			//+ "     TO_CHAR(TRUNC(((A.PREPAY_SUPPLY_AMT + A.PREPAY_SURTAX_AMT) / A.PREPAY_AMT)  * 100, 2), 'FM999.0') AS  PREPAY_AMT_PERCENT,                    \n"
        			+ "     TO_CHAR(TRUNC((A.PREPAY_AMT / A.CON_AMT) * 100, 2), 'FM999.0') AS  PREPAY_AMT_PERCENT,                    \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"
					+ "     B.PREPAY_ID,									\n"
					+ "     B.SUB_CONT_MOD_ID,                          	\n"
					+ "     B.PREPAY_SEQ,                                  	\n"
					+ "     B.CORP_ID,                                     	\n"
					+ "     B.STATUS_CD,            	                    \n"
					+ "     B.PREPAY_DATE,              	                \n"
					+ "     B.PREPAY_AMT AS PRE_PREPAY_AMT,    	            \n"
					+ "     B.PREPAY_SUPPLY_AMT,                           	\n"
					+ "     B.PREPAY_SUPPLY_TAMT,                          	\n"
					+ "     B.PREPAY_SUPPLY_NAMT,                          	\n"
					+ "     B.PREPAY_SURTAX_AMT,                           	\n"
					+ "     NVL(B.REQ_PREPAY_AMT, A.PREPAY_AMT) AS REQ_PREPAY_AMT,																	\n"
					+ "     NVL(B.REQ_PREPAY_SUPPLY_TMAT, A.PREPAY_SUPPLY_TAMT) AS REQ_PREPAY_SUPPLY_TMAT,					                     	\n"
					+ "     NVL(B.REQ_PREPAY_SUPPLY_NAMT, A.PREPAY_SUPPLY_NAMT) AS REQ_PREPAY_SUPPLY_NAMT,					                     	\n"
					+ "     NVL(B.REQ_PREPAY_SURTAX_AMT, A.PREPAY_SURTAX_AMT) AS REQ_PREPAY_SURTAX_AMT,						                      	\n"
					+ "     TO_CHAR(TRUNC((NVL(B.REQ_PREPAY_AMT, A.PREPAY_AMT) / A.CON_AMT) * 100, 2), 'FM999.0') AS REQ_PREPAY_PERCENT,           	\n"
					+ "     NVL(B.PREPAY_AMT,A.PREPAY_AMT) - NVL(B.REQ_PREPAY_AMT, A.PREPAY_AMT) AS GIVE_AMT,          								\n"
					+ "     NVL(B.REQ_PREPAY_SUPPLY_TMAT, A.PREPAY_SUPPLY_TAMT) - NVL(B.PREPAY_SUPPLY_TAMT, A.PREPAY_SUPPLY_TAMT) AS GIVE_SUPPLY_TMAT, 	\n"
					+ "     NVL(B.REQ_PREPAY_SUPPLY_NAMT, A.PREPAY_SUPPLY_NAMT) - NVL(B.PREPAY_SUPPLY_NAMT, A.PREPAY_SUPPLY_NAMT) AS GIVE_SUPPLY_NAMT, 	\n"
					+ "     NVL(B.REQ_PREPAY_SURTAX_AMT, A.PREPAY_SURTAX_AMT) - NVL(B.PREPAY_SURTAX_AMT, A.PREPAY_SURTAX_AMT) AS GIVE_SURTAX_AMT, 	\n"
					+ "     TO_CHAR(TRUNC(((NVL(B.REQ_PREPAY_AMT, A.PREPAY_AMT) - NVL(B.PREPAY_AMT,A.PREPAY_AMT)) / A.CON_AMT) * 100, 2), 'FM999.0') AS GIVE_PERCENT,           	\n"
					+ "     B.PREPAY_DESC,                                 	\n"
					+ "     B.CON_CUR_CD AS PRE_CON_CUR_CD,                	\n"
					+ "     NVL(B.TAX_METHOD_CD, '1') AS TAX_METHOD_CD,    	\n"
					+ "     NVL(B.TAX_DY, TO_CHAR(SYSDATE, 'YYYY-MM-DD')) AS TAX_DY,						                                    	\n"
					+ "     B.TAX_CHARG_NM,                                	\n"
					+ "     B.TAX_CHARG_HP,                                	\n"
					+ "     B.TAX_CHARG_EMAIL,                             	\n"
					+ "     NVL(B.REQ_DIV_CD, '1') AS REQ_DIV_CD,          	\n"
					+ "     B.SIGN_DATA,                                   	\n"
					+ "     B.SIGN_DT,                                     	\n"
					+ "     B.SIGN_DN,                                     	\n"
					+ "     B.CRE_BY,                                      	\n"
					+ "     B.CRE_DATE,                                    	\n"
					+ "     B.UPD_BY,                                      	\n"
					+ "     B.UPD_DATE,                                    	\n"
					+ "		C.CORP_ID,										\n"
					+ "		C.SUB_CONT_MOD_ID,        						\n"
					+ "		C.SIGN_SEQ,               						\n"
					+ "		SUBSTR(VENDCD, 0,3) || '-' || SUBSTR(VENDCD, 3,2) || '-' || SUBSTR(VENDCD, 5,5)AS VENDCD,        						\n"
					+ "		C.MEMBER_NAME,            						\n"
					+ "		C.BOSS_NAME,              						\n"
					+ "		C.POST_CODE,              						\n"
					+ "		C.ADDRESS,                						\n"
					+ "		C.TEL_NUM,                						\n"
					+ "		C.MEMBER_SLNO,            						\n"
					+ "		NVL(B.TAX_CHARG_NM, C.USER_NAME) AS  USER_NAME,										              						\n"
					+ "		C.HP1,                    						\n"
					+ "		C.HP2,                    						\n"
					+ "		C.HP3,                    						\n"
					+ "		NVL(B.TAX_CHARG_HP, C.HP1 || '-' || C.HP2 || '-' || C.HP3) AS HP,														\n"
					+ "		NVL(B.TAX_CHARG_EMAIL, C.EMAIL) AS EMAIL,										                  						\n"
					+ "		DECODE(C.SIGN_DATE, null, '미서명', '서명완료' ) AS  CUST_SIGN_DATE,					              						\n"
					+ "		C.SIGN_DN,                						\n"
					+ "		C.SIGN_DATA					      				\n"
        			+ " FROM SUB2000T A, PREPAY_OUT	B		    			\n"
        			+ " 	, CONT_OUT_CUST C      							\n"
        			+ " WHERE A.SUB_CONT_MOD_ID = B.SUB_CONT_MOD_ID(+)      \n"
        			+ " AND A.SUB_CONT_MOD_ID = C.SUB_CONT_MOD_ID		    \n";
        	
        	sqlstr += " AND A.SUB_CONT_ID = '"+ params.get("selectSubContId") +"'	\n";
             
            search.setStatement(sqlstr);
            System.out.println(sqlstr);
            listRowSet = search.execute();
            rowObject = RowSetUtility.getValueObject(listRowSet.getRow(0));
            
        }
        catch(Exception e) {
            WAFLogger.error(this.getClass().getName() + " --> getPrePayment() : " + e.getMessage());
            WAFLogger.error("SQL : " + search.getStatement());
            WAFLogger.error(e);
            return null;
        }
        finally {

            if( rowObject == null ) rowObject = new ValueObject();
            return rowObject;
        }
    }
 
    /**
     *@param ValueObject
     *@return ValueObject
     *기   능 : 기성신청현황 상세(외주) 기성정보 조회
     *@author OK
     *@version 2014. 6. 30.
     *@since JDK1.7
     */
    public ValueObject getAcmpData(ValueObject Params) {
        Search search = new SearchImpl();
        RowSet listRowSet = null;
        StringBuffer sql = new StringBuffer();
        ValueObject rowObject = null;
        String sqlstr = "";
        
        try {
//        	sqlstr += " SELECT 			  								  																\n"
//        			+ "     A.SUB_CONT_ID                              						--외주계약서ID          			  			\n"
//        			+ "     , A.DEPT_NAME                              						--현장명                			  			\n"
//        			+ "     , A.CON_CUR_CD				                              		--계약통화                			  			\n"
//        			+ "     , B.CON_CORP_ID				                                	--계약업체ID             			  			\n"
//        			+ "     , B.CORP_ID					                                	--협력업체ID             			  			\n"
//        			+ "     , B.CORP_REG_NO					                            	--사업자등록번호          			  			\n"
//        			+ "     , B.CORP_KOR					                            	--계약업체명               			  			\n"
//        			+ "     , ''	AS BOSS_NAME		                                	--대표이사                			  			\n"
//        			+ "     , TO_CHAR(A.START_WORK_DATE,'YYYY-MM-DD') AS START_WORK_DATE    --계약기간 시작일         			  			\n"
//        			+ "     , TO_CHAR(A.END_WORK_DATE,'YYYY-MM-DD') AS END_WORK_DATE        --계약기간 종료일         			  			\n"
//        			+ "     , A.CON_AMT							                            --계약금액                			  			\n"
//        			+ "     , A.PREPAY_AMT					                                --선급금액                			  			\n"
//        			+ "     , '1'    	AS dsfasdf				                            --발행구분                			  			\n"
//        			+ "     , '김대금'   AS fdefd				                            --담당자명                			  			\n"
//        			+ "     , '02-1111-2222' AS fesds                              			--담당자 핸드폰번호        			  			\n"
//        			+ "     , 'xxxx@xxx.com' AS dfema			                            --담당자 이메일            			  			\n"
//        			+ "     , C.CHECK_COMP													--검사인_소속                			  		\n"
//        			+ "     , C.CHECK_MAN													--검사인_성명              			  			\n"
//        			+ "     , C.CHECK_TEL													--검사인_연락처            			  			\n"
//        			+ "     , C.ATTEN_COMP													--입회인_소속          			  			\n"
//        			+ "     , C.ATTEN_MAN													--입회인_성명          			  			\n"
//        			+ "     , C.ATTEN_TEL													--입회인_연락처          			  			\n"
//        			+ "     , NVL(C.ACMP_NO, 1) AS ACMP_NO                              --기성차수                			  			\n"
//        			+ "     , NVL(C.PRE_FUND_TAMT, 0) AS  PRE_FUND_TAMT     --기성 전회까지 과세               		            		\n"
//        			+ "     , NVL(C.PRE_FUND_NAMT, 0) AS  PRE_FUND_NAMT     --기성 전회까지 면세        	                       		\n"
//        			+ "     , NVL(C.PRE_FUND_AMT, 0)  AS PRE_FUND_AMT         --기성 전회까지 합계             	                        \n"
//        			+ "     , ROUND((NVL(C.PRE_FUND_AMT, 0) / A.CON_AMT)*100,1) PRE_FUND_RATE                 	                    \n"
//        			+ "     , NVL(C.PRE_PAY_DEDUCT_TAMT, 0) AS  PRE_PAY_DEDUCT_TAMT     --선급공제  전회까지 과세                           \n"
//        			+ "     , NVL(C.PRE_PAY_DEDUCT_NAMT, 0) AS  PRE_PAY_DEDUCT_NAMT     --선급공제  전회까지 면세                           \n"
//        			+ "     , NVL(C.PRE_PAY_DEDUCT_AMT, 0) AS  PRE_PAY_DEDUCT_AMT     --선급공제  전회까지 합계                             \n"
//        			+ "     , ROUND(NVL(C.PRE_PAY_DEDUCT_RATE, 0),1) AS  PRE_PAY_DEDUCT_RATE     --선급공제  전회까지 기성율              \n"
//        			+ "     , NVL(C.FUND_TAMT, 0) AS FUND_TAMT                     --기성 금회 과세                                    		\n"
//        			+ "     , NVL(C.FUND_NAMT, 0) AS FUND_NAMT                     --기성 금회 면세                                       	\n"
//        			+ "     , NVL(C.FUND_AMT, 0) AS FUND_AMT                          --기성 금회 합계                                    	\n"
//        			+ "     , ROUND((NVL(C.FUND_AMT, 0) / A.CON_AMT)*100,1) FUND_RATE                                   			\n"
//        			+ "     , NVL(C.PAY_DEDUCT_TAMT, 0) AS PAY_DEDUCT_TAMT                     --선급공제 금회 과세                       \n"
//        			+ "     , NVL(C.PAY_DEDUCT_NAMT, 0) AS PAY_DEDUCT_NAMT                     --선급공제 금회 면세                       \n"
//        			+ "     , NVL(C.PAY_DEDUCT_AMT, 0) AS PAY_DEDUCT_AMT                     --선급공제 금회 합계                         \n"
//        			+ "     , ROUND(NVL(C.PAY_DEDUCT_RATE, 0),1) AS  PAY_DEDUCT_RATE     --선급공제  금회 기성율                           \n"
//        			+ "     , NVL(C.TOT_FUND_TAMT, 0) AS TOT_FUND_TAMT      --기성 누계 과세                                  				\n"
//        			+ "     , NVL(C.TOT_FUND_NAMT, 0) AS TOT_FUND_NAMT      --기성 누계 면세                                     			\n"
//        			+ "     , NVL(C.TOT_FUND_AMT, 0) AS TOT_FUND_AMT          --기성 누계 합계                                   			\n"
//        			+ "     , ROUND((NVL(C.TOT_FUND_AMT, 0) / A.CON_AMT)*100,1) TOT_FUND_RATE                                   	\n"
//        			+ "     , NVL(C.TOT_PAY_DEDUCT_TAMT, 0) AS TOT_PAY_DEDUCT_TAMT      --선급공제 누계 과세                               \n"
//        			+ "     , NVL(C.TOT_PAY_DEDUCT_NAMT, 0) AS TOT_PAY_DEDUCT_NAMT      --선급공제 누계 면세                               \n"
//        			+ "     , NVL(C.TOT_PAY_DEDUCT_AMT, 0) AS TOT_PAY_DEDUCT_AMT      --선급공제 누계 합계                                  \n"
//        			+ "     , ROUND(NVL(C.TOT_PAY_DEDUCT_RATE, 0),1) AS  TOT_PAY_DEDUCT_RATE     --선급공제  누계 기성율                  \n"
//        			+ "     , A.CON_AMT - NVL(C.TOT_FUND_TAMT, 0) AS RESIDUAL_TAMT   --기성 잔여 과세                                  	 \n"
//        			+ "     , A.CON_AMT - NVL(C.TOT_FUND_NAMT, 0) AS RESIDUAL_NTAMT   --기성 잔여 면세                                 	\n"
//        			+ "     , A.CON_AMT - NVL(C.TOT_FUND_AMT, 0) AS RESIDUAL_AMT   --기성 잔여 헙계                                  		\n"
//        			+ "     , ROUND(((A.CON_AMT - NVL(C.TOT_FUND_AMT, 0)) / A.CON_AMT)*100,1) RESIDUAL_RATE                         \n"
//        			+ "     , A.CON_AMT - NVL(C.TOT_PAY_DEDUCT_TAMT, 0) AS RESIDUAL_DEDUCT_TAMT   --선급공제 잔여 과세                    \n"
//        			+ "     , A.CON_AMT - NVL(C.TOT_PAY_DEDUCT_NAMT, 0) AS RESIDUAL_DEDUCT_NAMT   --선급공제 잔여 면세                     \n"
//        			+ "     , A.CON_AMT - NVL(C.TOT_PAY_DEDUCT_AMT, 0) AS RESIDUAL_DEDUCT_AMT   --선급공제 잔여 합계                       \n"
//        			+ "     , ROUND(((A.CON_AMT - NVL(C.TOT_PAY_DEDUCT_AMT, 0)) / A.CON_AMT)*100,1) RESIDUAL_DEDUCT_RATE              \n"
//					+ "     , NVL(C.PRE_REQU_SUPPLY_TAMT,0) AS PRE_REQU_SUPPLY_TAMT           --전회 과세 청구액 공급가액                    \n"
//					+ "     , NVL(C.PRE_REQU_SUPPLY_NAMT,0) AS PRE_REQU_SUPPLY_NAMT           --전회 면세 청구액 공급가액                    \n"
//					+ "     , NVL(C.PRE_REQU_SUPPLY_AMT,0) AS PRE_REQU_SUPPLY_AMT             --전회 과세 청구액 공급가액                    \n"
//					+ "     , NVL(C.REQU_SUPPLY_TAMT,0) AS REQU_SUPPLY_TAMT           		  --금회 과세 청구액 공급액 		           \n"
//					+ "     , NVL(C.REQU_SUPPLY_NAMT,0) AS REQU_SUPPLY_NAMT           		  --금회 면세 청구액 공급액    		 		   \n"
//					+ "     , NVL(C.REQU_SUPPLY_AMT,0) AS REQU_SUPPLY_AMT           		  --금회 합계 청구액 공급액      			   \n"
//					+ "     , NVL(C.TOT_REQU_SUPPLY_TAMT,0) AS TOT_REQU_SUPPLY_TAMT           --누계 과세 청구액 공급액                       \n"
//					+ "     , NVL(C.TOT_REQU_SUPPLY_NAMT,0) AS TOT_REQU_SUPPLY_NAMT           --누계 면세 청구액 공급액                       \n"
//					+ "     , NVL(C.TOT_REQU_SUPPLY_AMT,0) AS TOT_REQU_SUPPLY_AMT             --누계 합계 청구액 공급액                	   \n"
//					+ "     , NVL(C.PRE_REQU_SURTAX_AMT,0) AS PRE_REQU_SURTAX_AMT             --전회 과세 청구액 부가세                       \n"
//					+ "     , NVL(C.REQU_SURTAX_AMT,0) AS REQU_SURTAX_AMT           		  --금회 과세 청구액 부가세       				\n"
//					+ "     , NVL(C.TOT_REQU_SURTAX_AMT,0) AS TOT_REQU_SURTAX_AMT             --누계 과세 청구액 부가세                        \n"
//					+ "     , NVL(C.PRE_REQU_AMT,0) AS PRE_REQU_AMT           				  --전회 합계 청구액 합계					   \n"
//					+ "     , NVL(C.REQU_AMT,0) AS REQU_AMT                                   --금회 합계 청구액 합계                   		\n"
//					+ "     , NVL(C.TOT_REQU_AMT,0) AS TOT_REQU_AMT           				  --누계 합계 청구액 합계     					\n"
//        			+ "     , C.ACMP_REMARK --특기사항                       																	    \n"
//        			+ " FROM SUB1000T!CCSIF A, SUB1020T!CCSIF B, SUB1040T!CCSIF C		    													\n"
//        			+ " WHERE 1=1      																											\n"
//        			+ " AND A.SUB_CONT_ID = B.SUB_CONT_ID      																					\n"
//        			+ " AND B.CON_CORP_ID = C.CON_CORP_ID(+)		    																		\n";
//        	
//        	sqlstr += " AND A.SUB_CONT_ID = '"+ params.get("selectSubContId") +"'																\n";
//        	sqlstr += " AND C.ACMP_YYYYMM = '201206'																							\n";
//    		
//        	System.out.println(params.get("selectSubContId"));		//외주계약서ID
//    		System.out.println(params.get("acmpId"));				//기성ID
//    		System.out.println(params.get("acmpYyyymm").replaceAll("-", ""));			//기성년월
//    		System.out.println(params.get("conCorpId"));			//계약업체ID
//    		System.out.println(params.get("acmpNo"));				//기성차수
//    		
//            search.setStatement(sqlstr);
//            System.out.println(sqlstr);


      	  	sql.append("		   SELECT A.ACMP_ID  --기성ID																						\n");
      	  	sql.append(" 				,A.DEPT_CD--현장코드																							\n");
      	  	sql.append(" 				,B.DEPT_NAME--현장명																							\n");
      	  	sql.append(" 				,A.SUB_CONT_ID--계약ID																						\n");
      	  	sql.append(" 				,B.CON_DOC_NO--계약번호																						\n");
      	  	sql.append(" 				,B.BUILD_NAME--계약명																						\n");
      	  	sql.append(" 				,C.CORP_REG_NO--사업자번호																					\n");
      	  	sql.append(" 				,C.CORP_KOR   --계약업체명																					\n");
      	  	sql.append(" 				,A.CON_CORP_ID--계약업체																					\n");
      	  	sql.append(" 				,TO_CHAR(B.CON_DATE, 'YYYY-MM-DD') CON_DATE--계약일자																					\n");
      	  	sql.append(" 				,TO_CHAR(B.START_WORK_DATE, 'YYYY-MM-DD') START_WORK_DATE--계약시작일																					\n");
      	  	sql.append(" 				,TO_CHAR(B.END_WORK_DATE, 'YYYY-MM-DD') END_WORK_DATE--계약종료일																					\n");
      	  	sql.append(" 				,B.CON_AMT--계약금																					\n");
      	  	sql.append(" 				,B.CON_SUPPLY_AMT--계약공급가																					\n");
      	  	sql.append(" 				,B.CON_SUPPLY_TAMT--계약공급가_과세																					\n");
      	  	sql.append(" 				,B.CON_SUPPLY_NAMT--계약공급가_면세																					\n");
      	  	sql.append(" 				,B.CON_SURTAX_AMT--계약금_부가세																					\n");
      	  	sql.append(" 				,B.PREPAY_AMT--선급금																					\n");
      	  	sql.append(" 				,B.PREPAY_SUPPLY_AMT--선급금공급가																					\n");
      	  	sql.append(" 				,B.PREPAY_SUPPLY_TAMT--선급금공급가_과세																					\n");
      	  	sql.append(" 				,B.PREPAY_SUPPLY_NAMT--선급금공급가_면세																					\n");
      	  	sql.append(" 				,B.PREPAY_SURTAX_AMT--선급금부가세																					\n");
		      
      	  	// 최초계약금액의 선급금을 지불하기위해 수정	By hanwool 	2012-09-18
      	  	sql.append("				,F.CON_AMT AS FIRST_CON_AMT--최초계약금																		\n");
      	  	sql.append("				,F.CON_SUPPLY_AMT AS FIRST_CON_SUPPLY_AMT--최초계약공급가													\n");
      	  	sql.append("				,F.CON_SUPPLY_TAMT AS FIRST_CON_SUPPLY_TAMT--최초계약공급가_과세												\n");
      	  	sql.append("				,F.CON_SUPPLY_NAMT AS FIRST_CON_SUPPLY_NAMT--최초계약공급가_면세												\n");
      	  	sql.append("				,F.CON_SURTAX_AMT AS FIRST_CON_SURTAX_AMT--최초계약금_부가세   												\n");
      	  	sql.append("				,F.PREPAY_AMT AS FIRST_PREPAY_AMT--최초선급금																\n");
      	  	sql.append("				,F.PREPAY_SUPPLY_AMT AS FIRST_PREPAY_SUPPLY_AMT--최초선급금공급가											\n");
      	  	sql.append("				,F.PREPAY_SUPPLY_TAMT AS FIRST_PREPAY_SUPPLY_TAMT--최초선급금공급가_과세										\n");
      	  	sql.append("				,F.PREPAY_SUPPLY_NAMT AS FIRST_PREPAY_SUPPLY_NAMT--최초선급금공급가_면세										\n");
      	  	sql.append("				,F.PREPAY_SURTAX_AMT AS FIRST_PREPAY_SURTAX_AMT--최초선급금부가세											\n");
      	  	
      	  	sql.append(" 				,(NVL(D.SUPPLY_AMT,0) + NVL(D.SURTAX_AMT,0)) SL_PREPAY_AMT --선급발생금																					\n");
      	  	sql.append(" 				,NVL(D.SUPPLY_AMT, 0) SL_PREPAY_SUPPLY_AMT--선급발생_공급가																					\n");
      	  	sql.append(" 				,NVL(D.SUPPLY_TAMT, 0) SL_PREPAY_SUPPLY_TAMT--선급발생_공급가_과세																					\n");
      	  	sql.append(" 				,NVL(D.SUPPLY_NAMT, 0) SL_PREPAY_SUPPLY_NAMT--선급발생_공급가_면세																					\n");
      	  	sql.append(" 				,NVL(D.SURTAX_AMT, 0) SL_PREPAY_SURTAX_AMT--선급발생_부가세																					\n");
      	  	sql.append(" 				,A.ACMP_YYYYMM--기성년월																					\n");
      	  	sql.append(" 				,TO_CHAR(TO_DATE(A.ACMP_YYYYMM, 'YYYYMM'), 'YYYY-MM') ACMP_YYYY_MM--기성년월																					\n");
      	  	sql.append(" 				,A.ACMP_NO--기성차수																					\n");
      	  	sql.append(" 				,TO_CHAR(A.ACMP_DATE, 'YYYY-MM-DD') ACMP_DATE--기성일자																					\n");
      	  	sql.append(" 				,A.CON_CUR_CD--계약통화																					\n");
      	  	sql.append(" 				,F_GET_CODE_NAME('911', A.CON_CUR_CD) CON_CUR_NM--계약통화																					\n");
      	  	sql.append(" 				,A.PROOF_CD--증빙구분																					\n");
      	  	sql.append(" 				,F_GET_CODE_NAME('PROOF_CD', A.PROOF_CD) PROOF_NM --증빙구분																					\n");
      	  	sql.append(" 				,TO_CHAR(A.CON_START_DATE, 'YYYY-MM-DD') CON_START_DATE--기성공사시작일																					\n");
      	  	sql.append(" 				,TO_CHAR(A.CON_END_DATE, 'YYYY-MM-DD') CON_END_DATE--기성공사종료일																					\n");
      	  	sql.append(" 				,A.CHECK_COMP--검사인_소속																					\n");
      	  	sql.append(" 				,A.CHECK_MAN--검사인_성명																					\n");
      	  	sql.append(" 				,A.CHECK_TEL--검사인_연락처																					\n");
      	  	sql.append(" 				,A.ATTEN_COMP--입회인_소속																					\n");
      	  	sql.append(" 				,A.ATTEN_MAN--입회인_성명																					\n");
      	  	sql.append(" 				,A.ATTEN_TEL--입회인_연락처																					\n");
      	  	
      	  	sql.append(" 				,ROUND((A.PRE_FUND_AMT/B.CON_SUPPLY_AMT)*100,2) PRE_FUND_RATE--전월기성율																					\n");
      	  	sql.append(" 				,DECODE(NVL(B.CON_SUPPLY_TAMT,0),0,0,ROUND((A.PRE_FUND_TAMT/B.CON_SUPPLY_TAMT)*100,2)) PRE_FUND_TRATE--전월기성율_과세   																					\n");
      	  	sql.append(" 				,DECODE(NVL(B.CON_SUPPLY_NAMT,0),0,0,ROUND((A.PRE_FUND_NAMT/B.CON_SUPPLY_NAMT)*100,2)) PRE_FUND_NRATE--전월기성율_면세   																					\n");
      	  	sql.append(" 				,A.PRE_FUND_AMT--전월기성금액																					\n");
      	  	sql.append(" 				,A.PRE_FUND_TAMT--전월기성금액_과세																					\n");
      	  	sql.append(" 				,A.PRE_FUND_NAMT--전월기성금액_면세																					\n");
      	  	sql.append(" 				,DECODE(NVL(D.SUPPLY_AMT, 0),0,0,ROUND((A.PRE_PAY_DEDUCT_AMT/D.SUPPLY_AMT)*100,2)) PRE_PAY_DEDUCT_RATE--전월선급공제율																					\n");
      	  	sql.append(" 				,DECODE(NVL(D.SUPPLY_TAMT, 0),0,0,ROUND((A.PRE_PAY_DEDUCT_TAMT/D.SUPPLY_TAMT)*100,2)) PRE_PAY_DEDUCT_TRATE--전월선급공제율_과세   																					\n");
      	  	sql.append(" 				,DECODE(NVL(D.SUPPLY_NAMT, 0),0,0,ROUND((A.PRE_PAY_DEDUCT_NAMT/D.SUPPLY_NAMT)*100,2)) PRE_PAY_DEDUCT_NRATE--전월선급공제율_면세																					\n");   
      	  	sql.append(" 				,A.PRE_PAY_DEDUCT_AMT--전월선급공제금액																					\n");
      	  	sql.append(" 				,A.PRE_PAY_DEDUCT_TAMT--전월선급공제금액_과세																					\n");
      	  	sql.append(" 				,A.PRE_PAY_DEDUCT_NAMT--전월선급공제금액_면세																					\n");
      	  	sql.append(" 				,A.PRE_REQU_SUPPLY_AMT--전월청구_공급가																					\n");
      	  	sql.append(" 				,A.PRE_REQU_SUPPLY_TAMT--전월청구_공급가_과세																					\n");
      	  	sql.append(" 				,A.PRE_REQU_SUPPLY_NAMT--전월청구_공급가_면세																					\n");
      	  	sql.append(" 				,A.PRE_REQU_SURTAX_AMT--전월청구_부가세																					\n");
      	  	sql.append(" 				,A.PRE_REQU_SURTAX_AMT PRE_REQU_SURTAX_TAMT--전월청구_부가세_과세																					\n");
      	  	sql.append(" 				,0 PRE_REQU_SURTAX_NAMT--전월청구_부가세_면세																					\n");
      	  	sql.append(" 				,A.PRE_REQU_AMT--전월청구액																					\n");
      	  	sql.append(" 				,(A.PRE_REQU_SUPPLY_TAMT + A.PRE_REQU_SURTAX_AMT) PRE_REQU_TAMT--전월청구액_과세																					\n");
      	  	sql.append(" 				,A.PRE_REQU_SUPPLY_NAMT PRE_REQU_NAMT --전월청구액_면세																					\n");
      	  	
      	  	sql.append(" 				,ROUND((A.FUND_AMT/B.CON_SUPPLY_AMT)*100,2) FUND_RATE--금회기성율																					\n");
      	  	sql.append(" 				,DECODE(NVL(B.CON_SUPPLY_TAMT,0),0,0,ROUND((A.FUND_TAMT/B.CON_SUPPLY_TAMT)*100,2)) FUND_TRATE--금회기성율_과세																					\n");
      	  	sql.append(" 				,DECODE(NVL(B.CON_SUPPLY_NAMT,0),0,0,ROUND((A.FUND_NAMT/B.CON_SUPPLY_NAMT)*100,2)) FUND_NRATE--금회기성율_면세																					\n");
      	  	sql.append(" 				,A.FUND_AMT--금회기성금액																					\n");
      	  	sql.append(" 				,A.FUND_TAMT--금회기성금액_과세																					\n");
      	  	sql.append(" 				,A.FUND_NAMT--금회기성금액_면세																					\n");
      	  	sql.append(" 				,DECODE(NVL(D.SUPPLY_AMT, 0),0,0,ROUND((A.PAY_DEDUCT_AMT/D.SUPPLY_AMT)*100,2)) PAY_DEDUCT_RATE--금회선급공제율																					\n");
      	  	sql.append(" 				,DECODE(NVL(D.SUPPLY_TAMT, 0),0,0,ROUND((A.PAY_DEDUCT_TAMT/D.SUPPLY_TAMT)*100,2)) PAY_DEDUCT_TRATE--금회선급공제율_과세   																					\n");
      	  	sql.append(" 				,DECODE(NVL(D.SUPPLY_NAMT, 0),0,0,ROUND((A.PAY_DEDUCT_NAMT/D.SUPPLY_NAMT)*100,2)) PAY_DEDUCT_NRATE--금회선급공제율_면세   																					\n");
      	  	sql.append(" 				,A.PAY_DEDUCT_AMT--금회선급공제금액																					\n");
      	  	sql.append(" 				,A.PAY_DEDUCT_TAMT--금회선급공제금액_과세																					\n");
      	  	sql.append(" 				,A.PAY_DEDUCT_NAMT--금회선급공제금액_면세																					\n");
      	  	sql.append(" 				,A.REQU_SUPPLY_AMT--금회청구_공급가																					\n");
      	  	sql.append(" 				,A.REQU_SUPPLY_TAMT--금회청구_공급가_과세																					\n");
      	  	sql.append(" 				,A.REQU_SUPPLY_NAMT--금회청구_공급가_면세																					\n");
      	  	sql.append(" 				,A.REQU_SURTAX_AMT--금회청구_부가세																					\n");
      	  	sql.append(" 				,A.REQU_SURTAX_AMT REQU_SURTAX_TAMT--금회청구_부가세_과세																					\n");
      	  	sql.append(" 				,0 REQU_SURTAX_NAMT--금회청구_부가세_면세																					\n");
      	  	sql.append(" 				,A.REQU_AMT--금회청구액																					\n");
      	  	sql.append(" 				,(A.REQU_SUPPLY_TAMT + A.REQU_SURTAX_AMT) REQU_TAMT--금회청구액_과세																					\n");
      	  	sql.append(" 				,A.REQU_SUPPLY_NAMT REQU_NAMT --금회청구액_면세																					\n");
      	  	
      	  	sql.append(" 				,ROUND((A.TOT_FUND_AMT/B.CON_SUPPLY_AMT)*100,2) TOT_FUND_RATE--누계기성율												\n");
      	  	sql.append(" 				,DECODE(NVL(B.CON_SUPPLY_TAMT,0),0,0,ROUND((A.TOT_FUND_TAMT/B.CON_SUPPLY_TAMT)*100,2)) TOT_FUND_TRATE--누계기성율_과세																					\n");
      	  	sql.append(" 				,DECODE(NVL(B.CON_SUPPLY_NAMT,0),0,0,ROUND((A.TOT_FUND_NAMT/B.CON_SUPPLY_NAMT)*100,2)) TOT_FUND_NRATE--누계기성율_면세																					\n");
      	  	sql.append(" 				,A.TOT_FUND_AMT--누계기성금액																					\n");
      	  	sql.append(" 				,A.TOT_FUND_TAMT--누계기성금액_과세																					\n");
      	  	sql.append(" 				,A.TOT_FUND_NAMT--누계기성금액_면세																					\n");
      	  	sql.append(" 				,DECODE(NVL(D.SUPPLY_AMT, 0),0,0,ROUND((A.TOT_PAY_DEDUCT_AMT/D.SUPPLY_AMT)*100,2)) TOT_PAY_DEDUCT_RATE--누계선급공제율																					\n");
      	  	sql.append(" 				,DECODE(NVL(D.SUPPLY_TAMT, 0),0,0,ROUND((A.TOT_PAY_DEDUCT_TAMT/D.SUPPLY_TAMT)*100,2)) TOT_PAY_DEDUCT_TRATE--누계선급공제율_과세																					\n");   
      	  	sql.append(" 				,DECODE(NVL(D.SUPPLY_NAMT, 0),0,0,ROUND((A.TOT_PAY_DEDUCT_NAMT/D.SUPPLY_NAMT)*100,2)) TOT_PAY_DEDUCT_NRATE--누계선급공제율_면세																					\n");   
      	  	sql.append(" 				,A.TOT_PAY_DEDUCT_AMT--누계선급공제금액																					\n");
      	  	sql.append(" 				,A.TOT_PAY_DEDUCT_TAMT--누계선급공제금액_과세																					\n");
      	  	sql.append(" 				,A.TOT_PAY_DEDUCT_NAMT--누계선급공제금액_면세																					\n");
      	  	sql.append(" 				,A.TOT_REQU_SUPPLY_AMT--누계청구_공급가																					\n");
      	  	sql.append(" 				,A.TOT_REQU_SUPPLY_TAMT--누계청구_공급가_과세																					\n");
      	  	sql.append(" 				,A.TOT_REQU_SUPPLY_NAMT--누계청구_공급가_면세																					\n");
      	  	sql.append(" 				,A.TOT_REQU_SURTAX_AMT--누계청구_부가세																					\n");
      	  	sql.append(" 				,A.TOT_REQU_SURTAX_AMT TOT_REQU_SURTAX_TAMT--누계청구_부가세_과세																					\n");
      	  	sql.append(" 				,0 TOT_REQU_SURTAX_NAMT--누계청구_부가세_면세																					\n");
      	  	sql.append(" 				,A.TOT_REQU_AMT--누계청구액																					\n");
      	  	sql.append(" 				,(A.TOT_REQU_SUPPLY_TAMT + A.TOT_REQU_SURTAX_AMT) TOT_REQU_TAMT--누계청구액_과세																					\n");
      	  	sql.append(" 				,A.TOT_REQU_SUPPLY_NAMT TOT_REQU_NAMT --누계청구액_면세																					\n");
      	  	
      	  	sql.append(" 				,ROUND(((B.CON_SUPPLY_AMT - A.TOT_FUND_AMT)/B.CON_SUPPLY_AMT)*100,2) RES_FUND_RATE--잔여기성율																					\n");
      	  	sql.append(" 				,DECODE(NVL(B.CON_SUPPLY_TAMT,0),0,0,ROUND(((B.CON_SUPPLY_TAMT - A.TOT_FUND_TAMT)/B.CON_SUPPLY_TAMT)*100,2)) RES_FUND_TRATE--잔여기성율_과세																					\n");
      	  	sql.append(" 				,DECODE(NVL(B.CON_SUPPLY_NAMT,0),0,0,ROUND(((B.CON_SUPPLY_NAMT - A.TOT_FUND_NAMT)/B.CON_SUPPLY_NAMT)*100,2)) RES_FUND_NRATE--잔여기성율_면세																					\n");
      	  	sql.append(" 				,(B.CON_SUPPLY_AMT - A.TOT_FUND_AMT) RES_FUND_AMT --잔여기성금액																					\n");
      	  	sql.append(" 				,(B.CON_SUPPLY_TAMT - A.TOT_FUND_TAMT) RES_FUND_TAMT--잔여기성금액_과세																					\n");
      	  	sql.append(" 				,(B.CON_SUPPLY_NAMT - A.TOT_FUND_NAMT) RES_FUND_NAMT--잔여기성금액_면세																					\n");
      	  	sql.append(" 				,DECODE(NVL(D.SUPPLY_AMT,0),0,0,ROUND(((D.SUPPLY_AMT - A.TOT_PAY_DEDUCT_AMT)/D.SUPPLY_AMT)*100,2)) RES_PAY_DEDUCT_RATE--잔여선급공제율																					\n");
      	  	sql.append(" 				,DECODE(NVL(D.SUPPLY_TAMT,0),0,0,ROUND(((D.SUPPLY_TAMT - A.TOT_PAY_DEDUCT_TAMT)/D.SUPPLY_TAMT)*100,2)) RES_PAY_DEDUCT_TRATE--잔여선급공제율_과세																					\n");
      	  	sql.append(" 				,DECODE(NVL(D.SUPPLY_NAMT,0),0,0,ROUND(((D.SUPPLY_NAMT - A.TOT_PAY_DEDUCT_NAMT)/D.SUPPLY_NAMT)*100,2)) RES_PAY_DEDUCT_NRATE--잔여선급공제율_면세																					\n");
      	  	sql.append(" 				,(NVL(D.SUPPLY_AMT, 0) - A.TOT_PAY_DEDUCT_AMT) RES_PAY_DEDUCT_AMT --잔여선급공제금액																					\n");
      	  	sql.append(" 				,(NVL(D.SUPPLY_TAMT, 0) - A.TOT_PAY_DEDUCT_TAMT) RES_PAY_DEDUCT_TAMT--잔여선급공제금액_과세																					\n");
      	  	sql.append(" 				,(NVL(D.SUPPLY_NAMT, 0) - A.TOT_PAY_DEDUCT_NAMT) RES_PAY_DEDUCT_NAMT--잔여선급공제금액_면세																					\n");
      	  	sql.append(" 				,A.ACMP_REMARK--특기사항																					\n");
      	  	sql.append("			FROM SUB1040T A																					\n");
      	  	sql.append(" 				,SUB2000T B																					\n");
      	  	sql.append(" 				,SUB1020T C																					\n");
      	  	sql.append(" 				,(SELECT SUB_CONT_ID 																		\n");
      	  	sql.append("				 		,SUM(NVL(A.PREPAY_SUPPLY_AMT,0)) AS SUPPLY_AMT												\n");
      	  	sql.append("					    ,SUM(NVL(A.PREPAY_SUPPLY_TAMT,0)) AS SUPPLY_TAMT 												\n");
      	  	sql.append("  						,SUM(NVL(A.PREPAY_SUPPLY_NAMT,0)) AS SUPPLY_NAMT 												\n");
      	  	sql.append("						,SUM(NVL(A.PREPAY_SURTAX_AMT,0)) AS SURTAX_AMT													\n");
      	  	sql.append("				  FROM SUB1030T A   											\n");  
      	  	sql.append("				  WHERE A.SUB_CONT_ID = '"+ params.get("selectSubContId") +"'								\n");
      	    sql.append("				    and A.status_cd = '10'									    \n");
    	  	sql.append("                 ) D																					\n");   
      	  	// 최초계약금액의 선급금을 지불하기위해 수정	By hanwool 	2012-09-18
      	  	sql.append("				,(SELECT * FROM SUB2000T																						\n");
      	  	sql.append("				  WHERE  MOD_NO = '0'																							\n");
      	  	sql.append("						AND SUB_CONT_ID = '"+ params.get("selectSubContId") +"' ) F																				\n");
      	  	
      	  	sql.append("		 	WHERE A.ACMP_ID = '"+ params.get("acmpId") +"' -- 변수 기성ID																					\n"); 
      	  	sql.append("		 	AND A.SUB_CONT_ID = B.SUB_CONT_ID																					\n");
      	  	sql.append("		 	AND A.MOD_NO = B.MOD_NO																					\n");
      	  	sql.append("		 	AND A.CON_CORP_ID = C.CON_CORP_ID																					\n");
      	  	sql.append("		 	AND A.SUB_CONT_ID = D.SUB_CONT_ID (+)		                            				\n");
      	
      	  	search.setStatement(sql.toString());
      	  	System.out.println(sql.toString());
      	  	
            listRowSet = search.execute();
            rowObject = RowSetUtility.getValueObject(listRowSet.getRow(0));
            
        }
        catch(Exception e) {
            WAFLogger.error(this.getClass().getName() + " --> getPrePayment() : " + e.getMessage());
            WAFLogger.error("SQL : " + search.getStatement());
            WAFLogger.error(e);
            return null;
        }
        finally {

            if( rowObject == null ) rowObject = new ValueObject();
            return rowObject;
        }
    }
    
    /**
     *@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);
            System.out.println(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;
        }
    }  

    
    
    /** 첨부서류 
     * @return
     * @throws Exception
     */
    public RowSet getAcmpFileRowSet(String acmp_id, String code) throws Exception {
        Search search = new SearchImpl();
        RowSet listRowSet = null;
        StringBuffer sql = new StringBuffer();
        try {
    		sql.append("	SELECT A.DETAILCD								\n");
    		sql.append(" 		   ,A.DETAILNM								\n");
    		sql.append(" 		   ,B.DOC_CD								\n");
    		/**
    		 * 2018.11.23
    		 * 이인오
    		 * 안쓰는소스 경영정보 디비링크 삭제
    		 */
    		sql.append("	FROM EBID_COM911T A, SUB1045T!CCSIF B			\n");
    		sql.append("	WHERE A.BASECD = 'SUB_ACMP_FILE'				\n");
    		sql.append("	AND A.DETAILCD = B.DOC_CD(+)					\n");
    		sql.append("	AND B.ACMP_ID(+) = "+acmp_id+"						\n");
    		sql.append("	AND A.CHG_CODE01 = '"+code+"'					\n");
    		sql.append("	ORDER BY A.DETAILCD					\n");
        	
    		System.out.println(sql);
        	
            search.setStatement(sql.toString());
            
            listRowSet = search.execute();
            WAFLogger.debug(sql.toString());
            
           
            
        } catch(Exception e) {
            WAFLogger.error(this.getClass().getName() + " --> getListRowSet() : \n" + e.getMessage());
            WAFLogger.error("SQL : " + search.getStatement());
            WAFLogger.error(e);
            
        } finally {
            if( listRowSet == null ) listRowSet = new RowSetImpl();
           
        }
        
        return listRowSet;
    }
    
}
