flowable 任務多例項
阿新 • • 發佈:2020-08-01
專案地址:https://gitee.com/lwj/flowable.git 分支flowable-base
*業務場景:
收集每個員工的績效考核資訊;
收集一次組織活動的資訊;
一個合同需要三個經理審批,可以是順序的也可以是並行的;
一個合同計劃審批有30個人審批,只需要其中70%的人審批通過即可。等等 *
1、任務多例項四個內建變數
屬性 | 解釋 |
---|---|
nrOfInstances | 一共有多少個例項 |
nrOfCompletedInstances | 已經完成的例項個數 |
nrOfActiveInstances | 未完成的例項個數 |
2、配置多例項
2.1、配置引數
2.2、配置候選人
2.3、配置結束條件
3、啟動設定userList
public ReturnVo add(Leave leave, String sessionId) {
ReturnVo returnVo = new ReturnVo(ReturnCode.FAIL, "新增失敗");
try {
String leaveId = UUIDGenerator.generate();
leave.setId(leaveId);
StartProcessInstanceVo startProcessInstanceVo = new StartProcessInstanceVo();
startProcessInstanceVo.setBusinessKey(leaveId);
User user = SecurityUtils.getCurrentUserObject();
startProcessInstanceVo.setCreator(user.getId());
startProcessInstanceVo.setCurrentUserCode(user.getId());
startProcessInstanceVo.setFormName("請假流程");
startProcessInstanceVo.setSystemSn("flow");
startProcessInstanceVo.setProcessDefinitionKey("leave");
Map<String, Object> variables = new HashMap<>();
variables.put("days", leave.getDays());
startProcessInstanceVo.setVariables(variables);
//設定三個人作為多例項的人員
List<String> userList = new ArrayList<>();
userList.add("00000005");
userList.add("00000006");
variables.put("userList", userList);
ReturnVo<ProcessInstance> returnStart = flowableProcessInstanceService.startProcessInstanceByKey(startProcessInstanceVo);
if (returnStart.getCode().equals(ReturnCode.SUCCESS)){
String processInstanceId = returnStart.getData().getProcessInstanceId();
leave.setProcessInstanceId(processInstanceId);
this.LeaveService.insertLeave(leave);
returnVo = new ReturnVo(ReturnCode.SUCCESS, "新增成功");
}else {
returnVo = new ReturnVo(returnStart.getCode(), returnStart.getMsg());
}
} catch (Exception e) {
logger.error("LeaveController-add:", e);
e.printStackTrace();
}
return returnVo;
}