Business state flow arrangement processing method, device and equipment

By combining state process examples and state process templates, the memory usage and presentation problems of traditional systems when handling business state flow are solved, and efficient state flow processing is achieved.

CN119228105AActive Publication Date: 2024-12-31BEIJING ZHIJIAN ENERGY CO LTD
View PDF 10 Cites 0 Cited by

Patent Information

Application Number
CN202411419010.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-11
Publication Date
2024-12-31
Estimated Expiration
2044-10-11

AI Technical Summary

Technical Problem

When handling the flow of business states, traditional logistics and transportation process management systems cannot intuitively display the current state and occupy too much system memory, resulting in high complexity and low performance.

Method used

The state process instance is used as a stateful state machine and the state process template is used as a stateless state machine. The business state flow is completed through the state process template, reducing the complexity of system access and improving performance.

Benefits of technology

It realizes the intuitive display of the current business status without occupying too much system memory, and improves the performance and efficiency of the state flow system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119228105A_ABST
    Figure CN119228105A_ABST
Patent Text Reader

Abstract

The invention provides a business state flow arrangement processing method which specifically comprises the steps that when a trigger event is received, a state machine process instance corresponding to a waybill event request is inquired according to the trigger event, the state machine process instance is created and generated according to an initial business waybill, and the waybill event request is sent to the state machine process instance; the process instance comprises service state information of the service waybill; obtaining the current state of the waybill according to the state machine process instance, and querying a process template corresponding to the trigger event; wherein the process template comprises state machine rule configuration information; and obtaining an operation list corresponding to the trigger event according to the process template, and traversing and executing each operation according to the operation list, thereby completing the state circulation of the trigger event. According to the processing method, the stateful state machine and the stateless state machine are combined to be used in a matched mode to process service state circulation, the problems existing when the stateful state machine is independently used and the stateless state machine is independently used are solved, and the performance of the state circulation system is effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of data processing technology, and in particular to a method, device and equipment for orchestrating and processing business state flow transitions. Background Art

[0002] The transfer of waybill status is the core link in the field of bulk transportation. The waybill link is long and the waybill status is changeable, which requires multi-tenant, multi-scenario, and multi-dimensional adaptation. Traditional logistics and transportation process management systems usually use a separate stateful state machine or a stateless state machine to handle the flow of business status. When processing the flow of business status, the stateful state machine takes up a large amount of memory; the stateless state machine has the problem of not being able to intuitively display the current state of the business. Therefore, how to design a system that can intuitively display the current state of the business without occupying too much system memory to handle the flow of business status has become an urgent problem to be solved by researchers in this field. Summary of the invention

[0003] In view of this, the present disclosure proposes a method, device and equipment for orchestrating and processing business state flow, which can realize both intuitive display of the current state of the business and not occupy too much system memory to process the business state flow. The present disclosure uses the created state process instance as a stateful state machine and the state process template as a stateless state machine, so that during the business state flow process, the state process instance only needs to call the corresponding state process template and complete the business state flow according to the state process template. The complexity of business system access is reduced, and the performance of the state flow system is improved.

[0004] According to a first aspect of the present disclosure, a method for orchestrating a service state flow is provided, comprising:

[0005] When a trigger event is received, a corresponding state machine process instance is queried according to the trigger event, wherein the state machine process instance is created and generated according to the initial business waybill, and the process instance contains the business status information of the business waybill;

[0006] Obtain the current state of the waybill according to the state machine process instance, and query the process template corresponding to the trigger event; wherein the process template contains state machine rule configuration information;

[0007] The operation list corresponding to the triggering event is obtained according to the process template, and each operation is traversed and executed according to the operation list, thereby completing the state flow of the triggering event.

[0008] In a possible implementation, querying the corresponding state machine process instance according to the trigger event includes:

[0009] Extracting waybill information from the trigger event;

[0010] The state machine process instance is obtained according to the waybill information query.

[0011] In a possible implementation, after obtaining the current state of the waybill according to the state machine process instance and querying the process template corresponding to the trigger event, the method further includes:

[0012] Determine whether the trigger event matches the current status of the waybill;

[0013] When it is determined that the triggering event matches the current state of the waybill, a step of obtaining an operation list corresponding to the triggering event according to the process template is executed.

[0014] In a possible implementation, after obtaining an operation list corresponding to the trigger event according to the process template and traversing and executing each operation according to the operation list, the method further includes:

[0015] Determine whether the state transition conditions are met;

[0016] When it is determined that the state transition condition is met, the next trigger event is triggered.

[0017] In a possible implementation, determining whether a state transition condition is met includes:

[0018] Record the successful execution of the current event in redis and MySQL, then obtain the execution status of other events in the current state from redis, and mark the execution status of other events;

[0019] Then perform logical operations based on the configured flow expression to obtain a Boolean value;

[0020] When the Boolean value is true, it indicates that the state transition condition is met.

[0021] In a possible implementation, it is characterized in that when determining whether the trigger event matches the current state of the waybill, it further includes:

[0022] When it is determined that the triggering event does not match the current state of the waybill, determining the triggering event;

[0023] When it is determined that the triggering event is an out-of-order event, an operation of starting an out-of-order event processing flow;

[0024] Among them, the out-of-order event is an event in which the current trigger node in the events configured for the business waybill is inconsistent with the configured trigger node.

[0025] In a possible implementation, the out-of-order event processing process includes:

