<?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="Ywvideotaskrunsetbean" type="cn.vp.XXX.model.YwvideotaskrunsetBean"/> -->	<typeAlias alias="Ywvideotaskrunset" type="cn.im.ywvideotaskrunset.YwvideotaskrunsetBean"/>
	
	<sql id="condition_Ywvideotaskrunset">
		where 1=1
		<isNotEmpty prepend='AND ' property='LIKErunsetid'>
			(runsetid like '%$LIKErunsetid$%'   )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='runsetid'>
			(runsetid = #runsetid#  )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='LIKEtaskid'>
			(taskid like '%$LIKEtaskid$%'  )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='taskid'>
			(taskid = #taskid# )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='LIKEtaskname'>
			(taskname like '%$LIKEtaskname$%'  )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='taskname'>
			(taskname = #taskname# )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='LIKEtasktype'>
			(tasktype like '%$LIKEtasktype$%'  )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='tasktype'>
			(tasktype = #tasktype# )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='LIKEchannelsetid'>
			(channelsetid like '%$LIKEchannelsetid$%'  )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='channelsetid'>
			(channelsetid = #channelsetid# )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='LIKErunstatus'>
			(runstatus like '%$LIKErunstatus$%'  )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='runstatus'>
			(runstatus = #runstatus# )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='LIKErunprogress'>
			(runprogress like '%$LIKErunprogress$%'  )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='runprogress'>
			(runprogress = #runprogress# )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='LIKEruntime'>
			(runtime like '%$LIKEruntime$%'  )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='runtime'>
			(runtime = #runtime# )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='LIKEcreateaccount'>
			(createaccount like '%$LIKEcreateaccount$%'  )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='createaccount'>
			(createaccount = #createaccount# )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='LIKEcreatetime'>
			(createtime like '%$LIKEcreatetime$%'  )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='createtime'>
			(createtime = #createtime# )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='LIKEmodifyaccount'>
			(modifyaccount like '%$LIKEmodifyaccount$%'  )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='modifyaccount'>
			(modifyaccount = #modifyaccount# )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='LIKEmodifytime'>
			(modifytime like '%$LIKEmodifytime$%'  )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='modifytime'>
			(modifytime = #modifytime# )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='LIKEremarks'>
			(remarks like '%$LIKEremarks$%'  )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='remarks'>
			(remarks = #remarks# )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='LIKEextend1'>
			(extend1 like '%$LIKEextend1$%'  )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='extend1'>
			(extend1 = #extend1# )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='LIKEextend2'>
			(extend2 like '%$LIKEextend2$%'  )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='extend2'>
			(extend2 = #extend2# )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='LIKEextend3'>
			(extend3 like '%$LIKEextend3$%'  )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='extend3'>
			(extend3 = #extend3# )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='LIKEextend4'>
			(extend4 like '%$LIKEextend4$%'  )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='extend4'>
			(extend4 = #extend4# )
		</isNotEmpty>
		<isNotEmpty property='tableparam'>
			$tableparam$
		</isNotEmpty>
		<isNotEmpty property='order'>
			$order$
		</isNotEmpty>
	</sql>
	
	<!-- add object -->
	<insert id="insert_Ywvideotaskrunset" parameterClass="java.util.Map">
		insert into 
		ywvideotaskrunset(
		<dynamic prepend=" ">  
			<isNotEmpty prepend=',' property='runsetid'>runsetid</isNotEmpty>
			<isNotEmpty prepend=',' property='taskid'>taskid</isNotEmpty>
			<isNotEmpty prepend=',' property='taskname'>taskname</isNotEmpty>
			<isNotEmpty prepend=',' property='tasktype'>tasktype</isNotEmpty>
			<isNotEmpty prepend=',' property='channelsetid'>channelsetid</isNotEmpty>
			<isNotEmpty prepend=',' property='runstatus'>runstatus</isNotEmpty>
			<isNotEmpty prepend=',' property='runprogress'>runprogress</isNotEmpty>
			<isNotEmpty prepend=',' property='runtime'>runtime</isNotEmpty>
			<isNotEmpty prepend=',' property='createaccount'>createaccount</isNotEmpty>
			<isNotEmpty prepend=',' property='createtime'>createtime</isNotEmpty>
			<isNotEmpty prepend=',' property='modifyaccount'>modifyaccount</isNotEmpty>
			<isNotEmpty prepend=',' property='modifytime'>modifytime</isNotEmpty>
			<isNotEmpty prepend=',' property='remarks'>remarks</isNotEmpty>
			<isNotEmpty prepend=',' property='extend1'>extend1</isNotEmpty>
			<isNotEmpty prepend=',' property='extend2'>extend2</isNotEmpty>
			<isNotEmpty prepend=',' property='extend3'>extend3</isNotEmpty>
			<isNotEmpty prepend=',' property='extend4'>extend4</isNotEmpty>

		</dynamic>  
	    <![CDATA[ 
	        ) values ( 
	    ]]>  
	     <dynamic prepend=" "> 
			<isNotEmpty prepend=',' property='runsetid'>#runsetid#</isNotEmpty>
			<isNotEmpty prepend=',' property='taskid'>#taskid#</isNotEmpty>
			<isNotEmpty prepend=',' property='taskname'>#taskname#</isNotEmpty>
			<isNotEmpty prepend=',' property='tasktype'>#tasktype#</isNotEmpty>
			<isNotEmpty prepend=',' property='channelsetid'>#channelsetid#</isNotEmpty>
			<isNotEmpty prepend=',' property='runstatus'>#runstatus#</isNotEmpty>
			<isNotEmpty prepend=',' property='runprogress'>#runprogress#</isNotEmpty>
			<isNotEmpty prepend=',' property='runtime'>#runtime#</isNotEmpty>
			<isNotEmpty prepend=',' property='createaccount'>#createaccount#</isNotEmpty>
			<isNotEmpty prepend=',' property='createtime'>#createtime#</isNotEmpty>
			<isNotEmpty prepend=',' property='modifyaccount'>#modifyaccount#</isNotEmpty>
			<isNotEmpty prepend=',' property='modifytime'>#modifytime#</isNotEmpty>
			<isNotEmpty prepend=',' property='remarks'>#remarks#</isNotEmpty>
			<isNotEmpty prepend=',' property='extend1'>#extend1#</isNotEmpty>
			<isNotEmpty prepend=',' property='extend2'>#extend2#</isNotEmpty>
			<isNotEmpty prepend=',' property='extend3'>#extend3#</isNotEmpty>
			<isNotEmpty prepend=',' property='extend4'>#extend4#</isNotEmpty>

		 </dynamic>  
	    <![CDATA[ 
	        ) 
	    ]]> 
	</insert>
	
	<!-- edit object  -->
	<update id="update_Ywvideotaskrunset" parameterClass="java.util.Map">
		update ywvideotaskrunset 
		<dynamic prepend="set ">   
			
			<isNotEmpty prepend=',' property='taskid'>taskid=#taskid#</isNotEmpty>
			<isNotEmpty prepend=',' property='taskname'>taskname=#taskname#</isNotEmpty>
			<isNotEmpty prepend=',' property='tasktype'>tasktype=#tasktype#</isNotEmpty>
			<isNotEmpty prepend=',' property='channelsetid'>channelsetid=#channelsetid#</isNotEmpty>
			<isNotEmpty prepend=',' property='runstatus'>runstatus=#runstatus#</isNotEmpty>
			<isNotEmpty prepend=',' property='runprogress'>runprogress=#runprogress#</isNotEmpty>
			<isNotEmpty prepend=',' property='runtime'>runtime=#runtime#</isNotEmpty>
			<isNotEmpty prepend=',' property='createaccount'>createaccount=#createaccount#</isNotEmpty>
			<isNotEmpty prepend=',' property='createtime'>createtime=#createtime#</isNotEmpty>
			<isNotEmpty prepend=',' property='modifyaccount'>modifyaccount=#modifyaccount#</isNotEmpty>
			<isNotEmpty prepend=',' property='modifytime'>modifytime=#modifytime#</isNotEmpty>
			<isNotEmpty prepend=',' property='remarks'>remarks=#remarks#</isNotEmpty>
			<isNotEmpty prepend=',' property='extend1'>extend1=#extend1#</isNotEmpty>
			<isNotEmpty prepend=',' property='extend2'>extend2=#extend2#</isNotEmpty>
			<isNotEmpty prepend=',' property='extend3'>extend3=#extend3#</isNotEmpty>
			<isNotEmpty prepend=',' property='extend4'>extend4=#extend4#</isNotEmpty>

		</dynamic>
		where runsetid = #XGTJrunsetid#
			<isNotEmpty prepend='AND ' property='XGTJtaskid'> taskid = #XGTJtaskid# </isNotEmpty>
			<isNotEmpty prepend='AND ' property='XGTJtaskname'> taskname = #XGTJtaskname# </isNotEmpty>
			<isNotEmpty prepend='AND ' property='XGTJtasktype'> tasktype = #XGTJtasktype# </isNotEmpty>
			<isNotEmpty prepend='AND ' property='XGTJchannelsetid'> channelsetid = #XGTJchannelsetid# </isNotEmpty>
			<isNotEmpty prepend='AND ' property='XGTJrunstatus'> runstatus = #XGTJrunstatus# </isNotEmpty>
			<isNotEmpty prepend='AND ' property='XGTJrunprogress'> runprogress = #XGTJrunprogress# </isNotEmpty>
			<isNotEmpty prepend='AND ' property='XGTJruntime'> runtime = #XGTJruntime# </isNotEmpty>
			<isNotEmpty prepend='AND ' property='XGTJcreateaccount'> createaccount = #XGTJcreateaccount# </isNotEmpty>
			<isNotEmpty prepend='AND ' property='XGTJcreatetime'> createtime = #XGTJcreatetime# </isNotEmpty>
			<isNotEmpty prepend='AND ' property='XGTJmodifyaccount'> modifyaccount = #XGTJmodifyaccount# </isNotEmpty>
			<isNotEmpty prepend='AND ' property='XGTJmodifytime'> modifytime = #XGTJmodifytime# </isNotEmpty>
			<isNotEmpty prepend='AND ' property='XGTJremarks'> remarks = #XGTJremarks# </isNotEmpty>
			<isNotEmpty prepend='AND ' property='XGTJextend1'> extend1 = #XGTJextend1# </isNotEmpty>
			<isNotEmpty prepend='AND ' property='XGTJextend2'> extend2 = #XGTJextend2# </isNotEmpty>
			<isNotEmpty prepend='AND ' property='XGTJextend3'> extend3 = #XGTJextend3# </isNotEmpty>
			<isNotEmpty prepend='AND ' property='XGTJextend4'> extend4 = #XGTJextend4# </isNotEmpty>

	</update>
	
	<!-- delete object -->
	<delete id="delete_Ywvideotaskrunset" parameterClass="java.util.Map">
		delete from ywvideotaskrunset 
		<include refid="condition_Ywvideotaskrunset"/>
	</delete>
	
	<!-- batch delete object -->
	<delete id="batch_delete_Ywvideotaskrunset" parameterClass="java.util.Map">
		delete from ywvideotaskrunset 
		where 1=1
			<isNotEmpty prepend='AND ' property='keyword'>
			key  in (#keyword#)
			</isNotEmpty>
	</delete>
	
	<!-- query objects by page-->
	<select id="query_Ywvideotaskrunset" resultClass="java.util.HashMap" parameterClass="java.util.Map">
		select 
			runsetid,taskid,taskname,
			tasktype,(select csmc from xtcl where csdl='ywVideoTaskType' and csdm=tasktype) as tasktypename,
			runstatus,(select csmc from xtcl where csdl='ywTaskRunStatus' and csdm=runstatus) as runstatusname,
			channelsetid,runprogress,runtime,createaccount,createtime,modifyaccount,modifytime,remarks,extend1,extend2,extend3,extend4
		from ywvideotaskrunset 
		<include refid="condition_Ywvideotaskrunset"/>	
	</select>

	<select id="query_ywvideotaskcompleterate" resultClass="java.util.HashMap" parameterClass="java.util.Map">
		select 
			a.runsetid,a.taskid,a.taskname,
			a.tasktype,(select csmc from xtcl where csdl='ywVideoTaskType' and csdm=a.tasktype) as tasktypename,
			a.runtime,count(b.runsetid) as sbzs,sum(b.sbdrzs) as sbdrzs,sum(b.onlinestotal) as onlinestotal, sum(b.totalnormal) as totalnormal, sum(b.totalczzx) as totalczzx,sum(b.totallxczwh) as totallxczwh 
		from ywvideotaskrunset a left join (
			select 
				runsetid,taskid,videonum,channelnum,count(*) as sbdrzs,sum(case when isonline = '1' then isonline else 0 end) as onlinestotal,sum(case when nosignalstatus = '1' and videoocclusionstatus = '1' and scenechangestatus = '1' and imgtoodarkstatus = '1' and imgoverbrightstatus = '1' and imgclearstatus = '1' and imgcolorstatus = '1' then '1' else '0' end) as totalnormal,sum(case when videostatus = '1' or videostatus = '104' then '1' else '0' end) as totalczzx,sum(case when videostatus = '1' then '1' else '0' end) as totallxczwh 
			from ywvideotaskrunresulthistory 
			where 1=1 
			group by runsetid,taskid,videonum,channelnum
		) b
		on a.runsetid = b.runsetid and a.taskid = b.taskid
		where 1=1 
		<isNotEmpty prepend='AND ' property='tasktype'>
			a.tasktype = #tasktype#
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='LIKEtaskname'>
			a.taskname like '%$LIKEtaskname$%'
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='startruntime'>
			<![CDATA[
				a.runtime >= #startruntime#
			]]>
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='endruntime'>
			<![CDATA[
				a.runtime <= #endruntime#
			]]>
		</isNotEmpty>
		group by a.runsetid,a.taskid,a.taskname,a.tasktype,a.runtime
		order by a.runtime desc
	</select>
	
	<!-- query objects totalcount -->
	<select id="count_Ywvideotaskrunset" resultClass="java.lang.Integer" parameterClass="java.util.Map">
		select count(*) from ywvideotaskrunset 
		<include refid="condition_Ywvideotaskrunset"/>			
	</select>
	
	<!-- batch add objects -->
	<insert id="batch_insert_Ywvideotaskrunset" parameterClass="java.util.List">
	 	<![CDATA[
          INSERT
      	]]>
      	<iterate conjunction=" " > 
			into ywvideotaskrunset(
			 <![CDATA[ 
				runsetid,taskid,taskname,tasktype,channelsetid,runstatus,runprogress,runtime,createaccount,createtime,modifyaccount,modifytime,remarks,extend1,extend2,extend3,extend4
			)values
			 ]]>  		 
			 <![CDATA[ 
				(
				#list[].runsetid#,#list[].taskid#,#list[].taskname#,#list[].tasktype#,#list[].channelsetid#,#list[].runstatus#,#list[].runprogress#,#list[].runtime#,#list[].createaccount#,#list[].createtime#,#list[].modifyaccount#,#list[].modifytime#,#list[].remarks#,#list[].extend1#,#list[].extend2#,#list[].extend3#,#list[].extend4#
				)
			]]>    
    	</iterate> 
	</insert>


</sqlMap>











