Table processing methods, devices and storage media

By introducing import and export interceptors into the table processing methods, and utilizing I18Nkey annotations and internationalization files, data content is processed asynchronously, which solves the memory consumption and performance bottlenecks of multilingual table processing in existing technologies, and improves code readability and maintainability.

CN120012731BActive Publication Date: 2025-10-31ZHONGKE YUNGU TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411994708.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-10-31
Estimated Expiration
2044-12-31

AI Technical Summary

Technical Problem

Existing technologies suffer from problems such as high memory consumption, performance bottlenecks, and poor code readability and maintainability when processing complex tables containing multilingual text.

Method used

By introducing import and export interceptors into the table processing methods, utilizing I18Nkey annotations and internationalization files, the internationalized table headers are parsed, data content is processed asynchronously, data volume is limited to avoid memory overflow, and annotations are read through reflection mechanism to improve performance and maintainability.

Benefits of technology

It improves the performance of table import and export, enhances code readability and maintainability, and ensures efficient processing in resource-constrained environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120012731B_ABST
    Figure CN120012731B_ABST
Patent Text Reader

Abstract

This application provides a table processing method, apparatus, and storage medium. The method includes: when a user initiates an import request for a table in any language, invoking an import interceptor corresponding to the import request to intercept the import request; obtaining the table to be imported and the import language to be used for importing the table according to the import request; invoking the table entity class corresponding to the table to obtain the key value of the I18Nkey annotation on the table entity class; determining the internationalized table header corresponding to the table in the import language according to the key value and the internationalization file; parsing the table to obtain the data content of each attribute under each internationalized table header; when the data content is not empty, storing the data content into the import result file corresponding to the table; and completing the import operation for the table according to all the data content in the import result file, thereby improving the performance of table import, increasing the efficiency of table import, and improving code readability and maintainability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing technology, and more specifically to a table processing method, apparatus and storage medium. Background Technology

[0002] With the expansion of global business, multilingual support for software products has become a key factor in improving user experience. Traditional table internationalization solutions use Apache's POI library, which lacks the native ability to extract table headers as objects for reading and generating Excel spreadsheets.

[0003] Using the POI library for table internationalization can be problematic because POI tends to load the entire Excel file into memory for operations. This can consume significant memory when processing large Excel files, and may lead to memory overflow issues, especially in resource-constrained environments, for internationalized files containing large amounts of data or complex formatting. Loading the entire Excel file into memory can also present performance bottlenecks, particularly when processing complex tables containing multilingual text. Furthermore, POI requires table processing within the code and cannot abstract concrete class objects for flexible manipulation.

[0004] Therefore, the existing solutions for internationalizing tables consume a lot of memory and have a poor impact on performance, code readability, and maintainability when processing complex tables containing multilingual text. Summary of the Invention

[0005] The purpose of this application is to provide a table processing method, apparatus, and storage medium to solve the problems of poor performance, code readability, and maintainability when processing complex tables containing multilingual text in the prior art.

[0006] To achieve the above objectives, the first aspect of this application provides a table processing method, including:

[0007] In the case of a user-initiated import request for a table in any language, the import interceptor corresponding to the import request is invoked to intercept the import request.

[0008] Retrieve the tables to be imported and the language to be used for importing the tables based on the import request;

[0009] Call the table entity class corresponding to the table to get the key value of the I18Nkey annotation on the table entity class;

[0010] Determine the corresponding internationalized table header for the imported language based on the key value and the internationalization file;

[0011] Parse the table to obtain the data content of each attribute under each internationalized header of the table;

[0012] If the data content is not empty, the data content will be stored in the import result file corresponding to the table;

[0013] Complete the import operation for the table based on all the data in the import result file.

[0014] In this embodiment of the application, the process of importing a table based on all the data in the import result file includes: determining whether the number of data contents to be imported in the import result file is greater than a first preset number; if the number of data contents to be imported is greater than the first preset number, sending an error message and indicating that the table import has failed; if the number of data contents to be imported is less than or equal to the first preset number, indicating that the table import has succeeded.

[0015] In this embodiment of the application, the method further includes: determining whether the number of imported data contents in the import result file is greater than a second preset number; if the number of imported data contents is less than the second preset number, processing the data contents of each attribute under each internationalized header in real time; if the number of imported data contents is greater than or equal to the second preset number, processing the data contents of each attribute under each internationalized header asynchronously.

[0016] In this embodiment of the application, the method further includes: when a user initiates an export request for a table in any language, invoking an export interceptor corresponding to the export request to intercept the export request; obtaining at least one data content to be exported, the export language to be used for exporting all data content, and the table entity class according to the export request; determining whether the number of at least one data content to be exported has reached the single export limit; if the number of single export has not reached the limit, determining the key value corresponding to the data content to be exported according to the table entity class; determining the internationalized table header corresponding to the data content to be exported under the export language according to the key value and the internationalization file; and filling each data content into the attribute under each internationalized table header to generate an export file corresponding to the data content to be exported.

