Universal report generation method and device

文档序号:1185108 发布日期:2020-09-22 浏览:11次 中文

阅读说明:本技术 一种通用报表生成方法及装置 (Universal report generation method and device ) 是由 刘浩 于 2020-06-12 设计创作,主要内容包括:本发明实施例提供了一种通用报表生成方法及装置,该方法包括获取表格配置信息,根据数据源格式,读取数据源格式对应的数据源中的数据,形成二维业务数据,确定表格合并信息是否包括合并行列号,若是,则根据合并行列号,对二维业务数据对应的二维数据位图进行行压缩和/或列压缩,确定出HTML表格模板,将二维业务数据和表格描述信息填充到HTML表格模板中,生成报表,而无需提前定制报表模板,也不限定某种特定的报表,只需要通过简单的配置即可生成不同格式的报表,从而可以满足不同使用场景的需求,提高了报表的通用性,并可以解决现有技术中报表模板通用性不强、使用场景有局限性的问题。(The embodiment of the invention provides a method and a device for generating a universal report, wherein the method comprises the steps of acquiring form configuration information, reading data in a data source corresponding to a data source format according to the data source format to form two-dimensional service data, determining whether form combination information comprises a combination column number or not, if so, performing row compression and/or column compression on a two-dimensional data bitmap corresponding to the two-dimensional service data according to the combination column number to determine an HTML form template, filling the two-dimensional service data and form description information into the HTML form template to generate the report without customizing the form template in advance or limiting a certain specific report, and generating the reports with different formats only through simple configuration, so that the requirements of different use scenes can be met, the universality of the report is improved, and the problems that the universality of the form template in the prior art is not strong, the, The use scenario has a problem of limitation.)

1. A method for generating a universal report is characterized by comprising the following steps:

acquiring form configuration information, wherein the form configuration information comprises a data source format, form description information and form merging information;

reading data in a data source corresponding to the data source format according to the data source format to form two-dimensional service data;

determining whether the table merge information includes a merge column number;

if so, performing row compression and/or column compression on a two-dimensional data bitmap corresponding to the two-dimensional service data according to the combined parallel column number to determine an HTML table template;

and filling the two-dimensional service data and the form description information into the HTML form template to generate a report.

2. The method of claim 1, wherein the method further comprises:

and when the table merging information does not comprise the merging parallel column number, determining the HTML table template according to the two-dimensional service data.

3. The method of claim 1, wherein the performing row compression and/or column compression on the two-dimensional table of the two-dimensional service data according to the merged column number to determine an HTML table template comprises:

generating a two-dimensional data bitmap and a two-dimensional direction bitmap corresponding to the two-dimensional data bitmap in advance, setting a data value of the two-dimensional data bitmap to be 1 and setting a direction value of the two-dimensional direction bitmap to be null; the two-dimensional data bitmap, the two-dimensional direction bitmap and the two-dimensional service data have the same row number and column number correspondingly;

compressing the data value of each line in the two-dimensional data bitmap corresponding to the merged line number from right to left according to the two-dimensional service data and the merged line number in the merged row number, determining the two-dimensional data bitmap after row compression, and compressing the data value of each line in the two-dimensional data bitmap corresponding to the merged column number from bottom to top according to the two-dimensional service data and the merged column number in the merged row number, determining the two-dimensional data bitmap after row compression;

and determining the HTML table template according to the two-dimensional data bitmap after the row compression, the two-dimensional data bitmap after the column compression and the two-dimensional data bitmap without merged rows and columns.

4. The method according to claim 3, wherein the compressing the data value of each row in the two-dimensional data bitmap corresponding to the merged row number from right to left according to the two-dimensional service data and the merged row number in the merged column number to determine the two-dimensional data bitmap after row compression, and compressing the data value of each column in the two-dimensional data bitmap corresponding to the merged column number from bottom to top according to the two-dimensional service data and the merged column number in the merged column number to determine the two-dimensional data bitmap after column de-compression, comprises:

comparing the last data of each row in the two-dimensional service data corresponding to the merged row number with the previous data in sequence according to the merged row number and the two-dimensional data bitmap, if the last data is equal to the previous data, accumulating the data at the corresponding position of the two-dimensional data bitmap to the previous data, subtracting the data at the corresponding position from the data, determining the two-dimensional data bitmap after row compression, setting the direction value of the corresponding position of the row data after each time of equality ending as a first direction threshold value, and determining the two-dimensional direction bitmap after row compression;

comparing the last data of each column in the two-dimensional service data corresponding to the merged column number with the previous data in sequence according to the merged column number and the two-dimensional data bitmap, if the last data is equal to the previous data, accumulating the data at the position corresponding to the two-dimensional data bitmap to the previous data, subtracting the data at the corresponding position from the data, determining the two-dimensional data bitmap after column compression, setting the direction value of the position corresponding to the column data after each time of equality ending as a second direction threshold value, and determining the two-dimensional direction bitmap after column discharge compression;

and determining the compressed two-dimensional data bitmap according to the two-dimensional data bitmap after the row compression and the two-dimensional data bitmap after the column compression, and determining the compressed two-dimensional direction bitmap according to the two-dimensional direction bitmap after the row compression and the two-dimensional direction bitmap after the column compression.

5. The method of claim 4, wherein said determining the HTML table template from the two-dimensional data bitmap after the row compression, the two-dimensional data bitmap after the column compression, and the two-dimensional data bitmap without merged rows and columns comprises:

for any data of the compressed two-dimensional data bitmap, if the data is equal to 1, generating a standard cell at the corresponding position of the data;

if the data is less than 1, not processing;

if the data is larger than 1 and the direction value of the position corresponding to the data is a first direction threshold value, generating a row merging cell at the position corresponding to the data, and if the data is larger than 1 and the direction value of the position corresponding to the data is a second direction threshold value, generating a column merging cell at the position corresponding to the data;

and determining the HTML table template according to the standard cells, the row merging cells and the column merging cells.

6. The method of claim 1, wherein the table configuration information further comprises a relational operation expression;

filling the two-dimensional service data and the form description information into the HTML form template to generate a report, wherein the report comprises:

and filling the two-dimensional service data and the form description information into the HTML form template, determining form data which accords with the relational operation expression from the filled HTML form template according to the relational operation expression, marking the form data which accords with the relational operation expression, and generating the report.

7. The method of claim 6, wherein the relational operational expression includes a title name, a relational operator, and a preset data threshold;

the determining, according to the relational operation expression, table data conforming to the relational operation expression from the HTML table template after the filling, and marking the table data conforming to the relational operation expression, includes:

according to the title name, determining form data corresponding to the title name from the filled HTML form template;

and performing relational operation on each data in the table data and the preset data threshold value according to the relational operator, if the result is true, displaying the data with the true result according to a preset display format, and otherwise, not processing.

8. The method of any of claims 1 to 7, wherein the table configuration information further comprises a graphical parameter;

the step of filling the two-dimensional service data and the form description information into the HTML form template to generate a report includes:

filling the two-dimensional service data and the form description information into the HTML form template;

generating Scalable Vector Graphics (SVG) data corresponding to the graphics parameters according to the graphics parameters and the two-dimensional service data in the HTML form template corresponding to the graphics parameters;

and combining the SVG data and the filled HTML form template to generate the report.

9. A general report generation apparatus, comprising:

the device comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring form configuration information which comprises a data source format, form description information and form merging information;

the processing unit is used for reading data in a data source corresponding to the data source format according to the data source format to form two-dimensional service data; determining whether the table merge information includes a merge column number; if so, performing row compression and/or column compression on a two-dimensional data bitmap corresponding to the two-dimensional service data according to the combined parallel column number to determine an HTML table template; and filling the two-dimensional service data and the form description information into the HTML form template to generate a report.

10. A computing device, comprising:

a memory for storing a computer program;

a processor for calling a computer program stored in said memory and executing the method of any one of claims 1 to 8 in accordance with the obtained program.

11. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer-executable program for causing a computer to execute the method of any one of claims 1 to 8.

Technical Field

The embodiment of the invention relates to the field of financial technology (Fintech), in particular to a method and a device for generating a universal report.

Background

With the development of computer technology, more and more technologies are applied in the financial field, and the traditional financial industry is gradually changing to financial technology, but due to the requirements of the financial industry on safety and real-time performance, higher requirements are also put forward on the technologies. In the financial field, each business department needs a report to analyze and count the business data, and different business departments have different levels of requirements on the report, so developers need to develop different automatic report templates for different business departments.

The existing automatic reporting system is developed aiming at specific scenes, such as monitoring automatic service or counting the running state of a certain system, and the data acquisition, the report conversion and the report landing of the automatic reporting system are integrated into a whole. However, the report conversion of the automatic report system needs to configure a report template in advance, the conversion process is actually filling in the template, and if a new report needs to be developed, a new template needs to be configured.

In summary, a general report generation method is needed to solve the problems of the prior art that the report template is not highly versatile and the usage scenario is limited.

Disclosure of Invention

The embodiment of the invention provides a method and a device for generating a universal report, which are used for solving the problems of low universality and limited use scene of a report template in the prior art.

In a first aspect, an embodiment of the present invention provides a method for generating a general report, including:

acquiring form configuration information, wherein the form configuration information comprises a data source format, form description information and form merging information;

reading data in a data source corresponding to the data source format according to the data source format to form two-dimensional service data;

determining whether the table merge information includes a merge column number;

if so, performing row compression and/or column compression on a two-dimensional data bitmap corresponding to the two-dimensional service data according to the combined parallel column number to determine an HTML table template;

and filling the two-dimensional service data and the form description information into the HTML form template to generate a report.

In the technical scheme, the two-dimensional service data corresponding to the data source format can be automatically determined according to the data source format, so that a common data source with a certain format can be butted, whether the table merging information comprises a parallel column number or not is determined, when the table merging information is determined to comprise the parallel column number, different row compression and/or column compression can be carried out on a two-dimensional data bitmap corresponding to the two-dimensional service data according to different configurations of the parallel column number so as to determine HTML table templates with different formats, so that the specific table template is not limited, the flexibility of generating the HTML table template is improved, then the two-dimensional service data and the table description information are filled into the HTML table template with the corresponding format, a report with the corresponding format can be generated without customizing the report template in advance and limiting a certain specific report, the report forms with different formats can be generated only through simple configuration, so that the requirements of different use scenes can be met, the universality of the report forms is improved, and the problems that the universality of a report form template is not strong and the use scenes are limited in the prior art can be solved.

Optionally, the method further comprises:

and when the table merging information does not comprise the merging parallel column number, determining the HTML table template according to the two-dimensional service data.

According to the technical scheme, when the table merging information does not include the merging parallel column number, the HTML table template can be directly determined according to the two-dimensional service data, and the method is simple and convenient.

Optionally, the performing row compression and/or column compression on the two-dimensional table of the two-dimensional service data according to the combined parallel column number to determine an HTML table template includes:

generating a two-dimensional data bitmap and a two-dimensional direction bitmap corresponding to the two-dimensional data bitmap in advance, setting a data value of the two-dimensional data bitmap to be 1 and setting a direction value of the two-dimensional direction bitmap to be null; the two-dimensional data bitmap, the two-dimensional direction bitmap and the two-dimensional service data have the same row number and column number correspondingly;

compressing the data value of each line in the two-dimensional data bitmap corresponding to the merged line number from right to left according to the two-dimensional service data and the merged line number in the merged row number, determining the two-dimensional data bitmap after row compression, and compressing the data value of each line in the two-dimensional data bitmap corresponding to the merged column number from bottom to top according to the two-dimensional service data and the merged column number in the merged row number, determining the two-dimensional data bitmap after row compression;

and determining the HTML table template according to the two-dimensional data bitmap after the row compression, the two-dimensional data bitmap after the column compression and the two-dimensional data bitmap without merged rows and columns.

In the technical scheme, when the table merging information is determined to comprise the merging column number, the data value of each row in the two-dimensional data bitmap corresponding to the merging column number is compressed, or the data value of each column in the two-dimensional data bitmap corresponding to the merging column number is compressed, the HTML table template is determined according to the two-dimensional data bitmap after row compression, the two-dimensional data bitmap after column compression and the two-dimensional data bitmap without merging columns and rows, the HTML table templates with different formats can be generated through the simple configuration, and the requirements of different use scenes can be met.

Optionally, the compressing, according to the two-dimensional service data and a merged row number in the merged row number, data values of each row in the two-dimensional data bitmap corresponding to the merged row number from right to left to determine the two-dimensional data bitmap after row compression, and compressing, according to the two-dimensional service data and the merged column number in the merged row number, data values of each column in the two-dimensional data bitmap corresponding to the merged column number from bottom to top to determine the two-dimensional data bitmap after column dequeue compression, includes:

comparing the last data of each row in the two-dimensional service data corresponding to the merged row number with the previous data in sequence according to the merged row number and the two-dimensional data bitmap, if the last data is equal to the previous data, accumulating the data at the corresponding position of the two-dimensional data bitmap to the previous data, subtracting the data at the corresponding position from the data, determining the two-dimensional data bitmap after row compression, setting the direction value of the corresponding position of the row data after each time of equality ending as a first direction threshold value, and determining the two-dimensional direction bitmap after row compression;

comparing the last data of each column in the two-dimensional service data corresponding to the merged column number with the previous data in sequence according to the merged column number and the two-dimensional data bitmap, if the last data is equal to the previous data, accumulating the data at the position corresponding to the two-dimensional data bitmap to the previous data, subtracting the data at the corresponding position from the data, determining the two-dimensional data bitmap after column compression, setting the direction value of the position corresponding to the column data after each time of equality ending as a second direction threshold value, and determining the two-dimensional direction bitmap after column discharge compression;

and determining the compressed two-dimensional data bitmap according to the two-dimensional data bitmap after the row compression and the two-dimensional data bitmap after the column compression, and determining the compressed two-dimensional direction bitmap according to the two-dimensional direction bitmap after the row compression and the two-dimensional direction bitmap after the column compression.

In the technical scheme, the compressed two-dimensional data bitmap can be determined by processing the data values of the rows or the columns in the two-dimensional data bitmap according to the preset rule, and the direction value of the corresponding position of the row or column data which is equal to the end value every time is set as the first direction threshold value or the second direction threshold value, so that the compressed two-dimensional direction bitmap can be determined, and support is provided for determining the HTML table template of the final format.

Optionally, the determining the HTML table template according to the two-dimensional data bitmap after the row compression, the two-dimensional data bitmap after the column compression, and the two-dimensional data bitmap without merged rows and columns includes:

for any data of the compressed two-dimensional data bitmap, if the data is equal to 1, generating a standard cell at the corresponding position of the data;

if the data is less than 1, not processing;

if the data is larger than 1 and the direction value of the position corresponding to the data is a first direction threshold value, generating a row merging cell at the position corresponding to the data, and if the data is larger than 1 and the direction value of the position corresponding to the data is a second direction threshold value, generating a column merging cell at the position corresponding to the data;

and determining the HTML table template according to the standard cells, the row merging cells and the column merging cells.

In the above technical solution, for any data of the compressed two-dimensional data bitmap, if the data is equal to 1, a standard cell is generated at a corresponding position of the data, if the data is greater than 1 and it is determined that a direction value of the corresponding position of the data is a first direction threshold or a second direction threshold, a row or column merged cell is generated at the corresponding position of the data, and according to the standard cell, the row merged cell, and the column merged cell, an HTML form template of a final format can be determined, so that a form data form meeting a user requirement is presented to the user by using the HTML form template.

Optionally, the table configuration information further includes a relational operation expression;

filling the two-dimensional service data and the form description information into the HTML form template to generate a report, wherein the report comprises:

and filling the two-dimensional service data and the form description information into the HTML form template, determining form data which accords with the relational operation expression from the filled HTML form template according to the relational operation expression, marking the form data which accords with the relational operation expression, and generating the report.

In the technical scheme, the form data which accords with the relational operation expression is determined from the filled HTML form template according to the relational operation expression, and the form data which accords with the relational operation expression is marked to generate the report. Because various operational expressions are supported, the relational operational expressions can be used for screening and highlighting certain special data, and the effect of striking reminding can be achieved for the user, so that the user can conveniently perform corresponding processing, and the user experience is improved.

Optionally, the relational operation expression includes a title name, a relational operator, and a preset data threshold;

