1. 程式人生 > >activiti中的查詢sql

activiti中的查詢sql

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN" "http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">

<mapper namespace="com.le.ssm.dao.flow.FlowTaskMapper">

    <!-- 引數對映 -->
    <resultMap id="TaskRM" type="com.le.ssm.domain.flow.Task"
> <id property="id" column="id_" javaType="String" jdbcType="VARCHAR"/> <result property="startTime" column="start_time_" javaType="Date" jdbcType="TIMESTAMP"/> <result property="endTime" column="end_time_" javaType="Date" jdbcType="TIMESTAMP"/> <
result property="status" column="status" javaType="String" jdbcType="CHAR"/> </resultMap> <!-- 分頁查詢指定人的任務 status: 1:待簽收 2:已經簽收3:歷史任務 --> <sql id="getAllTaskSQL"> <!-- 查詢待簽收 --> select art.id_, art.create_time_ start_time_, null as end_time_, "1" as `status` from act_ru_task art left join act_ru_identitylink ari on art.id_ = ari.task_id_ where art.assignee_ is null and ( ( ari.user_id_ = #{userId} ) or ( ari.group_id_ in ( select aig.id_ from act_id_user aiu inner join act_id_membership aim on aiu.id_ = #{userId} and aiu.id_ = aim.user_id_ inner join act_id_group aig on aig.id_ = aim.group_id_ ) ) ) union all
<!-- 查詢已簽收 --> select art.id_, art.create_time_ start_time_, null as end_time_, "2" as `status` from act_ru_task art where art.assignee_ = #{userId} union all <!-- 查詢已完成 --> select aht.id_, aht.start_time_, aht.end_time_, "3" as `status` from act_hi_taskinst aht where aht.assignee_ = #{userId} </sql> <select id="getAllTask" resultMap="TaskRM"> select tab.id_, tab.start_time_, tab.end_time_, tab.`status` from (<include refid="getAllTaskSQL" />) tab order by tab.start_time_ desc limit #{pageNum}, #{pageSize} </select> <select id="getAllTaskCount" resultMap="TaskRM"> select count(1) from (<include refid="getAllTaskSQL" />) tab </select> </mapper>