/**
 * @(#)file    UserListBiz.java
 * @(#)author  Joung Kyu Park
 * @(#)version 1.0
 * @(#)date    May 31, 2007
 * @(#)since   JDK 1.4.2
 *
 * Copyright (c) www.hwenc.co.kr, Inc.
 * All rights reserved.
 * This software is the proprietary information of Hanwha E&C, Inc.
 */
package kr.co.udapsoft.ebid.buyer.test.biz;



import java.io.File;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import kr.co.hsnc.common.base.WAFLogger;
import kr.co.hsnc.common.config.WAFConfig;
import kr.co.hsnc.common.sql.RowSet;
import kr.co.hsnc.common.sql.RowSetImpl;
import kr.co.hsnc.common.sql.WAFSQLException;
import kr.co.hsnc.common.sql.persistent.Persistent;
import kr.co.hsnc.common.sql.persistent.PersistentImpl;
import kr.co.hsnc.common.sql.search.Search;
import kr.co.hsnc.common.sql.search.SearchImpl;
import kr.co.hsnc.common.sql.util.RowSetUtility;
import kr.co.hsnc.common.util.FileUtil;
import kr.co.hsnc.common.util.StringUtil;
import kr.co.hsnc.common.util.ValueObject;

import com.udapsoft.waf.system.Biz;
import com.udapsoft.waf.system.HandlerStorage;






public class FileMigrationBiz extends Biz {

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

	/* (non-Javadoc)
	 * @see kr.co.hwenc.system.Biz#doBiz()
	 */
	
	
	String db_link_nm = "@ccsif";
	
	public void doBiz() throws Exception {

		
//		TestCommon common = new TestCommon();
		
		if(storage.compareEvent("")){
			System.out.println("화면 조회");
		}
		else if(storage.compareEvent("CONT_COPY")){
			System.out.println("CONT_COPY 조회");
			
			String project_no = params.get("project_no");
			RowSet rowSet = getContFileList(project_no);
			RowSet rowSet2 = getContGuarFileList(project_no);
			RowSet rowSet3 = getContPrePayGuarFileList(project_no);
			RowSet rowSet4 = getContPrePayGivUpGuarFileList(project_no);
			
			
			System.out.println("계약서 관련 파일 이관* : " + rowSet.size());
			/*계약서 관련 파일 이관*/
			if(!addFilesProc(rowSet)){
				storage.setSuccess(false);
				storage.setMessage("계약서 관련 파일 이관 복사에 실폐하였습니다 : " + storage.getMessage());
			}
			
			
			System.out.println("보증서 관련 파일 이관 : " + rowSet2.size());
			/*보증서 관련 파일 이관*/
			if(!addFilesProc(rowSet2)){
				storage.setSuccess(false);
				storage.setMessage("보증서 관련 파일 이관 복사에 실폐하였습니다 : " + storage.getMessage());
			}
			
			System.out.println("선급 보증서 관련 파일 이관 : " + rowSet3.size());
			/*선급 보증서 관련 파일 이관*/
			if(!addFilesProc(rowSet3)){
				storage.setSuccess(false);
				storage.setMessage("선급 보증서 관련 파일 이관 복사에 실폐하였습니다 : " + storage.getMessage());
			}
			
			System.out.println("선급 포기각서 관련 파일 이관 : " + rowSet4.size());
			/*선급 포기각서 관련 파일 이관*/
			if(!addFilesProc(rowSet4)){
				storage.setSuccess(false);
				storage.setMessage("선급 포기각서 관련 파일 이관 복사에 실폐하였습니다 : " + storage.getMessage());
			}
			
		}else if(storage.compareEvent("CONT_OUT_COPY")){
			String project_no = params.get("project_no");
			RowSet rowSet = getContOutFileList(project_no);
			System.out.println("외주계약 관련 파일 이관 : " + rowSet.size());
			if(!addFilesProc(rowSet)){
				storage.setSuccess(false);
				storage.setMessage("외주계약 관련 파일 이관 복사에 실폐하였습니다 : " + storage.getMessage());
			}
		}else if(storage.compareEvent("ALL_COPY_PUR")){
			
			RowSet purContList = getPurContList();
			for(int i=0;i<purContList.size();i++){
				ValueObject vo = RowSetUtility.getValueObject(purContList.getRow(i));
				
				System.out.println("=================구매=start ===================== ");
				System.out.println("현장 코드 : " + vo.get("DEPT_CD"));
				System.out.println("현장 코드 : " + vo.get("PUR_CONT_ID"));
				
				RowSet rowSet = getContFileList(vo.get("DEPT_CD"), vo.get("PUR_CONT_ID"));
				/*RowSet rowSet2 = getContGuarFileList(vo.get("DEPT_CD"), vo.get("PUR_CONT_ID"));
				RowSet rowSet3 = getContPrePayGuarFileList(vo.get("DEPT_CD"), vo.get("PUR_CONT_ID"));
				RowSet rowSet4 = getContPrePayGivUpGuarFileList(vo.get("DEPT_CD"), vo.get("PUR_CONT_ID"));*/
				
				System.out.println("계약서 관련 파일 이관* : " + rowSet.size());
				/*계약서 관련 파일 이관*/
				if(!addFilesProc(rowSet)){
					storage.setSuccess(false);
					storage.setMessage("계약서 관련 파일 이관 복사에 실폐하였습니다 : " + storage.getMessage());
				}
				
				/*
				System.out.println("보증서 관련 파일 이관 : " + rowSet2.size());
				보증서 관련 파일 이관
				if(!addFilesProc(rowSet2)){
					storage.setSuccess(false);
					storage.setMessage("보증서 관련 파일 이관 복사에 실폐하였습니다 : " + storage.getMessage());
				}
				
				System.out.println("선급 보증서 관련 파일 이관 : " + rowSet3.size());
				선급 보증서 관련 파일 이관
				if(!addFilesProc(rowSet3)){
					storage.setSuccess(false);
					storage.setMessage("선급 보증서 관련 파일 이관 복사에 실폐하였습니다 : " + storage.getMessage());
				}
				
				System.out.println("선급 포기각서 관련 파일 이관 : " + rowSet4.size());
				선급 포기각서 관련 파일 이관
				if(!addFilesProc(rowSet4)){
					storage.setSuccess(false);
					storage.setMessage("선급 포기각서 관련 파일 이관 복사에 실폐하였습니다 : " + storage.getMessage());
				}
				
//				FileMigrationPayBiz paybiz = new FileMigrationPayBiz(storage);
//				paybiz.payAllRun();
				
				RowSet rowSet11 = getPayFileList(vo.get("DEPT_CD"), vo.get("PUR_CONT_ID"));
				RowSet rowSet12 = getContGuarFileList2(vo.get("DEPT_CD"), vo.get("PUR_CONT_ID"));
				RowSet rowSet13 = getContPrePayGuarFileList2(vo.get("DEPT_CD"), vo.get("PUR_CONT_ID"));
				RowSet rowSet14 = getPayGuarFileList(vo.get("DEPT_CD"), vo.get("PUR_CONT_ID"));
				
				
				대금 파일 이관
				System.out.println("대금 파일 이관 : "+ rowSet11.size());
				if(!addFilesProc(rowSet11)){
					storage.setSuccess(false);
					storage.setMessage("대금 파일 이관 복사에 실폐하였습니다 : " + storage.getMessage());
				}
				
				대금 등록 계약이행 보증 파일 이관
				System.out.println("대금 등록 계약이행 보증 파일 이관 : "+ rowSet12.size());
				if(!addFilesProc(rowSet12)){
					storage.setSuccess(false);
					storage.setMessage("대금 등록 계약이행 보증 파일 이관 복사에 실폐하였습니다 : " + storage.getMessage());
				}
				
				대금 등록된 선급 보증서 관련 파일 이관
				System.out.println("대금 등록된 선급 보증서 관련 파일 이관 : "+ rowSet13.size());
				if(!addFilesProc(rowSet13)){
					storage.setSuccess(false);
					storage.setMessage("대금 등록된 선급 보증서 관련 파일 이관 복사에 실폐하였습니다 : " + storage.getMessage());
				}
				
				하자이행보증 파일 이관
				System.out.println("하자이행보증 파일 이관 : "+ rowSet14.size());
				if(!addFilesProc(rowSet14)){
					storage.setSuccess(false);
					storage.setMessage("하자이행보증 파일 이관 복사에 실폐하였습니다 : " + storage.getMessage());
				}*/
			}
		}else if(storage.compareEvent("ALL_COPY_SUB")){
			RowSet outRow = getOutContList();
			for(int i=0;i<outRow.size();i++){
				ValueObject vo = RowSetUtility.getValueObject(outRow.getRow(i));
				
				
				RowSet rowSet5 = getContOutFileList(vo.get("DEPT_CD"), vo.get("SUB_CONT_ID"));
				RowSet rowSet15 = getPayOutFileList(vo.get("DEPT_CD"), vo.get("SUB_CONT_ID"));
				RowSet rowSet16 = getPayOutGuarFileList(vo.get("DEPT_CD"), vo.get("SUB_CONT_ID"));
				
				
				System.out.println("=================외주=start ===================== ");
				System.out.println("현장 코드 : " + vo.get("DEPT_CD"));
				System.out.println("현장 코드 : " + vo.get("SUB_CONT_ID"));
				
				System.out.println("외주계약 관련 파일 이관 : " + rowSet5.size());
				if(!addFilesProc(rowSet5)){
					storage.setSuccess(false);
					storage.setMessage("외주계약 관련 파일 이관 복사에 실폐하였습니다 : " + storage.getMessage());
				}
				
				/*외주 기성 첨부파일*/
				System.out.println("외주 기성 파일 이관 : "+ rowSet15.size());
				if(!addFilesProc(rowSet15)){
					storage.setSuccess(false);
					storage.setMessage("외주 기성 파일 이관 복사에 실폐하였습니다 : " + storage.getMessage());
				}
				
				/*외주 하자 이행 첨부파일*/
				System.out.println("외주 하자보증 파일 이관 : "+ rowSet16.size());
				if(!addFilesProc(rowSet16)){
					storage.setSuccess(false);
					storage.setMessage("외주 하자보증 파일 이관 복사에 실폐하였습니다 : " + storage.getMessage());
				}
			}
		}
	}

