Data processing method and device, computer equipment and storage medium

文档序号:1505361 发布日期:2020-02-07 浏览:8次 中文

阅读说明:本技术 数据处理的方法、装置、计算机设备和存储介质 (Data processing method and device, computer equipment and storage medium ) 是由 肖申波 何东旭 何鹏锐 于 2019-09-09 设计创作,主要内容包括:本申请涉及数据处理的技术领域,提供了一种数据处理的方法、装置、计算机设备和存储介质,分析EXCEL模板文件的数据内容结构的配置信息,并创建一个空白xml文件,将EXCEL模板文件的数据内容结构的配置信息分区域配置在空白xml文件中,形成一个xml配置文件;在导入第一EXCEL文件时,则解析出xml配置文件中配置的属性,并根据解析出来的属性对第一EXCEL文件的数据内容进行校验,校验成功则导入对应的数据内容;本申请中只需要维护xml配置文件以及EXCEL模板文件,就可以非常方便使用EXCEL的导入;无需以代码的形式进行,解决了目前使用代码导入文件时无法重用的问题。(The application relates to the technical field of data processing, and provides a data processing method, a data processing device, computer equipment and a storage medium, wherein the data processing method comprises the steps of analyzing configuration information of a data content structure of an EXCEL template file, creating a blank xml file, and configuring the configuration information of the data content structure of the EXCEL template file in the blank xml file in a partitioned mode to form an xml configuration file; when the first EXCEL file is imported, analyzing the attribute configured in the xml configuration file, checking the data content of the first EXCEL file according to the analyzed attribute, and importing the corresponding data content if the checking is successful; according to the method and the device, only the xml configuration file and the EXCEL template file need to be maintained, and the introduction of the EXCEL can be very conveniently used; the method does not need to be carried out in a code form, and solves the problem that the code can not be reused when the code is used for importing the file at present.)

1. A method of data processing, comprising the steps of:

analyzing configuration information of a data content structure of the EXCEL template file; the configuration information comprises attributes of a header part and a body part in the EXCEL template file, wherein the attributes comprise position attributes, content attributes and check rules of data items of each cell in the header part and the body part;

creating a blank xml file, and dividing the blank xml file into a first configuration area and a second configuration area;

sequentially combining the position attribute, the content attribute and the check rule of the data item of each cell in the header part of the EXCEL template file to obtain a first xml configuration of each cell, adding the first xml configuration into a first preset configurator to form first content, and configuring the first content in a first configuration area of the blank xml file; combining the position attribute, the content attribute and the check rule of the data item of each cell in the body part of the EXCEL template file in sequence to obtain a second xml configuration of each cell, adding the second xml configuration into a second preset configurator to form second content, and configuring the second content in a second configuration area of the blank xml file to generate an xml configuration file;

when an instruction of importing a first EXCEL file is received, loading the xml configuration file, and respectively analyzing the attribute of a header part and the attribute of a body part from a first configuration area and a second configuration area of the xml configuration file; verifying the data content of the first EXCEL file according to the attribute of the analyzed header part and the attribute of the body part;

if the verification of the data content of the first EXCEL file is successful, importing the data content which is successfully verified; and if the verification of the data content of the first EXCEL file is unsuccessful, marking the data content which is not verified successfully.

2. The data processing method of claim 1, wherein the step of generating the xml configuration file is followed by:

adding a CRC element in the xml configuration file to generate a new xml configuration file; the value of the CRC element is the CRC checksum of the original xml configuration file;

starting the new xml configuration file, and searching a CRC (cyclic redundancy check) element in the new xml configuration file; obtaining CRC checksum X of the original xml configuration file from the text field of the CRC check element;

reading all the new xml configuration files into an internal memory to obtain a first length of the xml configuration files;

searching a CRC (cyclic redundancy check) element in a new xml configuration file read from the memory to obtain a second length of the CRC element, and deleting the CRC element;

calculating a difference Y between the first length and the second length;

judging whether the X and the Y are consistent; if the configuration files are consistent, the verification is passed, and the xml configuration files are configured correctly; if the xml configuration file is inconsistent, the verification is not passed, and the xml configuration file is configured incorrectly.

3. The method of data processing according to claim 1, wherein the step of verifying the data content of the first EXCEL file according to the attributes of the parsed header portion and the attributes of the body portion comprises:

analyzing a header part and a body part in the first EXCEL file, and converting data in the header part and the body part;

verifying whether the converted data in the header part and the body part in the first EXCEL file correspond to the position attributes and the content attributes of the header part and the body part analyzed in the xml configuration file; and verifying whether the converted data in the header part and the body part in the first EXCEL file are correct or not according to the verification rules of the data items in the header part and the body part analyzed from the xml configuration file.

4. The method of claim 3, wherein the step of converting the data in the header portion and the body portion comprises:

identifying a first format of data in a header part and a body part of the first EXCEL file, and analyzing content attributes of the data in the header part and the body part of the EXCEL template file from the xml configuration file; the content attribute comprises a template format of data;

judging whether the first format is the same as the template format in the content attribute;

if not, judging whether a converter for converting the first format into the template format is arranged in the template;

