OA approval document intelligent typesetting and optimized printing method based on dynamic template engine

By using a dynamic template engine and intelligent optimization technology, the problems of fixed templates and rigid resource scheduling in traditional OA systems have been solved, enabling flexible and efficient printing of OA approval documents, adapting to the needs of multiple departments and scenarios, and improving the level of office automation for enterprises.

CN120911404AActive Publication Date: 2025-11-07QINGDAO CIVIL AVIATION KAIYA SYST INTEGRATION CO LTD
View PDF 13 Cites 0 Cited by

Patent Information

Application Number
CN202511438466.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-10
Publication Date
2025-11-07
Estimated Expiration
2045-10-10

AI Technical Summary

Technical Problem

Traditional OA systems use fixed templates for approval workflow printing, which are inflexible, have poor adaptability, and are difficult to support the differentiated needs of multiple departments and scenarios. They are also user-unfriendly, rely on manual scheduling for printing tasks, frequently experience resource conflicts, and have output formats that do not match business requirements, leading to repeated modifications and increased costs.

Method used

We adopt an intelligent layout and optimized printing method for OA approval documents based on a dynamic template engine. Through technical means such as template definition and storage, data binding, template generation and output, task acceptance and parsing, resource scheduling and monitoring, we can achieve personalized template design, intelligent optimization and efficient printing.

Benefits of technology

It enables flexible and efficient personalized printing output, adapts to diverse business needs, improves approval efficiency, reduces costs, enhances resource utilization and office automation, supports multiple printing devices, and adapts to rapidly changing business environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120911404A_ABST
    Figure CN120911404A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of office automation systems, and discloses an OA approval document intelligent typesetting and optimized printing method based on a dynamic template engine. The method comprises the steps of template definition and storage, data binding and replacement, template generation and output, template management and expansion, task acceptance and analysis, task scheduling and optimization, resource allocation and monitoring, and printing path and output optimization. And fault detection and recovery. According to the method, the efficiency and quality of the approval process can be improved, a larger customization space is provided for organizations, and the method adapts to a quickly changing business environment.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the technical field of office automation (OA) systems, and particularly relates to an OA approval document intelligent layout and optimized printing method based on a dynamic template engine. BACKGROUND

[0002] The approval flow printing method of the traditional OA system has the following limitations. Template fixation: most systems use preset templates, which cannot be flexibly adjusted in layout, fields or logic according to business needs (for example, the fixed template problem mentioned in invention patent CN20191000123A). Poor adaptability: difficult to support differentiated needs of multiple departments and multiple scenarios, such as dynamically embedding compliance clauses, risk assessment and other content in airport approval.

[0003] The existing technical defects are as follows: lack of user-friendly template design tools, non-technical personnel cannot operate independently. Printing task scheduling relies on manual priority setting, which is prone to resource conflicts. The output document format does not match the business needs, resulting in repeated modifications and increased costs.

[0004] Through the above analysis, the problems and defects of the prior art are: in the enterprise environment highly dependent on informationization and digitization management, the office automation (OA) system, as an important tool to improve work efficiency and simplify work flow, plays a key role. However, in actual application, the traditional OA approval flow printing method is often subject to some limitations and the problem of coexistence of high cost and low efficiency, especially the printing process of paper documents, which lacks an effective adaptation mechanism for complex approval logic and dynamic changes in demand. SUMMARY

[0005] In order to overcome the problems in the related art, the embodiments of the present application provide an OA approval document intelligent layout and optimized printing method based on a dynamic template engine, which particularly relates to a document layout method customized according to predefined strategies and rules, combined with dynamic data binding, intelligent optimization and resource scheduling technology, to realize personalized generation and efficient output of approval process documents.

[0006] The technical solution is as follows: the OA approval document intelligent layout and optimized printing method based on the dynamic template engine, the method comprising: S1, template definition and storage, the user defines multiple types of templates, including document templates and email templates, after the template definition is completed, the placeholders contained in the template are dynamically replaced with actual data when generating specific content; the defined template is stored in a location easy to access and manage, including a database or a file system; S2, data binding and replacement, the placeholders in the template are associated with the data source by using a data binding mechanism; the placeholders are automatically replaced with the corresponding actual data when the template is generated; S3, template generation and output, the user triggers the template generation process and specifies the required data source to generate the final document or email, and the user downloads, sends or saves the document or email; S4, template management and expansion, view, edit, delete and create new templates through the template management interface; new template types or placeholders are added as needed through the template expansion mechanism for dynamic expansion; S5, task acceptance and analysis, receiving a printing task, including document content, printing settings and printing requirements, analyzing the received task by extracting key information, including document page number and print quantity; S6, task scheduling and optimization, according to the priority, urgency of the printing task and the availability of the printing resources, the task scheduling is carried out, and the printing order is optimized; S7, resource allocation and monitoring, allocating printing resources to each task to make the task proceed, monitoring resource usage, including paper consumption, ink remaining, etc., and timely supplementing and regulating resources; S8, print path and output optimization; S9, fault detection and recovery.

[0007] In combination with all the technical solutions described above, the present application has the following beneficial effects: First, the present application aims to provide a more flexible, efficient and personalized platform to meet the diverse needs of enterprises, including: personalized template design: by introducing graphical interface design tools, users can customize the layout of process nodes, information input methods, etc. to meet the requirements of specific business processes. This design allows non-technical personnel to quickly build complex approval process templates. Intelligent template optimization: use AI algorithms and machine learning techniques to analyze historical approval data, automatically optimize template design, improve approval efficiency and predict potential problem points, thereby dynamically adjusting template structure and process logic. High-precision printing output: integrate advanced document generation engines and printing service interfaces to ensure accurate content and beautiful layout during the conversion process from electronic approval flow to paper documents. At the same time, it supports multiple printer device compatibility, adapting to different environmental needs.

[0008] Second, the present application solves the limitations of traditional OA systems through technical innovation and functional optimization, providing a flexible, efficient and personalized solution. This method not only improves the efficiency and quality of the approval process, but also provides more customization space for organizations, adapting to the rapidly changing business environment.

[0009] Third, the present application realizes the synergy and fusion across technical fields, and produces a synergistic gain effect beyond the simple superposition of a single technical field by organically combining the dynamic template engine technology, intelligent optimization algorithm and modern printing control technology; the technical solution of the present application provides significant and quantifiable technical progress, and has achieved a breakthrough improvement in key performance indicators (such as template processing efficiency, resource utilization, task completion time) compared with the prior art; significantly reduces the cost of paper document processing, reduces resource waste, improves the level of office automation, and provides effective technical support for promoting green office and organizational digital transformation. BRIEF DESCRIPTION OF DRAWINGS