	/**
	 * 마이그래션 계약 리스트
	 * @return
	 */
	private RowSet getPurContList(){
		RowSet rowSet = new RowSetImpl();
		Search search = new SearchImpl();
		StringBuffer sqlStr = new StringBuffer();
		
		try {
			
			sqlStr.append("SELECT DEPT_CD, PUR_CONT_ID                    \n");
			sqlStr.append("FROM PUR1000T                        \n");
			sqlStr.append("WHERE CRE_BY ='99996'  \n");
			sqlStr.append("GROUP BY DEPT_CD, PUR_CONT_ID        \n");

			search.setStatement(sqlStr.toString());
        
        	rowSet = search.execute();
		}catch (WAFSQLException se) {
            super.doException(se);
            this.storage.setSuccess(false);
            this.storage.setMessage(se.getMessage());
            storage.setDetailMessage(se);
            se.printStackTrace();
        }
		
		return rowSet;
	}
	private RowSet getOutContList(){
		RowSet rowSet = new RowSetImpl();
		Search search = new SearchImpl();
		StringBuffer sqlStr = new StringBuffer();
		
		try {
			
			sqlStr.append("SELECT DEPT_CD, sub_CONT_ID                    \n");
			sqlStr.append("FROM sub1000T                        \n");
			sqlStr.append("WHERE CRE_BY ='91581'  \n");
			sqlStr.append("GROUP BY DEPT_CD, sub_CONT_ID        \n");
			
			search.setStatement(sqlStr.toString());
			
			rowSet = search.execute();
		}catch (WAFSQLException se) {
			super.doException(se);
			this.storage.setSuccess(false);
			this.storage.setMessage(se.getMessage());
			storage.setDetailMessage(se);
			se.printStackTrace();
		}
		
		return rowSet;
	}
	
	
	private RowSet getContFileList(String project_no){
		return getContFileList(project_no, "");
	}
	private RowSet getContFileList(String project_no, String contid){
		RowSet rowSet = new RowSetImpl();
		Search search = new SearchImpl();
		StringBuffer sqlStr = new StringBuffer();
		
		try {
			
			sqlStr.append("SELECT  FILE_LIST.FILE_ID            AS FILE_ID           --첨부문서ID     \n");
			sqlStr.append("       ,FILE_LIST.UNIQUE_FILE_NAME   AS REAL_FILE_NAME    --고유파일명     \n");
			sqlStr.append("       ,FILE_LIST.FILE_PATH          AS FILE_PATH         --파일경로       \n");
			sqlStr.append("       ,FILE_LIST.FILE_EXT           AS FILE_EXT          --파일종류       \n");
			sqlStr.append("       ,FILE_LIST.FILE_SIZE          AS FILE_SIZE         --파일크기       \n");
			sqlStr.append("       ,FILE_LIST.FILE_NAME          AS FILE_NAME         --파일명         \n");
			sqlStr.append("       ,'PUR_CONT_MOD_ID'            AS FILE_GB           --파일 구분      \n");
			sqlStr.append("       ,CONT_MOD.PUR_CONT_MOD_ID        AS ID                --발주계약ID     \n");
			sqlStr.append("       ,'PUR_CONT_MOD_ID'            AS O_FILE_GB           --파일 구분      \n");
			sqlStr.append("       ,CONT_MOD.PUR_CONT_MOD_ID        AS O_ID                --발주계약ID     \n");
			sqlStr.append("       ,FILE_LIST.CRE_BY                                  --등록자         \n");
			sqlStr.append("       ,FILE_LIST.CRE_DATE                                --등록일시       \n");
			sqlStr.append("       ,FILE_LIST.UPD_BY                                  --수정자         \n");
			sqlStr.append("       ,FILE_LIST.UPD_DATE                                --수정일시       \n");
			sqlStr.append("       ,CONT.PUR_CONT_ID                                  --계약번호       \n");
			sqlStr.append("       ,'/cont/purchase/' || CONT_MOD.PUR_CONT_MOD_ID AS NEW_PATH                         --신규등록 될 디렉토리      \n");
			sqlStr.append("       ,'N' as MAP_YN                                     --file map 정보 여부       \n");
			sqlStr.append("       ,'N' as OPEN_CORP_YN                                  --file map 정보 여부       \n");
			sqlStr.append("       ,'Y' as USE_CON_YN                                  --file map 정보 여부       \n");
			sqlStr.append("       ,'F' as ADD_GB                                     --file map 정보 여부       \n");
			sqlStr.append("FROM PUR1000T"+db_link_nm+" CONT,                                                        \n");
			sqlStr.append("      ( SELECT PUR_CONT_ID, MAX(PUR_CONT_MOD_ID) AS PUR_CONT_MOD_ID   \n");
			sqlStr.append("          FROM PUR2000T"+db_link_nm+"                                                           \n");
			sqlStr.append("          WHERE CON_RUN_STS = '9'                                                           \n");
			sqlStr.append("        GROUP BY PUR_CONT_ID                                             \n");
			sqlStr.append("       ) CONT_MOD,                                                  \n");
			sqlStr.append("        (                                                                  \n");
			sqlStr.append("            SELECT  A.FILE_ID                                              \n");
			sqlStr.append("                   ,A.UNIQUE_FILE_NAME                                     \n");
			sqlStr.append("                   ,A.FILE_PATH                                            \n");
			sqlStr.append("                   ,A.FILE_EXT                                             \n");
			sqlStr.append("                   ,A.FILE_SIZE                                            \n");
			sqlStr.append("                   ,A.FILE_NAME                                            \n");
			sqlStr.append("                   ,'PUR_CONT_MOD_ID'                                      \n");
			sqlStr.append("                   ,A.PUR_CONT_ID                                          \n");
			sqlStr.append("                   ,A.CRE_BY                                               \n");
			sqlStr.append("                   ,A.CRE_DATE                                             \n");
			sqlStr.append("                   ,A.UPD_BY                                               \n");
			sqlStr.append("                   ,A.UPD_DATE                                             \n");
			sqlStr.append("             FROM  PUR1001T"+db_link_nm+" A                                              \n");
			sqlStr.append("            UNION ALL                                                      \n");
			sqlStr.append("            SELECT  A.FILE_ID                                              \n");
			sqlStr.append("                   ,A.UNIQUE_FILE_NAME                                     \n");
			sqlStr.append("                   ,A.FILE_PATH                                            \n");
			sqlStr.append("                   ,A.FILE_EXT                                             \n");
			sqlStr.append("                   ,A.FILE_SIZE                                            \n");
			sqlStr.append("                   ,A.FILE_NAME                                            \n");
			sqlStr.append("                   ,'PUR_CONT_MOD_ID'  AS FILE_GB                          \n");
			sqlStr.append("                   ,A.PUR_CONT_ID        AS ID                             \n");
			sqlStr.append("                   ,A.CRE_BY                                               \n");
			sqlStr.append("                   ,A.CRE_DATE                                             \n");
			sqlStr.append("                   ,A.UPD_BY                                               \n");
			sqlStr.append("                   ,A.UPD_DATE                                             \n");
			sqlStr.append("             FROM  PUR1002T"+db_link_nm+" A                                              \n");
			sqlStr.append("            where (file_name like '%계약%' or file_name like '%발주%')     \n");
			sqlStr.append("            and file_name not like '%이행%'                                \n");
			sqlStr.append("            and file_name not like '%보증%'                                \n");
			sqlStr.append("            and file_name not like '%증권%'                                \n");
			sqlStr.append(" )FILE_LIST                                                                \n");
			sqlStr.append(" WHERE CONT.PUR_CONT_ID = FILE_LIST.PUR_CONT_ID                            \n");
			sqlStr.append("  AND CONT.PUR_CONT_ID = CONT_MOD.PUR_CONT_ID                           \n");
			sqlStr.append("  AND CONT.DEPT_CD = '"+project_no+"'                                                \n");
			if(!"".equals(contid)){
				sqlStr.append("  AND CONT.PUR_CONT_ID = '"+contid+"'                                                \n");
				
			}
			sqlStr.append(" ORDER BY PUR_CONT_ID ASC                                          \n");

			search.setStatement(sqlStr.toString());
			
			rowSet = search.execute();
		}catch (WAFSQLException se) {
			super.doException(se);
			this.storage.setSuccess(false);
			this.storage.setMessage(se.getMessage());
			storage.setDetailMessage(se);
			se.printStackTrace();
		}
		
		return rowSet;
	}
	
