flowable 监听获取流程下一节点

//任务启动时监听
@Component
@Transactional
public class StartListener implements ExecutionListener {

    @Autowired
    private RepositoryService repositoryService;


    @Override
    public void notify(DelegateExecution execution) {

        List<SysUserEntity> userList = Lists.newArrayList();

        String crruentActivityId = execution.getCurrentActivityId();
        BpmnModel bpmnModel = repositoryService.getBpmnModel(execution.getProcessDefinitionId());
        ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
                .processDefinitionId(execution.getProcessDefinitionId()).singleResult();
        FlowNode flowNode = (FlowNode) bpmnModel.getFlowElement(crruentActivityId);
        // 输出连线
        List<SequenceFlow> outFlows = flowNode.getOutgoingFlows();


        for (SequenceFlow sequenceFlow : outFlows)
        {
            // 下一个审批节点
            FlowElement targetFlow = sequenceFlow.getTargetFlowElement();
            //如果是用户任务则获取待办人或组
            if (targetFlow instanceof UserTask)
            {
                // 如果下个审批节点为userTask
                UserTask userTask = (UserTask) targetFlow;
                //获取用户
                List<String> users = userTask.getCandidateUsers();
                //获取组
                List<String> group = userTask.getCandidateGroups();
                for (String str : users) {
                    userList.add(UserUtils.getByLoginName(str));
                }
                for (String str : group) {
                    userList.addAll(UserUtils.getUserListByRoleName(str));
                }
            }
        }

        //发送消息...


    }
}

《心脏病学》

猜你喜欢

转载自blog.csdn.net/kan_Feng/article/details/127111583