[0026] Persisting the out-of-order events in a dedicated out-of-order event table;

[0027] Then, the out-of-order events in the out-of-order event table are marked as "skipped" state, and an ordered queue of skipped events is maintained in memory;

[0028] Capturing the context of the current state machine of the out-of-order event according to the out-of-order event;

[0029] Priority evaluation is performed on the out-of-order events according to evaluation factors, wherein the evaluation factors include: at least one of the importance of the event type, the time sequence of the event occurrence, and the business impact degree.

[0030] In a possible implementation, when the triggering event is determined to be an abnormal event, an abnormal prompt is issued;

[0031] The abnormal event is an event triggered by a user's incorrect operation.

[0032] According to a second aspect of the present disclosure, a device for orchestrating a service state flow is provided, including:

[0033] A process instance query module, used for querying the corresponding state machine process instance according to the trigger event when receiving the trigger event, wherein the state machine process instance is created and generated according to the initial business waybill, and the process instance contains the business status information of the business waybill;

[0034] A process template query module, used to obtain the current state of the waybill according to the state machine process instance, and query the process template corresponding to the trigger event; wherein the process template contains state machine rule configuration information;

[0035] The business status transfer module is used to obtain the operation list corresponding to the trigger event according to the process template, and traverse and execute each operation according to the operation list, thereby completing the state transfer of the trigger event.

[0036] According to a third aspect of the present disclosure, a service state flow orchestration processing device is provided, comprising: a processor; and a memory for storing processor executable instructions; wherein the processor is configured to execute the method described in the first aspect of the present disclosure.

[0037] The present disclosure provides a method for orchestrating and processing a business state flow, specifically comprising: when a trigger event is received, querying a state machine process instance corresponding to a waybill event request according to the trigger event, wherein the state machine process instance is created and generated according to the initial business waybill, and the process instance contains the business state information of the business waybill; obtaining the current state of the waybill according to the state machine process instance, and querying the process template corresponding to the trigger event; wherein the process template contains state machine rule configuration information; obtaining an operation list corresponding to the trigger event according to the process template, and traversing and executing each operation according to the operation list, thereby completing the state flow of the trigger event. The above-mentioned processing method completes the business state flow by using a stateful state machine and a stateless state machine in combination, so as to realize the intuitive display of the current state of the business and the processing of the business state flow without occupying too much system memory. The present disclosure uses the created state flow instance as a stateful state machine, and uses the state flow template as a stateless state machine, so that in the process of business state flow, the state flow instance only needs to call the corresponding state flow template to complete the business state flow according to the state flow template. The complexity of business system access is reduced, and the performance of the state flow system is improved.

[0038] Further features and aspects of the present disclosure will become apparent from the following detailed description of exemplary embodiments with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate exemplary embodiments, features, and aspects of the disclosure and, together with the description, serve to explain the principles of the disclosure.

[0040] Figure 1 A flowchart showing a method for orchestrating a business status flow according to an embodiment of the present disclosure is shown;

[0041] Figure 2 A schematic diagram showing a flow chart of a method for orchestrating and processing a service state flow according to another embodiment of the present disclosure;

[0042] Figure 3 A schematic block diagram of a service state flow arrangement processing device according to an embodiment of the present disclosure is shown;

[0043] Figure 4 A schematic block diagram of a service state flow orchestration processing device according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0044] Various exemplary embodiments, features and aspects of the present disclosure will be described in detail below with reference to the accompanying drawings. The same reference numerals in the accompanying drawings represent elements with the same or similar functions. Although various aspects of the embodiments are shown in the accompanying drawings, the drawings are not necessarily drawn to scale unless otherwise specified.

[0045] The word “exemplary” is used exclusively herein to mean “serving as an example, example, or illustration.” Any embodiment described herein as “exemplary” is not necessarily to be construed as preferred or advantageous over other embodiments.

[0046] In addition, in order to better illustrate the present disclosure, numerous specific details are given in the following specific embodiments. It should be understood by those skilled in the art that the present disclosure can also be implemented without certain specific details. In some examples, methods, means, components and circuits well known to those skilled in the art are not described in detail in order to highlight the subject matter of the present disclosure.

[0047] <Method Example>

[0048] Figure 1 A flowchart of a method for orchestrating and processing business state flow according to an embodiment of the present disclosure is shown. Specifically, it includes: step S1100, when a trigger event is received, querying the corresponding state machine process instance according to the trigger event, wherein the state machine process instance is created and generated according to the initial business waybill, and the process instance contains the business state information of the business waybill; step S1200, obtaining the current state of the waybill according to the state machine process instance, and querying the process template corresponding to the trigger event; wherein the process template contains state machine rule configuration information; step S1300, obtaining the operation list corresponding to the trigger event according to the state machine rule configuration information recorded in the process template, and traversing and executing each operation according to the operation list, thereby completing the state flow of the trigger event.

[0049] Therefore, the present disclosure provides a method for orchestrating and processing a business state flow, which queries the corresponding state machine process instance according to the trigger event after receiving the trigger event, and then obtains the current state of the waybill according to the state machine process example, and determines the corresponding process template, thereby performing the state flow according to the process template. Among them, since the state machine process instance is created and generated according to the initial business waybill, it contains the business state information of the business waybill, so the state machine process instance can be used as a stateful state machine, and the process template contains the state machine rule configuration information, so it can be used as a stateless state machine. As a result, the business state flow orchestration method disclosed in the present disclosure effectively realizes the combination of a stateful state machine and a stateless state machine, and realizes the business state flow through this combination. Compared with the conventional technology that can only transfer the business state through a stateful state machine or a stateless state machine alone, it solves the technical problems of a large memory usage and overly complex state flow caused by the stateful state machine, and also effectively solves the problem that the stateless state machine method cannot intuitively display the current state of the business.

