Database Table Import Method, Device, Equipment and Medium
Through Apache poi technology and cell data type model, combined with columnar storage, the compatibility problem of importing different table headers in the existing technology is solved, flexible spreadsheet import is realized, and efficiency and adaptability are improved.
Patent Information
- Application Number
- CN202011185991.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-29
- Publication Date
- 2025-05-27
- Estimated Expiration
- 2040-10-29
AI Technical Summary
The existing technology is difficult to compatible with spreadsheet imports with different headers, resulting in the inability to adapt automatically when the project or member role changes, increasing the development workload and reducing the flexibility of data import.
Use Apache poi technology to obtain the array of data rows and columns in a spreadsheet and create the corresponding table in the database. Use the cell data type model to identify the data type, obtain data rules, and perform data processing before importing, and finally import the database table according to columnar storage.
It realizes spreadsheet import without fixed headers, breaks the limitations of header location and content, improves the flexibility of data import, saves secondary development workload, reduces costs, and improves data import efficiency.
Smart Images

Figure CN112286934B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing of big data, and particularly to a method, device, equipment and medium for importing a database table. Background Art
[0002] Currently, the import of spreadsheets often has a fixed table header agreed upon with the requester or user. The system is developed according to this fixed table header. The user exports a template from the system and then fills in or edits data locally according to this template (the table header cannot be changed). When importing, the system reads the data corresponding to each column row by row by identifying each column header, and finally imports it into the first database table to be imported. However, in actual use scenarios, users often report some special scenarios, such as the inability to unify the table style, differences between the table header and the agreed fixed table header (even if only one column is added to the table header), etc. For example: in the salary distribution of a project, since a project includes many sub-projects, and the roles of each member in the sub-projects are different, the salary distribution is also different. Moreover, in the project, new and deleted sub-projects will occur, and members will join and leave, and there will also be cases of adding or removing a certain type of role, resulting in the inability to fix the table header during the import of the salary spreadsheet every day or month. At this time, since the system cannot be compatible with the import of different table headers, it cannot meet the requirements of these special scenarios, and thus it is necessary to develop the corresponding table headers for spreadsheets separately for each special scenario, increasing the total amount of development work. And due to the inability to change the fixed table header, the maintainability after the spreadsheet is generated is poor. Summary of the Invention
[0003] The present invention provides a method, device, computer equipment and storage medium for importing a database table, which realizes the import of a spreadsheet without a fixed table header, and adopts a columnar storage method for storage, increasing the flexibility of data import, saving the workload of secondary development due to inconsistent table headers, greatly reducing costs, and improving the data import efficiency.
[0004] A method for importing a database table includes:
[0005] Receiving a first import request, and obtaining the document to be imported and the total project information in the first import request; the document to be imported includes the table to be imported; the total project information includes the total project name and the import table name;
[0006] By using Apache poi technology, obtaining the first data row cell array and the first data column cell array in the table to be imported, and at the same time creating a database table corresponding to the import table name in the database; the first data row cell array includes at least one first data row cell, and the first data column cell array includes at least one first data column cell;
[0007] Query the project base table that matches the total project name from the database, and obtain a member list that matches the content of each of the first data row cells from the project base table; the member list includes member identification codes and basic information associated with the member identification codes.
[0008] Identify a first type that matches the content of each of the first data column cells through a cell data type model, obtain data rules that match each of the first types, and obtain first attribute cells in the table to be imported; the first attribute cells refer to cells that correspond to both a first data row cell and a first data column cell.
[0009] Through Apache poi technology, perform pre-import data processing operations on each of the first attribute cells to obtain first data to be imported that corresponds to each of the first attribute cells; the pre-import data processing operation refers to verifying the first attribute cells according to the first type corresponding to the first attribute cells to obtain data to be processed, and then obtaining the first data to be imported according to the data to be processed, the data rules, and the member list that correspond to the first attribute cells.
[0010] In a columnar storage manner, correspondingly import each of the member identification codes, each of the first data column cells, and each of the first data to be imported into the database table to complete the first import request.
[0011] A database table import device, comprising:
[0012] A receiving module, configured to receive a first import request and obtain the document to be imported and total project information in the first import request; the document to be imported includes a table to be imported; the total project information includes a total project name and an import table name.
[0013] An obtaining module, configured to obtain a first data row cell array and a first data column cell array in the table to be imported through Apache poi technology, and simultaneously create a database table corresponding to the import table name in the database; the first data row cell array includes at least one first data row cell, and the first data column cell array includes at least one first data column cell.
[0014] A query module, configured to query a project base table that matches the total project name from the database, and obtain a member list that matches the content of each of the first data row cells from the project base table; the member list includes member identification codes and basic information associated with the member identification codes.
[0015] An identification module, configured to identify a first type that matches the content of each of the first data column cells through a cell data type model, obtain data rules that match each of the first types, and obtain first attribute cells in the to-be-imported table; the first attribute cells refer to the cells that correspond to one of the first data row cells and one of the first data column cells.
[0016] An execution module, configured to perform pre-import data processing operations on each of the first attribute cells through Apache poi technology to obtain first to-be-imported data corresponding to each of the first attribute cells; the pre-import data processing operations refer to verifying the first attribute cells according to the first type corresponding to the first attribute cells to obtain data to be processed, and then obtaining the first to-be-imported data according to the data to be processed, the data rules, and the member list corresponding to the first attribute cells.
[0017] An import module, configured to import each of the member identification codes, each of the first data column cells, and each of the first to-be-imported data into the database table in a columnar storage manner to complete the first import request.
[0018] A computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the steps of the above database table import method are implemented when the processor executes the computer program.
[0019] A computer-readable storage medium storing a computer program, where the steps of the above database table import method are implemented when the computer program is executed by a processor.
[0020] The database table import method, device, computer device and storage medium provided by the present invention obtain the document to be imported and the total project information in the first import request; the document to be imported includes the table to be imported; the total project information includes the total project name and the import table name; by using the Apache poi technology, obtain the first data row cell array and the first data column cell array in the table to be imported, and at the same time create a database table corresponding to the import table name in the database; query the project basic table matching the total project name from the database, and obtain the member list matching the content of each of the first data row cells from the project basic table; identify the first type matching the content of each of the first data column cells through the cell data type model, obtain the data rules matching each of the first types, and obtain the first attribute cells in the table to be imported; by using the Apache poi technology, perform pre-import data processing operations on each of the first attribute cells to obtain the first data to be imported corresponding to each of the first attribute cells; the pre-import data processing operation refers to verifying the first attribute cell according to the first type corresponding to the first attribute cell to obtain the data to be processed, and then obtaining the first data to be imported according to the data to be processed, the data rules and the member list corresponding to the first attribute cell; in a columnar storage manner, import each of the member identification codes, each of the first data column cells and each of the first data to be imported into the database table. In this way, the import of spreadsheets without a fixed header is realized, breaking the limitations of the position and content of the header, and the table can be freely designed as the project or members (roles) increase or decrease, achieving the effect of importing the database table without being restricted by the header. Moreover, it is stored in a columnar storage manner, providing a basis for subsequent modification of the same database table without being restricted by the header, increasing the flexibility of data import, saving the workload of secondary development due to inconsistent headers, greatly reducing costs, and improving data import efficiency. Brief Description of the Drawings
[0021] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments of the present invention. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0022] Figure 1 It is a schematic diagram of the application environment of the database table import method in an embodiment of the present invention;
[0023] Figure 2 It is a flowchart of the database table import method in an embodiment of the present invention;
[0024] Figure 3 is a flowchart of step S20 in the database table import method according to an embodiment of the present invention;
[0025] Figure 4 is a flowchart of step S40 in the database table import method according to an embodiment of the present invention;
[0026] Figure 5 is a flowchart of step S50 in the database table import method according to an embodiment of the present invention;
[0027] Figure 6 is a flowchart of step S50 in the database table import method according to another embodiment of the present invention;
[0028] Figure 7 is a schematic block diagram of the database table import device according to an embodiment of the present invention;
[0029] Figure 8 is a schematic diagram of a computer device according to an embodiment of the present invention. Detailed implementation manners
[0030] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0031] The database table import method provided by the present invention can be applied in an application environment such as Figure 1 , where the client (computer device) communicates with the server through a network. Among them, the client (computer device) includes, but is not limited to, various personal computers, laptop computers, smart phones, tablet computers, cameras, and portable wearable devices. The server can be implemented by an independent server or a server cluster composed of multiple servers.
[0032] In an embodiment, as Figure 2 shown, a database table import method is provided, and its technical solutions mainly include the following steps S10 - S60:
[0033] S10. Receive a first import request, and obtain the document to be imported and the total project information in the first import request; the document to be imported includes the table to be imported; the total project information includes the total project name and the import table name.
[0034] Understandably, the first import request is a request triggered when the document to be imported needs to be imported. The total project information is information related to the document to be imported, which can be obtained after being input on the import interface of the application software. The total project information includes the total project name and the import table name. The total project name is a unique identification name given to the total project, and the import table name is the name given to the database table to be imported. The document to be imported is a document that needs to be imported into the database. The file type of the document to be imported is not limited and can be a Word document or an Excel document. The document to be imported includes the table to be imported, which is the table that needs to be imported. For example, the table to be imported is a table in a Word document to be imported or a worksheet table in an Excel document to be imported, etc.
[0035] S20. By using the Apache poi technology, obtain the first data row cell array and the first data column cell array in the table to be imported, and at the same time create a database table corresponding to the import table name in the database. The first data row cell array includes at least one first data row cell, and the first data column cell array includes at least one first data column cell.
[0036] Understandably, the Apache poi technology is a cross-platform Java API (Java, Application Programming Interface) technology written in Java, which is mainly used for reading and writing documents of office software. Through the Apache poi technology, the file type information of the document to be imported is identified. The file type information includes the file format and the file version. The file format is the file type of the office software of the document to be imported, such as: Excel file type, Word file type, Powerpoint file type, etc. The file version is the version under the file format, such as: 95 version, 07 version, etc.; An Apache poi configuration component matching the file type information is queried from the configuration component management center. The configuration component management center is a management center for managing all Apache poi configuration components. The configuration component management center contains all Apache poi configuration components. The Apache poi configuration component is an environment component configured for different file types of office software. When operating on a file of an office software, the corresponding Apache poi configuration component is run to obtain the first data row cell array and the first data column cell array in the table to be imported. The first data row cell array is a cell set between the cells corresponding to the preset columns in the first row of the table to be imported and the next cell in the row that is empty. The first data column cell array is a cell set between the cells corresponding to the preset rows in the first column of the table to be imported and the next cell in the column that is empty.
[0037] Among them, a database table corresponding to the import table name is created in the database. The database is a columnar database. For example, columnar databases such as Hbase, Vertica, Greenplum, etc. can all adopt the columnar storage method. The database table is a columnar storage data table created in the database.
[0038] In one embodiment, as Figure 3 shown, in step S20, that is, through the Apache poi technology, obtaining the first data row cell array and the first data column cell array in the table to be imported includes:
[0039] S201, identifying the file type information of the document to be imported.
[0040] Understandably, the file type information includes a file format and a file version. The file format is the file type of the office software for the document to be imported, such as: Excel file type, Word file type, Powerpoint file type, etc. The file version is the version under the file format, such as: version 95, version 07, etc.
[0041] S202, obtain an Apache poi configuration component that matches the file type information from the self-configuration component management center, and run the Apache poi configuration component.
[0042] Understandably, first identify the file format of the document to be imported, then identify the file version of the document to be imported, and query the Apache poi configuration component that matches both the file format and the file version. The configuration component management center contains all Apache poi configuration components. The Apache poi configuration component is an environment component configured for the file types of different office softwares. When it is necessary to operate on a file of an office software, the Apache poi configuration component corresponding to the file is run.
[0043] S203, obtain the first data row cell array and the first data column cell array in the table to be imported.
[0044] Understandably, through the Apache poi technology, obtain the first data row cell array containing at least one of the first data row cells, and at the same time obtain the first data column cell data containing at least one of the second data column cells.
[0045] The present invention realizes identifying the file type information of the document to be imported; obtaining an Apache poi configuration component that matches the file type information from the self-configuration component management center, and running the Apache poi configuration component; obtaining the first data row cell array and the first data column cell array in the table to be imported. In this way, through the Apache poi technology, it is possible to identify documents to be imported with different file types and obtain the data in the table to be imported, improving the diversity and convenience of data import and enhancing user satisfaction.
[0046] S30, query a project basic table that matches the total project name from the database, and obtain a member list that matches the content of each of the first data row cells from the project basic table; the member list includes a member identification code and basic information associated with the member identification code.
[0047] Understandably, the database contains all the project basic tables corresponding one by one to the total projects. The project basic table is a table of all the basic information in a total project. For example, the project basic table includes members, genders, roles, project ratios, etc. Query the project basic table that matches the total project name from the database. The content of the first data row cell can be set according to requirements. For example, the content of the first data row cell is the project manager group, quality inspection group, etc. Obtain the member list that matches the content of each first data row cell. The member list contains the member identification codes and the basic information that match the content of the first data row cell. The member identification code is a unique identification code assigned to each member, and the basic information is the basic type of information related to the member. Among them, the matching process can be an exact match or a fuzzy match. For example, if the content of the first data row cell is "project manager group", obtain the member list with the role of "project manager".
[0048] S40. Identify the first type that matches the content of each first data column cell through the cell data type model, obtain the data rule that matches each first type, and obtain the first attribute cell in the table to be imported; the first attribute cell refers to the cell corresponding to both a first data row cell and a first data column cell.
[0049] Understandably, the cell data type model identifies the first type corresponding to each first data column cell. The cell data type model is a trained neural network model. The cell data type model can automatically identify the first type that matches the first data column cell. The first type is a data type identified according to the content of the first data column cell. The first type includes numerical type, character type, decimal point type, etc. The data rule is a rule defined according to the first type. One first type is associated with one data rule. For example, if the content in the first data column cell is "total revenue of XX project", identify the characteristics of "XX project", "revenue", and "total amount", and determine that the first type is the decimal point type. The data rule corresponding to this first type is divided according to the ratio of each member in the XX project. Identify the first type that matches the content of a first data column cell, indicating that the data type of the first attribute cell in the same row as the first data column cell is this first type. In this way, without a fixed table header or fixed content in the first column, the cell data type model automatically identifies the first type that matches the first data column cell, breaking the limitation of the traditional fixed table header.
[0050] Among them, the first attribute cell is the cell corresponding to the same column as one of the first data row cells and the same row as one of the first data column cells.
[0051] In one embodiment, as Figure 4 shown, in step S40, that is, the first type matching the content of each of the first data column cells identified by the cell data type model includes:
[0052] S401, input the content of the first data column cell into the cell data type model; the cell data type model is a neural network model based on the Word2Vec model.
[0053] Understandably, the cell data type model is a trained neural network model based on the Word2Vec model, that is, the network structure of the cell data type model is trained on the basis of the network structure of the Word2Vec model, and the cell data type model is a model that can automatically identify the first type matching the first data column cell by extracting data type features.
[0054] S402, extract data type features through the cell data type model.
[0055] Understandably, the data type feature is a feature related to the project matter type reflected after converting the text into word vectors. The process of extracting the data type feature is that the cell data type model splits the content of the first data row cell into words, splits the content of the first data row cell into several unit words, performs word vector conversion on the unit words to obtain data containing multiple word vectors, and then obtains a weight matrix through weighted processing, and extracts the data type feature from this weight matrix.
[0056] S403, identify the first type corresponding to the first data column cell according to the data type feature.
[0057] Understandably, according to the extracted data type feature, predict the probability values of each data type, obtain the data type corresponding to the highest probability value among all probability values, and determine it as the first type corresponding to the first data column cell.
[0058] The present invention realizes extracting data type features through the cell data type model by inputting the content of the first data column cell into the cell data type model; according to the data type features, identifying the first type corresponding to the first data column cell. In this way, it realizes automatically identifying the first type corresponding to the first data column cell through the cell data type model based on the Word2Vec model, without fixing the content of the cell, predicting the content requirements of the first data column cell through natural language recognition technology, and automatically identifying the corresponding first type, breaking the limitation of the header content, improving the flexibility of data import, and improving the recognition accuracy.
[0059] S50, through the Apache poi technology, perform pre-import data processing operations on each of the first attribute cells to obtain the first data to be imported corresponding to each of the first attribute cells; the pre-import data processing operation refers to verifying the first attribute cell according to the first type corresponding to the first attribute cell to obtain the data to be processed, and then obtaining the first data to be imported according to the data to be processed corresponding to the first attribute cell, the data rule, and the member list.
[0060] Understandably, through the Apache poi technology, perform pre-import data processing operations on each of the first attribute cells to obtain the first data to be imported corresponding to it. The pre-import data processing operation refers to verifying the first attribute cell according to the first type corresponding to the first attribute cell, that is, according to the first type corresponding to the first data column cell corresponding to the first attribute cell. The process of the verification is to convert the content in the first attribute cell into data conforming to the first type, and determine the verified data as the data to be processed. Then, according to the first type, the data rule corresponding to the first attribute cell can be determined. The data rule includes a processing field and a processing formula. The member list corresponding to the first attribute cell is the member list matching the content of the first data row cell corresponding to the first attribute cell. According to the data to be processed corresponding to the first attribute cell, the data rule, and the member list, that is, obtaining the cell information that matches both the member identification code and the processing field from the project basic table. The basic information includes multiple cell information. Input the cell information corresponding to the member identification code and the data to be processed into the processing formula to obtain the first data to be imported.
[0061] In an embodiment, such as Figure 5As shown, in step S50, that is, according to the first type corresponding to the first attribute cell, verifying the first attribute cell to obtain the data to be processed includes:
[0062] S501, detecting whether the content in the first attribute cell meets the conditions of the first type corresponding to the first attribute cell.
[0063] Understandably, obtain the content in the first attribute cell, and judge the obtained content in the first attribute cell to determine whether it meets the conditions of the first type corresponding to the first attribute cell.
[0064] S502, if it is detected that the content in the first attribute cell does not meet the conditions of the first type, then use the regular expression technology in the Apache poi technology to convert the content in the first attribute cell to obtain the data to be processed that meets the conditions of the first type.
[0065] Understandably, when it is detected that the first attribute cell does not meet the conditions of the first type, use the regular expression technology in the Apache poi technology to regularize the content in the first attribute cell, that is, convert it into a data type that meets the conditions of the first type, so as to obtain the data to be processed. For example: the content of the first attribute cell is the text type of "1364" input in text, while its corresponding first type is the numerical type, then perform text-to-number processing on the text type of "1364", convert it to the numerical type of "1364" input in number, and determine the numerical type of "1364" as the data to be processed for this first attribute cell.
[0066] S503, if it is detected that the content in the first attribute cell meets the conditions of the first type, then determine the content in the first attribute cell as the data to be processed.
[0067] Understandably, when it is detected that the first attribute cell meets the conditions of the first type, the content in the first attribute cell does not need to be processed, and it is directly determined as the data to be processed.
[0068] The present invention realizes verifying each first attribute cell through the regular expression technology in the Apache poi technology to obtain the data to be processed that meets the conditions of the corresponding first type. In this way, it can automatically verify the data in the table to be imported to meet the requirements of the data type, avoid the secondary modification operation of re-entering due to different types input by the user, save the modification time, reduce the threshold of data input, improve the flexibility of data import, and enhance the customer satisfaction of users.
[0069] In one embodiment, as Figure 6 shown, in step S50, that is, obtaining the first data to be imported according to the data to be processed, the data rule, and the member list corresponding to the first attribute cell includes:
[0070] S504, obtaining the data rule that matches the first type corresponding to the first attribute cell; the data rule includes a processing field and a processing formula.
[0071] Understandably, obtaining the data rule including the processing field and the processing formula, where the processing field is the field corresponding to the basic information related to the data rule, and the processing formula is the formula for processing the data to be processed and the processing field. For example: the first type is "decimal point type", the processing field of the corresponding data rule is "project proportion", and the processing formula of the processing field of the corresponding data rule is "C = A × B, where C is the first data to be imported, A is the data to be processed, and B is the processing field".
[0072] S505, obtaining the cell information that matches the member identification code and the processing field from all the basic information.
[0073] Understandably, querying the cell information that matches the member identification code in the member list and the data to be processed field from all the basic information. For example: the data to be processed of the first attribute cell is 10000.00, the content in the first data column unit corresponding to the first attribute cell is "total income of XX project", and its corresponding first type is "decimal point type", then the processing field of this data rule is "project proportion", that is, obtaining the cell information corresponding to the "project proportion" field.
[0074] S506, inputting the cell information corresponding to the member identification code and the data to be processed into the processing formula to obtain the first data to be imported.
[0075] Understandably, inputting the cell information corresponding one by one to the member identification code and the data to be processed into the corresponding processing formula, and obtaining the first data to be imported after being processed by the processing formula. For example: the data to be processed of the first attribute cell is 10000.00, a member identification code is 0001, the cell information of its corresponding "project proportion" is 10%, and its corresponding processing formula is "C = A × B, where C is the first data to be imported, A is the data to be processed, and B is the processing field", then the first data to be imported corresponding to this member identification code (0001) is 1000.00.
[0076] The present invention realizes obtaining a data rule that matches the first type corresponding to the first attribute cell; the data rule includes a processing field and a processing formula; obtaining cell information that matches the member identification code and the processing field from all the basic information; inputting the cell information corresponding to the member identification code and the data to be processed into the processing formula to obtain the first data to be imported. In this way, it realizes automatically obtaining the data rule (processing field and processing formula) corresponding to the first attribute cell, obtaining cell information that matches the processing field, and obtaining the first data to be imported corresponding to the first attribute cell through the processing formula.
[0077] S60. In a columnar storage mode, respectively import each of the member identification codes, each of the first data column cells, and each of the first data to be imported into the database table to complete the first import request.
[0078] Understandably, the column-based storage mode is relative to the row-based storage. In a database based on columnar storage, data is stored with columns as the basic logical storage units. The data in a column exists in a continuous storage form in the storage medium. Establish an association relationship among each of the member identification codes, each of the first data column cells, and each of the first data to be imported, and import them into the database table. In this way, each column is stored separately, and the data is the index, without considering the order of the table headers of the table to be imported. Therefore, it realizes storage in a columnar storage mode, increases the flexibility of data import, and is not limited by the specified number of table columns.
[0079] The present invention realizes the following steps: obtaining the document to be imported and the total project information in the first import request; the document to be imported includes the table to be imported; the total project information includes the total project name and the import table name; by using Apache poi technology, obtaining the first data row cell array and the first data column cell array in the table to be imported, and simultaneously creating a database table corresponding to the import table name in the database; querying the project base table matching the total project name from the database, and obtaining the member list matching the content of each of the first data row cells from the project base table; identifying the first type matching the content of each of the first data column cells through the cell data type model, obtaining the data rules matching each of the first types, and obtaining the first attribute cells in the table to be imported; by using Apache poi technology, performing pre-import data processing operations on each of the first attribute cells to obtain the first data to be imported corresponding to each of the first attribute cells; the pre-import data processing operation refers to verifying the first attribute cell according to the first type corresponding to the first attribute cell to obtain the data to be processed, and then obtaining the first data to be imported according to the data to be processed, the data rules and the member list corresponding to the first attribute cell; in a columnar storage manner, corresponding each of the member identification codes, each of the first data column cells and each of the first data to be imported to the database table. In this way, the import of spreadsheets without a fixed table header is realized, breaking the limitation of the position and content of the table header, and the table can be freely designed with the increase or decrease of projects or members (roles), achieving the effect of importing to the database table without being restricted by the table header. Moreover, it is stored in a columnar storage manner, providing a basis for subsequent modification of the same database table without being restricted by the table header, increasing the flexibility of data import, saving the workload of secondary development due to inconsistent table headers, greatly reducing the cost, and improving the data import efficiency.
[0080] In one embodiment, after step S60, that is, after completing the first import request, it includes:
[0081] S601, receiving a second import request, and obtaining the additional import document and the total project information in the second import request; the additional import document includes the additional import table.
[0082] Understandably, after completing the first import request, when it is necessary to add to the database table, the second import request is triggered. The import request contains the additional import document and the total project information. The additional import document is the document to be imported into the database table. Among them, the additional import document includes the additional import table, and the additional import table is the data table to be imported into the database table.
[0083] S602. Using the Apache poi technology, obtain the cell array of the second row and the cell array of the second data column in the said added import table, and at the same time query the database table corresponding to the said import table name from the said database; the cell array of the second row includes at least one cell of the second row, and the cell array of the second data column includes at least one cell of the second data column.
[0084] Understandably, the Apache poi technology is a cross-platform Java API (Java, Application Programming Interface) technology written in Java, which is mainly used for reading and writing documents of office software. Through the Apache poi technology, identify the file type information of the said document to be imported, and the file type information includes the file format and the file version. The file format is the file type of the office software of the said document to be imported, such as: Excel file type, Word file type, Powerpoint file type, etc. The file version is the version under the file format, such as: 95 version, 07 version, etc.; query the Apache poi configuration component matching the said file type information from the configuration component management center. The configuration component management center is the management center for managing all Apache poi configuration components, and the configuration component management center contains all Apache poi configuration components. The Apache poi configuration component is an environment component configured for different file types of office software. When it is necessary to operate on a file of a certain office software, run the Apache poi configuration component corresponding to the file, so as to obtain the cell array of the second row and the cell array of the second data column in the said added import table. The cell array of the second row is the cell set between the cells corresponding to the preset columns of the first row in the said added import table and the cell where the next cell in this row is empty. The cell array of the second data column is the cell set between the cells corresponding to the preset rows of the first column in the said added import table and the cell where the next cell in this column is empty.
[0085] Among them, query the created database table corresponding to the said import table name in the said database.
[0086] S603. Query the project basic table matching the said total project name from the database, and obtain the member list matching the content of each of the said cells of the second row from the said project basic table.
[0087] Understandably, the database contains all the project basic tables corresponding one by one to the total projects. The project basic table is a table of all the basic information in a total project. For example, the project basic table contains members, genders, roles, project ratios, etc. Query the project basic table that matches the total project name from the database. The content of the second-row cell can be set according to requirements. For example, the content of the second-row cell is the project manager group, the quality inspection group, etc. Obtain the member list that matches the content of each second-row cell. The member list contains the member identification codes and the basic information that match the content of this second-row cell. The member identification code is a unique identification code assigned to each member, and the basic information is the basic type of information related to the member. Among them, the matching process can be an exact match or a fuzzy match. For example, if the content of the second-row cell is "quality inspection group", obtain the member list with the role of "quality inspector".
[0088] S604, identify the second type that matches the content of each second-data-column cell through the cell data type model, obtain the data rule that matches each second type, and obtain the second-attribute cell in the add-import table; the second-attribute cell refers to the cell that corresponds to both a second-row cell and a second-data-column cell.
[0089] Understandably, the cell data type model identifies the second type corresponding to each second-data-column cell. The cell data type model is a trained neural network model. The cell data type model can automatically identify the second type that matches the second-data-column cell. The second type is a data type identified according to the content of the second-data-column cell. The second type includes numerical type, character type, decimal point type, etc. The data rule is a rule defined according to the second type. One second type is associated with one data rule. For example: the content in the second-data-column cell is "progress responsibilities of XX project", identify the characteristics of "XX project", "progress", and "responsibilities", determine that the second type is the character type, and the data rule corresponding to this second type is to add the responsibilities corresponding to the progress after the responsibilities of each member in XX project. Identify the second type that matches the content of a second-data-column cell, indicating that the data type of the second-attribute cell in the same row as this second-data-column cell is this second type.
[0090] Among them, the second-attribute cell is the cell corresponding to the same column as a second-row header cell and the same row as a second-data-column cell. The second type can be the same as the first type or not the same as the first type.
[0091] S605. Using the Apache poi technology, perform pre-import data processing operations on each of the second attribute cells to obtain second data to be imported corresponding to each of the second attribute cells. The pre-import data processing operation refers to performing verification on the second attribute cell according to the second type corresponding to the second attribute cell to obtain additional processing data, and then obtaining the second data to be imported based on the additional processing data, the data rules, and the member list corresponding to the second attribute cell.
[0092] Understandably, using the Apache poi technology, perform pre-import data processing operations on each of the second attribute cells to obtain second data to be imported corresponding to them. The pre-import data processing operation refers to performing verification on the second attribute cell according to the second type corresponding to the second attribute cell, that is, according to the second type corresponding to the second data column cell corresponding to the second attribute cell. The process of the verification is to convert the content in the second attribute cell into data conforming to this second type, determine the verified data as the data to be processed, and then according to the second type, the data rules corresponding to the second attribute cell can be determined. The data rules include processing fields and processing formulas. The member list corresponding to the second attribute cell is the member list that matches the content of the second data row cell corresponding to the second attribute cell. According to the data to be processed, the data rules, and the member list corresponding to the second attribute cell, that is, obtain cell information that matches both the member identification code and the processing field from the project base table. The basic information includes multiple cell information. Input the cell information corresponding to the member identification code and the data to be processed into the processing formula to obtain the second data to be imported.
[0093] S606. In a columnar storage manner, add each of the second data column cells to the first empty field in the first column of the database table, and insert all the second data to be imported into the database table according to the member list that matches the content of each of the second row cells.
[0094] Understandably, through the columnar storage method, add each of the second data column cells to the first empty field in the first column of the original database table, that is, at the end of the non-empty fields in the first column, and insert the member list that matches the content of each of the second row cells and all the second data to be imported into the original database table accordingly, completing the second import request and realizing the operation of adding data to the original database table.
[0095] The present invention realizes by obtaining the added import documents and the total project information in the second import request; by using the Apache poi technology, obtaining the cell array of the second row and the cell array of the second data column in the added import table, and simultaneously querying the database table corresponding to the import table name from the database; querying the project base table matching the total project name from the database, and obtaining the member list matching the content of each second row cell from the project base table; identifying the second type matching the content of each second data column cell through the cell data type model, obtaining the data rules matching each second type, and obtaining the second attribute cells in the added import table; by using the Apache poi technology, performing pre-import data processing operations on each second attribute cell to obtain the second data to be imported corresponding to each second attribute cell; in a columnar storage manner, adding each second data column cell to the first empty field in the first column of the database table, and inserting all the second data to be imported into the database table according to the member list matching the content of each second row cell. In this way, it is realized that in the case of subsequent data addition, it is not restricted by the historical table header, and database table import without table header restriction can be achieved, improving the flexibility and efficiency of data import, saving the workload of secondary development due to inconsistent table headers, greatly reducing costs, and improving data import efficiency.
[0096] In one embodiment, after step S60, that is, after completing the first import request, the following steps are further included:
[0097] S70, receiving an export request, and obtaining the user export list and the import table name in the export request.
[0098] Understandably, when the user needs to view the data imported into the database table, the export request is triggered. The export request includes the user export list, and the user export list includes the list of members whose data in the database table needs to be exported.
[0099] S80, obtaining the member identification codes matching the user export list from the database table corresponding to the import table name, and determining the obtained member identification codes as the export identification codes.
[0100] Understandably, from the database table corresponding to the import table name, the member identification codes that exactly match the member identification codes in the user export list are found, and the found member identification codes are marked as the export identification codes. The export identification codes are the member identification codes of the data that needs to be exported.
[0101] S90, filter out the data associated with the export identification code from the database table, obtain a row-style export table through row-column conversion, and export an Excel-format export document through Apache poi technology.
[0102] Understandably, filter out the data associated with the export identification code from the database table, convert the columnar-stored data into a row-style table to obtain the row-style export table. Through the Apache poi technology, create a blank Excel-format document, then write the row-style export table into this blank document to obtain the export document, and display it to the user.
[0103] The present invention realizes by obtaining the user export list and the import table name in the export request; obtaining the member identification code matching the user export list from the database table and determining it as the export identification code; filtering out the data associated with the export identification code from the database table, obtaining a row-style export table through row-column conversion, and exporting an Excel-format export document through Apache poi technology. In this way, it realizes converting a columnar-stored database table into a row-style Excel-format export document through Apache poi technology, which is convenient for users to view the data in the database table, improves the user's experience satisfaction, and enhances the convenience of data export.
[0104] In an embodiment, a database table import device is provided, which corresponds one-to-one with the database table import method in the above embodiment. As Figure 7 shown, the database table import device includes a receiving module 11, an obtaining module 12, a query module 13, an identifying module 14, an executing module 15, and an importing module 16. The detailed description of each functional module is as follows:
[0105] The receiving module 11 is used to receive a first import request and obtain the document to be imported and the total project information in the first import request; the document to be imported includes the table to be imported; the total project information includes the total project name and the import table name;
[0106] The obtaining module 12 is used to obtain the first data row cell array and the first data column cell array in the table to be imported through Apache poi technology, and at the same time create a database table corresponding to the import table name in the database; the first data row cell array includes at least one first data row cell, and the first data column cell array includes at least one first data column cell;
[0107] The query module 13 is used to query the project base table that matches the total project name from the database, and obtain a member list that matches the content of each of the first data row cells from the project base table; the member list includes member identification codes and basic information associated with the member identification codes.
[0108] The recognition module 14 is used to recognize a first type that matches the content of each of the first data column cells through a cell data type model, obtain data rules that match each of the first types, and obtain first attribute cells in the table to be imported; the first attribute cell refers to a cell that corresponds to both a first data row cell and a first data column cell.
[0109] The execution module 15 is used to perform pre-import data processing operations on each of the first attribute cells through Apache poi technology to obtain first data to be imported that corresponds to each of the first attribute cells; the pre-import data processing operation refers to performing verification on the first attribute cell according to the first type corresponding to the first attribute cell to obtain data to be processed, and then obtaining the first data to be imported according to the data to be processed, the data rules, and the member list that correspond to the first attribute cell.
[0110] The import module 16 is used to correspondingly import each of the member identification codes, each of the first data column cells, and each of the first data to be imported into the database table in a columnar storage manner to complete the first import request.
[0111] For the specific limitations of the database table import device, reference can be made to the limitations of the database table import method in the above text, which will not be elaborated here. Each module in the above database table import device can be implemented in whole or in part through software, hardware, and their combinations. The above modules can be embedded in the processor in the computer device in hardware form or be independent of it, or can be stored in the memory in the computer device in software form, so that the processor can call and execute the operations corresponding to the above modules.
[0112] In one embodiment, a computer device is provided. The computer device can be a server, and its internal structure diagram can be as Figure 8As shown. The computer device includes a processor, a memory, a network interface, and a database connected via a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile 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 the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, it implements a method for importing a database table.
[0113] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, it implements the method for importing a database table in the above embodiment.
[0114] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by the processor, it implements the method for importing a database table in the above embodiment.
[0115] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, storage, database, or other medium used in the embodiments provided by the present invention can include non-volatile and / or volatile memories. 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 an external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and Rambus dynamic RAM (RDRAM), etc.
[0116] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the above-mentioned division of each functional unit and module is used as an example. In actual applications, the above functions can be allocated to different functional units and modules according to needs, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0117] The above-described embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.
Claims
1. A method for importing a database table, characterized in that, it includes: Receiving a first import request, and obtaining the document to be imported and the total project information in the first import request; The document to be imported includes a table to be imported; the total project information includes a total project name and an import table name; By using the Apache poi technology, obtaining a first data row cell array and a first data column cell array in the table to be imported, and at the same time creating a database table corresponding to the import table name in the database; the first data row cell array includes at least one first data row cell, and the first data column cell array includes at least one first data column cell; Querying from the database a project base table that matches the total project name, and obtaining a member list that matches the content of each of the first data row cells from the project base table; the member list includes a member identification code and basic information associated with the member identification code; Identifying a first type that matches the content of each of the first data column cells through a cell data type model, obtaining a data rule that matches each of the first types, and obtaining a first attribute cell in the table to be imported; the first attribute cell refers to a cell that corresponds to both a first data row cell and a first data column cell; By using the Apache poi technology, performing a pre-import data processing operation on each of the first attribute cells to obtain first data to be imported corresponding to each of the first attribute cells; The pre-import data processing operation refers to verifying the first attribute cell according to the first type corresponding to the first attribute cell to obtain data to be processed, and then obtaining the first data to be imported according to the data to be processed, the data rule, and the member list corresponding to the first attribute cell; In a columnar storage manner, correspondingly importing each of the member identification codes, each of the first data column cells, and each of the first data to be imported into the database table to complete the first import request.
2. The database table import method according to claim 1, characterized in that, after completing the first import request, it includes: Receiving a second import request, and obtaining the additional import document and the total project information in the second import request; the additional import document includes an additional import table; By using the Apache poi technology, obtaining a second row cell array and a second data column cell array in the additional import table, and at the same time querying from the database the database table corresponding to the import table name; the second row cell array includes at least one second row cell, and the second data column cell array includes at least one second data column cell; Querying from the database a project base table that matches the total project name, and obtaining a member list that matches the content of each of the second row cells from the project base table; Identify the second type that matches the content of each of the second data column cells through the cell data type model, obtain the data rules that match each of the second types, and obtain the second attribute cells in the addition import table; the second attribute cell refers to the cell corresponding to one of the second row cells and one of the second data column cells; Through Apache poi technology, perform pre-import data processing operations on each of the second attribute cells to obtain the second data to be imported corresponding to each of the second attribute cells; the pre-import data processing operation refers to verifying the second attribute cell according to the second type corresponding to the second attribute cell to obtain the added processing data, and then obtaining the second data to be imported according to the added processing data, the data rules, and the member list corresponding to the second attribute cell; In the columnar storage mode, add each of the second data column cells to the first empty field in the first column of the database table, and insert all the second data to be imported into the database table according to the member list that matches the content of each of the second row cells.
3. The database table import method according to claim 1, characterized in that, After completing the first import request, it further includes: Receiving an export request, and obtaining the user export list and the import table name in the export request; Obtain the member identification codes that match the user export list from the database table corresponding to the import table name, and determine the obtained member identification codes as the export identification codes; Screen out the data associated with the export identification codes from the database table, obtain a row-style export table through row-column conversion, and export an Excel-format export document through Apache poi technology.
4. The database table import method according to claim 1, characterized in that, The obtaining of the first data row cell array and the first data column cell array in the to-be-imported table through Apache poi technology includes: Identifying the file type information of the to-be-imported document; Obtain the Apache poi configuration component that matches the file type information from the configuration component management center, and run the Apache poi configuration component; Obtain the first data row cell array and the first data column cell array in the to-be-imported table.
5. The database table import method according to claim 1, characterized in that, The identifying of the first type that matches the content of each of the first data column cells through the cell data type model includes: Input the content of the first data column cell into the cell data type model; the cell data type model is a neural network model based on the Word2Vec model; Extract data type features through the cell data type model; According to the data type features, identify the first type corresponding to the first data column cell.
6. The database table import method according to claim 1, characterized in that, Performing verification on the first attribute cell according to the first type corresponding to the first attribute cell to obtain data to be processed includes: Checking whether the content in the first attribute cell meets the conditions of the first type corresponding to the first attribute cell; If it is detected that the content in the first attribute cell does not meet the conditions of the first type, then using the regular expression technology in the Apache poi technology to convert the content in the first attribute cell to obtain the data to be processed that meets the conditions of the first type; If it is detected that the content in the first attribute cell meets the conditions of the first type, then determining the content in the first attribute cell as the data to be processed.
7. The database table import method according to claim 1, characterized in that obtaining the first data to be imported according to the data to be processed corresponding to the first attribute cell, the data rule, and the member list includes: Obtaining the data rule matching the first type corresponding to the first attribute cell; the data rule includes a processing field and a processing formula; Obtaining cell information matching the member identification code and the processing field from all the basic information; Inputting the cell information corresponding to the member identification code and the data to be processed into the processing formula to obtain the first data to be imported.
8. A database table import device, characterized in that it includes: A receiving module, configured to receive a first import request and obtain the document to be imported and the total project information in the first import request; The document to be imported includes a table to be imported; the total project information includes a total project name and an import table name; An obtaining module, configured to obtain a first data row cell array and a first data column cell array in the table to be imported through the Apache poi technology, and simultaneously create a database table corresponding to the import table name in the database; the first data row cell array includes at least one first data row cell, and the first data column cell array includes at least one first data column cell; A query module, configured to query a project basic table matching the total project name from the database, and obtain a member list matching the content of each of the first data row cells from the project basic table; the member list includes a member identification code and basic information associated with the member identification code; An identification module, configured to identify a first type matching the content of each of the first data column cells through a cell data type model, obtain a data rule matching each of the first types, and obtain a first attribute cell in the table to be imported; the first attribute cell refers to a cell corresponding to both a first data row cell and a first data column cell; An execution module, configured to perform pre-import data processing operations on each of the first attribute cells through the Apache poi technology to obtain first data to be imported corresponding to each of the first attribute cells; The pre-import data processing operation refers to verifying the first attribute cell according to the first type corresponding to the first attribute cell to obtain the data to be processed, and then obtaining the first data to be imported according to the data to be processed corresponding to the first attribute cell, the data rule, and the member list. An import module, configured to import each of the member identification codes, each of the first data column cells, and each of the first data to be imported into the database table in a columnar storage manner to complete the first import request.
9. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein, when the processor executes the computer program, the database table import method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium storing a computer program, wherein, when the computer program is executed by a processor, the database table import method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Material managing and controlling system and method
CN105913211A
Storage method and system for semiautomatic extraction and structuralization of document information
CN109636303A