Method and system for rolling back tasks based on historical task IDs based on flowable
Through the Flowable method, the task is rolled back in the current process instance using historical task ID, which solves the problem of cumbersome and low efficiency of task rollback operations in the existing technology, improves process continuity and efficiency, and enhances the workflow system adaptability.
Patent Information
- Application Number
- CN202411154686.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-22
- Publication Date
- 2024-12-06
- Estimated Expiration
- 2044-08-22
AI Technical Summary
In the prior art, if a task fallback is required after the workflow instance is started, the current process needs to be stopped and a new process instance needs to be restarted. The operation is cumbersome and affects the process continuity and efficiency.
Through a Flowable-based method, the historical task ID is used to fall back directly to the specified task node in the current process instance, including querying the current task instance, modifying the current task, updating the process record node, and deleting the target task information, realizing task backing.
Simplifies task back-up operations, maintains process continuity, improves processing efficiency, and enhances the flexibility and adaptability of the workflow system.
Smart Images

Figure CN118656152B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer software technology, and in particular to a method and system for rolling back tasks according to historical task IDs based on flowable. Background Art
[0002] In enterprise applications, workflow management systems are often used to automate business process management and ensure that business processes are executed according to predetermined rules. Flowable is a lightweight workflow engine that supports process customization, deployment, and execution. In the prior art, once a workflow instance is started and executed, if a task rollback is required, it is often necessary to stop the current process, restart a new process instance, and set the corresponding variable status based on historical data. This method is not only cumbersome to operate, but also affects the continuity and efficiency of the process. Summary of the invention
[0003] The technical task of the present invention is to address the above deficiencies and provide a method and system for rolling back tasks based on historical task IDs based on flowable, which not only maintains the continuity of the process but also improves processing efficiency.
[0004] The technical solution adopted by the present invention to solve its technical problem is:
[0005] The method for rolling back tasks based on historical task IDs based on flowable includes the following steps:
[0006] 1) Query the current task instance;
[0007] 2) Query historical task instances based on historical task IDs;
[0008] 3) Modify the current task and replace the historical task with the current task;
[0009] 4) Modify the process record node and change the ACT_ID_ of ru_execution to the definition ID of the target historical task;
[0010] 5) Modify the completion time of the target historical task; ensure that the historical task can correctly reflect the actual completion time after rolling back;
[0011] 6) Delete the target task information in ru_actinst;
[0012] 7) Task rollback is completed.
[0013] This method is a process control technology in a workflow management system, that is, a method for implementing task rollback in a flowable workflow engine. This task rollback method is concise and efficient. It uses the historical task ID to directly roll back to the specified task node in the current process instance without restarting the process instance. This maintains the continuity of the process and improves processing efficiency.
[0014] Furthermore, steps 1) to 7) are implemented through the API interface provided by Flowable.
[0015] Furthermore, the query of the current task instance is completed by calling the API provided by the Flowable engine, using the createTaskQuery method of TaskService, combined with the process instance ID (ProcessInstanceId) and the activity ID (ActivityId) to find the current task.
[0016] Furthermore, the historical task ID is used to query the related historical task instances, and the createHistoricTaskInstanceQuery method of HistoryService is combined with the historical task ID to find a specific historical task instance.
[0017] Furthermore, the ru_execution and ACT_ID_ are database tables and fields for recording process instance execution information in the Flowable workflow engine;
[0018] The ACT_ID_ of ru_execution is changed to the definition ID of the target historical task, the act_ru_execution table in the Flowable background table is updated, and the ACT_ID_ field value of the current task is changed to the definition ID of the target historical task (ie PROC_DEF_ID_).
[0019] Furthermore, the target task information in ru_actinst is deleted, and the data related to the original current task in the act_ru_variable, act_ru_task and other tables are cleared to ensure that these data will not affect the subsequent processes.
[0020] Furthermore, the specific implementation process of this method is as follows:
[0021] First check whether the current task information exists;
[0022] If it does not exist, the process ends directly;
[0023] If it exists, query the current task information;
[0024] After the task information is queried, query the historical task information of the target task;
[0025] Modify the current task to the target historical task and delete the original current task information;
[0026] Then modify the process record node from the original task to the definition information of the target historical task;
[0027] Then delete the ru_actinst information of the original current task to avoid affecting the subsequent task processing;
[0028] Finally, the historical task rollback was completed.
[0029] The present invention also claims a flowable-based system for rolling back tasks according to historical task IDs, comprising:
[0030] The current task information query module is used to query the current task instance;
[0031] The historical task information query module is used to query historical task instances based on historical task IDs;
[0032] The current task modification module is used to modify the current task and replace the historical task with the current task;
[0033] Modify the process record node module, which is used to modify the process record node and change the ACT_ID_ of ru_execution to the definition ID of the target historical task;
[0034] Completion time modification module, used to modify the completion time of the target historical tasks;
[0035] The original information deletion module is used to delete the target task information in ru_actinst;
[0036] The system specifically implements task rollback through the above-mentioned flowable-based method of rolling back tasks according to historical task IDs.
[0037] The present invention also claims a flowable-based device for rolling back tasks according to historical task IDs, comprising at least one memory and a processor;
[0038] The at least one memory is used to store a machine-readable program;
[0039] The at least one processor is used to call the machine-readable program to implement the above method.
[0040] The present invention also claims protection for a computer-readable medium having computer instructions stored thereon, which implement the above method when executed by a processor.
[0041] Compared with the prior art, the method and system for rolling back tasks based on historical task IDs based on flowable of the present invention have the following beneficial effects:
[0042] 1. Simplified the task rollback operation, avoiding the trouble of re-initiating the entire process instance;
[0043] 2. Maintaining the continuity of process instances is beneficial to process management and monitoring;
[0044] 3. Improved the adaptability of the workflow system to complex business scenarios;
[0045] 4. Enhanced the flexibility and practicality of the workflow system. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 It is a flowchart of a method for rolling back tasks according to historical task IDs based on flowable provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0047] The embodiment of the present invention provides a method for rolling back a task based on a historical task ID based on flowable, comprising the following steps:
[0048] 1. Query the current task instance;
[0049] 2. Query historical task instances based on historical task IDs;
[0050] 3. Modify the current task and replace the historical task with the current task;
[0051] 4. Modify the process record node and change the ACT_ID_ of ru_execution to the definition ID of the target historical task;
[0052] 5. Modify the completion time of the target historical tasks;
[0053] 6. Delete the target task information in ru_actinst;
[0054] 7. Task rollback completed.
[0055] Among them, steps 1 to 7 are implemented through the API interface provided by Flowable.
[0056] In step 4, the ru_execution and ACT_ID_ are the database table and field for recording the process instance execution information in the Flowable workflow engine.
[0057] In step 5, the completion time of the target historical task is modified to ensure that the historical task can correctly reflect the actual completion time after being rolled back.
[0058] The specific implementation of each step is as follows:
[0059] 1. Query the current task instance:
[0060] First, get the currently executing task instance. This can be done by calling the API provided by the Flowable engine, such as using the createTaskQuery method of TaskService, combining the process instance ID (ProcessInstanceId) and the activity ID (ActivityId) to find the current task.
[0061] 2. Query historical task instances based on historical task IDs:
[0062] Use the historical task ID to query related historical task instances. You can use the createHistoricTaskInstanceQuery method of HistoryService in combination with the historical task ID to find a specific historical task instance.
[0063] 3. Modify the current task and replace the historical task with the current task:
[0064] After finding the corresponding historical task, the relevant data of the current task instance needs to be updated with the data of the historical task. This may involve updating the variables, attachments and other information of the task.
[0065] 4. Modify the process record node and change the ACT_ID_ of ru_execution to the definition ID of the target historical task:
[0066] This step is the core rollback operation, which requires updating the act_ru_execution table in the Flowable background table and changing the ACT_ID_ field value of the current task to the definition ID of the target historical task (ie, PROC_DEF_ID_).
[0067] 5. Modify the completion time of the target historical task:
[0068] Update the completion timestamp of the historical task to reflect the actual time when the rollback operation occurred. This is achieved through methods provided by HistoryService, such as the setVariableLocal method.
[0069] 6. Delete the target task information in ru_actinst:
[0070] Clear the data related to the original current task in the act_ru_variable, act_ru_task and other tables to ensure that these data will not affect subsequent processes.
[0071] 7. Task rollback completed:
[0072] After the above steps, the task has been successfully rolled back to the specified historical task node. At this point, the workflow can continue to execute subsequent tasks from this node.
[0073] Figure 1 The flowchart shown describes the implementation process of this method, and the specific implementation process is as follows:
[0074] First check whether the current task information exists;
[0075] If it does not exist, the process ends directly;
[0076] If it exists, query the current task information;
[0077] After the task information is queried, query the historical task information of the target task;
[0078] Modify the current task to the target historical task and delete the original current task information;
[0079] Then modify the process record node from the original task to the definition information of the target historical task;
[0080] Then delete the ru_actinst information of the original current task to avoid affecting the subsequent task processing;
[0081] Finally, the historical task rollback was completed.
[0082] When implementing the above method, you should ensure that there are appropriate permissions and security considerations, because the operation involves direct modification of the Flowable background table. In actual operation, you may need to deal with concurrency issues to ensure that no other process instances are using or modifying the same historical task node while performing the rollback operation.
[0083] According to different business needs, the above steps may need to be expanded or adjusted, such as adding logging, error handling, transaction management, etc. Since direct database operations may cause data consistency issues, sufficient testing should be carried out when implementing this method, and ensure that all related process definitions (BPMN files) and task nodes can correctly handle rollback operations. The API names and parameters mentioned in this implementation may change with the update of the Flowable version, and should be adjusted according to the actual Flowable version used during implementation.
[0084] This method uses the historical task ID to directly roll back to the specified task node in the current process instance without restarting the process instance. This maintains the continuity of the process and improves processing efficiency.
[0085] The embodiment of the present invention further provides a system for rolling back tasks based on historical task IDs based on flowable, including:
[0086] The current task information query module is used to query the current task instance;
[0087] The historical task information query module is used to query historical task instances based on historical task IDs;
[0088] The current task modification module is used to modify the current task and replace the historical task with the current task;
[0089] Modify the process record node module, which is used to modify the process record node and change the ACT_ID_ of ru_execution to the definition ID of the target historical task;
[0090] Completion time modification module, used to modify the completion time of the target historical tasks;
[0091] The original information deletion module is used to delete the target task information in ru_actinst;
[0092] The system specifically implements task rollback through the method of rolling back tasks based on historical task IDs based on flowable described in the above embodiment, and the process is as follows:
[0093] 1. The current task information query module queries the current task instance:
[0094] First, get the currently executing task instance. This can be done by calling the API provided by the Flowable engine, such as using the createTaskQuery method of TaskService, combining the process instance ID (ProcessInstanceId) and the activity ID (ActivityId) to find the current task.
[0095] 2. The historical task information query module queries historical task instances based on historical task IDs:
[0096] Use the historical task ID to query related historical task instances. You can use the createHistoricTaskInstanceQuery method of HistoryService in combination with the historical task ID to find a specific historical task instance.
[0097] 3. The current task modification module modifies the current task and replaces the historical task with the current task:
[0098] After finding the corresponding historical task, the relevant data of the current task instance needs to be updated with the data of the historical task. This may involve updating the variables, attachments and other information of the task.
[0099] 4. Modify the process record node module and change the ACT_ID_ of ru_execution to the definition ID of the target historical task:
[0100] This step is the core rollback operation, which requires updating the act_ru_execution table in the Flowable background table and changing the ACT_ID_ field value of the current task to the definition ID of the target historical task (ie, PROC_DEF_ID_).
[0101] 5. The completion time modification module modifies the completion time of the target historical task:
[0102] Update the completion timestamp of the historical task to reflect the actual time when the rollback operation occurred. This is achieved through methods provided by HistoryService, such as the setVariableLocal method.
[0103] 6. The original information deletion module deletes the target task information in ru_actinst:
[0104] Clear the data related to the original current task in the act_ru_variable, act_ru_task and other tables to ensure that these data will not affect subsequent processes.
[0105] 7. Task rollback completed:
[0106] After the above steps, the task has been successfully rolled back to the specified historical task node. At this point, the workflow can continue to execute subsequent tasks from this node.
[0107] The specific implementation logic of this process is as follows:
[0108] First check whether the current task information exists;
[0109] If it does not exist, the process ends directly;
[0110] If it exists, query the current task information;
[0111] After the task information is queried, query the historical task information of the target task;
[0112] Modify the current task to the target historical task and delete the original current task information;
[0113] Then modify the process record node from the original task to the definition information of the target historical task;
[0114] Then delete the ru_actinst information of the original current task to avoid affecting the subsequent task processing;
[0115] Finally, the historical task rollback was completed.
[0116] The embodiment of the present invention also provides a flowable-based device for rolling back tasks according to historical task IDs, comprising at least one memory and a processor;
[0117] The at least one memory is used to store a machine-readable program;
[0118] The at least one processor is used to call the machine-readable program to implement the flowable-based method for rolling back tasks according to historical task IDs described in the above embodiment.
[0119] The embodiment of the present invention also provides a computer-readable medium, on which computer instructions are stored, and when the computer instructions are executed by a processor, the processor executes the method of rolling back tasks based on historical task IDs based on flowable as described in the above embodiment. Specifically, a system or device equipped with a storage medium can be provided, on which software program codes for implementing the functions of any of the above embodiments are stored, and a computer (or CPU or MPU) of the system or device is enabled to read and execute the program code stored in the storage medium.
[0120] In this case, the program code itself read from the storage medium can realize the function of any one of the above-mentioned embodiments, and thus the program code and the storage medium storing the program code constitute a part of the present invention.
[0121] The storage medium embodiments for providing the program code include a floppy disk, a hard disk, a magneto-optical disk, an optical disk (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), a magnetic tape, a non-volatile memory card, and a ROM. Alternatively, the program code can be downloaded from a server computer via a communication network.
[0122] In addition, it should be clear that the functions of any of the above embodiments can be implemented not only by executing the program code read by the computer, but also by enabling an operating system operating on the computer to complete part or all of the actual operations based on instructions from the program code.
[0123] In addition, it can be understood that the program code read from the storage medium is written to a memory provided in an expansion board inserted into the computer or written to a memory provided in an expansion unit connected to the computer, and then based on the instructions of the program code, a CPU installed on the expansion board or the expansion unit is enabled to perform part or all of the actual operations, thereby realizing the functions of any of the above-mentioned embodiments.
[0124] The present invention is shown and described in detail above through the accompanying drawings and preferred embodiments. However, the present invention is not limited to these disclosed embodiments. Based on the above multiple embodiments, those skilled in the art can know that the code review methods in the above different embodiments can be combined to obtain more embodiments of the present invention, and these embodiments are also within the protection scope of the present invention.
Claims
1. A method for rolling back tasks based on historical task IDs based on flowable, characterized in that: The following steps are involved: 1) Query the current task instance; 2) Query historical task instances based on historical task IDs; 3) Modify the current task and replace the historical task with the current task; 4) Modify the process record node and change the ACT_ID_ of ru_execution to the definition ID of the target historical task; 5) Modify the completion time of the target historical tasks; 6) Delete the target task information in ru_actinst; 7) Task rollback completed; The query of the current task instance is completed by calling the API provided by the Flowable engine, using the createTaskQuery method of TaskService, combining the process instance ID and the activity ID to find the current task; Use the historical task ID to query related historical task instances. Use the createHistoricTaskInstanceQuery method of HistoryService combined with the historical task ID to find a specific historical task instance. The ru_execution and ACT_ID_ are database tables and fields that record process instance execution information in the Flowable workflow engine; the ACT_ID_ of ru_execution is changed to the definition ID of the target historical task, the act_ru_execution table in the Flowable background table is updated, and the ACT_ID_ field value of the current task is changed to the definition ID of the target historical task; The target task information in ru_actinst is deleted, and the data related to the original current task in the act_ru_variable and act_ru_task tables are cleared to ensure that these data will not affect the subsequent processes.
2. The method for rolling back tasks based on historical task IDs based on flowable according to claim 1 is characterized in that: The steps 1) to 7) are implemented through the API interface provided by Flowable.
3. The method for rolling back tasks based on historical task IDs based on flowable according to claim 1 is characterized in that: The specific implementation process of this method is as follows: First check whether the current task information exists; If it does not exist, the process ends directly; If it exists, query the current task information; After the task information is queried, query the historical task information of the target task; Modify the current task to the target historical task and delete the original current task information; Then modify the process record node from the original task to the definition information of the target historical task; Then delete the ru_actinst information of the original current task to avoid affecting the subsequent task processing; Finally, the historical task rollback was completed.
4. A flowable-based system for rolling back tasks based on historical task IDs, characterized in that: include: The current task information query module is used to query the current task instance; The historical task information query module is used to query historical task instances based on historical task IDs; The current task modification module is used to modify the current task and replace the historical task with the current task; Modify the process record node module, which is used to modify the process record node and change the ACT_ID_ of ru_execution to the definition ID of the target historical task; Completion time modification module, used to modify the completion time of the target historical tasks; The original information deletion module is used to delete the target task information in ru_actinst; The system specifically implements task rollback through the flowable-based method for rolling back tasks according to historical task IDs as described in any one of claims 1 to 3.
5. A device for rolling back tasks based on historical task IDs based on flowable, characterized in that: comprising at least one memory and a processor; The at least one memory is used to store a machine-readable program; The at least one processor is used to call the machine-readable program to implement the method described in any one of claims 1 to 3.
6. A computer-readable medium, characterized in that The computer readable medium stores computer instructions, and when the computer instructions are executed by a processor, the method according to any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
Model-driven control system with workflow engine dynamically switched
CN105607907A
Streaming computing task management method and device, electronic equipment and storage medium
CN109697118A