	/**
	 * 계약 별 보증 첨부파일 목록 ( 업체 첨부로 구분 )
	 * @return
	 */
	private RowSet getContGuarFileList(String project_no){
		return getContGuarFileList(project_no, "");
	}
	private RowSet getContGuarFileList(String project_no, String contid){
		RowSet rowSet = new RowSetImpl();
		Search search = new SearchImpl();
		StringBuffer sqlStr = new StringBuffer();
		
		try {
			
			sqlStr.append(" SELECT  FILE_LIST.FILE_ID            AS FILE_ID                       --첨부문서ID                                                              \n");
			sqlStr.append("        ,FILE_LIST.UNIQUE_FILE_NAME   AS REAL_FILE_NAME                --고유파일명                                                              \n");
			sqlStr.append("        ,FILE_LIST.FILE_PATH          AS FILE_PATH                     --파일경로                                                                \n");
			sqlStr.append("        ,FILE_LIST.FILE_EXT           AS FILE_EXT                      --파일종류                                                                \n");
			sqlStr.append("        ,FILE_LIST.FILE_SIZE          AS FILE_SIZE                     --파일크기                                                                \n");
			sqlStr.append("        ,FILE_LIST.FILE_NAME          AS FILE_NAME                     --파일명                                                                  \n");
			sqlStr.append("        ,'GUARCONT_PUR_1_1'            AS FILE_GB                       --파일 구분                                                               \n");
			sqlStr.append("        ,FILE_LIST.PUR_CONT_ID        AS ID                            --발주계약ID                                                              \n");
			sqlStr.append("        ,'GUARCONT_PUR_1_1'            AS O_FILE_GB                     --파일 구분                                                               \n");
			sqlStr.append("        ,FILE_LIST.PUR_CONT_ID        AS O_ID                          --발주계약ID                                                              \n");
			sqlStr.append("        ,FILE_LIST.CRE_BY                                              --등록자                                                                  \n");
			sqlStr.append("        ,FILE_LIST.CRE_DATE                                            --등록일시                                                                \n");
			sqlStr.append("        ,FILE_LIST.UPD_BY                                              --수정자                                                                  \n");
			sqlStr.append("        ,FILE_LIST.UPD_DATE                                            --수정일시                                                                \n");
			sqlStr.append("        ,CONT.PUR_CONT_ID                                              --계약번호                                                                \n");
			sqlStr.append("        ,'/cont/purchase/guar/' || CONT_MOD.PUR_CONT_MOD_ID AS NEW_PATH     --신규등록될디렉토리                                                 \n");
			sqlStr.append("        ,'N' as MAP_YN                                                 --file map 정보 여부                                                      \n");
			sqlStr.append("        ,'N' as OPEN_CORP_YN                                           --file map 정보 여부                                                      \n");
			sqlStr.append("        ,'Y' as USE_CON_YN                                             --file map 정보 여부                                                      \n");
			sqlStr.append("        ,'F' as ADD_GB                                                 --file map 정보 여부                                                      \n");
			sqlStr.append(" FROM PUR1000T"+db_link_nm+" CONT,                                                                                                                             \n");
			sqlStr.append("       ( SELECT PUR_CONT_ID, MAX(PUR_CONT_MOD_ID) AS PUR_CONT_MOD_ID                                                                             \n");
			sqlStr.append("           FROM PUR2000T"+db_link_nm+"                                                                                                                         \n");
			sqlStr.append("           WHERE CON_RUN_STS = '9'                                                                                                                     \n");
			sqlStr.append("         GROUP BY PUR_CONT_ID                                                                                                                    \n");
			sqlStr.append("        ) CONT_MOD,                                                                                                                              \n");
			sqlStr.append("       (                                                                                                                                         \n");
			sqlStr.append("             select *                                                                                                                            \n");
			sqlStr.append("             from PUR1002T"+db_link_nm+"                                                                                                                       \n");
			sqlStr.append("             where  (file_name like '%이행%' or file_name like '%증권%' or     file_name like '%보증%' OR upper(file_name) like '%BOND%')        \n");
			sqlStr.append("             and file_name not like '%선급%'                                                                                                     \n");
			sqlStr.append("             and file_name not like '%선금금%'                                                                                                   \n");
			sqlStr.append("             and file_name not like '%선금급%'                                                                                                   \n");
			sqlStr.append("             union                                                                                                                               \n");
			sqlStr.append("             select *                                                                                                                            \n");
			sqlStr.append("             from (                                                                                                                              \n");
			sqlStr.append("                 select *                                                                                                                        \n");
			sqlStr.append("                 from PUR1002T"+db_link_nm+"                                                                                                                   \n");
			sqlStr.append("                 where (file_name like '%계약이행%' or file_name like '%계약 이행%')                                                             \n");
			sqlStr.append("                 minus                                                                                                                           \n");
			sqlStr.append("                 select *                                                                                                                        \n");
			sqlStr.append("                 from PUR1002T"+db_link_nm+"                                                                                                                   \n");
			sqlStr.append("                 where  (file_name like '%이행%' or file_name like '%증권%' or     file_name like '%보증%' OR upper(file_name) like '%BOND%')    \n");
			sqlStr.append("                 and file_name not like '%선급%'                                                                                                 \n");
			sqlStr.append("                 and file_name not like '%선금금%'                                                                                               \n");
			sqlStr.append("                 and file_name not like '%선금급%'                                                                                               \n");
			sqlStr.append("             )                                                                                                                                   \n");
			sqlStr.append("         )FILE_LIST                                                                                                                              \n");
			sqlStr.append("    WHERE CONT.PUR_CONT_ID = FILE_LIST.PUR_CONT_ID                                                                                               \n");
			sqlStr.append("     AND CONT.PUR_CONT_ID = CONT_MOD.PUR_CONT_ID                                                                                              \n");
			sqlStr.append("     AND CONT.DEPT_CD = '"+project_no+"'                                                                                                                   \n");
			if(!"".equals(contid)){
				sqlStr.append("     AND CONT.PUR_CONT_ID = '"+contid+"'                                                                                                                 \n");
			}
			sqlStr.append("     ORDER BY PUR_CONT_ID ASC                                                                                                                    \n");

			
			
			search.setStatement(sqlStr.toString());
			
			rowSet = search.execute();
		}catch (WAFSQLException se) {
			super.doException(se);
			this.storage.setSuccess(false);
			this.storage.setMessage(se.getMessage());
			storage.setDetailMessage(se);
			se.printStackTrace();
		}
		
		return rowSet;
	}
	/**
	 * 계약 별 선급 보증 첨부파일 목록 ( 업체 첨부로 구분 )
	 * @return
	 */
	private RowSet getContPrePayGuarFileList(String project_no){
		return getContPrePayGuarFileList(project_no, "");
	}
	private RowSet getContPrePayGuarFileList(String project_no, String contid){
		RowSet rowSet = new RowSetImpl();
		Search search = new SearchImpl();
		StringBuffer sqlStr = new StringBuffer();
		
		try {
			
			sqlStr.append(" SELECT  FILE_LIST.FILE_ID            AS FILE_ID                       --첨부문서ID                                                              \n");
			sqlStr.append("        ,FILE_LIST.UNIQUE_FILE_NAME   AS REAL_FILE_NAME                --고유파일명                                                              \n");
			sqlStr.append("        ,FILE_LIST.FILE_PATH          AS FILE_PATH                     --파일경로                                                                \n");
			sqlStr.append("        ,FILE_LIST.FILE_EXT           AS FILE_EXT                      --파일종류                                                                \n");
			sqlStr.append("        ,FILE_LIST.FILE_SIZE          AS FILE_SIZE                     --파일크기                                                                \n");
			sqlStr.append("        ,FILE_LIST.FILE_NAME          AS FILE_NAME                     --파일명                                                                  \n");
			sqlStr.append("        ,'GUARCONT_PUR_3_1'            AS FILE_GB                      --파일 구분                                                               \n");
			sqlStr.append("        ,PRE_PAY.PREPAY_ID              AS ID                          --선급내역ID                                                              \n");
			sqlStr.append("        ,'GUARCONT_PUR_3_1'            AS O_FILE_GB                    --파일 구분                                                               \n");
			sqlStr.append("        ,PRE_PAY.PREPAY_ID              AS O_ID                        --선급내역ID                                                            \n");
			sqlStr.append("        ,FILE_LIST.CRE_BY                                              --등록자                                                                  \n");
			sqlStr.append("        ,FILE_LIST.CRE_DATE                                            --등록일시                                                                \n");
			sqlStr.append("        ,FILE_LIST.UPD_BY                                              --수정자                                                                  \n");
			sqlStr.append("        ,FILE_LIST.UPD_DATE                                            --수정일시                                                                \n");
			sqlStr.append("        ,CONT.PUR_CONT_ID                                              --계약번호                                                                \n");
			sqlStr.append("        ,'/cont/purchase/guar/' || CONT_MOD.PUR_CONT_MOD_ID AS NEW_PATH     --신규등록될디렉토리                                                 \n");
			sqlStr.append("        ,'N' as MAP_YN                                                 --file map 정보 여부                                                      \n");
			sqlStr.append("        ,'N' as OPEN_CORP_YN                                           --file map 정보 여부                                                      \n");
			sqlStr.append("        ,'Y' as USE_CON_YN                                             --file map 정보 여부                                                      \n");
			sqlStr.append("        ,'F' as ADD_GB                                                 --file map 정보 여부                                                      \n");
			sqlStr.append(" FROM PUR1000T"+db_link_nm+" CONT, PUR2000T"+db_link_nm+" CONT_MOD, PUR1030T PRE_PAY,                                                                                                                             \n");
			sqlStr.append("       (                                                                                                                                         \n");
			sqlStr.append("             select *                                                                                                                            \n");
			sqlStr.append("             from PUR1002T"+db_link_nm+"                                                                                                                       \n");
			sqlStr.append("             where  (file_name like '%선급%' or file_name like '%선금%')        \n");
			sqlStr.append("             and file_name not like '%포기%'                                                                                                     \n");
			sqlStr.append("         )FILE_LIST                                                                                                                              \n");
			sqlStr.append("    WHERE PRE_PAY.PUR_CONT_ID = FILE_LIST.PUR_CONT_ID                                                                                                \n");
			sqlStr.append("      AND PRE_PAY.PUR_CONT_ID = CONT.PUR_CONT_ID                                                                                         \n");
			sqlStr.append("      AND PRE_PAY.PUR_CONT_ID = CONT_MOD.PUR_CONT_ID                                                                                        \n");
			sqlStr.append("      AND PRE_PAY.PUR_CONT_MOD_ID = CONT_MOD.PUR_CONT_MOD_ID                                                                                      \n");
			sqlStr.append("      AND CONT.DEPT_CD = '"+project_no+"'                                                                                                                   \n");
			if(!"".equals(contid)){
				sqlStr.append("      AND CONT.PUR_CONT_ID = '"+contid+"'                                                                                                                   \n");
			}
			
			sqlStr.append("     ORDER BY PUR_CONT_ID ASC                                                                                                                    \n");
			
			
			
			search.setStatement(sqlStr.toString());
			
			rowSet = search.execute();
		}catch (WAFSQLException se) {
			super.doException(se);
			this.storage.setSuccess(false);
			this.storage.setMessage(se.getMessage());
			storage.setDetailMessage(se);
			se.printStackTrace();
		}
		
		return rowSet;
	}
	/**
	 * 계약 별 선급 보증 첨부파일 목록 ( 업체 첨부로 구분 )
	 * @return
	 */
	private RowSet getContPrePayGivUpGuarFileList(String project_no){
		return getContPrePayGivUpGuarFileList(project_no, "");
	}
	private RowSet getContPrePayGivUpGuarFileList(String project_no, String contid){
		RowSet rowSet = new RowSetImpl();
		Search search = new SearchImpl();
		StringBuffer sqlStr = new StringBuffer();
		
		try {
			
			sqlStr.append("  SELECT  FILE_LIST.FILE_ID            AS FILE_ID                       --첨부문서ID                    \n");
			sqlStr.append("         ,FILE_LIST.UNIQUE_FILE_NAME   AS REAL_FILE_NAME                --고유파일명                    \n");
			sqlStr.append("         ,FILE_LIST.FILE_PATH          AS FILE_PATH                     --파일경로                      \n");
			sqlStr.append("         ,FILE_LIST.FILE_EXT           AS FILE_EXT                      --파일종류                      \n");
			sqlStr.append("         ,FILE_LIST.FILE_SIZE          AS FILE_SIZE                     --파일크기                      \n");
			sqlStr.append("         ,FILE_LIST.FILE_NAME          AS FILE_NAME                     --파일명                        \n");
			sqlStr.append("         ,'PUR_CONT_MOD_ID'            AS FILE_GB                      --파일 구분                      \n");
			sqlStr.append("         ,CONT_MOD.PUR_CONT_MOD_ID              AS ID                          --선급내역ID             \n");
			sqlStr.append("         ,'PUR_CONT_MOD_ID'            AS O_FILE_GB                    --파일 구분                      \n");
			sqlStr.append("         ,CONT_MOD.PUR_CONT_MOD_ID              AS O_ID                        --선급내역ID             \n");
			sqlStr.append("         ,FILE_LIST.CRE_BY                                              --등록자                        \n");
			sqlStr.append("         ,FILE_LIST.CRE_DATE                                            --등록일시                      \n");
			sqlStr.append("         ,FILE_LIST.UPD_BY                                              --수정자                        \n");
			sqlStr.append("         ,FILE_LIST.UPD_DATE                                            --수정일시                      \n");
			sqlStr.append("         ,CONT.PUR_CONT_ID                                              --계약번호                      \n");
			sqlStr.append("         ,'/prepay/purchase/' || CONT_MOD.PUR_CONT_MOD_ID AS NEW_PATH     --신규등록될디렉토리          \n");
			sqlStr.append("         ,'N' as MAP_YN                                                 --file map 정보 여부            \n");
			sqlStr.append("         ,'N' as OPEN_CORP_YN                                           --file map 정보 여부            \n");
			sqlStr.append("         ,'Y' as USE_CON_YN                                             --file map 정보 여부            \n");
			sqlStr.append("         ,'F' as ADD_GB                                                 --file map 정보 여부            \n");
			sqlStr.append("  FROM PUR1000T"+db_link_nm+" CONT,                                                                                   \n");
			sqlStr.append("        ( SELECT PUR_CONT_ID, MAX(PUR_CONT_MOD_ID) AS PUR_CONT_MOD_ID                                   \n");
			sqlStr.append("            FROM PUR2000T"+db_link_nm+"                                                                               \n");
			sqlStr.append("            GROUP BY PUR_CONT_ID                                                                        \n");
			sqlStr.append("        ) CONT_MOD,                                                                                     \n");
			sqlStr.append("        (     select *                                                                                  \n");
			sqlStr.append("              from PUR1002T"+db_link_nm+"                                                                             \n");
			sqlStr.append("              where  (file_name like '%선급%' or file_name like '%선금%')                               \n");
			sqlStr.append("              and file_name like '%포기%'                                                               \n");
			sqlStr.append("          )FILE_LIST                                                                                    \n");
			sqlStr.append("     WHERE CONT.PUR_CONT_ID = FILE_LIST.PUR_CONT_ID                                                     \n");
			sqlStr.append("       AND CONT.PUR_CONT_ID = CONT_MOD.PUR_CONT_ID                                                      \n");
			sqlStr.append("       AND CONT.DEPT_CD = '"+project_no+"'                                                                             \n");
			if(!"".equals(contid)){
				sqlStr.append("       AND CONT.PUR_CONT_ID = '"+contid+"'                                                                             \n");
			}
			sqlStr.append("      ORDER BY PUR_CONT_ID ASC                                                                          \n");
			
			
			
			search.setStatement(sqlStr.toString());
			
			rowSet = search.execute();
		}catch (WAFSQLException se) {
			super.doException(se);
			this.storage.setSuccess(false);
			this.storage.setMessage(se.getMessage());
			storage.setDetailMessage(se);
			se.printStackTrace();
		}
		
		return rowSet;
	}

	

