其他分享
首页 > 其他分享> > activity 获取 环节处理人和发起人账号

activity 获取 环节处理人和发起人账号

作者:互联网

    /**
     * 查找历史指定环节的处理人账号
     *
     * @param processInstanceId
     * @param taskName
     * @return
     */
    public String findHisTaskAssignee(String processInstanceId, String taskName) {
        String assignee = "";
        List<HistoricTaskInstance> list = this.getHistoryTaskInstanceByProcessInstanceIdDesc(processInstanceId);
        for (HistoricTaskInstance hti : list) {
            if (taskName.equals(hti.getName())) {
                assignee = hti.getAssignee();
                break;
            }
        }
        return assignee;
    }

    /**
     * 获取发起人
     *
     * @param processInstanceId //流程实例ID
     */
    public String getInitiator(String processInstanceId) {
        HistoricProcessInstance hip = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();            //获取历史流程实例
        //获取流程中已经执行的节点,按照执行先后顺序排序
        List<HistoricActivityInstance> hais = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId)
                .orderByHistoricActivityInstanceId().asc().list();
        // 获取bpmnModel
        BpmnModel bpmnModel = repositoryService.getBpmnModel(hip.getProcessDefinitionId());
        //全部活动实例
        List<FlowNode> historicFlowNodeList = new LinkedList<>();
        for (HistoricActivityInstance hai : hais) {
            historicFlowNodeList.add((FlowNode) bpmnModel.getMainProcess().getFlowElement(hai.getActivityId(), true));
            if (hai.getAssignee() != null) {
                //不为空的第一个节点办理人就是发起人
                return hai.getAssignee();
            }
        }
        return null;
    }

  

标签:hai,bpmnModel,return,String,账号,list,processInstanceId,发起人,activity
来源: https://www.cnblogs.com/first131/p/16292411.html