当前位置:网站首页>Chapter 5: Activiti process shunting judgment, judging to go to different task nodes
Chapter 5: Activiti process shunting judgment, judging to go to different task nodes
2022-08-05 10:21:00 【Full stack programmer webmaster】
大家好,又见面了,我是你们的朋友全栈君.
Here we undertake the previous blog post of the column,
Ask for leave in the process we will have a judgment,Because the general leave monitor has the right to directly approve and approve,Without the approval of the class teacher,There needs to be a judgement here.;
Here we assist a leave process,如下:
流程图如下:
So how do you judge which antenna is going?,That is, whether to go or notleave003这个节点呢,Here we need to write built-in expressions,类似el表达式:
另外一条线:
Next we create a new class,如下,Need to modify the flow chart file name in the deployment process definition method:
对了,There is also a need to modify the startup processkey,The flow chart of the previous test casekey是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 {
//Get the default process engine instance,会自动读取activiti.cfg.xml ,So we have to strictly define the name of the configuration file
private ProcessEngine processEngine =ProcessEngines.getDefaultProcessEngine();
/**
* 部署流程定义
*/
@Test
public void deploy() {
//获取部署相关service,这些都是activiti封装好的api接口,还有很多,The following will also be used a lot
Deployment deployment=processEngine.getRepositoryService()
//创建部署
.createDeployment()
//Load flowchart resource file
.addClasspathResource("diagrams/StudentLeave2.bpmn")
//Load process image
.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()方法,部署流程,After success, look at the process deployment table:act_re_deployment:
是有leave02的;
Then start the process again,
然后完成任务,to test our judgment.
到leave02节点;
Then we use what we learned in the previous chapter,在节点leave02结束的时候设置msg变量的值,So as to determine which node to go.
代码:
/**
* 完成任务时设置流程变量
*/
@Test
public void completeTaskVariablesTest(){
Map<String, Object> variables=new HashMap<String,Object>();
variables.put("msg", "common");
processEngine.getTaskService().complete("72502",variables);
}运行后,Found that the data in the task table is gone,说明没有走leave03节点,说明是没有问题的.
Go to the settings in the same waymsg为“important”chance to goleave03节点.
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/106142.html原文链接:https://javaforall.cn
边栏推荐
- 第九章:activit内置用户组设计与组任务分配和IdentityService接口的使用
- 【Unity】【UGUI】【在屏幕上显示文本】
- The fuse: OAuth 2.0 four authorized login methods must read
- [Unity] [UGUI] [Display text on the screen]
- Development common manual link sharing
- 技术干货 | 基于 MindSpore 实现图像分割之豪斯多夫距离
- hcip BGP enhancement experiment
- FPGA:开发环境Vivado的使用
- 还在找网盘资源吗?快点收藏如下几个值得收藏的网盘资源搜索神器吧!
- Introduction to SD NAND Flash!
猜你喜欢

FPGA: Use of the development environment Vivado

5. Deploy the web project to the cloud server

RT-Thread记录(一、RT-Thread 版本、RT-Thread Studio开发环境 及 配合CubeMX开发快速上手)

DFINITY 基金会创始人谈熊市沉浮,DeFi 项目该何去何从

What are the standards for electrical engineering

多线程(进阶) - 2.5w字总结

Which big guy has the 11G GI and ojvm patches in April or January 2020, please help?

这份阿里强推的并发编程知识点笔记,将是你拿大厂offer的突破口

Login function and logout function (St. Regis Takeaway)

【MindSpore Easy-Diantong Robot-01】You may have seen many knowledge quiz robots, but this one is a bit different
随机推荐
First Decentralized Heist?Loss of nearly 200 million US dollars: analysis of the attack on the cross-chain bridge Nomad
Is digital transformation a business buy-in?
力扣(LeetCode)216. 组合总和 III(2022.08.04)
Egg framework usage (1)
导火索:OAuth 2.0四种授权登录方式必读
The host computer develops C# language: simulates the STC serial port assistant to receive the data sent by the microcontroller
19.3 restart the Oracle environment
DFINITY 基金会创始人谈熊市沉浮,DeFi 项目该何去何从
Chapter 4: In the activiti process, variable transmission and acquisition process variables, setting and acquiring multiple process variables, setting and acquiring local process variables "recommende
入门 Polkadot 平行链开发,看这一篇就够了
一个栈的输入序列为1 2 3 4 5 的出站顺序的理解
Data Middle Office Construction (10): Data Security Management
PHP 操作mangoDb
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
Oracle 19.3 restart 环境
How to choose coins and determine the corresponding strategy research
如何测试一下现场的备机失败,转发主机的场景?
【MindSpore易点通机器人-01】你也许见过很多知识问答机器人,但这个有点不一样
Complete image segmentation efficiently based on MindSpore and realize Dice!
【AGC】增长服务1-远程配置示例