CN107977351B - Electronic report generation method and device, computer equipment and storage medium - Google Patents
Electronic report generation method and device, computer equipment and storage medium Download PDFInfo
- Publication number
- CN107977351B CN107977351B CN201711458911.9A CN201711458911A CN107977351B CN 107977351 B CN107977351 B CN 107977351B CN 201711458911 A CN201711458911 A CN 201711458911A CN 107977351 B CN107977351 B CN 107977351B
- Authority
- CN
- China
- Prior art keywords
- report
- data
- information
- layout
- preset
- 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
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/10—Text processing
- G06F40/166—Editing, e.g. inserting or deleting
- G06F40/177—Editing, e.g. inserting or deleting of tables; using ruled lines
- G06F40/18—Editing, e.g. inserting or deleting of tables; using ruled lines of spreadsheets
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/10—Text processing
- G06F40/166—Editing, e.g. inserting or deleting
- G06F40/186—Templates
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Audiology, Speech & Language Pathology (AREA)
- Health & Medical Sciences (AREA)
- Computational Linguistics (AREA)
- General Health & Medical Sciences (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Artificial Intelligence (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Stored Programmes (AREA)
- Document Processing Apparatus (AREA)
Abstract
The embodiment of the application discloses a method and a device for generating an electronic report, computer equipment and a storage medium, wherein the method comprises the following steps: acquiring a preset layout definition file; acquiring report data according to the data source configuration information and generating a report template according to the report layout information; analyzing the report layout information to obtain a preset layout component in the report layout information; acquiring type information of an electronic report to be generated selected by a user; based on the report data, selecting an application programming interface corresponding to the preset layout component according to the type information to generate a report component object; and filling the report component object in the report template to generate the electronic report. The method establishes the report template through the preset layout definition file, and then calls the report data by using the preset layout component to fill the report template so as to generate the electronic report, thereby providing a method for quickly generating electronic reports in various formats for users, reducing the workload of the users and saving the time of the users.
Description
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for generating an electronic report, a computer device, and a storage medium.
Background
At present, electronic Reports are mostly produced and generated through professional production software tools, such as Jasper Reports and the like, and although the tools such as Jasper Reports and the like are professional, the tools are too large, the learning cost is high, the configuration is complicated, the operation efficiency is low, and performance problems such as insufficient memory or abnormal memory are easily caused under the condition that the data volume of data source data is large. If the electronic report forms are generated by using frame coding modes such as POI (point of interest) and the like, such as PDF (Portable document Format), EXCEL (extensible markup language), WORD (WORD object) and the like, a large amount of codes need to be written, for report forms with complex formats, a large amount of time needs to be spent on writing related layout codes, the codes can be hundreds of lines or even thousands of lines, and meanwhile, for electronic report forms with the same content but different file formats, a plurality of sets of generation codes need to be written, so that the workload is large, and the maintenance.
Disclosure of Invention
The application provides an electronic report generation method, an electronic report generation device, computer equipment and a storage medium, so that electronic reports in various formats can be generated quickly.
In a first aspect, the present application provides a method for generating an electronic report, including:
acquiring a preset layout definition file, wherein the preset layout definition file comprises data source configuration information and report layout information;
acquiring report data according to the data source configuration information, and generating a report template according to the report layout information;
analyzing the report layout information to obtain a preset layout component in the report layout information;
acquiring type information of an electronic report to be generated selected by a user;
based on the report data, selecting an application programming interface corresponding to the preset layout component according to the type information to generate a report component object;
and filling the report component object in the report template to generate an electronic report.
In a second aspect, the present application provides an electronic report generating apparatus, including:
the system comprises a file acquisition unit, a report generation unit and a report generation unit, wherein the file acquisition unit is used for acquiring a preset layout definition file, and the preset layout definition file comprises data source configuration information and report layout information;
the acquisition generating unit is used for acquiring report data according to the data source configuration information and generating a report template according to the report layout information;
the analysis acquisition unit is used for analyzing the report layout information to acquire a preset layout component in the report layout information;
the type acquisition unit is used for acquiring the type information of the electronic report to be generated selected by the user;
the object generating unit is used for selecting an application programming interface corresponding to the preset layout component according to the type information to generate a report component object based on the report data;
and the filling generation unit is used for filling the report component object in the report template to generate the electronic report.
In a third aspect, the present application further provides a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor implements the electronic report generating method provided in any one of the applications when executing the program.
In a fourth aspect, the present application further provides a storage medium, wherein the storage medium stores a computer program, the computer program comprises program instructions, which when executed by a processor, cause the processor to execute any one of the electronic report generating methods provided in the present application.
The method comprises the steps of obtaining a preset layout definition file, wherein the preset layout definition file comprises data source configuration information and report layout information; acquiring report data according to the data source configuration information and generating a report template according to the report layout information; analyzing the report layout information to obtain a preset layout component in the report layout information; acquiring type information of an electronic report to be generated selected by a user; based on the report data, selecting an application programming interface corresponding to the preset layout component according to the type information to generate a report component object; and filling the report component object in the report template to generate an electronic report. The method establishes the report template through the preset layout definition file, and then calls the report data by using the preset layout component to fill the report template so as to generate the electronic report, thereby providing a method for quickly generating electronic reports in various formats for users, reducing the workload of the users and saving the time of the users.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is a schematic flow chart diagram illustrating a method for generating an electronic report according to an embodiment of the present application;
FIG. 2 is a schematic flow chart diagram of sub-steps of the electronic report generating method of FIG. 1;
FIG. 3 is a schematic flow chart diagram of sub-steps of the electronic report generating method of FIG. 1;
FIG. 4 is a schematic flow chart diagram of a method for generating an electronic report according to another embodiment of the present application;
FIG. 5 is a schematic block diagram of an electronic report generating apparatus according to an embodiment of the present application;
FIG. 6 is a schematic block diagram of a data parsing unit of the electronic report generating apparatus in FIG. 5;
FIG. 7 is a schematic block diagram of an electronic report generating apparatus according to another embodiment of the present application;
fig. 8 is a schematic block diagram of a computer device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some, but not all, embodiments of the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It will be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It is also to be understood that the terminology used in the description of the present application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in the specification of the present application and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be further understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
Referring to fig. 1, fig. 1 is a schematic flow chart of a method for generating an electronic report according to an embodiment of the present application. The electronic report generation method can be operated in a terminal or a server, and also can be operated in a system formed by the interaction of the terminal and the server, wherein the terminal comprises a desktop computer, a portable computer, a tablet computer, a Personal Digital Assistant (PDA) or a smart phone and the like; the server may be an independent server or a server cluster composed of a plurality of servers. As shown in fig. 1, the method includes steps S101 to S106.
S101, acquiring a preset layout definition file.
In this embodiment, the preset layout definition file includes data source configuration information and report layout information. The data source configuration information includes a data source name, a data source type, data source address information, and the like, where the data source address information may specifically be a Uniform Resource Locator (URL) address, and the like. The report layout information comprises report parameters and a preset layout component, the report parameters comprise report size information, style information and the like, and the preset layout component comprises a constant component, a variable component, a data source component and the like. The data source type includes JSON (JavaScript Object Notation), XML (eXtensible Markup Language), SQL (Structured Query Language), and other types.
The preset layout definition file may also have different formats, for example, an XML format file, that is, an XML language definition, which is similar to a hypertext markup language.
Specifically, before the obtaining of the preset layout definition file, the method further includes: and displaying a preset layout template to the user according to a preset layout instruction triggered by the user, so that the user edits and defines according to the preset layout template to generate a preset layout definition file according to the requirement. The preset layout definition file is obtained in order to analyze the preset layout definition file to obtain the related data source configuration information and report layout information.
S102, obtaining report data according to the data source configuration information, and generating a report template according to the report layout information.
In this embodiment, the Data source configuration information provides a source for report related Data, and supports multiple Data reading protocols, including but not limited to HTTP (Hyper Text Transfer Protocol ), FTP (File Transfer Protocol, File Transfer Protocol), JDBC (Java Data Base Connectivity, database Connectivity), and other protocols. Based on the protocols, reading corresponding data streams from a database, a local disk or a remote service according to data source address information in the data source configuration information to acquire report data. While supporting a variety of data formats including, without limitation, XML or JSON, etc.
Specifically, the data source configuration information includes a uniform resource locator and data type information; correspondingly, as shown in fig. 2, the obtaining report data according to the data source configuration information includes: steps S102a to S102 c.
S102a, acquiring a report data source according to the uniform resource locator information; s102b, determining an analysis rule according to the data type information; s102c, the report data source is analyzed according to the determined analysis rule to obtain report data. Specifically, the URL address is, for example, Http: do, the URL address is used to call the data source; the data type information corresponding to the data source includes JSON, XML, or SQL format, and different data types correspond to different parsing rules, so that parsing rules need to be determined according to the data type information, for example, a data type in a JSON format corresponds to a JSON parsing rule, and the JSON parsing rule is used to parse the report data source to obtain report data.
In addition, when the report data source is analyzed according to the determined analysis rule to obtain the report data, the analysis process corresponding to the analysis of the report data source according to the determined analysis rule to obtain the report data can be monitored; judging whether an alarm event triggering a preset alarm condition occurs in the analysis process; and if an alarm event triggering the preset alarm condition occurs, marking data corresponding to the alarm event. An alarm event occurs that triggers a preset alarm condition, which may be a preset threshold or other determination condition, and which may be set by a user. When the corresponding data value in the report data exceeds the preset threshold value, judging that the data value triggers a preset alarm event, marking the data corresponding to the alarm event, for example, by using a red font mark or a special symbol, and displaying the marked data in an electronic report to prompt a user that the related data is abnormal.
The report template is generated according to the report layout information including the information such as the style and the size of the electronic report, the report template is similar to the report frame and comprises the length, the width, the display style and the like of the electronic report, different positions of the report template correspond to different preset layout components, and the preset layout components are used for filling related data information.
S103, analyzing the report layout information to obtain a preset layout component in the report layout information.
In this embodiment, the purpose of analyzing the report layout information is to obtain all preset layout components in the report layout information, reference relevant data in the report data by using the preset layout components, and perform data filling on the report template through the preset layout components. The preset layout component comprises a constant component, a variable component, a data source component and the like.
And S104, acquiring the type information of the electronic report to be generated selected by the user.
In this embodiment, the type information of the report to be generated includes PDF, XML, TXT, Excel, word, or the like, and specifically is the type information of the electronic report required by the user, for example, if the user wants to obtain the electronic report in the PDF format, the user may select the type information of the report to be generated as the PDF format, so that the type information of the electronic report to be generated selected by the user is obtained as the PDF. Since different types of information require different types of APIs (Application Programming interfaces) to be called in the Apache POI. The Apache POI provides the API interface for reading and writing the document, wherein the Apache POI has different types of the electronic report to be generated and corresponds to different API interfaces, so that the type information of the report to be generated needs to be determined firstly.
In one embodiment, instead of Apache POIs, other types of API interface providing tools may be used, or the associated API interface tools may be written by themselves.
And S105, based on the report data, selecting an application programming interface corresponding to the preset layout component according to the type information to generate a report component object.
In this embodiment, when the type information selected by the user is different for the same preset layout component, the corresponding application programming interfaces are also different, for example, the application programming interfaces corresponding to the same constant component of the PDF and Excel type information are not the same, so that after the type information of the report to be generated is determined, the application programming interface corresponding to the preset layout component is selected according to the type information to generate the report component object. Of course, the corresponding application programming interfaces of different preset layout components in the same type of information are different. Specifically, as shown in FIG. 3, step S105 includes steps S105 a-S105 b.
S105a, determining the type of the application programming interface corresponding to the type information; s105, 105b, determining an application programming interface corresponding to the preset layout component according to the determined application programming interface type; s105, 105c, calling data information in the report data according to the application programming interface corresponding to the preset layout component to generate a report component object.
Specifically, determining an Application Programming Interface category corresponding to the type information, specifically determining an Application Programming Interface category corresponding to the type information selected by a user in an Apache POI, providing API (Application Programming Interface) Interface types in multiple file formats in the Apache POI, calling the determined Application Programming Interface through a preset layout component to circulate the report data to generate a report component object, and encapsulating the corresponding data and the API Interface by the report component object. Different preset layout components also call different API interfaces, or the same preset layout component also calls different API interfaces corresponding to different types of information. For example, the constant component is used for calling a constant value in report data acquired by a relevant API in the Apache POI to generate a corresponding report component object; the variable component is used for calling a relevant API in the Apache POI to acquire a variable value in the report data so as to generate a corresponding report component object; and the data source component is used for circulating report data and calling a related API of the Apache POI to generate a corresponding report component object.
And S106, filling the report component object in the report template to generate an electronic report.
In this embodiment, the report component object is filled in the report template to generate the electronic report according to the position of the report component name in the report template. Because the report template is generated by report layout information, the report template includes a corresponding preset layout component at a corresponding position, where the preset layout component is, for example, a constant component, a variable component, or a data source component, and the report component object corresponding to the constant component, the variable component, or the data source component is populated in the report template to generate a corresponding electronic report.
The electronic report generation method comprises the steps of acquiring a preset layout definition file, acquiring report data by using data source configuration information in the preset layout definition file, and generating a report template by using the report layout information; and selecting corresponding application programming interfaces to quote report data in the data source according to a preset layout component in the report layout information so as to generate the electronic report. The electronic report is generated by the method, and for multiple file formats of the same report, the electronic report can be generated only by compiling a set of preset layout definition files, so that a large amount of development time is saved, and the rapid development and the easy maintenance are really realized. Meanwhile, developers do not need to know the development related to PDF, word, Excel and the like, data service logic is more concentrated, and the working efficiency of the developers is improved.
Referring to fig. 4, fig. 4 is a schematic flowchart of a method for generating an electronic report according to another embodiment of the present application. The electronic report generation method can be operated in a terminal or a server, and also can be operated in a system formed by the interaction of the terminal and the server, wherein the terminal comprises a desktop computer, a portable computer, a tablet computer or a smart phone and the like; the server may be an independent server or a server cluster composed of a plurality of servers. As shown in FIG. 4, the electronic report method includes steps S201 to S210.
S201, acquiring a preset layout definition file.
In this embodiment, the preset layout definition file includes data source configuration information and report layout information. The data source configuration information includes a data source name, a data source type, data source address information, and the like, where the data source address information may specifically be a Uniform Resource Locator (URL) address, and the like. The report layout information comprises report parameters and a preset layout component, the report parameters comprise report size information, style information and the like, and the preset layout component comprises a constant component, a variable component, a data source component and the like.
S202, acquiring file information of report data corresponding to the data source configuration information according to the data source configuration information.
In this embodiment, the file information includes the size of the report file, but the file information does not include only the size of the report file and other information. For example, a data source type, such as XML or JSON, may also be included. The report file size is the size of report data, and may be several MB or GB, for example.
S203, judging whether the size of the report file is larger than a preset threshold value.
In this embodiment, the preset threshold is a preset condition for determining the size of the report data, and if the size of the report file of the report data exceeds the preset threshold, it is determined that the file of the report data is large. If the file size of the data source data is larger than the preset threshold, executing step S204; if the file size of the data source data is not greater than the preset threshold, step S205 is executed.
And S204, loading the data source data according to a preset loading rule to obtain report data.
In this embodiment, if the file size of the data source data is greater than the preset threshold, the data source data is loaded according to a preset loading rule to obtain report data. The preset loading rules include batch loading rules, that is, batch loading after the data source data is effectively segmented. By using the batch loading mode, the problems that the memory is insufficient due to one-time loading, the system operation efficiency is influenced and even the system is crashed can be effectively prevented.
S205, directly reading data source data according to the data source configuration information to obtain report data.
In this embodiment, the data source configuration information provides a source for report related data, and specifically, a corresponding data stream is read from a database, a local disk, or a remote service according to the data source configuration information in the URL address information to obtain report data.
In addition, the file information includes a data source type, and before the report data is acquired, it is further determined whether the electronic report generation method can support the data source type. Whether before step S204 or step S205 is performed, a determination needs to be made as to the data source type.
Specifically, judging whether the data source type corresponding to the data source configuration information is a preset data type; and if the data source type corresponding to the data source configuration information is not the preset data type, sending data source loading prompt information and a preset data source loading protocol to prompt a user to acquire report data through a data source loading expansion interface function according to the preset data source loading protocol.
The preset data type is used for judging whether the data source type supported by the electronic report generation method is available, for example, the preset data type includes a JSON type, an XML type or an SQL type, and if the data source type corresponding to the data source configuration information is one of the preset data types, it indicates that the data source type is supported; and if the data source type corresponding to the data source configuration information is not the type related to the preset data type, indicating that the data source type is not supported. Corresponding to the unsupported data source, the data source loading expansion interface is provided by sending the data source loading prompt information and presetting the data source loading protocol, and a developer can easily realize the own data source interface according to the presetting data source loading protocol so as to realize the loading of some unusual data formats.
And S206, generating a report template according to the report layout information.
In this embodiment, a report template is generated according to the report layout information including the information such as the style and size of the electronic report, the report template includes the length and width, the display style, and the like of the electronic report similar to the report frame, and different positions of the report template correspond to different preset layout components, and the preset layout components are used for filling the related data information.
And S207, analyzing the report layout information to obtain a preset layout component in the report layout information.
In this embodiment, the purpose of analyzing the report layout information is to obtain all preset layout components in the report layout information, reference relevant data in the report data by using the preset layout components, and perform data filling on the report template through the preset layout components. The preset layout component comprises a constant component, a variable component, a data source component and the like.
And S208, obtaining the type information of the electronic report to be generated selected by the user.
In this embodiment, the type information of the electronic report specifically required by the user, for example, if the user wants to obtain the electronic report in the PDF format, the user may select the type information of the to-be-generated report to be in the PDF format, so that the type information of the to-be-generated electronic report selected by the user is obtained as the PDF. Because different types of the electronic report to be generated are different and correspond to different API interfaces, the type information of the report to be generated needs to be determined first.
S209, based on the report data, selecting an application programming interface corresponding to the preset layout component according to the type information to generate a report component object.
In this embodiment, the application programming interfaces of the preset layout component corresponding to different types of information are different, for example, the application programming interfaces corresponding to PDF and Excel are different, so that after the type information of the report to be generated is determined, the application programming interface corresponding to the preset layout component is selected according to the type information to generate the report component object. And after the API interface type is determined, calling the determined application programming interface to circulate the report data through a preset layout component to generate a report component object, and packaging the corresponding data and the API interface by the report component object.
S210, filling the report component object in the report template to generate an electronic report.
In this embodiment, the report component object is filled in the report template to generate the electronic report according to the position of the report component name in the report template. Because the report template is generated by report layout information, the report template includes a corresponding preset layout component at a corresponding position, where the preset layout component is, for example, a constant component, a variable component, or a data source component, and the report component object corresponding to the constant component, the variable component, or the data source component is populated in the report template to generate a corresponding electronic report.
The electronic report generation method comprises the steps of acquiring a preset layout definition file, acquiring report data by using data source configuration information in the preset layout definition file, and generating a report template by using the report layout information; and selecting corresponding application programming interfaces to quote report data in the data source according to a preset layout component in the report layout information so as to generate the electronic report. The method for generating the electronic report really achieves quick development and easy maintenance. Meanwhile, functions of batch loading of data, loading of an expansion interface of a data source and the like are provided, and further the working efficiency of developers is improved.
Referring to fig. 5, fig. 5 is a schematic block diagram of an electronic report generating apparatus according to an embodiment of the present application. The electronic report generating apparatus 400 may be installed in a server or a terminal. As shown in fig. 5, the electronic report generating apparatus 400 includes: a file acquisition unit 401, an acquisition generation unit 402, a parsing acquisition unit 403, a type acquisition unit 404, an object generation unit 405, and a padding generation unit 406.
A file obtaining unit 401, configured to obtain a preset layout definition file.
The preset layout definition file comprises data source configuration information and report layout information. The data source configuration information includes a data source name, a data source type, data source address information and the like, and the data source address information may specifically be a uniform resource locator address and the like. The report layout information comprises report parameters and a preset layout component, the report parameters comprise report size information, style information and the like, and the preset layout component comprises a constant component, a variable component, a data source component and the like. The data source type comprises JSON, XML or SQL and the like.
Specifically, before the preset layout definition file is acquired, the method is further configured to: and displaying a preset layout template to the user according to a preset layout instruction triggered by the user, so that the user edits and defines according to the preset layout template to generate a preset layout definition file according to the requirement. The preset layout definition file is obtained in order to analyze the preset layout definition file to obtain the related data source configuration information and report layout information.
An obtaining and generating unit 402, configured to obtain report data according to the data source configuration information, and generate a report template according to the report layout information.
The data source configuration information provides a source for report related data, and supports a plurality of data reading protocols including but not limited to HTTP, FTP or JDBC (and the like).
Specifically, the acquisition generating unit 402 includes: a data source acquisition subunit 4021, a rule determination subunit 4022, and a data parsing subunit 4023.
A data source obtaining subunit 4021, configured to obtain a report data source according to the uniform resource locator information; a rule determining subunit 4022, configured to determine an analysis rule according to the data type information; the data parsing subunit 4023 is configured to parse the report data source according to the determined parsing rule to obtain report data. Specifically, the URL address is, for example, Http: do, the URL address is used to call the data source; the data type information corresponding to the data source includes JSON, XML, or SQL format, and different data types correspond to different parsing rules, so that parsing rules need to be determined according to the data type information, for example, a data type in a JSON format corresponds to a JSON parsing rule, and the JSON parsing rule is used to parse the report data source to obtain report data.
Further, as shown in fig. 6, the acquisition generation unit 402 further includes: a monitor acquisition subunit 4024, an event judgment subunit 4025, and a data flag subunit 4026. The monitoring obtaining subunit 4024 is configured to monitor an analysis process for analyzing the report data source according to the determined analysis rule to obtain report data; the event determining subunit 4025 is configured to determine whether an alarm event triggering a preset alarm condition occurs in the parsing process; the data marking subunit 4026 is configured to mark data corresponding to the alarm event if the alarm event triggering the preset alarm condition occurs. An alarm event occurs that triggers a preset alarm condition, which may be a preset threshold or other determination condition, and which may be set by a user. When the corresponding data value in the report data exceeds the preset threshold value, judging that the data value triggers a preset alarm event, marking the data corresponding to the alarm event, for example, by using a red font mark or a special symbol, and displaying the marked data in an electronic report to prompt a user that the related data is abnormal.
An analysis obtaining unit 403, configured to analyze the report layout information to obtain a preset layout component in the report layout information.
The purpose of analyzing the report layout information is to acquire all preset layout components in the report layout information, use the preset layout components to quote the related data in the report data, and use the preset layout components to perform data filling on the report template. The preset layout component comprises a constant component, a variable component, a data source component and the like.
A type obtaining unit 404, configured to obtain type information of the electronic report to be generated, which is selected by the user.
The type information of the report to be generated includes PDF, XML, TXT, Excel, word, or the like, and specifically is the type information of the electronic report required by the user, for example, if the user wants to obtain the electronic report in the PDF format, the user may select the type information of the report to be generated as the PDF format, so that the type information of the electronic report to be generated selected by the user is obtained as the PDF. Since different types of information require different types of API interfaces to be invoked in the Apache POI. The Apache POI provides the API interface for reading and writing the document, wherein the Apache POI has different types of the electronic report to be generated and corresponds to different API interfaces, so that the type information of the report to be generated needs to be determined firstly.
An object generating unit 405, configured to select, based on the report data, an application programming interface corresponding to the preset layout component according to the type information to generate a report component object.
When the type information selected by the user is different, the corresponding application programming interfaces of the same preset layout component are different, for example, the application programming interfaces corresponding to the same constant component of the PDF and Excel type information are different, so that after the type information of the report to be generated is determined, the application programming interface corresponding to the preset layout component is selected according to the type information to generate the report component object.
Specifically, the object generating unit 405 includes a category determining subunit 405a, an interface determining subunit 405b, and an object generating subunit 405 c.
A category determining subunit 405a, configured to determine an application programming interface category corresponding to the type information; an interface determining subunit 405b, configured to determine, according to the determined application programming interface category, an application programming interface corresponding to the preset layout component; and an object generation subunit 405c, configured to call, according to the application programming interface corresponding to the preset layout component, data information in the report data to generate a report component object.
Specifically, the type of an Application Programming Interface corresponding to type information selected by a user is determined in an Apache POI, API (Application Programming Interface) Interface types in multiple file formats are provided in the Apache POI, after the API Interface types are determined, the determined API interfaces are called by a preset layout component to circulate report data to generate a report component object, and the report component object encapsulates the corresponding data and the API Interface. Different preset layout components also call different API interfaces, or the same preset layout component also calls different API interfaces corresponding to different types of information. For example, the constant component is used for calling a constant value in report data acquired by a relevant API in the Apache POI to generate a corresponding report component object; the variable component is used for calling a relevant API in the Apache POI to acquire a variable value in the report data so as to generate a corresponding report component object; and the data source component is used for circulating report data and calling a related API of the Apache POI to generate a corresponding report component object.
And a filling generation unit 406, configured to fill the report component object in the report template to generate an electronic report.
And filling the report component object in the report template according to the position of the report component name in the report template to generate the electronic report. Because the report template is generated by report layout information, the report template includes a corresponding preset layout component at a corresponding position, where the preset layout component is, for example, a constant component, a variable component, or a data source component, and the report component object corresponding to the constant component, the variable component, or the data source component is populated in the report template to generate a corresponding electronic report.
Referring to fig. 7, fig. 7 is a schematic block diagram of an electronic report generating apparatus according to an embodiment of the present application. The electronic report generating apparatus 500 may be installed in a server or a terminal. As shown in fig. 7, the electronic report generating apparatus 500 includes: a file acquisition unit 501, an information acquisition unit 502, a file determination unit 503, a first loading unit 504, a second loading unit 505, a template generation unit 506, a parsing acquisition unit 507, a type acquisition unit 508, an object generation unit 509, and a padding generation unit 510.
A file obtaining unit 501, configured to obtain a preset layout definition file.
The preset layout definition file comprises data source configuration information and report layout information. The data source configuration information includes a data source name, a data source type, data source address information, and the like, and the data source address information may specifically be a uniform resource locator, and the like. The report layout information comprises report parameters and a preset layout component, the report parameters comprise report size information, style information and the like, and the preset layout component comprises a constant component, a variable component, a data source component and the like.
An information obtaining unit 502, configured to obtain, according to the data source configuration information, file information of report data corresponding to the data source configuration information.
The file information includes the size of the report file, but the file information does not include only the size of the report file and other information. For example, a data source type, such as XML or JSON, may also be included. The report file size is the size of report data, and may be several MB or GB, for example.
The file determining unit 503 is configured to determine whether the size of the report file is greater than a preset threshold.
The preset threshold is a preset condition for judging the size of the report data, and if the size of the report file of the report data exceeds the preset threshold, the file of the report data is judged to be large. If the file size of the data source data is larger than the preset threshold, calling a first loading unit 504; if the file size of the data source data is not greater than the preset threshold, the second loading unit 505 is invoked.
The first loading unit 504 is configured to load the data source data according to a preset loading rule to obtain report data.
And if the file size of the data source data is larger than the preset threshold, loading the data source data according to a preset loading rule to obtain report data. The preset loading rules include batch loading rules, that is, batch loading after the data source data is effectively segmented. By using the batch loading mode, the problems that the memory is insufficient due to one-time loading, the system operation efficiency is influenced and even the system is crashed can be effectively prevented.
And a second loading unit 505, configured to directly read data source data according to the data source configuration information to obtain report data.
The data source configuration information provides a source for report related data, and particularly reads corresponding data streams from a database, a local disk or a remote service according to the data source configuration information in the URL address information to acquire report data.
And the template generating unit 506 is used for generating a report template according to the report layout information.
The report template is generated according to the report layout information including the information such as the style and the size of the electronic report, the report template is similar to the report frame and comprises the length, the width, the display style and the like of the electronic report, different positions of the report template correspond to different preset layout components, and the preset layout components are used for filling related data information.
And an analysis obtaining unit 507, configured to analyze the report layout information to obtain a preset layout component in the report layout information.
The purpose of analyzing the report layout information is to acquire all preset layout components in the report layout information, use the preset layout components to quote the related data in the report data, and use the preset layout components to perform data filling on the report template. The preset layout component comprises a constant component, a variable component, a data source component and the like.
A type obtaining unit 508, configured to obtain type information of the electronic report to be generated, which is selected by the user.
Specifically, the type information of the electronic report required by the user, for example, if the user wants to obtain the electronic report in the PDF format, the user may select the type information of the report to be generated as the PDF format, so that the type information of the electronic report to be generated selected by the user is obtained as the PDF. Because different types of the electronic report to be generated are different and correspond to different API interfaces, the type information of the report to be generated needs to be determined first.
An object generating unit 509, configured to select, based on the report data, an application programming interface corresponding to the preset layout component according to the type information to generate a report component object.
When the type information selected by the user is different, the corresponding application programming interfaces of the same preset layout component are different, for example, the application programming interfaces corresponding to the same constant component of the PDF and Excel type information are different. And after the API interface type is determined, calling the determined application programming interface to circulate the report data through a preset layout component to generate a report component object, and packaging the corresponding data and the API interface by the report component object.
A filling generation unit 510, configured to fill the report component object in the report template to generate an electronic report.
And filling the report component object in the report template according to the position of the report component name in the report template to generate the electronic report. Because the report template is generated by report layout information, the report template includes a corresponding preset layout component at a corresponding position, where the preset layout component is, for example, a constant component, a variable component, or a data source component, and the report component object corresponding to the constant component, the variable component, or the data source component is populated in the report template to generate a corresponding electronic report.
The above-described apparatus may be implemented in the form of a computer program which is executable on a computer device as shown in fig. 8.
Referring to fig. 8, fig. 8 is a schematic block diagram of a computer device according to an embodiment of the present application. The computer device 700 may be a terminal or a server.
Referring to fig. 8, the computer device 700 includes a processor 720, a memory, which may include a non-volatile storage medium 730 and an internal memory 740, and a network interface 750, which are connected by a system bus 710.
The non-volatile storage medium 730 may store an operating system 731 and computer programs 732. The computer program 732, when executed, causes the processor 720 to perform a method of electronic report generation.
The processor 720 is used to provide computing and control capabilities, supporting the operation of the overall computer device 700.
The internal memory 740 provides an environment for running a computer program on a non-volatile storage medium, which when executed by the processor 720, causes the processor 720 to perform a spreadsheet generation method.
The network interface 750 is used for network communication such as sending assigned tasks 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 device 700 to which the disclosed aspects apply, as a particular computing device 700 may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
Wherein, the processor 720 is configured to run the program codes stored in the memory to implement the steps of the electronic report generating method provided by the above-mentioned embodiment.
It should be understood that, in the embodiment of the present Application, the Processor 720 may be a Central Processing Unit (CPU), and the Processor 720 may also be other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, and the like. Wherein a general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Those skilled in the art will appreciate that the configuration of computer device 700 depicted in FIG. 8 is not intended to be limiting of computer device 700 and may include more or less components than those shown, or some components in combination, or a different arrangement of components.
It will be understood by those skilled in the art that all or part of the processes in the electronic report generation method according to the above embodiments may be implemented by a computer program instructing related hardware, and the program may be stored in a storage medium, where the storage medium is a computer-readable storage medium. In the embodiment of the present invention, the program may be stored in a storage medium of a computer system and executed by at least one processor in the computer system to implement the flow steps of the embodiments including the methods as described above.
The computer readable storage medium may be a magnetic disk, an optical disk, a usb disk, a removable hard disk, a Random Access Memory (RAM), a magnetic disk or an optical disk, and various media capable of storing program codes.
Those of ordinary skill in the art will appreciate that the elements and algorithm steps of the examples described in connection with the embodiments disclosed herein may be embodied in electronic hardware, computer software, or combinations of both, and that the components and steps of the examples have been described in a functional general in the foregoing description for the purpose of illustrating clearly the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative. For example, the division of each unit is only one logic function division, and there may be another division manner in actual implementation. For example, various elements or components may be combined or may be integrated into another system, or some features may be omitted, or not implemented.
The steps in the method of the embodiment of the application can be sequentially adjusted, combined and deleted according to actual needs.
The units in the device of the embodiment of the application can be combined, divided and deleted according to actual needs.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be substantially or partially implemented in the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a terminal, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application.
While the invention has been described with reference to specific embodiments, the scope of the invention is not limited thereto, and those skilled in the art can easily conceive various equivalent modifications or substitutions within the technical scope of the invention. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims (6)
1. An electronic report generation method, comprising:
displaying a preset layout template to a user according to a preset layout instruction triggered by the user, enabling the user to edit and define a preset layout definition file according to the preset layout template as required, and acquiring the preset layout definition file, wherein the preset layout definition file comprises data source configuration information and report form layout information, and the data source configuration information comprises uniform resource locator information and data type information;
acquiring a report data source according to the uniform resource locator information;
determining an analysis rule according to the data type information;
analyzing the report data source according to the determined analysis rule to obtain report data;
generating a report template according to the report layout information;
analyzing the report layout information to obtain a preset layout component in the report layout information;
acquiring type information of an electronic report to be generated selected by a user;
based on the report data, selecting an application programming interface corresponding to the preset layout component to generate a report component object according to the type information of the electronic report to be generated;
filling the report component object in the report template to generate an electronic report;
selecting an application programming interface corresponding to the preset layout component to generate a report component object according to the type information of the electronic report to be generated based on the report data, wherein the generating of the report component object comprises the following steps:
determining the application programming interface category corresponding to the type information of the electronic report to be generated selected by the user in the Apache POI;
determining an application programming interface corresponding to the preset layout component according to the determined application programming interface type; and
and calling data information in the report data according to an application programming interface corresponding to the preset layout component to generate a report component object.
2. The electronic report generation method according to claim 1, further comprising, after parsing the report data source according to the determined parsing rule to obtain report data:
monitoring the analysis of the report data source according to the determined analysis rule to obtain an analysis process corresponding to the report data;
judging whether an alarm event triggering a preset alarm condition occurs in the analysis process;
and if an alarm event triggering the preset alarm condition occurs, marking data corresponding to the alarm event.
3. An electronic report generation apparatus, comprising:
the file acquisition unit is used for displaying a preset layout template to a user according to a preset layout instruction triggered by the user, enabling the user to edit and define a preset layout definition file according to the preset layout template as required, and acquiring the preset layout definition file, wherein the preset layout definition file comprises data source configuration information and report form layout information, and the data source configuration information comprises uniform resource locator information and data type information;
the data source acquisition subunit is used for acquiring a report data source according to the uniform resource locator information;
a rule determining subunit, configured to determine an analysis rule according to the data type information;
the data analysis subunit is used for analyzing the report data source according to the determined analysis rule to acquire report data;
the generating unit is used for generating a report template according to the report layout information;
the analysis acquisition unit is used for analyzing the report layout information to acquire a preset layout component in the report layout information;
the type acquisition unit is used for acquiring the type information of the electronic report to be generated selected by the user;
the object generating unit is used for selecting an application programming interface corresponding to the preset layout component to generate a report component object according to the type information of the electronic report to be generated based on the report data;
the filling generation unit is used for filling the report component object in the report template to generate an electronic report;
wherein the object generation unit comprises:
the category determining subunit is used for determining the application programming interface category corresponding to the type information of the electronic report to be generated selected by the user in the Apache POI;
the interface determining subunit is used for determining an application programming interface corresponding to the preset layout component according to the determined application programming interface type; and
and the object generation subunit is used for calling the data information in the report data according to the application programming interface corresponding to the preset layout component so as to generate a report component object.
4. An electronic report generation apparatus according to claim 3, characterized by further comprising:
the monitoring acquisition subunit is used for monitoring the analysis process of analyzing the report data source according to the determined analysis rule so as to acquire the corresponding report data;
an event judging subunit, configured to judge whether an alarm event triggering a preset alarm condition occurs in the parsing process;
and the data marking subunit is used for marking the data corresponding to the alarm event if the alarm event triggering the preset alarm condition occurs.
5. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the electronic report generating method according to any of claims 1 to 2 when executing the computer program.
6. A storage medium storing a computer program comprising program instructions which, when executed by a processor, cause the processor to perform the electronic report generating method according to any one of claims 1-2.
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711458911.9A CN107977351B (en) | 2017-12-28 | 2017-12-28 | Electronic report generation method and device, computer equipment and storage medium |
PCT/CN2018/075046 WO2019127844A1 (en) | 2017-12-28 | 2018-02-02 | Method and device for generating electronic report, computer equipment, and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711458911.9A CN107977351B (en) | 2017-12-28 | 2017-12-28 | Electronic report generation method and device, computer equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN107977351A CN107977351A (en) | 2018-05-01 |
CN107977351B true CN107977351B (en) | 2021-01-15 |
Family
ID=62008159
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201711458911.9A Active CN107977351B (en) | 2017-12-28 | 2017-12-28 | Electronic report generation method and device, computer equipment and storage medium |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN107977351B (en) |
WO (1) | WO2019127844A1 (en) |
Families Citing this family (19)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108874760B (en) * | 2018-05-23 | 2023-08-11 | 中国平安人寿保险股份有限公司 | Report file generation method, report file generation device, computer equipment and storage medium |
CN109325020A (en) * | 2018-08-20 | 2019-02-12 | 中国平安人寿保险股份有限公司 | Small sample application method, device, computer equipment and storage medium |
CN109491743A (en) * | 2018-11-05 | 2019-03-19 | 上海鋆创信息技术有限公司 | Visual Report Forms generation method, device, electronic equipment and storage medium |
CN109800402B (en) * | 2018-12-28 | 2023-08-08 | 广州明珞汽车装备有限公司 | Equipment information processing method and system for process simulation |
CN110188332B (en) * | 2019-04-18 | 2024-05-14 | 平安科技(深圳)有限公司 | Seat information table generation method, apparatus, computer device and storage medium |
CN112329413B (en) * | 2019-08-02 | 2024-07-02 | 阿里巴巴集团控股有限公司 | Template building method, file generating method, template system, template device and computer equipment |
CN110516218B (en) * | 2019-08-21 | 2023-10-10 | 深圳证券交易所 | Method for generating table, terminal and computer readable storage medium |
CN111126019B (en) * | 2019-11-28 | 2024-01-05 | 泰康保险集团股份有限公司 | Report generation method and device based on mode customization and electronic equipment |
CN111107401A (en) * | 2019-12-11 | 2020-05-05 | 北京明略软件系统有限公司 | Demonstration large screen customization method and device, computer equipment and readable storage medium |
CN111222310A (en) * | 2019-12-23 | 2020-06-02 | 福建亿能达信息技术股份有限公司 | Method and system for inputting and displaying irregular form |
CN111552688A (en) * | 2020-03-18 | 2020-08-18 | 北京达佳互联信息技术有限公司 | Data export method and device and electronic equipment |
CN112115691A (en) * | 2020-08-25 | 2020-12-22 | 上海乾臻信息科技有限公司 | Report generation method and device |
CN112818043A (en) * | 2021-01-26 | 2021-05-18 | 四川天翼网络服务有限公司 | Data source report generation method based on JSON self-description |
CN112883698B (en) * | 2021-03-22 | 2024-02-06 | 京东科技控股股份有限公司 | Chart generation method, apparatus, computer device and storage medium |
CN113591448B (en) * | 2021-08-03 | 2024-06-18 | 京东科技控股股份有限公司 | Report generation method, device and storage medium |
CN113778944A (en) * | 2021-08-25 | 2021-12-10 | 上海派森诺医学检验所有限公司 | Analysis report generation method and device and electronic equipment |
CN114139514A (en) * | 2022-02-08 | 2022-03-04 | 四川信用通数字科技股份有限公司 | Intelligent report generation method and device and computer storage medium |
CN114817267A (en) * | 2022-05-16 | 2022-07-29 | 通联支付网络服务股份有限公司 | Method, apparatus and medium for generating data report |
CN116757169B (en) * | 2023-08-11 | 2023-12-01 | 山东高速信息集团有限公司 | Method, equipment and medium for generating highway maintenance metering payment report |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101620591A (en) * | 2009-08-12 | 2010-01-06 | 国网电力科学研究院 | Method for designing module report form layout based on cell mode |
CN104281447A (en) * | 2014-09-01 | 2015-01-14 | 国家电网公司 | Report form fast generating and issuing system and method |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103020088A (en) * | 2011-09-27 | 2013-04-03 | 腾讯科技(深圳)有限公司 | Data processing device and method |
US9514118B2 (en) * | 2014-06-18 | 2016-12-06 | Yokogawa Electric Corporation | Method, system and computer program for generating electronic checklists |
CN106469140A (en) * | 2015-08-17 | 2017-03-01 | 朗新科技股份有限公司 | A kind of report generating system and its method |
CN105279228A (en) * | 2015-09-14 | 2016-01-27 | 深圳市永兴元科技有限公司 | Report processing method and device based on extensible markup language |
CN106372048A (en) * | 2016-08-30 | 2017-02-01 | 北京北信源软件股份有限公司 | Report generation system and report generation method |
-
2017
- 2017-12-28 CN CN201711458911.9A patent/CN107977351B/en active Active
-
2018
- 2018-02-02 WO PCT/CN2018/075046 patent/WO2019127844A1/en active Application Filing
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101620591A (en) * | 2009-08-12 | 2010-01-06 | 国网电力科学研究院 | Method for designing module report form layout based on cell mode |
CN104281447A (en) * | 2014-09-01 | 2015-01-14 | 国家电网公司 | Report form fast generating and issuing system and method |
Also Published As
Publication number | Publication date |
---|---|
WO2019127844A1 (en) | 2019-07-04 |
CN107977351A (en) | 2018-05-01 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107977351B (en) | Electronic report generation method and device, computer equipment and storage medium | |
CN109901834B (en) | Document page generation method, device, computer equipment and storage medium | |
CN108804159B (en) | Javascript module loading method and preprocessing method and device thereof, and computer equipment | |
CN110647320A (en) | Project framework construction method and device, computer equipment and storage medium | |
CN108415804B (en) | Method for acquiring information, terminal device and computer readable storage medium | |
CN111061464B (en) | Analysis code generation method, device, equipment and storage medium | |
CN110647471B (en) | Interface test case generation method, electronic device and storage medium | |
CN105786455B (en) | Data processing method and device and terminal | |
CN109460546A (en) | List generation method, device and electronic equipment | |
CN112765023A (en) | Test case generation method and device | |
CN112328259A (en) | Compiling time length processing method and device | |
CN113760729A (en) | Code detection method and device | |
US9571557B2 (en) | Script caching method and information processing device utilizing the same | |
CN113535587A (en) | Target application detection method and device and computer equipment | |
JP6505849B2 (en) | Generation of element identifier | |
CN111435326A (en) | Method and device for analyzing crash logs | |
CN113296752A (en) | Method, system, device and storage medium for generating API document | |
CN115809056A (en) | Component multiplexing implementation method and device, terminal equipment and readable storage medium | |
CN116185825A (en) | Front-end self-test method, front-end device, and computer-readable storage medium | |
CN114296793A (en) | Anti-obfuscation method and device for obfuscated codes, readable medium and electronic device | |
EP3785777B1 (en) | Information processing system, information processing method, and program for development apparatus | |
US11372638B2 (en) | Automated dependency detection and response | |
CN114691527A (en) | Unit test case generation method, apparatus, device, medium, and program product | |
CN114036421A (en) | Method, device and computer equipment for displaying HTML5 page response time | |
CN114201215A (en) | Interface document generation method and device, electronic equipment and storage 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 |