当前位置:网站首页>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 .
边栏推荐
- tornado之目录
- BUUCTF(3)
- L1-023 output gplt (20 points)
- [C language] open the door of C
- [Chongqing Guangdong education] National Open University spring 2019 770 real estate appraisal reference questions
- window上用.bat文件启动项目
- 【Kubernetes系列】Kubernetes 上安装 KubeSphere
- Vulhub vulnerability recurrence 76_ XXL-JOB
- SQL foundation 9 [grouping data]
- University stage summary
猜你喜欢
Improve the accuracy of 3D reconstruction of complex scenes | segmentation of UAV Remote Sensing Images Based on paddleseg
Practice (9-12 Lectures)
Used on windows Bat file startup project
User login function: simple but difficult
The frost peel off the purple dragon scale, and the xiariba people will talk about database SQL optimization and the principle of indexing (primary / secondary / clustered / non clustered)
大学阶段总结
Rhcsa the next day
Data double write consistency between redis and MySQL
深入浅出:了解时序数据库 InfluxDB
Experience installing VMware esxi 6.7 under VMware Workstation 16
随机推荐
深入浅出:了解时序数据库 InfluxDB
Amd RX 7000 Series graphics card product line exposure: two generations of core and process mix and match
[untitled] notice on holding "2022 traditional fermented food and modern brewing technology"
I was pressed for the draft, so let's talk about how long links can be as efficient as short links in the development of mobile terminals
Zhanrui tankbang | jointly build, cooperate and win-win zhanrui core ecology
【森城市】GIS数据漫谈(一)
Two years ago, the United States was reluctant to sell chips, but now there are mountains of chips begging China for help
Vulhub vulnerability recurrence 77_ zabbix
rapidjson读写json文件
Status of the thread
JVM -- class loading process and runtime data area
Valentine's Day is coming! Without 50W bride price, my girlfriend was forcibly dragged away...
University stage summary
大学阶段总结
Write a thread pool by hand, and take you to learn the implementation principle of ThreadPoolExecutor thread pool
Project 1 household accounting software (goal + demand description + code explanation + basic fund and revenue and expenditure details record + realization of keyboard access)
Rapidjson reading and writing JSON files
[Android reverse] function interception (use cache_flush system function to refresh CPU cache | refresh CPU cache disadvantages | recommended time for function interception)
大厂技术专家:架构设计中常用的思维模型
Vulhub vulnerability recurrence 76_ XXL-JOB