A data management method and system based on document template matching

Through the data management method based on document template matching, data filling and document generation are automatically processed, and the problems of low efficiency and poor accuracy caused by manual operations in the prior art are solved, and efficient and secure data management is achieved.

CN118278377BActive Publication Date: 2024-12-31SHANDONG AMBRERA INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410539819.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-30
Publication Date
2024-12-31
Estimated Expiration
2044-04-30

AI Technical Summary

Technical Problem

The existing reporting system relies on manual operations, resulting in low data management efficiency, poor accuracy, and human error and security problems.

Method used

The data management method based on document template matching is adopted. By configuring template identification, the business document template is obtained, the POI parsing identification rules are used to obtain data, and the data is converted into target text, formatting is performed, the template is automatically filled, and the management report document is generated.

Benefits of technology

It improves the efficiency and accuracy of document generation, reduces manual participation, reduces error risk, ensures the consistency of document formats, optimizes data management processes, and improves data security and confidentiality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118278377B_ABST
    Figure CN118278377B_ABST
Patent Text Reader

Abstract

The present invention belongs to the technical field of business data management, and in particular, relates to a data management method and system based on document template matching. The method includes configuring a template identifier to establish a business document template; obtaining the required business document template, including obtaining the business document template using a lightweight distributed file system; making a business data request based on the obtained business document template, including parsing the identifier in the business document template using POI and defining the identifier rules, and making a business data request according to the identifier rules; converting the requested business data into a target text according to the business data request; formatting the target text, and inserting the formatted target text into the location of the template identifier in the business document template. Through the technical solution of the present invention, template matching and content filling can be automated, which can make data classification, storage and retrieval more convenient and efficient.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of business data management, and in particular, relates to a data management method and system based on document template matching. Background Art

[0002] In the existing technology, data management and analysis play a vital role in the decision-making and development of enterprises. Many enterprises use report systems to complete the management and analysis of massive data. However, the existing report systems are usually completed by manual operations, which requires the staff to have a very clear understanding of the massive business data information, not only to accurately extract the required data information from various data sources, but also to accurately fill it into the report documents.

[0003] The tedious process of manually inputting data prolongs the time of document creation and reduces the efficiency of data management. At the same time, manual operation faces a higher risk of human error, and the accuracy of data management is also reduced. In addition, manual participation makes the security and confidentiality of data document management worrying. At this stage, a data management method and system based on document template matching is needed. Summary of the invention

[0004] In order to solve the problem of low efficiency and accuracy of data management, the present invention provides a data management method and system based on document template matching.

[0005] In a first aspect, the present invention provides a data management method based on document template matching, which adopts the following technical solution:

[0006] A data management method based on document template matching, comprising:

[0007] Configure template identifiers and create business document templates;

[0008] Obtaining required business document templates, including obtaining business document templates using a lightweight distributed file system;

[0009] Making a business data request based on the acquired business document template, including parsing an identifier in the business document template using the POI and defining an identifier rule, and making a business data request according to the identifier rule;

[0010] According to the business data request, convert the requested business data into target text;

[0011] Performing format processing on the target text, and inserting the formatted target text into the position where the template mark is located in the business document template;

[0012] Generate management report documents based on business document templates with target text inserted.

[0013] Furthermore, the establishment of the business document template includes obtaining the interface of the target business system according to the business document type, constructing a request and sending it to the interface URL of the target business system, obtaining the business data corresponding to the business identifier through the restful interface, and finally backfilling the business data into the business document template.

[0014] Furthermore, the use of a lightweight distributed file system to obtain business document templates includes deploying and configuring a lightweight distributed file system according to the type of business document template, uploading the business document template to the lightweight distributed file system, and obtaining the business document template through a database of the lightweight distributed file system.

[0015] Furthermore, the method utilizes POI to parse the identifiers in the business document template and defines identification rules, and makes business data requests according to the identification rules, including traversing each cell and paragraph in the document, determining the identification rules that map the identifiers to the business data requests, and according to the identification rules, extracting the content of the identifier and obtaining the business data through a restful interface.

[0016] Furthermore, the conversion of the requested business data into the target text includes obtaining the business data through a restful interface, loading the obtained business data into the WebView using the loadDataWithBaseURL of the WebView component, creating an HTML file containing the statistical chart drawing logic, loading the HTML file according to the built-in browser of the WebView and generating a screenshot file.

[0017] Furthermore, the formatting of the target text includes obtaining the format information of the original identifier in the template and the file stream of the target text, converting the file stream of the business data into an XWPFDocument object, obtaining the target text by iterating the XWPFDocument object, and formatting the obtained target text and the original identifier in the template to obtain the target text after formatting.

[0018] Furthermore, inserting the formatted target text into the position where the template identifier is located in the business document template includes reading the business document template, searching the template for the identifier position in the business document template through the replacePlaceholder method, and replacing the formatted target text with the identifier position in the business document template.

[0019] In a second aspect, a data management system based on document template matching includes:

[0020] The template building module is configured to: configure the template identifier and establish the business document template;

[0021] The template acquisition module is configured to: acquire the required business document template, including acquiring the business document template using a lightweight distributed file system;

[0022] The data acquisition module is configured to: make a business data request based on the acquired business document template, including parsing the identifier in the business document template using the POI and defining an identifier rule, and making a business data request according to the identifier rule;

[0023] The conversion module is configured to: convert the requested business data into a target text according to the business data request;

[0024] The processing module is configured to: perform format processing on the target text, and insert the format-processed target text into the position where the template identifier is located in the business document template;

[0025] The generation module is configured to generate a management report document according to a business document template into which a target text is inserted.

[0026] The third aspect provides a computer-readable storage medium having a program stored thereon, which, when executed by a processor, implements the steps in the data management method based on document template matching as described in the first aspect of the present invention.

[0027] The fourth aspect provides an electronic device, comprising a memory, a processor, and a program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps in a data management method based on document template matching as described in the first aspect of the present invention are implemented.

[0028] In summary, the present invention has the following beneficial technical effects:

[0029] 1. The present invention can automatically or semi-automatically fill relevant content into the template according to user needs, which not only avoids the tedious process of manual content input, but also improves the accuracy and standardization of the document, making the document generation more efficient; in addition, the document template matching technology can realize the automation of the entire process from template selection, content filling to data extraction, which greatly reduces the degree of manual participation and reduces the risk of human error; at the same time, whether it is creating a new document or modifying an existing document, it can be completed in a shorter time, improving the efficiency and stability of the entire document generation process.

[0030] 2. The present invention uses template matching technology to ensure that all generated documents remain consistent in format. By strictly filling in content according to the style and layout of the template, it can effectively avoid format confusion and inconsistency, making the entire document look neater and more professional.

[0031] 3. The present invention can accurately extract the required information from various data sources and fill it into the document, which not only reduces the errors that may occur in manual operations, but also greatly improves the efficiency and accuracy of data processing, and reduces labor costs, time costs and additional costs caused by errors.

[0032] 4. The present invention can also optimize the data management process. Through automated template matching and content filling, data classification, storage and retrieval can become more convenient and efficient, which not only helps to improve the efficiency of data management, but also improves the security and confidentiality of data. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] Figure 1 It is an overall flow chart of a data management method based on document template matching in an embodiment of the present invention. DETAILED DESCRIPTION

[0034] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present invention belongs.

[0035] It should be noted that the terms used herein are for describing specific embodiments only and are not intended to be limiting of exemplary embodiments according to the present invention.

[0036] In the absence of conflict, the embodiments of the present invention and the features of the embodiments may be combined with each other.

[0037] Example 1

[0038] Reference Figure 1 , a data management method based on document template matching in this embodiment includes:

[0039] Configure template identifiers and create business document templates;

[0040] Obtaining required business document templates, including obtaining business document templates using a lightweight distributed file system;

[0041] Acquiring business data based on the acquired business document template, including parsing the identifier in the business document template using the POI and defining an identifier rule, and making a business data request according to the identifier rule;

[0042] According to the acquired business data, convert the acquired business data into target text;

[0043] Performing format processing on the target text, and inserting the formatted target text into the position where the template mark is located in the business document template;

[0044] Generate management report documents based on business document templates with target text inserted.

[0045] The establishment of the business document template includes obtaining the interface of the target business system according to the business document type, constructing a request and sending it to the interface URL of the target business system, obtaining the business data corresponding to the business identifier through the restful interface, and finally backfilling the business data into the business document template.

[0046] The method of acquiring the business document template using the lightweight distributed file system includes deploying and configuring the lightweight distributed file system according to the type of the business document template, uploading the business document template to the lightweight distributed file system, and acquiring the business document template through the database of the lightweight distributed file system.

[0047] The method uses POI to parse the identifier in the business document template and define the identifier rules, and makes business data requests according to the identifier rules, including traversing each cell and paragraph in the document, determining the identifier mapping to the identification rules of the business data request, extracting the identifier content according to the identification rules, and obtaining the business data through the restful interface.

[0048] The obtained business data is converted into target text, including obtaining the business data through a restful interface, loading the obtained business data into WebView using the loadDataWithBaseURL of the WebView component, creating an HTML file containing statistical chart drawing logic, loading the HTML file according to the built-in browser of WebView and generating a screenshot file.

[0049] The formatting of the target text includes obtaining the format information of the original identifier in the template and the file stream of the target text, converting the file stream of the business data into an XWPFDocument object, obtaining the target text by iterating the XWPFDocument object, and formatting the obtained target text and the original identifier in the template to obtain the target text after formatting.

[0050] The method of inserting the formatted target text into the position of the template identifier in the business document template includes reading the business document template, searching the template for the identifier position in the document template through the replacePlaceholder method, and replacing the formatted target text with the identifier position in the business document template.

[0051] Specifically, a data management method based on document template matching in this embodiment includes the following steps:

[0052] like Figure 1As shown, S01, configure the template identifier and establish a business document template;

[0053] The business document template is generated manually by the business personnel. Since the business that different business personnel are responsible for is different, the business document template is created by the business personnel responsible for the corresponding business. In the process of creating the template, some business data that needs to be obtained through other business systems needs to be configured with specific business identifiers according to the identification rules.

[0054] This system is a tool-type operating system that does not involve specific business itself and matches all application businesses. Therefore, all business data involved in the system need to be obtained through other specific business systems, mainly through restful interfaces. For example, if an enterprise needs to obtain a report on business risks, it configures a risk report business template in the system, fills in the business ID of the data in the template, obtains the business data corresponding to the business ID through the restful interface, and finally fills the business data back into the business template.

[0055] Template identifiers are divided into public identifiers and business identifiers. Public identifiers are used to generate commonly used data, such as the current time (year-month-day, year-month, month-day) and other time formats.

[0056] Business identifier is used to obtain actual business data and generate target text, which is text, numbers or statistical charts.

[0057] The business identifier consists of three parts. The first part represents the format of the generated target text, the second part represents the business interface used to obtain data, and the third part represents the business name. For example, the identifier starting with $PIE_ represents the generation of a pie chart of the corresponding data after obtaining business data, and the identifier starting with $LINE_ represents the generation of a line chart of the corresponding data after obtaining business data; the identifier $PIE_YE_ABC represents the use of the business interface of YE to obtain the business data of ABC to generate a pie chart. According to actual business needs, a document template for a specific business is created. When generating a report document for business data, it is only necessary to write the content of the corresponding position on the template according to the identifier, without the need for business personnel to fill it out manually again, which greatly facilitates the generation of report documents for actual business data.

[0058] S02. Obtain the required business document template;

[0059] The primary advantage of document template matching technology is that it can quickly and accurately locate suitable templates. Through intelligent search algorithms and efficient indexing mechanisms, this technology can find document templates that meet user needs from a large number of templates in a short period of time, greatly shortening the time for document creation.

[0060] The above intelligent search algorithm and efficient indexing mechanism are provided by FastDFS. When there is a large amount of template information in the system, FastDFS, as a file server, mainly solves the problem of massive data storage, uploads business document template files to the distributed file system, and obtains template files through the interface of the distributed file system in applications that need to obtain business document templates.

[0061] In this embodiment, a lightweight distributed file system FastDFS is used to manage files. By storing the generated business document templates in FastDFS, the problems of large-capacity storage and load balancing are solved. Mechanisms such as redundant backup, load balancing, and linear expansion are fully considered, and attention is paid to indicators such as high availability and high performance.

[0062] S03. Utilize POI to parse the identifier in the business document template, and make a business data request according to the identifier rule.

[0063] Parse the obtained template file content into an operable data structure, and obtain the identification through the business template. The identification includes the category of the identification, the identification result information, the business logo of the identification, and the specific business content of the identification.

[0064] In this embodiment, the identifier $pub_yyyy_mm_dd indicates that the public identifier (pub) obtains the current time, and the identifier result is the actual time.

