Rule verification method, device, electronic device and storage medium

By dynamically selecting Groovy or MVEL languages ​​for rule verification, the problem of poor rule verification flexibility in the existing technology is solved, and an efficient and flexible rule verification method is realized to adapt to the verification needs of different rule complexity.

CN113535146BActive Publication Date: 2024-11-19ZHEJIANG JIXIANG ELECTRONIC-COMMERCE CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110797721.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-07-14
Publication Date
2024-11-19
Estimated Expiration
2041-07-14

AI Technical Summary

Technical Problem

In the prior art, the business rule verification methods are poor in flexibility and cannot effectively deal with different types of rules, resulting in inefficient verification and lack of flexibility and complex adaptability.

Method used

By obtaining the rule verification instruction, write it into the Groovy dynamic language or MVEL expression language according to the complexity of the rules to be verified, and obtain the verification variable, run and verify the result. If it fails, it will be intercepted or alarmed. Implement flexible configuration and efficient verification of rules.

Benefits of technology

It improves the flexibility and efficiency of rule verification, and can dynamically select the appropriate language for verification based on the rule complexity, which enhances the processing ability of multiple rules.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113535146B_ABST
    Figure CN113535146B_ABST
Patent Text Reader

Abstract

The present application relates to a rule verification method, wherein the rule verification method comprises: obtaining a rule verification instruction; obtaining a rule to be verified based on the rule verification instruction; writing the rule to be verified into a preset rule running language based on the complexity of the rule to be verified, wherein the preset rule running language comprises a Groovy dynamic language and an MVEL expression language; obtaining a verification variable corresponding to the rule to be verified, inputting the verification variable into the preset rule running language, running the preset rule running language into which the rule to be verified is written, and obtaining the running result, verifying the running result, and intercepting and / or alarming the verification rule that fails the verification. Through the present application, the problem of poor verification flexibility for different types of rules existing in the related art is solved, and it is realized that the corresponding rule running language can be configured based on the rule to be verified, thereby improving the flexibility of rule verification.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing, and in particular to a rule verification method, device, electronic device and storage medium. Background Art

[0002] With the continuous development of platform business, the increase in business complexity and business data volume, the number of abnormal business data is gradually increasing. Based on this, it is necessary to arrange certain verification of business data, among which the verification of business rules is particularly important. It is necessary to provide a method that can actively intercept or push to downstream systems according to dynamic rules.

[0003] The current method for business rule verification is to use a single rule language to verify the rules of basic variables. No matter how simple or complex the rules are, they need to be processed uniformly. Each time the rules are verified, the corresponding language code needs to be modified, which has poor flexibility and leads to overly complex verification rules. It is also impossible to guarantee the verification efficiency when verifying a large number of rules. There is currently no effective solution to the problem of poor verification flexibility for different types of rules in related technologies. Summary of the invention

[0004] In this embodiment, a rule verification method, device, electronic device and storage medium are provided to solve the problem of poor verification flexibility for different types of rules in the related art.

[0005] In the first aspect, a rule verification method is provided in this embodiment, including: obtaining a rule verification instruction, and obtaining a rule to be verified based on the rule verification instruction; writing the rule to be verified into a preset rule running language based on the complexity of the rule to be verified, and the preset rule running language includes Groovy dynamic language and MVEL expression language; obtaining a verification variable corresponding to the rule to be verified, inputting the verification variable into the preset rule running language, running the preset rule running language written into the rule to be verified, and obtaining the running result; verifying the running result, and intercepting and / or alarming the verification rule that fails the verification.

[0006] In another embodiment, obtaining the rule to be checked based on the rule checking instruction includes: obtaining a source address of the rule checking instruction, obtaining a corresponding rule to be checked based on the source address, and storing the rule to be checked in a database based on the source address.

[0007] In one of the embodiments, writing the rules to be checked into a preset rule running language based on the complexity of the rules to be checked includes: comparing the character complexity of the rules to be checked with the preset complexity; if the character complexity is greater than the preset complexity, writing the rules to be checked into the Groovy dynamic language; if the character complexity is less than the preset complexity, writing the rules to be checked into the MVEL expression language.

[0008] In another embodiment, before obtaining the verification variable corresponding to the rule to be verified, the method further includes: matching the corresponding preset variable attribute based on preset parameters as the variable attribute of the verification variable, and the variable attribute is used to obtain the corresponding verification variable; or; obtaining the parameter value in the business interface, matching the corresponding preset variable attribute based on the parameter value as the variable attribute of the verification variable.

[0009] In one of the embodiments, obtaining the verification variable corresponding to the rule to be verified includes: based on the rule to be verified, obtaining the variable attribute corresponding to the rule to be verified, and obtaining the verification variable corresponding to the variable attribute through reflection or dubbo generalization call.

[0010] In another embodiment, the running of the preset rule running language written into the rule to be verified includes: acquiring a corresponding language running engine based on the preset rule running language, and running the preset rule running language written into the rule to be verified based on the language running engine.

[0011] In one of the embodiments, the operation result is verified, and the verification rule that fails the verification is intercepted and / or an alarm is issued: a preset result corresponding to the verification variable is obtained, and the preset result includes a preset threshold value; the preset result is compared with the operation result, if the operation result is within the preset threshold range, the verification passes, if the operation result is not within the preset threshold range, the verification fails; if the verification result is that the verification fails, the rule to be verified is intercepted, and / or the alarm receiving target corresponding to the rule to be verified is obtained, and the verification result is sent to the alarm receiving target.

[0012] In the second aspect, a rule verification device is provided in the present embodiment, including: a rule to be verified acquisition module: used to obtain a rule verification instruction, and based on the rule verification instruction, obtain the rule to be verified; a rule to be verified writing module: used to write the rule to be verified into a preset rule running language based on the complexity of the rule to be verified, and the preset rule running language includes the Groovy dynamic language and the MVEL expression language; a rule to be verified running module: used to obtain a verification variable corresponding to the rule to be verified, input the verification variable into the preset rule running language, run the preset rule running language written into the rule to be verified, and obtain the running result; a rule to be verified verification module: used to verify the running result, and intercept and / or alarm the verification rule that fails the verification.

[0013] In a third aspect, an electronic device is provided in this embodiment, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the rule verification method described in the first aspect when executing the computer program.

[0014] In a fourth aspect, a storage medium is provided in this embodiment, on which a computer program is stored, and when the program is executed by a processor, the rule verification method described in the first aspect is implemented.

[0015] Compared with the related art, the rule verification method provided in the present embodiment obtains the rule verification instruction, and obtains the rule to be verified based on the rule verification instruction; writes the rule to be verified into a preset rule running language based on the complexity of the rule to be verified, and the preset rule running language includes the Groovy dynamic language and the MVEL expression language; obtains the verification variable corresponding to the rule to be verified, inputs the verification variable into the preset rule running language, runs the preset rule running language written into the rule to be verified, and obtains the running result; verifies the running result, and intercepts and / or alarms the verification rule that fails the verification, which solves the problem of poor verification flexibility for different types of rules in the related art, realizes that the corresponding rule running language can be configured based on the rule to be verified, and improves the flexibility of rule verification.

[0016] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0018] Figure 1 It is a hardware structure block diagram of a terminal of the rule verification method of this embodiment.

[0019] Figure 2 It is a flowchart of the rule verification method of this embodiment.

[0020] Figure 3 It is a schematic diagram of a new interface for adding rules to be checked in the checking rule method of this embodiment.

[0021] Figure 4 4 is a schematic diagram of a verification variable acquisition interface of the verification rule method of this embodiment.

[0022] Figure 5 It is a structural block diagram of the rule checking device of this embodiment. DETAILED DESCRIPTION

[0023] In order to more clearly understand the purpose, technical solutions and advantages of the present application, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments.

[0024] Unless otherwise defined, the technical terms or scientific terms involved in this application shall have the general meaning understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the", "these" and the like in this application do not represent quantitative restrictions, and they can be singular or plural. The terms "include", "comprise", "have" and any variants thereof involved in this application are intended to cover non-exclusive inclusions; for example, a process, method and system, product or device comprising a series of steps or modules (units) is not limited to the listed steps or modules (units), but may include unlisted steps or modules (units), or may include other steps or modules (units) inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether directly or indirectly. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships. For example, "A and / or B" can mean: A exists alone, A and B exist at the same time, and B exists alone. Usually, the character " / " indicates that the objects associated with each other are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.

