CN117669509A - Report generation method, device and equipment - Google Patents

Report generation method, device and equipment Download PDF

Info

Publication number
CN117669509A
CN117669509A CN202311695335.5A CN202311695335A CN117669509A CN 117669509 A CN117669509 A CN 117669509A CN 202311695335 A CN202311695335 A CN 202311695335A CN 117669509 A CN117669509 A CN 117669509A
Authority
CN
China
Prior art keywords
report
command
data
template
text
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.)
Pending
Application number
CN202311695335.5A
Other languages
Chinese (zh)
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.)
Beijing Jingwei Hirain Tech Co Ltd
Original Assignee
Beijing Jingwei Hirain Tech 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 Beijing Jingwei Hirain Tech Co Ltd filed Critical Beijing Jingwei Hirain Tech Co Ltd
Priority to CN202311695335.5A priority Critical patent/CN117669509A/en
Publication of CN117669509A publication Critical patent/CN117669509A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses a report generation method, a report generation device and report generation equipment, which relate to the field of computers, wherein the method comprises the following steps: defining a data set required for report generation; configuring a report template, wherein the report template comprises: reporting a command text; extracting a command set from the report command text; acquiring data from a data set required for report generation by executing a command set and filling the data into a report template to generate a report; thereby improving report generation efficiency.

Description

