Workflow state reverse recovery method, device, computer equipment and storage medium
By querying and storing table data before and after workflow status changes, determining new, updated, and deleted data, and gradually rolling back to the target state based on the execution timestamp, the performance, reliability, and maintainability issues of workflow management systems in the existing technology are solved, and efficient and stable status recovery is achieved.
Patent Information
- Application Number
- CN202310120676.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-14
- Publication Date
- 2025-09-09
- Estimated Expiration
- 2043-02-14
AI Technical Summary
The existing workflow management system has problems with poor performance, poor reliability and poor maintainability during the state recovery process. This is mainly because each recovery to the previous state requires a large amount of data calculation, and changes in the operation action logic will affect the recovery logic, resulting in data confusion.
Using a method similar to stacking and popping, the table data before and after the workflow status change is queried and stored respectively. New, updated and deleted data are determined by data comparison, and the data is bound to the execution timestamp of the operation action logic as the process operation record information, so as to achieve gradual rollback and recovery to the target state.
It improves the maintainability, reliability and performance of the workflow management system, reduces the amount of calculation, and ensures the success and stability of the recovery process.
Smart Images

Figure CN116307661B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of workflow management, and in particular relates to a workflow state reverse recovery method, device, computer equipment and storage medium. Background Art
[0002] Workflow management refers to the systematic implementation of the approval and management of the company's daily office workflow, including administrative, financial, personnel and procurement approval processes. The information management of workflows can improve the company's work efficiency.
[0003] The existing method of gradually restoring the workflow state (also referred to as workflow state) to the previous historical state is to perform logical calculations based on the workflow state data during recovery to determine whether recovery is possible. If recovery is possible, the action of the last operation is first calculated, and then the affected data is inferred based on the change logic of the operation action. Finally, the state is restored based on this part of the affected data. However, since each recovery (i.e., the process of restoring to the previous historical state) requires a large amount of calculation and depends on the existing data and the logic of the previous operation, if the logic of the operation changes in a certain version, corresponding judgment and compatibility must be performed in the recovery logic, otherwise the recovery will fail, causing data confusion, which will cause great instability and trouble to users. Therefore, the workflow management system has the following problems: (1) Poor performance, that is, since each recovery to the previous state requires a large amount of data calculation, and as the version update becomes more and more complex, the recovery time will be longer; (2) Poor reliability, that is, since the change of the operation logic will affect the calculation logic of the recovery, and the newly added actions also need to be compatible, so every time a change occurs in other places, the logic there must be adjusted synchronously, otherwise it will cause data confusion; (3) Poor maintainability, that is, since a large amount of calculation is involved, if the data and logic of a certain action have a slight deviation, it will also cause the recovery to fail and cause data confusion. Summary of the Invention
[0004] The purpose of the present invention is to provide a workflow state reverse recovery method, device, computer equipment and computer-readable storage medium to solve the problems of poor maintainability, reliability and performance in the state recovery process of existing workflow management systems.
[0005] In order to achieve the above object, the present invention adopts the following technical solutions:
[0006] In a first aspect, a method for reversing a workflow state is provided, comprising:
[0007] When receiving a workflow status change request, query and store all pre-change tables involving process status data;
[0008] Executing the operation action logic in response to the workflow state change request to change the workflow state;
[0009] After the workflow state changes, query and store all post-change tables related to the process state data, wherein all the post-change tables correspond one-to-one to all the pre-change tables;
[0010] For each of the changed tables, determining corresponding newly added data, updated data, and / or deleted data based on a comparison result with the data in the corresponding pre-changed table.
[0011] Merging the newly added data, updated data, and / or deleted data of each of the modified tables into a data packet, and binding the data packet and the execution timestamp of the operation action logic as a process operation record information and storing it in the process operation record table;
[0012] When a workflow state recovery request is received, all current tables related to process state data are queried and retrieved, and at least one process operation record information in the process operation record table is arranged in reverse order based on the execution timestamp to obtain a process operation record information sequence;
[0013] Based on all the current tables and the process operation record information sequence, the workflow is gradually rolled back and restored to the workflow target state requested to be restored in the workflow state recovery request.
[0014] Based on the above invention, a new workflow state recovery scheme similar to the push and pop method is provided. Specifically, before and after each workflow state change, all pre-change tables and post-change tables involving process state data are queried and stored. Then, for each post-change table among all the post-change tables, corresponding new data, updated data, and / or deleted data are determined based on a comparison result with the corresponding pre-change table. The new data, updated data, and / or deleted data in each post-change table are then packaged and bound together with the execution timestamp of the action logic as a process operation record, which is stored in the process operation record table, implementing a process similar to the push. Finally, upon receiving a workflow state recovery request, all current tables involving process state data are queried and, combined with a sequence of process operation record information obtained by reverse sorting based on the execution timestamps, the workflow is gradually rolled back to the target workflow state requested in the workflow state recovery request, implementing a process similar to the pop. This avoids the need for extensive computation and action logic during the recovery process, significantly improving the maintainability, reliability, and performance of the workflow management system and facilitating practical application and promotion.
[0015] In one possible design, all pre-change tables involving process state data are queried and stored, including:
[0016] Query and obtain all pre-change tables involving process status data in sequence;
[0017] Based on a MAP data structure including a key name KEY and a key value VALUE, table data of each pre-change table in all pre-change tables is obtained in the following manner: first, using the key name KEY as the column name and the key value VALUE as the column value, the column data of each row in the each pre-change table is simulated to obtain row data of each row in the MAP data structure; then, using the key name KEY as the row data primary key identifier ID and the key value VALUE as the row data, the row data of each row in the each pre-change table is simulated to obtain the table data of the each pre-change table;
[0018] The table data of each pre-change table are sequentially put into a linked list LIST data structure according to the query sequence, so as to obtain a first linked list LIST for storing all the pre-change tables.
[0019] In one possible design, all changed tables involving process state data are queried and stored, including:
[0020] Querying and obtaining all post-change tables related to process status data in the query order, wherein all post-change tables correspond one-to-one to all pre-change tables;
[0021] Based on a linked list LIST data structure and a MAP data structure including a key name KEY and a key value VALUE, table data of each changed table in all the changed tables is obtained in the following manner: first, using the key name KEY as the column name and the key value VALUE as the column value, column data of each row in each changed table is simulated to obtain row data of each row in the MAP data structure, and then the linked list LIST data structure is used to sequentially store the row data of each row in each changed table to obtain the table data of each changed table;
[0022] The table data of each changed table is sequentially put into another linked list LIST data structure according to the query sequence, so as to obtain a second linked list LIST for storing all the changed tables.
[0023] In one possible design, for each of the changed tables, determining corresponding newly added data, updated data, and / or deleted data based on a comparison result with the data in the corresponding pre-changed table includes:
[0024] Synchronously traversing the table data in the second linked list LIST and the table data in the first linked list LIST in sequence according to the query order;
[0025] For the second table data currently traversed and in the second linked list LIST and the first table data in the first linked list LIST, the corresponding newly added data, updated data and / or deleted data are determined according to any one of the following methods (A) to (C) or any combination thereof:
[0026] (A) for each second row of data in the second table data and in the MAP data structure, searching the first table data for a key name KEY corresponding to the primary key identifier ID of the row of data based on the primary key identifier ID of the corresponding row of data; if not, treating the corresponding second row of data as a newly added data item corresponding to the second table data and the first table data;
[0027] (B) for each second row of data in the second table data and in the MAP data structure, searching the first table data for a key name KEY corresponding to the row data primary key identifier ID based on the corresponding row data primary key identifier ID; if so, obtaining a first key value VALUE corresponding to the key name KEY corresponding to the row data primary key identifier ID from the first table data;
[0028] For each second row of data, determining corresponding different data in the following manner: for each column in the first key value VALUE, comparing the key value VALUE of the column with the key value VALUE in the second row of data and corresponding to the key name KEY of the column; if the comparison result of the two key values VALUE is different, then treating the key name KEY and key value VALUE of the column as a different data piece for the second row of data;
[0029] using the different data of each second row of data as a piece of update data corresponding to the second table data and the first table data;
[0030] (C) For each first row of data in the first table data and in the MAP data structure, search in the second table data based on the corresponding row data primary key identifier ID to see whether the key name KEY for the row data primary key identifier ID exists; if not, treat the corresponding first row of data as a deletion data corresponding to the second table data and the first table data.
[0031] In one possible design, the newly added data, updated data, and / or deleted data of each modified table are merged into a data packet, including:
[0032] The newly added data, updated data and / or deleted data of each of the changed tables are merged into a JSON data format to obtain a data packet.
[0033] In one possible design, based on all the current tables and the process operation record information sequence, the workflow is gradually rolled back to the workflow target state requested in the workflow state recovery request, including the following steps S70 to S76:
[0034] S70. Initialize the sort number K to 1, and then execute step S71, where K represents a positive integer and is less than or equal to the total number of the at least one process operation record information;
[0035] S71. All current tables are used as all changed tables involving process state data obtained after the most recent K-th historical workflow state update, and then step S72 is executed;
[0036] S72. Obtain the Kth process operation record in the process operation record sequence, parse the data packet in the Kth process operation record, obtain the newly added data, updated data, and / or deleted data in each changed table after the Kth most recent historical workflow state update, and then execute step S73;
[0037] S73. Based on all post-change tables related to process state data obtained after the Kth most recent historical workflow state update and the newly added data, updated data, and / or deleted data in each post-change table, all pre-change tables related to process state data before the Kth most recent historical workflow state update are restored, and then step S74 is executed.
[0038] S74. Determine whether the Kth most recent historical workflow state is the workflow target state requested to be restored in the workflow state restoration request. If so, execute step S76; otherwise, execute step S75.
[0039] S75. All pre-change tables involving process state data before the Kth most recent historical workflow state update are used as all post-change tables involving process state data obtained after the K+1th most recent historical workflow state update, and the sort number K is incremented by 1. The process then returns to step S72.
[0040] S76. Based on all pre-change tables involving process state data before the most recent K-th historical workflow state update, restore the workflow to the workflow target state.
[0041] In one possible design, after recovering all pre-change tables involving process state data before the most recent K-th historical workflow state update and before executing step S74, the method further includes:
[0042] Determine whether there is an anomaly in all pre-change tables involving process state data before the most recent K-th historical workflow state update. If so, terminate the workflow state reverse recovery. Otherwise, execute step S74.
[0043] In a second aspect, a workflow state reverse recovery device is provided, which includes a data query storage module, a state change response module, a before and after data comparison module, a data packaging and recording module, a state recovery response module and a state rollback recovery module;
[0044] The data query and storage module is used to query and store all pre-change tables involving process state data when a workflow state change request is received;
[0045] The state change response module is communicatively connected to the data query storage module and is used to execute operation action logic in response to the workflow state change request to change the workflow state;
[0046] The data query and storage module is further configured to query and store all post-change tables related to process state data after a workflow state changes, wherein all post-change tables correspond one-to-one to all pre-change tables;
[0047] The before-after data comparison module is communicatively connected to the data query storage module and is used to determine corresponding newly added data, updated data and / or deleted data for each changed table in all changed tables based on a comparison result with the data of the corresponding pre-change table;
[0048] The data packaging and recording module is communicatively connected to the before-after data comparison module, and is used to merge the newly added data, updated data and / or deleted data of each of the changed tables into a data packet, and bind the data packet and the execution timestamp of the operation action logic as a process operation record information and store it in the process operation record table;
[0049] The state recovery response module is communicatively connected to the data packaging and recording module and is configured to query and obtain all current tables related to process state data upon receiving a workflow state recovery request, and to arrange at least one process operation record information in the process operation record table in reverse order based on the execution timestamp to obtain a process operation record information sequence;
[0050] The state rollback recovery module is communicatively connected to the state recovery response module, and is used to gradually roll back the workflow to the workflow target state requested to be restored in the workflow state recovery request based on all the current tables and the process operation record information sequence.
[0051] In a third aspect, the present invention provides a computer device comprising a memory, a processor and a transceiver which are communicatively connected in sequence, wherein the memory is used to store a computer program, the transceiver is used to send and receive data, and the processor is used to read the computer program and execute the workflow state reverse recovery method as described in the first aspect or any possible design of the first aspect.
[0052] In a fourth aspect, the present invention provides a computer-readable storage medium having instructions stored thereon. When the instructions are run on a computer, the workflow state reverse recovery method as described in the first aspect or any possible design of the first aspect is executed.
[0053] In a fifth aspect, the present invention provides a computer program product comprising instructions, which, when executed on a computer, causes the computer to execute the workflow state reverse recovery method as described in the first aspect or any possible design of the first aspect.
[0054] Beneficial effects of the above scheme:
[0055] (1) The present invention creatively provides a new workflow state recovery scheme similar to the stack push and pop method, that is, before and after each workflow state change, all pre-change tables and all post-change tables involving process state data are queried and stored respectively, and then for each post-change table in all the post-change tables, the corresponding new data, updated data and / or deleted data are determined based on the data comparison result with the corresponding pre-change table, and then the new data, updated data and / or deleted data of each post-change table are packaged and bound together with the execution timestamp of the operation action logic as a process operation record information and stored in the process operation record table, realizing a process similar to stack push, and finally, when a workflow state recovery request is received, all current tables involving process state data are queried and obtained, and the process operation record information sequence obtained by reverse arrangement based on the execution timestamp is combined to gradually roll back the workflow to the workflow target state requested to be restored in the workflow state recovery request, realizing a process similar to stack pop, so that a large amount of calculations and action logic can be avoided in the recovery process, thereby greatly improving the maintainability, reliability and performance of the workflow management system, and facilitating practical application and promotion;
[0056] (2) Since this solution uses a method similar to stack push and pop, only the top operation of the stack is verified, which does not involve a large amount of calculation, so the performance is higher;
[0057] (3) Since this solution uses universal data changes, similar to push and pop processing, even if the action logic changes, it will not affect the recovery logic, so it is highly maintainable;
[0058] (4) Since each recovery of this solution is to take out the data change set of the last operation from the top of the stack and then restore and update, no calculation is involved, which can ensure that the recovery can be successful every time, so the reliability is also high. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0060] Figure 1 A flowchart of a workflow state reverse recovery method provided in an embodiment of the present application.
[0061] Figure 2 A schematic diagram of the structure of a workflow state reverse recovery device provided in an embodiment of the present application.
[0062] Figure 3 A schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0063] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the present invention will be briefly introduced below in conjunction with the drawings and the description of the embodiments or the prior art. Obviously, the following description of the structure of the drawings is only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work. It should be noted that the description of these embodiments is used to help understand the present invention, but does not constitute a limitation of the present invention.
[0064] It should be understood that although the terms first, second, etc. may be used herein to describe various objects, these objects should not be limited by these terms. These terms are merely used to distinguish one object from another. For example, a first object can be referred to as a second object, and similarly, a second object can be referred to as a first object without departing from the scope of the exemplary embodiments of the present invention.
[0065] It should be understood that the term "and / or" that may appear in this document is merely a description of the association relationship between associated objects, indicating that there may be three relationships. For example, A and / or B can indicate three situations: A exists alone, B exists alone, or A and B exist at the same time. For another example, A, B and / or C can indicate the existence of any one of A, B and C or any combination of them. The term " / and" that may appear in this document describes another type of association object relationship, indicating that there may be two relationships. For example, A / and B can indicate two situations: A exists alone or A and B exist at the same time. In addition, the character " / " that may appear in this document generally indicates that the previous and next associated objects are in an "or" relationship.
[0066] Example:
[0067] like Figure 1 As shown, the workflow state reverse recovery method provided in the first aspect of this embodiment can be executed by, but is not limited to, a computer device with certain computing resources, such as a platform server, a personal computer (PC, a multi-purpose computer with a size, price and performance suitable for personal use; desktops, laptops, small laptops, tablets and ultrabooks are all personal computers), a smart phone, a personal digital assistant (PDA) or a wearable device. Figure 1 As shown, the workflow state reverse recovery method may include, but is not limited to, the following steps S1 to S7.
[0068] S1. When a workflow status change request is received, query and store all pre-change tables involving process status data.
[0069] In step S1, the workflow state change request is routinely generated and sent locally when a user operates on the workflow and triggers a state change action. All pre-change tables are used to record the workflow state before the change. Specifically, querying and storing all pre-change tables involving process state data includes, but is not limited to, steps S11 to S13.
[0070] S11. Query and obtain all pre-change tables involving process status data in sequence.
[0071] In step S11, the specific query and acquisition method of all pre-change tables is the existing conventional method.
[0072] S12. Based on the MAP data structure including the key name KEY and the key value VALUE, the table data of each pre-change table in all the pre-change tables is obtained in the following manner: first, the column data of each row in the pre-change tables is simulated by using the key name KEY as the column name and the key value VALUE as the column value, and the row data of each row in the MAP data structure is obtained; then, the key name KEY is used as the row data primary key identifier ID and the key value VALUE is used as the row data, and each row in the pre-change tables is simulated to obtain the table data of the pre-change tables.
[0073] In step S12, the MAP data structure is an existing data structure similar to a key-value pair set, i.e., a key name KEY and a key value VALUE constitute a key-value pair, wherein the key value VALUE can store any data type. For example, the row data of a row in the MAP data structure is [column name 1: column value 1; column name 2: column value 2; column name 3: column value 3; ...]. Through the aforementioned step S12, the pre-change table data can be obtained, which is convenient for subsequent comparison of the pre-change table data. For example, it is possible to directly determine whether a record is newly added, updated, or deleted based on the row data primary key identifier ID.
[0074] S13. Put the table data of each pre-change table into a linked list LIST data structure in sequence according to the query order, and obtain a first linked list LIST for storing all the pre-change tables.
[0075] In step S13, the linked list LIST data structure is also a common basic data structure. It is a linear list, but it does not store data in a linear order. Instead, each node stores a pointer to the next node. Through the above step S13, subsequent traversal can be facilitated.
[0076] S2. Execute the operation action logic in response to the workflow state change request to change the workflow state.
[0077] In step S2, the specific response execution process is based on existing technical means, which will not be described in detail here.
[0078] S3. After the workflow state changes, query and store all post-change tables related to the process state data, wherein all the post-change tables correspond one-to-one to all the pre-change tables.
[0079] In the step S3, all the changed tables are used to record the workflow status after the change. Specifically, all the changed tables involving process status data are queried and stored, including but not limited to the following steps S31 to S33: S31. All the changed tables involving process status data are queried in sequence according to the query sequence, wherein all the changed tables correspond to all the pre-change tables one by one; S32. Based on the linked list LIST data structure and the MAP data structure containing the key name KEY and the key value VALUE, each table in all the changed tables is obtained in the following manner: Table data of the changed table: first use the key name KEY as the column name and the key value VALUE as the column value to simulate the column data of each row in each changed table, and obtain the row data of each row in the MAP data structure, and then use the linked list LIST data structure to store the row data of each row in the each changed table in sequence to obtain the table data of each changed table; S33. Put the table data of each changed table into another linked list LIST data structure in sequence according to the query order to obtain a second linked list LIST for storing all the changed tables.
[0080] S4. For each of the changed tables in all the changed tables, determine the corresponding newly added data, updated data, and / or deleted data based on the comparison result with the data of the corresponding pre-changed table.
[0081] In step S4, the newly added data may specifically refer to the newly added content in the post-change table relative to the pre-change table, the updated data may specifically refer to the updated content in the pre-change table relative to the post-change table, and the deleted data may specifically refer to the deleted content in the pre-change table relative to the post-change table. Specifically, for each post-change table among all the post-change tables, the corresponding newly added data, updated data, and / or deleted data are determined based on the comparison results with the corresponding pre-change table, including but not limited to the following steps S41 to S42.
[0082] S41. Synchronously traverse the table data in the second linked list LIST and the table data in the first linked list LIST in sequence according to the query order.
[0083] S42. For the second table data currently traversed and in the second linked list LIST and the first table data in the first linked list LIST, determine the corresponding new data, updated data and / or deleted data according to any one of the following methods (A) to (C) or any combination thereof.
[0084] (A) For each second row of data in the second table data and in the MAP data structure, the first table data is searched for a key name KEY corresponding to the primary key ID of the row of data based on the corresponding row of data primary key ID. If the key name KEY does not exist, the corresponding second row of data is treated as a new data item corresponding to both the second table data and the first table data. Alternatively, if both exist, there is no new data item corresponding to both the second table data and the first table data.
[0085] (B) For each second row of data in the second table data and in a MAP data structure, search the first table data for a key name KEY that is the primary key identifier ID of the row of data based on the corresponding row data primary key identifier ID. If so, obtain the first key value VALUE that corresponds to the key name KEY that is the primary key identifier ID of the row of data from the first table data; for each second row of data, determine the corresponding different data in the following manner: for each column in the first key value VALUE, compare the key value VALUE of the column with the key value VALUE that corresponds to the key name KEY of the column in the second row of data. If the comparison result of the two key values VALUE is different, use the key name KEY and key value VALUE of the column as a different data of the second row of data; use the different data of each second row of data as an updated data corresponding to the second table data and the first table data. The aforementioned first key value VALUE is a row of data in a MAP data structure, so there will be the key name KEY and key value VALUE of each column. If the comparison result of the two key values (VALUE) is different, it indicates that the corresponding column has changed during the change, while the opposite is not true. Therefore, the key name KEY and key value VALUE of the column can be used as the updated content in the pre-change table relative to the post-change table. In addition, if there is no difference in the second row data, there will be no updated data corresponding to the second table data and the first table data.
[0086] (C) For each first row of data in the first table data and in the MAP data structure, the second table data is searched for a key name KEY corresponding to the primary key ID of the row data based on the primary key ID of the corresponding row data. If the key name KEY does not exist, the corresponding first row of data is treated as a deletion data item corresponding to both the second table data and the first table data. Furthermore, if both exist, there is no deletion data item corresponding to both the second table data and the first table data.
[0087] S5. Combining the newly added data, updated data and / or deleted data of the modified tables into a data packet, and binding the data packet and the execution timestamp of the operation action logic as a process operation record information and storing it in the process operation record table.
[0088] In step S5, to achieve lightweight record keeping, the newly added data, updated data, and / or deleted data in each of the modified tables are preferably merged into a single data packet, including but not limited to: merging the newly added data, updated data, and / or deleted data in each of the modified tables into a JSON data format to obtain a single data packet. The aforementioned JSON data format is a lightweight existing data exchange format. Furthermore, the process operation record information may also, but is not limited to, include specific content such as the process ID, operator, and operation action.
[0089] S6. When a workflow state recovery request is received, query and obtain all current tables related to process state data, and arrange at least one process operation record information in the process operation record table in reverse order based on the execution timestamp to obtain a process operation record information sequence.
[0090] In step S6, the workflow state recovery request is also routinely generated and sent to the local computer when the user operates on the workflow and triggers the state recovery action. It needs to specifically but not limited to include the workflow target state requested for recovery. All current tables are used to record the current workflow state, that is, all changed tables involving process state data obtained after the most recent historical workflow state update. In addition, when the workflow state recovery request is received, it can also be determined whether the recovery is allowed based on various permission checks based on conventional permission verification methods. If so, the subsequent step S7 is executed, otherwise the workflow state reverse recovery is terminated.
[0091] S7. Based on all the current tables and the process operation record information sequence, the workflow is gradually rolled back and restored to the workflow target state requested to be restored in the workflow state restoration request.
[0092] In the step S7, specifically, it includes but is not limited to the following steps S70 to S76.
[0093] S70. Initialize the sort number K to 1, and then execute step S71, where K represents a positive integer and is less than or equal to the total number of information of the at least one process operation record information.
[0094] S71. All the current tables are taken as all changed tables involving process state data obtained after the latest K-th historical workflow state update, and then step S72 is executed.
[0095] S72. Obtain the Kth process operation record information in the process operation record information sequence, and parse the data packet in the Kth process operation record information, obtain the new data, updated data and / or deleted data of each changed table obtained after the most recent Kth historical workflow status update, and then execute step S73.
[0096] S73. Based on all the post-change tables involving process status data obtained after the K-th most recent historical workflow status update and the newly added data, updated data and / or deleted data in each post-change table, all pre-change tables involving process status data before the K-th most recent historical workflow status update are restored, and then step S74 is executed.
[0097] In step S73, the specific recovery process is opposite to the aforementioned step S42, that is: for newly added data, a delete statement is generated and the corresponding data deletion action is executed in the changed table; for updated data, an update statement is generated and the corresponding data update action is executed in the changed table; for deleted data, an insert statement is generated and the corresponding data insertion action is executed in the changed table; thus, through the aforementioned data deletion action, data update action and data insertion action, the table before the update can be restored. In addition, in order to promptly discover and handle existing recovery anomalies, preferably, after restoring all pre-change tables involving process state data before the most recent K-th historical workflow state update and before executing step S74, the method further includes: judging whether there is an anomaly in all pre-change tables involving process state data before the most recent K-th historical workflow state update (the specific anomaly judgment method is the existing conventional method, for example, if a column value should be an integer but a decimal is restored, it can be judged as an anomaly), if so, terminating the workflow state reverse recovery, otherwise executing step S74.
[0098] S74. Determine whether the Kth most recent historical workflow state is the workflow target state requested to be restored in the workflow state restoration request. If so, execute step S76; otherwise, execute step S75.
[0099] S75. All pre-change tables involving process state data before the Kth most recent historical workflow state update are used as all post-change tables involving process state data obtained after the K+1th most recent historical workflow state update, and the sort number K is incremented by 1. The process then returns to step S72.
[0100] S76. Based on all pre-change tables involving process state data before the most recent K-th historical workflow state update, restore the workflow to the workflow target state.
[0101] The above steps S70 to S76 can be specifically completed by opening a transaction (at this time, the primary key auto-increment of the table corresponding to this operation needs to be closed) and submitting the transaction when the workflow is restored to the workflow target state to complete the workflow recovery, and finally feeding back the recovery results to the user interface for notification.
[0102] Based on the workflow state reverse recovery method described in steps S1 to S7, a new workflow state recovery scheme similar to the stack push and pop method is provided. That is, before and after each workflow state change, all pre-change tables and all post-change tables involving process state data are queried and stored. Then, for each post-change table among all post-change tables, the corresponding new data, updated data, and / or deleted data are determined based on a comparison result with the data in the corresponding pre-change table. The new data, updated data, and / or deleted data in each post-change table are then packaged and bound together with the execution timestamp of the operation action logic as a process operation record information and stored in the process operation record table, thus implementing a stack push process. Finally, upon receiving a workflow state recovery request, all current tables involving process state data are queried and retrieved. Combined with the process operation record information sequence obtained by reverse sorting based on the execution timestamp, the workflow is gradually rolled back to the workflow target state requested in the workflow state recovery request, thus implementing a stack pop process. This avoids the need for a large amount of computation and action logic during the recovery process, thereby significantly improving the maintainability, reliability, and performance of the workflow management system and facilitating practical application and promotion.
[0103] like Figure 2 As shown, the second aspect of this embodiment provides a virtual device for implementing the workflow state reverse recovery method described in the first aspect, including a data query storage module, a state change response module, a before and after data comparison module, a data packaging and recording module, a state recovery response module and a state rollback recovery module;
[0104] The data query and storage module is used to query and store all pre-change tables involving process state data when a workflow state change request is received;
[0105] The state change response module is communicatively connected to the data query storage module and is used to execute operation action logic in response to the workflow state change request to change the workflow state;
[0106] The data query and storage module is further configured to query and store all post-change tables related to process state data after a workflow state changes, wherein all post-change tables correspond one-to-one to all pre-change tables;
[0107] The before-after data comparison module is communicatively connected to the data query storage module and is used to determine corresponding newly added data, updated data and / or deleted data for each changed table in all changed tables based on a comparison result with the data of the corresponding pre-change table;
[0108] The data packaging and recording module is communicatively connected to the before-after data comparison module, and is used to merge the newly added data, updated data and / or deleted data of each of the changed tables into a data packet, and bind the data packet and the execution timestamp of the operation action logic as a process operation record information and store it in the process operation record table;
[0109] The state recovery response module is communicatively connected to the data packaging and recording module and is configured to query and obtain all current tables related to process state data upon receiving a workflow state recovery request, and to arrange at least one process operation record information in the process operation record table in reverse order based on the execution timestamp to obtain a process operation record information sequence;
[0110] The state rollback recovery module is communicatively connected to the state recovery response module, and is used to gradually roll back the workflow to the workflow target state requested to be restored in the workflow state recovery request based on all the current tables and the process operation record information sequence.
[0111] The working process, working details and technical effects of the aforementioned device provided in the second aspect of this embodiment can be found in the workflow state reverse recovery method described in the first aspect, and will not be repeated here.
[0112] like Figure 3 As shown, the third aspect of this embodiment provides a computer device for implementing the workflow state reverse recovery method as described in the first aspect, comprising a memory, a processor, and a transceiver that are communicatively connected in sequence, wherein the memory is used to store a computer program, the transceiver is used to send and receive data, and the processor is used to read the computer program and execute the workflow state reverse recovery method as described in the first aspect. For example, the memory may include, but is not limited to, a random-access memory (RAM), a read-only memory (ROM), a flash memory, a first-in-first-out memory (FIFO), and / or a first-in-last-out memory (FILO), etc.
[0113] The working process, working details and technical effects of the aforementioned computer device provided in the third aspect of this embodiment can be found in the workflow state reverse recovery method described in the first aspect, and will not be repeated here.
[0114] A fourth aspect of this embodiment provides a computer-readable storage medium storing instructions including the workflow state reverse recovery method described in the first aspect. Specifically, the computer-readable storage medium stores instructions that, when executed on a computer, execute the workflow state reverse recovery method described in the first aspect. The computer-readable storage medium refers to a data storage medium, and may include, but is not limited to, a floppy disk, an optical disk, a hard disk, a flash memory, a USB flash drive, and / or a memory stick. The computer may be a general-purpose computer, a dedicated computer, a computer network, or other programmable device.
[0115] The working process, working details and technical effects of the aforementioned computer-readable storage medium provided in the fourth aspect of this embodiment can be referred to the workflow state reverse recovery method described in the first aspect, and will not be repeated here.
[0116] A fifth aspect of this embodiment provides a computer program product comprising instructions, which, when executed on a computer, causes the computer to execute the workflow state reverse recovery method described in the first aspect. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device.
[0117] Finally, it should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention shall be included in the scope of protection of the present invention.
Claims
1. A workflow state reverse recovery method, characterized in that: include: When a workflow status change request is received, all pre-change tables involving process status data are queried and stored, specifically including: sequentially querying and obtaining all pre-change tables involving process status data; based on a MAP data structure including a key name KEY and a key value VALUE, obtaining table data of each pre-change table in all pre-change tables in the following manner: first, using the key name KEY as the column name and the key value VALUE as the column value, simulating the column data of each row in the pre-change table to obtain the row data of each row in the MAP data structure; then, using the key name KEY as the row data primary key identifier ID and the key value VALUE as the row data, simulating each row in the pre-change table to obtain the table data of each pre-change table; sequentially putting the table data of each pre-change table into a linked list LIST data structure in the query order to obtain a first linked list LIST for storing all pre-change tables; Executing the operation action logic in response to the workflow state change request to change the workflow state; After the workflow state changes, query and store all post-change tables related to the process state data, wherein all the post-change tables correspond one-to-one to all the pre-change tables; For each of the changed tables, determining corresponding newly added data, updated data, and / or deleted data based on a comparison result with the data in the corresponding pre-changed table. Merging the newly added data, updated data, and / or deleted data of each of the modified tables into a data packet, and binding the data packet and the execution timestamp of the operation action logic as a process operation record information and storing it in the process operation record table; When a workflow state recovery request is received, all current tables related to process state data are queried and retrieved, and at least one process operation record information in the process operation record table is arranged in reverse order based on the execution timestamp to obtain a process operation record information sequence; Based on all the current tables and the process operation record information sequence, the workflow is gradually rolled back and restored to the workflow target state requested to be restored in the workflow state recovery request.
2. The workflow state reverse recovery method according to claim 1, characterized in that: Query and store all changed tables involving process status data, including: Querying and obtaining all post-change tables related to process status data in the query order, wherein all post-change tables correspond one-to-one to all pre-change tables; Based on a linked list LIST data structure and a MAP data structure including a key name KEY and a key value VALUE, table data of each changed table in all the changed tables is obtained in the following manner: first, using the key name KEY as the column name and the key value VALUE as the column value, column data of each row in each changed table is simulated to obtain row data of each row in the MAP data structure, and then the linked list LIST data structure is used to sequentially store the row data of each row in each changed table to obtain the table data of each changed table; The table data of each changed table is sequentially put into another linked list LIST data structure according to the query sequence, so as to obtain a second linked list LIST for storing all the changed tables.
3. The workflow state reverse recovery method according to claim 2, characterized in that: For each of the changed tables in all the changed tables, determining corresponding newly added data, updated data, and / or deleted data based on a comparison result with the data in the corresponding pre-changed table includes: Synchronously traversing the table data in the second linked list LIST and the table data in the first linked list LIST in sequence according to the query order; For the second table data currently traversed and in the second linked list LIST and the first table data in the first linked list LIST, the corresponding newly added data, updated data and / or deleted data are determined according to any one of the following methods (A) to (C) or any combination thereof: (A) For each second row of data in the second table data and in the MAP data structure, search the first table data for a key name KEY corresponding to the primary key identifier ID of the row of data based on the primary key identifier ID of the corresponding row of data; if the key name KEY does not exist, treat the corresponding second row of data as a newly added data corresponding to the second table data and the first table data; (B) for each second row of data in the second table data and in the MAP data structure, searching the first table data for a key name KEY corresponding to the primary key identifier ID of the row of data based on the corresponding row of data primary key identifier ID; if so, obtaining a first key value VALUE corresponding to the key name KEY corresponding to the primary key identifier ID of the row of data from the first table data; For each second row of data, determining corresponding different data in the following manner: for each column in the first key value VALUE, comparing the key value VALUE of the column with the key value VALUE in the second row of data and corresponding to the key name KEY of the column; if the comparison result of the two key values VALUE is different, then treating the key name KEY and key value VALUE of the column as a different data piece for the second row of data; using the different data of each second row of data as a piece of update data corresponding to the second table data and the first table data; (C) For each first row of data in the first table data and in the MAP data structure, search the second table data for a key name KEY corresponding to the primary key identifier ID of the row of data based on the primary key identifier ID of the row of data. If the key name KEY does not exist, treat the corresponding first row of data as a deletion data corresponding to the second table data and the first table data.
4. The workflow state reverse recovery method according to claim 1, characterized in that: Merge the newly added data, updated data, and / or deleted data of each of the modified tables into a data packet, including: The newly added data, updated data and / or deleted data of each of the changed tables are merged into a JSON data format to obtain a data packet.
5. The workflow state reverse recovery method according to claim 1, characterized in that: Based on all the current tables and the process operation record information sequence, the workflow is gradually rolled back to the workflow target state requested in the workflow state recovery request, including the following steps S70 to S76: S70. Initialize the sort number K to 1, and then execute step S71, where K represents a positive integer and is less than or equal to the total number of the at least one process operation record information; S71. All current tables are used as all changed tables involving process state data obtained after the most recent K-th historical workflow state update, and then step S72 is executed; S72. Obtain the Kth process operation record in the process operation record sequence, parse the data packet in the Kth process operation record, obtain the newly added data, updated data, and / or deleted data in each changed table after the Kth most recent historical workflow state update, and then execute step S73; S73. Based on all post-change tables related to process state data obtained after the Kth most recent historical workflow state update and the newly added data, updated data, and / or deleted data in each post-change table, all pre-change tables related to process state data before the Kth most recent historical workflow state update are restored, and then step S74 is executed. S74. Determine whether the Kth most recent historical workflow state is the workflow target state requested to be restored in the workflow state restoration request. If so, execute step S76; otherwise, execute step S75. S75. All pre-change tables involving process state data before the Kth most recent historical workflow state update are used as all post-change tables involving process state data obtained after the K+1th most recent historical workflow state update, and the sort number K is incremented by 1. The process then returns to step S72. S76. Based on all pre-change tables involving process state data before the most recent K-th historical workflow state update, restore the workflow to the workflow target state.
6. The workflow state reverse recovery method according to claim 5, characterized in that: After recovering all pre-change tables involving process state data before the Kth most recent historical workflow state update and before executing step S74, the method further includes: Determine whether there is an anomaly in all pre-change tables involving process state data before the most recent K-th historical workflow state update. If so, terminate the workflow state reverse recovery. Otherwise, execute step S74.
7. A workflow state reverse recovery device, characterized in that: It includes data query and storage module, state change response module, before and after data comparison module, data packaging and recording module, state recovery response module and state rollback recovery module; The data query storage module is used to query and store all pre-change tables related to process state data when receiving a workflow state change request, specifically including: querying and obtaining all pre-change tables related to process state data in sequence; obtaining table data of each pre-change table in all pre-change tables based on a MAP data structure containing a key name KEY and a key value VALUE in the following manner: first, using the key name KEY as the column name and the key value VALUE as the column value, simulate the column data of each row in the pre-change table to obtain the row data of each row in the MAP data structure; then, using the key name KEY as the row data primary key identifier ID and the key value VALUE as the row data, simulate each row in the pre-change table to obtain the table data of each pre-change table; and sequentially putting the table data of each pre-change table into a linked list LIST data structure in the query order to obtain a first linked list LIST for storing all pre-change tables; The state change response module is communicatively connected to the data query storage module and is used to execute operation action logic in response to the workflow state change request to change the workflow state; The data query and storage module is further configured to query and store all post-change tables related to process state data after a workflow state changes, wherein all post-change tables correspond one-to-one to all pre-change tables; The before-after data comparison module is communicatively connected to the data query storage module and is used to determine corresponding newly added data, updated data and / or deleted data for each changed table in all changed tables based on a comparison result with the data of the corresponding pre-change table; The data packaging and recording module is communicatively connected to the before-after data comparison module, and is used to merge the newly added data, updated data and / or deleted data of each of the changed tables into a data packet, and bind the data packet and the execution timestamp of the operation action logic as a process operation record information and store it in the process operation record table; The state recovery response module is communicatively connected to the data packaging and recording module and is configured to query and obtain all current tables related to process state data upon receiving a workflow state recovery request, and to arrange at least one process operation record information in the process operation record table in reverse order based on the execution timestamp to obtain a process operation record information sequence; The state rollback recovery module is communicatively connected to the state recovery response module, and is used to gradually roll back the workflow to the workflow target state requested to be restored in the workflow state recovery request based on all the current tables and the process operation record information sequence.
8. A computer device, characterized in that: It includes a memory, a processor and a transceiver that are communicatively connected in sequence, wherein the memory is used to store a computer program, the transceiver is used to send and receive data, and the processor is used to read the computer program and execute the workflow state reverse recovery method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores instructions, and when the instructions are executed on the computer, the workflow state reverse recovery method as described in any one of claims 1 to 6 is executed.
Citation Information
Patent Citations
Method for securely executing a workflow in a computer system
US20220229700A1
User restoration of workflow objects and elements from an archived database
US8818961B1