[0065] The identifier $bus_yw1_pie_getRiskPro represents the business identifier. The specific business interface address (http: / / 192.168.1.1) corresponding to yw1 is obtained through yw1 in the business interface configuration information. After obtaining the interface address, the specific business method behind the identifier is used to obtain the corresponding data. The interface address finally generated is http: / / 192.168.1.1 / getRiskPro. Specific business data results are obtained through this interface.

[0066] The algorithm for using POI to parse the identifier in the business document template is as follows:

[0067] {

[0068] errno:0, / / Error code (0, success, other numbers correspond to specific errors)

[0069] errmsg:“ ”, / / Error message (“” empty string means no exception in request, others means specific error message)

[0070] data_type: " " / / data type (data indicates specific data, pie indicates a pie chart, line indicates a line chart, etc.)

[0071] data:{ / / Result data

[0072] name:“ ”, / / Business name

[0073] Value:“ ”, / / Business data results

[0074] }

[0075] }

[0076] Process the parsed identifiers and store them in a list or map for subsequent data filling operations.

[0077] S04, converting the requested business data into target text;

[0078] The target text exists in various forms, such as text, numbers or statistical charts. The business data is converted according to the identification rules, and only the text or data content is generated without processing. When it needs to be converted into a chart, the statistical chart is drawn. Statistical charts of different styles are built in according to different formats. The obtained business data is loaded into the WebView using the loadDataWithBaseURL of the WebView component, and an HTML file containing the statistical chart drawing logic is created. The drawn statistical chart is embedded in the HTML page, and the HTML file is loaded according to the built-in browser of the WebView and a screenshot file is generated. The browser draws and generates a screenshot file.

[0079] Among them, generate a screenshot: browser.save_screenshot("chart_screenshot.png"), the saved screenshot file name and path is "chart_screenshot.png".

[0080] After obtaining the business data through the restful interface, the page is loaded through the built-in browser of WebView. After the page is loaded, the image download function on the page is performed. The downloaded image is obtained and inserted into the corresponding business document position.

[0081] S05, formatting the target text and inserting it into the business document template at the location where the mark is located;

[0082] Perform formatting on the target text, specifically standardizing the target text's font size, font, text position, etc.

[0083] The requested business data result is replaced in position. The text that needs to be replaced is formatted and replaced. The image position that needs to be replaced is replaced: First, read the business document template, which is expressed as:

[0084] FileInputStreamtemplateFile=newFileInputStream("path / to / template.docx");

[0085] XWPFDocument document = new XWPFDocument(templateFile),

[0086] Find the identified position in the template and replace it with the target text, as follows:

[0087] replacePlaceholder(document, "${target}", "target text"); Among them, format processing only processes text formatting. It obtains the format information of the original identifier in the template (including the font, font size, paragraph and other information of the text) and records it in the memory, then obtains the corresponding business data through restful, and finally formats the obtained business data and inserts it into the location of the original identifier.

[0088] The target text is formatted using the Apache POI library. The following code is an example:

[0089] / / Get the file stream

[0090] FileInputStreamfis=newFileInputStream("path / to / word / document.docx");

[0091] / / Convert the file stream to an XWPFDocument object

[0092] XWPFDocument document = new XWPFDocument(fis);

[0093] / / Iterate over this object