	/**
	 * 외주 계약 별 첨부파일 목록 
	 * @return
	 */
	private RowSet getContOutFileList(String project_no){
		return getContOutFileList(project_no, "");
	}
	private RowSet getContOutFileList(String project_no, String contid){
		RowSet rowSet = new RowSetImpl();
		Search search = new SearchImpl();
		StringBuffer sqlStr = new StringBuffer();
		
		try {
			
			
			sqlStr.append("SELECT  A.FILE_ID                                 --FILE_ID                 \n");
			sqlStr.append("       ,A.REAL_FILE_NAME                          --실제파일명              \n");
			sqlStr.append("       ,A.FILE_NAME                               --파일이름                \n");
			sqlStr.append("       ,A.FILE_ROUTE             AS FILE_PATH                 --파일경로    \n");
			sqlStr.append("       ,A.FILE_EXPAN             AS FILE_EXT                 --확장자       \n");
			sqlStr.append("       ,A.FILE_SIZE                               --파일크기                \n");
			sqlStr.append("       ,A.MINE_TYPE                               --MINE_TYPE               \n");
			sqlStr.append("       ,A.CONTENT_TYPE                            --CONTENT_TYPE            \n");
			sqlStr.append("       ,A.CONTENT_DISP                            --CONTENT_DISP            \n");
			sqlStr.append("       ,A.SUB_MINE_TYPE                           --SUB_MINE_TYPE           \n");
			sqlStr.append("       ,'SUB_CONT_MOD_ID'  AS O_FILE_GB                                     \n");
			sqlStr.append("       ,cont.SUB_CONT_MOD_ID            AS  O_ID                                  \n");
			sqlStr.append("       ,'SUB_CONT_MOD_ID'  AS FILE_GB                                       \n");
			sqlStr.append("       ,cont.SUB_CONT_MOD_ID            AS  ID                                    \n");
			sqlStr.append("       ,'/cont/outside/' || CONT.SUB_CONT_MOD_ID AS NEW_PATH                \n");
			sqlStr.append("       ,A.CRE_BY                                  --등록자                  \n");
			sqlStr.append("       ,A.CRE_DATE                                --등록일시                \n");
			sqlStr.append("       ,A.UPD_BY                                  --수정자                  \n");
			sqlStr.append("       ,A.UPD_DATE                                --수정일시                \n");
			sqlStr.append("       ,'N' as MAP_YN                                     --file map 정보 여부       \n");
			sqlStr.append("       ,'N' as OPEN_CORP_YN                                  --file map 정보 여부       \n");
			sqlStr.append("       ,'Y' as USE_CON_YN                                  --file map 정보 여부       \n");
			sqlStr.append("       ,'F' as ADD_GB                                     --file map 정보 여부       \n");
			sqlStr.append(" FROM  COM102T"+db_link_nm+" A, COM101T"+db_link_nm+" B,                                                \n");
			sqlStr.append("         ( SELECT MAX(SUB_CONT_MOD_ID)  AS SUB_CONT_MOD_ID, A.SUB_CONT_ID, A.DEPT_CD   \n");
			sqlStr.append("            FROM SUB1000T"+db_link_nm+" A, SUB2000T"+db_link_nm+" B                                     \n");
			sqlStr.append("            WHERE A.SUB_CONT_ID = B.SUB_CONT_ID                             \n");
			sqlStr.append("            AND B.CON_CLS_YN = 9                             \n");
			sqlStr.append("            GROUP BY A.SUB_CONT_ID, A.DEPT_CD                                          \n");
			sqlStr.append("         ) CONT                                                             \n");
			sqlStr.append("WHERE A.FILE_MAP_ID = B.FILE_MAP_ID                                         \n");
			sqlStr.append("AND B.FILE_CONN_ID = CONT.SUB_CONT_ID                                       \n");
			sqlStr.append("AND B.FILE_CONN_CLASS = 'SUB1000T'                                          \n");
			sqlStr.append("AND CONT.DEPT_CD = '"+project_no+"'                                                \n");
			if(!"".equals(contid)){
				sqlStr.append("AND CONT.SUB_CONT_ID = '"+contid+"'                                                \n");
			}
			sqlStr.append("ORDER BY B.FILE_MAP_ID ASC                                                  \n");
			
			
			search.setStatement(sqlStr.toString());
        
        	rowSet = search.execute();
		}catch (WAFSQLException se) {
            super.doException(se);
            this.storage.setSuccess(false);
            this.storage.setMessage(se.getMessage());
            storage.setDetailMessage(se);
            se.printStackTrace();
        }
		
		return rowSet;
	}
	
	private boolean copbyFile(ValueObject fileVo) {
		
		String path = StringUtil.replace("Z:/" + fileVo.get("FILE_PATH"), "/", File.separator);
		
		File file = new File(path, fileVo.get("REAL_FILE_NAME"));
		
		String localfilePath = WAFConfig.get("waf.repository.path");
		String detailPath = fileVo.get("NEW_PATH");
		if("".equals(detailPath) || detailPath == null)detailPath = "/com";
		
    	// 파일 복사 처리
    	FileUtil.checkDir(localfilePath + detailPath); // 디렉토리 존재여부 확인 및 생성
    	try {
			FileUtil.copyFile(file.getAbsolutePath() , localfilePath + detailPath + "/" + file.getName());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} // 파일 복사
    	
		return true;
	}
	
	
	private boolean addFilesProc(RowSet fileRowSet) {

        try {
            conn.begin();
            Connection con = conn.getConnection();

//            String fileID = addFile(con, file, fileName, contentType);
            		
            for(int i=0;i<fileRowSet.size();i++){
            	ValueObject fileMap = new ValueObject();
            	ValueObject fileVo = RowSetUtility.getValueObject(fileRowSet.getRow(i)); 
            	String fileId = addFile(con, fileVo);
            	
            	/*실파일 복사*/
            	copbyFile(fileVo);
            	
            	fileVo.set("FILE_ID", fileId);
            	
            	if(!"N".equals(fileVo.get("MAP_YN"))){
            		System.out.println("File map info 있는 경우임.");
            		//addFileMap(con, fileMapRowSet);
            	}else{
            		fileMap = fileVo;
            		addFileMap(con, fileMap);
            		
            	}
            }
            return true;
        }
        catch(Exception e) {

            WAFLogger.error(this.getClass().getName() + " --> addFilesProc() : " + e.getMessage());
            WAFLogger.error(e);

            conn.setRollback();
            storage.setDetailMessage(e);
            return false;
        }
        finally {

            conn.end();
        }
    }
	
	
	private String addFile(Connection connection, ValueObject fileVo) throws Exception {

        Persistent persistent = new PersistentImpl(connection);
        String sqlstr = "";
        try {

            sqlstr = " INSERT INTO PUB0500T "
                   + " ( FILE_ID, REAL_FILE_NAME, FILE_NAME, FILE_PATH, FILE_EXT,  "
                   + "   FILE_SIZE, MINE_TYPE, CONTENT_TYPE, CONTENT_DISP, SUB_MINE_TYPE,  "
                   + "   CRE_BY, CRE_DATE ) "
                   + " VALUES "
                   + " ( ?, ?, ?, ?, ?, "
                   + "   ?, ?, ?, ?, ?, "
                   + "   99997, TO_CHAR(SYSDATE, 'YYYYMMDDHH24MISS') ) " ;

            persistent.setStatement(sqlstr);

            String fileID = getFileID(connection);

            	
        	persistent.addParameter(fileID);
        	persistent.addParameter(fileVo.get("REAL_FILE_NAME"));
        	persistent.addParameter(fileVo.get("FILE_NAME"));
        	persistent.addParameter(fileVo.get("NEW_PATH"));
        	persistent.addParameter(fileVo.get("FILE_EXT"));
        	persistent.addParameter(fileVo.get("FILE_SIZE"));
        	persistent.addParameter(fileVo.get("MINE_TYPE"));
        	persistent.addParameter(fileVo.get("CONTENT_TYPE"));
        	persistent.addParameter(fileVo.get("CONTENT_DISP"));
        	persistent.addParameter(fileVo.get("SUB_MINE_TYPE"));
        	
        	persistent.execute();
            	
            
            return fileID;
        }
        catch(Exception e) {

            WAFLogger.error(this.getClass().getName() + " --> addFile() : " + e.getMessage());
            WAFLogger.error("SQL : " + sqlstr);
            WAFLogger.error(e);
            storage.setDetailMessage(e);
            throw e;
        }
    }