[0017] In this embodiment of the application, determining whether the number of at least one data content to be exported has reached the single export limit includes: for each data content, determining whether the data content is a single pagination request instance to obtain the number of data contents to be exported; adjusting the parameters of the single pagination request instance corresponding to the data content to determine the number of data contents that can be exported; and determining whether the single export limit has been reached based on the number of data contents to be exported and the number of data contents that can be exported.

[0018] In this embodiment, the export interceptor includes an export annotation, which includes first target information, first reserved information, proof information, public interface exportable information, string export path information, string export file name information, first data threshold information, first data restriction information, first type information, and string callback name information. Specifically, the first target information specifies the data export logic; the first reserved information specifies that the export annotation is read at runtime via reflection; the proof information generates metadata information; the public interface exportable information defines the name and public access level of the export annotation; the string export path information specifies the base path of the exported table; the string export file name information specifies the default file name of the exported table; the first data threshold information specifies the data threshold for asynchronous processing; the first data restriction information specifies the maximum number of exported data; the first type information specifies the callback class to be executed after export; and the string callback name information specifies the name of the callback bean.

[0019] In this embodiment of the application, the I18Nkey annotation includes second target information, second target information and attribute value. The second target information is used to specify that the I18Nkey annotation is only applied to the member variables of the class. The second target information is used to specify that the I18Nkey annotation is available at compile time and can be read at runtime through reflection mechanism. The attribute value is used to store internationalized key values.

[0020] In this embodiment, the import interceptor includes an import annotation, which includes third target information, third reserved information, public interface importable information, string import path information, string import file name information, first type information, second data threshold information, second data restriction information, and third type information. The third target information is used to specify the data import logic, the third reserved information is used to specify that the import annotation is read through reflection at runtime, the public interface importable information is used to define the name and public access level of the import annotation, the string import path information is used to specify the base path of the imported table, the string import file name information is used to specify the default file name of the imported table, the first type information is used to read and process the class of the imported table, the second data threshold information is used to specify the data threshold value for asynchronous processing, the second data restriction information is used to specify the maximum number of imported data, and the third type information is used to define the callback class after the data import is completed.

[0021] A second aspect of this application provides a form processing apparatus, comprising:

[0022] The memory is configured to store instructions;

[0023] The processor is configured to retrieve instructions from memory and, when executing instructions, to implement the aforementioned table processing method.

[0024] A third aspect of this application provides a machine-readable storage medium storing instructions that, when executed by a processor, configure the processor to perform the table processing method described above.

[0025] The above technical solution, upon receiving a user's import request for a table in any language, invokes the corresponding import interceptor to intercept the import request; retrieves the table to be imported and the import language required for the table based on the import request; calls the corresponding table entity class to obtain the key value of the I18Nkey annotation on the table entity class; determines the internationalized header of the table in the import language based on the key value and the internationalization file; parses the table to obtain the data content of each attribute under each internationalized header; if the data content is not empty, stores the data content in the import result file corresponding to the table; and completes the import operation for the table based on all the data content in the import result file. This improves the performance of table import, increases import efficiency, and enhances code readability and maintainability.

[0026] Other features and advantages of the embodiments of this application will be described in detail in the following detailed description section. Attached Figure Description

[0027] The accompanying drawings are provided to further illustrate the embodiments of this application and form part of the specification. They are used together with the following detailed description to explain the embodiments of this application, but do not constitute a limitation on the embodiments of this application. In the drawings:

[0028] Figure 1 The schematic diagram illustrates a flowchart of a table processing method according to an embodiment of this application;

[0029] Figure 2 The schematic diagram illustrates a flowchart of a table processing method according to another embodiment of this application;

[0030] Figure 3 The diagram illustrates the internal structure of a computer device according to an embodiment of this application. Detailed Implementation

[0031] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are only for illustration and explanation of the embodiments of this application and are not intended to limit the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.

[0032] It should be noted that if the embodiments of this application involve descriptions such as "first" or "second," these descriptions are for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, features defined with "first" or "second" may explicitly or implicitly include at least one of those features. Furthermore, the technical solutions of the various embodiments can be combined with each other, but this must be based on the ability of those skilled in the art to implement them. If the combination of technical solutions is contradictory or impossible to implement, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection claimed in this application.

[0033] Figure 1 A schematic flowchart illustrating a table processing method according to an embodiment of this application is shown. Figure 1 As shown in one embodiment of this application, a table processing method is provided, including the following steps:

[0034] Step 101: In the case of a user-initiated import request for a table in any language, call the import interceptor corresponding to the import request to intercept the import request.

[0035] Users can initiate import requests for tables in any language. In this embodiment, a new `ControllerBeanDefinitionProcessor` class is created, which can automatically scan classes under a specified package and identify methods with import annotations during the Spring application context initialization process. The processor can call the import interceptor corresponding to the import request through the `ControllerBeanDefinitionProcessor` class to intercept the import request.

