日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

activiti实现跳转节点的方法

發布時間:2024/10/5 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 activiti实现跳转节点的方法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1.通過代碼實現,即獲取到當前節點,然后退回到已走過的指定節點。代碼如下:

@RequestMapping("/returnNode")public String returnNode(String taskId) {// 取得當前任務.當前任務節點HistoricTaskInstance currTask = historyService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult();// 取得所有歷史任務按時間降序排序List<HistoricTaskInstance> hisInstances = historyService.createHistoricTaskInstanceQuery().processInstanceId(currTask.getProcessInstanceId()).orderByTaskCreateTime().desc().list();if(ObjectUtils.isEmpty(hisInstances)||hisInstances.size()<2){return "fail";}//目的節點HistoricTaskInstance lastTask = null;//所有目的節點的歷史記錄List<HistoricTaskInstance> commitList = historyService.createHistoricTaskInstanceQuery().processInstanceId(currTask.getProcessInstanceId()).taskName("one").orderByTaskCreateTime().asc().list();lastTask=commitList.get(0);if (null==lastTask){return "fail";}// 目的節點的taskIdString lastTaskId = lastTask.getId();// 目的節點的executionIdString lastExecutionId = lastTask.getExecutionId();//目的節點對應的流程定義IDString processDefinitionId = lastTask.getProcessDefinitionId();//對應的流程圖文件BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);String lastActivityId = null;//獲取所有和目的節點任務名一樣的已完成的歷史記錄List<HistoricActivityInstance> finishedList = historyService.createHistoricActivityInstanceQuery().executionId(lastExecutionId).finished().list();for (HistoricActivityInstance f: finishedList){if(lastTaskId.equals(f.getTaskId())){lastActivityId=f.getActivityId();break;}}FlowNode lastFlowNode = (FlowNode)bpmnModel.getMainProcess().getFlowElement(lastActivityId); // 取得當前節點的信息// 當前節點的executionIdString curExecutionId = currTask.getExecutionId();Execution execution = runtimeService.createExecutionQuery().executionId(curExecutionId).singleResult();String curActivityId = execution.getActivityId();FlowNode curFlowNode = (FlowNode) bpmnModel.getMainProcess().getFlowElement(curActivityId);//記錄當前節點的原活動方向List<SequenceFlow> oriSequenceFlows = new ArrayList<>();oriSequenceFlows.addAll(curFlowNode.getOutgoingFlows());//清理活動方向curFlowNode.getOutgoingFlows().clear();//建立新方向List<SequenceFlow> newSequenceFlowList = new ArrayList<>();SequenceFlow newSequenceFlow = new SequenceFlow();newSequenceFlow.setId("newSequenceFlowId");newSequenceFlow.setSourceFlowElement(curFlowNode);newSequenceFlow.setTargetFlowElement(lastFlowNode);newSequenceFlowList.add(newSequenceFlow);curFlowNode.setOutgoingFlows(newSequenceFlowList);// 完成任務taskService.complete(taskId);//恢復原方向curFlowNode.setOutgoingFlows(oriSequenceFlows);return "成功";}

對應的流程圖如下:

上述代碼可以實現從two節點退回到one節點

2.通過排他網關實現,流程圖如下:

通過設置two節點完成時的參數確定流程圖是退回到one節點還是結束。?

注意,方法一不會自動刪除流程中的參數,需要手動刪除,如果通過網關退回,可以實現退回后之前的流程變量自動被刪除。

總結

以上是生活随笔為你收集整理的activiti实现跳转节点的方法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。