当前位置:网站首页>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
边栏推荐
- 产品太多了,如何实现一次登录多产品互通?
- Which big guy has the 11G GI and ojvm patches in April or January 2020, please help?
- High-quality DeFi application building guide to help developers enjoy DeFi Summer
- MySQL之数据视图
- Handwriting Currying - toString Comprehension
- Voice-based social software development - making the most of its value
- 还在找网盘资源吗?快点收藏如下几个值得收藏的网盘资源搜索神器吧!
- Jenkins manual (2) - software configuration
- IO stream articles -- based on io stream to realize folder copy (copy subfolders and files in subfolders) full of dry goods
- linux下oracle常见操作以及日常积累知识点(函数、定时任务)
猜你喜欢

阿里全新推出:微服务突击手册,把所有操作都写出来了PDF

Egg framework usage (2)

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

百年北欧奢华家电品牌ASKO智能三温区酒柜臻献七夕,共品珍馐爱意

The JVM collection that Alibaba's top architects have summarized for many years, where can't I check it!

Egg framework usage (1)

High-quality DeFi application building guide to help developers enjoy DeFi Summer

This notebook of concurrent programming knowledge points strongly recommended by Ali will be a breakthrough for you to get an offer from a big factory
![[强网杯2022]WP-UM](/img/3d/caeab05ddca278af274dbf6e2f8ba1.png)
[强网杯2022]WP-UM

【 temperature warning program DE development 】 event driven model instance
随机推荐
How does the official account operate and maintain?Public account operation and maintenance professional team
FPGA: Basic Getting Started LED Lights Blinking
你最隐秘的性格在哪?
FPGA:基础入门LED灯闪烁
JS introduction to reverse the recycling business network of learning, simple encryption mobile phone number
还在找网盘资源吗?快点收藏如下几个值得收藏的网盘资源搜索神器吧!
linux下oracle常见操作以及日常积累知识点(函数、定时任务)
[强网杯2022]WP-UM
如何选币与确定对应策略研究
FPGA: Basic Getting Started Button Controlling LED Lights
Where is your most secretive personality?
SMB + SMB2: Accessing shares return an error after prolonged idle period
Development common manual link sharing
[Strong Net Cup 2022] WP-UM
【AGC】增长服务1-远程配置示例
第四章:redis 数组结构的set和一些通用命令「建议收藏」
2022 Hangzhou Electric Power Multi-School Session 6 1008.Shinobu Loves Segment Tree Regular Questions
2022 Huashu Cup Mathematical Modeling Question A Optimization Design Ideas for Ring Oscillators Code Sharing
Meteorological data processing example - matlab string cutting matching and R language date matching (data splicing)
百年北欧奢华家电品牌ASKO智能三温区酒柜臻献七夕,共品珍馐爱意