package com.eactive.eai.batch.scheduler;

import java.sql.ResultSet;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;

import org.slf4j.LoggerFactory;

import com.eactive.eai.batch.common.StringUtil;
import com.eactive.eai.batch.eventscheduler.holiday.HolidayManager;
import com.eactive.eai.batch.rule.dirInfo.BatchJobInfoVO;
import com.eactive.eai.batch.rule.dirInfo.DirInfoManager;
import com.eactive.eai.common.dao.BaseDAO;
import com.eactive.eai.common.dao.DAOException;
import com.eactive.eai.common.exception.ExceptionUtil;
import com.eactive.eai.common.util.DatetimeUtil;
import com.eactive.eai.common.util.Logger;


/**
* 1. 기능 :  Data Access Object 클래스
* 2. 처리 개요 : 스케줄러 부분은 특성상 메모리에 로딩하지 않는다.
* *     -
* 3. 주의사항
*
* @author  :송영국
* @version : v 1.0.0
* @see : 관련 기능을 참조
* @since   : 2006.01.10
*/
public class SchedulerMessageDAO extends BaseDAO implements SchedulerMessageQuery
{

	public SchedulerMessageDAO() {
		super();
		super.logger = Logger.getLogger(Logger.LOGGER_SCHEDULER);
	}

    //File Event 발생시 스케쥴정보에서 해당 거래구분코드의 전체 스케쥴 정보 조회하여
	//가장 우선순위(우선순위 > 스케줄시작시간 > 스케쥴종료시간)가 높은 스케쥴 정보 리턴
	public SchedulerMessageVO getScheduleInfo(String bizCode, String processCode, String osidinstidstCode) throws DAOException {

		ResultSet rs = null;
		int index    = 0;

        try {
            this.connect(SELECT_SEND_SCHEDULE_BY_BIZCODE);
			//logger.debug("SchedulerMessageDAO.getScheduleInfo() >>> 수행 SQL 문 : \n"+ SELECT_SEND_SCHEDULE_BY_BIZCODE);

			index = 1;
            this.preparedStatement.setString(index++, processCode     );	//logger.debug("SchedulerMessageDAO.getScheduleInfo() >>> 바인드("+(index-1)+") : ["+ processCode   +"]");
            this.preparedStatement.setString(index++, osidinstidstCode);	//logger.debug("SchedulerMessageDAO.getScheduleInfo() >>> 바인드("+(index-1)+") : ["+ osidinstidstCode   +"]");
			this.preparedStatement.setString(index++, bizCode         );	//logger.debug("SchedulerMessageDAO.getScheduleInfo() >>> 바인드("+(index-1)+") : ["+ bizCode   +"]");

            rs = executeQuery();

			SchedulerMessageVO info = null;
            if (rs.next()) {
                info = new SchedulerMessageVO();
                info.setScheduleCode   (StringUtil.nvlTrim(rs.getString("BjobMsgScheID"    ))); // 스케쥴 아이디
                info.setJobCode        (StringUtil.nvlTrim(rs.getString("BjobMsgDstcd"     ))); // Job 구분 코드
                info.setBizCode        (StringUtil.nvlTrim(rs.getString("BjobTranDstcdName"))); // 거래구분코드
                info.setStartTime      (StringUtil.nvlTrim(rs.getString("SndrcvStartHMS"   ))); // 송수신 시작 시간
                info.setEndTime        (StringUtil.nvlTrim(rs.getString("SndrcvEndHMS"     ))); // 송수신 종료 시간
                info.setProcessCode    (StringUtil.nvlTrim(rs.getString("BjobBzwkDstcd"    ))); // 업무구분 코드
                info.setProcessType    (StringUtil.nvlTrim(rs.getString("BjobPtrnDstcd"    ))); // 업무유형 구분
                info.setInstitutionCode(StringUtil.nvlTrim(rs.getString("OsidInstiDstcd"   ))); // 대외기관 코드
                info.setPriority       (                   rs.getInt   ("MsgPrcssPrity"     )); // 메시지 처리 우선 순위
                info.setHolyProcessGb  (StringUtil.nvlTrim(rs.getString("HoldyPrcssDstcd"  ))); // 공휴일처리구분
                info.setStartDelayDays (                   rs.getInt   ("StartDlayNoday"    )); 
                info.setEndDelayDays   (                   rs.getInt   ("EndDlayNoday"      )); 
            }
            return info;

 		} catch (DAOException ex) {
			throw ex;
        } catch(Exception e) {
			String errMsg = ExceptionUtil.getErrorCode(e, "BECEAISSC001", new String[] {processCode, osidinstidstCode, bizCode});
			throw new DAOException(errMsg);	//해당 스케쥴 정보를 찾을 수 없습니다. (업무구분: %1, 대외기관: %2, 거래구분: %3)
        } finally {
            disconnect();
        }
    }

    //File Event 발생시 스케쥴정보에서 해당 거래구분코드의 전체 스케쥴 정보 조회하여
	//가장 우선순위(우선순위 > 스케줄시작시간 > 스케쥴종료시간)가 높은 스케쥴 정보 리턴
	public SchedulerMessageVO getRecvScheduleInfo(String bizCode, String processCode, String osidinstidstCode) throws DAOException {

		ResultSet rs = null;
		int index    = 0;

        try {
            this.connect(SELECT_RECV_SCHEDULE_BY_BIZCODE);
			//logger.debug("SchedulerMessageDAO.getScheduleInfo() >>> 수행 SQL 문 : \n"+ SELECT_SEND_SCHEDULE_BY_BIZCODE);

			index = 1;
            this.preparedStatement.setString(index++, processCode     );	logger.debug("SchedulerMessageDAO.getScheduleInfo() >>> 바인드("+(index-1)+") : ["+ processCode   +"]");
            this.preparedStatement.setString(index++, osidinstidstCode);	logger.debug("SchedulerMessageDAO.getScheduleInfo() >>> 바인드("+(index-1)+") : ["+ osidinstidstCode   +"]");
			this.preparedStatement.setString(index++, bizCode         );	logger.debug("SchedulerMessageDAO.getScheduleInfo() >>> 바인드("+(index-1)+") : ["+ bizCode   +"]");

            rs = executeQuery();

			SchedulerMessageVO info = null;
            if (rs.next()) {
                info = new SchedulerMessageVO();
                info.setScheduleCode   (StringUtil.nvlTrim(rs.getString("BjobMsgScheID"    ))); // 스케쥴 아이디
                info.setJobCode        (StringUtil.nvlTrim(rs.getString("BjobMsgDstcd"     ))); // Job 구분 코드
                info.setBizCode        (StringUtil.nvlTrim(rs.getString("BjobTranDstcdName"))); // 거래구분코드
                info.setStartTime      (StringUtil.nvlTrim(rs.getString("SndrcvStartHMS"   ))); // 송수신 시작 시간
                info.setEndTime        (StringUtil.nvlTrim(rs.getString("SndrcvEndHMS"     ))); // 송수신 종료 시간
                info.setProcessCode    (StringUtil.nvlTrim(rs.getString("BjobBzwkDstcd"    ))); // 업무구분 코드
                info.setProcessType    (StringUtil.nvlTrim(rs.getString("BjobPtrnDstcd"    ))); // 업무유형 구분
                info.setInstitutionCode(StringUtil.nvlTrim(rs.getString("OsidInstiDstcd"   ))); // 대외기관 코드
                info.setPriority       (                   rs.getInt   ("MsgPrcssPrity"     )); // 메시지 처리 우선 순위
                info.setHolyProcessGb  (StringUtil.nvlTrim(rs.getString("HoldyPrcssDstcd"  ))); // 공휴일처리구분
                info.setStartDelayDays (                   rs.getInt   ("StartDlayNoday"    )); 
                info.setEndDelayDays   (                   rs.getInt   ("EndDlayNoday"      )); 
            }else{
            	info = insertNewRecvSchedule( processCode, osidinstidstCode, bizCode );
            }
            return info;

 		} catch (DAOException ex) {
			throw ex;
        } catch(Exception e) {
			String errMsg = ExceptionUtil.getErrorCode(e, "BECEAISSC001", new String[] {processCode, osidinstidstCode, bizCode});
			throw new DAOException(errMsg);	//해당 스케쥴 정보를 찾을 수 없습니다. (업무구분: %1, 대외기관: %2, 거래구분: %3)
        } finally {
            disconnect();
        }
    }

	public int insertJobToQueue(SchedulerMessageVO info) throws DAOException {

		int retValue = 0;
		int index    = 0;

		try {
			if ( info.getHdrInfoName() == null || info.getHdrInfoName().equals("") )
				info.setHdrInfoName(" ");
//			logger.debug( "[insertJobToQueue]line1-->\n"+ info.getHdrInfoName());
//			logger.debug( "[insertJobToQueue]line2-->\n"+ StringUtil.nvlTrim(info.getHdrInfoName()    , " ") );
			this.connect(INSERT_JOB_QUEUE);
			//logger.debug("SchedulerMessageDAO.insertJobToQueue() >>> 수행 SQL 문 : \n"+ INSERT_JOB_QUEUE);

			index = 1;
            this.preparedStatement.setString(index++, info.getUUID().trim());
            this.preparedStatement.setString(index++, info.getSubUUID().trim());
            this.preparedStatement.setInt   (index++, info.getRecvFailCnt());
            this.preparedStatement.setString(index++, info.getScheduleCode().trim());
            this.preparedStatement.setString(index++, info.getProcessCode().trim());
            this.preparedStatement.setString(index++, info.getInstitutionCode().trim());
            this.preparedStatement.setString(index++, info.getProcessType().trim());
            this.preparedStatement.setString(index++, info.getStartTime().trim());
            this.preparedStatement.setString(index++, "99999999999999999");
            this.preparedStatement.setString(index++, StringUtil.nvlTrim(info.getFilePath()       , " "));
            this.preparedStatement.setString(index++, StringUtil.nvlTrim(info.getFileName()       , " "));
            this.preparedStatement.setString(index++, StringUtil.nvlTrim(info.getRenamedFileName(), " "));
            this.preparedStatement.setInt   (index++, info.getPriority());
            this.preparedStatement.setString(index++, StringUtil.nvl(info.getHdrInfoName()        , " "));
            this.preparedStatement.setString(index++, StringUtil.nvlTrim(info.getCreateId()       , " "));
            this.preparedStatement.setString(index++, StringUtil.nvlTrim(info.getCreateTime()     , " "));

			retValue = this.executeUpdate();
			//logger.debug("[요구송신 스케쥴러] ==> 배치 JOB QUEUE 테이블 INSERT 건수: "+ retValue);

			if (retValue == 0) throw new DAOException("BECEAISSC019");  //배치작업 스케쥴 대기정보 insert 건 수가 0 건입니다.
			return retValue;

		} catch (DAOException ex) {
			throw ex;
		} catch (Exception ex) {
			String errMsg = ExceptionUtil.getErrorCode(ex, "BECEAISSC002");
			throw new DAOException(errMsg);	//배치작업 스케쥴 대기정보 등록시 오류가 발생하였습니다.
		} finally {
			disconnect();
		}
	}



	public ArrayList<SchedulerMessageVO> getExecutableJobList() throws DAOException {

		ResultSet rs = null;

		try {

			this.connect(SELECT_EXECUTABLE_JOB_FROM_QUEUE);
			//logger.debug("SchedulerMessageDAO.getExecutableJobList() >>> 수행 SQL 문 : \n"+ SchedulerMessageQuery.SELECT_EXECUTABLE_JOB_FROM_QUEUE);

			rs = executeQuery();

			ArrayList<SchedulerMessageVO> alist = new ArrayList<SchedulerMessageVO>();
			while (rs.next()) {
				SchedulerMessageVO info = new SchedulerMessageVO();
				info.setUUID           (StringUtil.nvlTrim(rs.getString("BjobDmndMsgID"      )));
				info.setSubUUID        (StringUtil.nvlTrim(rs.getString("BjobDmndSubMsgID"   )));
				info.setRecvFailCnt    (                   rs.getInt   ("TelgmReTralCnt"      ));
				info.setMsgCreateTime  (StringUtil.nvlTrim(rs.getString("BjobDmndMsgCretnHMS")));
				info.setScheduleCode   (StringUtil.nvlTrim(rs.getString("BjobMsgScheID"      )));
				info.setProcessCode    (StringUtil.nvlTrim(rs.getString("BjobBzwkDstcd"      )));
				info.setInstitutionCode(StringUtil.nvlTrim(rs.getString("OsidInstiDstcd"     )));
				info.setProcessType    (StringUtil.nvlTrim(rs.getString("BjobPtrnDstcd"      )));
				info.setStartTime      (StringUtil.nvlTrim(rs.getString("SndrcvStartHMS"     )));
				info.setEndTime        (StringUtil.nvlTrim(rs.getString("SndrcvEndHMS"       )));
				info.setFilePath       (StringUtil.nvlTrim(rs.getString("SndrcvFileDirName"  )));
				info.setFileName       (StringUtil.nvlTrim(rs.getString("SndrcvFileName"     )));
				info.setRenamedFileName(StringUtil.nvlTrim(rs.getString("BkupSndrcvFileName" )));
				info.setPriority       (                   rs.getInt   ("MsgPrcssPrity"       ));
				info.setUpdateId       (StringUtil.nvlTrim(rs.getString("ThisMsgAmndrID"     )));
				info.setUpdateTime     (StringUtil.nvlTrim(rs.getString("ThisMsgAmndHMS"     )));
				info.setJobCode        (StringUtil.nvlTrim(rs.getString("BjobMsgDstcd"       )));
				info.setBizCode        (StringUtil.nvlTrim(rs.getString("BjobTranDstcdName"  )));
				info.setInstitutionName(StringUtil.nvlTrim(rs.getString("OsidInstiName"      )));
				info.setBlockSize      (                   rs.getInt   ("TelgmBlckSize"       ));
				info.setSequenceSize   (                   rs.getInt   ("TelgmSernoSize"      ));
				info.setPacketSize     (                   rs.getInt   ("TelgmPcketSize"      ));
				info.setFlowRuleCode   (StringUtil.nvlTrim(rs.getString("FlowRuleCode"       )));
				info.setProcessName    (StringUtil.nvlTrim(rs.getString("BjobBzwkName"       )));
				info.setHdrInfoName    (                   rs.getString("HdrInfoName"         ));
				info.setHolyProcessGb  (StringUtil.nvlTrim(rs.getString("HoldyPrcssDstcd"    )));
				info.setStartDelayDays (                   rs.getInt   ("StartDlayNoday"      ));
				info.setEndDelayDays   (                   rs.getInt   ("EndDlayNoday"        ));
				info.setRecvRetryFlag  (StringUtil.nvlTrim(rs.getString("RqstRecvReTralUseYn")));//2009.6.19 add by kscheon
				alist.add(info);
			}

			return alist;


		} catch (DAOException ex) {
			throw ex;
		} catch (Exception ex) {
			String errMsg = ExceptionUtil.getErrorCode(ex, "BECEAISSC020");
			throw new DAOException(errMsg);  //배치작업 스케쥴 대기목록 테이블에서 수행대상 작업 조회시 오류가 발생하였습니다.
		} finally {
			disconnect();
		}
	}

	public ArrayList<SchedulerMessageVO> getExecutableJobListWithSuspendedJob() throws DAOException {

		ResultSet rs = null;

		try {

			this.connect(SELECT_EXECUTABLE_JOB_FROM_QUEUE_WITH_SUSPENDED_JOB);
			//logger.debug("SchedulerMessageDAO.getExecutableJobList() >>> 수행 SQL 문 : \n"+ SchedulerMessageQuery.SELECT_EXECUTABLE_JOB_FROM_QUEUE);

			rs = executeQuery();

			ArrayList<SchedulerMessageVO> alist = new ArrayList<SchedulerMessageVO>();
			while (rs.next()) {
				SchedulerMessageVO info = new SchedulerMessageVO();
				info.setUUID           (StringUtil.nvlTrim(rs.getString("BjobDmndMsgID"      )));
				info.setSubUUID        (StringUtil.nvlTrim(rs.getString("BjobDmndSubMsgID"   )));
				info.setRecvFailCnt    (                   rs.getInt   ("TelgmReTralCnt"      ));
				info.setMsgCreateTime  (StringUtil.nvlTrim(rs.getString("BjobDmndMsgCretnHMS")));
				info.setScheduleCode   (StringUtil.nvlTrim(rs.getString("BjobMsgScheID"      )));
				info.setProcessCode    (StringUtil.nvlTrim(rs.getString("BjobBzwkDstcd"      )));
				info.setInstitutionCode(StringUtil.nvlTrim(rs.getString("OsidInstiDstcd"     )));
				info.setProcessType    (StringUtil.nvlTrim(rs.getString("BjobPtrnDstcd"      )));
				info.setStartTime      (StringUtil.nvlTrim(rs.getString("SndrcvStartHMS"     )));
				info.setEndTime        (StringUtil.nvlTrim(rs.getString("SndrcvEndHMS"       )));
				info.setFilePath       (StringUtil.nvlTrim(rs.getString("SndrcvFileDirName"  )));
				info.setFileName       (StringUtil.nvlTrim(rs.getString("SndrcvFileName"     )));
				info.setRenamedFileName(StringUtil.nvlTrim(rs.getString("BkupSndrcvFileName" )));
				info.setPriority       (                   rs.getInt   ("MsgPrcssPrity"       ));
				info.setUpdateId       (StringUtil.nvlTrim(rs.getString("ThisMsgAmndrID"     )));
				info.setUpdateTime     (StringUtil.nvlTrim(rs.getString("ThisMsgAmndHMS"     )));
				info.setJobCode        (StringUtil.nvlTrim(rs.getString("BjobMsgDstcd"       )));
				info.setBizCode        (StringUtil.nvlTrim(rs.getString("BjobTranDstcdName"  )));
				info.setInstitutionName(StringUtil.nvlTrim(rs.getString("OsidInstiName"      )));
				info.setBlockSize      (                   rs.getInt   ("TelgmBlckSize"       ));
				info.setSequenceSize   (                   rs.getInt   ("TelgmSernoSize"      ));
				info.setPacketSize     (                   rs.getInt   ("TelgmPcketSize"      ));
				info.setFlowRuleCode   (StringUtil.nvlTrim(rs.getString("FlowRuleCode"       )));
				info.setProcessName    (StringUtil.nvlTrim(rs.getString("BjobBzwkName"       )));
				info.setHdrInfoName    (                   rs.getString("HdrInfoName"         ));
				info.setHolyProcessGb  (StringUtil.nvlTrim(rs.getString("HoldyPrcssDstcd"    )));
				info.setStartDelayDays (                   rs.getInt   ("StartDlayNoday"      ));
				info.setEndDelayDays   (                   rs.getInt   ("EndDlayNoday"        ));
				info.setRecvRetryFlag  (StringUtil.nvlTrim(rs.getString("RqstRecvReTralUseYn")));//2009.6.19 add by kscheon
				alist.add(info);
			}

			return alist;


		} catch (DAOException ex) {
			throw ex;
		} catch (Exception ex) {
			String errMsg = ExceptionUtil.getErrorCode(ex, "BECEAISSC020");
			throw new DAOException(errMsg);  //배치작업 스케쥴 대기목록 테이블에서 수행대상 작업 조회시 오류가 발생하였습니다.
		} finally {
			disconnect();
		}
	}


	public HashSet<String> getExecutingSysConnList() throws DAOException {

		ResultSet rs = null;

		try {

			this.connect(SELECT_EXECUTING_SYSTEMCONNID_FROM_PROCESSING);
			//logger.debug("SchedulerMessageDAO.getExecutingSysConnList() >>> 수행 SQL 문 : \n"+ SchedulerMessageQuery.SELECT_EXECUTING_SYSTEMCONNID_FROM_PROCESSING);

			rs = executeQuery();

			HashSet<String> hSet = new HashSet<String>();
			while (rs.next()) {
				hSet.add(rs.getString("SysLnkgDstcd"));
			}

			return hSet;

		} catch (DAOException ex) {
			throw ex;
		} catch (Exception ex) {
			String errMsg = ExceptionUtil.getErrorCode(ex, "BECEAISSC021");
			throw new DAOException(errMsg);  //배치작업 진행목록 테이블에서 수행중인 작업의 연결정보 조회시 오류가 발생하였습니다.
		} finally {
			disconnect();
		}
	}

