烈如歌歌 2020-06-04 10:11 采纳率: 0%
浏览 3639

activiti7 获取流程图各节点信息

网上都是5或者6版本的 获取流程图节点,连线列表的信息。
我想知道用activiti7版本的怎么获取流程图各节点信息,
因为我想查出连线和节点信息去设置一些自定义的信息。

``` // 查询当前的流程实例
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
BpmnModel bpmnModel = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId());
//获取当前流程的流程定义processDefinitionEntity,然后根据流程定义获得所有的节点
ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) repositoryService.createProcessDefinitionQuery()
.processDefinitionId(processInstance.getProcessDefinitionId()).singleResult();

    processDefinitionEntity.getActivities()
最主要的是 processDefinitionEntity.getActivities() 再activiti7版本没有这个get方法了。就不知道怎么用了。求教各位大神,帮我研究下。
  • 写回答

4条回答 默认 最新

  • 冰羽IOX 2020-12-29 17:35
    关注
      /**
       * 获取流程节点
       *
       * @param definitionId 流程定义ID
       * @param processId 流程ID(可能为子流程),也就是流程定义Key
       * @return
       */
      protected List<FlowElement> getProcessDefinitionNodes(String definitionId, String processId) {
        BpmnModel bpmnModel = repositoryService.getBpmnModel(definitionId);
    
        List<Process> processes = Lists.newArrayList();
    
        if (StrUtil.isNotEmpty(processId)) {
          processes.add(bpmnModel.getProcessById(processId));
        } else {
          processes = bpmnModel.getProcesses();
        }
    
        List<FlowElement> flowElements = Lists.newArrayList();
        processes.forEach(process -> flowElements.addAll(process.getFlowElements()));
    
        return flowElements;
      }  
    
    @GetMapping(value = "process/def/nodes/userTask")
      public AppResult getUserTaskNodes(
          @RequestParam(value = "id") String definitionId,
          @RequestParam(value = "processId", required = false) String processId) {
    
        List<FlowElement> flowElements = getProcessDefinitionNodes(definitionId, processId);
        List<UserTask> userTasks = Lists.newArrayList();
        flowElements.forEach(
            node -> {
              if (node instanceof UserTask) {
                userTasks.add((UserTask) node);
              }
            });
    
        return buildSuccess(userTasks);
      }
    
    // 返回数据格式(节点)
    
    {
    	"code": 200,
    	"message": "操作成功",
    	"data": [
    		{
    			"id": "Activity_14xmp0o",
    			"xmlRowNumber": 7,
    			"xmlColumnNumber": 5,
    			"name": "一级审批",
    			"asynchronous": false,
    			"notExclusive": false,
    			"incomingFlows": [
    				{
    					"id": "Flow_1s2ypsj",
    					"xmlRowNumber": 20,
    					"xmlColumnNumber": 5,
    					"sourceRef": "StartEvent_1",
    					"targetRef": "Activity_14xmp0o",
    					"waypoints": [
    						238,
    						470,
    						350,
    						470
    					]
    				}
    			],
    			"outgoingFlows": [
    				{
    					"id": "Flow_1xbbtsl",
    					"xmlRowNumber": 21,
    					"xmlColumnNumber": 5,
    					"sourceRef": "Activity_14xmp0o",
    					"targetRef": "Gateway_0astncq",
    					"waypoints": [
    						450,
    						470,
    						555,
    						470
    					]
    				}
    			],
    			"forCompensation": false,
    			"formKey": "one-level",
    			"candidateGroups": [
    				"one-approval"
    			],
    			"extended": false,
    			"exclusive": true
    		},
    		{
    			"id": "Activity_19kus41",
    			"xmlRowNumber": 11,
    			"xmlColumnNumber": 5,
    			"name": "二级审批",
    			"asynchronous": false,
    			"notExclusive": false,
    			"incomingFlows": [
    				{
    					"id": "Flow_101i5h2",
    					"xmlRowNumber": 34,
    					"xmlColumnNumber": 5,
    					"name": "通过",
    					"conditionExpression": "${gateway==true}",
    					"sourceRef": "Gateway_0astncq",
    					"targetRef": "Activity_19kus41",
    					"waypoints": [
    						580,
    						445,
    						580,
    						340,
    						670,
    						340
    					]
    				}
    			],
    			"outgoingFlows": [
    				{
    					"id": "Flow_0zdqnmv",
    					"xmlRowNumber": 42,
    					"xmlColumnNumber": 5,
    					"sourceRef": "Activity_19kus41",
    					"targetRef": "Gateway_0jvvxgy",
    					"waypoints": [
    						770,
    						340,
    						875,
    						340
    					]
    				}
    			],
    			"forCompensation": false,
    			"formKey": "two-level",
    			"candidateGroups": [
    				"two-approval"
    			],
    			"extended": false,
    			"exclusive": true
    		}
    	]
    }

    正好看到了,你可以这样做

    评论

报告相同问题?

悬赏问题

  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题