INNER JOIN ( SELECT PROC_INST_ID_ FROM ACT_HI_TASKINST WHERE ASSIGNEE_ =#{userSid} AND END_TIME_ IS NOT NULL ) temp ON ahpi.PROC_INST_ID_ = temp.PROC_INST_ID_
LEFT JOIN ACT_HI_TASKINST ahti ON ahti.PROC_INST_ID_ = temp.PROC_INST_ID_
INNER JOIN `ACT_HI_VARINST` A0 ON ahpi.PROC_INST_ID_ = A0.PROC_INST_ID_
LEFT JOIN ACT_RE_PROCDEF arpd ON ahpi.PROC_DEF_ID_ = arpd.ID_
<where>
<!-- <if test="proDefName != null and proDefName != ''">
AND arpd.NAME_ LIKE concat('%',#{proDefName},'%')
</if>-->
<iftest="startDate != null and startDate != ''">
AND ahpi.START_TIME_ <![CDATA[ >= ]]> #{startDate}
</if>
<iftest="endDate != null and endDate != ''">
AND ahpi.START_TIME_ <![CDATA[ <= ]]> #{endDate}
</if>
<iftest="names != null and names != ''">
and (A0.NAME_ = 'orderNames' and A0.TEXT_ LIKE concat('%',#{names},'%') or arpd.NAME_ LIKE concat('%',#{proDefName},'%'))
</if>
<iftest="startUserSid != null and startUserSid != ''">
and A0.NAME_ = 'INITIATOR' and A0.TEXT_ LIKE concat('%',#{startUserSid},'%')
</if>
<iftest="category != null and category != ''">
and arpd.CATEGORY_ LIKE concat('%',#{category},'%')