An intelligent decision-making method based on a rule engine and a finite state machine
By employing an intelligent decision-making method based on rule engines and finite state machines, the automation and intelligence of business state machines are achieved, solving the problem of frequent code modifications in traditional systems, improving system maintainability and portability, and enhancing data security.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- JIANGSU JARI GROUP CO LTD
- Filing Date
- 2024-09-11
- Publication Date
- 2026-07-14
AI Technical Summary
Traditional business decision-making systems require code modifications when business rules and logic change, resulting in a large maintenance workload. Furthermore, it is difficult to separate business personnel from coders. Existing open-source workflow engines have limited functionality, making it difficult to meet the needs of multi-level state machines, and they also have poor compatibility with domestic operating systems.
An intelligent decision-making method based on a rule engine and finite state machine is adopted. Through steps such as metadata management, state node and rule setting, and state space transition setting, the automatic operation of the business state machine is realized. The rule data is retrieved by the QT high-performance cross-platform development framework and in-memory database, thereby realizing the separation of business logic and code.
It improves the system's maintainability, testability, portability, and data security, reduces the workload of code modification, and adapts to complex and ever-changing business scenarios.
Smart Images

Figure CN119292660B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent decision-making technology, and in particular to an intelligent decision-making method based on a rule engine and a finite state machine. Background Technology
[0002] Currently, complex business decision-making systems inevitably experience changes in business rules and logic during operation. Traditional business state flow implementations involve writing business rules and logic into the code. When a rule or state transition relationship changes, the corresponding code must be modified and recompiled, resulting in a significant maintenance workload and testing difficulty. Furthermore, this approach fails to effectively separate business personnel from coders. While traditional business state flow implementation methods have been replaced by some automated workflow engines, current mature open-source workflow engines have limited functionality. For example, they struggle to meet the needs of multi-layered state machine business processes, and their poor compatibility with the domestic market requires substantial additional development work. On the other hand, to ensure the software is more compatible with domestic operating systems such as Kylin and Red Flag Linux, the QT high-performance cross-platform development framework, combining finite state machines and rule engines, has become a new solution. Summary of the Invention
[0003] The technical problem to be solved by the present invention is to address the shortcomings of the prior art by providing an intelligent decision-making method based on rule engines and finite state machines that can automate and intelligentize business decisions in complex systems. When business rules change, the business state machine in the application system can operate automatically without modifying the business logic code, and the method can improve the portability, reliability, and data security of the software.
[0004] The technical problem to be solved by this invention is achieved through the following technical solution. This invention is an intelligent decision-making method based on a rule engine and a finite state machine, and the steps of this method are as follows:
[0005] Step 1: Metadata management, which involves defining and maintaining state machine categories and the parameters and behaviors used by the rules and conditions under the state machines.
[0006] Step 1: Parameter management, which involves defining and maintaining the parameters or attributes used in the rules and conditions of the state;
[0007] Step 2: State machine classification and management, that is, defining and maintaining the state machines contained in the system;
[0008] Step 3: Behavior management, which involves defining and maintaining the actions performed when the rules are met;
[0009] Step Two: State Node and Rule Setting Management, which involves defining and maintaining the state nodes under the state machine, as well as the required rule conditions and actions to be executed when reaching a state node.
[0010] First, select a state machine and enter the state name;
[0011] The second step is to define the rule condition expression, select the condition parameters from the metadata table, define the corresponding thresholds, and select the "AND" and "OR" relationships between the compound conditions;
[0012] The third step is to define the processing behavior of the rule, select the behavior to be executed that satisfies the rule from the atomic behavior table, and set the order of priority of the execution behavior;
[0013] Fourth step: Repeat steps one through four until all states of the state machine are defined.
[0014] Step 3: State space transition settings, that is, setting the transition relationships between the states within a single state machine:
[0015] The first step is to select a specific state machine;
[0016] The second step is to select the states involved in the state machine;
[0017] The third step is to set the start status;
[0018] The fourth step is to set the sub-states of each state sequentially, starting from the start state, until the last state is the end state or contains a state transition behavior.
[0019] Step 4: Setting up external state space transitions, i.e., when the system contains multiple state machines, maintaining the transition relationships between the multiple state machines:
[0020] The first step is to select a specific state machine;
[0021] The second step is to select the state machine that the state machine may transition to from the state machine table.
[0022] The third step is to define the rule condition expression, select the condition parameters from the metadata table, define the corresponding thresholds, select the "AND" and "OR" relationships between the compound conditions, and save the combined condition expression to the database.
[0023] Fourth, repeat steps two and three until all possible state machine transitions have been defined;
[0024] Fifth, if multiple state machines have the same transition condition, set the transition priority;
[0025] Step 6: Repeat steps 1 through 5 until all external transitions of the state machines are set up.
[0026] Step 5: Obtain rule and state machine related data and store them in the system cache:
[0027] The first step is parameter initialization, which involves retrieving all parameters and their corresponding default values from the database's metadata table and storing them in the system cache;
[0028] The second step is to create an in-memory database and copy the state node table, internal state space transition table, and external state space transition table from the entity database to the in-memory database.
[0029] The third step is to create a matching criteria table in the in-memory database and add a record.
[0030] Step Six: Obtain the business execution or workflow plan, parse the plan, and store the parsing results in the system cache;
[0031] Step 7: Real-time acquisition of rule input data, that is, real-time acquisition of sensor data, externally input data, or data processed internally, and assigning them to the corresponding rule condition parameters;
[0032] Step 8: Rule matching, substitute the parameter values into the rule condition expression for matching;
[0033] Step 9: State transition processing within the state machine. Determine if the current state is the start state. If it is the start state, first search for the start state node in the state space transition table to obtain the current state node number, the next state node number, and the state number. Then set the start state flag to no. Next, perform rule matching based on the state number. If it is not the start state, parse the state number that may be the current state to transition to, and iterate through the state space transition table to search for the state node and rule number. Then, call the state transition rule matching method to perform rule matching based on the state number.
[0034] Step 10: Execute the corresponding actions, resolve the corresponding action method names, and execute the corresponding action methods in sequence;
[0035] Step 11: If the action method in Step 10 contains a state external transition method, then the state space external transition method is called;
[0036] Step 12: External state space transition processing:
[0037] The first step is to obtain the state machines that the current state machine may transition to from the external transition table of the state space, and sort them by priority.
[0038] The second step is to retrieve the information of the highest priority state machine to be transitioned to, including its condition expression and the name of the state machine to be transitioned to;
[0039] The third step is to call the state transition rule matching method to transition the current state machine to the starting state of another state machine;
[0040] Step 13: Create and set a timer to periodically trigger the internal state transition methods of the state machine.
[0041] The technical problem to be solved by this invention can also be further achieved through the following technical solutions. For the intelligent decision-making method based on rule engine and finite state machine described above, in steps two and four, the defined rule condition expressions are mainly concatenated into atomic condition expressions through user semantic mapping and escaping; if it is a compound condition expression, it is then combined according to the set logical relationship; the concatenated condition expressions are respectively escaped into rule condition expressions that are understood by the user and rule condition expressions that conform to the condition syntax of WHERE in SQL language, so as to meet the needs of business personnel to define and maintain rules, and coders to directly call the defined rules, thus effectively separating business personnel and coders.
[0042] The technical problem to be solved by the present invention can also be further achieved through the following technical solutions. For the intelligent decision-making method based on rule engine and finite state machine described above, in step five, an in-memory database is created. First, an SQLite in-memory database is created. Then, the state node table, the internal state space transition table, and the external state space transition table in the entity database are copied to the in-memory database as the master. Then, the state node table, the internal state space transition table, and the external state space transition table model QSqlTableModel are created respectively and bound to the corresponding in-memory database.
[0043] QSqlTableModel is a read / write model control based on the QTSQL class for manipulating database tables. It can retrieve the corresponding records of the data table according to the set conditions. Finally, a matching condition table is created in the memory data, and a record is added for use in matching rule condition expressions.
[0044] The technical problem to be solved by this invention can also be further achieved through the following technical solutions. For the intelligent decision-making method based on rule engine and finite state machine described above, the internal state transition rule condition matching in step nine includes the following steps:
[0045] The first step is to find the corresponding rule expression in the state node database table model by state node number and process the behavior expression.
[0046] The second step is to retrieve the condition parameter values from the system cache and input them into the rule expression mentioned above.
[0047] The third step is to use the parameter values as the conditions for setFilter in the matching condition database model.
[0048] The fourth step is to perform a query operation on the matching condition database table model. If there is no query result record, it means that the current rule condition of the state does not meet the requirement; if there is a query result record, it means that the current rule condition of the state meets the requirement. Obtain the next state node sequence number and assign it to the current state node variable, then obtain the action method name of the rule and call the corresponding execution action method. In this way, the transition between state nodes can be realized.
[0049] The technical problem to be solved by this invention can also be further achieved through the following technical solutions. For the intelligent decision-making method based on rule engine and finite state machine described above, the state transition rule matching method in step twelf includes the following steps:
[0050] Step 1: Obtain the rule expression;
[0051] Step 2: Substitute the parameter values from the conditions, set the WHERE condition to the rule expression that has been replaced with the condition parameter values, and execute the search to match the condition table;
[0052] Step 3: Determine if there is a query record. If there is a query result record, it means that the rule condition is met. Modify the current state machine parameter value to the state machine to be transferred, and set the start state flag to "Yes". At this point, the previously running state machine can be transferred to the transferred state machine for operation. If there is no query result record, it means that the rule condition is not met. The current state machine is still in the previous state machine waiting for the condition to be met before it is transferred out.
[0053] Compared with existing technologies, this invention utilizes a combination of rule engines and finite state machines. During the state transition process of the finite state machine in the system, the rule engine matches predefined transition conditions and executes corresponding actions or behaviors, thereby automating and intelligentizing business decisions in complex systems. Secondly, the implementation of this invention can improve the maintainability and testability of system code. For business scenarios with complex and volatile processes, only the transition conditions and relationships between states and the corresponding actions need to be adjusted, without modifying the business logic code, to achieve automatic operation of the business state machine in the system. At the same time, the use of the QT high-performance cross-platform development framework and the method of accessing rule data from an in-memory database can further improve the portability, operational reliability, and data security of the software. Attached Figure Description
[0054] Figure 1 This is an application flowchart of the present invention;
[0055] Figure 2 This is a flowchart illustrating the state transition implementation of the present invention. Detailed Implementation
[0056] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0057] Reference Figure 1-2 A smart decision-making method based on rule engine and finite state machine. Based on the combination of rule engine and finite state machine technology, it adopts the QT high-performance cross-platform development framework and the safe and reliable way of retrieving rule data from memory database. During the state transition process of the system finite state machine, the rule engine matches the predefined transition conditions and executes the corresponding actions or behaviors, thereby realizing the automation and intelligence of complex system business.
[0058] Among them, a finite state machine is a behavioral modeling tool for objects. It is applicable to systems with a finite number of states, a clear lifecycle, and a finite number of choices in each state. The next state is determined based on the current state and input of the system. A rule engine is a software system used to execute rules. These rules are usually represented as a set of conditions and actions. When the conditions are met, the rule engine will execute the corresponding actions.
[0059] By combining finite state machines and rule engines, the rule engine matches predefined transition conditions and executes corresponding actions or behaviors during the state transitions of the finite state machine in the system. This enables the automation and intelligence of complex system business processes. The implementation of this technology can improve the maintainability and testability of system code. For business scenarios with complex and volatile processes, only the transition conditions and relationships between states and the corresponding actions need to be adjusted. Without modifying the business logic code, the automatic operation of the business state machine in the system can be achieved.
[0060] The main steps of this method are as follows:
[0061] Step 1: Metadata management, defining and maintaining state machine categories and the parameters and behaviors used by the rules and conditions under the state machine:
[0062] Step 1: Parameter management, which involves defining and maintaining the parameters or attributes used in the rules and conditions of the state;
[0063] Step 2: State machine classification and management, that is, defining and maintaining the state machines contained in the system;
[0064] Step 3: Behavior management, which involves defining and maintaining the actions performed when the rules are met;
[0065] Step Two: State Node and Rule Setting Management, which involves defining and maintaining the state nodes under the state machine, as well as the required rule conditions and actions to be executed when reaching a state node.
[0066] First, select a state machine and enter the state name;
[0067] The second step is to define the rule condition expression, select the condition parameters from the metadata table, define the corresponding thresholds, and select the "AND" and "OR" relationships between the compound conditions;
[0068] The third step is to define the processing behavior of the rule, select the behavior to be executed that satisfies the rule from the atomic behavior table, and set the order of priority of the execution behavior;
[0069] Fourth step: Repeat steps one through four until all states of the state machine are defined.
[0070] Step 3: State space transition settings, that is, setting the transition relationships between the states within a single state machine:
[0071] The first step is to select a specific state machine;
[0072] The second step is to select the states involved in the state machine;
[0073] The third step is to set the start status;
[0074] The fourth step is to set the sub-states of each state sequentially, starting from the start state, until the last state is the end state or contains a state transition behavior.
[0075] Step 4: Setting up external state space transitions, i.e., when the system contains multiple state machines, maintaining the transition relationships between the multiple state machines:
[0076] The first step is to select a specific state machine;
[0077] The second step is to select the state machine that the state machine may transition to from the state machine table.
[0078] The third step is to define the rule condition expression, select the condition parameters from the metadata table, define the corresponding thresholds, select the "AND" and "OR" relationships between the compound conditions, and save the combined condition expression to the database.
[0079] Fourth, repeat steps two and three until all possible state machine transitions have been defined;
[0080] Fifth, if multiple state machines have the same transition condition, set the transition priority;
[0081] Step 6: Repeat steps 1 through 5 until all external transitions of the state machines are set up.
[0082] Step 5: Obtain rule and state machine related data and store them in the system cache:
[0083] The first step is parameter initialization, which involves retrieving all parameters and their corresponding default values from the database's metadata table and storing them in the system cache;
[0084] The second step is to create an in-memory database and copy the state node table, internal state space transition table, and external state space transition table from the entity database to the in-memory database.
[0085] The third step is to create a matching criteria table in the in-memory database and add a record.
[0086] Step Six: Obtain the business execution or workflow plan, parse the plan, and store the parsing results in the system cache;
[0087] Step 7: Real-time acquisition of rule input data, that is, real-time acquisition of sensor data, externally input data, or data processed internally, and assigning them to the corresponding rule condition parameters;
[0088] Step 8: Rule matching, substitute the parameter values into the rule condition expression for matching;
[0089] Step Nine: Internal state transition processing of the state machine. Determine if the current state is the start state. If it is, first search the internal transition table of the state machine for the start state node, obtain the current state node number, the next state node number, and the state number, then set the start state flag to no, and then perform rule matching based on the state number. If it is not the start state, parse the state number that may be the current state to transition to, iterate through the internal transition table of the state space to find the state node and rule number, and then call the state transition rule matching method to perform rule matching based on the state number.
[0090] Step 10: Execute the corresponding actions, resolve the corresponding action method names, and execute the corresponding action methods in sequence;
[0091] Step 11: If the action method in Step 10 contains a state external transition method, then the state space external transition method is called;
[0092] Step 12: External state space transition processing:
[0093] The first step is to obtain the state machines that the current state machine may transition to from the external transition table of the state space, and sort them by priority.
[0094] The second step is to retrieve the information of the highest priority state machine to be transitioned to, including its condition expression and the name of the state machine to be transitioned to;
[0095] The third step is to call the state transition rule matching method to transition the current state machine to the starting state of another state machine;
[0096] Step Fourteen: Create and set a timer to periodically trigger the internal state transition methods of the state machine.
[0097] In steps two and four, the defined rule condition expressions are mainly concatenated into atomic condition expressions through user-defined word meaning mapping and escaping. If it is a compound condition expression, it is further combined according to the set logical relationship. The concatenated condition expressions are respectively escaped into rule condition expressions that users can understand and rule condition expressions that conform to the condition syntax of the WHERE clause in SQL language. This satisfies the needs of business personnel to define and maintain rules, and coders to directly call the defined rules, thus achieving effective separation between business personnel and coders.
[0098] Step five involves creating an in-memory database. First, an SQLite in-memory database is created. Then, the state node table, internal state space transition table, and external state space transition table from the entity database are copied to this in-memory database. Next, QSqlTableModels are created for each of these tables and bound to the corresponding in-memory database. QSqlTableModel is a read / write model control based on the QTSQL class, allowing the retrieval of records based on set conditions. Finally, a matching condition table is created in the in-memory database, and a record is added for matching rule expressions. This allows the system to operate completely independently of the entity database, ensuring the reliability and security of rule data retrieval and significantly improving data retrieval speed and overall system performance, especially with large datasets.
[0099] Step nine, internal state transition rule condition matching, includes the following steps:
[0100] The first step is to find the corresponding rule expression in the state node database table model by state node number and process the behavior expression.
[0101] The second step is to retrieve the condition parameter values from the system cache and input them into the rule expression mentioned above.
[0102] The third step is to use the parameter values as the conditions for setFilter in the matching condition database model.
[0103] The fourth step involves executing a query operation on the matching condition database table model. If no query result is found, it means that the current rule condition for that state is not met; if a query result is found, it means that the current rule condition for that state is met. The next state node sequence number is then obtained and assigned to the current state node variable. Next, the action method name for that rule is obtained, and the corresponding action method is called. This process enables the transition between state nodes.
[0104] The state transition rule matching method in step twelve includes the following steps:
[0105] Step 1: Obtain the rule expression;
[0106] Step 2: Substitute the parameter values from the conditions, set the WHERE condition to the rule expression that has been replaced with the condition parameter values, and execute the search to match the condition table;
[0107] Step 3: Determine if there is a query record. If there is a query result record, it means that the rule condition is met. Modify the current state machine parameter value to the state machine to be transferred, and set the start state flag to "Yes". At this point, the previously running state machine can be transferred to the transferred state machine for operation. If there is no query result record, it means that the rule condition is not met. The current state machine is still in the previous state machine waiting for the condition to be met before it is transferred out.
[0108] Specifically:
[0109] like Figure 1 As shown, the present invention preferably provides an intelligent decision-making method based on a rule engine and a finite state machine. When the application system starts, the parameters are first initialized, an in-memory database is established to obtain rule data and store it in the in-memory database, the preset scheme to be executed by the system is obtained, parsed and stored in the system cache, and an internal state transition processing timer is started. Then, the data acquisition thread is started to receive real-time data and process it accordingly. Finally, the corresponding parameters of the rule expression are used to perform rule matching to drive state transition, so that the state machine of the application system is in an automatic operation state.
[0110] like Figure 2 The diagram shows the state transition method flow. The method for driving business state transitions is the key technical expenditure of this invention, and its specific implementation is as follows:
[0111] Determine if the state category has changed; if it has changed, update the state category.
[0112] Determine if the current state is the start state. If it is the start state, first look up the start state node of the state machine in the transition table inside the state space, obtain the current state node number, the next state node number and the state number, then set the start state flag to no, and then perform rule matching based on the state number.
[0113] If it is not the starting state, then parse the state number that may be the current state to be transitioned to, search for the state node and rule number in the internal transition table of the state space in a loop, and then call the state transition rule matching method to perform rule matching based on the state number;
[0114] The parameter value is substituted into the rule condition expression for matching. If the condition expression is true, it means that the condition is met, the state is updated, and the state transition process is completed.
[0115] Compared with existing decision-making methods, the beneficial effect of this invention is that it separates business decision-making logic from business code. When business rules change during the application of the business decision-making system, the business logic can be changed as needed simply by modifying the relationship between the business rules and the business state, without developers having to modify the code and perform a series of tasks such as compilation, testing, and deployment. This greatly improves the maintainability, scalability, and testability of the software system. At the same time, the software adopts the high-performance cross-platform development framework QT and the method of accessing rule data in memory database, which can further improve the portability, operational reliability, and data security of the software.
Claims
1. An intelligent decision-making method based on a rule engine and a finite state machine, characterized in that: The steps of this method are as follows: Step 1: Metadata management, which involves defining and maintaining state machine categories and the parameters and behaviors used by the rules and conditions under the state machines. Step 1: Parameter management, which involves defining and maintaining the parameters or attributes used in the rules and conditions of the state; Step 2: State machine classification and management, that is, defining and maintaining the state machines contained in the system; Step 3: Behavior management, which involves defining and maintaining the actions performed when the rules are met; Step Two: State Node and Rule Setting Management, which involves defining and maintaining the state nodes under the state machine, as well as the required rule conditions and actions to be executed when reaching a state node. First, select a state machine and enter the state name; The second step is to define the rule condition expression, select the condition parameters from the metadata table, define the corresponding thresholds, and select the "AND" and "OR" relationships between the compound conditions; The third step is to define the processing behavior of the rule, select the behavior to be executed that satisfies the rule from the atomic behavior table, and set the order of priority of the execution behavior; Fourth step: Repeat steps one through four until all states of the state machine are defined. Step 3: State space transition settings, that is, setting the transition relationships between the states within a single state machine: The first step is to select a specific state machine; The second step is to select the states involved in the state machine; The third step is to set the start status; The fourth step is to set the sub-states of each state sequentially, starting from the start state, until the last state is the end state or contains a state transition behavior. Step 4: Setting up external state space transitions, i.e., when the system contains multiple state machines, maintaining the transition relationships between the multiple state machines: The first step is to select a specific state machine; The second step is to select the state machine that the state machine may transition to from the state machine table. The third step is to define the rule condition expression, select the condition parameters from the metadata table, define the corresponding thresholds, select the "AND" and "OR" relationships between the compound conditions, and save the combined condition expression to the database. Fourth, repeat steps two and three until all possible state machine transitions have been defined; Fifth, if multiple state machines have the same transition condition, set the transition priority; Step 6: Repeat steps 1 through 5 until all external transitions of the state machines are set up. Step 5: Obtain rule and state machine related data and store them in the system cache: The first step is parameter initialization, which involves retrieving all parameters and their corresponding default values from the database's metadata table and storing them in the system cache; The second step is to create an in-memory database and copy the state node table, internal state space transition table, and external state space transition table from the entity database to the in-memory database. The third step is to create a matching criteria table in the in-memory database and add a record. Step Six: Obtain the business execution or workflow plan, parse the plan, and store the parsing results in the system cache; Step 7: Real-time acquisition of rule input data, that is, real-time acquisition of sensor data, externally input data, or data processed internally, and assigning them to the corresponding rule condition parameters; Step 8: Rule matching, substitute the parameter values into the rule condition expression for matching; Step 9: State transition processing within the state machine. Determine if the current state is the start state. If it is the start state, first search for the start state node in the state space transition table to obtain the current state node number, the next state node number, and the state number. Then set the start state flag to no. Next, perform rule matching based on the state number. If it is not the start state, parse the state number that may be the current state to transition to, and iterate through the state space transition table to search for the state node and rule number. Then, call the state transition rule matching method to perform rule matching based on the state number. Step 10: Execute the corresponding actions, resolve the corresponding action method names, and execute the corresponding action methods in sequence; Step 11: If the action method in Step 10 contains a state external transition method, then the state space external transition method is called; Step 12: External state space transition processing: The first step is to obtain the state machines that the current state machine may transition to from the external transition table of the state space, and sort them by priority. The second step is to retrieve the information of the highest priority state machine to be transitioned to, including its condition expression and the name of the state machine to be transitioned to; The third step is to call the state transition rule matching method to transition the current state machine to the starting state of another state machine; Step 13: Create and set a timer to periodically trigger the internal state transition methods of the state machine.
2. The intelligent decision-making method based on rule engine and finite state machine according to claim 1, characterized in that: In steps two and four, the defined rule condition expressions are mainly concatenated into atomic condition expressions through user-defined semantic mapping and escaping. If it is a compound condition expression, it is further combined according to the set logical relationship. The concatenated condition expressions are respectively escaped into rule condition expressions that users can understand and rule condition expressions that conform to the condition syntax of the WHERE clause in SQL language, so as to meet the needs of business personnel to define and maintain rules, and coders to directly call the defined rules, thus effectively separating business personnel and coders.
3. The intelligent decision-making method based on rule engine and finite state machine according to claim 1, characterized in that: In step five, an in-memory database is created. First, an SQLite in-memory database is created. Then, the state node table, the internal state space transition table, and the external state space transition table from the entity database are copied to this in-memory database. Then, create the state node table, the internal state space transition table, and the external state space transition table model QSqlTableModel respectively, and bind them to the corresponding in-memory database; QSqlTableModel is a read / write model control based on the QTSQL class for manipulating database tables. It can retrieve the corresponding records of the data table according to the set conditions. Finally, a matching condition table is created in the memory data, and a record is added for use in matching rule condition expressions.
4. The intelligent decision-making method based on rule engine and finite state machine according to claim 1, characterized in that: Step nine, internal state transition rule condition matching, includes the following steps: The first step is to find the corresponding rule expression in the state node database table model by state node number and process the behavior expression. The second step is to retrieve the condition parameter values from the system cache and input them into the rule expression mentioned above. The third step is to use the parameter values as the conditions for setFilter in the matching condition database model. The fourth step is to perform a query operation on the matching condition database table model. If there is no query result record, it means that the current rule condition of the state does not meet the requirement; if there is a query result record, it means that the current rule condition of the state meets the requirement. Obtain the next state node sequence number and assign it to the current state node variable, then obtain the action method name of the rule and call the corresponding execution action method. In this way, the transition between state nodes can be realized.
5. The intelligent decision-making method based on rule engine and finite state machine according to claim 1, characterized in that: The state transition rule matching method in step twelve includes the following steps: Step 1: Obtain the rule expression; Step 2: Substitute the parameter values from the conditions, set the WHERE condition to the rule expression that has been replaced with the condition parameter values, and execute the search to match the condition table; Step 3: Determine if there is a query record. If there is a query result record, it means that the rule condition is met. Modify the current state machine parameter value to the state machine to be transferred, and set the start state flag to "Yes". At this point, the previously running state machine can be transferred to the state machine to run. If there is no query result record, it means that the rule condition is not met. The current state machine is still in the previous state machine waiting for the condition to be met before it is transferred out.