[0036] In this embodiment, the import interceptor includes an import annotation. The import annotation includes third target information, third reserved information, public interface importable information, string import path information, string import file name information, first type information, second data threshold information, second data restriction information, and third type information. The third target information specifies the data import logic; the third reserved information specifies that the import annotation is read at runtime via reflection; the public interface importable information defines the name and public access level of the import annotation; the string import path information specifies the base path of the imported table; the string import file name information specifies the default file name of the imported table; the first type information is used to read and process the imported table's class; the second data threshold information specifies the data threshold for asynchronous processing; the second data restriction information specifies the maximum number of imported data; and the third type information defines the callback class after the data import is complete.

[0037] For example, the `@Importable` annotation can be used to indicate import. The `@Importable` annotation can include the following parts:

[0038] (1) @Target({ElementType.METHOD}): This is the third target information, indicating that this annotation can only be applied to methods. You can use @Importable to mark which methods are responsible for data import logic.

[0039] (2) @Retention(RetentionPolicy.RUNTIME): This is the third retention information. It sets the lifecycle of the annotation to runtime, allowing access to this annotation information via reflection during program execution.

[0040] (3) public@interfaceImportable: This refers to the public interface that can be imported. It defines the annotation name "Importable" and its public access level. The annotation defines multiple attributes, providing configuration flexibility for the import function.

[0041] (4) String path() default "import": This is the string import path information, which specifies the base path of the imported file. The default is "import", which may be used to build the complete file path.

[0042] (5) String fileName() default "import.xlsx": This is the string import file name information, which specifies the default import file name. The suffix indicates that it is expected to process an Excel file. The default name is "import.xlsx".

[0043] (6) `Class<?>reader()defaultDefaultImportListener.class`: This is the first type of information, specifying the class used to read and process imported files. The default is `DefaultImportListener.class`. This allows users to customize the import logic or use the default implementation.

[0044] (7) intasyncSize()default1000: This is the second data threshold information. It sets the threshold value for asynchronous data processing. If the value is exceeded, the data will be parsed and processed asynchronously.

[0045] (8) intmaxSize() default 10000: That is, the second data limit information, which specifies the maximum limit for imported data. By default, a maximum of 10000 records are allowed to be imported to prevent memory overflow or other performance issues.

[0046] (9) Class<?> callbackClazz() default NullImportCallback.class: That is, the third type of information, which defines the callback class after the import is completed. This callback class implements the ImportCallback interface and needs to implement the beforeInvoke method to send notifications or perform validations before executing the business logic. If the data does not meet the pre-execution conditions, the corresponding reason is returned. By default, it is NullImportCallback.class, which means that if not specifically specified, no specific operation will be performed after the import is completed.

[0047] Step 102: Obtain the table to be imported and the import language required for the import table according to the import request.

[0048] Step 103: Invoke the table entity class corresponding to the table to obtain the key value of the I18Nkey annotation on the table entity class.

[0049] Step 104: Determine the internationalized table header corresponding to the table in the import language according to the key value and the internationalization file.

[0050] A corresponding table entity class is established for each table, and annotations can be used to configure the table header on the fields of the table entity class. For example, the ExcelProperty annotation can be used to specify the table header of the field in the table, such as @ExcelProperty(value = "Name"). If additional processing is required for the table field, a new class can be created for the processing logic code and placed in the property converter annotated with ExcelProperty. The I18Nkey annotation can be used on the fields of the table entity class to specify the corresponding internationalization key, such as @I18nKey(paradise = "user.name").

[0051] In the embodiment of the present application, the I18Nkey annotation includes the second target information, the second target information, and the property value. The second target information is used to specify that the I18Nkey annotation is only applied to the member variables of the class. The second target information is used to specify that the I18Nkey annotation is available during compilation and can be read through the reflection mechanism during runtime. The property value is used to store the internationalization key value, that is, the key value.

[0052] The processor can obtain the table to be imported and the import language required for the table based on the import request. After obtaining the table to be imported, the processor can call the corresponding table entity class to obtain the key value of the I18nkey annotation on the table entity class. For example, @I18nKey(key=1). The processor can determine the internationalized table header corresponding to the table in the import language based on the key value and the internationalization file. The internationalization file includes table headers for the same key value in different languages, that is, each language includes multiple key values, and each key value corresponds to one table header. For example, the internationalization file includes: Chinese: 1-Name; English: 1-Name.

[0053] Step 105: Parse the table to obtain the data content of each attribute under each internationalized header of the table.

[0054] Step 106: If the data content is not empty, save the data content to the import result file corresponding to the table.

[0055] The processor can parse the table to obtain the data content of each attribute under each internationalized header. If the data content is not empty, it means that valid data content has been parsed, and the processor can store the data content into the import result file corresponding to the table.

[0056] In one embodiment, if the data content is empty, it can be indicated that the parsed data content is invalid, for example, it may be a blank line. In this case, the processor can remove the data content and may not store the data content in the import result file corresponding to the table.

