/**
 *
 * @(#)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.main.biz;


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;

import com.udapsoft.waf.common.ui.InitCombo;
import com.udapsoft.waf.system.Biz;
import com.udapsoft.waf.system.HandlerStorage;

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

	public void doBiz() throws Exception {

	    System.out.println("====================메인===========================");
	    
	    
	    ValueObject getSuppCnt = new ValueObject();
	    RowSet getMainBidList = new RowSetImpl();
	    RowSet getContIngList = new RowSetImpl();
	    RowSet PayRequestList = new RowSetImpl();
	    RowSet MainNotice = new RowSetImpl();
	    RowSet MainBbs = new RowSetImpl();
	    RowSet MainTax = new RowSetImpl();
	    
	    
	    String job_div = "";
	    
	    if(storage.getUser().get("RIGHT_NAME").equals("PURCHASE"))
	    {
	        job_div = "P";
	    }
	    else if(storage.getUser().get("RIGHT_NAME").equals("OUTSIDE"))
        {
            job_div = "O";
        }
	    else
	    {
	        job_div = "";
	    }
	    params.set("job_div", job_div);
	    getSuppCnt = getSuppCntList(params);
	    getMainBidList = getMainBidList(params);
	    getContIngList = getContIngList(params);
	    PayRequestList = getPayRequestList(params);
	    MainNotice = getMainNotice(params);
	    MainBbs = getMainBbs(params);
	    //MainTax = getTaxList(params); //2019.09.17 더존 ERP 사용하면서 스마트빌 미사용으로 주석처리(속도느림)
	    
	    
	    
        storage.addValueObject("getSuppCnt", getSuppCnt);
        storage.addRowSet("getMainBidList", getMainBidList);
        storage.addRowSet("getContIngList", getContIngList);
        storage.addRowSet("PayRequestList", PayRequestList);
        storage.addRowSet("MainNotice", MainNotice);
        storage.addRowSet("MainBbs", MainBbs);
        storage.addRowSet("MainTax", MainTax);
        
        
		storage.setSuccess(true);
	}
	
	
	private RowSet getMainBbs(ValueObject Params) {
        
        Search search = new SearchImpl();
        RowSet rowSet = new RowSetImpl();
        StringBuffer sqlStr = new StringBuffer();
        
        try {
            
            
              sqlStr.append("           SELECT                                                                                                   \n");
              sqlStr.append("           SEQ, TO_CHAR(TO_DATE(NOTI_DY, 'YYYY-MM-DD'), 'YYYY-MM-DD') NOTI_DATE         \n");   
              sqlStr.append("         , TITLE                                                                                                   \n");
              sqlStr.append("             FROM(                                                                                                  \n");
              sqlStr.append("                     SELECT                                                                                             \n");
              sqlStr.append("                             NOTI_DY                                                                                       \n");
              sqlStr.append("                         , NOTI_DIV                                                                                       \n");
              sqlStr.append("                         , SEQ                                                                                            \n");
              sqlStr.append("                         , DECODE(SUPP_OPEN_YN, 'Y', '공개', '비공개') SUPP_OPEN_YN                  \n");   
              sqlStr.append("                         , TITLE                                                                                          \n");
              sqlStr.append("                         , WRITE_ID                                                                                       \n");
              sqlStr.append("                         , WRITE_NM                                                                                       \n");
              sqlStr.append("                     FROM NOTI                                                                                          \n");
              sqlStr.append("                     WHERE NOTI_DIV = '2'                                                                           \n");
              sqlStr.append("                     ORDER BY NOTI_DY DESC, SEQ DESC                                                       \n");
              sqlStr.append("                     )  WHERE ROWNUM <= 5                                                                                                       \n");
            
            
            search.setStatement(sqlStr.toString());
            
            System.out.println(sqlStr.toString());
            System.out.println(search.getParameters());
            rowSet = search.execute();
        }
        catch (WAFSQLException se) {
            System.out.println("getMainBbs=========>" + se);
            super.doException(se);
            this.storage.setSuccess(false);
            this.storage.setMessage(se.getMessage());
            storage.setDetailMessage(se);
            se.printStackTrace();
        }
        finally {    
            super.conn.end();
            if(rowSet == null) rowSet = new RowSetImpl();
            return rowSet;
        }
    }


	private RowSet getMainNotice(ValueObject Params) {
        
        Search search = new SearchImpl();
        RowSet rowSet = new RowSetImpl();
        StringBuffer sqlStr = new StringBuffer();
        
        try {
            
            
            sqlStr.append("             SELECT SEQ, TITLE, TO_CHAR(TO_DATE(NOTI_DY, 'YYYY-MM-DD'),'YYYY-MM-DD') NOTI_DATE FROM (                                                                 \n");
            sqlStr.append("             SELECT                                                                \n");
            sqlStr.append("                       NOTI_DY                                                    \n");      
            sqlStr.append("                     , NOTI_DIV                                                          \n");
            sqlStr.append("                     , SEQ                                                               \n");
            sqlStr.append("                     , DECODE(SUPP_OPEN_YN, 'Y', '공개', '비공개') SUPP_OPEN_YN                                                  \n");    
            sqlStr.append("                     , TITLE                                                             \n");
            sqlStr.append("                     , WRITE_ID                                                          \n");
            sqlStr.append("                     , WRITE_NM                                                          \n");
            sqlStr.append("                 FROM NOTI                                                             \n");
            sqlStr.append("                 WHERE NOTI_DIV = '1'                                                              \n");
            sqlStr.append("                 ORDER BY NOTI_DY DESC, SEQ DESC             ) WHERE ROWNUM <= 5                                        \n");
            
            
            search.setStatement(sqlStr.toString());
            
            System.out.println(sqlStr.toString());
            System.out.println(search.getParameters());
            rowSet = search.execute();
        }
        catch (WAFSQLException se) {
            System.out.println("getMainNotice=========>" + se);
            super.doException(se);
            this.storage.setSuccess(false);
            this.storage.setMessage(se.getMessage());
            storage.setDetailMessage(se);
            se.printStackTrace();
        }
        finally {    
            super.conn.end();
            if(rowSet == null) rowSet = new RowSetImpl();
            return rowSet;
        }
	}
	
	
	private RowSet getContIngList(ValueObject Params) {
        Search search = new SearchImpl();
        RowSet rowSet = new RowSetImpl();
        StringBuffer sqlStr = new StringBuffer();
        
        try {
            if(params.get("job_div").equals("P"))
            {
                sqlStr.append("           SELECT *                                                                                                                                                 \n");
                sqlStr.append("                    FROM(                                                                                                                                             \n");
                sqlStr.append("                            SELECT '['||DEPT_CD||']['||MOD_NO_NM||']['||STATUS_NM||'] '||CST_DOC_NAME TITLE                      \n");
                sqlStr.append("                                        ,TO_CHAR(ORD_CON_DATE,'YYYY-MM-DD') NOTI_DATE                                                        \n");
                sqlStr.append("                                        ,PUR_CONT_MOD_ID AS CONT_MOD_ID, TEMPLATE_CD, CHG_CONT_YN, 'P' JOB_DIV                                                        \n");
                sqlStr.append("                                FROM(                                                                                                                                 \n");
                sqlStr.append("                                        SELECT DEPT_CD                                                                                                                                 \n");
                sqlStr.append("                                                    ,CASE WHEN A.MOD_NO = 0 THEN '당초'                                                                                                                                 \n");
                sqlStr.append("                                                    ELSE '변경' END MOD_NO_NM                                                                                                                                 \n");
                sqlStr.append("                                                    ,F_GET_CODE_NAME2('CONT_STATUS_CD',A.STATUS_CD) STATUS_NM                                                               \n");
                sqlStr.append("                                                    ,A.CST_DOC_NAME                                                                                                                                 \n");
                sqlStr.append("                                                    ,A.CON_CHARGE_ID                                                                                                                                 \n");
                sqlStr.append("                                                    ,A.STATUS_CD                                                                                                                                 \n");
                sqlStr.append("                                                    ,A.ORD_CON_DATE                                                                                                                                 \n");
                sqlStr.append("                                                    ,A.PUR_CONT_MOD_ID                                                                                                                                 \n");
                sqlStr.append("                                                    ,A.TEMPLATE_CD                                                                                                                                 \n");
                sqlStr.append("                                                    ,C.CHG_CONT_YN                                                                                                                                 \n");
                sqlStr.append("                                             FROM PUR2000T A, CONT_PUR_HTML B, CONT_TEMPLATE C, CONT_PUR_SUPP F	                                           \n");
        		sqlStr.append("                                             WHERE 1=1													                                           \n");
				sqlStr.append("                                             	AND A.PUR_CONT_MOD_ID = B.PUR_CONT_MOD_ID					                                           \n");
				sqlStr.append("                                             	AND A.TEMPLATE_CD = C.TEMPLATE_CD					                                           \n");
				sqlStr.append("                                             	AND B.SEQ=0					                                           \n");
				sqlStr.append("                                             	AND C.SEQ=0					                                           \n");
				sqlStr.append("                                             	AND A.PUR_CONT_MOD_ID = F.PUR_CONT_MOD_ID				                                           \n");
				sqlStr.append("                                             	AND F.SIGN_SEQ = 2			                                                                                                                         \n");
				sqlStr.append("                                             	AND CON_CHARGE_ID = ?			                                                                                                                         \n");
                sqlStr.append("                                        AND STATUS_CD IN (10,15,18,20,30,40,41)                                                                                                                                \n");
                sqlStr.append("                                        )                                                                                                                                 \n");
                sqlStr.append("                                        ORDER BY ORD_CON_DATE DESC                                                                                                                                 \n");
                sqlStr.append("                                )WHERE ROWNUM <= 5                                                                                                                                 \n");
            }
            else if(params.get("job_div").equals("O"))
            {
	            sqlStr.append("                    SELECT *                                                                                                                                \n");
	            sqlStr.append("                    FROM(                                                                                                                                \n");
	            sqlStr.append("                                SELECT '['||DEPT_CD||']['||MOD_NO_NM||']['||STATUS_NM||'] '||BUILD_NAME TITLE                                 \n");
	            sqlStr.append("                                            ,TO_CHAR(CON_DATE,'YYYY-MM-DD') NOTI_DATE                                                                                                                                \n");
	            sqlStr.append("                                            ,CON_CHARGE_ID, CONT_MOD_ID, TEMPLATE_CD, CHG_CONT_YN, 'O' JOB_DIV                                                                                                                                \n");
	            sqlStr.append("                                    FROM(                                                                                                                                \n");
	            sqlStr.append("                                                SELECT A.DEPT_CD                                                                                                                                \n");
	            sqlStr.append("                                                            ,CASE WHEN A.MOD_NO = 0 THEN '당초'                                                                                                                                \n");
	            sqlStr.append("                                                            ELSE '변경' END MOD_NO_NM                                                                                                                                 \n");
	            sqlStr.append("                                                           ,F_GET_CODE_NAME('CONT_STATUS_CD', A.STATUS_CD) STATUS_NM                                                                                                                                \n");
	            sqlStr.append("                                                           ,A.BUILD_NAME                                                                                                                                \n");
	            sqlStr.append("                                                           ,A.CON_CHARGE_ID                                                                                                                                \n");
	            sqlStr.append("                                                           ,A.STATUS_CD                                                                                                                                \n");
	            sqlStr.append("                                                           ,A.CON_DATE                                                                                                                                \n");
	            sqlStr.append("                                                           ,A.SUB_CONT_MOD_ID AS CONT_MOD_ID                                                                                                                                \n");
	            sqlStr.append("                                                           ,A.TEMPLATE_CD                                                                                                                                \n");
	            sqlStr.append("                                                           ,C.CHG_CONT_YN                                                                                                                                \n");
	            sqlStr.append("                                                    FROM SUB2000T A, CONT_OUT_HTML B, CONT_TEMPLATE C, CONT_OUT_SUPP F                                                                                                                     \n");
	            sqlStr.append("   															WHERE 1=1					\n");
	            sqlStr.append("   																	AND A.SUB_CONT_MOD_ID = B.SUB_CONT_MOD_ID					\n");
	            sqlStr.append("   																	AND A.TEMPLATE_CD = C.TEMPLATE_CD					\n");
	            sqlStr.append("   																	AND B.SEQ=0					\n");
	            sqlStr.append("   																	AND C.SEQ=0					\n");
	            sqlStr.append("   																	AND A.SUB_CONT_MOD_ID = F.SUB_CONT_MOD_ID				\n");
	            sqlStr.append("   																	AND F.SIGN_SEQ = 2				\n");
	            sqlStr.append("                                             						AND CON_CHARGE_ID = ?			                                                                                                                         \n");
	            sqlStr.append("                                            )                                                                                                                                \n");
	            sqlStr.append("                                ORDER BY CON_DATE DESC                                                                                                                                \n");
	            sqlStr.append("                        )WHERE ROWNUM <= 5                                                                                                                                \n");
            }
            else
            {
            	 sqlStr.append("           SELECT *                                                                                                                                                 \n");
                 sqlStr.append("                    FROM(                                                                                                                                             \n");
                 sqlStr.append("                            SELECT '['||DEPT_CD||']['||MOD_NO_NM||']['||STATUS_NM||'] '||CST_DOC_NAME TITLE                      \n");
                 sqlStr.append("                                        ,TO_CHAR(ORD_CON_DATE,'YYYY-MM-DD') NOTI_DATE                                                        \n");
                 sqlStr.append("                                        ,PUR_CONT_MOD_ID AS CONT_MOD_ID, TEMPLATE_CD, CHG_CONT_YN, 'P' JOB_DIV, CON_CHARGE_ID                                                   \n");
                 sqlStr.append("                                FROM(                                                                                                                                 \n");
                 sqlStr.append("                                        SELECT DEPT_CD                                                                                                                                 \n");
                 sqlStr.append("                                                    ,CASE WHEN A.MOD_NO = 0 THEN '당초'                                                                                                                                 \n");
                 sqlStr.append("                                                    ELSE '변경' END MOD_NO_NM                                                                                                                                 \n");
                 sqlStr.append("                                                    ,F_GET_CODE_NAME2('CONT_STATUS_CD',A.STATUS_CD) STATUS_NM                                                               \n");
                 sqlStr.append("                                                    ,A.CST_DOC_NAME                                                                                                                                 \n");
                 sqlStr.append("                                                    ,A.CON_CHARGE_ID                                                                                                                                 \n");
                 sqlStr.append("                                                    ,A.STATUS_CD                                                                                                                                 \n");
                 sqlStr.append("                                                    ,A.ORD_CON_DATE                                                                                                                                 \n");
                 sqlStr.append("                                                    ,A.PUR_CONT_MOD_ID                                                                                                                                 \n");
                 sqlStr.append("                                                    ,A.TEMPLATE_CD                                                                                                                                 \n");
                 sqlStr.append("                                                    ,C.CHG_CONT_YN                                                                                                                                 \n");
                 sqlStr.append("                                             FROM PUR2000T A, CONT_PUR_HTML B, CONT_TEMPLATE C, CONT_PUR_SUPP F	                                           \n");
                 sqlStr.append("                                             WHERE 1=1													                                           \n");
                 sqlStr.append("                                             	AND A.PUR_CONT_MOD_ID = B.PUR_CONT_MOD_ID					                                           \n");
                 sqlStr.append("                                             	AND A.TEMPLATE_CD = C.TEMPLATE_CD					                                           \n");
                 sqlStr.append("                                             	AND B.SEQ=0					                                           \n");
                 sqlStr.append("                                             	AND C.SEQ=0					                                           \n");
                 sqlStr.append("                                             	AND A.PUR_CONT_MOD_ID = F.PUR_CONT_MOD_ID				                                           \n");
                 sqlStr.append("                                             	AND F.SIGN_SEQ = 2			                                                                                                                         \n");
                 sqlStr.append("                                             	AND CON_CHARGE_ID = ?			                                                                                                                         \n");
                 sqlStr.append("                                        AND STATUS_CD IN (10,15,18,20,30,40,41)                                                                                                                                \n");
                 sqlStr.append("                                        )                                                                                                                                 \n");
                 sqlStr.append("                                        ORDER BY ORD_CON_DATE DESC                                                                                                                                 \n");
                 sqlStr.append("                                )WHERE ROWNUM <= 5                                                                                                                                 \n");
                 sqlStr.append("           UNION ALL															                                                                                                                   \n");
                 sqlStr.append("                    SELECT *                                                                                                                                \n");
                 sqlStr.append("                    FROM(                                                                                                                                \n");
                 sqlStr.append("                                SELECT '['||DEPT_CD||']['||MOD_NO_NM||']['||STATUS_NM||'] '||BUILD_NAME TITLE                                 \n");
                 sqlStr.append("                                            ,TO_CHAR(CON_DATE,'YYYY-MM-DD') NOTI_DATE                                                                                                                                \n");
                 sqlStr.append("                                            ,CONT_MOD_ID, TEMPLATE_CD, CHG_CONT_YN, 'O' JOB_DIV, CON_CHARGE_ID                                                                                                                                \n");
                 sqlStr.append("                                    FROM(                                                                                                                                \n");
                 sqlStr.append("                                                SELECT A.DEPT_CD                                                                                                                                \n");
                 sqlStr.append("                                                            ,CASE WHEN A.MOD_NO = 0 THEN '당초'                                                                                                                                \n");
                 sqlStr.append("                                                            ELSE '변경' END MOD_NO_NM                                                                                                                                 \n");
                 sqlStr.append("                                                           ,F_GET_CODE_NAME('CONT_STATUS_CD', A.STATUS_CD) STATUS_NM                                                                                                                                \n");
                 sqlStr.append("                                                           ,A.BUILD_NAME                                                                                                                                \n");
                 sqlStr.append("                                                           ,A.CON_CHARGE_ID                                                                                                                                \n");
                 sqlStr.append("                                                           ,A.STATUS_CD                                                                                                                                \n");
                 sqlStr.append("                                                           ,A.CON_DATE                                                                                                                                \n");
                 sqlStr.append("                                                           ,A.SUB_CONT_MOD_ID AS CONT_MOD_ID                                                                                                                                \n");
                 sqlStr.append("                                                           ,A.TEMPLATE_CD                                                                                                                                \n");
                 sqlStr.append("                                                           ,C.CHG_CONT_YN                                                                                                                                \n");
                 sqlStr.append("                                                    FROM SUB2000T A, CONT_OUT_HTML B, CONT_TEMPLATE C, CONT_OUT_SUPP F                                                                                                                     \n");
                 sqlStr.append("   															WHERE 1=1					\n");
                 sqlStr.append("   																	AND A.SUB_CONT_MOD_ID = B.SUB_CONT_MOD_ID					\n");
                 sqlStr.append("   																	AND A.TEMPLATE_CD = C.TEMPLATE_CD					\n");
                 sqlStr.append("   																	AND B.SEQ=0					\n");
                 sqlStr.append("   																	AND C.SEQ=0					\n");
                 sqlStr.append("   																	AND A.SUB_CONT_MOD_ID = F.SUB_CONT_MOD_ID				\n");
                 sqlStr.append("   																	AND F.SIGN_SEQ = 2				\n");
                 sqlStr.append("                                             						AND CON_CHARGE_ID = ?			                                                                                                                         \n");
                 sqlStr.append("                                            )                                                                                                                                \n");
                 sqlStr.append("                                ORDER BY CON_DATE DESC                                                                                                                                \n");
                 sqlStr.append("                        )WHERE ROWNUM <= 5                                                                                                                                \n");
            }
            
            
            
            search.setStatement(sqlStr.toString());
            if(!params.get("job_div").equals("O") && !params.get("job_div").equals("P"))
            {
            	search.addParameter(storage.getUser().get("acct_id"));
                search.addParameter(storage.getUser().get("acct_id"));
            }
            else
            {
            	search.addParameter(storage.getUser().get("acct_id"));
            }
            
            System.out.println(sqlStr.toString());
            System.out.println(search.getParameters());
            rowSet = search.execute();
        }
        catch (WAFSQLException se) {
            System.out.println("getPayRequestList=========>" + se);
            super.doException(se);
            this.storage.setSuccess(false);
            this.storage.setMessage(se.getMessage());
            storage.setDetailMessage(se);
            se.printStackTrace();
        }
        finally {    
            super.conn.end();
            if(rowSet == null) rowSet = new RowSetImpl();
            return rowSet;
        }
    }
	
	
	
	
/*	private RowSet getPayRequestList(ValueObject Params) {
        Search search = new SearchImpl();
        RowSet rowSet = new RowSetImpl();
        StringBuffer sqlStr = new StringBuffer();
        
        try {
            if(params.get("job_div").equals("P"))
            {
            	 sqlStr.append("            SELECT *                                                                                                                     \n");
                 sqlStr.append("                FROM(                                                                                                                    \n");
                 sqlStr.append("                     SELECT *                                                                                                                    \n");
                 sqlStr.append("                     FROM(                                                                                                                    \n");
                 sqlStr.append("                         SELECT '['||A.DEPT_CD||'][선급금]['|| F_GET_CODE_NAME2('PREPAY_STATUS_CD',A.PREPAY_PROC_GB)||'] '||B.CST_DOC_NAME TITLE                                                          \n");
                 sqlStr.append("                              ,TO_CHAR(A.PREPAY_DATE,'YYYY-MM-DD') NOTI_DATE , 'S' GUBUN, '' PAY_DIV_NM, '' PAY_DIV, 0 AS PAYREQ_ID					\n");
                 sqlStr.append("                              --,A.PUR_CONT_MOD_ID AS 	CONT_MOD_ID					\n");
                 sqlStr.append("                         FROM PUR1030T A                                                                                                                    \n");
                 sqlStr.append("                                 ,PUR1000T B                                                                                                                    \n");
                 sqlStr.append("                     WHERE A.PUR_CONT_ID = B.PUR_CONT_ID                                                                                                                    \n");
                 sqlStr.append("                         AND B.CON_CHARGE_ID = ?                                                                                                                    \n");
                 sqlStr.append("                         AND A.PREPAY_PROC_GB NOT IN ('10', '11')                                                                                                                    \n");
                 sqlStr.append("                     UNION ALL                                                                                                                    \n");
                 sqlStr.append("                     SELECT '['||DEPT_CD||']['||PAY_DIV_NM||']['||F_GET_CODE_NAME2('PURCHASE_STATUS_CD',TRIM(TO_CHAR(REQ_STATUS,'00')))||'] '||CST_DOC_NAME TITLE                                 \n");
                 sqlStr.append("                         ,TO_CHAR(REQ_DATE,'YYYY-MM-DD') NOTI_DATE , 'N' GUBUN, PAY_DIV_NM, PAY_DIV, PAYREQ_ID--, CONT_MOD_ID                                                                                          \n");
                 sqlStr.append("                         FROM(                                                                                                                    \n");
                 sqlStr.append("                             SELECT B.DEPT_CD                                                                                                                    \n");
                 sqlStr.append("                                     ,CASE WHEN A.DEPOSIT_CD = '3' THEN '중도금 '||TO_NUMBER(DEPOSIT_SEQ)||'차'                                                          \n");
                 sqlStr.append("                                      ELSE '잔금 '||TO_NUMBER(DEPOSIT_SEQ)||'차' END PAY_DIV_NM                                                                    \n");
                 sqlStr.append("                                     ,B.CST_DOC_NAME                                                                                                                    \n");
                 sqlStr.append("                                     ,B.REQ_DATE                                                                                                                    \n");
                 sqlStr.append("                                     ,A.REQ_STATUS                                                                                                                    \n");
                 sqlStr.append("                                     ,A.PAY_DIV                                                                                                                    \n");
                 sqlStr.append("                                     ,A.PAYREQ_ID                                                                                                                    \n");
                 sqlStr.append("                                     ,A.PUR_CONT_MOD_ID AS CONT_MOD_ID                                                                                                                    \n");
                 sqlStr.append("                             FROM PUR1100T A                                                                                                                    \n");
                 sqlStr.append("                                     ,PUR1000T B                                                                                                                    \n");
                 sqlStr.append("                         WHERE A.PUR_CONT_ID = B.PUR_CONT_ID                                                                                                                    \n");
                 sqlStr.append("                             AND B.CON_CHARGE_ID = ?                                                                                                                    \n");
                 sqlStr.append("                             AND A.REQ_STATUS != 10                                                                                                                    \n");
                 sqlStr.append("                                 )                                                                                                                       \n");
                 sqlStr.append("                             )ORDER BY NVL(NOTI_DATE,'0000-00-00') DESC                                                                                                                    \n");
                 sqlStr.append("                         )WHERE ROWNUM <= 5                                                                                                                      \n");
            }
            else if(params.get("job_div").equals("O"))
            {
                sqlStr.append("            SELECT *                                                                                                                       \n");
                sqlStr.append("                    FROM(                                                                                                                       \n");
                sqlStr.append("                        SELECT *                                                                                                                       \n");
                sqlStr.append("                            FROM(                                                                                                                       \n");
                sqlStr.append("                                 SELECT '['||A1.DEPT_CD||'][선급금]['|| F_GET_CODE_NAME2('PREPAY_STATUS_CD',B1.STATUS_CD)||'] '||A1.BUILD_NAME TITLE                                                     \n");             
			    sqlStr.append("                                                    ,TO_CHAR(B1.PREPAY_DATE,'YYYY-MM-DD') NOTI_DATE, A1.SUB_CONT_MOD_ID AS CONT_MOD_ID                                                                                             \n");
			    sqlStr.append("                                            FROM                                                                                                                                                                             \n");
			    sqlStr.append("                                                  SUB2000T A1,                                                                                                                                                                   \n");
			    sqlStr.append("                                                  SUB1030T B1    --외주)선급내역                                                                                                                                                   \n");
			    sqlStr.append("                                             WHERE A1.SUB_CONT_MOD_ID = B1.SUB_CONT_MOD_ID                                                                                                                                          \n");
			    sqlStr.append("                                             AND A1.CON_CLS_YN = '9'                                                                                                                                                          \n");
			    sqlStr.append("                                             AND A1.PREPAY_AMT > 0                                                                                                                                                          \n");
			    sqlStr.append("                                             AND B1.STATUS_CD NOT IN('10', '11')                                                                                 \n");
			    sqlStr.append("                                 			 AND A1.CON_CHARGE_ID = ?                                                                                                                       \n");
//                sqlStr.append("                UNION ALL                                                                                                                       \n");
//                sqlStr.append("                SELECT '['||DEPT_CD||'][기성 '||ACMP_YYYYMM||'-'||ACMP_NO||']['||F_GET_CODE_NAME2('ACMP_STATUS_CD',TRIM(TO_CHAR(STATUS_CD,'00')))||'] '||BUILD_NAME TITLE           \n");
//                sqlStr.append("                            ,TO_CHAR(ACMP_DATE,'YYYY-MM-DD') NOTI_DATE                                                                                                                       \n");
//                sqlStr.append("                        FROM(                                                                                                                       \n");
//                sqlStr.append("                                    SELECT A.DEPT_CD                                                                                                                       \n");
//                sqlStr.append("                                               ,A.ACMP_YYYYMM                                                                                                                       \n");
//                sqlStr.append("                                               ,A.ACMP_NO                                                                                                                       \n");
//                sqlStr.append("                                               ,B.BUILD_NAME                                                                                                                       \n");
//                sqlStr.append("                                               ,A.ACMP_DATE                                                                                                                       \n");
//                sqlStr.append("                                               ,B.CON_CHARGE_ID                                                                                                                       \n");
//                sqlStr.append("                                               ,A.STATUS_CD                                                                                                                       \n");
//                sqlStr.append("                                        FROM SUB1040T A                                                                                                                       \n");
//                sqlStr.append("                                                 ,SUB1000T B                                                                                                                       \n");
//                sqlStr.append("                                WHERE A.SUB_CONT_ID = B.SUB_CONT_ID                                                                                                                       \n");
//                sqlStr.append("                                    AND B.CON_CHARGE_ID = ?                                                                                                                       \n");
//                sqlStr.append("                                    AND A.STATUS_CD != '10'                                                                                                                       \n");
//                sqlStr.append("                                )                                                                                                                       \n");
                sqlStr.append("                    )ORDER BY CONT_MOD_ID DESC                                                                                                                       \n");
                sqlStr.append("                )WHERE ROWNUM <= 5                                                                                                                       \n");
            }
            else
            {
            	sqlStr.append("            SELECT *                                                                                                                     \n");
                sqlStr.append("                FROM(                                                                                                                    \n");
                sqlStr.append("                     SELECT *                                                                                                                    \n");
                sqlStr.append("                     FROM(                                                                                                                    \n");
                sqlStr.append("                         SELECT '['||A.DEPT_CD||'][선급금]['|| F_GET_CODE_NAME2('PREPAY_STATUS_CD',A.PREPAY_PROC_GB)||'] '||B.CST_DOC_NAME TITLE                                                          \n");
                sqlStr.append("                              ,TO_CHAR(A.PREPAY_DATE,'YYYY-MM-DD') NOTI_DATE , A.PUR_CONT_MOD_ID AS CONT_MOD_ID,  'S' GUBUN, 'P' AS JOB_DIV, '' PAY_DIV_NM, '' PAY_DIV, 0 AS PAYREQ_ID								\n");
                sqlStr.append("                              --,A.PUR_CONT_MOD_ID AS 	CONT_MOD_ID					\n");
                sqlStr.append("                         FROM PUR1030T A                                                                                                                    \n");
                sqlStr.append("                                 ,PUR1000T B                                                                                                                    \n");
                sqlStr.append("                     WHERE A.PUR_CONT_ID = B.PUR_CONT_ID                                                                                                                    \n");
                sqlStr.append("                         AND B.CON_CHARGE_ID = ?                                                                                                                    \n");
                sqlStr.append("                         AND A.PREPAY_PROC_GB NOT IN ('10', '11')                                                                                                                    \n");
                sqlStr.append("                     UNION ALL                                                                                                                    \n");
                sqlStr.append("                     SELECT '['||DEPT_CD||']['||PAY_DIV_NM||']['||F_GET_CODE_NAME2('PURCHASE_STATUS_CD',TRIM(TO_CHAR(REQ_STATUS,'00')))||'] '||CST_DOC_NAME TITLE					\n");
                sqlStr.append("                         ,TO_CHAR(REQ_DATE,'YYYY-MM-DD') NOTI_DATE , PUR_CONT_MOD_ID AS CONT_MOD_ID,  'N' GUBUN, 'P' AS JOB_DIV, PAY_DIV_NM,  PAY_DIV, PAYREQ_ID--, CONT_MOD_ID				\n");
                sqlStr.append("                         FROM(                                                                                                                    																										\n");
                sqlStr.append("                             SELECT B.DEPT_CD                                                                                                                   																					 \n");
                sqlStr.append("                                     ,CASE WHEN A.DEPOSIT_CD = '3' THEN '중도금 '||TO_NUMBER(DEPOSIT_SEQ)||'차'                                                          \n");
                sqlStr.append("                                      ELSE '잔금 '||TO_NUMBER(DEPOSIT_SEQ)||'차' END PAY_DIV_NM                                                                    \n");
                sqlStr.append("                                     ,B.CST_DOC_NAME                                                                                                                    \n");
                sqlStr.append("                                     ,B.REQ_DATE                                                                                                                    \n");
                sqlStr.append("                                     ,A.REQ_STATUS                                                                                                                    \n");
                sqlStr.append("                                     ,A.PUR_CONT_MOD_ID                                                                                                                    \n");
                sqlStr.append("                                     ,A.PAY_DIV                                                                                                                    \n");
                sqlStr.append("                                     ,A.PAYREQ_ID                                                                                                                    \n");
                sqlStr.append("                                     ,A.PUR_CONT_MOD_ID AS CONT_MOD_ID                                                                                                                    \n");
                sqlStr.append("                             FROM PUR1100T A                                                                                                                    \n");
                sqlStr.append("                                     ,PUR1000T B                                                                                                                    \n");
                sqlStr.append("                         WHERE A.PUR_CONT_ID = B.PUR_CONT_ID                                                                                                                    \n");
                sqlStr.append("                             AND B.CON_CHARGE_ID = ?                                                                                                                    \n");
                sqlStr.append("                             AND A.REQ_STATUS != 10                                                                                                                    \n");
                sqlStr.append("                                 )                                                                                                                       \n");
                sqlStr.append("                             )ORDER BY NVL(NOTI_DATE,'0000-00-00') DESC                                                                                                                    \n");
                sqlStr.append("                         )WHERE ROWNUM <= 5                                                                                                                      \n");
                sqlStr.append("              UNION ALL                                                                                       							         \n");
                sqlStr.append("            SELECT *                                                                                                                       \n");
                sqlStr.append("                    FROM(                                                                                                                       \n");
                sqlStr.append("                        SELECT *                                                                                                                       \n");
                sqlStr.append("                            FROM(                                                                                                                       \n");
                sqlStr.append("                                 SELECT '['||A1.DEPT_CD||'][선급금]['|| F_GET_CODE_NAME2('PREPAY_STATUS_CD',B1.STATUS_CD)||'] '||A1.BUILD_NAME TITLE                                                    		 \n");             
			    sqlStr.append("                                                    ,TO_CHAR(B1.PREPAY_DATE,'YYYY-MM-DD') NOTI_DATE, A1.SUB_CONT_MOD_ID AS CONT_MOD_ID, '' GUBUN,   'O' AS JOB_DIV, ''PAY_DIV_NM, '' PAY_DIV , 0 AS PAYREQ_ID                  \n");
			    sqlStr.append("                                            FROM                                                                                                                                                                             										\n");
			    sqlStr.append("                                                  SUB2000T A1,                                                                                                                                                                  								 \n");
			    sqlStr.append("                                                  SUB1030T B1    --외주)선급내역                                                                                                                                                   \n");
			    sqlStr.append("                                             WHERE A1.SUB_CONT_MOD_ID = B1.SUB_CONT_MOD_ID                                                                                                                                          \n");
			    sqlStr.append("                                             AND A1.CON_CLS_YN = '9'                                                                                                                                                          \n");
			    sqlStr.append("                                             AND A1.PREPAY_AMT > 0                                                                                                                                                          \n");
			    sqlStr.append("                                             AND B1.STATUS_CD NOT IN('10', '11')                                                                                 \n");
			    sqlStr.append("                                 			 AND A1.CON_CHARGE_ID = ?                                                                                                                       \n");
                sqlStr.append("                    )ORDER BY CONT_MOD_ID DESC                                                                                                                       \n");
                sqlStr.append("                )WHERE ROWNUM <= 5                                                                                                                       \n");
            }
            
            search.setStatement(sqlStr.toString());

            if(params.get("job_div").equals("P"))
            {
            	search.addParameter(storage.getUser().get("acct_id"));
            	search.addParameter(storage.getUser().get("acct_id"));            	
            }
            else if(params.get("job_div").equals("O"))
            {
            	search.addParameter(storage.getUser().get("acct_id"));
            }
            else
            {
            	search.addParameter(storage.getUser().get("acct_id"));
            	search.addParameter(storage.getUser().get("acct_id"));
            	search.addParameter(storage.getUser().get("acct_id")); 
            }
            
            
            System.out.println(sqlStr.toString());
            System.out.println(search.getParameters());
            rowSet = search.execute();
        }
        catch (WAFSQLException se) {
            System.out.println("getContIngList=========>" + se);
            super.doException(se);
            this.storage.setSuccess(false);
            this.storage.setMessage(se.getMessage());
            storage.setDetailMessage(se);
            se.printStackTrace();
        }
        finally {    
            super.conn.end();
            if(rowSet == null) rowSet = new RowSetImpl();
            return rowSet;
        }
    }*/
	
	private RowSet getPayRequestList(ValueObject Params) {
		 Search search = new SearchImpl();
	     RowSet listRowSet = null;
	     String sqlstr = "";
    
	    try {
	        if(params.get("job_div").equals("P"))
	        {
	        	sqlstr	+=	"		SELECT *																									  		\n"
	        			+ 	" 			FROM( 																									  		\n"
	        			+ 	"				SELECT 																										\n"
	        			+ 	"     	 			A.PUR_CONT_MOD_ID AS CONT_MOD_ID               				      										\n"
	        			+	"					,'['||A.DEPT_CD||'][선급금]['|| F_GET_CODE_NAME2('PREPAY_STATUS_CD',B.PREPAY_PROC_GB)||'] '||A.CST_DOC_NAME TITLE		\n"
	        			+	"					,TO_CHAR(TO_DATE(TAX_DY,'YYYYMMDD'),'YYYY-MM-DD') 		NOTI_DATE										\n"
	        			+	"					,'S' GUBUN  																							\n"
	        			+	"					,'' PAY_DIV  																							\n"
	                    +	"					,0 AS PAYREQ_ID	  																						\n"
	        			+ 	"   			FROM PUR2000T A, PUR1030T B				                			  										\n"
	        			+ 	"  					WHERE A.PUR_CONT_MOD_ID = B.PUR_CONT_MOD_ID																\n"
	        			+ 	"    				AND A.CON_CLS_YN = '9'																					\n"
	        			+ 	"    				AND B.PREPAY_AMT > 0																					\n"
	        			+ 	" 					ORDER BY A.PUR_CONT_ID DESC		) WHERE ROWNUM<=5														\n";
	        }
	        else if(params.get("job_div").equals("O"))
	        {
				sqlstr	+=	" 		SELECT *																									  		\n"
						+ 	" 			FROM (																									  		\n"
						+ 	"				SELECT 																										\n"
						+ 	"       			A1.SUB_CONT_MOD_ID    CONT_MOD_ID, 			               			  									\n"
						+ 	"					'['||A1.DEPT_CD||'][선급금]['|| F_GET_CODE_NAME2('PREPAY_STATUS_CD',B1.STATUS_CD)||'] '||A1.BUILD_NAME TITLE, 		\n"
						+ 	"       			TO_CHAR(B1.PREPAY_DATE,'YYYY-MM-DD') NOTI_DATE,		  													\n"
						+ 	"      				'' GUBUN,		  																						\n"
						+ 	"       			'' PAY_DIV,		  																						\n"
						+ 	" 					0 AS PAYREQ_ID		  																					\n"
						+ 	"   			FROM 				                			  															\n"
						+ 	"       			SUB2000T A1,				       			  															\n"
						+ 	"       			SUB1030T B1	       						  																\n"
						+ 	"  					WHERE A1.SUB_CONT_MOD_ID = B1.SUB_CONT_MOD_ID															\n"
						+ 	"    				AND A1.CON_CLS_YN = '9'																					\n"
						+ 	"    				AND A1.PREPAY_AMT > 0																					\n"
						+ 	"    				AND B1.STATUS_CD NOT IN('10', '11')																		\n"
						+ 	" 					ORDER BY CONT_MOD_ID DESC		) WHERE ROWNUM<=5														\n"; 
	        }
	        else
	        {
	        	sqlstr	+=	"		SELECT *																									  		\n"
	        			+ 	" 			FROM( 																									  		\n"
	        			+ 	"				SELECT 																										\n"
	        			+ 	"     	 			A.PUR_CONT_MOD_ID AS CONT_MOD_ID               				       										\n"
	        			+	"					,'['||A.DEPT_CD||'][선급금]['|| F_GET_CODE_NAME2('PREPAY_STATUS_CD',B.PREPAY_PROC_GB)||'] '||A.CST_DOC_NAME TITLE		\n"
	        			+	"					,TO_CHAR(to_DATE(TAX_DY,'YYYYMMDD'),'yyyy-mm-dd') 		NOTI_DATE										\n"
	        			+	"					,'S' GUBUN  																							\n"
	        			+	"					,'' PAY_DIV  																							\n"
	                    +	"					,0 AS PAYREQ_ID	  																						\n"
	        			+ 	"   			FROM PUR2000T A, PUR1030T B				                			  										\n"
	        			+ 	"  					WHERE A.PUR_CONT_MOD_ID = B.PUR_CONT_MOD_ID																\n"
	        			+ 	"    				AND A.CON_CLS_YN = '9'																					\n"
	        			+ 	"    				AND B.PREPAY_AMT > 0																					\n"
	        			+ 	" 					ORDER BY A.PUR_CONT_ID DESC		) WHERE ROWNUM<=0														\n" 
	        			+ 	" 		UNION ALL																											\n"  
	        			+	" 		SELECT *																									  		\n"
	        			+ 	" 			FROM (																									  		\n"
	        			+ 	"				SELECT 																										\n"
	        			+ 	"       			A1.SUB_CONT_MOD_ID    CONT_MOD_ID, 			               			  									\n"
	        			+ 	"					'['||A1.DEPT_CD||'][선급금]['|| F_GET_CODE_NAME2('PREPAY_STATUS_CD',B1.STATUS_CD)||'] '||A1.BUILD_NAME TITLE, 		\n"
						+ 	"       			TO_CHAR(B1.PREPAY_DATE,'YYYY-MM-DD') NOTI_DATE,		  													\n"
						+ 	"      				'' GUBUN,		  																						\n"
						+ 	"       			'' PAY_DIV,		  																						\n"
						+ 	" 					0 AS PAYREQ_ID		  																					\n"
	        			+ 	"   			FROM 				                			  															\n"
	        			+ 	"       			SUB2000T A1,				       			  															\n"
	        			+ 	"       			SUB1030T B1				       			  																\n"
	        			+ 	"  					WHERE A1.SUB_CONT_MOD_ID = B1.SUB_CONT_MOD_ID															\n"
	        			+ 	"    				AND A1.CON_CLS_YN = '9'																					\n"
	        			+ 	"    				AND A1.PREPAY_AMT > 0																					\n"
	        			+ 	"    				AND B1.STATUS_CD NOT IN('10', '11')																		\n"
	        			+ 	" 					ORDER BY CONT_MOD_ID DESC		) WHERE ROWNUM<=5														\n"; 
	        }
	         
	        search.setStatement(sqlstr);
	        listRowSet = search.execute();
	    }
	    catch (WAFSQLException se) {
	        System.out.println("getContIngList=========>" + se);
	        super.doException(se);
	        this.storage.setSuccess(false);
	        this.storage.setMessage(se.getMessage());
	        storage.setDetailMessage(se);
	        se.printStackTrace();
	    }
	    finally {    
	        super.conn.end();
	        if( listRowSet == null ) listRowSet = new RowSetImpl();
	        return listRowSet;
	    }
	}
	
	
	private RowSet getMainBidList(ValueObject Params) {
        Search search = new SearchImpl();
        RowSet rowSet = new RowSetImpl();
        StringBuffer sqlStr = new StringBuffer();
        
        try {
            sqlStr.append("             SELECT *                                                    \n");
            sqlStr.append("            FROM(                                                   \n");
            sqlStr.append("                     SELECT A.DEPT_NM -- 현장명                                                   \n");
            sqlStr.append("                   ,A.DEMANDED_TITLE -- 발주의뢰명                                                   \n");
            sqlStr.append("                   ,DECODE(A.SITEDESCDATE,NULL,'-',TO_CHAR(A.SITEDESCDATE,'yyyy-mm-dd')) SITEDESCDATE -- 현장설명                                                   \n");
            sqlStr.append("                   ,DECODE(A.BID_TO_DT,NULL,'-',TO_CHAR(A.BID_TO_DT,'yyyy-mm-dd')) BID_TO_DT -- 견적마감                                                   \n");
            sqlStr.append("                   ,DECODE(B.TBE_FIN_DT,NULL,'-',TO_CHAR(B.TBE_FIN_DT,'yyyy-mm-dd')) TBE_FIN_DT -- 기술검토                                                   \n");
            sqlStr.append("                   ,DECODE(A.OPEN_DT,NULL,'-',TO_CHAR(A.OPEN_DT,'yyyy-mm-dd')) OPEN_DT -- 견적서 개찰                                                   \n");
            sqlStr.append("                   ,DECODE(A.CONT_APP_DATE,NULL,'-',TO_CHAR(A.CONT_APP_DATE,'yyyy-mm-dd')) CONT_APP_DATE -- 시행결의                                                   \n");
            sqlStr.append("                   ,F_GET_CODE_NAME2('BID_STATUS_CD',A.STATUS_CD) STATUS_NM -- 진행상태                                                   \n");
            sqlStr.append("                   ,A.PUREMPNO                                                   																								\n");
            sqlStr.append("                   ,A.STATUS_CD                                                   																								\n");
            sqlStr.append("                   ,A.BID_NO                                                   																								\n");
            sqlStr.append("                   ,A.BID_DEG                                                   																								\n");
            sqlStr.append("                   ,A.DEMANDED_ID                                                   																								\n");
            sqlStr.append("                 FROM BID_MASTER A, TBE_INFO B                                                   \n");
            sqlStr.append("                 WHERE A.STATUS_CD IN ('03','04','05','06','07')                                                   \n");
            sqlStr.append("                     AND A.BID_NO = B.BID_NO                                                   \n");
            sqlStr.append("                     AND A.BID_DEG = B.BID_DEG                                                   \n");
            sqlStr.append("                     AND A.PUREMPNO = ?                                                   \n");
            sqlStr.append("                 ORDER BY A.DEMANDED_DATE DESC                                                   \n");
            sqlStr.append("            )WHERE ROWNUM <= 3                               \n");
            
            
            search.setStatement(sqlStr.toString());
            search.addParameter(storage.getUser().get("acct_id"));
            
            System.out.println(sqlStr.toString());
            System.out.println(search.getParameters());
            rowSet = search.execute();
        }
        catch (WAFSQLException se) {
            System.out.println("getSuppCarge=========>" + se);
            super.doException(se);
            this.storage.setSuccess(false);
            this.storage.setMessage(se.getMessage());
            storage.setDetailMessage(se);
            se.printStackTrace();
        }
        finally {    
            super.conn.end();
            if(rowSet == null) rowSet = new RowSetImpl();
            return rowSet;
        }
    }
	
	
	private ValueObject getSuppCntList(ValueObject Params) {
        Search search = new SearchImpl();
        RowSet rowSet = new RowSetImpl();
        StringBuffer sqlStr = new StringBuffer();
        ValueObject vo = new ValueObject();
        
        try {
        	sqlStr.append("SELECT SUM(TOT_CNT) ALL_CNT                                    \n");
        	sqlStr.append("            ,SUM(GUBUN_2) REQUEST_CNT                          \n");
        	sqlStr.append("            ,SUM(GUBUN_3) READY_CNT                            \n");
        	sqlStr.append("            ,SUM(GUBUN_4) PROV_CNT                             \n");
        	sqlStr.append("            ,SUM(GUBUN_5) REGIST_CNT                           \n");
        	sqlStr.append("            ,SUM(GUBUN_6) STOP_CNT                             \n");
        	sqlStr.append("            ,SUM(GUBUN_7) CANCEL_CNT                           \n");
        	sqlStr.append("FROM(                                                          \n");
        	sqlStr.append("select 1 TOT_CNT                                               \n");
        	sqlStr.append("         ,DECODE(STATUS,'00',1,0)  GUBUN_2  --  가입요청       \n");
        	sqlStr.append("         ,DECODE(STATUS,'01',1,0)  GUBUN_3  --  대기           \n");
        	sqlStr.append("         ,DECODE(STATUS,'02',1,0)  GUBUN_4  --  가등록         \n");
        	sqlStr.append("         ,DECODE(STATUS,'03',1,0)  GUBUN_5  --  등록           \n");
        	sqlStr.append("         ,DECODE(STATUS,'91',1,0)  GUBUN_6  --  거래중지       \n");
        	sqlStr.append("         ,DECODE(STATUS,'99',1,0)  GUBUN_7  --  거래취소       \n");
        	sqlStr.append("from supp_info                                                 \n");
        	sqlStr.append("WHERE NVL(STATUS,'AA') NOT IN ('AA')                           \n");
        	if(!params.get("job_div").equals("")){
        		sqlStr.append("AND JOB_DIV = ?                                              \n");
        		search.addParameter(params.get("job_div"));
        	}
        	sqlStr.append(")                                                              \n");

        	
         
            search.setStatement(sqlStr.toString());
           
            rowSet = search.execute();
            
            if(rowSet.size()>0){
                vo = RowSetUtility.getValueObject(rowSet.getRow(0));
            }
        }
        catch (WAFSQLException se) {
            System.out.println("getSuppCntList=========>" + se);
            super.doException(se);
            this.storage.setSuccess(false);
            this.storage.setMessage(se.getMessage());
            storage.setDetailMessage(se);
            se.printStackTrace();
        }
		return vo;
    }
	
	
	private RowSet getTaxList(ValueObject Params) {
        Search search = new SearchImpl();
        RowSet rowSet = new RowSetImpl();
        StringBuffer sqlStr = new StringBuffer();
        
        try {
            if(params.get("job_div").equals("P"))
            {
            	sqlStr.append("		SELECT *																															        			\n");
		 		sqlStr.append("			   FROM (  																															 				\n");
            	sqlStr.append("					SELECT A.*																															        \n");
		 		sqlStr.append("			   			FROM (  																															 	\n");
		 		sqlStr.append("			 		  		SELECT '0' AS PAY_DIV																											    \n");
		 		sqlStr.append("		                 		,'P' AS  JOB_DIV              																									    \n");
		        sqlStr.append("		      					 ,E.DEPT_CD       																										        \n");                                                                                                                            
		        sqlStr.append("		      					 ,E.DEPT_NAME        																									        \n");                                                                                                                            
				sqlStr.append("				 				 ,E.CST_DOC_NAME        																								    	\n");                                                                                                                           
				sqlStr.append("				 				 ,TO_CHAR(A.DTI_WDATE, 'YYYY-MM-DD') AS DTI_WDATE   --공급일자															    		\n");                                                                                   
				sqlStr.append("				 				 ,A.DTI_TYPE                                                     														    	\n");                                                                                
				sqlStr.append("				 				 ,DECODE(A.DTI_TYPE, '01', '과세', '02', '면세') AS DTI_TYPE_NM     													    		\n");                                                                                
				sqlStr.append("				 				 ,SUBSTR(A.SUP_COM_REGNO,0,3)||'-'||SUBSTR(A.SUP_COM_REGNO,4,2)||'-'||SUBSTR(A.SUP_COM_REGNO,6,5)  AS SUP_COM_REGNO_BAR	    	\n");                            
				sqlStr.append("				 				 ,A.SUP_COM_REGNO --공급자사업자번호                                                            						    							\n");                                                     
				sqlStr.append("				 				 ,A.SUP_COM_NAME   --공급자 상호                                                                   												    \n");                                                
				sqlStr.append("				 				 ,A.TOTAL_AMOUNT   --합계금액                                                                         					   							 	\n");                                             
				sqlStr.append("				 				 ,B.DTI_STATUS                                                                                           				    	\n");                                        
				sqlStr.append("				 				 ,A.DIRECTION                                                                                               			    	\n");                                     
				sqlStr.append("				 				 ,DECODE(A.DIRECTION, '1', '업체', '2', 'SGC이앤씨') AS DIRECTION_NM                                              			    	\n");                                 
				sqlStr.append("				 				 ,D.PUR_CONT_MOD_ID                                                                                               		    	\n");                                  
				sqlStr.append("				 				 ,A.CONVERSATION_ID                                                                                                  	    	\n");                               
				sqlStr.append("				 				 ,a.SUP_COM_ID     --공급자스마트빌ID                                                                                     		  	\n");                          
				sqlStr.append("				 				 ,a.BYR_COM_ID     --공급받는자스마트빌ID                                                                               		   		\n");                       
				sqlStr.append("				 				 ,a.INTERFACE_BATCH_ID                                         																    \n");                                                                                    
				sqlStr.append("				 				 ,B.RETURN_CODE                                                   															    \n");                                                                                
				sqlStr.append("				 				 ,'1' As BILL                                                        														    \n");                                                                               
				sqlStr.append("				 				 ,NVL(F.SEND_REQUEST,'9') SEND_REQUEST                                  													    \n");                                                                         
				sqlStr.append("				 				 ,NVL(F.SEND_REQUEST_DESC,'미전송') SEND_REQUEST_DESC                      													    \n");                                                                     
				sqlStr.append("				 				 ,A.BYR_COM_REGNO            																								    \n");
		        sqlStr.append("		     					 ,C.TMPSLIP_DEPT            																								    \n");
		        sqlStr.append("		     					 ,C.TMPSLIP_DT            																								        \n");
		        sqlStr.append("		     					 ,C.TMPSLIP_NO            																								        \n");
		        sqlStr.append("		     					 ,F_GET_USER_NM(DECODE(D.CRE_BY, NULL , D.UPD_BY,0 ,D.UPD_BY,D.CRE_BY)) AS USER_NAME            								\n");						
				sqlStr.append("				       	    FROM XXSB_DTI_MAIN@SMBLIF A 																								        \n");
				sqlStr.append("				 					 ,XXSB_DTI_STATUS@SMBLIF B																								    \n");
				sqlStr.append("				 				     ,ETEC_ERPIF.TAX_INT_INFO C																									    \n");
				sqlStr.append("				 					 ,PUR1030T D																											    \n");
				sqlStr.append("				 					 ,PUR2000T E																											    \n");
				sqlStr.append("				 					 ,XXSB_DTI_NTS@SMBLIF F																									    \n");
				sqlStr.append("				 			   WHERE C.PAY_DIV = 'P_PREPAY'																									    \n");
				sqlStr.append("				 				 AND A.CONVERSATION_ID = B.CONVERSATION_ID																					    \n");
				sqlStr.append("				 				 AND A.CONVERSATION_ID = C.CONVERSATION_ID																					    \n");
				sqlStr.append("				 				 AND C.PAY_KEY = D.PREPAY_ID																								    \n");
				sqlStr.append("				 				 AND D.PUR_CONT_MOD_ID = E.PUR_CONT_MOD_ID																					    \n");
				sqlStr.append("				 				 AND A.CONVERSATION_ID = F.CONVERSATION_ID(+)																				    \n");
				sqlStr.append("				       	   UNION ALL																													        \n");
				sqlStr.append("				 			  SELECT D.PAY_DIV AS PAY_DIV																									    \n");
				sqlStr.append("		                 		,'P' AS  JOB_DIV              																									    \n");
				sqlStr.append("				 					 ,E.DEPT_CD                   																							    \n");                                                                                                                    
				sqlStr.append("				 					 ,E.DEPT_NAME                    																						    \n");                                                                                                                    
				sqlStr.append("				 					 ,E.CST_DOC_NAME                    																					    \n");                                                                                                               
				sqlStr.append("				 					 ,TO_CHAR(A.DTI_WDATE, 'YYYY-MM-DD') AS DTI_WDATE   --공급일자															   		\n");                                                                                   
				sqlStr.append("				 					 ,A.DTI_TYPE                                                     														    \n");                                                                                
				sqlStr.append("				 					 ,DECODE(A.DTI_TYPE, '01', '과세', '02', '면세') AS DTI_TYPE_NM     													  	 	\n");                                                                                
				sqlStr.append("				 					 ,SUBSTR(A.SUP_COM_REGNO,0,3)||'-'||SUBSTR(A.SUP_COM_REGNO,4,2)||'-'||SUBSTR(A.SUP_COM_REGNO,6,5)  AS SUP_COM_REGNO_BAR	    \n");                            
				sqlStr.append("				 					 ,A.SUP_COM_REGNO --공급자사업자번호                                                                                      								\n");                           
				sqlStr.append("				 					 ,A.SUP_COM_NAME   --공급자 상호                                                                                          								\n");                      
				sqlStr.append("				 					 ,A.TOTAL_AMOUNT   --합계금액                                                         									   						\n");                                                             
				sqlStr.append("				 					 ,B.DTI_STATUS                                                                           								    \n");                                                        
				sqlStr.append("				 					 ,A.DIRECTION                                                                               							    \n");                                                     
				sqlStr.append("				 					 ,DECODE(A.DIRECTION, '1', '업체', '2', 'SGC이앤씨') AS DIRECTION_NM                              							    \n");                                                 
				sqlStr.append("				 					 ,D.PUR_CONT_MOD_ID                                                                               						    \n");                                                  
				sqlStr.append("				 					 ,A.CONVERSATION_ID                                                                                  					    \n");                                               
				sqlStr.append("				 					 ,a.SUP_COM_ID     --공급자스마트빌ID                                                                   				  		\n");                                          
				sqlStr.append("				 					 ,a.BYR_COM_ID     --공급받는자스마트빌ID                                         										  		\n");                                                                
				sqlStr.append("				 					 ,a.INTERFACE_BATCH_ID                                                               									    \n");                                                              
				sqlStr.append("				 					 ,B.RETURN_CODE                                                                         								    \n");                                                          
				sqlStr.append("				 					 ,'1' As BILL                                                                              								    \n");                                                         
				sqlStr.append("				 					 ,NVL(F.SEND_REQUEST,'9') SEND_REQUEST                                                         							    \n");                                                  
				sqlStr.append("				 					 ,NVL(F.SEND_REQUEST_DESC,'미전송') SEND_REQUEST_DESC                                             						    \n");                                              
				sqlStr.append("				 					 ,A.BYR_COM_REGNO            																							    \n");
		        sqlStr.append("		     						 ,C.TMPSLIP_DEPT            																								\n");
		        sqlStr.append("		     						 ,C.TMPSLIP_DT            																								    \n");
		        sqlStr.append("		     						 ,C.TMPSLIP_NO            																								    \n");
		        sqlStr.append("		     						 ,F_GET_USER_NM(DECODE(D.CRE_BY, NULL , D.UPD_BY,0 ,D.UPD_BY,D.CRE_BY)) AS USER_NAME              							\n");						
				sqlStr.append("					 			FROM XXSB_DTI_MAIN@SMBLIF A 																								    \n");
				sqlStr.append("					 				 ,XXSB_DTI_STATUS@SMBLIF B																								    \n");
				sqlStr.append("					 			     ,ETEC_ERPIF.TAX_INT_INFO C																									    \n");
				sqlStr.append("					 				 ,PUR1100T D																											    \n");
				sqlStr.append("					 				 ,PUR2000T E																											    \n");
				sqlStr.append("					 				 ,XXSB_DTI_NTS@SMBLIF F																									    \n");
				sqlStr.append("					 		   WHERE C.PAY_DIV = 'P_PAYREQ'																									    \n");
				sqlStr.append("					 			 AND A.CONVERSATION_ID = B.CONVERSATION_ID																					    \n");
				sqlStr.append("					 			 AND A.CONVERSATION_ID = C.CONVERSATION_ID																					    \n");
				sqlStr.append("					 			 AND C.PAY_KEY = D.PAYREQ_ID																								    \n");
				sqlStr.append("					 			 AND D.PUR_CONT_MOD_ID = E.PUR_CONT_MOD_ID																					    \n");
				sqlStr.append("					 			 AND A.CONVERSATION_ID = F.CONVERSATION_ID(+)																				    \n");
				sqlStr.append("					 		 ) A		                			  																						    \n");
		 		sqlStr.append("			  			WHERE 1=1	                                                                                                                            \n");
		        sqlStr.append("		 			AND  SEND_REQUEST='9'                                                                                                                       \n");
		        sqlStr.append("		 		ORDER BY A.DTI_WDATE DESC, PAY_DIV, DEPT_CD, CST_DOC_NAME,  TMPSLIP_NO  )                                                                      	\n");
		        sqlStr.append("		 WHERE ROWNUM<=5                                                                                                                              			\n");
            }
            else if(params.get("job_div").equals("O"))
            {
                sqlStr.append("		SELECT *                                                                                                                                                \n");
                sqlStr.append("		FROM (                                                                                                                                                  \n");
                sqlStr.append("		     SELECT A.*																																            \n");
                sqlStr.append("		           FROM (           			  																											    \n");
                sqlStr.append("		              SELECT '0' AS PAY_DIV       																										        \n");
                sqlStr.append("		                 		,'O' AS  JOB_DIV              																									    \n");
                sqlStr.append("		                 		,E.DEPT_CD             																									            \n");
                sqlStr.append("		                       , E.DEPT_NAME              																								        \n");
                sqlStr.append("		                       , E.BUILD_NAME CST_DOC_NAME       																							    \n");                                                                                                                            
                sqlStr.append("		                       , TO_CHAR(A.DTI_WDATE, 'YYYY-MM-DD') AS DTI_WDATE   --공급일자                                                        		    \n");                           
                sqlStr.append("		                       , A.DTI_TYPE                                                                                                             	    \n");                        
                sqlStr.append("		                       , DECODE(A.DTI_TYPE, '01', '과세', '02', '면세') AS DTI_TYPE_NM                                                                  \n");                      
                sqlStr.append("		                       , SUBSTR(A.SUP_COM_REGNO,0,3)||'-'||SUBSTR(A.SUP_COM_REGNO,4,2)||'-'||SUBSTR(A.SUP_COM_REGNO,6,5)  AS SUP_COM_REGNO_BAR	        \n");                
                sqlStr.append("		                       , A.SUP_COM_REGNO --공급자사업자번호                                                                                             \n");                  
                sqlStr.append("		                       , A.SUP_COM_NAME   --공급자 상호                                                                                                 \n");              
                sqlStr.append("		                       , A.TOTAL_AMOUNT   --합계금액                                                                                                    \n");            
                sqlStr.append("		                       , B.DTI_STATUS                                                                                                                   \n");        
                sqlStr.append("		                       , A.DIRECTION                                                                                                                    \n");      
                sqlStr.append("		                       , DECODE(A.DIRECTION, '1', '업체', '2', 'SGC이앤씨') AS DIRECTION_NM                                                                \n");   
                sqlStr.append("		                       , D.SUB_CONT_MOD_ID PUR_CONT_MOD_ID																						        \n");
                sqlStr.append("		                       , A.CONVERSATION_ID                  	 																					    \n");                                                                                                              
                sqlStr.append("		                       , a.SUP_COM_ID     --공급자스마트빌ID 																						    \n");                                                                                                            
                sqlStr.append("		                       , a.BYR_COM_ID     --공급받는자스마트빌ID																					    \n");                                                                                                         
                sqlStr.append("		                       , a.INTERFACE_BATCH_ID                      																				        \n");                                                                                                   
                sqlStr.append("		                       , B.RETURN_CODE                                																			        \n");                                                                                               
                sqlStr.append("		                       , '1' As BILL                                     																			    \n");                                                                                                  
                sqlStr.append("		                       ,NVL(F.SEND_REQUEST,'9') SEND_REQUEST                																		    \n");                                                                                           
                sqlStr.append("		                       ,NVL(F.SEND_REQUEST_DESC,'미전송') SEND_REQUEST_DESC    																	        \n");                                                                                   
                sqlStr.append("		                       ,A.BYR_COM_REGNO            																								        \n");
                sqlStr.append("		                       ,C.TMPSLIP_DEPT            																								        \n");
                sqlStr.append("		                       ,C.TMPSLIP_DT            																								        \n");
                sqlStr.append("		                       ,C.TMPSLIP_NO            																								        \n");
                sqlStr.append("		                       ,F_GET_USER_NM(NVL(D.UPD_BY,D.CRE_BY)) AS USER_NAME            														            \n");
                sqlStr.append("		                         FROM XXSB_DTI_MAIN@SMBLIF A 																									\n");
                sqlStr.append("		                       ,XXSB_DTI_STATUS@SMBLIF B																									    \n");
                sqlStr.append("		                       ,ETEC_ERPIF.TAX_INT_INFO C																										    \n");
                sqlStr.append("		                       ,SUB1030T D																												        \n");
                sqlStr.append("		                       ,SUB2000T E																												        \n");
                sqlStr.append("		                       ,XXSB_DTI_NTS@SMBLIF F																										    \n");
                sqlStr.append("		                        WHERE C.PAY_DIV = 'O_PREPAY' 																									\n");
                sqlStr.append("		                       AND A.CONVERSATION_ID = B.CONVERSATION_ID																						\n");
                sqlStr.append("		                       AND A.CONVERSATION_ID = C.CONVERSATION_ID																						\n");
                sqlStr.append("		                       AND C.PAY_KEY = D.PREPAY_ID																									    \n");
                sqlStr.append("		                       AND D.SUB_CONT_MOD_ID = E.SUB_CONT_MOD_ID																						\n");
                sqlStr.append("		                       AND A.CONVERSATION_ID = F.CONVERSATION_ID(+)																					    \n");
                sqlStr.append("		                       UNION ALL																														\n");
                sqlStr.append("		                    SELECT '1' AS PAY_DIV																												\n");
                sqlStr.append("		                 		,'O' AS  JOB_DIV              																									    \n");
                sqlStr.append("		                       ,E.DEPT_CD      																											        \n");                                                                                                                             
                sqlStr.append("		                       ,E.DEPT_NAME       																										        \n");                                                                                                                             
                sqlStr.append("		                       ,E.BUILD_NAME CST_DOC_NAME																									    \n");                                                                                                                                   
                sqlStr.append("		                       ,TO_CHAR(A.DTI_WDATE, 'YYYY-MM-DD') AS DTI_WDATE   --공급일자																    \n");                                                                                   
                sqlStr.append("		                       ,A.DTI_TYPE                                                     															        \n");                                                                            
                sqlStr.append("		                       ,DECODE(A.DTI_TYPE, '01', '과세', '02', '면세') AS DTI_TYPE_NM     														        \n");                                                                            
                sqlStr.append("		                       ,SUBSTR(A.SUP_COM_REGNO,0,3)||'-'||SUBSTR(A.SUP_COM_REGNO,4,2)||'-'||SUBSTR(A.SUP_COM_REGNO,6,5)  AS SUP_COM_REGNO_BAR		    \n");                            
                sqlStr.append("		                       ,A.SUP_COM_REGNO --공급자사업자번호                                                                                      	    \n");                           
                sqlStr.append("		                       ,A.SUP_COM_NAME   --공급자 상호                                                                                                  \n");                    
                sqlStr.append("		                       ,A.TOTAL_AMOUNT   --합계금액                                                                                                     \n");                 
                sqlStr.append("		                       ,B.DTI_STATUS                                                                                                                    \n");            
                sqlStr.append("		                       ,A.DIRECTION                                                                                                                     \n");         
                sqlStr.append("		                       ,DECODE(A.DIRECTION, '1', '업체', '2', 'SGC이앤씨') AS DIRECTION_NM                                                                 \n");     
                sqlStr.append("		                       ,E.SUB_CONT_MOD_ID PUR_CONT_MOD_ID																							    \n");
                sqlStr.append("		                       ,A.CONVERSATION_ID                   																						    \n");                                                                                                              
                sqlStr.append("		                       ,a.SUP_COM_ID     --공급자스마트빌ID    																					        \n");                                                                                                     
                sqlStr.append("		                       ,a.BYR_COM_ID     --공급받는자스마트빌ID   																				        \n");                                                                                                  
                sqlStr.append("		                       ,a.INTERFACE_BATCH_ID                         																				    \n");                                                                                                    
                sqlStr.append("		                       ,B.RETURN_CODE                                   																			    \n");                                                                                                
                sqlStr.append("		                       ,'1' As BILL                                        																		        \n");                                                                                           
                sqlStr.append("		                       ,NVL(F.SEND_REQUEST,'9') SEND_REQUEST                   																	        \n");                                                                                    
                sqlStr.append("		                       ,NVL(F.SEND_REQUEST_DESC,'미전송') SEND_REQUEST_DESC       																        \n");                                                                                
                sqlStr.append("		                       ,A.BYR_COM_REGNO            																								        \n");
                sqlStr.append("		                       ,C.TMPSLIP_DEPT            																								        \n");
                sqlStr.append("		                       ,C.TMPSLIP_DT            																								        \n");
                sqlStr.append("		                       ,C.TMPSLIP_NO            																								        \n");
                sqlStr.append("		                       ,F_GET_USER_NM(NVL(D.UPD_BY,D.CRE_BY)) AS USER_NAME            														    \n");
                sqlStr.append("		                         FROM XXSB_DTI_MAIN@SMBLIF A 																									\n");
                sqlStr.append("		                       ,XXSB_DTI_STATUS@SMBLIF B																									    \n");
                sqlStr.append("		                       ,ETEC_ERPIF.TAX_INT_INFO C																										    \n");
                sqlStr.append("		                       ,SUB1040T D																												        \n");
                sqlStr.append("		                       ,SUB2000T E																												        \n");
                sqlStr.append("		                       ,XXSB_DTI_NTS@SMBLIF F																										    \n");
                sqlStr.append("		                        WHERE C.PAY_DIV = 'O_ACMP' 																										\n");
                sqlStr.append("		                     AND A.CONVERSATION_ID = B.CONVERSATION_ID																						    \n");
                sqlStr.append("		                     AND A.CONVERSATION_ID = C.CONVERSATION_ID																						    \n");
                sqlStr.append("		                     AND C.PAY_KEY = D.ACMP_ID																										    \n");
                sqlStr.append("		                     AND D.SUB_CONT_ID = E.SUB_CONT_ID																								    \n");
                sqlStr.append("		                     AND D.MOD_NO = E.MOD_NO																										    \n");
                sqlStr.append("		                     AND A.CONVERSATION_ID = F.CONVERSATION_ID(+)																					    \n");
                sqlStr.append("		                     ) A		                			  																							\n");
                sqlStr.append("		          WHERE 1=1	                		                                                                                                            \n");
                sqlStr.append("		              AND  SEND_REQUEST='9'                                                                                                                     \n");
                sqlStr.append("		          ORDER BY DTI_WDATE DESC ,PAY_DIV, DEPT_CD, CST_DOC_NAME, TMPSLIP_NO)                                                                              \n");
                sqlStr.append("		    WHERE ROWNUM<=5                                                                                                                                     \n");
            }
            else
            {
	            sqlStr.append("		        SELECT * FROM (																															        			     \n"); 
	            sqlStr.append("		          SELECT *	FROM (																														        			     \n"); 
	            sqlStr.append("		                SELECT * FROM (																															        		\n");	      
	            sqlStr.append("		                      SELECT A.*																															         \n");     
	            sqlStr.append("		                          FROM (  																															 	     \n"); 
	            sqlStr.append("		                            SELECT '0' AS PAY_DIV																											         \n"); 
	            sqlStr.append("		                                    ,'P' AS  JOB_DIV              																									 \n");     
	            sqlStr.append("		                                 ,E.DEPT_CD       																										             \n"); 
	            sqlStr.append("		                                 ,E.DEPT_NAME        																									             \n"); 
	            sqlStr.append("		                             ,E.CST_DOC_NAME        																								    	         \n");
	            sqlStr.append("		                             ,TO_CHAR(A.DTI_WDATE, 'YYYY-MM-DD') AS DTI_WDATE   --공급일자															    		     \n"); 
	            sqlStr.append("		                             ,A.DTI_TYPE                                                     														    	         \n");
	            sqlStr.append("		                             ,DECODE(A.DTI_TYPE, '01', '과세', '02', '면세') AS DTI_TYPE_NM     													    		     \n"); 
	            sqlStr.append("		                             ,SUBSTR(A.SUP_COM_REGNO,0,3)||'-'||SUBSTR(A.SUP_COM_REGNO,4,2)||'-'||SUBSTR(A.SUP_COM_REGNO,6,5)  AS SUP_COM_REGNO_BAR	    	         \n");
	            sqlStr.append("		                             ,A.SUP_COM_REGNO --공급자사업자번호                                                            						    			\n");			
	            sqlStr.append("		                             ,A.SUP_COM_NAME   --공급자 상호                                                                   										\n");		
	            sqlStr.append("		                             ,A.TOTAL_AMOUNT   --합계금액                                                                         					   				\n");		
	            sqlStr.append("		                             ,B.DTI_STATUS                                                                                           				    	         \n");
	            sqlStr.append("		                             ,A.DIRECTION                                                                                               			    	         \n");
	            sqlStr.append("		                             ,DECODE(A.DIRECTION, '1', '업체', '2', 'SGC이앤씨') AS DIRECTION_NM                                              			    	         \n"); 
	            sqlStr.append("		                             ,D.PUR_CONT_MOD_ID                                                                                               		    	         \n");
	            sqlStr.append("		                             ,A.CONVERSATION_ID                                                                                                  	    	         \n");
	            sqlStr.append("		                             ,a.SUP_COM_ID     --공급자스마트빌ID                                                                                     		  	     \n");     
	            sqlStr.append("		                             ,a.BYR_COM_ID     --공급받는자스마트빌ID                                                                               		   		 \n");         
	            sqlStr.append("		                             ,a.INTERFACE_BATCH_ID                                         																             \n");
	            sqlStr.append("		                             ,B.RETURN_CODE                                                   															             \n");
	            sqlStr.append("		                             ,'1' As BILL                                                        														             \n");
	            sqlStr.append("		                             ,NVL(F.SEND_REQUEST,'9') SEND_REQUEST                                  													             \n");
	            sqlStr.append("		                             ,NVL(F.SEND_REQUEST_DESC,'미전송') SEND_REQUEST_DESC                      													             \n");
	            sqlStr.append("		                             ,A.BYR_COM_REGNO            																								             \n");
	            sqlStr.append("		                               ,C.TMPSLIP_DEPT            																								             \n");
	            sqlStr.append("		                               ,C.TMPSLIP_DT            																								             \n"); 
	            sqlStr.append("		                               ,C.TMPSLIP_NO            																								             \n"); 
	            sqlStr.append("		                               ,F_GET_USER_NM(DECODE(D.CRE_BY, NULL , D.UPD_BY,0 ,D.UPD_BY,D.CRE_BY)) AS USER_NAME            										 \n");
	            sqlStr.append("		                                FROM XXSB_DTI_MAIN@SMBLIF A 																								         \n");     
	            sqlStr.append("		                               ,XXSB_DTI_STATUS@SMBLIF B																								             \n");
	            sqlStr.append("		                                 ,ETEC_ERPIF.TAX_INT_INFO C																									             \n");
	            sqlStr.append("		                               ,PUR1030T D																											                 \n");
	            sqlStr.append("		                               ,PUR2000T E																											                 \n");
	            sqlStr.append("		                               ,XXSB_DTI_NTS@SMBLIF F																									             \n");
	            sqlStr.append("		                             WHERE C.PAY_DIV = 'P_PREPAY'																									         \n"); 
	            sqlStr.append("		                             AND A.CONVERSATION_ID = B.CONVERSATION_ID																					             \n");
	            sqlStr.append("		                             AND A.CONVERSATION_ID = C.CONVERSATION_ID																					             \n");
	            sqlStr.append("		                             AND C.PAY_KEY = D.PREPAY_ID																								             \n");
	            sqlStr.append("		                             AND D.PUR_CONT_MOD_ID = E.PUR_CONT_MOD_ID																					             \n");
	            sqlStr.append("		                             AND A.CONVERSATION_ID = F.CONVERSATION_ID(+)																				             \n");
	            sqlStr.append("		                               UNION ALL																													         \n");     
	            sqlStr.append("		                            SELECT D.PAY_DIV AS PAY_DIV																									             \n");
	            sqlStr.append("		                                    ,'P' AS  JOB_DIV              																									 \n");     
	            sqlStr.append("		                               ,E.DEPT_CD                   																							             \n");
	            sqlStr.append("		                               ,E.DEPT_NAME                    																						                 \n");
	            sqlStr.append("		                               ,E.CST_DOC_NAME                    																					                 \n");
	            sqlStr.append("		                               ,TO_CHAR(A.DTI_WDATE, 'YYYY-MM-DD') AS DTI_WDATE   --공급일자															   		     \n"); 
	            sqlStr.append("		                               ,A.DTI_TYPE                                                     														                 \n");
	            sqlStr.append("		                               ,DECODE(A.DTI_TYPE, '01', '과세', '02', '면세') AS DTI_TYPE_NM     													  	 	         \n");
	            sqlStr.append("		                               ,SUBSTR(A.SUP_COM_REGNO,0,3)||'-'||SUBSTR(A.SUP_COM_REGNO,4,2)||'-'||SUBSTR(A.SUP_COM_REGNO,6,5)  AS SUP_COM_REGNO_BAR	             \n");
	            sqlStr.append("		                               ,A.SUP_COM_REGNO --공급자사업자번호                                                                                      			\n");			
	            sqlStr.append("		                               ,A.SUP_COM_NAME   --공급자 상호                                                                                          			\n");		
	            sqlStr.append("		                               ,A.TOTAL_AMOUNT   --합계금액                                                         									   			\n");		
	            sqlStr.append("		                               ,B.DTI_STATUS                                                                           								                 \n");
	            sqlStr.append("		                               ,A.DIRECTION                                                                               							                 \n");
	            sqlStr.append("		                               ,DECODE(A.DIRECTION, '1', '업체', '2', 'SGC이앤씨') AS DIRECTION_NM                              							             \n"); 
	            sqlStr.append("		                               ,D.PUR_CONT_MOD_ID                                                                               						             \n");
	            sqlStr.append("		                               ,A.CONVERSATION_ID                                                                                  					                 \n");
	            sqlStr.append("		                               ,a.SUP_COM_ID     --공급자스마트빌ID                                                                   				  		         \n"); 
	            sqlStr.append("		                               ,a.BYR_COM_ID     --공급받는자스마트빌ID                                         										  		     \n");     
	            sqlStr.append("		                               ,a.INTERFACE_BATCH_ID                                                               									                 \n");
	            sqlStr.append("		                               ,B.RETURN_CODE                                                                         								                 \n");
	            sqlStr.append("		                               ,'1' As BILL                                                                              								             \n");
	            sqlStr.append("		                               ,NVL(F.SEND_REQUEST,'9') SEND_REQUEST                                                         							             \n");
	            sqlStr.append("		                               ,NVL(F.SEND_REQUEST_DESC,'미전송') SEND_REQUEST_DESC                                             						             \n"); 
	            sqlStr.append("		                               ,A.BYR_COM_REGNO            																							                 \n");
	            sqlStr.append("		                                 ,C.TMPSLIP_DEPT            																								         \n");
	            sqlStr.append("		                                 ,C.TMPSLIP_DT            																								             \n");
	            sqlStr.append("		                                 ,C.TMPSLIP_NO            																								             \n");
	            sqlStr.append("		                                 ,F_GET_USER_NM(DECODE(D.CRE_BY, NULL , D.UPD_BY,0 ,D.UPD_BY,D.CRE_BY)) AS USER_NAME              									 \n");
	            sqlStr.append("		                            FROM XXSB_DTI_MAIN@SMBLIF A 																								             \n");
	            sqlStr.append("		                               ,XXSB_DTI_STATUS@SMBLIF B																								             \n");
	            sqlStr.append("		                                 ,ETEC_ERPIF.TAX_INT_INFO C																									             \n");
	            sqlStr.append("		                               ,PUR1100T D																											                 \n");
	            sqlStr.append("		                               ,PUR2000T E																											                 \n");
	            sqlStr.append("		                               ,XXSB_DTI_NTS@SMBLIF F																									             \n");
	            sqlStr.append("		                             WHERE C.PAY_DIV = 'P_PAYREQ'																									         \n"); 
	            sqlStr.append("		                             AND A.CONVERSATION_ID = B.CONVERSATION_ID																					             \n");
	            sqlStr.append("		                             AND A.CONVERSATION_ID = C.CONVERSATION_ID																					             \n");
	            sqlStr.append("		                             AND C.PAY_KEY = D.PAYREQ_ID																								             \n");
	            sqlStr.append("		                             AND D.PUR_CONT_MOD_ID = E.PUR_CONT_MOD_ID																					             \n");
	            sqlStr.append("		                             AND A.CONVERSATION_ID = F.CONVERSATION_ID(+)																				             \n");
	            sqlStr.append("		                           ) A		                			  																						             \n");
	            sqlStr.append("		                          WHERE 1=1	                                                                                                                                 \n"); 
	            sqlStr.append("		                      AND  SEND_REQUEST='9'                                                                                                                          \n");   
	            sqlStr.append("		                    ORDER BY A.DTI_WDATE DESC, PAY_DIV, DEPT_CD, CST_DOC_NAME,  TMPSLIP_NO  ) B                                                                     \n");	      
	            sqlStr.append("		                 WHERE ROWNUM<=5                                                                                                                              		\n");	      
	            sqlStr.append("		               UNION ALL                                                                                                                                             \n");  	      
	            sqlStr.append("		                SELECT *                                                                                                                                             \n");         
	            sqlStr.append("		                FROM (                                                                                                                                               \n");         
	            sqlStr.append("		                     SELECT A.*																																         \n");         
	            sqlStr.append("		                           FROM (           			  																											 \n");         
	            sqlStr.append("		                              SELECT '0' AS PAY_DIV       																										     \n");         
	            sqlStr.append("		                                    ,'O' AS  JOB_DIV              																									 \n");     
	            sqlStr.append("		                                 ,E.DEPT_CD             																									         \n");         
	            sqlStr.append("		                                       , E.DEPT_NAME              																								     \n");         
	            sqlStr.append("		                                       , E.BUILD_NAME CST_DOC_NAME       																							 \n");         
	            sqlStr.append("		                                       , TO_CHAR(A.DTI_WDATE, 'YYYY-MM-DD') AS DTI_WDATE   --공급일자                                                        		 \n");             
	            sqlStr.append("		                                       , A.DTI_TYPE                                                                                                             	 \n");         
	            sqlStr.append("		                                       , DECODE(A.DTI_TYPE, '01', '과세', '02', '면세') AS DTI_TYPE_NM                                                               \n");             
	            sqlStr.append("		                                       , SUBSTR(A.SUP_COM_REGNO,0,3)||'-'||SUBSTR(A.SUP_COM_REGNO,4,2)||'-'||SUBSTR(A.SUP_COM_REGNO,6,5)  AS SUP_COM_REGNO_BAR	     \n");         
	            sqlStr.append("		                                       , A.SUP_COM_REGNO --공급자사업자번호                                                                                          \n");                 
	            sqlStr.append("		                                       , A.SUP_COM_NAME   --공급자 상호                                                                                              \n");              
	            sqlStr.append("		                                       , A.TOTAL_AMOUNT   --합계금액                                                                                                 \n");             
	            sqlStr.append("		                                       , B.DTI_STATUS                                                                                                                \n");         
	            sqlStr.append("		                                       , A.DIRECTION                                                                                                                 \n");         
	            sqlStr.append("		                                       , DECODE(A.DIRECTION, '1', '업체', '2', 'SGC이앤씨') AS DIRECTION_NM                                                             \n");              
	            sqlStr.append("		                                       , D.SUB_CONT_MOD_ID PUR_CONT_MOD_ID																						     \n");         
	            sqlStr.append("		                                       , A.CONVERSATION_ID                  	 																					 \n");         
	            sqlStr.append("		                                       , a.SUP_COM_ID     --공급자스마트빌ID 																						 \n");                 
	            sqlStr.append("		                                       , a.BYR_COM_ID     --공급받는자스마트빌ID																					 \n");                     
	            sqlStr.append("		                                       , a.INTERFACE_BATCH_ID                      																				     \n");         
	            sqlStr.append("		                                       , B.RETURN_CODE                                																			     \n");         
	            sqlStr.append("		                                       , '1' As BILL                                     																			 \n");         
	            sqlStr.append("		                                       ,NVL(F.SEND_REQUEST,'9') SEND_REQUEST                																		 \n");         
	            sqlStr.append("		                                       ,NVL(F.SEND_REQUEST_DESC,'미전송') SEND_REQUEST_DESC    																	     \n");         
	            sqlStr.append("		                                       ,A.BYR_COM_REGNO            																								     \n");         
	            sqlStr.append("		                                       ,C.TMPSLIP_DEPT            																								     \n");         
	            sqlStr.append("		                                       ,C.TMPSLIP_DT            																								     \n");         
	            sqlStr.append("		                                       ,C.TMPSLIP_NO            																								     \n");         
	            sqlStr.append("		                                       ,F_GET_USER_NM(NVL(D.UPD_BY,D.CRE_BY)) AS USER_NAME            														         \n");         
	            sqlStr.append("		                                         FROM XXSB_DTI_MAIN@SMBLIF A 																								\n");	      
	            sqlStr.append("		                                       ,XXSB_DTI_STATUS@SMBLIF B																									 \n");         
	            sqlStr.append("		                                       ,ETEC_ERPIF.TAX_INT_INFO C																										 \n");         
	            sqlStr.append("		                                       ,SUB1030T D																												     \n");         
	            sqlStr.append("		                                       ,SUB2000T E																												     \n");         
	            sqlStr.append("		                                       ,XXSB_DTI_NTS@SMBLIF F																										 \n");         
	            sqlStr.append("		                                        WHERE C.PAY_DIV = 'O_PREPAY' 																								\n");	      
	            sqlStr.append("		                                       AND A.CONVERSATION_ID = B.CONVERSATION_ID																					\n");	      
	            sqlStr.append("		                                       AND A.CONVERSATION_ID = C.CONVERSATION_ID																					\n");	      
	            sqlStr.append("		                                       AND C.PAY_KEY = D.PREPAY_ID																									 \n");         
	            sqlStr.append("		                                       AND D.SUB_CONT_MOD_ID = E.SUB_CONT_MOD_ID																					\n");	      
	            sqlStr.append("		                                       AND A.CONVERSATION_ID = F.CONVERSATION_ID(+)																					 \n");         
	            sqlStr.append("		                                       UNION ALL																													\n");	      
	            sqlStr.append("		                                    SELECT '1' AS PAY_DIV																											\n");	      
	            sqlStr.append("		                                    ,'O' AS  JOB_DIV              																									 \n");     
	            sqlStr.append("		                                       ,E.DEPT_CD      																											     \n");         
	            sqlStr.append("		                                       ,E.DEPT_NAME       																										     \n");         
	            sqlStr.append("		                                       ,E.BUILD_NAME CST_DOC_NAME																									 \n");         
	            sqlStr.append("		                                       ,TO_CHAR(A.DTI_WDATE, 'YYYY-MM-DD') AS DTI_WDATE   --공급일자																 \n");             
	            sqlStr.append("		                                       ,A.DTI_TYPE                                                     															     \n");         
	            sqlStr.append("		                                       ,DECODE(A.DTI_TYPE, '01', '과세', '02', '면세') AS DTI_TYPE_NM     														     \n");             
	            sqlStr.append("		                                       ,SUBSTR(A.SUP_COM_REGNO,0,3)||'-'||SUBSTR(A.SUP_COM_REGNO,4,2)||'-'||SUBSTR(A.SUP_COM_REGNO,6,5)  AS SUP_COM_REGNO_BAR		 \n");         
	            sqlStr.append("		                                       ,A.SUP_COM_REGNO --공급자사업자번호                                                                                      	 \n");                 
	            sqlStr.append("		                                       ,A.SUP_COM_NAME   --공급자 상호                                                                                               \n");              
	            sqlStr.append("		                                       ,A.TOTAL_AMOUNT   --합계금액                                                                                                  \n");             
	            sqlStr.append("		                                       ,B.DTI_STATUS                                                                                                                 \n");         
	            sqlStr.append("		                                       ,A.DIRECTION                                                                                                                  \n");         
	            sqlStr.append("		                                       ,DECODE(A.DIRECTION, '1', '업체', '2', 'SGC이앤씨') AS DIRECTION_NM                                                              \n");              
	            sqlStr.append("		                                       ,E.SUB_CONT_MOD_ID PUR_CONT_MOD_ID																							 \n");         
	            sqlStr.append("		                                       ,A.CONVERSATION_ID                   																						 \n");         
	            sqlStr.append("		                                       ,a.SUP_COM_ID     --공급자스마트빌ID    																					     \n");             
	            sqlStr.append("		                                       ,a.BYR_COM_ID     --공급받는자스마트빌ID   																				     \n");                 
	            sqlStr.append("		                                       ,a.INTERFACE_BATCH_ID                         																				 \n");         
	            sqlStr.append("		                                       ,B.RETURN_CODE                                   																			 \n");         
	            sqlStr.append("		                                       ,'1' As BILL                                        																		     \n");         
	            sqlStr.append("		                                       ,NVL(F.SEND_REQUEST,'9') SEND_REQUEST                   																	     \n");         
	            sqlStr.append("		                                       ,NVL(F.SEND_REQUEST_DESC,'미전송') SEND_REQUEST_DESC       																     \n");             
	            sqlStr.append("		                                       ,A.BYR_COM_REGNO            																								     \n");         
	            sqlStr.append("		                                       ,C.TMPSLIP_DEPT            																								     \n");         
	            sqlStr.append("		                                       ,C.TMPSLIP_DT            																								     \n");         
	            sqlStr.append("		                                       ,C.TMPSLIP_NO            																								     \n");         
	            sqlStr.append("		                                       ,F_GET_USER_NM(NVL(D.UPD_BY,D.CRE_BY)) AS USER_NAME            														 \n");         
	            sqlStr.append("		                                         FROM XXSB_DTI_MAIN@SMBLIF A 																								\n");	      
	            sqlStr.append("		                                       ,XXSB_DTI_STATUS@SMBLIF B																									 \n");         
	            sqlStr.append("		                                       ,ETEC_ERPIF.TAX_INT_INFO C																										 \n");         
	            sqlStr.append("		                                       ,SUB1040T D																												     \n");         
	            sqlStr.append("		                                       ,SUB2000T E																												     \n");         
	            sqlStr.append("		                                       ,XXSB_DTI_NTS@SMBLIF F																										 \n");         
	            sqlStr.append("		                                        WHERE C.PAY_DIV = 'O_ACMP' 																									\n");	      
	            sqlStr.append("		                                     AND A.CONVERSATION_ID = B.CONVERSATION_ID																						 \n");         
	            sqlStr.append("		                                     AND A.CONVERSATION_ID = C.CONVERSATION_ID																						 \n");         
	            sqlStr.append("		                                     AND C.PAY_KEY = D.ACMP_ID																										 \n");         
	            sqlStr.append("		                                     AND D.SUB_CONT_ID = E.SUB_CONT_ID																								 \n");         
	            sqlStr.append("		                                     AND D.MOD_NO = E.MOD_NO																										 \n");         
	            sqlStr.append("		                                     AND A.CONVERSATION_ID = F.CONVERSATION_ID(+)																					 \n");         
	            sqlStr.append("		                                     ) A		                			  																						\n");	      
	            sqlStr.append("		                          WHERE 1=1	                		                                                                                                         \n");         
	            sqlStr.append("		                              AND  SEND_REQUEST='9'                                                                                                                  \n");         
	            sqlStr.append("		                          ORDER BY DTI_WDATE DESC, PAY_DIV, DEPT_CD, CST_DOC_NAME,  TMPSLIP_NO) C                                                                    \n");          
	            sqlStr.append("		                    WHERE ROWNUM<=5                                                                                                                                  \n");
	            sqlStr.append("		                    )ORDER BY DTI_WDATE DESC)                                                                                                                        \n");
	            sqlStr.append("		                WHERE ROWNUM<=5                                                                                                                                      \n");
            }
            
            search.setStatement(sqlStr.toString());
            rowSet = search.execute();
        }
        catch (WAFSQLException se) {
            System.out.println("getPayRequestList=========>" + se);
            super.doException(se);
            this.storage.setSuccess(false);
            this.storage.setMessage(se.getMessage());
            storage.setDetailMessage(se);
            se.printStackTrace();
        }
        finally {    
            super.conn.end();
            if(rowSet == null) rowSet = new RowSetImpl();
            return rowSet;
        }
    }
}
