Business rule processing method and device, storage medium and electronic equipment
By generating and simulating business rules, it solves the problems of low development efficiency and delayed error discovery caused by hard coding, achieves rapid design and management, detects errors in a timely manner, and improves user experience.
Patent Information
- Application Number
- CN202410984547.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-22
- Publication Date
- 2024-10-29
AI Technical Summary
In the existing technology, business rule logic is strongly bound to the business logic through hard coding, resulting in low development efficiency. When business rules are wrong, they are only discovered after batch rule operations, affecting the user experience.
By obtaining the business template information and business indicator information selected by the user, the business rules to be tested are generated, the rule language is analyzed and stored, the decision request is simulated, and the simulation results are used to determine whether the preset rule logic is met, the business rules to be executed are determined, and the design state is provided. Test functionality.
It improves development efficiency and application scope, ensures timely detection of business rule errors, avoids rule engine errors, and improves user experience.
Smart Images

Figure CN118860468A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, storage medium and electronic device for processing business rules. Background Art
[0002] The rule engine evolved from the reasoning engine. It is a component embedded in the application that separates business decisions from application code and uses predefined semantic modules to write business decisions. It accepts data input, interprets business rules, and makes business decisions based on business rules.
[0003] At present, the processing of existing business rules is mainly carried out by aggregating metadata obtained from different data sources to determine the corresponding derived metadata and load it as the corresponding entity; the preset business rules are disassembled to obtain different rule statements, and configured as corresponding rule syntax for syntax checking and syntax testing; finally, batch rule operations are performed on the entities according to the preset business rules, and the corresponding processing results are returned.
[0004] However, using this business rule processing method will cause the business rule logic to be strongly bound to the business logic in the form of hard coding. The design of each business rule requires the full participation of technical personnel, resulting in reduced development efficiency. In the event of errors in the business rules, it will not be perceived until the batch rule operation returns the corresponding processing results, which will cause errors in the rule engine and affect the user experience. Summary of the invention
[0005] In view of this, the present application provides a business rule processing method, device, storage medium and electronic device, the main purpose of which is to improve the current existing technology that causes the business rule logic to be strongly bound to the business logic in the form of hard coding. Each design of business rules requires the full participation of technical personnel, resulting in reduced development efficiency. In the event of errors in business rules, it will also cause the batch rule operation to return the corresponding processing results before being perceived, thereby causing errors in the rule engine and affecting the user experience.
[0006] In a first aspect, the present application provides a method for processing business rules, including:
[0007] Obtain the business template information and business indicator information selected by the user;
[0008] Processing the business template information and business indicator information through a preset template engine to generate a business rule to be tested;
[0009] Performing rule language analysis on the business rule to be tested, and storing the business rule in a preset database when it is determined that the business rule to be tested meets the preset rule language condition;
[0010] In response to receiving a decision request corresponding to the business rule to be tested uploaded by a user, loading the business rule to be tested into a rule memory for simulation;
[0011] Based on the simulation result, if it is determined that the business rule to be tested complies with the preset rule logic, the business rule to be tested is determined as a business rule to be executed, and the business rule to be executed is a rule that can be applied and executed.
[0012] In a second aspect, the present application provides a business rule processing device, including:
[0013] An acquisition module, configured to acquire the business template information and business indicator information selected by the user;
[0014] A generating module is configured to process the business template information and the business indicator information through a preset template engine to generate a business rule to be tested;
[0015] An analysis module is configured to perform rule language analysis on the business rule to be tested, and if it is determined that the business rule to be tested meets a preset rule language condition, store the business rule in a preset database;
[0016] A simulation module is configured to, in response to receiving a decision request corresponding to the business rule to be tested uploaded by a user, load the business rule to be tested into a rule memory for simulation;
[0017] The determination module is configured to determine the business rule to be tested as a business rule to be executed based on the simulation result if it is determined that the business rule to be tested conforms to the preset rule logic. The business rule to be executed is a rule that can be applied and executed.
[0018] In a third aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which implements the method for processing the business rules of the first aspect when the computer program is executed by a processor.
[0019] In a fourth aspect, the present application provides an electronic device, including a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein the processor implements the method for processing the business rules of the first aspect when executing the computer program.
[0020] In a fifth aspect, the present application provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the method for processing the business rules of the first aspect is implemented.
[0021] By means of the above technical scheme, the present application provides a method, device, storage medium and electronic device for processing business rules, which first obtain business template information and business indicator information selected by a user; process the business template information and business indicator information through a preset template engine to generate a business rule to be tested; perform rule language analysis on the business rule to be tested, and when it is determined that the business rule to be tested meets the preset rule language conditions, store the business rule in a preset database; in response to receiving a decision request corresponding to the business rule to be tested uploaded by the user, load the business rule to be tested into a rule memory for simulation; based on the simulation result, if it is determined that the business rule to be tested meets the preset rule logic, the business rule to be tested is determined as a business rule to be executed, and the business rule to be executed is a rule that can be applied and executed. Compared with the current existing technology, the present application generates business rules to be tested by obtaining business template information and business indicator information selected by the user. It can map corresponding resource sets for configuration according to different business scenarios, provide rapid design and management of rules, and improve development efficiency and application scope; when receiving the decision request corresponding to the business rule to be tested uploaded by the user, the business rule to be tested is loaded into the rule memory for simulation, and based on the simulation result, if it is judged that the business rule to be tested conforms to the preset rule logic, the business rule to be tested is determined as the business rule to be executed, and the simulation status indicator input information is configured, and the corresponding rule calculation results generated by the execution rule are checked with the expected rule calculation results, so as to provide the rule designer with a design state testing function to ensure that if there are errors in the business rules, they can be discovered in time through testing, so as to avoid errors in the rule engine and improve the user experience.
[0022] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0024] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0025] Figure 1 A schematic diagram showing a process flow of a method for processing business rules provided in an embodiment of the present application;
[0026] Figure 2 A schematic diagram showing a process flow of a method for processing business rules provided in an embodiment of the present application;
[0027] Figure 3 A schematic diagram showing an example provided by an embodiment of the present application;
[0028] Figure 4 A schematic diagram showing an example provided by an embodiment of the present application;
[0029] Figure 5 A schematic diagram showing an example provided by an embodiment of the present application;
[0030] Figure 6 A schematic diagram showing an example provided by an embodiment of the present application;
[0031] Figure 7 A schematic diagram showing an example provided by an embodiment of the present application;
[0032] Figure 8 A schematic diagram of the structure of a business rule processing device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0033] The embodiments of the present application will be described in more detail below with reference to the accompanying drawings. It should be noted that the embodiments and features in the embodiments of the present application can be combined with each other without conflict.
[0034] In order to improve the current existing technology, the business rule logic is hard-coded and strongly bound to the business logic. Each business rule design requires the full participation of technical personnel, resulting in reduced development efficiency. In the case of errors in business rules, it will also cause the batch rule operation to return the corresponding processing results before being perceived, which will cause errors in the rule engine and affect the user experience. This embodiment provides a method for processing business rules, such as Figure 1 As shown, the method includes:
[0035] Step 101: Obtain the service template information and service indicator information selected by the user.
[0036] In the embodiment of the present application, in the rule engine, the R&D personnel design a set of templates for different scenarios during the development phase. Each set of templates is equipped with a corresponding rule abstract template, a rule generator and a rule management center, and the business template information can be a set selected by the user from multiple sets of templates for different scenarios.
[0037] Correspondingly, each set of service templates has corresponding service indicator information. The service indicator information in this embodiment is the service indicator information corresponding to the service template information selected by the user.
[0038] Specifically, the rule engine is developed from the reasoning engine. It is a component embedded in the application, which separates business decisions from application code and uses predefined semantic modules to write business decisions. It accepts data input, interprets business rules, and makes business decisions based on business rules.
[0039] Step 102: Process the business template information and business indicator information through a preset template engine to generate business rules to be tested.
[0040] In some examples, a template engine is a technical component used in Web development. Its core function is to separate the user interface (UI) from business data (or content), and to decouple the front-end display from the back-end logic. In actual applications, a template engine allows developers to write static template files containing variable parts (placeholders), which will be filled with dynamic data at runtime, and finally generate a complete standard HyperText Markup Language (HTML) document or other types of documents with dynamic content.
[0041] In the embodiment of the present application, the template engine in the rule engine is created to separate the user interface from the business data. It can generate documents in a specific format. The template engine used for the website will generate a standard HTML document.
[0042] There are many ways to implement a template engine. The simplest one is a "replacement" template engine, which simply replaces specific tags in the specified template content to generate the final required business data. In addition, there are also "interpretation" template engines and "compilation" template engines.
[0043] Specifically, the working principle of the preset template engine in the embodiment of the present application may include determining the back-end server processing business logic through business template information and business indicator information, and obtaining the data to be displayed. The template engine combines the data with the template file, and fills the dynamic data into the specified location by parsing the special syntax in the template file. The result of the combination is a complete HTML page containing dynamic content, which can be sent to the browser to be presented to the user. For this embodiment, generating corresponding business rules through the template engine can improve development efficiency, facilitate maintenance, support data reuse, etc.
[0044] In some examples, the business rules to be tested are business rules that need to be tested and are generated by a preset template engine, and the business rules to be tested are rules that have not been tested to see whether they meet the application conditions.
[0045] Step 103: Perform rule language analysis on the business rule to be tested, and if it is determined that the business rule to be tested meets the preset rule language conditions, store the business rule in a preset database.
[0046] Optionally, the rule language is the core component of the rule engine and is used to define and express business rules. This language allows business experts or developers to write rules in an easy-to-understand way without having to delve into programming details. The design goal of the rule language is usually to increase the degree of decoupling between business logic and system development, so that business rules can be managed and maintained independently of application code.
[0047] In the embodiment of the present application, the language of the business rule to be tested needs to meet the preset rule language conditions before further testing can be performed.
[0048] Correspondingly, the preset rule language condition is a rule language condition corresponding to the currently used rule engine, and the specific content of the preset rule language condition is not specifically limited herein.
[0049] In some examples, the preset database may be a business rule database (Business Rule Repository), which is a system dedicated to storing and managing business rules. As a centralized repository, it allows different roles within an organization (such as business analysts, information technology (IT) teams, and managers) to create, edit, review, version control, and retrieve business rules. The business rule database is an important part of the rule engine, ensuring the centralized, standardized, and versioned management of business rules, thereby improving the agility and consistency of business processes. In the business rule database, business rules are usually stored in a structured, readable, and easy-to-maintain form, such as a decision table, decision tree, natural language text, or a specific rule language. Through the business rule database, organizations can manage complex business logic more efficiently, achieve close integration between business strategies and IT systems, speed up the response to market changes, and ensure the transparency and compliance of the decision-making process.
[0050] Step 104 : In response to receiving a decision request corresponding to the business rule to be tested uploaded by the user, the business rule to be tested is loaded into the rule memory for simulation.
[0051] As an optional method, in the business decision engine of the rule engine, rule memory usually refers to the data structure or database used by the engine to store and manage business rules. It specifically refers to the part that stores business rules, which are loaded into the memory for efficient search, interpretation and execution. Specifically, in order to achieve real-time decision-making, the engine needs to be able to quickly retrieve and execute rules, so storing rules in memory can significantly improve the execution speed. Rule memory supports dynamic addition, modification or deletion of rules at runtime, so that business decisions can respond quickly as the external environment changes or internal policy adjustments. Rule memory may organize rules according to a certain structure (such as tree structure, priority sorting, etc.) to facilitate on-demand query and analysis by the engine to ensure the correct execution of the decision process. In some advanced business decision engines, rule memory may also support the coexistence and switching of different versions of rules to meet decision-making needs in different stages or scenarios.
[0052] In the embodiment of the present application, the rule memory is used to store the business rules to be tested. Accordingly, the simulation of the business rules to be tested can be the state indicator input and action output results of the simulation test, which is used to detect whether the business rules to be tested are reasonable, that is, whether they can be actually applied.
[0053] Step 105: Based on the simulation result, if it is determined that the business rule to be tested conforms to the preset rule logic, the business rule to be tested is determined as the business rule to be executed.
[0054] Among them, the business rules to be executed are rules that can be applied and executed.
[0055] For this embodiment, if it is determined that the business rule to be tested conforms to the preset rule logic, that is, it is determined that the business rule to be tested can be actually applied, the business rule to be tested is determined as a business rule to be executed.
[0056] Compared with the current existing technology, this embodiment generates the business rules to be tested by obtaining the business template information and business indicator information selected by the user. It can map the corresponding resource collection for configuration according to different business scenarios, provide rapid design and management of rules, and improve development efficiency and application scope; when receiving the decision request corresponding to the business rule to be tested uploaded by the user, the business rule to be tested is loaded into the rule memory for simulation, and based on the simulation result, if it is judged that the business rule to be tested conforms to the preset rule logic, the business rule to be tested is determined as the business rule to be executed, and the simulation state indicator input information is configured, and the corresponding rule calculation result generated by the execution rule is verified with the expected rule calculation result, which provides the rule designer with the design state testing function to ensure that if there is an error in the business rule, it can be discovered in time through testing to avoid causing errors in the rule engine and improve the user experience.
[0057] In order to further illustrate the specific implementation process of the method of this embodiment, this embodiment provides the following Figure 2 The specific method shown includes:
[0058] Step 201: Obtain the service template information selected by the user.
[0059] Optional, such as Figure 3 As shown in FIG. 1 , it is a schematic diagram of the structure of generating the rules to be tested. Specifically, the business template information selected by the user can be obtained by Figure 3 This is done using the template manager in .
[0060] Correspondingly, the template manager is essentially a highly available design pattern. R&D personnel design a set of templates for different scenarios during the development phase. Each set of templates is equipped with corresponding rule abstract templates, rule generators, and rule management centers: Specifically, the rule abstract template is written in a preset language, which realizes the separation of rule mode and rule data, thereby presenting customizable rule data to users instead of abstract rule modes; the rule generator compiles the rule mode and user-customized rule data using a template engine to generate executable rules; the rule management center provides users with management-related functions required for rule design, encapsulates complex database table partitioning and add, delete, modify, and query logic, so that users can edit, view, and reuse rules while designing and using them.
[0061] like Figure 4The structure diagram of the rule engine of the embodiment of the present application is shown as follows: Figure 5 The flowchart of the rule engine of the embodiment of the present application is shown. Specifically, the business designer designs the rule strategy in the rule center. After the rule center disassembles the rule strategy, it distributes it to the decision engine and action scheduler. The state manager periodically collects the underlying application indicators, runtime indicators and resource conditions. The decision engine combines the indicators collected by the underlying state manager with the issuance strategy and uses the decision algorithm to continuously make decisions. The action scheduler schedules application resources according to the results of the decision engine to achieve resource control. In summary, the general rule engine for multiple business scenarios consists of a rule center, a decision engine, an action scheduler and a state manager.
[0062] Step 202: Determine the service condition information and service action information corresponding to the service template information based on the triplet information included in the service template information.
[0063] The business indicator information includes business condition information and business action information.
[0064] For this embodiment, the triple information may be an object, an operator, and a value. Specifically, the business condition information and the business action information corresponding to the business template information may be determined by: Figure 3 This is achieved through the rule parameter pool in .
[0065] Correspondingly, the rule parameter pool is used to control the execution restrictions of the rules and is the main part of the rules designed for users. Specifically, the rule parameter pool is divided into two parts: conditions and actions. When the predetermined conditions are met, the corresponding actions are executed. In order to ensure the universality of the rules, the triple (object, operator, value) is used to abstract the mode of conditions and actions. When selecting different templates through the template manager, its object collection will also change accordingly according to the different settings of different scenarios.
[0066] It should be noted that in Figure 3 The engine controller is also included, and the rule engine control is composed of monitoring frequency and cooling cycle. The existing technical solution puts the rules in a high-frequency monitoring state. The problem caused by this is that if the task status indicators are collected at a high frequency and injected into the rule engine, on the one hand, a large amount of computing resources are allocated for high-frequency calculation matching, which affects the execution efficiency of the main business. On the other hand, the task status indicators have a lag, which causes the same rules to be triggered multiple times in a short period of time, thereby causing excessive expansion and waste of resources. Therefore, the embodiment of the present application adopts monitoring frequency and cooling cycle to make the decision and trigger of the decision engine adapt to the lag of the previous decision on the current task status indicator.
[0067] Step 203: Process the business template information and business indicator information through a preset template engine to generate business rules to be tested.
[0068] Step 204: Perform rule language analysis on the business rule to be tested, and if it is determined that the business rule to be tested meets the preset rule language conditions, store the business rule in a preset database.
[0069] Step 205: In response to receiving a decision request corresponding to the business rule to be tested uploaded by the user, the business rule to be tested is loaded into a rule memory for simulation.
[0070] Optionally, step 205 may specifically include: in response to receiving a decision request corresponding to the business rules to be tested uploaded by the user, obtaining the simulation status indicator input information uploaded by the user; loading the business rules to be tested into the rule memory based on the simulation status indicator input information; making a decision on the business rules to be tested, and obtaining the output business action information corresponding to the business rules to be tested.
[0071] For this embodiment, the simulation status indicator input information is the simulation status indicator input information uploaded by the status manager in the rule engine.
[0072] Specifically, in the rule engine, the State Manager is a component used to track and manage state information during rule execution. It plays a core role in the entire rule execution process, ensuring that the engine can correctly handle complex business processes and state transitions.
[0073] In the embodiment of the present application, the indicators taken by the state manager include multiple dimensions, including task runtime status, resource class status, and application class status. The state manager provides the decision engine with the input required for decision-making. Similar to the action scheduler, the state manager in the embodiment of the present application is divided into online mode and local test mode. Among them, the online mode is used in the production environment after deployment, providing users with real state indicator collection to match the trigger rules.
[0074] Correspondingly, the local test mode is a virtual state manager. In this mode, the user starts the decision engine to make decisions by simulating state indicator input, and then judges the rationality of the rule design by monitoring the corresponding action output of the action scheduler of the local test mode.
[0075] In some examples, step 205 specifically also includes: determining the reasoning factor information contained in the business rule to be tested; correspondingly, step 205 specifically also includes: based on the reasoning factor information, passing the business rule to be tested through a preset pattern matcher and a preset agenda to obtain the output business action information corresponding to the business rule to be tested.
[0076] In the embodiment of the present application, the output business action information is obtained through the action scheduler in the rule engine. The action scheduler in the rule engine is a component used to manage and schedule the actions required to be executed after the rule is executed. When a rule in the rule engine is successfully matched and triggered, the action scheduler is responsible for executing the corresponding operation or action according to the predefined order and logic.
[0077] Specifically, the action scheduler is the rule processing result execution module of the embodiment of the present application, which executes the corresponding action according to the decision result of the decision engine. The action scheduler is mainly responsible for the execution order processing after the rule is triggered. Specifically, the action scheduler uses a scheduling queue to maintain the execution order of different actions. The order in which the queue stores actions is mainly sorted from high to low according to the priority of the rule. The action scheduler in the embodiment of the present application is divided into an online mode and a local test mode, wherein the online mode is used for the production environment after deployment, providing users with real resource scheduling to adjust the current task status loop triggering rules.
[0078] Correspondingly, the local test mode is a virtual resource scheduler and does not directly provide real resource scheduling. In this mode, users input simulated status indicators, start the decision engine to make decisions, and then judge the rationality of rule design by monitoring the corresponding action output of the action scheduler in the local test mode.
[0079] It should be noted that in the embodiment of the present application, local test modes are introduced to the action scheduler and the state manager respectively, and the problem of rationality verification of design state rules is solved by simulating the rationality of state indicator input and action output.
[0080] As an optional method, step 205 specifically also includes: based on the reasoning factor information, if it is determined that an reasoning factor lock corresponding to the reasoning factor information exists in the preset pattern matcher, then in response to the cancellation of the reasoning factor lock, the business rule to be executed is passed through the preset pattern matcher and the preset agenda, and an reasoning factor lock is generated; if it is determined that the reasoning factor lock does not exist in the preset pattern matcher, the business rule to be executed is passed through the preset pattern matcher and the preset agenda, and an reasoning factor lock is generated; in response to obtaining the output business action information corresponding to the business rule to be tested, the reasoning factor lock is canceled.
[0081] The inference factor lock is used to lock the pending business rules containing the inference factor information.
[0082] In some examples, such as Figure 6The figure shows the structure diagram of the decision engine. The Business Decision Engine is an intelligent software system that helps enterprises automatically execute and manage complex business decision processes. It integrates business rules, strategies, algorithms and models, and dynamically executes decision logic based on real-time data and conditions to achieve business process automation and optimization.
[0083] exist Figure 6 In the rule session, the rules that are actually to be run in the rule engine are loaded. By injecting the corresponding facts into the rule session, the rule matching and processing results are returned.
[0084] In the embodiment of the present application, a memory management mechanism based on inference factor locks is used. Compared with the rule design in the design state, the running state manages the rules based on memory, thereby ensuring business logic perception. In the decision engine in the embodiment of the present application, the rule memory is the object of the rule modification and update operation, and the working memory is the operation object of the rule matching, which is usually the specific object referred to by the inference factor. In order to solve the concurrency problem caused by the dynamic update of rules and operation objects while the rule session is performing pattern matching, the embodiment of the present application uses a lock mechanism to deal with the triggering of the following two situations:
[0085] For example, suppose a rule contains an inference factor E, and the design state updates and applies the rule, thereby writing it from the disk to the rule memory. During this process, the rule session receives the update of the inference factor E and writes it to the working memory. Due to network and disk read and write efficiency and other reasons, this pattern match is based on the rules before the rule memory is updated and produces results that do not meet expectations. By locking the inference factor E at the beginning of the rule memory update and application, any update of the associated inference factor E and writing it to the working memory will wait in a loop until the rule memory update is completed, thereby ensuring that the matching result meets expectations.
[0086] For example, if the rule session receives an update of the inference factor E and writes it to the working memory. During this process, the design state updates and applies multiple rules containing the inference factor E and writes them to the rule memory. Due to network and disk read and write efficiency and other reasons, this pattern matching is based on the rules after the rule memory is updated and produces results that do not meet expectations. By locking the inference factor E at the beginning of the working memory update, any rule update associated with the inference factor E and writing to the rule memory will wait in a loop until the working memory update is completed, thereby ensuring that the matching result meets expectations.
[0087] Furthermore, in the decision engine, the Pattern Matcher and the Agenda together constitute the pattern matching part that compares facts and rules.
[0088] The essence of a pattern matcher is a pattern matching algorithm that matches facts with production rules to determine which rule to execute. This solution uses rule schema and rule body to effectively reduce the number of comparisons. Specifically, Figure 7 As shown, the rule schema is responsible for describing the hierarchical structure of reasoning factors in the domain reasoning network. Its general form is shown in the following formula 1:
[0089] IF E1,...,En then A(Formula 1)
[0090] In formula 1, E1,...,En represent the rule scheme inference factors. Each rule schema has a corresponding rule body, which represents the specific calculation method for the above factors. In each rule body, there are one or more inference rules for the factor composition.
[0091] For example, let's take an example of finding the value of X in the quadratic equation AX2+BX+C=0, where the rule schema+rule body is expressed as:
[0092] Rule schema: IF A, B, C THEN X
[0093] Rule body:
[0094] IF A=0,B≠0 THEN X=-C / B
[0095] IF A≠0THEN
[0096]
[0097] IF A≠0THEN
[0098]
[0099] In the embodiments of the present application,
[0100] Step 206: Based on the simulation result, if it is determined that the business rule to be tested conforms to the preset rule logic, the business rule to be tested is determined as the business rule to be executed.
[0101] Among them, the business rules to be executed are rules that can be applied and executed.
[0102] Optionally, step 206 may specifically include: based on the business action information and the output business action information, if it is determined that the business rule to be tested complies with the preset rule logic, determining the business rule to be tested as the business rule to be executed.
[0103] For this embodiment, in the current prior art, the business rule logic is strongly bound to the business logic in the form of hard coding. Each design of business rules requires the full participation of technical personnel, resulting in reduced development efficiency. The verification of rules is mainly divided into compile time and runtime, among which the compile-time rule verification is to detect the syntax of the rules. The runtime rule verification is caused by logical loopholes in the rule design, and the rule errors will not be perceived when the rules are put on the shelves and executed. Therefore, the lack of design-state rule verification will cause such errors to be perceived only after the batch rule operation returns the corresponding processing results, causing huge losses. Unresolved concurrency problems caused by dynamic configuration and hot deployment of rules in the running state: In the face of the variability of demand, business rules usually need to change frequently. The modification of rules should be perceived by the business logic in the running state. At the same time, frequent changes in business rules will cause traditional read-write concurrency problems.
[0104] Compared with the current existing technology, this embodiment generates a business rule to be tested by acquiring the business template information and business indicator information selected by the user, and can map the corresponding resource collection for configuration according to different business scenarios, provide rapid design and management of rules, and improve development efficiency and application scope; when receiving the decision request corresponding to the business rule to be tested uploaded by the user, the business rule to be tested is loaded into the rule memory for simulation, and based on the simulation result, if it is judged that the business rule to be tested conforms to the preset rule logic, the business rule to be tested is determined as the business rule to be executed, and the simulation state indicator input information is configured, and the corresponding rule calculation result generated by the execution rule is verified with the expected rule calculation result, so as to provide the rule designer with a design state test function, ensure that if there is an error in the business rule, it can be discovered in time through testing, avoid causing errors in the rule engine, and improve the user experience; the runtime rule session can also be cached and updated, and the decision engine based on the memory management mechanism of the inference factor lock provides decision management and execution of the rule running state, realizes the perception of business logic by dynamic modification of the rule, and ensures that the update of the rules and operation objects in the memory and the rule triggering meet expectations.
[0105] Further, as Figure 1 and Figure 2 The specific implementation of the method shown in the embodiment provides a processing device for business rules, such as Figure 8 As shown, the device includes: an acquisition module 31, a generation module 32, an analysis module 33, a simulation module 34, and a determination module 35.
[0106] The acquisition module 31 is configured to acquire the service template information and service indicator information selected by the user;
[0107] A generating module 32 is configured to process the business template information and the business indicator information through a preset template engine to generate a business rule to be tested;
[0108] The analysis module 33 is configured to perform rule language analysis on the business rule to be tested, and if it is determined that the business rule to be tested meets the preset rule language condition, store the business rule in a preset database;
[0109] The simulation module 34 is configured to load the business rule to be tested into the rule memory for simulation in response to receiving a decision request corresponding to the business rule to be tested uploaded by the user;
[0110] The determination module 35 is configured to determine the business rule to be tested as a business rule to be executed if it is determined based on the simulation result that the business rule to be tested conforms to the preset rule logic. The business rule to be executed is a rule that can be applied and executed.
[0111] In some examples of this embodiment, the acquisition module 31 is specifically configured to obtain the business template information selected by the user; determine the business condition information and business action information corresponding to the business template information based on the triple information contained in the business template information, wherein the business indicator information includes business condition information and business action information.
[0112] In some examples of this embodiment, the simulation module 34 is specifically configured to obtain the simulation status indicator input information uploaded by the user in response to receiving a decision request corresponding to the business rule to be tested uploaded by the user; load the business rule to be tested into the rule memory based on the simulation status indicator input information; make a decision on the business rule to be tested to obtain the output business action information corresponding to the business rule to be tested.
[0113] In some examples of this embodiment, the simulation module 34 is further configured to determine the reasoning factor information contained in the business rule to be tested; accordingly, the simulation module 34 is further configured to obtain the output business action information corresponding to the business rule to be tested through a preset pattern matcher and a preset agenda based on the reasoning factor information.
[0114] In some examples of the present embodiment, the simulation module 34 is further configured to be based on the reasoning factor information. If it is determined that an reasoning factor lock corresponding to the reasoning factor information exists in the preset pattern matcher, then in response to the cancellation of the reasoning factor lock, the business rule to be executed is passed through the preset pattern matcher and the preset agenda, and the reasoning factor lock is generated, and the reasoning factor lock is used to lock the business rule to be executed containing the reasoning factor information; if it is determined that the reasoning factor lock does not exist in the preset pattern matcher, the business rule to be executed is passed through the preset pattern matcher and the preset agenda, and the reasoning factor lock is generated; in response to obtaining the output business action information corresponding to the business rule to be tested, the reasoning factor lock is canceled.
[0115] In some examples of this embodiment, the determination module 35 is specifically configured to determine the business rule to be tested as a business rule to be executed if it is determined that the business rule to be tested conforms to the preset rule logic based on the business action information and the output business action information.
[0116] It should be noted that for other corresponding descriptions of the functional units involved in the business rule processing device provided in this embodiment, please refer to Figure 1 and Figure 2 The corresponding description in will not be repeated here.
[0117] Based on the above Figure 1 to Figure 2 The method shown in the embodiment also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned Figure 1 to Figure 2 The method shown.
[0118] Based on this understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, USB flash drive, mobile hard disk, etc.), including a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods of various implementation scenarios of the present application.
[0119] Based on the above Figure 1 to Figure 2 The method shown, and Figure 8 In order to achieve the above-mentioned purpose, the embodiment of the present application also provides an electronic device, such as a personal computer, a server, a laptop computer, a smart phone, an intelligent robot or other intelligent terminal, which includes a storage medium and a processor; the storage medium is used to store a computer program; the processor is used to execute the computer program to achieve the above-mentioned Figure 1 to Figure 2 The method shown.
[0120] Optionally, the above-mentioned physical device may also include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a WI-FI module, etc. The user interface may include a display, an input unit such as a keyboard, etc., and the optional user interface may also include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface), etc.
[0121] Those skilled in the art will appreciate that the above-mentioned physical device structure provided in this embodiment does not constitute a limitation on the physical device, and may include more or fewer components, or a combination of certain components, or different arrangements of components.
[0122] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware and software resources of the above-mentioned physical device, and supports the operation of the information processing program and other software and / or programs. The network communication module is used to realize the communication between the components inside the storage medium, and the communication with other hardware and software in the information processing physical device.
[0123] Based on the above Figure 1 to Figure 2 The present application also provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the above-mentioned Figure 1 to Figure 2 The method shown, the method implemented when the computer program is executed by the processor can refer to the various embodiments of the present application, and will not be described in detail here.
[0124] Through the description of the above implementation methods, the technicians in this field can clearly understand that the present application can be implemented by means of software plus necessary general hardware platforms, or by hardware. By obtaining the business template information and business indicator information selected by the user, the business rules to be tested are generated, and the corresponding resource collections can be mapped for configuration according to different business scenarios, providing rapid design and management of rules, and improving development efficiency and application scope; by receiving the decision request corresponding to the business rules to be tested uploaded by the user, the business rules to be tested are loaded into the rule memory for simulation, and based on the simulation results, if the business rules to be tested are judged to be in line with the preset rule logic, the business rules to be tested are determined as the business rules to be executed, and the simulation state indicator input information is configured, and the corresponding rule calculation results generated by the execution rules are checked with the expected rule calculation results, providing the rule designers with the design state test function, ensuring that the business rules can be discovered in time through testing when errors occur, avoiding errors in the rule engine, and improving the user experience; the runtime rule session can also be cached and updated, and the decision engine based on the memory management mechanism of the inference factor lock provides decision management and execution of the rule running state, realizing the dynamic modification of the rules to perceive the business logic, and ensuring that the rules and operation objects in the memory are updated and the rule triggering meets expectations.
[0125] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0126] The above is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features applied for herein.
Claims
1. A method for processing business rules, characterized in that: include: Obtain the business template information and business indicator information selected by the user; Processing the business template information and business indicator information through a preset template engine to generate a business rule to be tested; Performing rule language analysis on the business rule to be tested, and storing the business rule in a preset database when it is determined that the business rule to be tested meets the preset rule language condition; In response to receiving a decision request corresponding to the business rule to be tested uploaded by a user, loading the business rule to be tested into a rule memory for simulation; Based on the simulation result, if it is determined that the business rule to be tested complies with the preset rule logic, the business rule to be tested is determined as a business rule to be executed, and the business rule to be executed is a rule that can be applied and executed.
2. The method according to claim 1, characterized in that The obtaining of the service template information and service indicator information selected by the user includes: Acquire the service template information selected by the user; According to the triplet information included in the business template information, the business condition information and business action information corresponding to the business template information are determined, wherein the business indicator information includes the business condition information and the business action information.
3. The method according to claim 2, characterized in that The step of responding to receiving a decision request corresponding to the business rule to be tested uploaded by a user, loading the business rule to be tested into a rule memory for simulation, comprises: In response to receiving a decision request corresponding to the business rule to be tested uploaded by a user, obtaining simulation state indicator input information uploaded by the user; According to the simulation status indicator input information, the business rule to be tested is loaded into the rule memory; A decision is made on the business rule to be tested to obtain output business action information corresponding to the business rule to be tested.
4. The method according to claim 3, characterized in that Before making a decision on the business rule to be tested and obtaining output business action information corresponding to the business rule to be tested, the method further includes: Determining the inference factor information contained in the business rule to be tested; The making a decision on the business rule to be tested to obtain output business action information corresponding to the business rule to be tested includes: Based on the inference factor information, the business rule to be tested is passed through a preset pattern matcher and a preset agenda to obtain output business action information corresponding to the business rule to be tested.
5. The method according to claim 4, characterized in that The step of obtaining output business action information corresponding to the business rule to be tested by passing the business rule to be tested through a preset pattern matcher and a preset agenda based on the inference factor information includes: Based on the inference factor information, if it is determined that the preset pattern matcher has an inference factor lock corresponding to the inference factor information, in response to the cancellation of the inference factor lock, the business rule to be executed is passed through the preset pattern matcher and the preset agenda, and the inference factor lock is generated, and the inference factor lock is used to lock the business rule to be executed containing the inference factor information; If it is determined that the inference factor lock does not exist in the preset pattern matcher, the business rule to be executed is passed through the preset pattern matcher and the preset agenda, and the inference factor lock is generated; In response to obtaining the output business action information corresponding to the business rule to be tested, the inference factor lock is cancelled.
6. The method according to any one of claims 3 to 5, characterized in that Based on the simulation result, if it is determined that the business rule to be tested conforms to the preset rule logic, the business rule to be tested is determined as a business rule to be executed, including: Based on the business action information and the output business action information, if it is determined that the business rule to be tested conforms to the preset rule logic, the business rule to be tested is determined as a business rule to be executed.
7. A business rule processing device, characterized in that: include: An acquisition module, configured to acquire the business template information and business indicator information selected by the user; A generating module is configured to process the business template information and the business indicator information through a preset template engine to generate a business rule to be tested; An analysis module is configured to perform rule language analysis on the business rule to be tested, and if it is determined that the business rule to be tested meets a preset rule language condition, store the business rule in a preset database; A simulation module is configured to, in response to receiving a decision request corresponding to the business rule to be tested uploaded by a user, load the business rule to be tested into a rule memory for simulation; The determination module is configured to determine the business rule to be tested as a business rule to be executed based on the simulation result if it is determined that the business rule to be tested conforms to the preset rule logic. The business rule to be executed is a rule that can be applied and executed.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
9. An electronic device comprising a storage medium, a processor, and a computer program stored in the storage medium and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 6 is implemented.
10. A computer program product, comprising a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