	public int moveExecutableJodToProcessing(ArrayList<SchedulerMessageVO> alist) throws DAOException {


		try {

			this.connect(MOVE_JOB_FROM_QUEUE_TO_PROCESSING);
			//logger.debug("SchedulerMessageDAO.moveExecutableJodToProcessing() >>> 수행 SQL 문 : \n"+ MOVE_JOB_FROM_QUEUE_TO_PROCESSING);

			for (int i=0; i < alist.size(); i++) {

				SchedulerMessageVO info = (SchedulerMessageVO)alist.get(i);

				int index = 1;
				if ( info.getSystemConnCode().trim().equals("") ){
					this.preparedStatement.setString(index++, " ");
				}else{
					this.preparedStatement.setString(index++, info.getSystemConnCode().trim());	 
				}
				//
				logger.debug("SchedulerMessageDAO.moveExecutableJodToProcessing() >>> 바인드("+(index-1)+") : ["+ info.getSystemConnCode().trim()   +"]");
				this.preparedStatement.setString(index++, info.getUUID().trim()          );	 
				//
				logger.debug("SchedulerMessageDAO.moveExecutableJodToProcessing() >>> 바인드("+(index-1)+") : ["+ info.getUUID().trim()   +"]");
				this.preparedStatement.setString(index++, info.getSubUUID().trim()       );	 
				//
				logger.debug("SchedulerMessageDAO.moveExecutableJodToProcessing() >>> 바인드("+(index-1)+") : ["+ info.getSubUUID().trim()   +"]");

			logger.debug("SchedulerMessageDAO.moveExecutableJodToProcessing() >>> MOVE_JOB_FROM_QUEUE_TO_PROCESSING");
				this.preparedStatement.addBatch();
				
			}

			int[] resultCnt = this.preparedStatement.executeBatch();

			int totalCnt = 0;
			for (int i=0; i<resultCnt.length; i++) totalCnt += (resultCnt[i]==Statement.SUCCESS_NO_INFO? 1 : resultCnt[i]);
			logger.info("[스케쥴 핸들러] ");
			logger.info("[스케쥴 핸들러] ==> 배치 JOB 대기목록 -> 진행목록 복사 건 수: "+ totalCnt);

			if (alist.size() != totalCnt) {
				String errMsg = ExceptionUtil.getErrorCode("BECEAISSC022", new String[] {Integer.toString(alist.size()), Integer.toString(totalCnt)});
				throw new DAOException(errMsg);  //배치작업 대기목록에서 진행목록으로 이동할 작업 건수[{1}]와 이동된 작업 건수[{2}]가 불일치합니다.
			}

			this.prepareStatement(DELETE_JOB_FROM_QUEUE);
			//logger.debug("SchedulerMessageDAO.moveExecutableJodToProcessing() >>> 수행 SQL 문 : \n"+ DELETE_JOB_FROM_QUEUE);

			for (int i=0; i < alist.size(); i++) {

				SchedulerMessageVO info = (SchedulerMessageVO)alist.get(i);

				int index = 1;
				this.preparedStatement.setString(index++, info.getUUID().trim()     );
				this.preparedStatement.setString(index++, info.getSubUUID().trim()  );

				this.preparedStatement.addBatch();
			}

			resultCnt = this.preparedStatement.executeBatch();
			totalCnt = 0;
			for (int i=0; i<resultCnt.length; i++) totalCnt += (resultCnt[i]==Statement.SUCCESS_NO_INFO? 1 : resultCnt[i]);
			logger.info("[스케쥴 핸들러] ==> 배치 JOB 대기목록 DELETE 건 수: "+ totalCnt);

			return totalCnt;

		} catch (DAOException ex) {
			throw ex;
		} catch (Exception ex) {
			String errMsg = ExceptionUtil.getErrorCode(ex, "BECEAISSC023");
			throw new DAOException(errMsg);  //배치작업 대기목록에서 진행목록으로 진행할 작업을 이동시 오류가 발생하였습니다.
		} finally {
			disconnect();
		}
	}

	public int deleteJobFromProcessing(String uuid, String subUUID) throws DAOException {

		int retValue = 0;
		int index    = 0;

		try {

			this.connect(DELETE_JOB_FROM_PROCESSING);
			//logger.debug("SchedulerMessageDAO.deleteJobFromProcessing() >>> 수행 SQL 문 : \n"+ DELETE_JOB_FROM_PROCESSING);

			index = 1;
			this.preparedStatement.setString(index++, uuid);	//logger.debug("SchedulerMessageDAO.deleteJobFromProcessing() >>> 바인드("+(index-1)+") : ["+ uuid   +"]");
			this.preparedStatement.setString(index++, subUUID);	//logger.debug("SchedulerMessageDAO.deleteJobFromProcessing() >>> 바인드("+(index-1)+") : ["+ subUUID   +"]");

			retValue = this.executeUpdate();
			logger.info("[요구송수신] ==> 진행 완료 및 오류 작업 DELETE 건 수  : "+ retValue);

		} catch (DAOException ex) {
			throw ex;
		} catch (Exception ex) {
			String errMsg = ExceptionUtil.getErrorCode(ex, "BECEAISSC024", new String[] {uuid});
			throw new DAOException(errMsg);  //배치작업 진행목록에서 종료된 작업 삭제시 오류가 발생하였습니다. [UUID: {1}]
		} finally {
			disconnect();
		}
		return retValue;
	}

	public int deleteJobFromProcessing(String uuid) throws DAOException {

		int retValue = 0;
		int index    = 0;

		try {

			this.connect(DELETE_JOB_FROM_PROCESSING);
			//logger.debug("SchedulerMessageDAO.deleteJobFromProcessing() >>> 수행 SQL 문 : \n"+ DELETE_JOB_FROM_PROCESSING);

			index = 1;
			this.preparedStatement.setString(index++, uuid);	//logger.debug("SchedulerMessageDAO.deleteJobFromProcessing() >>> 바인드("+(index-1)+") : ["+ uuid   +"]");

			retValue = this.executeUpdate();
			logger.info("[요구송수신] ==> 진행 완료 및 오류 작업 DELETE 건 수  : "+ retValue);

		} catch (DAOException ex) {
			throw ex;
		} catch (Exception ex) {
			String errMsg = ExceptionUtil.getErrorCode(ex, "BECEAISSC024", new String[] {uuid});
			throw new DAOException(errMsg);  //배치작업 진행목록에서 종료된 작업 삭제시 오류가 발생하였습니다. [UUID: {1}]
		} finally {
			disconnect();
		}
		return retValue;
	}
	
	public int deleteJobFromProcessing() throws Exception {

		int retValue = 0;

		try {

			this.connect(DELETE_ALL_JOBS_FROM_PROCESSING);

			retValue = this.executeUpdate();
			logger.info("[작업 진행 TABLE 초기화] ==> 진행 완료 및 오류 작업 DELETE 건 수  : "+ retValue);

		} catch (Exception ex) {
			throw ex;
		} finally {
			disconnect();
		}
		return retValue;
	}

