Business function code generation method and device, medium and equipment
By parsing user requirement statements into Java objects and generating execution code using rule templates, combined with an automated testing platform, the problem of low efficiency in implementing vehicle business functions was solved, achieving efficient and low-cost function development.
Patent Information
- Application Number
- CN202410585986.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-11
- Publication Date
- 2025-11-14
AI Technical Summary
The current technology for implementing vehicle business functions is inefficient and costly, mainly due to the large number of personnel required for understanding requirements, coding, and testing, which leads to a long implementation cycle.
By acquiring user requirement statements, parsing them into Java objects, using rule type objects and rule templates to perform semantic rule transformation, generating executable code, and verifying and correcting it through an automated testing platform, the process of requirement design and coding is automated.
It improved the efficiency of generating business functions, reduced labor costs, shortened the function implementation cycle, and reduced the error rate.
Smart Images

Figure CN120950075A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of automotive technology, and in particular to a method, apparatus, medium, and device for generating code for business functions. Background Technology
[0002] In existing technologies, implementing a business function on a vehicle requires processes such as requirement transformation, design, development, testing, and deployment. Software developers, through understanding the functional requirements, then proceed with design, coding, and deployment. Design requires strong expertise in the business domain; coding requires a deep understanding of programming languages; and a large number of testers are needed to verify the functionality of each version. Overall, the human resource costs are high, and the function implementation cycle is lengthy. Therefore, existing technologies suffer from low efficiency and high cost in implementing business functions in vehicles. Summary of the Invention
[0003] To address the aforementioned technical problems, this disclosure provides a method, apparatus, medium, and device for generating code for business functions, thereby improving the efficiency of business function implementation.
[0004] This disclosure provides a method for generating code for business functions, including:
[0005] Obtain the user's input request statements for business service functions;
[0006] The requirement statement is parsed to obtain a Java object; wherein, the Java object includes: a rule type object;
[0007] Based on the rule template corresponding to the rule type object, the semantic rules of the requirement statement are transformed to generate the execution code of the business service function.
[0008] In some embodiments, the step of semantically transforming the requirement statement based on the rule template corresponding to the rule type object to generate the execution code for the business service function includes:
[0009] Obtain the transformation rules from the rule template corresponding to the rule type object; wherein, the transformation rules include: logical operation rules, arithmetic operation rules, and code library;
[0010] The semantics and logical operation relationships of the requirement statement are transformed according to the logical operation rules to generate a logical framework;
[0011] The arithmetic operation relationships of the requirement statement are transformed according to the arithmetic operation rules to generate an operation framework;
[0012] Definition information is generated by operating on the preset definition items in the code library; wherein, the definition items include: variables, execution actions, and signals;
[0013] Generate executable action statements from the computational framework and the definition information;
[0014] The code generator uses the computational framework and the executable action statements to generate the executable code for the business service function.
[0015] In some embodiments, the Java object further includes: a key representation object; the step of performing semantic rule transformation on the requirement statement based on the rule template corresponding to the rule type object to generate the execution code of the business service function includes:
[0016] Based on the rule templates corresponding to the key representation object and the rule type object, the semantic rules of the requirement statement are transformed to generate the execution code of the business service function;
[0017] The key representation objects include: a Java object for parsing Value expressions, a Java object for performing unit conversions, a Java object for finding signal groups, a Java object for expanding loop rules, a Java object for grouping lifecycles, a Java object for converting SOA signals to IDL signals, and a Java object for escaping special characters and converting pinyin for custom variables.
[0018] In some embodiments, after generating the executable code for the business service function, the method further includes:
[0019] Verify the execution code of the aforementioned business service functions;
[0020] After the execution code verification is passed, the functional version of the business service function and the scope of vehicles to be released are generated.
[0021] In some embodiments, verifying the execution code of the business service function includes:
[0022] Using the executed code as the currently executed code, perform the following verification operation on the currently executed code:
[0023] The currently executing code is verified based on a preset test simulation environment;
[0024] If the verification of the currently executing code fails, a prompt message is generated to correct the currently executing code;
[0025] Receive the new currently executing code corrected by the user based on the prompt information;
[0026] The verification operation is performed multiple times until the currently executing code passes verification, and the currently executing code that passes verification is determined as the target executing code for the business service function.
[0027] In some embodiments, the verification of the currently executing code based on a preset test simulation environment includes:
[0028] The requirement statement is parsed to obtain the test scenario parameters and test steps corresponding to the test cases based on natural language description;
[0029] The test steps are converted into script test files, and test cases are generated by executing the script test files.
[0030] The test simulation environment preset for the business service function is adjusted according to the test scenario parameters to obtain the target test simulation environment;
[0031] The test cases are executed in the target simulation environment, and the currently executing code is verified based on the execution results.
[0032] In some embodiments, obtaining the user's input request statement for the business service function includes:
[0033] Receive natural language statements input by users on the operation interface for business service functions;
[0034] The natural speech statements are converted into Extensible Markup Language (XML) files and stored.
[0035] Retrieve the XML file and parse it into an intermediate file;
[0036] The intermediate file is serialized into a JSON format requirement statement.
[0037] This disclosure provides a code generation apparatus for business functions, including:
[0038] The requirement elicitation module is used to obtain the requirement statements input by users for business service functions.
[0039] The statement parsing module is used to parse the requirement statement to obtain a Java object; wherein, the Java object includes: a rule type object;
[0040] The code conversion module is used to convert the semantic rules of the requirement statement based on the rule template corresponding to the rule type object, and generate the execution code of the business service function.
[0041] This disclosure also provides a computer-readable storage medium that stores a program or instructions that cause a computer to perform the steps of any of the above methods.
[0042] This disclosure also provides an electronic device, including:
[0043] One or more processors;
[0044] Memory, used to store one or more programs or instructions;
[0045] The processor executes the steps of any of the above methods by calling programs or instructions stored in the memory.
[0046] The technical solution provided in this disclosure has the following advantages compared with the prior art:
[0047] The technical solution provided in this disclosure includes: acquiring a user's input requirement statement for a business service function; parsing the requirement statement to obtain a Java object; wherein the Java object includes a rule type object; and performing semantic rule transformation on the requirement statement based on the rule template corresponding to the rule type object to generate executable code for the business service function. This technical solution utilizes rule templates to convert requirement statements described in natural language into executable code, eliminating the need for personnel designing business functions to have a deep understanding of programming languages. It effectively solves problems such as requirement mismatches and functional failures caused by coding issues, thus improving the efficiency of executable code generation. Attached Figure Description
[0048] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.
[0049] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0050] Figure 1 A flowchart illustrating a code generation method for a business function provided in this embodiment of the disclosure;
[0051] Figure 2 A structural block diagram of a service creation system provided in this disclosure embodiment;
[0052] Figure 3 This is a schematic diagram of the operation interface in an embodiment of this disclosure;
[0053] Figure 4A structural block diagram of a code generation apparatus for a business function provided in this embodiment of the disclosure;
[0054] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation
[0055] To better understand the above-mentioned objectives, features, and advantages of this disclosure, the solutions disclosed herein will be further described below. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other.
[0056] Numerous specific details are set forth in the following description in order to provide a full understanding of this disclosure, but this disclosure may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only some, and not all, of the embodiments of this disclosure.
[0057] Figure 1 This is a flowchart illustrating a code generation method for a business function provided in an embodiment of this disclosure. This method is applicable to the development of business functions for intelligent vehicles, improving the efficiency of vehicle function implementation, and can be applied to both autonomous and manned vehicles. This method can be executed by a code generation device for the business function, which can be implemented in software and / or hardware. Figure 1 As shown, the method includes the following steps:
[0058] S102. Obtain the user's input request statement for the business service function.
[0059] like Figure 2 As shown, one embodiment may include: receiving natural language statements input by the user on the operation interface for business service functions; converting the natural language statements into XML (eXtensible Markup Language) files for storage; retrieving the XML file and parsing the XML file into an intermediate file; and serializing the intermediate file into a JSON format requirement statement.
[0060] The user interface provided in this embodiment is used to create business service functions. Users can use this interface to create the business service functions they need to manage. Users can select vehicles through the user interface and input various information such as basic information, status information, control information, and rule information of the selected vehicles.
[0061] As an example, such as Figure 3As shown, the left side of the operation interface displays the business service functions of different nodes. For example, the resource is the initial node, the fault tree is the next level node of the resource, and the fault tree is further divided into basic functions, road mode and scenario mode nodes. The sentinel mode, which is the next level of the scenario mode, is the lowest level node.
[0062] For the business service functions represented by the lowest-level nodes, a requirement description tree is pre-configured. The requirement description tree is used to provide users with editing boxes for multiple requirement editing contents.
[0063] For example, Sentinel mode represents the business service function currently being managed in this embodiment. Sentinel mode can be selected by clicking, and then a pre-configured requirement description tree is obtained. This tree includes multiple requirement editing options such as entry / exit conditions, function exception conditions, and exit / non-exit conditions. Users can enter natural language statements representing their requirements in the various edit boxes within the requirement description tree. The front-end then logically combines these statements to dynamically generate an XML file representing the user's management requirements for the business service function. This XML file is then saved to the back-end rule system.
[0064] When a user wants to manage business service functions, they can request an XML file from the backend. The backend retrieves the XML file, parses it to generate a Java object, and then serializes the Java object into JSON to obtain the requested statement.
[0065] It is understandable that users can input multiple pieces of information about business service functions through the operation interface, such as vehicle model, version information, vehicle acquisition and control CAN signal library, SOA (Service Oriented Architecture) in-vehicle interaction signal library, EID / FID fault diagnosis library, etc., without any restrictions.
[0066] S104. Parse the requirement statement to obtain a Java object; the Java object includes, but is not limited to, a rule type object.
[0067] In this embodiment, the requirement statement can be input into a semantic rule recognition and conversion system, which parses the requirement statement and converts it into semantic rules. Specifically, parsing the requirement statement yields Java objects representing rule types, i.e., rule type objects. These rule type objects can be specific examples such as RuleSet, DeriveSignal, and ParseTree.
[0068] S106. Based on the rule template corresponding to the rule type object, the requirement statement is transformed into semantic rules to generate the execution code of the business service function.
[0069] In this embodiment of the semantic rule recognition and conversion system, the conversion rules in the rule template corresponding to the rule type object are first obtained; wherein, the conversion rules include: logical operation rules, arithmetic operation rules and code library.
[0070] Different rule type objects correspond to different rule templates, as shown in the examples provided in Table 1. A rule template can specifically be a Lua script template:
[0071] Table 1
[0072]
[0073] Table 1 above records the different rule templates corresponding to different rule types of objects, as well as the root directory and index file corresponding to each rule template.
[0074] Each rule template typically includes several parts: referenced modules, local constants, local variables, rules, and function entry points. Rules include logical operation rules and arithmetic operation rules. Function entry points can be used to integrate code libraries. The specific content of these parts varies depending on the rule template; for example, the rules in a rule set template include `if-then-other`, the rules in a derived signal template include `if-start trigger-end trigger`, and the rules in a parse tree template include `if-then`.
[0075] Then, based on logical operation rules, arithmetic operation rules, and the code library, the requirement statements are transformed according to semantic rules, as shown below.
[0076] The semantics and logical relationships of the requirement statements are transformed according to logical operation rules to generate a logical framework. Specifically, the logical operation rules include: and, or, not, if, and then.
[0077] The arithmetic operation relationships in the requirement statement are transformed according to the arithmetic operation rules to generate an operation framework. Specifically, the arithmetic operation rules include: arithmetic operators for various numerical operations (addition, subtraction, multiplication, division, modulo, etc.), relational operators for comparison operations (greater than, less than, equal to, not equal to, etc.), and logical operators for logical operations (logical AND, logical OR, NOT, etc.).
[0078] Definition information is generated by operating on preset definition items in the code library; these definition items include variables, actions, and signals. Specifically, the user defines and / or selects variables in the variable library, defines and / or selects actions in the action library, and defines and / or imports vehicle signal matrices from the signal library. Based on these operations, definition information about variables, actions, and vehicle signals is generated.
[0079] Then, the computational framework and definition information are used to generate executable action statements. Additionally, a code generator is used to generate executable code for the business service functions from the computational framework and executable action statements. The code generator can be implemented using existing technologies, employing a pre-defined programming language such as Python or Lua to generate executable code for the corresponding business service functions from the computational framework and executable action statements.
[0080] Considering that some requirement statements and the execution code to be generated may be quite complex in practical applications, in order to further improve the accuracy of the generated execution code, this embodiment can also combine other Java objects parsed from the requirement statement to perform semantic rule transformation on the basis of the rule template.
[0081] Therefore, in one embodiment, the Java object obtained by parsing the requirement statement may further include: a key representation object; correspondingly, this embodiment may include: based on the rule template corresponding to the key representation object and the rule type object, performing semantic rule transformation on the requirement statement to generate the execution code of the business service function. The key representation object may include the following examples:
[0082] Example 1: A Java object used to parse Value expressions; specifically, there are six main types of Value expressions: SignalValue, VariableValue, MethodValue (built-in method in the vehicle), CommonFunctionValue (built-in Lua function), ParentValue (parentheses), and SimpleValue (if there are units involved, such as time, speed, percentage, etc., for conversion).
[0083] Example 2: A Java object used for unit conversion; specifically, the unit conversion can be performed using the Python framework pint.
[0084] Example 3 is a Java object used to find signal groups; specifically, it searches for all signals in the entire Java object and groups the signals according to the grouping type, such as: soa_signals (SOA matrix), dbc_signals (DBO file), derived_signals (derived signals), db_signals (memory signals), lua_signals (variable signals | node signals), eid_signals (EID signals), fid_signals (FID signals), parameter_signals (parameter signals), vss_signals (VSS signals), and rmeta_signals (RMETA signals).
[0085] Example 4, Java objects used to expand loop rules. Specifically, loop rules need to be expanded according to loop objects; one use case is as follows: the logic of reporting the voltage data of each cell battery in the car to the vehicle system is the same. If it is added according to the rules, it will be mechanically added n times (e.g., n=120), which is very troublesome. Therefore, loop rules are used. SOA signal: MSG_CellVolt Cell voltage Cell battery voltage Float32
[120] (Float32
[260] in EEA2.0); DBO signal: CellVoltage1-CellVoltage120.
[0086] Example 5 is used to group Java objects for lifecycles; specifically, the LifeCycleType is found in the entire Java object, and the methods are grouped according to the grouping type, such as pre_init, post_init, pre_invoke, and post_invoke.
[0087] Example 6: A Java object used to convert SOA signals to IDL signals; specifically, the signals reported to the vehicle's infotainment system need to be converted from SOA signals.
[0088] Example 7 is a Java object used for custom variable special character escaping and pinyin conversion; specifically, user-entered variables may conflict with Lua syntax, requiring this Java object to filter all Chinese and English characters and convert Chinese characters to pinyin.
[0089] It should be noted that the above examples should not be interpreted as limitations. In practical applications, other Java objects can be used to transform the semantic rules of the requirement statements to further improve the accuracy of the generated execution code.
[0090] Based on the above embodiments, after generating the execution code of the business service function, the business service function can be published directly; or, the execution code of the business service function can be verified, and the business service function can be published after the execution code passes the verification.
[0091] Based on this, this embodiment can also provide the following method for generating code for business functions, including:
[0092] Obtain the user's input request statements for business service functions;
[0093] The requirement statement is parsed to obtain Java objects; these Java objects include rule type objects and key representation objects.
[0094] Based on the rule templates corresponding to key representation objects and / or rule type objects, semantic rules are transformed into the requirement statements to generate the execution code for business service functions;
[0095] Verify the execution code of business service functions;
[0096] After the code verification is passed, the functional version of the business service and the scope of vehicles to be released are generated.
[0097] In this embodiment, the implementation process of the above-mentioned step of verifying the execution code of the business service function may include the following.
[0098] The code to be executed is set as the currently executing code, and the following verification operation is performed on the currently executing code:
[0099] (1) Verify the currently executing code based on the preset test simulation environment;
[0100] In specific implementation, such as Figure 2 As shown, an automated verification platform can be used to perform verification operations on the executable code. The automated verification platform can parse the requirement statements to obtain test scenario parameters and corresponding test steps for test cases based on natural language descriptions.
[0101] The test steps are converted into script test files, and test cases are generated by executing the script test files.
[0102] The target test simulation environment is obtained by adjusting the preset test simulation environment of the business service function according to the test scenario parameters. Specifically, the pre-configured test simulation environment of the business service function can be pulled from the knowledge base, and then the specific parameters of the pulled test simulation environment can be adjusted according to the test scenario parameters such as code type, system type, vehicle type, road type and weather conditions to obtain the target test simulation environment.
[0103] Execute test cases in the target simulation environment and verify the currently executing code based on the execution results. Specifically, the Lua execution engine can be used to execute test cases in the target simulation environment, obtaining execution results of success, exception, or failure. The currently executing code is then verified based on these results. If all test cases execute successfully, the currently executing code is considered verified, meaning the business service function verification is successful. If at least one test case results in an exception or failure, the currently executing code is considered to have failed, meaning the business service function verification is unsuccessful.
[0104] (2) If the verification of the currently executed code fails, generate a prompt message to correct the currently executed code.
[0105] In practice, if the currently executed code fails verification, the automatic verification platform can generate a verification result report indicating that the verification failed. This verification result report is then input into the semantic rule recognition and conversion system to identify the failed executable action statements, operation frames, and logic frames, and generate prompt information. This prompt information is used to instruct the user to correct the erroneous executable action statements, operation frames, and logic frames.
[0106] (3) Receive the new current execution code corrected by the user based on the prompt information; for the new current execution code, return to step (1) and re-execute the verification operation.
[0107] The above verification operation is performed multiple times until the currently executing code passes verification, and the currently executing code that passes verification is identified as the target executing code for the business service function.
[0108] This embodiment can correct errors in the code of online business service functions by performing at least one verification operation on the currently executing code, thereby improving the accuracy of the executing code and reducing the error rate.
[0109] Once the target executable code has passed verification, the business service function has been verified and can be released. Based on this, the automated verification platform pushes the verified business service function to the function release system, generating the function version and release vehicle scope for the business service function. Subsequently, once the vehicle detects the new function version, the business service function can be updated.
[0110] In summary, the code generation method for business functions provided in this disclosure includes: obtaining a user's input requirement statement for a business service function; parsing the requirement statement to obtain a Java object; wherein the Java object includes a rule type object; and performing semantic rule transformation on the requirement statement based on the rule template corresponding to the rule type object to generate executable code for the business service function. This technical solution utilizes rule templates to convert requirement statements described in natural language into executable code, eliminating the need for personnel designing business functions to have a deep understanding of programming languages. It effectively solves problems such as requirement mismatches and functional failures caused by coding issues, thus improving the efficiency of executable code generation.
[0111] Implementing a business service function on a vehicle involves processes such as requirement transformation, design, coding, testing, and deployment. The semantic rule recognition and conversion system provided in this disclosure can automatically complete these processes without requiring developers to perform coding or requirement understanding. This effectively solves the problem of function failure caused by requirement mismatches and coding issues. For the testing and deployment stages, the automatic verification platform provided in this disclosure supports the conversion of requirement statements into test cases and test simulation environments, thereby verifying the execution code. It also supports code correction through prompts, which helps reduce the error rate of the executed code. Through these methods, the efficiency of vehicle function implementation is significantly improved, and the vehicle function deployment process and cycle are reduced, thus enhancing the efficiency of vehicle function deployment.
[0112] Corresponding to the code generation method for business functions provided in the embodiments of this disclosure, the embodiments of this disclosure also provide a code generation apparatus for business functions. Figure 4 A structural block diagram of the code generation apparatus for the business functions provided in the embodiments of this disclosure, such as... Figure 4 As shown, the code generation device for this business function includes:
[0113] The requirement acquisition module 210 is used to acquire the requirement statements input by the user for business service functions;
[0114] The statement parsing module 220 is used to parse the requirement statement to obtain a Java object; wherein, the Java object includes: a rule type object;
[0115] The code conversion module 230 is used to convert the semantic rules of the requirement statement based on the rule template corresponding to the rule type object, and generate the execution code of the business service function.
[0116] The vehicle passability detection device disclosed in the above embodiments can perform the vehicle passability detection methods disclosed in the above embodiments and has the same or corresponding beneficial effects. To avoid repetition, it will not be described again here.
[0117] This disclosure also provides a computer-readable storage medium that stores a program or instructions that cause a computer to perform the steps of any of the above methods.
[0118] Obtain the user's input request statements for business service functions;
[0119] The requirement statement is parsed to obtain a Java object; wherein, the Java object includes: a rule type object;
[0120] Based on the rule template corresponding to the rule type object, the semantic rules of the requirement statement are transformed to generate the execution code of the business service function.
[0121] Optionally, when executed by a computer processor, the computer-executable instructions can also be used to execute the technical solutions of any of the vehicle passability detection methods provided in the embodiments of this disclosure, thereby achieving the corresponding beneficial effects.
[0122] Based on the above description of the implementation methods, those skilled in the art can clearly understand that the embodiments of this disclosure can be implemented using software and necessary general-purpose hardware, and of course, they can also be implemented using hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solutions of the embodiments of this disclosure, or the parts that contribute to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory, hard disk, or optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments of this disclosure.
[0123] This disclosure also provides an electronic device, including: one or more processors; a memory for storing one or more programs or instructions; the processors execute the steps of any of the above methods by calling the programs or instructions stored in the memory, thereby achieving the corresponding beneficial effects.
[0124] Figure 5 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of this disclosure. For example... Figure 5 As shown, the electronic device includes one or more processors 301 and memory 302.
[0125] The processor 301 may be a central processing unit (CPU) or other form of processing unit with data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device to perform desired functions.
[0126] The memory 302 may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 301 may execute the program instructions to implement the vehicle passability detection method of the embodiments of this disclosure described above, and / or other desired functions. Various contents such as input signals, signal components, and noise components may also be stored in the computer-readable storage medium.
[0127] In one example, the electronic device may also include an input device 303 and an output device 304, which are interconnected via a bus system and / or other forms of connection mechanism (not shown).
[0128] In addition, the input device 303 may also include, for example, a keyboard, a mouse, etc.
[0129] The output device 304 can output various information to the outside, including determined distance information, direction information, etc. The output device 304 may include, for example, a display, a speaker, a printer, and a communication network and its connected remote output devices, etc.
[0130] Of course, for the sake of simplicity, Figure 5 Only some of the components of the electronic device relevant to this disclosure are shown, omitting components such as buses, input / output interfaces, etc. In addition, the electronic device may include any other suitable components depending on the specific application.
[0131] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, 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 said element.
[0132] The above description is merely a specific embodiment of this disclosure, enabling those skilled in the art to understand or implement it. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this disclosure. Therefore, this disclosure is not to be limited to the embodiments described herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for generating code for a business function, characterized in that, include: Obtain the user's input request statements for business service functions; The requirement statement is parsed to obtain a Java object; wherein, the Java object includes: a rule type object; Based on the rule template corresponding to the rule type object, the semantic rules of the requirement statement are transformed to generate the execution code of the business service function.
2. The method according to claim 1, characterized in that, The step of transforming the semantic rules of the requirement statement based on the rule template corresponding to the rule type object to generate the execution code of the business service function includes: Obtain the transformation rules from the rule template corresponding to the rule type object; wherein, the transformation rules include: logical operation rules, arithmetic operation rules, and code library; The semantics and logical operation relationships of the requirement statement are transformed according to the logical operation rules to generate a logical framework; The arithmetic operation relationships of the requirement statement are transformed according to the arithmetic operation rules to generate an operation framework; Definition information is generated by operating on the preset definition items in the code library; wherein, the definition items include: variables, execution actions, and signals; Generate executable action statements from the computational framework and the definition information; The code generator uses the computational framework and the executable action statements to generate the executable code for the business service function.
3. The method according to claim 1, characterized in that, The Java object further includes: a key representation object; the semantic rule transformation of the requirement statement based on the rule template corresponding to the rule type object to generate the execution code of the business service function includes: Based on the rule templates corresponding to the key representation object and the rule type object, the semantic rules of the requirement statement are transformed to generate the execution code of the business service function; The key representation objects include: a Java object for parsing Value expressions, a Java object for performing unit conversions, a Java object for finding signal groups, a Java object for expanding loop rules, a Java object for grouping lifecycles, a Java object for converting SOA signals to IDL signals, and a Java object for escaping special characters and converting pinyin for custom variables.
4. The method according to claim 1, characterized in that, After generating the executable code for the business service function, the method further includes: Verify the execution code of the aforementioned business service functions; After the execution code verification is passed, the functional version of the business service function and the scope of vehicles to be released are generated.
5. The method according to claim 4, characterized in that, The verification of the execution code of the business service function includes: Using the executed code as the currently executed code, perform the following verification operation on the currently executed code: The currently executing code is verified based on a preset test simulation environment; If the verification of the currently executing code fails, a prompt message is generated to correct the currently executing code; Receive the new currently executing code corrected by the user based on the prompt information; The verification operation is performed multiple times until the currently executing code passes verification, and the verified currently executing code is determined as the target executing code for the business service function.
6. The method according to claim 5, characterized in that, The verification of the currently executing code based on a preset test simulation environment includes: The requirement statement is parsed to obtain the test scenario parameters and test steps corresponding to the test cases based on natural language description; The test steps are converted into script test files, and test cases are generated by executing the script test files. The test simulation environment preset for the business service function is adjusted according to the test scenario parameters to obtain the target test simulation environment; The test cases are executed in the target simulation environment, and the currently executing code is verified based on the execution results.
7. The method according to claim 1, characterized in that, The process of obtaining user input regarding service function requirements includes: Receive natural language statements input by users on the operation interface for business service functions; The natural speech statements are converted into Extensible Markup Language (XML) files and stored. Retrieve the XML file and parse it into an intermediate file; The intermediate file is serialized into a JSON format requirement statement.
8. A code generation device for business functions, characterized in that, include: The requirement elicitation module is used to obtain the requirement statements input by users for business service functions. The statement parsing module is used to parse the requirement statement to obtain a Java object; wherein, the Java object includes: a rule type object; The code conversion module is used to convert the semantic rules of the requirement statement based on the rule template corresponding to the rule type object, and generate the execution code of the business service function.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a program or instructions that cause a computer to perform the steps of the method as described in any one of claims 1 to 7.
10. An electronic device, characterized in that, include: One or more processors; Memory, used to store one or more programs or instructions; The processor executes the steps of the method as described in any one of claims 1 to 7 by invoking programs or instructions stored in the memory.