Data processing methods, electronic devices and readable storage media
By generating front-end view layer objects in business code and parsing them into SpEL expressions, the problem of the high learning difficulty of SpEL expressions is solved, and rapid conversion and visualization of natural language and SpEL expressions are realized.
Patent Information
- Application Number
- CN202311279860.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-29
- Publication Date
- 2025-12-02
- Estimated Expiration
- 2043-09-29
AI Technical Summary
In existing technologies, SpEL expressions are difficult to learn, hard for non-professionals to understand and modify, have poor code readability, and cannot support natural language input parsing.
By creating a front-end view layer object based on business code, generating JSON format data, and parsing it into SpEL expressions, a fast conversion between natural language and SpEL expressions is achieved.
It simplifies the process of generating SpEL expressions, making it easy to operate, highly visual, and suitable for ordinary users.
Smart Images

Figure CN117312438B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a data processing method, an electronic device, and a readable storage medium. Background Technology
[0002] SpEL (Spring Expression Language) is an expression language within the Spring Framework. It's a powerful expression language used to dynamically access and manipulate object graphs at runtime. SpEL can be used for various purposes, such as property access, method calls, mathematical operations, logical operations, and conditional expressions. SpEL's syntax is similar to expression languages in other programming languages, while also borrowing features from XML and XPath. It allows for dynamic evaluation of expressions at runtime, enabling a more flexible and dynamic programming approach. In the Spring Framework, SpEL is widely used in configuration files, such as XML configuration, annotation configuration, and Java configuration. SpEL allows the use of expressions in configuration files to dynamically configure application behavior based on runtime conditions. The Spring Framework is an open-source application framework for building enterprise-grade Java applications. It provides a suite of solutions and tools to simplify the Java application development process, helping developers build maintainable, scalable, and efficient applications.
[0003] The inventors discovered the following problems during their research: In existing technologies, rule execution requires defining specific rules using SpEL expressions. Defining rules and actions on a webpage necessitates inputting SpEL expressions, and natural language input parsing is not supported. However, SpEL expressions typically require mastering multiple keywords and syntax rules, making them difficult for ordinary users or programming novices to learn. SpEL expressions are generally statements composed of symbols and keywords, which are not easily understood by non-professionals and clients, resulting in poor code readability. Furthermore, the structure and syntax of SpEL expressions are relatively complex, requiring certain skills and experience to modify or debug them. Summary of the Invention
[0004] The purpose of this application is to provide a data processing method, apparatus, system, and computer-readable storage medium that can automatically generate SpEL expressions based on business code, achieve rapid conversion between natural language and SpEL expressions, and is simple to operate and highly visualized.
[0005] To achieve the above objectives:
[0006] In a first aspect, embodiments of this application provide a data processing method, the method comprising:
[0007] A front-end view layer object is created based on the business code, and the front-end view layer object includes at least one type of natural language;
[0008] Based on the front-end view layer object, perform the rule definition operation and generate JSON format data according to the operation result;
[0009] The JSON format data is parsed to construct a SpEL expression.
[0010] In one embodiment, the step of creating a front-end view layer object based on business code includes at least one type of natural language, including:
[0011] Obtain first data and second data from the business code, wherein the first data includes class information in the business code, and the second data includes Chinese annotation information in the business code;
[0012] Generate third data based on the first data and the second data;
[0013] A front-end view layer object is generated based on the third data.
[0014] In one embodiment, the method further includes:
[0015] The first and second data in the business code are obtained through the Java reflection mechanism.
[0016] In one implementation, exceptions during the process of obtaining the first and second data in the business code are captured and handled.
[0017] In one embodiment, the step of performing rule-defined operations based on the front-end view layer object and generating JSON format data according to the operation results includes:
[0018] A rule tree is created based on the front-end view layer object, the rule tree including a definable rule box;
[0019] The rule definition operation is performed through the definable rule box to receive business rule data, which includes first business rule data and second business rule data. The first business rule data is obtained through the front-end view layer object, and the second business rule data is obtained through user input.
[0020] JSON format data is generated based on the front-end view layer object and the business rule data.
[0021] In one embodiment, the rule definition operation includes one or more of the following: initial value setting, comparison operator selection, selection value type setting, and matching result input.
[0022] In one implementation, parsing the JSON format data to construct a SpEL expression includes:
[0023] Parse the data structure from the JSON data;
[0024] Extract the numerical values from the JSON data according to the data structure;
[0025] The numerical values are concatenated using string concatenation to construct a SpEL expression.
[0026] In one embodiment, after parsing the JSON format data to construct the SpEL expression, the method further includes:
[0027] The SpEL expression is parsed using the SpEL parser and compiled into an evaluable expression object;
[0028] The expression object is evaluated to obtain the evaluation result of the expression.
[0029] Secondly, embodiments of this application also provide a data processing system, which includes a first data processing module, a second data processing module, and a third data processing module; wherein,
[0030] The first data processing module is used to create a front-end view layer object based on business code, wherein the front-end view layer object includes at least one type of natural language;
[0031] The second data processing module is used to receive input data based on the front-end view layer object to generate JSON format data;
[0032] The third data processing module is used to parse the JSON format data to construct a SpEL expression.
[0033] Thirdly, embodiments of this application also provide an electronic device, the electronic device including a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the above-described data processing method.
[0034] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the above-described data processing method.
[0035] The data processing method, apparatus, system, and computer-readable storage medium provided in this application include: creating a front-end view layer object based on business code, the front-end view layer object including at least one type of natural language; performing rule-defined operations based on the front-end view layer object, generating JSON format data based on the operation results; and parsing the JSON format data to construct a SpEL expression. This enables the automatic generation of SpEL expressions based on business code, achieving rapid conversion between natural language and SpEL expressions, with simple operation and high visualization. Attached Figure Description
[0036] Figure 1 This is a schematic diagram of the structure of a data processing system provided in an embodiment of the present invention;
[0037] Figure 2 This is a flowchart illustrating the data processing performed by the first data processing module provided in an embodiment of the present invention.
[0038] Figure 3 This is a schematic diagram of the main interface of the front-end view layer object provided in an embodiment of the present invention;
[0039] Figure 4 This is one of the schematic diagrams of the operation interface of the front-end view layer object provided in the embodiment of the present invention;
[0040] Figure 5 This is the second schematic diagram of the operation interface of the front-end view layer object provided in the embodiment of the present invention;
[0041] Figure 6 The third schematic diagram of the operation interface of the front-end view layer object provided in the embodiment of the present invention;
[0042] Figure 7 The fourth schematic diagram of the operation interface of the front-end view layer object provided in the embodiment of the present invention;
[0043] Figure 8 Fifth schematic diagram of the operation interface of the front-end view layer object provided in the embodiments of the present invention;
[0044] Figure 9 This is a schematic diagram of the structure of stored data provided in an embodiment of the present invention;
[0045] Figure 10 This is a flowchart illustrating the data processing method provided in an embodiment of the present invention. Detailed Implementation
[0046] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0047] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, components, features, and elements with the same names in different embodiments of this application may have the same meaning or different meanings, the specific meaning of which must be determined by its interpretation in that specific embodiment or further in conjunction with the context of that specific embodiment.
[0048] It should be understood that although the terms first, second, third, etc., may be used herein to describe various information, such information should not be limited to these terms. These terms are used only to distinguish information of the same type from one another. For example, without departing from the scope of this document, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if," as used herein, can be interpreted as "when," "when," or "in response to determination." Furthermore, as used herein, the singular forms "a," "an," and "the" are intended to also include the plural forms unless the context indicates otherwise. It should be further understood that the terms "comprising," "including," indicate the presence of the stated feature, step, operation, element, component, item, kind, and / or group, but do not exclude the presence, occurrence, or addition of one or more other features, steps, operations, elements, components, items, kinds, and / or groups. The terms "or" and "and / or" as used herein are to be interpreted as inclusive, or mean any one or any combination thereof. Therefore, "A, B, or C" or "A, B, and / or C" means "any one of the following: A; B; C; A and B; A and C; B and C; A, B, and C". Exceptions to this definition will only occur if the combination of elements, functions, steps, or operations is inherently mutually exclusive in some way.
[0049] It should be understood that although the steps in the flowcharts of this application's embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some of the steps in the figures may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be performed alternately or in turn with other steps or at least a portion of the sub-steps or stages of other steps.
[0050] It should be noted that step designations such as S210 and S220 are used in this document for the purpose of more clearly and concisely describing the corresponding content, and do not constitute a substantial limitation on the order. In specific implementation, those skilled in the art may execute S220 first and then S210, etc., but these should all be within the protection scope of this application.
[0051] It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit this application.
[0052] In the following description, the use of suffixes such as "module," "part," or "unit" to denote elements is solely for the purpose of illustrative purposes and has no specific meaning in itself. Therefore, "module," "part," or "unit" may be used interchangeably.
[0053] First Embodiment
[0054] See Figure 1 This application provides a data processing system comprising a first data processing module, a second data processing module, and a third data processing module. The main functions of the first data processing module are: localizing business code based on reflection and automatically constructing front-end view layer objects. The main functions of the second data processing module are: editing the graphical interface and storing data for the front-end view layer objects constructed by the first data processing module. The main function of the third data processing module is: converting the data stored in the second data processing module into SpEL expressions.
[0055] In the first data processing module, all classes, properties, and methods in the business code are localized into Chinese, and front-end view layer objects are automatically constructed. It's important to note that the front-end view layer is the part of a web or mobile application that users directly interact with. A front-end view layer object refers to the collection of elements and components that constitute the visual interface. In front-end frameworks or libraries, developers use components and elements to construct various parts of the page. These view layer objects can be various interface elements such as buttons, input boxes, images, and paragraphs.
[0056] like Figure 2 As shown, in the first data processing module, developers can use annotations to mark and specify Chinese names on classes, attributes, methods, and parameters, such as `@ZBomType("Chinese name")`. During system initialization, class information (i.e., first data) can be obtained through reflection, including but not limited to the class name, attributes, methods, and constructors. Chinese annotation information in business code (i.e., second data) can also be obtained through reflection. In Java, reflection allows programs to obtain type information and manipulate classes, interfaces, fields, methods, and constructors at runtime. Reflection enables dynamic creation of objects, invocation of methods, access to attributes, and retrieval of class information at runtime.
[0057] Next, after completing the custom annotations and obtaining the first and second data through reflection, the obtained data is then localized into Chinese. Specifically, the names of classes, attributes, and methods are appended with the corresponding Chinese names specified in the annotations. Thus, the first data processing module dynamically obtains information such as classes, attributes, and methods from the business code using reflection, and automatically performs Chinese localization based on the annotations added to the classes, methods, and parameters to obtain the third data.
[0058] Finally, the front-end view layer object is constructed based on the Chinese-language class, attribute, method, and other third-party data, and the third-party data is converted into JSON format and transmitted to the front end.
[0059] In one embodiment, the first data processing module can also implement exception handling. By capturing and handling exceptions that may occur during reflection operations, such as class non-existence or method non-existence, it provides more user-friendly error messages and a more stable and robust operating environment, thereby enhancing code reliability.
[0060] In one implementation, the first data processing module employs a caching mechanism to improve performance. After obtaining class information and performing Chinese localization, the processing result can be cached. The next time the same class is used, the Chinese-localized class information can be retrieved directly from the cache, avoiding repeated execution of reflection operations, thereby improving the system's response speed and performance.
[0061] In one embodiment, the first data processing module can dynamically obtain the currently callable methods and accessible attribute information through reflection and annotations, and provide them to the front-end object so as to display and execute the corresponding operations.
[0062] Thus, the first data processing module can easily translate classes, properties, and methods in the business code into Chinese and automatically generate corresponding front-end view layer objects. Simultaneously, based on the front-end's request content, the first data processing module can dynamically return currently callable methods and accessible property information to the front-end object, and provide appropriate parameter options for the currently operating method, achieving efficient interaction with the front-end. Furthermore, the automatic construction and Chinese translation of the front-end view layer objects ensure that business data is presented to users in a user-friendly and easy-to-understand manner.
[0063] Please refer to Figure 3 In the second data processing module, a rule tree can be used to display the relationships between elements and components in the front-end view layer object. For example, the parent rule box "DIY - Outsourcing Processes" is associated with two child rule boxes, 1100 and 1103. Rule box 1100 is associated with rule boxes H10, A18, etc., while rule box 1103 is associated with rule boxes H20, H21, H39, A21, etc. Clicking on any rule box will take you to... Figure 4 The rule definition interface shown is mainly composed of four parts: initial value setting, comparison operator selection, value type selection, and matching results.
[0064] For initial value setting operations, initial values are mainly divided into several types, including attributes, objects, collections, and methods. Attributes are single, immutable values, such as a business unit. Objects are translated from Java's Object class and allow attribute selection, such as extended views. In Java, an object refers to an instance of a class. An object is an actual data structure existing in memory; it has attributes (member variables) and methods (member functions) and can store data and perform operations. Collections are translated from Java's Map class and allow retrieving values by inputting a key, such as a material version attribute. A Map is a data structure in Java used to store key-value pairs. Each key is unique, and the corresponding value can be accessed through the key. Methods are translated from Java's Service layer and allow selection of the methods to be called. The Service layer, or business logic layer, is an intermediate layer between the Controller and Data Access layer (DAO layer). It is mainly responsible for handling business logic, coordinating different business operations, and providing high-level interfaces to upper layers.
[0065] For comparison operator selection, the main comparison operators include greater than, less than, equal to, not equal to, in set, and empty. For value type selection, you can choose input values or variables. For matching results, you can enter custom values through input boxes.
[0066] The following are examples illustrating four specific situations.
[0067] like Figure 5 As shown, when the initial value is selected as the object "Extended View", you can select the object attributes at the next level and then fill them into the initial value box. For example, "Extended View.Material Code", where "." represents the hierarchical relationship. When multiple judgments are needed, you can use... Add conditions to perform logical judgments using "AND" and "OR". Figure 5 In the comparison operator, select "equals". In the value type selection box, select the input value that matches the defined rule, such as "26594512532154416" or "123456789". In the result box, define an example result when the match is successful. The multiple logical judgments for each case are similar.
[0068] like Figure 6 As shown, when the initial value is selected as the set "Material Version Attributes", you can customize the input on the underline, and match the corresponding value from the set using the key value. For example, "Material Version Attributes.PQN3_CZ". Here, "." is used to indicate a hierarchical relationship, and other conditions are selected in the same way as in the example above.
[0069] like Figure 7 As shown, when the initial value is selected as the method "Extended View Service Class", you can proceed to the next level of selection and choose a method within that service class. For example, "Extended View Service Class.Get Earthwork Materials()", you can fill in the input parameters within the parentheses. The input parameters can be attributes passed in from the backend or custom input strings. Figure 7 The input parameters “Material Version”, “Plant”, and “Process Attribute” are attributes passed in from the backend, while “GY9MaterialPreRevision” and “PGY9_GROOVECUTTING” are custom input strings.
[0070] like Figure 8 As shown, when the initial value is selected as the attribute "Business Unit", the other conditions are selected in the same way as in the example above.
[0071] In the third data processing module, the JSON data returned from the front end is parsed and converted into Java objects. These objects are then concatenated into SpEL expressions. For example... Figure 9 As shown, JSON format data mainly consists of three parts: initValue, result, and map. InitValue represents the initial value, such as "Business Unit". Result represents the result, such as "Example Result". Map represents the connection logic between comparison operators, input values, and conditions, such as "map", "map1", "map2", "map3", and "map4".
[0072] In actual implementation, the JSON data returned by the front end is first parsed into a corresponding data structure. Then, the values of the initValue, result, and map parts are extracted from the parsed data structure. These values are retrieved using appropriate methods based on the structure of the JSON data. The map has four keys: comparison operator, input value, and and or. The values for and and or are array structures storing collection names, such as map1, used to represent the logical relationships between multiple conditions. Next, based on the extracted data, a SpEL expression string is constructed using string concatenation. The specific construction process depends on the data format and the required expression logic. Comparison operators, functions, etc., can be used to define the expression. Ensure that the generated expression string conforms to SpEL syntax rules. For the transformation and concatenation of values in the map, a depth-first search is used to achieve the logical connection between the conditions, as follows:
[0073] a. Retrieve the map key values from the parsed JSON data. Use the appropriate method to retrieve the map values based on the parsing library's methods and data structure.
[0074] Extract the comparison operator and input value from the b.map. Based on the structure of the JSON data, use the appropriate methods to obtain the comparison operator and input value. The comparison operator and input value can be of types such as strings and numbers; perform the appropriate type conversion as needed.
[0075] c. Extract the values of `and` and `or`. Based on the structure of the JSON data, retrieve the values of `and` and `or`. Since their values are array-like, they can be extracted into a collection or list using appropriate methods. Each element represents the name of a condition or combination of conditions, such as "map1".
[0076] d. Construct conditional logic expressions. Based on the extracted comparison operators, input values, and the values of `and` and `or`, construct expressions representing conditional logic. Depending on the specific requirements and the programming language used, use logical operators (such as `&&`, `||`) to combine the conditions.
[0077] e. Combine the extracted comparison operator, input value, and conditional logic expression into a SpEL expression, such as... Figure 4 The conditions in the expression, when concatenated and converted into a SpEL expression, are as follows:
[0078] Condition: {(#extendpandView.getItemId()=="26594512532154416"&extendpandView.getItemId()=="123456789")||#extendpandView.getItemId()=="987654321"}
[0079] Action: #{#result['result'] = "example result"}
[0080] The SpEL parser (ExpressionParser) parses the expression string and compiles it into an evaluable expression object (Expression). The expression object is then evaluated using the `getValue()` method; a result of `true` or `false` indicates correct expression conversion. The result of the expression is then processed or further operations are performed as needed. Different logic can be executed based on the expression's result.
[0081] Second Embodiment
[0082] See Figure 10 This application provides a data processing method, which can be executed by a data processing system provided in this application. The data processing system can be implemented using software and / or hardware. The data processing method provided in this embodiment includes:
[0083] Step S210: Create a front-end view layer object based on the business code. The front-end view layer object includes at least one type of natural language.
[0084] In one implementation, a front-end view layer object is created based on business code. The front-end view layer object includes at least one type of natural language, including:
[0085] Obtain the first data and the second data from the business code, wherein the first data includes class information in the business code and the second data includes Chinese annotation information in the business code;
[0086] Generate third data based on the first and second data;
[0087] Generate a front-end view layer object based on the third data.
[0088] In one embodiment, the data processing method of this application further includes: obtaining first data and second data from business code through JAVA reflection mechanism.
[0089] This step can be performed by the first data processing module in the data processing system.
[0090] In the first data processing module, all classes, properties, and methods in the business code are localized into Chinese, and front-end view layer objects are automatically constructed. It's important to note that the front-end view layer is the part of a web or mobile application that users directly interact with. A front-end view layer object refers to the collection of elements and components that constitute the visual interface. In front-end frameworks or libraries, developers use components and elements to construct various parts of the page. These view layer objects can be various interface elements such as buttons, input boxes, images, and paragraphs.
[0091] like Figure 2 As shown, in the first data processing module, developers can use annotations to mark and specify Chinese names on classes, attributes, methods, and parameters, such as `@ZBomType("Chinese name")`. During system initialization, class information (i.e., first data) can be obtained through reflection, including but not limited to the class name, attributes, methods, and constructors. Chinese annotation information in business code (i.e., second data) can also be obtained through reflection. In Java, reflection allows programs to obtain type information and manipulate classes, interfaces, fields, methods, and constructors at runtime. Reflection enables dynamic creation of objects, invocation of methods, access to attributes, and retrieval of class information at runtime.
[0092] Next, after completing the custom annotations and obtaining the first and second data through reflection, the obtained data is then localized into Chinese. Specifically, the names of classes, attributes, and methods are appended with the corresponding Chinese names specified in the annotations. Thus, the first data processing module dynamically obtains information such as classes, attributes, and methods from the business code using reflection, and automatically performs Chinese localization based on the annotations added to the classes, methods, and parameters to obtain the third data.
[0093] Finally, the front-end view layer object is constructed based on the Chinese-language class, attribute, method, and other third-party data, and the third-party data is converted into JSON format and transmitted to the front end.
[0094] Optionally, the data processing method further includes: capturing and handling exceptions during the process of obtaining the first and second data from the business code. Here, the first data processing module can also implement exception handling. By capturing and handling exceptions that may occur in reflection operations, such as classes not existing or methods not existing, more user-friendly error messages and a more stable and robust runtime environment are provided, thus enhancing code reliability.
[0095] Optionally, the first data processing module employs a caching mechanism to improve performance. After obtaining class information and performing Chinese localization, the processing results can be cached. The next time the same class is used, the Chinese-localized class information can be retrieved directly from the cache, avoiding repeated execution of reflection operations, thereby improving the system's response speed and performance.
[0096] Optionally, the first data processing module can dynamically obtain the currently callable methods and accessible property information through reflection and annotations, and provide them to the front-end object for display and execution of corresponding operations.
[0097] Thus, the first data processing module can easily translate classes, properties, and methods in the business code into Chinese and automatically generate corresponding front-end view layer objects. Simultaneously, based on the front-end's request content, the first data processing module can dynamically return currently callable methods and accessible property information to the front-end object, and provide appropriate parameter options for the currently operating method, achieving efficient interaction with the front-end. Furthermore, the automatic construction and Chinese translation of the front-end view layer objects ensure that business data is presented to users in a user-friendly and easy-to-understand manner.
[0098] Step S220: Execute the rule definition operation based on the front-end view layer object, and generate JSON format data according to the operation result.
[0099] In one implementation, a rule-defined operation is performed based on a front-end view layer object, and JSON format data is generated based on the operation result, including:
[0100] A rule tree is created based on the front-end view layer object. The rule tree includes a definable rule box.
[0101] The rule definition operation is performed through the definable rule box to receive business rule data, which includes first business rule data and second business rule data. The first business rule data is obtained through the front-end view layer object, and the second business rule data is obtained through user input.
[0102] Generate JSON format data based on front-end view layer objects and business rule data.
[0103] In one implementation, the rule definition operation includes one or more of the following: initial value setting, comparison operator selection, selection value type setting, and matching result input.
[0104] This step can be performed by the second data processing module in the data processing system.
[0105] like Figure 3As shown, in the second data processing module, the relationships between elements and components in the front-end view layer object can be displayed in a rule tree format. For example, the parent rule box "Self-made - Outsourced Process" is associated with two child rule boxes, 1100 and 1103. Rule box 1100 is further associated with rule boxes H10, A18, etc., while rule box 1103 is associated with rule boxes H20, H21, H39, A21, etc. Clicking on any rule box will take you to... Figure 4 The rule definition interface shown is mainly composed of four parts: initial value setting, comparison operator selection, value type selection, and matching results.
[0106] For initial value setting operations, initial values are mainly divided into several types, including attributes, objects, collections, and methods. Attributes are single, immutable values, such as a business unit. Objects are translated from Java's Object class and allow attribute selection, such as extended views. In Java, an object refers to an instance of a class. An object is an actual data structure existing in memory; it has attributes (member variables) and methods (member functions) and can store data and perform operations. Collections are translated from Java's Map class and allow retrieving values by inputting a key, such as a material version attribute. A Map is a data structure in Java used to store key-value pairs. Each key is unique, and the corresponding value can be accessed through the key. Methods are translated from Java's Service layer and allow selection of the methods to be called. The Service layer, or business logic layer, is an intermediate layer between the Controller and Data Access layer (DAO layer). It is mainly responsible for handling business logic, coordinating different business operations, and providing high-level interfaces to upper layers.
[0107] For comparison operator selection, the main comparison operators include greater than, less than, equal to, not equal to, in set, and empty. For value type selection, you can choose input values or variables. For matching results, you can enter custom values through input boxes.
[0108] The following are examples illustrating four specific situations.
[0109] like Figure 5 As shown, when the initial value is selected as the object "Extended View", you can select the object attributes at the next level and then fill them into the initial value box. For example, "Extended View.Material Code", where "." represents the hierarchical relationship. When multiple judgments are needed, you can use... Add conditions to perform logical judgments using "AND" and "OR". Figure 5In the comparison operator, select "equals". In the value type selection box, select the input value that matches the defined rule, such as "26594512532154416" or "123456789". In the result box, define an example result when the match is successful. The multiple logical judgments for each case are similar.
[0110] like Figure 6 As shown, when the initial value is selected as the set "Material Version Attributes", you can customize the input on the underline, and match the corresponding value from the set using the key value. For example, "Material Version Attributes.PQN3_CZ". Here, "." is used to indicate a hierarchical relationship, and other conditions are selected in the same way as in the example above.
[0111] like Figure 7 As shown, when the initial value is selected as the method "Extended View Service Class", you can proceed to the next level of selection and choose a method within that service class. For example, "Extended View Service Class.Get Earthwork Materials()", you can fill in the input parameters within the parentheses. The input parameters can be attributes passed in from the backend or custom input strings. Figure 7 The input parameters “Material Version”, “Plant”, and “Process Attribute” are attributes passed in from the backend, while “GY9MaterialPreRevision” and “PGY9_GROOVECUTTING” are custom input strings.
[0112] like Figure 8 As shown, when the initial value is selected as the attribute "Business Unit", the other conditions are selected in the same way as in the example above.
[0113] Step S230: Parse the JSON format data to construct a SpEL expression.
[0114] In one implementation, parsing JSON formatted data to construct a SpEL expression includes:
[0115] Parse the data structure from the JSON data;
[0116] Extracting numerical values from JSON data based on the data structure;
[0117] SpEL expressions are constructed by concatenating numerical values using string concatenation.
[0118] In one implementation, after parsing the JSON-formatted data to construct the SpEL expression, the process further includes:
[0119] SpEL expressions are parsed using SpEL's parser and compiled into evaluable expression objects;
[0120] Evaluate the expression object to obtain the evaluation result of the expression.
[0121] This step can be performed by the third data processing module in the data processing system.
[0122] In the third data processing module, the JSON data returned from the front end is parsed and converted into Java objects. These objects are then concatenated into SpEL expressions. For example... Figure 9 As shown, JSON format data mainly consists of three parts: initValue, result, and map. InitValue represents the initial value, such as "Business Unit". Result represents the result, such as "Example Result". Map represents the connection logic between comparison operators, input values, and conditions, such as "map", "map1", "map2", "map3", and "map4".
[0123] In actual implementation, the JSON data returned by the front end is first parsed into a corresponding data structure. Then, the values of the initValue, result, and map parts are extracted from the parsed data structure. These values are retrieved using appropriate methods based on the structure of the JSON data. The map has four keys: comparison operator, input value, and and or. The values for and and or are array structures storing collection names, such as map1, used to represent the logical relationships between multiple conditions. Next, based on the extracted data, a SpEL expression string is constructed using string concatenation. The specific construction process depends on the data format and the required expression logic. Comparison operators, functions, etc., can be used to define the expression. Ensure that the generated expression string conforms to SpEL syntax rules. For the transformation and concatenation of values in the map, a depth-first search is used to achieve the logical connection between the conditions, as follows:
[0124] a. Retrieve the map key values from the parsed JSON data. Use the appropriate method to retrieve the map values based on the parsing library's methods and data structure.
[0125] Extract the comparison operator and input value from the b.map. Based on the structure of the JSON data, use the appropriate methods to obtain the comparison operator and input value. The comparison operator and input value can be of types such as strings and numbers; perform the appropriate type conversion as needed.
[0126] c. Extract the values of `and` and `or`. Based on the structure of the JSON data, retrieve the values of `and` and `or`. Since their values are array-like, they can be extracted into a collection or list using appropriate methods. Each element represents the name of a condition or combination of conditions, such as "map1".
[0127] d. Construct conditional logic expressions. Based on the extracted comparison operators, input values, and the values of `and` and `or`, construct expressions representing conditional logic. Depending on the specific requirements and the programming language used, use logical operators (such as `&&`, `||`) to combine the conditions.
[0128] e. Combine the extracted comparison operator, input value, and conditional logic expression into a SpEL expression, such as... Figure 4 The conditions in the expression, when concatenated and converted into a SpEL expression, are as follows:
[0129] Condition: {(#extendpandView.getItemId()=="26594512532154416"&extendpandView.getItemId()=="123456789")||#extendpandView.getItemId()=="987654321"}
[0130] Action: #{#result['result'] = "example result"}
[0131] The SpEL parser (ExpressionParser) parses the expression string and compiles it into an evaluable expression object (Expression). The expression object is then evaluated using the `getValue()` method; a result of `true` or `false` indicates correct expression conversion. The result of the expression is then processed or further operations are performed as needed. Different logic can be executed based on the expression's result.
[0132] The specific execution process of the data processing method in this application embodiment can be referred to the data processing system of the first embodiment.
[0133] In summary, the method provided in the above embodiments involves creating a front-end view layer object based on business code, the front-end view layer object including at least one type of natural language; executing rule-defined operations based on the front-end view layer object, generating JSON format data based on the operation results; and parsing the JSON format data to construct a SpEL expression. This enables the automatic generation of SpEL expressions based on business code, achieving rapid conversion between natural language and SpEL expressions, with simple operation and high visualization.
[0134] Based on the same inventive concept as the foregoing embodiments, this embodiment also provides an electronic device, including a processor, a memory, and a computer program stored in the memory and executable on the processor. When executed by the processor, the computer program implements the aforementioned data processing method. For the specific steps implemented by the computer program when executed by the processor, please refer to... Figure 1 The description of the illustrated embodiments will not be repeated here.
[0135] Based on the same inventive concept as the foregoing embodiments, this embodiment also provides a computer-readable storage medium storing a computer program. The computer-readable storage medium can be a magnetic random access memory (FRAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM), etc.; it can also be various devices including one or any combination of the above-mentioned memories, such as mobile phones, computers, tablet devices, personal digital assistants, etc. When the computer program stored in the computer-readable storage medium is executed by a processor, it implements the above-described data processing method. For the specific steps implemented when the computer program is executed by the processor, please refer to [link to relevant documentation]. Figure 1 The description of the illustrated embodiments will not be repeated here.
[0136] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0137] In this document, the terms “comprising,” “including,” or any other variations thereof are intended to cover non-exclusive inclusion, which includes not only the elements listed but also other elements not expressly listed.
[0138] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A data processing method, characterized in that, The method includes: A front-end view layer object is created based on the business code, and the front-end view layer object includes at least one type of natural language; Based on the front-end view layer object, perform the rule definition operation and generate JSON format data according to the operation result; Parse the JSON format data to construct a SpEL expression; The step of performing rule-defined operations based on the front-end view layer object and generating JSON format data based on the operation results includes: A rule tree is created based on the front-end view layer object, the rule tree including a definable rule box; The rule definition operation is performed through the definable rule box to receive business rule data, which includes first business rule data and second business rule data. The first business rule data is obtained through the front-end view layer object, and the second business rule data is obtained through user input. Generate JSON format data based on the front-end view layer object and the business rule data; The rule definition operation includes one or more of the following: initial value setting, comparison operator selection, selection value type setting, and matching result input.
2. The method according to claim 1, characterized in that, The step of creating a front-end view layer object based on business code, wherein the front-end view layer object includes at least one type of natural language, including: Obtain first data and second data from the business code, wherein the first data includes class information in the business code, and the second data includes Chinese annotation information in the business code; Generate third data based on the first data and the second data; A front-end view layer object is generated based on the third data.
3. The method according to claim 2, characterized in that, The method further includes: The first and second data in the business code are obtained through the Java reflection mechanism.
4. The method according to claim 2 or 3, characterized in that, The method further includes: Capture and handle exceptions during the process of obtaining the first and second data in the business code.
5. The method according to claim 1, characterized in that, The process of parsing the JSON format data to construct a SpEL expression includes: The data structure is parsed from the JSON format data; Extract the numerical values from the JSON format data according to the data structure; The numerical values are concatenated using string concatenation to construct a SpEL expression.
6. The method according to claim 1 or 5, characterized in that, After parsing the JSON format data to construct the SpEL expression, the process also includes: The SpEL expression is parsed using the SpEL parser and compiled into an evaluable expression object; The expression object is evaluated to obtain the evaluation result of the expression.
7. An electronic device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the data processing method as described in any one of claims 1 to 6.
8. A computer-readable storage medium, characterized in that, The device contains a computer program that, when executed by a processor, implements the steps of the data processing method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Visualized generation method and system of calculation rule scripts
CN103577174A
Service rule generation method and system based on natural language processing
CN110196719A