<?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="Ptyhcdjs">
	<!-- <typeAlias alias="Ptyhcdjsbean" type="com.vp.XXX.model.PtyhcdjsBean"/> -->

	<sql id="condition_Ptyhcdjs">
		where 1=1
		<isNotEmpty prepend='AND ' property='LIKExh'>
			(xh like '%$LIKExh$%')
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='xh'>
			(xh = #xh# )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='LIKEyhbh'>
			(yhbh like '%$LIKEyhbh$%')
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='yhbh'>
			(yhbh = #yhbh# )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='LIKEjsbh'>
			(jsbh like '%$LIKEjsbh$%')
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='jsbh'>
			(jsbh = #jsbh# )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='LIKEcjry'>
			(cjry like '%$LIKEcjry$%' )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='cjry'>
			(cjry = #cjry# )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='LIKEcjrq'>
			(cjrq like '%$LIKEcjrq$%')
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='cjrq'>
			(cjrq = #cjrq# )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='LIKExgry'>
			(xgry like '%$LIKExgry$%' )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='xgry'>
			(xgry = #xgry# )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='LIKExgrq'>
			(xgrq like '%$LIKExgrq$%' )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='xgrq'>
			(xgrq = #xgrq# )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='LIKEbz'>
			(bz like '%$LIKEbz$%' )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='bz'>
			(bz = #bz# )
		</isNotEmpty>
		<isNotEmpty property='tableparam'>
			$tableparam$
		</isNotEmpty>
		<isNotEmpty property='order'>
			$order$
		</isNotEmpty>
	</sql>

	<select id="ptyhcdjs_query_ptyhmenu" resultClass="java.util.HashMap"
	parameterClass="java.util.Map">
		select  xh,yhbh,jsbh,cjry,cjrq,xgry,xgrq,bz from Ptyhcdjs 
		<include refid="condition_Ptyhcdjs"/>
	</select>
	<select id="query_Ptyhcdjs" resultClass="java.util.HashMap" 
 		parameterClass="java.util.Map">
 		select
 		xh,yhbh,jsbh,cjry,cjrq,xgry,xgrq,bz
 		from Ptyhcdjs
 		<include refid="condition_Ptyhcdjs" />
 	</select>

 	<select id="count_Ptyhcdjs" resultClass="java.lang.Integer"
 		parameterClass="java.util.Map">
 		select count(*) from Ptyhcdjs
 		<include refid="condition_Ptyhcdjs" />
 	</select>
	<!-- chenl-->
	<select id="query_ptyh_alreadyIn" resultClass="java.util.HashMap" parameterClass="java.util.Map">
		select 
			distinct b.yhbh,a.jsbh,b.yhmc ,b.yhzh
		from ptyhcdjs a left join ptyh b on a.yhbh = b.yhbh 	
		where 1=1	 and b.yhzh is not null
		<isNotEmpty prepend='AND ' property='yhmc'>
			(b.yhmc like '%$yhmc$%' )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='yhmcyhzh'>
			(b.yhmc like '%$yhmcyhzh$%' or b.yhzh like '%$yhmcyhzh$%' )
		</isNotEmpty>
		<isNotEmpty prepend='AND ' property='jsbh'>
			(a.jsbh = #jsbh# )
		</isNotEmpty>
		<isNotEmpty property='order'>
			$order$
		</isNotEmpty>
	</select>
	
	<select id="count_ptyh_alreadyIn" resultClass="java.lang.Integer" parameterClass="java.util.Map">
		select count(*) from(
			select distinct b.yhbh,a.jsbh,b.yhmc ,b.yhzh
			from ptyhcdjs a left join ptyh b on a.yhbh = b.yhbh 	
			where 1=1	 and b.yhzh is not null
			<isNotEmpty prepend='AND ' property='yhmc'>
				(b.yhmc like '%$yhmc$%' )
			</isNotEmpty>
			<isNotEmpty prepend='AND ' property='yhmcyhzh'>
				(b.yhmc like '%$yhmcyhzh$%' or b.yhzh like '%$yhmcyhzh$%' )
			</isNotEmpty>
			<isNotEmpty prepend='AND ' property='jsbh'>
				(a.jsbh = #jsbh# )
			</isNotEmpty>
		)x
	</select>
	
	<select id="query_ptyh_alreadyOut" resultClass="java.util.HashMap" parameterClass="java.util.Map">
	  	select  a.yhbh,a.yhmc,a.yhzh from ptyh a
	  		where 1=1  and yhzh is not null  
			and a.yhbh not in (select b.yhbh from ptyhcdjs b   where b.jsbh = #jsbh# )
			<isNotEmpty prepend='AND ' property='yhmc'>
				(a.yhmc like '%#yhmc#%' )
			</isNotEmpty>
 			<isNotEmpty prepend='AND ' property='yhmcyhzh'>
				(a.yhmc like '%$yhmcyhzh$%' or a.yhzh like '%$yhmcyhzh$%' )
			</isNotEmpty>
			<isNotEmpty property='order'>
				$order$
			</isNotEmpty>
	</select> 
	<select id="count_ptyh_alreadyOut"  resultClass="java.lang.Integer"  parameterClass="java.util.Map">
	  	select count(a.yhbh) from ptyh a
	  		where 1=1  and yhzh is not null  
			and a.yhbh not in (select b.yhbh from ptyhcdjs b   where b.jsbh = #jsbh# )
			<isNotEmpty prepend='AND ' property='yhmc'>
				(a.yhmc like '%#yhmc#%' )
			</isNotEmpty>
 			<isNotEmpty prepend='AND ' property='yhmcyhzh'>
				(a.yhmc like '%$yhmcyhzh$%' or a.yhzh like '%$yhmcyhzh$%' )
			</isNotEmpty>
	</select>
	
	<delete id="delete_PtyhcdjsByjsbh" parameterClass="java.util.Map">
		delete from Ptyhcdjs where jsbh = #jsbh# and yhbh = #yhbh#
	</delete>
	
	<delete id="delete_Ptyhcdjs" parameterClass="java.util.Map">
 		delete from Ptyhcdjs
 		<include refid="condition_Ptyhcdjs" />
 	</delete>

	
	<insert id="insert_PtyhcdjsByjsbh" parameterClass="java.util.Map">
	   insert into Ptyhcdjs(
			<isNotNull prepend='' property='xh'>xh</isNotNull>
			<isNotNull prepend=',' property='ssxm'>ssxm</isNotNull>
			<isNotNull prepend=',' property='yhbh'>yhbh</isNotNull>
			<isNotNull prepend=',' property='jsbh'>jsbh</isNotNull>
			<isNotNull prepend=',' property='cjry'>cjry</isNotNull>
			<isNotNull prepend=',' property='cjrq'>cjrq</isNotNull>
			<isNotNull prepend=',' property='xgry'>xgry</isNotNull>
			<isNotNull prepend=',' property='xgrq'>xgrq</isNotNull>
			<isNotNull prepend=',' property='bz'>bz</isNotNull> 
		 )values( 
			<isNotNull prepend='' property='xh'>#xh#</isNotNull>  
			<isNotNull prepend=',' property='ssxm'>#ssxm#</isNotNull>
			<isNotNull prepend=',' property='yhbh'>#yhbh#</isNotNull> 
			<isNotNull prepend=',' property='jsbh'>#jsbh#</isNotNull> 
			<isNotNull prepend=',' property='cjry'>#cjry#</isNotNull> 
			<isNotNull prepend=',' property='cjrq'>#cjrq#</isNotNull> 
			<isNotNull prepend=',' property='xgry'>#xgry#</isNotNull> 
			<isNotNull prepend=',' property='xgrq'>#xgrq#</isNotNull> 
			<isNotNull prepend=',' property='bz'>#bz#</isNotNull>     
		 )  
	</insert>

<!-- 	<update id="update_Ptyhcdjs" parameterClass="java.util.Map"> -->
<!-- 		update Ptyhcdjs set -->
<!-- 		xh = xh -->
<!-- 		<isNotEmpty prepend=',' property='yhbh'>yhbh=#yhbh#</isNotEmpty> -->
<!-- 		<isNotEmpty prepend=',' property='jsbh'>jsbh=#jsbh#</isNotEmpty> -->
<!-- 		<isNotEmpty prepend=',' property='cjry'>cjry=#cjry#</isNotEmpty> -->
<!-- 		<isNotEmpty prepend=',' property='cjrq'>cjrq=#cjrq#</isNotEmpty> -->
<!-- 		<isNotEmpty prepend=',' property='xgry'>xgry=#xgry#</isNotEmpty> -->
<!-- 		<isNotEmpty prepend=',' property='xgrq'>xgrq=#xgrq#</isNotEmpty> -->
<!-- 		<isNotEmpty prepend=',' property='bz'>bz=#bz#</isNotEmpty> -->

<!-- 		where 1=1 -->
<!-- 		<isNotEmpty prepend='AND ' property='XGTJxh'> -->
<!-- 			xh= #XGTJxh# -->
<!-- 		</isNotEmpty> -->
<!-- 		<isNotEmpty prepend='AND ' property='XGTJyhbh'> -->
<!-- 			yhbh= #XGTJyhbh# -->
<!-- 		</isNotEmpty> -->
<!-- 		<isNotEmpty prepend='AND ' property='XGTJjsbh'> -->
<!-- 			jsbh= #XGTJjsbh# -->
<!-- 		</isNotEmpty> -->
<!-- 		<isNotEmpty prepend='AND ' property='XGTJcjry'> -->
<!-- 			cjry= #XGTJcjry# -->
<!-- 		</isNotEmpty> -->
<!-- 		<isNotEmpty prepend='AND ' property='XGTJcjrq'> -->
<!-- 			cjrq= #XGTJcjrq# -->
<!-- 		</isNotEmpty> -->
<!-- 		<isNotEmpty prepend='AND ' property='XGTJxgry'> -->
<!-- 			xgry= #XGTJxgry# -->
<!-- 		</isNotEmpty> -->
<!-- 		<isNotEmpty prepend='AND ' property='XGTJxgrq'> -->
<!-- 			xgrq= #XGTJxgrq# -->
<!-- 		</isNotEmpty> -->
<!-- 		<isNotEmpty prepend='AND ' property='XGTJbz'> -->
<!-- 			bz= #XGTJbz# -->
<!-- 		</isNotEmpty> -->

<!-- 	</update> -->

<!-- 	<delete id="delete_Ptyhcdjs" parameterClass="java.util.Map"> -->
<!-- 		delete from Ptyhcdjs -->
<!-- 		<include refid="condition_Ptyhcdjs" /> -->
<!-- 	</delete> -->

<!-- 	<delete id="batch_delete_Ptyhcdjs" parameterClass="java.util.Map"> -->
<!-- 		delete from Ptyhcdjs -->
<!-- 		where 1=1 -->
<!-- 		<isNotNull prepend='AND ' property='keyword'> -->
<!-- 			key in (#keyword#) -->
<!-- 		</isNotNull> -->
<!-- 	</delete> -->


<!-- 	<insert id="batch_insert_Ptyhcdjs" parameterClass="java.util.List"> -->
<!-- 	 	<![CDATA[ -->
<!--           INSERT ALL -->
<!--       	]]> -->
<!-- 		<iterate conjunction=" "> -->
<!-- 			into Ptyhcdjs( -->
<!-- 			 <![CDATA[  -->
<!-- 				xh,yhbh,jsbh,cjry,cjrq,xgry,xgrq,bz -->
<!-- 			)values -->
<!-- 			 ]]>  		  -->
<!-- 			 <![CDATA[  -->
<!-- 				( -->
<!-- 			#list[].xh# -->
<!-- 				) -->
<!-- 			]]> -->
<!-- 		</iterate> -->
<!-- 	</insert> -->
</sqlMap>