[0050] Among them, it should be pointed out that when creating a state machine process instance based on the initial business waybill, it can be achieved in the following way. That is, the initialization operation is performed by calling the state machine engine initialization interface. After receiving a new waybill request, the corresponding process instance is created directly according to the waybill request. Among them, the created process instance contains the business status information of the business waybill, and may also contain the waybill number, the initial state of the waybill, and the current process instance node of the business waybill. Here, it should be pointed out that the created state machine process instance is directly saved to the database, so that for the business waybill, each time a new event is triggered, the state machine process instance can be directly called from the database, and there is no need to re-build the process instance.

[0051] At the same time, after receiving a new waybill request, it also includes the operation of obtaining the business type corresponding to the waybill through the waybill request, and then determining the corresponding state process template according to the business type.

[0052] Here, it should be pointed out that in the technical solution of the present invention, the state process template is pre-built. The state process template contains state machine rule configuration information. Here, it should be pointed out that the state machine rule configuration information refers to the relationship between: business status, events, and the operations associated with each event. In other words, the state process template records business status information, trigger events configured under each business state, and operations associated with each trigger event. Among them, there can be multiple trigger events configured under the business state, and similarly, the operations associated with each trigger event can also be multiple operations. Multiple operations are represented by an operation list.

[0053] That is, when performing business state flow orchestration through the business state flow orchestration method disclosed in the present invention, it is necessary to pre-build a state process template, store the pre-created state process template in the database, and also persistently store the created process instance in the database. This makes it possible to achieve the uniqueness of the state process template and the persistent storage of the process instance when combining the stateful state machine and the stateless state machine to perform business state flow orchestration, so that the business system does not need to pay attention to the state flow, but is fully handled by the framework layer, and at the same time solves the problem of memory occupation by the stateful state machine.

[0054] Among them, in a possible implementation manner, when constructing a state process template, it can be implemented in the following manner.

[0055] As mentioned above, the process template records the state machine rule configuration information. Here, it is necessary to explain that the state machine rule configuration information refers to the relationship between business states, events, and operations. That is, the events associated with each business state, and the operations associated with each event. By configuring the associated events for each business state and the associated operations for each event, the corresponding process template is finally generated.

[0056] For details, see Figure 2 As shown in the figure, when creating a process template, first, the business state pool, event pool, operation pool, and the binding relationship between events and operations are defined through the business system. Among them, the state pool contains multiple business state information, the event pool contains multiple triggering events, and the operation pool contains multiple operations. Here, it should be pointed out that the data in the state pool, event pool, and operation pool can be directly realized through manual definition.

[0057] After defining the above data through the business system, you can also store the defined business status pool, event pool, operation pool, binding relationship between events and operations, and business status flow rule information into the data, so as to facilitate direct calling when building process templates.

[0058] Specifically, see Figure 2 As shown, when constructing a process template, a flowchart of the corresponding business state flow will be established first according to the business type. Here, it should be pointed out that the flowchart contains all the business states required by the business type, as well as the flow order between the business states. Then, according to the business type, all the business states first included in the business type are extracted from the state pool. Then, for each business state included in the business type, the corresponding events are configured for each business state. Among them, when configuring events for the business state, the corresponding events are directly obtained from the previously pre-defined event pool. At the same time, when configuring events for each business state, the corresponding events can be flexibly selected according to the actual situation, and no specific restrictions are made here.

[0059] Next, according to the events configured for each business state, combined with the previously defined binding relationship between events and operations, the operations corresponding to each event are taken out from the operation pool, and the operations bound to each event are represented in the form of a list. This completes the construction of the process template.

[0060] Among them, what can be understood by those skilled in the art is that in the scheme of the present disclosure, there can be multiple pre-built state process templates, and each process template corresponds to a different business type. That is to say, when constructing a process template, it can be constructed based on the business type, and different business types correspond to different process templates. Therefore, when a business waybill of the same business type is generated, the process template corresponding to the business type can be directly called to realize the business state flow arrangement, and there is no need to construct a new process template.

[0061] After constructing the process template in the above manner, the process template can be stored in the database, which is convenient for the system to find and use when the business status is transferred. In one possible implementation method, when saving the constructed process template, the system can directly call the back-end saving interface to convert each state process template corresponding to the business type into json characters and store them in the database for storage, or it can first perform a legality check on the rules configured in the constructed process template and then call the back-end saving interface to convert each state process template corresponding to the business type into json characters and store them in the database for storage, without specific limitation.

[0062] Among them, when the legality of the rules configured in the constructed process template is checked, the responsibility chain mode is used for verification. Specifically, the system will first define multiple verifiers according to the node type in the flowchart configured by the process template, and define a verifier for each type of node in the process template for verification during verification. There is no limitation on the specific definition of the verifier. It usually includes defining at least one of the start node verifier, the end node verifier, the state node verifier, the process structure verifier and the process data verifier. Then the defined multiple verifiers are combined to form a link, and each point in the link corresponds to a verifier. Each verifier performs a legality check on the node of the corresponding node type in the constructed process template. When the entire link is fully checked, the corresponding process template legality check is completed, and then the verified process template will be stored in the database for use in subsequent state transfer. It should be noted that the order of each verifier that forms a link for verification can be flexibly determined without specific limitation.

