package com.eactive.eai.inbound.remote;

import com.eactive.eai.common.dao.Keys;

public interface RemoteServerQuery
{
    //EAI <-> REMOTE 파일 자동 전송시 업무구분에 의한 Remote 서버정보 조회
	public static final String SELECT_REMOTE_SERVER_BY_PATH =
		  "SELECT RmtSevrID             , \n"
		+ "       RmtSevrName           , \n"
		+ "       BjobBzwkDstcd         , \n"
		+ "       RmtSevrIP             , \n"
		+ "       RmtSevrNDMPortNoName  , \n"
		+ "       RmtSevrFTPPortNoName  , \n"
		+ "       RmtSevrFTPUID         , \n"
		+ "       RmtSevrFTPUserPwdName , \n"
        + "       RmtSevrRootDirName    , \n"
		+ "       RmtFileEvntCpyDstcd   , \n"
		+ "       ThisMsgUseYn          , \n"
		+ "       ThisMsgRegsntID       , \n"
		+ "       ThisMsgRegiHMS        , \n"
		+ "       ThisMsgAmndrID        , \n"
		+ "       ThisMsgAmndHMS          \n" 
		+ "FROM   " + Keys.TABLE_OWNER + "TSEAIBU01 \n"
		//+ "WHERE  ? LIKE RmtSevrRootDirName || '%' \n"
//		+ "WHERE  ? LIKE '%' || BjobBzwkDstcd || '%' \n"
//		+ "AND    ThisMsgUseYn = '1' --사용중인 것만 조회";
	+ "WHERE ThisMsgUseYn = '1' --사용중인 것만 조회";

    //REMOTE 서버 목록 조회
	public static final String SEARCH_REMOTE_SERVER =
		  "SELECT A.RmtSevrID             , \n"
		+ "       A.RmtSevrName           , \n"
		+ "       A.BjobBzwkDstcd         , \n"
		+ "       B.BjobBzwkName          , \n"
		+ "       A.RmtSevrIP             , \n"
		+ "       A.RmtSevrNDMPortNoName  , \n"
		+ "       A.RmtSevrFTPPortNoName  , \n"
		+ "       A.RmtSevrFTPUID         , \n"
		+ "       A.RmtSevrFTPUserPwdName , \n"
		+ "       A.RmtSevrRootDirName    , \n"
		+ "       A.RmtFileEvntCpyDstcd   , \n"
		+ "       A.ThisMsgUseYn          , \n"
		+ "       A.ThisMsgRegsntID       , \n"
		+ "       A.ThisMsgRegiHMS        , \n"
		+ "       A.ThisMsgAmndrID        , \n"
		+ "       A.ThisMsgAmndHMS          \n"
		+ "FROM   " + Keys.TABLE_OWNER + "TSEAIBU01          A \n"
//		+ "       " + Keys.TABLE_OWNER + "TSEAIBJ02          B \n"
        + "       LEFT OUTER JOIN " + Keys.TABLE_OWNER + "TSEAIBJ02          B \n"
//		+ "WHERE  A.BjobBzwkDstcd      = B.BjobBzwkDstcd    (+) \n"
        + "on  A.BjobBzwkDstcd      = B.BjobBzwkDstcd    \n"
//		+ "AND    A.BjobBzwkDstcd      LIKE ? || '%' \n"
        + "WHERE    A.BjobBzwkDstcd      LIKE ? || '%' \n";
		//+ " AND    ( ( ? = 'SERVER_NAME'    AND  A.RmtSevrName   LIKE '%' || ? || '%' ) OR \n"
		//+ "         ( ? = 'SERVER_ID'      AND  A.RmtSevrID     LIKE        ? || '%' ) OR \n"
		//+ "         ( ? = 'SERVER_IP'      AND  A.RmtSevrIP     LIKE '%' || ? || '%' ) ) \n"
		//+ "ORDER BY A.RmtSevrID ";

    //REMOTE 서버 등록
    public static final String INSERT_REMOTE_SERVER =
		  "INSERT INTO " + Keys.TABLE_OWNER + "TSEAIBU01 ( \n"
		+ "       RmtSevrID             , \n"
		+ "       RmtSevrName           , BjobBzwkDstcd     , RmtSevrIP               , RmtSevrNDMPortNoName   , \n"
		+ "       RmtSevrFTPPortNoName  , RmtSevrFTPUID     , RmtSevrFTPUserPwdName   , RmtSevrRootDirName     , \n"
		+ "       RmtFileEvntCpyDstcd   , ThisMsgUseYn      , ThisMsgRegsntID         , ThisMsgRegiHMS         , \n"
		+ "       ThisMsgAmndrID        , ThisMsgAmndHMS     ) \n"
//		+ "SELECT ? || 'RS' || NVL( TO_CHAR( SUBSTR(MAX(RmtSevrID),8,2) + 1, 'FM00'), '01'), \n"
//        + "SELECT ? || 'RS' || VALUE( TO_CHAR(INT(SUBSTR(MAX(RmtSevrID),8,2)) + 1, '00'), '01'), \n"
        + "SELECT cast(? as CHARACTER (5))  || 'RS' || VALUE( TO_CHAR(INT(SUBSTR(MAX(RmtSevrID),8,2)) + 1, '00'), '01'), \n"
		+ "       cast (? as VARCHAR(100))                   , cast(? as CHARACTER (5))                   , cast (? as VARCHAR(15))                   ,  \n"
		+ "       cast (? as VARCHAR(10))                   , cast (? as VARCHAR(10))                   , cast (? as VARCHAR(40))                  ,  cast (? as VARCHAR(40))                  , \n"
		+ "       cast (? as VARCHAR(300))                   , cast (? as CHARACTER(3))                   , cast (? as CHARACTER(1))                   ,  \n"
		+ "       cast (? as VARCHAR(40))                   , cast (? as CHARACTER(16))                   ,  cast (? as VARCHAR(40)) 					,\n"
		+ "       cast (? as CHARACTER(16))                \n"   
		+ "FROM   " + Keys.TABLE_OWNER + "TSEAIBU01 \n"
		+ "WHERE  BjobBzwkDstcd = ?";

    //REMOTE 서버 변경
	public static final String UPDATE_REMOTE_SERVER =
		  "UPDATE " + Keys.TABLE_OWNER + "TSEAIBU01 \n"
		+ "SET    RmtSevrName           = ?, \n"
		+ "       BjobBzwkDstcd         = ?, \n"
		+ "       RmtSevrIP             = ?, \n"
		+ "       RmtSevrNDMPortNoName  = ?, \n"
		+ "       RmtSevrFTPPortNoName  = ?, \n"
		+ "       RmtSevrFTPUID         = ?, \n"
		+ "       RmtSevrFTPUserPwdName = ?, \n"
		+ "       RmtSevrRootDirName    = ?, \n"
		+ "       RmtFileEvntCpyDstcd   = ?, \n"
		+ "       ThisMsgUseYn          = ?, \n"
		+ "       ThisMsgAmndrID        = ?, \n"
		+ "       ThisMsgAmndHMS        = ?  \n"
		+ "WHERE  RmtSevrID             = ?";

    //REMOTE 서버 삭제
	public static final String DELETE_REMOTE_SERVER =
		  "DELETE FROM " + Keys.TABLE_OWNER + "TSEAIBU01 \n"
		+ "WHERE  RmtSevrID   = ?";

}