[0025] The method embodiment provided in this embodiment can be executed in a terminal, a computer or a similar computing device. For example, running on a terminal, Figure 1 FIG. 1 is a hardware structure diagram of a terminal of the rule verification method of this embodiment. Figure 1 As shown, the terminal may include one or more ( Figure 1 Only one is shown in the figure) processor 102 and memory 104 for storing data, wherein processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA. The above terminal may also include a transmission device 106 and an input and output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.

[0026] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the rule verification method in this embodiment. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0027] The transmission device 106 is used to receive or send data via a network. The above network includes a wireless network provided by the communication provider of the terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (Radio Frequency, referred to as RF) module, which is used to communicate with the Internet wirelessly.

[0028] In this embodiment, a rule verification method is provided. Figure 2 is a flow chart of the rule verification method of this embodiment. Figure 2 As shown, the process includes the following steps:

[0029] Step S201, obtaining a rule verification instruction, and obtaining a rule to be verified based on the rule verification instruction.

[0030] In this embodiment, the rule verification instruction is first obtained. The rule verification instruction is sent by the rule sending end, and the purpose is to make the rule verification end start to perform rule verification. It can be understood that since there are many rules, in order to avoid errors when the rules are put into use, it is necessary to verify the rules to ensure that the rules put into use are accurate. Based on this, after obtaining the rule verification instruction, the rules to be verified are obtained. In this embodiment, the rules to be verified refer to calculation rules, such as comparing variables with variables through operators. Commonly used operators are: equal to, greater than, greater than or equal to, less than, less than or equal to, not equal to, etc. These rules are usually stored in the database in the form of code for dynamic loading; then, the rules to be verified are verified through the obtained rules to be verified.

[0031] Step S202, writing the rules to be checked into a preset rule execution language based on the complexity of the rules to be checked, wherein the preset rule execution language includes Groovy dynamic language and MVEL expression language.

[0032] It can be understood that the way to verify the rule to be verified is to input a variable into the rule to be verified, then run the rule to be verified, and then determine whether the verification is passed based on the running result of the rule to be verified; since the rule to be verified cannot be run directly, in this embodiment, before running the rule to be verified, it is also necessary to input the rule to be verified into the preset rule running language to ensure that the rule to be verified can be run. It can be understood that different rules have different levels of complexity. When the complexity of the rule to be verified is low, if a more complex rule running language is used, the efficiency of the rule verification cannot be guaranteed. It can be directly adapted to a simpler rule running language to ensure the running efficiency of the rule. The preset rule running language of this embodiment includes Groovy dynamic language and MVEL expression language. Based on these two languages, the rule to be verified can be written into them and run based on them. Among them, Groovy dynamic language (an agile development language based on JVM (Java virtual machine)) is suitable for the operation of more complex rules to be checked, but its flexibility is poor. Every time the rules to be checked are changed for operation, the code needs to be rewritten. As a code snippet, MVEL expression language is easier to match and run with relatively simple rules to be checked. For MVEL expression language (an expression language based on Java application), you only need to complete the writing of the rules to be checked and then substitute them for operation, but it cannot be applied to complex rules to be checked. Therefore, it is easy to understand that different preset rule running languages ​​need to be preset to run the rules to be checked. It is only necessary to ensure that the rules to be checked can be run normally. By inputting rules to be checked of different complexities into different rule running languages, the configuration efficiency of relatively simple rules to be checked can be improved, the overall verification efficiency is improved, and the overall flexibility of rule verification is improved.

[0033] Step S203, obtain the verification variable corresponding to the rule to be verified, input the verification variable into the preset rule running language, run the preset rule running language written into the rule to be verified, and obtain the running result. In this embodiment, the rule to be verified obtained in the above steps and the rule to be verified has been written into the preset rule running language, and can be verified. It can be understood that the rule is a calculation formula, and the rule to be verified can obtain a result by inputting a variable and then running the rule to be verified, and then judge whether the rule to be verified passes the verification based on the calculation result. Therefore, in this embodiment, by obtaining the verification variable, inputting it into the preset rule running language, and then running the preset rule running language, the running result can be obtained, which is used to verify the rule to be verified.