[0094] for (XWPFParagraph paragraph : document.getParagraphs()) {

[0095] / / Iterate rows

[0096] for (XWPFRun run : paragraph.getRuns()) {

[0097] / / Get the line text

[0098] String text = run.getText(0);

[0099] / / Check if the text is not NULL

[0100] if (text != null) {

[0101] / / Process the text content

[0102] System.out.println(text);

[0103] / / Process format information

[0104] System.out.println("Font: " + run.getFontFamily()); / / Get text font

[0105] System.out.println("Color: " + run.getColor()); / / Get text color

[0106] System.out.println("Font size: " + run.getFontSize()); / / Get the text font size

[0107] / / ...

[0108] / / Close the document object

[0109] document.close();

[0110] / / Close the file stream

[0111] fis.close();

[0112] S06. Generate management report documents for centralized management.

[0113] Embodiment 2

[0114] The purpose of this embodiment is to provide a data management system based on document template matching, including:

[0115] The template building module is configured to: establish a business document template and configure a template identifier;

[0116] The template acquisition module is configured to: acquire the required business document template, including acquiring the business document template using a lightweight distributed file system;

[0117] The data acquisition module is configured to: acquire business data based on the acquired business document template, including parsing the identifier in the business document template using the POI and defining the identifier rule, and making a business data request according to the identifier rule;

[0118] The conversion module is configured to: convert the acquired business data into a target text according to the acquired business data;

[0119] The processing module is configured to: perform format processing on the target text, and insert the format-processed target text into the position where the template identifier is located in the business document template;

[0120] The generation module is configured to generate a management report document according to a business document template into which a target text is inserted.

[0121] A computer-readable storage medium is provided, on which a program is stored. When the program is executed by a processor, the steps in the data management method based on document template matching as described in the first aspect of the present invention are implemented.

[0122] An electronic device is provided, comprising a memory, a processor, and a program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps in a data management method based on document template matching as described in the first aspect of the present invention are implemented.

[0123] Although the above describes the specific implementation mode of the present invention in conjunction with the accompanying drawings, it is not intended to limit the scope of protection of the present invention. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art on the basis of the technical solution of the present invention without creative work are still within the scope of protection of the present invention.

Claims

1. A data management method based on document template matching, characterized in that: include: Configure template identifiers and create business document templates; Obtaining required business document templates, including obtaining business document templates using a lightweight distributed file system; Making a business data request based on the acquired business document template, including parsing an identifier in the business document template using the POI and defining an identifier rule, and making a business data request according to the identifier rule; According to the business data request, the requested business data is converted into the target text, including obtaining the business data through the restful interface, loading the obtained business data into the WebView using the loadDataWithBaseURL of the WebView component, creating an HTML file containing the statistical chart drawing logic, loading the HTML file according to the built-in browser of the WebView and generating a screenshot file; Performing format processing on the target text, including obtaining the format information of the original identifier in the template and the file stream of the target text, converting the file stream of the business data into an XWPFDocument object, obtaining the target text by iterating the XWPFDocument object, performing format assembly on the obtained target text and the original identifier in the template to obtain the target text after format processing, and inserting the target text after format processing into the position where the template identifier is located in the business document template, wherein inserting the target text after format processing into the position where the template identifier is located in the business document template includes performing a reading operation on the business document template, searching for the identifier position in the business document template in the template by a replacePlaceholder method, and replacing the identifier position in the business document template with the target text after format processing; Generate management report documents based on business document templates with target text inserted.

2. A data management method based on document template matching according to claim 1, characterized in that: The establishment of the business document template includes obtaining the interface of the target business system according to the business document type, constructing a request and sending it to the interface URL of the target business system, obtaining the business data corresponding to the business identifier through the restful interface, and finally backfilling the business data into the business document template.

3. A data management method based on document template matching according to claim 2, characterized in that: The method of acquiring the business document template using the lightweight distributed file system includes deploying and configuring the lightweight distributed file system according to the type of the business document template, uploading the business document template to the lightweight distributed file system, and acquiring the business document template through the database of the lightweight distributed file system.

4. A data management method based on document template matching according to claim 3, characterized in that: The method uses POI to parse the identifier in the business document template and define the identifier rules, and makes business data requests according to the identifier rules, including traversing each cell and paragraph in the document, determining the identifier mapping to the identification rules of the business data request, extracting the identifier content according to the identification rules, and obtaining the business data through the restful interface.

5. A data management system based on document template matching, executing the method according to claim 1, characterized in that: include: The template building module is configured to: configure the template identifier and establish the business document template; The template acquisition module is configured to: acquire the required business document template, including acquiring the business document template using a lightweight distributed file system; The data acquisition module is configured to: make a business data request based on the acquired business document template, including parsing the identifier in the business document template using the POI and defining an identifier rule, and making a business data request according to the identifier rule; The conversion module is configured to: convert the requested business data into a target text according to the business data request; The processing module is configured to: perform format processing on the target text, and insert the format-processed target text into the position where the template identifier is located in the business document template; The generation module is configured to generate a management report document according to a business document template into which a target text is inserted.

6. A computer-readable storage medium storing a plurality of instructions, characterized in that: The instructions are suitable for being loaded by a processor of a terminal device and executing a data management method based on document template matching as described in any one of claims 1 to 4.

7. A terminal device, comprising a processor and a computer-readable storage medium, wherein the processor is used to implement each instruction; and the computer-readable storage medium is used to store multiple instructions, characterized in that: The instructions are suitable for being loaded by a processor and executing a data management method based on document template matching as described in any one of claims 1 to 4.