Data processing method, device and terminal equipment based on rule engine
By identifying the rule file type and using corresponding commands to encapsulate and execute rules, the complexity problem of the Drools rule engine when dealing with ordinary and rule flow files is solved, and the compatibility and development efficiency of the rule engine are improved.
Patent Information
- Application Number
- CN202010129897.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-02-28
- Publication Date
- 2025-01-17
- Estimated Expiration
- 2040-02-28
AI Technical Summary
When executing rule commands, the existing Drools rule engine needs to encapsulate a large number of repeated parameters of ordinary rule files and rule flow files respectively, which increases operational complexity and usage threshold, resulting in low development efficiency and insufficient compatibility of rule engines.
By identifying the type of rule files in the rule package, using corresponding commands to encapsulate and execute business rules, including specific commands for ordinary rule files and rule flow files, the encapsulation process of rule commands is simplified and the threshold for using the rule engine is lowered.
It achieves wider compatibility and development efficiency of the rule engine, simplifies the calling and execution of rule files, and reduces the need for developers to master rule commands.
Smart Images

Figure CN111338716B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of rule engines, and in particular, relates to a data processing method, apparatus and terminal device based on a rule engine. Background Art
[0002] The rule engine evolved from the inference engine and is a component embedded in the application. It separates business decisions from application code and writes business decisions using predefined semantic modules.
[0003] At present, the existing Drools rule engine is widely used as a common engine; however, the rule execution of the Drools rule engine is divided into two modes: rule flow execution and general rule execution, and the two modes of rule execution are not interoperable. For complex business logic, a rule package has both rule flow files and general rule files.
[0004] The traditional Drools engine has certain defects when executing rule commands: each command encapsulation can only support the execution of rule commands for one of the ordinary rule files or rule flow files; when there are different rule files in the rule package, it is necessary to encapsulate a large number of repeated parameters and replace the rule commands. In addition, people who use the rule engine need to master and use more rule commands, which makes the operation cumbersome and the use of the rule engine is inconvenient. At the same time, it increases the entry threshold for the use of the rule engine. Summary of the invention
[0005] The embodiments of the present application provide a data processing method, apparatus and terminal device based on a rule engine, which can solve the problem that a large number of repeated parameters need to be packaged when changing rule commands, and that personnel using the rule engine need to master and use more rule commands, which makes the operation cumbersome and inconvenient to use, and at the same time increases the entry threshold for the use of the rule engine.
[0006] In a first aspect, an embodiment of the present application provides a data processing method based on a rule engine, comprising:
[0007] Identifying a rule package of service data to be processed, and determining a type of rule files included in the rule package, wherein the types of rule files include common rule files and rule flow files;
[0008] According to the type of the rule file, respectively use commands corresponding to the common rule file or the rule flow file to encapsulate the service data to be processed, and obtain execution commands corresponding to the type of the rule file;
[0009] According to the execution command, the business rules of the business data to be processed in the rule file are executed to obtain the rule execution result.
[0010] In a possible implementation manner of the first aspect, the identifying the rule package of the service data to be processed and determining the type of the rule file included in the rule package includes:
[0011] Obtaining a name of a rule file in the rule package, wherein the name includes an extension of the rule file;
[0012] The type of the rule file is determined according to the extension.
[0013] In a possible implementation manner of the first aspect, according to the type of the rule file, using commands corresponding to the common rule file or the rule flow file respectively, performing command encapsulation on the service data to be processed to obtain an execution command corresponding to the type of the rule file, including:
[0014] If the type of the rule file is a common rule file, encapsulating the to-be-processed business data of the common rule file with commands to obtain a common rule execution command;
[0015] If the type of the rule file is a rule flow file, command encapsulation is performed on the service data to be processed in the rule flow file to obtain a rule flow execution command.
[0016] In a possible implementation manner of the first aspect, executing the business rule of the to-be-processed business data in the rule file according to the execution command includes:
[0017] If the type of the rule file is a rule stream file, the business rules of the business data to be processed in the rule stream file are executed in a preset order according to the rule stream execution command.
[0018] In a possible implementation manner of the first aspect, executing the business rule of the to-be-processed business data in the rule file according to the execution command includes:
[0019] If the rule file is a common rule file, the business rules of the business data to be processed in the common rule file are executed according to the common rule execution command according to the preset priority.
[0020] In a possible implementation manner of the first aspect, the rule package includes configuration information of the rule file, and the configuration information includes a declaration of the rule file, execution rule package information, and an execution rule name;
[0021] Accordingly, the rule package of the service data to be processed is identified, and the type of the rule file included in the rule package is determined, including:
[0022] The attributes of the rule file in the rule package are identified according to the configuration information; and the type of the rule file is determined according to the attributes.
[0023] In a possible implementation manner of the first aspect, executing the business rule of the to-be-processed business data in the rule file according to the execution command includes:
[0024] Execute commands according to the common rules, and execute rule commands according to the conditions and constraints in the common rule file;
[0025] According to the rule flow execution command, the rule command is executed according to the preset execution order in the rule flow file.
[0026] Exemplarily, after obtaining the rule execution result, it includes:
[0027] Determine whether there are data packets that do not execute business rules;
[0028] If there is a data packet in which the business rule is not executed, the rule file in the data packet is identified to determine the type of the rule file.
[0029] It should be understood that, according to the type of the rule file, the rule file is encapsulated with commands to obtain a common rule execution command or a rule flow execution command corresponding to the type of the rule file.
[0030] In a second aspect, an embodiment of the present application provides a data processing device based on a rule engine, comprising:
[0031] An identification module, used for identifying a rule package of service data to be processed and determining the type of rule files included in the rule package, wherein the type of rule files includes common rule files and rule flow files;
[0032] An encapsulation module, used to encapsulate the service data to be processed using commands corresponding to the common rule file or the rule flow file according to the type of the rule file, and obtain an execution command corresponding to the type of the rule file;
[0033] The execution module is used to execute the business rules of the business data to be processed in the rule file according to the execution command to obtain the rule execution result.
[0034] In a third aspect, an embodiment of the present application provides a terminal device, including a rule engine, a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the described method when executing the computer program.
[0035] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program implements the described method when executed by a processor.
[0036] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on a terminal device, enables the terminal device to execute the rule engine-based data processing method described in any one of the above-mentioned first aspects.
[0037] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here.
[0038] Compared with the prior art, the embodiments of the present application have the following beneficial effects: through the embodiments of the present invention, the rule package of the business data to be processed is identified, and the type of the rule file included in the rule package is determined, wherein the type of the rule file includes a common rule file and a rule flow file; according to the type of the rule file, the command corresponding to the common rule file or the rule flow file is used to encapsulate the business data to be processed, and an execution command corresponding to the type of the rule file is obtained; according to the execution command, the business rules of the business data to be processed in the rule file are executed to obtain the rule execution result. When changing the rule command, there is no need to perform a large number of repeated parameter encapsulation operations, which improves the development efficiency; the rule engine can more conveniently and quickly call the business data corresponding to different rule files, and execute the business rules according to the rule command of the corresponding rule file type; the compatibility of the rule engine is wider; and the access difficulty of the rule engine is reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0040] Figure 1 It is a schematic diagram of the system architecture provided by an embodiment of the present application;
[0041] Figure 2 It is a flowchart of a data processing method based on a rule engine provided in one embodiment of the present application;
[0042] Figure 3 is a flowchart of a data processing method based on a rule engine provided by another embodiment of the present application;
[0043] Figure 4is a structural diagram of a data processing device based on a rule engine provided in an embodiment of the present application;
[0044] Figure 5 It is a schematic diagram of the structure of the terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0045] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0046] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0047] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0048] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0049] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0050] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0051] The rule engine-based data processing method provided in the embodiment of the present application can be applied to terminal devices such as tablet computers, laptop computers, ultra-mobile personal computers (UMPCs), netbooks, personal digital assistants (PDAs), etc. The embodiment of the present application does not impose any restrictions on the specific types of terminal devices.
[0052] See also Figure 1 , is a schematic diagram of the system architecture provided by an embodiment of the present application. As shown in the figure, the data processing method based on the rule engine can be applied to the terminal device 20, and the terminal device 20 can obtain the business data processing request sent by the client 10, and obtain the business data to be processed sent by the client 10; the terminal device 20 can also obtain the business data to be processed from the server 30; identify the data packet of the business data to be processed, determine the type of the rule file in the data packet, encapsulate the command according to the rule file type, obtain the rule execution command corresponding to the rule file type, execute the corresponding business rule according to the rule execution command, and obtain the execution result; in addition, the client can also be an application client set in the terminal device, and the terminal device obtains the business data input by the user through the application client, and processes the business data accordingly through the rule engine to obtain the processing result; it realizes that the rule engine calls the business data more conveniently and quickly, and executes the business rules according to the rule command; makes the compatibility of the rule engine wider; reduces the access difficulty of the rule engine and improves the development efficiency.
[0053] See also Figure 2 , is a schematic flow chart of a data processing method based on a rule engine provided in the present application. As shown in the figure, the method includes the following steps.
[0054] Step S201 : identifying a rule package of service data to be processed, and determining the type of rule files included in the rule package, wherein the types of rule files include common rule files and rule flow files.
[0055] In this embodiment, the terminal device as the execution subject can be a computer or a server, etc.; the application of the terminal device is equipped with a rule engine. The rule engine can be a component embedded in the application, which is used to call and execute the rule package defined by the rule configurator, interpret the business rules and make business decisions based on the business rules; the rule package is a set of rules, which is a processing unit that can be called by the rule engine. The rule package contains the definitions of various data objects required by the rules and the definitions of the rules executed in sequence. For example, for life insurance business data, a policy contains multiple types of insurance, and each type of insurance corresponds to a set of rules, that is, a rule package; a set of rules or a rule package contains all the rules required for an insurance type. Each rule contains a trigger condition and a target action; the business data and the corresponding rule package are processed by the rule engine to obtain a business decision.
[0056] Among them, business data refers to user-related data, such as the user's age, income, etc.; business data is stored in the working memory of the platform device; the rule package corresponding to the business data is stored as central data in the knowledge base of the platform device, and the rule package is various rules corresponding to the business data; for example, according to the user's relevant data, the interest rate related to age or income, or the insurance amount and other data processing rules are set, a set of rules are formed into a rule file, and the related rule files are combined into a rule package for a business. For example, one insurance type corresponds to one rule package; an insurance policy can include multiple insurance types. When executing an insurance policy, the rule package corresponding to the insurance type can be added, and the business rules are executed according to the rule package to output the business decision.
[0057] Specifically, the types of the rule files include ordinary rule files and rule flow files; when the rule package of the business data to be processed is input to the rule engine of the terminal device, the rule engine needs to identify the type of the rule file in the input rule package. A rule package may contain rule files with multiple attributes, for example, ordinary rule files and rule flow files. Ordinary rule files are files with extensions of drl, drt, and dslr. Ordinary rule files record one or more independent rules. When multiple independent rules are included, the execution of the rules has no specific order; when the business data in the working memory changes, according to the conditions and constraints in the rules, a rule in the ordinary rule file may be repeatedly executed. The rule flow file is a file with an extension of bpmn. The rule flow file is composed of multiple rules and has a fixed execution process. It enters the corresponding branch according to the rules in the process. When the data in the working memory changes during the execution process, it will not cause the rules in the rule flow to be repeatedly executed. It is a complete set of processes and is executed in a fixed order. When calling a rule file in a rule package, the rule engine in the terminal device can identify the name of the rule file or the extension of the rule file and distinguish the type of the rule file according to the name or extension of the rule file.
[0058] It should be noted that before processing data through the rule engine, the terminal device can receive a request from the business system and obtain the business data requested by the business system for processing; or receive business data to be processed input by the user through the client; prepare the business data to obtain corresponding prepared data, interact with the prepared data with the database, standardize the prepared data into a message in the rule engine format, that is, the corresponding rule package, call the rule engine corresponding to the rule package, provide an interface for the called rule engine, and have the rule engine process the rule package; the rule engine can be a Drools rule engine.
[0059] Optionally, the step of identifying a rule package of the service data to be processed and determining a type of a rule file included in the rule package includes:
[0060] The name of the rule file in the rule package is obtained, wherein the name includes an extension of the rule file; and the type of the rule file is determined according to the extension.
[0061] In this embodiment, the attributes of the rule file correspond to different types, namely, ordinary rule types with simple attributes and rule flow types with complex attributes. Ordinary rule files are files with extensions of drl, drt, and dslr; rule flow files are files with extensions of bpmn.
[0062] In a possible implementation, the rule package includes configuration information of the rule file, and the configuration information includes a declaration of the rule file, execution rule package information, and an execution rule name;
[0063] Accordingly, the rule package of the service data to be processed is identified, and the type of the rule file included in the rule package is determined, including:
[0064] The attributes of the rule file in the rule package are identified according to the configuration information; and the type of the rule file is determined according to the attributes.
[0065] Specifically, the rule package is identified based on its naming characteristics. For example, a rule package corresponding to a certain insurance type includes a rule stream file with the naming characteristic of "insurance type name-stream", while a common rule file is directly named "insurance type name" without a suffix, that is, the rule file is identified by the suffix of the insurance type name. The rule file in the rule package can also be identified by reading the configuration in the rule package. The configuration in the rule package includes the declaration of the rule file. <kmodule>, Execution rule package information <kbase>And the name of the execution rule <ksession>, the attributes of the rule file are identified according to the specific content of the configuration to determine the attributes of the rule file in the rule package. The attributes of the rule file can also be identified according to the type of the file extension.
[0066] Step S202: According to the type of the rule file, commands corresponding to the common rule file or the rule flow file are used to encapsulate the service data to be processed, so as to obtain execution commands corresponding to the type of the rule file.
[0067] In this embodiment, since different types of rule files correspond to different data encapsulation commands, for example, the encapsulation command used by ordinary rules is FireAllRulesCommand, and the business data requested for processing corresponding to the ordinary rule file is encapsulated into an ordinary rule execution command; the encapsulation command used by rule flow rules is StartProcessCommand, and the business data requested for processing corresponding to the rule flow file is encapsulated into a rule flow rule execution command.
[0068] Specifically, by identifying the attributes of the rule file, it is determined whether the type of the rule file is a common rule file or a rule flow file; then the rule file is encapsulated according to the attributes; the object of the data encapsulation command is the business data processed by the request issued by the client, and the business data to be processed is encapsulated by inserting object commands, executing rule commands and obtaining execution result commands; and the corresponding data insertion commands, rule execution commands, and result data extraction commands are obtained.
[0069] For example, commands for inserting objects include InsertObjectCommand, InsertElementsCommand, etc.; commands for getting execution results include GetObjectsCommand, GetGlobalCommand, etc.
[0070] In addition, normal rules and rule flow rules are two modes natively supported by the rule engine Drools. Their commands differ only in the execution commands. The business data to be processed is encapsulated in different types of commands according to the rule file type corresponding to the business data to be processed. The two rules differ in application scenarios and execution processes. Whether to use normal rule files or rule flow files depends on business needs and goals.
[0071] Optional, such as Figure 3 FIG. 1 is a schematic diagram of an implementation flow of a data processing method based on a rule engine provided by another embodiment of the present application. According to the type of the rule file, commands corresponding to the common rule file or the rule flow file are used to encapsulate the service data to be processed, and an execution command corresponding to the type of the rule file is obtained, including:
[0072] Step S302: If the type of the rule file is a common rule file, command encapsulation is performed on the to-be-processed business data of the common rule file to obtain a common rule execution command.
[0073] In this embodiment, the encapsulation command used by the general rule is FireAllRulesCommand, which encapsulates the business data requested for processing corresponding to the general rule file into a general rule execution command; encapsulates the business data to be processed by inserting an object command, executing a rule command, and obtaining an execution result command; and obtains the execution command of the general rule of the corresponding data, and the execution command may include a data insertion command, a rule execution command, and a result data extraction command.
[0074] Step S303: If the type of the rule file is a rule flow file, command encapsulation is performed on the to-be-processed business data of the rule flow file to obtain a rule flow execution command.
[0075] In this embodiment, the encapsulation command used by the rule flow rule is StartProcessCommand, and the business data requested for processing corresponding to the rule flow file is encapsulated into a rule flow rule execution command; the business data to be processed is encapsulated by inserting an object command, executing a rule command, and obtaining an execution result command; and the execution command of the rule flow rule of the corresponding data is obtained, and the execution command may include a data insertion command, a rule execution command, and a result data extraction command.
[0076] Step S203: Execute the business rules of the business data to be processed in the rule file according to the execution command to obtain the rule execution result.
[0077] In this embodiment, one or more independent rules are recorded in the general rule file. When multiple independent rules are included, there is no specific order for the execution of the rules. When the business data in the working memory changes, a rule in the general rule file may be executed repeatedly according to the conditions and constraints in the rules. The rule flow file is composed of multiple rules and has a fixed execution process. It enters the corresponding branch according to the rules in the process. When the data in the working memory changes during the execution process, it will not cause the rules in the rule flow to be executed repeatedly. It is a complete set of processes and is executed in a fixed order.
[0078] Specifically, after the terminal device obtains the execution command after encapsulating the business data, it parses the encapsulated execution command, including parsing the data insertion command, to obtain all the business data to be processed corresponding to the current rule file; the execution command of the execution rule parses the rule file to obtain the specific execution rule corresponding to the business data in the rule engine, and uses the execution rule to uniformly process all the business data to be processed according to the rule, and obtains the final data processing result through the result data extraction command.
[0079] The processing result may be that the policy is compliant or not compliant, or may be that the user meets the purchase conditions or does not meet the purchase conditions, and so on.
[0080] In addition, the terminal device accepts business data input, interprets business rules, executes business rules, outputs data processing results according to business rules, makes business decisions corresponding to the business data requested by the client, and returns the business decisions to the client; the client can be the business system that issues the business data request, the terminal device receives the request of the business system, obtains the business data requested by the business system, calls and executes the rule package defined by the rule configurator through the rule engine of the terminal device, interprets the business rules and makes business decisions according to the business rules.
[0081] Through this embodiment, the type of the rule file contained in the rule package is identified, for example, the name of the rule file or the extension of the rule file is identified, and the type of the rule file in the rule package is determined to be a common rule file or a rule flow file; the command corresponding to the rule type is encapsulated for the rule file in the rule package, and the corresponding rule command is executed for the business data according to the encapsulated command rule. In the process of using the rule engine for business decision-making, for more complex business logic, the encapsulation process of the execution command for both the common rule file and the rule flow file is compatible, the versatility of the rule engine is realized, the possibility of failure of the configuration command of changing or adding new rules due to the unfamiliarity of the developer is reduced, and the tediousness of the developer to manually encapsulate multiple times is avoided, the running efficiency of the program is accelerated, and the logic of the use of the rules is simplified.
[0082] In a possible implementation, executing the business rule of the to-be-processed business data in the rule file according to the execution command includes:
[0083] Execute commands according to the common rules, and execute rule commands according to the conditions and constraints in the common rule file;
[0084] According to the rule flow execution command, the rule command is executed according to the preset execution order in the rule flow file.
[0085] In this embodiment, the general rule file is a rule group consisting of one or more rules. There is no predetermined execution order between each rule. One of the rules can be selectively executed according to the nodes in the rule group. The rule flow file refers to a rule flow consisting of a set of rules with a fixed execution order. There will be no redundant rules, and each rule needs to be executed in a fixed order. In addition, in the rule flow file, there can be different rule flow branches for the rules of a process, and a branch of the rule flow can be selected to execute each rule therein.
[0086] Optional, such as Figure 3 As shown, executing the business rules of the business data to be processed in the rule file according to the execution command includes:
[0087] Step S304: if the rule file is a common rule file, then according to the common rule execution command, the business rules of the business data to be processed in the common rule file are executed according to a preset priority to obtain an execution result.
[0088] In this implementation, one or more independent rules are recorded in the general rule file. When multiple independent rules are included, there is no specific order for the execution of the rules. When the business data in the working memory changes, a rule in the general rule file may be executed repeatedly according to the conditions and constraints in the rules. According to the conditions and constraints in the rules, the execution priority can be set, and the business rules of the business data to be processed in the general rule file are executed according to the set priority.
[0089] Step S305: If the type of the rule file is a rule flow file, the business rules of the to-be-processed business data in the rule flow file are executed in a preset order according to the rule flow execution command to obtain an execution result.
[0090] In this embodiment, the rule flow file is composed of multiple rules and has a fixed execution process. The corresponding branch is entered according to the rules in the process. When the data in the working memory changes during the execution process, it will not cause the rules in the rule flow to be executed repeatedly. It is a complete set of processes and is executed in a fixed order.
[0091] Optional, such as Figure 3 As shown in the figure, after obtaining the rule execution results, it includes:
[0092] Step S306, determining whether there is a data packet for which the business rule is not executed.
[0093] Optionally, if there is a data packet in which the business rule is not executed, the rule file in the data packet is identified to determine the type of the rule file.
[0094] In this embodiment, after executing the business rules of the business data to be processed in the rule file and obtaining the rule execution result, continue to detect whether there are any unexecuted rule files in the rule package. If so, continue to identify the type of rule file based on the attributes of the rule file, encapsulate the business data according to the type of the rule file, obtain the execution command corresponding to the rule file type, parse the rule file of the rule engine according to the execution command, and execute the corresponding rule command for the business data to be processed; if all the rule files in the rule package are executed, then the execution of the execution command is terminated, and the data processing result is output, that is, the business decision corresponding to the business data is output.
[0095] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0096] Through this embodiment, the rule package of the business data to be processed is identified, and the type of the rule file included in the rule package is determined; according to the type of the rule file, the business data to be processed in the rule file is command-encapsulated to obtain the execution command corresponding to the type of the rule file; according to the execution command, the business rules of the business data to be processed in the rule file are executed to obtain the rule execution result. This solves the problem that when changing the rule command, a large number of repeated parameters need to be encapsulated, and the personnel using the rule engine need to master and use more rule commands, which makes the operation cumbersome and inconvenient, and increases the entry threshold for the use of the rule engine; it enables the rule engine to call business data more conveniently and quickly, and execute business rules according to the rule command; it makes the compatibility of the rule engine wider; it reduces the access difficulty of the rule engine and improves the development efficiency.
[0097] Corresponding to the data processing method based on the rule engine described in the above embodiment, Figure 4 A structural block diagram of a data processing device based on a rule engine provided in an embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.
[0098] Reference Figure 4 The device includes: an identification module 41, a packaging module 42, and an execution module 43.
[0099] The identification module 41 is used to identify the rule package of the service data to be processed and determine the type of the rule file included in the rule package, wherein the type of the rule file includes a common rule file and a rule flow file;
[0100] The encapsulation module 42 is used to encapsulate the service data to be processed using commands corresponding to the common rule file or the rule flow file according to the type of the rule file, so as to obtain an execution command corresponding to the type of the rule file;
[0101] The execution module 43 is used to execute the business rules of the to-be-processed business data in the rule file according to the execution command to obtain the rule execution result.
[0102] In a possible implementation, the identification module 41 is further configured to obtain a name of a rule file in the rule package, where the name includes an extension of the rule file; and determine a type of the rule file according to the extension.
[0103] In a possible implementation, the encapsulation module 42 is also used to, if the type of the rule file is a common rule file, perform command encapsulation on the business data to be processed of the common rule file to obtain a common rule execution command; if the type of the rule file is a rule flow file, perform command encapsulation on the business data to be processed of the rule flow file to obtain a rule flow execution command.
[0104] In a possible implementation, the execution module 43 is also used to, if the type of the rule file is a rule stream file, execute the business rules of the business data to be processed in the rule stream file in a preset order according to the rule stream execution command; if the rule file is a common rule file, execute the business rules of the business data to be processed in the common rule file in a preset priority according to the common rule execution command.
[0105] In a possible implementation manner, the device further includes:
[0106] The processing module is used to determine whether there is a data packet that does not execute the business rules; if there is a data packet that does not execute the business rules, identify the rule file in the data packet and determine the type of the rule file.
[0107] In a possible implementation, the processing module is further configured to perform command encapsulation on the rule file according to the type of the rule file to obtain a common rule execution command or a rule flow execution command corresponding to the type of the rule file.
[0108] In a possible implementation, the rule package includes configuration information of the rule file, and the configuration information includes a declaration of the rule file, execution rule package information and an execution rule name; accordingly, the identification module is also used to identify the attributes of the rule file in the rule package according to the configuration information; and determine the type of the rule file according to the attributes.
[0109] In a possible implementation, the execution module is also used to execute commands according to the general rules, and execute rule commands according to the conditions and constraints in the general rule file; execute commands according to the rule flow, and execute rule commands according to a preset execution order in the rule flow file.
[0110] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0111] Through this embodiment, when changing the rule command, there is no need to perform a large number of repeated parameter packaging operations, which improves development efficiency; the rule engine can more conveniently and quickly call the business data corresponding to different rule files, and execute business rules according to the rule commands of the corresponding rule file type; the rule engine has wider compatibility; and the access difficulty of the rule engine is reduced.
[0112] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0113] Figure 5 This is a schematic diagram of the structure of a terminal device provided in an embodiment of the present application. Figure 5 As shown, the terminal device 5 of this embodiment includes: at least one processor 50 ( Figure 5 Only one is shown in the figure) a processor, a memory 51, a computer program 52 stored in the memory 51 and executable on the at least one processor 50, and a rule engine 53. When the processor 50 executes the computer program 52, the steps in any of the above-mentioned data processing method embodiments based on the rule engine are implemented.
[0114] The terminal device 5 may be a computing device such as a desktop computer, a notebook, a PDA, or a cloud server. The terminal device may include, but is not limited to, a processor 50 and a memory 51. Those skilled in the art will appreciate that Figure 5 It is only an example of the terminal device 5 and does not constitute a limitation on the terminal device 5. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, it may also include input and output devices, network access devices, etc.
[0115] The processor 50 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0116] In some embodiments, the memory 51 may be an internal storage unit of the terminal device 5, such as a hard disk or memory of the terminal device 5. In other embodiments, the memory 51 may also be an external storage device of the terminal device 5, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal device 5. Further, the memory 51 may also include both an internal storage unit and an external storage device of the terminal device 5. The memory 51 is used to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, such as the program code of the computer program. The memory 51 may also be used to temporarily store data that has been output or is to be output.
[0117] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0118] An embodiment of the present application provides a computer program product. When the computer program product runs on a mobile terminal, the mobile terminal can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0119] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium can at least include: any entity or device that can carry the computer program code to the camera / terminal device, recording medium, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0120] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0121] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0122] In the embodiments provided in the present application, it should be understood that the disclosed devices / network equipment and methods can be implemented in other ways. For example, the device / network equipment embodiments described above are merely schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0123] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0124] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.< / ksession> < / kbase> < / kmodule>
Claims
1. A data processing method based on a rule engine, characterized in that: include: Identifying a rule package of the business data to be processed and determining the type of rule files included in the rule package, wherein the types of rule files include common rule files and rule flow files, wherein the common rule file records one or more independent rules, and when a plurality of independent rules are included, the execution of the rules has no specific order; and the rule flow file is composed of a plurality of rules and has a fixed execution process; According to the type of the rule file, commands corresponding to the common rule file or the rule flow file are used to encapsulate the business data to be processed, and an execution command corresponding to the type of the rule file is obtained, wherein the object of the data encapsulation command is the business data requested for processing by the client, and the business data to be processed is encapsulated with an insert object command, an execute rule command, and an obtain execution result command; According to the execution command, the business rules of the business data to be processed in the rule file are executed to obtain the rule execution result; The step of identifying the rule package of the service data to be processed and determining the type of the rule file included in the rule package includes: Obtaining a name of a rule file in the rule package, wherein the name includes an extension of the rule file; Determine the type of the rule file according to the extension; According to the type of the rule file, respectively using commands corresponding to the common rule file or the rule flow file, command encapsulation is performed on the service data to be processed to obtain an execution command corresponding to the type of the rule file, including: If the type of the rule file is a common rule file, the business data to be processed in the common rule file is encapsulated with a command to obtain a common rule execution command, and the encapsulation command used by the common rule is FireAllRulesCommand; If the type of the rule file is a rule flow file, the business data to be processed in the rule flow file is encapsulated by command to obtain a rule flow execution command, and the encapsulation command used by the rule flow rule is StartProcessCommand; The executing, according to the execution command, the business rules of the business data to be processed in the rule file comprises: If the type of the rule file is a rule stream file, executing the business rules of the business data to be processed in the rule stream file in a preset order according to the rule stream execution command; The executing, according to the execution command, the business rules of the business data to be processed in the rule file comprises: If the rule file is a common rule file, the business rules of the business data to be processed in the common rule file are executed according to the common rule execution command according to the preset priority.
2. The data processing method based on rule engine according to claim 1, characterized in that: The rule package includes configuration information of the rule file, and the configuration information includes a declaration of the rule file, execution rule package information and an execution rule name; Accordingly, the rule package of the service data to be processed is identified, and the type of the rule file included in the rule package is determined, including: The attributes of the rule file in the rule package are identified according to the configuration information; and the type of the rule file is determined according to the attributes.
3. The data processing method based on rule engine according to claim 1, characterized in that: According to the execution command, executing the business rules of the business data to be processed in the rule file includes: Execute commands according to the common rules, and execute rule commands according to the conditions and constraints in the common rule file; According to the rule flow execution command, the rule command is executed according to the preset execution order in the rule flow file.
4. A data processing device based on a rule engine, characterized in that: include: an identification module, used to identify a rule package of service data to be processed and determine the type of rule files included in the rule package, wherein the types of rule files include common rule files and rule flow files, wherein the common rule file records one or more independent rules, and when a plurality of independent rules are included, the execution of the rules has no specific order; and the rule flow file is composed of a plurality of rules and has a fixed execution process; An encapsulation module is used to encapsulate the business data to be processed using commands corresponding to the common rule file or the rule flow file according to the type of the rule file, and obtain an execution command corresponding to the type of the rule file, wherein the object of the data encapsulation command is the business data requested for processing by the client, and the business data to be processed is encapsulated with an insert object command, an execute rule command, and an obtain execution result command; An execution module, used to execute the business rules of the business data to be processed in the rule file according to the execution command, and obtain the rule execution result; The step of identifying the rule package of the service data to be processed and determining the type of the rule file included in the rule package includes: Obtaining a name of a rule file in the rule package, wherein the name includes an extension of the rule file; Determine the type of the rule file according to the extension; According to the type of the rule file, respectively using commands corresponding to the common rule file or the rule flow file, command encapsulation is performed on the service data to be processed to obtain an execution command corresponding to the type of the rule file, including: If the type of the rule file is a common rule file, the business data to be processed in the common rule file is encapsulated with a command to obtain a common rule execution command, and the encapsulation command used by the common rule is FireAllRulesCommand; If the type of the rule file is a rule flow file, the business data to be processed in the rule flow file is encapsulated by command to obtain a rule flow execution command, and the encapsulation command used by the rule flow rule is StartProcessCommand; The executing, according to the execution command, the business rules of the business data to be processed in the rule file comprises: If the type of the rule file is a rule stream file, executing the business rules of the business data to be processed in the rule stream file in a preset order according to the rule stream execution command; The executing, according to the execution command, the business rules of the business data to be processed in the rule file comprises: If the rule file is a common rule file, the business rules of the business data to be processed in the common rule file are executed according to the common rule execution command according to the preset priority.
5. A terminal device, characterized in that: The method comprises a rule engine, a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor implements the method according to any one of claims 1 to 3 when executing the computer program.
6. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
Classification model based information processing method and classification model
CN106445928A