[0034] Step S204, verifying the operation result, and intercepting and / or alarming the verification rules that fail the verification.

[0035] In this embodiment, the operation results are obtained in the above steps, and the operation results can be used to verify whether the rules to be checked have passed the verification. The verification method for the operation results in this embodiment is to compare the operation results with the preset verification range. If the operation results are within the preset verification range, it can be confirmed that the rules to be checked have passed the verification. If they are not within the preset range, the rules to be checked cannot pass the verification. The preset verification range can be set based on the rules to be checked, or based on the verification variable setting, or can be obtained externally. It is only necessary to ensure that a range can be preset, and whether the rules to be checked have passed the verification by comparing whether the operation results are within the preset verification range. In addition, when the verification fails, it is necessary to intercept it and issue an alarm to ensure that the rules are maintained and modified in time to avoid economic and property losses.

[0036] Through the above steps, first obtain the rule verification instruction, then obtain the rule to be verified based on the rule verification instruction; then write the rule to be verified into the preset rule running language based on the complexity of the rule to be verified, then obtain the corresponding variable to be verified based on the rule to be verified, then input the verification variable into the preset rule running language, and then run the preset rule running language written into the rule to be verified to obtain the running result; by verifying the running result, it is determined whether the rule to be verified passes the verification, and the rule to be verified that fails the verification is intercepted and / or alarmed. The problem of poor verification flexibility for different types of rules in the related art is solved, and the corresponding rule running language can be configured based on the rule to be verified, thereby improving the flexibility of rule verification.

[0037] In another embodiment, based on the rule verification instruction, obtaining the rule to be verified includes: obtaining the source address of the rule verification instruction, obtaining the corresponding rule to be verified based on the source address, and storing the rule to be verified in a database based on the source address.

[0038] It can be understood that in this embodiment, the rules to be checked are stored in the database. The instruction sending end will send a rule verification instruction based on the rules to be checked in the database, so that the verification end verifies the rules to be checked. Based on this, the source address of the rule verification instruction can be obtained, and based on the source address, the storage address of the rule to be checked can be obtained, that is, it exists in a certain database. Then, based on the storage address of the rule to be checked, the rule to be checked is obtained for subsequent verification. By obtaining the source address of the rule verification instruction and obtaining the rule to be checked, it can be ensured that the verification end operates independently of the rule to be checked, thereby ensuring the integrity of the verification end.

[0039] In one of the embodiments, writing the rules to be checked based on the complexity of the rules to be checked into the preset rule running language includes: comparing the character complexity of the rules to be checked with the preset complexity; if the character complexity is greater than the preset complexity, writing the rules to be checked into the Groovy dynamic language; if the character complexity is less than the preset complexity, writing the rules to be checked into the MVEL expression language.

[0040] In this embodiment, the rules to be checked are written into the preset rule running language based on the complexity of the rules to be checked. First, the preset rule running language corresponding to the rules to be checked must be confirmed. Since this embodiment has two preset rule running languages, and each preset rule running language is applicable to different scenarios, it can be understood that the Groovy dynamic language can be applicable to rules to be checked with a greater degree of complexity, while the MVEL expression language is more applicable to rules to be checked with a smaller degree of complexity. Based on this, by obtaining the character complexity of the rules to be checked, and then comparing the character complexity with the preset complexity, if it is greater than the preset complexity, the rule to be checked is considered to be a complex rule and is written into the Groovy dynamic language. If it is less than the preset complexity, the rule to be checked is considered to be a simple rule and is written into the MVEL expression language. The preset complexity is confirmed by the technician based on experience or specific implementation results. Based on the comparison with the preset complexity, it can be confirmed whether the rule is complex enough. Based on this, it can adapt to rules of various complexities, dynamically configure its preset rule running language, and reduce the calculation amount of rule verification.

[0041] In another embodiment, before obtaining the verification variable corresponding to the rule to be verified, it also includes: matching the corresponding preset variable attributes based on preset parameters as the variable attributes of the verification variable, and the variable attributes are used to obtain the corresponding verification variable; or; obtaining the parameter value in the business interface, matching the corresponding preset variable attributes based on the parameter value as the variable attributes of the verification variable.

