Invoice template generation method and device, computer device, and storage medium
By parsing and updating the control information in the document template, and using metadata to generate the target document template, the problem of low efficiency in document template generation in traditional methods is solved, and the rapid reuse and efficient generation of document templates are realized.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- KINGDEE DEEKING CLOUDCOMPUTING CO LTD
- Filing Date
- 2022-09-22
- Publication Date
- 2026-05-12
AI Technical Summary
Traditional methods require precise settings and adjustments for each document template when creating them, leading to low efficiency, especially for multiple document templates with high information overlap.
By traversing each control in the source document's document template, parsing the control information, keeping the unbound field information unchanged, updating the bound field information, and using the target document's metadata for differentiated updates, a document template for the target document is generated.
It enables rapid reuse of document templates, improves generation efficiency, retains the unmodifiable information and identical field information of the source document, and only requires a small number of differential updates to generate the target document template.
Smart Images

Figure CN115409014B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, computer device, and storage medium for generating document templates. Background Technology
[0002] With the development of computer technology, various enterprise business systems have emerged, such as ERP (Enterprise Resource Planning) systems. These systems have greatly improved the operational and management efficiency of enterprises. Many of these systems have the function of creating and generating document templates, allowing users to easily print and use documents.
[0003] In traditional methods, when creating each document template, users need to precisely set and adjust the position, size, and other attributes of each control in the document template. Even for multiple document templates with a high degree of information overlap, each document template must be created separately, which takes a lot of time to create and adjust in order to obtain a single document template, resulting in very low efficiency. Summary of the Invention
[0004] Therefore, it is necessary to provide a document template generation method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can improve the efficiency of document template generation in response to the above-mentioned technical problems.
[0005] Firstly, this application provides a method for generating a document template. The method includes:
[0006] Iterate through each control in the document template of the source document and parse the control information of each traversed control;
[0007] If it is found that no field information is bound in the parsed control information, then the control information remains unchanged;
[0008] If the control information is parsed to contain field information, then the control information is updated according to the metadata preset for the target document.
[0009] The document template for the target document is generated based on the unchanged control information in the document template of the source document and the updated control information.
[0010] Secondly, this application also provides a document template generation device. The device includes:
[0011] The control parsing module is used to traverse each control in the document template of the source document and parse the control information of each traversed control; if the parsed control information is found to have no bound field information, the control information is kept unchanged.
[0012] The control information update module is used to update the control information according to the metadata preset for the target document if it is found that the control information is bound to field information.
[0013] The document template generation module is used to generate the document template of the target document based on the unchanged control information and the updated control information in the document template of the source document.
[0014] In one embodiment, the metadata includes field information of each field in the target document and corresponding data source information; the control information update module is further configured to modify the data source information corresponding to the field information bound in the control information according to the target data source information corresponding to the target field information that matches the field information bound in the control information if it is found that the control information is bound to field information.
[0015] In one embodiment, the metadata includes field information of each field in the target document; the control information update module is further configured to clear the control information if it is found that the control information is bound to field information and there is no target field information in the metadata that matches the field information bound to the control information.
[0016] In one embodiment, the control information update module is further configured to clear the data source information corresponding to the field information bound in the control information if it is found that the control information is bound to field information, there is no target field information in the metadata that matches the field information bound in the control information, and the field information bound in the control information is the field information in the entry table of the source document.
[0017] In one embodiment, the control information update module is further configured to clear all information in the control information if it is found that the control information is bound to field information, there is no target field information in the metadata that matches the field information bound to the control information, and the field information bound to the control information is field information in the main table of the source document.
[0018] In one embodiment, the control parsing module is further configured to: if the parsed control type is a control type that does not involve a data source, then keep the control information of the control unchanged; if the parsed control type is a control type that involves a data source, then identify whether field information is bound in the control information; if not bound, then execute the step of keeping the control information unchanged if the parsed control information does not contain bound field information.
[0019] The control information update module is also used to perform the step of updating the control information according to the preset metadata for the target document if there is binding.
[0020] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, which, when executed by the processor, causes the processor to perform the steps in the document template generation method described in the embodiments of this application.
[0021] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, causes the processor to perform the steps in the document template generation method described in the embodiments of this application.
[0022] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, causes the processor to perform the steps in the document template generation method described in the embodiments of this application.
[0023] The aforementioned document template generation method, apparatus, computer equipment, storage medium, and computer program product traverse each control in the document template of the source document, parses the control information of each traversed control, and if unbound field information is found in the parsed control information, the control information remains unchanged. If field information is found to be bound in the parsed control information, the control information is updated according to the metadata preset for the target document. Based on the unchanged control information in the document template of the source document and the updated control information, the document template of the target document is generated. By keeping the control information without bound field information unchanged and updating the control information with bound field information according to the metadata of the target document, the document template of the target document can be preserved to the greatest extent possible. This preserves some information in the document template of the source document that does not involve fields and the field information that is the same as that in the target document. Only a small amount of differentiated updates are needed to the control information with bound field information to quickly convert the document template of the source document into the document template of the target document, realizing rapid reuse of document templates and improving the efficiency of document template generation. Attached Figure Description
[0024] Figure 1 This is an application environment diagram of a document template generation method in one embodiment;
[0025] Figure 2 This is a flowchart illustrating a document template generation method in one embodiment;
[0026] Figure 3This is a schematic diagram of control information in a document template in one embodiment;
[0027] Figure 4 This is a schematic diagram of the operation interface for creating a source document template in one embodiment;
[0028] Figure 5 This is a schematic diagram of the operation interface for instructing the generation of a document template in one embodiment;
[0029] Figure 6 This is a schematic diagram of a document template for a target document generated in one embodiment;
[0030] Figure 7 This is a schematic diagram of the metadata of a document in one embodiment;
[0031] Figure 8 This is a schematic diagram illustrating the metadata of a purchase order and a sales delivery note in one embodiment;
[0032] Figure 9 This is a schematic diagram of the overall process of a document template generation method in one embodiment;
[0033] Figure 10 This is a structural block diagram of a document template generation device in one embodiment;
[0034] Figure 11 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0035] 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.
[0036] The document template generation 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. Users can select a source document template and a target document type through terminal 102. Terminal 102 can generate a document template generation request based on the selected source document template and target document type, and send the request to server 104. Server 104 can respond to the document template generation request by executing the document template generation method in various embodiments of this application to generate a target document template based on the source document template, and then send the target document template to terminal 102 for display. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart vehicle devices, etc. Portable wearable devices can include smartwatches, smart bracelets, head-mounted devices, etc. Server 104 can be implemented using a standalone server or a server cluster consisting of multiple servers.
[0037] In one embodiment, such as Figure 2 As shown, a method for generating document templates is provided, which can be applied to... Figure 1 Taking server 104 as an example, the following steps are included:
[0038] S202, iterate through each control in the document template of the source document and parse the control information of each traversed control.
[0039] The source document template is an existing document template upon which the target document template is based. The source document is the document corresponding to the source document template. A control is an information unit within a document template. Control information describes detailed information about the control. Each control has corresponding control information.
[0040] In one embodiment, the document template may be an XML (Extensible Markup Language) file or a JSON (JavaScript Object Notation) file, etc.
[0041] In one embodiment, control information can be the code corresponding to the control. For example... Figure 3 The image shows the control information in the document template. Each control has corresponding control information, for example: Figure 3 The diagram illustrates the control information corresponding to fixed text, images, main table fields, and entry table fields.
[0042] In one embodiment, the control information may include the control's style and layout information. In another embodiment, if the control involves a data source, the control information may also include data source information. Figure 3 As shown, the style layout information may include at least one of the following: control coordinates, font, control type, field information, and parent control ID. Control type may include at least one of the following: paper type, fixed text, image, table, page number, row, column, cell, and field.
[0043] In one embodiment, a user can select a document template for a source document and a document type for a target document via a terminal. The terminal can then generate a document template generation request based on the selected source document template and target document type, and send the request to the server. The server can respond to the document template generation request by retrieving the source document template and the target document's metadata, and then iterate through the controls in the source document template, parsing the control information of each traversed control and outlining subsequent steps.
[0044] The target document is the document for which a document template needs to be generated. It's important to understand that the source document and the target document are different documents. For example, the source document might be a purchase order, and the target document might be a sales delivery note.
[0045] In one embodiment, the user can display, for example, on the terminal. Figure 4 The interface shown is for creating source document templates. Users can drag and drop or edit the templates. Figure 4 Add or adjust various controls in the interface. Figure 4 The document displayed is a template of a completed source document. Figure 4 The source document corresponding to the document template in the document is a purchase order. Figure 4 The purchase order document template contains controls of various types, including images, fixed text, page numbers, tables, rows, columns, cells, and fields. For example, the purchase order template includes controls for fixed text such as document number, document date, preparer, supplier, salesperson, serial number, product, warehouse, unit, quantity, unit price, amount, and current time. Field controls include controls for information such as $document number, $document date, $preparer.name, $supplier.supplier name, $supplier, $F(serial number), $F(product code.product name), $F(warehouse.warehouse name), $F(unit.unit name), $F(quantity), $F(unit price), and $F(amount). Figure 4 The image in the control is an image type control.
[0046] In one embodiment, a user can select a pre-made source document template and choose the document type for the target document via a terminal. For example... Figure 5 As shown, users can access information from... Figure 5 Select a document template from the list of completed document templates shown as the source document template, for example... Figure 5 The purchase order document template was selected.
[0047] Users can select Figure 5 In the "Save As" option, select the document type of the target document in the Save As settings window, for example, Figure 5 The document type "Sales Delivery Order" was selected as the target document.
[0048] In one embodiment, such as Figure 5 As shown, users can also enter at least one of the following information in the Save As settings window: the template code and template name of the target document template to be generated.
[0049] S204. If the parsed control information shows that no field information is bound, then keep the control information unchanged.
[0050] Among them, field information is information used to characterize the field.
[0051] In one embodiment, field information may be a field identifier or a field name, etc.
[0052] Specifically, if the parsed control information reveals that no field information is bound, the server can leave the corresponding control information unchanged.
[0053] For example, controls such as images, fixed text, current time, and page number information in the source document template do not involve database fields, so their control information can remain unchanged. For example: Figure 3 The column header information (i.e., serial number, product, warehouse, unit, quantity, unit price, and amount) in the data table of the source document template is fixed text, and the corresponding control information can remain unchanged.
[0054] S206 If the control information is parsed and found to contain bound field information, then update the control information according to the metadata preset for the target document.
[0055] Specifically, if the parsed control information contains bound field information, the server can modify or clear the corresponding control information based on the metadata preset for the target document.
[0056] In one embodiment, the metadata can be an XML (Extensible Markup Language) file or a JSON (JavaScript Object Notation) file, etc.
[0057] In one embodiment, the metadata contains field information for each field in the target document. If field information is parsed from the control information, the server can match the field information in the control information with the field information in the metadata. If a matching field exists in the metadata, the corresponding control information is modified according to the metadata. If no matching field exists in the metadata, the corresponding control information is cleared.
[0058] S208: Generate the document template for the target document based on the control information that remains unchanged in the document template of the source document and the updated control information.
[0059] Specifically, after traversing all controls and processing the information of each control accordingly, the server can generate and save the document template of the target document based on the unchanged control information in the document template of the source document and the updated control information.
[0060] It is understandable that after iterating through all the controls in the source document's document template, some controls retain their information unchanged, while others have their information updated. The server generates the target document's document template based on whether the controls remain unchanged or their information is updated after the iteration.
[0061] like Figure 6 As shown, it is based on Figure 4 A diagram illustrating the target document template generated from the document template of the purchase order (i.e., the document template of the source document). Figure 4 The controls for fixed text types, such as purchase order template, document number, document date, preparer, supplier, salesperson, serial number, product, warehouse, unit, quantity, unit price, amount, and current time, do not have bound field information. Figure 6 The control information of these controls remains unchanged. Figure 4 The controls with fields such as $document number, $document date, $preparer.name, $supplier.supplier name, $salesperson, $F(serial number), $F(product code.product name), $F(warehouse.warehouse name), $F(unit.unit name), $F(quantity), $F(unit price), and $F(amount) have bound field information, therefore... Figure 6 The document template of the target document in the middle has updated the control information, such as... Figure 4 The $Supplier.SupplierName control information in the purchase order document template (i.e., the source document document template) has been cleared.
[0062] In one embodiment, after generating the document template for the target document, the user can modify the document template or add fields to the template document that distinguish the target document from the source document, thus obtaining the final document template for the target document. For example: because Figure 4 The fixed text control information in the source document template remains unchanged, so Figure 6 The fixed text information in the generated target document template is consistent with that in the source document, so users can... Figure 6 The interface shown allows users to modify fixed text in the document template of the target document. For example, users can change "Purchase Order Print Template" to "Sales Outbound Order Print Template".
[0063] The above document template generation method iterates through each control in the document template of the source document, parses the control information of each traversed control, and if the parsed control information does not contain bound field information, the control information remains unchanged. If the parsed control information contains bound field information, the control information is updated according to the metadata preset for the target document. Based on the unchanged control information in the document template of the source document and the updated control information, the document template of the target document is generated. By keeping the control information without bound fields unchanged—for example, retaining the paper, color, font, and table style of the source document template, as well as the images, page numbers, and fixed text—while updating the control information with bound fields based on the target document's metadata, this approach maximizes the preservation of unmodified information from the source document template that doesn't involve any fields, as well as field information identical to that in the target document. Only minor updates to the control information with bound fields are needed to quickly convert the source document template into the target document template, enabling rapid template reuse and improving template generation efficiency.
[0064] In one embodiment, the metadata includes field information of each field in the target document and the corresponding data source information; if field information is parsed from the control information, updating the control information according to the metadata preset for the target document includes: if field information is parsed from the control information, modifying the data source information corresponding to the field information bound in the control information according to the target data source information corresponding to the target field information that matches the field information bound in the control information in the metadata.
[0065] Here, data source information refers to the source of the data corresponding to a field in the database. Metadata is a file used to define the relationship between field information and data source information. Target field information refers to the field information in the metadata that matches the field information bound to the control information. Target data source information refers to the data source information in the metadata that corresponds to the target field information.
[0066] In one embodiment, the data source information may include database table information and database field information. Database table information is used to represent data tables in the database. Database field information is used to represent fields within the data tables. In one embodiment, database table information may be the table name or identifier of the database table, etc. Database field information may be the field name or identifier of a database field, etc.
[0067] In one embodiment, a user can pre-create the metadata of the target document via a terminal.
[0068] In one embodiment, the field information of each field in the target document and the corresponding data source information can be pre-recorded in the metadata.
[0069] In one embodiment, a user can pre-create corresponding metadata for each document.
[0070] like Figure 7 The image shows an example of metadata for a document. As can be seen from the image, the metadata records the field names and field identifiers (i.e., field information) of each field in the document, as well as the corresponding database table names and database field names (i.e., data source information).
[0071] like Figure 8 The two metadata entries shown are the metadata for a purchase order and the metadata for a sales delivery note, respectively. As can be seen from the diagram, the information in the metadata differs between different documents, and is set according to the specific document. For example, a purchase order contains a supplier field, while a sales delivery note does not have a supplier field but has different customer and batch fields than the purchase order.
[0072] In one embodiment, if field information is parsed from the control information, the server can match the field information in the control information with the field information in the metadata. If there is a field information in the metadata that matches the field information in the control information, the server can modify the data source information corresponding to the field information bound in the control information based on the target data source information corresponding to the target field information that matches the field information bound in the control information in the metadata.
[0073] In one embodiment, the field information is a field identifier. The server can match the field identifier in the control information with the field identifier in the metadata. If a field identifier in the metadata matches the field identifier in the control information, the server can modify the data source information corresponding to the field information bound in the control information based on the target data source information corresponding to the target field identifier in the metadata that matches the field identifier in the control information.
[0074] In one embodiment, the server can replace the data source information corresponding to the field information bound in the control information with the target data source information corresponding to the target field information in the metadata.
[0075] In one embodiment, all information in the control information except for the modified data source information remains unchanged.
[0076] For example: Figure 4 In the purchase order document template (i.e., the source document template), the main table contains fields such as document number, document date, preparer, salesperson, and the journal entry table contains fields such as serial number, product, warehouse, unit, quantity, unit price, and amount. Figure 8 The metadata of the sales delivery order shown also exists (i.e., the metadata of the target document). Therefore, the data source information corresponding to these fields in the purchase order document template can be modified to the data source information corresponding to these fields in the metadata of the sales delivery order.
[0077] In one embodiment, after traversing all controls, if the data source information in the control information of a cell control is inconsistent with the data source information in the control information of the corresponding data table control, the server can clear the data source information in the control information of the cell control.
[0078] In the above embodiments, by establishing metadata containing field information and corresponding data source information for each field in the target document, and upon parsing out the field information bound to the control information, the data source information corresponding to the field information bound to the control information is modified based on the target data source information corresponding to the target field information that matches the field information bound to the control information in the metadata. This allows for simple modification of the data source information corresponding to the field information in the control information that matches the metadata of the target document, enabling the rapid conversion of the source document's document template into the target document's document template. Identical fields are automatically retained, achieving rapid reuse of document templates and improving the efficiency of document template generation. Furthermore, by modifying the data source information corresponding to the field information bound to the control information based on the target data source information corresponding to the target field information that matches the field information bound to the control information in the metadata, the data source information in the control information of the source document's document template can be accurately modified to the corresponding data source information in the target document, improving the accuracy of document template generation.
[0079] In one embodiment, the metadata includes field information of each field in the target document; if field information is bound in the parsed control information, then updating the control information according to the preset metadata for the target document includes: if field information is bound in the parsed control information and there is no target field information in the metadata that matches the field information bound in the control information, then the control information is cleared.
[0080] Among them, clearing processing refers to the process of clearing all or part of the information in the control information.
[0081] In one embodiment, if the control information is found to contain bound field information, the server can match the field information in the control information with the field information in the metadata. If there is no field information in the metadata that matches the field information bound to the control information, the server can clear the control information.
[0082] In one embodiment, if the control information is parsed to contain field information and there is no target field information in the metadata that matches the field information bound to the control information, the server can identify the degree of clearing based on the position of the field information bound to the control information in the source document, in order to determine whether all or part of the information in the control information needs to be cleared.
[0083] In one embodiment, if the field information bound to the control information is located in the main table of the source document, the server can determine that all information in the control information needs to be cleared. In another embodiment, if the field information bound to the control information is located in the journal entry table of the source document, the server can determine that some information in the control information needs to be cleared.
[0084] The main table refers to the location outside the data tables in the source document. The journal entry table refers to the data tables within the source document. For example: Figure 4 As shown, 402 is the main table and 404 is the journal entry table.
[0085] In one embodiment, the server can match the field information bound in the control information with the field information in the metadata of the source document to determine the location of the field information bound in the control information in the source document.
[0086] In the above embodiments, if the control information is found to be bound to field information and there is no target field information in the metadata that matches the field information bound to the control information, the control information is cleared. This allows for the rapid clearing of control information in the document template of the source document that does not match the field information of the target document. This achieves automatic removal of the difference fields between the source document and the target document, enables rapid reuse of document templates, and improves the efficiency of document template generation.
[0087] In one embodiment, if the control information is parsed to contain field information and there is no target field information in the metadata that matches the field information bound to the control information, then clearing the control information includes: if the control information is parsed to contain field information, there is no target field information in the metadata that matches the field information bound to the control information, and the field information bound to the control information is field information in the entry table of the source document, then clear the data source information corresponding to the field information bound to the control information.
[0088] Specifically, if the parsed control information contains bound field information, and the metadata does not contain a target field information that matches the bound field information in the control information, the server can determine the degree of removal based on the location of the bound field information in the source document. If the bound field information in the control information is a field information in the entry table of the source document, the removal degree determination result is that part of the information in the control information needs to be removed, and the server can respond to the removal degree determination result by clearing the data source information corresponding to the bound field information in the control information.
[0089] It is understandable that if the field information bound in the control information is the field information in the entry table of the source document, since the entry table is the data table in the document template of the source document, it is not possible to clear the entire data in a cell of the data table. That is, it is not possible to clear the entire control information corresponding to that cell, so only the corresponding data source information is cleared.
[0090] In the above embodiments, if the parsed control information contains bound field information, the metadata does not contain target field information that matches the field information bound to the control information, and the field information bound to the control information is a field from the entry table in the source document, then the data source information corresponding to the field information bound to the control information is cleared. This allows for the rapid removal of control information corresponding to field information that does not match the target document from the document template of the source document. This enables the rapid conversion of the document template of the source document into the document template of the target document with only minor differential updates to the control information bound to the field information, achieving rapid reuse of document templates and improving the efficiency of document template generation. Furthermore, in the case where the field information bound to the control information is a field from the entry table in the source document, only the data source information in the control information is cleared, avoiding the abnormal consequences caused by directly removing the control information from the entire cell in the entry table, thus improving the applicability of the solution.
[0091] In one embodiment, if the control information is parsed to contain field information and there is no target field information in the metadata that matches the field information bound to the control information, then clearing the control information includes: if the control information is parsed to contain field information, there is no target field information in the metadata that matches the field information bound to the control information, and the field information bound to the control information is a field information in the master table of the source document, then clear all information in the control information.
[0092] Specifically, if the parsed control information contains bound field information, and the metadata does not contain a target field information that matches the bound field information in the control information, the server can determine the degree of removal based on the location of the bound field information in the source document. If the bound field information in the control information is a field information in the master table of the source document, the removal degree determination result is that all information in the control information needs to be removed, and the server can respond to the removal degree determination result by clearing all information in the control information.
[0093] It is understandable that if the field information bound to the control information is the field information in the main table of the source document, since the main table is located outside the data table in the document template of the source document and the information in the main table is relatively independent of each other, the corresponding control information can be completely removed.
[0094] In the above embodiments, if the parsed control information contains bound field information, the metadata does not contain target field information that matches the field information bound to the control information, and the field information bound to the control information is a field information in the master table of the source document, then all information in the control information is cleared. This allows for the rapid removal of control information corresponding to field information in the source document's document template that does not match the target document. This enables the rapid conversion of the source document's document template into the target document's document template with only minor differential updates to the control information bound to the field information, achieving rapid reuse of document templates and improving document template generation efficiency. Furthermore, clearing all information in the control information when the field information bound to the control information is a field information in the master table of the source document improves the applicability of the solution.
[0095] In one embodiment, the method further includes: if the parsed control type is a control type that does not involve a data source, then keeping the control information unchanged; if the parsed control type is a control type that involves a data source, then identifying whether the control information is bound to field information; if not bound, then performing the step of keeping the control information unchanged if the parsed control information is not bound to field information; if bound, then performing the step of updating the control information according to the metadata preset for the target document if the parsed control information is bound to field information.
[0096] Specifically, the server can first determine the control type based on the control information, and then determine whether the control type involves a data source. If the control type does not involve a data source, the server can keep the control information unchanged. If the control type involves a data source, the server can identify whether there is bound field information in the control information involving the data source. If not bound, the server executes the step of keeping the control information unchanged if no bound field information is found in the parsed control information; if bound, the server executes the step of updating the control information according to the preset metadata for the target document if bound field information is found in the parsed control information.
[0097] like Figure 9 As shown, because paper information is a control type that does not involve the data source, the server can directly keep the control information of the paper information unchanged, that is, without processing it, as shown. Figure 9 The "Completed" step. Because tables, rows, columns, cells, text, and images are control types involving data sources, the server can further determine whether the control information is bound to field information, that is, execute... Figure 9 The steps for determining "whether there is a bound data source" and "whether there is bound field information" are as follows.
[0098] In the above embodiments, for control types that do not involve data sources, the control information is kept unchanged. For control types that involve data sources, it is further determined whether the control information is bound to field information. This optimizes the processing flow and improves the efficiency of document template generation.
[0099] like Figure 9 The diagram shown is a schematic representation of the overall process of the document template generation method in various embodiments of this application. First, the user selects a document template for the source document via the terminal. The server, based on the user's selection, obtains the document template object of the source document and the metadata of the target document, retrieving field information and data source information from the metadata. The server can iterate through each control in the document template object of the source document to determine the control type of the traversed control. If the control type is a control type that does not involve a data source, such as paper information, the server can keep the corresponding control information unchanged (i.e., ...). Figure 9 (Completion in the process). If the control type is a table, row, column, cell, text, or image control that involves a data source, the server can determine whether the control information is bound to a data source. If not, it skips the process, meaning the corresponding control information remains unchanged. If a data source is bound, the server can determine whether the control information is bound to field information. If not, it skips the process, meaning the corresponding control information remains unchanged. If field information is bound, the server can determine whether the bound field information is within the metadata of the target document. That is, whether the target document's metadata contains a target field information that matches the bound field information. If so, the server can modify the data source information in the control information based on the data source information in the metadata. If not, the server can determine whether the bound field information is a field bound to a data table (i.e., entry table) in the source document. If not (i.e., the field information bound to the control information is a field in the main table of the source document), the server can remove the entire control, i.e., clear all information in the control information. If so (i.e., the field information bound to the control information is a field in the entry table of the source document), the server can clear the data source information in the control information. After traversing all controls, if the data source information in the cell control's control information is inconsistent with the data source information in the control information of its corresponding data table control, the server can clear the data source information in the cell control's control information. Finally, the server can obtain the document template of the target document based on the traversed control information and save it.
[0100] It should be understood that although the steps in the flowcharts of the above embodiments 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 above embodiments 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.
[0101] Based on the same inventive concept, this application also provides a document template generation apparatus for implementing the document template generation method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more document template generation apparatus embodiments provided below can be found in the limitations of the document template generation method described above, and will not be repeated here.
[0102] In one embodiment, such as Figure 10 As shown, a document template generation device 1000 is provided, including: a control parsing module 1002, a control information updating module 1004, and a document template generation module 1006, wherein:
[0103] The control parsing module 1002 is used to traverse each control in the document template of the source document and parse the control information of each traversed control; if the parsed control information does not contain bound field information, the control information is kept unchanged.
[0104] The control information update module 1004 is used to update the control information according to the metadata preset for the target document if the control information is parsed and bound to field information.
[0105] The document template generation module 1006 is used to generate the document template of the target document based on the control information that remains unchanged in the document template of the source document and the updated control information.
[0106] In one embodiment, the metadata includes field information for each field in the target document and the corresponding data source information. The control information update module 1004 is further configured to, if it is found that the control information is bound to field information, modify the data source information corresponding to the field information bound to the control information based on the target data source information corresponding to the target field information that matches the field information bound to the control information in the metadata.
[0107] In one embodiment, the metadata includes field information for each field in the target document. The control information update module 1004 is further configured to clear the control information if it is found that the control information is bound to field information and there is no target field information in the metadata that matches the field information bound to the control information.
[0108] In one embodiment, the control information update module 1004 is further configured to clear the data source information corresponding to the field information bound in the control information if it is found that the control information is bound to field information, there is no target field information in the metadata that matches the field information bound in the control information, and the field information bound in the control information is the field information in the entry table of the source document.
[0109] In one embodiment, the control information update module 1004 is further configured to clear all information in the control information if it is found that the control information is bound to field information, there is no target field information in the metadata that matches the field information bound to the control information, and the field information bound to the control information is field information in the master table of the source document.
[0110] In one embodiment, the control parsing module 1002 is further configured to: if the parsed control type is a control type that does not involve a data source, then keep the control information of the control unchanged; if the parsed control type is a control type that involves a data source, then identify whether field information is bound in the control information; if not bound, then execute the step of keeping the control information unchanged if no field information is bound in the parsed control information.
[0111] The control information update module 1004 is also used to perform the following steps if there is binding: if the control information is parsed and the field information is bound, then update the control information according to the metadata preset for the target document.
[0112] The aforementioned document template generation device traverses each control in the source document's document template, parses the control information of each traversed control, and if the parsed control information contains unbound fields, it keeps the control information unchanged. If the parsed control information contains bound fields, it updates the control information according to the metadata preset for the target document. Based on the unchanged control information in the source document's document template and the updated control information, the document template for the target document is generated. By keeping the control information without bound fields unchanged and updating the control information with bound fields according to the target document's metadata, it can retain, to the greatest extent possible, some information in the source document's document template that does not involve fields and the field information that is the same as that in the target document. Only a small amount of differentiated updates are needed to the control information with bound fields to quickly convert the source document's document template into the target document's document template, realizing rapid reuse of document templates and improving the efficiency of document template generation.
[0113] Each module in the aforementioned document template generation device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.
[0114] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 11 As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. 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, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores document data, document metadata, and completed document templates. The network interface communicates with external terminals via a network connection. When executed by the processor, the computer program implements a document template generation method.
[0115] Those skilled in the art will understand that Figure 11 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.
[0116] In one embodiment, a computer device is 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-described method embodiments.
[0117] 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.
[0118] 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.
[0119] 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.
[0120] 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.
[0121] 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.
[0122] 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 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 method for generating document templates, characterized in that, The method includes: Iterate through each control in the document template of the source document and parse the control information of each traversed control; If it is found that no field information is bound in the parsed control information, then the control information remains unchanged; If the control information is parsed to contain bound field information, then the control information is updated according to the metadata preset for the target document. This includes: if the control information is parsed to contain bound field information, the metadata does not contain target field information that matches the bound field information in the control information, and the bound field information in the control information is a field in the entry table of the source document, then the data source information corresponding to the bound field information in the control information is cleared; if the control information is parsed to contain bound field information, the metadata does not contain target field information that matches the bound field information in the control information, and the bound field information in the control information is a field in the main table of the source document, then all information in the control information is cleared. The metadata contains the field information of each field in the target document. The main table refers to the location outside the data table in the source document, and the entry table refers to the data table in the source document. The document template for the target document is generated based on the unchanged control information in the document template of the source document and the updated control information.
2. The method according to claim 1, characterized in that, The metadata includes field information for each field in the target document and the corresponding data source information; If the parsed control information is found to contain bound field information, then updating the control information according to the preset metadata for the target document includes: If the control information is parsed to contain field information, then the data source information corresponding to the field information bound in the control information is modified according to the target data source information corresponding to the target field information that matches the field information bound in the control information in the metadata.
3. The method according to claim 1, characterized in that, The method further includes: pre-recording the field information of each field in the target document and the corresponding data source information into the metadata.
4. The method according to claim 1, characterized in that, The method also includes: pre-establishing corresponding metadata for each document.
5. The method according to any one of claims 1 to 4, characterized in that, The method further includes: If the control type of the control is determined to be a control type that does not involve a data source, then the control information of the control remains unchanged. If the control type is determined to be a control type involving a data source, then identify whether the control information is bound to field information. If not bound, then execute the step of keeping the control information unchanged if unbound field information is found in the parsed control information; If there is binding, then the step of updating the control information according to the preset metadata for the target document if the control information is parsed and found to be bound to field information is executed.
6. A document template generation device, characterized in that, The device includes: The control parsing module is used to traverse each control in the document template of the source document and parse the control information of each traversed control; if the parsed control information is found to have no bound field information, the control information is kept unchanged. The control information update module is used to update the control information according to the metadata preset for the target document if the control information is found to be bound to field information. This includes: if the control information is found to be bound to field information, the metadata does not contain target field information matching the field information bound to the control information, and the field information bound to the control information is a field in the entry table of the source document, then the data source information corresponding to the field information bound to the control information is cleared; if the control information is found to be bound to field information, the metadata does not contain target field information matching the field information bound to the control information, and the field information bound to the control information is a field in the main table of the source document, then all information in the control information is cleared. The metadata includes the field information of each field in the target document. The main table refers to a location outside the data table in the source document, and the entry table refers to the data table in the source document. The document template generation module is used to generate the document template of the target document based on the unchanged control information and the updated control information in the document template of the source document.
7. 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 5.
8. 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 5.
9. 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 5.