the determining, according to the relational operation expression, table data conforming to the relational operation expression from the HTML table template after the filling, and marking the table data conforming to the relational operation expression, includes:

according to the title name, determining form data corresponding to the title name from the filled HTML form template;

and performing relational operation on each data in the table data and the preset data threshold value according to the relational operator, if the result is true, displaying the data with the true result according to a preset display format, and otherwise, not processing.

According to the technical scheme, the form data corresponding to the title name is determined from the filled HTML form template according to the title name, each data in the form data and the preset data threshold value are subjected to relational operation according to the relational operator, the data with the true result can be displayed according to the preset display format, the effect of striking reminding is achieved, the data can be conveniently and visually displayed for a user, and therefore user experience is improved.

Optionally, the table configuration information further includes a graphic parameter;

the step of filling the two-dimensional service data and the form description information into the HTML form template to generate a report includes:

filling the two-dimensional service data and the form description information into the HTML form template;

generating Scalable Vector Graphics (SVG) data corresponding to the graphics parameters according to the graphics parameters and the two-dimensional service data in the HTML form template corresponding to the graphics parameters;

and combining the SVG data and the filled HTML form template to generate the report.

In the technical scheme, Scalable Vector Graphics (SVG) data corresponding to the graphics parameters are generated according to the graphics parameters and the two-dimensional service data in the HTML form template corresponding to the graphics parameters, and the SVG data and the filled HTML form template are combined to generate a report. The form of combining the charts is displayed for the user, so that the user can conveniently perform corresponding processing, the visual experience of the user is improved, and the automatic generation of the graphical report can be realized.

In a second aspect, an embodiment of the present invention further provides a general report generating device, including:

the device comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring form configuration information which comprises a data source format, form description information and form merging information;

the processing unit is used for reading data in a data source corresponding to the data source format according to the data source format to form two-dimensional service data; determining whether the table merge information includes a merge column number; if so, performing row compression and/or column compression on a two-dimensional data bitmap corresponding to the two-dimensional service data according to the combined parallel column number to determine an HTML table template; and filling the two-dimensional service data and the form description information into the HTML form template to generate a report.

Optionally, the processing unit is further configured to:

and when the table merging information does not comprise the merging parallel column number, determining the HTML table template according to the two-dimensional service data.

Optionally, the processing unit is specifically configured to:

generating a two-dimensional data bitmap and a two-dimensional direction bitmap corresponding to the two-dimensional data bitmap in advance, setting a data value of the two-dimensional data bitmap to be 1 and setting a direction value of the two-dimensional direction bitmap to be null; the two-dimensional data bitmap, the two-dimensional direction bitmap and the two-dimensional service data have the same row number and column number correspondingly;

compressing the data value of each line in the two-dimensional data bitmap corresponding to the merged line number from right to left according to the two-dimensional service data and the merged line number in the merged row number, determining the two-dimensional data bitmap after row compression, and compressing the data value of each line in the two-dimensional data bitmap corresponding to the merged column number from bottom to top according to the two-dimensional service data and the merged column number in the merged row number, determining the two-dimensional data bitmap after row compression;

and determining the HTML table template according to the two-dimensional data bitmap after the row compression, the two-dimensional data bitmap after the column compression and the two-dimensional data bitmap without merged rows and columns.

Optionally, the processing unit is specifically configured to:

comparing the last data of each row in the two-dimensional service data corresponding to the merged row number with the previous data in sequence according to the merged row number and the two-dimensional data bitmap, if the last data is equal to the previous data, accumulating the data at the corresponding position of the two-dimensional data bitmap to the previous data, subtracting the data at the corresponding position from the data, determining the two-dimensional data bitmap after row compression, setting the direction value of the corresponding position of the row data after each time of equality ending as a first direction threshold value, and determining the two-dimensional direction bitmap after row compression;

comparing the last data of each column in the two-dimensional service data corresponding to the merged column number with the previous data in sequence according to the merged column number and the two-dimensional data bitmap, if the last data is equal to the previous data, accumulating the data at the position corresponding to the two-dimensional data bitmap to the previous data, subtracting the data at the corresponding position from the data, determining the two-dimensional data bitmap after column compression, setting the direction value of the position corresponding to the column data after each time of equality ending as a second direction threshold value, and determining the two-dimensional direction bitmap after column discharge compression;

and determining the compressed two-dimensional data bitmap according to the two-dimensional data bitmap after the row compression and the two-dimensional data bitmap after the column compression, and determining the compressed two-dimensional direction bitmap according to the two-dimensional direction bitmap after the row compression and the two-dimensional direction bitmap after the column compression.

Optionally, the processing unit is specifically configured to:

for any data of the compressed two-dimensional data bitmap, if the data is equal to 1, generating a standard cell at the corresponding position of the data;

if the data is less than 1, not processing;

if the data is larger than 1 and the direction value of the position corresponding to the data is a first direction threshold value, generating a row merging cell at the position corresponding to the data, and if the data is larger than 1 and the direction value of the position corresponding to the data is a second direction threshold value, generating a column merging cell at the position corresponding to the data;

and determining the HTML table template according to the standard cells, the row merging cells and the column merging cells.

Optionally, the table configuration information further includes a relational operation expression;

the processing unit is specifically configured to:

and filling the two-dimensional service data and the form description information into the HTML form template, determining form data which accords with the relational operation expression from the filled HTML form template according to the relational operation expression, marking the form data which accords with the relational operation expression, and generating the report.

Optionally, the relational operation expression includes a title name, a relational operator, and a preset data threshold;

the processing unit is specifically configured to:

according to the title name, determining form data corresponding to the title name from the filled HTML form template;

