A layout-based document data interaction method and server
Patent Information
- Application Number
- CN202610801903.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-04
- Publication Date
- 2026-10-13
AI Technical Summary
[0004]然而,由于PDF文档内部的编辑状态与MIS的流程状态在物理与逻辑上相割裂,系统仅能控制文件的整体上传与下载,无法对文档内部实现字段级、节点级的动态可见与可写控制,导致多环节审批中可能会出现越权修改他人填写内容的状态失控问题
[0025]1、将版式文档的底层表单域与管理信息系统的业务流程节点进行解耦,构建二维权限矩阵以实现字段级别的权限管控。在多环节审批流转中,根据当前节点动态渲染表单域的交互状态,并在后端剥离越权修改的数据,仅提取合法更新数据。从而降低了前端环境被绕过或篡改的风险,减少了用户在审批过程中越权修改他人历史数据的可能性。
Smart Images

Figure CN122904868A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of information processing technology, and in particular to a data interaction method and server based on a layout document. Background Technology
[0002] In compliance management and production execution scenarios such as the safety management system of shipping companies, there are typically a large number of records, forms, and evidence materials with fixed formats that need to be retained for a long time and are traceable. To ensure the consistency of the same record in display, printing, and auditing across different terminals, the industry usually uses fixed-format documents such as PDFs to store these business forms. At the same time, relevant policies and standards have put forward clear compliance requirements for the archiving of electronic records, the legal validity of electronic signatures, and the auditability of the entire process. This prompts companies to integrate traditional formatted document management into a unified Management Information System (MIS) for circulation and control.
[0003] In relevant Management Information Systems (MIS), business workflows for such fixed-format documents typically employ a parallel approach of attachment workflow or independent form systems. Specifically, the system treats the PDF document as an attachment node in the business process. When a user triggers a corresponding task, they download the PDF template locally or open it in a separate third-party PDF editor, complete the content and electronic signature, and then re-upload the modified PDF file as an attachment to the MIS system to advance the process. Regarding permissions and status management, the relevant technologies primarily rely on the MIS's own menu permissions and document-level read / write permissions to control the user's overall access to the attachment. In the data storage and archiving stage, the system directly archives and saves the finally uploaded PDF file and independently records the approval workflow time and operator information through the MIS workflow log, thus piecing together a chain of business approval records.
[0004] However, because the editing state within a PDF document is physically and logically separated from the workflow state in the MIS, the system can only control the overall upload and download of the file. It cannot implement dynamic visibility and writability control at the field and node levels within the document, which may lead to unauthorized modifications to content filled in by others during multi-stage approval processes, resulting in a loss of control over the status. Summary of the Invention
[0005] This application provides a data interaction method and server based on a layout document, which can reduce the risk of loss of control in the multi-stage approval process of management information systems due to unauthorized modification of content filled in by others.
[0006] Firstly, a data interaction method based on a layout document is provided, characterized by being applied to a server. The method includes: extracting field identifiers of form fields from a preset layout document template and constructing a two-dimensional permission matrix mapping the field identifiers to the operation permissions of management information system process nodes, where operation permissions include editable and read-only states; upon receiving a pending processing request for a target layout document instance, determining the current management information system process node of the target layout document instance and extracting a set of target operation permissions corresponding to the current management information system process node from the two-dimensional permission matrix; and based on the target operation permission set, overlaying the historical payload data of the target layout document instance onto the preset layout document template to generate front-end rendering instructions. The system controls the front-end interface to render form fields defined as editable as allowed input and form fields defined as read-only as locked. When a form update request containing updated field data and field identifiers is received from the front-end interface, the updated field data associated with the field identifiers in read-only state is stripped as unauthorized data, and the updated field data associated with the field identifiers in editable state is extracted as valid update data. The valid update data is merged into the corresponding field positions in the historical payload data to generate the latest payload data. The target layout document instance is updated based on the latest payload data, and the current management information system process node is advanced to the next management information system process node.
[0007] By adopting the above technical solution, the underlying form fields of the formatted document are decoupled from the business process nodes of the management information system, and a two-dimensional permission matrix is constructed to achieve field-level permission control. In multi-stage approval workflows, the interactive state of the form fields is dynamically rendered based on the current node, and data modified without authorization is stripped away on the backend, extracting only legitimate updated data. This reduces the risk of the front-end environment being bypassed or tampered with, and decreases the possibility of users unauthorizedly modifying others' historical data during the approval process.
[0008] In conjunction with some embodiments of the first aspect, in some embodiments, the step of merging legitimate update data into the corresponding field position in historical payload data to generate the latest payload data specifically includes: obtaining the physical boundary size of the target form field corresponding to the legitimate update data in a preset layout document template; calculating the actual rendering size required for the legitimate update data under a preset font specification based on a preset typesetting rendering engine; if the actual rendering size exceeds the physical boundary size, splitting the legitimate update data into basic visible data and overflow payload data; writing the basic visible data and associated overflow anchor point identifier into the corresponding field position in the historical payload data, and storing the overflow payload data in an extended payload area independent of the main layout to generate the latest payload data.
[0009] By adopting the above technical solution, when data exceeds the layout space of the preset document template, the data is split into basic visible data and overflow payload data and stored separately. This maintains the consistency of the main layout of the document while preserving the complete user input, avoiding text overlap or layout distortion caused by excessively long data.
[0010] In conjunction with some embodiments of the first aspect, in some embodiments, the step of overlaying historical payload data of a target layout document instance onto a preset layout document template to generate front-end rendering instructions based on a target operation permission set specifically includes: when parsing historical payload data, if it is detected that the data of the current form field contains an overflow anchor point identifier, a composite front-end rendering instruction containing a main layout rendering instruction and an extended interaction instruction is generated; the main layout rendering instruction is used to control the front-end interactive interface to render basic visible data and overflow anchor point identifiers within the physical boundary of the current form field; the extended interaction instruction is used to call and render overflow payload data from the extended payload area when the front-end interactive interface listens for a trigger operation on the overflow anchor point identifier, and restricts the rendering layer of the overflow payload data from changing the basic layout structure of the preset layout document template.
[0011] By adopting the above technical solution, during the front-end rendering stage, a composite instruction containing main layout rendering and extended interactive instructions is generated for form fields with overflow data. Users can view the overflow payload data by triggering the overflow anchor point, and the rendering layer of the overflow data is independent of the main layout. This interaction method provides a way to read extremely long texts without changing the basic layout structure of the preset document template.
[0012] In conjunction with some embodiments of the first aspect, in some embodiments, after the step of advancing the current management information system process node to the next management information system process node, the method further includes: if the next management information system process node is an archived final state node, then extracting all overflow load data in the extended load area; appending an appendix layout page matching the overflow load data to the end of a preset layout document template; converting the overflow anchor point identifier into an in-document link pointing to the appendix layout page; and merging the latest load data, the appendix layout page, and the in-document link to generate an uneditable static archived layout document.
[0013] By adopting the above technical solution, when the process flows to the final archiving node, the independently stored overflow payload data is transformed into an appendix format page, and associated with the overflow anchor point of the main page through in-document links, so that the final generated static archive format document contains all approval opinions and long text inputs at the physical file level.
[0014] In conjunction with some embodiments of the first aspect, in some embodiments, when receiving a form update request from the front-end interactive interface containing updated field data and field identifiers, the method further includes: extracting the front-end process node identifier carried in the form update request from the front-end local cache, and obtaining the server-side process node identifier currently maintained by the management information system for the target format document instance; if the server-side process node identifier is detected to be inconsistent with the front-end process node identifier, it is determined that the front-end state has a cache disconnection, the data extraction step of the form update request is interrupted, and a state overwrite instruction is generated based on the server-side process node identifier; the state overwrite instruction is returned to the front-end interactive interface to instruct the front-end interactive interface to discard the locally cached front-end process node identifier, and obtain the real target operation permission set based on the server-side process node identifier by re-initiating a loading request.
[0015] By adopting the above technical solution, a consistency verification mechanism between the front-end cache state and the server-side process node identifier is added when receiving form update requests. When a front-end state disconnect is detected, data submission is intercepted and the front-end is instructed to re-acquire the target operation permission set. This mechanism reduces the risk of data overwriting or state conflicts caused by inconsistencies between the primary and secondary states, and improves the data accuracy of the system under network latency or multi-terminal operation scenarios.
[0016] In conjunction with some embodiments of the first aspect, in some embodiments, after the step of extracting the set of target operation permissions corresponding to the current management information system process node from the two-dimensional permission matrix, the method further includes: extracting linkage calculation rules defined between multiple form fields from a preset format document template, wherein the linkage calculation rules include a first form field as a calculation input item and a second form field as a calculation output item; for a target linkage calculation rule where the first form field falls into an editable state and the second form field falls into a read-only state, upon receiving a form update request, calculating and generating derived data for the second form field based on the valid update data of the first form field and the target linkage calculation rule; and synchronously updating the derived data to the field position corresponding to the second form field in the historical payload data.
[0017] By adopting the above technical solution, linkage calculation rules are defined between multiple form fields. On the server side, the data in the editable form fields is calculated and the related read-only form field data is updated. This places the business logic calculation on the server side, reducing the computational overhead and manual repetitive data entry operations on the front end, and helps maintain the consistency of cross-field data.
[0018] In conjunction with some embodiments of the first aspect, in some embodiments, before the step of stripping the updated field data associated with the field identifier that falls into a read-only state as unauthorized data when a form update request containing updated field data and field identifiers from the front-end interactive interface is received, the method further includes: parsing the request idempotency identifier and the front-end document instance version number carried in the form update request; verifying whether the request idempotency identifier exists in the server's processed request record library, and comparing the front-end document instance version number with the current server-side document instance version number of the target layout document instance; if the request idempotency identifier does not exist in the processed request record library, and the front-end document instance version number is consistent with the current server-side document instance version number, allowing the step of extracting legitimate update data; if the request idempotency identifier already exists in the processed request record library, or the front-end document instance version number is inconsistent with the current server-side document instance version number, then intercepting the form update request and returning a status error message; when performing the step of updating the target layout document instance based on the latest payload data, simultaneously incrementing the current server-side document instance version number and writing the request idempotency identifier into the processed request record library.
[0019] By adopting the above technical solution, a verification mechanism for request idempotency and document instance version number is introduced before data updates. This mechanism can identify and intercept duplicate submission requests caused by network retransmissions or concurrent operations from multiple terminals, avoiding duplicate writes under the same business semantics, reducing the probability of concurrency conflicts and data overwriting, thereby maintaining data consistency in high-concurrency scenarios.
[0020] In a second aspect, embodiments of this application provide a server comprising: one or more processors and a memory; the memory is coupled to the one or more processors and is used to store computer program code, the computer program code including computer instructions, wherein the one or more processors invoke the computer instructions to cause the server to perform the method described in the first aspect and any possible implementation thereof.
[0021] Thirdly, embodiments of this application provide a computer program product containing instructions that, when the computer program product is run on a server, cause the server to perform the method described in the first aspect and any possible implementation thereof.
[0022] Fourthly, embodiments of this application provide a computer-readable storage medium including instructions that, when executed on a server, cause the server to perform the method described in the first aspect and any possible implementation thereof.
[0023] Understandably, the server provided in the second aspect, the computer program product provided in the third aspect, and the computer storage medium provided in the fourth aspect are all used to execute the methods provided in the embodiments of this application. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods, and will not be repeated here.
[0024] One or more technical solutions provided in the embodiments of this application have at least the following technical effects or advantages:
[0025] 1. Decouple the underlying form fields of the layout document from the business process nodes of the management information system, and construct a two-dimensional permission matrix to achieve field-level permission control. In multi-stage approval workflows, the interactive state of the form fields is dynamically rendered based on the current node, and unauthorized modifications are stripped from the backend, extracting only legitimate update data. This reduces the risk of the frontend environment being bypassed or tampered with, and decreases the possibility of users unauthorizedly modifying others' historical data during the approval process.
[0026] 2. When data exceeds the layout space of the preset document template, the data is split into basic visible data and overflow payload data and stored separately. This preserves the complete user input while maintaining the consistency of the main layout of the document, avoiding text overlap or layout distortion caused by excessively long data.
[0027] 3. A verification mechanism for request idempotency and document instance version number was introduced before data updates. This mechanism can identify and intercept duplicate submission requests caused by network retransmissions or concurrent operations from multiple devices, avoiding duplicate writes under the same business semantics, reducing the probability of concurrency conflicts and data overwriting, thereby maintaining data consistency in high-concurrency scenarios. Attached Figure Description
[0028] Figure 1 This is a flowchart illustrating a data interaction method based on a layout document in an embodiment of this application.
[0029] Figure 2 This is another flowchart illustrating a data interaction method based on a layout document in an embodiment of this application.
[0030] Figure 3 This is a schematic diagram of the physical device structure of a server in an embodiment of this application. Detailed Implementation
[0031] The terminology used in the following embodiments of this application is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. As used in the specification and appended claims of this application, the singular expressions “a,” “an,” “the,” “the,” “the,” and “this” are intended to include the plural expressions as well, unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in this application refers to and includes any or all possible combinations of one or more of the listed items.
[0032] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature, and in the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.
[0033] This application provides a data interaction method and server based on a layout document, which can reduce the risk of loss of control in the multi-stage approval process of management information systems due to unauthorized modification of content filled in by others.
[0034] Please see Figure 1 This is a flowchart illustrating a data interaction method based on a layout document in an embodiment of this application.
[0035] S101. Extract the field identifiers of form fields from the preset format document template, and construct a two-dimensional permission matrix that maps the field identifiers to the operation permissions of the process nodes in the management information system.
[0036] Among them, a preset document template refers to a low-level document file with a fixed layout and interactive capabilities that is pre-registered and configured in the management information system, such as a PDF format open flame operation approval form template containing text fields, date and time fields, and signature fields. The field identifier of a form field is used to represent a unique identifier for each independent interactive data collection area in the preset document template, such as a unique Field_ID generated by combining the template identifier with the form field name. Management information system process nodes refer to the various independent approval or processing steps in the business approval workflow, such as the department head approval node. Operation permissions are used to represent the level of interactive control over a specific form field under a specific process node, such as editable, read-only, invisible, or required status. A two-dimensional permission matrix is a data structure model that uses the field identifier of the form field as one dimension (e.g., rows) and the management information system process node or role as the other dimension (e.g., columns) to record the fine-grained permission status under the cross-correspondence between the two.
[0037] Specifically, the server first parses the underlying structure of the preset document template (such as the AcroForm dictionary for PDF), traverses and extracts the field names, types, and coordinate ranges of all interactive form field components, and generates a globally unique field identifier dictionary accordingly. Then, the server reads the business approval workflow bound to the template in the management information system, obtaining all process nodes and associated job role information. Next, the server cross-combines the extracted field identifiers with the process nodes, assigning corresponding operation permission status to each intersection point according to pre-set business rules or administrator authorization configurations. In this way, the form's field-level permissions are deeply decoupled and mapped to the organizational structure and process nodes of the management information system, thereby generating and persistently storing this two-dimensional permission matrix in memory or a database, providing a dynamic, non-hard-coded field-level permission verification benchmark in subsequent document flow.
[0038] In some embodiments, a two-dimensional permission matrix mapping field identifiers to the operation permissions of process nodes in the management information system can be constructed in various ways. Optionally, the server receives field permission selection instructions from the administrator for each process node and role through a visual configuration interface, parses the instructions to obtain the permission status of each field identifier under the corresponding node, executes a conflict resolution algorithm (such as the highest permission priority strategy) to eliminate permission discrepancies when the same user holds multiple positions, and writes the final permission status data into the permission configuration table of a relational database according to the matrix data structure. Optionally, the server reads a pre-written permission mapping configuration file in JSON or XML format, parses the node array and field permission mapping dictionary in the file, performs a validity check in combination with the field dictionary of a preset document template, and after the check passes, directly instantiates the two-dimensional permission matrix object in the server's distributed cache using memory mapping technology.
[0039] S102. Upon receiving a pending processing request for a target document instance, determine the current management information system process node of the target document instance, and extract the target operation permission set corresponding to the current management information system process node from the two-dimensional permission matrix.
[0040] Among them, a target format document instance refers to a specific document record object generated based on a preset format document template, which is actually circulating in the business process and carries specific business data, such as a specific open flame operation approval form instance initiated by a ship on a certain day. A pending processing request refers to a network request initiated by a user through a terminal device to the server, intending to open and process the document task currently due for their approval, such as an embedded loading request triggered by a user clicking on an item in a unified pending list. The current management information system process node is used to represent the actual approval flow stage of the target format document instance, i.e., the true master state maintained by the management information system. The target operation permission set refers to the summary data of the operation permission status corresponding to all form fields under the current process node, such as a permission control list that clearly specifies which signature fields are editable and which basic information fields are read-only under the current node.
[0041] Specifically, after receiving a pending processing request from the front end, the server first parses the instance identifier and task identifier carried in the request. Based on this, it queries the workflow engine and instance metadata table of the management information system to obtain the identifier of the current actual process node where the target document instance is located. Subsequently, using the process node identifier and the role of the current user as an index, the server queries the two-dimensional permission matrix constructed in S101, matches and extracts the set of target operation permissions specific to the current management information system process node. Through this extraction process, different review positions only have write permissions to the corresponding signing area within their own nodes, providing strict permission data support for subsequent on-demand dynamic rendering.
[0042] In some embodiments, the target operation permission set corresponding to the current management information system process node can be extracted from the two-dimensional permission matrix in multiple ways. Optionally, the server queries the two-dimensional permission matrix based on the current process node identifier to obtain a basic permission status set, and then calls the permission dynamic fine-tuning interface to perform secondary filtering and correction on the basic permission status according to the business attributes (such as the ship to which it belongs, the operation type) and applicable scope configuration records of the current target format document instance, and finally outputs the corrected target operation permission set. Optionally, the server extracts the linkage calculation rules defined between multiple form fields from the configuration records of the preset format document template. The linkage calculation rules include a first form field as a calculation input item and a second form field as a calculation output item. Then, based on the current process node identifier, the server performs column slicing query in the two-dimensional permission matrix to obtain the basic permission set, and binds and encapsulates the extracted linkage calculation rules with the basic permission set to jointly generate a target operation permission set containing static permissions and dynamic logic.
[0043] S103. Based on the target operation permission set, the historical payload data of the target layout document instance is superimposed onto the preset layout document template to generate front-end rendering instructions, so as to control the front-end interactive interface to render the form fields defined as editable in the target operation permission set as allowed input, and render the form fields defined as read-only as locked.
[0044] Historical payload data refers to the collection of business data that has been legally filled in and structured in previous process nodes for the target format document instance, such as the job information and review comments filled in the preceding nodes stored in XML or JSON format. Front-end rendering instructions refer to the code or data packages sent from the server to the front-end browser to guide the front-end on how to render the document and control the form's interactive state, such as composite instructions containing PDF background streams and form overlay state configurations. The front-end interactive interface represents the visual, layout-style operation window embedded in the management information system's business pages, as seen by the user on the terminal device, such as the PDF interactive reader component in a web browser.
[0045] Specifically, the server extracts historical payload data associated with the target layout document instance and, in conjunction with the target operation permission set, logically overlays this structured data with the underlying format of the preset layout document template. Instead of directly generating a physically locked static PDF file, the server dynamically generates front-end rendering instructions containing layout background information, historical data values, and the interactive states of each form field. Upon receiving these instructions, the front-end interface dynamically draws form field components on top of the background. Fields marked as editable in the target operation permission set are rendered as active input boxes or signature areas for user input. Fields marked as read-only are rendered as plain text with historical data or as locked components with a disabled state, thus achieving field-level state control on the front end.
[0046] In some embodiments, front-end rendering instructions can be generated based on the target operation permission set in various ways. Optionally, the server converts a preset layout document template into a high-resolution image or SVG base map, encapsulates the historical payload data and the target operation permission set into a JSON-formatted form configuration object, and then combines the base map URL and the form configuration object to generate front-end rendering instructions for distribution. The front-end then draws the corresponding HTML input controls on the absolute coordinates of the base map according to these instructions. Optionally, the server utilizes a PDF parsing library to directly inject the historical payload data into the AcroForm dictionary object of the PDF template on the server side, and strictly iterates and modifies the ReadOnly attribute flag and appearance stream of each form field inside the PDF according to the target operation permission set. Finally, the modified PDF file stream is distributed as a front-end rendering instruction to the front-end PDF reader component for native rendering.
[0047] S104. When receiving a form update request from the front-end interactive interface containing updated field data and field identifiers, the updated field data associated with the field identifiers that fall into the read-only state is stripped as unauthorized data, and the updated field data associated with the field identifiers that fall into the editable state is extracted as valid update data.
[0048] In this context, a form update request refers to a data packet sent to the server when a user completes data entry, signing, or modification on the front-end interactive interface, triggering a submit or process save operation. This could be a structured POST request containing the user's latest input. Updated field data refers to the latest values of each form field carried in the request, such as newly entered approval comments or selected security measures. Unauthorized data refers to data in the request containing read-only fields that should not be modified in the current node, such as maliciously altered historical approval comments from others. Legitimate update data represents field data that meets the current node's permission requirements, is permitted to be modified by the current user, and has passed business rule validation.
[0049] Specifically, due to the risk of the front-end environment being bypassed or tampered with, the server needs to perform strict secondary permission verification and status arbitration on the backend after receiving a form update request. The server extracts all field identifiers and their corresponding update field data from the request, and compares them one by one with the target operation permission set of the current process node. If it finds that some field identifiers are explicitly defined as read-only in the permission set, but the request contains update data for these fields, the server will determine that this data is unauthorized data and directly remove and discard it, while recording it in the security audit log. Only when the field identifier is explicitly defined as editable in the permission set will the server extract its associated update field data as legitimate update data for subsequent persistent storage. Through this mandatory backend filtering, the risk of unauthorized modification of content filled in by others during multi-stage approval is reduced.
[0050] In some embodiments, legitimate update data can be extracted and its status and consistency verified in various ways. Optionally, the server extracts the front-end process node identifier (i.e., secondary status) carried in the form update request from the front-end local cache, and obtains the server-side process node identifier (i.e., primary status) currently maintained by the management information system for the target format document instance. If the server-side process node identifier is found to be inconsistent with the front-end process node identifier, it is determined that there is a cache disconnect in the front-end status, the data extraction step of the form update request is interrupted, and a status overwrite instruction is generated based on the server-side process node identifier and returned to the front-end interactive interface to instruct the front-end interactive interface to discard the locally cached front-end process node identifier, and obtain the real target operation permission set based on the server-side process node identifier by re-initiating the loading request. Optionally, the server parses the idempotency flag and front-end document instance version number carried in the form update request, verifies whether the idempotency flag exists in the server's processed request record database, and compares the front-end document instance version number with the current server-side document instance version number of the target layout document instance. If the idempotency flag does not exist in the processed request record database, and the front-end document instance version number matches the current server-side document instance version number, the step of extracting valid update data is allowed. If the idempotency flag already exists or the version numbers are inconsistent, the form update request is intercepted and a status error message is returned. Optionally, for the target linkage calculation rule in the extracted linkage calculation rule where the first form field is in an editable state and the second form field is in a read-only state, when the server receives the form update request, based on the valid update data of the first form field and the target linkage calculation rule, the server calculates and generates derived data for the second form field on the server side, and synchronously updates the derived data to the field position corresponding to the second form field in the historical payload data.
[0051] S105. Merge the valid updated data into the corresponding field positions in the historical load data to generate the latest load data, update the target format document instance based on the latest load data, and advance the current management information system process node to the next management information system process node.
[0052] The latest payload data refers to a complete set of structured business data that integrates existing legitimate historical data with current node legitimate update data. For example, it could be a complete XML or JSON data package containing all historical approval opinions and the latest approval opinions. The next management information system process node refers to the subsequent approval step in the business approval workflow that follows the current step, such as the captain's approval node after the department head's review.
[0053] Specifically, the server extracts the legitimate update data and, according to the mapping model of field identifiers, overwrites or appends it to the corresponding field positions in the historical payload data (for example, performing difference merging, only updating fields newly added in this node), thereby constructing the latest payload data reflecting the current business status. Subsequently, the server uses this latest payload data to persistently update the record of the target format document instance in the database and synchronously update the instance metadata (such as submission status, last review time, etc.). After confirming that the data update is correct, the server calls the event interface of the workflow engine to officially advance the process status of the target format document instance from the current management information system process node to the next management information system process node, and synchronously generates new pending tasks to push to the next stage for processing.
[0054] In some embodiments, legitimate update data can be merged into the corresponding field positions in historical payload data in various ways to generate the latest payload data and advance the process. Optionally, the server reads the historical payload data XML string stored in the database, parses it into a DOM tree, traverses the key-value pairs of legitimate update data to update or insert the corresponding XML nodes, then reserializes the updated DOM tree and writes it to the database. Simultaneously, when executing the step of updating the target layout document instance based on the latest payload data, the current server-side document instance version number is incremented, and the request idempotency flag is written to the processed request record database. Finally, the process engine interface is called to advance the node. Optionally, the server performs a deep merge of the legitimate update data and historical payload data in a JSON object in memory. For evidence data such as signatures, it appends them to a separate evidence array. Then, a persistent transaction is triggered to write the merged JSON data and the updated instance metadata to a distributed storage medium. After the transaction is successfully committed, an asynchronous message queue is triggered to notify the workflow engine of the management information system to advance the current process node to the next management information system process node.
[0055] In the above embodiments, the underlying form fields of the formatted document are decoupled from the business process nodes of the management information system, and a two-dimensional permission matrix is constructed to achieve field-level permission control. During multi-stage approval workflows, the interactive state of the form fields is dynamically rendered based on the current node, and unauthorized modifications are stripped from the backend, extracting only legitimate update data. This reduces the risk of the frontend environment being bypassed or tampered with, and decreases the possibility of users unauthorizedly modifying others' historical data during the approval process.
[0056] However, formatted documents typically have fixed physical layout and boundary constraints. When users enter long text in form fields, directly rendering it within the limited physical boundaries can easily lead to text overlap or overflow, affecting the document's layout standards. Limiting input length directly on the front end might prevent the entry of some business data. Therefore, how to handle the input and display of long text while maintaining the fixed layout structure of the document is a technical problem that needs further resolution.
[0057] Please see Figure 2 This is another flowchart illustrating a data interaction method based on a layout document in an embodiment of this application.
[0058] S201. Extract the field identifiers of form fields from the preset document template, and construct a two-dimensional permission matrix that maps the field identifiers to the operation permissions of the process nodes in the management information system.
[0059] S202. Upon receiving a pending processing request for a target document instance, determine the current management information system process node of the target document instance, and extract the target operation permission set corresponding to the current management information system process node from the two-dimensional permission matrix.
[0060] S203. Based on the target operation permission set, the historical payload data of the target layout document instance is superimposed onto the preset layout document template to generate front-end rendering instructions, so as to control the front-end interactive interface to render the form fields defined as editable in the target operation permission set as allowed input, and render the form fields defined as read-only as locked.
[0061] S204. When receiving a form update request from the front-end interactive interface containing updated field data and field identifiers, the updated field data associated with the field identifiers that fall into the read-only state is stripped as unauthorized data, and the updated field data associated with the field identifiers that fall into the editable state is extracted as valid update data.
[0062] Step S201 is similar to step S101, step S202 is similar to step S102, step S203 is similar to step S103, and step S204 is similar to step S104, so they will not be repeated here.
[0063] S205. Obtain the physical boundary size of the target form field corresponding to the valid updated data in the preset layout document template.
[0064] Physical boundary dimensions refer to the width and height values of a fixed rectangular area reserved for a specific form field in the two-dimensional layout coordinate system of a preset document template. For example, the absolute display area of a multi-line text box defined on a PDF page is 200 pixels wide and 50 pixels high.
[0065] Specifically, because formatted documents have fixed layout characteristics and cannot be arbitrarily expanded or deformed like web pages, when processing legitimate update data, the server first needs to parse the underlying structure tree of the preset formatted document template to find the target form field component corresponding to the current legitimate update data. Next, the server reads the component's coordinate attributes (such as the top-left X / Y coordinates and bottom-right X / Y coordinates) or width and height attributes, calculates and extracts the strictly defined physical boundary dimensions of the target form field on the page, and uses this as a spatial reference condition for subsequently determining whether data overflows.
[0066] In some embodiments, the physical boundary dimensions of the target form field corresponding to the legitimate updated data in the preset layout document template can be obtained in several ways. Optionally, the server loads the PDF file stream of the preset layout document template, uses a PDF parsing library to read the AcroForm dictionary, iterates to find the Widget annotation dictionary corresponding to the field identifier, extracts its Rect array attribute, and calculates the width and height dimensions of the physical boundary. Optionally, the server queries the template metadata table pre-parsed and stored in the database, and directly retrieves the width and height values of the form field defined and fixed at design time based on the template ID and field identifier.
[0067] S206. Based on the preset typesetting rendering engine, calculate the actual rendering size required for valid updated data under the preset font specifications.
[0068] The preset typesetting rendering engine refers to a server-side integrated calculation module used to simulate text typesetting behavior in front-end or printers, such as a FreeType-based text measurement engine. Preset font specifications refer to the typesetting parameters specified for the target form field in a preset layout document template, such as font type, font size, line spacing, and character spacing, for example, SimSun, 12 points, single line spacing. Actual rendering size refers to the absolute two-dimensional space occupied by the valid updated data after virtual typesetting according to the preset font specifications.
[0069] Specifically, to predict whether the text entered by the user will exceed the form field, the server calls a preset typesetting and rendering engine, takes valid updated data (such as a long text) as input, and loads the preset font specifications bound to the target form field. The typesetting and rendering engine simulates the actual text drawing process in memory, taking into account typesetting rules such as automatic line wrapping and punctuation restrictions, and calculates the actual total width and height required if the text is fully displayed, i.e., the actual rendering size, providing data support for subsequent overflow detection.
[0070] In some embodiments, the actual rendering size required for legitimate update data under a preset font specification can be calculated in several ways. Optionally, the server calls Java's Graphics2D API to create a virtual graphics context in memory, sets the preset font specification, uses a FontMetrics object to measure the overall width of the legitimate update data string, and calculates the total height after line breaks by combining the physical boundary width. Optionally, the server can also call a headless browser instance via Node.js, create a hidden div element in the virtual DOM, apply CSS styles with the preset font specification, inject the legitimate update data into the div, and then obtain its scrollHeight and scrollWidth as the actual rendering size through the DOM API.
[0071] S207. If the actual rendering size exceeds the physical boundary size, the valid update data will be split into basic visible data and overflow payload data.
[0072] Basic visible data refers to the truncated data that can be fully displayed within the physical boundaries of the target form field without disrupting the original layout structure of the preset document template, such as the first 50 characters of a long text. Overflow payload data refers to the remaining data that cannot be directly displayed within the main form field due to space limitations, such as the portion from the 51st character to the end of a long text.
[0073] Specifically, the server compares the calculated actual rendered size with the physical boundary size obtained from S205. If the height or width of the actual rendered size is found to be larger than the physical boundary size, it indicates that the user has entered too much content, and direct rendering would cause the text to be obscured or break the page. In this case, the server will intelligently truncate the legitimate update data according to the physical boundary's capacity limit, splitting it into two parts: one part is the basic visible data that just fills the physical boundary, and the other part is the overflow load data that exceeds the boundary. This ensures that the page layout is aesthetically pleasing and fixed while preventing the loss of business data.
[0074] In some embodiments, legitimate update data can be split into basic visible data and overflow payload data in various ways. Optionally, the server uses a binary search algorithm combined with a typesetting rendering engine to gradually increase the length of the truncated string for virtual measurement until it finds the maximum character index position that just does not exceed the physical boundary size. The data before this index is classified as basic visible data, and the data after is classified as overflow payload data. Optionally, the server can also calculate the maximum number of characters that can be accommodated in a single line and the maximum number of lines allowed according to a preset font specification, multiply the two to obtain the maximum visible character capacity, and directly slice the legitimate update data according to this capacity to split it into basic visible data and overflow payload data. It is understood that other methods can also be used to split legitimate update data, which are not limited here.
[0075] S208. Write the basic visible data and the associated overflow anchor point identifier into the corresponding field position in the historical load data, and store the overflow load data in the extended load area independent of the main page to generate the latest load data.
[0076] Overflow anchor markers are special markers inserted at the end of basic visible data or at specific positions in form fields to indicate the existence of more content and provide an interactive entry point, such as "..." or "Click to view more" icons / text. Extended payload areas are independent storage spaces specifically allocated within the data structure that do not directly participate in the regular rendering of the main page; they are used to safely store all overflowing long text or attachment data.
[0077] Specifically, when constructing the latest payload data, the server no longer directly writes the complete, valid update data into the regular field positions. Instead, the server only writes the basic visible data into the original field positions corresponding to the historical payload data, followed by an overflow anchor identifier. Simultaneously, the server transfers the separated overflow payload data to a specially designated extended payload area within the data packet, establishing a mapping between the overflow anchor identifier and the corresponding data in the extended payload area. This separate storage method generates the latest payload data that maintains the fixed layout of the main page while fully preserving the user's extremely long input content.
[0078] In some embodiments, basic visible data and overflow payload data can be written in multiple ways to generate composite rendering instructions. Optionally, when parsing historical payload data, if the server detects that the data in the current form field contains overflow anchor markers, it generates composite front-end rendering instructions containing main layout rendering instructions and extended interaction instructions. The main layout rendering instructions control the front-end to render basic visible data and overflow anchor markers within the physical boundaries. The extended interaction instructions are used to call from the extended payload area and render the overflow payload data in the form of a floating pop-up when the front-end detects a click trigger operation for the overflow anchor marker, and restrict its rendering layer from changing the basic layout structure. Optionally, when the process node advances to the final archive node, the server extracts all overflow payload data in the extended payload area, appends a matching appendix layout page to the end of the preset layout document template, converts the overflow anchor markers into in-document links pointing to the appendix layout page, and merges the latest payload data, appendix layout page, and in-document links to generate an uneditable static archive layout document.
[0079] S209. Update the target format document instance based on the latest load data and advance the current management information system process node to the next management information system process node.
[0080] Step S209 is similar to step S105, and will not be described again here.
[0081] The above embodiments introduce a size comparison and data splitting mechanism based on the layout rendering engine. When legitimate update data exceeds the physical boundary of the target form field, it is split into basic visible data and overflow payload data, and the overflow anchor point is retained on the main page, with the overflow data stored separately. Combined with composite rendering commands and the appendix page appending mechanism during archiving, this solution provides a way to store and display long text data without disrupting the original layout structure of the preset document, balancing layout standards and data integrity.
[0082] The above describes a data interaction method based on a layout document in the embodiments of this application. The exemplary server 300 provided in the embodiments of this application is described below.
[0083] Figure 3This is a schematic diagram of an exemplary hardware structure of a server 300 provided in an embodiment of this application. In some embodiments, the server 300 is a computer device. The computer device includes a processor, memory, and a network interface connected via a system bus. The processor of the computer device provides computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The database of the computer device is used to store data. The network interface of the computer device is used to communicate with other external terminals or servers via a network connection. In some embodiments, the network interface can be a wired network interface; in some embodiments, the network interface can also be a wireless network interface. When the computer program is executed by the processor, it implements a data interaction method based on a layout document according to an embodiment of this application.
[0084] Those skilled in the art will understand that Figure 3 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.
[0085] In some embodiments of this application, a computer-readable storage medium is also provided, including instructions that, when executed on the server 300, cause the server 300 to perform a data interaction method based on a layout document according to an embodiment of this application.
[0086] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit it. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
[0087] As used in the above embodiments, depending on the context, the term "when..." can be interpreted as meaning "if...", "after...", "in response to determining...", or "in response to detecting...". Similarly, depending on the context, the phrase "when determining..." or "if (the stated condition or event) is interpreted as meaning "if determining...", "in response to determining...", "when (the stated condition or event) is detected", or "in response to detecting (the stated condition or event)".
[0088] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially as a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive), etc.
[0089] 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. This program can be stored in a computer-readable storage medium, and when executed, it can include the processes described in the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM or random access memory (RAM), magnetic disks, or optical disks.
Claims
1. A data interaction method based on layout documents, characterized in that, Applied to a server, the method includes: Extract field identifiers from form fields from a preset document template, and construct a two-dimensional permission matrix that maps the field identifiers to the operation permissions of process nodes in the management information system. The operation permissions include editable and read-only states. Upon receiving a pending processing request for a target format document instance, the current management information system process node of the target format document instance is determined, and the set of target operation permissions corresponding to the current management information system process node is extracted from the two-dimensional permission matrix. Based on the target operation permission set, the historical load data of the target layout document instance is superimposed on the preset layout document template to generate front-end rendering instructions, so as to control the front-end interactive interface to render the form fields defined as editable in the target operation permission set as allowed input, and render the form fields defined as read-only as locked. When a form update request containing updated field data and field identifiers is received from the front-end interactive interface, the updated field data associated with the field identifier that falls into the read-only state is stripped as unauthorized data, and the updated field data associated with the field identifier that falls into the editable state is extracted as legitimate update data. The legally updated data is merged into the corresponding field position in the historical load data to generate the latest load data. The target layout document instance is updated based on the latest load data, and the current management information system process node is advanced to the next management information system process node.
2. The method according to claim 1, characterized in that, The step of merging the legally updated data into the corresponding field positions in the historical payload data to generate the latest payload data specifically includes: Obtain the physical boundary size of the target form field in the preset layout document template that corresponds to the legal update data; Based on a preset typesetting and rendering engine, calculate the actual rendering size required for the legal update data under a preset font specification; If the actual rendering size exceeds the physical boundary size, the valid update data is split into basic visible data and overflow payload data; The basic visible data and associated overflow anchor point identifier are written into the corresponding field position in the historical load data, and the overflow load data is stored in the extended load area independent of the main layout to generate the latest load data.
3. The method according to claim 2, characterized in that, The step of overlaying the historical payload data of the target layout document instance onto the preset layout document template to generate front-end rendering instructions based on the target operation permission set specifically includes: When parsing the historical load data, if the data of the current form field is detected to contain the overflow anchor point identifier, a composite front-end rendering instruction containing the main layout rendering instruction and the extended interaction instruction is generated. The main layout rendering command is used to control the front-end interactive interface to render the basic visible data and the overflow anchor point identifier within the physical boundary of the current form field. The extended interaction instruction is used to call and render the overflow load data from the extended load area when the front-end interactive interface detects a trigger operation for the overflow anchor point identifier, and to restrict the rendering layer of the overflow load data from changing the basic layout structure of the preset layout document template.
4. The method according to claim 3, characterized in that, After the step of advancing the current management information system process node to the next management information system process node, the method further includes: If the next management information system process node is an archived final state node, then extract all overflow load data in the extended load area; An appendix formatted page matching the overflow load data is appended to the end of the preset document template; The overflow anchor point identifier is converted into an in-document link pointing to the appendix layout page, and the latest payload data, the appendix layout page, and the in-document link are merged to generate an uneditable static archive layout document.
5. The method according to claim 1, characterized in that, When receiving a form update request originating from the front-end interactive interface, which includes updated field data and field identifiers, the method further includes: Extract the front-end process node identifier from the front-end local cache carried in the form update request, and obtain the server-side process node identifier that the management information system is currently maintaining for the target format document instance. If the server-side process node identifier is found to be inconsistent with the front-end process node identifier, it is determined that the front-end state has a cache disconnection, the data extraction step of the form update request is interrupted, and a state overwrite instruction is generated based on the server-side process node identifier. The state overwrite instruction is returned to the front-end interactive interface to instruct the front-end interactive interface to discard the locally cached front-end process node identifier, and obtain the real target operation permission set based on the server-side process node identifier by re-initiating a loading request.
6. The method according to claim 1, characterized in that, After the step of extracting the set of target operation permissions corresponding to the current management information system process node from the two-dimensional permission matrix, the method further includes: Extract the linkage calculation rules defined between multiple form fields from the preset layout document template. The linkage calculation rules include a first form field as a calculation input item and a second form field as a calculation output item. For a target linkage calculation rule where the first form field falls into the editable state and the second form field falls into the read-only state, upon receiving the form update request, the derived data of the second form field is calculated and generated based on the valid update data of the first form field and the target linkage calculation rule. The derived data is synchronously updated to the field position in the historical payload data corresponding to the second form field.
7. The method according to claim 1, characterized in that, Before the step of stripping the updated field data associated with the field identifier that falls into the read-only state as unauthorized data when a form update request containing updated field data and field identifiers is received from the front-end interactive interface, the method further includes: Parse the idempotency flag and front-end document instance version number carried in the form update request; Verify whether the request idempotency flag exists in the server's processed request record database, and compare the front-end document instance version number with the current server-side document instance version number of the target format document instance; When the request idempotency identifier does not exist in the processed request record library, and the front-end document instance version number is consistent with the current server-side document instance version number, the step of extracting legitimate update data is allowed; If the idempotency flag of the request already exists in the processed request record library, or if the front-end document instance version number is inconsistent with the current server-side document instance version number, then the form update request is intercepted and an abnormal status message is returned. When performing the step of updating the target format document instance based on the latest payload data, the version number of the current server-side document instance is incremented simultaneously, and the request idempotency identifier is written into the processed request record database.
8. A server, characterized in that, The server includes: one or more processors and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code including computer instructions, and the one or more processors call the computer instructions to cause the server to perform the method as described in any one of claims 1-7.
9. A computer program product containing instructions, characterized in that, When the computer program product is run on the server, the server performs the method as described in any one of claims 1-7.
10. A computer-readable storage medium comprising instructions, characterized in that, When the instructions are executed on the server, the server causes the server to perform the method as described in any one of claims 1-7.