if yes, calling the converter to convert the data in the header part and the body part; and if not, making a prompt of lacking the converter to prompt a user to expand the converter.

5. The method of data processing according to claim 1, wherein the step of generating an xml configuration file is followed by:

when inquiring the inquiry data in the table of the appointed database and receiving the instruction of exporting the inquiry data, analyzing the configuration information in the xml configuration file; the configuration information at least comprises position attributes of each cell in a header part and a body part of the EXCEL template file; wherein the form is consistent with configuration information of the EXCEL template file;

generating a second EXCEL file with consistent position attributes according to the position attributes of each cell in the header part and the body part analyzed by the xml configuration file;

and filling the query data into the cells of the second EXCEL file with the same position attribute according to the position attribute of the table of the query data in the database.

6. The method of data processing according to claim 1, wherein the step of generating an xml configuration file is followed by:

acquiring the starting position and the ending position of each cell attribute configured in the xml configuration file;

adding annotation information at the starting position or the ending position of each cell attribute;

and establishing a mapping relation among the annotation information, the attributes of each cell and the starting position or the ending position, and storing the mapping relation in the xml configuration file.

7. An apparatus for data processing, comprising:

an analysis unit for analyzing configuration information of a data content structure of the EXCEL template file; the configuration information comprises attributes of a header part and a body part in the EXCEL template file, wherein the attributes comprise position attributes, content attributes and check rules of data items of each cell in the header part and the body part;

the system comprises a creating unit, a first configuration area and a second configuration area, wherein the creating unit is used for creating a blank xml file and dividing the blank xml file into the first configuration area and the second configuration area;

the configuration unit is used for sequentially combining the position attribute, the content attribute and the check rule of the data item of each cell in the header part of the EXCEL template file to obtain a first xml configuration of each cell, adding the first xml configuration into a first preset configuration character to form first content, and then configuring the first content in a first configuration area of the blank xml file; combining the position attribute, the content attribute and the check rule of the data item of each cell in the body part of the EXCEL template file in sequence to obtain a second xml configuration of each cell, adding the second xml configuration into a second preset configurator to form second content, and configuring the second content in a second configuration area of the blank xml file to generate an xml configuration file;

the analysis unit is used for loading the xml configuration file when receiving an instruction of importing a first EXCEL file, and respectively analyzing the attribute of the header part and the attribute of the body part from a first configuration area and a second configuration area of the xml configuration file; verifying the data content of the first EXCEL file according to the attribute of the analyzed header part and the attribute of the body part;

the processing unit is used for importing the data content which is successfully verified if the data content of the first EXCEL file is successfully verified; and if the verification of the data content of the first EXCEL file is unsuccessful, marking the data content which is not verified successfully.

8. The data processing apparatus of claim 7, further comprising:

the generating unit is used for adding a CRC element in the xml configuration file to generate a new xml configuration file; the value of the CRC element is the CRC checksum of the original xml configuration file;

the starting unit is used for starting the new xml configuration file and searching CRC (cyclic redundancy check) elements in the new xml configuration file; obtaining CRC checksum X of the original xml configuration file from the text field of the CRC check element;

the reading unit is used for reading all the new xml configuration files into the memory to obtain the first length of the xml configuration files;

the searching unit is used for searching the CRC check element in the new xml configuration file read from the memory to obtain a second length of the CRC check element and deleting the CRC check element;

a calculating unit for calculating a difference Y between the first length and the second length;

the judging unit is used for judging whether the X and the Y are consistent; if the configuration files are consistent, the verification is passed, and the xml configuration files are configured correctly; if the xml configuration file is inconsistent, the verification is not passed, and the xml configuration file is configured incorrectly.

9. A computer device comprising a memory and a processor, the memory having stored therein a computer program, characterized in that the processor, when executing the computer program, implements the steps of the method according to any of claims 1 to 6.

10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 6.

Technical Field

The present application relates to the field of data processing technologies, and in particular, to a method and an apparatus for data processing, a computer device, and a storage medium.

Background

In the current processing process of data import and export (particularly excel form files), basically, most of data are checked, converted and returned in a code mode, and then data import and export are carried out; the code mode refers to that for each excel form file template, data is imported and exported by developing a corresponding code program. However, when data is imported and exported in a code mode, the code needs to be manually maintained; different codes need to be developed when different types of files are imported and exported, and the codes need to be re-developed when different types of files are imported and exported, so that the efficiency is low.

Disclosure of Invention

The application mainly aims to provide a data processing method, a data processing device, a computer device and a storage medium, and solve the problem that codes are repeatedly developed when a code import file is used at present.

To achieve the above object, the present application provides a data processing method, comprising the steps of:

analyzing configuration information of a data content structure of the EXCEL template file; the configuration information comprises attributes of a header part and a body part in the EXCEL template file, wherein the attributes comprise position attributes, content attributes and check rules of data items of each cell in the header part and the body part;

creating a blank xml file, and dividing the blank xml file into a first configuration area and a second configuration area;

sequentially combining the position attribute, the content attribute and the check rule of the data item of each cell in the header part of the EXCEL template file to obtain a first xml configuration of each cell, adding the first xml configuration into a first preset configurator to form first content, and configuring the first content in a first configuration area of the blank xml file; combining the position attribute, the content attribute and the check rule of the data item of each cell in the body part of the EXCEL template file in sequence to obtain a second xml configuration of each cell, adding the second xml configuration into a second preset configurator to form second content, and configuring the second content in a second configuration area of the blank xml file to generate an xml configuration file;

when an instruction of importing a first EXCEL file is received, loading the xml configuration file, and respectively analyzing the attribute of a header part and the attribute of a body part from a first configuration area and a second configuration area of the xml configuration file; verifying the data content of the first EXCEL file according to the attribute of the analyzed header part and the attribute of the body part;

if the verification of the data content of the first EXCEL file is successful, importing the data content which is successfully verified; and if the verification of the data content of the first EXCEL file is unsuccessful, marking the data content which is not verified successfully.

Further, after the step of generating the xml configuration file, the method further includes:

adding a CRC element in the xml configuration file to generate a new xml configuration file; the value of the CRC element is the CRC checksum of the original xml configuration file;

starting the new xml configuration file, and searching a CRC (cyclic redundancy check) element in the new xml configuration file; obtaining CRC checksum X of the original xml configuration file from the text field of the CRC check element;

reading all the new xml configuration files into an internal memory to obtain a first length of the xml configuration files;

searching a CRC (cyclic redundancy check) element in a new xml configuration file read from the memory to obtain a second length of the CRC element, and deleting the CRC element;

calculating a difference Y between the first length and the second length;

judging whether the X and the Y are consistent; if the configuration files are consistent, the verification is passed, and the xml configuration files are configured correctly; if the xml configuration file is inconsistent, the verification is not passed, and the xml configuration file is configured incorrectly.

Further, the step of verifying the data content of the first EXCEL file according to the attribute of the parsed header part and the attribute of the body part includes:

analyzing a header part and a body part in the first EXCEL file, and converting data in the header part and the body part;

verifying whether the converted data in the header part and the body part in the first EXCEL file correspond to the position attributes and the content attributes of the header part and the body part analyzed in the xml configuration file; and verifying whether the converted data in the header part and the body part in the first EXCEL file are correct or not according to the verification rules of the data items in the header part and the body part analyzed from the xml configuration file.

Further, the step of converting the data in the header part and the body part includes:

identifying a first format of data in a header part and a body part of the first EXCEL file, and analyzing content attributes of the data in the header part and the body part of the EXCEL template file from the xml configuration file; the content attribute comprises a template format of data;

judging whether the first format is the same as the template format in the content attribute;

if not, judging whether a converter for converting the first format into the template format is arranged in the template;

if yes, calling the converter to convert the data in the header part and the body part; and if not, making a prompt of lacking the converter to prompt a user to expand the converter.

Further, after the step of generating the xml configuration file, the method includes:

when inquiring the inquiry data in the table of the appointed database and receiving the instruction of exporting the inquiry data, analyzing the configuration information in the xml configuration file; the configuration information at least comprises position attributes of each cell in a header part and a body part of the EXCEL template file; wherein the form is consistent with configuration information of the EXCEL template file;

generating a second EXCEL file with consistent position attributes according to the position attributes of each cell in the header part and the body part analyzed by the xml configuration file;

and filling the query data into the cells of the second EXCEL file with the same position attribute according to the position attribute of the table of the query data in the database.

Further, after the step of generating the xml configuration file, the method includes:

acquiring the starting position and the ending position of each cell attribute configured in the xml configuration file;

adding annotation information at the starting position or the ending position of each cell attribute;

and establishing a mapping relation among the annotation information, the attributes of each cell and the starting position or the ending position, and storing the mapping relation in the xml configuration file.

The present application further provides a data processing apparatus, including:

an analysis unit for analyzing configuration information of a data content structure of the EXCEL template file; the configuration information comprises attributes of a header part and a body part in the EXCEL template file, wherein the attributes comprise position attributes, content attributes and check rules of data items of each cell in the header part and the body part;

the system comprises a creating unit, a first configuration area and a second configuration area, wherein the creating unit is used for creating a blank xml file and dividing the blank xml file into the first configuration area and the second configuration area;

the configuration unit is used for sequentially combining the position attribute, the content attribute and the check rule of the data item of each cell in the header part of the EXCEL template file to obtain a first xml configuration of each cell, adding the first xml configuration into a first preset configuration character to form first content, and then configuring the first content in a first configuration area of the blank xml file; combining the position attribute, the content attribute and the check rule of the data item of each cell in the body part of the EXCEL template file in sequence to obtain a second xml configuration of each cell, adding the second xml configuration into a second preset configurator to form second content, and configuring the second content in a second configuration area of the blank xml file to generate an xml configuration file;

the analysis unit is used for loading the xml configuration file when receiving an instruction of importing a first EXCEL file, and respectively analyzing the attribute of the header part and the attribute of the body part from a first configuration area and a second configuration area of the xml configuration file; verifying the data content of the first EXCEL file according to the attribute of the analyzed header part and the attribute of the body part;

