自己以前写的有意思的ibatis

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="Statistcs">
	
	<cacheModel id="code-CacheModel" type ="LRU" readOnly="true" serialize="false">  
        <flushInterval seconds="10"/> 
        <!-- <flushOnExecute statement="getStatistcsData1"/> -->
        <property name="cache-size" value="1000" />    
    </cacheModel>  
	
	<!-- 获得统计信息 -->	
	<statement id="getStatistcsDataExt" resultClass="java.util.HashMap" parameterClass="map" 
		cacheModel="code-CacheModel" remapResults="true">
			select a.name, 
			       (select count(*) from projects t1 where t1.academy_id = a.id   		
						and t1.category_id in (select id from categories where order_doc_id = #orderDocId#)) as apply_count,
			       (select count(*) from projects t2 
			       		where t2.academy_id = a.id and t2.apply_check_state = 3
			       			and t2.category_id in (select id from categories where order_doc_id = #orderDocId#)) as elected_count,		
				   <iterate property="ids" conjunction=",">			       	
						(select count(*) from projects t3, evaluate_result er 
							where t3.academy_id = a.id 
								and er.project_id = t3.id 
								and t3.category_id in (select id from categories where order_doc_id = #orderDocId#) 
								and er.hierarchy_id = ($ids[]$)) as '$ids[]$'	   
				   </iterate>				   
			from academies a
			<dynamic>
				<isNotEmpty property="academyIds">
					where a.id in ($academyIds$)
				</isNotEmpty>
			</dynamic>
			order by apply_count desc, elected_count desc
	</statement>
	
	<!-- 获得统计信息 去除缓存-->	
	<statement id="getStatistcsDataExt1" resultClass="java.util.HashMap" parameterClass="map" 
		cacheModel="code-CacheModel" remapResults="true">
			select a.name, 
			       (select count(*) from projects t1 where t1.academy_id = a.id
			       		and t1.category_id in (select id from categories where order_doc_id = #orderDocId#)) as apply_count,
			       (select count(*) from projects t2			       	
			       		where t2.academy_id = a.id and t2.apply_check_state = 3
			       			and t2.category_id in (select id from categories where order_doc_id = #orderDocId#)) as elected_count,		
				   <iterate property="ids" conjunction=",">			       	
						(select count(*) from projects t3, evaluate_result er  
							where t3.academy_id = a.id 
								and er.project_id = t3.id
								and t3.category_id in (select id from categories where order_doc_id = #orderDocId#)  
								and er.hierarchy_id = ($ids[]$)) as '$ids[]$'	   
				   </iterate>				   
			from academies a
			<dynamic>
				<isNotEmpty property="academyIds">
					where a.id in ($academyIds$)
				</isNotEmpty>
			</dynamic>
			order by apply_count desc, elected_count desc
	</statement>
	
	<!-- 获得统计信息 -->	
	<statement id="getStatistcsData" resultClass="java.util.HashMap" parameterClass="map" 
		cacheModel="code-CacheModel" remapResults="true">
			select a.name, 
			       (select count(*) from projects t1 where t1.academy_id = a.id
			       		and t1.category_id in (select id from categories where order_doc_id = #orderDocId#)) as apply_count,
			       (select count(*) from projects t2 
			       		where t2.academy_id = a.id and t2.apply_check_state = 3
			       			and t2.category_id in (select id from categories where order_doc_id = #orderDocId#)) as elected_count			   
			from academies a
			<dynamic>
				<isNotEmpty property="academyIds">
					where a.id in ($academyIds$)
				</isNotEmpty>
			</dynamic>
			order by apply_count desc, elected_count desc
	</statement>
	
	<!-- 取得项目等级ID -->
	<select id="getHierarchyIds" resultClass="int">
		select distinct hierarchy_id from evaluate_result where hierarchy_id > 0
	</select>
	
	
	<update id="updateTime" parameterClass="map">
		update projects p set id = id
		<dynamic>
			<isEqual prepend="," property="evaluateType" compareValue="1">
				p.start_time = #time#
			</isEqual>
			<isEqual prepend="," property="evaluateType" compareValue="2">
				p.mid_check_time = #time#
			</isEqual>
			<isEqual prepend="," property="evaluateType" compareValue="3">
				p.end_time = #time#
			</isEqual>
		</dynamic>
		where id in ($ids$)
	</update>	
</sqlMap>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值