activiti流程图画法以及相关设置
2020-02-28 本文已影响0人
李中凯_f395
1.最简单的流程图
其中包括开始节点、任务节点以及结束节点

1.1 相关设置
设置id(也就是流程实例key),设置name

使用设置eclipse任务办理人(选中该任务节点)

1.2 部署流程
public Deployment deploy() {
repositoryService.createDeployment().addClasspathResource("流程bpmn文件")
.addClasspathResource("流程bpmn文件生成的png图").deploy();
}
1.3 启动流程
public ProcessInstance startByKey() {
return runtimeService.startProcessInstanceByKey("流程实例key,也就是整个流程图的id");
}
1.4 查询任务
public List<Task> findTaskByUser() {
return taskService.createTaskQuery().taskAssignee("办理人").list();
}
1.5 办理任务
public void complete() {
taskService.complete("任务id");
}
1.6 查询流程定义列表
public List<ProcessDefinition> findDefList(String key) {
return repositoryService.createProcessDefinitionQuery()
.processDefinitionKey(key)
.list();
}
1.6 查询历史任务
public List<HistoricTaskInstance> findHiTask() {
return testUtil.findHiTask("studentLeave:1:80004");
}
1.7 查询历史活动
public List<HistoricActivityInstance> findHiActivite(String proInsId) {
return historyService.createHistoricActivityInstanceQuery()
.processDefinitionId(proInsId)
.finished()
.list();
}
2 设置流程变量
2.1 启动流程并设置流程变量
public ProcessInstance startByKey(String key, Map<String, Object> map) {
return runtimeService.startProcessInstanceByKey(key, map);
}
2.2 在流程运行时设置流程变量
public void setRuntimeVariables(String executionId, Map<String, Object> map) {
runtimeService.setVariables(executionId, map);
}
2.3 在任务节点设置流程变量
public void setTaskVariables(String taskId, Map<String, Object> map) {
taskService.setVariables(taskId, map);
}
2.4 执行任务时设置变量
public void complete(String taskId, Map<String, Object> map) {
taskService.complete(taskId, map);
}
2.5 获取运行时流程变量
public Object getTaskVariable(String taskId, String key) {
return taskService.getVariable(taskId, key);
}
2.6 获取任务流程变量
public Object getTaskVariable(String taskId, String key) {
return taskService.getVariable(taskId, key);
}
3 连线(在连线上设置条件)
3.1 设置连线条件


3.2 排他网关
同样需要设置连线条件,可以在网关节点处设置默认连线


3.3 并行网关
不需要设置连线条件

4 设置流程办理人
4.1 直接写死(如上1.1设置办理人)
4.2 使用变量

4.3 设置任务监听

public class MyTaskListener implements TaskListener, ExecutionListener {
@Override
public void notify(DelegateTask delegateTask) {
delegateTask.setAssignee("张三");
}
@Override
public void notify(DelegateExecution delegateExecution) throws Exception {
}
}
5 多用户任务分配
5.1 直接写死

5.2 设置变量

5.3 使用监听
public class MyTaskListener1 implements TaskListener, ExecutionListener {
@Override
public void notify(DelegateTask delegateTask) {
delegateTask.addCandidateUser("张三");
delegateTask.addCandidateUser("李四");
}
@Override
public void notify(DelegateExecution delegateExecution) throws Exception {
}
}
6 设置子流程
6.1 局部子流程


6.2 全局子流程


called element中设置对应的流程id