and performing relational operation on each data in the table data and the preset data threshold value according to the relational operator, if the result is true, displaying the data with the true result according to a preset display format, and otherwise, not processing.

Optionally, the table configuration information further includes a graphic parameter;

the processing unit is specifically configured to:

filling the two-dimensional service data and the form description information into the HTML form template;

generating Scalable Vector Graphics (SVG) data corresponding to the graphics parameters according to the graphics parameters and the two-dimensional service data in the HTML form template corresponding to the graphics parameters;

and combining the SVG data and the filled HTML form template to generate the report.

In a third aspect, an embodiment of the present invention provides a computing device, including:

a memory for storing a computer program;

and the processor is used for calling the computer program stored in the memory and executing the general report generation method according to the obtained program.

In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, where a computer-executable program is stored, and the computer-executable program is configured to enable a computer to execute a general report generation method.

Drawings

In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, 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 diagram of a system architecture according to an embodiment of the present invention;

fig. 2 is a schematic flow chart of a method for generating a general report according to an embodiment of the present invention;

fig. 3 is a schematic diagram of row merging for data in the r-th row in the CSV table according to an embodiment of the present invention;

FIG. 4 is a diagram illustrating a highlight display of tabular data corresponding to relational operational expressions according to an embodiment of the present invention;

fig. 5 is a schematic structural diagram of a general report generating device according to an embodiment of the present invention.

Detailed Description

In order to make the objects, technical solutions and advantages of the present invention clearer, the present invention will be described in further detail with reference to the accompanying drawings, and it is apparent that the described embodiments are only a part of the embodiments of the present invention, not all of the embodiments. 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 invention.

Fig. 1 is a system architecture provided in an embodiment of the present invention. As shown in fig. 1, the system architecture may be a server 100 including a processor 110, a communication interface 120, and a memory 130.

The communication interface 120 is used for communicating with a terminal device, and transceiving information transmitted by the terminal device to implement communication.

The processor 110 is a control center of the server 100, connects various parts of the entire server 100 using various interfaces and lines, performs various functions of the server 100 and processes data by running or executing software programs and/or modules stored in the memory 130 and calling data stored in the memory 130. Alternatively, processor 110 may include one or more processing units.

The memory 130 may be used to store software programs and modules, and the processor 110 executes various functional applications and data processing by operating the software programs and modules stored in the memory 130. The memory 130 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function, and the like; the storage data area may store data created according to a business process, and the like. Further, the memory 130 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.

It should be noted that the structure shown in fig. 1 is only an example, and the embodiment of the present invention is not limited thereto.

Based on the above description, fig. 2 exemplarily shows a flow of a general report generating method according to an embodiment of the present invention, and the flow may be executed by a general report generating apparatus.

As shown in fig. 2, the process specifically includes:

in step 201, form configuration information is obtained.

In the embodiment of the present invention, the table configuration information may include a data source format, table description information, table merging information, a relational operation expression, and a graphic parameter. The data source format can be CSV, vertical line separator, Excel, and the like; the table description information can comprise a report title set by a user, a text description of the report and the like; the table merging information may include a merging and parallel column number configured by the user, an unconfigured merging and parallel column number, and the like; the relational operation expression can comprise a title name, a relational operator and a preset data threshold; the graphic parameters may be parameters for generating a line graph, a bar graph, a pie graph, and the like, and furthermore, the preset data threshold may be set according to the user's requirement.

It should be noted that a complete automatic report system generally requires at least four steps of data acquisition, report conversion, report landing, report display, and the like. However, different business systems have basically different data collection modes, such as client uploading, crawler capturing, program calculation, SQL export, shell and other scripting language export, and in order to make the report form of the present invention more versatile, the present invention can be embedded in any existing system, so the present invention does not involve a data collection module, and directly interfaces with the data source of the original system, and requires that the data source is a file with a certain format.

Step 202, reading data in a data source corresponding to the data source format according to the data source format to form two-dimensional service data.

In the embodiment of the invention, the data in the data source corresponding to the data source format is read according to the data source format, so that the two-dimensional service data corresponding to the data source format is formed. Specifically, data is initialized according to the settings of a user in a configuration file, and then a data source is read to a two-dimensional list according to an incoming data source file format. For example, list is L, and the number of rows M and the number of columns N of L are calculated.

It should be noted that the data source of the embodiment of the present invention is a data file with standard format M rows and N columns, and the data source may be directly derived from the database, or may be generated by two layers of M × N for loop.

Step 203, determine whether the table merging information includes a merging column number.

In the embodiment of the invention, before generating the HTML table template, whether the table merging information comprises a merging column number or not needs to be judged. When the table merging information is determined not to include the merging parallel serial number, determining an HTML table template according to the two-dimensional service data; and when the table merging information is determined to comprise a parallel column number, performing row compression and/or column compression on the two-dimensional data bitmap corresponding to the two-dimensional service data according to the parallel column number, and determining the HTML table template.

And 204, when the table merging information is determined to include the merging parallel column number, performing row compression and/or column compression on the two-dimensional data bitmap corresponding to the two-dimensional service data according to the merging parallel column number, and determining an HTML table template.