the processing unit is used for importing the data content which is successfully verified if the data content of the first EXCEL file is successfully verified; and if the verification of the data content of the first EXCEL file is unsuccessful, marking the data content which is not verified successfully.

Further, the apparatus further comprises:

the generating unit is used for adding a CRC element in the xml configuration file to generate a new xml configuration file; the value of the CRC element is the CRC checksum of the original xml configuration file;

the starting unit is used for starting the new xml configuration file and searching CRC (cyclic redundancy check) elements in the new xml configuration file; obtaining CRC checksum X of the original xml configuration file from the text field of the CRC check element;

the reading unit is used for reading all the new xml configuration files into the memory to obtain the first length of the xml configuration files;

the searching unit is used for searching the CRC check element in the new xml configuration file read from the memory to obtain a second length of the CRC check element and deleting the CRC check element;

a calculating unit for calculating a difference Y between the first length and the second length;

the judging unit is used for judging whether the X and the Y are consistent; if the configuration files are consistent, the verification is passed, and the xml configuration files are configured correctly; if the xml configuration file is inconsistent, the verification is not passed, and the xml configuration file is configured incorrectly.

The present application further provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of any one of the above methods when executing the computer program.

The present application also provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, carries out the steps of the method of any of the above.

The method, the device, the computer equipment and the storage medium for data processing analyze the configuration information of the data content structure of the EXCEL template file, create a blank xml file, and configure the configuration information of the data content structure of the EXCEL template file in the blank xml file in different areas to form an xml configuration file; when the first EXCEL file is imported, analyzing the attribute configured in the xml configuration file, checking the data content of the first EXCEL file according to the analyzed attribute, and importing the corresponding data content if the checking is successful; according to the method and the device, only the xml configuration file and the EXCEL template file need to be maintained, and the introduction of the EXCEL can be very conveniently used; the method does not need to be carried out in the form of codes, and solves the problem that the codes are repeatedly developed when the codes are used for importing files at present.

Drawings

FIG. 1 is a schematic diagram of the steps of a data processing method according to an embodiment of the present application;

FIG. 2 is a block diagram of an apparatus for data processing according to an embodiment of the present application;

fig. 3 is a block diagram illustrating a structure of a computer device according to an embodiment of the present application.

The implementation, functional features and advantages of the objectives of the present application will be further explained with reference to the accompanying drawings.

Detailed Description

In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.

Referring to fig. 1, an embodiment of the present application provides a data processing method, including the following steps:

step S1, analyzing the configuration information of the data content structure of the EXCEL template file; the configuration information comprises attributes of a header part and a body part in the EXCEL template file, wherein the attributes comprise position attributes, content attributes and check rules of data items of each cell in the header part and the body part;

step S2, creating a blank xml file, and dividing the blank xml file into a first configuration area and a second configuration area;

step S3, sequentially combining the position attribute and the content attribute of each cell in the header part of the EXCEL template file and the check rule of the data item to obtain a first xml configuration of each cell, adding the first xml configuration into a first preset configurator to form first content, and configuring the first content in a first configuration area of the blank xml file; combining the position attribute, the content attribute and the check rule of the data item of each cell in the body part of the EXCEL template file in sequence to obtain a second xml configuration of each cell, adding the second xml configuration into a second preset configurator to form second content, and configuring the second content in a second configuration area of the blank xml file to generate an xml configuration file;

step S4, when receiving an instruction of importing a first EXCEL file, loading the xml configuration file, and respectively analyzing the attribute of the header part and the attribute of the body part from the first configuration area and the second configuration area of the xml configuration file; verifying the data content of the first EXCEL file according to the attribute of the analyzed header part and the attribute of the body part;

step S5, if the verification of the data content of the first EXCEL file is successful, importing the data content which is successfully verified; and if the verification of the data content of the first EXCEL file is unsuccessful, marking the data content which is not verified successfully.

In this embodiment, as described in the step S1, the EXCEL template file is a template file for storing data in the data system, that is, the data uploaded to the data system needs to be uploaded in the form of the template file. Analyzing the data content structure of the EXCEL template file to decompose a sheet (worksheet) from the EXCEL template file, wherein each sheet comprises a header and a body, and the content in the header is public information (which can be understood as a title), such as a project name, a business name, a reporting period and the like; the body part is a data body specifically uploaded and comprises a horizontal table format and a vertical table format. The header and body comprise a plurality of cells, each cell being a data item, such as: the report name in the header and the column of the corresponding enterprise name in the body; the data items include check rule configurations, such as mandatory check, digital check, and the like.

The EXCEL template file is a preset template file corresponding to the EXCEL to be uploaded; that is, the EXCEL template file is a pre-established template file, and the EXCEL file to be imported in the subsequent system should be consistent with the structure of the EXCEL template file. The structure of the EXCEL template file may be configuration information of a data content structure of the EXCEL template file, where the configuration information includes a position attribute, a content attribute, and a verification rule of a data item of each cell in a header part (header part) and a body part (specific data filled in a cell corresponding to the header) of the EXCEL template file; the position attribute is position information of each cell in the worksheet, the content attribute is a format attribute (English format, Chinese format, capital and small form format, and the like) of the content in the cell, and the check rule is mainly used for checking whether data must be filled in the cells corresponding to the header part and the body part, whether the filled data is correct, and the like, specifically, the check rule includes mandatory check, data type check, digital size and length check, and the like.