	public ArrayList<SchedulerMessageVO> getExecutableRecvScheduleList() throws DAOException {

		ResultSet rs = null;

		try {

			this.connect(SELECT_EXECUTABLE_RECV_SCHEDULE_LIST);
			//logger.debug("SchedulerMessageDAO.getExecutableRecvScheduleList() >>> 수행 SQL 문 : \n"+ SchedulerMessageQuery.SELECT_EXECUTABLE_RECV_SCHEDULE_LIST);

			rs = executeQuery();

			int cnt = 1;
			ArrayList<SchedulerMessageVO> alist = new ArrayList<SchedulerMessageVO>();
			while (rs.next()) {
				SchedulerMessageVO info = new SchedulerMessageVO();
                info.setScheduleCode     (StringUtil.nvlTrim(rs.getString("BjobMsgScheID"      )));   // 스케쥴 아이디
                info.setJobCode          (StringUtil.nvlTrim(rs.getString("BjobMsgDstcd"       )));   // Job 구분 코드
                info.setBizCode          (StringUtil.nvlTrim(rs.getString("BjobTranDstcdName"  )));   // 거래구분코드
                info.setStartTime        (StringUtil.nvlTrim(rs.getString("SndrcvStartHMS"     )));   // 송수신 시작 시간
                info.setEndTime          (StringUtil.nvlTrim(rs.getString("SndrcvEndHMS"       )));   // 송수신 종료 시간
                info.setProcessCode      (StringUtil.nvlTrim(rs.getString("BjobBzwkDstcd"      )));   // 업무구분 코드
                info.setProcessType      (StringUtil.nvlTrim(rs.getString("BjobPtrnDstcd"      )));   // 업무유형 구분
                info.setHolyProcessGb    (StringUtil.nvlTrim(rs.getString("HoldyPrcssDstcd"    )));   // 공휴일 처리 유형
                info.setRpttYn           (StringUtil.nvlTrim(rs.getString("RpttYn"             )));   // 반복여부
                info.setInstitutionCode  (StringUtil.nvlTrim(rs.getString("OsidInstiDstcd"     )));   // 대외기관 코드
                info.setRecvRetryFlag    (StringUtil.nvlTrim(rs.getString("RqstRecvReTralUseYn")));   // 요구수신실패시 재시도여부
                info.setRecvRetryCnt     (rs.getInt("RqstRecvReTralCnt"      ));   // 요구수신실패시 재시도회수
                info.setRecvRetrySecs    (rs.getInt("RqstRecvReTralIntvalTtm"));   // 요구수신실패시 재시도간격
                info.setRecvFailCnt      (rs.getInt("RecvFileFailCnt"        ));   // 요구수신실패 회수

				int    recvFileEndCnt  = rs.getInt("RecvFileEndCnt");
				int    recvFileFailCnt = info.getRecvFailCnt();
				String recentExecTime  = StringUtil.nvlTrim(rs.getString("RecentExecTime")) + "0";  //yyyyMMddHHmmssSSS 형태로 맞춤

				//logger.info("[요구수신 스케쥴러] * 요구수신 스케쥴정보 ["+ cnt +"]: "+ info.getScheduleCode() +" | "+ info.getProcessCode() +" | "+ info.getInstitutionCode() +" | "+ info.getBizCode() +" | "+ info.getStartTime() +" | "+ info.getEndTime());

				String holyProcessGb = info.getHolyProcessGb();
				if ( ( holyProcessGb.equals("1") && HolidayManager.getInstance().isAllHoliday(DatetimeUtil.getCurrentDate()) ) ||
				     ( holyProcessGb.equals("2") && HolidayManager.getInstance().isHoliday(DatetimeUtil.getCurrentDate()) ) ){
					logger.info("[스케쥴 핸들러]    ★★★ 영업일이 아니므로 처리 하지 않습니다.("+ info.getProcessCode() +" | "+ info.getInstitutionCode()+" | "+ info.getScheduleCode() +") ★★★");
					continue;
				}
				
				//요구수신 최초 수행인 경우, 요구수신 작업 수행함
				if (recvFileEndCnt == 0 && recvFileFailCnt == 0) {
					logger.info("[요구수신 스케쥴러]    * 요구수신 스케쥴정보 ["+ cnt +"]: "+ info.getScheduleCode() +" | "+ info.getProcessCode() +" | "+ info.getInstitutionCode() +" | "+ info.getBizCode() +" | "+ info.getStartTime() +" | "+ info.getEndTime() +"  ==> 요구수신 최초 수행, Job_Queue 에 추가예정.");
					alist.add(info);

				//요구수신 수행이 성공적으로 완료된 경우, 요구수신 작업 수행 안함
				} else if ((info.getRpttYn().equals("0")) && (recvFileEndCnt > 0)) {
					logger.info("[요구수신 스케쥴러]    * 요구수신 스케쥴정보 ["+ cnt +"]: "+ info.getScheduleCode() +" | "+ info.getProcessCode() +" | "+ info.getInstitutionCode() +" | "+ info.getBizCode() +" | "+ info.getStartTime() +" | "+ info.getEndTime() +"  ==> 요구수신 파일 수신이 이미 완료되었음.");

				//요구수신 수행이 실패한 경우, 재시도 회수를 체크하여 재수행
				} else if (recvFileFailCnt > 0) {
					SimpleDateFormat sdf  = new SimpleDateFormat("yyyyMMddHHmmssSSS");
					SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
					long latestTime  = sdf.parse(recentExecTime).getTime();
					Date currDate    = new Date();
					long currTime    = currDate.getTime();
					long diffSeconds = (currTime - latestTime) / 1000;
					Date nextDate    = new Date(latestTime + (info.getRecvRetrySecs() * 1000));

					//해당 스케쥴정보의 요구수신 재시도 여부가 설정되지 않은 경우, 요구수신 작업 수행 안함
					if (info.getRecvRetryFlag().equals("0")) {
						logger.info("[요구수신 스케쥴러]    * 요구수신 스케쥴정보 ["+ cnt +"]: "+ info.getScheduleCode() +" | "+ info.getProcessCode() +" | "+ info.getInstitutionCode() +" | "+ info.getBizCode() +" | "+ info.getStartTime() +" | "+ info.getEndTime() +"  ==> 요구수신 재시도가 설정되지 않았음. (미완료 작업건수: "+ info.getRecvFailCnt() +")");

					//해당 스케쥴정보의 요구수신 재시도 회수를 초과한 경우, 요구수신 작업 수행 안함
					} else if (info.getRecvRetryCnt() > 0 && (info.getRecvFailCnt()-1) >= info.getRecvRetryCnt()) {
						logger.info("[요구수신 스케쥴러]    * 요구수신 스케쥴정보 ["+ cnt +"]: "+ info.getScheduleCode() +" | "+ info.getProcessCode() +" | "+ info.getInstitutionCode() +" | "+ info.getBizCode() +" | "+ info.getStartTime() +" | "+ info.getEndTime() +"  ==> 요구수신 재시도 회수만큼 수행하였으나 파일 수신 미완료. (재시도 회수: "+ info.getRecvRetryCnt() +")");

					//해당 스케쥴정보의 요구수신 재시도 수행 간격에 따른 재시도 시간이 되지 않은 경우, 다음 Timer Event 시 다시 체크
					} else if (diffSeconds < info.getRecvRetrySecs()) {
						logger.info("[요구수신 스케쥴러]    * 요구수신 스케쥴정보 ["+ cnt +"]: "+ info.getScheduleCode() +" | "+ info.getProcessCode() +" | "+ info.getInstitutionCode() +" | "+ info.getBizCode() +" | "+ info.getStartTime() +" | "+ info.getEndTime() +"  ==> 요구수신 재시도 시간이 되지 않았음. (재시도 회수: "+ (info.getRecvFailCnt()-1) +"/"+ info.getRecvRetryCnt() +", 현재시간: "+ sdf1.format(currDate) +", 재시도 수행시간: "+ sdf1.format(nextDate) +")");

					//해당 스케쥴정보의 요구수신 재시도 설정 조건에 일치하는 경우, 요구수신 작업 수행 함
					} else {
						logger.info("[요구수신 스케쥴러]    * 요구수신 스케쥴정보 ["+ cnt +"]: "+ info.getScheduleCode() +" | "+ info.getProcessCode() +" | "+ info.getInstitutionCode() +" | "+ info.getBizCode() +" | "+ info.getStartTime() +" | "+ info.getEndTime() +"  ==> 요구수신 재시도 수행, Job_Queue 에 추가예정. (재시도 회수: "+ info.getRecvFailCnt() +"/"+ info.getRecvRetryCnt() +")");
						alist.add(info);
					}
				} else {
					if (info.getRpttYn().equals("1")){
						logger.info("[요구수신 스케쥴러]    * 요구수신 스케쥴정보 ["+ cnt +"]: "+ info.getScheduleCode() +" | "+ info.getProcessCode() +" | "+ info.getInstitutionCode() +" | "+ info.getBizCode() +" | "+ info.getStartTime() +" | "+ info.getEndTime() +"  ==> 타이머 성격 요구수신  수행, Job_Queue 에 추가예정. (재시도 회수: "+ info.getRecvFailCnt() +"/"+ info.getRecvRetryCnt() +")");
						alist.add(info);
					}
				}
				cnt++;
			}

			return alist;


		} catch (DAOException ex) {
			throw ex;
		} catch (Exception ex) {
			String errMsg = ExceptionUtil.getErrorCode(ex, "BECEAISSC025");
			throw new DAOException(errMsg);  //작업 대기목록 테이블에서 수행대상 작업 조회시 오류가 발생하였습니다.
		} finally {
			disconnect();
		}
	}
	public int moveExecutableJodToProcessingWithNewID(SchedulerMessageVO info,  String strUUID, String strSubUUID) throws DAOException {

		ResultSet rs = null;
		
		int retValue = 0;

		try {

			this.connect(SELCT_JOB_FROM_QUEUE);
			//logger.debug("SchedulerMessageDAO.moveExecutableJodToProcessingWithNewID() >>> 수행 SQL 문 : \n"+ SELCT_JOB_FROM_QUEUE);
			
			int index = 1;
			this.preparedStatement.setString(index++, info.getUUID());
			this.preparedStatement.setString(index++, info.getSubUUID());

			rs = executeQuery();

			String strTelgmReTralCnt      ;
			String strBjobDmndMsgCretnHMS ;
			String strBjobMsgScheID       ;
			String strBjobBzwkDstcd       ;
			String strOsidInstiDstcd      ;
			String strBjobPtrnDstcd       ;
			String strSndrcvStartHMS      ;
			String strSndrcvEndHMS        ;
			String strSndrcvFileDirName   ;
			String strSndrcvFileName      ;
			String strBkupSndrcvFileName  ;
			String strMsgPrcssPrity       ;
			String strThisMsgAmndrID      ;
			String strThisMsgAmndHMS      ;

			if ( !rs.next()) {
				throw new DAOException(" 대기 작업이 없습니다.");  //배치작업 대기목록에서 진행목록으로 진행할 작업을 이동시 오류가 발생하였습니다.
			}
			strTelgmReTralCnt        =   StringUtil.nvlTrim(rs.getString("TelgmReTralCnt"));
			strBjobDmndMsgCretnHMS   =   StringUtil.nvlTrim(rs.getString("BjobDmndMsgCretnHMS"));
			strBjobMsgScheID         =   StringUtil.nvlTrim(rs.getString("BjobMsgScheID"));
			strBjobBzwkDstcd         =   StringUtil.nvlTrim(rs.getString("BjobBzwkDstcd"));
			strOsidInstiDstcd        =   StringUtil.nvlTrim(rs.getString("OsidInstiDstcd"));
			strBjobPtrnDstcd         =   StringUtil.nvlTrim(rs.getString("BjobPtrnDstcd"));
			strSndrcvStartHMS        =   StringUtil.nvlTrim(rs.getString("SndrcvStartHMS"));
			strSndrcvEndHMS          =   StringUtil.nvlTrim(rs.getString("SndrcvEndHMS"));
			strSndrcvFileDirName     =   StringUtil.nvlTrim(rs.getString("SndrcvFileDirName"));
			strSndrcvFileName        =   StringUtil.nvlTrim(rs.getString("SndrcvFileName"));
			strBkupSndrcvFileName    =   StringUtil.nvlTrim(rs.getString("BkupSndrcvFileName"));
			strMsgPrcssPrity         =   StringUtil.nvlTrim(rs.getString("MsgPrcssPrity"));
			strThisMsgAmndrID        =   StringUtil.nvlTrim(rs.getString("ThisMsgAmndrID"));
			strThisMsgAmndHMS        =   StringUtil.nvlTrim(rs.getString("ThisMsgAmndHMS"));
			

			this.prepareStatement(UPDATE_PROCESSING_WITH_NEW_JOB);
			
			index = 1;
			
			this.preparedStatement.setString(index++, strTelgmReTralCnt      ); //logger.debug("SchedulerMessageDAO.moveExecutableJodToProcessingWithNewID() >>> 바인드("+(index-1)+") : ["+ strTelgmReTralCnt      +"]");
			this.preparedStatement.setString(index++, strBjobDmndMsgCretnHMS ); //logger.debug("SchedulerMessageDAO.moveExecutableJodToProcessingWithNewID() >>> 바인드("+(index-1)+") : ["+ strBjobDmndMsgCretnHMS +"]");
			this.preparedStatement.setString(index++, strBjobMsgScheID       ); //logger.debug("SchedulerMessageDAO.moveExecutableJodToProcessingWithNewID() >>> 바인드("+(index-1)+") : ["+ strBjobMsgScheID       +"]");
			this.preparedStatement.setString(index++, strBjobBzwkDstcd       ); //logger.debug("SchedulerMessageDAO.moveExecutableJodToProcessingWithNewID() >>> 바인드("+(index-1)+") : ["+ strBjobBzwkDstcd       +"]");
			this.preparedStatement.setString(index++, strOsidInstiDstcd      ); //logger.debug("SchedulerMessageDAO.moveExecutableJodToProcessingWithNewID() >>> 바인드("+(index-1)+") : ["+ strOsidInstiDstcd      +"]");
			this.preparedStatement.setString(index++, strBjobPtrnDstcd       ); //logger.debug("SchedulerMessageDAO.moveExecutableJodToProcessingWithNewID() >>> 바인드("+(index-1)+") : ["+ strBjobPtrnDstcd       +"]");
			this.preparedStatement.setString(index++, strSndrcvStartHMS      ); //logger.debug("SchedulerMessageDAO.moveExecutableJodToProcessingWithNewID() >>> 바인드("+(index-1)+") : ["+ strSndrcvStartHMS      +"]");
			this.preparedStatement.setString(index++, strSndrcvEndHMS        ); //logger.debug("SchedulerMessageDAO.moveExecutableJodToProcessingWithNewID() >>> 바인드("+(index-1)+") : ["+ strSndrcvEndHMS        +"]");
			this.preparedStatement.setString(index++, strSndrcvFileDirName   ); //logger.debug("SchedulerMessageDAO.moveExecutableJodToProcessingWithNewID() >>> 바인드("+(index-1)+") : ["+ strSndrcvFileDirName   +"]");
			this.preparedStatement.setString(index++, strSndrcvFileName      ); //logger.debug("SchedulerMessageDAO.moveExecutableJodToProcessingWithNewID() >>> 바인드("+(index-1)+") : ["+ strSndrcvFileName      +"]");
			this.preparedStatement.setString(index++, strBkupSndrcvFileName  ); //logger.debug("SchedulerMessageDAO.moveExecutableJodToProcessingWithNewID() >>> 바인드("+(index-1)+") : ["+ strBkupSndrcvFileName  +"]");
			this.preparedStatement.setString(index++, strMsgPrcssPrity       ); //logger.debug("SchedulerMessageDAO.moveExecutableJodToProcessingWithNewID() >>> 바인드("+(index-1)+") : ["+ strMsgPrcssPrity       +"]");
			this.preparedStatement.setString(index++, strThisMsgAmndrID      ); //logger.debug("SchedulerMessageDAO.moveExecutableJodToProcessingWithNewID() >>> 바인드("+(index-1)+") : ["+ strThisMsgAmndrID      +"]");
			this.preparedStatement.setString(index++, strThisMsgAmndHMS      ); //logger.debug("SchedulerMessageDAO.moveExecutableJodToProcessingWithNewID() >>> 바인드("+(index-1)+") : ["+ strThisMsgAmndHMS      +"]");

			this.preparedStatement.setString(index++, strSubUUID      ); //logger.debug("SchedulerMessageDAO.moveExecutableJodToProcessingWithNewID() >>> 바인드("+(index-1)+") : ["+ strSubUUID      +"]");
			this.preparedStatement.setString(index++, strUUID            ); //logger.debug("SchedulerMessageDAO.moveExecutableJodToProcessingWithNewID() >>> 바인드("+(index-1)+") : ["+ strUUID      +"]");

			retValue = this.preparedStatement.executeUpdate();
			logger.info("[스케쥴 핸들러] ==> 프로세싱 JOB UPDATE 건 수: "+ retValue);

			// 큐에서 작업 삭제
			this.prepareStatement(DELETE_JOB_FROM_QUEUE); 		//logger.debug("SchedulerMessageDAO.moveExecutableJodToProcessingWithNewID() >>> 수행 SQL 문 : \n"+ DELETE_JOB_FROM_QUEUE);
			index = 1;
			this.preparedStatement.setString(1, info.getUUID());
			this.preparedStatement.setString(2, info.getSubUUID() );
			retValue = this.preparedStatement.executeUpdate();
			logger.info("[스케쥴 핸들러] ==> 배치 JOB 대기목록 DELETE 건 수: "+ retValue);

			// 로그에서 삭제
			this.prepareStatement(DELETE_JOB_FROM_LOGMASTER); 		//logger.debug("SchedulerMessageDAO.moveExecutableJodToProcessingWithNewID() >>> 수행 SQL 문 : \n"+ DELETE_JOB_FROM_LOGMASTER);
			index = 1;
			this.preparedStatement.setString(index++, info.getUUID());
			retValue = this.preparedStatement.executeUpdate();
			logger.info("[스케쥴 핸들러] ==> 로그마스터 DELETE 건 수: "+ retValue);

			this.prepareStatement(DELETE_JOB_FROM_LOGDETAIL); 		//logger.debug("SchedulerMessageDAO.moveExecutableJodToProcessingWithNewID() >>> 수행 SQL 문 : \n"+ DELETE_JOB_FROM_LOGDETAIL);
			index = 1;
			this.preparedStatement.setString(index++, info.getUUID());
			retValue = this.preparedStatement.executeUpdate();
			logger.info("[스케쥴 핸들러] ==> 로그디테일 DELETE 건 수: "+ retValue);

			return retValue;

		} catch (DAOException ex) {
			throw ex;
		} catch (Exception ex) {
			String errMsg = ExceptionUtil.getErrorCode(ex, "BECEAISSC023");
			throw new DAOException(errMsg);  //배치작업 대기목록에서 진행목록으로 진행할 작업을 이동시 오류가 발생하였습니다.
		} finally {
			disconnect();
		}
	}
	
	
	public SchedulerMessageVO getScheduleByScheduleCode(String ScheduleCode) throws Exception
	{
		ResultSet rs = null;
		SchedulerMessageVO info = new SchedulerMessageVO();

		try {
			this.connect(SELECT_SCHEDULE_BY_CODE);
			//logger.debug("SchedulerMessageDAO.getScheduleByScheduleCode() >>> 수행 SQL 문 : \n"+ SchedulerMessageQuery.SELECT_SCHEDULE_BY_CODE);

			int index = 1;
			this.preparedStatement.setString(index++, ScheduleCode);
			logger.debug("SchedulerMessageDAO.getScheduleByScheduleCode() >>>  ScheduleCode -->[" + ScheduleCode + "]");

			rs = executeQuery();

			while (rs.next()) {
				info.setProcessCode			(StringUtil.nvlTrim(rs.getString( "BjobBzwkDstcd"     )));
			    info.setProcessName			(StringUtil.nvlTrim(rs.getString( "BjobBzwkName"      )));
			    info.setInstitutionCode		(StringUtil.nvlTrim(rs.getString( "OsidInstiDstcd"    )));
			    info.setInstitutionName		(StringUtil.nvlTrim(rs.getString( "OsidInstiName"     )));
			    info.setJobCode				(StringUtil.nvlTrim(rs.getString( "BjobMsgDstcd"      )));
			    info.setScheduleCode		(StringUtil.nvlTrim(rs.getString( "BjobMsgScheID"     )));
			    info.setProcessType			(StringUtil.nvlTrim(rs.getString( "BjobPtrnDstcd"     )));
			    info.setBizCode             (StringUtil.nvlTrim(rs.getString( "BjobTranDstcdName" )));
			    info.setRecvFailCnt			(rs.getInt   ( "RqstRecvReTralCnt" ));
			    info.setStartTime			(StringUtil.nvlTrim(rs.getString( "SndrcvStartHMS"    )));
			    info.setEndTime				(StringUtil.nvlTrim(rs.getString( "SndrcvEndHMS"      )));

				break;
			}

			return info;
		} catch (DAOException ex) {
			throw ex;
		} catch (Exception ex) {
			String errMsg = ExceptionUtil.getErrorCode(ex, "BECEAISSC025");
			throw new DAOException(errMsg);  //작업 대기목록 테이블에서 수행대상 작업 조회시 오류가 발생하였습니다.
		} finally {
			disconnect();
		}
	}
//	File Event 발생시 스케쥴정보에서 해당 거래구분코드의 전체 스케쥴 정보 조회하여
	//가장 우선순위(우선순위 > 스케줄시작시간 > 스케쥴종료시간)가 높은 스케쥴 정보 리턴
	public SchedulerMessageVO getScheduleInfo(String scheduleId) throws DAOException {

		ResultSet rs = null;
//		int index    = 0;

        try {
            this.connect(SELECT_SEND_SCHEDULE_BY_SCHEDULEID);
			//logger.debug("SchedulerMessageDAO.getScheduleInfo() >>> 수행 SQL 문 : \n"+ SELECT_SEND_SCHEDULE_BY_SCHEDULEID);

            this.preparedStatement.setString(1, scheduleId     );	
            logger.debug("SchedulerMessageDAO.getScheduleInfo() >>> 바인드 : ["+ scheduleId   +"]");
 
            rs = executeQuery();

			SchedulerMessageVO info = null;
            if (rs.next()) {
                info = new SchedulerMessageVO();
                info.setScheduleCode   (StringUtil.nvlTrim(rs.getString("BjobMsgScheID"    )));   // 스케쥴 아이디
                info.setJobCode        (StringUtil.nvlTrim(rs.getString("BjobMsgDstcd"     )));   // Job 구분 코드
                info.setBizCode        (StringUtil.nvlTrim(rs.getString("BjobTranDstcdName")));   // 거래구분코드
                info.setStartTime      (StringUtil.nvlTrim(rs.getString("SndrcvStartHMS"   )));   // 송수신 시작 시간
                info.setEndTime        (StringUtil.nvlTrim(rs.getString("SndrcvEndHMS"     )));   // 송수신 종료 시간
                info.setProcessCode    (StringUtil.nvlTrim(rs.getString("BjobBzwkDstcd"    )));   // 업무구분 코드
                info.setProcessType    (StringUtil.nvlTrim(rs.getString("BjobPtrnDstcd"    )));   // 업무유형 구분
                info.setInstitutionCode(StringUtil.nvlTrim(rs.getString("OsidInstiDstcd"   )));   // 대외기관 코드
                info.setRecvRetryFlag  (StringUtil.nvlTrim(rs.getString("RqstRecvReTralUseYn")));
                
                try{
                	info.setRecvRetryCnt   (Integer.parseInt(StringUtil.nvlTrim(rs.getString("RqstRecvReTralCnt"))));
                }catch (Exception e){
                	logger.error(scheduleId +" ] RecvRetryCnt 을 설정하는데 오류가 발생했습니다. - "+rs.getString("RqstRecvReTralCnt"));
                }
                try{
                	info.setRecvRetrySecs  (Integer.parseInt(StringUtil.nvlTrim(rs.getString("RqstRecvReTralIntvalTtm"))));
                }catch (Exception e){
                	logger.error(scheduleId +" ] RecvRetrySecs 을 설정하는데 오류가 발생했습니다. - "+rs.getString("RqstRecvReTralIntvalTtm"));
                }
            }
            return info;

 		} catch (DAOException ex) {
			throw ex;
        } catch(Exception e) {
			//String errMsg = ExceptionUtil.getErrorCode(e, "BECEAISSC001", new String[] {processCode, osidinstidstCode, bizCode});
        	String errMsg = (scheduleId +"] 에 해당하는 스케줄 정보를 조회하는데 오류가 발생했습니다. - "+e.getMessage());
			throw new DAOException(errMsg);	//해당 스케쥴 정보를 찾을 수 없습니다. (업무구분: %1, 대외기관: %2, 거래구분: %3)
        } finally {
            disconnect();
        }
    }

	
	//2008.09.22 by kscheon
	/*
	public ArrayList getExecutableReReqRecvScheduleList() throws DAOException {

		ResultSet rs = null;

		try {

			this.connect(SELECT_EXECUTABLE_RE_REQ_RECV_SCHEDULE_LIST);
			//logger.debug("SchedulerMessageDAO.getExecutableRecvScheduleList() >>> 수행 SQL 문 : \n"+ SchedulerMessageQuery.SELECT_EXECUTABLE_RECV_SCHEDULE_LIST);

			rs = executeQuery();

			int cnt = 1;
			ArrayList<SchedulerMessageVO> alist = new ArrayList<SchedulerMessageVO>();
			ArrayList<SchedulerMessageVO> deletelist = new ArrayList<SchedulerMessageVO>();
			
//			boolean isDelete = false;
			
			while (rs.next()) {

				SchedulerMessageVO info = new SchedulerMessageVO();
                info.setScheduleCode     (StringUtil.nvlTrim(rs.getString("BjobMsgScheID"      )));   // 스케쥴 아이디
                info.setJobCode          (StringUtil.nvlTrim(rs.getString("BjobMsgDstcd"       )));   // Job 구분 코드
                info.setBizCode          (StringUtil.nvlTrim(rs.getString("BjobTranDstcdName"  )));   // 거래구분코드
                info.setStartTime        (StringUtil.nvlTrim(rs.getString("SndrcvStartHMS"     )));   // 송수신 시작 시간
                info.setEndTime          (StringUtil.nvlTrim(rs.getString("SndrcvEndHMS"       )));   // 송수신 종료 시간
                info.setProcessCode      (StringUtil.nvlTrim(rs.getString("BjobBzwkDstcd"      )));   // 업무구분 코드
                info.setProcessType      (StringUtil.nvlTrim(rs.getString("BjobPtrnDstcd"      )));   // 업무유형 구분
                info.setInstitutionCode  (StringUtil.nvlTrim(rs.getString("OsidInstiDstcd"     )));   // 대외기관 코드
                info.setRecvRetryFlag    (StringUtil.nvlTrim(rs.getString("RqstRecvReTralUseYn")));   // 요구수신실패시 재시도여부
                info.setRecvRetryCnt     (rs.getInt("RqstRecvReTralCnt"      ));   // 요구수신실패시 재시도회수
                info.setRecvRetrySecs    (rs.getInt("RqstRecvReTralIntvalTtm"));   // 요구수신실패시 재시도간격
                info.setRecvFailCnt      (rs.getInt("RecvFileFailCnt"        ));   // 요구수신실패 회수
                
                info.setRePrcssStartYMS   (rs.getString("RePrcssStartYMS"));

				int    recvFileEndCnt  = rs.getInt("RecvFileEndCnt");
				int    recvFileFailCnt = info.getRecvFailCnt();
				String recentExecTime  = StringUtil.nvlTrim(rs.getString("RecentExecTime")) + "0";  //yyyyMMddHHmmssSSS 형태로 맞춤

				//logger.info("[요구수신 스케쥴러] * 요구수신 스케쥴정보 ["+ cnt +"]: "+ info.getScheduleCode() +" | "+ info.getProcessCode() +" | "+ info.getInstitutionCode() +" | "+ info.getBizCode() +" | "+ info.getStartTime() +" | "+ info.getEndTime());

				//요구수신 최초 수행인 경우, 요구수신 작업 수행함
				//if (recvFileEndCnt == 0 && recvFileFailCnt == 0) {
				//	logger.info("[요구수신 스케쥴러]    * 요구수신 스케쥴정보 ["+ cnt +"]: "+ info.getScheduleCode() +" | "+ info.getProcessCode() +" | "+ info.getInstitutionCode() +" | "+ info.getBizCode() +" | "+ info.getStartTime() +" | "+ info.getEndTime() +"  ==> 요구수신 최초 수행, Job_Queue 에 추가예정.");
				//	alist.add(info);

				//요구수신 수행이 성공적으로 완료된 경우, 재처리 queue에서 삭제
				//} 
				if (recvFileEndCnt > 0) {
					logger.info("[요구수신 재처리  스케쥴러]    * 요구수신 재처리 스케쥴정보 ["+ cnt +"]: "+ info.getScheduleCode() +" | "+ info.getProcessCode() +" | "+ info.getInstitutionCode() +" | "+ info.getBizCode() +" | "+ info.getStartTime() +" | "+ info.getEndTime() +"  ==> 요구수신 파일 수신이 이미 완료되었음.");
					
					deletelist.add(info);

				//요구수신 수행이 실패한 경우, 재시도 회수를 체크하여 재수행
				} else if (recvFileFailCnt > 0) {
					SimpleDateFormat sdf  = new SimpleDateFormat("yyyyMMddHHmmssSSS");
					SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
					long latestTime  = sdf.parse(recentExecTime).getTime();
					Date currDate    = new Date();
					long currTime    = currDate.getTime();
					long diffSeconds = (currTime - latestTime) / 1000;
					Date nextDate    = new Date(latestTime + (info.getRecvRetrySecs() * 1000));

					//해당 스케쥴정보의 요구수신 재시도 여부가 설정되지 않은 경우, 요구수신 작업 수행 안함
					if (info.getRecvRetryFlag().equals("0")) {
						logger.info("[요구수신 재처리  스케쥴러]    * 요구수신 재처리  스케쥴정보 ["+ cnt +"]: "+ info.getScheduleCode() +" | "+ info.getProcessCode() +" | "+ info.getInstitutionCode() +" | "+ info.getBizCode() +" | "+ info.getStartTime() +" | "+ info.getEndTime() +"  ==> 요구수신 재시도가 설정되지 않았음. (미완료 작업건수: "+ info.getRecvFailCnt() +")");

					//해당 스케쥴정보의 요구수신 재시도 회수를 초과한 경우, 요구수신 작업 수행 안함
					//info.getRecvRetryCnt() != 0 조건은 재시도 반복회수가 0인 경우는 무한 반복하게 하기 위함
					} else if (info.getRecvRetryCnt() > 0 && (info.getRecvFailCnt()-1) >= info.getRecvRetryCnt()) {
						logger.info("[요구수신 재처리  스케쥴러]    * 요구수신 재처리  스케쥴정보 ["+ cnt +"]: "+ info.getScheduleCode() +" | "+ info.getProcessCode() +" | "+ info.getInstitutionCode() +" | "+ info.getBizCode() +" | "+ info.getStartTime() +" | "+ info.getEndTime() +"  ==> 요구수신 재시도 회수만큼 수행하였으나 파일 수신 미완료. (재시도 회수: "+ info.getRecvRetryCnt() +")");
						deletelist.add(info);
						
					//해당 스케쥴정보의 요구수신 재시도 수행 간격에 따른 재시도 시간이 되지 않은 경우, 다음 Timer Event 시 다시 체크
					} else if (diffSeconds < info.getRecvRetrySecs()) {
						logger.info("[요구수신 재처리  스케쥴러]    * 요구수신 재처리  스케쥴정보 ["+ cnt +"]: "+ info.getScheduleCode() +" | "+ info.getProcessCode() +" | "+ info.getInstitutionCode() +" | "+ info.getBizCode() +" | "+ info.getStartTime() +" | "+ info.getEndTime() +"  ==> 요구수신 재시도 시간이 되지 않았음. (재시도 회수: "+ (info.getRecvFailCnt()-1) +"/"+ info.getRecvRetryCnt() +", 현재시간: "+ sdf1.format(currDate) +", 재시도 수행시간: "+ sdf1.format(nextDate) +")");

					//해당 스케쥴정보의 요구수신 재시도 설정 조건에 일치하는 경우, 요구수신 작업 수행 함
					} else {
						logger.info("[요구수신 재처리  스케쥴러]    * 요구수신 재처리  스케쥴정보 ["+ cnt +"]: "+ info.getScheduleCode() +" | "+ info.getProcessCode() +" | "+ info.getInstitutionCode() +" | "+ info.getBizCode() +" | "+ info.getStartTime() +" | "+ info.getEndTime() +"  ==> 요구수신 재시도 수행, Job_Queue 에 추가예정. (재시도 회수: "+ info.getRecvFailCnt() +"/"+ info.getRecvRetryCnt() +")");
						alist.add(info);
					}
				}
				cnt++;
			}
			
			if (deletelist != null && deletelist.size() > 0){
				logger.info("[요구수신 재처리  스케쥴러]    재처리 완료 건수  ["+ deletelist.size() +"] ");
				
				for (int i=0; i< deletelist.size(); i++){
					SchedulerMessageVO deleteInfo = (SchedulerMessageVO)deletelist.get(i);
					logger.info("[요구수신 재처리  스케쥴러]    재처리 대기큐 목록에서  삭제합니다. ["+ deleteInfo.getScheduleCode()+"]");
					this.prepareStatement(DELETE_RETRY_QUEUE); 		
					this.preparedStatement.setString(1,deleteInfo.getScheduleCode() );
					this.preparedStatement.setString(2,deleteInfo.getRePrcssStartYMS() );
					this.preparedStatement.executeUpdate();
				}
			}

			return alist;


		} catch (DAOException ex) {
			throw ex;
		} catch (Exception ex) {
			ex.printStackTrace();
			String errMsg = ExceptionUtil.getErrorCode(ex, "BECEAISSC025");
			throw new DAOException(errMsg);  //작업 대기목록 테이블에서 수행대상 작업 조회시 오류가 발생하였습니다.
		} finally {
			disconnect();
		}
	}
	
	//2008.09.22 by kscheon
	public void insertRertyQueue(com.eactive.eai.batch.doc.BatchDoc info)throws DAOException{
		
		int index = 0;
		int retValue = 0;
		
		try{
			this.connect(INSERT_RETRY_QUEUE);

			index = 1;
			
            this.preparedStatement.setString(index++, info.getEAIBatchMessage().getHeader().getEventScheduleID());
            this.preparedStatement.setString(index++, info.getEAIBatchMessage().getHeader().getScheduleCode());
           
			retValue = this.executeUpdate();
			//logger.debug("[요구송신 스케쥴러] ==> 배치 JOB QUEUE 테이블 INSERT 건수: "+ retValue);

			if (retValue == 0) throw new DAOException("BECEAISSC019");  //배치작업 스케쥴 대기정보 insert 건 수가 0 건입니다.

		} catch (DAOException ex) {
			throw ex;
		} catch (Exception ex) {
			String errMsg = ExceptionUtil.getErrorCode(ex, "BECEAISSC002");
			throw new DAOException(errMsg);	//배치작업 스케쥴 대기정보 등록시 오류가 발생하였습니다.
		} finally {
			disconnect();
		}
		
	}
	*/
	
	
	public SchedulerMessageVO getReqSendScheduleInfo(String scheduleId) throws DAOException {

		ResultSet rs = null;
//		int index    = 0;

        try {
            this.connect(SELECT_REQ_SEND_SCHEDULE_BY_SCHEDULEID);
			//logger.debug("SchedulerMessageDAO.getScheduleInfo() >>> 수행 SQL 문 : \n"+ SELECT_REQ_SEND_SCHEDULE_BY_SCHEDULEID);

            this.preparedStatement.setString(1, scheduleId     );	
            logger.debug("SchedulerMessageDAO.getReqSendScheduleInfo() >>> 바인드 : ["+ scheduleId   +"]");
 
            rs = executeQuery();

			SchedulerMessageVO info = null;
            if (rs.next()) {
                info = new SchedulerMessageVO();
                info.setScheduleCode   (StringUtil.nvlTrim(rs.getString("BjobMsgScheID"          ))); // 스케쥴 아이디
                info.setJobCode        (StringUtil.nvlTrim(rs.getString("BjobMsgDstcd"           ))); // Job 구분 코드
                info.setBizCode        (StringUtil.nvlTrim(rs.getString("BjobTranDstcdName"      ))); // 거래구분코드
                info.setStartTime      (StringUtil.nvlTrim(rs.getString("SndrcvStartHMS"         ))); // 송수신 시작 시간
                info.setEndTime        (StringUtil.nvlTrim(rs.getString("SndrcvEndHMS"           ))); // 송수신 종료 시간
                info.setProcessCode    (StringUtil.nvlTrim(rs.getString("BjobBzwkDstcd"          ))); // 업무구분 코드
                info.setProcessType    (StringUtil.nvlTrim(rs.getString("BjobPtrnDstcd"          ))); // 업무유형 구분
                info.setPriority	   (                   rs.getInt   ("MsgPrcssPrity"	         ));
                info.setInstitutionCode(StringUtil.nvlTrim(rs.getString("OsidInstiDstcd"         ))); // 대외기관 코드
                info.setRecvFailCnt    (                   rs.getInt   ("RecvFileFailCnt"        ));  // 요구송신실패 횟수
                info.setRecvRetryFlag  (StringUtil.nvlTrim(rs.getString("RqstRecvReTralUseYn"    ))); //재시도사용유무 설정
                info.setRecvRetrySecs  (                   rs.getInt   ("RqstRecvReTralIntvalTtm"));  //재시도 간격(초)
                info.setRecvRetryCnt   (                   rs.getInt   ("RqstRecvReTralCnt"      ));  //재시도 횟수 

            }
            return info;

 		} catch (DAOException ex) {
			throw ex;
        } catch(Exception e) {
			//String errMsg = ExceptionUtil.getErrorCode(e, "BECEAISSC001", new String[] {processCode, osidinstidstCode, bizCode});
        	String errMsg = (scheduleId +"] 에 해당하는 스케줄 정보를 조회하는데 오류가 발생했습니다. - "+e.getMessage());
			throw new DAOException(errMsg);	//해당 스케쥴 정보를 찾을 수 없습니다. (업무구분: %1, 대외기관: %2, 거래구분: %3)
        } finally {
            disconnect();
        }
    }
	
	
	//2009.8.14 by kscheon 실행큐에 실행중인 작업 조회
	public ArrayList<SchedulerMessageVO> getExecutJobList(String jobCode) throws DAOException {

		ResultSet rs = null;

		try {

			this.connect(SELECT_EXECUTING_JOB_FROM_PROCESSING);
			//logger.debug("SchedulerMessageDAO.getExecutableRecvScheduleList() >>> 수행 SQL 문 : \n"+ SchedulerMessageQuery.SELECT_EXECUTABLE_RECV_SCHEDULE_LIST);
			this.preparedStatement.setString(1, jobCode     );	
			rs = executeQuery();

			ArrayList<SchedulerMessageVO> alist = new ArrayList<SchedulerMessageVO>();
			while (rs.next()) {
				SchedulerMessageVO info = new SchedulerMessageVO();
				info.setProcessCode(rs.getString("BjobBzwkDstcd"));
				info.setPriority   (rs.getInt   ("MsgPrcssPrity"));
				
				alist.add(info);
			}
            return alist;

 		} catch (DAOException ex) {
			throw ex;
        } catch(Exception e) {
			
        	String errMsg = (" 실행큐 조회중에 오류가 발생했습니다. - "+e.getMessage());
			throw new DAOException(errMsg);	
        } finally {
            disconnect();
        }
		
	}
	
