<?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>
自己以前写的有意思的ibatis
最新推荐文章于 2020-02-14 15:31:52 发布