Methods, modules, and software systems for exporting Excel files
By customizing the header and data body of the Excel file and using interface and method definitions to process the query data list, the problem of low efficiency in exporting Excel files in the WMS system is solved, and an efficient export method is achieved.
Patent Information
- Application Number
- CN202310224943.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-03
- Publication Date
- 2025-11-14
- Estimated Expiration
- 2043-03-03
AI Technical Summary
Existing technologies are inefficient when exporting Excel files from WMS systems, and the unpredictable nature of user needs leads to a large amount of repetitive work, increasing development costs.
The header and data body of the exported Excel file are customized by defining interface and method information, and mapping rules are used to process the query data list, reducing repetitive workload.
It significantly improves the efficiency of exporting Excel files, reduces the workload of technical research and development, and provides flexible export methods.
Smart Images

Figure CN116226252B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer computing, and in particular to a method, module, and software system for exporting Excel files. Background Technology
[0002] In WMS systems, a common business function is to export various data, such as material information, user information, warehouse information, and inventory information, to Excel files for enterprise users to perform data statistics or year-end reports. Different enterprises have different uses for the exported data, resulting in varying export requirements. In the WMS system, this means that every page may have export requirements, and different users may have different requirements for the exported content of the same data list. This uncertainty leads to front-end and back-end spending a significant amount of time developing and implementing the function, modifying or even customizing the content of the exported Excel file according to different user needs. However, because different export functions have highly repetitive processing logic, this results in tedious and repetitive work, adding extra time costs to system development.
[0003] Therefore, existing methods for exporting Excel files are currently inefficient. Summary of the Invention
[0004] The purpose of this invention is to provide a method, module, and software system for exporting Excel files, so as to improve the efficiency of exporting Excel files.
[0005] In a first aspect, embodiments of the present invention provide a method for exporting an Excel file, comprising: receiving query conditions sent by a client from a general export interface; the query conditions including: a query interface name, a query method, header information, and the filename of the Excel file to be exported; the header information including multiple sets of key-value pairs, wherein the key of each set of key-value pairs is a field name, and the value is the Chinese name corresponding to the field name; determining the interface definition information and method definition information of the query interface based on the query interface name and the query method; determining class information based on the interface definition information and the method definition information; parsing the class information to obtain the fields in the class information and the annotation content corresponding to the fields; constructing mapping rules based on the fields and the annotation content; parsing the header information to obtain the target header information of the Excel file to be exported; calling the query interface according to the interface definition information and the method definition information, querying the database through the query interface to obtain a query data list; processing the query data list according to the mapping rules to obtain a data body list; and outputting the Excel file to be exported based on the filename of the Excel file to be exported, the data body list, and the target header information.
[0006] In conjunction with the first aspect, the present invention provides a first possible implementation of the first aspect, wherein the annotation content includes a sorting identifier and a value replacement identifier; the step of constructing a mapping rule based on the field and the annotation content includes: determining a sorting rule based on the field and the sorting identifier, and determining a value replacement rule based on the field and the value replacement identifier.
[0007] In conjunction with the first possible implementation of the first aspect, this embodiment of the invention provides a second possible implementation of the first aspect, wherein the step of determining the sorting rule based on the above-mentioned fields and the above-mentioned sorting identifier includes: obtaining the sorting value of the field corresponding to the above-mentioned sorting identifier; and constructing the sorting rule of the above-mentioned fields and the above-mentioned sorting identifier based on the size of the above-mentioned sorting value.
[0008] In conjunction with the first possible implementation of the first aspect, this embodiment of the invention provides a third possible implementation of the first aspect, wherein the value replacement identifier is defined by a dictionary value; the step of determining the value replacement rule based on the field and the value replacement identifier includes: obtaining the dictionary value in the value replacement identifier; querying the corresponding dictionary name based on the dictionary value; and constructing the value replacement rule based on the dictionary value, the dictionary name, and the field.
[0009] In conjunction with the first possible implementation of the first aspect, this embodiment of the invention provides a fourth possible implementation of the first aspect, wherein the step of processing the query data list according to the above mapping rules to obtain a data body list includes: sorting the query data list according to the above sorting rules to obtain an ordered data list; and performing value replacement on the ordered data list according to the above value replacement rules to obtain a data body list.
[0010] In conjunction with the first aspect, this embodiment of the invention provides a fifth possible implementation of the first aspect, wherein the step of parsing the above header information to obtain the target header information of the Excel file to be exported includes: parsing the above header information to obtain the values of the key-value pairs in the above header information; and using the values of the above key-value pairs as the target header information of the Excel file to be exported.
[0011] In conjunction with the first aspect, this invention provides a sixth possible implementation of the first aspect, wherein the step of outputting the Excel file to be exported based on the filename of the Excel file to be exported, the data body list, and the target header information includes: passing the filename of the Excel file to be exported to EasyExcel to construct an initial ExcelWriter object; creating an initial WriteSheet table; storing the data body list and the target header information into the initial WriteSheet table to obtain a target WriteSheet table; writing the target WriteSheet table into the initial ExcelWriter object to obtain a target ExcelWriter object; and converting the target ExcelWriter object into a byte stream and returning it to the client, so that the client can output the Excel file to be exported based on the byte stream.
[0012] In conjunction with the first aspect, this embodiment of the invention provides a seventh possible implementation of the first aspect, wherein, before the step of determining the interface definition information and method definition information of the query interface based on the query interface name and the query method, the method further includes: querying whether the query interface name and the query method are both valid; if both are valid, determining the interface definition information and method definition information of the query interface based on the query interface name and the query method; otherwise, returning a prompt message indicating that the query interface name is invalid, and ending the export task.
[0013] Secondly, embodiments of the present invention provide a module for exporting Excel files, comprising: a query condition receiving submodule, used to receive query conditions sent by a client from a general export interface; the query conditions include: a query interface name, a query method, header information, and the filename of the Excel file to be exported; the header information includes multiple sets of key-value pairs, where the key of each key-value pair is a field name, and the value is the Chinese name corresponding to the field name; a custom information determining submodule, used to determine the interface definition information and method definition information of the query interface based on the query interface name and the query method; a class information determining submodule, used to determine class information based on the interface definition information and the method definition information; and an annotation content determining submodule, used to parse the class information to obtain the class information. The module includes: a field definition and its corresponding annotation; a mapping rule construction submodule, used to construct mapping rules based on the fields and annotations; a header information determination submodule, used to parse the header information to obtain the target header information of the Excel file to be exported; a query data list acquisition submodule, used to call the query interface based on the interface definition and method definition, query the database through the query interface, and obtain the query data list; a data body list acquisition submodule, used to process the query data list according to the mapping rules to obtain the data body list; and an Excel file export submodule, used to output the Excel file to be exported based on the filename of the Excel file to be exported, the data body list, and the target header information.
[0014] Thirdly, embodiments of the present invention provide a software system, wherein the software system includes: the module for exporting Excel files as described in the second aspect, a user and role basic information management module, an inbound management module, an outbound management module, and an inventory management module; wherein the user and role basic information management module, the inbound management module, the outbound management module, the inventory management module, and the module for exporting Excel files are sequentially connected; the user and role basic information management module is used to create executable permissions for users; the inbound management module is used to execute the inbound process corresponding to the executable permissions according to the executable permissions and create inbound documents; the outbound management module is also used to execute the outbound process corresponding to the executable permissions according to the executable permissions and create outbound documents; the inventory management module is used to adjust the inventory quantity according to the inbound documents and the outbound documents; the module for exporting Excel files is used to export the user information of the users, the inbound documents, the outbound documents, the file names of the Excel files to be exported corresponding to the inventory quantity, the data subject list, and the target header information, and output the Excel files to be exported.
[0015] The embodiments of the present invention bring the following beneficial effects:
[0016] This invention provides a method, module, and software system for exporting Excel files, comprising: receiving query conditions sent by a client from a general export interface; the query conditions including: a query interface name, a query method, header information, and the filename of the Excel file to be exported; the header information including multiple key-value pairs, where the key of each key-value pair is a field name, and the value is the Chinese name corresponding to the field name; determining the interface definition information and method definition information of the query interface based on the query interface name and the query method; determining class information based on the interface definition information and the method definition information; parsing the class information to obtain the fields in the class information and the annotation content corresponding to the fields; constructing mapping rules based on the fields and the annotation content; parsing the header information to obtain the target header information of the Excel file to be exported; calling the query interface according to the interface definition information and the method definition information, querying the database through the query interface to obtain a query data list; processing the query data list according to the mapping rules to obtain a data body list; and outputting the Excel file to be exported based on the filename of the Excel file to be exported, the data body list, and the target header information. This method allows for customized configuration of the header and data body of the exported content through interface definition information and method definition information, significantly reducing the workload of technical research and development and improving research and development efficiency.
[0017] Other features and advantages disclosed in this embodiment will be set forth in the following description, or some features and advantages may be inferred from the description or determined without doubt, or may be learned by practicing the techniques described above.
[0018] To make the above-mentioned objects, features and advantages of this disclosure more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0019] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0020] Figure 1 A flowchart illustrating a method for exporting an Excel file according to an embodiment of the present invention;
[0021] Figure 2 A flowchart illustrating another method for exporting an Excel file provided in an embodiment of the present invention;
[0022] Figure 3 This is a schematic diagram of the structure of a module for exporting Excel files provided in an embodiment of the present invention;
[0023] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention.
[0024] Icons: 31-Query Condition Receiving Submodule; 32-Custom Information Determination Submodule; 33-Class Information Determination Submodule; 34-Annotation Content Determination Submodule; 35-Mapping Rule Construction Submodule; 36-Table Header Information Determination Submodule; 37-Query Data List Retrieval Submodule; 38-Data Body List Retrieval Submodule; 39-Excel File Export Submodule; 41-Export Excel File Module; 42-User and Role Basic Information Management Module; 43-Inbound Management Module; 44-Outbound Management Module; 45-Inventory Management Module. Detailed Implementation
[0025] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0026] Currently, a common business function frequently used in WMS systems is exporting various data, such as material information, user information, warehouse information, and inventory information, to Excel files for enterprise users to perform data statistics or year-end reports. Different enterprises have different uses for the exported data, resulting in varying export requirements. In the WMS system, this means that every page may have export requirements, and different users may have different requirements for the exported content of the same data list. This uncertainty leads to front-end and back-end spending a significant amount of time developing and implementing the function, modifying or even customizing the content of the exported Excel file to varying degrees according to different user needs. However, because different export functions have highly repetitive content in some processing logic, this results in tedious and repetitive work, adding extra time costs to system development.
[0027] Based on this, embodiments of the present invention provide a method, module, and software system for exporting Excel files. This technology can alleviate the aforementioned technical problems and improve the efficiency of exporting Excel files. To facilitate understanding of the embodiments of the present invention, a method for exporting Excel files disclosed in the embodiments of the present invention will first be described in detail.
[0028] Example 1
[0029] Figure 1 This is a flowchart illustrating a method for exporting an Excel file according to an embodiment of the present invention. Figure 1 As seen, the method includes the following steps:
[0030] Step S101: Receive the query conditions sent by the client from the general export interface; the query conditions include: query interface name, query method, header information and file name of the Excel file to be exported; the header information includes multiple sets of key-value pairs, where the key of each set of key-value pairs is the field name and the value is the Chinese name corresponding to the field name.
[0031] In this embodiment, if the query conditions sent by the client are received from the general export interface, the Excel file to be exported corresponding to the query conditions is parsed, and a set of key-value pairs is formed by using the field name of the Excel file to be exported as the key and the Chinese name rendered by the corresponding field as the value, and stored in a list as the table header information. The front end passes in the query conditions for querying this list, the interface name and method used to query the list, and the specified file name of the Excel file to be generated. All of the above conditions are passed in as export conditions and the export interface is called.
[0032] Step S102: Based on the query interface name and the query method described above, determine the interface definition information and method definition information of the query interface.
[0033] Step S103: Determine class information based on the above interface definition information and the above method definition information.
[0034] In this embodiment, the specific interface definition information and method definition information are first obtained based on the input query interface name and query method, and the input query conditions are converted into JSON data objects. Then, the above query interface name is input in the manner of general interface calling, so as to obtain the returned data of this list through the above query method and the processed query conditions, and thus determine the class information based on the above returned data.
[0035] Step S104: Parse the above class information to obtain the fields in the above class information and the annotation content corresponding to the above fields.
[0036] In this embodiment, this type of information is parsed to obtain the fields contained in the class and the multiple annotations modifying these fields. Different annotations correspond to different functional implementations and judgments. The annotations currently used mainly have two functions: one is to indicate whether the field needs to be replaced, that is, to pre-mark whether the value of the corresponding field needs to be processed. For example, in the system, "No" is often replaced with 1 or 0 and stored in the database. However, for users, the meaning of 1 and 0 is not intuitive. Therefore, it can be marked by annotations, and the replacement processing can be performed when parsing the data, thereby obtaining the fields in the above class information and the annotations corresponding to the above fields.
[0037] Step S105: Construct mapping rules based on the above fields and annotation content.
[0038] In this embodiment, the fields in this type of information are parsed to have annotations used for sorting, and the sorting value of the field in the annotation is obtained. If only one field in this type of information is modified by this annotation, the sorting is performed directly according to the value corresponding to this field. If multiple fields are modified by this annotation, a mapping structure between fields and sorting is formed, and the values of different fields are sorted according to the size of the field sorting value, thereby constructing the above-mentioned annotation content construction mapping rules.
[0039] Step S106: Parse the above header information to obtain the target header information of the Excel file to be exported.
[0040] Here, the above value, i.e., the Chinese name, is used as the header information of the exported Excel file, and the corresponding field names are obtained and stored in the above annotation content to construct the mapping rules. Thus, the target header information of the Excel file to be exported can be obtained by parsing the above header information through the above step S106.
[0041] Step S107: Call the query interface according to the above interface definition information and the above method definition information, and query the database through the query interface to obtain the query data list.
[0042] Here, the system parses the query data list obtained in the above steps. By default, the system converts the queried data into a list of JSON objects, meaning this list contains JSON data. The system iterates through and parses this list of JSON objects, retrieving the corresponding fields based on their names. If the current field is stored in the mapping rules constructed by the annotations mentioned above, the list is reordered according to the corresponding annotation mapping rules to ensure order, and this sorted data is then re-stored in the query data list.
[0043] Step S108: Process the above query data list according to the above mapping rules to obtain the data subject list.
[0044] Here, the system typically returns more information about the objects than the fields displayed in the list. These undisplayed fields are often irrelevant to the user. Therefore, during export, the decision to export a field depends on whether the front-end provides that field. Furthermore, the front-end's display fields can be exposed for user-defined configuration. This way, the list displays the corresponding fields based on the user's configuration, and the front-end receives the displayed fields as the list during export. While this increases the front-end's workload, it provides a more flexible export method. Further, after obtaining the corresponding field values, some are processed and the original values are replaced to ensure good readability of the exported Excel content. First, the mapping structure is used to determine if the current field name has a corresponding conversion value. If a corresponding conversion value exists, the original value is replaced. If no corresponding conversion value exists, the original value is used directly. The processed values are then added to the data body list, resulting in the aforementioned data body list.
[0045] Step S109: Output the Excel file to be exported based on the filename of the Excel file to be exported, the above data body list, and the above target header information.
[0046] This invention provides a method for exporting an Excel file, comprising: receiving query conditions sent by a client from a general export interface; the query conditions including: a query interface name, a query method, header information, and the filename of the Excel file to be exported; the header information including multiple key-value pairs, where the key of each key-value pair is a field name, and the value is the Chinese name corresponding to the field name; determining the interface definition information and method definition information of the query interface based on the query interface name and the query method; determining class information based on the interface definition information and the method definition information; parsing the class information to obtain the fields in the class information and the annotation content corresponding to the fields; constructing mapping rules based on the fields and the annotation content; parsing the header information to obtain the target header information of the Excel file to be exported; calling the query interface according to the interface definition information and the method definition information, querying the database through the query interface to obtain a query data list; processing the query data list according to the mapping rules to obtain a data body list; and outputting the Excel file to be exported based on the filename of the Excel file to be exported, the data body list, and the target header information. This method allows for customized configuration of the header and data body of the exported content through interface definition information and method definition information, significantly reducing the workload of technical research and development and improving research and development efficiency.
[0047] Example 2
[0048] exist Figure 1 Based on the method shown, for exporting an Excel file, Figure 2 This is a flowchart illustrating another method for exporting Excel files provided in an embodiment of the present invention. Figure 2 As seen, the method includes:
[0049] Step S201: Receive the query conditions sent by the client from the general export interface; the query conditions include: query interface name, query method, table header information and file name of the Excel file to be exported; the table header information includes multiple sets of key-value pairs, where the key of each set of key-value pairs is the field name and the value is the Chinese name corresponding to the field name.
[0050] Step S202: Based on the query interface name and the query method described above, determine the interface definition information and method definition information of the query interface.
[0051] In one embodiment, before step S202, the method further includes: first, checking whether the query interface name and the query method are both valid. If both are valid, determining the interface definition information and method definition information of the query interface based on the query interface name and the query method. Otherwise, returning a message indicating that the query interface name is invalid, and ending the export task.
[0052] Step S203: Determine class information based on the above interface definition information and the above method definition information.
[0053] Step S204: Parse the above class information to obtain the fields in the above class information and the annotation content corresponding to the above fields; wherein, the above annotation content includes sorting identifier and value replacement identifier.
[0054] Step S205: Determine the sorting rule based on the above fields and the above sorting identifier, and determine the value replacement rule based on the above fields and the above value replacement identifier.
[0055] Here, the steps for determining the sorting rules based on the aforementioned fields and sorting identifiers include: First, obtaining the sorting value of the field corresponding to the sorting identifier. Then, constructing the sorting rules for the aforementioned fields and sorting identifiers based on the magnitude of the sorting value.
[0056] Furthermore, the aforementioned value replacement identifier is defined using dictionary values; the determination of the value replacement rule based on the aforementioned fields and the aforementioned value replacement identifier includes the following steps A1-A3:
[0057] Step A1: Obtain the dictionary value in the above value replacement identifier.
[0058] Step A2: Query the corresponding dictionary name based on the dictionary value above.
[0059] Step A3: Construct value replacement rules based on the dictionary values, dictionary names, and fields mentioned above.
[0060] Step S206: Parse the above header information to obtain the target header information of the Excel file to be exported.
[0061] Step S206 above includes: First, parsing the header information to obtain the values of the key-value pairs in the header information. Then, using the values of the key-value pairs as the target header information of the Excel file to be exported.
[0062] Step S207: Call the query interface according to the above interface definition information and the above method definition information, and query the database through the query interface to obtain the query data list.
[0063] Step S208: Process the above-mentioned query data list according to the above sorting rules and value replacement rules to obtain the data body list.
[0064] Here, step S208 includes: First, sorting the query data list according to the above sorting rules to obtain an ordered data list. Then, replacing the values in the ordered data list according to the above value replacement rules to obtain a data body list.
[0065] In this embodiment, the system typically returns more object content information than the fields displayed in the aforementioned data body list. Therefore, these undisplayed fields are mostly content that users are not interested in. Thus, during export, the decision to export a field is based on whether the frontend provides that field. Furthermore, the frontend's display fields can be exposed for user-defined configuration. This way, the list displays the corresponding fields according to the user's custom configuration, and during export, the frontend passes the displayed fields as the list. While this increases the frontend's workload, it provides a more flexible export method. Further, the mapping structure is used to determine if the current field name has a corresponding conversion value. If a corresponding conversion value exists, the original value is replaced. If no corresponding conversion value exists, the original value is used directly. Finally, the processed value is added to the aforementioned data body list.
[0066] Step S209: Output the Excel file to be exported based on the filename of the Excel file to be exported, the above data body list, and the above target header information.
[0067] Here, step S209 above includes the following steps B1-B5:
[0068] Step B1: Pass the filename of the Excel file to be exported to EasyExcel to construct an initial ExcelWriter object.
[0069] Step B2: Create the initial WriteSheet table.
[0070] Step B3: Store the above data body list and the above target header information into the above initial WriteSheet table to obtain the target WriteSheet table.
[0071] Step B4: Write the target WriteSheet table to the initial ExcelWriter object to obtain the target ExcelWriter object.
[0072] Step B5: Convert the target ExcelWriter object into a byte stream and return it to the client so that the client can output the Excel file to be exported based on the byte stream.
[0073] This invention provides a method for exporting an Excel file, comprising: receiving query conditions sent by a client from a general export interface; the query conditions including: a query interface name, a query method, header information, and the filename of the Excel file to be exported; the header information including multiple key-value pairs, where the key of each key-value pair is a field name, and the value is the Chinese name corresponding to the field name; determining the interface definition information and method definition information of the query interface based on the query interface name and the query method; determining class information based on the interface definition information and the method definition information; parsing the class information to obtain the fields in the class information and the annotation content corresponding to the fields; wherein the annotation content includes a sorting identifier and a value replacement identifier; constructing a mapping rule based on the fields and the annotation content; parsing the header information to obtain the target header information of the Excel file to be exported; calling the query interface according to the interface definition information and the method definition information, querying the database through the query interface to obtain a query data list; processing the query data list according to the sorting rule and the value replacement rule to obtain a data body list; and outputting the Excel file to be exported based on the filename of the Excel file to be exported, the data body list, and the target header information. This method allows for customized configuration of the header and data body of the exported content by defining interface and method information and based on sorting and value replacement rules, thereby reducing the workload of technical research and development and improving research and development efficiency.
[0074] Example 3
[0075] Figure 3 This is a schematic diagram of the structure of a module for exporting Excel files, provided in an embodiment of the present invention. Figure 3 As can be seen, this module includes:
[0076] The query condition receiving submodule 31 is used to receive query conditions sent by the client from the general export interface. The query conditions include: query interface name, query method, table header information and file name of the Excel file to be exported. The table header information includes multiple sets of key-value pairs, where the key of each set of key-value pairs is the field name and the value is the Chinese name corresponding to the field name.
[0077] The custom information determination submodule 32 is used to determine the interface definition information and method definition information of the query interface based on the query interface name and the query method mentioned above.
[0078] The class information determination submodule 33 is used to determine class information based on the above interface definition information and the above method definition information.
[0079] The annotation content determination submodule 34 is used to parse the above class information to obtain the fields in the above class information and the annotation content corresponding to the above fields.
[0080] The mapping rule construction submodule 35 is used to construct mapping rules based on the above fields and the above annotation content.
[0081] The header information determination submodule 36 is used to parse the above header information to obtain the target header information of the Excel file to be exported.
[0082] The query data list retrieval submodule 37 is used to call the query interface based on the interface definition information and the method definition information, and query the database through the query interface to obtain the query data list.
[0083] The data subject list acquisition submodule 38 is used to process the above-mentioned query data list according to the above mapping rules to obtain the data subject list.
[0084] Excel file export submodule 39 is used to output the Excel file to be exported based on the file name of the Excel file to be exported, the above data body list and the above target header information.
[0085] The above-mentioned query condition receiving submodule 31, the above-mentioned custom information determining submodule 32, the above-mentioned class information determining submodule 33, the above-mentioned annotation content determining submodule 34, the above-mentioned mapping rule construction submodule 35, the above-mentioned table header information determining submodule 36, the above-mentioned query data list obtaining submodule 37, the data body list obtaining submodule 38, and the above-mentioned Excel file exporting submodule 39 are connected in sequence.
[0086] The module for exporting Excel files provided in this embodiment of the invention has the same technical features as the method for exporting Excel files provided in the above embodiments, and therefore can solve the same technical problems and achieve the same technical effects. Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working process of the module described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0087] Example 4
[0088] This embodiment provides a software system. Figure 4 This is a schematic diagram of the structure of a software system provided in an embodiment of the present invention. Figure 4 As seen above, the software system includes: the Excel file export module 41, the user and role basic information management module 42, the inbound management module 43, the outbound management module 44, and the inventory management module 45 in the above embodiments.
[0089] The aforementioned user and role basic information management module 42, the aforementioned inbound management module 43, the aforementioned outbound management module 44, the aforementioned inventory management module 45, and the aforementioned export Excel file module 41 are connected in sequence.
[0090] In actual operation, the aforementioned user and role basic information management module 42, the aforementioned inbound management module 43, the aforementioned outbound management module 44, and the aforementioned inventory management module 45 are connected in sequence; the aforementioned user and role basic information management module 42, the aforementioned inbound management module 43, and the aforementioned outbound management module 44 are all connected to the aforementioned Excel file export module 41.
[0091] Furthermore, the aforementioned user and role basic information management module 42 is used to create executable permissions for users; the aforementioned inbound management module 43 is used to execute the inbound process corresponding to the aforementioned executable permissions and create inbound documents; the aforementioned outbound management module 44 is also used to execute the outbound process corresponding to the aforementioned executable permissions and create outbound documents; the aforementioned inventory management module 45 is used to adjust the inventory quantity based on the aforementioned inbound documents and the aforementioned outbound documents; the aforementioned export Excel file module 41 is used to export the aforementioned user information, the aforementioned inbound documents, the aforementioned outbound documents, the filename of the Excel file to be exported corresponding to the aforementioned inventory quantity, the aforementioned data subject list, and the aforementioned target header information, and output the aforementioned Excel file to be exported.
[0092] In this embodiment, the aforementioned software system is a WMS system, namely a warehouse management system. The WMS system creates users and corresponding executable permissions through a user and role basic information management module. Users execute the inbound process through the inbound management module, creating inbound documents, executing the receiving process, completing inbound tasks and documents, and ultimately affecting the inventory quantity in the inventory management module, causing it to increase. Conversely, users execute the outbound process through the outbound management module, creating outbound documents, executing the allocation and dispatch process, completing outbound tasks and documents, and ultimately affecting the inventory quantity in the inventory management module, causing it to decrease. The inventory management module records the actual inventory quantity in the system, as well as the actual execution results of the inbound and outbound modules and the corresponding inventory quantity increase / decrease data. Therefore, in the aforementioned management module, whether it's the user and role basic information data, the document content of the inbound and outbound management module, or the inventory information records in the inventory management module, all are data information managed by the WMS. This data information can be used as the data subject involved in the aforementioned general export method to achieve the method of exporting Excel files.
[0093] The software system provided in this embodiment of the invention has the same technical features as the Excel file export module provided in the above embodiments, and therefore can solve the same technical problems and achieve the same technical effects. Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working process of the system described above can be referred to the corresponding process in the foregoing module embodiments, and will not be repeated here.
[0094] Furthermore, in the description of the embodiments of the present invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in the present invention based on the specific circumstances.
[0095] In the description of this invention, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing the invention and for simplifying the description, and do not indicate or imply that the module or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.
Claims
1. A method for exporting Excel files, characterized in that, include: Receive query conditions sent by the client from the general export interface; The query conditions include: query interface name, query method, table header information, and the file name of the Excel file to be exported; the table header information includes multiple sets of key-value pairs, where the key of each set of key-value pairs is the field name, and the value is the Chinese name corresponding to the field name; Based on the query interface name and the query method, determine the interface definition information and method definition information of the query interface; Class information is determined based on the interface definition information and the method definition information; Parse the class information to obtain the fields in the class information and the annotation content corresponding to the fields; A mapping rule is constructed based on the fields and the annotation content; Parse the header information to obtain the target header information of the Excel file to be exported; The query interface is invoked according to the interface definition information and the method definition information, and the database is queried through the query interface to obtain a list of query data; The query data list is processed according to the mapping rules to obtain a data body list; The Excel file to be exported is output based on the filename of the Excel file to be exported, the data body list, and the target header information.
2. The method for exporting Excel files according to claim 1, characterized in that, The annotation content includes sorting identifiers and value replacement identifiers; The step of constructing mapping rules based on the fields and the annotation content includes: The sorting rule is determined based on the field and the sorting identifier, and the value replacement rule is determined based on the field and the value replacement identifier.
3. The method for exporting Excel files according to claim 2, characterized in that, The step of determining the sorting rule based on the field and the sorting identifier includes: Obtain the sort value of the field corresponding to the sort identifier; The sorting rules for the field and the sorting identifier are constructed based on the size of the sorting value.
4. The method for exporting Excel files according to claim 2, characterized in that, The value replacement identifier is defined using dictionary values; The step of determining the value replacement rule based on the field and the value replacement identifier includes: Retrieve the dictionary value from the value replacement identifier; The corresponding dictionary name can be obtained by querying the dictionary value; A value replacement rule is constructed based on the dictionary value, the dictionary name, and the field.
5. The method for exporting Excel files according to claim 2, characterized in that, The steps of processing the query data list according to the mapping rules to obtain the data body list include: The query data list is sorted according to the sorting rules to obtain an ordered data list; The ordered data list is then subjected to value replacement based on the value replacement rules to obtain a data body list.
6. The method for exporting Excel files according to claim 1, characterized in that, The steps of parsing the header information to obtain the target header information of the Excel file to be exported include: Parse the header information to obtain the values of the key-value pairs in the header information; The value of the key-value pair is used as the target header information of the Excel file to be exported.
7. The method for exporting Excel files according to claim 1, characterized in that, The steps for outputting the Excel file to be exported based on the filename of the Excel file to be exported, the data body list, and the target header information include: Pass the filename of the Excel file to be exported to EasyExcel to construct an initial ExcelWriter object; Create the initial WriteSheet table; The data body list and the target header information are stored in the initial WriteSheet table to obtain the target WriteSheet table; Write the target WriteSheet table into the initial ExcelWriter object to obtain the target ExcelWriter object; The target ExcelWriter object is converted into a byte stream and returned to the client, so that the client can output the Excel file to be exported based on the byte stream.
8. The method for exporting Excel files according to claim 1, characterized in that, Before the step of determining the interface definition information and method definition information of the query interface based on the query interface name and the query method, the method further includes: Check whether the query interface name and the query method are both valid; If both are valid, determine the interface definition information and method definition information of the query interface based on the query interface name and the query method; Otherwise, return a message indicating that the query interface name is invalid and end the export task.
9. A module for exporting Excel files, characterized in that, The module for exporting Excel files includes: The query condition receiving submodule is used to receive query conditions sent by the client from the general export interface. The query conditions include: query interface name, query method, table header information, and the file name of the Excel file to be exported. The table header information includes multiple sets of key-value pairs, where the key of each set of key-value pairs is the field name, and the value is the Chinese name corresponding to the field name. The custom information determination submodule is used to determine the interface definition information and method definition information of the query interface based on the query interface name and the query method. The class information determination submodule is used to determine class information based on the interface definition information and the method definition information; The annotation content determination submodule is used to parse the class information to obtain the fields in the class information and the annotation content corresponding to the fields. The mapping rule construction submodule is used to construct mapping rules based on the fields and the annotation content; The header information determination submodule is used to parse the header information to obtain the target header information of the Excel file to be exported. The query data list retrieval submodule is used to call the query interface according to the interface definition information and the method definition information, and query the database through the query interface to obtain the query data list; The data subject list acquisition submodule is used to process the query data list according to the mapping rules to obtain the data subject list; The Excel file export submodule is used to output the Excel file to be exported based on the file name of the Excel file to be exported, the data body list, and the target header information.
10. A software system, characterized in that, The software system includes: the module for exporting Excel files as described in claim 9, the user and role basic information management module, the inbound management module, the outbound management module, and the inventory management module; The user and role basic information management module, the inbound management module, the outbound management module, the inventory management module, and the module for exporting Excel files are sequentially connected. The user and role basic information management module is used to create executable permissions for users; The inbound management module is used to execute the inbound process corresponding to the executable permissions and create inbound documents. The outbound management module is also used to execute the outbound process corresponding to the executable permission according to the executable permission, and to create outbound documents; The inventory management module is used to adjust the inventory quantity based on the inbound and outbound documents; The module for exporting Excel files is used to export the user's user information, the inbound documents, the outbound documents, the file names of the Excel files to be exported corresponding to the inventory quantity, the data subject list, and the target header information, and output the Excel files to be exported.
Citation Information
Patent Citations
Big-data SQL query method and system for SolrCloud
CN107229672A
Code generation method and device, electronic equipment and storage medium
CN114579109A