A General Data Entry Method, Device, Equipment, and Medium Based on a Data Model
Through a general data entry method based on data model, users can easily import Excel data into business tables, solving the problems of large workload of developers and in real-time visualization of user operations in the existing technology, realizing dynamic data maintenance and updates, and is suitable for various project systems.
Patent Information
- Application Number
- CN202111668309.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-31
- Publication Date
- 2025-07-29
- Estimated Expiration
- 2041-12-31
AI Technical Summary
In the prior art, external large-scale Excel data import requires the generation of corresponding three-layer architecture code for each data table, resulting in large workload for developers, inability to visualize user operations in real time, and poor independence of the input module, making it impossible to adapt to various project systems.
Provide a general data entry method based on data model. It specifies data sources and table fields through the configuration interface, uses Apache POI to parse Excel files, and implements visual addition, deletion, modification and search operations on the front end, reduces back-end code generation, and uses JDBC technology to complete database operations.
It realizes that users can intuitively operate Excel data import, reduces the workload of developers, enhances the independence of the entry module, is suitable for various project systems, and provides real-time visual data management functions.
Smart Images

Figure CN114510478B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and particularly to a general data method, device, equipment, and medium based on a data model. Background Art
[0002] In the development of computer programs, data models (i.e., data tables) are indispensable for systems, whether large or small. Maintaining and managing data models is very important for a system. Then, where does the data of a system come from? In addition to some data established during system development, often based on business requirements, data also needs to be imported from outside the system.
[0003] When importing data from outside the system, usually large batches of data are provided as Excel externally, and small batches of single operations are directly completed on the corresponding operation page. However, there are the following deficiencies in the current import of large batches of external Excel data:
[0004] (1) In code implementation, it is necessary to generate corresponding three-tier architecture codes for each data table to implement database operations. Therefore, the heavy rewriting work of a large amount of code leads to heavy tasks for developers, poor independence of the input module, and inability to adapt to various project systems;
[0005] (2) Management operations on data, such as adding business tables to be maintained, can only be implemented by developers, and users cannot be involved, resulting in a significant increase in the workload of developers;
[0006] (3) Users' operations on data are not real-time visual operations, and they cannot obtain intuitive feedback in real time. Summary of the Invention
[0007] The technical problem to be solved by the present invention is to provide a general data input method, device, equipment, and medium based on a data model. Users only need to specify the business tables for which data needs to be imported, and they can easily implement the input of Excel data into the business tables of the system. Moreover, users can operate intuitively, just like directly operating a database, which is more conducive to the dynamic maintenance and update of data; in addition, compared with the traditional input method, users can arbitrarily specify business tables for data input within a certain limit, and are no longer limited to which tables' input functions are implemented by developers; for developers, in code implementation, the business tables use general input functions, and there is no need to generate respective codes for each table to be input, which greatly reduces the development work.
[0008] In a first aspect, the present invention provides a general data input method based on a data model, including a configuration process, a data import process, and a visual process of adding, deleting, modifying, and querying;
[0009] The configuration process is as follows: A series of configuration interfaces are provided for the user to specify the data source and the general input object table, confirm the table information and configure the table fields. The configuration of the table fields includes indicating whether the field is empty and whether it is a primary key. After the user's configuration is completed, the background executes the save operation to add the configuration information to the data model. The data model includes a general input batch table, general input table fields, and general input table information. The corresponding input table IDs in the general input batch table and the general input table fields are associated with the primary key ID in the general input table information.
[0010] The data import process is as follows: The general input list is displayed for the user to select the general input object table configured through the above configuration process, and enter the operation page of the general input object table. After parsing the selected Excel file by the Apache POI tool, the following data import process is performed:
[0011] S1. Obtain the data of the Excel file and convert it into a List <map>Store;
[0012] S2. Perform data legality verification;
[0013] S3. Perform primary key verification;
[0014] S4. Batch insert into the database;
[0015] The visualized process of adding, deleting, modifying, and querying is as follows: On the data operation page of the general input object table, interactive buttons for adding, deleting, modifying, and querying are provided for users to directly perform the operations of adding, deleting, modifying, and querying.
[0016] In a second aspect, the present invention provides a general data input device based on a data model, including:
[0017] A configuration module for providing a series of configuration interfaces for users to specify a data source and a general input object table, confirm table information, and configure table fields. The configured table fields include indicating whether a field is empty and whether it is a primary key. After the user configuration is completed, the background executes the save operation to add the configuration information to the data model. The data model includes a general input batch table, general input table fields, and general input table information. The corresponding input table IDs in the general input batch table and the general input table fields are associated with the primary key ID in the general input table information;
[0018] A data import module for displaying the general input list for users to select the general input object table configured through the configuration process and enter the operation page of the general input object table. After parsing the Execl file selected by the user by the Apache POI tool, the following data import process is performed:
[0019] S1. Obtain the data of the Execl file and convert it into a List <map>Store;
[0020] S2. Perform data legality verification;
[0021] S3. Perform primary key verification;
[0022] S4. Batch insert into the database;
[0023] A visual add, delete, modify, and query module for providing interactive buttons for adding, deleting, modifying, and querying on the data operation page of the general input object table, allowing users to directly perform add, delete, modify, and query operations..
[0024] In a third aspect, the present invention provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the method described in the first aspect is implemented.
[0025] In a fourth aspect, the present invention provides a computer-readable storage medium with a computer program stored thereon. When the program is executed by a processor, the method described in the first aspect is implemented.
[0026] One or more technical solutions provided in the embodiments of the present invention have at least the following technical effects or advantages: A large amount of JavaScript is used in the front end to complete the interaction of the user page, making the user's operations have the characteristics of real-time visualization; in the implementation of the back end, this design uses the API program provided by Apache POI to read and write Microsoft Office format files. In terms of code implementation, it does not need to generate corresponding three-tier architecture code for each data table to implement database operations. The business table uses the general input function and will not generate additional code, only adding non-affecting fields to the original table. At the same time, it is a pure input module with strong independence and is applicable to various project systems. Transferring part of the database management functions and the maintenance and management operations of the business table to the front-end page for users to use facilitates the user's data management operations and reduces the workload of developers.
[0027] The above description is only an overview of the technical solution of the present invention. In order to be able to understand the technical means of the present invention more clearly, it can be implemented according to the content of the specification. And in order to make the above and other purposes, features, and advantages of the present invention more obvious and understandable, the following specifically illustrates the specific embodiments of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] The present invention will be further described below with reference to the accompanying drawings in conjunction with embodiments.
[0029] Figure 1 It is a schematic diagram of the data source management interface of the present invention;
[0030] Figure 2 Schematic diagram of the data structure of the present invention;
[0031] Figure 3 Flowchart of the method in the first embodiment of the present invention;
[0032] Figure 4 Schematic diagram of the general input list in the embodiment of the present invention;
[0033] Figure 5 Schematic diagram of the general input addition interface in the embodiment of the present invention;
[0034] Figure 6 Schematic diagram of the configuration table field interface in the embodiment of the present invention;
[0035] Figure 7 Schematic diagram of the operation status of the general input list in the embodiment of the present invention;
[0036] Figure 8 Schematic diagram of the table operation page in the embodiment of the present invention;
[0037] Figure 9 Schematic diagram of the state when the import box pops up on the table operation page in the embodiment of the present invention;
[0038] Figure 10 Schematic diagram of the import completion status on the table operation page in the embodiment of the present invention;
[0039] Figure 11 Schematic diagram of the state of batch recall of import in the embodiment of the present invention;
[0040] Figure 12 Schematic diagram of the new operation of visualization in the embodiment of the present invention;
[0041] Figure 13 Schematic diagram of the delete operation of visualization in the embodiment of the present invention;
[0042] Figure 14 Schematic diagram of the modify operation of visualization in the embodiment of the present invention;
[0043] Figure 15 Schematic diagram of the completion of the update operation of visualization in the embodiment of the present invention;
[0044] Figure 16 Schematic diagram of the query operation of visualization in the embodiment of the present invention;
[0045] Figure 17 Schematic diagram of the structure of the device in the second embodiment of the present invention;
[0046] Figure 18 Schematic diagram of the structure of the electronic device in the third embodiment of the present invention;
[0047] Figure 19 This is the structural schematic diagram of the medium in the fourth embodiment of the present invention. Detailed implementation manners
[0048] In the embodiments of the present application, by providing a general data entry method, device, equipment, and medium based on a data model, a user only needs to specify a business table for which data needs to be imported, and can easily implement the entry of Excel data into the business table of the system. Moreover, the user can operate intuitively, just like directly operating a database, which is more conducive to the dynamic maintenance and update of data. In addition, compared with the traditional entry method, the user can arbitrarily specify a business table for data entry within a certain limit, and is no longer limited to which tables' entry functions are implemented by developers. For developers, in terms of code implementation, the business table uses a general entry function, and there is no need to generate respective codes for each table that needs to be entered, which greatly reduces the development workload.
[0049] The overall idea of the technical solution in the embodiments of the present application is as follows: A large amount of JavaScript is used in the front end to complete the interaction of the user page, making the user's operations have the characteristics of real-time visualization; in the implementation of the back end, this design uses the API program provided by Apache POI to read and write Microsoft Office format files. In terms of code implementation, it does not need to generate corresponding three-tier architecture codes for each data table to implement the operation of the database. Instead, it uses JDBC technology to complete the operation of the database and further completes the encapsulation with the help of the JdbcUtils tool class. The business table uses a general entry function and will not generate additional codes, but only adds non-affecting fields to the original table. At the same time, it is a pure entry module with strong independence and is applicable to various project systems. Transfer a part of the database management functions and the maintenance and management operations of the business table to the front-end page for users to use, which facilitates the user's management operations of data and reduces the workload of developers.
[0050] The following introduces the preliminary preparation and database design of the present invention:
[0051] An important feature of the general data entry of the present invention is the word "general". Then how to embody "general"? That is, the process of completing the entry for all tables that need to be entered is exactly the same (i.e., the codes and processes are respectively the same), and the difference is zero. There is no need to create corresponding architecture codes (Controller, Service, Dao, etc.) for each table, but use JDBC technology to complete the operation of the database. For the convenience of use, the JdbcUtils tool class is further used to complete the encapsulation during the implementation process. After that, only two steps of creating a data source in advance and then obtaining and executing the SQL need to be completed for use.
[0052] Such as Figure 1 As shown, it is the data source management interface, which is used to create data sources in advance. It supports cross-database operations. However, only one data source information needs to be filled in for the same database, and the operations under the same database share this data source.
[0053] The data model used in the present invention is as Figure 2 shown: It includes a general input batch table, general input table fields, and general input table information. There are corresponding input table IDs in both the general input batch table and the general input table fields, and this corresponding input table ID is associated with the primary key ID in the general input table information; each record in the general input table information corresponds to a table using the general input function, and the general input table fields store the fields owned by each general input table. Through the unique ID (i.e., the primary key ID) in the general input table information, the fields corresponding to this general input table can be found in the general input table fields table. This data model only has three tables, so it has the advantages of simple structure, clear relationships, and conforming to the normal form.
[0054] Embodiment 1
[0055] As Figure 3 shown, this embodiment provides a general data input method based on a data model, including a configuration process, a data import process, and a visual add, delete, modify, and query process;
[0056] The configuration process is: providing a series of configuration interfaces for the user to specify the data source and the general input object table, confirming the table information and configuring the table fields. The configuration of the table fields includes indicating whether the field is empty and whether it is the primary key; after the user's configuration is completed, the background executes the save operation to add the configuration information to the data model. The data model includes a general input batch table, general input table fields, and general input table information. The corresponding input table IDs in the general input batch table and the general input table fields are associated with the primary key ID in the general input table information;
[0057] Among them, as Figure 4 shown, it is the general input list, which has the general input function, allowing the user to configure the table to be operated on and add it to the general input list. Click Figure 4 "General Input Add" in it, and you can enter the Figure 5 page to specify the data source and the table, and start configuring the table. Its data source is obtained by Figure 1 creating in advance. According to Figure 5 the general input add in it, adding a business table using this function actually means adding a new record to the general input table information (fs_general_entry) in the data model, Figure 4 The data in the general input list comes from here. In the code implementation, different from its data model, when designing a JAVA entity class, an additional List needs to be set <fsgeneralentrycolumn>The columnList attribute is used to store the column field information of this general input form. Then, the fields owned by a certain general input form can be obtained and set through the Get / Set methods.
[0058] After clicking "Next", configure the table fields for the business table using this function. The page is as Figure 6 shown. It is the interface for configuring table fields. The field list shown in the figure is used to display all the fields of this table in the database, and the description read for this field is used as the "explanation". The program executes an Sql statement to obtain the field information of this table. Taking Mysql as an example, the statement is: SELECT COLUMN_NAME, COLUMN_COMMENT FROM INFORMATION_SCHEMA.Columns WHERE table_schema = database name and table_name = table name (the statements for SqlServer and Oracle are slightly different). For those with an empty "explanation", its column name will be taken as the "explanation". Then, this "explanation" will be used for the display of this field on the page and in the import template.
[0059] There can be multiple columns as the "primary key", which is used to judge whether the data is repeated (for example: determining a user based on name and mobile phone number), and the primary key is fixed and not empty. The "display form type" is defaulted to text type and can be selected as number or time type. For those selected as time type, a "special field format" (i.e., time format) needs to be specified for this field; the column field formats for text and number types do not take effect.
[0060] The data import process is as follows: After completing the addition operation of general input, the newly added table can be found in the general input list. As Figure 7 shown, display the general input list for the user to select the general input object table configured through the above configuration process. Click the "Operation" button for the record of the general input object table. As Figure 8 shown, enter the data operation page of this general input object table. Click the import button. As Figure 9 shown, an import box will pop up. The import box provides direct import and "download template" - style import. If the user selects direct import, they need to manually check whether the column names are consistent with the column descriptions in the table configuration. If they select "download template" - style import, they will import using the downloaded template and do not need to manually check whether the column names are consistent with the column descriptions in the table configuration. Subsequently, the Apache POI tool will perform the data import process on the Execl file selected by the user. Apache POI is an open - source library of the Apache Software Foundation. POI provides APIs for Java programs to read and write Microsoft Office format files. The data import process is as follows:
[0061] S1. Obtain the data of the Excel file and convert it into a List <map>Store;
[0062] S2. Perform data legality verification;
[0063] S3. Perform primary key verification;
[0064] S4. Batch insert into the database. After successful import, as Figure 10 shown.
[0065] Among them, Figure 8 The data operation page shown is the data display and operation page of the table. A series of data operations such as import, addition, deletion, modification, and query can be performed on this data operation page.
[0066] The visualized process of addition, deletion, modification, and query is as follows: On the data operation page of the general input object table, interactive buttons for addition, deletion, modification, and query are provided for users to directly perform addition, deletion, modification, and query operations.
[0067] Among them, as a more optimal or more specific implementation manner of this embodiment, the method further includes an import batch recall process;
[0068] The import batch recall process is as follows: On the data operation page of the general input object table, an interactive button for import batch recall is provided for users to directly perform import batch recall operations. When the interactive button for import batch recall is triggered, as Figure 11 shown, first display the records that have been imported and have not been recalled yet, and when selected by the user, match all the data imported in the same batch according to the same value of the import batch identification field, and perform batch deletion.
[0069] Specifically, after the above table field configuration is completed, when the background executes the save, it first executes the initialization process, that is:
[0070] Judge whether there is an identification column in the business table corresponding to the general input object table as the unique identifier for each record;
[0071] If so, end the initialization process;
[0072] If not, execute the alter statement to modify the table structure, add a record identification column with the column name "FS_GENERAL_UUID", and generate a unique random value using the database function; then judge whether the initialization is successful. If so, end the initialization process; if not, delete the newly added unique identification column to restore the table structure and re-execute the initialization process.
[0073] During the data import process:
[0074] The specific content of S1 includes:
[0075] S11. Use the MultipartFile class to receive the Excel file passed from the front end, and call the getInputStream method to convert the file into an input stream to read the content of the Excel file;
[0076] S12. Obtain the name of the file through the getOriginalFilename method, and create a Workbook object according to the suffix of the name. If the suffix is xls, create an HSSFWorkbook object; if the suffix is xlsx, create an XSSFWorkbook object;
[0077] S13. Create a container of the ArrayList<Map<String, Object>> type, store the content in the general input object table into the container, obtain the sheet of the Workbook object, and call the getRow method of the sheet object to obtain the data of the specified row;
[0078] Among them, when obtaining the data of the first row, first store the column names (Chinese column names) of each column of the data in the first row in an ordered set List for later use in the List <map>The key of each Map in the container, and then traverse to obtain each subsequent line of data and store it in the List <map>In the container, as the subsequent List <map>The value of each Map in the container; it should be noted that when obtaining the value of each row of cells as the value of the Map, it is necessary to judge the type of this cell (string, number, time type, etc.) and perform corresponding processing (such as formatting time, etc.);
[0079] Specifically, S2 is: perform data legality verification. The data legality verification is divided into the legality judgment of empty fields and the judgment of data types and formats. Among them, regular expressions need to be used to perform legality verification on fields in time format;
[0080] Specifically, S3 is: before inserting each piece of data, first take out the field that sets the primary key for this piece of data, convert the column description to the column name, add the data value, splice the query SQL statement, and directly execute the query SQL using the encapsulated JDBC utility class to find out whether there are fields with the same primary key. Duplicate data is not allowed to be inserted;
[0081] Specifically, S4 is: first add an import batch identification field to the general input object table. The field name is "FS_GENERAL_BATCH_ID" and is used to identify the import batch. After that, an import batch identification field needs to be inserted additionally for each insert operation; after completing the above S1 to S3, the List <map>The values stored in the container (this value includes the key and value of each Map) are concatenated into a batch insert SQL statement, and the JDBC utility class is also used to execute it; after completing this batch insert, a record is added correspondingly in the general input batch table, recording the import information (import status, import quantity), and associating with the data in the general input object table;
[0082] The visualized add, delete, modify, and query process includes the following situations:
[0083] (1) As Figure 12 shown, most of the interactions on the data operation page are implemented using jQuery. When the new operation button is triggered, a new row of text boxes is added on the data operation page for the user to input new data text, and the background completes the operation of inserting the new data into the database; each row of Tr has several cells td, which can be obtained by passing column information in the background. The background first checks whether there is an uncompleted operation on the page. If there is, it first executes its completion event; if not, it creates a variable label, concatenates the page label code, assigns it to the variable label, and then finds the tbody element and uses the prepend method to insert the label code at the head of the table, that is, $("tbody").prepend(label). When the user enters legal data and triggers the event to complete the addition, the content of all text boxes in the newly added row tr is obtained, corresponding to the column description one by one, saved in an array in the form of key-value pairs, and converted to json. Then an ajax request is executed, and the json of the data to be added and the row record ID are passed to the background. The background judges whether the row record ID is empty. If it is empty, the addition operation is executed; if it is not empty, the update operation is executed;
[0084] The background obtains the data and converts it into a List convenient for Java operation <map>, perform data legality verification. If the verification passes, convert the column description to a column name, add the data value, piece together the insert SQL, and use the encapsulated JDBC utility class to execute the SQL to complete the insertion of a new record into the database;
[0085] (2) As Figure 13 shown, when the operation button for deleting any record is triggered on the data operation page, the background deletes the corresponding data according to the FS_GENERAL_UUID of the record. When the operation button for batch deletion is triggered, multiple selected records are batch-deleted together;
[0086] (3) As Figure 14 shown, when the user triggers the event of modifying the table on the data operation page, double-click on a cell to enter the edit state (text box), and the data to be modified can be directly operated on the page. Multiple values in the same row can be edited. When double-clicking on another row or clicking "Finish", the data update operation is completed. The implementation of the modification operation is similar to that of adding. The flag for performing modification and addition is the FS_GENERAL_UUID mentioned above. At this time, according to the FS_GENERAL_UUID, the data record to be modified can be located and accurately modified. The update operation is as Figure 15 shown.
[0087] (4) As Figure 16 shown, when the user triggers the query event on the data operation page, the fields set as query fields when saving the input table or modifying the input table will display query boxes on the page. When the user clicks the query to trigger the query event on the page and enters the query conditions, the query is performed according to the conditions entered by the user. When the type of the query field is text or number, the query is performed according to the set query method. The query method of the field can be fuzzy query (like) or exact query (=); when the field type is time, a time control will be provided to query according to the start time and end time. When returning to the page, the relevant information queryMapList of the query columns will also be returned,
[0088] model.addAttribute("queryMapList", queryMapList).
[0089] Based on the same inventive concept, the present application also provides an apparatus corresponding to the method in Embodiment 1. For details, see Embodiment 2.
[0090] Embodiment 2
[0091] As Figure 17 shown, in this embodiment, a general data entry apparatus based on a data model is provided, including:
[0092] Configuration module, which is used to provide a series of configuration interfaces for users to specify data sources and general input object tables, confirm table information and configure table fields. The configured table fields include indicating whether a field is empty and whether it is a primary key. After the user's configuration is completed, it is saved by the background and the configuration information is added to the data model. The data model includes a general input batch table, general input table fields, and general input table information. The corresponding input table IDs in the general input batch table and the general input table fields are associated with the primary key ID in the general input table information.
[0093] Among them, as Figure 4 shown, it is a general input list with a general input function for users to configure the tables to be operated on and add them to the general input list. Click Figure 4 "General Input Add" in it to enter Figure 5 the page, specify the data source and the table, and start configuring the table. The data source is obtained by Figure 1 being created in advance. Adding a new table according to Figure 5 "General Input Add" in it actually means adding a new record to the general input table information (fs_general_entry) in the data model. Figure 4 The data in the general input list in it comes from this. In code implementation, different from its data model, when designing a JAVA entity class, an additional List needs to be set. <fsgeneralentrycolumn>The columnList attribute is used to store the column field information of this general input form. Then, the fields owned by a certain general input form can be obtained and set through the Get / Set method.
[0094] After clicking "Next", configure the form fields of the general input form. The page is as Figure 6 shown, which is the interface for configuring form fields. The field list shown in the figure is used to display all the fields of this table in the database, and the description read from this field is used as "description". The program executes an Sql statement to obtain the field information of this table. Taking Mysql as an example, the statement is: SELECT COLUMN_NAME, COLUMN_COMMENT FROM INFORMATION_SCHEMA.Columns WHERE table_schema = database name and table_name = table name (the statements for SqlServer and Oracle are slightly different). If the "description" is empty, its column name will be taken as the "description". Then, this "description" will be used for the display of this field on the page and in the import template.
[0095] There can be multiple columns as "primary keys", which are used to determine whether the data is repeated (for example: determining a user based on name and mobile phone number), and the primary key is fixed and not empty. The "display form type" defaults to text type and can be selected as number or time type. For the time type, a "special field format" (i.e., time format) needs to be specified for this field; the column field formats for text and number types do not work.
[0096] The data import module is used to display the general input list, allowing the user to select the general input object table configured through the configuration process and enter the operation page of this general input object table. After parsing the Execl file selected by the user by the Apache POI tool, the following data import process is carried out:
[0097] S1. Obtain the data of the Execl file and convert it into a List <map>Store;
[0098] S2. Perform data legality verification;
[0099] S3. Perform primary key verification;
[0100] S4. Batch insert into the database;
[0101] After completing the addition operation of the general entry, the newly added table can be found in the general entry list. As Figure 7 shown, display the general entry list for the user to select the general entry object table configured through the configuration process, click the "Operation" button of the record in the general entry object table. As Figure 8 shown, enter the data operation page of the general entry object table, click the import button. As Figure 9 shown, an import box will pop up. The import box provides direct import and "download template" - style import. If the user selects direct import, the user needs to manually check whether the column names are consistent with the column descriptions in the table configuration. If the user selects "download template" - style import, then import using the downloaded template, and there is no need for the user to manually check whether the column names are consistent with the column descriptions in the table configuration. Subsequently, the Apache POI tool will perform the data import process on the Excel file selected by the user. Apache POI is an open - source library of the Apache Software Foundation. POI provides APIs for Java programs to read and write Microsoft Office format files.
[0102] A visual add - delete - modify - query module for providing interactive buttons for adding, deleting, modifying, and querying on the data operation page of the general entry object table for the user to directly perform add - delete - modify - query operations.
[0103] Among them, as a more optimal or more specific implementation manner of this embodiment, the device further includes:
[0104] An import batch recall module for providing an interactive button for import batch recall on the data operation page of the general entry object table for the user to directly perform the import batch recall operation. When the interactive button for import batch recall is triggered, as Figure 11 shown, first display the records that have been imported and not yet recalled, and when selected by the user, match all the data imported in the same batch according to the same value of the import batch identification field, and perform batch deletion.
[0105] Specifically, when the configuration module completes the above - mentioned table field configuration and the background executes the save operation, it first executes an initialization process, that is:
[0106] Judge whether there is an identification column in the business table corresponding to the general entry object table as the unique identifier for each record;
[0107] If so, end the initialization process;
[0108] If not, execute the alter statement to modify the table structure, add a record identification column with the column name "FS_GENERAL_UUID", and use the database function to generate a unique random value; then determine whether the initialization is successful. If so, end the initialization process; if not, delete the newly added unique identification column to restore the table structure and re-execute the initialization process.
[0109] During the data import process:
[0110] The specific steps of S1 include:
[0111] S11: Use the MultipartFile class to receive the excel file passed from the front end, and call the getInputStream method to convert the file into an input stream to read the content of the excel file;
[0112] S12: Obtain the name of the file through the getOriginalFilename method, and create a Workbook object according to the suffix of the name. If the suffix is xls, create an HSSFWorkbook object; if the suffix is xlsx, create an XSSFWorkbook object;
[0113] S13: Create a container of the ArrayList<Map<String, Object>> type, store the content in the general input object table into the container, obtain the sheet of the Workbook object, and call the getRow method of the sheet object to obtain the data of the specified row;
[0114] Among them, when obtaining the data of the first row, first store the column names (Chinese column names) of each column of the data in the first row in an ordered set List for later use in List <map>The key of each Map in the container, and then traverse to obtain each subsequent line of data and store it in the List <map>In the container, as the subsequent List <map>The value of each Map in the container; it should be noted that when obtaining the value of each row of cells as the value of the Map, it is necessary to determine the type of this cell (string, number, time type, etc.) and perform corresponding processing (such as formatting the time, etc.);
[0115] Specifically, S2 is: perform data legality verification. The data legality verification is divided into the legality judgment of empty fields and the judgment of data type and format. Among them, regular expressions are required to perform legality verification on fields in time format;
[0116] Specifically, S3 is: before inserting each piece of data, first take out the field that sets the primary key for this piece of data, convert the column description to the column name, add the data value, splice the query SQL statement, and directly execute the query SQL using the encapsulated JDBC utility class to find out whether there are fields with the same primary key. Duplicate data is not allowed to be inserted;
[0117] Specifically, S4 is: first add an import batch identification field to the general input object table. The field name is "FS_GENERAL_BATCH_ID", which is used to identify the import batch. After that, an import batch identification field needs to be inserted additionally for each insert operation; after completing the above S1 to S3, the List <map>The values stored in the container are concatenated into an SQL statement for batch insertion, and the JDBC utility class is also used to execute it; after this batch insertion is completed, a record is added correspondingly in the general input batch table, recording the import information (import status, import quantity), and associating with the data in the general input object table;
[0118] The visual add, delete, modify, and query module executes the following several processes:
[0119] (1) As Figure 12 shown, most of the interactions on the data operation page are implemented using jQuery. When the new operation button is triggered, a new row of text boxes is added to the data operation page for the user to input new data text, and the background completes the operation of inserting the new data into the database; each row of Tr has several cells td, which can be obtained by passing column information in the background. The background first checks whether there is an uncompleted operation on the page. If there is, it first executes its completion event; if not, it creates a variable label, concatenates the page label code, assigns it to the variable label, then finds the tbody element, and uses the prepend method to insert the label code at the head of the table, that is, $("tbody").prepend(label). When the user enters legal data and triggers the event to complete the addition, obtain the content of all text boxes in the newly added row tr, correspond one by one with the column descriptions, save them in an array in the form of key-value pairs, and convert them to json. Then execute an ajax request, and pass the json of the data to be added and the row record ID to the background. The background determines whether the row record ID is empty. If it is empty, it executes the addition operation; if it is not empty, it executes the update operation;
[0120] The background obtains the data and converts the data into a List convenient for Java operations <map>, perform data legality verification. If the verification passes, convert the column description to a column name, add the data value, piece together the insert SQL, and use the encapsulated JDBC utility class to execute the SQL to complete the insertion of a new record into the database;
[0121] (2) As Figure 13 shown, when the operation button for deleting any record is triggered on the data operation page, the background deletes the corresponding data according to the FS_GENERAL_UUID of the record. When the operation button for batch deletion is triggered, multiple selected records are batch-deleted together;
[0122] (3) As Figure 14 shown, when the user triggers the event of modifying the table on the data operation page, double-click on a cell to enter the editing state (text box), and the data to be modified can be directly operated on the page. Multiple values in the same row can be edited. When double-clicking on another row or clicking "Finish", the data update operation is completed. The implementation of the modification operation is similar to that of adding. The flag for executing modification and addition is the FS_GENERAL_UUID mentioned above. At this time, based on the FS_GENERAL_UUID, the data record to be modified can be located and accurately modified. The update operation is as Figure 15 shown.
[0123] (4) As Figure 16 shown, when the user triggers the query event on the data operation page, the fields set as query fields when saving the input table or modifying the input table will display query boxes on the page. When the user clicks the query to trigger the query event on the page and enters the query conditions, the query is performed according to the conditions entered by the user. When the type of the query field is text or number, the query is performed according to the set query method. The query method of the field can be fuzzy query (like) or exact query (=); when the field type is time, a time control will be provided to query according to the start time and end time. When returning to the page, the relevant information queryMapList of the query columns will also be returned, and model.addAttribute("queryMapList", queryMapList).
[0124] Since the device introduced in the second embodiment of the present invention is the device used to implement the method in the first embodiment of the present invention, based on the method introduced in the first embodiment of the present invention, those skilled in the art can understand the specific structure and variations of the device, so it will not be elaborated here. Any device used in the method of the first embodiment of the present invention falls within the scope of protection of the present invention.
[0125] Based on the same inventive concept, this application provides an electronic device embodiment corresponding to Embodiment 1. For details, see Embodiment 3.
[0126] Embodiment 3
[0127] This embodiment provides an electronic device. As shown in Figure 18 , it includes a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, any implementation manner in Embodiment 1 can be realized.
[0128] Since the electronic device introduced in this embodiment is the device used to implement the method in Embodiment 1 of the present application, based on the method introduced in Embodiment 1 of the present application, those skilled in the art can understand the specific implementation manner of the electronic device in this embodiment and its various variations. Therefore, the specific implementation of how this electronic device realizes the method in the embodiments of the present application will not be described in detail here. As long as the device used by those skilled in the art to implement the method in the embodiments of the present application belongs to the scope protected by the present application.
[0129] Based on the same inventive concept, the present application provides a storage medium corresponding to Embodiment 1, as detailed in Embodiment 4.
[0130] Embodiment 4
[0131] This embodiment provides a computer-readable storage medium. As shown in Figure 19 , a computer program is stored thereon. When the computer program is executed by a processor, any implementation manner in Embodiment 1 can be realized.
[0132] The technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages: The methods, devices, systems, devices, and media provided in the embodiments of the present application
[0133] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, a device, or a system, or a computer program product. Therefore, the present invention can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memories, CD-ROMs, optical memories, etc.) containing computer-usable program codes.
[0134] The present invention is described with reference to the flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It should be understood that each flow and / or block in the flowchart and / or block diagram, and combinations of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processors of general-purpose computers, special-purpose computers, embedded processors, or other programmable data processing devices to produce a machine, such that the instructions executed by the processors of the computer or other programmable data processing devices produce means for implementing the functions specified in the flow Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0135] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory produce a manufactured article including instruction means that implement the functions specified in the flow Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0136] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in the flow Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0137] Although the specific embodiments of the present invention have been described above, those skilled in the art of this technology should understand that the specific embodiments we described are illustrative rather than limiting the scope of the present invention. Equivalent modifications and variations made by those skilled in the art in accordance with the spirit of the present invention should all be covered by the scope protected by the claims of the present invention.< / map> < / map> < / map> < / map> < / map> < / map> < / fsgeneralentrycolumn> < / map> < / map> < / map> < / map> < / map> < / map> < / fsgeneralentrycolumn> < / map> < / map>
Claims
1. A general data entry method based on a data model, characterized in that: Including a configuration process, a data import process, and a visualization process for adding, deleting, modifying, and querying; The configuration process is as follows: Provide a configuration interface for the user to specify the data source and the general input object table, confirm the table information and configure the table fields. The configured table fields include indicating whether the field is empty and whether it is the primary key. After the user configuration is completed, the background executes the save operation to add the configuration information to the data model. The data model includes a general input batch table, general input table fields, and general input table information. The corresponding input table ID in the general input batch table and the corresponding input table ID in the general input table fields are both associated with the primary key ID in the general input table information; The data import process is as follows: Display the general input list for the user to select the general input object table configured through the configuration process and enter the operation page of the general input object table. After parsing the Excel file selected by the user by the Apache POI tool, perform the following data import process: S1. Obtain the data of the Excel file and convert it into a List <map>Store;< / map> S2. Perform data legality verification; S3. Perform primary key verification; S4. Batch insert into the database; The visualization process for adding, deleting, modifying, and querying is as follows: Provide interactive buttons for adding, deleting, modifying, and querying on the data operation page of the general input object table for the user to directly perform the operations of adding, deleting, modifying, and querying.
2. The general data entry method based on a data model according to claim 1, characterized in that: When the background executes the save of the user configuration, it first executes the initialization process, that is: Judge whether there is an identification column in the business table corresponding to the general input object table as the unique identifier for each record; If so, end the initialization process; If not, then execute the alter statement to modify the table structure, add a record identification column, and generate a unique random value using the database function. Then judge whether the initialization is successful. If so, end the initialization process. If not, delete the newly added unique identification column to restore the table structure and re-execute the initialization process.
3. A general data entry method based on a data model according to claim 1, characterized in that: During the data import process: The specific steps of S1 include: S11. Use the MultipartFile class to receive the excel file passed from the front end, and call the getInputStream method to convert the file into an input stream form to read the content of the excel file; S12. Obtain the name of the file through the getOriginalFilename method, and create a Workbook object according to the suffix of the name. If the suffix is xls, create an HSSFWorkbook object, and if the suffix is xlsx, create an XSSFWorkbook object; S13. Create a container of the type ArrayList<Map<String, Object>>, store the content in the general input object table into the container, obtain the sheet of the Workbook object, and call the getRow method of the sheet object to obtain the data of the specified row; Among them, when obtaining the data of the first row, first store the column names of each column of the data in the first row in an ordered set List, which is used as the subsequent List <map>The key of each Map in the container, and then traverse to obtain each subsequent line of data and store it in the List <map>In the container, as the subsequent List <map>The value of each Map in the container;< / map> < / map> < / map> The specific steps of S2 are: Perform data legality verification. The data legality verification is divided into the legality judgment of empty fields and the judgment of data type and format. Among them, regular expressions are needed to perform legality verification on the fields in time format; Specifically, S3 is as follows: Before inserting each piece of data, first retrieve the field that sets the primary key for this piece of data, convert the column description to a column name, add the data value, splice the query SQL statement, and directly execute the query SQL using the encapsulated JDBC utility class to find whether there is a field with the same primary key. Duplicate data insertion is not allowed; Specifically, S4 is as follows: First, add an import batch identification field to the general input object table to identify the import batch, and then an import batch identification field needs to be inserted additionally for each insertion operation; after completing S1 to S3, List <map>The values stored in the container are spliced into a batch insert SQL statement and executed using the JDBC utility class; after completing this batch insert, add a record to the corresponding general input batch table to record the import information and associate it with the data in the general input object table;< / map> The visual process of adding, deleting, modifying, and querying includes the following situations: (1) When the add operation button is triggered, a new row of text boxes is added to the data operation page for the user to input the text of the new data. The background completes the operation of inserting the new data into the database: when the user inputs legal data and triggers the event to complete the addition, obtain the content of all text boxes in the new row tr, corresponding to the column descriptions one by one, save them in an array in the form of key-value pairs, convert them to json, and then execute an ajax request to pass the json of the data to be added and the row record ID to the background. The background determines whether the row record ID is empty. If it is empty, perform the add operation; if it is not empty, perform the update operation; The background obtains the data and converts the data into a List that is convenient for Java operations <map>, perform data legality verification. If the verification passes, convert the column description to a column name, add the data value, piece together the insert sql, and use the encapsulated JDBC utility class to execute the Sql to complete the insertion of the new record into the database;< / map> (2) When the operation button for deleting any record is triggered, the background deletes this piece of data according to the FS_GENERAL_UUID of the record. When the operation button for batch deletion is triggered, multiple selected records are deleted in batch; (3) When the user triggers the event of modifying the table on the data operation page, the background can locate the data record to be modified according to the FS_GENERAL_UUID and accurately perform the modification operation on it; (4) When the user triggers the query event on the data operation page, the fields set as query fields when saving the input table or modifying the input table will display query boxes on the page and perform queries according to the conditions input by the user.
4. The general data entry method based on a data model according to claim 1, wherein: It also includes the process of batch recall for import; The process of batch recall for import is as follows: Provide an interactive button for batch recall of import on the data operation page of the general input object table for the user to directly perform the operation of batch recall of import. When the interactive button for batch recall of import is triggered, first display the records that have been imported and have not been recalled yet. When selected by the user, match all the data imported in the same batch according to the same value of the import batch identification field and perform batch deletion.
5. A general data entry device based on a data model, characterized in that: It includes: Configuration module, which is used to provide a configuration interface for users to specify data sources and general input object tables, confirm table information and configure table fields. The configured table fields include indicating whether a field is empty and whether it is a primary key. After the user configuration is completed, it is saved by the background and the configuration information is added to the data model. The data model includes a general input batch table, general input table fields, and general input table information. The corresponding input table IDs in the general input batch table and the general input table fields are both associated with the primary key ID in the general input table information. Data import module, which is used to display a general input list for users to select a general input object table configured by the configuration module and enter the operation page of the general input object table. After parsing the selected Excel file by the Apache POI tool, the following data import process is performed: S1. Obtain the data of the Excel file and convert it into a List <map>Store; < / map> S2. Perform data legality verification; S3. Perform primary key verification; S4. Batch insert into the database; Visual addition, deletion, modification, and query module, which is used to provide interactive buttons for addition, deletion, modification, and query on the data operation page of the general input object table for users to directly perform addition, deletion, modification, and query operations.
6. The general data entry device based on a data model according to claim 5, wherein: When the background executes to save the user configuration, it first executes an initialization process, that is: Judge whether there is an identification column in the business table corresponding to the general input object table as the unique identifier for each record; If so, end the initialization process; If not, execute the alter statement to modify the table structure, add a record identification column, and generate a unique random value using a database function. Then judge whether the initialization is successful. If so, end the initialization process. If not, delete the newly added unique identification column to restore the table structure and re-execute the initialization process.
7. The general data entry device based on a data model according to claim 5, characterized in that: During the data import process: The specific content of S1 includes: S11. Use the MultipartFile class to receive the Excel file passed from the front end, and call the getInputStream method to convert the file into an input stream form to read the content of the Excel file; S12. Obtain the name of the file through the getOriginalFilename method, and create a Workbook object according to the suffix of the name. If the suffix is xls, create an HSSFWorkbook object. If the suffix is xlsx, create an XSSFWorkbook object; S13. Create a container of the ArrayList<Map<String, Object>> type, store the content in the general input object table in the container, obtain the sheet of the Workbook object, and call the getRow method of the sheet object to obtain the data of the specified row; Among them, when obtaining the data of the first row, first store the column names of each column of the data in the first row in an ordered set List, which is used as the subsequent List <map>The key of each Map in the container, and then traverse to obtain each subsequent line of data and store it in the List <map>In the container; < / map> < / map> The specific content of S2 is: perform data legality verification. The data legality verification is divided into the legality judgment of empty fields and the judgment of data types and formats. Among them, regular expressions are needed to perform legality verification on fields with time formats; Specifically, S3 is as follows: Before inserting each piece of data, first retrieve the field that sets the primary key for this piece of data, convert the column description to a column name, add the data value, splice the query SQL statement, directly execute the query SQL using the encapsulated JDBC utility class, and check whether there is a field with the same primary key. Duplicate data insertion is not allowed; Specifically, S4 is as follows: First, add an import batch identification field to the general input object table to identify the import batch. After that, an import batch identification field needs to be inserted additionally for each insert operation. After completing this batch insert, add a corresponding record in the general input batch table to record the import information and associate it with the data in the general input object table; The visual add, delete, modify, and query module executes the following specific process: (1) When the add operation button is triggered, a new row of text boxes is added on the data operation page for the user to input the new data text. The background completes the operation of inserting the new data into the database. When the user enters legal data and triggers the event to complete the addition, obtain all the text box contents of the new row tr, correspond them one by one with the column descriptions, save them in an array in the form of key-value pairs, convert them to json, and then execute an ajax request to send the json of the data to be added and the row record ID to the background. The background determines whether the row record ID is empty. If it is empty, perform the add operation; if it is not empty, perform the update operation; The background obtains the data and converts it into a List that is convenient for Java operations <map>, perform data legality verification. If the verification passes, convert the column description to a column name, add the data value, splice the insert sql, and use the encapsulated JDBC utility class to execute the Sql to complete the insertion of the new record into the database;< / map> (2) When the delete operation button of any record is triggered, the background deletes this piece of data according to the FS_GENERAL_UUID of the record. When the batch delete operation button is triggered, multiple selected records are batch deleted together; (3) When the user triggers the event of modifying the table on the data operation page, the background can locate the data record to be modified according to the FS_GENERAL_UUID and accurately perform the modification operation on it; (4) When the user triggers the query event on the data operation page, the fields set as query fields when saving the input table or modifying the input table will display query boxes on the page.
8. A general data entry device based on a data model according to claim 5, characterized in that: It also includes: An import batch recall module, which provides an interactive button for import batch recall on the data operation page of the general input object table for the user to directly perform the import batch recall operation. When the interactive button for import batch recall is triggered, first display the records that have been imported and have not been recalled yet. When selected by the user, match all the data imported in the same batch according to the same value of the import batch identification field and perform batch deletion.
9. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the method described in any one of claims 1 to 4.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method described in any one of claims 1 to 4.
Citation Information
Patent Citations
Database general management system based on webpage
CN107480262A
Method and system for generating front-end and back-end codes
CN112596719A