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

  <statement id="getProcCount" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
		 SELECT COUNT(L1.LOGPRCSSSERNO) AS "CNT"
       FROM $schemaId$.$tableName$  L1,
         (  SELECT EAIBZWKDSTCD, MSGDPSTYMS, EAISVCSERNO, MAX(LOGPRCSSSERNO) LOGPRCSSSERNO
              FROM $schemaId$.$tableName$
             WHERE MSGDPSTYMS BETWEEN '$start$' AND '$end$'
							<isNotEqual compareValue="''" prepend="AND" property="insts">
			 				     EAISEVRINSTNCNAME IN ( $insts$ )
				      </isNotEqual>
          GROUP BY EAIBZWKDSTCD, MSGDPSTYMS, EAISVCSERNO
          ) L0
      WHERE L0.EAIBZWKDSTCD = L1.EAIBZWKDSTCD
	      AND L0.MSGDPSTYMS = L1.MSGDPSTYMS
	      AND L0.EAISVCSERNO = L1.EAISVCSERNO
	      AND L0.LOGPRCSSSERNO = L1.LOGPRCSSSERNO
	      AND L1.LOGPRCSSSERNO != '900'
	      AND L1.EAIERRCD NOT LIKE 'REC%'
	      AND (
			        ( L1.SVCMOTIVUSEDSTCD = 'ASYN' AND L1.PSVINTFACDSTICNAME = 'ASYN'  AND L1.LOGPRCSSSERNO IN ('200', '400') )
			        OR
			        ( L1.SVCMOTIVUSEDSTCD = 'SYNC' AND L1.PSVINTFACDSTICNAME = 'SYNC'  AND L1.LOGPRCSSSERNO = '400' )
			        OR
			        ( L1.SVCMOTIVUSEDSTCD = 'ASYN' AND L1.PSVINTFACDSTICNAME = 'SYNC'  AND L1.LOGPRCSSSERNO = '400' )
			        OR
			        ( L1.SVCMOTIVUSEDSTCD = 'SYNC' AND L1.PSVINTFACDSTICNAME = 'ASYN'  AND L1.LOGPRCSSSERNO = '400' )
     			  )
  </statement>
  
  <statement id="getProcCountWithSR02" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
	SELECT 
		EAIGROUPCOCD
		,MAX(NOMALNOITM) AS "MAXCOUNT"
		,SUM(NOMALNOITM) AS "TOTCOUNT"
	FROM
	(
	 SELECT BASEHH , BASEHHMM ,EAIGROUPCOCD, SUM(NOMALNOITM) AS "NOMALNOITM"
		FROM (
			SELECT 
				 SR02.BASEHH
				,SR02.BASEHHMM
				,(CASE WHEN TRIM(HE01.EAIGROUPCOCD) IS NULL THEN 'KBO' ELSE HE01.EAIGROUPCOCD END) EAIGROUPCOCD
				,SR02.NOMALNOITM 
			FROM $schemaId$.TSEAISR02 SR02 ,$schemaId$.TSEAIHE01 HE01
			WHERE SR02.BASEYMD = #baseYmd#
			AND SR02.EAISVCNAME = HE01.EAISVCNAME
			) TMP1
	 GROUP BY BASEHH,BASEHHMM,EAIGROUPCOCD
	 ) TMP2
	GROUP BY EAIGROUPCOCD
  </statement>
  
   <statement id="getProcCountDateWithBJ08" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
   	SELECT
            SUBSTR(FileTrsmtStartHMS, 1, 8) AS BASEYMD
          , SUM(CASE WHEN ThisStgePrcssRsultCd = 'E' THEN 0 ELSE 1 END) AS TOTCOUNT			      
      FROM  $schemaId$.TSEAIBJ08 BJ08, $schemaId$.TSEAIBJ02 BJ02
      WHERE BJ08.FileTrsmtStartHMS &gt;= CONCAT( #searchStart#  , '0000000000' ) 
      AND   BJ08.FileTrsmtStartHMS &lt;= CONCAT( #searchEnd# , '9999999999' )			        
      AND   BJ08.BjobBzwkDstcd = BJ02.BjobBzwkDstcd
	GROUP BY
        SUBSTR(FileTrsmtStartHMS, 1, 8)
   </statement>
   
   <statement id="getProcCountHourWithBJ08" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
   	SELECT
           SUBSTR(FileTrsmtStartHMS, 1, 8) AS BASEYMD
          ,SUBSTR(FileTrsmtStartHMS, 9, 2) AS BASEHH  
          ,SUM(CASE WHEN ThisStgePrcssRsultCd = 'E' THEN 0 ELSE 1 END) AS TOTCOUNT			      
      FROM  $schemaId$.TSEAIBJ08 BJ08, $schemaId$.TSEAIBJ02 BJ02
      WHERE BJ08.FileTrsmtStartHMS &gt;= CONCAT( #searchStart#  , '0000000000' )
      AND   BJ08.FileTrsmtStartHMS &lt;= CONCAT( #searchEnd# , '9999999999' )				        
      AND   BJ08.BjobBzwkDstcd = BJ02.BjobBzwkDstcd
	GROUP BY
        SUBSTR(FileTrsmtStartHMS, 1, 8)
       ,SUBSTR(FileTrsmtStartHMS, 9, 2)
   </statement>
   
   <statement id="getProcCountDateWithES01" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
	SELECT  SUBSTR(MSGREGDATE, 1, 8) AS BASEYMD
			,SUM(CASE WHEN ES01.ERRYN = 'C' THEN 1 ELSE 0 END) AS TOTCOUNT
 	 FROM $schemaId$.TSEAIES01 ES01
	 WHERE MSGREGDATE &gt;= CONCAT( #searchEnd# , '9999999999' )	 
	 AND MSGREGDATE &lt;=  CONCAT( #searchEnd# , '9999999999' ) 
	GROUP BY 
		SUBSTR(MSGREGDATE, 1, 8)
   </statement>
   
   <statement id="getProcCountHourWithES01" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
	SELECT  SUBSTR(MSGREGDATE, 1, 8) AS BASEYMD
		   ,SUBSTR(MSGREGDATE, 9, 2) AS BASEHH
		   ,SUM(CASE WHEN ES01.ERRYN = 'C' THEN 1 ELSE 0 END) AS TOTCOUNT
 	 FROM $schemaId$.TSEAIES01 ES01
	 WHERE MSGREGDATE &gt;= CONCAT( #startDt# , '00000000' ) 
	  AND MSGREGDATE &lt;=  CONCAT( #endDt# , '99999999' ) 
	GROUP BY 
		SUBSTR(MSGREGDATE, 1, 8)
	   ,SUBSTR(MSGREGDATE, 9, 2)
   </statement>
  
  <statement id="getProcCountDayWithSR02" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
	SELECT 
		 BASEYMD		
		,SUM(NOMALNOITM) AS "TOTCOUNT"
	FROM
	(
	 SELECT BASEYMD , SUM(NOMALNOITM) AS "NOMALNOITM"
		FROM (
			SELECT 
				 SR02.BASEYMD				
				,(CASE WHEN TRIM(HE01.EAIGROUPCOCD) IS NULL THEN 'KBO' ELSE HE01.EAIGROUPCOCD END) EAIGROUPCOCD
				,SR02.NOMALNOITM 
			FROM $schemaId$.TSEAISR02 SR02 ,$schemaId$.TSEAIHE01 HE01
			WHERE SR02.BASEYMD BETWEEN #searchStart# AND #searchEnd#
			AND SR02.EAISVCNAME = HE01.EAISVCNAME
			) TMP1
	 GROUP BY BASEYMD,EAIGROUPCOCD
	 ) TMP2
	GROUP BY BASEYMD
  </statement>
  
  <statement id="getHourProcCountWithSR02" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
	 SELECT BASEYMD ,BASEHH, SUM(NOMALNOITM) AS "TOTCOUNT"
		FROM (
			SELECT  SR02.BASEYMD 
				,SR02.BASEHH	
				,SR02.NOMALNOITM 
			FROM $schemaId$.TSEAISR02 SR02 ,$schemaId$.TSEAIHE01 HE01
			WHERE SR02.BASEYMD BETWEEN #startDt# AND #endDt#
			AND SR02.EAISVCNAME = HE01.EAISVCNAME
			) TMP1
		<dynamic prepend="WHERE" > 
			<isEqual compareValue="Y" prepend="AND" property="compare">
				(TMP1.BASEYMD = #startDt# AND TMP1.BASEHH &gt;= #startHh#) AND (TMP1.BASEYMD =#endDt# AND TMP1.BASEHH &lt;= #endHh#)
			</isEqual>
			<isEqual compareValue="N" prepend="AND" property="compare">
				(TMP1.BASEYMD = #startDt# AND TMP1.BASEHH &gt;= #startHh#) OR (TMP1.BASEYMD =#endDt# AND TMP1.BASEHH &lt;= #endHh#)
			</isEqual>
		</dynamic>	
	 GROUP BY BASEYMD ,BASEHH
  </statement>
  
  <statement id="getTimeoutCount" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
  	SELECT COUNT(DISTINCT EAISVCSERNO) AS "CNT"
		  FROM $schemaId$.$tableName$
		 WHERE MSGDPSTYMS BETWEEN #start# AND #end# 
			 AND EAIERRCD LIKE 'REC%'		
			 AND EAIERRCD IN ( $timeoutErr$ )
			 AND EAISEVRINSTNCNAME IN ( $insts$ )
	</statement>
	
	<statement id="getErrorCount" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
    SELECT COUNT(DISTINCT EAISVCSERNO) AS "CNT"
		  FROM $schemaId$.$tableName$ 
		 WHERE MSGDPSTYMS BETWEEN #start# AND #end# 
			 AND EAIERRCD LIKE 'REC%'		
			 AND EAIERRCD NOT IN ( $timeoutErr$ )
			 AND EAISEVRINSTNCNAME IN ( $insts$ )
	</statement>
	
	<statement id="insertPeakTpsHistory" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
	      INSERT INTO $schemaId$.TSEAIRM15 
	      (BASEINFODSTCD, BZWKGROUPNAME, EAIGROUPCODSTCD, BASEYMD, PRCSSNOITM, TPSNOITM)
	      VALUES (#baseInfo#, #bzwkGroupName#, #eaiGroupCoCd#, #baseYMS#, #prcssNoitm#, #tpsNoitm#)
	</statement>
	  
	<statement id="getTimeoutCountBranchTest" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">     
		SELECT COUNT(DISTINCT EAISVCSERNO) AS "CNT"
		  FROM $schemaId$.$tableName$ L1, $schemaId$.TSEAIHE01 H1
		 WHERE L1.MSGDPSTYMS BETWEEN #start# AND #end#
			 AND L1.EAIERRCD LIKE 'REC%'
			 AND L1.EAIERRCD IN ( $timeoutErr$ )
			 AND L1.EAISEVRINSTNCNAME IN ( $insts$ )
			 AND L1.EAISVCNAME = H1.EAISVCNAME
			<isEqual compareValue="개설" prepend="AND" property="commDiv">
			      SUBSTR(H1.EAISVCNAME,LENGTH(H1.EAISVCNAME)-2) IN ('S01','R02')
			</isEqual>
			<isEqual compareValue="취급" prepend="AND" property="commDiv">
			      SUBSTR(H1.EAISVCNAME,LENGTH(H1.EAISVCNAME)-2) IN ('S02','R01')
			</isEqual>
    </statement>
  
	<statement id="getErrorCountBranchTest" parameterClass="java.util.HashMap" resultClass="java.lang.Integer"> 
    SELECT COUNT(DISTINCT EAISVCSERNO) AS "CNT"
		  FROM $schemaId$.$tableName$  L1,  $schemaId$.TSEAIHE01 H1
		 WHERE L1.MSGDPSTYMS BETWEEN #start# AND #end#
			 AND L1.EAIERRCD LIKE 'REC%'
			 AND L1.EAIERRCD NOT IN ( $timeoutErr$  )
			 AND L1.EAISEVRINSTNCNAME IN ( $insts$ )
			 AND L1.EAISVCNAME = H1.EAISVCNAME
			<isEqual compareValue="개설" prepend="AND" property="commDiv">
			     SUBSTR(H1.EAISVCNAME,LENGTH(H1.EAISVCNAME)-2) IN ('S01','R02')
			</isEqual>
			<isEqual compareValue="취급" prepend="AND" property="commDiv">
			      SUBSTR(H1.EAISVCNAME,LENGTH(H1.EAISVCNAME)-2) IN ('S02','R01')
			</isEqual>
    </statement>
  
	<statement id="getMinMaxDate" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
			SELECT MIN(STATCYMD) "minDate", MAX(STATCYMD) "maxDate"
			  FROM $schemaId$.TSEAIRM11
				<isNotEmpty prepend="WHERE" property="hostName">
				      EAIMONISYSHOSTNAME = #hostName#
				</isNotEmpty>
    </statement>
  
	<statement id="getMinMaxTime" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
		SELECT COALESCE(MIN(STATCHMS),0) "minTime", COALESCE(MAX(STATCHMS),0) "maxTime"  
		  FROM  $schemaId$.TSEAIRM11
		WHERE 1=1
		<isNotEmpty prepend="AND" property="baseDate">
		      STATCYMD = #baseDate#
		</isNotEmpty>
		<isNotEmpty prepend="AND" property="hostName">
		      EAIMONISYSHOSTNAME = #hostName#
		</isNotEmpty>
    </statement>
  
	<statement id="insertTradeStatics" parameterClass="com.eactive.eai.rms.onl.tracking.vo.DbStaticsVo" resultClass="java.lang.Integer">
			INSERT INTO  $schemaId$.TSEAIRM11
						    	( EAIMONIJOBDSTCD, EAIMONISVCDSTCD, STATCYMD, STATCHMS
						    	, EAIMONISYSHOSTNAME, EAIMONIPRCSSNOITM, EAIMONITOUTNOITM, EAIMONIERRNOITM
						    	, MAXSSPERPRCSSQANTY )
	    		 VALUES (#eaiMoniJobDstcd#, #eaiMoniSvcDstcd#, #statcYmd#, #statcHMS#
	    		         , #eaiMoniSysHostName#, #eaiMoniPrcssNoitm#, #eaiMoniToutNoitm#, #eaiMoniErrNoitm#
	    		         , #maxSSPerPrcssQanty#)
    </statement>
  
	<statement id="sumTradeStatics" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
	   	  SELECT COALESCE(MAX(STATCHMS),0) "maxTime" , COALESCE(SUM(EAIMONIPRCSSNOITM),0) "sumProc"
	    	     , COALESCE(SUM(EAIMONITOUTNOITM),0) "sumTimeout", COALESCE(SUM(EAIMONIERRNOITM),0) "sumError"
	    	     , COALESCE(MAX(MAXSSPERPRCSSQANTY),0) "maxTps"
				FROM   $schemaId$.TSEAIRM11
				WHERE  EAIMONIJOBDSTCD = #eaiMoniJobDstcd#
				AND    EAIMONISVCDSTCD = #eaiMoniSvcDstcd#
				AND    STATCYMD = #statcYmd#
			<isNotEmpty prepend="AND" property="hostName">
			      EAIMONISYSHOSTNAME = #hostName#
			</isNotEmpty>
    </statement>
  
	<statement id="resetTradeStatics" parameterClass="java.util.HashMap" resultClass="java.lang.Integer">
			UPDATE  $schemaId$.TSEAIRM11 
			SET EAIMONIPRCSSNOITM = 0, EAIMONITOUTNOITM = 0, EAIMONIERRNOITM = 0, MAXSSPERPRCSSQANTY = 0.0
			WHERE  STATCYMD = #statcYmd#
			<isNotEmpty prepend="AND" property="statcHMS">
			     STATCHMS &lt;= #statcHMS#
			</isNotEmpty>
    </statement>
  
	<statement id="selectEAISevrDstcd" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
    SELECT EAISVCNAME "EAISvcName", '$schemaId$' AS "schema"  
      FROM $schemaId$.TSEAIHE01
     ORDER BY 1
    </statement>
  
   <statement id="getItsmErrorLogList" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
		SELECT  
			'ONLINE' AS TYPE,
			LG.MSGDPSTYMS AS MSGDPSTYMS,
			<!-- 'S9'||substr(LG.EAIERRCD,7) AS EAIERRCD, -->
			LG.EAIERRCD AS EAIERRCD,
			LG.EAISVCNAME AS EAISVCNAME,
			CM01.BZWKDSTICNAME AS BZWKDSTICNAME,
			MIN(LG.LOGPRCSSSERNO) AS LOGPRCSSSERNO,
			LG.EAISEVRINSTNCNAME AS INSTANCENAME,
			LG.EAIERRCTNT AS EAIERRCTNT
		FROM 
			$schemaId$.$tableName$ LG,
			$schemaId$.TSEAICM01 CM01
	 	WHERE  
	 		LG.EAIBZWKDSTCD = CM01.EAIBZWKDSTCD
	 	AND 
	 		LG.MSGDPSTYMS BETWEEN  CONCAT( #startDt# ,  '000' ) AND CONCAT( #endDt# , '999' ) 	
	 	<isEqual compareValue="timeout" prepend="AND" property="errortype">
	  	  	LG.EAIERRCD IN ($timeOutCodes$)	
	  	</isEqual>
	  	 <isEqual compareValue="bizerror" prepend="AND" property="errortype">
	  	 	LG.EAIERRCD IN ($bizErrorCodes$)	
	  	</isEqual>
	  	<isEqual compareValue="connectError" prepend="AND" property="errortype">
	  	 	TRIM(LG.RSPNSERRCDNAME) LIKE 'REC%' 
	  	AND LG.EAIERRCD NOT IN ($bizErrorCodes$) 
	  	AND LG.EAIERRCD NOT IN ($timeOutCodes$)
	  	</isEqual>
        GROUP BY 
        	BZWKDSTICNAME, MSGDPSTYMS, EAIERRCD, EAISVCNAME, EAISEVRINSTNCNAME, EAIERRCTNT
   </statement>
   
   
   <statement id="getEaiBatchErrorList" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
		SELECT
			'BATCH' AS TYPE,
			THISSTGEENDHMS AS MSGDPSTYMS,
			BJOBMSGDSTCD AS EAISVCNAME,
			BJOBBZWKDSTCD AS BZWKDSTICNAME,
			EAISEVRINSTNCNAME AS INSTANCENAME,
			EAIOBSTCLOCCURCAUSCTNT AS EAIERRCTNT
		FROM
			$schemaId$.TSEAIBJ04
		WHERE
			THISSTGEPRCSSRSULTCD = 'E'
		AND
			THISSTGEENDHMS BETWEEN CONCAT( #startDt# ,  '000' ) AND CONCAT( #endDt# , '999' )
   </statement>
   
	<statement id="getFepBatchErrorList" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
		SELECT
			'BATCH' AS TYPE,
			BJ08.FILETRSMTENDHMS AS MSGDPSTYMS,
			BJ01.INFID AS EAISVCNAME,
			BJ02.BJOBBZWKNAME BZWKDSTICNAME,
			BJ08.EAISEVRINSTNCNAME AS INSTANCENAME,
			BJ08.EAIOBSTCLOCCURCAUSCTNT AS EAIERRCTNT
		FROM
			$schemaId$.TSEAIBJ01 BJ01,
			$schemaId$.TSEAIBJ02 BJ02,
			(
			SELECT
				*
			FROM
				$schemaId$.TSEAIBJ08
			WHERE
				THISSTGEPRCSSRSULTCD = 'E'
			AND
				FILETRSMTENDHMS BETWEEN CONCAT( #startDt# ,  '000' ) AND CONCAT( #endDt# , '999' )
			) BJ08
		WHERE
			BJ02.BJOBBZWKDSTCD = BJ01.BJOBBZWKDSTCD
		AND
			BJ01.BJOBTRANDSTCDNAME = BJ08.BJOBTRANDSTCDNAME
	</statement>
  
</sqlMap>
