Disclosure of Invention
The invention aims to provide a workflow engine depending on a form, which is used for solving the problems of low form updating speed, easiness in form loss, easiness in error and complexity.
In order to achieve the purpose, the invention provides the following technical scheme:
a workflow engine based on tables is divided into a workflow storage part and a workflow execution part, wherein the workflow storage part is used for storing the workflow, and the workflow execution part is used for maintaining table data;
the workflow storage comprises a trigger mode, a trigger condition, action execution and action storage; the triggering mode creates an expression according to the instruction generating mode and sends the expression to the table; the triggering condition verifies the form data according to the expression so as to judge whether to operate the form data or not; when the expression is verified, the workflow can complete one or more specific workflow execution operations; when the action is stored in the workflow, generating an abstract syntax tree of an expression and synchronously storing the abstract syntax tree along with the workflow;
the workflow executes and generates a table relation tree and a table influence tree according to the configuration of the user table, wherein the table relation tree represents the data association relation between the tables, and the table influence tree represents the execution process of the table relation tree; the system completes the data updating of the current table according to the expression and completes the data updating of the associated table in sequence according to the table influence tree.
Preferably, the specific process executed by the workflow is as follows:
s1, taking the current form as the starting end, obtaining the form influence tree and the related workflow;
s2, verifying the trigger condition of the next-stage workflow, and ending if the trigger condition does not pass;
s3, executing the action of the next stage workflow, finishing the data update of the next form, and storing the created data as the input of the subsequent workflow;
s4, maintaining the operation behavior on the second table;
and S5, sequentially verifying the subsequent workflow according to the sequence of the table influence tree, and completing the data update of the next table until the data update of the end table is completed.
Preferably, the abstract syntax tree is formed by lexical analysis and syntax analysis of an expression; lexical analysis converts expressions in text form into recognizable element units, and syntactic analysis forms an abstract syntax tree by combining and verifying the element units.
Preferably, when the action is stored in the abstract syntax tree, whether the trigger condition and the expression are legal or not is sequentially verified.
Preferably, the triggering mode includes a data creation trigger, a data update trigger, a data deletion trigger, a data field expiration trigger, a trigger after searching data at a specified time, a trigger after searching data by a manual trigger, a trigger at a specified time, and a manual trigger.
By adopting the workflow engine which is based on the form and has the structure, the form data is updated without manual intervention, the updating speed is high, the safety is high, and the management is more convenient.
Detailed Description
The technical scheme of the invention is further explained by combining the drawings and the embodiment.
A form-dependent workflow engine includes workflow storage and workflow execution.
The workflow storage comprises a trigger mode, a trigger condition, action execution and action storage. The triggering mode creates an expression according to the instruction generating mode and sends the expression to the table; the triggering condition verifies the form data according to the expression so as to judge whether to operate the form data or not; when the expression is verified, the action execution completes one or more workflow execution operations; when the action is stored in the workflow, an abstract syntax tree of the expression is generated and is synchronously stored along with the workflow.
And the workflow execution completes the data updating of the current table according to the expression and completes the data updating of the associated table in sequence according to the table influence tree.
Specifically, the workflow of the workflow storage phase is as shown in fig. 1.
S1: automatically creating an expression according to a triggering mode;
s2: the trigger condition verifies the form data according to the expression; if the verification fails, the verification can be directly ended, or the reason can be prompted to return to the step S1 again;
s3: entering a workflow execution stage according to the expression;
s4: when the workflow is stored, verifying whether the triggering condition and the expression are legal or not, and simultaneously generating an AST structure;
s5: the workflow and AST are saved.
The triggering mode comprises the following modes:
create data trigger-trigger after creation action occurs to binding table
② data updating triggering-triggering after binding table generating updating action
Triggering of deleting data-triggering after deleting action of binding table
Data field expiration trigger-execution after expiration of binding form specified time type field
Triggering after searching data at specified time-after the specified time is reached, obtaining data through screening conditions and executing
After the data are found out by manual trigger, the data are obtained by the screening condition and executed
Seventhly, triggering at specified time, and directly executing after the specified time is reached
Manual triggering-after manual triggering by a user, directly executing
The expression mainly comprises the following five elements:
constants — written-down values in code languages, typically text or numbers, such as: 'text constants', 12, etc
Method-various methods for implementing functional logic, such as: NOW (), IF, etc
③ variables — table fields that the current execution environment can use, such as: { Current data.number field }, { target Table.text field }
Operation-digital operation and comparison, +, -, +, -,/, >, <
Brackets-influencing priority, (), [ ]
An expression parsing process embodiment is shown in fig. 2-3.
1. And lexical analysis, namely converting the expression in the text form into the recognizable elements.
2. And (5) parsing, performing combination verification on the code elements, and then generating the AST.
And executing the workflow, wherein when the configuration of the workflow is changed, all the workflows in the whole working area generate a table relationship tree and a table influence tree according to the configuration.
Table (b): A. b, C
Workflow: w1 depends on the table A, and when the data of the table A is created, the data is triggered to be created in the table B; w2 relies on Table B to trigger when the data in Table B is created, and acts as creating data in Table C.
The table relationship tree in the normal state is shown in fig. 4. If the workflow w3 depends on the table C at the moment, and the action is triggered when the data of the table C is created to be used for creating the data in the A table, the generated table relationship tree is shown in FIG. 5, and the table falls into a dead loop stage and is not allowed by the system. Thus, the resulting table influence tree is shown in FIG. 6.
The workflow is executed according to a table influence tree, and when the data creation of the table A occurs, the workflow is executed through the following steps:
s1, taking the table A as an initial end, and obtaining a table influence tree and a related workflow;
s2, verifying the trigger condition of the workflow w1, and ending the process if the trigger condition does not pass;
s3, executing the action of the workflow w1, completing the creation of the form B, and storing the created data as the input of the subsequent workflow;
s4, maintaining the creating behavior on the form B;
s5, verifying the trigger condition of the workflow w2, and ending the process if the trigger condition does not pass;
s6, executing the action of the workflow w2, and completing the creation of the form C;
and S7, ending.
The above is a specific embodiment of the present invention, but the scope of the present invention should not be limited thereto. Any changes or substitutions that can be easily made by those skilled in the art within the technical scope of the present invention are included in the protection scope of the present invention, and therefore, the protection scope of the present invention is subject to the protection scope defined by the appended claims.