[0010] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and serve to explain the principles of the present disclosure, together with the description; Figure 1 is a flow chart of the OA approval document intelligent layout and optimized printing method based on the dynamic template engine provided by the embodiment of the present application; Figure 2 is a schematic diagram of the placeholder automatic replacement process provided by the embodiment of the present application; Figure 3 is a schematic diagram of the template generation and output provided by the embodiment of the present application; Figure 4 is a schematic diagram of the template management interface provided by the embodiment of the present application; Figure 5 is a flow chart of the task analysis provided by the embodiment of the present application; Figure 6 is a schematic diagram of the three-layer scheduling model provided by the embodiment of the present application; Figure 7 is a schematic diagram of the printer state modeling provided by the embodiment of the present application; Figure 8 is a schematic diagram of the resource allocation provided by the embodiment of the present application; Figure 9 is a flow chart of the fault self-recovery provided by the embodiment of the present application; Figure 10 is a principle diagram of the OA approval document intelligent layout and optimized printing method based on the dynamic template engine provided by the embodiment of the present application. DETAILED DESCRIPTION

[0011] In order to make the above-mentioned purposes, features and advantages of the present application more obvious and easy to understand, the specific embodiments of the present application will be described in detail below. In the following description, a large number of specific details are set forth in order to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar improvements without departing from the scope of the present application, therefore the present application is not limited to the specific embodiments disclosed below.

[0012] The present application realizes the automatic generation and multi-format output of the approval document content by introducing the template engine supporting the dynamic binding and safe replacement of multi-source data; realizes the multi-objective optimization allocation of the printing task and resources by combining the intelligent scheduling algorithm based on reinforcement learning and multi-constraint graph matching; and builds the printing management system with the fault self-recovery and dynamic regulation and control capabilities by relying on the real-time resource monitoring and digital twin technology. The method significantly improves the automation degree, printing efficiency and resource utilization rate of the OA approval document processing, and solves the technical problems of poor template flexibility, rigid printing process and lack of intelligence in resource scheduling in the traditional system.

[0013] Embodiment 1, as shown in Figure 1 and Figure 10 The OA approval document intelligent layout and optimized printing method based on the dynamic template engine provided by the present application includes: S1, template definition and storage, the user defines multiple types of templates, including document templates, email templates, etc., after the template definition is completed, the placeholders contained in the template are dynamically replaced with actual data when generating specific content; the defined template is stored in a location that is easy to access and manage, such as a database or a file system.

[0014] Exemplarily, after the template definition is completed, the system realizes the dynamic replacement of the placeholder to the actual data by the following steps, specifically including: S1.1, placeholder resolution: the system scans the template file (e.g. XML / HTML) and matches the placeholder format by regular expression. The specific steps of matching the placeholder format by regular expression are as follows: (1) Pattern Compilation; (2) Text Scanning: use the compiled Pattern object to create a Matcher object for the template content (templateContent) to be parsed. The matcher will be responsible for searching for sub-sequences in the text that match the pattern. (3) Iterative Matching and Extraction: call the matcher.find() method to find the next matching sub-sequence in the template content. Each time a match is found: check the specific format of the match. By querying whether the capture group matcher.group(1) is null, it is determined whether the match is in the format ${variable_name}. If so, extract the value of the capture group as the key. If matcher.group(1) is null, it means that the match is in the format #{table_name.field_name}, and the value of the capture group matcher.group(2) is extracted as the key. Finally, the variable variableKey is assigned to the extracted placeholder identifier (e.g. approver_name or expense_form.amount), which is used for subsequent data binding and replacement operations. (4) Processing Complete: when the matcher.find() method can no longer find more matches, the loop ends and the placeholder resolution phase is complete. The system has successfully identified all placeholders in the template that meet the predetermined format and their specific content.

[0015] S1.2, data source binding; including: structured data source, associated database table field (e.g. expense_form.amount), query data through ORM framework (e.g. MyBatis). Dynamic variable: get runtime variable (e.g. approver_name) from the approval context (e.g. BpmContextUtil). The process of obtaining runtime variables from the approval context (e.g. BpmContextUtil) can be described as follows: the process aims to dynamically obtain variable values from the memory environment at the time of process execution (i.e. the approval context) for placeholder replacement in the template (e.g. ${approver_name}).

[0016] S1.3, Type-safe substitution, includes: formatting numeric placeholders (e.g. amounts, dates) (e.g. DecimalFormat("#,##0.00")). HTML escaping (XSS protection) or truncation (overflow protection) for text placeholders. (1) Numeric Formatting: Purpose: Ensure that numeric values such as amounts, quantities, percentages are displayed in a form that is consistent with regional conventions, easy to read, and professionally standardized.

[0017] S1.4, Dynamic rendering; includes: recursively processing nested placeholders using template engines (e.g. Freemarker, Thymeleaf).

[0018] S1.5, Result verification, checking un-substituted placeholders (e.g. Logger.warn("Un-substituted placeholder: " + variableKey)). Performing syntax checks (e.g. XML tag closure checks) before generating the final document.

[0019] The process of performing syntax checks before generating the final document is a critical step in the system after all data binding and dynamic rendering is completed. This process aims to ensure that the output document is correctly formatted and structurally complete, avoiding the generation of invalid documents due to template logic errors or data issues. The specific process is as follows: (1) Content extraction and caching: The system caches the complete content (usually in string form) obtained after dynamic rendering into a temporary buffer as the input source for syntax checking.

[0020] (2) Document type identification and parser selection: The system identifies the document type based on the pre-set output format (e.g. XML, HTML) or automatically analyzes the beginning of the content, and selects the corresponding syntax parser (e.g. XML parser, HTML parser) accordingly.

