<?xml version="1.0" encoding="gbk" standalone="no"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="" >
<!-- 	<typeAlias alias="Ywcountarearecordbean" type="cn.vp.XXX.model.YwcountarearecordBean"/> -->	<typeAlias alias="Ywcountarearecord" type="cn.yw..YwcountarearecordBean"/>
	
	<sql id="condition_Ywcountarearecord">
		where 1=1
		<isNotEmpty prepend='AND' property='LIKEcountId'>
			(countId like '%$LIKEcountId$%'   )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='countId'>
			(countId = #countId#  )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKEareanum'>
			(areanum like '%$LIKEareanum$%'  )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='areanum'>
			(areanum = #areanum# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKEareaname'>
			(areaname like '%$LIKEareaname$%'  )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='areaname'>
			(areaname = #areaname# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKEcountMonth'>
			(countMonth like '%$LIKEcountMonth$%'  )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='countMonth'>
			(countMonth = #countMonth# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKEcountDate'>
			(countDate like '%$LIKEcountDate$%'  )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='countDate'>
			(countDate = #countDate# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKEcountHour'>
			(countHour like '%$LIKEcountHour$%'  )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='countHour'>
			(countHour = #countHour# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKEvideocount'>
			(videocount like '%$LIKEvideocount$%'  )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='videocount'>
			(videocount = #videocount# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKEnoconfigcount'>
			(noconfigcount like '%$LIKEnoconfigcount$%'  )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='noconfigcount'>
			(noconfigcount = #noconfigcount# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKErecordnormalcount'>
			(recordnormalcount like '%$LIKErecordnormalcount$%'  )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='recordnormalcount'>
			(recordnormalcount = #recordnormalcount# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKErecordabnormalcount'>
			(recordabnormalcount like '%$LIKErecordabnormalcount$%'  )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='recordabnormalcount'>
			(recordabnormalcount = #recordabnormalcount# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKErecordintactrate'>
			(recordintactrate like '%$LIKErecordintactrate$%'  )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='recordintactrate'>
			(recordintactrate = #recordintactrate# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKEcreateTime'>
			(createTime like '%$LIKEcreateTime$%'  )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='createTime'>
			(createTime = #createTime# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKEupdateTime'>
			(updateTime like '%$LIKEupdateTime$%'  )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='updateTime'>
			(updateTime = #updateTime# )
		</isNotEmpty>
		<isNotEmpty property='tableparam'>
			$tableparam$
		</isNotEmpty>
		<isNotEmpty property='order'>
			$order$
		</isNotEmpty>
	</sql>
	
	<!-- add object -->
	<insert id="insert_Ywcountarearecord" parameterClass="java.util.Map">
		insert into 
		ywcountarearecord(
		<dynamic prepend=" ">  
			<isNotEmpty prepend=',' property='countId'>countId</isNotEmpty>
			<isNotEmpty prepend=',' property='areanum'>areanum</isNotEmpty>
			<isNotEmpty prepend=',' property='areaname'>areaname</isNotEmpty>
			<isNotEmpty prepend=',' property='countMonth'>countMonth</isNotEmpty>
			<isNotEmpty prepend=',' property='countDate'>countDate</isNotEmpty>
			<isNotEmpty prepend=',' property='countHour'>countHour</isNotEmpty>
			<isNotEmpty prepend=',' property='videocount'>videocount</isNotEmpty>
			<isNotEmpty prepend=',' property='noconfigcount'>noconfigcount</isNotEmpty>
			<isNotEmpty prepend=',' property='recordnormalcount'>recordnormalcount</isNotEmpty>
			<isNotEmpty prepend=',' property='recordabnormalcount'>recordabnormalcount</isNotEmpty>
			<isNotEmpty prepend=',' property='recordintactrate'>recordintactrate</isNotEmpty>
			<isNotEmpty prepend=',' property='createTime'>createTime</isNotEmpty>
			<isNotEmpty prepend=',' property='updateTime'>updateTime</isNotEmpty>

		</dynamic>  
	    <![CDATA[ 
	        ) values ( 
	    ]]>  
	     <dynamic prepend=" "> 
			<isNotEmpty prepend=',' property='countId'>#countId#</isNotEmpty>
			<isNotEmpty prepend=',' property='areanum'>#areanum#</isNotEmpty>
			<isNotEmpty prepend=',' property='areaname'>#areaname#</isNotEmpty>
			<isNotEmpty prepend=',' property='countMonth'>#countMonth#</isNotEmpty>
			<isNotEmpty prepend=',' property='countDate'>#countDate#</isNotEmpty>
			<isNotEmpty prepend=',' property='countHour'>#countHour#</isNotEmpty>
			<isNotEmpty prepend=',' property='videocount'>#videocount#</isNotEmpty>
			<isNotEmpty prepend=',' property='noconfigcount'>#noconfigcount#</isNotEmpty>
			<isNotEmpty prepend=',' property='recordnormalcount'>#recordnormalcount#</isNotEmpty>
			<isNotEmpty prepend=',' property='recordabnormalcount'>#recordabnormalcount#</isNotEmpty>
			<isNotEmpty prepend=',' property='recordintactrate'>#recordintactrate#</isNotEmpty>
			<isNotEmpty prepend=',' property='createTime'>#createTime#</isNotEmpty>
			<isNotEmpty prepend=',' property='updateTime'>#updateTime#</isNotEmpty>

		 </dynamic>  
	    <![CDATA[ 
	        ) 
	    ]]> 
	</insert>
	
	<!-- edit object  -->
	<update id="update_Ywcountarearecord" parameterClass="java.util.Map">
		update ywcountarearecord 
		<dynamic prepend="set ">   
			
			<isNotEmpty prepend=',' property='areanum'>areanum=#areanum#</isNotEmpty>
			<isNotEmpty prepend=',' property='areaname'>areaname=#areaname#</isNotEmpty>
			<isNotEmpty prepend=',' property='countMonth'>countMonth=#countMonth#</isNotEmpty>
			<isNotEmpty prepend=',' property='countDate'>countDate=#countDate#</isNotEmpty>
			<isNotEmpty prepend=',' property='countHour'>countHour=#countHour#</isNotEmpty>
			<isNotEmpty prepend=',' property='videocount'>videocount=#videocount#</isNotEmpty>
			<isNotEmpty prepend=',' property='noconfigcount'>noconfigcount=#noconfigcount#</isNotEmpty>
			<isNotEmpty prepend=',' property='recordnormalcount'>recordnormalcount=#recordnormalcount#</isNotEmpty>
			<isNotEmpty prepend=',' property='recordabnormalcount'>recordabnormalcount=#recordabnormalcount#</isNotEmpty>
			<isNotEmpty prepend=',' property='recordintactrate'>recordintactrate=#recordintactrate#</isNotEmpty>
			<isNotEmpty prepend=',' property='createTime'>createTime=#createTime#</isNotEmpty>
			<isNotEmpty prepend=',' property='updateTime'>updateTime=#updateTime#</isNotEmpty>

		</dynamic>
		where 1=1 
			<isNotEmpty prepend='AND' property='XGTJcountId'> countId = #XGTJcountId#</isNotEmpty>
			<isNotEmpty prepend='AND' property='XGTJareanum'> areanum = #XGTJareanum# </isNotEmpty>
			<isNotEmpty prepend='AND' property='XGTJareaname'> areaname = #XGTJareaname# </isNotEmpty>
			<isNotEmpty prepend='AND' property='XGTJcountMonth'> countMonth = #XGTJcountMonth# </isNotEmpty>
			<isNotEmpty prepend='AND' property='XGTJcountDate'> countDate = #XGTJcountDate# </isNotEmpty>
			<isNotEmpty prepend='AND' property='XGTJcountHour'> countHour = #XGTJcountHour# </isNotEmpty>
			<isNotEmpty prepend='AND' property='XGTJvideocount'> videocount = #XGTJvideocount# </isNotEmpty>
			<isNotEmpty prepend='AND' property='XGTJnoconfigcount'> noconfigcount = #XGTJnoconfigcount# </isNotEmpty>
			<isNotEmpty prepend='AND' property='XGTJrecordnormalcount'> recordnormalcount = #XGTJrecordnormalcount# </isNotEmpty>
			<isNotEmpty prepend='AND' property='XGTJrecordabnormalcount'> recordabnormalcount = #XGTJrecordabnormalcount# </isNotEmpty>
			<isNotEmpty prepend='AND' property='XGTJrecordintactrate'> recordintactrate = #XGTJrecordintactrate# </isNotEmpty>
			<isNotEmpty prepend='AND' property='XGTJcreateTime'> createTime = #XGTJcreateTime# </isNotEmpty>
			<isNotEmpty prepend='AND' property='XGTJupdateTime'> updateTime = #XGTJupdateTime# </isNotEmpty>

	</update>
	
	<!-- delete object -->
	<delete id="delete_Ywcountarearecord" parameterClass="java.util.Map">
		delete from ywcountarearecord 
		<include refid="condition_Ywcountarearecord"/>
	</delete>
	
	<!-- batch delete object -->
	<delete id="batch_delete_Ywcountarearecord" parameterClass="java.util.Map">
		delete from ywcountarearecord 
		where 1=1
			<isNotEmpty prepend='AND' property='keyword'>
			key  in (#keyword#)
			</isNotEmpty>
	</delete>
	
	<!-- query objects by page-->
	<select id="query_Ywcountarearecord" resultClass="java.util.HashMap" parameterClass="java.util.Map">
		select 
			countId,areanum,areaname,countMonth,countDate,countHour,videocount,noconfigcount,recordnormalcount,recordabnormalcount,recordintactrate,createTime,updateTime
		from ywcountarearecord 
		<include refid="condition_Ywcountarearecord"/>		
	</select>
	<select id="listareaRecordCount" resultClass="java.util.HashMap" parameterClass="java.util.Map">
		SELECT a.areanum,a.areaname,
		(select count(*)     from ywrecordcurrentstate b      where b.VIDEOCATALOG=a.areanum  ) as configcount,  
		<!-- SUM(noconfigcount) as configcount, -->
			SUM(recordnormalcount) as recordnormalcount,SUM(recordabnormalcount) as recordabnormalcount,
			(select count(*) from ywvideosyncchannel  e
				<isNotEmpty prepend=' ' property='bmbh'>
				 	right JOIN sbtdjqqx m on (m.sbbh=e.videonum and m.tdbh=e.channelnum )
				</isNotEmpty> 
				where 
				(e.admincatalogue = a.areanum  <!-- or (e.xzbh in (select xzbh from ptxzs where sjxzbh = a.areanum))  -->)
				<isNotEmpty prepend='and' property='bmbh'>
					 m.bmbh = #bmbh#
				</isNotEmpty> 
			
			) as totalnum
		FROM ywcountarearecord  a
		WHERE 1=1
		<isNotEmpty prepend="AND"  property='areanum'>
			(a.areanum = #areanum# or (a.areanum in (select xzbh from ptxzs where sjxzbh = a.areanum))
		</isNotEmpty>
		<isNotEmpty property='tableparam'>
			$tableparam$
		</isNotEmpty>
			
		GROUP BY
			a.areanum,a.areaname
		<isNotEmpty property='order'>
			$order$
		</isNotEmpty>
		<!-- <isNotEmpty property='start'>
			limit $start$ , $limit$
		</isNotEmpty>  -->
			
	</select>
	<select id="count_listareaRecordCount" resultClass="java.lang.Integer" parameterClass="java.util.Map">
		select count(*) from (
			SELECT a.areanum,a.areaname
		FROM ywcountarearecord  a
		WHERE 1=1
		<isNotEmpty prepend="AND"  property='areanum'>
			(a.areanum = #areanum# or (a.areanum in (select xzbh from ptxzs where sjxzbh = a.areanum))
		</isNotEmpty>
		<isNotEmpty property='tableparam'>
			$tableparam$
		</isNotEmpty>
		GROUP BY
			a.areanum,a.areaname
		) m
			
	</select>
	
	<!-- query objects totalcount -->
	<select id="count_Ywcountarearecord" resultClass="java.lang.Integer" parameterClass="java.util.Map">
		select count(*) from ywcountarearecord 
		<include refid="condition_Ywcountarearecord"/>			
	</select>
	
	<!-- batch add objects -->
	<insert id="batch_insert_Ywcountarearecord" parameterClass="java.util.List">
	 	<![CDATA[
          INSERT
      	]]>
      	<iterate conjunction=" " > 
			into ywcountarearecord(
			 <![CDATA[ 
				countId,areanum,areaname,countMonth,countDate,countHour,videocount,noconfigcount,recordnormalcount,recordabnormalcount,recordintactrate,createTime,updateTime
			)values
			 ]]>  		 
			 <![CDATA[ 
				(
				#list[].countId#,#list[].areanum#,#list[].areaname#,#list[].countMonth#,#list[].countDate#,#list[].countHour#,#list[].videocount#,#list[].noconfigcount#,#list[].recordnormalcount#,#list[].recordabnormalcount#,#list[].recordintactrate#,#list[].createTime#,#list[].updateTime#
				)
			]]>    
    	</iterate> 
	</insert>
</sqlMap>