[0057] Step 107: Complete the import operation for the table based on all the data in the import result file.

[0058] If the amount of non-empty data obtained from parsing the table exceeds the maximum import capacity, in order to ensure the normal import of the table, the processor can complete the import operation for the table based on all the data content in the import result file.

[0059] In this embodiment of the application, the process of importing a table based on all the data in the import result file includes: determining whether the number of data contents imported from the import result file is greater than a first preset number; if the number of data contents imported is greater than the first preset number, sending an error message to indicate that the table import has failed; and if the number of data contents imported is less than or equal to the first preset number, indicating that the table import has succeeded.

[0060] The processor can determine whether the number of data items imported from the result file exceeds a first preset limit. This first preset limit can be set according to actual needs. If the imported number exceeds the first preset limit, it indicates that the parsed valid data content exceeds the maximum import limit, and the processor can send an exception message, confirming that the table import failed. If the imported number is less than or equal to the first preset limit, it indicates that the parsed valid data content does not exceed the maximum import limit, and the processor can confirm that the table import was successful.

[0061] In this embodiment of the application, the method further includes: determining whether the number of imported data contents in the import result file is greater than a second preset number; if the number of imported data contents is less than the second preset number, processing the data contents of each attribute under each internationalized header in real time; if the number of imported data contents is greater than or equal to the second preset number, processing the data contents of each attribute under each internationalized header asynchronously.

[0062] The processor can determine whether the number of data items imported from the result file exceeds a second preset limit. This second preset limit can be set according to actual conditions. If the imported number is less than the second preset limit, it indicates a small number of items are being imported, and the processor can process the data content of each attribute under each internationalized header in real time. If the imported number is greater than or equal to the second preset limit, it indicates a large number of items are being imported, and the processor can process the data content of each attribute under each internationalized header asynchronously to ensure import efficiency.

[0063] In this embodiment of the application, the method further includes: when a user initiates an export request for a table in any language, invoking an export interceptor corresponding to the export request to intercept the export request; obtaining at least one data content to be exported, the export language to be used for exporting all data content, and the table entity class according to the export request; determining whether the number of at least one data content to be exported has reached the single export limit; if the number of single export has not reached the limit, determining the key value corresponding to the data content to be exported according to the table entity class; determining the internationalized table header corresponding to the data content to be exported under the export language according to the key value and the internationalization file; and filling each data content into the attribute under each internationalized table header to generate an export file corresponding to the data content to be exported.

[0064] Users can initiate export requests for tables in any language. In this embodiment, a new `ControllerBeanDefinitionProcessor` class is created, which can automatically scan classes under a specified package and identify methods that export annotations during the Spring application context initialization process. The processor can call the export interceptor corresponding to the export request through the `ControllerBeanDefinitionProcessor` class to intercept the export request.

[0065] In this embodiment, the export interceptor includes an export annotation, which includes first target information, first reserved information, proof information, public interface exportable information, string export path information, string export file name information, first data threshold information, first data restriction information, first type information, and string callback name information. Specifically, the first target information specifies the data export logic; the first reserved information specifies that the export annotation is read at runtime via reflection; the proof information generates metadata information; the public interface exportable information defines the name and public access level of the export annotation; the string export path information specifies the base path of the exported table; the string export file name information specifies the default file name of the exported table; the first data threshold information specifies the data threshold for asynchronous processing; the first data restriction information specifies the maximum number of exported data; the first type information specifies the callback class to be executed after export; and the string callback name information specifies the name of the callback bean.

[0066] For example, the import annotation can be represented by @Exportable. The @Exportable annotation can include the following parts:

[0067] (1) @Target({ElementType.METHOD}): This is the first target information, indicating that this annotation can be applied to methods, meaning that it is designed to modify methods that perform data export operations.

[0068] (2) @Retention(RetentionPolicy.RUNTIME): This is the first retention information. It sets the retention policy of the annotation to runtime, ensuring that the annotation can be accessed through reflection during program execution.

[0069] (3) @Documented: This is the documentation information. This annotation will be recorded by JavaDoc so that this metadata information can be included when generating development documentation.

[0070] (4) `public@interface Exportable`: This refers to the publicly exportable information of the interface. It defines the annotation name `Exportable` and its public access level. The annotation contains several configuration attributes to customize the export behavior:

[0071] (5) String path()default"export": This is the string export path information, which specifies the default base directory path for the exported file as "export". The actual complete path of the exported file will be constructed based on this path.

[0072] (6) String fileName() default "export.xlsx": This is the string export file name information. The default export file name is set to "export.xlsx", which implies that the default export format is Excel.

[0073] (7) int asyncSize() default 1000: This is the first data threshold information, which defines the batch size of asynchronous data processing. The default value is 1000 records, which helps to optimize the performance of large-scale data export.

