<?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="SocketPort">

<statement id="selectListCount" resultClass="java.lang.Integer">
		SELECT 	COUNT(*) AS "TOTALCOUNT"
			FROM  $schemaId$.TSEAIRM31
			WHERE 1=1
				<isEmpty property ="searchAdptrPort">
					<isNotEmpty prepend="AND" property="searchEaiSevrDstCd">
						EAISEVRDSTCD  = #searchEaiSevrDstCd#
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrBzwkNameDesc">
						RECVADPTRDESC LIKE CONCAT( '%', #searchAdptrBzwkNameDesc#, '%')  OR  SENDADPTRDESC LIKE CONCAT( '%', #searchAdptrBzwkNameDesc#, '%')
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrBzwkName">
						UPPER(RECVADPTRBZWKNAME) LIKE CONCAT( '%', UPPER(#searchAdptrBzwkName#) , '%')  OR  UPPER(SENDADPTRBZWKNAME) LIKE CONCAT( '%', UPPER(#searchAdptrBzwkName#) , '%')
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrPort">						
						RECVTESTPORT LIKE concat('%' , #searchAdptrPort# , '%') OR RECVREALPORT LIKE concat('%' ,#searchAdptrPort#,'%' )
					</isNotEmpty>
				</isEmpty>
				<isNotEmpty property ="searchAdptrPort">
					<isNotEmpty prepend="AND" property="searchAdptrBzwkNameDesc">
						RECVADPTRDESC LIKE CONCAT( '%', #searchAdptrBzwkNameDesc# , '%')  OR  SENDADPTRDESC LIKE CONCAT( '%', #searchAdptrBzwkNameDesc# , '%')
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrBzwkName">
						UPPER(RECVADPTRBZWKNAME) LIKE CONCAT( '%', UPPER(#searchAdptrBzwkName#) , '%')  OR  UPPER(SENDADPTRBZWKNAME) LIKE CONCAT( '%', UPPER(#searchAdptrBzwkName#) , '%')
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrPort">						
						RECVTESTPORT LIKE concat('%' , #searchAdptrPort# , '%') OR RECVREALPORT LIKE concat('%' ,#searchAdptrPort# ,'%')
					</isNotEmpty>
				</isNotEmpty>
	</statement>

 <statement id="selectList" resultClass="java.util.HashMap">
		SELECT 
			  ROWNO AS ROWNO
			, EAISEVRDSTCD AS "EAISEVRDSTCD"
		    , RECVADPTRBZWKNAME AS "RECVADPTRBZWKNAME"
		    , RECVADPTRDESC AS "RECVADPTRDESC"
		    , RECVTESTPORT AS "RECVTESTPORT"
		    , RECVREALPORT AS "RECVREALPORT"
		    , RECVPORTLASTYMD AS "RECVPORTLASTYMD"
		    , RECVLASTADMUSERID AS "RECVLASTADMUSERID"
		    , SENDADPTRBZWKNAME AS "SENDADPTRBZWKNAME"
		    , SENDADPTRDESC AS "SENDADPTRDESC"
		    , SENDTESTPORT AS "SENDTESTPORT"
			, SENDREALPORT AS "SENDREALPORT"
		    , SENDPORTLASTYMD AS "SENDPORTLASTYMD"
		    , SENDLASTADMUSERID AS "SENDLASTADMUSERID"
		FROM (
              SELECT  @NO := @NO + 1 AS ROWNO
				    , EAISEVRDSTCD
				    , RECVADPTRBZWKNAME
				    , RECVADPTRDESC
				    , RECVTESTPORT
				    , RECVREALPORT
				    , RECVPORTLASTYMD
				    , RECVLASTADMUSERID
				    , SENDADPTRBZWKNAME
				    , SENDADPTRDESC
				    , SENDTESTPORT
					, SENDREALPORT
				    , SENDPORTLASTYMD
				    , SENDLASTADMUSERID
			FROM  $schemaId$.TSEAIRM31 , (SELECT @NO := 0) R
			WHERE 1=1
				<isEmpty property ="searchAdptrPort">
					<isNotEmpty prepend="AND" property="searchEaiSevrDstCd">
						EAISEVRDSTCD  = #searchEaiSevrDstCd#
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrBzwkNameDesc">
						RECVADPTRDESC LIKE CONCAT( '%', #searchAdptrBzwkNameDesc#, '%')  OR  SENDADPTRDESC LIKE CONCAT( '%', #searchAdptrBzwkNameDesc#, '%')
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrBzwkName">
						UPPER(RECVADPTRBZWKNAME) LIKE CONCAT( '%', UPPER(#searchAdptrBzwkName#) , '%')  OR  UPPER(SENDADPTRBZWKNAME) LIKE CONCAT( '%', UPPER(#searchAdptrBzwkName#) , '%')
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrPort">						
						RECVTESTPORT LIKE concat('%' , #searchAdptrPort# , '%') OR RECVREALPORT LIKE concat('%' , #searchAdptrPort# , '%')
					</isNotEmpty>
				</isEmpty>
				<isNotEmpty property ="searchAdptrPort">
					<isNotEmpty prepend="AND" property="searchAdptrBzwkNameDesc">
						RECVADPTRDESC LIKE CONCAT( '%', #searchAdptrBzwkNameDesc# , '%')  OR  SENDADPTRDESC LIKE CONCAT( '%', #searchAdptrBzwkNameDesc# , '%')
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrBzwkName">
						UPPER(RECVADPTRBZWKNAME) LIKE CONCAT( '%', UPPER(#searchAdptrBzwkName#) , '%')  OR  UPPER(SENDADPTRBZWKNAME) LIKE CONCAT( '%', UPPER(#searchAdptrBzwkName#) , '%')
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrPort">						 
						RECVTESTPORT LIKE concat('%' , #searchAdptrPort# , '%') OR RECVREALPORT LIKE concat('%' , #searchAdptrPort# ,'%')
					</isNotEmpty>
				</isNotEmpty>
			) ORGTABLE
		WHERE ROWNO BETWEEN #startNum# AND #endNum#
	</statement>	
	
	<statement id="selectAllList" resultClass="java.util.HashMap">
	 		SELECT 
	 		  @NO := @NO + 1 AS ROWNO
		    , EAISEVRDSTCD
		    , RECVADPTRBZWKNAME
		    , RECVADPTRDESC
		    , RECVTESTPORT
		    , RECVREALPORT
		    , RECVPORTLASTYMD
		    , RECVLASTADMUSERID
		    , SENDADPTRBZWKNAME
		    , SENDADPTRDESC
		    , SENDTESTPORT
			, SENDREALPORT
		    , SENDPORTLASTYMD
		    , SENDLASTADMUSERID
		FROM  $schemaId$.TSEAIRM31 , (SELECT @NO := 0) R
		WHERE 1=1
			<isEmpty property ="searchAdptrPort">
				<isNotEmpty prepend="AND" property="searchEaiSevrDstCd">
					EAISEVRDSTCD  = #searchEaiSevrDstCd#
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchAdptrBzwkNameDesc">
					RECVADPTRDESC LIKE CONCAT( '%', #searchAdptrBzwkNameDesc#, '%')  OR  SENDADPTRDESC LIKE CONCAT( '%', #searchAdptrBzwkNameDesc#, '%')
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchAdptrBzwkName">
					UPPER(RECVADPTRBZWKNAME) LIKE CONCAT( '%', UPPER(#searchAdptrBzwkName#) , '%')  OR  UPPER(SENDADPTRBZWKNAME) LIKE CONCAT( '%', UPPER(#searchAdptrBzwkName#) , '%')
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchAdptrPort">						
					RECVTESTPORT LIKE concat('%' , #searchAdptrPort# , '%') OR RECVREALPORT LIKE concat('%' , #searchAdptrPort# , '%')
				</isNotEmpty>
			</isEmpty>
			<isNotEmpty property ="searchAdptrPort">
				<isNotEmpty prepend="AND" property="searchAdptrBzwkNameDesc">
					RECVADPTRDESC LIKE CONCAT( '%', #searchAdptrBzwkNameDesc# , '%')  OR  SENDADPTRDESC LIKE CONCAT( '%', #searchAdptrBzwkNameDesc# , '%')
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchAdptrBzwkName">
					UPPER(RECVADPTRBZWKNAME) LIKE CONCAT( '%', UPPER(#searchAdptrBzwkName#) , '%')  OR  UPPER(SENDADPTRBZWKNAME) LIKE CONCAT( '%', UPPER(#searchAdptrBzwkName#) , '%')
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchAdptrPort">						 
					RECVTESTPORT LIKE concat('%' ,#searchAdptrPort# , '%') OR RECVREALPORT LIKE concat('%' , #searchAdptrPort# , '%')
				</isNotEmpty>
			</isNotEmpty>
			
			<isEqual compareValue="ASC" property="searchOrderType">
	          ORDER BY EAISEVRDSTCD, RECVTESTPORT
	       	</isEqual>
	        <isEqual compareValue="DESC" property="searchOrderType">
	          ORDER BY EAISEVRDSTCD, RECVTESTPORT DESC
	        </isEqual>  	
	</statement>

	<statement id="selectInitPort" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
		SELECT COALESCE(MAX(RECVTESTPORT)+1,#resvTportSt#) AS ASSIGNPORT  
		  	FROM $schemaId$.TSEAIRM31
		 WHERE RECVTESTPORT BETWEEN #resvTportSt# AND  #resvTportEn# 
		 UNION ALL
		  SELECT COALESCE(MAX(RECVREALPORT)+1,#resvRportSt#) AS ASSIGNPORT  
		   FROM $schemaId$.TSEAIRM31
		WHERE RECVREALPORT BETWEEN #resvRportSt# AND  #resvRportEn# 
		 UNION ALL
		 SELECT COALESCE(MAX(SENDTESTPORT)+1,#sendTportSt#) AS ASSIGNPORT  
		  FROM $schemaId$.TSEAIRM31
		WHERE SENDTESTPORT BETWEEN #sendTportSt# AND  #sendTportEn# 
		 UNION ALL
		 SELECT COALESCE(MAX(SENDREALPORT)+1, #sendRportSt#) AS ASSIGNPORT  
		  FROM $schemaId$.TSEAIRM31
		WHERE SENDREALPORT BETWEEN #sendRportSt# AND  #sendRportEn#
	</statement>
	
	<statement id="selectListToExcel" resultClass="java.util.HashMap">
		SELECT 
			  $headersStr$
		FROM (
              SELECT  EAISEVRDSTCD
				    , RECVADPTRBZWKNAME
				    , RECVADPTRDESC
				    , RECVTESTPORT
				    , RECVREALPORT
				    , RECVPORTLASTYMD
				    , RECVLASTADMUSERID
				    , SENDADPTRBZWKNAME
				    , SENDADPTRDESC
				    , SENDTESTPORT
					, SENDREALPORT
				    , SENDPORTLASTYMD
				    , SENDLASTADMUSERID
			FROM  $schemaId$.TSEAIRM31
			where 1=1
				<isEmpty property ="searchAdptrPort">
					<isNotEmpty prepend="AND" property="searchEaiSevrDstCd">
						EAISEVRDSTCD  = #searchEaiSevrDstCd#
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrBzwkNameDesc">
						RECVADPTRDESC LIKE CONCAT( '%', #searchAdptrBzwkNameDesc#, '%')  OR  SENDADPTRDESC LIKE CONCAT( '%', #searchAdptrBzwkNameDesc#, '%')
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrBzwkName">
						UPPER(RECVADPTRBZWKNAME) LIKE CONCAT( '%', UPPER(#searchAdptrBzwkName#) , '%')  OR  UPPER(SENDADPTRBZWKNAME) LIKE CONCAT( '%', UPPER(#searchAdptrBzwkName#) , '%')
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrPort">						
						RECVTESTPORT LIKE concat('%' , #searchAdptrPort# , '%') OR RECVREALPORT LIKE concat('%' , #searchAdptrPort# , '%')
					</isNotEmpty>
				</isEmpty>
				<isNotEmpty property ="searchAdptrPort">
					<isNotEmpty prepend="AND" property="searchAdptrBzwkNameDesc">
						RECVADPTRDESC LIKE CONCAT( '%', #searchAdptrBzwkNameDesc# , '%')  OR  SENDADPTRDESC LIKE CONCAT( '%', #searchAdptrBzwkNameDesc# , '%')
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrBzwkName">
						UPPER(RECVADPTRBZWKNAME) LIKE CONCAT( '%', UPPER(#searchAdptrBzwkName#) , '%')  OR  UPPER(SENDADPTRBZWKNAME) LIKE CONCAT( '%', UPPER(#searchAdptrBzwkName#) , '%')
					</isNotEmpty>
					<isNotEmpty prepend="AND" property="searchAdptrPort">						 
						RECVTESTPORT LIKE concat('%' , #searchAdptrPort# , '%') OR RECVREALPORT LIKE concat('%' , #searchAdptrPort# , '%')
					</isNotEmpty>
				</isNotEmpty>
			) TMP1
			ORDER BY EAISEVRDSTCD, RECVTESTPORT
	</statement>

</sqlMap>
