这段代码的问题在于在条件判断中,createBys应该被写成createBys.size() > 0来判断是否为空。
修改后的代码如下:
select v.* from (
select t.* from BPM_TASK t left join bpm_def d on t.def_id_= d.def_id_ where ASSIGNEE_=#{userId} and t.TENANT_ID_=#{tenantId} and t.STATUS_!='COMPLETED' and t.STATUS_!='LOCKED'
UNION
select t.* from bpm_task t left join bpm_def d on t.def_id_= d.def_id_ left join bpm_task_user u on
t.TASK_ID_=u.TASK_ID_
where t.ASSIGNEE_ is null AND t.STATUS_!='COMPLETED' and t.STATUS_!='LOCKED' and (u.USER_ID_=#{userId} and t.TENANT_ID_=#{tenantId}
or u.GROUP_ID_ in
#{id}
)
) v where 1=1
and ${w.whereSql}
AND (
v.BUS_KEY_ LIKE CONCAT('%', #{query}, '%') OR v.SUBJECT_ LIKE CONCAT('%', #{query}, '%') OR v.CREATE_BY_ LIKE CONCAT('%', #{query}, '%')
OR v.CREATE_BY_ IN
#{createBy}
)
ORDER BY ${w.orderBySql}