[0063] Among them, when each verifier verifies the process template, it includes: the start node verifier will verify the start node of the process template, verify whether the start node's own attributes are empty and whether the start condition and end condition are correct. The end node verifier will verify the end node in the process template, verify whether the end's own attributes are empty and whether the start condition and end condition are correct. The state node verifier will verify the state node in the process template, verify whether its own attributes are correct, whether the start condition and end condition are correct, and whether the flow rules are configured. The process structure verifier will verify the designated nodes of each node connection and connection in the process template, as well as the matching of each node and connection. When the process data verifier verifies the process template, it includes whether the configured event exists in the database, whether the configured rule expression and the logical symbols and events in the expression are correct, whether the configured events are repeated, and whether some specially configured events meet the requirements of binding in the outgoing line of the specified state node. It should be noted that the above verification of the process template is based on the business flow rules configured in advance by the business system. When the rules configured in the process template are inconsistent with the configuration rules defined by the business system during the verification, the corresponding process template will be rebuilt to ensure that the system can accurately perform state transitions according to the constructed process template when the business state flows, and there will be no business state transition errors caused by problems in building the process template. The legality verification of the process template improves the correctness of the construction of the process template.

[0064] Furthermore, when creating a process instance based on the constructed process template, the process instance can be directly created according to the flowchart of the process template corresponding to the business type. Specifically, when the system receives a new waybill request, it will search for the corresponding process template according to the business type carried in the waybill request. After finding the corresponding process template, it will obtain the corresponding flowchart configured in the front end according to the process template, and directly create a process instance according to the obtained flowchart combined with the waybill request, making the creation of process instances faster and easier, and improving the performance of the system.

[0065] For further information, see Figure 2 As shown, the business system also defines the front-end page components corresponding to each business state contained in each business type and the binding relationship between the front-end page components and events. Among them, the front-end page components include: at least one configuration item among buttons, styles, icons and display texts.

[0066] By defining the front-end page components for each business status included in each business type, the system realizes the dynamic front-end page style in different scenarios and different states. The binding relationship between the defined components and events allows you to directly click the button component in the front-end page to trigger the business status flow when the business status flows. The bound event is the trigger event, which realizes the dynamic business logic. At the same time, by configuring the event binding for the defined front-end page components, the user can directly trigger the front-end page component when triggering an event. This further simplifies the event triggering operation method, making the event triggering more intuitive and simple.

[0067] At the same time, in the method disclosed in the present invention, the operation interface can also be defined through the business system, and the binding relationship between the operation interface and the post-operation logic, the mapping relationship between the trigger event and the operation interface, and the mapping relationship between the state name and the operation interface can be configured. Among them, the post-operation logic refers to what kind of post-operation needs to be performed after the business state flows to a certain state node. For example, what post-logical operations need to be performed after the waybill flows to the waiting vehicle, such as the need to send a notification or the need to modify the business database. The operation interface is a type of atomic action component that is used to define the operations performed after the trigger event and the state flow. Different states can reuse the same operation interface. For example, after the entry event is triggered, a message needs to be sent.

[0068] When the business status is transferred later, after the trigger event is triggered, the subsequent business status can be transferred directly, or it can be determined whether to perform the corresponding post-operation logic after the trigger event is triggered according to the mapping relationship between the defined trigger event and the operation interface, and then the subsequent business status transfer can be performed. When determining whether to perform the corresponding post-operation after the trigger event is triggered, if it is determined to perform the corresponding post-operation, the business system will call the defined operation import to perform the post-operation bound to the operation interface, and perform the business status conversion after completing the corresponding post-operation; if the post-operation is not performed, the subsequent business status transfer will be directly entered.

[0069] In one possible implementation, after the business state transfer is completed, the current state of the business can be returned directly, or it can be determined whether to perform corresponding post-operations according to the mapping relationship between the defined state name and the operation interface, and then the current state of the business can be returned. When determining whether to perform corresponding post-operations after the business state transition, if it is determined that the corresponding post-operations are not performed, the current state of the business is returned directly; if it is determined that the corresponding post-operations are performed, the corresponding operation interface is called, and the current state of the business is returned after the bound post-operations are completed.

[0070] After completing the front-end flow chart configuration (i.e., the definition of the front-end components and the binding of components to events) and the back-end business state and operation logic configuration (i.e., the construction of the flow template) in the above manner, the state flow arrangement method disclosed in the present invention can be executed. Figure 2 The state flow process shown performs business state flow.

[0071] Here, it should be pointed out that when executing the state process orchestration method disclosed in the present invention, the state process orchestration is performed for each waybill. Therefore, a new waybill needs to be generated first. After generating a new waybill, the framework state machine engine initialization interface is called to perform initialization operations. At the same time, the state machine framework layer waits to receive the waybill request. After receiving the waybill request, the process template is directly searched according to the business type in the waybill request.

[0072] In one possible implementation, the corresponding process template can be searched in the memory first. If the corresponding process template is found in the memory, the process template is directly used to transfer the business status. If the process template is not found in the memory, it is searched in the database and the found process template is cached in the memory. Through this operation, the next time a waybill request of the same type as the business waybill occurs, the process template can be directly called from the memory without having to repeatedly search for the process template in the database. This effectively reduces the number of interactions with the database and further improves the orchestration efficiency of the business status flow.

