<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="Adapter">
  <statement id="selectChgAdapterList" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
     SELECT 
   	 	  @NO := @NO + 1  AS "ROWNUM" ,
   	 	 AD01.ADPTRNICKNAME AS "ADPTRNICKNAME",
    	 AD01.ADPTRBZWKGROUPNAME AS "ADPTRBZWKGROUPNAME", 			         
         AD01.EAIBZWKDSTCD AS "EAIBZWKDSTCD",  
       	 CASE WHEN 
       	 		AD01.ADPTRUSEYN IS NULL 
       	 			THEN '0' 
       	 		ELSE 
       	 			AD01.ADPTRUSEYN 
       	 END AS "ADPTRUSEYN",   
         AD01.ADPTRBZWKGROUPDESC AS "ADPTRBZWKGROUPDESC", 
         AD01.OSIDINSTIBZWKRSEMPNAME AS "OSIDINSTIBZWKRSEMPNAME",
         AD01.OSIDINSTITELNO AS "OSIDINSTITELNO",
         AD01.EAIBZWKDSTCD AS "EAIBZWKDSTCD",
         CASE WHEN RM06.EAIBZWKDSTCD IS NULL THEN 'N' ELSE 'Y' END AS "AUTHCHK"
	FROM $schemaId$.TSEAIAD01 AD01 INNER JOIN $schemaId$.TSEAIRM06 RM06
	 ON (AD01.EAIBZWKDSTCD = RM06.EAIBZWKDSTCD AND RM06.USERID = #loginId#)
	 , (SELECT @NO := 0) R
	WHERE AD01.ADPTRCD IN ('NET', 'SOC') 
	AND NOT AD01.ADPTRNICKNAME LIKE '%000'
	 AND AD01.TESTMASTERYN != '1'  
	<!-- KEYWORD -->
	<isNotEmpty prepend="AND" property="searchAdptrBzwkGroupName">
	      UPPER(AD01.ADPTRBZWKGROUPNAME) LIKE CONCAT('%', UPPER(#searchAdptrBzwkGroupName#), '%')
	</isNotEmpty>
	<isNotEmpty prepend="AND" property="searchAdptrBzwkGroupDesc">
	      UPPER(AD01.ADPTRBZWKGROUPDESC) LIKE CONCAT('%', UPPER(#searchAdptrBzwkGroupDesc#), '%')
	</isNotEmpty>
	<isNotEmpty prepend="AND" property="searchEaibzwkdstcd">
	      UPPER(AD01.EAIBZWKDSTCD) LIKE CONCAT('%', UPPER(#searchEaibzwkdstcd#), '%')
	</isNotEmpty>
   </statement>  
  <statement id="selectListCount" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
		SELECT COUNT(*) CNT
		FROM   $schemaId$.TSEAIAD01
		WHERE  EAIBZWKDSTCD IN ( select EAIBZWKDSTCD from $schemaId$.tseairm06 where USERID = #loginId#)
			<!-- IOFLAG -->
			<isNotEmpty prepend="AND" property="searchAdptrIoDstCd">
			      ADPTRIODSTCD = #searchAdptrIoDstCd#
			</isNotEmpty>
			<!-- STDFLAG -->
			<isNotEmpty prepend="AND" property="searchAdptrMsgPtrnCd">
			      ADPTRMSGPTRNCD = #searchAdptrMsgPtrnCd#
			</isNotEmpty>
			
			<!-- USEDFLAG -->
			<isNotEmpty prepend="AND" property="searchAdptrUseYn">
			      ADPTRUSEYN = #searchAdptrUseYn#
			</isNotEmpty>
			
			<!-- KEYWORD -->
			<isNotEmpty prepend="AND" property="searchAdptrBzwkGroupName">
			      UPPER(ADPTRBZWKGROUPNAME) LIKE CONCAT( '%' , UPPER(#searchAdptrBzwkGroupName#) , '%' )
			</isNotEmpty>
			
			<!-- DESCRIPTION -->
			<isNotEmpty prepend="AND" property="searchAdptrBzwkGroupDesc">
			     UPPER(ADPTRBZWKGROUPDESC) LIKE CONCAT( '%' , UPPER(#searchAdptrBzwkGroupDesc#) , '%' )
			</isNotEmpty>
			
			<isNotEmpty prepend="AND" property="searchKesauseyn">
				  KESAUSEYN = #searchKesauseyn#
			</isNotEmpty>
			
			<isNotEmpty prepend="AND" property="searchTestmasteryn">
			      TESTMASTERYN = #searchTestmasteryn#
			</isNotEmpty>
			
			<isNotEmpty prepend="AND" property="searchAdptrnickname">
				 UPPER(ADPTRNICKNAME) LIKE CONCAT( '%' , UPPER(#searchAdptrnickname#) , '%' )
			</isNotEmpty>
			<isNotEmpty prepend="AND" property="searchAdptrCd">
			      ADPTRCD = #searchAdptrCd#
			</isNotEmpty>
			<isNotEmpty prepend="AND" property="searchEaiBzwkDstcd">
			      EAIBZWKDSTCD = #searchEaiBzwkDstcd# 
			</isNotEmpty>
			<isNotEmpty prepend="AND" property="searchEaiSevrDstcd">
			      EAISEVRDSTCD = #searchEaiSevrDstcd#
			</isNotEmpty>
			<isNotEmpty prepend="AND" property="searchAdptrMsgDstCd">
			      ADPTRMSGDSTCD = #searchAdptrMsgDstCd#
			</isNotEmpty>
			<isNotEmpty prepend="AND" property="searchDrAdptrYn">
			   	 DRADPTRYN = #searchDrAdptrYn#
			</isNotEmpty>
  </statement>
  
  <statement id="selectList" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
		SELECT ROWNO AS "ROWNO"
		     , ADPTRBZWKGROUPNAME AS "ADPTRBZWKGROUPNAME"
		     , ADPTRMSGPTRNCD     AS "ADPTRMSGPTRNCD"
		     , EAIBZWKDSTCD       AS "EAIBZWKDSTCD"
		     , ADPTRCD            AS "ADPTRCD"
		     , ADPTRMSGDSTCD      AS "ADPTRMSGDSTCD"
		     , ADPTRIODSTCD       AS "ADPTRIODSTCD"
		     , REFCLSNAME         AS "REFCLSNAME"
		     , SNDRCVHMSLOGYN     AS "SNDRCVHMSLOGYN"
		     , ADPTRUSEYN         AS "ADPTRUSEYN"
		     , SPCFCLUUSEYN       AS "SPCFCLUUSEYN"
		     , ADPTRBZWKGROUPDESC AS "ADPTRBZWKGROUPDESC"
		     , OSIDINSTINO        AS "OSIDINSTINO"
		     , KESAUSEYN		  AS "KESAUSEYN"
		     , TESTMASTERYN 	  AS "TESTMASTERYN"
			 , ADPTRNICKNAME	  AS "ADPTRNICKNAME"
			 , EAISEVRDSTCD		  AS "EAISEVRDSTCD"
			 , DRADPTRYN		  AS "DRADPTRYN"
			 , BIDINTERFACE		  AS "BIDINTERFACE"
		FROM ( 
          SELECT 	@NO := @NO + 1 AS ROWNO, 
          			ADPTRBZWKGROUPNAME,
			         ADPTRMSGPTRNCD, 
			         EAIBZWKDSTCD, ADPTRCD,  ADPTRMSGDSTCD, 
			         CASE WHEN ADPTRIODSTCD = 'I' THEN 'INBOUND'
			              WHEN ADPTRIODSTCD = 'O' THEN 'OUTBOUND'
			              ELSE ADPTRIODSTCD END ADPTRIODSTCD, 
			         REFCLSNAME, SNDRCVHMSLOGYN, ADPTRUSEYN, 
			         SPCFCLUUSEYN, ADPTRBZWKGROUPDESC,
			         OSIDINSTINO ,KESAUSEYN ,TESTMASTERYN ,ADPTRNICKNAME ,EAISEVRDSTCD ,DRADPTRYN, BIDINTERFACE
				FROM (SELECT  * FROM $schemaId$.TSEAIAD01 		
				   <isNotEmpty prepend="" property="sortName" >
				   	  ORDER BY $sortName$ $sortOrder$  
				   </isNotEmpty> 
				     ) T ,  (SELECT @NO := 0) R 
			   WHERE EAIBZWKDSTCD IN ( select EAIBZWKDSTCD from $schemaId$.TSEAIRM06 where USERID = #loginId#)
				<!-- IOFLAG -->
			<isNotEmpty prepend="AND" property="searchAdptrIoDstCd">
			      ADPTRIODSTCD = #searchAdptrIoDstCd#
			</isNotEmpty>
			<!-- STDFLAG -->
			<isNotEmpty prepend="AND" property="searchAdptrMsgPtrnCd">
			      ADPTRMSGPTRNCD = #searchAdptrMsgPtrnCd#
			</isNotEmpty>
			
			<!-- USEDFLAG -->
			<isNotEmpty prepend="AND" property="searchAdptrUseYn">
			      ADPTRUSEYN = #searchAdptrUseYn#
			</isNotEmpty>
			
			<!-- KEYWORD -->
			<isNotEmpty prepend="AND" property="searchAdptrBzwkGroupName">
			      UPPER(ADPTRBZWKGROUPNAME) LIKE CONCAT( '%' , UPPER(#searchAdptrBzwkGroupName#) , '%' )
			</isNotEmpty>
			
			<!-- DESCRIPTION -->
			<isNotEmpty prepend="AND" property="searchAdptrBzwkGroupDesc">
			     UPPER(ADPTRBZWKGROUPDESC) LIKE CONCAT( '%' , UPPER(#searchAdptrBzwkGroupDesc#) , '%' )
			</isNotEmpty>
			
			<isNotEmpty prepend="AND" property="searchKesauseyn">
				  KESAUSEYN = #searchKesauseyn#
			</isNotEmpty>
			
			<isNotEmpty prepend="AND" property="searchTestmasteryn">
			      TESTMASTERYN = #searchTestmasteryn#
			</isNotEmpty>
			
			<isNotEmpty prepend="AND" property="searchAdptrnickname">
				 UPPER(ADPTRNICKNAME) LIKE CONCAT( '%' , UPPER(#searchAdptrnickname#) , '%' )
			</isNotEmpty>
			<isNotEmpty prepend="AND" property="searchAdptrCd">
			      ADPTRCD = #searchAdptrCd#
			</isNotEmpty>
			<isNotEmpty prepend="AND" property="searchEaiBzwkDstcd">
			      EAIBZWKDSTCD = #searchEaiBzwkDstcd# 
			</isNotEmpty>
			<isNotEmpty prepend="AND" property="searchEaiSevrDstcd">
			      EAISEVRDSTCD = #searchEaiSevrDstcd#
			</isNotEmpty>
			<isNotEmpty prepend="AND" property="searchAdptrMsgDstCd">
			      ADPTRMSGDSTCD = #searchAdptrMsgDstCd#
			</isNotEmpty>
			<isNotEmpty prepend="AND" property="searchDrAdptrYn">
			   	 DRADPTRYN = #searchDrAdptrYn#
			</isNotEmpty>
		) TMP1
		WHERE ROWNO BETWEEN #startNum# AND #endNum#
  </statement>  
  
  <statement id="selectListForItsm" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
	SELECT
		CM01.APPLCD APPLCD,
		CM01.BZWKDSTICNAME BZWKDSTICNAME,
		AD01.ADPTRBZWKGROUPNAME,
		AD01.ADPTRMSGPTRNCD,
		AD01.EAIBZWKDSTCD,
		AD01.ADPTRCD,
		AD01.ADPTRIODSTCD,
		AD01.ADPTRUSEYN,
		AD01.ADPTRBZWKGROUPDESC,
		AD01.ADPTRNICKNAME,
		AD01.ADPTRINSTICODE
	FROM
		$schemaId$.TSEAIAD01 AD01
	LEFT OUTER JOIN
		$schemaId$.TSEAICM01 CM01
	ON
		TRIM(CM01.APPLCD) = SUBSTR(AD01.ADPTRBZWKGROUPNAME, 2, 3)
	WHERE
		AD01.ADPTRBZWKGROUPNAME IN ($adapterList$)
  </statement>  
  
  <statement id="selectListToExcel" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
		SELECT $headersStr$
		FROM ( 
          SELECT  ADPTRBZWKGROUPNAME, 
			         ADPTRMSGPTRNCD, 
			         EAIBZWKDSTCD, ADPTRCD,  ADPTRMSGDSTCD, 
			         CASE WHEN ADPTRIODSTCD = 'I' THEN 'INBOUND'
			              WHEN ADPTRIODSTCD = 'O' THEN 'OUTBOUND'
			              ELSE ADPTRIODSTCD END ADPTRIODSTCD, 
			         REFCLSNAME, SNDRCVHMSLOGYN, ADPTRUSEYN, 
			         SPCFCLUUSEYN, ADPTRBZWKGROUPDESC,
			         OSIDINSTINO ,KESAUSEYN ,TESTMASTERYN ,ADPTRNICKNAME , EAISEVRDSTCD ,DRADPTRYN
				FROM (SELECT  * FROM $schemaId$.TSEAIAD01
				ORDER BY ADPTRBZWKGROUPNAME 
				   <isNotEmpty prepend="" property="sortName" >
				   	  ORDER BY $sortName$ $sortOrder$  
				   </isNotEmpty> 
				     ) T 
			    WHERE EAIBZWKDSTCD IN ( select EAIBZWKDSTCD from $schemaId$.TSEAIRM06 where USERID = #loginId#) 
				<!-- IOFLAG -->
			<isNotEmpty prepend="AND" property="searchAdptrIoDstCd">
			      ADPTRIODSTCD = #searchAdptrIoDstCd#
			</isNotEmpty>
			<!-- STDFLAG -->
			<isNotEmpty prepend="AND" property="searchAdptrMsgPtrnCd">
			      ADPTRMSGPTRNCD = #searchAdptrMsgPtrnCd#
			</isNotEmpty>
			<!-- USEDFLAG -->
			<isNotEmpty prepend="AND" property="searchAdptrUseYn">
			      ADPTRUSEYN = #searchAdptrUseYn#
			</isNotEmpty>
			<!-- KEYWORD -->
			<isNotEmpty prepend="AND" property="searchAdptrBzwkGroupName">
			      UPPER(ADPTRBZWKGROUPNAME) LIKE CONCAT( '%' , UPPER(#searchAdptrBzwkGroupName#) , '%' )
			</isNotEmpty>
			<!-- DESCRIPTION -->
			<isNotEmpty prepend="AND" property="searchAdptrBzwkGroupDesc">
			     UPPER(ADPTRBZWKGROUPDESC) LIKE CONCAT( '%' , UPPER(#searchAdptrBzwkGroupDesc#) , '%' )
			</isNotEmpty>
			<isNotEmpty prepend="AND" property="searchKesauseyn">
				  KESAUSEYN = #searchKesauseyn#
			</isNotEmpty>
			<isNotEmpty prepend="AND" property="searchTestmasteryn">
			      TESTMASTERYN = #searchTestmasteryn#
			</isNotEmpty>
			<isNotEmpty prepend="AND" property="searchAdptrnickname">
				 UPPER(ADPTRNICKNAME) LIKE CONCAT( '%' , UPPER(#searchAdptrnickname#) , '%' )
			</isNotEmpty>
			<isNotEmpty prepend="AND" property="searchAdptrCd">
			      ADPTRCD = #searchAdptrCd#
			</isNotEmpty>
			<isNotEmpty prepend="AND" property="searchEaiBzwkDstcd">
			      EAIBZWKDSTCD = #searchEaiBzwkDstcd# 
			</isNotEmpty>
			<isNotEmpty prepend="AND" property="searchEaiSevrDstcd">
			      EAISEVRDSTCD = #searchEaiSevrDstcd#
			</isNotEmpty>
			<isNotEmpty prepend="AND" property="searchAdptrMsgDstCd">
			      ADPTRMSGDSTCD = #searchAdptrMsgDstCd#
			</isNotEmpty>
			<isNotEmpty prepend="AND" property="searchDrAdptrYn">
			   	 DRADPTRYN = #searchDrAdptrYn#
			</isNotEmpty>
		) TMP1
  </statement>  
  
  <statement id="selectDetail" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
     SELECT  ADPTRBZWKGROUPNAME 
			, ADPTRMSGPTRNCD	
			, EAIBZWKDSTCD		
			, ADPTRCD			
			, ADPTRMSGDSTCD		
			, ADPTRIODSTCD		
			, REFCLSNAME	
			, SNDRCVHMSLOGYN	
			, ADPTRUSEYN		
			, SPCFCLUUSEYN		
			, ADPTRBZWKGROUPDESC	
			, OSIDINSTINO			
			, EAISEVRDSTCD		
			, EAILASTAMNDYMS	
			, OSIDINSTIYN			
			, OSIDINSTIBZWKRSEMPNAME	
			, OSIDINSTITELNO	
			, MONIUSEYN			
			, MONICNDNCTNT		
			, KESAUSEYN			
			, TESTMASTERYN 		
			, ADPTRNICKNAME		
			, COMPANYCODEDATA	
			, ADPTRINSTICODE    
			, CIRNUMBER	
			, DRADPTRYN	
			, BIDINTERFACE	
			, MSGENCODE
		   FROM $schemaId$.TSEAIAD01
		  WHERE ADPTRBZWKGROUPNAME = #ADPTRBZWKGROUPNAME#
  </statement>
    
  <statement id="selectListCombo" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
	  SELECT ADPTRBZWKGROUPNAME 
	       , EAIBZWKDSTCD 
	       , ADPTRCD 
	       , ADPTRMSGPTRNCD 
	       , ADPTRMSGDSTCD 
	       , ADPTRIODSTCD 
	       , ADPTRBZWKGROUPDESC 
	  FROM $schemaId$.TSEAIAD01
	  <dynamic prepend="WHERE">
		<isNotEmpty prepend="AND" property="adptrUseYn">
		      ADPTRUSEYN = '1'
		</isNotEmpty>
		<isNotEmpty prepend="AND" property="asyncDstcd">
		      ADPTRBZWKGROUPNAME LIKE CONCAT( '%\_' , #asyncDstcd# , '%')
		</isNotEmpty>
		<isNotEmpty prepend="AND" property="adptrIoDstcd">
		      (ADPTRBZWKGROUPNAME LIKE '%\_IO\_%'  OR ADPTRBZWKGROUPNAME LIKE CONCAT('%\_' ,  #adptrIoDstcd# , '\_%') )
		</isNotEmpty>
		<isEqual compareValue="1" prepend="AND" property="queryType">
			  (ADPTRBZWKGROUPNAME LIKE CONCAT('\_' , #chnlCd# , '%') OR ADPTRBZWKGROUPNAME LIKE '\_CBS%'  
			  <isNotEmpty prepend="OR" property="chnlCd2">
			  ADPTRBZWKGROUPNAME LIKE CONCAT('\_' , #chnlCd2# , '%') 
			  </isNotEmpty>
			  <isNotEmpty prepend="OR" property="eaiSvcName">
		     	 ADPTRBZWKGROUPNAME IN (SELECT GSTATSYSADPTRBZWKGROUPNAME FROM $schemaId$.TSEAIHE01 WHERE EAISVCNAME=#eaiSvcName#)
			  </isNotEmpty>
			  ) 
		</isEqual>
		<isEqual compareValue="2" prepend="AND" property="queryType">
		(ADPTRBZWKGROUPNAME LIKE '\_CBS%' AND ADPTRBZWKGROUPNAME LIKE CONCAT( '%{' , (SELECT INSTANCECODE FROM $schemaId$.TSEAIIF06 WHERE EAIBZWKDSTCD=#eaiBzwkDstcd#) , '}') ) 
		</isEqual>
		<isEqual compareValue="3" prepend="AND" property="queryType">
		(
		 (ADPTRBZWKGROUPNAME LIKE '\_CBS%' AND ADPTRBZWKGROUPNAME LIKE CONCAT( '%{' , (SELECT INSTANCECODE FROM $schemaId$.TSEAIIF06 WHERE EAIBZWKDSTCD=#eaiBzwkDstcd#) , '}' ) ) 
		 OR  (ADPTRBZWKGROUPNAME LIKE '\_CBS%' AND ADPTRBZWKGROUPNAME LIKE CONCAT( '%{' , (SELECT INSTANCECODE FROM $schemaId$.TSEAIIF06 WHERE EAIBZWKDSTCD=#chnlCd#) , '}')  ) 
		 OR  ADPTRBZWKGROUPNAME LIKE CONCAT( '\_' , #chnlCd# , '%' )
			  <isNotEmpty prepend="OR" property="chnlCd2">
			  ADPTRBZWKGROUPNAME LIKE CONCAT( '\_' , #chnlCd2# , '%' ) 
			  </isNotEmpty>
			 <isNotEmpty prepend="OR" property="eaiSvcName">
		     	 ADPTRBZWKGROUPNAME IN (SELECT PSVSYSADPTRBZWKGROUPNAME FROM $schemaId$.TSEAIHE02 WHERE EAISVCNAME=#eaiSvcName#)
			  </isNotEmpty>
		 )
		</isEqual>
	  </dynamic>
	 ORDER BY 1
  </statement>

  <statement id="updateAdaptersForSimYn">
    UPDATE $schemaId$.TSEAIHE01
       SET SIMYN =#simYn#
     WHERE EAIBZWKDSTCD LIKE CONCAT( #eaiBzwkDstcd# , '%')
	   AND EAISVCNAME LIKE CONCAT( #channel# , '%')
	<isEqual compareValue="EAI" prepend="AND" property="schemaId">
		EAISVCNAME NOT IN (SELECT EAISVCNAME FROM $schemaId$.TSEAIHE02 WHERE PSVSYSADPTRBZWKGROUPNAME LIKE '_CBS%' AND SVCPRCSSNO=1)
	  <!--  SUBSTR(EAISVCNAME,LENGTH(EAISVCNAME)-1,2) IN ('S1') -->
	</isEqual>
	<isEqual compareValue="FEP" prepend="AND" property="schemaId">
	   SUBSTR(EAISVCNAME,LENGTH(EAISVCNAME)-1,2) IN ('S2','R2')
	</isEqual>
	   
  </statement>
  
    <statement id="selectListForSingleNode" parameterClass="java.util.HashMap" resultClass="java.util.LinkedHashMap">
    SELECT A.ADPTRBZWKGROUPNAME,A2.EAISEVRINSTNCNAME 
      FROM (
	  		SELECT AD01.ADPTRBZWKGROUPNAME 
	  		  FROM $schemaId$.TSEAIAD01 AD01, $schemaId$.TSEAIAD02 AD02
	         WHERE AD01.ADPTRBZWKGROUPNAME = AD02.ADPTRBZWKGROUPNAME
	           AND (AD01.ADPTRBZWKGROUPNAME LIKE '%NET_AsC%' OR AD01.ADPTRBZWKGROUPNAME LIKE '%NET_SyC%')
	           AND AD02.EAISEVRINSTNCNAME != 'ALL'
	           AND AD01.ADPTRUSEYN ='1'
	         GROUP BY AD01.ADPTRBZWKGROUPNAME HAVING count(1) =1
	      ) A , $schemaId$.TSEAIAD02 A2
      WHERE A.ADPTRBZWKGROUPNAME = A2.ADPTRBZWKGROUPNAME
    </statement>

  <statement id="updateSingleNode">
		UPDATE $schemaId$.TSEAIAD02 
		   SET EAISEVRINSTNCNAME = CONCAT( SUBSTR(EAISevrInstncName,1,9) , #node# , substr(EAISevrInstncName,11,1) )  
		 WHERE ADPTRBZWKGROUPNAME IN (
		       SELECT AD01.ADPTRBZWKGROUPNAME FROM $schemaId$.TSEAIAD01 AD01 , $schemaId$.TSEAIAD02 AD02
		        WHERE AD01.ADPTRBZWKGROUPNAME = AD02.ADPTRBZWKGROUPNAME
		          AND (AD01.ADPTRBZWKGROUPNAME LIKE '%NET_AsC%' OR AD01.ADPTRBZWKGROUPNAME LIKE '%NET_SyC%')
		          AND AD02.EAISEVRINSTNCNAME != 'ALL'
		          AND AD01.ADPTRUSEYN ='1'
		        GROUP BY AD01.ADPTRBZWKGROUPNAME HAVING COUNT(1) =1
		       )
  </statement>
  <statement id="selectTakeOverCount" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
		SELECT COUNT(1) FROM (
		        SELECT COUNT(1) FROM $schemaId$.TSEAISY02 
		        WHERE  EAISEVRINSTNCNAME != 'ALL' 
		        GROUP BY  CONCAT(  SUBSTR(EAISEVRINSTNCNAME,1,9) , '_' , SUBSTR(EAISEVRINSTNCNAME,11,1) ) 
		        HAVING COUNT(1) &gt; 1
		)
    </statement>
    

	<statement id="selectListRealTimeGroup" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
		SELECT REALTIMEGROUPNAME AS CODE
			 , REALTIMEGROUPNAME AS NAME
		  FROM $schemaId$.TSEAIAD01
		 WHERE (  TRIM(REALTIMEGROUPNAME) != '' 
		 	   OR TRIM(REALTIMEGROUPNAME) IS NOT NULL )
		 GROUP BY REALTIMEGROUPNAME
		 ORDER BY 1
	</statement>

	<statement id="selectListForChnlInfo" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
		SELECT ADPTRBZWKGROUPNAME 
			 , ADPTRBZWKGROUPDESC 
		  FROM $schemaId$.TSEAIAD01
		 where ADPTRCD ='NET'
		 AND NOT EAIBZWKDSTCD='IFE'
		 AND UPPER(ADPTRBZWKGROUPNAME) LIKE CONCAT( '%' , UPPER(#searchAdptrBzwkGroupName#) , '%')
	</statement>
	
	<statement id="selectAdapterNickName" parameterClass="java.util.HashMap" resultClass="java.lang.String">
		SELECT 
			IFNULL(MAX(SUBSTRING(ADPTRNICKNAME,6,3)), '000') AS NICKNAME 
		FROM $schemaId$.TSEAIAD01
		WHERE ADPTRNICKNAME LIKE #NICKNAME# || '%'
  </statement> 
  
    <statement id="selectadapterPortList" resultClass="java.util.HashMap">
		SELECT DISTINCT AD1.PRPTY2VAL AS "PORT" ,AD01.ADPTRBZWKGROUPNAME AS "ADPTRBZWKGROUPNAME"
			FROM $schemaId$.TSEAIAD01 AD01 ,$schemaId$.TSEAIAD02 AD02,$schemaId$.TSEAIAD15 AD1 ,$schemaId$.TSEAIAD15 AD2
		WHERE AD01.ADPTRBZWKGROUPNAME = AD02.ADPTRBZWKGROUPNAME
		AND AD02.PRPTYGROUPNAME = AD1.PRPTYGROUPNAME
		AND AD1.PRPTYGROUPNAME = AD2.PRPTYGROUPNAME
		AND AD1.PRPTYNAME = 'port.number' 
		AND AD1.PRPTY2VAL != ''
		AND AD2.PRPTYNAME = 'socket.type'
		AND AD2.PRPTY2VAL = 'SERVER'
		<isNotEmpty prepend="AND" property="chkInstYn" >
			 (AD01.ADPTRBZWKGROUPNAME LIKE  CONCAT( '%' , #chkInst1# , '%' )  OR AD01.ADPTRBZWKGROUPNAME  CONCAT( '%' , #chkInst2# , '%' )  OR AD01.ADPTRBZWKGROUPNAME CONCAT( '%' , #chkInst3# , '%' ))
									     			
		</isNotEmpty>
   </statement> 
   <statement id="selectAdptGrpNameByPort" resultClass="java.util.HashMap">
		SELECT DISTINCT ADPTRBZWKGROUPNAME FROM $schemaId$.TSEAIAD02 AD02 
			LEFT JOIN $schemaId$.TSEAIAD15 AD15
			ON AD02.ADPTRBZWKNAME=AD15.PRPTYGROUPNAME
		WHERE AD15.PRPTYNAME ='port.number' 
		<isNotEmpty prepend="AND" property="searchPortNum" >
			 AD15.PRPTY2VAL LIKE CONCAT('%' , #searchPortNum# , '%' )
		</isNotEmpty>
		<isNotEmpty prepend="AND" property="searchAdptrBzwkGroupName" >
			 UPPER(AD02.ADPTRBZWKGROUPNAME) LIKE CONCAT('%' , UPPER(#searchAdptrBzwkGroupName#) , '%')
		</isNotEmpty>
   </statement>  
   
   <statement id="insert" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
    INSERT INTO $schemaId$.TSEAIAD01 ( 
			 ADPTRBZWKGROUPNAME
			,ADPTRMSGPTRNCD
			,EAIBZWKDSTCD
			,ADPTRCD
			,ADPTRMSGDSTCD
			,ADPTRIODSTCD
			,REFCLSNAME
			,SNDRCVHMSLOGYN
			,ADPTRUSEYN
			,SPCFCLUUSEYN
			,ADPTRBZWKGROUPDESC
			,OSIDINSTINO
			,EAILASTAMNDYMS
			,OSIDINSTIYN
			,OSIDINSTIBZWKRSEMPNAME
			,OSIDINSTITELNO
			,MONIUSEYN
			,MONICNDNCTNT
			,KESAUSEYN
			,TESTMASTERYN
			,ADPTRNICKNAME
			,COMPANYCODEDATA
			,ADPTRINSTICODE
			,EAISEVRDSTCD
			,CIRNUMBER
			,DRADPTRYN
			,BIDINTERFACE
			,MSGENCODE
		 ) VALUES ( 
		     #ADPTRBZWKGROUPNAME#
			,#ADPTRMSGPTRNCD#
			,#EAIBZWKDSTCD#
			,#ADPTRCD#
			,#ADPTRMSGDSTCD#
			,#ADPTRIODSTCD#
			,#REFCLSNAME#
			,#SNDRCVHMSLOGYN#
			,#ADPTRUSEYN#
			,#SPCFCLUUSEYN#
			,#ADPTRBZWKGROUPDESC#
			,#OSIDINSTINO#
			,DATE_FORMAT(LOCALTIMESTAMP, '%Y%m%d%H%i')
			,#OSIDINSTIYN#
			,#OSIDINSTIBZWKRSEMPNAME#
			,#OSIDINSTITELNO#
			,#MONIUSEYN#
			,#MONICNDNCTNT#
			,#KESAUSEYN#
			,#TESTMASTERYN#
			,#ADPTRNICKNAME#
			,#COMPANYCODEDATA#
			,#ADPTRINSTICODE#
			,#EAISEVRDSTCD#
			,#CIRNUMBER#
			,#DRADPTRYN#
			,#BIDINTERFACE#
			,#MSGENCODE#
		 )
  </statement>
  
  <statement id="insertClone" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
    INSERT INTO $schemaId$.TSEAIAD01 ( 
			 ADPTRBZWKGROUPNAME
			,ADPTRMSGPTRNCD
			,EAIBZWKDSTCD
			,ADPTRCD
			,ADPTRMSGDSTCD
			,ADPTRIODSTCD
			,REFCLSNAME
			,SNDRCVHMSLOGYN
			,ADPTRUSEYN
			,SPCFCLUUSEYN
			,ADPTRBZWKGROUPDESC
			,OSIDINSTINO
			,EAILASTAMNDYMS
			,OSIDINSTIYN
			,OSIDINSTIBZWKRSEMPNAME
			,OSIDINSTITELNO
			<isNotEmpty prepend="," property="MONIUSEYN">
			 MONIUSEYN
			</isNotEmpty>
			,MONICNDNCTNT
			,KESAUSEYN
			,TESTMASTERYN
			,COMPANYCODEDATA
			,ADPTRINSTICODE
			,EAISEVRDSTCD
			,CIRNUMBER
			,DRADPTRYN
			,MSGENCODE
		 ) VALUES ( 
		     #ADPTRBZWKGROUPNAME#
			,#ADPTRMSGPTRNCD#
			,#EAIBZWKDSTCD#
			,#ADPTRCD#
			,#ADPTRMSGDSTCD#
			,#ADPTRIODSTCD#
			,#REFCLSNAME#
			,#SNDRCVHMSLOGYN#
			,#ADPTRUSEYN#
			,#SPCFCLUUSEYN#
			,#ADPTRBZWKGROUPDESC#
			,#OSIDINSTINO#
			,DATE_FORMAT(LOCALTIMESTAMP, '%Y%m%d%H%i')
			,#OSIDINSTIYN#
			,#OSIDINSTIBZWKRSEMPNAME#
			,#OSIDINSTITELNO#
			<isNotEmpty prepend="," property="MONIUSEYN">
			 #MONIUSEYN#
			</isNotEmpty>
			,#MONICNDNCTNT#
			,#KESAUSEYN#
			,#TESTMASTERYN#
			,#COMPANYCODEDATA#
			,#ADPTRINSTICODE#
			,#EAISEVRDSTCD#
			,#CIRNUMBER#
			,#DRADPTRYN#
			,#MSGENCODE#
		 )
  </statement>
  
  <statement id="update" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
    UPDATE $schemaId$.TSEAIAD01 
    SET      ADPTRMSGPTRNCD         = #ADPTRMSGPTRNCD#        
			,EAIBZWKDSTCD           = #EAIBZWKDSTCD#          
			,ADPTRCD                = #ADPTRCD#               
			,ADPTRMSGDSTCD          = #ADPTRMSGDSTCD#         
			,ADPTRIODSTCD           = #ADPTRIODSTCD#          
			,REFCLSNAME             = #REFCLSNAME#            
			,SNDRCVHMSLOGYN         = #SNDRCVHMSLOGYN#        
			,ADPTRUSEYN             = #ADPTRUSEYN#            
			,SPCFCLUUSEYN           = #SPCFCLUUSEYN#          
			,ADPTRBZWKGROUPDESC     = #ADPTRBZWKGROUPDESC#    
			,OSIDINSTINO            = #OSIDINSTINO#           
			,EAILASTAMNDYMS         = DATE_FORMAT(LOCALTIMESTAMP, '%Y%m%d%H%i')
			,OSIDINSTIYN            = #OSIDINSTIYN#           
			,OSIDINSTIBZWKRSEMPNAME = #OSIDINSTIBZWKRSEMPNAME#
			,OSIDINSTITELNO         = #OSIDINSTITELNO#  
			<isNotEmpty prepend="," property="MONIUSEYN">
			 MONIUSEYN              = #MONIUSEYN# 
			</isNotEmpty>      
			,MONICNDNCTNT           = #MONICNDNCTNT#        
			,KESAUSEYN              = #KESAUSEYN#
			,TESTMASTERYN			= #TESTMASTERYN#
			,ADPTRNICKNAME			= #ADPTRNICKNAME#
			,COMPANYCODEDATA		= #COMPANYCODEDATA#	
			,ADPTRINSTICODE			= #ADPTRINSTICODE#
			,EAISEVRDSTCD			= #EAISEVRDSTCD#
			,CIRNUMBER  			= #CIRNUMBER#
			,DRADPTRYN 				= #DRADPTRYN#
			,BIDINTERFACE 			= #BIDINTERFACE#
			,MSGENCODE 			    = #MSGENCODE#
     WHERE  ADPTRBZWKGROUPNAME = #ADPTRBZWKGROUPNAME#
  </statement> 
</sqlMap>