	private SchedulerMessageVO insertNewRecvSchedule( String processCode, String institutionCode, String jobCode)
	 throws DAOException {
		String id = null;
    	
		BatchJobInfoVO bjvo = DirInfoManager.getInstance().getFileInfoByDstcd(processCode, jobCode);
    	if ( bjvo == null ){
    		return null;
    	}
		String bjobMsgDstcd = bjvo.getMsgDstCode();
		
    	try {
			ResultSet rs = null;
            this.connect(GET_BJOBMSGSCHEID);

            this.preparedStatement.setString(1, "R");
            this.preparedStatement.setString(2, bjobMsgDstcd);
            this.preparedStatement.setString(3, bjobMsgDstcd);
            rs = executeQuery();
            if (rs.next()) {
                id = rs.getString(1);
            }else{
            	return null;
            }
		} catch (Exception e) {
			logger.error( e.getMessage(), e);
			return null;
        } finally {
            this.disconnect();
		}
        

        try {
            this.connect(ADD_JOB_SCH_INFO);
            this.preparedStatement.setString( 1, id             );
            this.preparedStatement.setString( 2, bjobMsgDstcd   );
            this.preparedStatement.setString( 3, "RR"           );
            this.preparedStatement.setString( 4, institutionCode);
            this.preparedStatement.setString( 5, "0000"         );
            this.preparedStatement.setString( 6, "2359"         );
            this.preparedStatement.setString( 7, "SYSTEM"        );
            this.preparedStatement.setString( 8, "0"            );
            this.preparedStatement.setString( 9, "0"            );
            this.preparedStatement.setString(10, "0"            );
            this.preparedStatement.setInt   (11, 0              );
            this.preparedStatement.setInt   (12, 0              );
            this.preparedStatement.setString(13, "0"            );
            this.preparedStatement.setString(14, "0"            );
            this.preparedStatement.setString(15, "0"            );
            this.preparedStatement.setString(16, "SYSTEM"       );
            this.preparedStatement.setString(17, "SYSTEM"       );
            executeUpdate();
            SchedulerMessageVO     info = new SchedulerMessageVO();
            info.setScheduleCode   (id);              // 스케쥴 아이디
            info.setJobCode        (bjobMsgDstcd);    // Job 구분 코드
            info.setBizCode        (jobCode);         // 거래구분코드
            info.setStartTime      ("0000");          // 송수신 시작 시간
            info.setEndTime        ("2359");          // 송수신 종료 시간
            info.setProcessCode    (processCode);     // 업무구분 코드
            info.setProcessType    ("RR");            // 업무유형 구분
            info.setInstitutionCode(institutionCode); // 대외기관 코드
            info.setPriority       (999);             // 메시지 처리 우선 순위
            info.setHolyProcessGb  ("0");             // 공휴일처리구분
            info.setStartDelayDays (0); 
            info.setEndDelayDays   (0); 
            return info;
        } catch (Exception e) {
        	logger.error( e.getMessage(), e);
            throw new DAOException(
                ExceptionUtil.getErrorCode(e, "BECEAIUSC008"));
        } finally {
            this.disconnect();
        }
	}
	
