Rule management method and device

By providing a rule management method, users can customize rule parameters to generate target rules and generate execution code, solving the problems of high complexity and high learning cost of existing rule engines, and achieving the effect of simplifying rule management operations.

CN120163597APending Publication Date: 2025-06-17GIGACLOUD TECH (SUZHOU) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510143617.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-10
Publication Date
2025-06-17

AI Technical Summary

Technical Problem

In the prior art, the powerful rule engines on the market are complex and have high learning costs, making it difficult to effectively manage complex and frequently changing business rules.

Method used

Provides a rule management method. By receiving new requests and obtaining rule lists and rule templates, users can customize rule parameters to generate target rules and generate corresponding execution codes to simplify rule management operations.

Benefits of technology

It reduces the complexity and learning costs of users in rule management, simplifies the operation process, supports non-technical personnel to flexibly edit rules, and improves the efficiency of rule management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120163597A_ABST
    Figure CN120163597A_ABST
Patent Text Reader

Abstract

The invention discloses a rule management method and device, and belongs to the technical field of computers. The method comprises the steps that a new building request is received, a rule list is obtained according to a rule set identifier carried by the new building request, the rule list comprises at least one rule template, and the rule template comprises at least one blank leaving parameter; obtaining a first target rule, wherein the first target rule is obtained after a user-defined value is added to a blank leaving parameter in the rule template by a user; generating a first execution code corresponding to the first target rule; the problems of high complexity and high learning cost of a rule engine with powerful functions in the market in the prior art are solved; and the effect of simplifying the rule management operation of the user is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and particularly to a rule management method and apparatus. Background Art

[0002] Currently, companies such as online e-commerce, online car-hailing, and express delivery all use preset rules to manage or operate their businesses.

[0003] However, these businesses all have the characteristics of complex conditions and frequent changes. Taking logistics quotation as an example, this function is used in links such as order delivery and financial settlement. The involved quotation rules are very complex and are affected by many factors. Logistics companies, warehouses, delivery ranges, service methods, volume, weight, regions, whether to calculate fuel surcharges separately or charge peak-season surcharges, etc. will all affect the final quotation. In addition to complex conditions, the quotation rules often need to be adjusted according to policies and corporate strategies.

[0004] To address the challenges brought by complex and frequently changing rules, currently, powerful rule engines are provided in the market. It allows users to define complex business rules in a declarative manner and dynamically execute these rules at runtime. Its disadvantages are high complexity and high learning cost. Summary of the Invention

[0005] In order to solve the problems of high complexity and high learning cost of the powerful rule engines in the existing technology in the market, embodiments of the present invention provide a rule management method and apparatus. The technical solutions are as follows:

[0006] In a first aspect, a rule management method is provided. The method includes: receiving a new creation request, obtaining a rule list according to the rule set identifier carried in the new creation request, the rule list including at least one rule template, the rule template including at least one blank parameter; obtaining a first target rule, where the first target rule is obtained after the blank parameter in the rule template is added with a user-defined value; generating a first execution code corresponding to the first target rule.

[0007] Optionally, the rule template includes a condition part and a result part, the condition part and / or the result part include blank parameters, and the result part is the content to be executed after the condition part is satisfied.

[0008] Optionally, after obtaining the rule list according to the rule set identifier carried in the new creation request, the method further includes: displaying a user interface, and displaying the at least one rule template in the user interface; obtaining a first target rule obtained after the blank parameter in the at least one rule template is added with a user-defined value.

[0009] Optionally, after generating the first execution code corresponding to the first target rule, the method further includes: generating a first storage identifier for the first execution code; storing the first execution code and the corresponding first storage identifier in a code library.

[0010] Optionally, the new request carries a user identifier. After generating the first execution code corresponding to the first target rule, the method further includes: generating a first storage identifier and version information for the first execution code; storing the corresponding relationship between the first execution code and the first storage identifier, and the corresponding relationships among the first storage identifier, the user identifier, and the version information in a code library.

[0011] Optionally, the method further includes: receiving a rule replication request, where the rule replication request carries a first storage identifier corresponding to a rule to be replicated; obtaining the first execution code corresponding to the first storage identifier in the code library; creating a second storage identifier, and storing the first execution code and the second storage identifier in the code library in a corresponding manner.

[0012] Optionally, the method further includes: receiving an edit request carrying a third storage identifier; obtaining the first execution code corresponding to the third storage identifier, and displaying a first target rule and at least one rule template according to the first execution code; obtaining a second target rule, where the second target rule includes the first target rule and the rule template with custom values added by the user to the blank parameters; generating a second execution code according to the second target rule, and using the second execution code to replace the first execution code corresponding to the third storage identifier in the code library.

