标签:tin proc 历史记录 办理 strong tool nbsp dep col
假设: 某公司的员工请假单审批流程是 发起者-->部门主管--->部门经理 共三个节点发起者:公司所有的用户
部门主管:aaa(审批)
部门经理:bbb(审批)
java Activiti工作流引擎共有23张数据表用来存储审批 这里我只是使用了核心的几张表
第一步:发布流程定义
发布定义员工请假申请单流程 mysql> UPDATE act_ge_property SET rev_ = 2, value_ = '101' WHERE name_ = 'next.dbid' AND rev_ = 1; mysql> select * from act_ge_property; +----------------+--------------+------+ | NAME_ | VALUE_ | REV_ | +----------------+--------------+------+ | next.dbid | 101 | 2 | | schema.history | create(5.12) | 1 | | schema.version | 5.12 | 1 | +----------------+--------------+------+ 3 rows in set ========================================================================= mysql> INSERT INTO `act_re_deployment` SET id_ = '1', name_ = '员工请假申请单', category_ = NULL, deploy_time_ = '2018-02-09 20:23:36'; mysql> select * from act_re_deployment; +-----+--------------+-----------+-------------------------+ | ID_ | NAME_ | CATEGORY_ | DEPLOY_TIME_ | +-----+--------------+-----------+-------------------------+ | 1 | 员工请假申请单 | NULL | 2018-02-09 20:23:36 | +-----+--------------+-----------+-------------------------+ 1 row in set ========================================================================= mysql> INSERT INTO `act_ge_bytearray` SET id_='2', rev_= 1, name_= 'diagram/diagram.bpmn', bytes_= _binary'<?xml..?>..中间xml省去..</definitions>', deployment_id_= '1', generated_= 0; ========================================================================= mysql> INSERT INTO `act_re_procdef` SET id_ = 'myprocess:1:4', rev_ = 1, category_ = 'http://www.activiti.org/test', name_ = 'my process', key_ = 'myprocess', version_ = 1, deployment_id_ = '1', resource_name_ = 'diagram/diagram.bpmn', dgrm_resource_name_ = 'diagram/diagram.png', description_ = NULL, has_start_form_key_ = 0, suspension_state_ = 1; mysql> select * from `act_re_procdef`\g; *************************** 1. row *************************** id_: myprocess:1:4 rev_: 1 category_: http://www.activiti.org/test name_: my process key_: myprocess version_: 1 deployment_id_: 1 resource_name_: diagram/diagram.bpmn dgrm_resource_name_: diagram/diagram.png description_: null has_start_form_key_: 0 suspension_state_: 1 1 row in set (0.00 sec) =========================================================================
第二步:员工发起请假流程审批实例
通过流程定义 processDefinitionKey 来启动一个流程流程 ========================================================================= mysql> UPDATE act_ge_property SET rev_ = 3, value_ = '201' WHERE name_ = 'next.dbid' AND rev_ = 2; mysql> select * from act_ge_property; +----------------+--------------+------+ | NAME_ | VALUE_ | REV_ | +----------------+--------------+------+ | next.dbid | 201 | 3 | | schema.history | create(5.12) | 1 | | schema.version | 5.12 | 1 | +----------------+--------------+------+ 3 rows in set ========================================================================= 向流程实例表插入一条数据 mysql> INSERT INTO `act_ru_execution` SET id_ = '101', rev_ = 1, proc_inst_id_ = '101', business_key_ = NULL, proc_def_id_ = 'myprocess:1:4', act_id_ = 'one', is_active_ = 1, is_concurrent_ = 0, is_scope_ = 1, is_event_scope_ = 0, parent_id_ = NULL, super_exec_ = NULL, suspension_state_ = 1, cached_ent_state_ = 2; mysql> select * from `act_ru_execution`\G; *************************** 1. row *************************** id_: 101 rev_: 1 proc_inst_id_: 101 business_key_: null parent_id_: null proc_def_id_: myprocess:1:4 super_exec_: null act_id_: one is_active_: 1 is_concurrent_: 0 is_scope_: 1 is_event_scope_: 0 suspension_state_: 1 cached_ent_state_: 2 1 row in set (0.00 sec) ========================================================================= 流程实例历史记录表 mysql> INSERT INTO `act_hi_procinst` SET id_ = '101', proc_inst_id_ = '101', business_key_ = NULL, proc_def_id_ = 'myprocess:1:4', start_time_ = '2018-02-09 21:38:20', end_time_ = NULL, duration_ = NULL, start_user_id_ = NULL, start_act_id_ = 'startevent1', end_act_id_ = NULL, super_process_instance_id_ = NULL, delete_reason_ = NULL; mysql> select * from `act_hi_procinst`\g; *************************** 1. row *************************** id_: 101 proc_inst_id_: 101 business_key_: null proc_def_id_: myprocess:1:4 start_time_: 2018-02-09 21:38:20 end_time_: null duration_: null start_user_id_: null start_act_id_: startevent1 end_act_id_: null super_process_instance_id_: null delete_reason_: null 1 row in set (0.00 sec) ========================================================================= mysql> INSERT INTO `act_hi_actinst` SET id_ = '102', proc_def_id_ = 'myprocess:1:4', proc_inst_id_ = '101', execution_id_ = '101', act_id_ = 'startevent1', task_id_ = NULL, call_proc_inst_id_ = NULL, act_name_ = 'start', act_type_ = 'startevent', assignee_ = NULL, start_time_ = '2018-02-09 21:38:20', end_time_ = '2018-02-09 21:38:20', duration_ = 6; mysql> INSERT INTO `act_hi_actinst` SET id_ = '103', proc_def_id_ = 'myprocess:1:4', proc_inst_id_ = '101', execution_id_ = '101', act_id_ = 'one', task_id_ = '104', call_proc_inst_id_ = NULL, act_name_ = '部门主管审批', act_type_ = 'usertask', assignee_ = 'aaa', start_time_ = '2018-02-09 21:38:20', end_time_ = NULL, duration_ = NULL; mysql> select * from `act_hi_actinst`\G; *************************** 1. row *************************** id_: 102 proc_def_id_: myprocess:1:4 proc_inst_id_: 101 execution_id_: 101 act_id_: startevent1 task_id_: null call_proc_inst_id_: null act_name_: start act_type_: startevent assignee_: null start_time_: 2018-02-09 21:38:20 end_time_: 2018-02-09 21:38:20 duration_: 6 *************************** 2. row *************************** id_: 103 proc_def_id_: myprocess:1:4 proc_inst_id_: 101 execution_id_: 101 act_id_: one task_id_: 104 call_proc_inst_id_: null act_name_: 部门主管审批 act_type_: usertask assignee_: aaa start_time_: 2018-02-09 21:38:20 end_time_: null duration_: null 2 rows in set (0.00 sec) ========================================================================= mysql> INSERT INTO `act_ru_task` SET id_ = '104', rev_ = 1, name_ = '部门主管审批', parent_task_id_ = NULL, description_ = NULL, priority_ = 50, create_time_ = '2018-02-09 21:38:20', owner_ = NULL, assignee_ = 'aaa', delegation_ = NULL, execution_id_ = '101', proc_inst_id_ = '101', proc_def_id_ = 'myprocess:1:4', task_def_key_ = 'one', due_date_ = NULL, suspension_state_ = 1; mysql> select * from `act_ru_task`\G; *************************** 1. row *************************** id_: 104 rev_: 1 execution_id_: 101 proc_inst_id_: 101 proc_def_id_: myprocess:1:4 name_: 部门主管审批 parent_task_id_: null description_: null task_def_key_: one owner_: null assignee_: aaa delegation_: null priority_: 50 create_time_: 2018-02-09 21:38:20 due_date_: null suspension_state_: 1 1 row in set (0.00 sec) ========================================================================= mysql> INSERT INTO `act_hi_taskinst` SET id_ = '104', proc_def_id_ = 'myprocess:1:4', proc_inst_id_ = '101', execution_id_ = '101', name_ = '部门主管审批', parent_task_id_ = NULL, description_ = NULL, owner_ = NULL, assignee_ = 'aaa', start_time_ = '2018-02-09 21:38:20', claim_time_ = NULL, end_time_ = NULL, duration_ = NULL, delete_reason_ = NULL, task_def_key_ = 'one', form_key_ = NULL, priority_ = 50, due_date_ = NULL; mysql> select * from `act_hi_taskinst`\G; *************************** 1. row *************************** id_: 104 proc_def_id_: myprocess:1:4 task_def_key_: one proc_inst_id_: 101 execution_id_: 101 name_: 部门主管审批 parent_task_id_: null description_: null owner_: null assignee_: aaa start_time_: 2018-02-09 21:38:20 claim_time_: null end_time_: null duration_: null delete_reason_: null priority_: 50 due_date_: null form_key_: null 1 row in set (0.00 sec) ========================================================================= mysql> INSERT INTO `act_ru_identitylink` SET id_ = '105', rev_ = 1, type_ = 'participant', user_id_ = 'aaa', group_id_ = NULL, task_id_ = NULL, proc_inst_id_ = '101', proc_def_id_ = NULL; mysql> select * from `act_ru_identitylink`\G; *************************** 1. row *************************** id_: 105 rev_: 1 group_id_: null type_: participant user_id_: aaa task_id_: null proc_inst_id_: 101 proc_def_id_: null 1 row in set (0.00 sec) =========================================================================
第三步:部门主管审批 用户是(aaa) 这里我们是写死的 项目当中我们可以使用部门角色来动态查询到不同部门的主管人员审批
部门主管(aaa)办理自己的任务 任务ID:104 ========================================================================= 查询任务表下面的所有待办任务 mysql> SELECT DISTINCT RES.* FROM act_ru_task RES ORDER BY RES.id_ ASC LIMIT 2147483647 offset 0\G; *************************** 1. row *************************** id_: 104 rev_: 1 execution_id_: 101 proc_inst_id_: 101 proc_def_id_: myprocess:1:4 name_: 部门主管审批 parent_task_id_: null description_: null task_def_key_: one owner_: null assignee_: aaa delegation_: null priority_: 50 create_time_: 2018-02-09 21:38:20 due_date_: null suspension_state_: 1 1 row in set (0.00 sec) ========================================================================= mysql> UPDATE act_ge_property SET rev_ = 4, value_ = '301' WHERE name_ = 'next.dbid' AND rev_ = 3; ========================================================================= mysql> INSERT INTO `act_hi_actinst` SET id_ = '201', proc_def_id_ = 'myprocess:1:4', proc_inst_id_ = '101', execution_id_ = '101', act_id_ = 'two', task_id_ = '202', call_proc_inst_id_ = NULL, act_name_ = '部门经理审批', act_type_ = 'usertask', assignee_ = 'bbb', start_time_ = '2018-02-09 22:03:25', end_time_ = NULL, duration_ = NULL; mysql> select * from `act_hi_actinst` where id_=201\G; *************************** 1. row *************************** id_: 201 proc_def_id_: myprocess:1:4 proc_inst_id_: 101 execution_id_: 101 act_id_: two task_id_: 202 call_proc_inst_id_: null act_name_: 部门经理审批 act_type_: usertask assignee_: bbb start_time_: 2018-02-09 22:03:25 end_time_: null duration_: null 1 row in set (0.00 sec) ========================================================================= 任务表插入一条数据 mysql> INSERT INTO `act_ru_task` SET id_ = '202', rev_ = 1, name_ = '部门经理审批', parent_task_id_ = NULL, description_ = NULL, priority_ = 50, create_time_ = '2018-02-09 22:03:25', owner_ = NULL, assignee_ = 'bbb', delegation_ = NULL, execution_id_ = '101', proc_inst_id_ = '101', proc_def_id_ = 'myprocess:1:4', task_def_key_ = 'two', due_date_ = NULL, suspension_state_ = 1; mysql> select * from `act_ru_task` where id_=202\G; *************************** 1. row *************************** id_: 202 rev_: 1 execution_id_: 101 proc_inst_id_: 101 proc_def_id_: myprocess:1:4 name_: 部门经理审批 parent_task_id_: null description_: null task_def_key_: two owner_: null assignee_: bbb delegation_: null priority_: 50 create_time_: 2018-02-09 22:03:25 due_date_: null suspension_state_: 1 1 row in set (0.00 sec) ========================================================================= mysql> INSERT INTO `act_hi_taskinst` SET id_ = '202', proc_def_id_ = 'myprocess:1:4', proc_inst_id_ = '101', execution_id_ = '101', name_ = '部门经理审批', parent_task_id_ = NULL, description_ = NULL, owner_ = NULL, assignee_ = 'bbb', start_time_ = '2018-02-09 22:03:25', claim_time_ = NULL, end_time_ = NULL, duration_ = NULL, delete_reason_ = NULL, task_def_key_ = 'two', form_key_ = NULL, priority_ = 50, due_date_ = NULL; mysql> select * from `act_hi_taskinst` where id_=202\G; *************************** 1. row *************************** id_: 202 proc_def_id_: myprocess:1:4 task_def_key_: two proc_inst_id_: 101 execution_id_: 101 name_: 部门经理审批 parent_task_id_: null description_: null owner_: null assignee_: bbb start_time_: 2018-02-09 22:03:25 claim_time_: null end_time_: null duration_: null delete_reason_: null priority_: 50 due_date_: null form_key_: null 1 row in set (0.00 sec) ========================================================================= mysql> INSERT INTO `act_ru_identitylink` SET id_ = '203', rev_ = 1, type_ = 'participant', user_id_ = 'bbb', group_id_ = NULL, task_id_ = NULL, proc_inst_id_ = '101', proc_def_id_ = NULL; mysql> select * from `act_ru_identitylink` where id_=203\G; *************************** 1. row *************************** ID_: 203 REV_: 1 GROUP_ID_: NULL TYPE_: participant USER_ID_: bbb TASK_ID_: NULL PROC_INST_ID_: 101 PROC_DEF_ID_: NULL 1 row in set (0.00 sec) ========================================================================= 更新当前节点办理结束时间 mysql> UPDATE act_hi_actinst SET execution_id_ = '101', assignee_ = 'aaa', end_time_ = '2018-02-09 22:03:25', duration_ = 1505337 WHERE id_ = '103'; mysql> select * from act_hi_actinst where id_=103\G; *************************** 1. row *************************** id_: 103 proc_def_id_: myprocess:1:4 proc_inst_id_: 101 execution_id_: 101 act_id_: one task_id_: 104 call_proc_inst_id_: null act_name_: 部门主管审批 act_type_: usertask assignee_: aaa start_time_: 2018-02-09 21:38:20 end_time_: 2018-02-09 22:03:25 duration_: 1505337 1 row in set (0.00 sec) ========================================================================= mysql> UPDATE act_ru_execution SET rev_ = 2, proc_def_id_ = 'myProcess:1:4', act_id_ = 'two', is_active_ = 1, is_concurrent_ = 0, is_scope_ = 1, is_event_scope_ = 0, parent_id_ = NULL, super_exec_ = NULL, suspension_state_ = 1, cached_ent_state_ = 2 WHERE id_ = '101' AND rev_ = 1; mysql> select * from act_ru_execution where id_=101\G; *************************** 1. row *************************** id_: 101 rev_: 2 proc_inst_id_: 101 business_key_: null parent_id_: null proc_def_id_: myprocess:1:4 super_exec_: null act_id_: two is_active_: 1 is_concurrent_: 0 is_scope_: 1 is_event_scope_: 0 suspension_state_: 1 cached_ent_state_: 2 1 row in set (0.00 sec) ========================================================================= mysql> UPDATE act_hi_taskinst SET execution_id_ = '101', name_ = '部门主管审批', parent_task_id_ = NULL, description_ = NULL, owner_ = NULL, assignee_ = 'aaa', claim_time_ = NULL, end_time_ = '2018-02-09 22:03:25', duration_ = 1505300, delete_reason_ = 'completed', task_def_key_ = 'one', form_key_ = NULL, priority_ = 50, due_date_ = NULL WHERE id_ = '104'; mysql> select * from act_hi_taskinst where id_=104\G; *************************** 1. row *************************** id_: 104 proc_def_id_: myprocess:1:4 task_def_key_: one proc_inst_id_: 101 execution_id_: 101 name_: 部门主管审批 parent_task_id_: null description_: null owner_: null assignee_: aaa start_time_: 2018-02-09 21:38:20 claim_time_: null end_time_: 2018-02-09 22:03:25 duration_: 1505300 delete_reason_: completed priority_: 50 due_date_: null form_key_: null 1 row in set (0.00 sec) ========================================================================= 删除当前待办任务数据,表示办理完成 mysql> DELETE FROM act_ru_task WHERE id_ = '104' AND rev_ = 1; =========================================================================
第四步:部门经理审批 用户(bbb) 也是最后一个节点审批
部门经理(bbb)办理自己的任务 也是最后一个审批节点 任务ID:202 ========================================================================= 查询任务表下面的所有待办任务 mysql> SELECT DISTINCT RES.* FROM act_ru_task RES ORDER BY RES.id_ ASC LIMIT 2147483647 offset 0\G; *************************** 1. row *************************** id_: 202 rev_: 1 execution_id_: 101 proc_inst_id_: 101 proc_def_id_: myprocess:1:4 name_: 部门经理审批 parent_task_id_: null description_: null task_def_key_: one owner_: null assignee_: bbb delegation_: null priority_: 50 create_time_: 2018-02-09 21:58:15 due_date_: null suspension_state_: 1 1 row in set (0.00 sec) ========================================================================= mysql> UPDATE act_ge_property SET rev_ = 5, value_ = '401' WHERE name_ = 'next.dbid' AND rev_ = 4; mysql> select * from act_ge_property; +----------------+--------------+------+ | NAME_ | VALUE_ | REV_ | +----------------+--------------+------+ | next.dbid | 401 | 5 | | schema.history | create(5.12) | 1 | | schema.version | 5.12 | 1 | +----------------+--------------+------+ ========================================================================= mysql> INSERT INTO `act_hi_actinst` SET id_ = '301', proc_def_id_ = 'myprocess:1:4', proc_inst_id_ = '101', execution_id_ = '101', act_id_ = 'endevent1', task_id_ = NULL, call_proc_inst_id_ = NULL, act_name_ = 'end', act_type_ = 'endevent', assignee_ = NULL, start_time_ = '2018-02-09 22:25:39', end_time_ = '2018-02-09 22:25:39', duration_ = 0; mysql> select * from `act_hi_actinst` where id_=301\G; *************************** 1. row *************************** id_: 301 proc_def_id_: myprocess:1:4 proc_inst_id_: 101 execution_id_: 101 act_id_: endevent1 task_id_: null call_proc_inst_id_: null act_name_: end act_type_: endevent assignee_: null start_time_: 2018-02-09 22:25:39 end_time_: 2018-02-09 22:25:39 duration_: 0 1 row in set (0.00 sec) ========================================================================= mysql> UPDATE act_hi_taskinst SET execution_id_ = '101', name_ = '部门经理审批', parent_task_id_ = NULL, description_ = NULL, owner_ = NULL, assignee_ = 'bbb', claim_time_ = NULL, end_time_ = '2018-02-09 22:25:39', duration_ = 1334701, delete_reason_ = 'completed', task_def_key_ = 'two', form_key_ = NULL, priority_ = 50, due_date_ = NULL WHERE id_ = '202'; mysql> select * from act_hi_taskinst where id_=202\G; *************************** 1. row *************************** id_: 202 proc_def_id_: myprocess:1:4 task_def_key_: two proc_inst_id_: 101 execution_id_: 101 name_: 部门经理审批 parent_task_id_: null description_: null owner_: null assignee_: bbb start_time_: 2018-02-09 22:03:25 claim_time_: null end_time_: 2018-02-09 22:25:39 duration_: 1334701 delete_reason_: completed priority_: 50 due_date_: null form_key_: null 1 row in set (0.00 sec) ========================================================================= mysql> UPDATE act_hi_procinst SET proc_def_id_ = 'myProcess:1:4', start_time_ = '2018-02-09 21:38:20', end_time_ = '2018-02-09 22:25:39', duration_ = 2839765, end_act_id_ = 'endevent1', delete_reason_ = NULL WHERE id_ = '101'; mysql> select * from `act_hi_procinst` where id_=101\g; *************************** 1. row *************************** id_: 101 proc_inst_id_: 101 business_key_: null proc_def_id_: myprocess:1:4 start_time_: 2018-02-09 21:38:20 end_time_: 2018-02-09 22:25:39 duration_: 2839765 start_user_id_: null start_act_id_: startevent1 end_act_id_: endevent1 super_process_instance_id_: null delete_reason_: null 1 row in set (0.00 sec) ========================================================================= mysql> UPDATE act_hi_actinst SET execution_id_ = '101', assignee_ = 'bbb', end_time_ = '2018-02-09 22:25:39', duration_ = 1334740 WHERE id_ = '201'; mysql> select * from act_hi_actinst where id_=201\g; *************************** 1. row *************************** id_: 201 proc_def_id_: myprocess:1:4 proc_inst_id_: 101 execution_id_: 101 act_id_: two task_id_: 202 call_proc_inst_id_: null act_name_: 部门经理审批 act_type_: usertask assignee_: bbb start_time_: 2018-02-09 22:03:25 end_time_: 2018-02-09 22:25:39 duration_: 1334740 1 row in set (0.00 sec) ========================================================================= mysql> delete from act_ru_task where id_ = '202' and rev_ = 1; mysql> delete from act_ru_identitylink where id_ = '105'; mysql> delete from act_ru_identitylink where id_ = '203'; mysql> delete from act_ru_execution where id_ = '101' and rev_ = 2; =========================================================================
标签:tin proc 历史记录 办理 strong tool nbsp dep col
原文地址:http://blog.51cto.com/771541213/2070800