Rule engine execution method, apparatus, device, and computer readable storage medium

By utilizing the execution method of the rule engine and processing rule conditions with hash values ​​and combined key values, the problem of low efficiency in business rule development under traditional coding methods is solved, achieving efficient processing of business rules and simplified integration of the rule base.

CN115145552BActive Publication Date: 2026-06-26CLOUDLINK SCM TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CLOUDLINK SCM TECH CO LTD
Filing Date
2022-05-23
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

Traditional coding methods are inefficient when processing business rules. Adding or modifying conditions requires rewriting the code, resulting in low efficiency in business code development.

Method used

By adopting the execution method of the rule engine, the rule instance object structure value is assembled through the preset rule parameter class, the hash key value and the combined key value are constructed, and the rule result is obtained from the rule engine. This simplifies the separation of business logic and code, and the rule result can be obtained by only modifying the rule instance object structure value.

Benefits of technology

It simplifies the development process of business code, improves the development efficiency of business rule processing, supports rich rule operations, and simplifies the integration and adjustment of the rule base.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115145552B_ABST
    Figure CN115145552B_ABST
Patent Text Reader

Abstract

The application discloses a rule engine execution method, device and equipment and a computer readable storage medium. The application assembles a rule instance object structure value according to preset rule parameter classes, obtains a target condition object instance, constructs a hash key value according to the target condition object instance and a fixed query condition array, constructs a combined key value according to the target condition object instance, a dynamic query condition array and a classification combination condition array, and obtains a rule result from the rule engine according to the hash key value and the combined key value. The application processes rule conditions based on the rule engine, separates business logic from code, and thus simplifies development of business code.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of rule engine technology, and in particular to a method, apparatus, device, and computer-readable storage medium for executing a rule engine. Background Technology

[0002] As business demands continue to grow, different customer groups are placing increasingly higher demands on personalization, involving more and more rules and conditions. Currently, traditional conditional codes are typically used to handle business rules. However, traditional coding methods result in complex code, and the code needs to be modified again when adding or changing conditions, which leads to low efficiency in developing business code to execute business rules.

[0003] The above content is only used to help understand the technical solution of the present invention and does not represent an admission that the above content is prior art. Summary of the Invention

[0004] The main objective of this invention is to provide a method, apparatus, device, and computer-readable storage medium for executing a rule engine, aiming to solve the technical problem of low efficiency in developing business code for executing business rules.

[0005] To achieve the above objectives, the present invention provides a method for executing a rule engine, the method comprising:

[0006] The rule instance object structure value is assembled according to the preset rule parameter class; the rule parameter class includes a fixed condition frame, a dynamic condition frame, and a category combination condition frame, and the rule instance object structure value includes a fixed query condition array, a dynamic query condition array, and a category combination condition array;

[0007] Obtain a target condition object instance, and construct a hash key value based on the target condition object instance and the fixed query condition array;

[0008] And construct combined key values ​​based on the target condition object instance, the dynamic query condition array, and the classification combination condition array;

[0009] The rule results are obtained from the rule engine based on the hash key value and the combined key value.

[0010] Optionally, the step of constructing a hash key value based on the target condition object instance and the fixed query condition array includes:

[0011] Obtain the primary key value of the target condition object instance;

[0012] The hash key value is obtained by concatenating the array of fixed query conditions with the primary key value of the target condition object instance.

[0013] Optionally, the step of constructing the combined key value based on the target condition object instance, the dynamic query condition array, and the classification combination condition array includes:

[0014] Obtain the primary key value of the target condition object instance;

[0015] The dynamic query condition array, the category combination condition array, and the primary key value of the target condition object instance are concatenated to obtain all the combined key values.

[0016] Optionally, the step of concatenating the dynamic query condition array, the category combination condition array, and the primary key value of the target condition object instance to obtain all the combined key values ​​includes:

[0017] By using a pre-defined recursive algorithm, the dynamic query condition array is concatenated with the primary key value of the target condition object instance to obtain the combined conditions;

[0018] The combined conditions are combined with the classification combined condition array to obtain all the combined key values.

[0019] Optionally, the step of concatenating the dynamic query condition array with the primary key value of the target condition object instance to obtain the combined conditions includes:

[0020] If there are multiple dynamic query conditions, then determine the target dynamic query condition that is not empty in each of the dynamic query conditions;