In the embodiment of the invention, in the process of generating the HTML table template by row compression and/or column compression of the two-dimensional data bitmap corresponding to the two-dimensional service data according to the combined column number in the table merging information, firstly, a two-dimensional data bitmap and a two-dimensional direction bitmap corresponding to the two-dimensional data bitmap are generated in advance, the data value of the two-dimensional data bitmap is set to be 1, and the direction value of the two-dimensional direction bitmap is set to be null; the method comprises the steps of generating a two-dimensional data bitmap, a two-dimensional direction bitmap and two-dimensional service data, wherein the number of rows and the number of columns of the two-dimensional data bitmap and the two-dimensional direction bitmap are the same correspondingly, then compressing the data value of each row in the two-dimensional data bitmap corresponding to a merging row number from right to left according to the two-dimensional service data and the merging row number in the merging row number, determining the two-dimensional data bitmap after row compression, compressing the data value of each column in the two-dimensional data bitmap corresponding to the merging column number from bottom to top according to the merging row number in the two-dimensional service data and the merging column number, determining the two-dimensional data bitmap after column compression, and then determining the HTML table template according to the two-dimensional data bitmap after row compression, the two-dimensional data bitmap after column compression and the.

Specifically, according to a merging row number and a two-dimensional data bitmap in table row-column merging information, comparing last data of each row in two-dimensional service data corresponding to the merging row number with previous data in sequence, if the last data is equal to the previous data, accumulating data at a position corresponding to the two-dimensional data bitmap to the previous data, subtracting self data from the data at the corresponding position, determining a two-dimensional data bitmap after row compression, setting a direction value of a position corresponding to row data which is equal to each end as a first direction threshold value, determining a two-dimensional direction bitmap after row compression, comparing the last data of each column in the two-dimensional service data corresponding to the merging column number with the previous data in sequence according to the merging column number and the two-dimensional data bitmap in the table row-column merging information, and if the last data is equal to the previous data, accumulating data at a position corresponding to the two-dimensional data bitmap to the previous data, subtracting the data of the corresponding position from the data of the corresponding position, determining a two-dimensional data bitmap after the column compression, setting the direction value of the corresponding position of the column data which is equal to each end as a second direction threshold value, determining a two-dimensional direction bitmap after the column compression, then determining the two-dimensional data bitmap after the compression according to the two-dimensional data bitmap after the row compression and the two-dimensional data bitmap after the column compression, determining the two-dimensional direction bitmap after the compression according to the two-dimensional data bitmap after the row compression and the two-dimensional direction bitmap after the column compression, then aiming at any data of the two-dimensional data bitmap after the compression, if the data is equal to 1, generating a standard cell at the corresponding position of the data, if the data is less than 1, not processing, if the data is greater than 1 and the direction value of the corresponding position of the data is the first direction threshold value, generating a row merging cell at the corresponding position of the data and the number of the row merging cells is equal to the data, and if the data is greater than 1 and the direction value of the corresponding position of the data is a second direction threshold, generating a column merging cell at the corresponding position of the data, wherein the number of the column merged cells is equal to the data value, and determining an HTML table template according to the standard cells, the row merging cells and the column merging cells, namely performing different row compression and/or column compression on a two-dimensional data bitmap corresponding to the two-dimensional service data according to different configurations of table merging information, so as to determine HTML table templates with different formats corresponding to the table merging information, wherein the specific table templates are not limited, and thus the flexibility of generating the HTML table template is improved. The two-dimensional data bitmap and the two-dimensional direction bitmap are corresponding to the same number of rows and columns of the two-dimensional service data; the first direction threshold and the second direction threshold may be set empirically.

For example, using the PyH module (the module used to generate HTML content in Python) to define a blank HTML (hypertext Markup Language) page, the body of the report is an HTML table, and the user is allowed to set a title, a caption, and so on by configuration before rendering the table. If the table is the simplest table, no merging cells exist, the table is simple, an PyH module is directly used for generating an M × N table, and if the table is a table with merged rows and columns, a user only needs to configure combinable row and column numbers, for example, a purchase-sales-storage table shown in table 1, which relates to multiple-combination parallel and multiple-combination parallel, and only needs to configure the combined row number and the combined column number in the parameters of the merged row and column, so that a corresponding report can be generated.

TABLE 1

Figure BDA0002536531970000141

In this case, taking the CSV format as an example, as can be seen from table 1, the data format of the first row is: entering, exiting and exiting; the data formats of the first and second columns are:

quarterly, month;

first quarter, month;

first quarter, february;

first quarter, march;

quarterly, april;

second quarter, May;

…。

and generating the HTML template after combination according to the configured combinable parallel column number. First, an M × N two-dimensional data bitmap (bitmap, which may also be referred to as a dot-matrix) is generated by initialization, the data values are all 1, and then an M × N two-dimensional direction bitmap is generated, and all the direction values are null. When the two-dimensional service data are subjected to line merging, all parallel line numbers R in the configuration are sequentially taken out, data of L [ R-1] lines are taken out, the data are a 1 x N one-dimensional array, the last bit data of the array are sequentially compared with the previous bit data, if the data are equal, the data x at the same position of the two-dimensional data bitmap are transmitted to the data at the left bit position in the two-dimensional data bitmap, namely the value of the position on the two-dimensional data bitmap is reduced by x, the value at the left position is added by x, the data of the L [ R-1] lines are operated in a circulating mode, meanwhile, the last continuous equal position is set as R at the same position of the two-dimensional data bitmap, and the R represents the transverse direction. This process can be described as compressing the data in R rows from right to left, recording the number of compressed grids in the final position, with the direction of compression being R. The row merging form of the data of the r-th row in the CSV table can be as shown in fig. 3, where D1, D2, and D … D5 are assumed data contents of the r-th row, and are compared with the previous data in sequence from the last bit of data of the row, i.e. the last bit D5 of the row is compared with the previous bit D2 and found to be unequal, no processing is performed, proceeding sequentially, when proceeding to D4, it is found that D4 is equal to the previous bit data D4, data 1 at the same position of the two-dimensional data bitmap is transferred to data 1 one bit to the left in the two-dimensional data bitmap, thus, the data 1 at the same position of the two-dimensional data bitmap is changed into 0, the data 1 at the left bit is changed into 2, and the operation is circulated until the data operation of the row is finished, the meaning in which the data value of the two-dimensional data bitmap is set to 1 means that the number of cells to be merged is recorded at the final position every time equality ends. After the data operation of the r-th row is completed, the data bitmap finally generated by the r-th row may be as shown in table 2, and the direction bitmap finally generated by the r-th row may be as shown in table 3.