[0073] After obtaining the state machine process instance and process template corresponding to the current business waybill through the above steps, the flow of business status can be arranged according to the currently triggered trigger event. Among them, the trigger event is triggered after receiving the waybill request. In one possible implementation, there are two types of event triggering, one is user triggering and the other is system internal triggering. For user-triggered events, the user can trigger them through the trigger component through the pre-defined front-end component described above. Internal triggering refers to some timed triggered events customized within the system.

[0074] Furthermore, when the business status is transferred, the business status can be transferred directly according to the trigger event, or the business status can be transferred after first determining whether the trigger event performs post-operation logic. Among them, when it is determined that the trigger event does not perform post-operation logic according to the mapping relationship between the trigger event and the operation interface defined by the business system, the subsequent business status is directly transferred. When it is determined that the trigger event performs post-operation logic, the system will call the corresponding operation interface, and the business status is transferred after the post-operation is completed.

[0075] At the same time, before the business state flow is carried out, the business system will query the corresponding waybill data according to the waybill information carried in the received waybill request, and encapsulate the waybill data into the context of the state machine. After obtaining the trigger event and the state machine context, the system will call the fireEvent interface of the state machine engine, and hand over the trigger event, waybill information, the unique identifier of the event, and the context of the state machine to the state machine engine for control, and carry out the business state flow. Among them, the fireEvent interface is customized by the state machine engine, which is common knowledge in the field and will not be elaborated here.

[0076] The waybill information includes the waybill number. When the state machine engine controls the business state flow, it first determines whether the trigger event matches the current state of the waybill based on the association between the business states and events recorded in the state machine rule configuration information recorded in the acquired process template. If they match, the normal business state flow is performed. If they do not match, an exception prompt is directly thrown.

[0077] Specifically, when the business status is transferred after determining that the trigger event matches the current status of the waybill, the association between each event and operation recorded in the state machine rule configuration information recorded in the process template is also first used to find the operation list corresponding to the trigger event from the binding relationship between the event and the operation recorded in the configuration information, and then the operations in the operation list are traversed and executed according to the found operation list. Among them, if an exception occurs during the execution of the operations in the operation list, the current trigger event is marked as failed and stored in the database. At this time, the state machine engine will inform the business system that the trigger has failed, and the business system will search for the same trigger event and hand over the found trigger event to the state machine engine to re-transfer the business status. If the execution is completed normally during the execution process, the next state flow is performed at this time.

[0078] It should be noted that before the next state transition, it is necessary to determine whether the state transition conditions are met. Specifically, the current event execution is successfully recorded in redis and MySQL, and then the execution status of other events in the current state is obtained from redis, marked as executed or not executed. Then, logical operations are performed according to the transition expression configured in the configuration, and finally a Boolean value of true or false is obtained. The transition expression can be expressed by the formula:

[0079] (A1∧A2∧...∧A n )∨(B1∨B2∨...∨B m )∨(C1∧(C2∨C3)∧C4)∨...

[0080] Where ∧ represents the and operator, and ∨ represents the or operator. A, B, and C represent different types of events, and n represents n events of type A. n represents the nth A-type event, m represents m B-type events, B m It represents the mth B-type event. Brackets represent different combinations. The expression represents the combination of different types of events for logical operations and calculation of Boolean values.

[0081] After the Boolean value is calculated, if the Boolean value is false, it means that the event matching the current state has not been executed yet, and the business state flow will not be performed; if it is true, it means that all events matching the current state have been executed, and the subsequent state flow link will be entered.

[0082] After the business status transfer is completed, the system will record the status transfer log and return the current business status and configuration information of the current status node. Furthermore, after the business status transfer is completed, it will determine whether to perform the corresponding post-operation logic based on the configuration information. When it is determined not to perform the post-operation logic, the system will record the status transfer log and return the current business status and configuration information of the current status node. When performing the post-operation logic, the system will call the configured operation interface to perform the corresponding subsequent operations, then record the status transfer log, and return the current business status and configuration information of the current status node.

[0083] Furthermore, when it is determined that the triggering event does not match the current status of the waybill, the system will throw an exception prompt. At the same time, the system will judge the triggering subject of the event based on the event attributes carried by the event. When it is determined that the triggering subject of the event is an event triggered by the user (i.e., user event), it is determined to be an abnormal event, and the system will start the abnormal event processing process; when it is determined that the triggering subject of the event is an event triggered by a custom trigger within the system (i.e., internal event), the triggering event is determined to be an out-of-order event, and the system will start the out-of-order event processing process.

[0084] It should be noted that internal events are pushed by external servers or generated by scheduled tasks and message queues. Out-of-order events are events in which the current triggering node is inconsistent with the configured triggering node when the internal event is triggered. Abnormal events are events caused by user misoperation that result in inconsistency between the triggering event and the current business status node.

[0085] More specifically, when determining that the triggering event is an out-of-order event and starting the out-of-order event processing process, the following methods can be used:

[0086] First, in order to ensure that the event information of out-of-order events will not be lost in the event of a system failure, the system will first establish a special out-of-order event table and persist the complete event information of out-of-order events to the special out-of-order event table for storage. When storing out-of-order events, the stored information includes at least one of the event ID, event type, trigger time, associated business ID, request parameters (JSON format), processing status and priority of the out-of-order event.