[0021] The target dynamic query conditions and the primary key values ​​of the target condition object instances are concatenated according to the order of the preset business rules to obtain the combined conditions.

[0022] Optionally, before the step of obtaining the rule result from the rule engine based on the hash key value and the combined key value, the method further includes:

[0023] Obtain the newly added condition object instance and check whether there is a historical condition object instance corresponding to the newly added condition object instance in the rule engine;

[0024] If a historical condition object instance exists corresponding to the newly added condition object instance, then the newly added primary key value of the newly added condition object instance is obtained;

[0025] The new key value is constructed based on the newly added primary key value and the structure value of the rule instance object;

[0026] The newly added key value and the newly added primary key value are stored in the rule engine.

[0027] Optionally, after the step of determining if a historical condition object instance exists corresponding to the newly added condition object instance, the method further includes:

[0028] Check if the historical condition object instance is empty;

[0029] If the historical condition object instance is not empty, then the corresponding historical key value of the historical condition object instance is deleted.

[0030] Furthermore, to achieve the above objectives, the present invention also provides an execution device for a rule engine, the execution device for the rule engine comprising:

[0031] The condition acquisition module is used to assemble the structure value of the rule instance object according to the preset rule parameter class; wherein, the rule parameter class includes a fixed condition frame, a dynamic condition frame and a category combination condition frame, and the structure value of the rule instance object includes a fixed query condition array, a dynamic query condition array and a category combination condition array;

[0032] The key value construction module is used to obtain a target condition object instance and construct a hash key value based on the target condition object instance and the fixed query condition array.

[0033] The key value construction module is also used to construct combined key values ​​based on the target condition object instance, the dynamic query condition array, and the classification combination condition array;

[0034] The result acquisition module is used to obtain rule results from the rule engine based on the hash key value and the combined key value.

[0035] In addition, to achieve the above objectives, the present invention also provides a rule engine execution device, which includes a memory, a processor, and a rule engine execution program stored in the memory and executable on the processor. When the rule engine execution program is executed by the processor, it implements the steps of the rule engine execution method described above.

[0036] In addition, to achieve the above objectives, the present invention also provides a computer-readable storage medium storing a rule engine execution program, which, when executed by a processor, implements the steps of the rule engine execution method described above.

[0037] This invention provides a method, apparatus, device, and computer-readable storage medium for executing a rule engine. The method assembles rule instance object structure values ​​according to a preset rule parameter class, which includes a fixed condition framework, a dynamic condition framework, and a category-combination condition framework. The rule instance object structure values ​​include a fixed query condition array, a dynamic query condition array, and a category-combination condition array. The method involves obtaining a target condition object instance, constructing a hash key value based on the target condition object instance and the fixed query condition array, and constructing a combined key value based on the target condition object instance, the dynamic query condition array, and the category-combination condition array. The method then retrieves the rule result from the rule engine based on the hash key value and the combined key value. This invention processes rule conditions based on a rule engine, separating business logic from code, thereby simplifying the development of business code. Furthermore, the processing logic of this invention's hash-based keyword rule engine, by encapsulating the core rule instance object, allows for rule result retrieval by modifying only the rule instance object structure value when adding or changing rule conditions, thus simplifying the compilation of the rule base and improving the efficiency of business rule processing development. Attached Figure Description

[0038] Figure 1 This is a schematic diagram of the hardware operating environment of the device involved in the embodiments of the present invention;

[0039] Figure 2 This is a flowchart illustrating the first embodiment of the execution method of the rule engine of the present invention;

[0040] Figure 3 This is a schematic diagram of the device structure of the execution device of the rule engine of the present invention;

[0041] Figure 4 This is a schematic diagram of the rule storage process involved in an embodiment of the rule engine execution method of the present invention;

[0042] Figure 5 This is a schematic diagram of the business rule application process involved in an embodiment of the rule engine execution method of the present invention.

[0043] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0044] 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 a part of the embodiments of the present invention, and not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.

[0045] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

[0046] Reference Figure 1 , Figure 1 This is a schematic diagram of the terminal / device structure of the hardware operating environment involved in the embodiments of the present invention.

[0047] In this embodiment of the invention, the terminal can be a PC (personal computer), a portable computer, a server, or other terminal device.

