Table processing method and device and storage medium

By using import interceptors and export interceptors in table processing, parsing and processing international table headers, the performance bottlenecks and code readability problems in the existing technology when handling complex tables are solved, and efficient table import and export are achieved.

CN120012731AActive Publication Date: 2025-05-16ZHONGKE YUNGU TECH
View PDF 4 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

The prior art has problems such as performance bottlenecks, high memory consumption, and poor code readability and maintainability when processing complex tables containing multilingual text.

Method used

By calling the import interceptor and export interceptor, parsing the table and generating international table headers, processing data content in real time or asynchronously, generating import result files or export files, improving the performance and efficiency of table processing.

Benefits of technology

It improves the performance and efficiency of importing tables, improves the readability and maintainability of codes, and solves the problems of memory overflow and performance bottlenecks in the existing technology.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120012731A_ABST
    Figure CN120012731A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a table processing method and device and a storage medium. The method comprises the following steps: when a user initiates an import request for a table of any language, calling an import interceptor corresponding to the import request to intercept the import request; according to the import request, obtaining a table needing to be imported and an import language needing to be adopted for importing the table; calling a table entity class corresponding to the table to obtain a key value of the I18Nkey annotation on the table entity class; according to the key value and the internationalized file, determining a corresponding internationalized header of the table under the import language; analyzing the table to obtain data content of each attribute under each internationalized header of the table; when the data content is not empty, storing the data content into an import result file corresponding to the table; according to all the data contents in the import result file, the import operation for the table is completed, the table import performance is improved, the table import efficiency is higher, and the code readability and maintainability are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a table processing method, device and storage medium. Background Art

[0002] With the expansion of global business, multi-language support of software products has become one of the key factors to improve user experience. The traditional table internationalization solution uses Apache's POI library, which has no native ability to extract the table header into an object to read and generate an Excel table.

[0003] Use the POI class library to implement table internationalization. Because POI tends to load the entire Excel table file into memory for operation, it may consume more memory when processing large Excel table files. For internationalized files containing large amounts of data or complex formats, it may cause memory overflow problems, especially in resource-constrained environments. POI may encounter performance bottlenecks when loading the entire Excel table file into memory for operation. For example, when processing complex tables containing multilingual text, the performance impact may be more obvious. POI must process tables in code, and cannot abstract specific class objects for flexible operation.

[0004] Therefore, the solutions adopted in the prior art for processing table internationalization consume a large amount of memory and have a poor impact on performance, code readability and maintainability when processing complex tables containing multi-language texts. Summary of the invention

[0005] The purpose of the embodiments of the present application is to provide a table processing method, device and storage medium to solve the problems in the prior art of poor performance, code readability and maintainability when processing complex tables containing multi-language texts.

[0006] In order to achieve the above-mentioned purpose, the first aspect of the present application provides a table processing method, comprising:

[0007] In case of an import request for a table in any language initiated by a user, an import interceptor corresponding to the import request is called to intercept the import request through the import interceptor;

[0008] Obtain the form to be imported and the language to be used for importing the form according to 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 internationalized table header corresponding to the table in 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 table header;

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

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

[0014] In an embodiment of the present application, completing the import operation for the table based on all the data content in the import result file includes: determining whether the import quantity of the data content in the import result file is greater than a first preset quantity; if the import quantity is greater than the first preset quantity, sending an abnormal prompt and the import of the table fails; if the import quantity is less than or equal to the first preset quantity, the import of the table is successful.

[0015] In an embodiment of the present application, the method also includes: determining whether the imported quantity of data content in the import result file is greater than a second preset quantity; when the imported quantity is less than the second preset quantity, processing the data content of each attribute under each internationalization header in real time; when the imported quantity is greater than or equal to the second preset quantity, asynchronously processing the data content of each attribute under each internationalization header.

[0016] In an embodiment of the present application, the method also includes: in the case of an export request initiated by a user for a table in any language, calling an export interceptor corresponding to the export request to intercept the export request through the export interceptor; obtaining at least one data content to be exported, the export language required to export all the data content, and the table entity class according to the export request; judging whether the at least one data content to be exported reaches the single export limit; if the single export limit is not reached, determining the key value corresponding to the data content currently required to be exported according to the table entity class; determining the internationalization header corresponding to the data content currently required to be exported under the export language according to the key value and the internationalization file; filling each data content into the attributes under each internationalization header to generate an export file corresponding to the data content currently required to be exported.

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