Report generation method, device and equipment
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a report generating method, apparatus, and device.
Background
In the software running process, as the recorded or collected data are more and more, the processing of the data and the generation of corresponding reports become more and more complex, and the problem of data calculation errors commonly exists in manual report writing, the report generating work can be rapidly completed by developing the function of automatically generating reports by software, and meanwhile, the problems of sequence calculation errors and the like caused by manual report writing are avoided, so that the report generating efficiency and accuracy can be greatly improved.
In the conventional report generation scheme, by configuring a fixed bookmark at a specified position in a template, and judging whether data is to be inserted or replaced at the bookmark according to the bookmark name. However, when the report is generated in the traditional scheme, the content and the format of the report generated by the bookmark mode are fixed, and if the template content needs to be modified later, the code needs to be modified and the execution file needs to be regenerated, so that the efficient report generation efficiency still cannot be brought.
Disclosure of Invention
In view of the foregoing, a primary object of the present application is to provide a report generating method, apparatus and device, so as to improve report generating efficiency.
The first aspect of the present application provides a report generating method, which includes:
defining a data set required for report generation;
configuring a report template, wherein the report template comprises: reporting a command text;
extracting a command set from the report command text;
data is acquired from the data set required for report generation by executing the command set and populated into the report template to generate the report.
In some implementations of the first aspect of the present application, the data set required for report generation is defined by: defining data required for report generation, defining attributes of the data required for report generation, and defining interfaces for value according to the attributes.
In some implementations of the first aspect of the present application, configuring the report template includes:
and configuring a total style text and a report command text in the template to obtain a report template, wherein the report command text is used for indicating that data is extracted from a data set required for report generation and is filled into the report template in a specified format, and the total style text is used for defining the total style of the report template.
In some implementations of the first aspect of the present application, reporting the command text includes: a plurality of report commands, the command set comprising: a plurality of command objects, extracting a command set from a report command text, comprising:
matching texts conforming to a preset command format in the report command texts through regular expressions to obtain a plurality of report commands, wherein the regular expressions are character matching formulas written based on the preset command format;
the plurality of report commands are parsed to generate a plurality of command objects, the plurality of command objects constituting a command set.
In some implementations of the first aspect of the present application, obtaining data from a data set required for report generation by executing a command set and populating a report template to generate a report includes:
obtaining a command object from a command set, the command object comprising: type parameters and command configuration parameters;
executing a command object according to the type parameter and the command configuration parameter to acquire data from a data set required by report generation and fill the data into a report template;
after all command objects in the command set have been executed, a report is obtained.
In some implementations of the first aspect of the present application, obtaining data from a data set required for report generation and populating a report template includes:
Caching the data set required by report generation into a variable cache pool, wherein the variable cache pool is used for caching variables of the data set required by report generation;
and acquiring data from the variable cache pool according to the command object and filling the data into the report template.
In some implementations of the first aspect of the present application, the command object includes: a parent command object or a child command object, the child command object having a corresponding parent command object in the command set, the method further comprising:
when the currently executed command object is a parent command object and the corresponding child command object exists in the currently executed command object, executing the child command object corresponding to the currently executed command object.
In some implementations of the first aspect of the present application, the report command includes the following types: attribute value commands, condition judgment commands, form loop commands, form row loop commands, object loop commands, and count commands.
A second aspect of the present application provides a report generating apparatus, the apparatus comprising:
a data set definition module for defining a data set required for report generation;
the template configuration module is used for configuring a report template, and the report template comprises: reporting a command text;
The command set extraction module is used for extracting a command set from the report command text;
and the command set execution module is used for acquiring data from the data set required by report generation by executing the command set and filling the data into the report template to generate a report.
A third aspect of the present application provides a report generating apparatus, the apparatus comprising: comprising a memory and a processor for executing a program stored in the memory, running any one of the report generating methods as provided in the first aspect of the present application.
The technical scheme provided by the application has the following beneficial effects:
the application provides a data source for report generation by defining a data set required for report generation; then configuring a report template comprising a report command text, and extracting a command set from the report command text as follows; finally, the report is generated by executing the command set to obtain data from the data set required for report generation and populating the report template. Compared with the prior art, the method and the device realize decoupling of the report template and the filling data by automatically acquiring the data from the data set and filling the data into the report template by executing the command set, and the generated report is not influenced by the modification of the report template, but only focuses on the configuration of the report command text, namely, the filling of the data is not influenced no matter what the format of the report template is modified. Under the condition that the data set and the report command text are not modified, the code logic modification based on the new template format requirement is not needed, and the report generation efficiency is higher.
Drawings
Fig. 1 is a schematic flow chart of a report generating method according to an embodiment of the present application;
FIG. 2 is a schematic flow chart of defining a data set according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a report template provided in an embodiment of the present application;
FIG. 4 is a schematic flow chart of a configuration report template according to an embodiment of the present application;
FIG. 5 is a schematic flow chart of command set extraction according to an embodiment of the present application;
FIG. 6 is a schematic flow chart of filling data in a report template by an execution command set according to an embodiment of the present application;
FIG. 7 is a simplified flow diagram of a report generation method provided by an embodiment of the present application;
FIG. 8 is a flowchart of another report generating method according to an embodiment of the present disclosure;
FIG. 9 is a schematic flow chart of executing command sets according to an embodiment of the present application;
FIG. 10 is a flowchart of another report generating method according to an embodiment of the present disclosure;
FIG. 11 is a flowchart of filling data into a report template according to an embodiment of the present disclosure;
fig. 12 is a schematic structural diagram of a report generating device according to an embodiment of the present application;
fig. 13 is a schematic structural diagram of a report generating device according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are only some, but not all, of the embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
In addition to the prior art problems mentioned in the background, the applicant has found by studying the prior art that the following problems exist: 1. bookmark configuration is cumbersome. When generating reports, it often happens that the same data is inserted in different positions, which requires that bookmarks are configured in each position, and the bookmark names cannot be consistent, so that the data mapping is easy to confuse. 2. No table configuration is supported. When generating reports, it is often necessary to present data in a tabular form, while bookmarks do not allow custom configuration of the columns and columns of the table, but only fix the table columns and contents at the bookmark locations in the code. When a table column needs to be modified, the implementation in the code needs to be modified. 3. List configuration is not supported. In the traditional report generation method, only a list of data in a report template can be configured, and a list format for automatically generating contents cannot be configured.
Based on the problem that the prior art mentioned in the background art cannot generate the report efficiently, referring to fig. 1, an embodiment of the present application provides a report generating method, which specifically includes the following steps:
s101: the data sets required for report generation are defined.
In the embodiment of the present application, the data set required for generating the report refers to data provided by the platform for generating the report, and the data set required for generating the report may be one data set or may be multiple data sets, which is specifically determined by an actual report generating application scenario, and is not limited herein. The data sets required for report generation will be further described with respect to the software running report to be generated, and the data sets required for report generation may include a use case list data set, a requirement list data set, an item list data set, and the like. The method and the device provide data sources for the subsequent generation report by defining the data set so that the data can be acquired from the data set later and then filled into the report template; in addition, after the report data set is defined, the data set can be used in any combination in the template, the report template can be modified at any time to display different report data, no change to codes of a system is needed, and the system has higher expandability.
In some implementations of embodiments of the present application, referring to fig. 2, the data set is specifically defined by: defining data required for report generation, defining attributes of the data required for report generation, and defining interfaces for value according to the attributes. In fig. 2, data provided by the definition platform refers to data required for generating a definition report, attributes defining each data refer to attributes defining the data required for generating the report, and interfaces for obtaining data object values according to the attributes refer to interfaces for defining values according to the attributes. Wherein, defining the data required by report generation is to convert the data required by report generation into operable data objects according to a certain rule and format through writing codes, and one data set in the application can comprise a plurality of data objects; the attribute of the report generation required data specifically includes an attribute name and an attribute value for use as identification information or basic information of the report generation required data. It should be noted that, in the definition process of the data sets in the present application, a unique identifier is assigned to each data set so as to determine the data set. In addition, the application also needs to define an interface for obtaining a subsequent attribute value or data according to an attribute name, and specifically, the application needs to realize a report data interface including a getDataBeanList (property) method and a data object interface reporting a getDataValue (property) method when defining a data set, wherein the getDataBeanList (property) method is used for returning corresponding data in the data set according to the attribute name, and the getDataValue (property) method is used for returning corresponding attribute value according to the attribute name.
Taking the definition of data sets cases as an example, the data set sets cases may be implemented getDataBeanList (property) by the following code:
taking the definition case list data set req as an example, providing externally exposed name, identity, req, parent and other attributes in the data set, the method can be realized by the following codes:
s102: configuring a report template, wherein the report template comprises: report command text.
In the embodiment of the application, the report template refers to a word document for filling data, the report command text refers to a report command which exists in the report template in a text form, and the application configures the report command text in the report template to fill the data in the data set into the report template in a specified format.
It should be noted that, in order to obtain a more standardized report, the report template further includes: overall style text, whereby in some implementations configuring the report template specifically includes the steps of:
the overall style text and the report command text are configured in the template to obtain a report template, wherein the report command text is used for indicating that the data is filled in the template in a specified format. By configuring the overall style text, the report can be generated according to a predefined template format when the report is generated, so that the consistency of the report is ensured; and also helps to reduce errors and confusion, ensuring that the report follows the same generation rules, making the generated report more standardized.
Where the overall style text refers to text present in the report template that defines the overall style of the report template, such as hierarchical effects in the report template, default text, forms, and the like. Based on this, the report template may be regarded as being composed of the overall style text and the report command text, but it should be noted that the overall style text and the report command text in this application do not refer to a continuous piece of text, but should be understood as a collection or classification of intermittent independent text. Referring to fig. 3, fig. 3 is a schematic diagram of a report template provided in an embodiment of the present application, where "in combination with a software requirement analysis result, a functional test is performed on software from functional suitability," specifically: "belongs to the total style text," $ { c: count, d: gftr GNSH, as: itemCount, hidden } $ { c: if, w: [ itemCount >0] } "" belongs to the report command text.
In embodiments of the present application, a template may refer to a document for configuring report command text or overall style text, for example, the template may be a word document, and configuration of report command text and/or overall style text may be achieved by editing the word document; the configuration report template refers to configuration report command text and/or overall style text in the template, and it should be noted that, in the process of configuring the report template, at least the configuration report command text is needed, that is, the overall style of the report template may not be defined, and subsequent data filling may be directly implemented through the configuration report command text. Based on this, the report template may refer to a template configured with at least the text of the message command.
In some implementations of embodiments of the present application, the report command in the configuration report template is marked with "$ { }" such as "$ { case. Name }" representing obtaining the case name "$ { c: fo, d: cases, w: id <5}" representing traversing the data of case list id <5 "$ { case. Icon, pic }" representing obtaining the case icon attribute and writing it in a picture manner in the report template, all contain "$ { }" marks.
In some implementations of the embodiments of the present application, a specific configuration process of the report template is shown in fig. 4, and fig. 4 is a schematic flow chart of configuring the report template, specifically implemented by the following manner: firstly, configuring the overall style of a report template, wherein the overall style comprises the hierarchical result, default text, table and other data of the template; then, according to the provided report command and defined data set, the data and input pattern of the position input are configured by the report command in the position desired to be input in the report template. And finally, saving the report template to a designated path, and loading the report template through the saved path of the report template when the report is generated later.
S103: a command set is extracted from the report command text.
In the implementation of the present application, the report command text includes all report commands in the report template, from which a plurality of report commands can be extracted, and the command set may refer to a set of all report commands in the report template, where in a specific implementation, the report commands exist in the set in the form of objects, and where the command set includes a plurality of command objects. Wherein, the command object refers to an object for packaging the report command, which includes attributes such as command type parameter, command configuration parameter, and the like, and in some implementation, includes attributes of parent-child relationship.
An embodiment of extracting a command set from a report command text is shown in fig. 5, and fig. 5 is a flowchart of report command parsing, specifically as follows: firstly, loading a report template through a storage path of the report template; then, extracting a report command in the report command text; and finally, analyzing the report command in the report template and generating an executable command object by traversing the extracted report command until the traversing of the report command is completed.
S104: data is acquired from the data set required for report generation by executing the command set and populated into the report template to generate the report.
In the embodiment of the present application, reporting refers to a document obtained by filling data in a report template, data is acquired from a data set through a command set and is filled into the report template, and it is understood that data filling is performed in the report template, and a part, which needs to be filled, in the report template of the present application is not manually input by a person, but automatically acquires data from the data set through a report command and is input into the report template.
In some implementations of embodiments of the present application, a command set is made up of a plurality of command objects. An embodiment of filling the report template with command set acquisition data can be seen in fig. 6, specifically as follows: first, creating a report generator; then, in the process of executing the command set, calling a report generator according to the command object in the command set to execute the operation corresponding to the command object; until all the command objects in the command set have been executed. Finally, the command to save the report is invoked to persist the data to the report template, thereby obtaining the report. The report generator in this application provides the following functions: inserting text, symbol, picture, table and other functions, replacing text and paragraph functions, paragraph copying, table row copying functions, paragraph deleting, table deleting and table row deleting functions, setting list serial numbers, custom fields, catalogues and other functions, switching cursor positions, and setting header and footer functions. Therefore, the invention supports common word operation modes such as form configuration, text filling, condition judgment, picture filling, list serial number and the like, and supports random modification of templates, modification of forms and form columns, and customization of the required report generation format.
The specific function selection is determined by the command parameters of the command object. For example, "$ { c: ft, d: cases, t:" use case- "+name+" table "}" means traversing the set of cases, and creating a use case table from each use case, the table titled "use case- { case name } table"; for another example, "$ { name, checkbox: [ true ] }" means that a tick box is added after the name and the state is tick;
in some implementations of the embodiments of the present application, the loading and generating of the report template may be specifically implemented by the following code:
public static void main(String[]args)throws Exception{
ReportData data = new ReportData (); creating a dataset object;
string templatePath = "D: \\ ltest\ the ltemplite.docx"; the// report template holds the address;
string path= "D: \ltestlloutput result.docx"; a// report save address;
wordreport wr2=new wordreport (template path, data); importing/importing the data set object, the report template save address, and the report save address into a report generator;
wr2.reportwordbytag (); the// report generator performs a method of generating a report;
}
further to the flow shown in fig. 1 in conjunction with fig. 7, first define the data set required for report generation, then configure the report template with report command text, and then extract the command set based on the report command text to complete report command parsing; and finally, acquiring data from the data set based on the command set, filling the data into a report template to finish the data mapping, and generating a report after finishing the data mapping. Compared with the prior art, the method and the device realize decoupling of the report template and the filling data by automatically acquiring the data from the data set and filling the data into the report template by executing the command set, and the generated report is not influenced by the modification of the report template, but only focuses on the configuration of the report command text, namely, the filling of the data is not influenced no matter what the format of the report template is modified. Under the condition that the data set and the report command text are not modified, the code logic modification based on the new template format requirement is not needed, and the report generation efficiency is higher.
In addition, the embodiment of the application realizes the automation of the report generation process, reduces the time and manpower resources required by manually creating the report, and improves the working efficiency. In addition, compared with the tedious bookmark configuration in the prior art, the method and the device have the advantage that the data mapping is realized based on the command set, so that the accuracy is higher.
Referring to fig. 8, fig. 8 is a schematic flow chart of another report generating method according to an embodiment of the present application, and specifically includes the following steps based on the flow chart shown in fig. 1:
s801: the data sets required for report generation are defined.
In the embodiment of the present application, the specific implementation manner of S801 is the same as S101, and the detailed description is omitted herein.
S802: configuring a report template, wherein the report template comprises: report command text.
In the embodiment of the present application, the specific implementation manner of S802 is the same as S102, and the detailed description of the present application is omitted here.
S803: and matching texts conforming to a preset command format in the report command texts through a regular expression to obtain a plurality of report commands, wherein the regular expression is a character matching formula written based on the preset command format.
In the embodiment of the application, the report command in the report template is marked with "${ }" and the report command is a command text existing in the report template in a "${ }" format, that is, the preset command format is "${ }" and the text conforming to the preset command format is matched in the report template by a regular expression, wherein the regular expression is also called a regular expression, refers to a character matching formula for operating a character string, and a rule character string is formed by a plurality of specific characters and specific character combinations defined in advance and can be used for expressing matching logic of the character string. For example, by regular expression "\$ \{? } "matches all text in the" $ { } "format in the report template and adds it to a command list. Compared with the problem that the code needs to be repeatedly modified because the content of the custom template is not supported in the prior art, the method and the device provide various report commands to configure report patterns and data, and can be applicable to generation of various common reports.
It should be noted that, in some implementations of the embodiments of the present application, the specific format of the report is $ { c: fo, d: data }, where the c parameter declares the command type and the d parameter is used to declare the dataset.
In some implementations of embodiments of the present application, the report commands are divided into six categories, namely an object rotation command, a condition judgment command, an attribute value command, a table row rotation command, a table rotation command, and a count command. In addition, the embodiment of the application also provides formats of the six types of report commands, and the formats and meanings of the types of commands are as follows:
(1) The command format of the attribute value command is as follows:
${case.name,lni:3,as:caseName};
wherein the attribute-valued commands are typically the most commands used in the report template, which do not require the command type to be deasserted by the c-parameter and the data set to be deasserted by the d-parameter. The parameters supported by the attribute value command include: logic calculations, l, checkbox, pic, hide, merge, as, etc., it should be noted that the specific meaning of each parameter may be referred to in table one. Through the attribute value command, data which need to be displayed, including text, pictures, check boxes, list styles, cell combinations and the like, can be configured in the report template, and in addition, variables in the configuration report can be defined for subsequent use.
(2) The command format of the condition judgment command is as follows:
${c:if,w:[this.number=1&&this.name=’a’]}xxx${end};
wherein, the condition judgment command is a range command, and the end symbol "$ { end }" is required. When the condition is judged to be true, outputting data in a command range in a configuration report; when the condition is judged to be "false", the text within the command range is removed. Determining whether a piece of text content is to be generated into the report template according to a certain condition can be achieved by using the condition judgment command. In addition, the conditional predicate command of the present application supports nesting all other commands.
(3) The command format of the form loop command is as follows:
${c:ft,d:cases}${end};
wherein the form loop command is a range command, which requires a tape terminator "$ { end }. The form loop command must be declared inside the form in the report template. In traversing according to the dataset, a table is replicated for each traversal, and specific values are inserted in the table according to the attribute-valued command. In the traversal process according to the form circulation command, the currently traversed data object can be acquired through the this, and the property attribute of the currently traversed data object can be acquired through the "$ { this. Property }" or directly using the "$ { property }". If the acquired property attribute is also a list, supporting nested traversal according to the attribute. In the form loop commands, nesting of all commands except the "ft" command is supported.
(4) The command format of the form line cycle command is as follows:
${c:fr,d:cases}${end};
wherein the table row loop command is a range command, which requires a tape terminator "$ { end }. The form row cycle command must be declared inside the form. When traversing according to the data set, the table row is duplicated in each traversal, and specific values are inserted in the cells of the report template according to the value command. In addition, the property attribute value of the current traversal data object can be obtained in a "$ { property }" manner in the traversal process. In the table row loop command, the support nest defines all commands except "ft". It should be noted that, the difference between the table row circulation command and the table circulation command is that when the table circulation command is executed, a plurality of tables are created in a circulation manner; and the form line loop command, when executed, loops through the form to create form lines.
(5) The command format of the object loop command is as follows:
${c:fo,d:cases}${end};
wherein the object rotation command is a range command, and the end symbol "$ { end }" is required to be taken. If the object rotation command is inside the table, it needs to be guaranteed to be within the same cell. In traversing from the dataset, each traversal replicates all the content in the command, including tables, pictures, text, paragraphs, and so forth. In the traversal process, the property attribute value of the current traversal data object can be obtained in a "$ { property }" manner. In the object loop commands, nesting all commands is supported.
(6) The command format of the count command is as follows:
${c:count,d:cases,as:caseCount};
the counting command is used for counting the number of data items in the data set cases and caching the result into a caseCount variable. Based on this, the count command is mainly used to count the length of the dataset. Wherein screening of the data sets is supported and caching of statistics is supported.
Furthermore, the present application supports the input of the following command parameters in the above command format:
1. c: the command type is declared, support fo, ft, fr, if, count, property, default to property.
2. d: the data set is declared. If $ { c: fo, d: cases } means traversing the cases dataset.
3. w: data set screening conditions are declared.
4. l: the list format is declared.
5. distict: declaring deduplication of the dataset. If { c: fo, d: cases, distict: [ name, number ] }, we mean that the cases dataset is first de-duplicated according to name, number, and then the de-duplicated dataset is traversed.
6. orderby: the claim orders the data set, supporting ordering according to a plurality of fields.
7. merge: whether or not merging is required according to the cell values in the statement table.
8. t: the title of the form is declared.
9. checkbox: the statement adds a checkbox behind the value and sets the checkbox state according to the condition.
10. pic: the attribute value is declared to be in picture format.
11. hide: the declaration hidden attribute values, not necessarily exposed in the Word report, are used to define variables in conjunction with as commands.
12. as: declarative variables, such as "$ { case. Name, as: caseName }" represent that the name attribute value of the case object is obtained and cached as a variable caseName, the value of which can be used directly later. When the same variable name is repeatedly declared, the previously declared variable will be overridden.
The specific description and examples of the command parameters can be found in table one.
Table 1 commands and parameters supporting configuration in report
The embodiment of the application provides various commands and parameters for users to use, depth customization reporting can be realized according to the commands, the users can freely combine different commands, adjust the parameters of the commands and nest the commands to add additional processing steps, so that reports meeting specific requirements are obtained, and flexible report customization is realized.
S804: the plurality of report commands are parsed to generate a plurality of command objects, the plurality of command objects constituting a command set.
In an embodiment of the present application, further parsing the report Command generates a Command object, which may be a Command object in java. By repeatedly executing the analysis of the message command, all the report commands in the report template are analyzed and command objects are generated, so that the report commands are converted into executable command objects.
The embodiment of the application supports the nesting of commands, meets the report generation requirement of complex scenes, for example, the table circulation commands are nested in the object circulation commands, and the function that a plurality of sub-tables are generated according to the data set of the current traversal is realized in each traversal. Meanwhile, the nesting of the support commands also illustrates that one report command can be a combination of a plurality of report commands, and in the process of analyzing the report command to generate the command object, the report command and the command object are not necessarily in one-to-one correspondence, and can also be in one-to-many correspondence. Meanwhile, because command nesting is supported, in the process of generating command objects, father-son relations among the command objects need to be maintained at the same time, and therefore, a command set in the embodiment of the application comprises: the parent command object and the child command object are exemplified by "$ { c: fo } { case. Name } $ { end }", in this report command, "$ { case. Name }" is the child command of "$ { c: fo }" command, in which "$ { c: fo }" is the parent command object and "$ { case. Name }" is the child command object, and in this example, it can be seen that the command object generated by analyzing the report command is a one-to-two correspondence.
S805: obtaining a command object from a command set, the command object comprising: type parameters and command configuration parameters;
In the embodiment of the present application, the type parameter refers to a parameter for distinguishing the command type, for example, the type parameter "ft" represents a table loop command, the parameter "fr" represents a table row loop command, and the like. The command configuration parameters refer to parameters for determining the command execution action, such as rules or operations for rule commands, e.g., currently used data sets, how to make decisions, what value ranges to take, filling in or removing data, inserting tables, etc. For example, "$ { c: fo, d: data }", the c parameter refers to a type parameter, through which the type of the command object can be determined, and the d parameter is a command configuration parameter, through which the currently used data set can be specified.
In some implementations of the embodiments of the present application, the report commands supported by the present application are classified into 6 classes, which are an object circulation command, a condition judgment command, an attribute value command, a table row circulation command, a table circulation command, and a count command, respectively. Relevant parameters of the configuration command are supported in the report command, including a used data set, simple calculation logic, condition judgment, a used list, whether the report command is a picture, whether the report command needs to be cached as a variable, and the like. Correspondingly, command configuration parameters in the commands that support configuration include, but are not limited to: the method comprises the steps of data set configuration parameters, calculation logic configuration parameters, condition judgment configuration parameters, list configuration parameters, indication of whether the parameters are picture configuration parameters or not, and indication of whether the parameters are cached as variable configuration parameters or not; the type parameters supporting configuration include, but are not limited to: object loop command type parameters, condition judgment command type parameters, attribute value command type parameters, table row loop command type parameters, table loop command type parameters, and technical command type parameters.
S806: and executing the command object according to the type parameter and the command configuration parameter to acquire data from the data set and fill the data into the report template.
In the embodiment of the application, executing the command object according to the type parameter and the command configuration parameter refers to acquiring data from the data set according to different operations and rules specified by different types of command objects and writing the data into the report template according to a specified format, wherein the types of the command objects are determined based on the type parameter, and the operations or rules specified by the command objects are determined by the command configuration parameter. The purpose of executing command objects based on type parameters and command configuration parameters is to provide a dynamic and flexible way of data population for the report template.
In some implementations of the embodiments of the present application, the command object may be further distinguished as a parent command object or a child command object, that is, the command object includes a parent command object or a child command object, where the child command object exists in the command set and is corresponding to the currently executed command object, and when the currently executed command object is the parent command object and the currently executed command object exists in the corresponding child command object in the process of executing the data set, the child command object corresponding to the currently executed command object is preferentially executed. For example, when the currently executed command object is a, a is a parent class of the command objects B, C and D, that is, a is a parent command object, B, C and D are child command objects corresponding to a, after a is executed, the corresponding child classes B, C and D are preferentially executed.
In some implementations of the embodiments of the present application, the execution of the command objects in the command set may be as shown in fig. 9, where first, the command objects in the data set are acquired; then, judging the type of the command object based on the type parameter, and executing type corresponding operation based on the type of the command object; and finally judging whether the currently executed command object has a corresponding subcommand object, if so, executing the subcommand object, and if not, executing the next command object.
In some implementations of embodiments of the present application, referring to fig. 10, data is acquired from a data set required for report generation and is filled into a report template, specifically by the following steps:
s1001: the data set required for report generation is cached in a variable cache pool for caching variables of the data set required for report generation.
In the embodiment of the application, the variable cache pool refers to a memory space for caching variables in a data set, the variables comprise variable names and variable values, and the data set required by report generation is cached in the variable cache pool in advance, so that the variable values can be quickly acquired according to the variable names. Specifically, a custom java class can be created as a data parser for storing all data in the data set in the variable cache pool.
Before caching data, the data parser needs to acquire a data set, which can be specifically realized by the following ways: 1. all data objects corresponding to the data set define a report data IDataBean interface, so that the value is taken through the attribute; 2. the data parser judges whether the data object contains a property field; 3. if the data object contains a property field, taking a value by an IDataBean. 4. If the data object does not contain the property field, acquiring a value corresponding to the property field through a Java reflection mechanism, and if the data object does not contain the property field, returning to null.
S1002: and acquiring data from the variable cache pool according to the command object and filling the data into the report template.
In the embodiment of the present application, acquiring data from a variable cache pool according to a command object and filling the data into a report template refers to acquiring corresponding data from the variable cache pool according to rules and operations indicated by the command object, and filling the data into the report template according to a specified format, where the data acquired from the variable cache pool, specifically, acquiring a variable value corresponding to a variable name from the variable cache pool according to the variable name in the command object, and filling the variable value into the report template. Specifically, a java class can be customized to serve as a data parser, and the data parser can obtain data according to a command object through the following scheme: 1. determining a data set according to the context of the command object; 2. processing variables in the command object; 3. the functions of condition screening, sorting, de-duplication and the like in the command object are realized; 4. according to the type of the command Object, data is acquired through a variable cache pool, for example, the data format acquired by a loop command is List < idatabbe >, the data format acquired by a count command is intelger, and the data format acquired by an attribute value command is Object.
In some implementations of the embodiments of the present application, in a case where data cannot be obtained from the variable cache pool, the data parser may further obtain data from a local data set or a global data set, where a priority order of obtaining the data is: variable cache pools, local datasets, and global datasets. Specifically, when data cannot be acquired from the variable cache, acquiring the data from the local data set; when data is not available from the local data set, data is obtained from the global data set. Where a local data set refers to a data set within a certain range generated by a range command, which may be an object rotation command, a form row rotation command, etc. When there is no data in the variable cache pool indicated to be acquired by the command object, the data parser will preferentially acquire data from the local data set generated by the range command. For example, "$ { c: fo, d: cases } $ { case. Name } $ { end }" means that multiple objects are created from the case dataset traversal and case name attribute values are output in each object. Here, "$ { case. Name }" will preferentially obtain the name attribute value of the case object from the local dataset corresponding to "$ { c: fo, d: cases }". Global data sets refer to all data sets required for report generation. When the command object indicates the acquired data does not exist in the local data set, the data is acquired from the global data set.
In an embodiment of the present application, if the command object indicates that the acquired data is not a variable in the cache, acquiring from the local data set or the global data set according to the property attribute in the command object; for example, the manner in which data is acquired by "$ { case. Name }" isas follows: 1. the data analyzer judges whether a case/name variable exists in the cache, and if so, the data analyzer returns a variable value; 2. the data analyzer judges whether a case variable exists in the cache, and if so, the data analyzer acquires a name attribute from the cached case object and returns the name attribute; 3. the data analyzer judges whether the local data set contains a case object, if so, the name attribute of the case object is obtained and returned; 4. the data analyzer judges whether the global data set contains a case object, if so, the name attribute of the case object is obtained and returned; 5. and if the data parser does not find the defined data, returning null.
In some implementations of embodiments of the present application, the data population of the report template may be specifically shown with reference to fig. 11. Firstly, creating all data caches of a data set required by a data parser to generate a report; then, determining and acquiring a data set related to the command object; next, by executing computational logic, conditional judgment statements, etc. in the command object, it is determined that the currently executing command object indicates the acquired data set or data objects in the data set. Finally, before returning the data, judging whether the data needs to be defined as a variable, if so, caching the data into a variable cache pool, and if not, directly returning the data. Among them, the purpose of defining data as variables is to improve the reusability of data. For example, when a certain data is repeatedly used, it may be considered to be implemented by defining a variable, for example, in a word document, the value of "total number of demands" needs to be used multiple times, and then "total number of demands" may be defined as a variable reqTotalNum, and then the variable may be directly used by $ { reqTotalNum }.
S807: after all command objects in the command set have been executed, a report is obtained.
In the flow shown in fig. 8, all report commands in the report template are parsed to obtain a dataset by matching the report commands in the report command text with regular expressions, thereby implementing the conversion of the report commands into executable command objects. Executing the command object according to the type parameter and the command configuration parameter of the command object, and filling the data in the data set into the report template in a specified format, thereby realizing the automation of report generation.
Referring to fig. 12, an embodiment of the present application further provides a report generating apparatus, including:
a data set definition module 1201 for defining a data set required for report generation;
a template configuration module 1202 for configuring a report template, the report template comprising: reporting a command text;
a command set extraction module 1203 configured to extract a command set from the report command text;
a command set execution module 1204 for retrieving data from the data set required for report generation by executing the command set and populating the report template to generate the report.
In some implementations of embodiments of the present application, the data set required for report generation is defined by: defining data required for report generation, defining attributes of the data required for report generation, and defining interfaces for value according to the attributes.
In some implementations of embodiments of the present application, configuring a report template includes:
and configuring a total style text and a report command text in the template to obtain a report template, wherein the report command text is used for indicating that data is extracted from a data set required for report generation and is filled into the report template in a specified format, and the total style text is used for defining the total style of the report template.
In some implementations of embodiments of the present application, reporting command text includes: a plurality of report commands, the command set comprising: a plurality of command objects, extracting a command set from a report command text, comprising:
matching texts conforming to a preset command format in the report command texts through regular expressions to obtain a plurality of report commands, wherein the regular expressions are character matching formulas written based on the preset command format;
the plurality of report commands are parsed to generate a plurality of command objects, the plurality of command objects constituting a command set.
In some implementations of embodiments of the present application, retrieving data from a data set required for report generation by executing a command set and populating a report template to generate a report includes:
obtaining a command object from a command set, the command object comprising: type parameters and command configuration parameters;
Executing a command object according to the type parameter and the command configuration parameter to acquire data from a data set required by report generation and fill the data into a report template;
after all command objects in the command set have been executed, a report is obtained.
In some implementations of embodiments of the present application, obtaining data from a data set required for report generation and populating a report template includes:
caching the data set required by report generation into a variable cache pool, wherein the variable cache pool is used for caching variables of the data set required by report generation;
and acquiring data from the variable cache pool according to the command object and filling the data into the report template.
In some implementations of embodiments of the present application, the command object includes: a parent command object or a child command object, the child command object having a corresponding parent command object in the command set, the apparatus further operable to:
when the currently executed command object is a parent command object and the corresponding child command object exists in the currently executed command object, executing the child command object corresponding to the currently executed command object.
In some implementations of embodiments of the present application, the report command includes the following types: attribute value commands, condition judgment commands, form loop commands, form row loop commands, object loop commands, and count commands.
As shown in fig. 13, an embodiment of the present application further provides an apparatus, including: a memory 1301, a processor 1302;
wherein the memory 1301 is for storing a program;
the processor 1302 is configured to execute programs in the memory to implement the steps of the report generating method provided in the embodiments of the present application.
Finally, it is also noted that in the present application embodiments, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A report generation method, the method comprising:
defining a data set required for report generation;
configuring a report template, the report template comprising: reporting a command text;
extracting a command set from the report command text;
data is acquired from the data set required for report generation by executing the command set and populated into the report template to generate a report.
2. The report generating method according to claim 1, wherein the data set required for the report generation is defined by: defining data required for report generation, defining attributes of the data required for report generation, and defining interfaces for values according to the attributes.
3. The report generating method as claimed in claim 1, wherein said configuring the report template comprises:
and configuring a total style text and a report command text in a template to obtain the report template, wherein the report command text is used for indicating that data is extracted from a data set required for generating the report and is filled into the report template in a specified format, and the total style text is used for defining the total style of the report template.
4. The report generating method according to claim 1, wherein the report command text includes: a plurality of reporting commands, the command set comprising: a plurality of command objects, said extracting a command set from said report command text, comprising:
command matching is performed on the report command text through a regular expression, wherein the text accords with a preset command format, so that the report commands are obtained, and the regular expression is a character matching formula written based on the preset command format;
parsing the plurality of report commands to generate the plurality of command objects, the plurality of command objects constituting the command set.
5. The report generating method as set forth in claim 4, wherein said obtaining data from said data set required for report generation by executing said command set and populating said report template to generate a report, comprises:
obtaining the command object from the command set, the command object comprising: type parameters and command configuration parameters;
executing the command object according to the type parameter and the command configuration parameter to acquire data from a data set required by the report generation and fill the data into the report template;
After all the command objects in the command set have been executed, the report is obtained.
6. The report generating method as set forth in claim 5, wherein said acquiring data from a data set required for said report generation and populating said report template comprises:
caching the data set required by report generation into a variable cache pool, wherein the variable cache pool is used for caching variables of the data set required by report generation;
and acquiring data from the variable cache pool according to the command object and filling the data into the report template.
7. The report generating method as claimed in claim 5, wherein the command object comprises: a parent command object or a child command object, the child command object having a corresponding parent command object in the command set, the method further comprising:
and in the process of executing the command set, when the currently executed command object is the father command object and the corresponding subcommand object exists in the currently executed command object, preferentially executing the subcommand object corresponding to the currently executed command object.
8. The report generating method as recited in claim 4, wherein the report command comprises the following types: attribute value commands, condition judgment commands, form loop commands, form row loop commands, object loop commands, and count commands.
9. A report generating apparatus, the apparatus comprising:
a data set definition module for defining a data set required for report generation;
the template configuration module is used for configuring a report template, and the report template comprises: reporting a command text;
the command set extraction module is used for extracting a command set from the report command text;
and the command set execution module is used for acquiring data from the data set required by report generation by executing the command set and filling the data into the report template to generate a report.
10. A report generating apparatus, the apparatus comprising: comprising a memory and a processor for executing a program stored in the memory, running the report generating method as claimed in any one of claims 1 to 8.
CN202311695335.5A 2023-12-11 2023-12-11 Report generation method, device and equipment Pending CN117669509A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311695335.5A CN117669509A (en) 2023-12-11 2023-12-11 Report generation method, device and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311695335.5A CN117669509A (en) 2023-12-11 2023-12-11 Report generation method, device and equipment