    /**
     * 파일맵을 추가한다.
	 * @param connection
	 * @return
	 * @throws Exception
	 */
    private String getFileID(Connection connection) throws Exception {

        Persistent persistent = new PersistentImpl(connection);
        String sqlstr = "";
        try {

            sqlstr = " SELECT ETEC_EBID.PUB0500T_S.NEXTVAL AS FILE_ID \n"
                   + " FROM   DUAL                          \n" ;

            persistent.setStatement(sqlstr);

            return persistent.query().getRow(0).get("FILE_ID");
        }
        catch(Exception e) {

            WAFLogger.error(this.getClass().getName() + " --> getFileID() : " + e.getMessage());
            WAFLogger.error("SQL : " + sqlstr);
            WAFLogger.error(e);
            storage.setDetailMessage(e);
            throw e;
        }
    }

    /**
	 * @param connection
	 * @param fileID
	 * @param fileGB
	 * @param ID
	 * @throws Exception
	 */
    private void addFileMap(Connection connection, ValueObject fileMapVo) throws Exception {

        Persistent persistent = new PersistentImpl(connection);
        StringBuffer sqlstr = new StringBuffer();
        try {
        	sqlstr.append(" INSERT INTO PUB0510T  \n");
        	sqlstr.append(" ( FILE_MAP_ID, FILE_ID, O_FILE_GB, O_ID, FILE_GB, ID, OPEN_CORP_YN, USE_CON_YN, ADD_GB, \n");
        	sqlstr.append("   CRE_BY, CRE_DATE )  \n");
        	sqlstr.append(" VALUES  \n");
        	sqlstr.append(" ( ETEC_EBID.PUB0510T_S.NEXTVAL, ?, ?, ?, ?, ?, ?, ?, ?,  \n");
        	sqlstr.append("   99997, TO_CHAR(SYSDATE, 'YYYYMMDDHH24MISS') )  \n");
        	

            persistent.setStatement(sqlstr.toString());

            	
        	persistent.addParameter(fileMapVo.get("FILE_ID"));
        	persistent.addParameter(fileMapVo.get("O_FILE_GB"));
        	persistent.addParameter(fileMapVo.get("O_ID"));
        	persistent.addParameter(fileMapVo.get("FILE_GB"));
        	persistent.addParameter(fileMapVo.get("ID"));
        	persistent.addParameter(fileMapVo.get("OPEN_CORP_YN"));
        	persistent.addParameter(fileMapVo.get("USE_CON_YN"));
        	persistent.addParameter(fileMapVo.get("ADD_GB"));
        	
        	persistent.execute();
            	


        }
        catch(Exception e) {

            WAFLogger.error(this.getClass().getName() + " --> addFile() : " + e.getMessage());
            WAFLogger.error("SQL : " + sqlstr);
            WAFLogger.error(e);
            storage.setDetailMessage(e);
            throw e;
        }
    }
    
    
    
    
    
    
	/**
	 * 대금 파일 이관
	 * @return
	 */
	private RowSet getPayFileList(String project_no){
		return getPayFileList(project_no, "");
	}
	private RowSet getPayFileList(String project_no, String contid){
		RowSet rowSet = new RowSetImpl();
		Search search = new SearchImpl();
		StringBuffer sqlStr = new StringBuffer();
		
		try {
			
			sqlStr.append(" SELECT  A.FILE_ID                                 --FILE_ID                              \n");
			sqlStr.append("        ,A.REAL_FILE_NAME                          --실제파일명                           \n");
			sqlStr.append("        ,A.FILE_NAME                               --파일이름                             \n");
			sqlStr.append("        ,A.FILE_ROUTE             AS FILE_PATH                 --파일경로                 \n");
			sqlStr.append("        ,A.FILE_EXPAN             AS FILE_EXT                 --확장자                    \n");
			sqlStr.append("        ,A.FILE_SIZE                               --파일크기                             \n");
			sqlStr.append("        ,A.MINE_TYPE                               --MINE_TYPE                            \n");
			sqlStr.append("        ,A.CONTENT_TYPE                            --CONTENT_TYPE                         \n");
			sqlStr.append("        ,A.CONTENT_DISP                            --CONTENT_DISP                         \n");
			sqlStr.append("        ,A.SUB_MINE_TYPE                           --SUB_MINE_TYPE                        \n");
			sqlStr.append("        ,'PURCHASE_'  || PAY.PAYREQ_ID  AS O_FILE_GB                                      \n");
			sqlStr.append("        ,A.DETAILCD            AS  O_ID                                                   \n");
			sqlStr.append("        ,'PURCHASE_' || PAY.PAYREQ_ID  AS FILE_GB                                         \n");
			sqlStr.append("        ,A.DETAILCD            AS  ID                                                     \n");
			sqlStr.append("        ,'/payment/purchase/' || PAY.PAYREQ_ID AS NEW_PATH                                \n");
			sqlStr.append("        ,A.CRE_BY                                  --등록자                               \n");
			sqlStr.append("        ,A.CRE_DATE                                --등록일시                             \n");
			sqlStr.append("        ,A.UPD_BY                                  --수정자                               \n");
			sqlStr.append("        ,A.UPD_DATE                                --수정일시                             \n");
			sqlStr.append("        ,'N' as MAP_YN                                     --file map 정보 여부           \n");
			sqlStr.append("        ,'N' as OPEN_CORP_YN                                  --file map 정보 여부        \n");
			sqlStr.append("        ,'Y' as USE_CON_YN                                  --file map 정보 여부          \n");
			sqlStr.append("        ,'F' as ADD_GB                                     --file map 정보 여부           \n");
			sqlStr.append(" FROM  PUR1100T"+db_link_nm+" PAY,  PUR1000T"+db_link_nm+" CONT,                                                      \n");
			sqlStr.append("         (                                                                                \n");
			sqlStr.append("             SELECT B.FILE_ID                                                             \n");
			sqlStr.append("                      , B.REAL_FILE_NAME                                                  \n");
			sqlStr.append("                      , B.FILE_NAME                                                       \n");
			sqlStr.append("                      , B.FILE_ROUTE                                                      \n");
			sqlStr.append("                      , B.FILE_EXPAN                                                      \n");
			sqlStr.append("                      , B.FILE_SIZE                                                       \n");
			sqlStr.append("                      , B.MINE_TYPE                                                       \n");
			sqlStr.append("                      , B.CONTENT_TYPE                                                    \n");
			sqlStr.append("                      , B.CONTENT_DISP                                                    \n");
			sqlStr.append("                      , B.SUB_MINE_TYPE                                                   \n");
			sqlStr.append("                      , B.CRE_BY                                                          \n");
			sqlStr.append("                      , B.CRE_DATE                                                        \n");
			sqlStr.append("                      , B.UPD_BY                                                          \n");
			sqlStr.append("                      , B.UPD_DATE                                                        \n");
			sqlStr.append("                      , C.DETAILCD                                                        \n");
			sqlStr.append("                      , C.DETAILNM                                                        \n");
			sqlStr.append("                      , A.FILE_CONN_ID                                                    \n");
			sqlStr.append("             FROM COM101T"+db_link_nm+" A, COM102T"+db_link_nm+" B, COM911T"+db_link_nm+" C                                         \n");
			sqlStr.append("             WHERE A.FILE_MAP_ID = B.FILE_MAP_ID                                          \n");
			sqlStr.append("             AND A.FILE_CONN_CLASS = 'PUR1100T'                                           \n");
			sqlStr.append("             AND C.BASECD = 'PUR_PAY_FILE'                                                \n");
			sqlStr.append("             AND C.DETAILCD NOT IN ( '120', '130', '140')                                 \n");
			sqlStr.append("             and file_name LIKE C.CHG_CODE02 || '%'                                       \n");
			sqlStr.append("             order by a.file_map_id desc                                                  \n");
			sqlStr.append("         )       A                                                                        \n");
			sqlStr.append("   WHERE PAY.PAYREQ_ID = A.FILE_CONN_ID                                                   \n");
			sqlStr.append("   AND PAY.PUR_CONT_ID = CONT.PUR_CONT_ID                                                 \n");
			sqlStr.append("   AND CONT.DEPT_CD = '"+project_no+"'                                                              \n");
			if(!"".equals(contid)){
				sqlStr.append("   AND CONT.PUR_CONT_ID = '"+contid+"'                                                              \n");
			}
			sqlStr.append("   order by O_FILE_GB asc, FILE_ID ASC                                                    \n");

			
			search.setStatement(sqlStr.toString());
        
        	rowSet = search.execute();
		}catch (WAFSQLException se) {
            super.doException(se);
            this.storage.setSuccess(false);
            this.storage.setMessage(se.getMessage());
            storage.setDetailMessage(se);
            se.printStackTrace();
        }
		
		return rowSet;
	}
	