[0018] In an embodiment of the present application, the export interceptor includes an export annotation, and the export annotation includes first target information, first reserved 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 category information and string callback name information; wherein, the first target information is used to specify the data export logic, the first reserved information is used to specify the reading of the export annotation through the reflection mechanism during 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 export 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 critical information is used to specify the data critical value of asynchronous processing, the first data restriction information is used to specify the maximum limit on the exported data, the first category information is used to specify the callback class executed after the export is completed, and the string callback name information is used to specify the name of the callback bean.

[0019] In an embodiment of the present 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 member variables of the class. The second target information is used to specify that the I18Nkey annotation is available at compile time and read through the reflection mechanism at runtime. The attribute value is used to store internationalized key values.

[0020] In an embodiment of the present application, the import interceptor includes an import annotation, and the import annotation includes third target information, third reserved information, public interface importable information, string import path information, string import file name information, first category information, second data critical information, second data restriction information and third category information; the third target information is used to specify the data import logic, the third reserved information is used to specify the reading of the import annotation through the reflection mechanism during 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 category information is used to read and process the class of the imported table, the second data critical information is used to specify the data critical value for asynchronous processing, the second data restriction information is used to specify the maximum limit on the imported data, and the third category information is used to define the callback class after the data import is completed.

[0021] A second aspect of the present application provides a table processing device, comprising:

[0022] a memory configured to store instructions;

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

[0024] A third aspect of the present application provides a machine-readable storage medium, on which instructions are stored. When the instructions are executed by a processor, the processor is configured to execute the above-mentioned table processing method.

[0025] Through the above technical solution, in the case of an import request initiated by a user for a table in any language, the import interceptor corresponding to the import request is called to intercept the import request through the import interceptor; the table to be imported and the import language required for importing the table are obtained according to the import request; the table entity class corresponding to the table is called to obtain the key value of the I18Nkey annotation on the table entity class; the internationalization header corresponding to the table in the import language is determined according to the key value and the internationalization file; the table is parsed to obtain the data content of each attribute under each internationalization header of the table; when the data content is not empty, the data content is stored in the import result file corresponding to the table; the import operation for the table is completed according to all the data content in the import result file, the performance of importing the table is improved, the efficiency of importing the table is higher, and the code readability and maintainability are improved.

[0026] Other features and advantages of the embodiments of the present application will be described in detail in the subsequent specific implementation section. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] The accompanying drawings are used to provide a further understanding of the embodiments of the present application and constitute a part of the specification. Together with the following specific implementations, they are used to explain the embodiments of the present application, but do not constitute a limitation on the embodiments of the present application. In the accompanying drawings:

[0028] Figure 1 The flowchart of the table processing method according to the embodiment of the present application is schematically shown;

[0029] Figure 2 A schematic diagram of a flow chart of a table processing method according to another embodiment of the present application is shown;

[0030] Figure 3 The internal structure diagram of a computer device according to an embodiment of the present application is schematically shown. DETAILED DESCRIPTION

[0031] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the specific implementation methods described herein are only used to illustrate and explain the embodiments of the present application, and are not used to limit the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0032] It should be noted that if there are descriptions involving "first", "second", etc. in the embodiments of the present application, the descriptions of "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or suggesting their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.

[0033] Figure 1 The flowchart of the table processing method according to the embodiment of the present application is schematically shown. Figure 1 As shown, in one embodiment of the present application, a table processing method is provided, comprising the following steps:

[0034] Step 101: When a user initiates an import request for a table in any language, an import interceptor corresponding to the import request is called to intercept the import request through the import interceptor.

[0035] The user can initiate an import request for a table in any language. In the embodiment of the present application, a new ControllerBeanDefinitionProcessor class is created, which can automatically scan the classes under the specified package during the initialization of the Spring application context and identify the imported annotated methods. The processor can call the import interceptor corresponding to the import request through the ControllerBeanDefinitionProcessor class to intercept the import request through the import interceptor.