    /**
     * 2009.11.24 거래로그 화면에서 재전송을 실행하기 위해 데이터 조회(RTS에서 Framework 로 이동 )
     */
    public JobMasterLogVO getJobLogByKey(String uuid,String subUuid) throws DAOException {
    	
            
    	try{
			this.connect(SELECT_LOG_MASTER_BY_KEYS);
		
			int index = 1;
			this.preparedStatement.setString(index++, uuid    ); //logger.debug(">>> 바인드("+(index-1)+") : ["+ uuid +"]");
			this.preparedStatement.setString(index++, subUuid ); //logger.debug(">>> 바인드("+(index-1)+") : ["+ subUuid +"]");
			
			ResultSet rs = executeQuery();
			
		
			JobMasterLogVO info = null;
			while (rs.next()) {
			
				info = new JobMasterLogVO();
				info.setUuid           (StringUtil.nvlTrim(rs.getString("BjobDmndMsgID"         )));
				info.setSubUuid        (StringUtil.nvlTrim(rs.getString("BjobDmndSubMsgID"      )));
				info.setRetryCount     (                   rs.getInt   ("TelgmReTralCnt"        ) );
				info.setScheduleCode   (StringUtil.nvlTrim(rs.getString("BjobMsgScheID"         )));
				info.setMsgCreateTime  (StringUtil.nvlTrim(rs.getString("BjobDmndMsgCretnHMS"   )));
				info.setProcessCode    (StringUtil.nvlTrim(rs.getString("BjobBzwkDstcd"         )));
				info.setProcessName    (StringUtil.nvlTrim(rs.getString("BjobBzwkName"          )));
				info.setOrganCode      (StringUtil.nvlTrim(rs.getString("OsidInstiDstcd"        )));
				info.setOrganName      (StringUtil.nvlTrim(rs.getString("OsidInstiName"         )));
				info.setProcessType    (StringUtil.nvlTrim(rs.getString("BjobPtrnDstcd"         )));
				info.setMsgSenderId    (StringUtil.nvlTrim(rs.getString("MsgSndrID"             )));
				info.setMsgSenderName  (StringUtil.nvlTrim(rs.getString("MsgSndrName"           )));
				info.setSystemConnCode (StringUtil.nvlTrim(rs.getString("SysLnkgDstcd"          )));
				info.setRemoteServerIp (StringUtil.nvlTrim(rs.getString("LnkgIPInfoName"        )));
				info.setRuleCode       (StringUtil.nvlTrim(rs.getString("FlowRuleCd"            )));
				info.setWeblogicName   (StringUtil.nvlTrim(rs.getString("EAISevrInstncName"     )));
				info.setStartTime      (StringUtil.nvlTrim(rs.getString("TranStartHMS"          )));
				info.setEndTime        (StringUtil.nvlTrim(rs.getString("TranEndHMS"            )));
				info.setStatus         (StringUtil.nvlTrim(rs.getString("TranPrcssDstcd"        )));
				info.setErrMsg         (StringUtil.nvlTrim(rs.getString("EAIObstclOccurCausCtnt")));
				info.setErrHandleId    (StringUtil.nvlTrim(rs.getString("ObstclPrcsrID"         )));
				info.setErrHandleTime  (StringUtil.nvlTrim(rs.getString("ObstclPrcssHMS"        )));
				
			}

	        return info;
        } catch (DAOException ex) {
			throw ex;
        } catch (Exception e) {
			String errMsg = ExceptionUtil.getErrorCode(e, "UNDEFINEDCD", new String[] {});
			throw new DAOException(errMsg);
        } finally {
            disconnect();
        }
    }

