Activiti7---Changes in the contents of the database tables at various stages

1. Description

This article refers to immort.Liu 's blog post.

2. Changes in the database tables at each stage of Activiti7

2.1 The deployment phase of the process

2.1.1 Code

	/**
     * 部署流程
     */
    @Test
    public void testDeployProcess() {
    
    
        Deployment deploy = repositoryService.createDeployment()
                .addClasspathResource("processes/test.bpmn")
                .addClasspathResource("processes/test.png")
                .name("测试数据库内容变化-1")
                .deploy();
        System.out.println("流程部署ID:"+deploy.getId());
        System.out.println("流程部署名称:"+deploy.getName());
    }

2.1.2 Changed table

The tables that have changed during the deployment phase are:

  • act_ge_bytearray (资源表)
  • act_re_deployment (流程定义部署表,存储流程部署信息)
  • act_re_procdef (流程定义表,记录流程定义信息)

2.1.3 The content of the data in the table

  • act_ge_bytearray

Insert picture description here

  • The first line stores the xml file of bpmn

  • The second line stores the png image file

  • act_re_deployment
    Insert picture description here
    The above figure explains the source of these data, and you can also set other fields in the table during deployment.

  • act_re_procdef
    Insert picture description here
    The key field in the above table can be used to start the process. This article uses the key to start the process.

2.2 Start process instance

2.2.1 Code

	/**
     * 启动流程
     */
    @Test
    public void  testStartProcess(){
    
    
        securityUtil.logInAs("salaboy");
        //启动流程实例,同时还要指定业务标识businessKey
        //第一个参数:是指流程定义key
        //第二个参数:业务标识businessKey
        ProcessInstance test = runtimeService.startProcessInstanceByKey("test","1001");
        System.out.println("流程实例id:"+test.getId());
        System.out.println("流程部署id:"+test.getProcessDefinitionId());
    }

2.2.2 Changed table

  • act_hi_actinst
  • act_hi_identitylink
  • act_hi_procinst
  • act_hi_taskinst
  • act_ru_execution
  • act_ru_identitylink
  • act_ru_task

Note: Generally, the records at the beginning of act_hi_ will not be deleted after the process instance runs.

2.2.3 The content of the data in the table

  • act_hi_actinst
    English full spelling: activiti_history_action_instance
    translates: activiti_historical_activity_instance
    Activity instance: I personally think it is a node in the process, such as the description of purchase application : Each time a task (activity instance) is processed,
    a record will be added to the table.
    Insert picture description here
  • act_hi_identitylink
    Full spelling in English: activiti_history_identity_link
    translates: activiti_historical_identity_contact

Insert picture description here
It records the historical information of the task participants of each process instance (record one for each participant).

  • act_hi_procinst
    Full spelling in English: activiti_history_process_instence
    translates: activiti_史_process_instance
    Description: Every time a process is started, a process instance will be generated. There is one more piece of information in the table.

Insert picture description here

  • act_hi_taskinst
    Full spelling in English: activiti_history_task_instence
    translates: activiti_historical_task_instance The
    table records each execution (including pending execution) task instance

Insert picture description here

  • act_ru_execution
    Full spelling in English: activiti_run_execution
    translates: activiti_跑_exec
    The data structure stored in the table is a tree structure, that is, there is a parent field in the table.
    Explanation: Process instance execution, if there is only one branch at present, a process instance has only one record and the primary key id of the execution table is the same as the process instance id. If there are multiple branches currently running, there are multiple records in the execution table. The record where the primary key of the execution table is different from the process instance id. Regardless of how many branches there are currently, there will always be a record in the execution table whose primary key is the same as the process instance id. When a process instance is completed, the records related to the process instance in this table are deleted.

Insert picture description here

  • act_ru_identitylink
    English full spelling: activiti_run_identity_link
    translated: activiti_execution_identity_link
    description: Stores the participants in the unfinished process instance. If there is a process instance with two participants zhangsan and lisi, when waiting for zhangsan to execute, This process instance has only one record. When the execution of shangsan is completed and it is the turn of lisi to execute, then this process instance has two records. When the execution of this process instance is completed, in this table, all participants corresponding to the completed process instance will be It is deleted, but the act_hi_identitylinktable will not be deleted. You can understand the table name.