After the configuration information of the data content structure of the EXCEL template file is analyzed, it needs to be configured in an xml file.

As described in the above step S2, creating a blank xml file, and dividing the blank xml file into two areas, namely a first allocation area and a second allocation area; and the two areas are used for respectively configuring the attributes of different parts in the EXCEL template file. The first configuration area is used for configuring the attribute of the header part in the EXCEL template file, and the second configuration area is used for configuring the attribute of the body part in the EXCEL template file.

As described in the above step S3, when the position attribute, the content attribute, and the check rule of the data item of each cell in the header portion of the EXCEL template file are sequentially combined, they can be directly spliced together (separated by "", "%" or "-"); obtaining a first xml configuration of each cell after combination; the first xml of each cell is configured as a combination of all attributes of the cell, for example, the combination is: location attribute% content attribute% data item. And adding the first xml configuration corresponding to each cell into a first preset configurator to form first content, and storing the first content in the first configuration area of the blank xml file. The first preset configuration symbol is used for partitioning the first xml configuration among the cells, so that confusion among the cells is avoided. For example, in this embodiment, the first preset configurator is "% label"% ", and the attribute configuration of any cell in the header part is then"% label "= first xml configuration".

When the position attribute, the content attribute and the check rule of the data item of each cell in the body part in the EXCEL template file are combined in sequence, the cells can be directly spliced together (only separated by "", "%" or "-"); obtaining a second xml configuration of each cell after combination; the second xml of each cell is configured as a combination of all attributes of the cell, for example, the combination is: location attribute-content attribute-verification rule of data item. And adding the second xml configuration corresponding to each cell into a second preset configurator to form second content, and storing the second content in a second configuration area of the blank xml file. The second preset configuration symbol is used for partitioning the second xml configuration among the cells, so that confusion among the cells is avoided. For example, in the present embodiment, the second preset configurer is "% type", and when an attribute of one cell of the body part is configured, the "type" is configured in the second xml. And storing all the contents configured in the first configuration area and the second configuration area, and generating an xml configuration file.

In this embodiment, the attributes of the header part and the body part are respectively configured in different configuration areas of the xml file, and are configured through preset different configuration symbols, so that the distinction is facilitated, and the confusion of the xml configuration file is avoided.

As described in step S4, the first EXCEL file is data to be imported into the system, and when data is imported into the data system, data having a structure matching the EXCEL template file, that is, the structure of the data content in the first EXCEL file needs to match the data content structure of the EXCEL template file.

The first EXCEL file is required to be consistent in format with the EXCEL template (or configured xml configuration file), otherwise the check will not pass. Therefore, in this embodiment, the xml configuration file is loaded and analyzed, two configuration areas in the xml configuration file are analyzed, and the configurators in the configuration areas are analyzed. The xml configuration file is provided with two configuration areas, wherein one configuration area is used for configuring the attribute of the header part, and the other configuration area is used for configuring the attribute of the body part; therefore, two configuration areas can be directly identified from the xml configuration file, and according to the difference of the configuration characters used in each configuration area, whether the attribute of the header part or the attribute of the body part is specifically configured in each configuration area can be determined; if the configurator "% label ═ is identified from one of the configuration areas, the configuration area is indicated as the attribute of the header part; and each configurator in the configuration area is added with the specific attribute of each cell in the header part.

In the embodiment, whether the configured attribute of the configurator belongs to the cells of the header part or the cells of the body part is determined according to the configurator; determining a position attribute, a content attribute and a verification rule of a data item of the data in each cell in the EXCEL template file according to the first xml configuration or the second xml configuration in the configuration symbol, verifying the data content of the first EXCEL file according to the position attribute and the content attribute of each data, and verifying whether the data content in the first EXCEL file is legal or not according to the corresponding verification rule; for example, if it is checked that the data in a certain cell or a certain column must be filled, it is necessary to check whether the data in the cell corresponding to the first EXCEL file is legal (must be filled, must be a number, etc.).

As described in the above step S5, if the verification of the data content in the first EXCEL file is successful, the data that is successfully verified is imported, and if the verification is unsuccessful, the data content that is not successfully verified is marked, for example, by using a color mark or other error verification process. In the embodiment, only the xml configuration file and the EXCEL template file need to be maintained, so that the import of the EXCEL can be very conveniently used without being carried out in a code form; and the code can be repeatedly used, and the repeated development of codes is avoided.

In an embodiment, after the xml configuration file is configured, the xml configuration file needs to be verified.

Specifically, after the step S3 of generating the xml configuration file, the method further includes:

step S50, adding a CRC element in the xml configuration file to generate a new xml configuration file; the value of the CRC element is the CRC checksum of the original xml configuration file;