Publications (1)

Publication Number Publication Date
CN117669509A true CN117669509A (en) 2024-03-08

Family

ID=90071134

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311695335.5A Pending CN117669509A (en) 2023-12-11 2023-12-11 Report generation method, device and equipment

Country Status (1)

Country Link
CN (1) CN117669509A (en)

Similar Documents

Publication Publication Date Title
US9542622B2 (en) Framework for data extraction by examples
US8176412B2 (en) Generating formatted documents
US7673235B2 (en) Method and apparatus for utilizing an object model to manage document parts for use in an electronic document
US7752224B2 (en) Programmability for XML data store for documents
EP3358470B1 (en) Method of preparing documents in markup languages
US8397157B2 (en) Context-free grammar
CN108762743B (en) Data table operation code generation method and device
US20040133854A1 (en) Persistent document object model
US8413070B1 (en) Declarative resizeable list in electronic form
US20170154019A1 (en) Template-driven transformation systems and methods
CN110020307A (en) A kind of method for drafting and device of client&#39;s end-view
CN110738037A (en) Method, apparatus, device and storage medium for automatically generating electronic form
CN103412853A (en) Method for automatically generating test cases aiming at document converters
CN104881275A (en) Electronic spreadsheet generating method and device
CN111913739B (en) Service interface primitive defining method and system
CN109614329B (en) Software test case aided design method based on interface control file
CN115202626A (en) Low-code front-end development method supporting multi-technology stack components
CN111488155A (en) Coloring language translation method
JPWO2005098660A1 (en) Document processing apparatus and document processing method
JPWO2005098658A1 (en) Document processing apparatus and document processing method
CN116090416A (en) Standard writing method, system, equipment and medium based on standard knowledge graph
CN117669509A (en) Report generation method, device and equipment
CN107577476A (en) A kind of Android system source code difference analysis method, server and medium based on Module Division
US20220222065A1 (en) System and method of computer-assisted computer programming
US11210454B2 (en) Method for preparing documents written in markup languages while implementing a user interface for dealing with data of an information system

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