	/**
	 * 대금 등록 계약이행 보증 파일 이관
	 * @return
	 */
	private RowSet getContGuarFileList2(String project_no){
		return getContGuarFileList2(project_no, "");
	}
	private RowSet getContGuarFileList2(String project_no, String contid){
		RowSet rowSet = new RowSetImpl();
		Search search = new SearchImpl();
		StringBuffer sqlStr = new StringBuffer();
		
		try {
			
			sqlStr.append(" SELECT  A.FILE_ID                                 --FILE_ID                            \n");
			sqlStr.append("        ,A.REAL_FILE_NAME                          --실제파일명                         \n");
			sqlStr.append("        ,A.FILE_NAME                               --파일이름                           \n");
			sqlStr.append("        ,A.FILE_ROUTE             AS FILE_PATH                 --파일경로               \n");
			sqlStr.append("        ,A.FILE_EXPAN             AS FILE_EXT                 --확장자                  \n");
			sqlStr.append("        ,A.FILE_SIZE                               --파일크기                           \n");
			sqlStr.append("        ,A.MINE_TYPE                               --MINE_TYPE                          \n");
			sqlStr.append("        ,A.CONTENT_TYPE                            --CONTENT_TYPE                       \n");
			sqlStr.append("        ,A.CONTENT_DISP                            --CONTENT_DISP                       \n");
			sqlStr.append("        ,A.SUB_MINE_TYPE                           --SUB_MINE_TYPE                      \n");
			sqlStr.append("        ,'GUARCONT_PUR_1_1'   AS O_FILE_GB                                              \n");
			sqlStr.append("        ,CONT_MOD.PUR_CONT_MOD_ID            AS  O_ID                                           \n");
			sqlStr.append("        ,'GUARCONT_PUR_1_1'  AS FILE_GB                                                 \n");
			sqlStr.append("        ,CONT_MOD.PUR_CONT_MOD_ID            AS  ID                                             \n");
			sqlStr.append("        ,'/cont/purchase/guar/' || CONT_MOD.PUR_CONT_MOD_ID AS NEW_PATH                 \n");
			sqlStr.append("        ,A.CRE_BY                                  --등록자                             \n");
			sqlStr.append("        ,A.CRE_DATE                                --등록일시                           \n");
			sqlStr.append("        ,A.UPD_BY                                  --수정자                             \n");
			sqlStr.append("        ,A.UPD_DATE                                --수정일시                           \n");
			sqlStr.append("        ,'N' as MAP_YN                                     --file map 정보 여부         \n");
			sqlStr.append("        ,'N' as OPEN_CORP_YN                                  --file map 정보 여부      \n");
			sqlStr.append("        ,'Y' as USE_CON_YN                                  --file map 정보 여부        \n");
			sqlStr.append("        ,'F' as ADD_GB                                     --file map 정보 여부         \n");
			sqlStr.append(" FROM  PUR1100T"+db_link_nm+" PAY,  PUR1000T"+db_link_nm+" CONT,                                                    \n");
			sqlStr.append("         (                                                                              \n");
			sqlStr.append("               SELECT PUR_CONT_ID, MAX(PUR_CONT_MOD_ID) AS  PUR_CONT_MOD_ID             \n");
			sqlStr.append("               FROM PUR2000T"+db_link_nm+"                                                            \n");
			sqlStr.append("               WHERE CON_RUN_STS = '9'                                                  \n");
			sqlStr.append("               GROUP BY PUR_CONT_ID                                                     \n");
			sqlStr.append("          ) CONT_MOD,                                                                   \n");
			sqlStr.append("         (                                                                              \n");
			sqlStr.append("             SELECT B.FILE_ID                                                           \n");
			sqlStr.append("                      , B.REAL_FILE_NAME                                                \n");
			sqlStr.append("                      , B.FILE_NAME                                                     \n");
			sqlStr.append("                      , B.FILE_ROUTE                                                    \n");
			sqlStr.append("                      , B.FILE_EXPAN                                                    \n");
			sqlStr.append("                      , B.FILE_SIZE                                                     \n");
			sqlStr.append("                      , B.MINE_TYPE                                                     \n");
			sqlStr.append("                      , B.CONTENT_TYPE                                                  \n");
			sqlStr.append("                      , B.CONTENT_DISP                                                  \n");
			sqlStr.append("                      , B.SUB_MINE_TYPE                                                 \n");
			sqlStr.append("                      , B.CRE_BY                                                        \n");
			sqlStr.append("                      , B.CRE_DATE                                                      \n");
			sqlStr.append("                      , B.UPD_BY                                                        \n");
			sqlStr.append("                      , B.UPD_DATE                                                      \n");
			sqlStr.append("                      , C.DETAILCD                                                      \n");
			sqlStr.append("                      , C.DETAILNM                                                      \n");
			sqlStr.append("                      , A.FILE_CONN_ID                                                  \n");
			sqlStr.append("             FROM COM101T"+db_link_nm+" A, COM102T"+db_link_nm+" B, COM911T"+db_link_nm+" C                                       \n");
			sqlStr.append("             WHERE A.FILE_MAP_ID = B.FILE_MAP_ID                                        \n");
			sqlStr.append("             AND A.FILE_CONN_CLASS = 'PUR1100T'                                         \n");
			sqlStr.append("             AND C.BASECD = 'PUR_PAY_FILE'                                              \n");
			sqlStr.append("             AND C.DETAILCD IN ( '120')                                                 \n");
			sqlStr.append("             and file_name LIKE C.CHG_CODE02 || '%'                                     \n");
			sqlStr.append("             order by a.file_map_id desc                                                \n");
			sqlStr.append("         )       A                                                                      \n");
			sqlStr.append("   WHERE PAY.PAYREQ_ID = A.FILE_CONN_ID                                                 \n");
			sqlStr.append("   AND PAY.PUR_CONT_ID = CONT.PUR_CONT_ID                                               \n");
			sqlStr.append("   AND PAY.PUR_CONT_ID = CONT_MOD.PUR_CONT_ID                                           \n");
			sqlStr.append("   AND CONT.DEPT_CD = '"+project_no+"'                                                            \n");
			if(!"".equals(contid)){
				sqlStr.append("   AND CONT.PUR_CONT_ID = '"+contid+"'                                                            \n");
			}
			
			sqlStr.append("  ORDER BY  CONT.PUR_CONT_ID ASC , A.FILE_ID ASC                                                      \n");
			
			search.setStatement(sqlStr.toString());
			
			rowSet = search.execute();
		}catch (WAFSQLException se) {
			super.doException(se);
			this.storage.setSuccess(false);
			this.storage.setMessage(se.getMessage());
			storage.setDetailMessage(se);
			se.printStackTrace();
		}
		
		return rowSet;
	}
	