[0013] Optionally, the rule set identifier includes at least one of a freight rate quotation identifier and a product quotation identifier.

[0014] In a second aspect, a rule management device is provided. The device includes a processor and a memory; a program is stored in the memory, and the program is loaded and executed by the processor to perform any of the above rule management methods.

[0015] In a third aspect, a computer-readable storage medium is provided. A program is stored in the storage medium, and when the program is executed by a processor, it is used to implement any of the above rule management methods.

[0016] The beneficial effects brought by the technical solutions provided in the embodiments of the present invention are:

[0017] The rule management method provided by this application receives a new request, obtains a rule list according to the rule set identifier carried by the new request. The rule list includes at least one rule template, and the rule template includes at least one blank parameter; obtains a first target rule, where the first target rule is obtained after the user adds a custom value to the blank parameter in the rule template; generates a first execution code corresponding to the first target rule; solves the problem that the rule engines with powerful functions in the prior art have high complexity and high learning costs; and achieves the effect of simplifying the operation of the user for rule management. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0019] Figure 1 is a flowchart of the rule management method provided in an embodiment of the present invention;

[0020] Figure 2 is a flowchart of the rule management method provided in another embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0021] To make the objectives, technical solutions, and advantages of the present invention clearer, the following will further describe the embodiments of the present invention in detail with reference to the drawings. The "electronic device" mentioned in the text may include a smart phone, a tablet computer, a smart TV, an e-book reader, an MP3 player (Moving Picture Experts Group Audio Layer III), an MP4 (Moving Picture Experts Group Audio Layer IV) player, a laptop computer, a desktop computer, and so on.

[0022] Figure 1 is a flowchart of the rule management method provided in an embodiment of this application. This embodiment is described by taking the method being used in an electronic device with computing capabilities as an example. The electronic device may be a user terminal or a server. The user terminal includes, but is not limited to: a computer, a tablet computer, etc. The type of the electronic device is not limited in this embodiment. The method at least includes the following steps:

[0023] Step 101: Receive a new creation request, and obtain a rule list according to the rule set identifier carried in the new creation request. The rule list includes at least one rule template, and the rule template includes at least one blank parameter.

[0024] Among them, the corresponding relationship between the rule set identifier and the rule list can be preset by developers. Developers can set multiple rule templates for each business goal as needed to achieve the business goal. The rule template includes at least one blank parameter. Among them, the blank parameter is of a parameter type defined by the developer, but its specific value is to be user-defined.

[0025] Taking the business goal of logistics quotation as an example, the rule template may include over-length fee for volume, fuel surcharge, peak season fee, overweight fee, basic freight, cumulative output of fees, and so on.

[0026] In an example, the rule template may include a condition part and a result part. The condition part and / or the result part includes a blank parameter, and the result part is the content to be executed after the above condition part is satisfied. Taking the rule template for over-length fee as an example, the rule template for over-length fee may be if the lower limit value (blank parameter) < the longest side of the product <= the upper limit value (blank parameter), then the over-length fee is RMB A yuan, and A is a blank parameter. The rule for cumulative output of fees may be to accumulate the output result values of other rule templates of the logistics quotation to obtain the final logistics quotation fee.

[0027] Step 102: Obtain a first target rule, which is obtained after the blank parameter in the rule template is added with a user-defined value.

[0028] Step 103: Generate a first execution code corresponding to the first target rule.

[0029] In summary, the rule management method provided by this application receives a new creation request, obtains a rule list according to the rule set identifier carried in the new creation request. The rule list includes at least one rule template, and the rule template includes at least one blank parameter; obtains a first target rule, which is obtained after the blank parameter in the rule template is added with a user-defined value; generates a first execution code corresponding to the first target rule; solves the problems of high complexity and high learning cost of powerful rule engines in the existing technology in the market; and achieves the effect of simplifying the operation of users for rule management.

[0030] Figure 2It is a flowchart of a rule management method provided by an embodiment of the present application. In this embodiment, it is described by taking the method being used in an electronic device with computing capabilities as an example. The electronic device can be a user terminal or a server. The user terminal includes, but is not limited to: computers, tablets, etc. The type of the electronic device is not limited in this embodiment. The method at least includes the following steps:

[0031] Step 201, receive a new creation request, and obtain a rule list according to the rule set identifier carried in the new creation request. The rule list includes at least one rule template, and the rule template includes at least one blank parameter.

[0032] Among them, the corresponding relationship between the rule set identifier and the rule list can be preset by developers. The rule set identifier includes at least one of a freight rate quotation identifier and a product quotation identifier. Developers can set multiple rule templates for each business objective as needed to achieve the business objective. The rule template includes at least one blank parameter. Among them, the blank parameter is a parameter type defined by the developer, but its specific value is to be customized by the user.

[0033] Taking the business objective of logistics quotation as an example, the rule template can include over-length fee for volume, fuel surcharge, peak season fee, overweight fee, basic freight, cumulative fee output, etc.

[0034] In one example, the rule template can include a condition part and a result part. The condition part and / or the result part includes a blank parameter. The result part is the content to be executed after the above condition part is satisfied. Taking the rule template of over-length fee as an example, the rule template of over-length fee can be if the lower limit value (blank parameter) cm < the longest side of the product <= the upper limit value (blank parameter) cm, then the over-length fee is RMB A yuan, and A is a blank parameter. The cumulative fee output rule can be to accumulate the output result values of other rule templates of the logistics quotation to obtain the final logistics quotation fee.

[0035] Step 202, display a user interaction interface, and display the at least one rule template in the user interaction interface.

[0036] Specifically, the implementation of this step can be: display the at least one rule template, and input boxes are displayed at the blank parameter positions of each rule template for the user to add custom values.

[0037] Furthermore, a submit button can also be displayed in the user interaction interface. When it is detected that the submit button is triggered, step 203 is executed.

[0038] Step 203, obtain a first target rule in which the blank parameters in the at least one rule template are added with custom values by the user.

[0039] It should be noted that in the several rule templates displayed in the user interface, the user can select a rule template that meets their needs for editing, that is, selectively add custom values to the blank parameters of one or more rule templates.

[0040] Step 204: Generate the first execution code corresponding to the first target rule and its corresponding first storage identifier.

[0041] The implementation of this step can be as follows: Developers pre-set the corresponding running code for each rule template, and the specific values of the blank parameters in the running code are blank. When generating the first execution code corresponding to the first target rule, the custom values added by the user to the blank parameters in the target rule can be directly added to the running code.

[0042] Taking the rule template for the over-length fee as an example, if the lower limit value (blank parameter) cm < the longest side of the product <= the upper limit value (blank parameter) cm, then the over-length fee is RMB A yuan. The lower limit value added by the user as a custom value is 120, the upper limit value added by the user as a custom value is 150, and the over-length fee added by the user as a custom value is 5. Then the code in the condition part of the first execution code can be MVEL.leftLtRightLe(120, in.skuVar.maxLength, 150).

[0043] Furthermore, before executing step 205, the first execution code can be run to verify whether there are errors in the rules configured by the user.

[0044] Step 205: Store the first execution code and the first storage identifier corresponding to it in the code library.

[0045] Optionally, the new request in step 201 carries a user identifier. After generating the first execution code, generate its corresponding first storage identifier and version information; store the corresponding relationship between the first execution code and the first storage identifier, and the corresponding relationship between the first storage identifier, the user identifier, and the version information in the code library.

[0046] Steps 201 to 205 can implement the above functions through the configuration management module. The electronic device can also be provided with an actuator module, which is responsible for rule execution and mainly consists of five parts: rule loading, rule parsing, rule matching, rule execution, and runtime data, and can execute the first execution code. Specifically, the first execution code can be run when receiving a quotation request, and the fee calculation result obtained by running the first code can be output.

[0047] In summary, the rule management method provided by this application receives a new request, obtains a rule list according to the rule set identifier carried in the new request. The rule list includes at least one rule template, and the rule template includes at least one blank parameter; obtains a first target rule, which is obtained after the blank parameter in the rule template is added with a user-defined value by the user; generates a first execution code corresponding to the first target rule; solves the problem in the prior art that the rule engines with powerful functions in the market have high complexity and high learning costs; achieves the effect of simplifying the operation of users for rule management; provides an easy-to-operate rule management user interface, thus truly realizing the support for non-technical personnel to flexibly edit rules.

[0048] Optionally, the user can also copy the rule set function in the user interface to achieve efficient batch addition of rules. The specific implementation can be to display a copy button in the user interface, and when it is detected that the copy button is triggered, receive a rule copy request, which carries a first storage identifier corresponding to the rule to be copied; obtain the first execution code corresponding to the first storage identifier in the code library; create a second storage identifier, and store the first execution code and the second storage identifier in the code library in correspondence.

[0049] In an example, the rules edited by the user can be modified. The specific implementation can be: display an edit button in the user interface; receive an edit request carrying a third storage identifier, which is generated when the edit button is triggered; obtain the first execution code corresponding to the third storage identifier, and display the first target rule and at least one rule template according to the first execution code; obtain a second target rule, which includes the first target rule and the rule obtained after the blank parameter in the rule template is added with a user-defined value by the user; generate a second execution code according to the second target rule, and use the second execution code to replace the first execution code corresponding to the third storage identifier in the code library.