and storing the checksum in the xml configuration file as the value of the CRC check element according to the length sum of the data items in the original xml configuration file.

Step S51, starting the new xml configuration file and searching the CRC check element in the new xml configuration file; obtaining CRC checksum X of the original xml configuration file from the text field of the CRC check element;

step S52, reading all the new xml configuration files into a memory to obtain a first length of the xml configuration files;

in the process, a new xml configuration file is read from a memory to obtain a first length of the new xml configuration file, and the value of the first length comprises the length of the CRC check element and the length of the original xml configuration file.

Step S53, searching the CRC check element in the new xml configuration file read from the memory to obtain the second length of the CRC check element, and deleting the CRC check element;

in this embodiment, the CRC check element is searched, and the second length of the CRC check element is calculated; it is understood that the first length minus the second length is the length of the original xml configuration file.

Step S54, calculating the difference Y between the first length and the second length;

step S55, judging whether X is consistent with Y; if the configuration files are consistent, the verification is passed, and the xml configuration files are configured correctly; if the xml configuration file is inconsistent, the verification is not passed, and the xml configuration file is configured incorrectly.

In this embodiment, a difference Y between the first length and the second length is calculated, where the difference Y is an actual length of the original xml configuration file calculated when the new xml configuration file is read from the memory; the length is obtained by memory reading calculation, so that the length is an accurate value; comparing the data with the check sum X obtained from the CRC check element, judging whether the data are consistent, if so, passing the check, and correctly configuring the xml configuration file; if the xml configuration file is inconsistent with the xml configuration file, the verification is not passed, and the xml configuration file is not configured correctly and needs to be configured again.

In an embodiment, in the step S4, the step of verifying the data content of the first EXCEL file according to the attribute of the parsed header portion and the attribute of the body portion includes:

a. analyzing a header part and a body part in the first EXCEL file, and converting data in the header part and the body part;

b. verifying whether the converted data in the header part and the body part in the first EXCEL file correspond to the position attributes and the content attributes of the header part and the body part analyzed in the xml configuration file; and verifying whether the converted data in the header part and the body part in the first EXCEL file are correct or not according to the verification rules of the data items in the header part and the body part analyzed from the xml configuration file.

In this embodiment, a first EXCEL file to be uploaded is analyzed, and a header part and a body part in the file are analyzed; the system is provided with a plurality of converters, such as date conversion, digital conversion and the like, which are used for format conversion of the data in the head part and the body part. In this embodiment, the extension of the converter is also supported, which facilitates data conversion.

After the format conversion is carried out on the data, continuously verifying whether the converted data in the head part and the body part in the first EXCEL file are consistent with the position attributes and the content attributes of the head part and the body part analyzed in the xml configuration file, and verifying whether the converted data in the head part and the body part in the first EXCEL file are correct according to the verification rules of the data items in the head part and the body part analyzed in the xml configuration file; verifying that the data is correct includes verifying that the cells that must be filled with the data have the data in them and that the data is of the correct data type (e.g., number, etc.).

In this embodiment, the first EXCEL file to be uploaded is decomposed, and each part of data content corresponding to the first EXCEL file has an independent processing logic, for example, the data of the header part has a header transfer class for processing (reading, converting, checking, etc.); the processing mode of each part is realized through an interface, and when the adjustment or the expansion is needed, the logic of a specific service can be realized by inheriting the class or realizing the interface, and then the logic is accessed to the processor of the upper layer, so that the purpose of external expansion without modifying the logic is achieved.

In an embodiment, the step of converting the data in the header part and the body part includes:

identifying a first format of data in a header part and a body part of the first EXCEL file, and analyzing content attributes of the data in the header part and the body part of the EXCEL template file from the xml configuration file; the content attribute comprises a template format of data;

judging whether the first format is the same as the template format in the content attribute;

if not, judging whether a converter for converting the first format into the template format is arranged in the template;

if yes, calling the converter to convert the data in the header part and the body part; and if not, making a prompt of lacking the converter to prompt a user to expand the converter.

In this embodiment, the content attributes of the data in the header part and the body part of the cell in the EXCEL template file include the template format of the data content in the cell; when the first EXCEL file is uploaded, it needs to be ensured that the format of the data content in the cell is consistent with the template format of the corresponding cell in the template file. Therefore, the first format of the data in the header part and the body part in the first EXCEL file is analyzed, and whether the format is the same as the template format in the content attribute is judged; if the two types of data are different, format conversion is required to be carried out on the data; in this embodiment, a plurality of converters (e.g., case conversion, date format conversion, etc.) are built in, and format conversion is performed on the data in the first EXCEL file by the built-in converters to convert the first format into the template format. If the corresponding converter is not used for realizing conversion, a prompt of lacking the converter is made to prompt a user to expand the converter; the user can upload the corresponding converter for expansion so as to perform format conversion.

In one embodiment, after the step S3 of generating the xml configuration file, the method includes:

step S501, when inquiring the inquiry data in the table of the designated database and receiving the instruction of exporting the inquiry data, analyzing the configuration information in the xml configuration file; the configuration information at least comprises position attributes of each cell in a header part and a body part of the EXCEL template file; wherein the form is consistent with configuration information of the EXCEL template file;

