/**
 * @(#)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 FileMigrationPayBiz extends Biz {

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

	/* (non-Javadoc)
	 * @see kr.co.hwenc.system.Biz#doBiz()
	 */
	public void doBiz() throws Exception {

		
//		TestCommon common = new TestCommon();
		System.out.println(storage.getEvent());
		if(storage.compareEvent("")){
			System.out.println("화면 조회");
		}
		else if(storage.compareEvent("PAY_COPY")){
			RowSet rowSet1 = getPayFileList();
			RowSet rowSet2 = getContGuarFileList();
			RowSet rowSet3 = getContPrePayGuarFileList();
			RowSet rowSet4 = getPayGuarFileList();
			
			/*대금 파일 이관*/
			System.out.println("대금 파일 이관 : "+ rowSet1.size());
			if(!addFilesProc(rowSet1)){
				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("PAY_OUT_COPY")){
			
			RowSet rowSet1 = getPayOutFileList();
			RowSet rowSet2 = getPayOutGuarFileList();
			
			/*외주 기성 첨부파일*/
			System.out.println("외주 기성 첨부파일 : "+ rowSet1.size());
			if(!addFilesProc(rowSet1)){
				storage.setSuccess(false);
				storage.setMessage("복사에 실폐하였습니다 : " + storage.getMessage());
			}
			
			/*외주 하자 이행 첨부파일*/
			System.out.println("외주 하자 이행 첨부파일 : "+ rowSet2.size());
			if(!addFilesProc(rowSet2)){
				storage.setSuccess(false);
				storage.setMessage("복사에 실폐하였습니다 : " + storage.getMessage());
			}
		}
	}

	public void payAllRun(){
		RowSet rowSet1 = getPayFileList();
		RowSet rowSet2 = getContGuarFileList();
		RowSet rowSet3 = getContPrePayGuarFileList();
		RowSet rowSet4 = getPayGuarFileList();
		
		/*대금 파일 이관*/
		System.out.println("대금 파일 이관 : "+ rowSet1.size());
		if(!addFilesProc(rowSet1)){
			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());
		}
		
		
		
		RowSet rowSet5 = getPayOutFileList();
		RowSet rowSet6 = getPayOutGuarFileList();
		
		
		/*외주 기성 첨부파일*/
		System.out.println("외주 기성 파일 이관 : "+ rowSet5.size());
		if(!addFilesProc(rowSet5)){
			storage.setSuccess(false);
			storage.setMessage("복사에 실폐하였습니다 : " + storage.getMessage());
		}
		
		/*외주 하자 이행 첨부파일*/
		System.out.println("외주 보증 파일 이관 : "+ rowSet6.size());
		if(!addFilesProc(rowSet6)){
			storage.setSuccess(false);
			storage.setMessage("복사에 실폐하였습니다 : " + storage.getMessage());
		}
		
	}
	/**
	 * 대금 파일 이관
	 * @return
	 */
	private RowSet getPayFileList(){
		RowSet rowSet = new RowSetImpl();
		Search search = new SearchImpl();
		StringBuffer sqlStr = new StringBuffer();
		
		try {
			String db_link_nm = params.get("db_link_nm");
			if("".equals(db_link_nm) || db_link_nm == null) db_link_nm="@REALF";
			
			String project_no = params.get("project_no");
			if("".equals(project_no) || project_no == null) project_no="2014";
			
			
			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 = ?                                                              \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 getContGuarFileList(){
		RowSet rowSet = new RowSetImpl();
		Search search = new SearchImpl();
		StringBuffer sqlStr = new StringBuffer();
		
		try {
			String db_link_nm = params.get("db_link_nm");
			if("".equals(db_link_nm) || db_link_nm == null) db_link_nm="@REALF";
			
			String project_no = params.get("project_no");
			if("".equals(project_no) || project_no == null) project_no="2014";
			
			
			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 = ?                                                            \n");
			sqlStr.append("  ORDER BY  CONT.PUR_CONT_ID ASC , A.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 getPayGuarFileList(){
		RowSet rowSet = new RowSetImpl();
		Search search = new SearchImpl();
		StringBuffer sqlStr = new StringBuffer();
		
		try {
			String db_link_nm = params.get("db_link_nm");
			if("".equals(db_link_nm) || db_link_nm == null) db_link_nm="@REALF";
			
			String project_no = params.get("project_no");
			if("".equals(project_no) || project_no == null) project_no="2014";
			
			
			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 = ?                                                                    \n");
			sqlStr.append("   ORDER BY PAY.PAYREQ_ID ASC, A.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 getContPrePayGuarFileList(){
		RowSet rowSet = new RowSetImpl();
		Search search = new SearchImpl();
		StringBuffer sqlStr = new StringBuffer();
		
		try {
			String db_link_nm = params.get("db_link_nm");
			if("".equals(db_link_nm) || db_link_nm == null) db_link_nm="@REALF";
			
			String project_no = params.get("project_no");
			if("".equals(project_no) || project_no == null) project_no="2014";
			
			
			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 = ?                                                                       \n");
			sqlStr.append("  ORDER BY PRE_PAY.PREPAY_ID ASC, A.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 getPayOutFileList(){
		RowSet rowSet = new RowSetImpl();
		Search search = new SearchImpl();
		StringBuffer sqlStr = new StringBuffer();
		
		try {
			String db_link_nm = params.get("db_link_nm");
			if("".equals(db_link_nm) || db_link_nm == null) db_link_nm="@REALF";
			
			String project_no = params.get("project_no");
			if("".equals(project_no) || project_no == null) project_no="2014";
			
			
			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, 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 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 = ?                                                           \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(){
		RowSet rowSet = new RowSetImpl();
		Search search = new SearchImpl();
		StringBuffer sqlStr = new StringBuffer();
		
		try {
			String db_link_nm = params.get("db_link_nm");
			if("".equals(db_link_nm) || db_link_nm == null) db_link_nm="@REALF";
			
			String project_no = params.get("project_no");
			if("".equals(project_no) || project_no == null) project_no="2014";
			
			
			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 = ?                                                                \n");
			sqlStr.append("   order by O_ID 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;
	}
	
	
	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{
            		//System.out.println("File map info 없는 경우임.");
            		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 "
                   + " ( ?, ?, ?, ?, ?, "
                   + "   ?, ?, ?, ?, ?, "
                   + "   ?, 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.addParameter(fileVo.get("CRE_BY"));
        	
        	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("   ?, 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.addParameter(fileMapVo.get("CRE_BY"));
        	
        	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;
        }
    }
	
    
}