[0036] In an embodiment of the present application, 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 category information, second data critical information, second data restriction information and third category information; the third target information is used to specify the data import logic, the third reserved information is used to specify the reading of the import annotation through the reflection mechanism during the 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 basic 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 category information is used to read and process the class of the imported table, the second data critical information is used to specify the data critical value of asynchronous processing, the second data restriction information is used to specify the maximum limit of the imported data, and the third category information is used to define the callback class after the data import is completed.

[0037] For example, an import annotation can be represented by @Importable. 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 annotate methods that are responsible for data import logic.

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

[0040] (3) public@interfaceImportable: public interface importable information, defines the name of the annotation Importable and its public access level, and defines multiple attributes within the annotation, providing configuration flexibility for the import function:

[0041] (4)Stringpath()default"import": string import path information, specifies the base path of the imported file, the default is "import", this path may be used to construct a complete file path.

[0042] (5)StringfileName()default"import.xlsx": string import file name information, specifies the default import file name, and the suffix indicates that the file to be processed is an Excel file. The default name is "import.xlsx".

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

[0044] (7) intasyncSize() default1000: the second data critical information, which sets the critical value of asynchronous data processing. If the critical value exceeds the critical value, 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 imported 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 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 the compilation period and can be read through the reflection mechanism during the 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 to be used for importing the table according to the import request. After obtaining the table to be imported, the processor can call the table entity class corresponding to the table to obtain the key value of the I18Nkey annotation on the table entity class, that is, the key value. For example, @I18nKey (key = 1). The processor can determine the internationalization header corresponding to the table in the import language according to the key value and the internationalization file. Among them, the internationalization file includes headers in different languages ​​for the same key value, that is, each language includes multiple key values, and each key value corresponds to a 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 table header of the table.

[0054] Step 106: When the data content is not empty, the data content is stored in 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 internationalization header of the table. If the data content is not empty, it means that valid data content is parsed, and the processor can store the data content into the import result file corresponding to the table.

[0056] In one embodiment, when the data content is empty, it may be explained that the parsed data content is invalid, for example, it may be a blank line, etc. At this time, the processor may remove the data content and may not store the data content into the import result file corresponding to the table.

[0057] Step 107: Complete the import operation for the table according to all the data contents in the import result file.

[0058] The number of non-empty data contents obtained when parsing the table may exceed the maximum import quantity that can be tolerated. At this time, in order to ensure normal import of the table, the processor can complete the import operation for the table according to all the data contents in the import result file.

[0059] In an embodiment of the present application, completing the import operation for the table based on all the data content in the import result file includes: determining whether the import quantity of the data content in the import result file is greater than a first preset quantity; if the import quantity is greater than the first preset quantity, sending an exception prompt to determine that the import of the table has failed; if the import quantity is less than or equal to the first preset quantity, determining that the import of the table has been successful.

[0060] The processor can determine whether the import quantity of the data content in the import result file is greater than the first preset quantity. Among them, the first preset quantity can be set according to actual needs. In the case where the import quantity is greater than the first preset quantity, it can be said that the valid data content parsed at this time exceeds the maximum import quantity. At this time, the processor can send an abnormal prompt and determine that the import table failed. In the case where the import quantity is less than or equal to the first preset quantity, it can be said that the valid data content parsed at this time does not exceed the maximum import quantity. At this time, the processor can determine that the import table is successful.

[0061] In an embodiment of the present application, the method also includes: determining whether the imported quantity of data content in the import result file is greater than a second preset quantity; when the imported quantity is less than the second preset quantity, processing the data content of each attribute under each internationalization header in real time; when the imported quantity is greater than or equal to the second preset quantity, asynchronously processing the data content of each attribute under each internationalization header.

[0062] The processor can determine whether the import quantity of the data content in the import result file is greater than the second preset quantity. The second preset quantity can be set according to the actual situation. When the import quantity is less than the second preset quantity, it can be said that the import quantity at this time is small, and the processor can process the data content of each attribute under each internationalization header in real time. When the import quantity is greater than or equal to the second preset quantity, it can be said that the import quantity at this time is large, and the processor can asynchronously process the data content of each attribute under each internationalization header to ensure import efficiency.