[0021] (3) Structured syntax checking: Call the selected parser to strictly parse and check the cached content. Core checks include: Tag closure check: Ensure that all start tags have corresponding end tags and the nesting order is correct. For example, check that in XML, every <tag>all have corresponding< / tag> , and there is no cross-nested (e.g. ). Attribute legality check: Check if the attributes of the tags are in line with the specification (e.g. whether the attribute name is legal, and the value is correctly enclosed in quotes). Special character escaping verification: Confirm that all reserved characters (e.g. XML's <, >, &) have been correctly escaped (e.g. <, >, &), to prevent parsing ambiguity. Document structure integrity check: Verify that the document has the necessary root element and conforms to the structure defined by the type definition (e.g. DTD, Schema).

[0022] (4) Error handling and logging: If the parser passes the check successfully without throwing any exception, it means the document syntax is correct, and the process continues. If the parser throws an exception (e.g. SAXParseException), the exception is caught, the error details (e.g. error type, line number, column number, and specific content fragment) are recorded, and the log (e.g. Logger.error) is output, and the generation process may be aborted or an alert is triggered.

[0023] (5) Check pass and document output: Only after passing all syntax checks, the system will cache the intermediate content as the final valid document, and perform subsequent output operations (e.g. download, send or save). Otherwise, it will return an error message or fall back to a safe version according to the strategy.

[0024] (2) ORM Object-Relational Mapping: The specific association method of associating placeholders in templates with data sources (e.g. database records, user input, etc.) using data binding mechanisms; including direct key-value binding using Map to store variable name and value correspondence, ORM field binding by associating database entity fields through JPA / Hibernate annotations, dynamic context binding by obtaining variables from runtime environment (e.g. approval context, Session), API data binding by calling external API to obtain data (URL and parameter mapping need to be configured); see Table 1 for details.

[0025] Table 1 Data Binding Table

[0026] Among them, the placeholders in the template are associated with the data source (such as database records, user input, etc.) using the data binding mechanism, and the present application further innovates: Lazy loading, lazy loading for large data fields (such as attachment content), and only requesting data when replacing; Cascading binding, supporting nested object access (e.g. #{expense.creator.department}); Type converter, automatically handling data type differences (e.g. database BigDecimal -> template string); For example, the automatic placeholder replacement process is shown in Figure 2 ; Specifically including: Step 1, placeholder positioning: using regular expressions to identify placeholders; Step 2, data source analysis: selecting data source type according to placeholder prefix; (1) Prefix recognition and classification: The system pre-defines a set of placeholder syntax rules, where different prefixes correspond to different data source types. The mapping relationship is shown in Table 2: Table 2 Mapping relationship table

[0027] (2) Routing and data acquisition: According to the recognized prefix, the system executes the corresponding data acquisition strategy: For ${variable}: Action: Determine that data needs to be obtained from the runtime context (Context). Operation: Extract the string between the prefix and the suffix as the key (e.g. the key of ${approver_name} is "approver_name"), and then use context_vars.get(key) or similar methods to find the corresponding value from the in-memory context variable mapping table.

[0028] For #{entity.field}: Action: Determine that data needs to be obtained from the database (through ORM). Operation: Extract the string between the prefix and the suffix and parse it according to its rules (e.g. split by the dot.). First, determine the entity or table to be queried according to the first part entity (e.g. "expense"), and then determine the specific attribute to be obtained according to the subsequent part field (e.g. "amount") or field.subfield (e.g. "creator.department"). Finally, construct and execute the query through the ORM framework (e.g. orm_query(entity)) to obtain the target value.

[0029] For other prefixes (such as the hypothetical @{api.endpoint}): Action: Determine that an external API service needs to be called. Operation: Extract the identifier, parse it into a specific URL and parameters according to the pre-configured API mapping rules, initiate a network request and parse the response, and extract the required data.

[0030] (3) Exception handling: If the data does not exist in the data source selected according to the prefix, the system will handle it according to the pre-set strategy, such as recording warnings, using default values or throwing exceptions to interrupt the process.

[0031] Step 3, safe replacement: output safe data source through defensive processing; The defensive processing process mainly includes the following core operations: (1) Input cleaning and standardization: First, raw data (rawValue, which can be of types such as String, Number, Date, etc.) from different data sources is uniformly converted into a string format (rawValue.toString()) to provide a unified input for subsequent processing.

[0032] (2) Safe escaping: This is the core step to prevent code injection attacks (such as XSS). The system will escape special characters in the string according to the output context. For HTML output context: use HtmlUtils.htmlEscape() and other utility classes to convert characters with special HTML meaning (such as <, >, &, ", ') in the string into corresponding HTML entities (such as <, >, &, ", '). This ensures that even if there are malicious script tags (such as <script>alert('xss')< / script> ) in user input or the database, they will be displayed as normal text and will not be executed.

[0033] (3) Type-aware formatting: After escaping, the system further judges the nature of the data type and applies corresponding formatting rules to improve the professionalism and readability of the output.

[0034] Numerical recognition and formatting: Use NumberUtils.isNumber() and other methods to determine if the escaped string represents a valid number. If so, call the corresponding formatting function (such as formatDecimal) to add thousand separators, uniform decimal places, etc. (for example, format 5000.5 to 5,000.50) according to the locale or business rules.

[0035] Non-numerical processing: If the content is not a number, use the safely escaped string directly.

[0036] (4) Final replacement: Replace the safe string (escapedValue or formatted number string) obtained after the above "defensive processing" to the original placeholder position in the template.

[0037] Step 4, loop / condition processing: Process complex structures recursively; The specific implementation steps are as follows: (1) Initial call and data model transmission: When the user triggers template generation, the system passes a "data model" (dataModel) containing all the data to be replaced to the template engine. This data model can be a simple key-value pair Map, or a nested structure containing complex objects and lists.

[0038] (2) Template scanning and directive recognition: The template engine starts scanning the template content. When it encounters a control directive (such as Freemarker's <#list...> or <#if...>), it knows that the next thing to process is a complex structure, not a simple placeholder.

[0039] (3) Entering the recursive processing branch: For a loop directive (such as <#list expenses as item>): The engine first gets the variable named expenses from the dataModel. It expects this to be a collection (such as List or Array). The engine starts iterating over each element in the collection. For the current element (named item in the directive), the engine creates a new, local context in which the item variable points to the current element being processed. The engine recursively processes all the template content between the <#list> and < / #list> tags in this local context. This means that, in this local context, the engine performs the complete "scan-recognize-replace" flow again. In this local flow, if it encounters ${item.date}, the engine looks up the item object in the local context and extracts the date property from it. If the item object itself contains a deeper nested object (for example, ${item.department.name}), the engine continues to recurse deeper until it gets the final name string value. After processing all the content for the current item, the engine moves to the next element in the collection and repeats the above steps until it has iterated over all elements. For a conditional directive (such as <#if amount>1000>): The engine first evaluates the conditional expression (amount>1000). If the condition is true, the engine recursively processes the template content between the <#if> and < / #if> tags. Again, in processing this content, the engine performs the complete "scan-recognize-replace" flow again, which can handle any placeholders or nested control directives contained within.

[0040] (4) Primitive data type processing: When the recursion has gone as deep as it can, and the engine encounters a primitive data type (such as item.date or item.amount), it stops the recursion and performs the standard "placeholder replacement" flow, including type-safe formatting (such as formatting a date as 'yyyy-MM-dd') and safe escaping.

[0041] (5) Result merging and return: The engine merges all the pieces generated by the recursive processing (such as the content of each row in a list) in the order they were generated, resulting in the complete, data-populated document.

[0042] For example, in the placeholder automatic replacement process, the placeholder is automatically replaced for the exception type through an exception handling mechanism, which includes: for the placeholder unbound exception type, a warning is recorded and the original placeholder is retained (or replaced with an empty string); for the data type mismatch exception type, type conversion is forced by calling a type converter; for the data source unavailable exception type, cached data or a default value (configured default: "N / A") is enabled; through the above technical features, the effects of the present application are shown in Table 3.

[0043] Table 3 Effect Comparison Table

[0044] S3, template generation and output: the user triggers the template generation process and specifies the required data source to generate the final document or email, and the user downloads, sends or saves the document or email. The template generation and output are as shown in Figure 3 . Specifically, it includes: Step S3.1, user triggers REST API request and parameter passing; The user selects the template type (document / email), data source (such as approval sheet ID process_instance_id=123), and output format (PDF / DOCX / plain text, etc.) through the front-end interface; Step S3.2 Template engine processing: dynamically select the template engine according to the file type, select the Apache Freemarker engine for document templates, and select the Thymeleaf engine for email templates; see Table 4.

[0045] Table 4 Thymeleaf Engine Table

[0046] For example, the embodiment (Freemarker generates HTML): Step S3.3 Format conversion and rendering, including document generation and email generation; document generation includes: using open source libraries to convert HTML to PDF / DOCX; email generation includes: building a MIME email (supporting HTML body and attachments).

[0047] Step S3.4 Output control, including download file, email sending, and cloud storage saving mode for multi-channel output; see Table 5 for multi-channel output.

[0048] Table 5 Multi-channel Output Table

[0049] Exemplary, the key technical innovation points in step S3.3 format conversion and rendering include: In document generation, the same template can generate different format outputs (such as HTML→PDF or DOCX) through dynamic format adaptation, and the renderer is automatically selected by OutputFormatResolver: the detailed steps are as follows: (1) Receive user output format request: when the user triggers a document generation request through the front-end interface or API, the desired output format will be specified. For example, in a REST API request, the parameters outputFormat: "pdf" or outputFormat: "docx" will be passed to the backend service. This step is the starting point of the entire dynamic adaptation process.

[0050] (2) Call format resolver (OutputFormatResolver): after the system receives the outputFormat parameter, it will call a factory method named resolveRenderer. This method is the core hub of the "dynamic format adaptation" function of the invention. Processing logic: the method uses a switch statement inside to match the format string passed in. If the format is "pdf", an instance of the PdfRenderer class is created and returned. If the format is "docx", an instance of the DocxRenderer class is created and returned. If the format is not supported (such as "txt"), an UnsupportedFormatException exception is thrown to notify the user or upstream system. Output: return a specific renderer object that implements the DocumentRenderer interface. This interface defines common methods such as render(htmlContent, outputStream) to ensure the consistency of different renderers.

[0051] (3) Perform format conversion: After the system obtains a specific renderer object (such as PdfRenderer), it will call its render method, taking the HTML intermediate document generated by the template engine and containing all dynamic data as input, and perform format conversion. The work of PdfRenderer: It will use libraries such as Apache PDFBox or iText to parse the structure and style of HTML and accurately convert it to PDF format. It will handle pagination, font embedding, image rendering, etc., to ensure that the layout of the PDF document is consistent with the HTML preview. The work of DocxRenderer: It will use libraries such as Apache POI or docx4j to map HTML content to elements such as paragraphs, tables, and styles in Word documents, generating an editable.docx file.

[0052] (4) Output the final document: The renderer writes the converted binary data stream (PDF or DOCX) to the specified output stream (OutputStream). This output stream can be connected to: HTTP response, for user browser download. File system, for local saving. Cloud storage service (such as Aliyun OSS), for archiving. Email service, as an attachment. Exemplary, in the process of generating an email, including mail-document linkage: when the document is attached to the email, it is automatically compressed and encrypted (ZIP+AES256), protecting sensitive data.

[0053] Exemplary, in step S3.4 output control, version control is performed, and each generation records the template version + data snapshot, supporting traceability (database table design example), see Table 6; Table 6 Database design table

[0054] Step 1: Calculate the template version fingerprint (template_version); Purpose: uniquely identify the template used to generate the document, ensuring that the template has not been tampered with. Process: The system obtains the complete source code of the template currently used for rendering (for example, the Freemarker or Thymeleaf template string stored in the database). Perform MD5 hash operation on the template source code. MD5 is a widely used cryptographic hash function that can map data of any length to a 32-bit hexadecimal string. Take the calculated MD5 value (such as a3f5e2c8b1d7...) as the value of the template_version field.

[0055] Innovation: Instead of using a simple version number (e.g., v1.0) to identify the template, the hash value is used. This allows for precise detection of even the slightest changes in the template. Even if only a single punctuation mark is modified, the MD5 value will be completely different, eliminating the risk of having the same version number but different content.

[0056] Step 2: Capture and serialize data snapshot (data_snapshot); Purpose: To record all dynamic data relied upon when generating the document, ensuring that the document can be reproduced with the same data at any time. Process: Before the template engine performs data binding and replacement, the system performs a deep copy of the entire data model (dataModel) currently used for rendering. This data model is a complex object containing values corresponding to all placeholders, possibly including database query results, runtime variables, API return data, etc. This deep-copied data object is converted into a structured JSON string using JSON serialization technology. This JSON string is stored in the database as the value of the data_snapshot field. Innovation: Traditional logs may only record key fields, while the invention records complete and structured data snapshots. This allows not only to know "who is the approver", but also to know the specific content of each item in the list at that time, achieving "time freezing" at the data level.

[0057] Step 3: Calculate output file checksum (output_hash); Purpose: Create a unique "digital fingerprint" for the final generated file (such as PDF, DOCX), to verify the integrity and authenticity of the file, and prevent the file from being tampered with during storage or transmission. Process: Before the file is generated and ready for output (download, send or save), the system reads the entire binary content of the file. Perform SHA-256 hash operation on the binary content. SHA-256 is a more secure encryption hash function than MD5, producing a 64-bit hexadecimal string. The calculated SHA-256 value (e.g., f4b3a1c2d5e6...) is used as the value of the output_hash field. Innovation: SHA-256 is used instead of MD5 because SHA-256 has stronger collision resistance and is more suitable for scenarios that require high security. By checking output_hash, you can ensure that the file downloaded by the user is exactly the same as the original file generated by the system.

[0058] Step 4: Persistent storage; purpose: store the above three key information together with the metadata of the generated task (such as generation time, operator, task ID, etc.) into the database. Process: the system constructs a new database record containing the following core fields: id: automatically generated unique primary key. template_version: template MD5 value calculated in step 1. data_snapshot: JSON data snapshot generated in step 2. output_hash: file SHA-256 value calculated in step 3. generated_at: current timestamp. generated_by: ID or username of the current operator. task_id: associated print or generation task ID. Insert this record into a special "document version control table" (such as document_version_audit).

[0059] S4, Template management and extension, view, edit, delete and create new templates through the template management interface; add new template types or placeholders as needed through the template extension mechanism for dynamic extension.

[0060] For example, the template management interface is shown in Figure 4 View, edit, delete and create new templates through the template management interface include: First, template full life cycle management; see Table 7; Table 7 Template full life cycle management table

[0061] Second, template syntax checking (real-time); for example, dynamic extension through the template extension mechanism according to the needs of new template types or placeholders includes extension type and implementation; specifically including: for new template types, dynamically extend the template renderer through the plug-in architecture (SPI mechanism) to dynamically extend the template renderer, for custom placeholders, define extension interfaces by registering placeholder parsers to dynamically extend, in addition, for style extension, dynamically inject style rules using the CSS-in-JS scheme to dynamically extend; see Table 8; Table 8 Dynamic extension table

[0062] S5, Task acceptance and analysis, receive print tasks, including document content, print settings (such as paper size, print quality, etc.) and print requirements (such as double-sided printing, binding, etc.), parse the received task by extracting key information such as document page number, print copies, etc. Among them, the task analysis adopts a multi-stage analysis process, as shown in Figure 5 For example, the multi-stage analysis core algorithm improvement points are shown in Table 9; Table 9 Core Algorithm Improvement Table

[0063] S6, task scheduling and optimization, according to the priority of the printing task, the urgency and the availability of printing resources (such as printers, paper, ink, etc.), task scheduling is performed, and the printing order is optimized to reduce waiting time and resource waste. For example, the task scheduling adopts a three-layer scheduling model, as shown in Figure 6-9 ; wherein the three-layer scheduling model and the prior art are compared in Table 10; Table 10 Comparison of Three-Layer Scheduling Model and Prior Art

[0064] For example, the task scheduling specifically includes: step I. Dynamic priority calculation; fuzzy logic + entropy weight method is used to calculate the comprehensive priority. The specific implementation steps are as follows: (1) Index selection and data collection: purpose: determine the key dimensions that affect the priority of the task. Process: the system extracts three core indicators from the "key information matrix" (from S5.4): task.deadline (deadline): represents the urgency of the task (Urgency). The closer the deadline, the higher the urgency. task.user_rank (user rank): represents the importance of the task (Importance). For example, the task submitted by the CEO is more important than the task of ordinary employees. task.paper_usage (paper consumption): represents the resource cost of the task (Resource Cost). The more resources consumed, the higher the cost, and the priority should be relatively reduced.

[0065] (2) Data Normalization: Purpose: To convert original data of different dimensions and value ranges to a unified scale (usually [0, 1] interval) for fair comparison and weighted calculation. Process: Normalize deadline and user_rank in a positive way (the larger the value, the higher the priority). For example, urgency = normalize(task.deadline) could be (max_deadline - task.deadline) / (max_deadline - min_deadline). Normalize paper_usage in a reverse way, because resource consumption is a cost, and the higher the cost, the lower the priority should be. resource_cost = 1 - normalize(task.paper_usage). Here normalize(task.paper_usage) maps paper consumption to [0, 1], the more consumption, the larger the value; 1 -... then reverses it, the more consumption, the smaller resource_cost.

[0066] (3) Entropy Weighting: Purpose: To solve the problem of how to assign weights to urgency, importance, and resource cost. Entropy weighting is an objective weighting method that determines weights based on the dispersion of each index data (information entropy). The greater the data fluctuation (the smaller the entropy), the more information the index provides, and the greater its weight in the comprehensive evaluation. Process: The system collects the normalized index values of all tasks to be scheduled, forming an index matrix. Calculate the entropy value of each index. The smaller the entropy value, the greater the difference between the index in different tasks, and the higher its contribution to task sorting. Calculate the weight of each index according to the entropy value. The formula is roughly: weight = (1 - entropy) / Σ(1 - each index entropy). Output: Get a weight vector weights = [w1, w2, w3], for example [0.5, 0.3, 0.2], indicating that urgency accounts for 50%, importance accounts for 30%, and resource cost accounts for 20%.

[0067] (4) Fuzzy Inference: Purpose: To input the normalized index values and objective weights into a "fuzzy inference system" to simulate the decision-making process of human experts, handle fuzzy concepts such as "high", "medium", "low", and output the final priority. Process: Define fuzzy sets: Define fuzzy linguistic variables for each input index and output priority. Input: urgency can be {low, medium, high}; importance can be {low, medium, high}; resource_cost can be {low, medium, high}. Output: priority can be {defer, normal, high, critical}. Establish fuzzy rule base: This is the embodiment of human expert knowledge. For example: IF urgency IS high THEN priority IS critical (if very urgent, then priority is "critical") IF importance IS low AND resource_cost IS high THEN priority IS defer (if not important and very resource-consuming, then priority is "defer") IF urgency IS medium AND importance IS high THEN priority IS high, Fuzzy inference and defuzzification: (1) Map the normalized input values (e.g. urgency = 0.8) to the corresponding fuzzy sets (e.g. the membership degree of "high" is 0.9, and the membership degree of "medium" is 0.1). (2) According to the fuzzy rule base, calculate the activation strength of each rule. (3) Aggregate the outputs of all activated rules. (4) Use defuzzification methods such as "center of gravity method" to convert the fuzzy output set into an accurate priority score (e.g. 0.92). Weighted fusion: In the inference process, combine the weights calculated by the entropy weight method to adjust the influence of different indexes. (5) Output the final priority: Purpose: Generate a floating point number between 0.0 and 1.0 as the final comprehensive priority of the task. Process: The fuzzy inference system outputs an accurate value, for example 0.92. This value will be passed to "Step II. Resource-aware scheduling algorithm" as an important input parameter for its task-resource matching optimization. Step II. Resource-aware scheduling algorithm; Specific implementation steps (based on improved genetic algorithm GA): (1) Problem Modeling and Chromosome Encoding: Objective: To convert the scheduling problem into a "chromosome" form that can be handled by genetic algorithms. Process: Define "genes": Each "gene" represents a task-printer assignment pair. For example, Gene(taskId=5, printerId=2, startTime=100) means assigning task 5 to printer 2 and starting printing at time point 100. Define "chromosome": A "chromosome" represents a complete scheduling plan, i.e., the assignment set of all tasks to be scheduled. For example, Chromosome = [Gene1, Gene2,..., GeneN]. Encoding method: Use integer encoding, with printerId and startTime represented by integers.

[0068] (2) Initialize Population: Objective: To generate a set of random, diverse initial scheduling plans. Process: Randomly generate N chromosomes (e.g., N=100), each containing a random assignment plan for all tasks, forming the initial population.

[0069] (3) Define Fitness Function: Objective: To evaluate the "goodness" of a scheduling plan. This is the core guide for algorithm optimization. Process: The fitness function is a multi-objective function aimed at maximizing the weighted sum of the following indicators: High-priority task completion: High-priority tasks should be assigned and completed first. Resource utilization: Printers, paper, ink, etc. resources should be used efficiently, avoiding idling. User satisfaction: The actual completion time of tasks should be as close as possible or better than their expected time. Load balancing: Avoid overloading some printers while others are idle. Formula example: Fitness = α * (Σ(task priority * task completion status)) + β * (resource utilization) + γ * (1 / average waiting time) + δ * (load balancing) Where α, β, γ, δ are weight coefficients adjusted according to business needs.

[0070] (4) Selection: Objective: From the current population, select individuals with high fitness (good scheduling plans) as "parents" for breeding the next generation. Process: Use "roulette wheel selection" or "tournament selection" methods, etc. The higher the fitness of an individual, the higher the probability of being selected.

[0071] (5) Crossover: Objective: Through "crossbreeding", combine the excellent genes of two parent individuals to produce new, possibly better offspring individuals. Process: Randomly select two parent chromosomes, randomly select a crossover point, exchange gene fragments after the crossover point to generate two new offspring chromosomes.

[0072] (6) Mutation: Purpose: Introduce random changes to increase population diversity and avoid local optimum. Process: Basic mutation: With a certain probability, randomly change the printerld or startTime of a gene. Improvement point - Introduce simulated annealing: In order to jump out of local optimum more effectively, the invention introduces the idea of simulated annealing. The probability or strength of mutation will be dynamically adjusted ( "cooling" ) with the increase of the number of iterations of the algorithm. In the early stage, allow a larger range of mutation (high temperature, explore the global) ; in the later stage, the mutation range gradually narrows (low temperature, fine search for local optimum). Code sketch: if random ( ) < exp ( -1 / temp ) : swap_random_genes ( chromosome ) (7) Elitism and iteration: Purpose: Ensure that the best individual in each generation is not lost, and gradually approach the global optimal solution. Process: The individual with the highest fitness in each generation is directly reserved to the next generation. Then, fill the remaining positions with new individuals generated by selection, crossover, and mutation to form a new generation population. Repeat this process until the preset number of iterations or the fitness converges.

[0073] (8) Output the optimal scheduling scheme: Purpose: Decode the final optimal chromosome found into specific task allocation instructions. Process: After the algorithm ends, select the chromosome with the highest fitness, parse the Gene array it contains to get the final scheduling scheme of which task should be allocated to which printer and when to start printing. This scheme will be passed to the "step S7 Resource allocation and monitoring" module for execution. Improved genetic algorithm (GA) implementation steps: Chromosome encoding: Each gene represents a task-printer allocation scheme; performance optimization effects are shown in Table 11; Table 11 Performance optimization effect table

[0074] S7, Resource allocation and monitoring, allocate printing resources to each task, make the task proceed, monitor resource usage such as paper consumption, ink remaining, etc., and perform timely resource replenishment and control.

[0075] For example, resource allocation adopts a dynamic allocation architecture, as shown in Figure 8 ; specifically including: resource allocation adopts a multi-constraint graph matching algorithm; Step 1: Constructing the Weighted Bipartite Graph Purpose: Abstract the "tasks" and "printers" in the physical world and their mutual relationships into a mathematical graph model.

[0076] Step 2: Defining the Matching ObjectivePurpose: To clarify what problem the algorithm is trying to solve. Process: Find a matching (Matching) M. Matching M is a subset of the edge set that must satisfy a hard constraint: in matching M, any vertex (whether it's a task or a printer) can appear in at most one edge. This guarantees a "one-to-one" assignment: a task won't be assigned to multiple printers, and a printer won't handle multiple tasks simultaneously. Among all possible matchings that satisfy the "one-to-one" constraint, find the one with the maximum total weight. That is: Maximize: Σ_{(i,j) ∈ M} Score_{ij}In layman's terms: Under the premise of fairness (one task per printer), maximize the total "satisfaction" of all pairs.

[0077] Step 3: Applying the Matching AlgorithmPurpose: Use an efficient mathematical algorithm to solve the "maximum weight matching" problem defined above. Process: (1) Choose an algorithm: The system calls the max_weight_matching function in a graph computation library (such as Python's NetworkX). This function usually implements the Kuhn-Munkres algorithm (Hungarian algorithm) or its optimized versions for sparse graphs or large-scale graphs internally. (2) Execute the algorithm: The algorithm receives the weighted bipartite graph G constructed in the previous step as input. The algorithm iteratively calculates through a series of complex mathematical operations (such as vertex labeling adjustment, finding augmenting paths). Finally, the algorithm outputs an optimal matching result M. This result is a dictionary or set containing all the selected edges. For example: {('task_0', 'printer_2'), ('task_1','printer_0'), ('task_2', 'printer_1')}.

[0078] Step 4: Executing the AllocationPurpose: Convert the mathematical results calculated by the algorithm into actual system operations.

[0079] Process: (1) The system parses the result of optimal_matching. (2) For each edge (task_i, printer_j) in the matching result: the system officially assigns task task_i to printer printer_j. The system updates the resource status of printer printer_j (e.g., subtracts the demand of task task_i from its A4 paper inventory). The system updates the status of task task_i to "assigned" and records the ID of its assigned printer. (3) Unmatched tasks (if any, usually due to temporary lack of printer resources) will be put into a waiting queue, waiting for the next round of assignment.

[0080] For example, monitoring resource usage includes: a) Multimodal sensor data collection, see Table 12; Table 12 Multimodal sensor data collection table

[0081] b) Time series anomaly detection; use LSTM-Autoencoder to detect abnormal consumption: Step 1: Data collection and preprocessing Purpose: Prepare high-quality time series data for model training and inference. Process: (1) Multimodal data collection: The system collects consumption data for multiple resources in real time through sensors (such as photoelectric sensors, ink counting chips) deployed on the printer or from the printer driver / API. According to the code input_shape=(60, 4), the system will collect 4 key parameters, such as: param_1: A4 paper consumption per minute. param_2: Cyan ink consumption per minute (milliliters). param_3: Magenta ink consumption per minute (milliliters). param_4: Pages printed per minute (as a contextual reference).

[0082] (2) Build a time window: The system slices the continuously collected data into fixed time windows. The code 60 means that each window contains 60 minutes of historical data. For example, the system will generate a data matrix with shape (60, 4), where 60 rows represent 60 time steps (minutes), and 4 columns represent 4 parameters.

[0083] (3) Data normalization: Since different parameters have different dimensions and value ranges (such as paper count is an integer and ink volume is a decimal), the system will perform normalization (such as Min-Max Scaling or Z-Score standardization) on the data to scale all values to the [0, 1] or [-1, 1] interval, accelerating model convergence and improving accuracy.

[0084] Step 2: Building and training LSTM-Autoencoder model; Purpose: Train a neural network that can "remember" normal consumption patterns.

[0085] Step 3: Real-time monitoring and anomaly detection; Purpose: In the production environment, use the trained model to detect anomalies in real time.

[0086] Step 4: Model update and iteration; Purpose: Ensure that the model can adapt to the normal mode drift caused by equipment aging, business changes, etc. Process: (1) The system will periodically (such as every week) or after confirming that a certain "abnormality" is actually a new "normal" mode, add this part of new data to the training set.

[0087] (2) Fine-tune or retrain the model using the updated training set, so that the model can continue to learn and adapt to the latest normal state.

[0088] S8, print path and output optimization, according to the characteristics and requirements of the printing equipment, optimize the print path to reduce the printing time and improve the printing quality, format the output, such as adjusting the font size, color, alignment, etc. to meet the printing requirements.

[0089] S9, fault detection and recovery, in the printing process, real-time monitoring of equipment status, such as paper jam, ink shortage, etc. Once the fault is found, take recovery measures immediately, such as clearing paper jam, replacing ink, etc. to ensure that the printing task can be completed smoothly.

[0090] The above is only the preferred embodiment of the present application, but the protection scope of the present application is not limited to this, any skilled person in the art within the technical scope disclosed by the present application, any modification, equivalent replacement and improvement within the spirit and principle of the present application should be covered within the protection scope of the present application.

Claims

1. An OA approval document intelligent layout and optimized printing method based on a dynamic template engine, characterized in that The method realizes intelligent layout and efficient printing of the approval document through a dynamic template engine, and specifically includes the following steps: S1, template definition and storage, defining multiple types of templates, including document templates and email templates; after the template definition is completed, the placeholders contained in the template are dynamically replaced with actual data when generating specific content; store the defined template in a location that is easy to access and manage, including a database or a file system; S2, data binding and replacement, use the data binding mechanism to associate the placeholders in the template with the data source; when generating the template, the placeholders are automatically replaced with the corresponding actual data; S3, template generation and output, generate the final document or email by triggering the template generation process and specifying the required data source, and download, send or save the document or email; S4, template management and extension, view, edit, delete and create new templates through the template management interface; through the template extension mechanism, add new template types or placeholders for dynamic extension as needed; S5, task acceptance and analysis, receive a printing task, including document content, printing settings and printing requirements, analyze the received task by extracting key information, including document page number and print quantity; S6, task scheduling and optimization, according to the priority, urgency and availability of the printing resources, the task scheduling is performed, and the printing order is optimized; S7, resource allocation and monitoring, allocate printing resources to each task to make the task proceed, monitor resource usage, including paper consumption and ink remaining, and perform resource replenishment and control in time; S8, print path and output optimization; S9, fault detection and recovery.

2. The OA approval document intelligent layout and optimized printing method based on a dynamic template engine according to claim 1, characterized in that, In step S1, after the template definition is completed, the dynamic replacement of the placeholder to the actual data is realized through the following steps: S1.1, placeholder analysis: the system scans the template file and matches the placeholder format through a regular expression; S1.2, data source binding: structured data source, associated database table field, query data through ORM framework; For dynamic variables, get runtime variables from the approval context; S1.3, type-safe replacement, format numerical placeholders; perform HTML escaping or truncation processing on text placeholders; S1.4, dynamic rendering; use the template engine to recursively process nested placeholders; S1.5, result verification, check the un-replaced placeholders, and perform syntax checking before generating the final document.

3. The method according to claim 1, wherein the method is characterized in that, In step S2, the data binding mechanism realizes the dynamic connection between the template and the data source through a data binding architecture with a three-layer association model, including: Template layer, define placeholder syntax rules; Mapping layer, establish the association relationship between the placeholder and the data source, including key-value pair mapping and ORM object relationship mapping; Data source layer, provide structured data; The specific association manner of associating the placeholders in the template with the data source by using the data binding mechanism; including using Map to store the corresponding relationship between variable name and value for direct key-value binding, associating database entity fields through JPA / Hibernate annotation for ORM field binding, obtaining variables from the runtime environment for dynamic context binding, and obtaining data through API for API data binding; wherein the association of the placeholders in the template with the data source by using the data binding mechanism further comprises: Lazy loading, using lazy loading for large data fields, and requesting data only when replacing; Cascading binding, supporting nested object access; Type converter, automatically handling data type differences.

4. The OA approval document intelligent layout and optimized printing method based on a dynamic template engine of claim 1, characterized in that, In step S2, the placeholder automatic replacement includes: S2.1, placeholder positioning: using regular expressions to identify placeholders; S2.2, data source analysis: selecting a data source type according to the placeholder prefix; S2.3, safe replacement: outputting a safe data source through defensive processing; S2.4, loop / condition processing: recursively processing complex structures; During the placeholder automatic replacement process, for abnormal types, the placeholder automatic replacement is performed through an exception handling mechanism, which includes: for an abnormal type of an unbound placeholder, a warning is recorded and the original placeholder is retained; For data type mismatch abnormal types, a type converter is called for forced conversion; For data source unavailable abnormal types, cached data or default values are enabled.

5. The method for OA approval document intelligent layout and optimized printing based on dynamic template engine according to claim 1, characterized in that, In step S3, generating the final document or email includes: S3.1, triggering REST API request and parameter passing; selecting template type, data source, and output format through the front-end interface; S3.2, template engine processing, dynamically selecting a template engine according to the file type, selecting ApacheFreemarker engine for document templates, and selecting Thymeleaf engine for email templates; S3.3, format conversion and rendering, including document generation and email generation; document generation includes: converting HTML to PDF / DOCX using open source libraries; email generation includes: building a MIME email; in document generation, the same template can generate different format outputs through dynamic format adaptation, and an OutputFormatResolver is used to automatically select a renderer; in email generation, it includes mail-document linkage: when a document is used as an email attachment, ZIP and AES256 are used for automatic compression and encryption to protect sensitive data; S3.4, output control, including download file, email sending, and cloud storage saving mode for multi-channel output; in output control, version control is performed, template version and data snapshot are recorded each time, and traceability is supported.

6. The method for OA approval document intelligent layout and optimized printing based on dynamic template engine according to claim 1, characterized in that, In step S4, viewing, editing, deleting, and creating new templates through the template management interface includes: First, template full life cycle management; The second step is template syntax validation. New template types or placeholders are dynamically added as needed through a template extension mechanism, including the extension type and implementation. Specifically, for new template types, a plugin architecture is used to dynamically load the template renderer for dynamic extension; for custom placeholders, an extension interface is defined by registering a placeholder resolver for dynamic extension.

7. The method for OA approval document intelligent layout and optimized printing based on dynamic template engine according to claim 1, characterized in that, In step S5, the task parsing adopts a multi-stage parsing process; The received task is parsed by extracting key information, including: S5.

1. Structured data parsing is performed using adaptive template matching, and unstructured data parsing is performed using a visual-semantic joint model. Among them, structured data parsing using adaptive template matching includes: dynamically validating fields using extended JSON Schema and supporting default value filling. Unstructured data parsing is performed using a visual-semantic joint model. The unstructured data parsing includes: an OCR stage, using an improved TRBA model to extract text from print task sheets; and an NLP stage, based on domain knowledge graphs for entity recognition, including: constructing a print domain entity library and using a BiLSTM-CRF model for sequence labeling; the sequence labeling using the BiLSTM-CRF model includes both the original text and the labeled results. S5.2 Dynamic rule engine verification; S5.3 Real-time rule updates: Push new rules via WebSocket and obtain a key information matrix; S5.4 Optimize the obtained key information matrix for tasks, including: task scheduling based on reinforcement learning and resource conflict prediction; Reinforcement learning-based task scheduling includes: dynamically adjusting task priorities using the DQN algorithm; For the state space: printer queue length, current task page count, remaining ink level; Using the reward function: R = \alpha \times \frac{1}{waiting time} + \beta \times ink balance; The resource conflict prediction includes: establishing a directed graph model of printed resources and using topological sorting to detect infeasible task combinations.

8. The method for OA approval document intelligent layout and optimized printing based on dynamic template engine according to claim 1, characterized in that, In step S6, a three-layer scheduling model is adopted for task scheduling; Task scheduling specifically includes: S6.1 Dynamic Priority Calculation: The comprehensive priority is calculated using fuzzy logic and entropy weighting. S6.2 Resource-aware scheduling algorithm, including the improved genetic algorithm GA to implement resource-aware scheduling; S6.3 Real-time resource monitoring and prediction; including: printer status modeling, LSTM ink level prediction; Optimizing the printing order includes: time window optimization, conflict resolution mechanisms including resource conflict detection; resolution strategies including priority preemption, resource replacement, and task fragmentation; and load balancing strategies, such as printer allocation based on consistent hashing.

9. The OA approval document intelligent layout and optimized printing method based on a dynamic template engine of claim 8, characterized in that, In step S7, resource allocation adopts a dynamic allocation architecture. The specific implementation steps of printer allocation based on consistent hashing include: (1) Construct a consistent hash ring: Organize the entire hash space into a ring structure with the beginning and end connected; each point on the ring corresponds to a hash value; (2) Mapping printer nodes: According to the unique identifier of each printer, a hash value is calculated through a hash function, and the printer is mapped to the corresponding position on the hash ring; (3) Mapping print tasks: For each print task to be scheduled, a hash value is calculated according to a certain key attribute, and it is also mapped to a certain point on the hash ring; (4) Assigning printers to tasks: Starting from the position of the print task on the ring, find the first printer node clockwise, and assign the task to it; (5) Processing node increase and decrease: When a printer fails to go offline or a new printer goes online, only the mapping of the node needs to be removed or the mapping of the new node needs to be added on the ring; only the tasks between the new node and the next node counterclockwise are affected, which will be reassigned to the new node, while the mapping relationship between most tasks on the ring and printers remains unchanged, thereby minimizing the impact of remapping; (6) Introducing virtual nodes: To avoid uneven distribution of printer nodes on the ring leading to load tilt, multiple virtual nodes are generated for each physical printer node and mapped to different positions on the ring; by increasing the number of virtual nodes, the task allocation can be more uniform, achieving better load balancing.

10. The method for OA approval document intelligent layout and optimized printing based on dynamic template engine according to claim 1, characterized in that, In step S7, the resource allocation adopts a dynamic allocation architecture, and the resource reallocation based on Q-learning is implemented through the following steps: (1) Define the state space: the system state is composed of key resource indicators; (2) Define the action space: the actions that the agent can perform represent reallocation decisions; (3) Design the reward function: the reward function is used to evaluate the goodness of the action and guide the agent to learn the optimal strategy; (4) Build and update the Q table.

Citation Information

Patent Citations

  • Printing template establishment method and template printing method

    CN107402729A

  • Custom printing method and device, computer equipment and medium

    CN112214184A

  • Joint computing unloading and resource allocation method based on multi-agent DDQN

    CN114584951A

  • Printing method

    CN116009793A

  • Printing method and system for quickly realizing label field mapping and label rule configuration

    CN117032602A