<?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="JmsQueueMonitor">
<!--  #### JMS Queue Monitor ###  -->
	<!--  목록 조회  -->
	<statement id="selectListCount" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
		SELECT 
			COUNT(*)
	    FROM $schemaId$.TSEAIQM01 Q1, $schemaId$.TSEAICM01 C1
		WHERE Q1.EAIBZWKDSTCD = C1.EAIBZWKDSTCD
		AND Q1.QUEUSEYN = '1'
		<isNotEmpty prepend="AND" property="searchEaiBzwkdstcd">
			Q1.EAIBZWKDSTCD LIKE '%' ||  #searchEaiBzwkdstcd# || '%'
		</isNotEmpty>
		<isNotEmpty prepend="AND" property="searchEaiQueBzwkCtnt">
			Q1.EAIQUEBZWKCTNT LIKE '%' || #searchEaiQueBzwkCtnt# ||'%'
		</isNotEmpty>
		<isNotEmpty prepend="AND" property="searchInst">
			Q1.EAISEVRINSTNCNAME LIKE '%'|| #searchInst#
		</isNotEmpty>
		<isNotEmpty prepend="AND" property="searchQueName">
			Q1.NONSYNCZTRANQUENAME LIKE '%' || #searchQueName# || '%'
		</isNotEmpty>
 	</statement>
	<statement id="selectList" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
			SELECT * FROM (
				SELECT 
				ROW_NUMBER() OVER (ORDER BY Q1.EAIBZWKDSTCD, Q1.EAISEVRINSTNCNAME) AS "ROWNO",
				Q1.EAIBZWKDSTCD        "EAIBZWKDSTCD",      
				C1.BZWKDSTICNAME       "BZWKDSTICNAME",     
				Q1.EAIQUEBZWKDTALSCTNT "EAIQUEBZWKCTNT",    
				Q1.EAISEVRINSTNCNAME   "EAISEVRINSTNCNAME", 
				Q1.QUEUSAGDSTCD        "QUEUSAGDSTCD",      
				Q1.NONSYNCZTRANQUENAME "NONSYNCZTRANQUENAME",
				CASE WHEN QUEUSAGDSTCD = '1' 
				  THEN 0  
				END AS "SENDQUEUECOUNT",
				CASE WHEN QUEUSAGDSTCD = '2' 
				  THEN 0  
				END AS "RECEIVEQUEUECOUNT",
				CASE WHEN QUEUSAGDSTCD = '3'
				  THEN 0  
				END AS "SENDERRORQUEUECOUNT",
				CASE WHEN QUEUSAGDSTCD = '4'
				  THEN 0
				END AS "RECEIVEERRORCOUNT"
		    FROM $schemaId$.TSEAIQM01 Q1, $schemaId$.TSEAICM01 C1
			WHERE Q1.EAIBZWKDSTCD = C1.EAIBZWKDSTCD
			AND Q1.QUEUSEYN = '1'
			<isNotEmpty prepend="AND" property="searchEaiBzwkdstcd">
				Q1.EAIBZWKDSTCD LIKE '%' ||  #searchEaiBzwkdstcd# || '%'
			</isNotEmpty>
			<isNotEmpty prepend="AND" property="searchEaiQueBzwkCtnt">
				Q1.EAIQUEBZWKCTNT LIKE '%' || #searchEaiQueBzwkCtnt# ||'%'
			</isNotEmpty>
			<isNotEmpty prepend="AND" property="searchInst">
				Q1.EAISEVRINSTNCNAME LIKE '%'|| #searchInst#
			</isNotEmpty>
			<isNotEmpty prepend="AND" property="searchQueName">
				Q1.NONSYNCZTRANQUENAME LIKE '%' || #searchQueName# || '%'
			</isNotEmpty>
            ORDER BY Q1.EAIBZWKDSTCD, Q1.EAIQUEBZWKCTNT, Q1.EAISEVRINSTNCNAME
            ) TMP WHERE "ROWNO" BETWEEN #startNum# AND #endNum#            
	</statement>
	<statement id="selectListToExcel" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
			SELECT $headersStr$ FROM (
				SELECT 
				ROW_NUMBER() OVER (ORDER BY Q1.EAIBZWKDSTCD, Q1.EAISEVRINSTNCNAME) AS "ROWNO",
				Q1.EAIBZWKDSTCD        "EAIBZWKDSTCD",      
				C1.BZWKDSTICNAME       "BZWKDSTICNAME",     
				Q1.EAIQUEBZWKCTNT      "EAIQUEBZWKCTNT",    
				Q1.EAISEVRINSTNCNAME   "EAISEVRINSTNCNAME", 
				Q1.QUEUSAGDSTCD        "QUEUSAGDSTCD",      
				Q1.NONSYNCZTRANQUENAME "NONSYNCZTRANQUENAME",
				CAST (CASE WHEN QUEUSAGDSTCD = '1' 
				  THEN 0  
				END AS VARCHAR )AS "SENDQUEUECOUNT",
				CAST (CASE WHEN QUEUSAGDSTCD = '2' 
				  THEN 0  
				END AS VARCHAR )AS "RECEIVEQUEUECOUNT",
				CAST (CASE WHEN QUEUSAGDSTCD = '3' 
				  THEN 0  
				END AS VARCHAR )AS "SENDERRORQUEUECOUNT",
				CAST (CASE WHEN QUEUSAGDSTCD = '4' 
				  THEN 0  
				END AS VARCHAR ) "RECEIVEERRORCOUNT"
		    FROM $schemaId$.TSEAIQM01 Q1, $schemaId$.TSEAICM01 C1
			WHERE Q1.EAIBZWKDSTCD = C1.EAIBZWKDSTCD
			AND Q1.QUEUSEYN = '1'
			<isNotEmpty prepend="AND" property="searchEaiBzwkdstcd">
				Q1.EAIBZWKDSTCD LIKE '%' ||  #searchEaiBzwkdstcd# || '%'
			</isNotEmpty>
			<isNotEmpty prepend="AND" property="searchEaiQueBzwkCtnt">
				Q1.EAIQUEBZWKCTNT LIKE '%' || #searchEaiQueBzwkCtnt# ||'%'
			</isNotEmpty>
			<isNotEmpty prepend="AND" property="searchInst">
				Q1.EAISEVRINSTNCNAME LIKE '%'|| #searchInst#
			</isNotEmpty>
			<isNotEmpty prepend="AND" property="searchQueName">
				Q1.NONSYNCZTRANQUENAME LIKE '%' || #searchQueName# || '%'
			</isNotEmpty>
            ORDER BY Q1.EAIBZWKDSTCD, Q1.EAIQUEBZWKCTNT, Q1.EAISEVRINSTNCNAME
            ) TMP            
	</statement>
	<statement id="selectDetail"  parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
			select 
				Q1.EAIBzwkDstcd, 
				C1.BzwkDsticName, 
				Q1.EAIQueBzwkCtnt,
				Q1.EAISevrInstncName,
				Q1.QueUsagDstcd, 
				Q1.NonSynczTranQueName 
				from $schemaId$.tseaiqm01 Q1, $schemaId$.tseaicm01 C1
				where Q1.EAIBzwkDstcd = C1.EAIBzwkDstcd
				and Q1.QueUseYn = '1'
                <isNotEmpty prepend="AND" property="nonSynczTranQueName">
				Q1.NonSynczTranQueName = #nonSynczTranQueName#
                </isNotEmpty>
                ORDER BY Q1.EAIBzwkDstcd, Q1.EAIQueBzwkCtnt, Q1.EAISevrInstncName
	</statement>
	
	<statement id="connectionInfo" resultClass="java.util.HashMap">
	 	SELECT  PrptyName, Prpty2Val
         		FROM  $schemaId$.TSEAICM03
		WHERE	PrptyGroupName = #prptyGroupName#
	</statement>
	
	<statement id="serviceInfo" resultClass="java.util.HashMap">
	 	SELECT  EAISvcName, EAISvcDesc
         		FROM  $schemaId$.TSEAIHE01
	</statement>
	
	<statement id="selectBoxCount"   parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
	 	SELECT  MAX(SUBSTR(EAISEVRINSTNCNAME,7,1))
         		FROM  $schemaId$.TSEAISY02
        WHERE EAISEVRIP != '*' 		
	</statement>
	
	<statement id="selectInstCount"   parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
	 	SELECT  MAX(SUBSTR(EAISEVRINSTNCNAME,8,1))
         		FROM  $schemaId$.TSEAISY02
        WHERE EAISEVRIP != '*'
	</statement>
	<statement id="selectQueueMonitoringList" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
		SELECT 
			Q1.EAIBZWKDSTCD, C1.BZWKDSTICNAME, Q1.EAIQUEBZWKCTNT, Q1.EAISEVRINSTNCNAME, Q1.QUEUSAGDSTCD, Q1.NONSYNCZTRANQUENAME ,
			CASE WHEN QUEUSAGDSTCD = '1' 
				  THEN 0  
				END AS "SENDQUEUECOUNT",
				CASE WHEN QUEUSAGDSTCD = '2' 
				  THEN 0  
				END AS "RECEIVEQUEUECOUNT",
				CASE WHEN QUEUSAGDSTCD = '3'
				  THEN 0  
				END AS "SENDERRORQUEUECOUNT",
				CASE WHEN QUEUSAGDSTCD = '4'
				  THEN 0
				END AS "RECEIVEERRORCOUNT"
		FROM $schemaId$.TSEAIQM01 Q1 
		INNER JOIN $schemaId$.TSEAICM01 C1 ON Q1.EAIBZWKDSTCD = C1.EAIBZWKDSTCD 
		WHERE Q1.QUEUSEYN = '1'
		ORDER BY Q1.EAIBZWKDSTCD, Q1.EAIQUEBZWKCTNT, Q1.EAISEVRINSTNCNAME
	</statement>
</sqlMap>