[0048] like Figure 1 As shown, the execution device of this rule engine may include: a processor 1001, such as a CPU (Central Processing Unit), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to implement communication between these components. The user interface 1003 may include a display screen or an input unit such as a keyboard; optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as Wi-Fi). The memory 1005 may be a high-speed random access memory (RAM) or a stable non-volatile memory (NVM), such as a disk drive. The memory 1005 may also optionally be a storage device independent of the aforementioned processor 1001.

[0049] Those skilled in the art will understand that Figure 1 The structure shown does not constitute a limitation on the device and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0050] like Figure 1 As shown, the memory 1005, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and a rule engine execution program.

[0051] exist Figure 1 In the device shown, network interface 1004 is mainly used to connect to the backend server and communicate data with it; user interface 1003 is mainly used to connect to the client (user terminal) and communicate data with it; while processor 1001 can be used to call the rule engine execution program stored in memory 1005 and perform the following operations:

[0052] The rule instance object structure value is assembled according to the preset rule parameter class; the rule parameter class includes a fixed condition frame, a dynamic condition frame, and a category combination condition frame, and the rule instance object structure value includes a fixed query condition array, a dynamic query condition array, and a category combination condition array;

[0053] Obtain a target condition object instance, and construct a hash key value based on the target condition object instance and the fixed query condition array;

[0054] And construct combined key values ​​based on the target condition object instance, the dynamic query condition array, and the classification combination condition array;

[0055] The rule results are obtained from the rule engine based on the hash key value and the combined key value.

[0056] Furthermore, the processor 1001 can also be used to call the rule engine execution program stored in the memory 1005 and perform the following operations:

[0057] Obtain the primary key value of the target condition object instance;

[0058] The hash key value is obtained by concatenating the array of fixed query conditions with the primary key value of the target condition object instance.

[0059] Furthermore, the processor 1001 can also be used to call the rule engine execution program stored in the memory 1005 and perform the following operations:

[0060] Obtain the primary key value of the target condition object instance;

[0061] The dynamic query condition array, the category combination condition array, and the primary key value of the target condition object instance are concatenated to obtain all the combined key values.

[0062] Furthermore, the processor 1001 can also be used to call the rule engine execution program stored in the memory 1005 and perform the following operations:

[0063] By using a pre-defined recursive algorithm, the dynamic query condition array is concatenated with the primary key value of the target condition object instance to obtain the combined conditions;

[0064] The combined conditions are combined with the classification combined condition array to obtain all the combined key values.

[0065] Furthermore, the processor 1001 can also be used to call the rule engine execution program stored in the memory 1005 and perform the following operations:

[0066] If there are multiple dynamic query conditions, then determine the target dynamic query condition that is not empty in each of the dynamic query conditions;

[0067] The target dynamic query conditions and the primary key values ​​of the target condition object instances are concatenated according to the order of the preset business rules to obtain the combined conditions.

[0068] Furthermore, the processor 1001 can also be used to call the rule engine execution program stored in the memory 1005 and perform the following operations:

[0069] Obtain the newly added condition object instance and check whether there is a historical condition object instance corresponding to the newly added condition object instance in the rule engine;

[0070] If a historical condition object instance exists corresponding to the newly added condition object instance, then the newly added primary key value of the newly added condition object instance is obtained;

[0071] The new key value is constructed based on the newly added primary key value and the structure value of the rule instance object;

[0072] The newly added key value and the newly added primary key value are stored in the rule engine.

[0073] Furthermore, the processor 1001 can also be used to call the rule engine execution program stored in the memory 1005 and perform the following operations:

[0074] Check if the historical condition object instance is empty;

[0075] If the historical condition object instance is not empty, then the corresponding historical key value of the historical condition object instance is deleted.

[0076] Based on the above hardware structure, various embodiments of the execution method of the rule engine of the present invention are proposed.

[0077] This invention provides a method for executing a rule engine, referring to... Figure 2 , Figure 2 This is a flowchart illustrating the first embodiment of the execution method of the rule engine of the present invention.

[0078] In this embodiment, the execution method of the rule engine includes:

[0079] Step S10: Assemble rule instance object structure values ​​according to preset rule parameter classes; the rule parameter classes include fixed condition frames, dynamic condition frames, and category combination condition frames, and the rule instance object structure values ​​include fixed query condition arrays, dynamic query condition arrays, and category combination condition arrays.

