当前位置:网站首页>Activiti common operation data table relationship
Activiti common operation data table relationship
2022-07-04 07:35:00 【MrJason architect】
1. Process definition post deployment operations activiti Of 3 The table is as follows :
act_re_deployment Process definition deployment table , Add one record for each deployment
act_re_procdef Process definition form , Deploying each new process definition will add a record to this table
act_ge_bytearray Process resource table
Be careful :
act_re_deployment and act_re_procdef One-to-many relation , A deployment generates a record in the process deployment table , But a deployment can deploy multiple process definitions , Each process definition generates a record in the process definition table . Each process is defined in act_ge_bytearray There will be two resource records ,bpmn and png.
Suggest : Deploy one process at a time , In this way, the deployment table and process definition table are one-to-one related , Easy to read process deployment and process definition information .
2. Start process instance operation data table
act_hi_actinst Process instance execution history
act_hi_actinst And act_hi_identitylink adopt PROC_INST_ID relation
act_hi_identitylink History information of participating users in the process
act_hi_procinst Process instance history information , Business ID Come here BUSINESS_KEY_
Be careful PROC_INST_ID_ and PROC_DEF_ID_ Field
act_hi_taskinst Process task history information
act_ru_execution Process execution information , Business ID Come here BUSINESS_KEY_
act_ru_identitylink Participating user information of the process
act_ru_task Task information
3. Start the process instance and add Businesskey( Business identification )
The process definition is deployed in activiti after , You can use... In the system activiti To manage the execution of the process , An execution process represents an execution of a process .
For example, after deploying the system travel process , If a user wants to apply for a business trip, this process needs to be executed , If another user also wants to apply for a business trip, this process also needs to be executed , Each execution does not affect each other , Each execution is a separate process instance .
When starting a process instance , designated businesskey, Will be in act_ru_execution # Stored in the execution table of the process instance businesskey.
Businesskey: Business identification , It is usually the primary key of the business table , The business ID corresponds to the process instance one by one . The business ID comes from the business system . Storing a business ID is to associate and query the data of the business system according to the business ID .
such as : The travel process starts a process instance , You can send the... Of the travel slip id Store as business ID to activiti in , Future queries activiti The process instance information can be used to get the information of the difference order id Thus, the travel slip information can be obtained by associating and querying the business system database .
/** * Start process instance , add to businessKey */
@Test
public void addBusinessKey(){
// 1、 obtain ProcessEngine
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
// 2、 obtain RunTimeService
RuntimeService runtimeService = processEngine.getRuntimeService();
// 3、 Start process instance , At the same time, you should also specify the business id businessKey, That is, travel application form id, Here is 1001
ProcessInstance processInstance = runtimeService.
startProcessInstanceByKey("myEvection","1001");
// 4、 Output processInstance Related properties
System.out.println(" Business id=="+processInstance.getBusinessKey());
}
Activiti Of act_ru_execution Store business ID in :
Operate database tables
Start process instance , Operate the following database tables :
SELECT * FROM act_ru_execution # Process instance execution table , Record the execution of the current process instance
explain :
Process instance execution , If there is currently only one branch , A process instance has only one record and executes the primary key of the table id And process instances id identical , If multiple branches are currently running, there are multiple records in the execution table , There are primary keys and process instances of the execution table id Different records . No matter how many branches there are currently, there will always be a record of the primary key of the execution table and the process instance id identical
A process instance is running , Records related to process instances in this table are deleted .
SELECT * FROM act_ru_task # Task execution table , Record the current task
explain : Start process instance , The process is currently executing to the first task node , This table will insert a record indicating the execution of the current task , If the task is completed, the record is deleted .
SELECT * FROM act_ru_identitylink # Task participants , Record the users or groups currently participating in the task
SELECT * FROM act_hi_procinst # Process instance history table
Process instance start , A record will be inserted in this table , The process instance running completion record will not be deleted .
SELECT * FROM act_hi_taskinst # Task history table , Record all tasks
Start a mission , Not only in act_ru_task Table insert record , A record will also be inserted in the historical task table , The primary key of the task history table is the task id, When the task is completed, the record in this table will not be deleted .
SELECT * FROM act_hi_actinst # Activity history table , Record all activities
Activities include tasks , So this table not only records the tasks , Other activities during process execution are also recorded , Like the start event 、 End the event .
Access to the process businessKey( Business identification )
String businessKey = processInstance.getBusinessKey();
stay activiti Of act_ru_execution surface , Field BUSINESS_KEY Is to store business KEY Of .
4. Process delete
public void deleteDeployment() {
// Process deployment id
String deploymentId = "1";
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
// Get... Through the process engine repositoryService
RepositoryService repositoryService = processEngine
.getRepositoryService();
// Delete process definition , If the process definition has an existing process instance started, there is an error in deletion
repositoryService.deleteDeployment(deploymentId);
// Set up true Cascade delete process definition , Even if the process has a process instance started, it can be deleted , Set to false Non level deletion method , If the process
//repositoryService.deleteDeployment(deploymentId, true);
}
explain :
Use repositoryService Delete process definition , History table information will not be deleted
If there is no running process under the process definition , It can be deleted with normal .
If there is a running process under the process definition , Use normal delete to report error , You can use the cascade delete method to delete all the processes and related records .
Delete the unfinished process node first , Finally, you can completely delete the process definition information
The deletion of intermediate links in project development is generally only available to super administrators .
5. Process resource download
Now our process resource file has been uploaded to the database , If other users want to view these resource files , Resource files can be downloaded from the database to the local database .
The solution is :
1、jdbc Yes blob type ,clob Type data is read out , Save to file directory
2、 Use activiti Of api To achieve
Use commons-io.jar solve IO The operation of
introduce commons-io Dependency package
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
Obtain process definition resources through process definition objects , obtain bpmn and png
import org.apache.commons.io.IOUtils;
@Test
public void deleteDeployment(){
// Get engine
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
// obtain repositoryService
RepositoryService repositoryService = processEngine.getRepositoryService();
// According to the deployment id Delete deployment information , If you want to cascade delete , You can add a second parameter ,true
repositoryService.deleteDeployment("1");
}
public void queryBpmnFile() throws IOException {
// 1、 Get the engine
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
// 2、 obtain repositoryService
RepositoryService repositoryService = processEngine.getRepositoryService();
// 3、 Get the query :ProcessDefinitionQuery, Set query conditions , Get the desired process definition
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
.processDefinitionKey("myEvection")
.singleResult();
// 4、 Define information through the process , Get deployed ID
String deploymentId = processDefinition.getDeploymentId();
// 5、 adopt repositoryService Methods , Realize reading picture information and bpmn Information
// png Stream of pictures
InputStream pngInput = repositoryService.getResourceAsStream(deploymentId, processDefinition.getDiagramResourceName());
// bpmn The flow of documents
InputStream bpmnInput = repositoryService.getResourceAsStream(deploymentId, processDefinition.getResourceName());
// 6、 structure OutputStream flow
File file_png = new File("d:/evectionflow01.png");
File file_bpmn = new File("d:/evectionflow01.bpmn");
FileOutputStream bpmnOut = new FileOutputStream(file_bpmn);
FileOutputStream pngOut = new FileOutputStream(file_png);
// 7、 Input stream , Conversion of output stream
IOUtils.copy(pngInput,pngOut);
IOUtils.copy(bpmnInput,bpmnOut);
// 8、 Closed flow
pngOut.close();
bpmnOut.close();
pngInput.close();
bpmnInput.close();
}
explain :
deploymentId Deploy for the process ID
resource_name by act_ge_bytearray In the table NAME_ The value of the column
Use repositoryService Of getDeploymentResourceNames Method to obtain the names of all files under the specified deployment
Use repositoryService Of getResourceAsStream Method passed in deployment ID And resource picture name can obtain the input stream of the file with the specified name under the deployment
Finally, output the picture resources in the input stream .
边栏推荐
- Project 1 household accounting software (goal + demand description + code explanation + basic fund and revenue and expenditure details record + realization of keyboard access)
- JVM -- class loading process and runtime data area
- socket inet_ pton() inet_ Ntop() function (a new network address translation function, which converts the expression format and numerical format to each other. The old ones are inet_aton(), INET_ ntoa
- Blog stop statement
- How does dataframe calculate the average value of each row as another column
- window上用.bat文件启动项目
- Write a thread pool by hand, and take you to learn the implementation principle of ThreadPoolExecutor thread pool
- L1-024 the day after tomorrow (5 points)
- [FreeRTOS] FreeRTOS learning notes (7) - handwritten FreeRTOS two-way linked list / source code analysis
- Types of references in BibTex
猜你喜欢
Redis - detailed explanation of cache avalanche, cache penetration and cache breakdown
socket inet_ pton() inet_ Ntop() function (a new network address translation function, which converts the expression format and numerical format to each other. The old ones are inet_aton(), INET_ ntoa
Cell reports: Wei Fuwen group of the Institute of zoology, Chinese Academy of Sciences analyzes the function of seasonal changes in the intestinal flora of giant pandas
BasicVSR++: Improving Video Super-Resolutionwith Enhanced Propagation and Alignment
Chain ide -- the infrastructure of the metauniverse
Unity 从Inspector界面打开资源管理器选择并记录文件路径
Four sets of APIs for queues
Master-slave replication principle of MySQL database
Solution of running crash caused by node error
Pangu open source: multi support and promotion, the wave of chip industry
随机推荐
How to buy financial products in 2022?
Technical experts from large factories: common thinking models in architecture design
Electronic Association C language level 1 35, bank interest
Boast about Devops
SQL foundation 9 [grouping data]
[Chongqing Guangdong education] National Open University spring 2019 770 real estate appraisal reference questions
[real case] how to deal with the failure of message consumption?
[Flink] temporal semantics and watermark
L1-027 rental (20 points)
Oracle-存储过程与函数
[network security] what is emergency response? What indicators should you pay attention to in emergency response?
JVM -- class loading process and runtime data area
21个战略性目标实例,推动你的公司快速发展
MySQL 数据库 - 函数 约束 多表查询 事务
博客停更声明
Redis - detailed explanation of cache avalanche, cache penetration and cache breakdown
Guoguo took you to write a linked list, and the primary school students said it was good after reading it
《剑指Offer》第2版——力扣刷题
Advanced MySQL: Basics (5-8 Lectures)
Directory of tornado