Import processing method, device, terminal and medium based on Excel file
By dividing the processing links in the excel file import process into general and business specialization links, forming a general processing component, the problem of high binding between import scripts and business scenarios is solved, and flexible expansion capabilities and adaptability are achieved.
Patent Information
- Application Number
- CN202411969500.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-04-04
AI Technical Summary
The existing automated import methods have a high degree of binding of import scripts to business scenarios, lack flexible expansion capabilities, and cannot adapt to diversified business development needs.
By dividing each processing link in the excel file import process into a general processing link and a business specialization link, it forms a general processing component for users to call directly, and decoupling between the general processing link and the business specialization link.
It realizes the applicability of a general import component, reduces duplicate general code, improves the flexibility and expansion capabilities of the system, and can adapt to different business scenario needs.
Smart Images

Figure CN119761319A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to an import processing method, device, terminal and medium based on Excel files. Background Art
[0002] In modern enterprise information management, importing data into the system through Excel files is one of the common functions. At present, there are two ways to implement data import from Excel files: one is manual operation import, and the other is automatic import based on script code. In scenarios involving large amounts of data, automatic import is the preferred import operation method for most managers.
[0003] The existing automated import method requires developers to design targeted script codes based on specific business scenarios, which can automate the entire process of file data reading, verification, caching and importing. However, this approach has technical problems such as the import script is highly bound to the business scenario, lacks flexible expansion capabilities, and cannot adapt to diverse business development needs. Summary of the invention
[0004] The present application provides an import processing method, device, terminal and medium based on Excel files, which are used to solve the technical problems that the existing automated import method has the problem that the import script is highly bound to the business scenario, lacks flexible expansion capabilities, and cannot adapt to diverse business development needs.
[0005] In order to solve the above technical problems, the first aspect of the present application provides an import processing method based on Excel files, comprising:
[0006] Receive the Excel file to be imported;
[0007] Input the excel file into a preset general processing component to perform preprocessing by the general processing component, wherein the general processing component includes: a file parsing logic for reading file data in the excel file, and a cache processing logic for writing the file data into a preset cache unit;
[0008] Obtain data verification logic and data import logic through the preset processing logic input interface;
[0009] According to the data verification logic, the file data is subjected to data verification processing, and then according to the data import logic, the file data that has passed the verification and is stored in the cache unit is subjected to import processing.
[0010] Preferably, according to the data verification logic, the file data is subjected to data verification processing, and then the cache processing logic is called, and then the verified file data is written into the cache unit, and then according to the data import logic, the file data stored in the cache unit that has passed the verification is subjected to import processing, including:
[0011] By using the data verification logic, the file data is subjected to data verification processing, and the file data is divided into first file data and second file data, wherein the first file data is file data that has passed the data verification processing, and the second file data is file data that has not passed the data verification processing;
[0012] The first file data is stored in a preset cache unit through the cache processing logic in the general processing component, and then the first file data is imported and processed according to the data import logic.
[0013] Preferably, after performing data verification processing on the file data through the data verification logic and dividing the file data into the first file data and the second file data, the method further comprises:
[0014] The cache processing logic in the general processing component is used to store the second file data in a preset cache unit, and then the data export logic in the general processing component is used to generate a verification failure data file based on the second file data, and the verification failure data file is exported.
[0015] Preferably, after reading the data verification logic and the data import logic through the preset processing logic input interface, it also includes:
[0016] When the reading result of the data verification logic and / or the data import logic is empty, the business type to which the Excel file belongs is determined according to the file data;
[0017] According to the business type, historical data verification logic and / or historical data import logic corresponding to the business type is read from a database.
[0018] Preferably, the general processing component further comprises: a distributed lock logic for performing a lock process on repeated instructions received within a preset time interval.
[0019] At the same time, the second aspect of the present application provides an import processing device based on Excel files, comprising:
[0020] A file receiving unit, used for receiving the Excel file to be imported;
[0021] A general component preprocessing unit, used for inputting the excel file into a preset general processing component so as to be preprocessed by the general processing component, wherein the general processing component comprises: a file parsing logic for reading file data in the excel file, and a cache processing logic for writing the file data into a preset cache unit;
[0022] An import configuration reading unit is used to read data verification logic and data import logic through a preset processing logic input interface;
[0023] The import execution unit is used to perform data verification processing on the file data according to the data verification logic, and then import processing on the file data that has passed the verification and is stored in the cache unit according to the data import logic.
[0024] Preferably, it also includes:
[0025] A data export unit is used to store the second file data into a preset cache unit through the cache processing logic in the general processing component, and then generate a verification failure data file according to the second file data through the data export logic in the general processing component, and export the verification failure data file.
[0026] Preferably, it also includes:
[0027] The historical import configuration multiplexing unit is used to determine the business type of the Excel file according to the file data when the reading result of the data verification logic and / or the data import logic is empty, and read the historical data verification logic and / or historical data import logic corresponding to the business type from the database according to the business type.
[0028] The third aspect of the present application also provides a computer terminal, including: a memory and a processor;
[0029] The memory is used to store program code, and the program code is used to implement an import processing method based on Excel files as provided in the first aspect of the present application;
[0030] The processor is used for reading and executing the program code.
[0031] The fourth aspect of the present application also provides a computer-readable storage medium, in which a program code is stored. The program code is used to be read and executed by a processor to implement an import processing method based on Excel files as provided in the first aspect of the present application.
[0032] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:
[0033] The solution provided by the present application divides the various processing links in the process of importing conventional Excel files into general processing links such as reading and caching and business-specific links such as data verification and data import rules. Then, the script logic of the general processing links is modularly encapsulated to form a general processing component that can be directly called by users to reduce repeated general code. At the same time, the script logic of the business-specific links is obtained through a preset processing logic input interface, thereby realizing the decoupling of the general processing links and the business-specific links to adapt to the needs of different business scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0035] Figure 1 A basic flow chart of an Excel file-based import processing method provided in this application.
[0036] Figure 2 A flowchart of another embodiment of an Excel file-based import processing method provided in the present application.
[0037] Figure 3 A logic block diagram of an import processing method based on Excel files provided in this application.
[0038] Figure 4 A schematic diagram of the structure of an embodiment of an import processing device based on Excel files provided in this application.
[0039] Figure 5 A structural schematic diagram of a computer terminal for implementing an import processing method based on Excel files provided in this application. DETAILED DESCRIPTION
[0040] In response to the problems existing in the existing automated import method, research has found that the existing practice is usually for developers to design targeted scripts based on specific business scenario links and characteristics to achieve automation of the imported business scenario. However, when faced with diverse business scenarios, the designed import scripts are highly bound to specific business scenarios, making it impossible to stably execute in other business scenarios. To address this phenomenon, traditional approaches generally include: modifying the original script to adapt it to the new business scenario. This approach requires frequent script modifications when faced with the coexistence of new and old businesses, which is labor-intensive. Another approach is to rewrite new import scripts for new business scenarios. The newly written import scripts also contain a large amount of general processing code, which increases the bloat of the system.
[0041] In view of this, the present application provides an import processing method, device, terminal and medium based on Excel files, which are used to solve the technical problems that the existing automated import method has the problem that the import script is highly bound to the business scenario, lacks flexible expansion capabilities, and cannot adapt to diverse business development needs.
[0042] In order to make the purpose, features, and advantages of the invention of this application more obvious and easy to understand, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the embodiments described below are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0043] First, a detailed description of an embodiment of an import processing method based on an Excel file provided by the present application is as follows:
[0044] See also Figures 1 to 3 , the present application provides an Excel file-based import processing method embodiment, including:
[0045] Step 101, receiving the Excel file to be imported;
[0046] Step 102, inputting the Excel file into a preset general processing component to perform preprocessing by the general processing component;
[0047] The general processing component includes: a file parsing logic for reading file data in an excel file, and a cache processing logic for writing file data into a preset cache unit;
[0048] Step 103: Obtain data verification logic and data import logic through a preset processing logic input interface;
[0049] Step 104: perform data verification processing on the file data according to the data verification logic, and then perform import processing on the file data that has passed the verification and is stored in the cache unit according to the data import logic.
[0050] It should be noted that, first of all, based on the conventional Excel file import script, the script logic corresponding to the general processing links such as file content parsing, data cache reading and writing, distributed locks, etc. can be extracted, and these script logics can be uniformly encapsulated and integrated to form a general processing component. After completing this preliminary preparation, the file import processing can be implemented normally.
[0051] When it is necessary to import a file, first, receive the Excel file to be imported input by the user, and then input the Excel file into the pre-built general processing component for pre-processing through the general processing logic configured in the general processing component. At the same time, through the reserved processing logic input interface, the interface is used to provide users with a channel for inputting customized data verification logic and data import logic corresponding to the business scenario. The system reads the customized processing logic input by the user through the interface, and then performs data verification and data import according to the acquired data verification logic and data import logic to complete the file data import task.
[0052] The technical solution of this embodiment provides a universal import component that can be applied to a variety of business scenarios and has a higher reusability. When facing a new business scenario, the user only needs to enter the business customized processing logic such as data verification logic and data import logic corresponding to the business scenario through the reserved processing logic input interface, combined with calling the preset universal processing component to contain universal processing logic, support different types of data models and business requirements, the user only needs to inherit and implement specific methods to complete the customized data import function, thereby achieving the purpose of adapting to different business scenario requirements, and there is no need to rewrite the script logic for the new business scenario.
[0053] More specifically, if Figure 2 As shown, step 104 of this embodiment may include:
[0054] Step 1041: Perform data verification processing on the file data through data verification logic, and divide the file data into first file data and second file data;
[0055] The first file data is file data that has passed the data verification process, and the second file data is file data that has not passed the data verification process;
[0056] Step 1042: The first file data is stored in a preset cache unit through the cache processing logic in the general processing component, and then the first file data is imported and processed according to the data import logic.
[0057] Furthermore, in addition to the general processing logic mentioned above, the general processing component mentioned in this embodiment may further include: data export logic, which is used to export file data that has not passed the data link for user reference.
[0058] Accordingly, after the data verification process in step 1041, the following steps may be further performed:
[0059] Step 1043: The second file data is stored in a preset cache unit through the cache processing logic in the general processing component, and then a verification failure data file is generated according to the second file data through the data export logic in the general processing component, and the verification failure data file is exported.
[0060] It should be noted that this embodiment performs data verification based on the acquired data verification logic in the pre-import stage, introduces a cache mechanism, stores intermediate data (such as success and failure information) in the cache, avoids repeated calculations, and improves performance. At the same time, the pre-configured data export logic in the general processing component can be selectively called to return verification error information. Users can download error data files and view error data so that they can make modifications in time to avoid importing error data.
[0061] It is understandable that the cache unit mentioned in this embodiment preferably uses Redis, and other caches may also be used, and the cache unit in which the second file data is stored and the cache unit in which the first file data is stored may be the same unit or two independent cache units.
[0062] Furthermore, the solution provided in this embodiment may further include, after the file parsing logic in the general processing component reads the file data of the excel file:
[0063] Step 1001: When the reading result of the data verification logic and / or the data import logic is empty, the business type to which the Excel file belongs is determined according to the file data;
[0064] Step 1002: According to the business type, read the historical data verification logic and / or historical data import logic corresponding to the business type from the database.
[0065] It should be noted that when the user does not input customized processing logic or the reading result of the data verification logic and / or data import logic is empty due to errors in the interface operation, at this time, the business type of the Excel file can be determined according to the read file data, and based on historical data such as the data verification logic and / or data import logic input in previous Excel file import tasks, the historical data verification logic and / or data import logic corresponding to this business type can be matched for use in this import task, thereby further improving the fault tolerance capability of the automated import processing method of the present application.
[0066] Furthermore, in order to prevent users from repeatedly submitting import requests, this embodiment may also configure distributed lock logic in the general processing component, such as a distributed lock mechanism based on Redis, to ensure that no repeated operations occur during the import process, thereby ensuring the correctness and consistency of data processing.
[0067] The above is a detailed description of an overall embodiment of an import processing method based on Excel files provided by the present application. The following is a detailed description of an embodiment of an import processing device based on Excel files provided by the present application.
[0068] See also Figure 4 The second aspect of the present application provides an import processing device based on Excel files, comprising:
[0069] The file receiving unit 201 is used to receive the Excel file to be imported;
[0070] The general component preprocessing unit 202 is used to input the Excel file into a preset general processing component to perform preprocessing by the general processing component, wherein the general processing component includes: a file parsing logic for reading file data in the Excel file, and a cache processing logic for writing the file data into a preset cache unit;
[0071] The import configuration reading unit 203 is used to read the data verification logic and the data import logic through a preset processing logic input interface;
[0072] The import execution unit 204 is used to perform data verification processing on the file data according to the data verification logic, and then import the file data that has passed the verification and is stored in the cache unit according to the data import logic.
[0073] More specifically, the import execution unit includes:
[0074] Performing data verification processing on the file data through data verification logic to divide the file data into first file data and second file data;
[0075] The first file data is file data that has passed the data verification process, and the second file data is file data that has not passed the data verification process;
[0076] The first file data is stored in a preset cache unit through the cache processing logic in the general processing component, and then the first file data is imported and processed according to the data import logic.
[0077] Optionally, it also includes:
[0078] The data export unit 205 is used to store the second file data into a preset cache unit through the cache processing logic in the general processing component, and then generate a verification failure data file according to the second file data through the data export logic in the general processing component, and export the verification failure data file.
[0079] Optionally, it also includes:
[0080] The historical import configuration reuse unit 200 is used to determine the business type of the Excel file based on the file data when the reading result of the data verification logic and / or data import logic is empty, and read the historical data verification logic and / or historical data import logic corresponding to the business type from the database according to the business type.
[0081] In addition, the present application also provides a computer terminal and a computer-readable storage medium for implementing an import processing method based on an Excel file, as follows:
[0082] like Figure 5 As shown, the present application provides a computer terminal embodiment, the main components of the terminal include: a memory 33 and a processor 31, the memory 33 and the processor 31 can be connected via a communication bus 34;
[0083] The memory 33 is used to store program codes, and the program codes are used to implement an import processing method based on an Excel file as provided in the above embodiment;
[0084] The processor 31 is used to read and execute program codes.
[0085] The present application provides a computer-readable storage medium embodiment, in which program code is stored, and the program code is used to be read and executed by a processor to implement an import processing method based on an Excel file as provided in the above embodiment.
[0086] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the terminals, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0087] In the several embodiments provided in the present application, it should be understood that the disclosed terminals, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0088] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application described herein can, for example, be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0089] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0090] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0091] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0092] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0093] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. An import processing method based on Excel files, characterized in that: include: Receive the Excel file to be imported; Input the excel file into a preset general processing component to perform preprocessing by the general processing component, wherein the general processing component includes: a file parsing logic for reading file data in the excel file, and a cache processing logic for writing the file data into a preset cache unit; Obtain data verification logic and data import logic through the preset processing logic input interface; According to the data verification logic, the file data is subjected to data verification processing, and then according to the data import logic, the file data that has passed the verification and is stored in the cache unit is subjected to import processing.
2. The import processing method based on Excel file according to claim 1 is characterized in that: According to the data verification logic, the file data is subjected to data verification processing, and then the verified file data is written into the cache unit by calling the cache processing logic, and then according to the data import logic, the file data stored in the cache unit that has passed the verification is subjected to import processing, including: By using the data verification logic, the file data is subjected to data verification processing, and the file data is divided into first file data and second file data, wherein the first file data is file data that has passed the data verification processing, and the second file data is file data that has not passed the data verification processing; The first file data is stored in a preset cache unit through the cache processing logic in the general processing component, and then the first file data is imported and processed according to the data import logic.
3. The import processing method based on Excel file according to claim 2 is characterized in that: After performing data verification processing on the file data through the data verification logic and dividing the file data into first file data and second file data, the following further comprises: The cache processing logic in the general processing component is used to store the second file data in a preset cache unit, and then the data export logic in the general processing component is used to generate a verification failure data file based on the second file data, and the verification failure data file is exported.
4. The import processing method based on Excel file according to claim 1 is characterized in that: Through the preset processing logic input interface, after reading the data verification logic and data import logic, it also includes: When the reading result of the data verification logic and / or the data import logic is empty, the business type to which the Excel file belongs is determined according to the file data; According to the business type, historical data verification logic and / or historical data import logic corresponding to the business type is read from a database.
5. The import processing method based on Excel file according to claim 1 is characterized in that: The general processing component also includes: a distributed lock logic, which is used to perform locking processing on repeated instructions received within a preset time interval.
6. An import processing device based on Excel files, characterized in that: include: A file receiving unit, used for receiving the Excel file to be imported; A general component preprocessing unit, used for inputting the excel file into a preset general processing component so as to be preprocessed by the general processing component, wherein the general processing component comprises: a file parsing logic for reading file data in the excel file, and a cache processing logic for writing the file data into a preset cache unit; An import configuration reading unit is used to read data verification logic and data import logic through a preset processing logic input interface; The import execution unit is used to perform data verification processing on the file data according to the data verification logic, and then import processing on the file data that has passed the verification and is stored in the cache unit according to the data import logic.
7. The import processing device based on Excel file according to claim 6 is characterized in that: Also includes: A data export unit is used to store the second file data into a preset cache unit through the cache processing logic in the general processing component, and then generate a verification failure data file according to the second file data through the data export logic in the general processing component, and export the verification failure data file.
8. The import processing device based on Excel file according to claim 6 is characterized in that: Also includes: The historical import configuration multiplexing unit is used to determine the business type of the Excel file according to the file data when the reading result of the data verification logic and / or the data import logic is empty, and read the historical data verification logic and / or historical data import logic corresponding to the business type from the database according to the business type.
9. A computer terminal, characterized in that: include: Memory and processor; The memory is used to store program codes, and the program codes are used to implement an import processing method based on an Excel file as described in any one of claims 1 to 5; The processor is used for reading and executing the program code.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program code, and the program code is used to be read and executed by a processor to implement an import processing method based on an Excel file as described in any one of claims 1 to 5.