    public JobFileTransferVO getFileLogList(String uuid, String subUuid, String fileName) throws DAOException {
    	try {

			this.connect(SELECT_FILE_LOG_BY_KEYS);
			logger.debug(">>> 일괄작업 Stage 로그 검색 SQL : \n"+ SELECT_FILE_LOG_BY_KEYS);

			int index = 1;
            this.preparedStatement.setString(index++, uuid     ); logger.debug(">>> 바인드("+(index-1)+") : ["+ uuid +"]"    );
            this.preparedStatement.setString(index++, subUuid  ); logger.debug(">>> 바인드("+(index-1)+") : ["+ subUuid +"]" );
            this.preparedStatement.setString(index++, fileName ); logger.debug(">>> 바인드("+(index-1)+") : ["+ fileName +"]");

            ResultSet rs = executeQuery();

			if (rs.next()) {

				JobFileTransferVO fileInfo =  new JobFileTransferVO();
				fileInfo.setUuid              (uuid);
				fileInfo.setSubUuid           (subUuid);
				fileInfo.setFileName          (fileName);
				fileInfo.setFilePath          (StringUtil.nvlTrim(rs.getString("RqstRecvFileStorgDirName")));
				fileInfo.setRenamedFileName   (StringUtil.nvlTrim(rs.getString("BkupSndrcvFileName"      )));
				fileInfo.setBjobTranDstcdName (rs.getString("BjobTranDstcdName"                           ));
				fileInfo.setHdrInfoName       (rs.getString("HdrInfoName"                                 ));
				return fileInfo;
            }
			return null;
        } catch (DAOException ex) {
			throw ex;
        } catch (Exception e) {
			String errMsg = ExceptionUtil.getErrorCode(e, "UNDEFINEDCD", new String[] {});
			throw new DAOException(errMsg);
        } finally {
            disconnect();
        }
    }