step S502, generating a second EXCEL file with consistent position attributes according to the position attributes of each cell in the header part and the body part analyzed by the xml configuration file;

step S503, according to the location attribute of the table in the database of the query data, filling the query data into the cells of the second EXCEL file with the same location attribute.

In this embodiment, if the queried data needs to be exported from the data system, during the export, a corresponding second EXCEL file needs to be created according to the configuration information of the corresponding EXCEL template file, and then, according to the location attribute of the table of the query data in the database, the query data is filled into the cell of the second EXCEL file with the same location attribute.

In another embodiment, after the step S3 of generating the xml configuration file, the method includes:

step S5a, acquiring the starting position and the ending position of each cell attribute configured in the xml configuration file;

step S5b, adding annotation information at the starting position or the ending position of each cell attribute;

step S5c, establishing a mapping relationship between the annotation information, the cell attributes, and the start position or the end position, and storing the mapping relationship in the xml configuration file.

In this embodiment, after the xml configuration file is generated, in order to record the attribute position of each cell, annotation information is added to the xml configuration file, where the annotation information is used to mark the cell attribute marked by the annotation information, and a mapping relationship between the annotation information and each cell attribute and the start position or the end position is established and stored in the xml configuration file, so that it is convenient to intuitively know at which position of the xml configuration file the attribute of each cell is specifically configured according to the mapping relationship, and it is convenient to query, maintain, and modify.

In summary, in the data processing method provided by the present application, the configuration information of the data content structure of the EXCEL template file is analyzed, a blank xml file is created, and the configuration information of the data content structure of the EXCEL template file is configured in the blank xml file in different areas to form an xml configuration file; when the first EXCEL file is imported, analyzing the attribute configured in the xml configuration file, checking the data content of the first EXCEL file according to the analyzed attribute, and importing the corresponding data content if the checking is successful; according to the method and the device, only the xml configuration file and the EXCEL template file need to be maintained, and the introduction of the EXCEL can be very conveniently used; the method does not need to be carried out in the form of codes, and solves the problem that the codes are repeatedly developed when the codes are used for importing files at present.

Referring to fig. 2, an embodiment of the present application further provides a data processing apparatus, including:

an analysis unit 10 for analyzing configuration information of a data content structure of the EXCEL template file; the configuration information comprises attributes of a header part and a body part in the EXCEL template file, wherein the attributes comprise position attributes, content attributes and check rules of data items of each cell in the header part and the body part;

the creating unit 20 is configured to create a blank xml file, and divide the blank xml file into a first configuration area and a second configuration area;

the configuration unit 30 is configured to sequentially combine the location attribute, the content attribute, and the check rule of the data item of each cell in the header portion of the EXCEL template file to obtain a first xml configuration of each cell, add the first xml configuration to a first preset configurator to form first content, and then configure the first content in a first configuration area of the blank xml file; combining the position attribute, the content attribute and the check rule of the data item of each cell in the body part of the EXCEL template file in sequence to obtain a second xml configuration of each cell, adding the second xml configuration into a second preset configurator to form second content, and configuring the second content in a second configuration area of the blank xml file to generate an xml configuration file;

the parsing unit 40 is configured to, when receiving an instruction to import a first EXCEL file, load the xml configuration file, and parse an attribute of the header portion and an attribute of the body portion from a first configuration area and a second configuration area of the xml configuration file, respectively; verifying the data content of the first EXCEL file according to the attribute of the analyzed header part and the attribute of the body part;

the processing unit 50 is configured to, if the verification of the data content of the first EXCEL file is successful, import the data content that is successfully verified; and if the verification of the data content of the first EXCEL file is unsuccessful, marking the data content which is not verified successfully.

In an embodiment, after the xml configuration file is configured, the xml configuration file needs to be verified.

Specifically, the above apparatus further comprises:

the generating unit is used for adding a CRC element in the xml configuration file to generate a new xml configuration file; the value of the CRC element is the CRC checksum of the original xml configuration file;

the starting unit is used for starting the new xml configuration file and searching CRC (cyclic redundancy check) elements in the new xml configuration file; obtaining CRC checksum X of the original xml configuration file from the text field of the CRC check element;

the reading unit is used for reading all the new xml configuration files into the memory to obtain the first length of the xml configuration files;

in the process, a new xml configuration file is read from a memory to obtain a first length of the new xml configuration file, and the value of the first length comprises the length of the CRC check element and the length of the original xml configuration file.

The searching unit is used for searching the CRC check element in the new xml configuration file read from the memory to obtain a second length of the CRC check element and deleting the CRC check element;

in this embodiment, the CRC check element is searched, and the second length of the CRC check element is calculated; it is understood that the first length minus the second length is the length of the original xml configuration file.

A calculating unit for calculating a difference Y between the first length and the second length;

the judging unit is used for judging whether the X and the Y are consistent; if the configuration files are consistent, the verification is passed, and the xml configuration files are configured correctly; if the xml configuration file is inconsistent, the verification is not passed, and the xml configuration file is configured incorrectly.