Insert picture description here

  • act_ru_task
    Full spelling in English: activiti_run_task
    translated: activiti_execute_task
    Description: The table stores the pending tasks (nodes to be processed) in the unfinished process instance. Generally speaking, there is only one record in the table for each process instance.

Insert picture description here

2.3 Task processing

2.3.1 Code

	/**
     * 查询及完成任务
     */
    @Test
    public void testTaskProcess(){
    
    

        List<Task> list = taskService.createTaskQuery()
                .taskAssignee("user1")
                .list();
        for (Task task : list) {
    
    
            System.out.println("任务id:"+task.getId());
            System.out.println("任务处理人:"+task.getAssignee());
            System.out.println("流程实例id:"+task.getProcessInstanceId());
            //完成任务
            taskService.complete(task.getId());
        }

    }

2.3.2 Changed table

  • act_hi_actinst
  • act_hi_identitylink
  • act_hi_taskinst
  • act_ru_execution
  • act_ru_identitylink
  • act_ru_task

Note: Generally, the records at the beginning of act_hi_ will not be deleted after the process instance runs.

2.3.3 Changes in the data in the table

The specific changes of the table can be compared with the table in section 2.2.3.

  • act_hi_actinst
    English full spelling: activiti_history_action_instance
    translates: activiti_史_活动_instance
    Activity instance: I personally think it is a node in the process, such as a purchase request.
    Each time a task (activity instance) is processed, a record will be added to the table.
    Changes in the table: After a task is processed, a record is added to this table. Because a task was processed.

Insert picture description here

  • act_hi_identitylink
    English full spelling: activiti_history_identity_link
    translates: activiti_historical_identity_contact It
    records the historical information of the task participants of each process instance (for each participant, record one).
    Changes in the table: A record has been added to the table. The reason is, waiting for lisi to process a task at this time. One more identity.

Insert picture description here

  • act_hi_taskinst
    Full spelling in English: activiti_history_task_instence
    translates: activiti_historical_task_instance The
    table records the
    changes in the task instance table that has been executed each time (including those to be executed) : A record has been added to the table because the process has completed one Task instance, now it's time to process the second task instance. So there is an extra record.

Insert picture description here

  • act_ru_execution
    English all spelling: activiti_run_execution
    translates: activiti_exec_execution
    Note: The data structure stored in the table is a tree structure, that is, there is a parent field in the table.
    Note: The process instance is executed. If there is only one branch at present, a process instance has only one record and the primary key id of the execution table is the same as the process instance id. If there are multiple branches currently running, there are multiple records in the execution table. The record where the primary key of the execution table is different from the process instance id. Regardless of how many branches there are currently, there will always be a record in the execution table whose primary key is the same as the process instance id. When a process instance runs and completes, the records related to the process instance in this table are deleted.
    Changes in the table: The second record of the process instance is updated in the table. Because the previous task instance has been processed and the current task instance to be processed has changed, the corresponding record in the table has been updated (below The picture has a better display) The
    above record is before the task processing, and the latter is after the task processing.

Insert picture description here

  • act_ru_identitylink
    Full spelling in English: activiti_run_identity_link
    translated: activiti_execution_identity_link
    description: Stores the participants in the unfinished process instance, if there are two participants zhangsan and lisi in a process instance, when waiting for zhangsan to execute, This process instance has only one record. When the execution of shangsan is completed and it is the turn of lisi to execute, then this process instance has two records. When the execution of this process instance is completed, in this table, all participants corresponding to the completed process instance will be It is deleted, but the act_hi_identitylinktable will not be deleted. You can understand the table name.
    Changes in the table: A record has been added.

Insert picture description here

  • act_ru_task
    Full spelling in English: activiti_run_task
    translated: activiti_execute_task
    Description: The table stores the pending tasks (nodes to be processed) in the unfinished process instance. Generally speaking, there is only one record in the table for each process instance.
    Changes in the table: The record corresponding to this process instance is updated in the table. Always show examples of tasks that currently need to be processed.