	public ArrayList<JobFileTransferVO> getScheduledJobList(ArrayList<String> basisList ) throws DAOException {

		ResultSet rs = null;

		try {

			String query = SELECT_SCHEDULE_BASIS;
			if ( basisList.size()>0 ){
				query = query + "AND RTRIM( SndrcvCyclTypName ) IN ( '";
				query = query + basisList.get(0) + "'";
				for ( int inx=1; inx < basisList.size(); inx++ ){
					query = query + ", '" + basisList.get(inx) + "'";
				}
				query = query + ")";
			}
			
			this.connect(query);
			//logger.debug("SchedulerMessageDAO.getScheduledJobList() >>> 수행 SQL 문 : \n"+ query);
			rs = executeQuery();

			ArrayList<JobFileTransferVO> alist = new ArrayList<JobFileTransferVO>();
			while (rs.next()) {
				JobFileTransferVO schedule = new JobFileTransferVO();
				schedule.setBjobMsgScheID    (rs.getString("BjobMsgScheID"    ));
				schedule.setBjobBzwkDstcd    (rs.getString("BjobBzwkDstcd"    ));
				schedule.setBjobBzwkName     (rs.getString("BjobBzwkName"     ));
				schedule.setOsidInstiDstcd   (rs.getString("OsidInstiDstcd"   ));
				schedule.setOsidInstiName    (rs.getString("OsidInstiName"    ));
				schedule.setBjobTranDstcdName(rs.getString("BjobTranDstcdName"));
				schedule.setBjobMsgDstcd     (rs.getString("BjobMsgDstcd"     ));
				schedule.setSendRecvYn       (rs.getString("SendRecvYn"       ));
				schedule.setSndrcvCyclTypName(rs.getString("SndrcvCyclTypName"));
				schedule.setUapplCd          (rs.getString("UapplCd"          ));
				schedule.setThisMsgChrgIDs   (rs.getString("ThisMsgChrgIDs"   ));
				schedule.setSndrcvStartHMS   (rs.getString("SndrcvStartHMS"   ).trim());
				schedule.setSndrcvEndHMS     (rs.getString("SndrcvEndHMS"     ).trim());
				
				alist.add(schedule);
			}
            return alist;

 		} catch (DAOException ex) {
			throw ex;
        } catch(Exception e) {
			
        	String errMsg = ("스케쥴 리스트  조회 중에 오류가 발생했습니다. - "+e.getMessage());
			throw new DAOException(errMsg);	
        } finally {
            disconnect();
        }
	}    

	public ArrayList<JobProcessingVO> getProcessinbgJobList() throws DAOException {

		ResultSet rs = null;

		try {

			this.connect(SELECT_ALL_JOBS_FROM_PROCESSING);
			//logger.debug("SchedulerMessageDAO.getExecutableJobList() >>> 수행 SQL 문 : \n"+ SchedulerMessageQuery.SELECT_EXECUTABLE_JOB_FROM_QUEUE);

			rs = executeQuery();

			ArrayList<JobProcessingVO> alist = new ArrayList<JobProcessingVO>();
			while (rs.next()) {
				JobProcessingVO vo = new JobProcessingVO();
				vo.setBjobDmndMsgID         (StringUtil.nvlTrim(rs.getString("BjobDmndMsgID"      )));
				vo.setBjobDmndSubMsgID      (StringUtil.nvlTrim(rs.getString("BjobDmndSubMsgID"   )));
				vo.setTelgmReTralCnt        (rs.getInt("TelgmReTralCnt"                            ));
				vo.setSysLnkgDstcd          (StringUtil.nvlTrim(rs.getString("SysLnkgDstcd"       )));
				vo.setBjobDmndMsgCretnHMS   (StringUtil.nvlTrim(rs.getString("BjobDmndMsgCretnHMS")));
				vo.setBjobMsgScheID         (StringUtil.nvlTrim(rs.getString("BjobMsgScheID"      )));
				vo.setBjobBzwkDstcd         (StringUtil.nvlTrim(rs.getString("BjobBzwkDstcd"      )));
				vo.setOsidInstiDstcd        (StringUtil.nvlTrim(rs.getString("OsidInstiDstcd"     )));
				vo.setBjobPtrnDstcd         (StringUtil.nvlTrim(rs.getString("BjobPtrnDstcd"      )));
				vo.setSndrcvStartHMS        (StringUtil.nvlTrim(rs.getString("SndrcvStartHMS"     )));
				vo.setSndrcvEndHMS          (StringUtil.nvlTrim(rs.getString("SndrcvEndHMS"       )));
				vo.setSndrcvFileDirName     (StringUtil.nvlTrim(rs.getString("SndrcvFileDirName"  )));
				vo.setSndrcvFileName        (StringUtil.nvlTrim(rs.getString("SndrcvFileName"     )));
				vo.setBkupSndrcvFileName    (StringUtil.nvlTrim(rs.getString("BkupSndrcvFileName" )));
				vo.setMsgPrcssPrity         (rs.getInt("MsgPrcssPrity"                             ));
				vo.setThisMsgAmndrID        (StringUtil.nvlTrim(rs.getString("ThisMsgAmndrID"     )));
				vo.setThisMsgAmndHMS        (StringUtil.nvlTrim(rs.getString("ThisMsgAmndHMS"     )));
				vo.setMsgQueEtractDmndHMS   (StringUtil.nvlTrim(rs.getString("MsgQueEtractDmndHMS")));
				vo.setMsgPrcssStusCd        (StringUtil.nvlTrim(rs.getString("MsgPrcssStusCd"     )));
				alist.add(vo);
			}

			return alist;


		} catch (DAOException ex) {
			throw ex;
		} catch (Exception ex) {
			String errMsg = ExceptionUtil.getErrorCode(ex, "BECEAISSC020");
			throw new DAOException(errMsg);  //배치작업 스케쥴 대기목록 테이블에서 수행대상 작업 조회시 오류가 발생하였습니다.
		} finally {
			disconnect();
		}
	}
}