[0074] (8) int maxSize() default 10000: This is the first data limit information, which specifies the maximum number of records to be exported. The default value is 10000 records to prevent problems caused by excessive data volume.

[0075] (9) `Class<?>callbackClazz()default NullExportCallback.class`: This is the first type of information, specifying the callback class to be executed after the export is complete. The default is `NullExportCallback.class`, meaning that no callback operation will be executed unless otherwise specified. Users can define a custom callback class to handle the export process logic. This callback class must implement the `ExportCallback` interface, implement the `dataLoaded` method (used for batch processing of raw exported data), and implement the `beforeWrite` method (processing data before writing to the file, allowing time-consuming and laborious operations to be performed in this method).

[0076] (10) String callbackBeanName()default: This is the string callback name information. An additional attribute is added to specify the name of the callback bean. The default is an empty string. This allows for more flexible invocation of callback logic through Spring Beans, enhancing integration with the Spring framework.

[0077] The ControllerBeanDefinitionProcessor class in this embodiment may include the following parts:

[0078] (1) Class members and constructors: private static final Logger log: uses SLF4J for logging; private MetadataReaderFactory metadataReaderFactory: used to obtain the class's metadata; private ResourcePatternResolver resourcePatternResolver: used to locate and read resource files, such as classpath resources; private ApplicationContext applicationContext: references the Spring application context in order to obtain application configuration information.

[0079] (2) Interface Implementation: The implementation of the BeanDefinitionRegistryPostProcessor interface allows custom logic to be executed after all bean definitions have been registered but before bean instantiation. The PostProcessBeanDefinitionRegistry method is called at this time to scan and enhance eligible Controller classes; the implementations of the ResourceLoaderAware and ApplicationContextAware interfaces are used to inject resource loaders and application contexts, respectively, to access resources and application configurations.

[0080] (3) Method Resolution: postProcessBeanDefinitionRegistry: The entry point for executing the main logic. It checks whether the controller.enhancer.package property is configured, determines the packages to be scanned, calls the scannerPackages method to scan classes under the specified package, and finds methods annotated with @Exportable and @Importable. scannerPackages: Implements the package scanning logic. It constructs resource paths based on the given package name and uses ResourcePatternResolver to find all matching class resources. For each readable resource, it obtains the class's metadata through MetadataReaderFactory and attempts to load the class. For each class, it uses ReflectionUtils.MethodCallback to traverse all its methods, checks whether there are @Exportable or @Importable annotations, groups the methods with these annotations by class, and stores them in the global static variables ControllerEnhancer.exportableClazzSet and ControllerEnhancer.importableClazzSet for subsequent processing.

[0081] The ControllerEnhancer class implements the InitializingBean interface, which is used to call the afterPropertiesSet method to execute some initialization logic after all beans in the Spring container have been initialized. Its main function is to dynamically enhance the Controller class according to the configuration to achieve import and export functions.

[0082] The initialization logic (afterPropertiesSet) is as follows: (1) Configure RequestMappingInfo.BuilderConfiguration, which inherits the configuration of HandlerMapping, such as path matching rules, content negotiation strategy, etc.; (2) Call the exportEnhancer and importEnhancer methods respectively to enhance the Controller methods that need to be exported and imported.

[0083] Import Enhancer: For each method annotated with @Importable, create a new DTO class (dynamically generated via ByteBuddy) and add additional fields (such as importResult) and related annotations to it; create an instance of AbstractImportController and register the newly generated import method with RequestMappingHandlerMapping via reflection to respond to specific import request paths.

[0084] Export Enhancer: For each method annotated with @Exportable, a subclass is dynamically generated using ByteBuddy, and the original method is overridden to insert export logic; the new method is registered to RequestMappingHandlerMapping so that it can respond to specific export request paths.

[0085] The processor can obtain at least one piece of data to be exported, the export language to be used for exporting all data, and the table entity class based on the export request. The processor can determine whether the number of at least one piece of data to be exported has reached the single export limit. The single export limit can be set according to the actual situation.

[0086] In this embodiment of the application, determining whether the number of at least one data content to be exported has reached the single export limit includes: for each data content, determining whether the data content is a single pagination request instance to obtain the number of data contents to be exported; adjusting the parameters of the single pagination request instance corresponding to the data content to determine the number of data contents that can be exported; and determining whether the single export limit has been reached based on the number of data contents to be exported and the number of data contents that can be exported.

[0087] For each piece of data, the processor can determine whether it represents a single pagination request instance to calculate the number of data items that need to be exported, thus adapting to the requirements of paginated queries and exports. The processor can adjust the parameters of the single pagination request instance corresponding to the data item; for example, it can be set to the first page and one record per page to quickly determine the number of data items that can be exported. The processor can then determine whether the single export limit has been reached based on the number of data items that need to be exported and the number of data items that can be exported.