[0080] Step S20: Obtain a target condition object instance, and construct a hash key value based on the target condition object instance and the fixed query condition array;

[0081] Step S30: Construct combined key values ​​based on the target condition object instance, the dynamic query condition array, and the classification combination condition array;

[0082] Step S40: Obtain rule results from the rule engine based on the hash key value and the combined key value.

[0083] In this embodiment, the rule engine execution method is applied to a hash-based keyword rule engine. Rule parameter classes are pre-defined in the rule engine. These class classes are used to construct the structure values ​​of rule instance objects and to create conditional processing logic for various business rules. Specifically, the rule parameter classes include fixed query condition frames (fixcondition keys), dynamic rule condition frames (unfixed conditions), non-empty dynamic frames (notEmpty conditions), and group-based condition frames. The conditions include: a fixed query condition frame (a required condition used to assemble a hash key value for targeted information retrieval); a dynamic rule condition frame (a non-required condition used to assemble key elements of the hash key value); and a category combination condition frame (which may include multiple frames, such as category combination condition frame 1 (originating category combination condition data), category combination condition frame 2 (destination category combination condition data), and category combination condition frame 3 (interruption category combination condition data). The data corresponding to each category combination condition frame is determined according to the actual situation. Category combination condition frames are used to assemble key elements of the hash key value item based on different data types. A non-empty dynamic frame is used to determine whether a condition is required based on the actual situation and the business logic. In practice, certain dynamic conditions are required as mandatory fields, such as the business type not being empty. It should be noted that the business rule engine in this embodiment provides rule parameter classes for assembling business rules, as described above. Rule instance object structure values ​​are obtained by assembling rules based on preset rule parameter classes. These rule instance object structure values ​​are parameter values ​​instantiated from the rule parameter classes. The rule instance object structure values ​​may include fixed query condition arrays, dynamic query condition arrays, and category combination condition arrays. The business rule engine inputs a target condition object instance, followed by the rule instance object structure value. A hash key value is constructed based on the target condition object instance and the fixed query condition array, and a combined key value is constructed based on the target condition object instance, the dynamic query condition array, and the category combination condition array. Finally, the rule result is obtained based on the hash key value and the combined key value. This embodiment provides preset rule parameter classes for multiple scenarios to adapt to various situations and support richer rule operations. Furthermore, based on these rule parameter classes and the hash-based keyword rule engine processing logic in this embodiment, business code development is simplified, rule library integration is simplified, and development speed is improved.

[0084] This embodiment uses Redis's hash value-based keyword processing logic. Compared to current rule engines on the market, it allows for the direct addition, modification, or order adjustment of conditions in the rule condition list without requiring the rule base to be rebuilt, thereby improving the processing efficiency of business rules.

[0085] Furthermore, in step S20 above, the detailed steps for constructing the hash key value based on the target condition object instance and the fixed query condition array include:

[0086] Step A: Obtain the primary key value of the target condition object instance;

[0087] Step B involves concatenating the fixed query condition array with the primary key value of the target condition object instance to obtain the hash key value.

[0088] In this embodiment, the keyword rule engine can construct a hash key value after inputting the target condition object instance and the rule instance object structure value. The specific process of constructing the hash key value can be as follows: obtain the fixed query condition array in the rule instance object structure value, obtain the primary key value of the target condition object instance, concatenate the fixed query condition array with the primary key value of the target condition object instance to obtain the hash key value. The fixed query conditions are static, and the primary key value of the target condition object instance is a unique value. The primary key value can be id or index value to ensure that the id in the business rule table is unique.

[0089] The processing logic in this embodiment does not involve business rules. Therefore, when business conditions change, it is not necessary to rebuild the rule base. Only the structure value of the rule instance object needs to be changed to realize the function of the rule engine and improve the efficiency of business rule processing.

[0090] Furthermore, in step S30 above, the detailed step of constructing the combined key value based on the target condition object instance, the dynamic query condition array, and the classification combination condition array includes:

[0091] Step C: Obtain the primary key value of the target condition object instance;

[0092] Step D involves concatenating the dynamic query condition array, the category combination condition array, and the primary key value of the target condition object instance to obtain all the combined key values.

[0093] In this embodiment, after inputting the target condition object instance and rule instance object structure value in the keyword rule engine, all combined key values ​​can be constructed. The combined key value is the key value. Specifically, the specific process of constructing all combined key values ​​can be as follows: obtain the dynamic query condition array and the category combined condition array in the rule instance object structure value, obtain the primary key value of the target condition object instance, and concatenate the dynamic query condition array, the category combined condition array, and the primary key value of the target condition object instance to obtain all combined key values.

[0094] Further, the detailed steps of step D above, which involve concatenating the dynamic query condition array, the classification combination condition array, and the primary key value of the target condition object instance to obtain all the combined key values, include:

[0095] Step d1: Using a preset recursive algorithm, the dynamic query condition array is concatenated with the primary key value of the target condition object instance to obtain the combined condition;

[0096] Step d2 involves combining the classification combination conditions with the combination condition array to obtain all the combination key values.

[0097] In this embodiment, the process of constructing combined key values ​​based on dynamic query conditions is as follows: by using a preset recursive algorithm, the array of dynamic query conditions is concatenated with the primary key value of the target condition object instance to obtain combined conditions; the combined conditions are then multiplied with the array of categorized combined conditions to obtain all combined key values.

[0098] Specifically, step d1, which involves concatenating the dynamic query condition array with the primary key value of the target condition object instance to obtain the combined conditions, further includes:

[0099] Step d1: If there are multiple dynamic query condition arrays, then determine the target dynamic query condition array that is not empty in each of the dynamic query condition arrays;

[0100] Step d2: Concatenate the target dynamic query condition array and the primary key value of the target condition object instance according to the order of the preset business rules to obtain the combined conditions.

[0101] In this embodiment, firstly, a non-empty target dynamic query condition array is determined. Following a preset business rule, the target dynamic query condition array and the primary key values ​​of the target condition object instance are concatenated. A recursive algorithm is used to logically process the dynamic query condition array, assembling it into various combined conditions. For example, the dynamic query condition array may include "a", "a,b", and "a,b,c". Through the recursive algorithm, all combined conditions "a", "a,b,ab", and "a,b,c,ab,ac,bc,abc" are output in an orderly manner. Then, it is checked whether the combined condition array is empty. If a non-empty combined condition array is detected, the above combined conditions are multiplied by the combined condition array to obtain all combined key values. For example, if the combined condition is "a", "b,ab", "a,b,c,ab,ac,bc,abc", then the combined condition array is checked for emptiness. If it is found to be non-empty, the combined conditions are multiplied by the combined condition array to obtain all combined key values. Given the condition array "a, b, c, ab, ac, bc, abc", where x = 1, y = 2, and null, the combination conditions and the condition array are multiplied together. All combination key values ​​"a", "b", "c", "ab", "ac", "bc", "acb", "ax: 1", "ay: 2", "bx: 1", "cx: 1", ..., "abcy: 2" are output in an ordered manner. In this embodiment, the condition array can include multiple groups. The above logic algorithm is applied sequentially to different condition data to obtain all combination fields. Then, based on the hash key value and the combination key value array, the results are retrieved from the REIDS cache. The first result in the result set that is not empty is used as the business decision, and this result is output.

[0102] Furthermore, based on the first embodiment described above, a second embodiment of the execution method of the rule engine of the present invention is proposed. In this embodiment, before step S30, the step of obtaining the rule result from the rule engine based on the hash key value and the combined key value, the method further includes:

[0103] Step E: Obtain the newly added condition object instance and check whether there is a historical condition object instance corresponding to the newly added condition object instance in the rule engine;

[0104] Step F: If a historical condition object instance exists corresponding to the newly added condition object instance, then obtain the newly added primary key value of the newly added condition object instance.

[0105] Step G: Construct a new key value based on the newly added primary key value and the structure value of the rule instance object;

[0106] Step H: Store the newly added key value and the newly added primary key value in the rule engine.

[0107] In this embodiment, the process of storing business rules is as follows: First, obtain the newly added condition object instance, denoted as the new storage object. The new storage object may be a new condition or a rule change condition. Then, first obtain the new condition object instance and check if there is a corresponding historical condition object instance in the rule engine, which can be denoted as the original storage object. If there is a corresponding historical condition object instance, it indicates that the new storage object is a rule change condition that alters the original storage object. Then, obtain the new primary key value of the new condition object instance, i.e., obtain the new identifier of the new storage object. Construct a new key value based on the new primary key value and the rule instance object structure value. Specifically, construct a hash key value based on the new primary key value and the rule instance object structure value, and construct all combined key values. Store the hash key value, combined key values, and the new primary key value in the Redis hash.

[0108] Furthermore, if no historical condition object instance corresponds to the newly added condition object instance, it indicates that the newly added condition object instance is a newly added rule condition. In this case, the newly added primary key value of the newly added condition object instance is obtained, and a hash key value is constructed based on the newly added primary key value and the rule instance object structure value. All combined key values ​​are also constructed, and the hash key values, combined key values, and the newly added primary key value are stored in the Redis hash. Figure 4 As shown, the business rule is first written, and then the MySQL (database management system) determines the status of the business rule. If the business rule is effective, it is stored; if the business rule is invalid, it is deleted.

[0109] Furthermore, in step F above, after the step of finding a historical condition object instance corresponding to the newly added condition object instance, the method further includes:

[0110] Step G: Check whether the historical condition object instance is empty;

[0111] Step H: If the historical condition object instance is not empty, then delete the historical key value corresponding to the historical condition object instance.

[0112] In this embodiment, if a historical condition object instance exists corresponding to the newly added condition object instance, it is checked whether the historical condition object instance is empty. If the historical condition object instance is not empty, the original hash key value and the original combined key value corresponding to the historical condition object instance need to be deleted to replace the historical condition object instance with the newly added condition object instance. Specifically, first, the historical condition object instance is input, and the rule instance object structure value is input. The fixed query condition array in the rule instance object structure value is concatenated with the historical primary key value of the historical condition object instance to construct the hash key value corresponding to the historical condition object instance. The dynamic rule condition array and the classification combined condition array of the rule instance object are concatenated with the historical primary key value of the historical condition object instance to construct the key value. The hash key value and the key value are removed from the Redis hash.

[0113] In this embodiment, during business development, the execution method of the aforementioned rule engine needs to be relied upon in the POM file. An instantiated class is constructed according to the rule parameter class standard requirements based on the logic of the business rules. When a business rule takes effect, the rule storage method is called to store the rule. When an effective business rule is changed, the rule storage method is called again. When a business rule becomes invalid, the rule deletion method is called. When a business rule is applied, the rule result is retrieved. Figure 5 As shown, the process first retrieves business rules, combines hash keys, assembles fields using a recursive algorithm, calls `HGET key field` to return all hash field results from the Redis storage system, and extracts the first non-NULL unique identifier as the optimal result. Based on this unique identifier, the optimal result is then returned from the business rule base. This application's hash-based keyword rule engine is used in the development of business rule recommendation applications, simplifying the compilation of the rule base and improving development speed.

[0114] The present invention also provides an execution device for a rule engine, such as... Figure 3 The execution device of the rule engine shown includes: a condition acquisition module A10, used to determine the rule parameter class for assembling business rules, and obtain the rule instance object structure value according to the rule parameter class; a key value construction module A20, used to acquire condition object instances, construct hash key values ​​according to the condition object instances and the rule instance object structure value, and construct all combined key values; and a result acquisition module A30, used to obtain rule results from the rule engine according to the hash key values ​​and the combined key values. Specific embodiments of the execution device of the rule engine of the present invention are basically the same as the embodiments of the above-described rule engine execution method, and will not be described in detail here.

[0115] The present invention also provides an execution device for a rule engine, characterized in that the execution device includes a memory, a processor, and a rule engine execution program stored in the memory and executable on the processor. When the rule engine execution program is executed by the processor, it implements the steps of the rule engine execution method as described in any of the above embodiments. Specific embodiments of the rule engine execution device of the present invention are basically the same as the embodiments of the rule engine execution method described above, and will not be repeated here.

[0116] The present invention also provides a computer-readable storage medium storing a rule engine execution program, which, when executed by a processor, implements the steps of the rule engine execution method as described in any of the above embodiments. Specific embodiments of the computer-readable storage medium of the present invention are substantially the same as the embodiments of the rule engine execution method described above, and will not be repeated here.

[0117] It is understood that in the description of this specification, references to terms such as "one embodiment," "another embodiment," "other embodiments," or "first embodiment to Nth embodiment," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the present invention. In this specification, illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0118] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.