[0063] In an embodiment of the present application, the method also includes: in the case of an export request initiated by a user for a table in any language, calling an export interceptor corresponding to the export request to intercept the export request through the export interceptor; obtaining at least one data content to be exported, the export language required to export all the data content, and the table entity class according to the export request; judging whether the at least one data content to be exported reaches the single export limit; if the single export limit is not reached, determining the key value corresponding to the data content currently required to be exported according to the table entity class; determining the internationalization header corresponding to the data content currently required to be exported under the export language according to the key value and the internationalization file; filling each data content into the attributes under each internationalization header to generate an export file corresponding to the data content currently required to be exported.

[0064] The user can initiate an export request for a table in any language. In the embodiment of the present application, a new ControllerBeanDefinitionProcessor class is created, which can automatically scan the classes under the specified package during the Spring application context initialization process to identify the export annotated methods. The processor can call the export interceptor corresponding to the export request through the ControllerBeanDefinitionProcessor class to intercept the export request through the export interceptor.

[0065] In an embodiment of the present application, the export interceptor includes an export annotation, and the export annotation includes first target information, first reserved 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 category information and string callback name information; wherein, the first target information is used to specify the data export logic, the first reserved information is used to specify the reading of the export annotation through the reflection mechanism during 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 export 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 critical information is used to specify the data critical value of asynchronous processing, the first data restriction information is used to specify the maximum limit on the exported data, the first category information is used to specify the callback class executed after the export is completed, and the string callback name information is used to specify the name of the callback bean.

[0066] For example, an 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, which sets the annotation’s retention policy to runtime, ensuring that the annotation can be accessed through the reflection mechanism while the program is running.

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

[0070] (4) public@interface Exportable: public interface exportable information, defines the name of the annotation Exportable and its public access level. The annotation contains several configuration properties for customizing export behavior:

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

[0072] (6)String fileName()default"export.xlsx": This is the string export file name information. It sets the default export file name to "export.xlsx", which means the default export format is Excel.

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

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

[0075] (9)Class<?>callbackClazz()default NullExportCallback.class: The first type of information specifies the callback class to be executed after the export is completed. The default is NullExportCallback.class, which means that if no special specification is made, no callback operation will be performed. Users can customize a callback class to handle the export process logic. The callback class needs to implement the ExportCallback interface and implement the dataLoaded method: used to batch process the original export data; implement the beforeWrite method: to process the data before writing the file. Time-consuming and laborious operations can be performed in this method.

[0076] (10)String callbackBeanName()default: String callback name information, adds an additional attribute to specify the name of the callback bean, and defaults to an empty string. This allows more flexibility in calling callback logic through SpringBean, enhancing the integration capability 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 Metadata Reader Factory metadata Reader Factory: used to obtain class metadata; private Resource Pattern Resolver resource Pattern Resolver: used to locate and read resource files, such as class path resources; private Application Context application Context: references the Spring application context 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 are registered but before beans are instantiated. The PostProcessBeanDefinitionRegistry method is called at this time to scan and enhance eligible Controller classes; the implementation 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 analysis: postProcessBeanDefinitionRegistry: The entry point for executing the main logic, used to check whether the controller.enhancer.package property is configured, determine the package that needs to be scanned, call the scannerPackages method to scan the classes under the specified package, and find methods with @Exportable and @Importable annotations. scannerPackages: Implements package scanning logic, used to build a resource path based on the given package name, and uses ResourcePatternResolver to find all matching class resources. For each readable resource, obtain the class metadata through MetadataReaderFactory and try to load the class. For each class, use ReflectionUtils.MethodCallback to traverse all its methods, check whether there is an @Exportable or @Importable annotation, group the methods with these annotations by class, and store 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 are initialized. Its main function is to dynamically enhance the Controller class according to the configuration to realize the import and export functions.

[0082] The initialization logic (afterPropertiesSet) is: (1) configure RequestMappingInfo.BuilderConfiguration to inherit 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 by ByteBuddy) and add additional fields (such as importResult) and relevant annotations to it; create an instance of AbstractImportController and register it with RequestMappingHandlerMapping for the newly generated import method through reflection to respond to the specific import request path.