TABLE 2

1 2 0 1 3 0 0 1 1

TABLE 3

Air conditioner R Air conditioner Air conditioner R Air conditioner Air conditioner Air conditioner Air conditioner

Based on the same operation, all parallel column numbers C are taken out, compressed from bottom to top, and the number of compressed grids is recorded at the final position, wherein the compression direction is C and represents the longitudinal direction. After all the operations of merging the row numbers and the column numbers are completed, the final two-dimensional data bitmap and the two-dimensional direction bitmap are generated. Circulating the two-dimensional data bitmap, and if the data at the position is 1, directly generating a standard cell by td (an PyH module generates a cell command and is also an HTML cell label); if the data at the position is 0, no operation is performed; if the data at the position is larger than 1, assuming to be X, simultaneously checking the direction value of the same position on the two-dimensional direction bitmap, if the data is R, td generates a row merging cell, and rows equals X, namely the number of the row merging cells equals to the data X; if the data at this position is greater than 1, let X, and the direction value at the same position on the two-dimensional direction bitmap is checked at the same time, and if C, td generates a column-merging cell, colspan ═ X, i.e., the number of cells for column merging is equal to data X. After the entire M × N loop is completed, the HTML form template in the final format is generated. Wherein, rowspan is the rowspan attribute of HTML label, colspan is the colspan attribute of HTML label.

Step 205, filling the two-dimensional service data and the form description information into the HTML form template, and generating a report.

In the embodiment of the invention, two-dimensional service data and form description information are filled into an HTML form template, form data corresponding to a title name are determined from the filled HTML form template according to the title name, each data in the form data is subjected to relational operation with a preset data threshold value according to a relational operator, if the result is true, the data with the true result is displayed according to a preset display format, otherwise, the data is not processed, and a report is generated; or filling the two-dimensional service data and the form description information into an HTML form template, generating Scalable Vector Graphics (SVG) data corresponding to the graphics parameters according to the graphics parameters and the two-dimensional service data in the HTML form template corresponding to the graphics parameters, and combining the SVG data with the filled HTML form template to generate a report.

Specifically, the format of the configuration expression is key 1: relation operator 1: value 1; key 2: relation operator 2: value 2; … are provided. Wherein key is title name, value is data content, relational operator support ═! Here, the term "<", and the like. As shown in fig. 4, all keys are taken out to form a list keyList, all operators are taken out to form a list optionList, all values are taken out to form a list valueList, the keyList is operated circularly, all data in the key column are taken out in sequence, the data content and the value corresponding to the key are subjected to the relational operation according to the operation set by the relational operators, and if the result is true, the data in the data bit is displayed according to the specified highlight format. And then filling the data in the L into an HTML template, highlighting the marked cells, namely, the circular data list L and the two-dimensional data bitmap, sequentially taking out the row and column data in the L, writing the row and column data in the L into the HTML template generated by the two-dimensional data bitmap, and setting a highlighted attribute for the cells at the highlighted position. Generating corresponding graphic SVG data (Scalable Vector Graphics) according to configured graphic parameters, wherein the graphic support generates a line graph, a bar graph, a pie graph and the like, mainly using a pygal module of python to generate SVG format data, configuring a data source name of an X axis and a data source name (a plurality of pieces can be) of a Y axis by a user, corresponding to a column name of data in a table by the data source name, and finding X, Y a column number of the axis in the table according to the data source name. Then, the data in the column is extracted from the L to obtain the data List of the X axis and the Y axis. And then calling parameters of corresponding graphics of the pygal module, transmitting the data List of the X, Y axis, and rendering the data in the SVG format. And finally, landing the HTML file, and simultaneously adding the content of the SVG data into an HTML file body, wherein the data in the SVG format can be directly displayed in the HTML, so that the SVG data can be directly added at the tail of the HTML data body, and the HTML is finally written into the file. In addition, when a graphical report is automatically generated according to an X, Y axis data source and a graphical name configured by a user, SVG data is generated by using a pygal module, and graphics in a picture format can be directly generated through matplotlib, plotly and the like, and then the graphics are embedded into HTML to fall to the ground, so that the purpose of automatically generating the graphical report is achieved.

The above embodiment shows that, by automatically determining the two-dimensional service data corresponding to the data source format according to the data source format, it is possible to interface a common data source with a certain format, then determine whether the table merging information includes a merging and parallel column number, and when it is determined that the table merging information includes a merging and parallel column number, perform different row compression and/or column compression on the two-dimensional data bitmap corresponding to the two-dimensional service data according to different configurations of the merging and parallel column numbers, so as to determine HTML table templates with different formats, so as not to limit a specific table template, thereby improving the flexibility of generating the HTML table template, and then fill the two-dimensional service data and the table description information into the HTML table template with a corresponding format, thereby generating a report with a corresponding format without customizing the report template in advance and limiting a specific report, the report forms with different formats can be generated only through simple configuration, so that the requirements of different use scenes can be met, the universality of the report forms is improved, and the problems that the universality of a report form template is not strong and the use scenes are limited in the prior art can be solved.

