<?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="Sbtdjqqx">
	<!-- <typeAlias alias="Sbtdjqqxbean" type="com.vp.XXX.model.SbtdjqqxBean"/> -->

	<sql id="condition_Sbtdjqqx">
		where 1=1
		<isNotEmpty prepend='AND' property='LIKExh'>
			(xh like
			concat('%',#LIKExh# ,'%') )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='xh'>
			(xh = #xh# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKEkhbh'>
			(khbh like
			concat('%',#LIKEkhbh# ,'%') )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='khbh'>
			(khbh = #khbh# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKEbmbh'>
			(bmbh like
			concat('%',#LIKEbmbh# ,'%') )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='bmbh'>
			(bmbh = #bmbh# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKEsbbh'>
			(sbbh like
			concat('%',#LIKEsbbh# ,'%') )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='sbbh'>
			(sbbh = #sbbh# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKEtdbh'>
			(tdbh like
			concat('%',#LIKEtdbh# ,'%') )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='tdbh'>
			(tdbh = #tdbh# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKEtdlx'>
			(tdlx like
			concat('%',#LIKEtdlx# ,'%') )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='tdlx'>
			(tdlx = #tdlx# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKEdqx'>
			(dqx like
			concat('%',#LIKEdqx# ,'%') )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='dqx'>
			(dqx = #dqx# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKExqx'>
			(xqx like
			concat('%',#LIKExqx# ,'%') )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='xqx'>
			(xqx = #xqx# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKEkqx'>
			(kqx like
			concat('%',#LIKEkqx# ,'%') )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='kqx'>
			(kqx = #kqx# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKEpqx'>
			(pqx like
			concat('%',#LIKEpqx# ,'%') )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='pqx'>
			(pqx = #pqx# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKElxhfqx'>
			(lxhfqx like
			concat('%',#LIKElxhfqx# ,'%') )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='lxhfqx'>
			(lxhfqx = #lxhfqx# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKElxxzqx'>
			(lxxzqx like
			concat('%',#LIKElxxzqx# ,'%') )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='lxxzqx'>
			(lxxzqx = #lxxzqx# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKElxdjqx'>
			(lxdjqx like
			concat('%',#LIKElxdjqx# ,'%') )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='lxdjqx'>
			(lxdjqx = #lxdjqx# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKEcjry'>
			(cjry like
			concat('%',#LIKEcjry# ,'%') )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='cjry'>
			(cjry = #cjry# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKEcjrq'>
			(cjrq like
			concat('%',#LIKEcjrq# ,'%') )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='cjrq'>
			(cjrq = #cjrq# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKExgry'>
			(xgry like
			concat('%',#LIKExgry# ,'%') )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='xgry'>
			(xgry = #xgry# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKExgrq'>
			(xgrq like
			concat('%',#LIKExgrq# ,'%') )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='xgrq'>
			(xgrq = #xgrq# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKEbz'>
			(bz like
			concat('%',#LIKEbz# ,'%') )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='bz'>
			(bz = #bz# )
		</isNotEmpty>
		<isNotEmpty property='tableparam'>
			$tableparam$
		</isNotEmpty>
		<isNotEmpty property='order'>
			$order$
		</isNotEmpty>
	</sql>

	<!-- add object -->
	<insert id="insert_Sbtdjqqx" parameterClass="java.util.Map">
		insert into
		Sbtdjqqx(
		<dynamic prepend=" ">
			<isNotEmpty prepend=',' property='bmbh'>bmbh</isNotEmpty>
			<isNotEmpty prepend=',' property='sbbh'>sbbh</isNotEmpty>
			<isNotEmpty prepend=',' property='tdbh'>tdbh</isNotEmpty>
			<isNotEmpty prepend=',' property='xh'>xh</isNotEmpty>
			<isNotEmpty prepend=',' property='khbh'>khbh</isNotEmpty>
			<isNotEmpty prepend=',' property='tdlx'>tdlx</isNotEmpty>
			<isNotEmpty prepend=',' property='dqx'>dqx</isNotEmpty>
			<isNotEmpty prepend=',' property='xqx'>xqx</isNotEmpty>
			<isNotEmpty prepend=',' property='kqx'>kqx</isNotEmpty>
			<isNotEmpty prepend=',' property='pqx'>pqx</isNotEmpty>
			<isNotEmpty prepend=',' property='lxhfqx'>lxhfqx</isNotEmpty>
			<isNotEmpty prepend=',' property='lxxzqx'>lxxzqx</isNotEmpty>
			<isNotEmpty prepend=',' property='lxdjqx'>lxdjqx</isNotEmpty>
			<isNotEmpty prepend=',' property='cjry'>cjry</isNotEmpty>
			<isNotEmpty prepend=',' property='cjrq'>cjrq</isNotEmpty>
			<isNotEmpty prepend=',' property='xgry'>xgry</isNotEmpty>
			<isNotEmpty prepend=',' property='xgrq'>xgrq</isNotEmpty>
			<isNotEmpty prepend=',' property='bz'>bz</isNotEmpty>

		</dynamic>  
	    <![CDATA[ 
	        ) values ( 
	    ]]>
		<dynamic prepend=" ">
			<isNotEmpty prepend=',' property='bmbh'>#bmbh#</isNotEmpty>
			<isNotEmpty prepend=',' property='sbbh'>#sbbh#</isNotEmpty>
			<isNotEmpty prepend=',' property='tdbh'>#tdbh#</isNotEmpty>
			<isNotEmpty prepend=',' property='xh'>#xh#</isNotEmpty>
			<isNotEmpty prepend=',' property='khbh'>#khbh#</isNotEmpty>
			<isNotEmpty prepend=',' property='tdlx'>#tdlx#</isNotEmpty>
			<isNotEmpty prepend=',' property='dqx'>#dqx#</isNotEmpty>
			<isNotEmpty prepend=',' property='xqx'>#xqx#</isNotEmpty>
			<isNotEmpty prepend=',' property='kqx'>#kqx#</isNotEmpty>
			<isNotEmpty prepend=',' property='pqx'>#pqx#</isNotEmpty>
			<isNotEmpty prepend=',' property='lxhfqx'>#lxhfqx#</isNotEmpty>
			<isNotEmpty prepend=',' property='lxxzqx'>#lxxzqx#</isNotEmpty>
			<isNotEmpty prepend=',' property='lxdjqx'>#lxdjqx#</isNotEmpty>
			<isNotEmpty prepend=',' property='cjry'>#cjry#</isNotEmpty>
			<isNotEmpty prepend=',' property='cjrq'>#cjrq#</isNotEmpty>
			<isNotEmpty prepend=',' property='xgry'>#xgry#</isNotEmpty>
			<isNotEmpty prepend=',' property='xgrq'>#xgrq#</isNotEmpty>
			<isNotEmpty prepend=',' property='bz'>#bz#</isNotEmpty>

		</dynamic>  
	    <![CDATA[ 
	        ) 
	    ]]>
	</insert>

	<!-- edit object -->
	<update id="update_Sbtdjqqx" parameterClass="java.util.Map">
		update Sbtdjqqx
		<dynamic prepend="set ">
			<isNotEmpty prepend=',' property='khbh'>khbh=#khbh#</isNotEmpty>
			<isNotEmpty prepend=',' property='tdlx'>tdlx=#tdlx#</isNotEmpty>
			<isNotEmpty prepend=',' property='dqx'>dqx=#dqx#</isNotEmpty>
			<isNotEmpty prepend=',' property='xqx'>xqx=#xqx#</isNotEmpty>
			<isNotEmpty prepend=',' property='kqx'>kqx=#kqx#</isNotEmpty>
			<isNotEmpty prepend=',' property='pqx'>pqx=#pqx#</isNotEmpty>
			<isNotEmpty prepend=',' property='lxhfqx'>lxhfqx=#lxhfqx#
			</isNotEmpty>
			<isNotEmpty prepend=',' property='lxxzqx'>lxxzqx=#lxxzqx#
			</isNotEmpty>
			<isNotEmpty prepend=',' property='lxdjqx'>lxdjqx=#lxdjqx#
			</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>

		</dynamic>
		where 1=1
		<isNotEmpty prepend='AND' property='bmbh'>
			bmbh= #bmbh#
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='sbbh'>
			sbbh= #sbbh#
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='tdbh'>
			tdbh= #tdbh#
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='xh'>
			xh= #xh#
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='khbh'>
			khbh= #khbh#
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='tdlx'>
			tdlx= #tdlx#
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='dqx'>
			dqx= #dqx#
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='xqx'>
			xqx= #xqx#
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='kqx'>
			kqx= #kqx#
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='pqx'>
			pqx= #pqx#
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='lxhfqx'>
			lxhfqx= #lxhfqx#
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='lxxzqx'>
			lxxzqx= #lxxzqx#
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='lxdjqx'>
			lxdjqx= #lxdjqx#
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='cjry'>
			cjry= #cjry#
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='cjrq'>
			cjrq= #cjrq#
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='xgry'>
			xgry= #xgry#
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='xgrq'>
			xgrq= #xgrq#
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='bz'>
			bz= #bz#
		</isNotEmpty>

	</update>

	<!-- delete object -->
	<delete id="delete_Sbtdjqqx" parameterClass="java.util.Map">
		delete from Sbtdjqqx
		<include refid="condition_Sbtdjqqx" />
	</delete>

	<!-- batch delete object -->
	<delete id="batch_delete_Sbtdjqqx" parameterClass="java.util.Map">
		delete from Sbtdjqqx
		where 1=1
		<isNotEmpty prepend='AND' property='keyword'>
			key in (#keyword#)
		</isNotEmpty>
	</delete>

	<!-- query objects by page -->
	<select id="query_Sbtdjqqx" resultClass="java.util.HashMap"
		parameterClass="java.util.Map">
		select
		bmbh,sbbh,tdbh,xh,khbh,tdlx,dqx,xqx,kqx,pqx,lxhfqx,lxxzqx,lxdjqx,cjry,cjrq,xgry,xgrq,bz
		from Sbtdjqqx
		<include refid="condition_Sbtdjqqx" />
		
	</select>

	<!-- query objects totalcount -->
	<select id="count_Sbtdjqqx" resultClass="java.lang.Integer"
		parameterClass="java.util.Map">
		select count(*) from Sbtdjqqx
		<include refid="condition_Sbtdjqqx" />
	</select>
	
	<select id="query_Sbtdjqqx_userrole" resultClass="java.util.HashMap"
		parameterClass="java.util.Map">
		select td.tdmc,x.csmc as tdlxmc,
			qx.bmbh,qx.sbbh,qx.tdbh,qx.xh,qx.khbh,qx.tdlx,
			qx.dqx,qx.xqx,qx.kqx,qx.pqx,qx.lxhfqx,
			qx.lxxzqx,qx.lxdjqx,qx.cjry,qx.cjrq,qx.xgry,qx.xgrq,qx.bz
		from Sbtdjqqx qx 
		left join sbtdspsr td on qx.sbbh = td.sbbh and qx.tdbh = td.tdbh 
		left join xtcl x on x.csdm = qx.tdlx and x.csdl = 'channelSmallType'
		where 1=1
		<isNotEmpty prepend='AND' property='LIKEsbbh'>
			(qx.sbbh like concat('%',#LIKEsbbh# ,'%') )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='tdlx'>
			(qx.tdlx = #tdlx# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKEtdmc'>
			(td.tdmc like concat('%',#LIKEtdmc# ,'%') )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='bmbh'>
			(qx.bmbh = #bmbh# )
		</isNotEmpty>
		
	</select>

	<select id="count_Sbtdjqqx_userrole" resultClass="java.lang.Integer"
		parameterClass="java.util.Map">
		select count(*) from (
			select td.tdmc,x.csmc as tdlxmc,
				qx.bmbh,qx.sbbh,qx.tdbh,qx.xh,qx.khbh,qx.tdlx,
				qx.dqx,qx.xqx,qx.kqx,qx.pqx,qx.lxhfqx,
				qx.lxxzqx,qx.lxdjqx,qx.cjry,qx.cjrq,qx.xgry,qx.xgrq,qx.bz
			from Sbtdjqqx qx 
			left join sbtdspsr td on qx.sbbh = td.sbbh and qx.tdbh = td.tdbh 
			left join xtcl x on x.csdm = qx.tdlx and x.csdl = 'channelSmallType'
			where 1=1
			<isNotEmpty prepend='AND' property='LIKEsbbh'>
				(qx.sbbh like concat('%',#LIKEsbbh# ,'%') )
			</isNotEmpty>
			<isNotEmpty prepend='AND' property='tdlx'>
				(qx.tdlx = #tdlx# )
			</isNotEmpty>
			<isNotEmpty prepend='AND' property='LIKEtdmc'>
				(td.tdmc like concat('%',#LIKEtdmc# ,'%') )
			</isNotEmpty>
			<isNotEmpty prepend='AND' property='bmbh'>
				(qx.bmbh = #bmbh# )
			</isNotEmpty>
		)xxx
	</select>
	
	<select id="count_Sbtdjqqx_bybmbh" resultClass="java.lang.Integer" parameterClass="java.util.Map">
		select count(*) from Sbtdjqqx where 1=1  and sbbh = #sbbh# and tdbh = #tdbh#
	</select>
	
	<update id="update_bmbh_Sbtdjqqx_bysbtd" parameterClass="java.util.Map" >
		update  Sbtdjqqx set bmbh = #bmbh# where 1=1  and sbbh = #sbbh# and tdbh = #tdbh#
	</update>
	
	<update id="update_Sbtdjqqx_qx" parameterClass="java.util.Map" >
		update  Sbtdjqqx set dqx =  #dqx# , 
							 xqx =  #xqx# ,  
							 kqx =  #kqx# ,  
							 pqx =  #pqx# , 
							 lxhfqx =  #lxhfqx# , 
							 lxxzqx =  #lxxzqx# , 
							 lxdjqx =  #lxdjqx# 
		where 1=1 and sbbh = #sbbh# and tdbh = #tdbh#
	</update>
	 
	<!-- batch add objects -->
	<insert id="batch_insert_Sbtdjqqx" parameterClass="java.util.List">
	 	<![CDATA[
          INSERT
      	]]>
		<iterate conjunction=" ">
			into Sbtdjqqx(
			 <![CDATA[ 
				xh,khbh,bmbh,sbbh,tdbh,tdlx,dqx,xqx,kqx,pqx,lxhfqx,lxxzqx,lxdjqx,cjry,cjrq,xgry,xgrq,bz
			)values
			 ]]>  		 
			 <![CDATA[ 
				(
			#list[].bmbh#,#list[].sbbh#,#list[].tdbh#
				)
			]]>
		</iterate>
	</insert>
	
	<!-- 查询客户通配权限 -->
	<select id="query_Xtkhtptdqx" resultClass="java.util.HashMap" parameterClass="java.util.Map">
		select 
			xh,khbh,qybh,wbbh,dqx,xqx,kqx,pqx,lxhfqx,lxxzqx,lxdjqx,cjry,cjrq,xgry,xgrq,bz
		from xtkhtptdqx 
		where 1=1
		<isNotEmpty prepend='AND' property='khbh'>
			(khbh = #khbh# )
		</isNotEmpty>
		
	</select>
	
	<!-- 查询客户精确和通配权限列表 -->
	<select id="query_kh_jqtd_right" resultClass="java.util.HashMap" parameterClass="java.util.Map">
		select dd.*,ee.csmc as tdlxmc,ff.xzmc from
			(
				select 
					bb.sbbh,bb.tdbh,bb.tdlx,bb.tdmc,bb.xzbh
				from xtkhjqtdqx aa
				left join sbtdspsr bb ON aa.sbbh = bb.sbbh and aa.tdbh = bb.tdbh
				where 1=1 
				<isNotEmpty prepend='AND' property='khbh'>
					(aa.khbh = #khbh# )
				</isNotEmpty>
				union 
				select 
					cc.sbbh,cc.tdbh,cc.tdlx,cc.tdmc,cc.xzbh 
				from sbtdspsr cc
				where 1=1
				<isNotEmpty property='tableparam'>
					$tableparam$
				</isNotEmpty>
		)dd 
		left join xtcl ee on ee.csdm = dd.tdlx and ee.csdl = 'channelSmallType'
		left join ptxzs ff on dd.xzbh = ff.xzbh 
		where 1=1 AND
		not exists(
			select xx.sbbh,xx.tdbh  from sbtdjqqx xx 
			where dd.sbbh =xx.sbbh and dd.tdbh = xx.tdbh
			<isNotEmpty prepend='AND' property='khbh'>
				(xx.khbh = #khbh# )
			</isNotEmpty>
			<isNotEmpty prepend='AND' property='bmbh'>
				(xx.bmbh = #bmbh# )
			</isNotEmpty>
		)				
		<isNotEmpty prepend='AND' property='LIKEsbbh'>
			(dd.sbbh like concat('%',#LIKEsbbh# ,'%') )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKEtdmc'>
			(dd.tdmc like concat('%',#LIKEtdmc# ,'%') )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='tdlx'>
			(dd.tdlx = #tdlx# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='xzbh'>
			(dd.xzbh = #xzbh# )
		</isNotEmpty>
		
	</select>
	
	<!-- 查询客户精确和通配权限总数 -->
	<select id="count_kh_jqtd_right" resultClass="java.lang.Integer" parameterClass="java.util.Map">
		select count(*) from
			(
				select 
					bb.sbbh,bb.tdbh,bb.tdlx,bb.tdmc,bb.xzbh
				from xtkhjqtdqx aa
				left join sbtdspsr bb ON aa.sbbh = bb.sbbh and aa.tdbh = bb.tdbh
				where 1=1 
				<isNotEmpty prepend='AND' property='khbh'>
					(aa.khbh = #khbh# )
				</isNotEmpty>
				union 
				select 
					cc.sbbh,cc.tdbh,cc.tdlx,cc.tdmc,cc.xzbh 
				from sbtdspsr cc
				where 1=1				
				<isNotEmpty property='tableparam'>
					$tableparam$
				</isNotEmpty>
		)dd 
		where 1=1 AND
		not exists(
			select xx.sbbh,xx.tdbh  from sbtdjqqx xx 
			where dd.sbbh =xx.sbbh and dd.tdbh = xx.tdbh
			<isNotEmpty prepend='AND' property='khbh'>
				(xx.khbh = #khbh# )
			</isNotEmpty>
			<isNotEmpty prepend='AND' property='bmbh'>
				(xx.bmbh = #bmbh# )
			</isNotEmpty>
		)	
		<isNotEmpty prepend='AND' property='LIKEsbbh'>
			(dd.sbbh like concat('%',#LIKEsbbh# ,'%') )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKEtdmc'>
			(dd.tdmc like concat('%',#LIKEtdmc# ,'%') )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='tdlx'>
			(dd.tdlx = #tdlx# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='xzbh'>
			(dd.xzbh = #xzbh# )
		</isNotEmpty>
	</select>

	<!-- 查询机构精确和通配权限列表 -->
	<select id="query_jg_jqtd_right" resultClass="java.util.HashMap" parameterClass="java.util.Map">
		select  dd.*,ee.csmc as tdlxmc,ff.xzmc,gg.tdmc from(
			select 
				aa.sbbh,aa.tdbh,aa.tdlx 
			from sbtdjqqx aa
			where 1=1 
			<isNotEmpty prepend='AND' property='khbh'>
				(aa.khbh = #khbh# )
			</isNotEmpty>
			<isNotEmpty prepend='AND' property='sjbmbh'>
				(aa.bmbh = #sjbmbh# )
			</isNotEmpty>
			and not exists(
				select xx.sbbh,xx.tdbh  from sbtdjqqx xx 
				where aa.sbbh =xx.sbbh and aa.tdbh = xx.tdbh
				<isNotEmpty prepend='AND' property='khbh'>
					(xx.khbh = #khbh# )
				</isNotEmpty>
				<isNotEmpty prepend='AND' property='bmbh'>
					(xx.bmbh = #bmbh# )
				</isNotEmpty> 
			)
		)dd 		
		left join xtcl ee on ee.csdm = dd.tdlx and ee.csdl = 'channelSmallType'
		left join sbtdspsr gg on dd.sbbh= gg.sbbh and dd.tdbh = gg.tdbh
		left join ptxzs ff on gg.xzbh = ff.xzbh 
		where 1=1
		<isNotEmpty prepend='AND' property='LIKEsbbh'>
			(dd.sbbh like concat('%',#LIKEsbbh# ,'%') )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='tdlx'>
			(dd.tdlx = #tdlx# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKEtdmc'>
			(gg.tdmc like concat('%',#LIKEtdmc# ,'%') )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='xzbh'>
			(gg.xzbh = #xzbh# )
		</isNotEmpty>
		
	</select>
	
	<!-- 查询机构精确和通配权限总数 -->
	<select id="count_jg_jqtd_right" resultClass="java.lang.Integer" parameterClass="java.util.Map">
		select  count(*) from(
			select 
				aa.sbbh,aa.tdbh,aa.tdlx 
			from sbtdjqqx aa
			where 1=1 
			<isNotEmpty prepend='AND' property='khbh'>
				(aa.khbh = #khbh# )
			</isNotEmpty>
			<isNotEmpty prepend='AND' property='sjbmbh'>
				(aa.bmbh = #sjbmbh# )
			</isNotEmpty>
			and not exists(
				select xx.sbbh,xx.tdbh  from sbtdjqqx xx 
				where aa.sbbh =xx.sbbh and aa.tdbh = xx.tdbh
				<isNotEmpty prepend='AND' property='khbh'>
					(xx.khbh = #khbh# )
				</isNotEmpty>
				<isNotEmpty prepend='AND' property='bmbh'>
					(xx.bmbh = #bmbh# )
				</isNotEmpty> 
			)
		)dd 		
		left join xtcl ee on ee.csdm = dd.tdlx and ee.csdl = 'channelSmallType'
		left join sbtdspsr gg on dd.sbbh= gg.sbbh and dd.tdbh = gg.tdbh
		left join ptxzs ff on gg.xzbh = ff.xzbh 
		where 1=1
		<isNotEmpty prepend='AND' property='LIKEsbbh'>
			(dd.sbbh like concat('%',#LIKEsbbh# ,'%') )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='tdlx'>
			(dd.tdlx = #tdlx# )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='LIKEtdmc'>
			(gg.tdmc like concat('%',#LIKEtdmc# ,'%') )
		</isNotEmpty>
		<isNotEmpty prepend='AND' property='xzbh'>
			(gg.xzbh = #xzbh# )
		</isNotEmpty>
	</select>

</sqlMap>