[0119] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0120] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.

[0121] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.

Claims

1. A method for executing a rule engine, characterized in that, The execution method of the rule engine includes the following steps: The rule instance object structure value is assembled according to a preset rule parameter class. The rule parameter class includes a fixed query condition frame, a dynamic rule condition frame, a non-empty dynamic frame, and a category combination condition frame. The fixed query condition frame is a required fixed condition used to assemble hash key values. The dynamic rule condition frame is a non-required condition used to assemble the key elements of the items in the hash key values. The category combination condition frame is used to assemble the key elements of the hash key value items according to different data types. The non-empty dynamic frame determines whether the dynamic condition is required based on the processing of business logic. The rule instance object structure value includes a fixed query condition array, a dynamic query condition array, and a category combination condition array. Obtain the target condition object instance, obtain the primary key value of the target condition object instance, and concatenate the fixed query condition array with the primary key value of the target condition object instance to obtain the hash key value; And obtain the primary key value of the target condition object instance; The dynamic query condition array is concatenated with the primary key value of the target condition object instance using a preset recursive algorithm. If there are multiple dynamic query condition arrays, the target dynamic query condition array that is not empty in each of the dynamic query condition arrays is determined. The target dynamic query condition array and the primary key value of the target condition object instance are concatenated according to the order of the preset business rules to obtain the combined conditions; The combination conditions are multiplied by the classification combination condition array to obtain all the combination key values; The rule results are obtained from the rule engine based on the hash key value and the combined key value.