[0042] In this embodiment, the check variable is not only directly obtained through the preset parameters, but there are multiple ways to obtain it. It can be understood that not all parameter values ​​obtained through multiple ways can be directly used as the check variable. Therefore, in this embodiment, the parameters obtained through multiple ways are used as variable attributes of the check variable. In this embodiment, the variable attribute is the description value of the check variable, and each check variable is preset with a corresponding variable attribute; based on the obtained parameter value, as the variable attribute of the check variable, the parameter value can be matched with the check variable, so that the check attribute corresponding to the rule to be checked can be obtained, and then the corresponding check variable can be obtained through the check attribute, so that the preset parameters can be obtained. The check variable corresponding to the parameter of the number or business port is used to check the rule to be checked. There are two specific ways. One is to match the preset variable attribute through the preset parameter, that is, there is a preset parameter, which can be used directly to obtain the check variable for rule verification. The variable obtained based on this can also be called the basic variable. The other is to obtain the parameter value in the business interface, that is, to obtain the interface parameter, and then obtain the check variable through the interface parameter as the variable attribute. The check variable obtained based on this can also be called the interface variable. It is easy to understand that obtaining different check variables in different ways can improve the richness of the check variable acquisition and improve the accuracy of rule verification.

[0043] In one of the embodiments, obtaining the verification variable corresponding to the rule to be verified includes: based on the rule to be verified, obtaining the variable attribute corresponding to the rule to be verified, and obtaining the verification variable corresponding to the variable attribute through reflection or dubbo generalization call.

