Method, device, electronic device and storage medium for implementing a workflow engine
Through the workflow engine implementation method, the flow of process objects is automatically managed, which solves the technical difficulty and cost issues brought by customized static workflows and realizes flexible process management and efficient business optimization.
Patent Information
- Application Number
- CN202111335337.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-11
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2041-11-11
AI Technical Summary
The customized static workflow processing in the existing technology leads to problems such as difficulty in post-project business optimization and technical processing, and high technical implementation costs.
Through the workflow engine implementation method, the target workflow definition information is obtained according to the front-end business request, a workflow instance is created and the execution flow is started, and it is automatically determined whether the process object meets the completion conditions. The pre-configured interceptor is called for flow transfer to realize the automated management of the process.
It improves the degree of process automation, simplifies process design and technical implementation, reduces manpower and time costs, and supports workflow management for various business types.
Smart Images

Figure CN113961332B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of automatic program processing technology, and in particular to a method, device, electronic device and storage medium for implementing a workflow engine. Background Art
[0002] Workflow refers to the automated execution and management of business processes through computers. Workflow is widely used across various industries, such as business trips, leave requests, vehicle usage, billing, and comprehensive operations and maintenance. Any process involving workflows requires workflow.
[0003] In related technologies, the workflow is implemented as follows:
[0004] 1) Business personnel and technical personnel fully communicate the details of the workflow and clarify the process nodes, process content, process permissions, etc. of each workflow.
[0005] 2) Front-end technicians develop a visual interface (such as a web system application interface), business personnel trigger detailed menu controls, and page interaction determines which workflow to enter based on the controls triggered by the business personnel, while also obtaining node process judgment data.
[0006] 3) The back-end technical staff implements the business logic of process control (such as how many layers of approval control the process has, process data analysis, etc.) based on the process modeling details after communication (such as: clarifying where the next process is, clarifying what the process content is, clarifying whether the operator has the authority, etc.), and returns the response data to the front-end to inform it of the node process judgment result.
[0007] Finally, every workflow operation requires the preservation and maintenance of business and process data.
[0008] This implementation has the following shortcomings:
[0009] (1) Each business process requires a clear and specific process design. Before development, the requirements designer needs to communicate and implement with the business personnel. During technical implementation, each node flow requires a rigid judgment of the next process node and operator. Therefore, the scalability of project iterative business optimization is not high. As long as the business logic is expanded, it will bring great difficulties to the technical processing, or even make it impossible to implement.
[0010] (2) If the system involves multiple process work transactions, a workflow needs to be established for each process transaction, and each process needs to develop an interactive page and background processing program separately, which consumes a lot of technical manpower and time.
[0011] (3) The completed workflow is a customized static process, which brings great difficulties to the subsequent project business optimization and technical processing. Summary of the Invention
[0012] The present application provides a method, device, electronic device and storage medium for implementing a workflow engine to solve the problems of difficulty in post-project business optimization and technical processing, high technical implementation cost, etc. caused by customized static workflow processing in the existing technology.
[0013] In a first aspect, an embodiment of the present application provides a method for implementing a workflow engine, including:
[0014] Obtain the corresponding target workflow definition information based on the input parameter information carried by the front-end business request;
[0015] Creating a corresponding workflow instance based on the target workflow definition information, and starting an execution flow corresponding to the workflow instance;
[0016] Extracting the process objects in the workflow instance, and determining in sequence according to the flow information in the workflow instance whether each process object meets the corresponding completion condition;
[0017] If the completion condition is not met, the pre-configured first interceptor is called, and when the first interceptor detects that the process object meets the corresponding completion condition, the process flows to the next process object for judgment.
[0018] In a second aspect, an embodiment of the present application further provides a device for implementing a workflow engine, including:
[0019] The workflow definition information acquisition module is used to obtain the corresponding target workflow definition information based on the input parameter information carried by the front-end business request;
[0020] A starting module, configured to create a corresponding workflow instance based on the target workflow definition information and start an execution flow corresponding to the workflow instance;
[0021] A flow determination module is used to extract the process objects in the workflow instance and determine whether each process object meets the corresponding completion condition according to the flow information in the workflow instance;
[0022] The interception module is used to call a pre-configured first interceptor if the process object does not meet the completion condition, and when the first interceptor detects that the process object meets the corresponding completion condition, flow to the next process object for judgment.
[0023] In a third aspect, an embodiment of the present application further provides an electronic device, comprising:
[0024] one or more processors;
[0025] a storage device for storing one or more programs,
[0026] When the one or more programs are executed by the one or more processors, the one or more processors implement the method of the first aspect described above.
[0027] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon, which implements the method of the first aspect when executed by a processor.
[0028] The technical solution provided in this application has the following beneficial effects:
[0029] In this embodiment, after obtaining the corresponding target workflow definition information according to the input parameter information carried by the front-end business request, the corresponding workflow instance can be created based on the target workflow definition information, and the execution flow corresponding to the workflow instance can be started. The execution flow automatically extracts the process objects in the current workflow instance according to the workflow definition information, and judges in turn whether each process object meets the corresponding completion condition according to the flow information in the workflow instance. For process objects that do not meet the completion condition, the pre-configured first interceptor is called, and when it is detected by the first interceptor that the process object meets the corresponding completion condition, the flow is automatically advanced to the next process object for judgment. It is convenient for the judgment of the node process and realizes the real separation execution of the start process command, so as to achieve which process to start according to the front-end request and start the command to execute the corresponding workflow process. There is no need for technical personnel to handle it again manually, and the process automation level is high. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 This is a flowchart of a method embodiment of a workflow engine implementation provided in Example 1 of the present application;
[0031] Figure 2 This is a flowchart of a method embodiment of a workflow engine implementation provided in Example 2 of the present application;
[0032] Figure 3 This is a schematic diagram of the execution order of each interceptor in the interceptor chain provided in Example 2 of the present application;
[0033] Figure 4 This is a schematic diagram of the working principle of a workflow engine in an application scenario example provided in Example 2 of the present application;
[0034] Figure 5 This is a structural block diagram of an apparatus embodiment for implementing a workflow engine provided in Example 3 of the present application;
[0035] Figure 6 This is a structural diagram of an electronic device provided in Example 4 of the present application. DETAILED DESCRIPTION
[0036] The present application will be further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are intended only to illustrate the present application and are not intended to limit the present application. It should also be noted that, for ease of description, the accompanying drawings only illustrate portions of the present application, not all of the structures.
[0037] Example 1
[0038] Figure 1 This is a flowchart of a method for implementing a workflow engine, as provided in Example 1 of this application. This embodiment can be applied to process management systems that adhere to the industry-standard BPMN 2.0 (Business Process Modeling Notation) specification. By modeling processes defined in XML format based on the BPMN 2.0 specification, a workflow engine for business processes is created, applicable to workflows across a variety of business types.
[0039] This embodiment may include the following steps:
[0040] Step 110: Obtain corresponding target workflow definition information according to the input parameter information carried by the front-end business request.
[0041] For example, the front-end service request may be generated by the front-end client based on the workflow identifier carried in the service type after the front-end client detects the service type triggered by the first user. Service types may include workflow types for different scenarios, such as leave application type, car use application type, business trip application type, and visitor access application type.
[0042] In an exemplary implementation scenario, the first user may be an applicant using a workflow. When the first user logs into the system and triggers the workflow application function, the front-end client displays multiple business types for the first user to choose from. After detecting that the first user has selected a business type (e.g., a leave application type) and filled in the relevant application information, the front-end client reads the workflow identifier bound to the selected business type, generates a business request based on the workflow identifier and the application information, and then sends the business request to the back-end. The business request may include the selected workflow identifier. The workflow identifier is used to uniquely identify a workflow.
[0043] After receiving the business request, the service backend parses the workflow ID and application information from the request. The application information can then be passed to the business party as business data for processing. The workflow ID is then sent to the workflow service for processing. The workflow service retrieves the corresponding target workflow definition information, ProcessDefinition, based on the workflow ID. Workflow definition information refers to the description of the workflow and can be expressed in text, flowcharts, and other formats. For example, workflow definition information may include the business type, workflow ID, and process node information.
[0044] In one embodiment, step 110 may further include the following steps:
[0045] When the front-end business request is received, a designated workflow service is triggered; and the designated workflow service loads the corresponding target workflow definition information according to the workflow identifier.
[0046] In this embodiment, when the service backend receives a front-end business request, it triggers the specified workflow service RunTimeService (also known as runtime service) in the workflow engine Flowable, and sends the parsed workflow identifier to the workflow service to tell the workflow service which workflow branch to start.
[0047] Based on the workflow identifier, the workflow service can search and load the corresponding target workflow file from the flow file database. The target workflow file contains the target workflow definition information. The flow file database stores multiple predefined workflow files, each containing relevant information such as the corresponding workflow identifier. The workflow file can be in the bpmn.XML format.
[0048] Step 120: Create a corresponding workflow instance based on the target workflow definition information, and start the execution flow corresponding to the workflow instance.
[0049] After the workflow service obtains the bpmn.XML file, it can parse the file to obtain the corresponding target workflow definition information and create the corresponding workflow instance based on the target workflow definition information. <bpmnmodel>, each process instance will have at least one execution flow <process>,Process is a memory object that can be executed by the program. Among them, workflow instance and execution flow are both code interfaces.
[0050] In the implementation, the workflow service can call the start interface startProcessInstance to start the execution flow in the workflow instance.
[0051] It should be noted that when the workflow service calls the startup interface, you also need to pay attention to the configuration of the following parameters: the applicant identifier applyUserid (i.e. the first user identifier), which is the department leader who needs to review the project. Through this identifier, you can obtain the department leader corresponding to this user; the workflow identifier businessKey (i.e. the workflow instance identifier), which is the business type key and business process id when the process is defined, connected by an underscore, that is, key_id; the result push address callBackUrl, that is, the reachable path of the workflow service.
[0052] In one embodiment, after the execution flow is started, the embodiment may further include the following steps:
[0053] A pre-configured second interceptor is called to obtain the initial node of the workflow instance and perform initialization processing on the initial node.
[0054] During implementation, after starting the workflow instance, you can call the command executor (CommandExecutor, which is also a code interface) and use the command executor to execute the interceptor chain (interceptors). The interceptor chain can include multiple pre-added interceptors with an execution order, such as the log interceptor LogInterceptor (when the log level is debug, the startup log will be output), the transaction interceptor SpringTransactionInterceptor (used for Spring transaction management, including doTransaction, commit, and rollback of user transactions), the command context interceptor CommandContextInterceptor (executes the SqlSession close method to persist the data), the command caller interceptor commandInvokerInterceptor (the interceptor that actually executes the start process command), the bpmn parsing interceptor BpmnOverrideContextInterceptor, the process interceptor TransactionContextInterceptor, and other custom interceptors (to ensure scalability according to actual needs), etc. (It should be noted that the interceptors listed above are not limited to the order of execution).
[0055] In practice, each interceptor in the interceptor chain executes the execute method of the next interceptor in its own execute method, which is a nested call. Therefore, the order in which each interceptor is executed can be roughly as follows: Figure 3 shown.
[0056] For example, the second interceptor can be a commandInvokerInterceptor, which can be the first interceptor in the interceptor chain. Before executing the command of the workflow instance, the commandInvokerInterceptor method is executed. The initialization operation (InitialOperation) is performed within the second interceptor. The process.getInitialFlowElement method can be used to obtain the initial node of the workflow instance and then initialize the initial node.
[0057] The initial node is an empty node, that is, the 0th node.
[0058] Step 130: extract the process objects in the workflow instance, and determine in sequence whether each process object meets the corresponding completion condition according to the flow information in the workflow instance.
[0059] For example, process objects may include sequence flows, activity tasks (including user tasks, service tasks, etc.), gateways (including exclusive gateways and parallel gateways), events (including start events, end events, etc.), etc. These process objects can be extracted from the workflow instance, and each one can be judged to see if the corresponding completion conditions are met.
[0060] In one embodiment, step 130 can be implemented by calling a node operation facilitator (DefaultFlowableEngineAgenda). This node operation facilitator is used to advance node flow, determine all process nodes, and automatically advance the flow to the next node (i.e., the subsequent node) until the process is completed. DefaultFlowableEngineAgenda holds operation objects, operations, and encapsulates node operations into different operations to facilitate node flow and automate business processes.
[0061] Then step 130 may further include the following steps:
[0062] Step 130 - 1 : Add the process object in the workflow instance to the operation stack.
[0063] During implementation, an operation stack can be created in the node operation pusher. After extracting the process objects from the workflow instance, all process objects can be pushed into the (invoke.add()) operation stack.
[0064] Step 130 - 2 : in the operation stack, starting from the initial node in the process object, obtain the operation object corresponding to each process object, and determine whether the operation of each operation object corresponding to each process object is completed.
[0065] Step 130 - 3 : If all operation objects in the process object are completed, it is determined that the process object meets the corresponding completion condition, and the process object operation is popped out of the stack.
[0066] Step 130 - 4 : If any operation object in the process object has not been completed, it is determined that the process object does not meet the corresponding completion condition.
[0067] After all process objects have been pushed onto the operation stack, the process objects can be traversed one at a time, starting from the initial node of the operation stack. First, it is determined whether each process object has a corresponding operation object. For example, sequence flows, start events, end events, and initial nodes often do not have operation objects. If an operation object is available for the process object, it is further determined whether the corresponding operation has been completed for each operation object. Otherwise, if the current process object has no operation object, the traversal continues to the next process object (i.e., the subsequent element).
[0068] For example, if a process object is a joint approval node, and the approvers are A, B, and C, and all three must agree before proceeding to the next approval node, then this process object has three corresponding operation objects: A Approval Operation Object, B Approval Operation Object, and C Approval Operation Object. If A, B, and C all complete their approvals, then A Approval Operation Object, B Approval Operation Object, and C Approval Operation Object are all completed, meaning the process object meets the corresponding completion condition. If A and B complete their approvals, but C does not, then A Approval Operation Object and B Approval Operation Object are completed, but C Approval Operation Object is not, and the process object does not meet the corresponding completion condition.
[0069] When it is determined that the current process object meets the corresponding completion condition, the process object operation can be popped out of the stack and the traversal continues to the next process object.
[0070] In one embodiment, before determining whether the operations on the operation objects corresponding to the process objects are completed in step 130-2, step 130 may further include the following steps:
[0071] Determine whether each process object has an actor, which includes one or more operation objects; if the process object has a corresponding actor, execute the corresponding actor; if the process object does not have a corresponding actor, determine that the process object meets the corresponding completion condition, and pop the process object operation out of the stack.
[0072] In this embodiment, the actor corresponding to each process object can be obtained. If the process object has an actor, the actor can be executed. The process of executing the actor can be to execute each operation object. If the actor does not exist, it means that the process object (such as a sequence flow) has no operation object. In this case, it can be determined that the process object meets the corresponding completion condition and the process object operation is popped out of the stack.
[0073] Step 140: If the completion condition is not met, a pre-configured first interceptor is called, and when the first interceptor detects that the process object meets the corresponding completion condition, the process flows to the next process object for judgment.
[0074] In this step, if it is determined that the currently traversed process object does not meet the corresponding completion condition, the first interceptor in the interceptor chain can be called to interrupt the continued execution of the current workflow instance and execute the method of the first interceptor. The first interceptor is used to monitor the completion status of the current process object (i.e., whether the completion condition is met). If the first interceptor detects that the current process object does not meet the corresponding completion condition, the current process object in the workflow instance is terminated and monitoring continues; if the first interceptor detects that the current process object meets the corresponding completion condition, the process object operation is popped out of the stack, the first interceptor is exited, and the workflow instance is notified to flow to the next process object for judgment. The above operations are repeated until the node is an end event and the process ends. Exemplarily, the first interceptor can be a process interceptor TransactionContextInterceptor.
[0075] In one embodiment, when it is necessary to flow to the next process object, the next process object can be automatically determined according to the flow information, and flow to the next process object for judgment.
[0076] In this embodiment, after obtaining the corresponding target workflow definition information according to the input parameter information carried by the front-end business request, the corresponding workflow instance can be created based on the target workflow definition information, and the execution flow corresponding to the workflow instance can be started. The execution flow automatically extracts the process objects in the current workflow instance according to the workflow definition information, and judges in turn whether each process object meets the corresponding completion condition according to the flow information in the workflow instance. For process objects that do not meet the completion condition, the pre-configured first interceptor is called, and when it is detected by the first interceptor that the process object meets the corresponding completion condition, the flow is automatically advanced to the next process object for judgment. It is convenient for the judgment of the node process and realizes the real separation execution of the start process command, so as to achieve which process to start according to the front-end request and start the command to execute the corresponding workflow process. There is no need for technical personnel to handle it again manually, and the process automation level is high.
[0077] Example 2
[0078] Figure 2 This is a flowchart of a method embodiment of a workflow engine implementation provided in the second embodiment of the present application. This embodiment, based on the first embodiment, describes the specific process of defining workflow information, which may include the following steps:
[0079] Step 210: When it is detected that the second user triggers the new process function, multiple workflow processes are displayed to the second user.
[0080] This embodiment provides a visual business interaction interface to help second users define process models and dynamically configure process definitions. Configurable workflow processes can directly correspond to one or even multiple modules, making each workflow process shared and easy to maintain. This allows for unified process maintenance, unified business data, and process-related data maintenance.
[0081] During implementation, Vue technology can be used to implement the front-end workflow configuration page, and to implement the configuration interface for adding and modifying configurations. Managers can configure process definitions at any time by simply entering the display platform.
[0082] In an exemplary implementation scenario, the second user's permissions differ from those of the first user. The second user may be a manager or maintenance personnel who creates workflows. When the second user logs in to the system and triggers the new workflow function (for example, by accessing the "Process Management" menu -> "Add a New Workflow"), the front-end client displays a visual new workflow page to the second user. The new workflow page can include multiple workflow processes. Different workflow processes may have different flow information and contain different process nodes.
[0083] Step 220 : Acquire the target workflow process selected by the second user from the multiple workflow processes, and receive process information input by the second user for the target workflow process, wherein the process information includes business type and process node information.
[0084] The second user can select at least one workflow process as the target workflow process from the multiple workflow processes displayed above according to actual business needs. After the client detects the target workflow process selected by the second user, the process page related to the target workflow process is displayed for the second user to input the process information corresponding to the target workflow process.
[0085] For example, process information may include business types and process node information. The process node information may include, for example, the approver information for each process node, including the approver's name, department, etc. Business types may include, for example, leave application types, car use application types, business trip application types, visitor access application types, etc.
[0086] For example, suppose there are two workflow processes for the second user to choose from. One includes two approval nodes. The first is a joint approval node, requiring approval from all three parties before proceeding to the second approval node. The second is a signed-or-signed approval node, requiring only one of the two parties to approve the process. The other workflow process could include one approval node, a joint approval node, requiring approval from all three parties to terminate the process.
[0087] Assume the second user selects the first workflow process and enters the process information for leave applications. This workflow is for leave applications. In the first approval node, the approvers are A, B, and C. Therefore, approval from A, B, and C is required before the next approval node can proceed. In the second approval node, the approvers are D and E. Only approval from D or E is required for the process to end.
[0088] It should be noted that three interfaces can be designed in the front-end configuration interface: the workflow process definition list interface process / query / flow / settings, the process details interface process / query / flow / details, and the process / setting interface for saving flow definitions. These three interfaces implement the interaction between steps 210 and 220.
[0089] Step 230: Generate workflow definition information based on the process information and the target workflow process.
[0090] After receiving the process information input by the second user, the front-end client sends the process information to the backend, and the backend transmits the parameters to the Flowable workflow engine. The workflow engine can then generate workflow definition information for the business process based on the process information and the corresponding target workflow process. The workflow definition information includes a workflow identifier assigned by the backend to the current business process, which uniquely identifies the business process.
[0091] It should be noted that each business type event can be represented by a key. If the second user selects more than one target workflow process for that business type, each business process can be represented by a process ID. Both the key and the process ID are globally unique and constitute the workflow identifier.
[0092] After the workflow definition information is generated, the backend can generate a workflow file in a specified format using the workflow definition information and store the workflow file. For example, the workflow file in the specified format can be a bpmn.XML format file.
[0093] Step 240: When the front-end service request is received, a specified workflow service is triggered.
[0094] Step 250: The designated workflow service loads the corresponding target workflow definition information according to the workflow identifier.
[0095] Step 260: Create a corresponding workflow instance based on the target workflow definition information.
[0096] Step 270: extract the process objects in the workflow instance, and determine in sequence whether each process object meets the corresponding completion condition according to the flow information in the workflow instance.
[0097] Step 280: If the completion condition is not met, an interceptor is added to the process object, and when the interceptor detects that the process object meets the corresponding completion condition, the process flows to the next process object for judgment.
[0098] In this embodiment, workflow processes are independent of business operations. When a second user needs to add a new business process, they can select a target workflow process from multiple pre-created workflow processes and enter the corresponding process information for the target workflow process. This process information is business-related process information, including business type and process node information. The system can then automatically generate workflow definition information for the business process based on the process information entered by the second user and the target workflow process. This enables dynamic configuration of workflows and simplifies the business logic and technical implementation of process design.
[0099] Workflow processes are independent of business operations, eliminating the conflict between changing requirements and hard-coded code. When business processes change (each modification is stored as a new version), they can be modified simply through configuration, eliminating the need for code-level improvements. This allows for quick and flexible maintenance of changing business processes, saving both manpower and time. For example, consider two business processes: a leave application and a car application. Both are created using workflow process A. Suppose the approver for the leave application process is Zhang San, while the approver for the car application process is Wang Wu. If Zhang San later leaves the company, the leave application event can be bound to the car application process. This way, when a user submits a leave application, it will follow the car application process and be approved by Wang Wu. Alternatively, when a business process changes from one workflow process to another, simply bind the business type to the workflow process to be replaced.
[0100] Furthermore, through the workflow configuration approach of this embodiment, the implementation code for business processes is no longer scattered across various business systems, allowing for unified management and maintenance. Developers no longer need to worry about numerous participants, activity node connections, and process flow control, thereby improving development efficiency and reducing code error rates.
[0101] In order to enable those skilled in the art to better understand the present application, the present application is illustrated below through an application scenario example. Figure 4 , shows a schematic diagram of the working principle of the workflow engine in this application scenario. Take the personal leave application process as an example to illustrate:
[0102] Step 1: Process definition
[0103] The administrator (i.e., the second user) logs in to the system and clicks on the "Process Management" menu -> "Add Process" to open the "Add Process" page to add different types of processes. The administrator selects the target workflow process on the "Add Process" page and enters the corresponding process information. The relevant parameter data is as follows:
[0104] Business type: leave application process (the type of process is customizable and can be added at will, including leave application, car application, business trip application, visitor entry and exit application, etc.);
[0105] Process node information: Assume there are two approval nodes. The first approval node is a joint approval node: the approvers are A, B, and C, and all three must agree before entering the second approval node; the second approval node is an or-sign node: the approvers are D or E, and the process ends as long as one person agrees.
[0106] The generated process file format is: bpmn.XML format file.
[0107] Step 2: Submit your leave application
[0108] The applicant (i.e., the first user) opens the "Leave Application" menu, fills in the application information, and clicks the "Submit" button to submit the application. This application data is the business data. After processing by the business party, a request is sent to the workflow service provider to initiate the leave approval process.
[0109] (1) Start command
[0110] like Figure 4 As shown, the front-end initiates a request to the workflow engine based on the applicant's application. The event triggers the RuntimeService runtime service. The workflow engine starts a new approval flow (i.e., execution flow) and calls startProcessInstanceCmd to start the process (start command). The workflow service will load and parse the bpmnXML format file (i.e., Figure 4 Construction process), create a process instance <bpmnmodel>, each process instance will have at least one execution flow <process>.
[0111] The generated Process gets the initial node of the process through the process.getInitialFlowElement method. When constructing the Execution entity later, set the initial node (i.e. Figure 4 InitialOperation in the node starts the initialization operation).
[0112] (2) Command Executor
[0113] The CommanExecutor command executor is used to implement the startup command in part, and the other part is used to execute various interceptors in the interceptor chain (some default interceptors will be added during the event execution process).
[0114] (3) Node transfer
[0115] Operation step 2 initiates a request to the workflow engine, executes the commandInvokerInterceptor command caller interceptor in various interceptors of the interceptor chain, initializes the process start node (initialOperation start node initialization), executes startProcessInstancecmd to start the process, and then performs the following two operations:
[0116] 1) Execute operations in the stack
[0117] Push (invoke.add()) all process node operations of the leave application process instance (the leave application process definition of operation step 1 has been created, and the leave application process has 2 process nodes) into the operation stack of the DefaultFlowableEngineAgenda node operation pusher.
[0118] 2) Continue the flow operation, including the operation on the node and the operation on the sequence flow
[0119] For node operations, record the node start, obtain the node actor and execute the actor. If there is no actor, create a sequence flow operation and operate on the sequence flow.
[0120] For sequence flow operations, find the element following the current element and set it as the current execution element. If the element following the current element is a node, it is executed directly; if the element following the current element is a sequence flow, a continuation operation is constructed.
[0121] In the leave application process, after the process is started, 1) and 2) are executed in sequence. The initial operation of the start node is executed, the 0th node [empty start event], the operation is added to the stack, the operation is popped out of the stack, and there is no actor; the post-node element is the 1st node, and the 1st node operation is directly executed and pushed into the stack, where the 1st node is the countersignature. There are three approval tasks, namely A, B, and C. All three must be approved before it can be passed. If A and B are approved (the operation is executed and the operation has been performed), and C has not yet approved (the operation is executed and the operation has not been performed), it enters the TransactionContextInterceptor process interceptor among the various interceptors. The interceptor determines whether the node meets the completion conditions. If C has not approved, the task does not meet the completion conditions and the current operation ends. If C is approved, all three tasks are completed, and the completion conditions (operation executed, operation completed) are met. The current node operation is popped out of the stack, and the next node (post-node) is searched; the second node is found, the operation is pushed into the stack, and the second node is or signed. If one of D or E is approved, the completion conditions (operation executed, operation completed) are met, and the next node (post-node) is searched. The above operations are repeated until the node is the end event and the process ends.
[0122] Through this example, the following beneficial effects can be achieved:
[0123] By using terms such as activity, flow, state, and behavior, it is possible for business analysts and developers to talk in the same language. Excellent process design modeling tools can even save developers from having to translate user requirements into detailed design documents.
[0124] The visual display platform and configurable workflow process definition do not require clear process design and are not affected by business process changes. Managers can configure the process definition at any time as long as they enter the display platform.
[0125] Using a workflow engine, the implementation code of business processes is no longer scattered across various business systems. Instead, it can be managed and maintained in a unified manner, avoiding conflicts with hard coding. This allows for business expansion at any time while reducing the resource consumption of technical personnel.
[0126] Developers do not need to pay attention to too many participants, activity node connections and process flow control issues, which improves the development efficiency of developers and reduces the code error rate.
[0127] Example 3
[0128] Figure 5 The structural block diagram of an apparatus embodiment for implementing a workflow engine provided in the third embodiment of the present application may include the following modules:
[0129] The workflow definition information acquisition module 510 is used to obtain the corresponding target workflow definition information according to the input parameter information carried by the front-end business request;
[0130] A starting module 520, configured to create a corresponding workflow instance based on the target workflow definition information and start an execution flow corresponding to the workflow instance;
[0131] The flow determination module 530 is used to extract the process objects in the workflow instance and determine whether each process object meets the corresponding completion condition according to the flow information in the workflow instance;
[0132] The interception module 540 is used to call a pre-configured first interceptor if the process object does not meet the completion condition, and when the first interceptor detects that the process object meets the corresponding completion condition, flow to the next process object for judgment.
[0133] In one embodiment, the apparatus may further include the following modules:
[0134] The flow module is used to determine the next flow object if it is determined that the flow object meets the completion condition, and flow to the next flow object for judgment.
[0135] In one embodiment, the apparatus may further include the following modules:
[0136] The initialization module is used to call the pre-configured second interceptor to obtain the initial node of the workflow instance and perform initialization processing on the initial node.
[0137] In one embodiment, the flow determination module 530 is specifically configured to:
[0138] Adding the process object in the workflow instance to the operation stack;
[0139] In the operation stack, starting from the initial node in the process object, obtaining the operation object corresponding to each process object, and determining whether the operation of each operation object corresponding to each process object is completed;
[0140] If all operation objects in the process object are completed, it is determined that the process object meets the corresponding completion conditions, and the process object operation is popped out of the stack;
[0141] If any operation object in the process object has not been completed, it is determined that the process object does not meet the corresponding completion condition.
[0142] In one embodiment, the flow determination module 530 is further configured to:
[0143] Determine whether each process object has an actor, wherein the actor includes one or more operation objects;
[0144] If the process object has a corresponding actor, execute the corresponding actor;
[0145] If the process object does not have a corresponding actor, it is determined that the process object meets the corresponding completion condition, and the process object operation is popped out of the stack.
[0146] In one embodiment, the input parameter information includes a workflow identifier, and the front-end service request is a request generated by the front-end client according to the workflow identifier carried in the service type after the front-end client detects the service type triggered by the first user;
[0147] The workflow definition information acquisition module 510 is specifically used to:
[0148] When receiving the front-end business request, triggering the specified workflow service;
[0149] The designated workflow service loads the corresponding target workflow definition information according to the workflow identifier.
[0150] In one embodiment, the apparatus may further include the following modules:
[0151] A workflow process display module is used to display multiple workflow processes to the second user when it is detected that the second user triggers the new process function;
[0152] a process information acquisition module, configured to acquire a target workflow process selected by the second user from the plurality of workflow processes, and receive process information input by the second user for the target workflow process, the process information including a business type and process node information;
[0153] The workflow definition information generating module is used to generate workflow definition information according to the process information and the target workflow process.
[0154] In one embodiment, the apparatus may further include the following modules:
[0155] The workflow file generating module is used to generate a workflow file in a specified format from the workflow definition information and store the workflow file.
[0156] The device for implementing a workflow engine provided in an embodiment of the present application can execute a method for implementing a workflow engine in embodiment 1 or embodiment 2 of the present application, and has functional modules and beneficial effects corresponding to the execution method.
[0157] Example 4
[0158] Figure 6 This is a structural diagram of an electronic device provided in Example 4 of the present application, such as Figure 6 As shown, the electronic device includes a processor 610, a memory 620, an input device 630, and an output device 640; the number of processors 610 in the electronic device can be one or more. Figure 6 In the figure, a processor 610 is used as an example; the processor 610, memory 620, input device 630 and output device 640 in the electronic device can be connected via a bus or other means. Figure 6 The bus connection is taken as an example.
[0159] The memory 620, as a computer-readable storage medium, can be used to store software programs, computer-executable programs, and modules, such as the program instructions / modules corresponding to the first or second embodiment of the present application. The processor 610 executes the software programs, instructions, and modules stored in the memory 620 to execute various functional applications and data processing of the electronic device, that is, to implement the method mentioned in the first or second embodiment of the method.
[0160] The memory 620 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and at least one application required for a function; the data storage area may store data created based on the use of the terminal, etc. In addition, the memory 620 may include a high-speed random access memory and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 620 may further include a memory remotely located relative to the processor 610, and these remote memories may be connected to the device / terminal / server via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0161] The input device 630 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the electronic device. The output device 640 may include a display device such as a display screen.
[0162] Example 5
[0163] Embodiment 5 of the present application further provides a storage medium comprising computer-executable instructions, which, when executed by a computer processor, are used to execute the method in embodiment 1 or embodiment 2 of the above method.
[0164] Of course, the storage medium containing computer-executable instructions provided in an embodiment of the present application, whose computer-executable instructions are not limited to the method operations described above, can also execute related operations in the method provided in any embodiment of the present application.
[0165] Through the above description of the implementation methods, those skilled in the art can clearly understand that the present application can be implemented with the help of software and necessary general-purpose hardware, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for enabling an electronic device (which can be a personal computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0166] It is worth noting that in the embodiments of the above-mentioned device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application.
[0167] Note that the above are only preferred embodiments of the present application and the technical principles employed. Those skilled in the art will understand that the present application is not limited to the specific embodiments described herein, and that various obvious changes, readjustments, and substitutions can be made by those skilled in the art without departing from the scope of protection of the present application. Therefore, although the present application has been described in more detail through the above embodiments, the present application is not limited to the above embodiments and may include many other equivalent embodiments without departing from the scope of the present application. The scope of the present application is determined by the scope of the appended claims.< / process> < / bpmnmodel> < / process> < / bpmnmodel>
Claims
1. A method for implementing a workflow engine, characterized in that: include: Obtain corresponding target workflow definition information based on input parameter information carried by the front-end service request; wherein the input parameter information includes a workflow identifier, and the front-end service request is a request generated by the front-end client based on the workflow identifier carried in the service type after detecting the service type triggered by the first user; Creating a corresponding workflow instance based on the target workflow definition information, and starting an execution flow corresponding to the workflow instance; Calling a pre-configured second interceptor to obtain the initial node of the workflow instance and perform initialization processing on the initial node; Extracting process objects in the workflow instance and determining whether each process object meets corresponding completion conditions in accordance with flow information in the workflow instance; wherein the process objects include sequence flows, activity tasks, gateways, and events; If the completion condition is not met, the pre-configured first interceptor is called, and when the first interceptor detects that the process object meets the corresponding completion condition, the next process object is automatically determined according to the flow information, and the flow is transferred to the next process object for judgment; The step of obtaining the corresponding target workflow definition information according to the input parameter information carried by the front-end business request includes: When receiving the front-end business request, triggering the specified workflow service; The designated workflow service searches for and loads corresponding target workflow definition information from a flow file database according to the workflow identifier.
2. The method according to claim 1, characterized in that The method further comprises: If it is determined that the process object meets the completion condition, the next process object is determined and the process flows to the next process object for judgment.
3. The method according to claim 1, characterized in that The step of sequentially judging whether each process object meets the corresponding completion condition according to the flow information in the workflow instance includes: Adding the process object in the workflow instance to the operation stack; In the operation stack, starting from the initial node in the process object, obtaining the operation object corresponding to each process object, and determining whether the operation of each operation object corresponding to each process object is completed; If all operation objects in the process object are completed, it is determined that the process object meets the corresponding completion conditions, and the process object operation is popped out of the stack; If any operation object in the process object has not been completed, it is determined that the process object does not meet the corresponding completion condition.
4. The method according to claim 3, characterized in that Before determining whether the operations of the operation objects corresponding to the process objects are completed, determining whether the process objects meet the corresponding completion conditions in sequence according to the flow information in the workflow instance further includes: Determine whether each process object has an actor, wherein the actor includes one or more operation objects; If the process object has a corresponding actor, execute the corresponding actor; If the process object does not have a corresponding actor, it is determined that the process object meets the corresponding completion condition, and the process object operation is popped out of the stack.
5. The method according to claim 1, wherein Before acquiring corresponding target workflow definition information according to the input parameter information carried in the front-end business request, the method further includes: When it is detected that the second user triggers the new process function, multiple workflow processes are displayed to the second user; Acquire a target workflow process selected by the second user from the multiple workflow processes, and receive process information input by the second user for the target workflow process, the process information including a business type and process node information; Workflow definition information is generated according to the process information and the target workflow process.
6. The method according to claim 5, characterized in that After generating workflow definition information according to the process information and the target workflow process, the method further includes: The workflow definition information is used to generate a workflow file in a specified format, and the workflow file is stored.
7. A device for implementing a workflow engine, characterized in that: include: A workflow definition information acquisition module is configured to acquire corresponding target workflow definition information based on input parameter information carried in a front-end service request; wherein the input parameter information includes a workflow identifier, and the front-end service request is a request generated by the front-end client based on the workflow identifier carried in the service type after the front-end client detects the service type triggered by the first user; A starting module, configured to create a corresponding workflow instance based on the target workflow definition information and start an execution flow corresponding to the workflow instance; An initialization module, configured to call a pre-configured second interceptor to obtain an initial node of the workflow instance and perform initialization processing on the initial node; A flow determination module is used to extract process objects in the workflow instance and determine whether each process object meets the corresponding completion condition according to the flow information in the workflow instance; wherein the process objects include sequence flows, activity tasks, gateways and events; an interception module, configured to call a pre-configured first interceptor if the process object does not meet the completion condition, and automatically determine the next process object according to the flow information when the first interceptor detects that the process object meets the corresponding completion condition, and flow to the next process object for judgment; The workflow definition information acquisition module is specifically configured to trigger a designated workflow service upon receiving the front-end business request; the designated workflow service searches for and loads the corresponding target workflow definition information from a flow file database according to the workflow identifier.
8. An electronic device, characterized in that: The electronic device comprises: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Process engine implementation method and device, electronic equipment and readable storage medium
CN112182000A
Working method of workflow engine, server, medium and equipment
CN112712335A
Dialogue management method and device and storage medium
CN113449086A
BPMN-based spaceflight workflow management system
CN113504955A