Jbpm4.4提供两个接口可以获取该用户的待处理任务:
一个是个人的任务:taskService.findPersonalTasks(userId)
另一个是取得该用户对应的候选任务:taskService.findGroupTasks(userId)
有时我们需要在一个列表中显示该用户的所有任务,包括他的个人任务,候选任务,这时直接用
jbpm4.4提供的api完成不了该功能要求。
可以使用以下方式进行扩展:
问题流程的个人任务:
select distinct task from org.jbpm.pvm.internal.task.TaskImpl task
where task.assignee = '验证人员a' and task.execution.processDefinitionId like
'problemProcess%' order by task.priority desc
问题流程的待选任务(组和个人):
select distinct task from org.jbpm.pvm.internal.task.TaskImpl task
left join task.participations ppi
where ppi.task = task.dbid and ppi.type='candidate' and (task.assignee is null)
and ( ppi.userId ='验证人员a' or ppi.groupId in ( select distinct g.id from
org.jbpm.pvm.internal.identity.impl.MembershipImpl m join m.user u join m.group g
where u.id = '验证人员a' ) )
and task.execution.processDefinitionId like 'problemProcess%'
order by task.priority desc
查找某个人所在的组findGroupsByUser:
select distinct g from org.jbpm.pvm.internal.identity.impl.MembershipImpl m join m.user
u join m.group g where u.id = :userId