[0044] In this embodiment, the method of obtaining the check variable based on the rule to be checked is to first obtain the variable attribute corresponding to the check rule. The variable attribute is preset by the technician based on the rule to be checked when writing, representing the type of variable that can make the rule to be checked operate. Therefore, it is only necessary to obtain the variable attribute, obtain the check variable corresponding to its variable attribute through reflection (reflection is to map the various method attributes in the java class into Java objects one by one, and then obtain the value of the object's attribute) or obtain the check variable corresponding to the variable attribute through dubbo generalization call; that is, obtain the variable attribute corresponding to the rule to be checked, and then call the corresponding required check variable through the variable attribute. In other embodiments, there can be other methods to call or map the check variable corresponding to the variable attribute. This embodiment does not make specific requirements, and only needs to ensure that the corresponding check variable can be obtained through the variable attribute. Through this method, it can be ensured that the obtained parameter values ​​can be used to obtain the check variable. In another embodiment, running the preset rule running language written into the rule to be checked includes: obtaining the corresponding language running engine based on the preset rule running language, and running the preset rule running language written into the rule to be checked based on the language running engine.

[0045] It can be understood that the preset rule running language cannot be run directly, and it is also necessary to obtain the language running engine corresponding to the preset rule running language and run the preset rule running language through the language running engine. Therefore, in this embodiment, the corresponding language running engine is obtained based on the preset rule running language, such as the groovy class loader, or the execution engine of the MVEL expression language, which can be used to load the preset rule running language, and then based on the corresponding language running engine, to run the preset rule running language, which can ensure the normal operation of the preset rule running language.

[0046] In one of the embodiments, verifying the operation result and intercepting and / or alarming the verification rule that fails the verification includes: obtaining a preset result corresponding to the verification variable, the preset result including a preset threshold; comparing the preset result with the operation result, if the operation result is within the preset threshold range, the verification passes, if the operation result is not within the preset threshold range, the verification fails; if the verification result is that the verification fails, intercepting the rule to be verified, and / or obtaining the alarm receiving target corresponding to the rule to be verified, and sending the verification result to the alarm receiving target.

[0047] In this embodiment, since the operation result has been obtained, the verification result is obtained based on the operation result, and then the corresponding operation is performed on the rule to be checked based on the verification result. It can be understood that the verification result can be obtained by comparing the operation result with the preset range. When the operation result is within the range of the preset result, it can be determined that the rule to be checked has passed the verification, and the verification result is verification passed, and no other operation is required. If the operation result is not within the range of the preset result, it can be determined that the rule to be checked has not passed the verification, and the verification result is verification failed. It can be understood that when the rule to be checked does not pass the verification, it is necessary to intercept the rule to be checked, and an alarm can also be issued to the preset receiving target, and the failed rule to be checked and its verification result can be sent to the receiving target. Through this embodiment, it can be ensured that when the rule to be checked fails the verification, a timely reminder and repair of the rule to be checked can be given.

[0048] In one embodiment, a Skynet system is established as a verification terminal of the rule to be verified, and rule verification is performed based on the verification terminal, including:

[0049] Step S301, obtaining an operation interface, which can be provided by a management background interface to add, delete, modify, and query rule variables and rules to be verified.

[0050] In this embodiment, data related to the verification rules are stored in a database, which may be MySQL, redis or other databases, and no specific requirements are made in this embodiment.

[0051] Step S302, write each rule to be verified into the corresponding groovy script or MELV expression, and then write the groovy script or MELV expression into the corresponding node of the configuration center zookeeper (a reliable coordination system for distributed systems).

[0052] When checking rules through the Skynet system, the groovy script or MELV expression corresponding to the rule will be pulled from Zookeeper, and based on this, the rule to be checked will be added to the database. Then it is loaded into the JVM (virtual machine) memory through the groovy class loader, or the MELV expression is run through the runtime engine corresponding to the MELV expression, that is, the rule-bearing language is run through the language runtime engine. It can be understood that in other embodiments, the configuration center for storing the preset rule runtime language can also be: diamond, apollo configuration center, redis, etc. It only needs to ensure that the preset rule runtime language can be stored and configured, such as Figure 3 As shown, Figure 3 : is a schematic diagram of a new interface for adding rules to be verified in the rule verification method in this embodiment. Figure 3In the figure, you can see the input interface for the rule, including the input rule name, rule code, rule code description, and the corresponding variable selection interface, as well as the rule-bearing language input interface for verifying the rule. You can also select the alarm recipient when the rule fails, as well as an explanation of the rule. Based on this, by entering relevant data into the new interface for the rule to be verified, you can store the preset rule running language for rule verification.

[0053] Step S303, before calling the Skynet system interface to perform rule verification, obtain the parameter value from the preset parameter or business interface, and then compare the parameter value with the variable attribute of the verification variable. When performing rule verification, based on the rule to be verified, pull the corresponding variable attribute, and obtain the corresponding variable value through reflection or dubbo generalization call. Reflection maps various method attributes in the Java class into various Java objects, and then obtains the value of the object attribute; the dubbo generalization call method is mainly used in the case where there is no API (Application Programming Interface) interface and model class element. All POJOs (Plain Ordinary Java Objects) in specific parameters and their return values ​​are represented by Map objects. This calling method is usually used in framework integration. For example, when implementing a general service testing framework, GenericService, the generalization interface provided by Dubbo, can be used to perform generalization calls to call all service implementations; then the rule to be verified is based on the variable value for rule verification, such as Figure 4 As shown, Figure 4 Schematic diagram of the verification variable acquisition interface of the rule verification method in this embodiment.

[0054] Step S304, judge the rule verification result, send the verification result to the business party, intercept and alarm the unverified rules in real time, and write the abnormal data into the database at the same time. Then the abnormal data can be viewed in the intercepted data list in the management background.

[0055] It should be noted that the steps shown in the above process or the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0056] In this embodiment, a rule checking device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. The terms "module", "unit", "subunit" and the like used below can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0057] Figure 5 is a structural block diagram of the rule verification device of this embodiment, such as Figure 5 As shown, the device includes: a to-be-verified rule acquisition module 10, a to-be-verified rule writing module 20, a to-be-verified rule running module 30, a to-be-verified rule verification module 40, and a verification variable configuration module.

[0058] The to-be-verified rule acquisition module 10 is used to acquire a rule verification instruction, and acquire the to-be-verified rule based on the rule verification instruction;

[0059] The module 10 for obtaining rules to be checked is also used to obtain the source address of the rule checking instruction, obtain the corresponding rules to be checked based on the source address, and store the rules to be checked in the database based on the source address.

