<?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>