Report processing method, apparatus, device, medium, and computer program product
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA CONSTRUCTION BANK
- Filing Date
- 2023-09-27
- Publication Date
- 2026-08-07
AI Technical Summary
由正则匹配检索出的改造点只针对于函数,需要花费更多的时间实现对表名和字段的检索和替换,从而导致工作效率降低
[0039] The aforementioned report processing methods, devices, computer equipment, storage media, and computer program products acquire report files, extract structured query statements from the report files, and then extract functions, fields, and table names from the structured query statements. This allows for the decomposition of functions, table names, and fields within the structured query statements, thus obtaining the functions, table names, and fields within the structured query statements. By using the mapping relationship between functions in the source database of the currently running structured query statement and functions in the target database of the structured query statement to be run, functions in the structured query statement are replaced to obtain an initial structured query statement. Furthermore, by using a mapping dictionary based on the table names and fields in the source and target databases, table names and fields in the initial structured query statement are replaced, allowing for the automatic execution of the replacement of functions, table names, and fields within the structured query statement. This reduces the replacement time for functions, fields, and table names in the structured query statement, quickly obtaining the updated structured query statement after replacement, thereby improving work efficiency.
Smart Images

Figure CN117290359B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of big data and data processing technology, and in particular to a report processing method, apparatus, computer equipment, storage medium and computer program product. Background Technology
[0002] Currently, database localization has become a strategic direction for many enterprises. During this process, database systems are often upgraded from Oracle to domestically developed databases based on MySQL. While the syntax of query statements in these two databases is largely the same, there are many differences in their built-in functions. Often, functions supported by Oracle are replaced by other functions in domestically developed databases. This can lead to data sources in reports failing to execute correctly due to changes in the database system, resulting in the inability to retrieve target data. Another issue is that when existing projects need to be refactored, changes may be made to tables and fields in the database, which can also cause query statements in reports to fail, preventing the retrieval of corresponding data.
[0003] Currently, the typical approach to modifying reports involves first copying the report files from the system environment to the local machine, extracting the structural query statements, and then using regular expressions to identify the functions that need modification. However, since the modification points identified by regular expressions only apply to functions, it requires more time to search and replace table names and fields, thus reducing work efficiency. Summary of the Invention
[0004] Therefore, it is necessary to provide a report processing method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can improve work efficiency in response to the above-mentioned technical problems.
[0005] Firstly, this application provides a report processing method, the method comprising:
[0006] Obtain the report file and extract the structural query statements from the report file;
[0007] Extract the functions, table names, and fields from the structured query statement;
[0008] Based on the mapping relationship, the functions in the structured query statement are replaced to obtain the initial structured query statement; the mapping relationship represents the mapping between the functions in the source database where the structured query statement is currently running and the functions in the target database where the structured query statement is to be run.
[0009] Based on the mapping dictionary, the table names and fields in the initial structure query statement are replaced to obtain the updated structure query statement; the mapping dictionary represents the mapping between table names in the source database and table names in the target database, as well as the mapping between fields in the source database and fields in the target database.
[0010] In one embodiment, the method further includes:
[0011] The updated structure query statement is used to replace the structure query statement in the report file to obtain the updated report file;
[0012] The updated report file is uploaded to the server, and a preview request for the uploaded updated report file is sent to the server through an interface to obtain the preview request result; the server is used to identify the functions in the updated report file;
[0013] If the preview request result indicates that previewing is allowed, the data in the updated report file is obtained.
[0014] In one embodiment, before replacing the function in the structured query statement based on the mapping relationship to obtain the initial structured query statement, the process includes:
[0015] Determine the target database for the structure query statement to be executed, and the source database currently executing the structure query statement;
[0016] Based on the table name mapping relationship and field mapping relationship between the target database and the source database, a mapping dictionary between the target database and the source database is established;
[0017] Obtain functions with the same functionality from the source database and the target database;
[0018] Establish the correspondence between the functions that have the same function;
[0019] Based on the correspondence, the mapping relationship between the functions in the source database and the functions in the target database is determined.
[0020] In one embodiment, the method further includes:
[0021] If no function with the same functionality as the function in the source database exists in the target database, the function is rewritten according to the function logic to obtain a rewritten function with the same functionality as the function in the source database.
[0022] Establish a matching relationship between the rewritten function and the functions in the source database;
[0023] The mapping relationship is updated based on the matching relationship to obtain the updated mapping relationship.
[0024] In one embodiment, extracting the structure query statement from the report file includes:
[0025] Obtain the first content contained in the table data mapping tags of the report file;
[0026] Identify the table data tags in the first content; extract the content contained in the table data tags to obtain the second content;
[0027] Identify the query tags in the second content; extract the content contained in the query tags to obtain a structured query statement.
[0028] In one embodiment, the step of replacing the function in the structure query statement based on the mapping relationship to obtain the initial structure query statement includes:
[0029] Based on the mapping relationship, determine the target function that is consistent with the function in the structure query statement;
[0030] If the name of the target function differs from the name of the function, the name of the function is replaced with the name of the target function to obtain the initial structure query statement.
[0031] Secondly, this application provides a report processing apparatus, the apparatus comprising:
[0032] The statement extraction module is used to obtain report files and extract the structural query statements from the report files.
[0033] The statement splitting module is used to extract functions, table names, and fields from the structured query statement;
[0034] The first replacement module is used to replace the functions in the structured query statement based on the mapping relationship to obtain an initial structured query statement; the mapping relationship represents the mapping between the functions in the source database where the structured query statement is currently running and the functions in the target database where the structured query statement is to be run.
[0035] The second replacement module is used to replace the table name and the field in the initial structure query statement based on the mapping dictionary to obtain an updated structure query statement; the mapping dictionary represents the mapping between the table name in the source database and the table name in the target database, as well as the mapping between the field in the source database and the field in the target database.
[0036] Thirdly, this application provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the above-described method.
[0037] Fourthly, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-described method.
[0038] Fifthly, this application provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the above-described method.
[0039] The aforementioned report processing methods, devices, computer equipment, storage media, and computer program products acquire report files, extract structured query statements from the report files, and then extract functions, fields, and table names from the structured query statements. This allows for the decomposition of functions, table names, and fields within the structured query statements, thus obtaining the functions, table names, and fields within the structured query statements. By using the mapping relationship between functions in the source database of the currently running structured query statement and functions in the target database of the structured query statement to be run, functions in the structured query statement are replaced to obtain an initial structured query statement. Furthermore, by using a mapping dictionary based on the table names and fields in the source and target databases, table names and fields in the initial structured query statement are replaced, allowing for the automatic execution of the replacement of functions, table names, and fields within the structured query statement. This reduces the replacement time for functions, fields, and table names in the structured query statement, quickly obtaining the updated structured query statement after replacement, thereby improving work efficiency.
[0040] Furthermore, by replacing the structure query statement in the report file with the updated structure query statement, the report file can be updated to obtain the updated report file. By uploading the updated report file to the server and then previewing it through the interface, the functions in the updated report file can be identified, thus enabling a successful preview of the updated report file. If the preview is successful, the data in the updated report file can be obtained. Attached Figure Description
[0041] To more clearly illustrate the technical solutions in the embodiments or related technologies of this application, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0042] Figure 1 This is an application environment diagram of the report processing method in one embodiment;
[0043] Figure 2 This is a flowchart illustrating a report processing method in one embodiment;
[0044] Figure 3 This is a flowchart illustrating the data acquisition steps in one embodiment;
[0045] Figure 4 This is a flowchart illustrating the steps for establishing mapping relationships and a mapping dictionary in one embodiment;
[0046] Figure 5 This is a flowchart illustrating the function rewriting steps in one embodiment;
[0047] Figure 6 This is a flowchart illustrating the statement extraction steps in one embodiment;
[0048] Figure 7 This is a flowchart illustrating the function replacement step in one embodiment;
[0049] Figure 8 This is a structural block diagram of a report processing device in one embodiment;
[0050] Figure 9 This is a structural block diagram of the report processing device in another embodiment;
[0051] Figure 10 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0052] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0053] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0054] The report processing method provided in this application embodiment can be applied to, for example, Figure 1In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104 or placed on a cloud or other network server. Terminal 102 obtains a report file and then extracts the structure query statement from the report file to obtain the structure query statement. Terminal 102 extracts the functions, table names, and fields from the structure query statement to obtain the functions, fields, and table names in the structure query statement. Based on the mapping relationship between the functions in the source database of the currently running structure query statement and the functions in the target database of the structure query statement to be run, terminal 102 replaces the functions in the structure query statement to obtain the initial structure query statement. Based on the mapping dictionary determined by the mapping between table names in the source database and table names in the target database, and the mapping between fields in the source database and fields in the target database, terminal 102 replaces the table names and fields in the initial structure query statement to obtain the replaced updated structure query statement. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, etc. Server 104 can be implemented using a standalone server or a server cluster consisting of multiple servers.
[0055] In one exemplary embodiment, such as Figure 2 As shown, a report processing method is provided, which can be applied to... Figure 1 Taking the terminal in the example, the explanation includes the following steps 202 to 208. Wherein:
[0056] Step 202: Obtain the report file and extract the structure query statements from the report file.
[0057] The report files are automatically downloaded from the server via an interface between the server and the terminal. The report files are typically in XML format. They can be stored on the terminal's local hard drive. Automatically downloading report files from the server via this interface saves download time.
[0058] Structured query statements are SQL (Structured Query Language) extracted from report files using statement extraction tools. For example, the DOM (Document Object Model) tool can be used to extract structured query statements from report files, resulting in the structured query statements within the report file.
[0059] Optionally, the terminal automatically downloads report files from the server through an interface that interacts with the server. The terminal uses the DOM tool to extract statements from the downloaded report files, obtaining the structured query statements within the report files.
[0060] Step 204: Extract the functions, table names, and fields from the structured query statement.
[0061] In this context, functions, table names, and fields from a structured query statement are extracted simultaneously. For example, using JSQLParser (a structured query parsing tool) to parse a structured query statement into a traversable hierarchical structure of Java classes allows for the simultaneous separation or extraction of functions, table names, and fields from the structured query statement.
[0062] Optionally, the terminal uses the JSQLParser tool to parse the structured query statement obtained from the report file into a traversable hierarchical structure of Java classes, that is, to separate the functions, fields and table names in the structured query statement at the same time.
[0063] Step 206: Based on the mapping relationship, replace the functions in the structured query statement to obtain the initial structured query statement. The mapping relationship represents the mapping between functions in the source database of the currently running structured query statement and functions in the target database of the structured query statement to be run.
[0064] The source database for the currently running structured query statement refers to the database to which the functions and syntax carried by the structured query statement belong. For example, if a structured query statement can be successfully executed on a system with database A installed, meaning that the report file carrying the structured query statement can be successfully opened on a system with database A installed, then database A is the source database for the currently running structured query statement.
[0065] The target database for the structured query statement to be executed refers to the database to which the functions, table names, and fields carried in the structured query statement belong after function, table name, and field substitutions. For example, if you need to execute a structured query statement on a system where database B is installed, but the functions, fields, and table names carried in the structured query statement belong to database A, then you need to first replace the functions, fields, and table names carried in the structured query statement with functions, fields, and table names that the system with database B installed can recognize, and then execute the substituted structured query statement based on the system with database B installed. In this case, database A is the source database, and database B is the target database.
[0066] Two functions in the source and target databases that have a mapping relationship have the same functionality. For example, function A in the source database can be used to sort numbers in a report file, and function B in the target database can also be used to sort numbers in a report file; therefore, there is a mapping between function A and function B. The mapping relationship can be pre-built or built in real-time. A mapping relationship contains at least one pair of function mappings.
[0067] Function replacement refers to finding a function Y that maps to function X extracted from the structured query statement, and that function Y belongs to the target database, and then replacing function X in the structured query statement with function Y, thus completing the function replacement.
[0068] Optionally, the terminal pre-establishes a mapping relationship between the functions of the source database installed on the system currently running the structured query statement and the functions of the target database installed on the system to be run. Based on the established mapping relationship, the terminal obtains the functions that are mapped to the functions in the structured query statement and belong to the target database, and then uses the functions from the target database to replace the functions in the structured query statement to obtain the initial structured query statement.
[0069] Step 208: Based on the mapping dictionary, replace the table names and fields in the initial structure query statement to obtain the updated structure query statement. The mapping dictionary represents the mapping between table names in the source database and table names in the target database, as well as the mapping between fields in the source database and fields in the target database.
[0070] In this mapping, two table names or fields in the source and target databases have the same meaning and are mapped to each other. For example, if table name M in the source database means "personal information" and table name N in the target database also means "personal information," then there is a mapping between table name M and table name N. Similarly, if field m in the source database means "education level" and field n in the target database also means "education level," then there is a mapping between field m and field n. The mapping dictionary can be pre-built or constructed in real-time, and it must include at least one pair of table names and one pair of fields with corresponding mappings.
[0071] Optionally, the terminal pre-establishes a mapping dictionary based on the mapping between the fields and table names of the source database installed on the system currently running the structured query statement and the fields and table names of the target database installed on the system to be run. Based on the established mapping dictionary, the terminal retrieves fields from the mapping dictionary that are mapped to fields in the initial structured query statement and belong to the target database, and then replaces the fields in the initial structured query statement with the fields from the target database. Similarly, the terminal retrieves table names from the mapping dictionary that are mapped to table names in the initial structured query statement and belong to the target database, and then replaces the table names in the initial structured query statement with the table names from the target database, thus obtaining the updated structured query statement.
[0072] In one embodiment, the replacement of functions, table names, and fields in a structured query statement can be performed simultaneously, or the table names and fields in the structured query statement can be replaced first, followed by the replacement of functions. For example, functions, fields, and table names in a structured query statement can be replaced simultaneously based on mapping relationships and a mapping dictionary. Another example is that fields and table names in a structured query statement can be replaced first based on a mapping dictionary to obtain an initial structured query statement, and then functions in the initial structured query statement can be replaced based on mapping relationships to obtain an updated structured query statement.
[0073] In one embodiment, where the server can be used to extract and replace structured query statements in a report file, the server obtains the report file and then uses a DOM tool to extract the structured query statements from it. The server uses a JSQLParser tool to parse the structured query statements from the report file into a traversable hierarchy of Java classes, obtaining the functions, fields, and table names within the structured query statements. The server pre-establishes a mapping relationship between functions in the source database installed on the system currently running the structured query statement and functions in the target database installed on the system to be run. The server retrieves functions from this mapping relationship that are mapped to functions in the structured query statement and belong to the target database, and then replaces the functions in the structured query statement with the functions from the target database to obtain the initial structured query statement. The server pre-establishes a mapping dictionary based on the mapping between fields and table names in the source database installed on the system currently running the structured query statement and fields and table names in the target database installed on the system to be run. The server retrieves fields from the mapping dictionary that are mapped to fields in the initial structure query statement and belong to the target database. Then, it replaces the fields in the initial structure query statement with the fields from the target database. The server also retrieves table names from the mapping dictionary that are mapped to table names in the initial structure query statement and belong to the target database. Then, it replaces the table names in the initial structure query statement with the table names from the target database, thus obtaining the updated structure query statement.
[0074] In one embodiment, the report processing method can also be applied to a server. The server sends a report file to a terminal, enabling the terminal to extract the structure query statement from the report file. The terminal then extracts the functions, table names, and fields from the structure query statement. Based on a mapping relationship, the functions in the structure query statement are replaced to obtain an initial structure query statement. Based on a mapping dictionary, the table names and fields in the initial structure query statement are replaced to obtain an updated structure query statement. This updated structure query statement is then used to replace the structure query statement in the report file, resulting in an updated report file to be uploaded to the server. The server then uploads the updated report file to the terminal. Upon receiving a preview request for the updated report file, the server previews the updated report file and sends the preview request result to the terminal, allowing the terminal to obtain the data in the updated report file if the preview request result allows previewing.
[0075] In the above report processing method, the report file is obtained, and then the structured query statement is extracted from the report file. The functions, fields, and table names in the structured query statement are then extracted, allowing for the breakdown of these elements. Based on the mapping relationship between functions in the source database of the currently running structured query statement and functions in the target database of the structured query statement to be run, the functions in the structured query statement are replaced to obtain the initial structured query statement. Finally, based on the mapping dictionary between table names in the source database and table names in the target database, as well as between fields in the source database and fields in the target database, the table names and fields in the initial structured query statement are replaced. This allows the replacement of functions, table names, and fields in the structured query statement to be executed automatically, reducing the replacement time and quickly obtaining the updated structured query statement, thus improving work efficiency.
[0076] In one exemplary embodiment, such as Figure 3 As shown, the report processing method also includes steps 302 to 306. Wherein:
[0077] Step 302: Replace the structure query statement in the report file with the update structure query statement to obtain the updated report file.
[0078] The process of replacing the structure query statement in the report file refers to writing back the updated structure query statement, after replacing the fields, table names, and functions, to the report file, thereby updating the report file and obtaining an updated report file that can be successfully opened.
[0079] Optionally, the terminal writes the updated structure query statement, after replacing fields, table names, and functions, back to the report file to replace the structure query statement in the report file and obtain the replaced updated report file.
[0080] Step 304: Upload the updated report file to the server and send a preview request for the uploaded updated report file to the server via an interface. The server is used to identify the functions in the updated report file.
[0081] The functions in the update report file have special characteristics, and the update report file cannot be opened by directly executing the structure query statement. Therefore, the update report file needs to be uploaded to a server that can identify the functions in the update report file.
[0082] A preview request refers to a request to preview an uploaded report file on the server. Preview request results can be either successful or unsuccessful. A successful request means the updated report file can be previewed, while a unsuccessful request means the updated report file cannot be previewed.
[0083] After allowing preview, you can open the updated report file. This is equivalent to obtaining a preview file of the updated report file from the interface, and then you can get the data recorded in the updated report file.
[0084] Optionally, the terminal replaces the structure query statement with an updated report file containing the updated structure query statement, and uploads the updated report file to a server that can identify the functions in the updated report file via an interface with the server. The terminal then sends a preview request for the updated report file to the server through the interface and obtains the preview request result.
[0085] Step 306: If the preview request result indicates that previewing is allowed, obtain the data in the updated report file.
[0086] The data in the updated report file can be obtained by scanning the updated report file after it has been successfully previewed.
[0087] Optionally, if the terminal detects that the preview request result indicates that the updated report file can be previewed, it opens the updated report file on the server through the interface and scans the data in the opened updated report file to obtain the data in the updated report file.
[0088] In this embodiment, the report file is updated by replacing the structure query statement in the report file with the updated structure query statement. The updated report file is then obtained by uploading the updated report file to the server and previewing it through an interface. This allows for the identification of functions in the updated report file, enabling a successful preview. If the preview is successful, the data in the updated report file can be obtained.
[0089] In one exemplary embodiment, such as Figure 4 As shown, steps 402 to 410 precede step 206. Wherein:
[0090] Step 402: Determine the target database of the structure query statement to be executed and the source database of the structure query statement currently being executed.
[0091] The target database refers to the database containing the functions, fields, and table names that the structured query statement carries after function, table name, and field substitutions. The source database refers to the database containing the functions, fields, and table names currently carried by the structured query statement.
[0092] Optionally, the terminal determines the database to which the functions, fields, and table names carried in the current structured query statement belong, thus obtaining the source database for the currently running structured query statement. The terminal also determines the target database for the structured query statement to be run.
[0093] Step 404: Based on the table name mapping relationship and field mapping relationship between the target database and the source database, establish a mapping dictionary between the target database and the source database.
[0094] In this context, table name mapping refers to the mapping relationship between table names with the same meaning in the target database and the source database. For example, if table name M in the target database has the same meaning as table name N in the source database, then there is a table name mapping relationship between table name M and table name N.
[0095] Field mapping relationships refer to the mapping relationships between fields with the same meaning in the target database and the source database. For example, if field m in the target database has the same meaning as field n in the source database, then there is a field mapping relationship between field m and field n. A mapping dictionary is a collection of at least one field mapping relationship and at least one table name mapping relationship.
[0096] Optionally, the terminal establishes a table name mapping relationship between table names with the same meaning in the target database and the source database, and a field mapping relationship between fields with the same meaning in the target database and the source database. The terminal combines the table name mapping relationship and the field mapping relationship to obtain a mapping dictionary between the target database and the source database.
[0097] Step 406: Obtain functions with the same functionality from the source database and the target database.
[0098] Optionally, the terminal can retrieve functions with the same functionality from both the source and target databases.
[0099] Step 408: Establish the correspondence between functions with the same functionality.
[0100] The correspondence refers to the relationship between functions with the same functionality in the source database and the target database.
[0101] Step 410: Based on the correspondence, determine the mapping relationship between the functions in the source database and the functions in the target database.
[0102] The mapping relationship is a set of at least one correspondence relationship.
[0103] Optionally, the terminal establishes a mapping relationship between functions in the target database and functions in the source database based on the correspondence between functions with the same functionality in the target database and the source database.
[0104] In this embodiment, a mapping dictionary is established between the target database and the source database in advance based on the table name mapping relationship and field mapping relationship between the target database and the source database. A mapping relationship is also established in advance based on the correspondence between functions with the same function in the source database and the target database. When replacing functions, table names and fields in the structured query statement, the replacement can be automatically performed according to the mapping dictionary and mapping relationship, thereby reducing the replacement time and improving the replacement efficiency.
[0105] In one exemplary embodiment, such as Figure 5 As shown, the report processing method also includes steps 502 to 506. Wherein:
[0106] Step 502: If there is no function in the target database that has the same function as the function in the source database, rewrite the function according to the function logic to obtain a rewritten function that has the same function as the function in the source database.
[0107] Among them, function rewriting based on function logic refers to rewriting a function that conforms to the logic of the target database and can be executed on a system in which the target database is installed, based on the functionality of the functions in the source database.
[0108] The absence of a function in the target database that performs the same function as a function in the source database can be understood as meaning that a function in the source database cannot be implemented by any function in the target database. For example, if function A in the source database sorts data in a report file, and after iterating through all functions in the target database, it is found that none of the functions in the target database can perform the sorting function, then it means that no function in the target database has the same functionality as function A in the source database.
[0109] Optionally, if the terminal detects that a certain function in the source database has a function that no function in the target database can implement, it rewrites a function that is logically consistent with the target database and can be executed on a system where the target database is installed, based on the function in the source database.
[0110] Step 504: Establish a matching relationship between the rewritten function and the functions in the source database.
[0111] In this context, the matching relationship refers to the mapping between the rewritten function and a function in the source database. That is, the rewritten function has the same functionality as a function in the source database. For example, if it is detected that there is no function in the target database that has the same functionality as function A in the source database, then a rewritten function is created that logically conforms to the target database and can be executed on a system where the target database is installed. In this case, a matching relationship exists between the rewritten function and function A, meaning they have the same functionality.
[0112] Step 506: Update the mapping relationship based on the matching relationship to obtain the updated mapping relationship.
[0113] Optionally, the terminal adds the newly obtained matching relationship to the mapping relationship to obtain the updated mapping relationship.
[0114] In this embodiment, when no function with the same functionality as the function in the source database exists in the target database, the function is rewritten according to the function logic to obtain the rewritten function. Then, the mapping relationship is updated according to the matching relationship between the rewritten function and the function in the source database to obtain the updated mapping relationship. This allows the replacement of functions in the structured query statement to be found based on the mapping relationship, thereby enabling the replacement of functions in the structured query statement and allowing the report file with the updated structured query statement to be successfully previewed.
[0115] In one exemplary embodiment, such as Figure 6 As shown, step 202 includes steps 602 to 606.
[0116] in:
[0117] Step 602: Obtain the first content contained in the table data mapping tag of the report file.
[0118] A report file contains multiple tags, and the Table Data Map tag is one of them. For example, the TableDataMap tag. The primary content contained within a Table Data Map tag can be understood as the fields and their specific contents. For instance, if the field "Name" belongs to the Table Data Map tag, then the specific entries "Name1" and "Name2" would be the primary content within that tag.
[0119] Optionally, the terminal determines the TableDataMap label from multiple labels based on the labels in the report file, and then obtains the specific content contained in the TableDataMap label to get the first content.
[0120] Step 604: Determine the table data tags in the first content. Extract the content contained in the table data tags to obtain the second content.
[0121] In this context, a table data tag refers to one of several tags within the first content. For example, continuing from the example in step 602, both Name 1 and Name 2 can be understood as tags within the first content. If Name 1 is a table data tag, then all personal information about Name 1, such as age and work experience, belongs to the second content contained within Name 1, i.e., it belongs to the second content contained within the table data tag. In the report file, the table data tag can be a TableData tag.
[0122] Optionally, the terminal determines the TableData tag from the multiple tags in the first content, and then obtains the specific content contained in the TableData tag to obtain the second content.
[0123] Step 606: Determine the query tags in the second content. Extract the content contained in the query tags to obtain the structured query statement.
[0124] In this context, a query tag refers to one of several tags within the second content. For example, continuing from the example in step 604, age, work experience, etc., are all second content items included in "Name 1," meaning they are tags within the second content. Therefore, the content under the "Work Experience" tag, such as "First Work Experience," "Second Work Experience," etc., are all multiple tags within the second content. If "First Work Experience" is a query tag within the second content, then the working hours, work location, etc., of the first work experience are all content included in that query tag. In report files, the query tag can be a "Query" tag.
[0125] Optionally, the terminal determines the Query tag from the multiple tags in the second content, and then obtains the specific content contained in the Query tag to obtain the structured query statement.
[0126] In this embodiment, by first obtaining the first content contained in the table data mapping tag of the report file, then determining the table data tag from the first content and extracting the second content contained in the table data tag, and then determining the query tag from the second content and extracting the content contained in the query tag, the structured query statement can be accurately obtained.
[0127] In one exemplary embodiment, such as Figure 7 As shown, step 206 includes steps 702 to 704.
[0128] in:
[0129] Step 702: Based on the mapping relationship, determine the target function that is consistent with the function in the structure query statement.
[0130] Optionally, the terminal determines the functionality of the function in the structured query statement, and then, based on the mapping relationship, determines the target function that is consistent with the functionality of the function in the structured query statement.
[0131] Step 704: If there is a difference between the function name of the target function and the function name of the function, replace the function name of the function with the function name of the target function to obtain the initial structure query statement.
[0132] Optionally, if the terminal obtains a target function that has the same function as the function in the structured query statement but a different function name, based on the mapping relationship, it replaces the function name of the function in the structured query statement with the function name of the target function to obtain the initial structured query statement.
[0133] In this embodiment, by obtaining a target function that has the same function as the function in the structure query statement but a different function name, based on the mapping relationship, the function name of the target function is used to replace the function name in the structure query statement to obtain the initial structure query statement. This reduces the replacement time and improves the efficiency of the replacement process.
[0134] This application also provides an application scenario in which the above-described report processing method is applied. Specifically, the report processing method is applied in this scenario as follows:
[0135] The terminal automatically downloads report files from the server through an interface that interacts with the server. Using DOM tools, the terminal identifies the `TableDataMap` tag from multiple tags in the report file, and then retrieves the content contained within the `TableDataMap` tag to obtain the first content. Based on the multiple tags in the first content, the terminal identifies the `TableData` tag from multiple tags, and then retrieves the content contained within the `TableData` tag to obtain the second content. Based on the multiple tags in the second content, the terminal identifies the `Query` tag from multiple tags, and then retrieves the content contained within the `Query` tag to obtain the structured query statement.
[0136] The terminal uses the JSQLParser tool to parse the structured query statement obtained from the report file into a traversable hierarchical structure of Java classes, that is, to separate the functions, fields and table names in the structured query statement at the same time.
[0137] The terminal determines the database to which the functions, fields, and table names carried in the current structured query statement belong, thus obtaining the source database for the currently running structured query statement. Simultaneously, the terminal determines the target database for the structured query statement to be run. The terminal establishes table name mappings between tables with the same meaning in the target and source databases, and establishes field mappings between fields with the same meaning in the target and source databases. By combining the table name and field mappings, the terminal obtains a mapping dictionary between the target and source databases. The terminal establishes a correspondence between functions with the same functionality in the source and target databases. Based on the correspondence between functions with the same functionality in the target and source databases, the terminal establishes a mapping between functions in the target database and functions in the target database.
[0138] The terminal determines the functionality of the functions in the structured query statement, and then, based on the mapping relationship, determines the target function that has the same functionality as the functions in the structured query statement. Once the terminal obtains the target function that has the same functionality as the functions in the structured query statement but a different function name, it replaces the function name in the structured query statement with the name of the target function to obtain the initial structured query statement.
[0139] Based on the established mapping dictionary, the terminal retrieves fields from the mapping dictionary that are mapped to fields in the initial structure query statement and belong to the target database. Then, it replaces the fields in the initial structure query statement with the fields from the target database. The terminal also retrieves table names from the mapping dictionary that are mapped to table names in the initial structure query statement and belong to the target database. Then, it replaces the table names in the initial structure query statement with the table names from the target database to obtain the updated structure query statement.
[0140] The terminal writes the updated structure query statement, after replacing fields, table names, and functions, back to the report file to replace the structure query statement in the report file, resulting in a replaced updated report file. The terminal then uploads this updated report file, containing the replaced structure query statement, to a server that can recognize the functions within it, via an interface with the server. The terminal sends a preview request for the updated report file to the server through the interface and receives the preview request result. If the preview request result indicates that previewing the updated report file is allowed, the terminal opens the updated report file on the server through the interface and scans the data within it to obtain the data from the updated report file.
[0141] In this embodiment, by acquiring a report file, extracting the structured query statement from the report file, and then extracting the functions, fields, and table names from the structured query statement, the functions, table names, and fields in the structured query statement can be split, thus obtaining the functions, table names, and fields in the structured query statement. Based on the mapping relationship between functions in the source database of the currently running structured query statement and functions in the target database of the structured query statement to be run, the functions in the structured query statement are replaced to obtain the initial structured query statement. By using a mapping dictionary based on the table names in the source database and the table names in the target database, as well as the fields in the source database and the fields in the target database, the table names and fields in the initial structured query statement are replaced. This allows the replacement of functions, table names, and fields in the structured query statement to be executed automatically, thereby reducing the replacement time of functions, fields, and table names in the structured query statement, quickly obtaining the updated structured query statement after replacement, and improving work efficiency.
[0142] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0143] Based on the same inventive concept, this application also provides a report processing apparatus for implementing the report processing method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more report processing apparatus embodiments provided below can be found in the limitations of the report processing method described above, and will not be repeated here.
[0144] In one exemplary embodiment, such as Figure 8 As shown, a report processing device 800 is provided, including:
[0145] The statement extraction module 802 is used to obtain report files and extract the structural query statements from the report files.
[0146] The statement splitting module 804 is used to extract functions, table names, and fields from structured query statements.
[0147] The first replacement module 806 is used to replace functions in a structured query statement based on a mapping relationship to obtain an initial structured query statement. The mapping relationship represents the mapping between functions in the source database of the currently running structured query statement and functions in the target database of the structured query statement to be run.
[0148] The second replacement module 808 is used to replace table names and fields in the initial structure query statement based on the mapping dictionary, thereby obtaining an updated structure query statement. The mapping dictionary represents the mapping between table names in the source database and table names in the target database, as well as the mapping between fields in the source database and fields in the target database.
[0149] In this embodiment, by acquiring a report file, extracting the structured query statement from the report file, and then extracting the functions, fields, and table names from the structured query statement, the functions, table names, and fields in the structured query statement can be split, thus obtaining the functions, table names, and fields in the structured query statement. Based on the mapping relationship between functions in the source database of the currently running structured query statement and functions in the target database of the structured query statement to be run, the functions in the structured query statement are replaced to obtain the initial structured query statement. By using a mapping dictionary based on the table names in the source database and the table names in the target database, as well as the fields in the source database and the fields in the target database, the table names and fields in the initial structured query statement are replaced. This allows the replacement of functions, table names, and fields in the structured query statement to be executed automatically, thereby reducing the replacement time of functions, fields, and table names in the structured query statement, quickly obtaining the updated structured query statement after replacement, and improving work efficiency.
[0150] In one embodiment, such as Figure 9 As shown, the report processing device 800 also includes:
[0151] The third replacement module 902 is used to replace the structure query statements in the report file with the updated structure query statements to obtain the updated report file.
[0152] The preview module 904 is used to upload updated report files to the server. It sends a preview request for the uploaded updated report files to the server via an interface and obtains the preview request result. The server is used to identify the functions in the updated report files.
[0153] The data acquisition module 906 is used to obtain data from the updated report file if the preview request result indicates that previewing is allowed.
[0154] In one embodiment, the first replacement module is further configured to:
[0155] Determine the target database for the query statement to be executed, and the source database for the currently executing query statement. Based on the table name and field mapping relationships between the target and source databases, establish a mapping dictionary between them. Obtain functions with the same functionality from both the source and target databases. Establish the correspondence between these functions. Based on this correspondence, determine the mapping relationship between functions in the source and target databases.
[0156] In one embodiment, the device further includes:
[0157] The function rewriting module is used to rewrite functions based on function logic when no function with the same functionality as the function in the source database exists in the target database, resulting in a rewritten function with the same functionality as the function in the source database.
[0158] The relationship establishment module is used to establish matching relationships between rewritten functions and functions in the source database.
[0159] The relationship update module is used to update the mapping relationship based on the matching relationship to obtain the updated mapping relationship.
[0160] In one embodiment, the statement extraction module is further configured to:
[0161] Retrieve the first content contained in the table data mapping tags of the report file. Identify the table data tags within the first content. Extract the content contained in the table data tags to obtain the second content. Identify the query tags within the second content. Extract the content contained in the query tags to obtain the structured query statement.
[0162] In one embodiment, the first replacement module is further configured to:
[0163] Based on the mapping relationship, a target function with the same functionality as the function in the structured query statement is identified. If the function name of the target function differs from the function name of the function in question, the function name of the function in question is replaced with the name of the target function to obtain the initial structured query statement.
[0164] Each module in the aforementioned report processing device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0165] In one exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 10As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a report processing method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0166] Those skilled in the art will understand that Figure 10 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0167] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
[0168] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.
[0169] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0170] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0171] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0172] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A report processing method, characterized in that, The method includes: Obtain the report file and extract the structural query statements from the report file; Extract the functions, table names, and fields from the structured query statement; Determine the target database for the structure query statement to be executed, and the source database currently executing the structure query statement; Based on the pre-established mapping relationship between the target database and the source database, the functions in the structured query statement are replaced to obtain the initial structured query statement; the mapping relationship represents the mapping between the functions in the source database currently running the structured query statement and the functions in the target database to be run the structured query statement. Based on a pre-established mapping dictionary between the target database and the source database, the table names and fields in the initial structure query statement are replaced to obtain an updated structure query statement; the updated structure query statement is used to replace the structure query statement in the report file to obtain an updated report file that can be executed in the target database; the mapping dictionary represents the mapping between table names in the source database and table names in the target database, as well as the mapping between fields in the source database and fields in the target database.
2. The method according to claim 1, characterized in that, The method further includes: The updated structure query statement is used to replace the structure query statement in the report file to obtain the updated report file; The updated report file is uploaded to the server, and a preview request for the uploaded updated report file is sent to the server through an interface to obtain the preview request result; the server is used to identify the functions in the updated report file; If the preview request result indicates that previewing is allowed, the data in the updated report file is obtained.
3. The method according to claim 1, characterized in that, The method further includes: Based on the table name mapping relationship and field mapping relationship between the target database and the source database, a mapping dictionary between the target database and the source database is established; Obtain functions with the same functionality from the source database and the target database; Establish the correspondence between the functions that have the same function; Based on the correspondence, the mapping relationship between the functions in the source database and the functions in the target database is determined.
4. The method according to claim 3, characterized in that, The method further includes: If no function with the same functionality as the function in the source database exists in the target database, the function is rewritten according to the function logic to obtain a rewritten function with the same functionality as the function in the source database. Establish a matching relationship between the rewritten function and the functions in the source database; The mapping relationship is updated based on the matching relationship to obtain the updated mapping relationship.
5. The method according to claim 1, characterized in that, The extraction of the structure query statement from the report file includes: Obtain the first content contained in the table data mapping tags of the report file; Identify the table data tags in the first content; extract the content contained in the table data tags to obtain the second content; Identify the query tags in the second content; extract the content contained in the query tags to obtain a structured query statement.
6. The method according to claim 1, characterized in that, The process involves replacing the functions in the structured query statement based on a pre-established mapping relationship between the target database and the source database to obtain an initial structured query statement, including: Based on the pre-established mapping relationship between the target database and the source database, a target function that is consistent with the function in the structure query statement is determined; If the name of the target function differs from the name of the function, the name of the function is replaced with the name of the target function to obtain the initial structure query statement.
7. A report processing device, characterized in that, The device includes: The statement extraction module is used to obtain report files and extract the structural query statements from the report files. The statement splitting module is used to extract functions, table names, and fields from the structured query statement; The first replacement module is used to determine the target database of the structured query statement to be executed and the source database of the structured query statement currently being executed; based on the pre-established mapping relationship between the target database and the source database, the function in the structured query statement is replaced to obtain an initial structured query statement; the mapping relationship represents the mapping between the function in the source database of the structured query statement currently being executed and the function in the target database of the structured query statement to be executed. The second replacement module is used to replace the table names and fields in the initial structure query statement based on a pre-established mapping dictionary between the target database and the source database, to obtain an updated structure query statement; the updated structure query statement is used to replace the structure query statement in the report file to obtain an updated report file that can be executed in the target database; the mapping dictionary represents the mapping between table names in the source database and table names in the target database, as well as the mapping between fields in the source database and fields in the target database.
8. The apparatus according to claim 7, characterized in that, The device further includes: The third replacement module is used to replace the structure query statement in the report file with the updated structure query statement to obtain an updated report file; The preview module is used to upload the updated report file to the server, send a preview request for the uploaded updated report file to the server through an interface, and obtain a preview request result; the server is used to identify the functions in the updated report file; The data acquisition module is used to obtain data from the updated report file if the preview request result indicates that previewing is allowed.
9. The apparatus according to claim 7, characterized in that, The first replacement module is also used for: Based on the table name mapping relationship and field mapping relationship between the target database and the source database, a mapping dictionary between the target database and the source database is established; functions with the same function are obtained from the source database and the target database; and a correspondence relationship is established between the functions with the same function. Based on the correspondence, the mapping relationship between the functions in the source database and the functions in the target database is determined.
10. The apparatus according to claim 9, characterized in that, The device further includes: The function rewriting module is used to rewrite functions according to function logic when there are no functions with the same functionality as the functions in the source database in the target database, so as to obtain rewritten functions with the same functionality as the functions in the source database. The relationship establishment module is used to establish a matching relationship between the rewritten function and the functions in the source database; The relationship update module is used to update the mapping relationship based on the matching relationship to obtain the updated mapping relationship.
11. The apparatus according to claim 7, characterized in that, The statement extraction module is also used for: Obtain the first content contained in the table data mapping tags of the report file; determine the table data tags in the first content; extract the content contained in the table data tags to obtain the second content; determine the query tags in the second content; extract the content contained in the query tags to obtain the structured query statement.
12. The apparatus according to claim 7, characterized in that, The first replacement module is also used for: Based on the pre-established mapping relationship between the target database and the source database, a target function with the same functionality as the function in the structured query statement is determined; if there is a difference between the function name of the target function and the function name of the function, the function name of the function is replaced with the function name of the target function to obtain the initial structured query statement.
13. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.
14. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
15. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Data extraction method and related device
CN115408419A