Camunda 創建 流程圖回調 (三)

其實在上一張已經提到過,Camunda的回調方法。

這裏在補充一下。

 

一 看一下流程圖

 

二 設置回調

這裏我們使用2種回調,來觸發

1 審批:EventListener

2 審覈:  JavaDelegate

 

I 使用EventListener:

① application.yml  中開啓監聽

camunda.bpm:
  #開啓監聽
  eventing:
    execution: true
    history: true
    task: true

② 代碼實現

一個監聽事件,有多種狀態,

create
assigment
complete
delete
start
end

這裏我們使用  delegateTask.eventName=='create'  ,

並且delegateTask.name=='審批'  就回調該方法。

@Component
public class AuditListener {
 
    @EventListener(condition = "#delegateTask.eventName=='create' && #delegateTask.name=='審批'")
    public void notity(DelegateTask delegateTask){
        System.out.println("審覈流程 - USER TASK - "+delegateTask.getEventName());
        Object assignee=delegateTask.getAssignee();
        System.out.println("審批人:"+ assignee);
        Object approve=delegateTask.getVariable("approve");
        System.out.println("審批結果:"+ approve);
        System.out.println("===========================");
    }
 
}

至此,@EventListener就好了

 

③ 測試運行:

 

II 使用JavaDelegate

① 在審覈節點,我們填寫如下

 

 

② 代碼:

public class AuditDelegate implements JavaDelegate {
    @Override
    public void execute(DelegateExecution execution) throws Exception {
        System.out.println("審覈流程 - SERVICE TASK - 回調");
        Object approved=execution.getVariable("approve");
        System.out.println("審批結果:"+ approved);
        Object amount=execution.getVariable("amount");
        System.out.println("審批金額:"+ amount);
        System.out.println("===========================");
    }
}

③ 測試運行

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章