Based on the same technical concept, fig. 5 exemplarily shows a general report generation apparatus provided in an embodiment of the present invention, and the apparatus can execute a flow of a general report generation method.

As shown in fig. 5, the apparatus includes:

an obtaining unit 501, configured to obtain table configuration information, where the table configuration information includes a data source format, table description information, and table merging information;

a processing unit 502, configured to read data in a data source corresponding to the data source format according to the data source format to form two-dimensional service data; determining whether the table merge information includes a merge column number; if so, performing row compression and/or column compression on a two-dimensional data bitmap corresponding to the two-dimensional service data according to the combined parallel column number to determine an HTML table template; and filling the two-dimensional service data and the form description information into the HTML form template to generate a report.

Optionally, the processing unit 502 is further configured to:

and when the table merging information does not comprise the merging parallel column number, determining the HTML table template according to the two-dimensional service data.

Optionally, the processing unit 502 is specifically configured to:

generating a two-dimensional data bitmap and a two-dimensional direction bitmap corresponding to the two-dimensional data bitmap in advance, setting a data value of the two-dimensional data bitmap to be 1 and setting a direction value of the two-dimensional direction bitmap to be null; the two-dimensional data bitmap, the two-dimensional direction bitmap and the two-dimensional service data have the same row number and column number correspondingly;

compressing the data value of each line in the two-dimensional data bitmap corresponding to the merged line number from right to left according to the two-dimensional service data and the merged line number in the merged row number, determining the two-dimensional data bitmap after row compression, and compressing the data value of each line in the two-dimensional data bitmap corresponding to the merged column number from bottom to top according to the two-dimensional service data and the merged column number in the merged row number, determining the two-dimensional data bitmap after row compression;

and determining the HTML table template according to the two-dimensional data bitmap after the row compression, the two-dimensional data bitmap after the column compression and the two-dimensional data bitmap without merged rows and columns.

Optionally, the processing unit 502 is specifically configured to:

comparing the last data of each row in the two-dimensional service data corresponding to the merged row number with the previous data in sequence according to the merged row number and the two-dimensional data bitmap, if the last data is equal to the previous data, accumulating the data at the corresponding position of the two-dimensional data bitmap to the previous data, subtracting the data at the corresponding position from the data, determining the two-dimensional data bitmap after row compression, setting the direction value of the corresponding position of the row data after each time of equality ending as a first direction threshold value, and determining the two-dimensional direction bitmap after row compression;

comparing the last data of each column in the two-dimensional service data corresponding to the merged column number with the previous data in sequence according to the merged column number and the two-dimensional data bitmap, if the last data is equal to the previous data, accumulating the data at the position corresponding to the two-dimensional data bitmap to the previous data, subtracting the data at the corresponding position from the data, determining the two-dimensional data bitmap after column compression, setting the direction value of the position corresponding to the column data after each time of equality ending as a second direction threshold value, and determining the two-dimensional direction bitmap after column discharge compression;

and determining the compressed two-dimensional data bitmap according to the two-dimensional data bitmap after the row compression and the two-dimensional data bitmap after the column compression, and determining the compressed two-dimensional direction bitmap according to the two-dimensional direction bitmap after the row compression and the two-dimensional direction bitmap after the column compression.

Optionally, the processing unit 502 is specifically configured to:

for any data of the compressed two-dimensional data bitmap, if the data is equal to 1, generating a standard cell at the corresponding position of the data;

if the data is less than 1, not processing;

if the data is larger than 1 and the direction value of the position corresponding to the data is a first direction threshold value, generating a row merging cell at the position corresponding to the data, and if the data is larger than 1 and the direction value of the position corresponding to the data is a second direction threshold value, generating a column merging cell at the position corresponding to the data;

and determining the HTML table template according to the standard cells, the row merging cells and the column merging cells.

Optionally, the table configuration information further includes a relational operation expression;

the processing unit 502 is specifically configured to:

and filling the two-dimensional service data and the form description information into the HTML form template, determining form data which accords with the relational operation expression from the filled HTML form template according to the relational operation expression, marking the form data which accords with the relational operation expression, and generating the report.

Optionally, the relational operation expression includes a title name, a relational operator, and a preset data threshold;

the processing unit 502 is specifically configured to:

according to the title name, determining form data corresponding to the title name from the filled HTML form template;

and performing relational operation on each data in the table data and the preset data threshold value according to the relational operator, if the result is true, displaying the data with the true result according to a preset display format, and otherwise, not processing.

Optionally, the table configuration information further includes a graphic parameter;

the processing unit 502 is specifically configured to:

filling the two-dimensional service data and the form description information into the HTML form template;

generating Scalable Vector Graphics (SVG) data corresponding to the graphics parameters according to the graphics parameters and the two-dimensional service data in the HTML form template corresponding to the graphics parameters;

and combining the SVG data and the filled HTML form template to generate the report.

Based on the same technical concept, an embodiment of the present invention provides a computing device, including:

a memory for storing a computer program;

and the processor is used for calling the computer program stored in the memory and executing the general report generation method according to the obtained program.

Based on the same technical concept, an embodiment of the present invention provides a computer-readable storage medium storing a computer-executable program for causing a computer to execute a general report generating method.

As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.

The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.

These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.

These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.

While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the invention.

It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present application and their equivalents, the present invention is also intended to include such modifications and variations.

20页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:生成表格的方法、装置、电子设备及计算机可读存储介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!