[0084] Export Enhancer: For each method annotated with @Exportable, use ByteBuddy to dynamically generate a subclass, override the original method to insert the export logic; register the new method to RequestMappingHandlerMapping so that it can respond to specific export request paths.

[0085] The processor may obtain at least one data content to be exported, the export language to be used to export all the data content, and the table entity class according to the export request. The processor may determine whether the at least one data content to be exported reaches the single export limit. The single export limit may be set according to actual conditions.

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

[0087] For each data content, the processor can determine whether the data content is a single paging request instance to obtain the number of data contents currently required to be exported, thereby meeting the needs of paging query and export. The processor can adjust the parameters of the single paging request instance corresponding to the data content, for example, it can be set to the first page and one record per page to quickly determine the number of data contents that can be exported currently. The processor can determine whether the single export limit is reached based on the number of data contents currently required to be exported and the number of data contents that can be exported currently.

[0088] If the number of data contents that currently need to be exported is greater than the number of data contents that can currently be exported, it can be said that the single export limit has been reached. At this time, an exception prompt can be sent. If the number of data contents that currently need to be exported is less than or equal to the number of data contents that can currently be exported, it can be said that the single export limit has not been reached. At this time, the key value corresponding to the data content that currently needs to be exported can be determined based on the table entity class. The processor can determine the internationalization header corresponding to the data content that currently needs to be exported in the export language based on the key value and the internationalization file. The processor can fill each data content into the attributes under each internationalization header to generate an export file corresponding to the data content that currently needs to be exported.

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

[0090] like Figure 2 As shown, a flowchart of 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, calls the original methods of Table A and Table B through reflection 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 an export file and uploading the file.

[0092] Among them, the internationalization processing logic when exporting tables includes: a. Parameter verification: first check whether the parameter is a single PageQueryRequest instance, which is to meet the needs of paging query and export; b. Paging adjustment: copy and adjust the PageQueryRequest parameter, set it to the first page and 1 record per page, so as to quickly obtain the total number of records; c. Check the export limit: check the total amount of data according to exportable.maxSize(), and throw an exception if it exceeds the limit; d. Data export: use originMethod to call the actual query method to obtain a complete data list. Initialize the ExportCallback instance and use the cache to avoid repeated creation. When the amount of data is greater than exportable.asyncSize(), call the doAsyncExport method and return a DownloadPage object with a task ID, indicating that the task is not completed 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, according to the user request, obtain the user Locale language and request object, determine whether there is an internationalized table class of the corresponding language in the current cache, if so, obtain the cache class, if not, obtain the corresponding language value of ResourceBundle through the language and the value of the I18Nkey of the corresponding table entity class field, and 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 a file, submit it to the file service, and let the user download it.

[0093] When importing Table C and Table D, the AbstractImportController interceptor intercepts the import request, 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, puts the data into the object, and calls the original methods of Table A and Table B through reflection to obtain the data, thereby completing the data import of Table C and Table D.

[0094] Among them, the internationalization processing logic when importing a table includes: a. Processing user file parsing requests, that is, importing according to user requests, obtaining the user's Local language, request object and imported Excel file; b. Determining whether there is an internationalized table class of the corresponding language in the current cache, if so, obtaining the cache class, if not, obtaining the corresponding language value of the internationalized resource file through the Local language and the value of the I18Nkey of the corresponding table entity class field, and 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 , store the valid value in List; d. Determine whether the number of parsed Lists is greater than Importable.maxSize. If the number of imports exceeds the maximum limit, report an exception directly; e. Determine whether the number of parsed Lists is greater than Importable.asyncSize. If it is greater, call the asynchronous processing logic. If it is less, process in real time; f. Create a new processing result List, loop 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 return value of this method is not empty, directly record the reason and do not execute the business logic. If the return value is empty, reflectively call the method originally marked by @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 and upload the file service for users to download and obtain the import results.

[0095] Through the above technical solution, when importing and exporting tables, the code is more concise, which improves scalability, readability and maintainability. Based on the @Exportable annotation or @Importable annotation, and then operating the corresponding table class and internationalization file, the internationalization processing access of the table can be completed quickly, the performance of importing tables is improved, and the efficiency of importing and exporting tables is higher.

