Camunda Modeler设计器变量使用el表达式,如:${}
事件
image.png开始事件:
- initiator
流程启动人
通过identityService.setAuthenticatedUserId(startProcessBo.getUserId())设置的就是流程启东人
public String startProcess(StartProcessBo startProcessBo) {
identityService.setAuthenticatedUserId(startProcessBo.getUserId());
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(
startProcessBo.getDefinitionKey(),
startProcessBo.getBusinessKey(),
startProcessBo.getVariables()
);
return processInstance.getProcessInstanceId();
}
User Task
image.png- Assignee
任务处理人 - Candidate groups
候选组 - Candidate users
候选用户 - Due date
到期日 - Follow up date
跟进日期,是指任务的约定完成日期或截止日期。
有助于任务管理和优先级设定 - Priority
优先级
send task
image.png(1)在同一流程定义中发送消息
@Slf4j
@Component("sendMessage")
public class SendMessage implements JavaDelegate {
@Override
public void execute(DelegateExecution execution) throws Exception {
execution.getProcessEngineServices().getRuntimeService()
.createMessageCorrelation("messageName").processInstanceBusinessKey(execution.getBusinessKey()).correlate();
}
}
(2)一个流程定义发送消息,另一个流程定义接收消息
启动流程
public class Test{
StartProcessBo startProcessBo = new StartProcessBo();
startProcessBo.setBusinessKey(String.valueOf(carOrderCollectDetect.getOrderCollectId()));
startProcessBo.setDefinitionKey(carDetectDefinitionKey);
VariableMap variableMap = Variables.createVariables();
variableMap.put("test","test");
bpmFormService.startProcess(startProcessBo);
}
@Slf4j
@Component("sendMessageHandler")
public class SendMessageHandler implements JavaDelegate {
@Override
public void execute(DelegateExecution execution) throws Exception {
execution.getProcessEngineServices().getRuntimeService()
.createMessageCorrelation("messageName").processInstanceBusinessKey(execution.getBusinessKey()).correlate();
}
}
会签
同一个审批节点,需要多个人审批:
- 会签:几个审批人,要全部同意
${nrOfInstances == nrOfCompletedInstances}
${nrOfCompletedInstances == nrOfInstances || !approve }
- 或签:几个审批人,只要有一个同意
${1 == nrOfCompletedInstances} - 加签:增加审批人
runtimeService.createProcessInstanceModification(processInstanceId)
.startBeforeActivity(activityId)
.setVariable("user",user)
.execute();
nrOfInstances 实例的数目
nrOfCompletedInstances 完成实例的数目
nrOfActiveInstances 未完成实例的数目
loopCounter 循环计数器,办理人在列表中的索引。
事务
默认是同步调用,service task 抛出异常会回滚到上一个user task,如果需要不回滚到上一个user task,需要配置service task 为异步延续,只要就只回滚当前service task
网友评论