当前位置:网站首页>第五章:activiti流程分流判断,判断走不同的任务节点
第五章:activiti流程分流判断,判断走不同的任务节点
2022-08-05 10:05:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
这里我们承接专栏的上一篇博文,
请假流程中我们会有个判断,因为一般的请假班长有权直接审批通过,不用班主任批准,那这里就需要加个判断了;
这里我们辅助一个请假流程,如下:
流程图如下:
那么怎么判断走那天线的,也就是要不要走leave003这个节点呢,这里我们需要写内置表达式,类似el表达式:
另外一条线:
下面我们新建一个类,如下,需要修改部署流程定义方法里面的流程图文件名:
对了,还有要修改启动流程中的key,之前的测试案例流程图的key是StudentLeaveProcess00,现在改成StudentLeaveProcess02.如下:
代码如下:
package com.xiaoyexinxixn.ActivityLesson.flow;
import static org.junit.Assert.*;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.junit.Test;
import com.xiaoyexinxixn.ActivityLesson.model.Student;
public class StudentLeaveProcess2 {
//获取默认流程引擎实例,会自动读取activiti.cfg.xml ,所以我们要严格定义配置文件的名称
private ProcessEngine processEngine =ProcessEngines.getDefaultProcessEngine();
/**
* 部署流程定义
*/
@Test
public void deploy() {
//获取部署相关service,这些都是activiti封装好的api接口,还有很多,下面也会用到很多
Deployment deployment=processEngine.getRepositoryService()
//创建部署
.createDeployment()
//加载流程图资源文件
.addClasspathResource("diagrams/StudentLeave2.bpmn")
//加载流程图片
.addClasspathResource("diagrams/StudentLeave2.png")
//流程名称
.name("leave02")
//部署流程
.deploy();
System.out.println("流程部署的ID: "+deployment.getId());
System.out.println("流程部署的Name: "+deployment.getName());
}
/*
* 启动流程实例
*/
@Test
public void start(){
//运行启动流程的servicee
ProcessInstance pi=processEngine.getRuntimeService()
//定义流程表的KEY字段值,key值是我们前面定义好的key,可在act_re_procdef表中的key_字段中找到,
.startProcessInstanceByKey("studentLeaveProcess02");
System.out.println(pi.getId());
System.out.println(pi.getProcessDefinitionId());
} }
运行deploy()方法,部署流程,成功后看看流程部署表:act_re_deployment:
是有leave02的;
然后再启动流程,
然后完成任务,去测试我们的判断。
到leave02节点;
然后我们利用上一章学习的知识,在节点leave02结束的时候设置msg变量的值,从而判断走哪个节点。
代码:
/**
* 完成任务时设置流程变量
*/
@Test
public void completeTaskVariablesTest(){
Map<String, Object> variables=new HashMap<String,Object>();
variables.put("msg", "common");
processEngine.getTaskService().complete("72502",variables);
}
运行后,发现任务表的数据没有了,说明没有走leave03节点,说明是没有问题的。
同理走设置msg为“important”机会走leave03节点。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/106142.html原文链接:https://javaforall.cn
边栏推荐
- 数据中台建设(十):数据安全管理
- 无题七
- The century-old Nordic luxury home appliance brand ASKO smart wine cabinet in the three-temperature area presents the Chinese Valentine’s Day, and tastes the love of the delicacy
- 【 temperature warning program DE development 】 event driven model instance
- Redis源码解析:Redis Cluster
- MySQL advanced (twenty-seven) database index principle
- 【MindSpore Easy-Diantong Robot-01】You may have seen many knowledge quiz robots, but this one is a bit different
- 无题六
- 阿里顶级架构师多年总结的JVM宝典,哪里不会查哪里!
- 歌词整理
猜你喜欢
Our Web3 Entrepreneurship Project, Yellow
Oracle temporary table space role
Meteorological data processing example - matlab string cutting matching and R language date matching (data splicing)
气象数据数据处理实例——matlab字符串切割匹配与R语言日期匹配(数据拼接)
mysql进阶(二十七)数据库索引原理
IDEA performs the Test operation, resulting in duplicate data when data is inserted
The JVM collection that Alibaba's top architects have summarized for many years, where can't I check it!
STM32+ULN2003驱动28BYJ4步进电机(根据圈数正转、反转)
After Keil upgrades to AC6, what changes?
The century-old Nordic luxury home appliance brand ASKO smart wine cabinet in the three-temperature area presents the Chinese Valentine’s Day, and tastes the love of the delicacy
随机推荐
Open Source Summer | How OpenHarmony Query Device Type (eTS)
无题十四
韦东山 数码相框 项目学习(六)tslib的移植
IO stream articles -- based on io stream to realize folder copy (copy subfolders and files in subfolders) full of dry goods
第八章:activiti多用户任务分配
无题十一
百年北欧奢华家电品牌ASKO智能三温区酒柜臻献七夕,共品珍馐爱意
Jenkins使用手册(2) —— 软件配置
Oracle temporary table space role
自定义过滤器和拦截器实现ThreadLocal线程封闭
[Unity] [UGUI] [Display text on the screen]
攻防世界-PWN-new_easypwn
第三章 : redis数据结构种类
Which big guy has the 11G GI and ojvm patches in April or January 2020, please help?
SD NAND Flash简介!
5.部署web项目到云服务器
[Strong Net Cup 2022] WP-UM
Can MySQL use aggregate functions without GROUP BY?
阿里顶级架构师多年总结的JVM宝典,哪里不会查哪里!
偏向锁/轻量锁/重级锁锁锁更健康,上锁解锁到底是怎么完成实现的