Insert picture description here

2.4 End of process

When all tasks are completed, the process ends.

2.4.1 Code

 	/**
     * 查询及完成任务
     */
    @Test
    public void testTaskProcess(){
    
    

        List<Task> list = taskService.createTaskQuery()
                .taskAssignee("user2")
                .list();
        for (Task task : list) {
    
    
            System.out.println("任务id:"+task.getId());
            System.out.println("任务处理人:"+task.getAssignee());
            System.out.println("流程实例id:"+task.getProcessInstanceId());
            //完成任务
            taskService.complete(task.getId());
        }

    }

2.4.2 Changed table

Same as the table in section 2.3

  • act_hi_actinst
  • act_hi_identitylink
  • act_hi_taskinst
  • act_ru_execution
  • act_ru_identitylink
  • act_ru_task

Note: Generally, the records at the beginning of act_hi_ will not be deleted after the process instance runs.

2.4.3 Changes in the data in the table

  • act_hi_actinst
    English full spelling: activiti_history_action_instance
    translates: activiti_史_活动_instance
    Activity instance: I personally think it is a node in the process, such as a purchase request.
    Each time a task (activity instance) is processed, a record will be added to the table.
    Changes in the table: After task processing, this table adds records. Because of the task.

Insert picture description here

  • act_hi_identitylink
    Full spelling in English: activiti_history_identity_link
    translated: activiti_historical_identity_contact It
    records the historical information of the task participants of each process instance (for each participant, record one).
    Changes in the table: A record has been added to the table. The reason is that the process instance has already run to completion. So many task instances were processed. So there are many more records in the table.

    Insert picture description here
  • act_hi_taskinst
    Full spelling in English: activiti_history_task_instence
    translates: activiti_historical_task_instance The
    table records each executed (including pending) task instances
    . Changes in the table: Records are added to the table, and the process instance has been completed. So many task instances were processed. So there are many more records in the table.

Insert picture description here

  • act_ru_execution
    English all spelling: activiti_run_execution
    translates: activiti_exec_execution
    Note: The data structure stored in the table is a tree structure, that is, there is a parent field in the table.
    Note: The process instance is executed. If there is only one branch at present, a process instance has only one record and the primary key id of the execution table is the same as the process instance id. If there are multiple branches currently running, there are multiple records in the execution table. The record where the primary key of the execution table is different from the process instance id. Regardless of how many branches there are currently, there will always be a record in the execution table whose primary key is the same as the process instance id. When a process instance is completed, the records related to the process instance in this table are deleted.
    Changes in the table: The table is empty. Because all process instances have been executed. So there is no process instance in execution.

Insert picture description here

  • act_ru_identitylink
    English full spelling: activiti_run_identity_link
    translated: activiti_execution_identity_link
    description: Stores the participants in the unfinished process instance. If there is a process instance with two participants zhangsan and lisi, when waiting for zhangsan to execute, This process instance has only one record. When the execution of shangsan is completed and it is the turn of lisi to execute, then this process instance has two records. When the execution of this process instance is completed, in this table, all participants corresponding to the completed process instance will be It is deleted, but the act_hi_identitylinktable will not be deleted. You can understand the table name.
    Changes in the table: The table is empty. Because all process instances have been executed. So there is no process instance in execution.

Insert picture description here

  • act_ru_task
    Full spelling in English: activiti_run_task
    translated: activiti_execute_task
    Description: The table stores the pending tasks (nodes to be processed) in the unfinished process instance. Generally speaking, there is only one record in the table for each process instance.
    Changes in the table: The table is empty. Because all process instances have been executed. So there is no process instance in execution.

Insert picture description here

3. Summary

After the above detailed process tracking, the tables involved in a simple process and the changes in the contents of the table from the beginning to the end are reflected, and the test is over.

Guess you like

Origin blog.csdn.net/Lv_vI/article/details/108235762