	/**
	 * 하자이행보증 파일 이관
	 * @return
	 */
	private RowSet getPayGuarFileList(String project_no){
		return getPayGuarFileList(project_no, "");
	}
	private RowSet getPayGuarFileList(String project_no, String contid){
		RowSet rowSet = new RowSetImpl();
		Search search = new SearchImpl();
		StringBuffer sqlStr = new StringBuffer();
		
		try {
			
			
			sqlStr.append(" SELECT  A.FILE_ID                                 --FILE_ID                                    \n");
			sqlStr.append("        ,A.REAL_FILE_NAME                          --실제파일명                                 \n");
			sqlStr.append("        ,A.FILE_NAME                               --파일이름                                   \n");
			sqlStr.append("        ,A.FILE_ROUTE             AS FILE_PATH                 --파일경로                       \n");
			sqlStr.append("        ,A.FILE_EXPAN             AS FILE_EXT                 --확장자                          \n");
			sqlStr.append("        ,A.FILE_SIZE                               --파일크기                                   \n");
			sqlStr.append("        ,A.MINE_TYPE                               --MINE_TYPE                                  \n");
			sqlStr.append("        ,A.CONTENT_TYPE                            --CONTENT_TYPE                               \n");
			sqlStr.append("        ,A.CONTENT_DISP                            --CONTENT_DISP                               \n");
			sqlStr.append("        ,A.SUB_MINE_TYPE                           --SUB_MINE_TYPE                              \n");
			sqlStr.append("        ,'GUARCONT_PUR_5_1'   AS O_FILE_GB                                                      \n");
			sqlStr.append("        ,PAY.PAYREQ_ID            AS  O_ID                                                      \n");
			sqlStr.append("        ,'GUARCONT_PUR_5_1'  AS FILE_GB                                                         \n");
			sqlStr.append("        ,PAY.PAYREQ_ID            AS  ID                                                        \n");
			sqlStr.append("        ,'/cont/purchase/guar/' || CONT_MOD.PUR_CONT_MOD_ID AS NEW_PATH                         \n");
			sqlStr.append("        ,A.CRE_BY                                  --등록자                                     \n");
			sqlStr.append("        ,A.CRE_DATE                                --등록일시                                   \n");
			sqlStr.append("        ,A.UPD_BY                                  --수정자                                     \n");
			sqlStr.append("        ,A.UPD_DATE                                --수정일시                                   \n");
			sqlStr.append("        ,'N' as MAP_YN                                     --file map 정보 여부                 \n");
			sqlStr.append("        ,'N' as OPEN_CORP_YN                                  --file map 정보 여부              \n");
			sqlStr.append("        ,'Y' as USE_CON_YN                                  --file map 정보 여부                \n");
			sqlStr.append("        ,'F' as ADD_GB                                     --file map 정보 여부                 \n");
			sqlStr.append(" FROM  PUR1100T"+db_link_nm+" PAY,  PUR1000T"+db_link_nm+" CONT,                                                            \n");
			sqlStr.append("         (                                                                                      \n");
			sqlStr.append("               SELECT PUR_CONT_ID, MAX(PUR_CONT_MOD_ID) AS  PUR_CONT_MOD_ID                     \n");
			sqlStr.append("               FROM PUR2000T"+db_link_nm+"                                                                    \n");
			sqlStr.append("               WHERE CON_RUN_STS = '9'                                                          \n");
			sqlStr.append("               GROUP BY PUR_CONT_ID                                                             \n");
			sqlStr.append("          ) CONT_MOD,                                                                           \n");
			sqlStr.append("         (                                                                                      \n");
			sqlStr.append("             SELECT B.FILE_ID                                                                   \n");
			sqlStr.append("                      , B.REAL_FILE_NAME                                                        \n");
			sqlStr.append("                      , B.FILE_NAME                                                             \n");
			sqlStr.append("                      , B.FILE_ROUTE                                                            \n");
			sqlStr.append("                      , B.FILE_EXPAN                                                            \n");
			sqlStr.append("                      , B.FILE_SIZE                                                             \n");
			sqlStr.append("                      , B.MINE_TYPE                                                             \n");
			sqlStr.append("                      , B.CONTENT_TYPE                                                          \n");
			sqlStr.append("                      , B.CONTENT_DISP                                                          \n");
			sqlStr.append("                      , B.SUB_MINE_TYPE                                                         \n");
			sqlStr.append("                      , B.CRE_BY                                                                \n");
			sqlStr.append("                      , B.CRE_DATE                                                              \n");
			sqlStr.append("                      , B.UPD_BY                                                                \n");
			sqlStr.append("                      , B.UPD_DATE                                                              \n");
			sqlStr.append("                      , C.DETAILCD                                                              \n");
			sqlStr.append("                      , C.DETAILNM                                                              \n");
			sqlStr.append("                      , A.FILE_CONN_ID                                                          \n");
			sqlStr.append("             FROM COM101T"+db_link_nm+" A, COM102T"+db_link_nm+" B, COM911T"+db_link_nm+" C                                               \n");
			sqlStr.append("             WHERE A.FILE_MAP_ID = B.FILE_MAP_ID                                                \n");
			sqlStr.append("             AND A.FILE_CONN_CLASS = 'PUR1100T'                                                 \n");
			sqlStr.append("             AND C.BASECD = 'PUR_PAY_FILE'                                                      \n");
			sqlStr.append("             AND C.DETAILCD IN ( '140')                                                         \n");
			sqlStr.append("             and file_name LIKE C.CHG_CODE02 || '%'                                             \n");
			sqlStr.append("             order by a.file_map_id desc                                                        \n");
			sqlStr.append("         )       A                                                                              \n");
			sqlStr.append("   WHERE PAY.PAYREQ_ID = A.FILE_CONN_ID                                                         \n");
			sqlStr.append("   AND PAY.PUR_CONT_ID = CONT.PUR_CONT_ID                                                       \n");
			sqlStr.append("   AND PAY.PUR_CONT_ID = CONT_MOD.PUR_CONT_ID                                                   \n");
			sqlStr.append("   AND CONT.DEPT_CD = '"+project_no+"'                                                                    \n");
			if(!"".equals(contid)){
				sqlStr.append("   AND CONT.PUR_CONT_ID = '"+contid+"'                                                                    \n");
			}
			sqlStr.append("   ORDER BY PAY.PAYREQ_ID ASC, A.FILE_ID ASC                                                                   \n");
			
			
			
			search.setStatement(sqlStr.toString());
			
			rowSet = search.execute();
		}catch (WAFSQLException se) {
			super.doException(se);
			this.storage.setSuccess(false);
			this.storage.setMessage(se.getMessage());
			storage.setDetailMessage(se);
			se.printStackTrace();
		}
		
		return rowSet;
	}
	/**
	 * 대금 등록된 선급 보증서 관련 파일 이관
	 * @return
	 */
	private RowSet getContPrePayGuarFileList2(String project_no){
		return getContPrePayGuarFileList2(project_no, "");
	}
	private RowSet getContPrePayGuarFileList2(String project_no, String contid){
		RowSet rowSet = new RowSetImpl();
		Search search = new SearchImpl();
		StringBuffer sqlStr = new StringBuffer();
		
		try {
			
			
			sqlStr.append(" SELECT  A.FILE_ID                                 --FILE_ID                                       \n");
			sqlStr.append("        ,A.REAL_FILE_NAME                          --실제파일명                                    \n");
			sqlStr.append("        ,A.FILE_NAME                               --파일이름                                      \n");
			sqlStr.append("        ,A.FILE_ROUTE             AS FILE_PATH                 --파일경로                          \n");
			sqlStr.append("        ,A.FILE_EXPAN             AS FILE_EXT                 --확장자                             \n");
			sqlStr.append("        ,A.FILE_SIZE                               --파일크기                                      \n");
			sqlStr.append("        ,A.MINE_TYPE                               --MINE_TYPE                                     \n");
			sqlStr.append("        ,A.CONTENT_TYPE                            --CONTENT_TYPE                                  \n");
			sqlStr.append("        ,A.CONTENT_DISP                            --CONTENT_DISP                                  \n");
			sqlStr.append("        ,A.SUB_MINE_TYPE                           --SUB_MINE_TYPE                                 \n");
			sqlStr.append("        ,'GUARCONT_PUR_3_1'   AS O_FILE_GB                                                         \n");
			sqlStr.append("        ,PRE_PAY.PREPAY_ID            AS  O_ID                                                     \n");
			sqlStr.append("        ,'GUARCONT_PUR_3_1'  AS FILE_GB                                                            \n");
			sqlStr.append("        ,PRE_PAY.PREPAY_ID            AS  ID                                                       \n");
			sqlStr.append("        ,'/cont/purchase/guar/' || CONT_MOD.PUR_CONT_MOD_ID AS NEW_PATH                            \n");
			sqlStr.append("        ,A.CRE_BY                                  --등록자                                        \n");
			sqlStr.append("        ,A.CRE_DATE                                --등록일시                                      \n");
			sqlStr.append("        ,A.UPD_BY                                  --수정자                                        \n");
			sqlStr.append("        ,A.UPD_DATE                                --수정일시                                      \n");
			sqlStr.append("        ,'N' as MAP_YN                                     --file map 정보 여부                    \n");
			sqlStr.append("        ,'N' as OPEN_CORP_YN                                  --file map 정보 여부                 \n");
			sqlStr.append("        ,'Y' as USE_CON_YN                                  --file map 정보 여부                   \n");
			sqlStr.append("        ,'F' as ADD_GB                                     --file map 정보 여부                    \n");
			sqlStr.append(" FROM  PUR1100T"+db_link_nm+" PAY,  PUR1000T"+db_link_nm+" CONT, PUR2000T"+db_link_nm+" CONT_MOD, PUR1030T PRE_PAY,        \n");
			sqlStr.append("         (                                                                                         \n");
			sqlStr.append("             SELECT B.FILE_ID                                                                      \n");
			sqlStr.append("                      , B.REAL_FILE_NAME                                                           \n");
			sqlStr.append("                      , B.FILE_NAME                                                                \n");
			sqlStr.append("                      , B.FILE_ROUTE                                                               \n");
			sqlStr.append("                      , B.FILE_EXPAN                                                               \n");
			sqlStr.append("                      , B.FILE_SIZE                                                                \n");
			sqlStr.append("                      , B.MINE_TYPE                                                                \n");
			sqlStr.append("                      , B.CONTENT_TYPE                                                             \n");
			sqlStr.append("                      , B.CONTENT_DISP                                                             \n");
			sqlStr.append("                      , B.SUB_MINE_TYPE                                                            \n");
			sqlStr.append("                      , B.CRE_BY                                                                   \n");
			sqlStr.append("                      , B.CRE_DATE                                                                 \n");
			sqlStr.append("                      , B.UPD_BY                                                                   \n");
			sqlStr.append("                      , B.UPD_DATE                                                                 \n");
			sqlStr.append("                      , C.DETAILCD                                                                 \n");
			sqlStr.append("                      , C.DETAILNM                                                                 \n");
			sqlStr.append("                      , A.FILE_CONN_ID                                                             \n");
			sqlStr.append("             FROM COM101T"+db_link_nm+" A, COM102T"+db_link_nm+" B, COM911T"+db_link_nm+" C                                \n");
			sqlStr.append("             WHERE A.FILE_MAP_ID = B.FILE_MAP_ID                                                   \n");
			sqlStr.append("             AND A.FILE_CONN_CLASS = 'PUR1100T'                                                    \n");
			sqlStr.append("             AND C.BASECD = 'PUR_PAY_FILE'                                                         \n");
			sqlStr.append("             AND C.DETAILCD IN ( '130')                                                            \n");
			sqlStr.append("             and file_name LIKE C.CHG_CODE02 || '%'                                                \n");
			sqlStr.append("             order by a.file_map_id desc                                                           \n");
			sqlStr.append("         )       A                                                                                 \n");
			sqlStr.append("   WHERE PAY.PAYREQ_ID = A.FILE_CONN_ID                                                            \n");
			sqlStr.append("   AND PAY.PUR_CONT_ID = CONT.PUR_CONT_ID                                                          \n");
			sqlStr.append("   AND PAY.PUR_CONT_ID = PRE_PAY.PUR_CONT_ID                                                       \n");
			sqlStr.append("   AND PRE_PAY.PUR_CONT_ID = CONT_MOD.PUR_CONT_ID                                                  \n");
			sqlStr.append("   AND PRE_PAY.PUR_CONT_MOD_ID = CONT_MOD.PUR_CONT_MOD_ID                                          \n");
			sqlStr.append("   AND CONT.DEPT_CD = '"+project_no+"'                                                                       \n");
			if(!"".equals(contid)){
				sqlStr.append("   AND CONT.PUR_CONT_ID = '"+contid+"'                                                                       \n");
			}
			sqlStr.append("  ORDER BY PRE_PAY.PREPAY_ID ASC, A.FILE_ID ASC                                                                    \n");

			
			
			
			search.setStatement(sqlStr.toString());
			rowSet = search.execute();
		}catch (WAFSQLException se) {
			super.doException(se);
			this.storage.setSuccess(false);
			this.storage.setMessage(se.getMessage());
			storage.setDetailMessage(se);
			se.printStackTrace();
		}
		
		return rowSet;
	}
	
	

