All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mapper.query.xml Maven / Gradle / Ivy

There is a newer version: 2.5.1
Show newest version
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
  PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="Query">
    <select id="getActiveOrders" resultType="order" parameterType="hashmap">
    	${limitBefore}
    	<include refid="selectActiveOrdersPart"/>
		<include refid="fromActiveOrdersPart"/>
		${orderby}
		${limitAfter}
    </select>
    
    <select id="getActiveOrdersCount" resultType="long" parameterType="hashmap">
   		select count(*)
    	<include refid="fromActiveOrdersPart"/>
    </select>
    
	<select id="getActiveTasks" resultType="task" parameterType="hashmap">
    	${limitBefore}
        <include refid="selectActiveTasksPart"/>
		<include refid="fromActiveTasksPart"/>
		${orderby}
		${limitAfter}
    </select>
    
    <select id="getActiveTasksCount" resultType="long" parameterType="hashmap">
   		select count(*)
    	<include refid="fromActiveTasksPart"/>
    </select>
    
    <select id="getNextActiveTasks" resultType="task" parameterType="hashmap">
    	<include refid="selectActiveTasksPart"/>
    	from wf_task where parent_Task_Id in (
    	select ht.id from wf_hist_task ht 
    	where ht.order_id=#{orderId, jdbcType=VARCHAR} and ht.task_name=#{taskName, jdbcType=VARCHAR} and ht.parent_task_id=#{parentTaskId, jdbcType=VARCHAR}
    	)
    </select>
    
	<select id="getWorkItems" resultType="workitem" parameterType="hashmap">
		${limitBefore}
	 	<include refid="selectWorkItemsPart"/>
		<include refid="fromWorkItemsPart"/>
      	${orderby}
      	${limitAfter}
	</select>
	
	<select id="getWorkItemsCount" resultType="long" parameterType="hashmap">
   		select count(*)
    	<include refid="fromWorkItemsPart"/>
	</select>
    
    <sql id="selectActiveOrdersPart">
    	select 
    		id,
    		process_Id as processId,
    		creator,
    		create_Time as createTime,
    		parent_Id as parentId,
    		parent_Node_Name as parentNodeName,
    		expire_Time as expireTime,
    		last_Update_Time as lastUpdateTime,
    		last_Updator as lastUpdator,
    		order_No as orderNo,
    		variable,
    		version
    </sql>
    
    <sql id="fromActiveOrdersPart">
		from wf_order
		<where>
      		<if test="processId != null">
        		and process_Id = #{processId, jdbcType=VARCHAR}
      		</if>
      		<if test="parentId != null">
        		and parent_Id = #{parentId, jdbcType=VARCHAR}
      		</if>
        	<if test="excludedIds != null and excludedIds.length > 0">
         	    and id not in
				<foreach collection="excludedIds" index="index" item="item" open="(" separator="," close=")">
					#{item, jdbcType=VARCHAR}
				</foreach>
			</if>
      		<if test="orderNo != null">
        		and order_No = #{orderNo, jdbcType=VARCHAR}
      		</if>
      		<if test="createTimeStart != null">
        		and create_Time &gt;= #{createTimeStart, jdbcType=VARCHAR}
      		</if>
      		<if test="createTimeEnd != null">
        		and create_Time &lt;= #{createTimeEnd, jdbcType=VARCHAR}
      		</if>
		</where>
    </sql>
    
    <sql id="selectActiveTasksPart">
        select 
            id,
            order_Id as orderId,
            task_Name as taskName,
            display_Name as displayName,
            task_Type as taskType,
            perform_Type as performType,
            operator,
            create_Time as createTime,
            finish_Time as finishTime,
            expire_Time as expireTime,
            action_Url as actionUrl,
            parent_Task_Id as parentTaskId,
            variable,
            version
    </sql>
    
    <sql id="fromActiveTasksPart">
        from wf_task 
        left join wf_task_actor ta on ta.task_id = id 
        <where>
	        <if test="actorIds != null and actorIds.length > 0">
		        and ta.actor_Id in
				<foreach collection="actorIds" index="index" item="item" open="(" separator="," close=")">
					#{item, jdbcType=VARCHAR}
				</foreach>
			</if>
	        <if test="taskNames != null and taskNames.length > 0">
		        and task_Name in
				<foreach collection="taskNames" index="index" item="item" open="(" separator="," close=")">
					#{item, jdbcType=VARCHAR}
				</foreach>
			</if>
	        <if test="excludedIds != null and excludedIds.length > 0">
		        and id not in
				<foreach collection="excludedIds" index="index" item="item" open="(" separator="," close=")">
					#{item, jdbcType=VARCHAR}
				</foreach>
			</if>
      		<if test="orderId != null">
        		and order_Id = #{orderId, jdbcType=VARCHAR}
      		</if>
      		<if test="createTimeStart != null">
        		and create_Time &gt;= #{createTimeStart, jdbcType=VARCHAR}
      		</if>
      		<if test="createTimeEnd != null">
        		and create_Time &lt;= #{createTimeEnd, jdbcType=VARCHAR}
      		</if>
		</where>
    </sql>
    
    <sql id="selectWorkItemsPart">
	 	select 
	 	    o.process_Id as processId, 
	 	    t.order_Id as orderId, 
	 	    t.id as taskId, 
	 	    p.display_Name as processName, 
	 	    p.instance_Url as instanceUrl, 
	 	    o.parent_Id as parentId, 
	 	    o.creator, 
	  	    o.create_Time as orderCreateTime, 
	  	    o.expire_Time as orderExpireTime, 
	  	    o.order_No as orderNo, 
	  	    o.variable as orderVariable,
	  	    t.variable as taskVariable,
	   	    t.display_Name as taskName, 
	   	    t.task_Type as taskType, 
	   	    t.perform_Type as performType, 
	   	    t.operator, 
	   	    t.action_Url as actionUrl, 
	        t.create_Time as taskCreateTime, 
	        t.finish_Time as taskEndTime, 
	        t.expire_Time as taskExpireTime 
    </sql>
    
    <sql id="fromWorkItemsPart">
	    from wf_task t 
	    left join wf_order o on t.order_id = o.id 
	    left join wf_task_actor ta on ta.task_id=t.id 
	    left join wf_process p on p.id = o.process_id 
		<where>
      		<if test="processId != null">
        		and o.process_Id = #{processId, jdbcType=VARCHAR}
      		</if>
	        <if test="actorIds != null and actorIds.length > 0">
	            and ta.actor_Id in
				<foreach collection="actorIds" index="index" item="item" open="(" separator="," close=")">
					#{item, jdbcType=VARCHAR}
				</foreach>
			</if>
      		<if test="createTimeStart != null">
        		and t.create_Time &gt;= #{createTimeStart, jdbcType=VARCHAR}
      		</if>
      		<if test="createTimeEnd != null">
        		and t.create_Time &lt;= #{createTimeEnd, jdbcType=VARCHAR}
      		</if>
      		<if test="parentId != null">
        		and o.parent_Id = #{parentId, jdbcType=VARCHAR}
      		</if>
      		<if test="taskType != null">
        		and t.task_Type = #{taskType, jdbcType=NUMERIC}
      		</if>
      		<if test="performType != null">
        		and t.perform_Type = #{performType, jdbcType=NUMERIC}
      		</if>
      	</where>
    </sql>
</mapper>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy