Rule generation method and computing device
By configuring the page to generate rule expressions that can be recognized by the rule engine, the problem of low rule generation efficiency in the existing technology is solved, and efficient and flexible modification of rule generation is achieved.
Patent Information
- Application Number
- CN202510586461.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-07
- Publication Date
- 2025-09-19
AI Technical Summary
The existing technology has low efficiency in rule generation and is inefficient when rule codes need to be rewritten.
Get configuration information through the configuration page, generate rule expressions that can be recognized by the rule engine, and store them in the rule base. Modify the rules directly on the configuration page without rewriting the rule expressions.
It improves the efficiency of rule generation, reduces the steps for users to write rule codes, and enhances the flexibility of rule modification and addition.
Smart Images

Figure CN120669961A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computers, and in particular to a rule generation method and a computing device. Background Art
[0002] In some scenarios, you can complete task processing according to preset rules. For example, in a process approval scenario, you can complete the approval task according to the process approval rules.
[0003] In related technologies, preset rules can be written in the form of code to obtain rule codes, and the rule codes can be stored in a rule library. When tasks need to be processed according to preset rules, the rule codes in the rule library can be run through the rule engine to realize rule judgment of the task.
[0004] However, in the above method, when the preset rules need to be modified or added, the rule code needs to be rewritten, resulting in low efficiency in rule generation. Summary of the Invention
[0005] The embodiments of the present application provide a rule generation method and a computing device, which can improve the efficiency of rule generation.
[0006] In a first aspect, an embodiment of the present application provides a rule generation method, comprising:
[0007] Obtain configuration information entered on a configuration page, the configuration information including multiple conditions and conditional relationships between the conditions; generate a rule expression based on the configuration information, the rule expression being an expression recognizable by a rule engine; and store the rule expression in a rule library of the rule engine.
[0008] In a rule generation method provided in an embodiment of the present application, when a rule needs to be generated, the configuration information of the front end can be converted into a rule expression recognizable by the rule engine based on the configuration information entered by the user on the rule configuration page, and the rule expression is stored in the rule library of the rule engine. Through the above method, compared with the method of writing rule expressions to generate rules, this solution can directly configure the rules through the configuration page without the need for users to write them themselves, and when the rules need to be modified and added, they can be modified directly on the configuration page without rewriting the rule expression, thereby improving the efficiency of rule generation.
[0009] In one possible implementation, a regular expression is generated based on configuration information, including:
[0010] Determine engine information corresponding to the rule engine, where the engine information includes multiple target information types that the rule engine can identify;
[0011] According to the engine information, each condition in the configuration information is converted into a type to obtain multiple target conditions, and the condition relationship is processed to obtain the target relationship;
[0012] A regular expression is obtained by combining multiple target conditions and target relationships, and the regular expression includes multiple target conditions and target relationships.
[0013] In the above method, the engine information can be used to determine the type of information that the rule engine can recognize, so that each condition in the configuration information can be converted into a type to obtain multiple target conditions and target relationships that the rule engine can recognize, and then multiple target conditions and target relationships are combined to obtain a rule expression. There is no need for the user to write a rule expression. The configuration information can be directly converted into a rule expression through the rule engine, thereby improving the efficiency of rule generation.
[0014] In one possible implementation, for any condition, type conversion is performed on the condition based on engine information to obtain the target condition corresponding to the condition, including:
[0015] Determine first information and second information in the condition, where the information type of the first information is an information type recognizable by the rule engine, and the information type of the second information is an information type unrecognizable by the rule engine;
[0016] Performing type conversion processing on the second information according to the engine information to obtain third information;
[0017] The first information and the third information are processed by expression combination to obtain a target condition corresponding to the condition.
[0018] In the above method, the first information that can be recognized by the rule engine and the second information that cannot be recognized in the condition can be determined based on the engine information, and then the second information that cannot be recognized can be converted into third information that can be recognized, so that the rule engine can recognize the condition and improve the efficiency of rule generation.
[0019] In one possible implementation, the first information and the third information are processed by expression combination to obtain a target condition corresponding to the condition, including:
[0020] determining a first position of the first information in the condition and a second position of the second information in the condition;
[0021] According to the first position and the second position, the first information and the third information are subjected to expression combination processing to obtain a target condition, wherein the first information is located at the first position in the target condition and the third information is located at the second position in the target condition.
[0022] In the above method, the target condition is obtained by combining the positions of the first information and the third information, thereby improving the efficiency of rule generation.
[0023] In a second aspect, an embodiment of the present application provides a task processing method, including:
[0024] Obtaining a task processing request, where the task processing request includes task information of a target task, and the task information includes field values corresponding to multiple task fields;
[0025] In the rule engine's rule library, obtain the rule expression corresponding to the target task;
[0026] According to the rule expression, the task information is processed to obtain the task processing result corresponding to the target task.
[0027] In the above method, when task processing is required, the corresponding rule expression can be directly obtained from the rule library of the rule engine, which improves the efficiency of task processing compared to the method of rewriting the rule expression according to the task; at the same time, if the same task is repeatedly executed, the execution result of the corresponding historical task can be directly obtained without repeating the task processing, thereby improving the efficiency of task processing.
[0028] In one possible implementation, obtaining a rule expression corresponding to a target task from a rule library of a rule engine includes:
[0029] Obtaining a target task type and a historical task processing record of a target task, wherein the historical task processing record includes multiple historical task types and a regular expression corresponding to each historical task type;
[0030] If a first historical task type among the multiple historical task types is the same as the target task type, determining the regular expression corresponding to the first historical task type as the regular expression corresponding to the target task;
[0031] If the target task type does not exist in multiple historical task types, the corresponding relationship between multiple task types and multiple rule expressions is obtained in the rule library of the rule engine, and the rule expression corresponding to the target task is determined based on the target task type and the corresponding relationship.
[0032] In the above method, you can first determine whether there is a first historical task type that is the same as the target task type in the cached historical tasks. If so, the rule expression corresponding to the first historical task type is determined as the rule expression corresponding to the target task. If not, the rule expression is searched in the rule library of the rule engine. This can improve the efficiency of the search, thereby further improving the efficiency of task processing.
[0033] In one possible implementation, a rule expression includes multiple target conditions and target relationships, where the target relationship is an AND relationship or an OR relationship. Task information is processed according to the rule expression to obtain a task processing result corresponding to the target task, including:
[0034] Determine the task field corresponding to each target condition, and determine the condition execution result corresponding to the target condition based on the field value corresponding to the task field and the target condition;
[0035] According to the target relationship, a logical operation is performed on the multiple condition execution results corresponding to the multiple target conditions to obtain the task processing result. The logical operation is an AND operation or an OR operation.
[0036] In the above method, the condition execution result corresponding to each target condition can be determined first, and then the task processing result can be obtained according to the target relationship, thereby improving the efficiency of task processing.
[0037] In one possible implementation, determining a conditional execution result corresponding to the target condition based on a field value corresponding to the task field and the target condition includes:
[0038] If the field value corresponding to the task field meets the target condition, the condition execution result is determined to be the first result, and the first result is used to indicate that the target condition is met;
[0039] If the field value corresponding to the task field does not meet the target condition, the condition execution result is determined to be a second result, and the second result is used to indicate that the target condition is not met.
[0040] In the above method, if the field value corresponding to the task field meets the target condition, it means that the target condition is met; if the field value corresponding to the task field does not meet the target condition, it means that the target condition is not met, thereby determining the condition execution result corresponding to the target condition and improving the efficiency of task processing.
[0041] In one possible implementation, obtaining a rule expression corresponding to a target task from a rule base of a rule engine includes:
[0042] Get at least one historical task;
[0043] If the target task does not exist in at least one historical task, obtain the rule expression corresponding to the target task from the rule library of the rule engine;
[0044] The method also includes:
[0045] If there is a first historical task in the historical tasks that is the same as the target task, the task processing result of the first historical task is determined as the task processing result of the target task.
[0046] In the above method, if there is a first historical task that is the same as the target task, the task processing result of the first historical task is directly determined as the task processing result of the target task, which reduces the computational load of the computing device and improves the efficiency of task processing.
[0047] In a third aspect, an embodiment of the present application provides a rule generation device, comprising: a first acquisition module, a generation module, and a storage module, wherein:
[0048] The first acquisition module is used to acquire configuration information input on the configuration page, where the configuration information includes multiple conditions and conditional relationships between the conditions;
[0049] The generation module is used to generate a rule expression based on the configuration information, where the rule expression is an expression that can be recognized by the rule engine;
[0050] The storage module is used to store rule expressions in the rule base of the rule engine.
[0051] In a rule generation method provided in an embodiment of the present application, when a rule needs to be generated, the configuration information of the front end can be converted into a rule expression recognizable by the rule engine based on the configuration information entered by the user on the rule configuration page, and the rule expression is stored in the rule library of the rule engine. Through the above method, compared with the method of writing rule expressions to generate rules, this solution can directly configure the rules through the configuration page without the need for users to write them themselves, and when the rules need to be modified and added, they can be modified directly on the configuration page without rewriting the rule expression, thereby improving the efficiency of rule generation.
[0052] In one possible implementation, the generation module is specifically used to:
[0053] Determine engine information corresponding to the rule engine, where the engine information includes multiple target information types that the rule engine can identify;
[0054] According to the engine information, each condition in the configuration information is converted into a type to obtain multiple target conditions, and the condition relationship is processed to obtain the target relationship;
[0055] A regular expression is obtained by combining multiple target conditions and target relationships, and the regular expression includes multiple target conditions and target relationships.
[0056] In the above method, the engine information can be used to determine the type of information that the rule engine can recognize, so that each condition in the configuration information can be converted into a type to obtain multiple target conditions and target relationships that the rule engine can recognize, and then multiple target conditions and target relationships are combined to obtain a rule expression. There is no need for the user to write a rule expression. The configuration information can be directly converted into a rule expression through the rule engine, thereby improving the efficiency of rule generation.
[0057] In one possible implementation, the generation module is specifically used to:
[0058] Determine first information and second information in the condition, where the information type of the first information is an information type recognizable by the rule engine, and the information type of the second information is an information type unrecognizable by the rule engine;
[0059] Performing type conversion processing on the second information according to the engine information to obtain third information;
[0060] The first information and the third information are processed by expression combination to obtain a target condition corresponding to the condition.
[0061] In the above method, the first information that can be recognized by the rule engine and the second information that cannot be recognized in the condition can be determined based on the engine information, and then the second information that cannot be recognized can be converted into third information that can be recognized, so that the rule engine can recognize the condition and improve the efficiency of rule generation.
[0062] In one possible implementation, the generation module is specifically used to:
[0063] determining a first position of the first information in the condition and a second position of the second information in the condition;
[0064] According to the first position and the second position, the first information and the third information are subjected to expression combination processing to obtain a target condition, wherein the first information is located at the first position in the target condition and the third information is located at the second position in the target condition.
[0065] In the above method, the target condition is obtained by combining the positions of the first information and the third information, thereby improving the efficiency of rule generation.
[0066] In a fourth aspect, an embodiment of the present application provides a task processing device, comprising: a second acquisition module, a third acquisition module and a processing module, wherein:
[0067] The second acquisition module is used to obtain a task processing request, where the task processing request includes task information of the target task, and the task information includes field values corresponding to multiple task fields;
[0068] The third acquisition module is used to obtain the rule expression corresponding to the target task in the rule library of the rule engine;
[0069] The processing module is used to process the task information according to the regular expression to obtain the task processing result corresponding to the target task.
[0070] In the above method, when task processing is required, the corresponding rule expression can be directly obtained from the rule library of the rule engine, which improves the efficiency of task processing compared to the method of rewriting the rule expression according to the task; at the same time, if the same task is repeatedly executed, the execution result of the corresponding historical task can be directly obtained without repeating the task processing, thereby improving the efficiency of task processing.
[0071] In one possible implementation, the third acquisition module is specifically configured to:
[0072] Obtaining a target task type and a historical task processing record of a target task, wherein the historical task processing record includes multiple historical task types and a regular expression corresponding to each historical task type;
[0073] If a first historical task type among the multiple historical task types is the same as the target task type, determining the regular expression corresponding to the first historical task type as the regular expression corresponding to the target task;
[0074] If the target task type does not exist in multiple historical task types, the corresponding relationship between multiple task types and multiple rule expressions is obtained in the rule library of the rule engine, and the rule expression corresponding to the target task is determined based on the target task type and the corresponding relationship.
[0075] In the above method, you can first determine whether there is a first historical task type that is the same as the target task type in the cached historical tasks. If so, the rule expression corresponding to the first historical task type is determined as the rule expression corresponding to the target task. If not, the rule expression is searched in the rule library of the rule engine. This can improve the efficiency of the search, thereby further improving the efficiency of task processing.
[0076] In one possible implementation, the third acquisition module is specifically configured to:
[0077] Determine the task field corresponding to each target condition, and determine the condition execution result corresponding to the target condition based on the field value corresponding to the task field and the target condition;
[0078] According to the target relationship, a logical operation is performed on the multiple condition execution results corresponding to the multiple target conditions to obtain the task processing result. The logical operation is an AND operation or an OR operation.
[0079] In the above method, the condition execution result corresponding to each target condition can be determined first, and then the task processing result can be obtained according to the target relationship, thereby improving the efficiency of task processing.
[0080] In one possible implementation, the third acquisition module is specifically configured to:
[0081] If the field value corresponding to the task field meets the target condition, the condition execution result is determined to be the first result, and the first result is used to indicate that the target condition is met;
[0082] If the field value corresponding to the task field does not meet the target condition, the condition execution result is determined to be a second result, and the second result is used to indicate that the target condition is not met.
[0083] In the above method, if the field value corresponding to the task field meets the target condition, it means that the target condition is met; if the field value corresponding to the task field does not meet the target condition, it means that the target condition is not met, thereby determining the condition execution result corresponding to the target condition and improving the efficiency of task processing.
[0084] In one possible implementation, the third acquisition module is specifically configured to:
[0085] Get at least one historical task;
[0086] If the target task does not exist in at least one historical task, obtain the rule expression corresponding to the target task from the rule library of the rule engine;
[0087] The method also includes:
[0088] If there is a first historical task in the historical tasks that is the same as the target task, the task processing result of the first historical task is determined as the task processing result of the target task.
[0089] In the above method, if there is a first historical task that is the same as the target task, the task processing result of the first historical task is directly determined as the task processing result of the target task, which reduces the computational load of the computing device and improves the efficiency of task processing.
[0090] In a fifth aspect, an embodiment of the present application provides a computing device, the computing device including a memory and a processor;
[0091] Memory and processor coupling;
[0092] The memory is used to store program instructions;
[0093] The processor is configured to call program instructions so that the computing device executes the rule generation method involved in the first aspect and any possible implementation manner.
[0094] In a sixth aspect, an embodiment of the present application provides a computing device, the computing device including a memory and a processor;
[0095] Memory and processor coupling;
[0096] The memory is used to store program instructions;
[0097] The processor is used to call program instructions to enable the computing device to execute the task processing method involved in the second aspect and any possible implementation manner.
[0098] In the seventh aspect, an embodiment of the present application provides a computer-readable storage medium, which stores computer execution instructions. When the computer execution instructions are executed by an electronic device, they are used to implement the rule generation method involved in the first aspect and any possible implementation method.
[0099] In an eighth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer execution instructions are stored. When the computer execution instructions are executed by an electronic device, they are used to implement the task processing method involved in the second aspect and any possible implementation method.
[0100] In a ninth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by an electronic device, implements the rule generation method involved in the first aspect and any possible implementation method.
[0101] In a tenth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by an electronic device, implements the task processing method involved in the second aspect and any possible implementation method.
[0102] In the rule generation method and computing device shown in the embodiments of the present application, when it is necessary to generate a rule, the configuration information entered by the user in the configuration interface can be obtained, and then, based on the configuration information, the configuration information is converted into a regular expression that can be recognized by the rule engine through the expression generation engine, and the regular expression is stored in the rule library of the rule engine. In this way, when the user needs to use the corresponding rule, the required rule can be directly called from the rule library. At the same time, compared to the method of generating rules by writing code, only the corresponding configuration information needs to be entered in the configuration interface, and the expression generation engine can directly convert it into a regular expression that can be recognized by the rule engine, thereby improving the efficiency of rule generation. BRIEF DESCRIPTION OF THE DRAWINGS
[0103] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0104] Figure 1 A schematic diagram of the application scenario architecture provided by the embodiment of the present application;
[0105] Figure 2 A schematic diagram of the system architecture provided in an embodiment of the present application;
[0106] Figure 3 A flowchart of a rule generation method provided in an embodiment of the present application;
[0107] Figure 4 A schematic diagram of a configuration page of a rule generation system provided in an embodiment of the present application;
[0108] Figure 5 A schematic diagram of the process of generating a regular expression based on configuration information provided in an embodiment of the present application;
[0109] Figure 6 A flowchart of a task processing method provided in an embodiment of the present application;
[0110] Figure 7 A schematic diagram of the structure of a rule generation device provided in an embodiment of the present application;
[0111] Figure 8 A schematic diagram of the structure of a task processing device provided in an embodiment of the present application;
[0112] Figure 9 A schematic diagram of the structure of a computing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0113] Exemplary embodiments are described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numbers in different figures represent identical or similar elements, unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all possible implementations consistent with the present invention. Rather, they are merely examples of apparatuses and methods consistent with certain aspects of the present invention, as detailed in the appended claims.
[0114] To facilitate understanding, the technical terms involved in the embodiments of this application are first explained.
[0115] Rule Engine: A rule engine is a component embedded in an application that defines, manages, and executes a set of rules or logic. By separating business rules from the core application code, a rule engine allows users to dynamically manage and modify these rules without changing the application code.
[0116] Rule base: A rule engine usually includes a rule base for storing rule expressions.
[0117] For ease of understanding, the following Figure 1 and Figure 2 , describes the application scenarios involved in the embodiments of this application.
[0118] Figure 1 For the application scenario architecture diagram provided in this application embodiment, please see Figure 1 , including a terminal device and a computing device. The terminal device can be a user's local device. The browser on the terminal device can display the configuration interface corresponding to the rule generation system, where the user can configure the rules. The browser on the terminal device can also display the approval interface corresponding to the rule generation system, where the user can enter task information for the task to be approved and submit the task for approval. The computing device can be a server device. The computing device can be equipped with a rule engine for converting the configuration information entered by the user on the terminal device into executable rule expressions and for processing the task to be approved.
[0119] Figure 2 For a schematic diagram of the system architecture provided in this application embodiment, please see Figure 2 , including a user interaction layer, an extension layer, and an execution layer. The user interaction layer may include a rule configuration interface and a factor configuration interface, and users may configure rules through the configuration interface of the interaction layer. The extension layer may include an expression generation engine and an operator extension engine. The expression generation engine may convert the types of rules configured in the configuration interface to obtain rule expression types that can be recognized by the rule generation system; the operator extension engine may extend the operators of various rule expressions through the interface, for example, it may extend the include operator, intersection operator, union operator, etc. The execution layer may include cache management and a rule execution engine. The rule execution engine may be used to process tasks according to rule expressions; and the cache management may be used to cache the processing results of tasks executed according to rule expressions.
[0120] In an embodiment of the present application, when rules need to be generated, the configuration information of the front end can be converted into a rule expression that can be recognized by the rule engine based on the configuration information entered by the user on the rule configuration page, and the rule expression is stored in the rule library of the rule engine. Through the above method, compared with the method of writing rule expressions to generate rules, this solution can directly configure rules through the configuration page without the need for users to write them themselves, and when rules need to be modified or added, they can be modified directly on the configuration page without rewriting the rule expression, thereby improving the efficiency of rule generation.
[0121] The technical solutions shown in this application are described in detail below through specific embodiments. It should be noted that the following embodiments can exist independently or in combination with each other, and the same or similar contents will not be repeated in different embodiments.
[0122] Figure 3 This is a flowchart of a rule generation method provided in an embodiment of the present application. Figure 3 , the method may include:
[0123] S301. Obtain configuration information entered on the configuration page.
[0124] The execution subject of the embodiments of the present application may be a computing device, or a rule generation device provided in the computing device. The computing device may be a server or other device. The rule generation device may be implemented by software, or by a combination of software and hardware.
[0125] Configuration information may include multiple conditions and conditional relationships between the conditions.
[0126] Conditions can be formed by parameters, operators, and values. Parameters can be descriptive names of conditions; operators can be used to indicate the relationship between parameters and values. For example, operators can include greater than, less than, and equal to. Optionally, operators can also include intersection, union, contains, and does not contain. Values can be the specific value corresponding to the condition, and can be in numeric or string form.
[0127] For example, assuming the parameter of condition 1 is "contract", the operator is "equal to", and the value is "standard contract", then condition 1 can be: contract equals standard contract; assuming the parameter of condition 2 is "number of applications", the operator is "less than", and the value is "5", then condition 2 can be: number of applications is less than 5.
[0128] Conditional relationships can be used to indicate the relationship between two or more conditions. These can include "and" and "or" relationships. For example, a conditional relationship could be "condition 1 is met AND condition 2 is met," or "condition 1, condition 2, or condition 3 is met."
[0129] The configuration page may refer to a browser page corresponding to the rule generation system displayed on the user's terminal device. The user can enter configuration information in the configuration interface to configure the rules. The configuration page may include multiple controls, such as condition controls and relationship controls. The user can enter configuration information by interacting with multiple controls on the configuration page. For example, the user can enter multiple conditions corresponding to the configuration information by interacting with multiple condition controls, or enter conditional relationships between multiple conditions corresponding to the configuration information by interacting with multiple relationship controls.
[0130] Next, combine Figure 4 , through specific examples, the configuration page of the rule generation system is explained.
[0131] Figure 4 For a schematic diagram of the configuration page of the rule generation system provided in the embodiment of this application, please see Figure 4 , the configuration page can include multiple condition controls and multiple relationship controls, and users can enter corresponding information in the controls through click interaction. Figure 4 In the configuration page shown, relationship control 1 can correspond to the relationship between relationship control 2, relationship control 3 and relationship control 4, wherein relationship control 2 can correspond to the relationship between condition control 1 and condition control 2; relationship control 3 can correspond to the relationship between condition control 3, condition control 4, condition control 5 and relationship control 5, and relationship control 5 corresponds to the relationship between condition control 9 and relationship control 7, and relationship control 7 corresponds to the relationship between condition control 12 and condition control 13; relationship control 4 can correspond to the relationship between condition control 6, condition control 7, condition control 8 and relationship control 6, and relationship control 6 corresponds to the relationship between condition control 10 and condition control 11.
[0132] S302: Generate a regular expression according to the configuration information.
[0133] The rule expression may be an expression executable by a rule engine. The rule engine may be an application within a computing device that can execute corresponding rules according to the rule expression.
[0134] A rule expression can be generated in the following manner: determining the engine information corresponding to the rule engine, the engine information including multiple target information types that the rule engine can recognize; performing type conversion processing on each condition in the configuration information according to the engine information to obtain multiple target conditions, and performing type conversion processing on the condition relationship to obtain the target relationship; combining multiple target conditions and target relationships to obtain a rule expression, which includes multiple target conditions and target relationships.
[0135] The multiple target information types may include a number type, a string type, etc. Optionally, the multiple target information types may also refer to a program language type.
[0136] For example, if the configuration information is "amount exceeds 100 yuan", after performing type conversion on the configuration information, the rule expression can be obtained as "amount > 100".
[0137] S303: Store the rule expression in the rule base of the rule engine.
[0138] The rule base of the rule engine may be located in a preset storage space of the computing device, and the rule base may store multiple rule expressions.
[0139] Optionally, the preset storage space of the computing device may also include a cache space. When the user calls the target rule from the rule library to execute the target task, the execution result of the target task can be stored in the cache space. In this way, when the user calls the target rule from the rule library again to execute the current task, it can first be determined whether the current task and the target task are consistent. If they are consistent, the execution result of the target task can be directly obtained from the cache space without re-executing according to the target rule, thereby improving the efficiency of task processing.
[0140] exist Figure 3 In the illustrated embodiment, when rules need to be generated, the configuration information entered by the user on the configuration interface can be obtained. Based on the configuration information, the expression generation engine converts the configuration information into a regular expression recognizable by the rule engine, and the regular expression is stored in the rule library of the rule engine. In this way, when the user needs to use the corresponding rule, the required rule can be directly called from the rule library. At the same time, compared to the method of generating rules by writing code, only the corresponding configuration information needs to be entered on the configuration interface, and the expression generation engine can directly convert it into a regular expression recognizable by the rule engine, thereby improving the efficiency of rule generation.
[0141] Based on the above embodiments, Figure 5 , the process of generating regular expressions based on configuration information ( Figure 3 S302 in the embodiment is described in detail.
[0142] Figure 5 This is a schematic diagram of the process of generating a regular expression based on configuration information provided in the embodiment of the present application. Figure 5 As shown, see Figure 5 , the method may include:
[0143] S501: Determine engine information corresponding to the rule engine.
[0144] The engine information includes multiple target information types that can be identified by the rule engine.
[0145] The various target information types that the rule engine can identify may include string types, number types, etc. The various target information types may also refer to programming language types that the rule engine can identify, such as Java language, C programming language, etc.
[0146] S502: For any condition in the configuration information, determine the first information and the second information in the condition.
[0147] The first information and the second information can be determined in the following manner: for any condition, the condition is extracted and processed to obtain the parameters, operators and values corresponding to the condition; the information types of the parameters, operators and values are determined respectively, so as to determine the information types corresponding to the parameters, operators and values respectively; according to the information type, the first information and the second information in the condition are determined, wherein the information type of the first information is an information type that can be recognized by the rule engine, and the information type of the second information is an information type that cannot be recognized by the rule engine.
[0148] For example, assuming that the engine information is of English type, symbol type and numeric type, and the condition is: age is greater than 18, then after extracting and processing the condition, the corresponding parameter can be obtained as "age", the corresponding operator is "greater than", and the corresponding value is "18". Among them, the information type of the parameter and operator is of Chinese type, which does not belong to the information type that the rule engine can recognize, so the parameter and operator are the second information; the information type of the value is of numeric type, which belongs to the information type that the rule engine can recognize, so the value is the first information.
[0149] S503: Perform type conversion on the second information according to the engine information to obtain third information.
[0150] The expression generation engine in the computing device may perform type conversion on the second information, that is, convert the second information into third information, where the information type of the third information is an information type recognizable by the rule engine.
[0151] For example, assuming that the engine information is of English type, symbol type, and number type, if the second information is "age", then after type conversion processing, the third information obtained can be "age"; if the second information is "greater than", then after type conversion processing, the third information obtained can be ">".
[0152] S504: Determine a first position of the first information in the condition and a second position of the second information in the condition.
[0153] For any condition, the parameters, operators, and values can be included in order from left to right, where the position corresponding to the parameter is position 1, the position corresponding to the operator is position 2, and the position corresponding to the value is position 3.
[0154] For example, assuming that the first information is an operator, the first position of the first information in the condition is position 2; assuming that the second information is a parameter and a value, the second position of the second information in the condition is position 1 and position 3.
[0155] S505: Perform expression combination processing on the first information and the third information according to the first position and the second position to obtain a target condition.
[0156] The first information is located at a first position in the target condition, and the third information is located at a second position in the target condition.
[0157] S506: Perform type conversion on the conditional relationship in the configuration information to obtain the target relationship.
[0158] The expression generation engine can be used to perform type conversion on the conditional relationship, thereby converting the conditional relationship into an information type that can be recognized by the rule engine.
[0159] For example, assuming that the engine information is of English type, when the conditional relationship is an "and relationship", after the conditional relationship is type-converted, the target relationship obtained is "and"; when the conditional relationship is an "or relationship", after the conditional relationship is type-converted, the target relationship obtained is "or".
[0160] It should be noted that there is no sequential order in the execution order between the above steps S502-S505 and step S506, that is, steps S502-S505 can be executed first, and then step S506; step S506 can be executed first, and then step S502-S505; or steps S502-S505 and step S506 can be executed at the same time.
[0161] S507: Combine multiple target conditions and target relationships to obtain a regular expression.
[0162] The rule expression includes multiple target conditions and target relationships.
[0163] According to the configuration information, the combination relationship between multiple target conditions and target relationships can be determined.
[0164] For example, assuming that the target relationship corresponds to the relationship between the first target condition and the second target condition, the target relationship is "and", the first target condition is "age>18", and the second target condition is "id=VIP", then the rule expression can be obtained as "age>18 and id=VIP".
[0165] exist Figure 5 In the illustrated embodiment, when a rule needs to be generated, a rule expression can be generated based on configuration information. Engine information corresponding to the rule engine can be determined. The engine information can refer to multiple target information types recognizable by the rule engine. The configuration information can include multiple conditions and conditional relationships between the multiple conditions. For any condition within the configuration information, first information and second information are determined within the condition, where the information type of the first information is an information type recognizable by the rule engine and the information type of the second information is an information type not recognizable by the rule engine. The first position of the first information within the condition and the second position of the second information within the condition are determined, respectively. Based on the first position and the second position, the first information and the third information are combined to obtain a target condition. The conditional relationship within the configuration information is converted to a type to obtain a target relationship. Multiple target conditions and target relationships are combined to obtain a rule expression. In this way, based on the configuration information, by performing type conversion on multiple conditions and conditional relationships, the configuration information input by the user is converted into a rule expression recognizable by the rule engine. This improves the efficiency of rule generation compared to a method that requires the user to edit the rule expression.
[0166] Figure 6 This is a flowchart of a task processing method provided in an embodiment of the present application. Figure 6 , the method may include:
[0167] S601: Obtain a task processing request.
[0168] The execution subject of the embodiments of the present application may be a computing device, or a task processing device provided in the computing device. The computing device may be a server or other device. The task processing device may be implemented by software, or by a combination of software and hardware.
[0169] The task processing request may be used to request a computing device to process a target task. The task processing request may include task information of the target task, wherein the task information may include field values corresponding to multiple task fields.
[0170] A task field can refer to multiple parameters required to process the target task. For example, if the target task is "Approval Plan Passed," multiple task fields can include "Content Rating," "Scheme Priority," "Execution Risk," and so on. In this case, the value corresponding to the "Content Rating" task field in the task information can be "Level 3," the value corresponding to the "Scheme Priority" task field in the task information can be "Level 1," and the value corresponding to the "Execution Risk" task field in the task information can be "High."
[0171] S602: Obtain a rule expression corresponding to the target task from the rule library of the rule engine.
[0172] The rule base of the rule engine may refer to a storage space within a computing device for storing multiple rule expressions.
[0173] A rule expression may refer to an expression that can be recognized by a rule engine, and the rule engine may execute a corresponding target task according to the rule expression.
[0174] The rule expression corresponding to the target task can be obtained in the following manner: obtain the target task type of the target task, and the historical task processing record, the historical task processing record includes multiple historical task types, and the rule expression corresponding to each historical task type; if the first historical task type among the multiple historical task types is the same as the target task type, then the rule expression corresponding to the first historical task type is determined as the rule expression corresponding to the target task; if the target task type does not exist among the multiple historical task types, in the rule library of the rule engine, obtain the correspondence between the multiple task types and the multiple rule expressions, and determine the rule expression corresponding to the target task based on the target task type and the correspondence.
[0175] The target task type may refer to the task type corresponding to the target task. For example, the task type may include a plan approval type, a contract approval type, a business approval type, etc. A corresponding rule expression may exist for any task type.
[0176] Obtaining the regular expression corresponding to the target task also includes: if there is a first historical task in the historical tasks that is the same as the target task, then the task processing result of the first historical task can be directly determined as the task processing result of the target task.
[0177] S603: Process the task information according to the rule expression to obtain a task processing result corresponding to the target task.
[0178] The rule expression includes multiple target conditions and target relationships, and the target relationship may include an AND relationship and an OR relationship.
[0179] The task processing result corresponding to the target task can be determined by: determining the task field corresponding to each target condition, and determining the condition execution result corresponding to the target condition based on the field value corresponding to the task field and the target condition; performing a logical operation on the multiple condition execution results corresponding to the multiple target conditions based on the target relationship to obtain the task processing result, where the logical operation is an AND operation or an OR operation. The task processing result can include "yes" and "no".
[0180] The condition execution result corresponding to the target condition can be determined in the following manner: if the field value corresponding to the task field meets the target condition, the condition execution result is determined to be the first result, and the first result is used to indicate that the target condition is met; if the field value corresponding to the task field does not meet the target condition, the condition execution result is determined to be the second result, and the second result is used to indicate that the target condition is not met.
[0181] For example, assuming that the rule expression includes two target conditions, target condition 1 is: contract type is equal to business type, target condition 2 is: contract signing time is greater than 2024, and the target relationship between target condition 1 and target condition 2 is: and relationship, then, the task field corresponding to target condition 1 is "contract type", and the task field corresponding to target condition 2 is "contract signing time". If the field value of the task field corresponding to target condition 1 is "financial type", then the conditional execution result of target condition 1 can be determined to be the second result. If the field value of the task field corresponding to target condition 2 is "2025", then the conditional execution result of target condition 2 can be determined to be the first result. By performing an and operation on the conditional execution results according to the target relationship, it can be obtained that the task processing result is no, that is, the task processing of the target task is correct.
[0182] exist Figure 6 In the illustrated embodiment, when a task needs to be processed, a task processing request can be first obtained, wherein the task processing request can be used to request a computing device to process a target task, and the task processing request can include task information of the target task; based on the target task, a rule expression corresponding to the target task is obtained from the rule base of the rule engine; based on the rule expression, the task information is processed to obtain a task processing result corresponding to the target task. Through the above method, when task processing is required, the corresponding rule expression can be directly obtained from the rule base of the rule engine, which improves the efficiency of task processing compared to the method of rewriting the rule expression based on the task; at the same time, if the same task is repeatedly executed, the execution result of the corresponding historical task can be directly obtained without repeating the task processing, thereby improving the efficiency of task processing.
[0183] Figure 7 This is a schematic diagram of the structure of a rule generation device provided in an embodiment of the present application. Figure 7The rule generating device 10 may include: a first acquiring module 11, a generating module 12 and a storing module 13, wherein:
[0184] The first acquisition module 11 is used to acquire configuration information input on the configuration page, where the configuration information includes multiple conditions and the conditional relationships between the conditions;
[0185] The generating module 12 is used to generate a regular expression according to the configuration information, where the regular expression is an expression that can be recognized by the rule engine;
[0186] The storage module 13 is used to store the rule expression in the rule base of the rule engine.
[0187] The rule generation device provided in this embodiment can be used to execute the rule generation method shown in the above method embodiment. Its implementation principle and technical effects are similar and will not be described in detail here.
[0188] In a possible implementation, the generating module 12 is specifically configured to:
[0189] Determine engine information corresponding to the rule engine, where the engine information includes multiple target information types that the rule engine can identify;
[0190] According to the engine information, each condition in the configuration information is converted into a type to obtain multiple target conditions, and the condition relationship is processed to obtain the target relationship;
[0191] A regular expression is obtained by combining multiple target conditions and target relationships, and the regular expression includes multiple target conditions and target relationships.
[0192] In a possible implementation, the generating module 12 is specifically configured to:
[0193] Determine first information and second information in the condition, where the information type of the first information is an information type recognizable by the rule engine, and the information type of the second information is an information type unrecognizable by the rule engine;
[0194] Performing type conversion processing on the second information according to the engine information to obtain third information;
[0195] The first information and the third information are processed by expression combination to obtain a target condition corresponding to the condition.
[0196] In a possible implementation, the generating module 12 is specifically configured to:
[0197] determining a first position of the first information in the condition and a second position of the second information in the condition;
[0198] According to the first position and the second position, the first information and the third information are subjected to expression combination processing to obtain a target condition, wherein the first information is located at the first position in the target condition and the third information is located at the second position in the target condition.
[0199] The rule generation device provided in this embodiment can be used to execute the rule generation method shown in the above method embodiment. Its implementation principle and technical effects are similar and will not be described in detail here.
[0200] Figure 8 This is a structural diagram of a task processing device provided in an embodiment of the present application. Figure 8 The task processing device 20 may include: a second acquisition module 21, a third acquisition module 22 and a processing module 23, wherein:
[0201] The second acquisition module 21 is used to acquire a task processing request, where the task processing request includes task information of a target task, and the task information includes field values corresponding to multiple task fields;
[0202] The third acquisition module 22 is used to obtain the rule expression corresponding to the target task from the rule library of the rule engine;
[0203] The processing module 23 is used to process the task information according to the regular expression to obtain the task processing result corresponding to the target task.
[0204] The task processing device provided in this embodiment can be used to execute the task processing method shown in the above method embodiment. Its implementation principle and technical effects are similar and will not be described in detail here.
[0205] In a possible implementation, the third obtaining module 22 is specifically configured to:
[0206] Obtaining a target task type and a historical task processing record of a target task, wherein the historical task processing record includes multiple historical task types and a regular expression corresponding to each historical task type;
[0207] If a first historical task type among the multiple historical task types is the same as the target task type, determining the regular expression corresponding to the first historical task type as the regular expression corresponding to the target task;
[0208] If the target task type does not exist in multiple historical task types, the corresponding relationship between multiple task types and multiple rule expressions is obtained in the rule library of the rule engine, and the rule expression corresponding to the target task is determined based on the target task type and the corresponding relationship.
[0209] In a possible implementation, the third obtaining module 22 is specifically configured to:
[0210] Determine the task field corresponding to each target condition, and determine the condition execution result corresponding to the target condition based on the field value corresponding to the task field and the target condition;
[0211] According to the target relationship, a logical operation is performed on the multiple condition execution results corresponding to the multiple target conditions to obtain the task processing result. The logical operation is an AND operation or an OR operation.
[0212] In a possible implementation, the third obtaining module 22 is specifically configured to:
[0213] If the field value corresponding to the task field meets the target condition, the condition execution result is determined to be the first result, and the first result is used to indicate that the target condition is met;
[0214] If the field value corresponding to the task field does not meet the target condition, the condition execution result is determined to be a second result, and the second result is used to indicate that the target condition is not met.
[0215] In a possible implementation, the third obtaining module 22 is specifically configured to:
[0216] Get at least one historical task;
[0217] If the target task does not exist in at least one historical task, obtain the rule expression corresponding to the target task from the rule library of the rule engine;
[0218] The method also includes:
[0219] If there is a first historical task in the historical tasks that is the same as the target task, the task processing result of the first historical task is determined as the task processing result of the target task.
[0220] The task processing device provided in this embodiment can be used to execute the task processing method shown in the above method embodiment. Its implementation principle and technical effects are similar and will not be described in detail here.
[0221] Figure 9 A schematic diagram of the structure of a computing device provided in an embodiment of the present application is shown in FIG. Figure 9 As shown, the computing device 30 may include: a memory 31 and a processor 32;
[0222] Among them, the memory 31 and the processor 32 are coupled and can communicate with each other; illustratively, the memory 31 and the processor 32 communicate through a communication bus 33, the memory 31 is used to store computer execution instructions, and the processor 32 is used to call program instructions to enable the electronic device to execute the rule generation method involved in the first aspect and any possible implementation, and execute the task processing method involved in the second aspect and any possible implementation.
[0223] Optionally, the processor may be a central processing unit (CPU), a graphics processing unit (GPU), other general-purpose processors, a digital signal processor (DSP), or an application-specific integrated circuit (ASIC). A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the embodiments of the present application may be directly implemented as being executed by a hardware processor, or may be implemented by a combination of hardware and software modules in the processor.
[0224] An embodiment of the present application provides a computer-readable storage medium, which stores computer execution instructions. When the computer execution instructions are executed by an electronic device, they are used to implement the rule generation method involved in the first aspect and any possible implementation method, and to execute the task processing method involved in the second aspect and any possible implementation method.
[0225] An embodiment of the present application provides a computer program product, including a computer program, which, when executed by an electronic device, implements the rule generation method involved in the first aspect and any possible implementation, and executes the task processing method involved in the second aspect and any possible implementation.
[0226] All or part of the steps in the above-described method embodiments may be implemented by hardware associated with program instructions. The aforementioned program may be stored in a readable memory. When executed, the program performs the steps of the above-described method embodiments. The aforementioned memory (storage medium) includes: read-only memory (ROM), RAM, flash memory, hard disk, solid-state drive, magnetic tape, floppy disk, optical disc, and any combination thereof.
[0227] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable terminal device to generate a machine, so that the instructions executed by the processing unit of the computer or other programmable terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0228] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0229] These computer program instructions can also be loaded onto a computer or other programmable terminal device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable device to implement the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0230] Obviously, those skilled in the art may make various changes and modifications to the embodiments of the present application without departing from the spirit and scope of the embodiments of the present application. Thus, if these modifications and variations of the embodiments of the present application fall within the scope of the claims of the present application and their equivalents, the embodiments of the present application are intended to include such modifications and variations.
[0231] In the embodiments of the present application, the terms "include", "comprise" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising 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, an element defined by the sentence "comprising a ..." does not exclude the presence of other identical elements in the process, method, article or device comprising the element. The term "or" and its variations may refer to "and / or". In the embodiments of the present application, the terms "first", "second", etc. are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. In the embodiments of the present application, "multiple" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are in an "or" relationship.
[0232] Those skilled in the art will readily conceive of other embodiments of the present application after considering the invention disclosed in the specification and practice. The embodiments of the present application are intended to cover any variations, uses, or adaptations of the embodiments of the present application, which follow the general principles of the embodiments of the present application and include common knowledge or customary technical means in the art that are not disclosed in the embodiments of the present application.
Claims
1. A rule generation method, characterized in that: include: Obtaining configuration information entered on a configuration page, the configuration information including multiple conditions and conditional relationships between the conditions; Generate a regular expression based on the configuration information, where the regular expression is an expression recognizable by a rule engine; The rule expression is stored in a rule base of the rule engine.
2. The method according to claim 1, characterized in that Generate a regular expression based on the configuration information, including: Determining engine information corresponding to the rule engine, where the engine information includes multiple target information types identifiable by the rule engine; Performing type conversion processing on each condition in the configuration information according to the engine information to obtain a plurality of target conditions, and processing the conditional relationship to obtain a target relationship; The regular expression is obtained by combining the multiple target conditions and the target relationship, and the regular expression includes the multiple target conditions and the target relationship.
3. The method according to claim 2, characterized in that For any condition, according to the engine information, the condition is type-converted to obtain the target condition corresponding to the condition, including: Determining first information and second information in the condition, wherein the information type of the first information is an information type recognizable by the rule engine, and the information type of the second information is an information type unrecognizable by the rule engine; performing type conversion processing on the second information according to the engine information to obtain third information; Perform expression combination processing on the first information and the third information to obtain a target condition corresponding to the condition.
4. The method according to claim 3, characterized in that Performing expression combination processing on the first information and the third information to obtain a target condition corresponding to the condition includes: determining a first position of the first information in the condition and a second position of the second information in the condition; According to the first position and the second position, the first information and the third information are processed by expression combination to obtain the target condition, wherein the first information is located at the first position in the target condition and the third information is located at the second position in the target condition.
5. A task processing method, characterized in that: include: Obtaining a task processing request, wherein the task processing request includes task information of a target task, wherein the task information includes field values corresponding to a plurality of task fields; Obtaining a rule expression corresponding to the target task from a rule library of the rule engine; The task information is processed according to the regular expression to obtain a task processing result corresponding to the target task.
6. The method according to claim 5, characterized in that Obtain the rule expression corresponding to the target task from the rule library of the rule engine, including: Obtaining a target task type and a historical task processing record of a target task, wherein the historical task processing record includes multiple historical task types and a regular expression corresponding to each historical task type; If a first historical task type among the multiple historical task types is the same as the target task type, determining the regular expression corresponding to the first historical task type as the regular expression corresponding to the target task; If the target task type does not exist in the multiple historical task types, the correspondence between multiple task types and multiple rule expressions is obtained in the rule library of the rule engine, and the rule expression corresponding to the target task is determined based on the target task type and the correspondence.
7. The method according to claim 5 or 6, characterized in that The rule expression includes multiple target conditions and target relations, wherein the target relations are AND relations or OR relations; Processing the task information according to the regular expression to obtain a task processing result corresponding to the target task includes: Determine the task field corresponding to each target condition, and determine the condition execution result corresponding to the target condition based on the field value corresponding to the task field and the target condition; A logical operation is performed on the multiple condition execution results corresponding to the multiple target conditions according to the target relationship to obtain the task processing result, where the logical operation is an AND operation or an OR operation.
8. The method according to claim 7, characterized in that Determining a conditional execution result corresponding to the target condition according to a field value corresponding to the task field and the target condition, including: If the field value corresponding to the task field satisfies the target condition, determining that the condition execution result is a first result, where the first result is used to indicate that the target condition is satisfied; If the field value corresponding to the task field does not meet the target condition, the condition execution result is determined to be a second result, and the second result is used to indicate that the target condition is not met.
9. The method according to claim 5, characterized in that In the rule library of the rule engine, obtain the rule expression corresponding to the target task, including: Get at least one historical task; If the target task does not exist in the at least one historical task, obtaining a rule expression corresponding to the target task in a rule library of a rule engine; The method further comprises: If there is a first historical task in the historical tasks that is the same as the target task, the task processing result of the first historical task is determined as the task processing result of the target task.
10. A computing device, characterized in that The computing device includes a memory and a processor; The memory is coupled to the processor; The memory is used to store program instructions; The processor is configured to call the program instructions so as to enable the computing device to execute the method according to any one of claims 1 to 4 and the method according to any one of claims 5 to 9.
Citation Information
Patent Citations
Service rule configuration method, system and equipment based on rule engine and medium
CN115185613A