	/**
	 * 외주 기성 별 첨부파일 목록 
	 * @return
	 */
	private RowSet getPayOutFileList(String project_no){
		return getPayOutFileList(project_no, "");
	}
	private RowSet getPayOutFileList(String project_no, String contid){
		RowSet rowSet = new RowSetImpl();
		Search search = new SearchImpl();
		StringBuffer sqlStr = new StringBuffer();
		
		try {
			
			sqlStr.append(" SELECT  A.FILE_ID                                 --FILE_ID                           \n");
			sqlStr.append("        ,A.REAL_FILE_NAME                          --실제파일명                        \n");
			sqlStr.append("        ,A.FILE_NAME                               --파일이름                          \n");
			sqlStr.append("        ,A.FILE_ROUTE             AS FILE_PATH                 --파일경로              \n");
			sqlStr.append("        ,A.FILE_EXPAN             AS FILE_EXT                 --확장자                 \n");
			sqlStr.append("        ,A.FILE_SIZE                               --파일크기                          \n");
			sqlStr.append("        ,A.MINE_TYPE                               --MINE_TYPE                         \n");
			sqlStr.append("        ,A.CONTENT_TYPE                            --CONTENT_TYPE                      \n");
			sqlStr.append("        ,A.CONTENT_DISP                            --CONTENT_DISP                      \n");
			sqlStr.append("        ,A.SUB_MINE_TYPE                           --SUB_MINE_TYPE                     \n");
			sqlStr.append("        ,'RESOLUTION_'  || PAY.ACMP_ID  AS O_FILE_GB                                   \n");
			sqlStr.append("        ,A.DETAILCD            AS  O_ID                                                \n");
			sqlStr.append("        ,'RESOLUTION_' || PAY.ACMP_ID  AS FILE_GB                                      \n");
			sqlStr.append("        ,A.DETAILCD            AS  ID                                                  \n");
			sqlStr.append("        ,'/payment/outside/' || PAY.ACMP_ID AS NEW_PATH                                \n");
			sqlStr.append("        ,A.CRE_BY                                  --등록자                            \n");
			sqlStr.append("        ,A.CRE_DATE                                --등록일시                          \n");
			sqlStr.append("        ,A.UPD_BY                                  --수정자                            \n");
			sqlStr.append("        ,A.UPD_DATE                                --수정일시                          \n");
			sqlStr.append("        ,'N' as MAP_YN                                     --file map 정보 여부        \n");
			sqlStr.append("        ,'N' as OPEN_CORP_YN                                  --file map 정보 여부     \n");
			sqlStr.append("        ,'Y' as USE_CON_YN                                  --file map 정보 여부       \n");
			sqlStr.append("        ,'F' as ADD_GB                                     --file map 정보 여부        \n");
			sqlStr.append(" FROM  SUB1040T"+db_link_nm+" PAY,  SUB1000T"+db_link_nm+" CONT,                                                   \n");
			sqlStr.append("         (                                                                             \n");
			sqlStr.append("             SELECT B.FILE_ID                                                          \n");
			sqlStr.append("                      , B.REAL_FILE_NAME                                               \n");
			sqlStr.append("                      , B.FILE_NAME                                                    \n");
			sqlStr.append("                      , B.FILE_ROUTE                                                   \n");
			sqlStr.append("                      , B.FILE_EXPAN                                                   \n");
			sqlStr.append("                      , B.FILE_SIZE                                                    \n");
			sqlStr.append("                      , B.MINE_TYPE                                                    \n");
			sqlStr.append("                      , B.CONTENT_TYPE                                                 \n");
			sqlStr.append("                      , B.CONTENT_DISP                                                 \n");
			sqlStr.append("                      , B.SUB_MINE_TYPE                                                \n");
			sqlStr.append("                      , B.CRE_BY                                                       \n");
			sqlStr.append("                      , B.CRE_DATE                                                     \n");
			sqlStr.append("                      , B.UPD_BY                                                       \n");
			sqlStr.append("                      , B.UPD_DATE                                                     \n");
			sqlStr.append("                      , C.DETAILCD                                                     \n");
			sqlStr.append("                      , C.DETAILNM                                                     \n");
			sqlStr.append("                      , A.FILE_CONN_ID                                                 \n");
			sqlStr.append("             FROM COM101T"+db_link_nm+" A, COM102T"+db_link_nm+" B, EBID_COM911T C                                      \n");
			sqlStr.append("             WHERE A.FILE_MAP_ID = B.FILE_MAP_ID                                       \n");
			sqlStr.append("             AND A.FILE_CONN_CLASS = 'SUB1040T'                                        \n");
			sqlStr.append("             AND C.BASECD = 'SUB_ACMP_FILE'                                            \n");
			sqlStr.append("             AND C.DETAILCD NOT  IN ( '570')                                           \n");
			sqlStr.append("             and file_name LIKE C.CHG_CODE02 || '. ' || C.DETAILNM ||  '%'             \n");
			sqlStr.append("             order by a.file_map_id desc                                               \n");
			sqlStr.append("         )       A                                                                     \n");
			sqlStr.append("   WHERE PAY.ACMP_ID = A.FILE_CONN_ID                                                  \n");
			sqlStr.append("   AND PAY.SUB_CONT_ID = CONT.SUB_CONT_ID                                              \n");
			sqlStr.append("   AND CONT.DEPT_CD = '"+project_no+"'                                                           \n");
			if(!"".equals(contid)){
				sqlStr.append("   AND CONT.SUB_CONT_ID = '"+contid+"'                                                           \n");
			}
			sqlStr.append("   order by O_FILE_GB asc, FILE_ID ASC                                                 \n");

			
			
			search.setStatement(sqlStr.toString());
			search.addParameter(project_no);
        
        	rowSet = search.execute();
		}catch (WAFSQLException se) {
            super.doException(se);
            this.storage.setSuccess(false);
            this.storage.setMessage(se.getMessage());
            storage.setDetailMessage(se);
            se.printStackTrace();
        }
		
		return rowSet;
	}
	/**
	 * 외주 하자 이행 첨부파일
	 * @return
	 */
	private RowSet getPayOutGuarFileList(String project_no){
		return getPayOutGuarFileList(project_no, "");
	}
	private RowSet getPayOutGuarFileList(String project_no, String contid){
		RowSet rowSet = new RowSetImpl();
		Search search = new SearchImpl();
		StringBuffer sqlStr = new StringBuffer();
		
		try {
			
			
			sqlStr.append(" SELECT  A.FILE_ID                                 --FILE_ID                           \n");
			sqlStr.append("        ,A.REAL_FILE_NAME                          --실제파일명                        \n");
			sqlStr.append("        ,A.FILE_NAME                               --파일이름                          \n");
			sqlStr.append("        ,A.FILE_ROUTE             AS FILE_PATH                 --파일경로              \n");
			sqlStr.append("        ,A.FILE_EXPAN             AS FILE_EXT                 --확장자                 \n");
			sqlStr.append("        ,A.FILE_SIZE                               --파일크기                          \n");
			sqlStr.append("        ,A.MINE_TYPE                               --MINE_TYPE                         \n");
			sqlStr.append("        ,A.CONTENT_TYPE                            --CONTENT_TYPE                      \n");
			sqlStr.append("        ,A.CONTENT_DISP                            --CONTENT_DISP                      \n");
			sqlStr.append("        ,A.SUB_MINE_TYPE                           --SUB_MINE_TYPE                     \n");
			sqlStr.append("        ,'GUARCONT_OUT_5_1'   AS O_FILE_GB                                             \n");
			sqlStr.append("        ,PAY.ACMP_ID            AS  O_ID                                               \n");
			sqlStr.append("        ,'GUARCONT_OUT_5_1'  AS FILE_GB                                                \n");
			sqlStr.append("        ,PAY.ACMP_ID           AS  ID                                                  \n");
			sqlStr.append("        ,'/cont/outside/guar/' || CONT_MOD.SUB_CONT_MOD_ID AS NEW_PATH                 \n");
			sqlStr.append("        ,A.CRE_BY                                  --등록자                            \n");
			sqlStr.append("        ,A.CRE_DATE                                --등록일시                          \n");
			sqlStr.append("        ,A.UPD_BY                                  --수정자                            \n");
			sqlStr.append("        ,A.UPD_DATE                                --수정일시                          \n");
			sqlStr.append("        ,'N' as MAP_YN                                     --file map 정보 여부        \n");
			sqlStr.append("        ,'N' as OPEN_CORP_YN                                  --file map 정보 여부     \n");
			sqlStr.append("        ,'Y' as USE_CON_YN                                  --file map 정보 여부       \n");
			sqlStr.append("        ,'F' as ADD_GB                                     --file map 정보 여부        \n");
			sqlStr.append(" FROM  SUB1040T"+db_link_nm+" PAY,  SUB1000T"+db_link_nm+" CONT,                                                   \n");
			sqlStr.append("           ( SELECT SUB_CONT_ID, MAX(SUB_CONT_MOD_ID) AS SUB_CONT_MOD_ID               \n");
			sqlStr.append("              FROM SUB2000T"+db_link_nm+"                                                            \n");
			sqlStr.append("              WHERE CON_CLS_YN = '9'                                                   \n");
			sqlStr.append("              GROUP BY SUB_CONT_ID                                                     \n");
			sqlStr.append("           ) CONT_MOD,                                                                 \n");
			sqlStr.append("         (                                                                             \n");
			sqlStr.append("             SELECT B.FILE_ID                                                          \n");
			sqlStr.append("                      , B.REAL_FILE_NAME                                               \n");
			sqlStr.append("                      , B.FILE_NAME                                                    \n");
			sqlStr.append("                      , B.FILE_ROUTE                                                   \n");
			sqlStr.append("                      , B.FILE_EXPAN                                                   \n");
			sqlStr.append("                      , B.FILE_SIZE                                                    \n");
			sqlStr.append("                      , B.MINE_TYPE                                                    \n");
			sqlStr.append("                      , B.CONTENT_TYPE                                                 \n");
			sqlStr.append("                      , B.CONTENT_DISP                                                 \n");
			sqlStr.append("                      , B.SUB_MINE_TYPE                                                \n");
			sqlStr.append("                      , B.CRE_BY                                                       \n");
			sqlStr.append("                      , B.CRE_DATE                                                     \n");
			sqlStr.append("                      , B.UPD_BY                                                       \n");
			sqlStr.append("                      , B.UPD_DATE                                                     \n");
			sqlStr.append("                      , C.DETAILCD                                                     \n");
			sqlStr.append("                      , C.DETAILNM                                                     \n");
			sqlStr.append("                      , A.FILE_CONN_ID                                                 \n");
			sqlStr.append("             FROM COM101T"+db_link_nm+" A, COM102T"+db_link_nm+" B, COM911T"+db_link_nm+" C                                      \n");
			sqlStr.append("             WHERE A.FILE_MAP_ID = B.FILE_MAP_ID                                       \n");
			sqlStr.append("             AND A.FILE_CONN_CLASS = 'SUB1040T'                                        \n");
			sqlStr.append("             AND C.BASECD = 'SUB_ACMP_FILE'                                            \n");
			sqlStr.append("             AND C.DETAILCD  IN ( '570')                                               \n");
			sqlStr.append("             and file_name LIKE C.CHG_CODE02 || '. ' || C.DETAILNM ||  '%'             \n");
			sqlStr.append("             order by a.file_map_id desc                                               \n");
			sqlStr.append("         )       A                                                                     \n");
			sqlStr.append("   WHERE PAY.ACMP_ID = A.FILE_CONN_ID                                                  \n");
			sqlStr.append("   AND PAY.SUB_CONT_ID = CONT.SUB_CONT_ID                                              \n");
			sqlStr.append("   AND PAY.SUB_CONT_ID = CONT_MOD.SUB_CONT_ID                                          \n");
			sqlStr.append("   AND CONT.DEPT_CD = '"+project_no+"'                                                                \n");
			if(!"".equals(contid)){
				sqlStr.append("   AND CONT.SUB_CONT_ID = '"+contid+"'                                                                \n");
			}
			
			sqlStr.append("   order by O_ID asc, FILE_ID ASC                                                      \n");
			
			
			
			search.setStatement(sqlStr.toString());
			
			rowSet = search.execute();
		}catch (WAFSQLException se) {
			super.doException(se);
			this.storage.setSuccess(false);
			this.storage.setMessage(se.getMessage());
			storage.setDetailMessage(se);
			se.printStackTrace();
		}
		
		return rowSet;
	}
	
    
}