[0096] Figure 1 and Figure 2 FIG. 1 is a flow chart of 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 in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1 and Figure 2At least part of the steps 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 part of the sub-steps or stages of other steps.

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

[0098] a memory configured to store instructions;

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

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

[0101] In one embodiment, a processor is provided, and the processor is used to run a program, wherein the above table processing method is executed when the program is run.

[0102] In one embodiment, a computer device is provided. The computer device 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, a memory (not shown in the figure) and a database (not shown in the figure) connected through a system bus. Among them, the processor A01 of the computer device is used to provide computing and control capabilities. The memory of the computer device includes an 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 in the figure). The internal memory A03 provides an environment for the operation of the operating system B01 and the computer program B02 in the non-volatile storage medium A04. The database of the computer device is used to store data such as import and export data. The network interface A02 of the computer device is used to communicate with an external terminal through a network connection. When the computer program B02 is executed by the processor A01, a table processing method is implemented.

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

[0104] An embodiment of the present application provides a device, which includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, the following steps are implemented: in the case of an import request for a table in any language initiated by a user, calling an import interceptor corresponding to the import request to intercept the import request through the import interceptor; obtaining the table to be imported and the import language to be adopted for importing the table according to the import request; calling a table entity class corresponding to the table to obtain the key value of the I18Nkey annotation on the table entity class; determining the internationalization 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 internationalization header of the table; when the data content is not empty, storing the data content in 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.

[0105] In one embodiment, completing the import operation for the table based on all the data content in the import result file includes: determining whether the import quantity of the data content in the import result file is greater than a first preset quantity; if the import quantity is greater than the first preset quantity, sending an exception prompt and the import of the table fails; if the import quantity is less than or equal to the first preset quantity, the import of the table is successful.

[0106] In one embodiment, the method also includes: determining whether the imported quantity of data content in the import result file is greater than a second preset quantity; when the imported quantity is less than the second preset quantity, processing the data content of each attribute under each internationalization header in real time; when the imported quantity is greater than or equal to the second preset quantity, asynchronously processing the data content of each attribute under each internationalization header.

[0107] In one embodiment, the method also includes: in the case of an export request initiated by a user for a table in any language, calling an export interceptor corresponding to the export request to intercept the export request through the export interceptor; obtaining at least one data content to be exported, the export language required to export all the data content, and the table entity class according to the export request; judging whether the at least one data content to be exported reaches the single export limit; if the single export limit is not reached, determining the key value corresponding to the data content currently required to be exported according to the table entity class; determining the internationalization header corresponding to the data content currently required to be exported under the export language according to the key value and the internationalization file; filling each data content into the attributes under each internationalization header to generate an export file corresponding to the data content currently required to be exported.

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

[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 critical information, first data restriction information, first category information and string callback name information; wherein the first target information is used to specify the data export logic, the first reserved information is used to specify the reading of the export annotation through the reflection mechanism during 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 export 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 critical information is used to specify the data critical value of asynchronous processing, the first data restriction information is used to specify the maximum limit on the exported data, the first category information is used to specify the callback class executed after the export is completed, and the string callback name information is used to specify the name of the callback bean.

[0110] In one embodiment, 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 member variables of the class, the second target information is used to specify that the I18Nkey annotation is available at compile time and is read through the reflection mechanism at runtime, and the attribute value is 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 category information, second data critical information, second data restriction information and third category information; the third target information is used to specify the data import logic, the third reserved information is used to specify the reading of the import annotation through the reflection mechanism 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 category information is used to read and process the class of the imported table, the second data critical information is used to specify the data critical value for asynchronous processing, the second data restriction information is used to specify the maximum limit on the imported data, and the third category information is used to define the callback class after the data import is completed.

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

[0113] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0114] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0115] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0116] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions 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] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0119] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules 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 technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0120] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0121] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.

Claims