[0087] Then mark each disordered event in the disordered event table as a "skipped" state. At the same time, in order to facilitate the subsequent processing of disordered events, the system will maintain an ordered queue of skipped events (disordered events) in memory. Among them, in order to facilitate the search and update of ordered queues, the ordered queues can be stored in a balanced tree of data structure, and the tree nodes of the balanced tree contain at least one of the event ID, priority, and timestamp information. When sorting, the priority is preferably the primary sorting key and the timestamp is the secondary sorting key. It should be noted that through the above-mentioned sorting method, the time complexity of insertion, deletion, and search operations in the balanced tree can be achieved, and all of them are O (log n). It should be noted that the skipped event is the event after the disordered event is marked.

[0088] Furthermore, when storing out-of-order events, in addition to storing the information of the out-of-order events themselves, it is also necessary to capture the context of the current state machine of the out-of-order events, including at least one of the current business state, system timestamp, and key business indicators.

[0089] Finally, the out-of-order events are evaluated for priority. The higher the priority, the higher the priority in subsequent processing. The priority of out-of-order events can be defined by the business system, including direct configuration when the business system configures events. For example, event A must be executed before event B. And the evaluation is performed based on the evaluation factors. When performing the evaluation, the business system is allowed to customize the weights of the evaluation factors, and the priority of the event is calculated using a weighted scoring model. The evaluation factors include: the importance of the event type, the time sequence of the event, and at least one of the degree of business impact. It should be noted that the use of a weighted scoring model to calculate the priority of time is common knowledge in the field and will not be elaborated on here. If the business system does not define it, the default priority policy can also be used to record the event priority according to the time when the event is accepted. There is no specific limitation.

[0090] After the above processing of the disordered events, the disordered events after the above processing will be stored in the database. At the same time, after the above processing of the disordered events, the state machine is still in the current state, and will not trigger events or transfer states, waiting for subsequent events to be triggered.

[0091] When the next trigger event is triggered, the normal business state flow can be directly performed according to the trigger event. It is also possible to first determine whether the current trigger event exists in the ordered queue maintained in the memory. If not, the normal business state transition process is performed. If it exists, the out-of-order event and the trigger event found at this time are the same event, which means that the stored out-of-order event is the correct trigger event under the current state node. The out-of-order event becomes an out-of-order event because the trigger event is inconsistent with the event that should be triggered by the current state node, and is stored in the database. At this time, the out-of-order event found in the ordered queue will be taken out of the database as the trigger event for subsequent state flow.

[0092] Specifically, when the state flow is performed using the retrieved out-of-order event as a trigger event, the state machine engine will reconstruct the state machine environment when the out-of-order event occurs based on the context information of the state machine when the out-of-order event occurs stored in the database, including at least one of request parameters, trigger nodes, and business-customized parameters.

[0093] Next, the system will start the intelligent decision engine for each disordered event to determine the target state of the business status flow. Specifically, because the same event will be combined in different flow rules as a factor of logical operation during the business status flow, the event may flow to state A or state B in the flow rule. At this time, the intelligent decision engine will make intelligent decisions based on the decision factors in response to this situation, determine the target state of the event flow, and perform state flow. For example, in the list review stage, the intelligent decision engine will determine the target state of the event according to the approval result of the list associated with the waybill, the number of approvals, and at least one of the approval contents, according to the pre-configured business rules. For example, if the list review is rejected more than 3 times, the state flows to rejected; if the approval is performed by a certain role, the state flows to a special state.

[0094] Among them, the intelligent decision factors include: the current actual business state, state machine context information, dependencies between events, and at least one of the business rules specified in advance by the business system. It should be noted that when the intelligent decision engine refers to the decision factor and determines the target state of the event flow according to the rule engine of the intelligent decision engine, the rule engine supports dynamic rule loading, allowing the business system to update the decision logic in real time.

[0095] After obtaining the target state of the business state transfer, the system will transfer the business state. The process of transferring the business state is consistent with the above-mentioned process of transferring the business state, and will not be described in detail here.

[0096] When the business status is transferred, the system will predefine the compensation operations corresponding to each operation and store them in the database. Among them, the compensation operation can be defined according to the actual situation and is not specifically limited here. When certain operations that occur during the state transfer execution process cannot be completed, the state machine engine will trigger the predefined compensation operation to ensure that the system returns to a consistent state. For example, for the event of calling the number, there is no number in the factory, but the driver shows that there is a number when he actually calls the number. Under normal circumstances, the driver's call will not pass at this time, but because of the time difference, the state is not synchronized. For this situation, the business system will define the compensation logic in advance to make the call pass.

[0097] During the business status flow, if an event fails to be triggered all the time, the system will mark the event as a dead letter event, indicating that the state machine cannot resolve this type of event and manual intervention is required.

[0098] In one possible implementation, when the state machine is triggered by a correct event (the triggering event is a legal event configured for the current state), the state machine will flow to the next state normally. Because the time when the triggering event is triggered and the time when the event is received are inconsistent, a time difference occurs and the business data of the business changes during this period. For the above scenario, it is essentially an out-of-order event. Because the triggering time and the event receiving time are inconsistent, the business data may change during this period and cause the state machine context information to change, so that the triggering event and the state machine context do not match when the state flow is performed, resulting in abnormal state flow. Therefore, for the above scenario, it is essentially an out-of-order scenario, and the processing flow of out-of-order events will also be initiated. The specific processing process is consistent with the above-mentioned out-of-order event processing process, and no further elaboration will be given here.