[0088] If the amount of data to be exported exceeds the current export limit, the single export limit has been reached. An exception message should be sent. If the amount of data to be exported is less than or equal to the current export limit, the single export limit has not been reached. In this case, the key value corresponding to the data to be exported can be determined based on the table entity class. The processor can then determine the corresponding internationalized header for the exported data in the export language based on the key value and the internationalization file. The processor can then populate each data item into the attribute under each internationalized header to generate the export file corresponding to the exported data.

[0089] When exporting a table, if the amount of data to be exported exceeds the set number for asynchronous export, the `doAsyncExport` method can be called, returning a `DownloadPage` object with a task ID, indicating that the task is not yet complete. If the amount of data to be exported is less than or equal to the set number for asynchronous export, the `doExport` method can be called directly to complete the export, and a download link can be set to the `DownloadPage` object.

[0090] like Figure 2 As shown, a flowchart illustrating another table processing method is provided.

[0091] When exporting Table A and Table B, the generation of Table A and Table B can be triggered. At this time, the AbstractExportController interceptor intercepts the export request, uses reflection to call the original methods of Table A and Table B to obtain data, calls the internationalization processing logic, generates an internationalized table class according to the corresponding table class, internationalization resources and language, calls the Covertor class to process the data according to the internationalization rules, thereby generating the export file and uploading the file.

[0092] The internationalization logic during table export includes: a. Parameter validation: First, check if the parameter is a single PageQueryRequest instance to accommodate paginated queries and exports; b. Pagination adjustment: Copy and adjust the PageQueryRequest parameter to set it to the first page and one record per page for quick record retrieval; c. Export limit check: Check the total data volume using exportable.maxSize(), and throw an exception if the limit is exceeded; d. Data export: Use originMethod to call the actual query method to obtain the complete data list. Initialize an ExportCallback instance, using caching to avoid duplicate creation. When the data volume exceeds exportable.asyncSize(), call the doAsyncExport method and return a DownloadPage object with a task ID, indicating that the task is incomplete and asynchronous export is performed. Otherwise, directly call the `doExport` method to complete the export and set the download link to the `DownloadPage` object for real-time export; e. Export: Based on the user request, obtain the user's Locale language and the request object, determine whether there is a corresponding internationalized table class in the current cache, if so, obtain the cached class; if not, obtain the corresponding language value of the `ResourceBundle` through the language and the value of the I18Nkey of the corresponding table entity class field, then generate the corresponding language table entity class through reflection and JavaPoet, and store it in the cache. f. Use the corresponding language table entity class to call `EasyExcelFactory.write` to generate the file, submit it to the file service for the user to download.

[0093] When importing tables C and D, the AbstractImportController interceptor intercepts the import request, calls the internationalization processing logic, generates an internationalized table class based on the corresponding table class, internationalization resources, and language, calls the Covertor class to process the data according to the internationalization rules, puts the data into the object, and uses reflection to call the original methods of tables A and B to obtain the data, thereby completing the data import of tables C and D.

[0094] The internationalization processing logic when importing tables includes: a. Processing user file parsing requests, i.e., importing based on user requests, obtaining the user's Local language, the requested object, and the Excel file to be imported; b. Determining whether there is an internationalized table class for the corresponding language in the current cache. If so, retrieving the cached class; otherwise, obtaining the language value corresponding to the internationalized resource file through the Local language and the value of the I18Nkey field in the corresponding table entity class, then generating the corresponding language table entity class through reflection and JavaPoet, and storing it in the cache; c. Using the corresponding language table entity class to call EasyExcel.read to parse the Excel file and remove blank lines. d. Check if the number of items in the parsed list is greater than `Importable.maxSize`. If the number exceeds the maximum limit, throw an exception. e. Check if the number of items in the parsed list is greater than `Importable.asyncSize`. If it is, call the asynchronous processing logic; if it is less, process in real time. f. Create a new processing result list, loop through the parsed list, call the `callbackClazz.beforeInvoke` method to parse the data, send a notification or verify the data before entering the business processing logic. If the method returns a non-empty value, record the reason directly and do not execute the business logic. If the return value is empty, reflectively call the method marked with `@Importable` to process the parsed data. Store the processing results in the processing result list. g. Use the processing result list to generate a file, upload it to a file service, and allow users to download and obtain the import results.

[0095] The above technical solutions result in more concise code for importing and exporting tables, improving scalability, readability, and maintainability. Based on the @Exportable or @Importable annotations, and by manipulating the corresponding table class and internationalization files, the internationalization of tables can be quickly integrated, improving the performance of importing tables and making the import and export of tables more efficient.

[0096] Figure 1 and Figure 2 This is a flowchart illustrating a table processing method in one embodiment. It should be understood that, although... Figure 1 and Figure 2 The steps in the flowchart are shown sequentially as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise explicitly stated herein, there is no strict order in which these steps are executed, and they can be performed in other orders. Figure 1 and Figure 2At least some of the steps in the process may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least some of the sub-steps or stages of other steps.

[0097] In one embodiment, a table processing apparatus is provided, comprising:

[0098] The memory is configured to store instructions;