1. A table processing method, characterized in that: The method comprises: In case of an import request for a table in any language initiated by a user, calling an import interceptor corresponding to the import request to intercept the import request through the import interceptor; Acquire the form to be imported and the import language to be used for importing the form according to the import request; Call the table entity class corresponding to the table to obtain the key value of the I18Nkey annotation on the table entity class; Determine the internationalization header corresponding to the table in the imported language according to the key value and the internationalization file; Parsing the table to obtain the data content of each attribute under each internationalization header of the table; If the data content is not empty, storing the data content into an import result file corresponding to the table; The import operation for the table is completed according to all the data contents in the import result file.

2. The table processing method according to claim 1, characterized in that: The completing the import operation for the table according to all the data contents in the import result file comprises: Determine whether the imported quantity of the data content in the imported result file is greater than a first preset quantity; In the case where the imported quantity is greater than the first preset quantity, sending an abnormal prompt to determine that the import of the table fails; When the imported quantity is less than or equal to the first preset quantity, it is determined that the import of the table is successful.

3. The table processing method according to claim 1, characterized in that: The method further comprises: Determine whether the imported quantity of the data content in the imported result file is greater than a second preset quantity; When the imported quantity is less than the second preset quantity, processing the data content of each attribute under each internationalization header in real time; When the import quantity is greater than or equal to the second preset quantity, the data content of each attribute under each internationalization header is processed asynchronously.

4. The table processing method according to claim 1, characterized in that: The method further comprises: In case of an export request for a table in any language initiated by a user, calling an export interceptor corresponding to the export request to intercept the export request through the export interceptor; According to the export request, at least one data content currently required to be exported, the export language required to export all the data content, and the table entity class are obtained; Determine whether at least one data content to be exported reaches a single export limit; In the case that the single export limit quantity is not reached, determining the key value corresponding to each data content currently required to be exported according to the table entity class; Determine the internationalization header corresponding to the data content currently required to be exported in the export language according to the key value and the internationalization file; Each data content is filled into the attributes under each internationalization header to generate an export file corresponding to the data content currently required to be exported.

5. The table processing method according to claim 4, characterized in that: The step of determining whether the at least one data content to be exported reaches a single export limit includes: For each data content, determine whether the data content is a single paging request instance to obtain the number of data contents currently required to be exported; Adjusting the parameters of a single paging request instance corresponding to the data content to determine the amount of data content that can be exported currently; Whether the single export limit quantity is reached is determined according to the quantity of data contents currently required to be exported and the quantity of data contents currently capable of being exported.

6. The table processing method according to claim 4, characterized in that: The export interceptor includes an export annotation, and the export annotation includes first target information, first reserved information, certification information, public interface exportable information, string export path information, string export file name information, first data critical information, first data restriction information, first category information, and string callback name information; Among them, the first target information is used to specify the data export logic, the first retention information is used to specify that the export annotation is read through the reflection mechanism during runtime, the certification information is used to generate metadata information, the public interface exportable information is used to define the name and public access level of the export 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 critical information is used to specify the data critical value of asynchronous processing, the first data restriction information is used to specify the maximum limit on the exported data, the first category information is used to specify the callback class 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, second target information and attribute value, the second target information is used to specify that the I18Nkey annotation is only applied to member variables of the class, the second target information is used to specify that the I18Nkey annotation is available at compile time and is read through a reflection mechanism at runtime, and the attribute value is used to store internationalized key values.

8. The table processing method according to claim 1, characterized in that: The import interceptor includes an import annotation, and the import annotation includes third target information, third reserved information, public interface importable information, string import path information, string import file name information, first category information, second data critical information, second data restriction information and third category information; The third target information is used to specify the data import logic, the third retention information is used to specify reading the import annotation through the reflection mechanism during 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 category information is used to read and process the class of the imported table, the second data critical information is used to specify the data critical value for asynchronous processing, the second data limit information is used to specify the maximum limit on the imported data, and the third category information is used to define the callback class after the data import is completed.

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

10. A machine-readable storage medium having instructions stored thereon, characterized in that: When the instruction is executed by a processor, the processor is configured to execute the table processing method according to any one of claims 1 to 8.

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

  • LIMS internationalization report custom generation method, device, equipment and medium

    CN117709324A

  • Data importing method and device, electronic device and storage medium

    CN118114632A