[0099] Based on the above processing of out-of-order events, it is ensured that events are not lost and the triggering events can be triggered correctly, and the problem of abnormal business status flow caused by business data changes when the event acceptance timing and event triggering timing are inconsistent is solved.

[0100] When determining that the trigger event is an abnormal event and starting the abnormal event processing flow, the following methods can be used:

[0101] That is, when handling abnormal events, the system will configure virtual events to return the state machine to a normal state.

[0102] Specifically, first, the system will pre-embed points in the wrong link to obtain each abnormal event, and define the corresponding virtual event according to each abnormal event to obtain each virtual event. At the same time, the binding relationship between the virtual event and the abnormal event and the target state of the virtual event flow are configured and stored in the database. Among them, the abnormal event refers to the event caused by the user's misoperation that the trigger event and the current state node are inconsistent. The virtual event refers to the corresponding trigger event when the abnormal event is processed. The virtual event can be flexibly configured according to the actual situation, and no specific limitation is made here. Then, when processing the abnormal event, the corresponding virtual event is first found from the database according to the binding relationship between the configured virtual event and the abnormal event, and the found virtual event is handed over to the state machine engine as a trigger event. The state machine engine will first determine whether the trigger event is a configured virtual event according to the configured virtual event. If it is not a configured virtual event, the corresponding virtual event will be re-searched in the database according to the binding relationship between the configured abnormal event and the virtual event; if it is determined to be a virtual event, the state flow representing the state flow to the specified target state is legal, and a virtual state transition sequence can be created for business state flow. Among them, the virtual state transition sequence can be understood as a dynamic state transition template. That is to say, when creating a virtual state transition sequence, a state transition process template will be constructed based on the configuration information pre-defined by the business system, which is the same as the state process template. When performing a state transition, the corresponding process instance will complete the state flow according to the created virtual state transition sequence.

[0103] When the state is transferred according to the created virtual state transition sequence, the virtual state transition sequence will transfer the state of the current virtual event to the specified target state. Because the business system has configured the events corresponding to the state in advance and defined the binding relationship between events and operations, the operation list of the virtual events defined by the business system will be called and traversed when the business state is transferred according to the virtual state transition sequence. After the execution is completed, the event is marked, and then logical operations are performed to determine whether the transfer conditions are met. If the state transfer is met, the state machine can transfer to the specified target state. The specific state transfer method is consistent with the business state transfer method mentioned above, so I will not go into details here.

[0104] By configuring virtual events, the business status under abnormal circumstances can be corrected back to the correct state, ensuring the consistency of business data.

