Dynamic rule judgment method based on multi-channel data source
By using multi-channel data sources and JavaScript to dynamically generate scripts in the dynamic rule judgment technology, the problems of high usage threshold, high maintenance cost and slow calculation speed in the existing technology are solved, and fast and efficient data operations and complex logic are realized. processing to adapt to the needs of big data environments.
Patent Information
- Application Number
- CN202310238964.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-14
- Publication Date
- 2024-09-17
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing dynamic rule judgment technology has problems such as high threshold for use, high maintenance cost, inability to achieve visualization and compound progressive condition judgment, and limited computing speed. Especially in the big data environment, it is difficult to meet the needs of practical applications.
Adopting a dynamic rule judgment method based on multi-channel data sources, through the data collection part to design an scalable architecture and the rule judgment part to use JavaScript to dynamically generate scripts to achieve dynamic compilation and calculation, support multiple data sources such as MySQL, PGSQL, SQLServer, and through loops Control and conditional priorities enable complex logic processing.
It achieves fast and efficient data operations, reduces computing consumption, supports multi-level logical processing and real-time data collection, and can record both satisfied and unsatisfied rules at the same time, improving the clarity and visibility of judgments, adapting to most business scenarios and Highly available and scalable.
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of dynamic rule algorithms, and in particular to a dynamic rule judgment method based on multi-channel data sources. Background Art
[0002] This technology is a dynamic rule calculation method designed and implemented based on the premise of being light, changeable, simple, and traceable. Before the birth of big data, this technology basically took the form of some macro access for dynamic calculation. After the birth of big data, part of the dynamic calculation judgment will turn to rely on the big data computing framework. There are generally two directions for existing similar technologies. One is to write configuration scripts based on configuration files, and obtain whether the final execution result of the script meets the preset conditions of the script based on dynamic compilation of the script. The second is to dynamically assemble some storage tools (such as ES, Mysql, MongoDB) with conditional query statements based on preset conditions, and only return data that meets the query statement, leaving the rule judgment to the storage tool. Its shortcomings are summarized as follows:
[0003] 1. The script-based rule judgment technology has a very high threshold for use. It is necessary to write a complete executable script before adding a set of rules. It is not easy to debug errors, cannot be efficient and easy to use, and has a narrow scope of use.
[0004] 2. Based on the script writing rules, the maintenance of script files requires extremely high costs. As the number of scripts increases, the maintenance cost is also rising.
[0005] 3. The technology of writing dynamic rules based on scripts cannot be visualized well - it is impossible to interpret the script itself into elements that can be presented on the page.
[0006] 4. Dynamically assembling query statements with rule conditions based on preset conditions and handing over rule judgment to the storage database has a fatal flaw - it is impossible to record and feedback the reasons for "not meeting" the conditions, and can only obtain data that "meets" the conditions, which is not conducive to focusing on both positive and negative scene requirements in actual application. In addition, dynamically assembling judgment conditions means that it is impossible to perform compound progressive condition judgments, which has relatively large data collection limitations.
[0007] 5. The technology of dynamically assembling query statements with rule conditions based on preset conditions cannot achieve high availability and scalability, because its computing engine is actually a storage tool rather than its own application, and the computing speed and hardware dependence are often restricted by the storage tool. Summary of the invention
[0008] In view of the above problems, the present invention provides a dynamic rule judgment method based on multi-channel data sources. The present invention is divided into data collection and rule judgment parts. The data collection part has been designed as an extensible mode to support new data collectors at any time. Currently, it can support data collection of some mainstream RDS - MySQL, PGSQL, SQLServer. The rule judgment part adopts dynamic generation of JavaScript, automatic assembly and completion of scripts, and dynamic compilation and calculation to realize rule judgment.
[0009] The technical solution provided by the present invention is: a dynamic rule judgment method based on multi-channel data sources, including a data collection part and a rule judgment part, the data collection part designs a set of collector extensible architecture, only needs to implement the definition of the data collection interface based on the rule element, the corresponding data collection can be carried out, the rule element includes the parameters of the transmission form, the database element and the code processor element, the core processing method of the rule judgment part is the scriptengine of java, the rule element will be referenced to various rule objects and rule groups, wherein the smallest calculation judgment unit is "rule". These rules generally include rule elements and their corresponding judgment conditions, multiple rule element judgment conditions are combined together, specifying the "and" and "or" relationship, and forming a "rule", this rule will be dynamically compiled and stored in the memory according to the js syntax when the application is initialized, wherein the rule elements and variable placeholders will be compiled into the parameters of the js method, and the script logic of js is a set of "if-else if-else" judgment statements, success is returned if successful, and the associated judgment rules and actual values are returned if failed, so as to record the reasons for success and failure.
[0010] Furthermore, the parameters of the transmission form, this type of element needs to define the value path in the input parameter object, the definition form is JsonPath, when collecting data, the value will be taken based on the JsonPath according to the current object body.
[0011] Furthermore, the database element, this type of element needs to define the data source type, the corresponding query template and the value-taking method, and will automatically fill in the placeholders in the template for data collection during data collection.
[0012] Furthermore, the code processor element, this type of element will be executed by the specified processing method. This type of element needs to define the element path to be executed and the collection path of the execution result, some template parameters, and various predefined built-in methods will be called according to the configuration to process the input parameter objects during data collection.
[0013] Furthermore, the data collection and judgment is not a one-way process, but a cyclic model, namely, data collection - conditional judgment - result output - data collection again based on the output data - conditional judgment - result output. To complete the cycle, a layer of loop control is added to the data collection and judgment, and the collection priority is added to the definition of the rule element.
[0014] The advantages of the present invention compared with the prior art are:
[0015] 1. Due to the pre-compilation, this algorithm model can reduce consumption in actual application and realize fast, efficient and low-consumption data calculation without the need for a big data computing framework.
[0016] 2. This calculation method has built-in applications and can be dynamically expanded with the application, which can adapt to most business scenarios.
[0017] 3. The algorithm model is based on the conditional control layer encapsulation, which can realize multi-level logic processing and support multiple real-time data collection methods. As long as there is a means to obtain data, this algorithm can be used. It can simultaneously record the rules and actual parameters that are met and not met under different combination conditions, making the judgment clearer and more visible.
[0018] 4. With this algorithm data structure, it is possible to establish a display layer for rule judgment and conditional control at the upper layer. Complex logical algorithms and scripts are automatically generated by the operation model. Technical personnel only need to understand some basic database queries and interface input and output parameters to configure the underlying data. Business personnel can directly understand and operate conditional judgments through the display layer. DETAILED DESCRIPTION
[0019] Example
[0020] A dynamic rule judgment method based on multi-channel data sources, including data collection and rule judgment. The judgment of rules comes from data, so data access is a subject that must be mastered. Only with data can judgment be made based on data. After the judgment is made, new data can be generated for further in-depth judgment. This data collection and data judgment is actually a progressive cycle. Therefore, this judgment method is divided into two engines: data collection and rule judgment.
[0021] In the data collection part, a set of scalable collector architecture is designed. It only needs to implement the definition of data collection interface based on rule elements to carry out corresponding data collection.
[0022] Rule elements currently support three categories:
[0023] The first type is a parameter in the form of transmission. This type of element needs to define the value path in the input parameter object in the form of JsonPath. When collecting data, the value will be taken based on the JsonPath according to the current object body.
[0024] The second category is database elements. This type of element needs to define the data source type, the corresponding query template and the value acquisition method. When collecting data, the placeholders in the template will be automatically filled in for data collection.
[0025] The third type is the code processor element, which will be executed in a specified processing mode, for example: addition executor. This type of element needs to define the element path to be executed and the collection path of the execution result, some template parameters, and various predefined built-in methods will be called according to the configuration to process the input parameter objects during data collection.
[0026] In the rule judgment part, the core processing method is java's scriptengine. Rule elements will be referenced to various rule objects and rule groups, among which the smallest calculation judgment unit is a "rule". These rules generally contain rule elements and their corresponding judgment conditions. Multiple rule element judgment conditions are combined together to specify the "and" and "or" relationships to form a "rule". This rule will be dynamically compiled according to js syntax and stored in memory when the application is initialized. The rule elements and variable placeholders will be compiled into parameters of js methods. The script logic of js is a set of "if-elseif-else" judgment statements. If successful, it returns success. If failed, it returns the associated judgment rules and actual values to record the reasons for success and failure.
[0027] Complete the closed loop of data collection and judgment. Data collection and judgment is not a one-way process. It can actually be a cyclical model, that is, data collection - conditional judgment - result output - another data collection based on the output data - conditional judgment - result output. To complete this cycle, a layer of loop control must be added on top of data collection and data judgment, and then the collection priority must be added to the definition of the rule element.
[0028] The data collection part of the present invention has been designed as an extensible mode to support new data collectors at any time. Currently, it can support data collection of some mainstream RDS - MySQL, PGSQL, SQLServer. The rule judgment part adopts dynamic generation of JavaScript, automatic assembly and completion scripts, and dynamic compilation and calculation to realize rule judgment.
[0029] The present invention and its embodiments are described, and such description is not restrictive. What is described in the embodiment is only one of the embodiments of the present invention, and the actual structure is not limited thereto. In short, if ordinary technicians in the field are inspired by it, without departing from the purpose of the invention, they can design a structure and embodiment similar to the technical solution without creativity, which should belong to the protection scope of the present invention.
Claims
1. A dynamic rule judgment method based on multi-channel data sources, characterized by: It includes a data collection part and a rule judgment part. The data collection part designs a set of collector extensible architecture. It only needs to implement the definition of the data collection interface based on the rule element to perform the corresponding data collection. The rule element includes parameters in the form of transmission, database elements and code processor elements. The core processing method of the rule judgment part is the Java scriptengine. The rule element will be referenced to various rule objects and rule groups, among which the smallest calculation judgment unit is a "rule". These rules generally contain rule elements and their corresponding judgment conditions. Multiple rule element judgment conditions are combined together to specify the "and" and "or" relationship to form a "rule". This rule will be dynamically compiled according to the js syntax and stored in the memory when the application is initialized. The rule elements and variable placeholders will be compiled into the parameters of the js method, and the js script logic is a set of "if-else if-else" judgment statements. If successful, it returns success, and if failed, it returns the associated judgment rules and actual values to record the reasons for success and failure.
2. A dynamic rule judgment method based on multi-channel data sources according to claim 1, characterized in that: The parameters of the transmission form, this type of element needs to define the value path in the input parameter object, the definition form is JsonPath, when collecting data, the value will be taken based on the current object body based on JsonPath.
3. The dynamic rule judgment method based on multi-channel data sources according to claim 1 is characterized in that: The database element, this type of element needs to define the data source type, the corresponding query template and the value acquisition method, and the placeholders in the template will be automatically filled in for data collection during data collection.
4. The dynamic rule judgment method based on multi-channel data sources according to claim 1 is characterized in that: The code processor element, this type of element will be executed in a specified processing mode. This type of element needs to define the element path to be executed and the collection path of the execution results, and some template parameters. When collecting data, various predefined built-in methods will be called according to the configuration to process the input parameter objects.
5. The dynamic rule judgment method based on multi-channel data sources according to claim 1 is characterized in that: The data collection and judgment is not a one-way process, but a cyclic model, namely, data collection - conditional judgment - result output - data collection again based on the output data - conditional judgment - result output. To complete the cycle, a layer of loop control is added to the data collection and judgment, and the collection priority is added to the definition of the rule element.
Citation Information
Patent Citations
Method and device for integrating multiple data sources and single sign-on system
CN101650747A
Rule engine, calculating method, service system and calling method
CN103942228A
Open-type multi-source data collection system and method
CN104111983A
Rule configuration method based on rule engine, terminal and equipment
CN107797826A
Rule-engine realization method and device
CN108399066A
