<foreachcollection="tagIdList"item="item"index="index"open="("separator=" or "close=")">
find_in_set(#{item},res.tag_ids)
</foreach>
</if>
<iftest="hisHandlerUserid !=null "> and exists (select 1 from xm_question_handle h where h.question_id = res.id and h.handler_userid=#{hisHandlerUserid} and handle_status=#{hisHandleStatus})</if>
<iftest=" createTimeStart !=null "> and res.create_time between #{createTimeStart} and #{createTimeEnd} </if>
<iftest=" ltimeStart !=null "> and res.ltime between #{ltimeStart} and #{ltimeEnd} </if>
<includerefid="where"/>
<iftest=" productId !=null and productId!='' "> and exists( select 1 from xm_menu m where m.menu_id=res.menu_id and m.product_id=#{productId}) </if>
<iftest="myUserid != null and myUserid != ''"> and ( res.create_userid=#{myUserid} or res.handler_userid=#{myUserid}) </if>
select res.*,pa.proc_inst_id,pa.assignee,pa.assignee_name,pa.main_title,pa.flow_branch_id,pa.task_name,pa.agree,pa.flow_last_time,pa.comment_msg,pa.proc_def_id,pa.flow_state from xm_question res left join xm_question_process_approva pa on res.id=pa.question_id and res.biz_proc_inst_id=pa.proc_inst_id
<foreachcollection="tagIdList"item="item"index="index"open="("separator=" or "close=")">
find_in_set(#{item},res.tag_ids)
</foreach>
</if>
<iftest="hisHandlerUserid !=null "> and exists (select 1 from xm_question_handle h where h.question_id = res.id and h.handler_userid=#{hisHandlerUserid} and handle_status=#{hisHandleStatus})</if>
<iftest=" createTimeStart !=null "> and res.create_time between #{createTimeStart} and #{createTimeEnd} </if>
<iftest=" ltimeStart !=null "> and res.ltime between #{ltimeStart} and #{ltimeEnd} </if>
<includerefid="whereForMap"/>
<includerefid="where"/>
<iftest=" productId !=null and productId!='' "> and exists( select 1 from xm_menu m where m.menu_id=res.menu_id and m.product_id=#{productId}) </if>
<iftest="myUserid != null and myUserid != ''"> and ( res.create_userid=#{myUserid} or res.handler_userid=#{myUserid}) </if>