[0105] Further, see Figure 2As shown in the figure, when the system is converting business status, it is often necessary to query the business status and business data at any time. When querying the current business status, the business system will query the business status based on the business information (waybill number, i.e. Figure 2 The business key shown in the figure calls the query interface of the state machine engine to obtain the current state of the business and the corresponding front-end configuration information under the current state, and returns the current state of the business and the corresponding front-end configuration information under the current state to the system front-end. The system front-end renders the page according to the returned configuration information, and finally obtains the current state of the business and related business data. Moreover, if there is a temporary need to adjust the display of a certain state under a certain business type, it only needs to be modified in the configuration information defined by the business system, without modifying the code or releasing the version, reducing the development and operation and maintenance costs.

[0106] Finally, after the business state flows to the end node of the corresponding process template, the corresponding state process instance ends its life cycle and is no longer called. If the current state instance is called later, the system will mark it as an illegal call.

[0107] Therefore, the present disclosure provides a method for orchestrating and processing a business state flow, which specifically includes: when a trigger event is received, querying a state machine process instance corresponding to a waybill event request according to the trigger event, wherein the state machine process instance is created and generated according to the initial business waybill, and the process instance contains the business state information of the business waybill; obtaining the current state of the waybill according to the state machine process instance, and querying the process template corresponding to the trigger event; wherein the process template contains state machine rule configuration information; obtaining an operation list corresponding to the trigger event according to the process template, and traversing and executing each operation according to the operation list, thereby completing the state flow of the trigger event. The above-mentioned processing method completes the business state flow by using a stateful state machine and a stateless state machine in combination, so that the current state of the business can be intuitively displayed without occupying too much system memory to process the business state flow. The present disclosure uses the created state flow instance as a stateful state machine, and the state flow template as a stateless state machine, so that in the process of business state flow, the state flow instance only needs to call the corresponding state flow template to complete the business state flow according to the state flow template. The complexity of business system access is reduced, and the performance of the state flow system is improved.

[0108] <Device Example>

[0109] Figure 3 FIG. 1 is a schematic block diagram of a service state flow arrangement processing device according to an embodiment of the present disclosure. Figure 3As shown, the device 100 includes: a process instance query module 110, a process template query module 120, and a business status transfer module 130. The process instance query module 110 is used to query the corresponding state machine process instance according to the trigger event when receiving the trigger event, wherein the state machine process instance is created and generated according to the initial business waybill, and the process instance contains the business status information of the business waybill; the process template query module 120 is used to obtain the current state of the waybill according to the state machine process instance, and query the process template corresponding to the trigger event; wherein the process template contains the state machine rule configuration information; the business status transfer module 130 is used to obtain the operation list corresponding to the trigger event according to the process template, and traverse and execute each operation according to the operation list, thereby completing the state transfer of the trigger event.

[0110] <Equipment Embodiment>

[0111] Figure 4 FIG. 1 is a schematic block diagram of a service state flow arrangement processing device according to an embodiment of the present disclosure. Figure 4 As shown, the service state flow arrangement processing device 200 includes: a processor 210 and a memory 220 for storing executable instructions of the processor 210. The processor 210 is configured to implement any of the above-mentioned service state flow arrangement processing methods when executing the executable instructions.

[0112] Here, it should be noted that the number of processors 210 may be one or more. At the same time, the service state flow orchestration processing device 200 of the embodiment of the present disclosure may also include an input device 230 and an output device 240. The processor 210, the memory 220, the input device 230, and the output device 240 may be connected via a bus or in other ways, which are not specifically limited here.

[0113] The memory 220 is a computer-readable storage medium that can be used to store software programs, computer executable programs, and various modules, such as the program or module corresponding to the service state flow orchestration processing method of the embodiment of the present disclosure. The processor 210 executes various functional applications and data processing of the service state flow orchestration processing device 200 by running the software program or module stored in the memory 220.

[0114] The input device 230 may be used to receive input numbers or signals. The signals may be key signals related to user settings and function control of the device / terminal / server. The output device 240 may include display devices such as display screens.

[0115] The embodiments of the present disclosure have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.

Claims

1. A method for processing business status flow, characterized in that: include: When a trigger event is received, a corresponding state machine process instance is queried according to the trigger event, wherein the state machine process instance is created and generated according to the initial business waybill, and the process instance contains the business status information of the business waybill; Obtain the current state of the waybill according to the state machine process instance, and query the process template corresponding to the trigger event; wherein the process template contains state machine rule configuration information; The operation list corresponding to the trigger event is obtained according to the state machine rule configuration information recorded in the process template, and each operation is traversed and executed according to the operation list, thereby completing the state flow of the trigger event.

2. The method according to claim 1, characterized in that: When querying the corresponding state machine process instance according to the trigger event, it includes: Extracting waybill information from the trigger event; The state machine process instance is obtained according to the waybill information query.

3. The method according to claim 1, characterized in that After obtaining the current state of the waybill according to the state machine process instance and querying the process template corresponding to the trigger event, it also includes: Determine whether the trigger event matches the current status of the waybill; When it is determined that the trigger event matches the current state of the waybill, a step is performed to obtain an operation list corresponding to the trigger event according to the state machine rule configuration information recorded in the process template.

4. The method according to claim 1, characterized in that After obtaining the operation list corresponding to the trigger event according to the process template and traversing and executing each operation according to the operation list, the process further includes: Determine whether the state transition conditions are met; When it is determined that the state transition condition is met, the next trigger event is triggered.

5. The method according to claim 4, characterized in that When judging whether the state transition conditions are met, it includes: Record the successful execution of the current event in redis and mysql, then obtain the execution status of other events in the current state from redis, and mark the execution status of other events; Then perform logical operations based on the configured flow expression to obtain a Boolean value; When the Boolean value is true, it indicates that the state transition condition is met.

6. The method according to claim 3, characterized in that When judging whether the trigger event matches the current state of the waybill, it also includes: When it is determined that the triggering event does not match the current state of the waybill, determining the triggering event; When it is determined that the triggering event is an out-of-order event, an operation of starting an out-of-order event processing flow; Among them, the out-of-order event is an event in which the current trigger node in the events configured for the business waybill is inconsistent with the configured trigger node.

7. The method according to claim 6, characterized in that The out-of-order event processing process includes: Persisting the out-of-order events in a dedicated out-of-order event table; Then, the out-of-order events in the out-of-order event table are marked as "skipped" state, and an ordered queue of skipped events is maintained in memory; Capturing the context of the current state machine of the out-of-order event according to the out-of-order event; Priority evaluation is performed on the out-of-order events according to evaluation factors, wherein the evaluation factors include: at least one of the importance of the event type, the time sequence of the event occurrence, and the business impact degree.

8. The method according to claim 6, characterized in that When the trigger event is determined to be an abnormal event, issuing an abnormal prompt; The abnormal event is an event triggered by a user's incorrect operation.

9. A service status flow arrangement processing device, characterized in that: include: A process instance query module, used for querying the corresponding state machine process instance according to the trigger event when receiving the trigger event, wherein the state machine process instance is created and generated according to the initial business waybill, and the process instance contains the business status information of the business waybill; A process template query module, used to obtain the current state of the waybill according to the state machine process instance, and query the process template corresponding to the trigger event; wherein the process template contains state machine rule configuration information; The business status transfer module is used to obtain the operation list corresponding to the trigger event according to the process template, and traverse and execute each operation according to the operation list, thereby completing the state transfer of the trigger event.

10. A service status flow arrangement processing device, characterized in that: include: processor; a memory for storing processor-executable instructions; Wherein, the processor is configured to implement the method described in any one of claims 1 to 8 when executing the executable instructions.

Citation Information

Patent Citations

  • State machine persistence method and state machine persistence system

    CN111142975A

  • State machine operation method and device, server, system and storage medium

    CN111414242A

  • Service state circulation maintenance method and device and electronic equipment

    CN112907198A

  • Service processing method and system based on state machine

    CN115375134A

  • Service state updating method and device

    CN116088891A