[0099] The processor is configured to retrieve instructions from memory and, when executing instructions, to implement the aforementioned table processing method.

[0100] In one embodiment, a storage medium is provided on which a program is stored, which, when executed by a processor, implements the table processing method described above.

[0101] In one embodiment, a processor is provided for running a program, wherein the program executes the table processing method described above during runtime.

[0102] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 3 As shown. The computer device includes a processor A01, a network interface A02, memory (not shown), and a database (not shown) connected via a system bus. The processor A01 provides computing and control capabilities. The memory includes internal memory A03 and a non-volatile storage medium A04. The non-volatile storage medium A04 stores an operating system B01, a computer program B02, and a database (not shown). The internal memory A03 provides an environment for the operation of the operating system B01 and the computer program B02 stored in the non-volatile storage medium A04. The database is used to store data such as imported and exported data. The network interface A02 is used for communication with external terminals via a network connection. When the computer program B02 is executed by the processor A01, it implements a table processing method.

[0103] Those skilled in the art will understand that Figure 3 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0104] This application provides an apparatus, including a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it performs the following steps: Upon receiving a user-initiated import request for a table in any language, it calls an import interceptor corresponding to the import request to intercept the import request; it obtains the table to be imported and the import language required for the imported table based on the import request; it calls the table entity class corresponding to the table to obtain the key value of the I18Nkey annotation on the table entity class; it determines the internationalized header of the table in the import language based on the key value and the internationalization file; it parses the table to obtain the data content of each attribute under each internationalized header of the table; if the data content is not empty, it stores the data content in the import result file corresponding to the table; and it completes the import operation for the table based on all the data content in the import result file.

[0105] In one embodiment, completing the table import operation based on all data content in the import result file includes: determining whether the number of data contents to be imported in the import result file is greater than a first preset number; if the number of data contents to be imported is greater than the first preset number, sending an exception prompt and indicating that the table import has failed; if the number of data contents to be imported is less than or equal to the first preset number, indicating that the table import has succeeded.

[0106] In one embodiment, the method further includes: determining whether the number of data contents imported from the import result file is greater than a second preset number; if the number of imports is less than the second preset number, processing the data contents of each attribute under each internationalized header in real time; if the number of imports is greater than or equal to the second preset number, processing the data contents of each attribute under each internationalized header asynchronously.

[0107] In one embodiment, the method further includes: in the case of a user-initiated export request for a table in any language, invoking an export interceptor corresponding to the export request to intercept the export request; obtaining, based on the export request, at least one data content to be exported, the export language to be used for exporting all data content, and the table entity class; determining whether the number of at least one data content to be exported has reached the single export limit; if the number of single export has not reached the limit, determining the key value corresponding to the data content to be exported based on the table entity class; determining the internationalized table header corresponding to the data content to be exported under the export language based on the key value and the internationalization file; and filling each data content into the attribute under each internationalized table header to generate an export file corresponding to the data content to be exported.

[0108] In one embodiment, determining whether the number of at least one data content to be exported has reached the single export limit includes: for each data content, determining whether the data content is a single pagination request instance to obtain the number of data contents to be exported; adjusting the parameters of the single pagination request instance corresponding to the data content to determine the number of data contents that can be exported; and determining whether the single export limit has been reached based on the number of data contents to be exported and the number of data contents that can be exported.

[0109] In one embodiment, the export interceptor includes an export annotation, which includes first target information, first reserved information, proof information, public interface exportable information, string export path information, string export file name information, first data threshold information, first data restriction information, first class information, and string callback name information. Specifically, the first target information specifies the data export logic; the first reserved information specifies that the export annotation is read at runtime via reflection; the proof information generates metadata information; the public interface exportable information defines the name and public access level of the export annotation; the string export path information specifies the base path of the exported table; the string export file name information specifies the default file name of the exported table; the first data threshold information specifies the data threshold for asynchronous processing; the first data restriction information specifies the maximum number of exported data; the first class information specifies the callback class to be executed after export; and the string callback name information specifies the name of the callback bean.

[0110] In one embodiment, the I18Nkey annotation includes second target information, second target information, and attribute values. The second target information is used to specify that the I18Nkey annotation is only applied to the member variables of the class. The second target information is used to specify that the I18Nkey annotation is available at compile time and can be read at runtime through reflection. The attribute values ​​are used to store internationalized key values.

[0111] In one embodiment, the import interceptor includes an import annotation, which includes third target information, third reserved information, public interface importable information, string import path information, string import file name information, first type information, second data threshold information, second data restriction information, and third type information. The third target information is used to specify the data import logic, the third reserved information is used to specify that the import annotation is read at runtime via reflection, the public interface importable information is used to define the name and public access level of the import annotation, the string import path information is used to specify the base path of the imported table, the string import file name information is used to specify the default file name of the imported table, the first type information is used to read and process the class of the imported table, the second data threshold information is used to specify the data threshold value for asynchronous processing, the second data restriction information is used to specify the maximum number of imported data, and the third type information is used to define the callback class after the data import is completed.