[0060] The module 20 for writing rules to be checked is used to write the rules to be checked into a preset rule running language based on the complexity of the rules to be checked. The preset rule running language includes Groovy dynamic language and MVEL expression language.

[0061] The module 20 for writing rules to be checked is also used to compare the character complexity of the rules to be checked with the preset complexity; if the character complexity is greater than the preset complexity, the rules to be checked are written into the Groovy dynamic language; if the character complexity is less than the preset complexity, the rules to be checked are written into the MVEL expression language.

[0062] The rule-to-be-verified running module 30 is used to obtain the verification variable corresponding to the rule-to-be-verified, input the verification variable into the preset rule running language, run the preset rule running language written into the rule-to-be-verified, and obtain the running result.

[0063] The to-be-verified rule running module 30 is also used to obtain a corresponding language running engine based on a preset rule running language, and to run the preset rule running language written into the to-be-verified rule based on the language running engine.

[0064] The to-be-verified rule verification module 40 is used to verify the operation result, and intercept and / or alarm the verification rules that fail the verification.

[0065] The verification module 40 of the rules to be verified is also used to obtain the preset results corresponding to the verification variables, and the preset results include preset thresholds; the preset results are compared with the operation results. If the operation results are within the preset threshold range, the verification is passed; if the operation results are not within the preset threshold range, the verification fails; if the verification result is that the verification fails, the rules to be verified are intercepted, and / or the alarm receiving target corresponding to the rules to be verified is obtained, and the verification results are sent to the alarm receiving target.

[0066] Verification variable configuration module: used to match the corresponding preset variable attributes based on preset parameters as the variable attributes of the verification variable, and the variable attributes are used to obtain the corresponding verification variable; or; obtain the parameter value in the business interface, match the corresponding preset variable attributes based on the parameter value, and use them as the variable attributes of the verification variable.

[0067] Verification variable configuration module: It is also used to obtain the variable attributes corresponding to the rules to be verified based on the rules to be verified, and obtain the verification variables corresponding to the variable attributes through reflection or dubbo generalization call.

[0068] It should be noted that the above modules can be functional modules or program modules, and can be implemented by software or hardware. For modules implemented by hardware, the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.

[0069] In this embodiment, an electronic device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0070] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0071] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:

[0072] S1, obtaining a rule verification instruction, and obtaining a rule to be verified based on the rule verification instruction.

[0073] S2, writing the rules to be checked into a preset rule execution language based on the complexity of the rules to be checked, wherein the preset rule execution language includes Groovy dynamic language and MVEL expression language.

[0074] S3, obtaining a verification variable corresponding to the rule to be verified, inputting the verification variable into the preset rule running language, running the preset rule running language written into the rule to be verified, and obtaining the running result.

[0075] S4, verifying the operation result, and intercepting and / or alarming the verification rules that fail the verification.

[0076] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation modes, and will not be repeated in this embodiment.

[0077] In addition, in combination with the rule verification method provided in the above embodiments, a storage medium may be provided in this embodiment to implement the rule verification method. The storage medium stores a computer program; when the computer program is executed by a processor, any rule verification method in the above embodiments is implemented.

[0078] It should be understood that the specific embodiments described herein are only used to explain the application, rather than to limit it. Based on the embodiments provided in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the protection scope of this application.

[0079] Obviously, the drawings are only some examples or embodiments of the present application. For ordinary technicians in the field, the present application can also be applied to other similar situations based on these drawings without creative work. In addition, it is understandable that although the work done in this development process may be complicated and lengthy, for ordinary technicians in the field, certain changes in design, manufacturing or production based on the technical content disclosed in this application are only conventional technical means and should not be regarded as insufficient content disclosed in this application.

[0080] The term "embodiment" in this application refers to a specific feature, structure or characteristic described in conjunction with the embodiment that can be included in at least one embodiment of the present application. The appearance of this phrase in various locations in the specification does not necessarily mean the same embodiment, nor does it mean that it is mutually exclusive with other embodiments and is independent or optional. It is clearly or implicitly understood by those of ordinary skill in the art that the embodiments described in this application can be combined with other embodiments without conflict.

[0081] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of patent protection. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the scope of protection of the present application. Therefore, the scope of protection of the present application shall be subject to the attached claims.

Claims