2. The execution method of the rule engine as described in claim 1, characterized in that, Before the step of obtaining the rule result from the rule engine based on the hash key value and the combined key value, the method further includes: Obtain the newly added condition object instance and check whether there is a historical condition object instance corresponding to the newly added condition object instance in the rule engine; If a historical condition object instance exists corresponding to the newly added condition object instance, then the newly added primary key value of the newly added condition object instance is obtained; The new key value is constructed based on the newly added primary key value and the structure value of the rule instance object; The newly added key value and the newly added primary key value are stored in the rule engine.

3. The execution method of the rule engine as described in claim 2, characterized in that, Following the step of determining if a historical condition object instance exists corresponding to the newly added condition object instance, the method further includes: Check if the historical condition object instance is empty; If the historical condition object instance is not empty, then the corresponding historical key value of the historical condition object instance is deleted.

4. An execution device for a rule engine, characterized in that, The execution device of the rule engine includes: The condition acquisition module is used to assemble the structure value of a rule instance object according to a preset rule parameter class. The rule parameter class includes a fixed query condition frame, a dynamic rule condition frame, a non-empty dynamic frame, and a category combination condition frame. The fixed query condition frame consists of required fixed conditions used to assemble hash key values. The dynamic rule condition frame consists of optional conditions used to assemble key elements of items in the hash key values. The category combination condition frame is used to assemble key elements of hash key value items according to different data types. The non-empty dynamic frame determines whether dynamic conditions are required based on business logic processing. The structure value of the rule instance object includes a fixed query condition array, a dynamic query condition array, and a category combination condition array. The key value construction module is used to obtain a target condition object instance, obtain the primary key value of the target condition object instance, and concatenate the fixed query condition array with the primary key value of the target condition object instance to obtain a hash key value; The key value construction module is further configured to obtain the primary key value of the target condition object instance; concatenate the dynamic query condition array with the primary key value of the target condition object instance using a preset recursive algorithm; if multiple dynamic query condition arrays exist, determine the target dynamic query condition array that is not empty in each dynamic query condition array; concatenate the target dynamic query condition array and the primary key value of the target condition object instance according to the order of preset business rules to obtain combined conditions; multiply the combined conditions with the classification combined condition array to obtain all combined key values. The result acquisition module is used to obtain rule results from the rule engine based on the hash key value and the combined key value.

5. An execution device for a rules engine, characterized in that, The execution device of the rule engine includes a memory, a processor, and a rule engine execution program stored in the memory and executable on the processor, the rule engine execution program being configured to implement the steps of the rule engine execution method as described in any one of claims 1 to 3.

6. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a rule engine execution program, which, when executed by a processor, implements the steps of the rule engine execution method as described in any one of claims 1 to 3.