[0112] This application also provides a computer program product that, when executed on a data processing device, is suitable for executing a program that initializes table processing method steps.

[0113] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0114] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0115] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0116] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0117] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0118] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0119] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0120] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0121] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

Claims

1. A table processing method, characterized in that, The method includes: In the event of a user-initiated import request for a table in any language, the import interceptor corresponding to the import request is invoked to intercept the import request. Based on the import request, obtain the table to be imported and the import language to be used for importing the table; Call the table entity class corresponding to the table to obtain the key value of the I18Nkey annotation on the table entity class; The internationalized header of the table under the imported language is determined based on the key value and the internationalization file; Parse the table to obtain the data content of each attribute under each internationalized header of the table; If the data content is not empty, the data content is stored in the import result file corresponding to the table; Complete the import operation for the table based on all the data content in the import result file; The import interceptor includes import annotations, which include third target information, third reserved information, public interface importable information, string import path information, string import file name information, first type of information, second data threshold information, second data restriction information, and third type of information; The third target information is used to specify the data import logic; the third reserved information is used to specify that the import annotation is read through reflection at runtime; the public interface importable information is used to define the name and public access level of the import annotation; the string import path information is used to specify the base path of the imported table; the string import file name information is used to specify the default file name of the imported table; the first type of information is used to read and process the imported table; the second data threshold information is used to specify the data threshold value for asynchronous processing; the second data limit information is used to specify the maximum limit number of imported data; and the third type of information is used to define the callback class after the data import is completed.

2. The table processing method according to claim 1, characterized in that, The step of completing the import operation for the table based on all the data content in the import result file includes: Determine whether the number of data contents imported from the import result file is greater than a first preset number; If the number of imported items exceeds the first preset number, an error message is sent to indicate that the import of the table has failed. If the number of imported data is less than or equal to the first preset number, the import of the table is determined to be successful.

3. The table processing method according to claim 1, characterized in that, The method further includes: Determine whether the number of data contents imported from the import result file is greater than the second preset number; If the number of imports is less than the second preset number, the data content of each attribute under each internationalized header will be processed in real time. If the number of imports is greater than or equal to the second preset number, the data content of each attribute under each internationalized header is processed asynchronously.

4. The table processing method according to claim 1, characterized in that, The method further includes: In the event of a user-initiated export request for a table in any language, the export interceptor corresponding to the export request is invoked to intercept the export request. Based on the export request, obtain at least one piece of data that needs to be exported, the export language required to export all data, and the table entity class; Determine whether at least one piece of data to be exported has reached the single export limit; If the single export limit is not reached, determine the key value corresponding to each data content that needs to be exported based on the table entity class. Based on the key value and the internationalization file, determine the internationalized header corresponding to the data content to be exported in the export language; Each data item is entered into the attribute under each internationalized header to generate an export file corresponding to the data item that needs to be exported.

5. The table processing method according to claim 4, characterized in that, The determination of whether the minimum amount of data to be exported has reached the single export limit includes: For each piece of data, determine whether the data content is a single pagination request instance to obtain the number of data contents that need to be exported. Adjust the parameters of a single pagination request instance corresponding to the data content to determine the amount of data content that can be exported at present; Determine whether the single export limit has been reached based on the amount of data that needs to be exported and the amount of data that can be exported.

6. The table processing method according to claim 4, characterized in that, The export interceptor includes export annotations, which include first target information, first retention information, proof information, public interface exportable information, string export path information, string export file name information, first data critical information, first data restriction information, first type information, and string callback name information. Wherein, the first target information is used to specify the data export logic, the first retention information is used to specify that the exported annotation is read through reflection mechanism at runtime, the proof information is used to generate metadata information, the public interface exportable information is used to define the name and public access level of the exported annotation, the string export path information is used to specify the base path of the exported table, the string export file name information is used to specify the default file name of the exported table, the first data threshold information is used to specify the data threshold value for asynchronous processing, the first data restriction information is used to specify the maximum number of exported data, the first class information is used to specify the callback class to be executed after the export is completed, and the string callback name information is used to specify the name of the callback bean.

7. The table processing method according to claim 1, characterized in that, The I18Nkey annotation includes second target information and attribute values. The second target information is used to specify that the I18Nkey annotation is only applied to the member variables of the class, and the attribute values ​​are used to store internationalized key values.

8. A form processing device, characterized in that, The device includes: The memory is configured to store instructions; A processor is configured to retrieve the instructions from the memory and, when executing the instructions, to implement the table processing method according to any one of claims 1 to 7.

9. A machine-readable storage medium storing instructions thereon, characterized in that, When executed by a processor, this instruction causes the processor to be configured to perform the table processing method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Formatting method for overseas project user-defined internationalized tags and date numbers

    CN106682242A

  • Form file import method, server and computer readable storage medium

    CN116226051A