[0050] If the user needs to adjust the quotation rules related to weight, he can very conveniently customize the quotation methods for different weight ranges on the user interface, and the background will automatically convert the input on the page into the corresponding running code, such as the mvel expression. The mvel expression corresponding to the condition part is: MVEL.leftLtRightLe({calculatedWeight1},out.skuVar.calculatedWeight,{calculated Weight2},true); the mvel expression corresponding to the cost accumulation rule is: {factor1}+{factor2}*Math.ceil(out.skuVar.calculatedWeight-{factor3}).

[0051] In one embodiment of the present invention, a rule management device is provided. The device includes a processor and a memory. A program is stored in the memory and is loaded and executed by the processor to implement any one of the above rule management methods.

[0052] In one embodiment of the present invention, a computer-readable storage medium is provided. A program is stored in the storage medium and is used to implement any one of the above rule management methods when executed by a processor.

[0053] It should be noted that when the rule management device provided in the above embodiment processes services, only the division of the above program modules is used for illustration. In actual applications, the above functions can be allocated to different program modules according to needs, that is, the internal structure of the electronic device is divided into different program modules to complete all or part of the functions described above. In addition, the rule management device provided in the above embodiment and the embodiment of the rule management method belong to the same concept. For the specific implementation process, please refer to the method embodiment and will not be elaborated here.

[0054] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages and disadvantages of the embodiments.

[0055] Those of ordinary skill in the art can understand that all or part of the steps to implement the above embodiments can be completed by hardware, or can be completed by a program instructing relevant hardware. The program can be stored in a computer-readable storage medium. The above-mentioned storage medium can be a read-only memory, a disk, an optical disc, etc.

[0056] The above is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A rule management method, characterized in that: The method comprises: receiving a new creation request, and acquiring a rule list according to a rule set identifier carried in the new creation request, wherein the rule list includes at least one rule template, and the rule template includes at least one blank parameter; Acquire a first target rule, where the first target rule is obtained after a user adds a custom value to a blank parameter in the rule template; A first execution code corresponding to the first target rule is generated.

2. The method according to claim 1, characterized in that The rule template includes a condition part and a result part, the condition part and / or the result part include a blank parameter, and the result part is the content that needs to be executed after the condition part is satisfied.

3. The method according to claim 1, characterized in that After obtaining the rule list according to the rule set identifier carried by the creation request, the method further includes: Displaying a user interaction interface, displaying the at least one rule template in the user interaction interface; A first target rule is obtained by obtaining a blank parameter in the at least one rule template in which a user adds a custom value.

4. The method according to claim 1, characterized in that: After generating the first execution code corresponding to the first target rule, the method further includes: generating a first storage identifier of the first execution code; The first execution code and the first storage identifier are stored in a code library correspondingly.

5. The method according to claim 1, characterized in that The new creation request carries a user identifier. After the first execution code corresponding to the first target rule is generated, the method further includes: Generate a first storage identifier and version information of the first execution code; The correspondence between the first execution code and the first storage identifier, and the correspondence between the first storage identifier, the user identifier, and the version information are stored in a code library.

6. The method according to claim 1, characterized in that The method further comprises: receiving a rule copy request, wherein the rule copy request carries a first storage identifier corresponding to the rule to be copied; Obtaining a first execution code corresponding to the first storage identifier in the code library; A new second storage identifier is created, and the first execution code and the second storage identifier are stored in the code library in correspondence.

7. The method according to claim 1, characterized in that The method further comprises: receiving an edit request carrying a third storage identifier; Acquire a first execution code corresponding to the third storage identifier, and display a first target rule and at least one rule template according to the first execution code; Acquire a second target rule, where the second target rule includes the first target rule and a blank parameter in the rule template that is obtained after a user adds a custom value; A second execution code is generated according to the second target rule, and the first execution code corresponding to the third storage identifier is replaced in the code library by the second execution code.

8. The method according to claim 1, characterized in that The rule set identifier includes at least one of a freight quotation identifier and a product quotation identifier.

9. A rule management device, characterized in that: The device comprises a processor and a memory; a program is stored in the memory, and the program is loaded and executed by the processor to implement the rule management method according to any one of claims 1 to 8.

10. A computer-readable storage medium, characterized in that: The storage medium stores a program, and when the program is executed by the processor, it is used to implement the rule management method according to any one of claims 1 to 7.