1. A rule verification method, characterized in that: include: Obtaining a rule verification instruction, and obtaining a rule to be verified based on the rule verification instruction; Writing the rules to be checked into a preset rule execution language based on the complexity of the rules to be checked, wherein the preset rule execution language includes Groovy dynamic language and MVEL expression language; The step of writing the rule to be checked into the preset rule running language based on the complexity of the rule to be checked includes: obtaining the character complexity of the rule to be checked, and comparing the character complexity of the rule to be checked with the preset complexity; if the character complexity is greater than the preset complexity, writing the rule to be checked into the Groovy dynamic language; if the character complexity is less than the preset complexity, writing the rule to be checked into the MVEL expression language; Obtaining a verification variable corresponding to the rule to be verified, inputting the verification variable into the preset rule running language, running the preset rule running language written into the rule to be verified, and obtaining the running result; Verifying the operation results, and intercepting and / or giving an alarm for the verification rules that fail the verification; Before obtaining the verification variable corresponding to the rule to be verified, the following step is also included: Matching a corresponding preset variable attribute based on a preset parameter as a variable attribute of the verification variable, wherein the variable attribute is used to obtain the corresponding verification variable; or; The parameter value in the business interface is obtained, and the corresponding preset variable attribute is matched based on the parameter value as the variable attribute of the verification variable.

2. The rule verification method according to claim 1, characterized in that: The obtaining of the to-be-verified rule based on the rule verification instruction includes: The source address of the rule verification instruction is obtained, and the corresponding rule to be verified is obtained based on the source address. The rule to be verified is stored in a database based on the source address.

3. The rule verification method according to claim 1, characterized in that: The obtaining of the verification variable corresponding to the rule to be verified includes: Based on the rule to be checked, obtain the variable attribute corresponding to the rule to be checked, and obtain the verification variable corresponding to the variable attribute through reflection or dubbo generalization call.

4. The rule verification method according to claim 1, characterized in that: The running of the preset rule running language written into the rule to be verified includes: A corresponding language execution engine is acquired based on the preset rule execution language, and the preset rule execution language written into the to-be-verified rule is executed based on the language execution engine.

5. The rule verification method according to claim 1, characterized in that: The verifying of the operation result and intercepting and / or giving an alarm for the verification rule that fails the verification includes: Obtaining a preset result corresponding to the verification variable, wherein the preset result includes a preset threshold; Compare the preset result with the running result, if the running result is within the preset threshold range, the verification is passed, if the running result is not within the preset threshold range, the verification is failed; If the verification result is that the verification fails, the rule to be verified is intercepted, and / or the alarm receiving target corresponding to the rule to be verified is obtained, and the verification result is sent to the alarm receiving target.

6. A rule verification device, characterized in that: include: A module for obtaining rules to be verified: used to obtain a rule verification instruction, and based on the rule verification instruction, obtain the rules to be verified; A module for writing rules to be verified: used for writing the rules to be verified into a preset rule running language based on the complexity of the rules to be verified, wherein the preset rule running language includes Groovy dynamic language and MVEL expression language; The step of writing the rule to be checked into the preset rule running language based on the complexity of the rule to be checked includes: obtaining the character complexity of the rule to be checked, and comparing the character complexity of the rule to be checked with the preset complexity; if the character complexity is greater than the preset complexity, writing the rule to be checked into the Groovy dynamic language; if the character complexity is less than the preset complexity, writing the rule to be checked into the MVEL expression language; A module for executing rules to be verified: used for obtaining a verification variable corresponding to the rule to be verified, inputting the verification variable into the preset rule execution language, executing the preset rule execution language written into the rule to be verified, and obtaining the execution result; The verification module for the rules to be verified is used to verify the operation results and intercept and / or alarm the verification rules that fail the verification; A check variable configuration module, used for matching corresponding preset variable attributes based on preset parameters as variable attributes of the check variable, wherein the variable attributes are used for obtaining the corresponding check variable; or; The parameter value in the business interface is obtained, and the corresponding preset variable attribute is matched based on the parameter value as the variable attribute of the verification variable.

7. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to execute the rule checking method according to any one of claims 1 to 5.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the rule checking method according to any one of claims 1 to 5 are implemented.