activiti 6 0自由跳轉

2021-09-24 09:41:49 字數 1460 閱讀 1946

task task = taskservice.createtaskquery() // 建立任務查詢

.processinstanceid(自己的processinstanceid) // 根據流程例項id查詢

.singleresult();

//獲取流程定義

process process = repositoryservice.getbpmnmodel(task.getprocessdefinitionid()).getmainprocess();

//獲取目標節點定義

flownode targetnode = (flownode) process.getflowelement("要跳轉的節點名");

//刪除當前執行任務

string executionentityid = managementservice.executecommand(new deletetaskcmd(task.getid()));

//流程執行到**節點

managementservice.executecommand(new setflownodeandgocmd(targetnode, executionentityid));

//刪除當前執行時任務命令,並返回當前任務的執行物件id

//這裡繼承了needsactivetaskcmd,主要時很多跳轉業務場景下,要求不能時掛起任務。可以直接繼承command即可

public class deletetaskcmd extends needsactivetaskcmd

@override

public string execute(commandcontext commandcontext, taskentity currenttask)

@override

public string getsuspendedtaskexception()

}//根據提供節點和執行物件id,進行跳轉命令

public class setflownodeandgocmd implements command

@override

public void execute(commandcontext commandcontext)

//隨便選一條連線來執行,時當前執行計畫為,從連線流轉到目標節點,實現跳轉

executionentity executionentity = commandcontext.getexecutionentitymanager().findbyid(executionid);

executionentity.setcurrentflowelement(flows.get(0));

commandcontext.getagenda().plantakeoutgoingsequenceflowsoperation(executionentity, true);

return null;

}}

Activiti6實現自由跳轉

工作快2年的小白,如有錯誤,懇請大家批評指點,這也是開始寫部落格的乙個初衷,能夠在分享互動 知識梳理中進步。之前工作的專案使用activiti5進行企業流程系統開發,現在這份工作也開始需要流程開發,了解到activiti6扔掉了原來的pvm,直接針對bpmn進行處理,效能有了一定的提公升 也有看到f...

activiti6 發布流程)

在講發布流程之前,我先普及一下activiti6的七大介面 repositoryservice 提供一系列管理流程部署和流程定義的api。runtimeservice 在流程執行時對流程例項進行管理與控制。historyservice 對流程的歷史資料進行操作,包括查詢 刪除這些歷史資料。ident...

activiti6 獲取下一節點 (持續更新)

這種方式是通過當前節點與當前節點之後的節點中間的連線物件 sequenceflow 類 中的outgoingflows屬性 標識輸出的物件 之後對輸出的物件進行判斷 判斷其是否是排他閘道器 exclusivegateway 如果是排他閘道器 再通過自己程式的邏輯處理來判斷下一節點是哪乙個節點。每行 ...