In an embodiment, the verifying the data content of the first EXCEL file by the parsing unit 40 according to the attribute of the parsed header part and the attribute of the body part specifically includes:

the first analysis subunit is used for analyzing the head part and the body part in the first EXCEL file and converting data in the head part and the body part;

the verification unit is used for verifying whether the converted data in the header part and the body part in the first EXCEL file correspond to the position attribute and the content attribute of the header part and the body part analyzed in the xml configuration file; and verifying whether the converted data in the header part and the body part in the first EXCEL file are correct or not according to the verification rules of the data items in the header part and the body part analyzed from the xml configuration file.

In one embodiment, the first analysis subunit comprises:

the identification module is used for identifying a first format of data in the header part and the body part of the first EXCEL file and analyzing the content attribute of the data in the header part and the body part of the EXCEL template file from the xml configuration file; the content attribute comprises a template format of data;

the first judging module is used for judging whether the first format is the same as the template format in the content attribute;

the second judgment module is used for judging whether a converter for converting the first format into the template format is arranged in the template storage module or not if the first format is different from the template format;

the conversion module is used for calling the converter to convert the data in the header part and the body part if the data exists; and if not, making a prompt of lacking the converter to prompt a user to expand the converter.

In an embodiment, the data processing apparatus further includes:

the export unit is used for analyzing the configuration information in the xml configuration file when querying the query data in the table of the specified database and receiving the instruction for exporting the query data; the configuration information at least comprises position attributes of each cell in a header part and a body part of the EXCEL template file; wherein the form is consistent with configuration information of the EXCEL template file;

the file generation unit is used for generating a second EXCEL file with consistent position attributes according to the position attributes of each cell in the header part and the body part analyzed by the xml configuration file;

and the filling unit is used for filling the query data into the cells with the same position attribute in the second EXCEL file according to the position attribute of the table of the query data in the database.

In another embodiment, the data processing apparatus further includes:

the acquiring unit is used for acquiring the starting position and the ending position of each cell attribute configured in the xml configuration file;

the adding unit is used for adding annotation information at the starting position or the ending position of each cell attribute;

and the establishing unit is used for establishing the mapping relation among the annotation information, the cell attributes and the starting position or the ending position, and storing the mapping relation in the xml configuration file.

For concrete implementation of each unit, subunit, and module in this embodiment, please refer to the description in the above method embodiment, which is not described herein again.

In summary, for the data processing apparatus provided by the present application, the configuration information of the data content structure of the EXCEL template file is analyzed, a blank xml file is created, and the configuration information of the data content structure of the EXCEL template file is configured in the blank xml file in different areas to form an xml configuration file; when the first EXCEL file is imported, analyzing the attribute configured in the xml configuration file, checking the data content of the first EXCEL file according to the analyzed attribute, and importing the corresponding data content if the checking is successful; according to the method and the device, only the xml configuration file and the EXCEL template file need to be maintained, and the introduction of the EXCEL can be very conveniently used; the method does not need to be carried out in the form of codes, and solves the problem that the codes are repeatedly developed when the codes are used for importing files at present.

Referring to fig. 3, a computer device, which may be a server and whose internal structure may be as shown in fig. 3, is also provided in the embodiment of the present application. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the computer designed processor is used to provide computational and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the computer device is used for storing template files and the like. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement any of the above-described methods of data processing.

Those skilled in the art will appreciate that the architecture shown in fig. 3 is only a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects may be applied.

An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements any of the above-mentioned data processing methods.

In summary, for the method, the apparatus, the computer device, and the storage medium for data processing provided in the embodiments of the present application, the configuration information of the data content structure of the EXCEL template file is analyzed, a blank xml file is created, and the configuration information of the data content structure of the EXCEL template file is configured in the blank xml file in different areas to form an xml configuration file; when the first EXCEL file is imported, analyzing the attribute configured in the xml configuration file, checking the data content of the first EXCEL file according to the analyzed attribute, and importing the corresponding data content if the checking is successful; according to the method and the device, only the xml configuration file and the EXCEL template file need to be maintained, and the introduction of the EXCEL can be very conveniently used; the method does not need to be carried out in the form of codes, and solves the problem that the codes are repeatedly developed when the codes are used for importing files at present.

It will be understood by those skilled in the art that all or part of the processes of the methods of the above embodiments may be implemented by hardware associated with instructions of a computer program, which may be stored on a non-volatile computer-readable storage medium, and when executed, may include processes of the above embodiments of the methods. Any reference to memory, storage, database, or other medium provided herein and used in the examples may include non-volatile and/or volatile memory. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), double-rate SDRAM (SSRSDRAM), Enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, apparatus, article, or method. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, apparatus, article, or method that includes the element.

The above description is only for the preferred embodiment of the present application and not intended to limit the scope of the present application, and all modifications of equivalent structures and equivalent processes, which are made by the contents of the specification and the drawings of the present application, or which are directly or indirectly applied to other related technical fields, are intended to be included within the scope of the present application.

18页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种基于文本分析技术的自动写稿系统

网友询问留言

已有0条留言

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

精彩留言,会给你点赞!