A data processing method and apparatus
By receiving business requests, determining business logic and factors, and creating and splitting target rule expressions using a pre-defined rule base, the flexibility and security issues of business rule configuration in existing technologies are resolved, and efficient data processing is achieved.
Patent Information
- Application Number
- CN202110679108.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-18
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2041-06-18
AI Technical Summary
Existing technologies that use fixed-syntax modules for configuring business rules cannot meet the new requirements for configuring business rules, and also have security risks and poor scalability.
By receiving business processing requests, determining business logic and factors, using a preset rule base to find target operators and connectors, creating target rule expressions, and splitting them into a list of basic expressions based on splitting conditions, data processing is performed.
It enables flexible and rapid business data processing, enhances the scalability of rule expressions, reduces storage requirements, and improves processing efficiency.
Smart Images

Figure CN113326407B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of financial technology (Fintech), and more particularly to a data processing method and apparatus. Background Technology
[0002] With the development of computer technology, more and more technologies are being applied in the financial field. The traditional financial industry is gradually transforming into financial technology. However, due to the security and real-time requirements of the financial industry, higher demands are being placed on technology.
[0003] Currently, existing technologies rely on fixed syntax modules to write business rules. However, this approach cannot meet the rule configuration requirements of new businesses. Furthermore, fixed syntax modules are heavily dependent on large rule engine frameworks, which poses security risks when introducing external JAR packages. Summary of the Invention
[0004] This invention provides a data processing method and apparatus that solves the problem that existing technologies cannot meet the rule configuration requirements of new business needs.
[0005] In a first aspect, the present invention provides a data processing method applied to a business rule configuration and processing system. The method includes: receiving a business processing request, the business processing request including business requirements and business data; determining, based on the business requirements, business logic corresponding to the business requirements, and determining factors and comparison values corresponding to the business logic; wherein the factors are used to characterize comparison items in the business logic; based on the business logic, searching for target operators and target connectors from a preset rule base, and creating a target rule expression based on the business logic, the target operators, the target connectors, the factors, and the comparison values; wherein the preset rule base includes operators and connectors, and the target rule expression is used to characterize expressions for processing the business data; splitting the target rule expression based on preset splitting conditions to obtain a target expression list; the target expression list includes multiple basic expressions for performing one data operation; processing the business data based on the target expression list to obtain a processing result, and feeding back the processing result.
[0006] The above method allows for the determination of business logic based on business requirements. This involves identifying the factors and comparison values corresponding to the business logic, specifically which comparison item is calculated when the business requirement processes the business data, and the corresponding comparison value. Based on this business logic, the target operator and target connector are then retrieved from a pre-defined rule base. Finally, a target rule expression is created based on the business logic and the previously determined factors, comparison values, target operators, and target connectors. In other words, the target rule expression is constructed from basic symbols and factors. This approach allows for more accurate determination of the target rule expression, eliminating the need for pre-configured syntax modules and enabling more flexible creation of target rule expressions based on actual business requirements. Furthermore, this method of configuring target rule expressions based on a pre-defined rule base and business requirements allows for flexible and rapid determination of expressions for processing business data, enhancing the extensibility of rule expressions and saving storage space by eliminating the need for large storage areas. Furthermore, the target rule expression can be split based on preset splitting conditions to obtain a list of target expressions, that is, multiple basic expressions that perform one data operation. Business data can then be processed based on these multiple basic expressions to obtain processing results, and the processing results can be fed back, thereby improving the processing efficiency of business processing requests.
[0007] Optionally, the step of splitting the target rule expression based on preset splitting conditions to obtain a target expression list includes: replacing preset characters in the target rule expression with space characters to obtain a first target rule expression; wherein the preset characters include at least tab, carriage return, and newline; dividing the first target rule expression based on the connectors in the first target rule expression list to obtain a first expression list; determining whether any sub-expression in the first expression list is a basic expression, and when it is determined that any sub-expression in the first expression list is the basic expression, using the first expression list as the target expression list.
[0008] In the above method, preset characters such as tabs, carriage returns, and newlines can be replaced with spaces to obtain the first target rule expression. In other words, characters without clear meaning and not relevant to the subsequent splitting of the target rule expression are replaced with spaces, thus formatting the target rule expression and improving the accuracy of the splitting. Furthermore, the first target rule expression can be split based on the connectors in it to obtain a first expression list. It is then determined whether any sub-expression in the first expression list is a basic expression. When any sub-expression in the first expression list is determined to be a basic expression, the first expression list is used as the target expression list. That is, after the first split, the determination of whether the sub-expressions obtained after the first split are basic expressions is performed. This method ensures that any sub-expression is a basic expression, thus allowing for simpler and more accurate calculations when processing business data using the target expression list.
[0009] Optionally, determining whether any sub-expression in the first expression list is a basic expression, and using the first expression list as the target expression list when it is determined that any sub-expression in the first expression list is the basic expression, includes: determining whether any sub-expression in the first expression list includes a bracket character; when it is determined that any sub-expression in the first expression list includes the bracket character, determining whether the length corresponding to the sub-expression is greater than a preset threshold; when it is determined that the length corresponding to the sub-expression is greater than the preset threshold, dividing the sub-expression based on the character length to obtain the processed sub-expression, wherein the processed sub-expression includes at least two secondary sub-expressions; replacing the sub-expression in the first expression list with the at least two secondary sub-expressions to obtain an updated first expression list, and using the updated first expression list as the target expression list.
[0010] In the above method, whether any subexpression in the first expression list is a basic expression is determined by whether it contains parentheses. If any subexpression contains parentheses, its length is further checked to see if it exceeds a preset threshold. In other words, if any subexpression contains parentheses and its length exceeds the preset threshold, it is determined that the subexpression is not a basic expression. This subexpression is then further divided based on its character length to obtain a processed subexpression containing at least two sub-subexpressions. The first expression list is then updated based on this to obtain the target expression list. This approach ensures that all subexpressions in the target expression list are basic expressions.
[0011] Optionally, determining whether any sub-expression in the first expression list is a basic expression; when determining that any sub-expression in the first expression list is the basic expression, using the first expression list as the target expression list, includes: when determining that any sub-expression in the first expression list does not include the parenthesis sub-character, determining whether the any sub-expression includes a preset connector; when determining that any sub-expression includes the preset connector, adding the string and connector in the first expression list that are not separated by a character from the preset connector to the any sub-expression to obtain a first sub-expression; replacing the any sub-expression in the first expression list with the first sub-expression to obtain an updated first expression list, using the updated first expression list as the target expression list; when determining that any sub-expression does not include the preset connector, adding an empty string to the any sub-expression to obtain a second sub-expression; replacing the any sub-expression in the first expression list with the second sub-expression to obtain an updated first expression list, using the updated first expression list as the target expression list.
[0012] In the above method, when it is determined that any subexpression does not contain parentheses, it is not directly determined that any subexpression is a basic expression. Instead, it is determined whether any subexpression is a basic expression by checking whether it contains a connector. This method can ensure that the subexpressions in the obtained target expression list are all basic expressions as much as possible.
[0013] Optionally, the step of processing the business data based on the target expression list to obtain a processing result includes: determining the data type of the business data based on the factor, wherein the data type is any one of Boolean, numeric, Date, and String; calculating a first target expression list corresponding to the data type of the comparison value based on the data type of the business data and the comparison value; and processing the business data based on the first target expression list to obtain a processing result.
[0014] In the above method, the data type corresponding to the business data can be determined, and based on the data type and comparison value of the business data, a first target expression list corresponding to the data type of the business data can be calculated. Then, the business data can be processed based on the first target expression list. This approach can avoid situations where the business data cannot be processed due to the data type of the business data and the data type targeted by the target expression list being different, thereby improving the efficiency of business data processing.
[0015] Optionally, determining the data type of the business data based on the factor includes: obtaining the annotation instance corresponding to the factor based on the factor name defined for the factor; and determining the data type of the business data based on the return value type defined in the annotation instance.
[0016] In the above method, the annotation instance corresponding to the factor can be obtained based on the factor name defined by the factor, and the data type of the business data can be determined based on the return value type defined in the annotation instance. This method can determine the data type of the business data more accurately.
[0017] Optionally, obtaining the annotation instance corresponding to the factor based on the factor name defined for the factor includes: determining the transmission parameter and parameter type defined for the factor based on the factor name defined for the factor; creating a parameter instance based on the parameter type, and assigning the parameter in the transmission parameter to the parameter instance based on a preset function to obtain a first parameter instance; determining the list of declaration fields of the corresponding class in the first parameter instance, and traversing any item in the list to determine the extended parameter value corresponding to any item in the list; and inputting the extended parameter value into the first parameter instance to obtain the annotation instance corresponding to the factor.
[0018] In the above method, when defining factors for different business scenarios, the parameter types and transmission parameters can be defined. Then, when obtaining the annotation instance corresponding to the factor, the parameters can be assigned to the extended parameters based on the predefined transmission parameters and parameter types. In other words, the parameters can be flexibly extended based on actual needs.
[0019] Secondly, the present invention provides a data processing apparatus, comprising: a receiving unit for receiving a business processing request, the business processing request including business requirements and business data; a creating unit for determining, based on the business requirements, business logic corresponding to the business requirements, and determining factors and comparison values corresponding to the business logic; wherein the factors are used to characterize comparison items in the business logic; and, based on the business logic, searching for target operators and target connectors from a preset rule base, and creating a target rule expression based on the business logic, the target operators, the target connectors, the factors, and the comparison values; wherein the preset rule base includes operators and connectors, and the target rule expression is used to characterize an expression for processing the business data; a splitting unit for splitting the target rule expression based on preset splitting conditions to obtain a target expression list; the target expression list includes multiple basic expressions for performing one data operation; and a processing unit for processing the business data based on the target expression list, obtaining a processing result, and feeding back the processing result.
[0020] Optionally, the splitting unit is configured to: replace preset characters in the target rule expression with space characters to obtain a first target rule expression; wherein the preset characters include at least tab, carriage return, and newline characters; divide the first target rule expression based on the connectors in the first target rule expression list to obtain a first expression list; determine whether any sub-expression in the first expression list is a basic expression, and when it is determined that any sub-expression in the first expression list is the basic expression, use the first expression list as the target expression list.
[0021] Optionally, the splitting unit is configured to: determine whether any sub-expression in the first expression list includes a parenthesis character; when it is determined that any sub-expression in the first expression list includes the parenthesis character, determine whether the length corresponding to the any sub-expression is greater than a preset threshold; when it is determined that the length corresponding to the any sub-expression is greater than the preset threshold, divide the any sub-expression based on the character length to obtain the processed any sub-expression, and the processed any sub-expression includes at least two secondary sub-expressions; replace the any sub-expression in the first expression list with the at least two secondary sub-expressions to obtain an updated first expression list, and use the updated first expression list as the target expression list.
[0022] Optionally, the splitting unit is configured to: when it is determined that any subexpression in the first expression list does not include the parenthesis character, determine whether the any subexpression includes a preset connector; when it is determined that any subexpression includes the preset connector, add the string and connector in the first expression list that are not separated by a character from the preset connector to the any subexpression to obtain a first subexpression; replace the any subexpression in the first expression list with the first subexpression to obtain an updated first expression list, and use the updated first expression list as the target expression list; when it is determined that any subexpression does not include the preset connector, add an empty string to the any subexpression to obtain a second subexpression; replace the any subexpression in the first expression list with the second subexpression to obtain an updated first expression list, and use the updated first expression list as the target expression list.
[0023] Optionally, the processing unit is configured to: determine the data type of the business data based on the factor, wherein the data type is any one of Boolean, numeric, Date, and String; calculate a first target expression list corresponding to the data type of the business data based on the data type of the business data and the comparison value; and process the business data based on the first target expression list to obtain a processing result.
[0024] Optionally, the processing unit is configured to: obtain an annotation instance corresponding to the factor based on the factor name defined for the factor; and determine the data type of the business data based on the return value type defined in the annotation instance.
[0025] Optionally, the processing unit is configured to: determine the transmission parameters and parameter types defined for the factor based on the factor name defined for the factor; create a parameter instance based on the parameter type, and assign the parameters in the transmission parameters to the parameter instance based on a preset function to obtain a first parameter instance; determine the list of declaration fields of the corresponding class in the first parameter instance, and traverse any item in the list to determine the extended parameter value corresponding to any item in the list; input the extended parameter value into the first parameter instance to obtain the annotation instance corresponding to the factor.
[0026] The beneficial effects of the second aspect and the various optional devices described above can be referred to the beneficial effects of the first aspect and the various optional methods described above, and will not be repeated here.
[0027] Thirdly, the present invention provides a computer device including a program or instructions, which, when executed, are used to perform the first aspect and the various optional methods of the first aspect.
[0028] Fourthly, the present invention provides a storage medium including a program or instructions, which, when executed, perform the first aspect and the various optional methods of the first aspect. Attached Figure Description
[0029] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below.
[0030] Figure 1 An application scenario diagram provided by an embodiment of the present invention;
[0031] Figure 2 This is a flowchart illustrating the steps of a data processing method provided in an embodiment of the present invention;
[0032] Figure 3This is a flowchart illustrating the steps of parsing a target rule expression according to an embodiment of the present invention.
[0033] Figure 4 This is a schematic diagram of the structure of a data processing device provided in an embodiment of the present invention. Detailed Implementation
[0034] To better understand the above technical solutions, the following will describe the above technical solutions in detail with reference to the accompanying drawings and specific embodiments. It should be understood that the embodiments of the present invention and the specific features in the embodiments are detailed descriptions of the technical solutions of the present invention, rather than limitations on the technical solutions of the present invention. In the absence of conflict, the embodiments of the present invention and the technical features in the embodiments can be combined with each other.
[0035] It should be noted that the terms "first," "second," etc., used in the specification and claims of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such use of images can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this invention. Rather, they are merely examples of apparatuses and methods consistent with some aspects of the invention as detailed in the appended claims.
[0036] As mentioned earlier, existing solutions for writing business requirement processing rules generally rely on relatively heavy rule engine frameworks, and the cost of learning other languages is high, which is not conducive to the maintenance of the framework. Furthermore, since they are written using fixed syntax modules, they cannot adapt to new business requirements in a timely and accurate manner when expanding business-related rule expressions, i.e., they have poor extensibility.
[0037] In view of this, the present invention provides a data processing method and apparatus. This method allows for the flexible configuration of corresponding rule expressions based on actual business needs, and the parsing of the rule expressions, thereby enabling fast and accurate processing of business data.
[0038] After introducing the design concept of the embodiments of the present invention, the following is a brief introduction to the application scenarios applicable to the data processing technical solutions in the embodiments of the present invention. It should be noted that the application scenarios described in the embodiments of the present invention are for the purpose of more clearly illustrating the technical solutions of the embodiments of the present invention, and do not constitute a limitation on the technical solutions provided by the embodiments of the present invention. As those skilled in the art will know, with the emergence of new application scenarios, the technical solutions provided by the embodiments of the present invention are also applicable to similar technical problems.
[0039] In the embodiments of the present invention, please refer to Figure 1 The illustrated application scenario includes an electronic device 101 and a processing server 102. The electronic device 101 can communicate with the processing server 102. For example, they can be connected directly or indirectly through wired or wireless communication methods; this invention is not limited to this.
[0040] The processing server 102 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. The electronic device 101 can be a smartphone, tablet, laptop, desktop computer, smart TV, smart wearable device, or a server, but is not limited to these.
[0041] In this scenario, a user can trigger a business processing request based on electronic device 101. The business rule configuration and processing system deployed on processing server 120 can then receive the request, which includes business requirements and business data. Based on the business requirements, the system determines the corresponding business logic, factors, and comparison values. Factors represent the comparison items in the business logic. Based on the business logic, the system searches for target operators and target connectors in a preset rule base. Based on the business logic, target rule expressions are created using the target logic, target operators, target connectors, factors, and comparison values. These expressions are then split based on preset splitting conditions to obtain a list of target expressions. Finally, the system processes the business data based on this list, obtains the processing results, and feeds the results back to electronic device 101.
[0042] It should be noted that the preset rule base can be stored in the storage area of the processing server 102, or in the storage area of other servers connected to the processing server 102; this embodiment of the invention does not impose any restrictions. Furthermore, operators and connectors can be stored independently in different locations within the aforementioned storage areas.
[0043] To further illustrate the data processing method provided in the embodiments of the present invention, a detailed description is provided below in conjunction with the accompanying drawings and specific implementation methods. Although the embodiments of the present invention provide method operation steps as shown in the following embodiments or drawings, more or fewer operation steps may be included in the method based on conventional or non-inventive methods. In steps where there is no logically necessary causal relationship, the execution order of these steps is not limited to the execution order provided in the embodiments of the present invention. In actual processing or when the device executes the method, it may be executed in the order shown in the embodiments or drawings, or in parallel (e.g., in an application environment with parallel processors or multi-threaded processing).
[0044] The following combination Figure 2 The flowchart shown illustrates the data processing method in this embodiment of the invention. The method flow of this embodiment of the invention is described below.
[0045] Step 201: Receive a business processing request, which includes business requirements and business data.
[0046] In step 201, a business processing request can be received. Specifically, this business processing request can be automatically triggered, for example, it can be periodically triggered, such as once a day or once an hour; or it can be triggered when a preset triggering condition is met. For example, when it is determined that the business does not match a rule expression, the preset triggering condition can be determined, that is, when the business is a new business, the business processing request is automatically triggered; or when the business corresponds to a new requirement, the preset triggering condition can be determined. Of course, the business processing request can also be triggered based on the user's actual usage needs, that is, based on the user's selection to trigger the business processing request.
[0047] For example, a business processing request includes business requirements and business data. Business requirements can be understood as the specific direction the business is aimed at and what processing is required. Business data can be understood as the data generated under the business.
[0048] Step 202: Based on business requirements, determine the business logic corresponding to the business requirements, and determine the factors and comparison values corresponding to the business logic; whereby the factors are used to characterize the comparison items in the business logic.
[0049] Step 203: Based on business logic, search for target operators and target connectors from the preset rule base, and create a target rule expression based on business logic, target operators, target connectors, factors, and comparison values; wherein, the preset rule base includes operators and connectors, and the target rule expression is used to represent the expression for processing business data.
[0050] In step 202, based on business requirements, the business logic corresponding to the business requirements is determined, and the factors and comparison values corresponding to the business logic are determined; wherein, the factors are used to characterize the comparison items in the business logic.
[0051] For example, factors could be the investment amount factor "investAmount", the first-time investment factor "firstInvest", the number of order cancellations across all channels factor "countWithDraw", and so on. The comparison value can be understood as an abstraction of the data corresponding to the business requirements. For example, if the business requirement is that the investment amount is greater than 10,000, then the factor is "investment amount" and the comparison value is "10,000".
[0052] For example, the operators in the preset rule base may include, but are not limited to: == (equal to), != (not equal to), > (greater than), >= (greater than or equal to), < (less than), <= (less than or equal to), in (includes), fct (matches the first character), notIn (does not include), is (is), and not (no). It should be noted that the content in parentheses is an explanation of the operators, and the same descriptive method will be used thereafter.
[0053] In this embodiment of the invention, the operators in the preset rule base are included in an enumeration. In actual implementation, operators in the enumeration can be added based on actual needs to meet the rule expression configuration requirements of various businesses.
[0054] For example, the connectors in the preset rule base may include AND and OR. Of course, in actual implementation, the connectors in the preset rule base can be updated based on actual needs or periodically to meet the configuration requirements of the business's rule expressions.
[0055] For example, if the factors are: investAmount, firstInvest; the comparison value is 10000; the target operators are >= and is; and the target connectors are and and or; then based on the business logic, target operators, target connectors, factors, and comparison value, the target rule expression is created as: (investAmount>=10000and firstInvest is Y), (investAmount>=10000or firstInvest is Y), ((investAmount>=10000and firstInvest is Y)or(investAmount>=10000or firstInvest is Y)).
[0056] Step 204: Based on the preset splitting conditions, split the target rule expression to obtain a target expression list; the target expression list includes multiple basic expressions that perform one data operation.
[0057] In step 204, the preset characters in the target rule expression are replaced with space characters to obtain the first target rule expression; wherein the preset characters include at least tab, carriage return, and newline characters; based on the connectors in the first target rule expression, the first target rule expression is divided to obtain the first expression list; it is determined whether any sub-expression in the first expression list is a basic expression, and when any sub-expression in the first expression list is determined to be a basic expression, the first expression list is used as the target expression list.
[0058] For example, please see Figure 3 , Figure 3 This is a flowchart illustrating the steps involved in determining whether any sub-expression in the first expression list is a basic expression in an embodiment of the present invention. Specifically, determining whether any sub-expression in the first expression list is a basic expression can employ, but is not limited to, the following steps:
[0059] Step 301: Determine whether any subexpression in the first expression list contains a parenthesis character; if it is determined that any subexpression in the first expression list contains a parenthesis character, proceed to step 302; if it is determined that any subexpression in the first expression list does not contain a parenthesis character, proceed to step 305.
[0060] In step 310, determining whether any subexpression in the first expression list includes parenthesis characters can be done by determining whether any subexpression includes "(", or by determining whether any subexpression includes "(" followed by ")", i.e., whether the parenthesis characters are "(" and / or ")".
[0061] Step 302: When it is determined that any subexpression in the first expression list contains parentheses, determine whether the length of any subexpression is greater than a preset threshold; when it is determined that the length of any subexpression is greater than the preset threshold, proceed to step 303; when it is determined that the length of any subexpression is not greater than the preset threshold, proceed to step 305.
[0062] Step 303: Divide any subexpression based on its character length to obtain any processed subexpression, and any processed subexpression includes at least two secondary subexpressions.
[0063] For example, step 303 can be implemented based on “item substring(1)”, where “item” is used to represent any subexpression.
[0064] Step 304: Replace any sub-expression in the first expression list with at least two secondary sub-expressions to obtain the updated first expression list, and use the updated first expression list as the target expression list.
[0065] Step 305: Use the first expression list as the target expression list.
[0066] Step 306: When it is determined that any subexpression in the first expression list does not contain a parenthesis character, determine whether any subexpression includes a preset connector; when it is determined that any subexpression includes a preset connector, proceed to step 307; when it is determined that any subexpression does not include a preset connector, proceed to step 309. For example, the preset connector is "and" or "or".
[0067] Step 307: When it is determined that any subexpression includes a preset connector, add the string and connector that are not separated from the preset connector in the first expression list to any subexpression to obtain the first subexpression.
[0068] Step 308: Replace any subexpression in the first expression list with the first subexpression to obtain the updated first expression list, and use the updated first expression list as the target expression list.
[0069] Step 309: When it is determined that any subexpression does not include the preset connector, add an empty string to any subexpression to obtain the second subexpression.
[0070] Step 310: Replace any sub-expression in the first expression list with the second sub-expression to obtain the updated first expression list, and use the updated first expression list as the target expression list.
[0071] As can be seen, in this embodiment of the invention, after obtaining any sub-expression in the first expression list, it is also possible to determine whether any sub-expression is a basic expression, thereby ensuring that all sub-expressions in the target expression list are basic expressions.
[0072] Step 205: Based on the list of target expressions, process the business data, obtain the processing results, and provide feedback on the processing results.
[0073] In step 205, based on the factor name defined by the factor, the annotation instance corresponding to the factor is obtained; based on the return value type defined in the annotation instance, the data type of the business data is determined, wherein the data type is any one of Boolean, numeric, Date, and String; based on the data type of the business data and the comparison value, a first target expression list corresponding to the data type of the business data is calculated; based on the first target expression list, the business data is processed to obtain the processing result.
[0074] For example, the first subexpression in the target expression list is determined, leading and trailing spaces in the first subexpression are cleared, and then the first subexpression is split into a string array. For example, the string corresponding to the first subexpression can be split into a string array using the "split()" method. Based on the string array, the corresponding factor, comparison value, and operator are determined. Then, based on the factor name defined by the factor, the annotation instance corresponding to the factor is obtained. Based on the return value type defined in the annotation instance, the data type of the business data is determined.
[0075] For example, before obtaining the annotation instance corresponding to the factor, the parameter passing parameters and parameter types corresponding to the factor definition can be determined based on the factor name. Then, a parameter instance can be created based on the parameter type. A preset function, such as the copy Properties function, is then called to assign the parameters in the parameter passing parameters to the parameter instance, thereby obtaining the first parameter instance. This determines the list of declared fields of the corresponding class in the first parameter instance. The list is then traversed, and the extended parameter values corresponding to the sub-items in the list are obtained through reflection. These extended parameter values are then input into the first parameter instance, thereby determining the parameter instance, i.e., the aforementioned annotation instance. Based on the return value type corresponding to the factor in the annotation instance, the data type of the business data can be determined.
[0076] In this embodiment of the invention, under different business parameter scenarios, it is only necessary to define the corresponding input parameters in the definition of the factor. Thus, when calculating the first target expression list, the input parameters can be assigned to the first target expression list, thereby realizing the expansion of the parameters in the first target expression list. This allows for flexible parameter expansion based on JAVA reflection.
[0077] For example, we can first determine whether the type of the business data is any of the aforementioned data types, namely Boolean, numeric, Date, and String. If the type of the business data is determined to be any of the aforementioned types, then we determine whether the business data is a list, that is, whether there are multiple comparison values and whether these multiple values form a list. When the business data is a list, we calculate any sub-expression in the target expression list and the first sub-expression corresponding to the data type of the business data, thereby obtaining the corresponding first target expression list. When the business data is a single business data, we directly determine the corresponding first target expression list based on the data type of the business data, and process the business data based on the first target expression list to determine the calculation result corresponding to each sub-expression in the first target expression list. Thus, based on the calculation result corresponding to each sub-expression and the connection relationship between other sub-expressions, we determine the corresponding processing result.
[0078] It should be noted that, for ease of description, in the following text, leftVal represents the value being compared, i.e., the business data (the actual value corresponding to the factor), and rightVal represents the comparison value.
[0079] For example, when the data type of the business data is Boolean, the business data is cast to Boolean and it is determined whether the operator in the subexpression in the target expression list is "==" or "is". If the operator is "==" or "is", the subexpression in the first target expression list is expressed as: leftVal == rightVal; if the operator is not "==" or "is", and the operator is "!=" or "not", the subexpression in the first target expression list is expressed as: leftVal ! = rightVal.
[0080] For example, when the data type of the business data is numeric, the business data is cast to BigDecima. When the operator in the subexpression in the target expression list is "==", the subexpression in the first target expression list is represented as: leftVal.compare to(rightVal) == 0; when the operator in the subexpression in the target expression list is not "==" and is "!=", the subexpression in the first target expression list is represented as: leftVal.compare to(rightVal)! =0; When the operator in the subexpression in the target expression list is not "==" or "!=", and is ">=", then the subexpression in the first target expression list is represented as: leftVal.compare to(rightVal)>=0; When the operator in the subexpression in the target expression list is not "==", "!=", and ">=", and is "<", then the subexpression in the first target expression list is represented as: leftVal.compare to(rightVal)<0; When the operator in the subexpression in the target expression list is not "==", "!=", ">=", and "<", and is "<=", then the subexpression in the first target expression list is represented as: leftVal.compare to(rightVal)<=0.
[0081] For example, when the data type of the business data is String, the business data and the comparison value are cast to Boolean. When the operator in the subexpression in the target expression list is "==", the subexpression in the first target expression list is represented as: leftVal.equals(rightVal); when the operator in the subexpression in the target expression list is not "==" and is "!=", the subexpression in the first target expression list is represented as: !leftVal.equals(rightVal); when the operator in the subexpression in the target expression list is not "==" or "!=" and is "in", the subexpression in the first target expression list is represented as: leftVal.contains(rightVal); when the operator in the subexpression in the target expression list is not "==", "!=", or "in" and is "fct", the subexpression in the first target expression list is represented as: leftVal.indexOf(rightVal) == 0.
[0082] For example, when the data type of the business data is Date, the business data and the comparison value are cast to the same Date type. When the operator in the subexpression of the target expression list is "==", the subexpression in the first target expression list is represented as: leftVal.equals(rightVal); when the operator in the subexpression of the target expression list is not "==" and is "!=", the subexpression in the first target expression list is represented as: leftVal.compare to(rightVal)!=0; when the operator in the subexpression of the target expression list is not "==" and "!=" and is ">", the subexpression in the first target expression list is represented as: leftVal.after(rightVal); when the operator in the subexpression of the target expression list is not "==", "!=" and ">" and is ">=", the subexpression in the first target expression list is represented as: leftVal.equals(rightVal)||leftVal.after(rightVal); when the target expression list... If the operator in the subexpression in the target expression list is not "==", "!=", ">", or ">=", and is "<", then the subexpression in the first target expression list is represented as: leftVal.before(rightVal); if the operator in the subexpression in the target expression list is not "==", "!=", ">", ">=", or "<", and is "<=", then the subexpression in the first target expression list is represented as: leftVal.equals(rightVal)||leftVal.before(rightVal).
[0083] As can be seen, in this embodiment of the invention, the sub-expression of the first target list expression can be determined based on the data type corresponding to the business data, the business data, the comparison value, and the connector in the sub-expression, thereby processing the business data.
[0084] like Figure 4As shown, the present invention provides a data processing apparatus, comprising: a receiving unit 401, configured to receive a business processing request, the business processing request including business requirements and business data; a creating unit 402, configured to determine, based on the business requirements, the business logic corresponding to the business requirements, and determine the factors and comparison values corresponding to the business logic; wherein, the factors are used to characterize the comparison items in the business logic; and, based on the business logic, searching for target operators and target connectors from a preset rule base, and creating a target rule expression based on the business logic, the target operators, the target connectors, the factors, and the comparison values; wherein, the preset rule base includes operators and connectors, and the target rule expression is used to characterize an expression for processing the business data; a splitting unit 403, configured to split the target rule expression based on preset splitting conditions to obtain a target expression list; the target expression list includes multiple basic expressions for performing one data operation; and a processing unit 404, configured to process the business data based on the target expression list, obtain a processing result, and feed back the processing result.
[0085] Optionally, the splitting unit 403 is configured to: replace preset characters in the target rule expression with space characters to obtain a first target rule expression; wherein the preset characters include at least tab, carriage return, and newline characters; divide the first target rule expression based on the connectors in the first target rule expression list to obtain a first expression list; determine whether any sub-expression in the first expression list is a basic expression, and when it is determined that any sub-expression in the first expression list is the basic expression, use the first expression list as the target expression list.
[0086] Optionally, the splitting unit 403 is configured to: determine whether any sub-expression in the first expression list includes a bracket character; when it is determined that any sub-expression in the first expression list includes the bracket character, determine whether the length of the sub-expression is greater than a preset threshold; when it is determined that the length of the sub-expression is greater than the preset threshold, divide the sub-expression based on the character length to obtain the processed sub-expression, wherein the processed sub-expression includes at least two secondary sub-expressions; replace the sub-expression in the first expression list with the at least two secondary sub-expressions to obtain an updated first expression list, and use the updated first expression list as the target expression list.
[0087] Optionally, the splitting unit 403 is configured to: when it is determined that any subexpression in the first expression list does not include the parenthesis character, determine whether the any subexpression includes a preset connector; when it is determined that any subexpression includes the preset connector, add the string and connector in the first expression list that are not separated by a character from the preset connector to the any subexpression to obtain a first subexpression; replace the any subexpression in the first expression list with the first subexpression to obtain an updated first expression list, and use the updated first expression list as the target expression list; when it is determined that any subexpression does not include the preset connector, add an empty string to the any subexpression to obtain a second subexpression; replace the any subexpression in the first expression list with the second subexpression to obtain an updated first expression list, and use the updated first expression list as the target expression list.
[0088] Optionally, the processing unit 404 is configured to: determine the data type of the business data based on the factor, wherein the data type is any one of Boolean, numeric, Date, and String; calculate a first target expression list corresponding to the data type of the business data based on the data type and the comparison value; and process the business data based on the first target expression list to obtain a processing result.
[0089] Optionally, the processing unit 404 is configured to: obtain an annotation instance corresponding to the factor based on the factor name defined for the factor; and determine the data type of the business data based on the return value type defined in the annotation instance.
[0090] Optionally, the processing unit 404 is configured to: determine the transmission parameters and parameter types defined for the factor based on the factor name defined for the factor; create a parameter instance based on the parameter type, and assign the parameters in the transmission parameters to the parameter instance based on a preset function to obtain a first parameter instance; determine the list of declaration fields of the corresponding class in the first parameter instance, and traverse any item in the list to determine the extended parameter value corresponding to any item in the list; input the extended parameter value into the first parameter instance to obtain the annotation instance corresponding to the factor.
[0091] This invention provides a computer device, including a program or instructions, which, when executed, are used to perform a data processing method and any optional method provided in this invention.
[0092] This invention provides a storage medium including a program or instructions, which, when executed, are used to perform a data processing method and any optional method provided in this invention.
[0093] Finally, it should be noted that those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, optical storage, etc.) containing computer-usable program code.
[0094] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing device, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0095] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0096] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
Claims
1. A data processing method, characterized by, The method is applied to a business rule configuration and processing system, and comprises the following steps: receiving a business processing request, the business processing request comprising a business requirement and business data; determining a business logic corresponding to the business requirement based on the business requirement, and determining a factor and a comparison value corresponding to the business logic; wherein the factor is used to represent a comparison item in the business logic; based on the business logic, finding a target operator and a target connector from a preset rule library, and creating a target rule expression based on the business logic, the target operator, the target connector, the factor, and the comparison value; wherein the preset rule library comprises operators and connectors, the operators in the preset rule library are determined by adding new operators in an enumeration based on actual requirements, and the connectors in the preset rule library are determined based on actual requirements or periodic updates; the target rule expression is used to represent an expression for processing the business data; splitting the target rule expression based on a preset splitting condition to obtain a target expression list; the target expression list comprises a plurality of basic expressions for performing one data operation; processing the business data based on the target expression list to obtain a processing result, and feeding back the processing result; the processing of the business data based on the target expression list to obtain a processing result comprises: determining a data type of the business data based on the factor, wherein the data type is any one of a Boolean type, a numerical type, a Date type, and a String type; calculating a first target expression list corresponding to the data type of the business data based on the data type of the business data and the comparison value; processing the business data based on the first target expression list to obtain a processing result.
2. The method of claim 1, wherein, the splitting of the target rule expression based on a preset splitting condition to obtain a target expression list comprises: replacing a preset character in the target rule expression with a space character to obtain a first target rule expression; wherein the preset character at least includes a tab, a carriage return, and a line feed; dividing the first target rule expression based on the connector in the first target rule expression to obtain a first expression list; determining whether any sub-expression in the first expression list is a basic expression, and when it is determined that any sub-expression in the first expression list is the basic expression, taking the first expression list as the target expression list.
3. The method of claim 2, wherein, the determination of whether any sub-expression in the first expression list is a basic expression, and when it is determined that any sub-expression in the first expression list is the basic expression, taking the first expression list as the target expression list comprises: determining whether the bracket character is included in any sub-expression in the first expression list; when it is determined that the bracket character is included in any sub-expression in the first expression list, determining whether a length corresponding to the any sub-expression is greater than a preset threshold value; when it is determined that the length corresponding to any of the sub-expressions is greater than the preset threshold, the any of the sub-expressions is divided based on the character length, and a processed any of the sub-expressions is obtained, and the processed any of the sub-expressions includes at least two secondary sub-expressions; the any of the sub-expressions in the first expression list is replaced by the at least two secondary sub-expressions, and an updated first expression list is obtained, and the updated first expression list is taken as the target expression list.
4. The method of claim 3, wherein, whether any of the sub-expressions in the first expression list is a basic expression is determined, and when it is determined that any of the sub-expressions in the first expression list is the basic expression, the first expression list is taken as the target expression list, including: when it is determined that any of the sub-expressions in the first expression list does not include a bracket sub-character, whether the any of the sub-expressions includes a preset connector is determined; when it is determined that the any of the sub-expressions includes the preset connector, a string without a character interval and the connector in the first expression list and the connector are added to the any of the sub-expressions, and a first sub-expression is obtained; the any of the sub-expressions in the first expression list is replaced by the first sub-expression, and an updated first expression list is obtained, and the updated first expression list is taken as the target expression list; when it is determined that the any of the sub-expressions does not include the preset connector, a null string is added to the any of the sub-expressions, and a second sub-expression is obtained; the any of the sub-expressions in the first expression list is replaced by the second sub-expression, and an updated first expression list is obtained, and the updated first expression list is taken as the target expression list.
5. The method of claim 1, wherein, the data type of the business data is determined based on the factor, including: an annotation instance corresponding to the factor is obtained based on a factor name defined by correspondence of the factor; a data type of the business data is determined based on a return value type defined in the annotation instance.
6. The method of claim 5, wherein, the annotation instance corresponding to the factor is obtained based on the factor name defined by correspondence of the factor, including: a transmission parameter and a parameter type defined by correspondence of the factor are determined based on the factor name defined by correspondence of the factor; a parameter instance is created based on the parameter type, and a parameter in the transmission parameter is assigned to the parameter instance based on a preset function, and a first parameter instance is obtained; a declaration field list of a corresponding class in the first parameter instance is determined, and any of the list is traversed, and an extension parameter value corresponding to the any of the list is determined; the extension parameter value is input into the first parameter instance, and the annotation instance corresponding to the factor is obtained.
7. A data processing apparatus, characterized by The device includes: a receiving unit configured to receive a service processing request, the service processing request including a service requirement and business data; The creating unit is configured to determine a business logic corresponding to the business requirement based on the business requirement, and determine a factor and a comparison value corresponding to the business logic, wherein the factor is used to represent a comparison item in the business logic, and based on the business logic, find a target operator and a target connector from a preset rule library, and create a target rule expression based on the business logic, the target operator, the target connector, the factor, and the comparison value; the preset rule library includes operators and connectors, the operators in the preset rule library are determined by adding new operators in an enumeration based on actual requirements, and the connectors in the preset rule library are determined based on actual requirements or periodic updates; and the target rule expression is used to represent an expression for processing the business data. The splitting unit is configured to split the target rule expression based on a preset splitting condition to obtain a target expression list; the target expression list includes a plurality of basic expressions for performing one data operation. The processing unit is configured to process the business data based on the target expression list to obtain a processing result, and feed back the processing result. The processing unit is specifically configured to determine a data type of the business data based on the factor, wherein the data type is any one of a Boolean type, a numerical type, a Date type, and a String type. The processing unit is specifically configured to calculate a first target expression list corresponding to the data type of the business data based on the data type of the business data and the comparison value. The processing unit is specifically configured to process the business data based on the first target expression list to obtain a processing result.
8. A computer device, comprising: The computer program product includes readable instructions, and when the readable instructions are executed, the method in any one of claims 1 to 6 is executed.
9. A storage medium, characterized by The computer program product includes readable instructions, and when the readable instructions are executed, the method in any one of claims 1 to 6 is executed.
10. A computer program product, characterised in that, The computer program product includes readable instructions, and when the readable instructions are executed, the method in any one of claims 1 to 6 is executed.
Citation Information
Patent Citations
Service processing method, device and equipment
CN111966334A