CN109871214B - Program code generation method, program code generation device, computer device, and storage medium - Google Patents

Program code generation method, program code generation device, computer device, and storage medium Download PDF

Info

Publication number
CN109871214B
CN109871214B CN201910083568.7A CN201910083568A CN109871214B CN 109871214 B CN109871214 B CN 109871214B CN 201910083568 A CN201910083568 A CN 201910083568A CN 109871214 B CN109871214 B CN 109871214B
Authority
CN
China
Prior art keywords
target
item
data item
generating
expression formula
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910083568.7A
Other languages
Chinese (zh)
Other versions
CN109871214A (en
Inventor
袁宏波
陈丹
吴永秀
张蒙川
吴光华
周锋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Kingdee Software China Co Ltd
Original Assignee
Kingdee Software China Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Kingdee Software China Co Ltd filed Critical Kingdee Software China Co Ltd
Priority to CN201910083568.7A priority Critical patent/CN109871214B/en
Publication of CN109871214A publication Critical patent/CN109871214A/en
Application granted granted Critical
Publication of CN109871214B publication Critical patent/CN109871214B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The application relates to a program code generation method, a program code generation device, a computer device and a storage medium. The method comprises the following steps: acquiring target data items selected from the data item set, and generating target calculation items according to the target data items, wherein each target calculation item corresponds to one identifier; acquiring and identifying an input expression formula, wherein the expression formula comprises identifiers corresponding to all target calculation items; and replacing the identifier in the expression formula with the corresponding target calculation item, and generating a program code according to the replaced expression formula. The program code generation method, the program code generation device, the computer equipment and the storage medium can improve the accuracy of the generated program code.

Description

Program code generation method, program code generation device, computer device, and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for generating a program code, a computer device, and a storage medium.
Background
With the development of computer technology, various programming languages are presented, and more people become programmers and engage in the related work of editing application programs. In a conventional method for editing an application program, a programmer inputs codes one by one, so as to generate program codes of the application program.
However, when the code or the programming sentence is very many and complicated, the conventional program code generation method is applied, the editing process is easy to make mistakes, and the accuracy is low.
Disclosure of Invention
In view of the above, it is necessary to provide a program code generating method, apparatus, computer device, and storage medium capable of improving accuracy in view of the above technical problems.
A method of program code generation, the method comprising:
acquiring target data items selected from a data item set, and generating target calculation items according to the target data items, wherein each target calculation item corresponds to an identifier;
acquiring and identifying an input expression formula, wherein the expression formula comprises identifiers corresponding to the target calculation items;
and replacing the identifier in the expression formula with a corresponding target calculation item, and generating a program code according to the replaced expression formula.
In one embodiment, the obtaining a target data item selected from a data item set, and generating a target computation item according to the target data item includes:
the method comprises the steps of obtaining a target data item selected from a data item set, obtaining a target filtering label selected from a middle filtering label set corresponding to the target data item, and obtaining a target function selected from a function set, wherein the target data item is used for obtaining target data from a database, the target filtering label is used for screening the target data, and the target function is used for calculating the target data after the target filtering label is screened;
and generating a target calculation item according to the target data item, the target filtering label and the target function.
In one embodiment, the obtaining a target filtering tag selected from the intermediate filtering tag set corresponding to the target data item includes:
acquiring a target tag name selected from a middle tag name set corresponding to the target data item;
acquiring a target tag value selected from the intermediate tag value set corresponding to the target tag name, and acquiring a selected target matching character from the matching character set;
and generating a target filtering label according to the target label name, the target label value and the target matching character.
In one embodiment, after obtaining the selected objective function from the set of functions, the method further includes:
when the target function belongs to a time function, acquiring a time parameter input according to the target function;
generating a target calculation item according to the target data item, the target filter tag and the target function, wherein the generating of the target calculation item comprises:
and generating a target calculation item according to the target data item, the target filtering label, the target function and the time parameter corresponding to the target function.
In one embodiment, the generating a target computation item according to the target data item, the target filter tag, the target time function, and the time parameter corresponding to the target time function includes:
generating a target symbol according to the target data item, the target filtering label, the target time function and the time parameter corresponding to the target time function;
and generating a target calculation item by the target data item, the target filtering label, the target time function, the time parameter corresponding to the target time function and the target symbol according to a preset arrangement sequence.
In one embodiment, after obtaining and identifying the input expression formula, the method further includes:
when the expression formula is matched with the identifier corresponding to each target calculation item, replacing the identifier in the expression formula with the corresponding target calculation item, and generating a program code according to the replaced expression formula;
and when the expression formula is not matched with the identifier corresponding to each target calculation item, generating prompt information.
In one embodiment, the obtaining a target data item selected from a data item set, and generating a target computation item according to the target data item includes:
when a selected instruction of a data item set displayed in a drop-down box corresponding to a first input box is detected, acquiring a target data item selected by the selected instruction from the data item set, displaying the target data item in the first input box, and generating a target calculation item according to the target data item;
the method further comprises the following steps:
when it is detected that the target data item is presented in the first input box, presenting the target computing item in a second input box.
A program code generation apparatus, the apparatus comprising:
the target calculation item generation module is used for acquiring target data items selected from a data item set and generating target calculation items according to the target data items, wherein each target calculation item corresponds to one identifier;
the expression formula identification module is used for acquiring and identifying an input expression formula, wherein the expression formula comprises identifiers corresponding to the target calculation items;
and the program code generation module is used for replacing the identifier in the expression formula with the corresponding target calculation item and generating a program code according to the replaced expression formula.
A computer device comprising a memory storing a computer program and a processor implementing the steps of the program code generation method described above when executing the computer program.
A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the above-mentioned program code generation method.
According to the program code generation method, the program code generation device, the computer equipment and the storage medium, the target calculation item which is edited in advance is selected from the data item set, errors are not prone to occurring, the program code can be generated by inputting the expression formula comprising the identifier, the input expression formula is generated by the simple identifier, errors are not prone to occurring, and the accuracy of generating the program code is improved.
Drawings
FIG. 1 is a diagram of an application environment of a program code generation method in one embodiment;
FIG. 2 is a flowchart illustrating a method for generating program code according to one embodiment;
FIG. 3 is a flowchart showing a program code generating step in another embodiment;
FIG. 4 is a flowchart showing a program code generating step in another embodiment;
FIG. 5 is a diagram of an edit page of a program code generation method in one embodiment;
FIG. 6 is a block diagram showing the construction of a program code generating apparatus according to one embodiment;
FIG. 7 is a block diagram showing the construction of a program code generating apparatus in another embodiment;
FIG. 8 is a diagram illustrating an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The program code generation method provided by the embodiment of the application can be applied to the application environment shown in fig. 1. Wherein the terminal 102 communicates with the server 104 via a network. The terminal 102 acquires a data item set stored in the server through a network, acquires a target data item selected from the data item set, and generates a target calculation item according to the target data item, wherein each target data item corresponds to an identifier; acquiring and identifying an input expression formula, wherein the expression formula comprises identifiers corresponding to all target calculation items; and replacing the identifier in the expression formula with the corresponding target calculation item, and generating a program code according to the replaced expression formula. The terminal 102 may be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices, and the server 104 may be implemented by an independent server or a server cluster formed by a plurality of servers.
In one embodiment, as shown in fig. 2, there is provided a program code generation method including the steps of:
step 202, obtaining target data items selected from the data item set, and generating target calculation items according to the target data items, wherein each target calculation item corresponds to one identifier.
The data item refers to metadata for representing a kind of data, such as "http _ requests _ total", "net _ conntrack _ dialer _ conn _ estishcovered _ total", and the like. The set of data items refers to a set containing at least one data item, and the target data item refers to a selected data item from the set of data items. Each identifier is used to uniquely identify the target computing item to which the identifier corresponds.
And presetting an algorithm for generating a target calculation item by the target data item before acquiring the target data item selected from the data item set. When a target data item selected from the data item set is acquired, the target data item can be generated into a target calculation item according to an algorithm for generating the target calculation item by the target data item. In a target computing item, a plurality of target data items may be included, one target data item corresponding to a set of target data.
It will be appreciated that program code tends to be very numerous and complex, requiring many target computing items. Therefore, a user can click a 'new calculation item' button on the editing page, and a new target calculation item is generated according to the target data item by acquiring the target data item selected from the data item set. For some applications or sentences with high use frequency, the efficiency can be improved by clicking to select the sentences.
Step 204, obtaining and identifying an input expression formula, wherein the expression formula comprises identifiers corresponding to the target calculation items.
The expression formula refers to a formula including identifiers corresponding to respective target calculation items. The expression formula input by the user is obtained and identified, and each identifier in the expression formula can be identified.
And step 206, replacing the identifier in the expression formula with the corresponding target calculation item, and generating a program code according to the replaced expression formula.
After the identifiers in the expression formula are identified, when a program code generation instruction is detected, the identifier is replaced by the target calculation item corresponding to each identifier, and the program code can be obtained. And when detecting an expression formula deleting instruction, deleting the expression formula.
When the program code is less, a 'manual input' button can be clicked, and the user can directly input the input program code. The program code generation method can be applied to a PromQL language to generate a PromQL program code.
In the embodiment, the target calculation item which is edited in advance is selected from the data item set, errors are not prone to occurring, the expression formula comprising the identifier is input, namely, the program code can be generated, the input expression formula is generated by the simple identifier, errors are not prone to occurring, and the accuracy of generating the program code is improved.
In one embodiment, obtaining a target data item selected from a set of data items, and generating a target computation item according to the target data item, includes: the method comprises the steps of obtaining a target data item selected from a data item set, obtaining a target filtering label selected from a middle filtering label set corresponding to the target data item, and obtaining a target function selected from a function set, wherein the target data item is used for obtaining target data from a database, the target filtering label is used for screening the target data, and the target function is used for calculating the target data after the target filtering label is screened; and generating a target calculation item according to the target data item, the target filtering label and the target function.
The filter tag refers to a tag for filtering data, and for example, the filter tag may be jobo ═ apiserver! GET, etc. The intermediate filtering tag set refers to a set containing at least one intermediate filtering tag, and the target filtering tag refers to an intermediate filtering tag selected from the intermediate filtering tag set.
A set of functions refers to a set that contains at least one function. The objective function refers to a function selected from a set of functions. The objective function may include an objective calculation function and an objective aggregation function. The target calculation function refers to a function for calculating a set of target data, and may be a function for rounding, calculating an absolute value, or the like. The objective aggregation function refers to a function for calculating a plurality of sets of objective data, such as a function for summing the plurality of sets of objective data, and calculating a maximum value or a minimum value, which includes aggregation significance.
And pre-establishing a corresponding relation between each data item and the filtering label set, and further establishing a corresponding relation between each data item and each filtering label in the corresponding filtering label set. Selecting a target data item from at least one data item in the data item set, acquiring a middle filtering label set corresponding to the target data item, and acquiring a target filtering label selected from the middle filtering label set. The target function obtained from the function set is obtained, and may include a target calculation function and a target aggregation function. And generating a target calculation item according to the target data item, the target filtering label and the target function.
When the target calculation item is complex, after the target calculation item is edited, a 'folding' button on the editing page can be clicked to fold the target calculation item, so that the editing space of the editing page is enlarged. Accordingly, when the target computing item needs to be expanded upon folding, the "expand" button on the edit page can be clicked. When the target computing item needs to be deleted, the "delete" button may be clicked.
In the embodiment, the target data item selected from the data item set is acquired, the target filtering label selected from the intermediate filtering label set corresponding to the target data item is acquired, the target function selected from the function set is acquired, the target calculation item is generated according to the selected target data item, the target filtering label and the target function, for some complicated target calculation items, the user only needs to perform selection operation to generate the target calculation item, and the accuracy of generating the target calculation item is improved.
In one embodiment, obtaining a target filtering tag selected from an intermediate filtering tag set corresponding to a target data item includes:
step 302, obtain the selected target tag name from the set of intermediate tag names corresponding to the target data item.
The tag name refers to the name of the filter tag, such as "job", "method", and the like. The correspondence relationship between each data item and the corresponding set of tag names is established in advance. And selecting a target data item from at least one data item in the data item set, acquiring a middle tag name set corresponding to the target data item, and acquiring a target tag name selected from the middle tag name set.
Step 304, obtaining a selected target tag value from the intermediate tag value set corresponding to the target tag name, and obtaining a selected target matching character from the matching character set.
The filter tag includes a tag name, a tag value, and a matching character. The target label value refers to the specific content of the target filter label for screening, such as "apiserver", "GET", and the like. A target match refers to a matching relationship between a target tag name and a target tag value, such as "═ and! And the like.
Accordingly, the corresponding relation between each label name and the corresponding intermediate label value set is established in advance. And selecting a target tag from at least one tag of the intermediate tag set, acquiring an intermediate tag value set corresponding to the target tag, and acquiring a target tag value selected from the intermediate tag value set.
Step 306, generating a target filter tag according to the target tag name, the target tag value and the target matching character.
In the present embodiment, a target tag selected from the intermediate tag name set corresponding to the target data item is acquired, a target tag value selected from the intermediate tag value set corresponding to the target tag name is acquired, a selected target match is acquired from the match set, and a target filter tag is generated from the target tag name, the target tag value, and the target match. The target tag name corresponds to the target data item, the target tag value corresponds to the target tag name, and the target tag name, the target tag value, and the target match are all selection operations, which can improve the accuracy of the generated target filter tag.
In one embodiment, after obtaining the selected objective function from the set of functions, the method further includes: and when the target function belongs to the time function, acquiring the time parameter input according to the target function. Generating a target calculation item according to the target data item, the target filter label and the target function, wherein the method comprises the following steps: and generating a target calculation item according to the target data item, the target filtering label, the target function and the time parameter corresponding to the target function.
It will be appreciated that when the objective function is a function of time, the function of time is a time dependent function, such as a growth rate function. And acquiring time parameters input according to the time function, and generating a target calculation item according to the target data item, the target filter tag, the target function and the time parameters corresponding to the target function.
In this embodiment, when the objective function belongs to the time function, the time parameter is obtained, and the objective calculation item is generated according to the objective data item, the objective filter tag, the objective function, and the time parameter corresponding to the objective function, so that the accuracy of the objective calculation item is improved.
In one embodiment, generating the target computation item according to the target data item, the target filter tag, the target time function and the time parameter corresponding to the target time function includes: generating a target symbol according to the target data item, the target filtering label, the target time function and the time parameter corresponding to the target time function; and generating a target calculation item by the target data item, the target filtering label, the target time function, the time parameter corresponding to the target time function and the target symbol according to a preset arrangement sequence.
It can be understood that when the content of the target calculation item is very complex, the target data item, the target filtering tag, the target time function and the time parameter corresponding to the target time function in the target calculation item are easily mixed into a whole, and the terminal cannot detect the specific target data item, the target filtering tag, the target time function and the time parameter corresponding to the target time function, which has the problem of low accuracy.
Therefore, a target symbol may be generated according to the target data item, the target filter tag, the target time function, and the time parameter corresponding to the target time function, and the target symbol may be a semicolon "; ", double quotation marks" ", big brackets" { } ", small brackets" () ", etc., without being limited thereto.
For example, [ ] represents the target symbol of the target time parameter, { } represents the target symbol of the target filter tag, () represents the target symbol of the target data item. Thus, the target computation item format generated is: the target time function (target data item { target filter tag 1, target filter tag 2} [ target time parameter ]).
It can be understood that, in the process of editing a more complex program code, by applying the program code generation method, the final program code can be obtained only by clicking the required sentence and selecting the sentence, the usability in the use process is higher, the time is saved, and the efficiency is improved.
The target symbol can be generated by detecting the corresponding target data item, the target filtering label, the target time function and the time parameter corresponding to the target time function according to the target symbol, so that the accuracy of generating the target calculation item is improved.
In one embodiment, after obtaining and identifying the input expression formula, the method further includes: when the expression formula is matched with the identifiers corresponding to the target calculation items, replacing the identifiers in the expression formula with the corresponding target calculation items, and generating program codes according to the replaced expression formula; when the expression formula does not match the identifiers corresponding to the target calculation items, prompt information is generated.
After the input expression formula is obtained and recognized, when the recognized input expression formula is matched with the identifier corresponding to the target calculation item, the steps of replacing the identifier in the expression formula with the corresponding target calculation item and generating the program code according to the replaced expression formula are executed. When the expression formula is not matched with the identifier corresponding to each target calculation item, if the expression formula is 'a +2b x 3 c', but the identifier corresponding to the target calculation item is only a and b, the expression formula is not matched with the identifier corresponding to each target calculation item, and prompt information is generated, so that a user can input a correct expression formula or input a correct target calculation item, and the accuracy of the generated program code is improved.
In one embodiment, obtaining a target data item selected from a set of data items, and generating a target computation item according to the target data item, includes:
step 402, when a selection instruction of the data item set displayed in the drop-down box corresponding to the first input box is detected, acquiring a target data item selected by the selection instruction from the data item set, displaying the target data item in the first input box, and generating a target calculation item according to the target data item.
And displaying each data item in the data item set in a drop-down box corresponding to the first input box, when a selection instruction of the data item set in the drop-down box is detected, taking the data item corresponding to the selection instruction as a target data item, displaying the target data item in the first input box, and generating a target calculation item according to the target data item.
Further, when a selected instruction of the middle filtering label set displayed in the drop-down box corresponding to the third input box is detected, a target filtering label selected by the selected instruction from the middle filtering label set is obtained, and the target filtering label is displayed in the third input box.
And when a selected instruction of the function set displayed in the pull-down box corresponding to the fourth input box is detected, acquiring a target function selected by the selected instruction from the function set, and displaying the target function in the fourth input box.
And generating a target calculation item according to the target data item, the target filtering label and the target function.
The program code generation method further includes:
and 404, when the target data item is detected to be displayed in the first input box, displaying the target calculation item in the second input box.
Further, when at least one of the target data item displayed in the first input box, the target filter tag displayed in the third input box, and the target function displayed in the fourth input box is detected, the target calculation item to be generated is displayed in the second input box.
In this embodiment, when a selection instruction of a data item set displayed in a drop-down box corresponding to a first input box is detected, a selected target data item is displayed in the first input box and a target calculation item is generated, and when that is the target data item in the first input box is detected, the target calculation item is displayed in a second input box, so that the content of the target calculation item can be displayed in real time.
In the program code editing process, the operation can be carried out on the electronic equipment through a network, an editing environment does not need to be built, and resources are saved.
It should be understood that although the various steps in the flow charts of fig. 2-4 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 2-4 may include multiple sub-steps or multiple stages that are not necessarily performed at the same time, but may be performed at different times, and the order of performance of the sub-steps or stages is not necessarily sequential, but may be performed in turn or alternating with other steps or at least some of the sub-steps or stages of other steps.
The PromQL is a set of powerful data query language defined by Prometheus (a new generation of cloud native monitoring system), and can conveniently perform operations such as query, filtering, aggregation, calculation and the like on data.
Traditional PromQL program code editing has focused primarily on a single line, simple direct manual editing input approach. In the face of editing complicated, multi-dimensional labels and various aggregation PromQL program codes, the manual editing input mode is relatively 'catch the witness', errors are prone to occur, debugging is difficult, and the complicated PromQL program codes are difficult to verify.
In one embodiment, the program code generation method can be applied to a PromQL program code editing process. For example, the PromQL program code: sum (net __ conntrack _ sealer _ conn _ established _ total { sealer _ name { (ALERM _ ALERMANAGER }, DIALER _ name! } [3m }) +100 http _ request _ duration _ microsystems.
In the PromQL program code, sum (rate (net __ conntrack _ dialer _ conn _ established _ total { dialer _ name:, "alert manager" ", dialer _ name |" "alert manager" [3m ])) is used as one target calculation item a, and http _ request _ duration _ micro second is used as another target calculation item b.
In the target calculation item a, sum is used as the target aggregation function, rate is used as the target calculation function, net __ conntrack _ dialer _ conn _ estableshied _ total is used as the target data item, dialer _ name ═ alert manager' is used as the target filtering label, and dialer _ name! "alert manager" as another target filter tag, 3m is a target time parameter. Where dialer _ name is the target tag name, and! "alert manager" is the target tag value.
In the target calculation item b, http _ request _ duration _ microsecond is a target data item.
The target calculation item can be generated by selecting the target data item, the target calculation function, the target aggregation function and the target filtering label, so that the target calculation item replaces an identifier in an expression formula to generate a PromQL program code, and the accuracy of generating the program code can be improved.
In one embodiment, as shown in FIG. 5, 502 is a rectangular box that generates program code. At 502, 504 is an edit box of the program code. In the edit box 504, 506 is the specific content of the target calculation item a, 508 is the identifier "a" of the target calculation item a, the target calculation item a is in a folded state, an "expansion" button can be clicked to expand and edit the target calculation item a, and a "deletion" button can be clicked to delete the target calculation item a. The specific content 510 of the target calculation item b, the identifier "b" of the target calculation item b, and the target calculation item b being in the expanded state, may be folded by clicking the "fold" button to fold the target calculation item a, or may be deleted by clicking the "delete" button to delete the target calculation item b.
In the target calculation item b, 514 is a selection box of the data item, and the data item in the drop-down selection box can be selected as the target data item by clicking 514 the selection box of the data item to expand the drop-down selection box. 516 is a box for filtering tag names contained in tags, 518 is a box for filtering matches contained in tags, and 520 is a box for filtering tag values contained in tags. By selecting the target tag name, target match, and target tag value, a target filter tag may be generated. Alternatively, the target tag name, target match and target tag value in the target filter tag may be manually entered by clicking a "manual enter" button. In one target calculation item, a plurality of target filter tags may be included, and the target filter tag is added by clicking a "add target filter tag" button. 522 is the box of the objective computation function and 524 is the box of the objective aggregation function.
When a new target calculation item needs to be added, a button of 'adding a new target calculation item' can be clicked for adding. 526 is an edit box of the expression formula, and the user can input the expression formula including an identifier corresponding to the target calculation item. When editing is complete, the program code 528 can be generated by clicking the "←" button. When the expression formula needs to be deleted, a delete button can be clicked. When the program code is simple, the 'manual input' button can be clicked to perform manual input.
In one embodiment, as shown in fig. 6, there is provided a program code generation apparatus including: a target calculation item generation module 602, an expression formula identification module 604, and a program code generation module 606, wherein:
and a target calculation item generation module 602, configured to obtain a target data item selected from the data item set, and generate a target calculation item according to the target data item, where each target calculation item corresponds to one identifier.
The expression formula identifying module 604 is configured to obtain and identify an input expression formula, where the expression formula includes identifiers corresponding to the target calculation items.
A program code generating module 606, configured to replace the identifier in the expression formula with a corresponding target calculation item, and generate a program code according to the replaced expression formula.
The program code generating device selects the target calculation item which is edited in advance from the data item set, is not easy to make mistakes, inputs the expression formula comprising the identifier, and can generate the program code, wherein the input expression formula is generated by the simple identifier, is not easy to make mistakes, and improves the accuracy of generating the program code.
In one embodiment, as shown in fig. 7, there is provided a program code generation apparatus including: a target calculation item generation module 702, a target calculation item presentation module 704, an expression formula identification module 706, a matching module 708, and a program code generation module 710, wherein:
and a target calculation item generation module 702, configured to obtain a target data item selected from the data item set, and generate a target calculation item according to the target data item, where each target calculation item corresponds to one identifier.
And a target calculation item presentation module 704, configured to present the target calculation item in the second input box when it is detected that the target data item is presented in the first input box.
And an expression formula identification module 706, configured to obtain and identify an input expression formula, where the expression formula includes identifiers corresponding to the target calculation items.
A matching module 708, configured to, when the expression formula matches the identifier corresponding to each target calculation item, perform a step of replacing the identifier in the expression formula with the corresponding target calculation item, and generating a program code according to the replaced expression formula; when the expression formula does not match the identifiers corresponding to the target calculation items, prompt information is generated.
And the program code generating module 710 is configured to replace the identifier in the expression formula with the corresponding target calculation item, and generate a program code according to the replaced expression formula.
The program code generating device selects the target calculation items which are edited in advance from the data item set, is not easy to make mistakes, inputs the expression formula comprising the identifiers, can generate the program codes when the expression formula is matched with the identifiers corresponding to the target calculation items, generates the prompt information when the expression formula is not matched with the identifiers corresponding to the target calculation items, and can improve the accuracy of generating the program codes.
In an embodiment, the target calculation item generating module 702 is further configured to obtain a target data item selected from the data item set, obtain a target filtering tag selected from a middle filtering tag set corresponding to the target data item, and obtain a target function selected from the function set, where the target data item is used to obtain target data from the database, the target filtering tag is used to filter the target data, and the target function is used to calculate the target data after the target filtering tag is filtered; and generating a target calculation item according to the target data item, the target filtering label and the target function.
In one embodiment, the target computation item generation module 702 is further configured to obtain a target tag name selected from the intermediate tag name set corresponding to the target data item; acquiring a target tag value selected from a middle tag value set corresponding to the target tag name, and acquiring a selected target matching character from a matching character set; and generating a target filtering label according to the target label name, the target label value and the target matching character.
In one embodiment, the target computation term generation module 702 is further configured to obtain a time parameter input according to the target function when the target function belongs to the time function. Generating a target calculation item according to the target data item, the target filter label and the target function, wherein the method comprises the following steps: and generating a target calculation item according to the target data item, the target filtering label, the target function and the time parameter corresponding to the target function.
In one embodiment, the target calculation item generating module 702 is further configured to generate a target symbol according to the target data item, the target filter tag, the target time function, and a time parameter corresponding to the target time function; and generating a target calculation item by the target data item, the target filtering label, the target time function, the time parameter corresponding to the target time function and the target symbol according to a preset arrangement sequence.
In an embodiment, the target computation item generating module 702 is further configured to, when a selection instruction for a data item set displayed in a drop-down box corresponding to the first input box is detected, obtain a target data item selected by the selection instruction from the data item set, display the target data item in the first input box, and generate a target computation item according to the target data item.
For specific limitations of the program code generation apparatus, reference may be made to the above limitations of the program code generation method, which are not described herein again. The respective modules in the above program code generation apparatus may be wholly or partially implemented by software, hardware, and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as shown in fig. 8. The computer device includes a processor, a memory, a network interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a program code generation method. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the computer equipment, an external keyboard, a touch pad or a mouse and the like.
Those skilled in the art will appreciate that the architecture shown in fig. 8 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory and a processor, the memory having a computer program stored therein, the processor implementing the following steps when executing the computer program: acquiring target data items selected from the data item set, and generating target calculation items according to the target data items, wherein each target calculation item corresponds to one identifier; acquiring and identifying an input expression formula, wherein the expression formula comprises identifiers corresponding to all target calculation items; and replacing the identifier in the expression formula with the corresponding target calculation item, and generating a program code according to the replaced expression formula.
In one embodiment, the processor, when executing the computer program, further performs the steps of: the method comprises the steps of obtaining a target data item selected from a data item set, obtaining a target filtering label selected from a middle filtering label set corresponding to the target data item, and obtaining a target function selected from a function set, wherein the target data item is used for obtaining target data from a database, the target filtering label is used for screening the target data, and the target function is used for calculating the target data after the target filtering label is screened; and generating a target calculation item according to the target data item, the target filtering label and the target function.
In one embodiment, the processor, when executing the computer program, further performs the steps of: acquiring a target tag name selected from a middle tag name set corresponding to a target data item; acquiring a target tag value selected from a middle tag value set corresponding to the target tag name, and acquiring a selected target matching character from a matching character set; and generating a target filtering label according to the target label name, the target label value and the target matching character.
In one embodiment, the processor, when executing the computer program, further performs the steps of: and when the target function belongs to the time function, acquiring the time parameter input according to the target function. Generating a target calculation item according to the target data item, the target filter label and the target function, wherein the method comprises the following steps: and generating a target calculation item according to the target data item, the target filtering label, the target function and the time parameter corresponding to the target function.
In one embodiment, the processor, when executing the computer program, further performs the steps of: generating a target symbol according to the target data item, the target filtering label, the target time function and the time parameter corresponding to the target time function; and generating a target calculation item by the target data item, the target filtering label, the target time function, the time parameter corresponding to the target time function and the target symbol according to a preset arrangement sequence.
In one embodiment, the processor, when executing the computer program, further performs the steps of: when the expression formula is matched with the identifiers corresponding to the target calculation items, replacing the identifiers in the expression formula with the corresponding target calculation items, and generating program codes according to the replaced expression formula; when the expression formula does not match the identifiers corresponding to the target calculation items, prompt information is generated.
In one embodiment, the processor, when executing the computer program, further performs the steps of: when a selection instruction of the data item set displayed in the drop-down box corresponding to the first input box is detected, a target data item selected from the data item set by the selection instruction is obtained, the target data item is displayed in the first input box, and a target calculation item is generated according to the target data item. The program code generation method further includes: when it is detected that the target data item is presented in the first input box, the target computing item is presented in the second input box.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of: acquiring target data items selected from the data item set, and generating target calculation items according to the target data items, wherein each target calculation item corresponds to one identifier; acquiring and identifying an input expression formula, wherein the expression formula comprises identifiers corresponding to all target calculation items; and replacing the identifier in the expression formula with the corresponding target calculation item, and generating a program code according to the replaced expression formula.
In one embodiment, the computer program when executed by the processor further performs the steps of: the method comprises the steps of obtaining a target data item selected from a data item set, obtaining a target filtering label selected from a middle filtering label set corresponding to the target data item, and obtaining a target function selected from a function set, wherein the target data item is used for obtaining target data from a database, the target filtering label is used for screening the target data, and the target function is used for calculating the target data after the target filtering label is screened; and generating a target calculation item according to the target data item, the target filtering label and the target function.
In one embodiment, the computer program when executed by the processor further performs the steps of: acquiring a target tag name selected from a middle tag name set corresponding to a target data item; acquiring a target tag value selected from a middle tag value set corresponding to the target tag name, and acquiring a selected target matching character from a matching character set; and generating a target filtering label according to the target label name, the target label value and the target matching character.
In one embodiment, the computer program when executed by the processor further performs the steps of: and when the target function belongs to the time function, acquiring the time parameter input according to the target function. Generating a target calculation item according to the target data item, the target filter label and the target function, wherein the method comprises the following steps: and generating a target calculation item according to the target data item, the target filtering label, the target function and the time parameter corresponding to the target function.
In one embodiment, the computer program when executed by the processor further performs the steps of: generating a target symbol according to the target data item, the target filtering label, the target time function and the time parameter corresponding to the target time function; and generating a target calculation item by the target data item, the target filtering label, the target time function, the time parameter corresponding to the target time function and the target symbol according to a preset arrangement sequence.
In one embodiment, the computer program when executed by the processor further performs the steps of: when the expression formula is matched with the identifiers corresponding to the target calculation items, replacing the identifiers in the expression formula with the corresponding target calculation items, and generating program codes according to the replaced expression formula; when the expression formula does not match the identifiers corresponding to the target calculation items, prompt information is generated.
In one embodiment, the computer program when executed by the processor further performs the steps of: when a selection instruction of the data item set displayed in the drop-down box corresponding to the first input box is detected, a target data item selected from the data item set by the selection instruction is obtained, the target data item is displayed in the first input box, and a target calculation item is generated according to the target data item. The program code generation method further includes: when it is detected that the target data item is presented in the first input box, the target computing item is presented in the second input box.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (10)

1. A method of program code generation, the method comprising:
acquiring target data items selected from a data item set, and generating target calculation items according to the target data items, wherein each target calculation item corresponds to an identifier;
acquiring and identifying an input expression formula, wherein the expression formula comprises identifiers corresponding to the target calculation items;
and replacing the identifier in the expression formula with a corresponding target calculation item, and generating a PromQL program code according to the replaced expression formula.
2. The method of claim 1, wherein obtaining a target data item selected from a set of data items, and generating a target computation item from the target data item comprises:
the method comprises the steps of obtaining a target data item selected from a data item set, obtaining a target filtering label selected from a middle filtering label set corresponding to the target data item, and obtaining a target function selected from a function set, wherein the target data item is used for obtaining target data from a database, the target filtering label is used for screening the target data, and the target function is used for calculating the target data after the target filtering label is screened;
and generating a target calculation item according to the target data item, the target filtering label and the target function.
3. The method of claim 2, wherein the obtaining a selected target filtering tag from the set of intermediate filtering tags corresponding to the target data item comprises:
acquiring a target tag name selected from a middle tag name set corresponding to the target data item;
acquiring a target tag value selected from the intermediate tag value set corresponding to the target tag name, and acquiring a selected target matching character from the matching character set;
and generating a target filtering label according to the target label name, the target label value and the target matching character.
4. The method of claim 2, wherein after obtaining the selected objective function from the set of functions, further comprising:
when the target function belongs to a time function, acquiring a time parameter input according to the target function;
generating a target calculation item according to the target data item, the target filter tag and the target function, wherein the generating of the target calculation item comprises:
and generating a target calculation item according to the target data item, the target filtering label, the target function and the time parameter corresponding to the target function.
5. The method of claim 4, wherein generating a target computation term according to the target data item, the target filter tag, the target time function, and the time parameter corresponding to the target time function comprises:
generating a target symbol according to the target data item, the target filtering label, the target time function and the time parameter corresponding to the target time function;
and generating a target calculation item by the target data item, the target filtering label, the target time function, the time parameter corresponding to the target time function and the target symbol according to a preset arrangement sequence.
6. The method of claim 1, wherein after obtaining and identifying the input expression formula, further comprising:
when the expression formula is matched with the identifier corresponding to each target calculation item, replacing the identifier in the expression formula with the corresponding target calculation item, and generating a PromQL program code according to the replaced expression formula;
and when the expression formula is not matched with the identifier corresponding to each target calculation item, generating prompt information.
7. The method of any one of claims 1-6, wherein obtaining a target data item selected from a set of data items, generating a target computation item from the target data item, comprises:
when a selected instruction of a data item set displayed in a drop-down box corresponding to a first input box is detected, acquiring a target data item selected by the selected instruction from the data item set, displaying the target data item in the first input box, and generating a target calculation item according to the target data item;
the method further comprises the following steps:
when it is detected that the target data item is presented in the first input box, presenting the target computing item in a second input box.
8. An apparatus for generating program code, the apparatus comprising:
the target calculation item generation module is used for acquiring target data items selected from a data item set and generating target calculation items according to the target data items, wherein each target calculation item corresponds to one identifier;
the expression formula identification module is used for acquiring and identifying an input expression formula, wherein the expression formula comprises identifiers corresponding to the target calculation items;
and the program code generation module is used for replacing the identifier in the expression formula with a corresponding target calculation item and generating a PromQL program code according to the replaced expression formula.
9. A computer device comprising a memory and a processor, the memory storing a computer program, wherein the processor implements the steps of the method of any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 7.
CN201910083568.7A 2019-01-29 2019-01-29 Program code generation method, program code generation device, computer device, and storage medium Active CN109871214B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910083568.7A CN109871214B (en) 2019-01-29 2019-01-29 Program code generation method, program code generation device, computer device, and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910083568.7A CN109871214B (en) 2019-01-29 2019-01-29 Program code generation method, program code generation device, computer device, and storage medium

Publications (2)

Publication Number Publication Date
CN109871214A CN109871214A (en) 2019-06-11
CN109871214B true CN109871214B (en) 2022-04-12

Family

ID=66918152

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910083568.7A Active CN109871214B (en) 2019-01-29 2019-01-29 Program code generation method, program code generation device, computer device, and storage medium

Country Status (1)

Country Link
CN (1) CN109871214B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111078026B (en) * 2019-11-15 2023-10-03 北京乐我无限科技有限责任公司 Input prompting method, device, electronic equipment and readable storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1226527A1 (en) * 1999-08-13 2002-07-31 MPower.com, Inc. A system, method, and computer program product for handling deferred expressions in an object oriented stochastic simulation model
CN101034349A (en) * 2007-04-06 2007-09-12 西安万年科技实业有限公司 Data base application system development platform based on functional design
CN107506442A (en) * 2017-08-24 2017-12-22 中国银行股份有限公司 The modeling method and device of a kind of model

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1226527A1 (en) * 1999-08-13 2002-07-31 MPower.com, Inc. A system, method, and computer program product for handling deferred expressions in an object oriented stochastic simulation model
CN101034349A (en) * 2007-04-06 2007-09-12 西安万年科技实业有限公司 Data base application system development platform based on functional design
CN107506442A (en) * 2017-08-24 2017-12-22 中国银行股份有限公司 The modeling method and device of a kind of model

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
"prometheus监控系列之prometheus server和监控linux系统";GeekXuShuo;《https://blog.csdn.net/qq_25934401/article/details/81391598》;20180803;1-13 *

Also Published As

Publication number Publication date
CN109871214A (en) 2019-06-11

Similar Documents

Publication Publication Date Title
CN108446116B (en) Application program page generation method and device, computer equipment and storage medium
CN108363587B (en) Application program operation monitoring method and device, computer equipment and storage medium
CN108874926B (en) Mass data query method, device, computer equipment and storage medium
CN109901834B (en) Document page generation method, device, computer equipment and storage medium
CN111061475B (en) Software code generating method, device, computer equipment and storage medium
CN110689232A (en) Workflow configuration optimization processing method and device and computer equipment
CN108664582B (en) Enterprise relation query method and device, computer equipment and storage medium
CN110955418A (en) Code generation method and device, computer equipment and storage medium
CN111563220A (en) Business website project construction method and device, computer equipment and storage medium
CN109597979B (en) List table generation method and device, computer equipment and storage medium
CN111666740A (en) Flow chart generation method and device, computer equipment and storage medium
CN111078507A (en) Data monitoring method, system, computer equipment and storage medium
CN112433712A (en) Report display method and device, computer equipment and storage medium
CN109828809B (en) Information visualization method and device for billboard, computer equipment and storage medium
CN111324716A (en) Index data acquisition method and device, computer equipment and storage medium
CN112464625A (en) Receipt generation method and device, computer equipment and storage medium
CN111949262A (en) Front-end project construction method and device, computer equipment and storage medium
CN110727777A (en) Knowledge graph management method and device, computer equipment and storage medium
CN111309991A (en) Query statement generation method and device and data query method and system
CN109871214B (en) Program code generation method, program code generation device, computer device, and storage medium
CN114611481A (en) Template configuration method and device, computer equipment and storage medium
CN113129155A (en) Multi-type personnel information processing method, equipment and storage medium
CN109542962B (en) Data processing method, data processing device, computer equipment and storage medium
CN112001615A (en) Process creation method, system, computer device, and storage medium
CN117112012A (en) Application configuration generation method, device, equipment and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant