A report generation method and device supporting multiple layouts and multiple templates
By generating unique template identifiers through hash algorithms, combined with layout coding and a visual formula builder, the problem of multiple layouts and templates in existing report generation technologies is solved, achieving efficient and accurate report generation and management, and improving the system's flexibility and reliability.
Patent Information
- Application Number
- CN202510282741.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-11
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2045-03-11
AI Technical Summary
Existing report generation technologies lack effective mechanisms when faced with various layout formats and personalized template customizations, resulting in low work efficiency and a high risk of errors, making it difficult to meet complex and ever-changing actual needs.
A unique identifier for the template is generated using a hash algorithm. The layout code is determined based on the identifier. The target layout component is selected from the preset layout component library. An element relationship network is constructed and a visual formula builder is provided. The subject tree is dynamically loaded, and layout description files and style sheets are generated, enabling flexible customization of report templates and layouts.
It improves the efficiency and accuracy of report generation, ensures the systematization and standardization of template management, enables layout reuse and rapid configuration, reduces the difficulty of formula configuration, improves the calculation speed and reliability of report data, and supports data traceability and problem troubleshooting.
Smart Images

Figure CN120257955B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of report generation, and in particular to a report generation method and device supporting multiple layouts and multiple templates. Background Art
[0002] Report generation technology is a crucial component of modern enterprise management and data analysis, widely used in fields such as finance and statistics. As enterprises become more information-based, report generation requirements are becoming increasingly diverse. Traditional static reports are no longer able to meet these complex and ever-changing needs. To address this challenge, the industry has gradually developed a variety of flexible report generation tools and technologies designed to improve data processing efficiency and report presentation quality.
[0003] Existing report generation technologies typically utilize predefined templates for report design and generation. Specifically, technicians pre-design report templates with fixed formats and populate the data through manual input or scripting. While these traditional methods can meet basic report creation requirements to a certain extent, they fall short when supporting diverse layouts and personalized template customization. This is particularly true when generating a large number of different report types simultaneously. The lack of effective mechanisms to ensure consistency and accuracy across reports leads to low efficiency and prone to errors.
[0004] Therefore, there is an urgent need for a report generation method that can efficiently manage multiple layouts and multiple templates to overcome the limitations of existing technologies. Summary of the Invention
[0005] The present application provides a report generation method and device that supports multiple layouts and multiple templates, realizes flexible customization of report templates and layouts, improves report generation efficiency and accuracy, and meets diverse needs.
[0006] In a first aspect of the present application, a report generation method supporting multiple layouts and multiple templates is provided, which is applied to a report generation platform. The method comprises:
[0007] Creating a report template table to determine core parameters and extended parameters of a target template, and using a hash algorithm to create a unique identifier for the target template based on the core parameters, the extended parameters, and a timestamp;
[0008] Determining a layout code corresponding to the target template according to the identifier, selecting a target layout component from a preset layout component library according to the layout code to generate a layout description file, and generating a style sheet having a mapping relationship with the identifier according to the layout description file;
[0009] Construct an element relationship network based on the row and column position relationship in the layout description file, record the row and column coordinates and style tags of each report element to generate an element table, dynamically load the subject tree and provide a visual formula builder to configure the formula to generate a formula table;
[0010] After receiving the target identifier, the row and column structure is obtained from the element table according to the target identifier, the calculation logic is loaded from the formula table, and the layout description is obtained from the style sheet, and a report is generated according to the row and column structure, the calculation logic and the layout description.
[0011] Optionally, determining a layout code corresponding to the target template according to the identifier, selecting a target layout component from a preset layout component library according to the layout code to generate a layout description file, and generating a style sheet mapped to the identifier according to the layout description file includes:
[0012] Querying a predefined layout rule library based on the identifier to obtain the layout code associated with the report type in the core parameter;
[0013] Matching a target layout component from a preset layout component library according to the layout code, wherein the preset layout component library includes XML structure definitions of a header layout and a footer layout;
[0014] Generate the layout description file according to the target layout component, wherein the layout description file includes row and column position relationships and style placeholders;
[0015] The layout description file is mapped to the identifier to generate a corresponding CSS style sheet path, and the path is stored in the style sheet.
[0016] Optionally, the step of constructing an element relationship network based on the row and column position relationship in the layout description file to record the row and column coordinates and style tags of each report element to generate an element table includes:
[0017] Parse the XML structure in the layout description file and extract all row and column nodes and corresponding attributes;
[0018] Create an initial element table, create corresponding row records and column records in the initial element table according to the first-level relationship and coordinate information of the row and column nodes, and assign a unique element identifier to each cell;
[0019] A CSS style sheet is obtained from the style sheet according to the style placeholder, and the style tags are parsed and associated with corresponding element identifiers to generate an element table.
[0020] Optionally, the dynamically loading the subject tree and providing a visual formula builder for formula configuration to generate a formula table includes:
[0021] According to the account set identifier in the core parameters, the first account code and the second hierarchical relationship associated with the current account set are filtered out from the preset account database to generate a dynamic account tree;
[0022] Rendering the subject tree in a visual formula builder and receiving user operation instructions by dragging subject nodes and selecting debit and credit directions and operators;
[0023] An abstract syntax tree is generated according to the operation instruction, an initial public table is created, and the structure of the abstract syntax tree, the associated first subject code and the corresponding element identifier are bound and stored in the initial formula table to generate a formula table.
[0024] Optionally, generating an abstract syntax tree according to the operation instruction includes:
[0025] Parsing the second subject code, operator, and direction mark in the operation instruction to construct an initial syntax tree node;
[0026] Performing a validity check on the initial syntax tree nodes according to preset verification rules, wherein the validity check includes subject existence check, debit / credit direction conflict detection, and circular reference interception;
[0027] The verified initial syntax tree nodes are rearranged according to operator priority to generate an abstract syntax tree, and metadata is added to the abstract syntax tree, the metadata including the dependent account set identifier, report period and calculation precision parameter.
[0028] Optionally, acquiring a row and column structure from the element table according to the target identifier, loading calculation logic from the formula table, and acquiring a layout description from the style sheet, and generating a report according to the row and column structure, the calculation logic, and the layout description includes:
[0029] Obtaining a target layout description file and a CSS style sheet path from the style sheet according to the target identifier, and parsing row and column structures and style tags;
[0030] Traversing each element identifier in the element table, and querying the debit and credit data in the account balance table in real time according to the structure of the abstract syntax tree bound to the formula table and the third account code;
[0031] Substituting the query result into the formula of the abstract syntax tree for calculation, generating a cell value, and filling the cell value into the corresponding coordinate according to the row and column position relationship in the target layout description file;
[0032] The CSS style sheet is obtained according to the CSS style sheet path, and the CSS style sheet is combined with the filled data and rendered into the report.
[0033] Optionally, the method further includes:
[0034] Parsing the structure of the abstract syntax tree in the formula table to extract all dependent fourth subject codes and calculation logic;
[0035] Reversely query the account balance table based on the fourth account code to obtain the original voucher number, amount and transaction date, and generate a list of original data sources;
[0036] Add a data traceability mark to each cell in the report, and when clicked, display a visual traceability path diagram, which includes the account calculation link and related voucher details;
[0037] Mark abnormal data nodes in the traceability path diagram and provide jump links to the original vouchers.
[0038] In a second aspect of the present application, a report generation system supporting multiple layouts and multiple templates is provided, comprising an identification module, a description module, a formula module, and an execution module, wherein:
[0039] an identification module configured to create a report template table to determine core parameters and extended parameters of a target template, and to create a unique identification of the target template based on the core parameters, the extended parameters, and a timestamp using a hash algorithm;
[0040] a description module configured to determine a layout code corresponding to the target template according to the identifier, select a target layout component from a preset layout component library according to the layout code to generate a layout description file, and generate a style sheet mapped to the identifier according to the layout description file;
[0041] A formula module is configured to construct an element relationship network based on the row and column position relationship in the layout description file, record the row and column coordinates and style tags of each report element to generate an element table, dynamically load the subject tree and provide a visual formula builder for formula configuration to generate a formula table;
[0042] The execution module is configured to receive a target identifier, obtain a row and column structure from the element table according to the target identifier, load calculation logic from the formula table, and obtain a layout description from the style sheet, and generate a report according to the row and column structure, the calculation logic, and the layout description.
[0043] In the third aspect of the present application, an electronic device is provided, including a processor, a memory, a user interface and a network interface, the memory is used to store instructions, the user interface and the network interface are both used to communicate with other devices, and the processor is used to execute the instructions stored in the memory so that the electronic device performs any of the methods described above.
[0044] In a fourth aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores instructions. When the instructions are executed, any one of the methods described above is executed.
[0045] In summary, one or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages:
[0046] 1. Create a report template table to identify the core parameters and extended parameters of the target template, and use a hash algorithm to create a unique identifier for the template based on the parameter value and timestamp, making template management more systematic and standardized. The distinction and management of core parameters and extended parameters helps to quickly generate report templates that meet requirements in different application scenarios, while the generation of unique identifiers facilitates accurate identification and version tracking of templates, facilitating template updates, reuse, and sharing.
[0047] 2. Determine the layout code based on the template identifier, select the target layout component from the preset layout component library to generate a layout description file, and generate a style sheet mapped to the identifier. This process enables layout reuse and rapid configuration. Users do not need to design the layout from scratch; they only need to select the appropriate layout code to quickly generate the layout description file and style sheet, greatly saving layout design time. At the same time, the provision of the preset layout component library ensures the standardization and consistency of the report layout, meeting the diverse needs of different users for report appearance and format;
[0048] 3. Build an element relationship network based on the layout description file, record the row and column coordinates and style tags of each report element, and generate an element table to achieve refined management of report elements. Dynamically load the subject tree and provide a visual formula builder for formula configuration, making formula configuration more intuitive and convenient, reducing the difficulty and error rate of formula configuration. Through the generation and management of the formula table, the calculation logic of each cell is ensured to be clear and accurate, providing a foundation for accurate calculation of report data;
[0049] 4. After receiving the target identifier, the system can quickly retrieve the required row and column structure, calculation logic, and layout description from the element table, formula table, and style sheet, enabling efficient report generation. The application of a real-time calculation engine and distributed computing model improves the calculation speed and processing capabilities of report data, ensuring the real-time and accuracy of reports. Furthermore, the generation of data lineage reports and calculation logs provides strong support for data tracing and troubleshooting within reports, helping to improve the credibility and reliability of report data.
[0050] 5. A state machine model is used to manage the template lifecycle, including states such as draft, pending review, and published, ensuring a standardized and organized report generation process. The integrated approval flow and generation of difference comparison views allow reviewers to clearly understand changes to report configurations, improving the accuracy and efficiency of approvals. The display of report disclosure templates through page configuration, as well as the real-time adjustment and display of report formulas, facilitates report analysis and adjustments, helping to improve report quality and application value. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 This is a flowchart of a report generation method supporting multiple layouts and multiple templates disclosed in an embodiment of the present application;
[0052] Figure 2 This is a schematic diagram of a new report template disclosed in the embodiment of this application;
[0053] Figure 3 is a schematic diagram of the editing template layout disclosed in the embodiment of this application;
[0054] Figure 4 It is a schematic diagram of the design header disclosed in the embodiment of this application;
[0055] Figure 5 It is a schematic diagram of the editing template design disclosed in the embodiment of this application;
[0056] Figure 6 It is a schematic diagram of the addition formula disclosed in the embodiment of this application;
[0057] Figure 7 This is a schematic diagram of the submission for approval disclosed in the embodiment of this application;
[0058] Figure 8 This is a schematic diagram of the details of the disclosure of the embodiment of this application after approval;
[0059] Figure 9 This is a module diagram of a report generation system supporting multiple layouts and multiple templates disclosed in an embodiment of the present application;
[0060] Figure 10 This is a structural diagram of an electronic device disclosed in an embodiment of the present application.
[0061] Explanation of the accompanying drawings: 901, identification module; 902, description module; 903, formula module; 904, execution module; 1001, processor; 1002, communication bus; 1003, user interface; 1004, network interface; 1005, memory. DETAILED DESCRIPTION
[0062] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this application, not all of the embodiments.
[0063] In the description of the embodiments of this application, words such as "for example" or "for instance" are used to indicate examples, illustrations, or explanations. Any embodiment or design described as "for example" or "for instance" in the embodiments of this application should not be construed as being preferred or advantageous over other embodiments or designs. Rather, the use of words such as "for example" or "for instance" is intended to present the relevant concepts in a concrete manner.
[0064] In the description of the embodiments of the present application, the term "multiple" means two or more. For example, multiple systems refer to two or more systems, and multiple screen terminals refer to two or more screen terminals. In addition, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized.
[0065] This embodiment discloses a report generation method that supports multiple layouts and multiple templates, which is applied to a report generation platform. Figure 1 This is a flow chart of a report generation method supporting multiple layouts and multiple templates disclosed in an embodiment of the present application. Figure 1 As shown, the method includes the following steps:
[0066] S101: Create a report template table to determine core parameters and extended parameters of a target template, and use a hash algorithm to create a unique identifier for the target template based on the core parameters, the extended parameters, and a timestamp.
[0067] S102: Determine a layout code corresponding to the target template according to the identifier, select a target layout component from a preset layout component library according to the layout code to generate a layout description file, and generate a style sheet having a mapping relationship with the identifier according to the layout description file;
[0068] S103, constructing an element relationship network based on the row and column position relationship in the layout description file, recording the row and column coordinates and style tags of each report element to generate an element table, dynamically loading the subject tree and providing a visual formula builder to configure formulas to generate a formula table;
[0069] S104: After receiving the target identifier, obtain the row and column structure from the element table according to the target identifier, load the calculation logic from the formula table, and obtain the layout description from the style sheet, and generate a report according to the row and column structure, the calculation logic, and the layout description.
[0070] Define core parameters (structured fields) in the report template table, including: company name (associated with the organizational structure), account set name (bound to the financial data source), report type (such as balance sheet, income statement, etc.), number of columns (determines the horizontal structure of the report), and contract group type (extends business scenario adaptability). Extended parameters use JSONB format to store dynamic configurations (such as custom tags and approval process identifiers). Use SHA-256 to calculate a digest of the core parameter values (such as company name + account set name + report type) and the timestamp to generate a globally unique identifier (template ID). If the hash result is repeated, a random salt is appended and recalculated to ensure uniqueness. A new version identifier is generated for each template modification and linked to previous versions. Based on the report type field (such as "Cash Flow Statement") in the template ID, a corresponding layout code is matched from a predefined layout rule library. The rule library uses key-value pairs, with the key being the report type and the value being the layout code and constraints (such as "Cash Flow Statement must contain a three-level header"). The preset layout component library contains XML definition files for components such as headers, footers, and page breaks. XML template files are precisely matched based on the layout code. Parse style placeholders (e.g., {{style_title}}) in the layout description file and extract corresponding CSS rules (e.g., font, color, border) from the preset style library. Generate a separate CSS file (e.g., style_8a1f6d.css) and associate its path with the template ID in the style table (template style association table). Extract row and column nodes and their attributes from the layout description file to generate a row-column coordinate mapping table. Associate CSS rules based on placeholder tags (e.g., bold). Query the account database for enabled accounts based on the A / C set ID and construct a tree structure (e.g., "Asset Class → Current Assets → Cash"). When a test A / C set is detected, load a predefined simulated account tree (e.g., "Test Account A → Sub-Account A1"). In the grid interface, the user selects the target cell (element ID = E001), drags the account node (e.g., "Cash" account code = 1001), and selects the operator (+ / -) and direction (debit / credit). Generate batch query SQL based on the account code list in the formula table to reduce database access times. Distribute cell calculation tasks to distributed computing nodes and aggregate results using the MapReduce model (e.g., summing multiple account balances in parallel). Inject CSS classes into corresponding cells based on style tags (e.g., bold) in the element table. Dynamically generate front-end scripts for collapsed rows (collapsed tags) to implement expand / collapse functionality. Parse the AST structure to extract dependent account codes (e.g., 1001, 1002); reverse query the account balance table to obtain original voucher information (e.g., voucher number, date, amount); and generate a visual link diagram: cell value → formula AST → account balance → original voucher. Add a floating prompt or hyperlink to a cell in the report; click to jump to the traceability details page.
[0071] Figure 2 This is a schematic diagram of the newly added report template disclosed in the embodiment of this application, such as Figure 2 As shown in the figure, the newly added report template includes company name, account set name, report template type, report template name, number of report generation columns, and contract group type.
[0072] Figure 3 This is a schematic diagram of the editing template layout disclosed in the embodiment of this application, such as Figure 3 As shown, the template layout includes header layout settings and footer layout settings.
[0073] Figure 4 This is a schematic diagram of the design header disclosed in the embodiment of this application, such as Figure 4 As shown, the header design includes three parts: left, middle and right. The left part can be the report name, the middle part can be the report year, and the right part can be the remarks.
[0074] Figure 5 This is a schematic diagram of the editing template design disclosed in the embodiment of this application, such as Figure 5 As shown, the template can add report items, including the report item name and data source.
[0075] Figure 6 is a schematic diagram of the addition formula disclosed in the embodiment of this application, such as Figure 6 As shown, under normal circumstances, all account configurations under this account set will be displayed, and then the debit and credit directions of the accounts will be selected for addition, subtraction, and summation operations. Because no account configuration is performed under the test account set, the display is empty.
[0076] Figure 7 This is a schematic diagram of the submission for approval disclosed in the embodiment of this application, such as Figure 7 As shown, after submission for approval, there will be report information and approval records.
[0077] Figure 8 This is a schematic diagram of the details of the application after the approval is passed. Figure 8 As shown, after approval, you will see the specific configuration, that is, Figure 8 Test column 1, test column 2, and test column 3 in .
[0078] Optionally, determining a layout code corresponding to the target template according to the identifier, selecting a target layout component from a preset layout component library according to the layout code to generate a layout description file, and generating a style sheet mapped to the identifier according to the layout description file includes:
[0079] Querying a predefined layout rule library based on the identifier to obtain the layout code associated with the report type in the core parameter;
[0080] Matching a target layout component from a preset layout component library according to the layout code, wherein the preset layout component library includes XML structure definitions of a header layout and a footer layout;
[0081] Generate the layout description file according to the target layout component, wherein the layout description file includes row and column position relationships and style placeholders;
[0082] The layout description file is mapped to the identifier to generate a corresponding CSS style sheet path, and the path is stored in the style sheet.
[0083] When determining a layout code for a template, the system queries the predefined layout rule library based on the template's unique identifier. The layout rule library stores layout codes corresponding to different report types. For example, if the target template is for a financial report, the system uses the report type information (one of the core parameters) included in the template identifier to find a layout code related to financial reports in the layout rule library. The preset layout component library is a repository of various layout components, including header and footer layouts. Each layout component has a unique layout code. Based on the layout code obtained in the previous step, the system matches the target layout component in the preset layout component library. For example, if the layout code is "layout-financial-001," the system finds the XML structure definitions for the corresponding header and footer layouts. The header layout might define the title style and column name placement, while the footer layout might define the location and style of the total row. Once the target layout components are determined, the system generates a layout description file based on these components. The layout description file is an XML file that details the row and column placement relationships and style placeholders for the report. For example, it will define the number of rows and columns in the report, as well as the width, height, alignment and other attributes of each row and column. Style placeholders are tags used to insert specific styles in subsequent steps, such as font color, background color, etc. After generating the layout description file, the system will map the file with the template identifier and generate the corresponding CSS style sheet path. The style sheet stores specific style information, such as fonts, colors, borders, etc. The style sheet is generated based on the style placeholders in the layout description file. For example, if there is a style placeholder "header-title" in the layout description file, the system will write the style information corresponding to the placeholder (such as bold font, 14pt font size, black color, etc.) into the style sheet according to the predefined style rules. The generated style sheet path will be stored in the template style association table so that the corresponding style can be quickly found and applied when the report is rendered.
[0084] By querying a predefined layout rule library based on a template identifier, you can precisely find the layout code corresponding to the report type. This avoids errors that can occur when manually selecting a layout, ensures a close match between the report layout and the content, and enhances the accuracy and professionalism of report generation. The use of a library of preset layout components allows for multiple reuse of layout components, reducing the need for repetitive design and configuration. When generating a report with a similar layout, you can directly call a pre-existing layout component, significantly saving time and effort and improving report generation efficiency. The layout description file specifies the row and column positional relationships and style placeholders, providing a unified standard for the report's row and column structure and style. This ensures consistent formatting across different report scenarios, facilitating user understanding and usage, and facilitating subsequent data analysis and processing. By mapping the layout description file to the identifier and generating the corresponding CSS style sheet path, the report's style can be dynamically adjusted and applied based on the template identifier. This not only ensures flexibility and aesthetics in report styling, but also facilitates unified style management and maintenance, improving system maintainability.
[0085] Optionally, the step of constructing an element relationship network based on the row and column position relationship in the layout description file to record the row and column coordinates and style tags of each report element to generate an element table includes:
[0086] Parse the XML structure in the layout description file and extract all row and column nodes and corresponding attributes;
[0087] Create an initial element table, create corresponding row records and column records in the initial element table according to the first-level relationship and coordinate information of the row and column nodes, and assign a unique element identifier to each cell;
[0088] A CSS style sheet is obtained from the style sheet according to the style placeholder, and the style tags are parsed and associated with corresponding element identifiers to generate an element table.
[0089] The layout description file is defined in an XML structure and contains information such as the report's row and column positional relationships and style placeholders. By parsing the XML file, all row and column nodes and their corresponding attributes are extracted. These attributes include, but are not limited to, row numbers, column numbers, and style categories. This information serves as the fundamental data for constructing report elements. Based on the parsed first-level relationships and coordinate information of the row and column nodes, an initial element table is created. Within this initial element table, corresponding row and column records are created for each row and column in the report, and each cell in the report is assigned a unique element identifier. This unique element identifier uniquely identifies each cell during subsequent processing, facilitating cell operations and management. Based on the style placeholders, the corresponding CSS style sheet is retrieved from the style sheet. The final element table is generated by parsing the style tags in the CSS style sheet and associating them with the corresponding element identifiers in the initial element table. This ensures that each cell contains not only row and column coordinate information but also specific style tags, such as font, color, and alignment, ensuring that the report's appearance and formatting conform to the predefined style.
[0090] By parsing the XML structure in the layout description file, the system extracts all row and column nodes and their corresponding attributes, converting the layout information into a manageable data structure. This enables the system to more clearly understand and process the report layout, laying the foundation for subsequent element management and report generation. This structured data makes it easier for the system to manipulate and manage row and column nodes, improving data processing efficiency and accuracy. When creating the initial element table, each cell is assigned a unique element identifier based on the first-level relationships and coordinate information of the row and column nodes. This ensures the uniqueness and identifiability of each report element within the entire report, avoiding confusion and duplication between elements. The assignment of unique element identifiers enables the system to precisely locate and manage each cell, improving the accuracy and reliability of report generation. By obtaining the CSS style sheet from the style sheet and parsing the style tags to their corresponding element identifiers, styles are tightly integrated with report elements. This allows the report style to be accurately applied to each element, ensuring the aesthetics and consistency of the report. The association between styles and elements enables the system to flexibly adjust and apply styles to meet different reporting requirements, improving the customizability and adaptability of reports.
[0091] Optionally, the dynamically loading the subject tree and providing a visual formula builder for formula configuration to generate a formula table includes:
[0092] According to the account set identifier in the core parameters, the first account code and the second hierarchical relationship associated with the current account set are filtered out from the preset account database to generate a dynamic account tree;
[0093] Rendering the subject tree in a visual formula builder and receiving user operation instructions by dragging subject nodes and selecting debit and credit directions and operators;
[0094] An abstract syntax tree is generated according to the operation instruction, an initial public table is created, and the structure of the abstract syntax tree, the associated first subject code and the corresponding element identifier are bound and stored in the initial formula table to generate a formula table.
[0095] The system obtains the A / C set identifier from the core parameters and then filters the first account code and second-level hierarchical relationship associated with the current A / C set from the preset account database based on this identifier. This process is similar to setting and retrieving account information for different A / C sets in an enterprise ERP system to ensure that the account tree matches the current A / C set. For example, when creating a new A / C set, accounting accounts need to be set. This account information is stored in the database for use when generating reports. Based on the account codes and hierarchical relationships obtained through this filtering, the system generates a dynamic account tree. The dynamic tree component supports asynchronous data loading, dynamically retrieving data as needed during user interaction, avoiding page lag or excessive loading times caused by loading large amounts of data all at once. For example, in Layui's dynamic tree component, data can be dynamically loaded based on user needs, improving system responsiveness and user experience. The generated account tree is then rendered in the visual formula builder. This allows users to intuitively see the structure and content of the account tree, facilitating subsequent operations. For example, in Java's JTree component, the display style of nodes can be customized by setting tree properties and renderers, improving user interface friendliness. The system receives user commands by dragging account nodes and selecting debit / credit directions and operators. This interaction is similar to financial software, where users can process and analyze financial data by dragging and dropping accounts. For example, in the NetSuite general ledger model, users can enter and query financial data by selecting accounts and debit / credit directions. Based on the user's commands, the system generates an abstract syntax tree (ABST). An ABST is a tree-like data structure used to represent the structure of program source code, converting user commands into executable code. For example, in Python, the ast module can be used to parse and generate ABSTs. The system creates an initial formula table and binds and stores the ABST structure, the associated first account code, and the corresponding element identifier to the initial formula table to generate the formula table. This process is similar to storing and managing financial data in a database, ensuring its accuracy and completeness. For example, in a bank's general ledger system, account and account set information is stored in the database for subsequent querying and analysis.
[0096] Based on the A / C set identifier in the core parameters, the first account code and second-level relationships associated with the current A / C set are filtered from the preset account database to generate a dynamic account tree. This ensures the accuracy and relevance of account data, avoids interference from irrelevant accounts, and improves the efficiency and accuracy of report formula configuration. The account tree is rendered in a visual formula builder, allowing users to configure formulas by dragging account nodes and selecting debit and credit directions and operators. This intuitive operation simplifies formula configuration and improves the user experience, making it easy for even non-technical personnel to configure complex report formulas. Based on the instructions, an abstract syntax tree is generated to create an initial formula table. The structure of the abstract syntax tree, the associated first account code, and the corresponding element identifier are bound and stored in the initial formula table to generate the formula table. The use of the abstract syntax tree clarifies the formula structure, facilitates subsequent formula parsing and calculation, and improves the efficiency and accuracy of report generation. By binding and storing the abstract syntax tree structure, the associated account code, and the corresponding element identifier, formula version management is facilitated. This allows for quick generation of new formula tables when report formulas need to be adjusted without modifying the code, ensuring real-time and flexible reporting.
[0097] Optionally, generating an abstract syntax tree according to the operation instruction includes:
[0098] Parsing the second subject code, operator, and direction mark in the operation instruction to construct an initial syntax tree node;
[0099] Performing a validity check on the initial syntax tree nodes according to preset verification rules, wherein the validity check includes subject existence check, debit / credit direction conflict detection, and circular reference interception;
[0100] The verified initial syntax tree nodes are rearranged according to operator priority to generate an abstract syntax tree, and metadata is added to the abstract syntax tree, the metadata including the dependent account set identifier, report period and calculation precision parameter.
[0101] An operation instruction includes the user-selected account node, debit / credit direction, and operator. For example, a user might select Account A and Account B and specify the addition operator. The system first parses these instructions, extracting key information such as the account code (secondary account code), operator type (e.g., addition, subtraction, multiplication, division), and direction (debit / credit direction). Assuming the user selects a credit amount for Account A (coded 1001) and a debit amount for Account B (coded 1002), and selects the addition operator, the operation instruction is parsed as follows:
[0102] Second subject codes: 1001 (Subject A) and 1002 (Subject B);
[0103] Operator: addition (+);
[0104] Direction mark: credit for account A and debit for account B.
[0105] Initial syntax tree nodes are the fundamental components of the abstract syntax tree. Each node represents an operation or a data item. The system constructs the initial syntax tree nodes based on the parsed operation instructions. For example, a node is created to represent the credit amount of account A. This node contains the account code 1001 and the direction flag "Credit." Another node is created to represent the debit amount of account B. This node contains the account code 1002 and the direction flag "Debit." An operator node is created to represent the addition operation, with the two account nodes as child nodes. After constructing the initial syntax tree nodes, the system performs validation checks based on pre-set rules to ensure the correctness and validity of the formula. The system checks whether the selected accounts exist in the account database of the current account set. For example, it verifies that account codes 1001 and 1002 are valid accounts, that is, whether they are defined and associated with the current account set. The system ensures that the selected debit and credit directions comply with accounting standards and business logic. For example, in certain business scenarios, some accounts may only appear in the debit or credit category, and the system needs to detect conflicts. Circular references are prevented in formulas, meaning that the value of a cell cannot depend on its own value. For example, if a formula attempts to calculate the value of one cell as the value of another cell, and the latter depends on the former, a circular reference error will occur. After passing the validity check, the system rearranges the verified initial syntax tree nodes according to operator precedence to generate an abstract syntax tree. For example, if a formula contains multiple operators, the system rearranges the nodes based on precedence (for example, multiplication and division take precedence over addition and subtraction). The system determines the order of precedence of the operators; for example, addition and subtraction have lower precedence than multiplication and division. The system rearranges the initial syntax tree nodes so that the operators are arranged in order of priority. For example, if a formula contains multiplication and addition, the system processes the multiplication operation first, then the addition operation. The final abstract syntax tree is constructed, in which each node is arranged in the correct order of operations. Finally, the system appends metadata to the abstract syntax tree, including the dependent account set identifier, reporting period, and calculation precision parameter. The dependent account set identifier identifies the account set on which the formula depends, ensuring that the correct account set data is used during calculations. Report Period: Specify the timeframe covered by the report, such as month, quarter, or year, to ensure data timeliness. Calculation Precision: Define the number of decimal places and other precision requirements for calculation results to meet the data accuracy requirements of different business scenarios. For example, you can set calculation results to retain two decimal places.
[0106] The system accurately parses all elements of the user-entered operation instructions during formula configuration, such as account codes, operators, and debit / credit direction indicators, to precisely construct initial syntax tree nodes. This provides accurate foundational data for subsequent formula verification and calculations, ensuring the accuracy of formula configuration. This is similar to precisely measuring the composition and proportions of raw materials on a factory production line, providing an accurate basis for subsequent processing and manufacturing. Pre-set validation rules verify the validity of initial syntax tree nodes, covering multiple aspects such as account existence verification, debit / credit conflict detection, and circular reference prevention. For example, account existence verification is like checking inventory availability before shipment, ensuring that the accounting accounts used actually exist, and avoiding report data errors caused by using non-existent accounts. This strict validation mechanism acts as a solid defense, blocking illegal formula configurations and ensuring the accuracy and reliability of report data. After verification, the initial syntax tree nodes are reordered according to operator priority. The resulting abstract syntax tree clearly expresses the formula's calculation logic, improving readability and maintainability.
[0107] Optionally, acquiring a row and column structure from the element table according to the target identifier, loading calculation logic from the formula table, and acquiring a layout description from the style sheet, and generating a report according to the row and column structure, the calculation logic, and the layout description includes:
[0108] Obtaining a target layout description file and a CSS style sheet path from the style sheet according to the target identifier, and parsing row and column structures and style tags;
[0109] Traversing each element identifier in the element table, and querying the debit and credit data in the account balance table in real time according to the structure of the abstract syntax tree bound to the formula table and the third account code;
[0110] Substituting the query result into the formula of the abstract syntax tree for calculation, generating a cell value, and filling the cell value into the corresponding coordinate according to the row and column position relationship in the target layout description file;
[0111] The CSS style sheet is obtained according to the CSS style sheet path, and the CSS style sheet is combined with the filled data and rendered into the report.
[0112] Based on the input target identifier, the system retrieves the target layout description file and CSS style sheet path corresponding to the target identifier from the style sheet. The target layout description file contains information such as the report's row and column structure and style tags, while the CSS style sheet path points to the CSS file that defines the report's style. By obtaining the layout description file and CSS style sheet path, the system can understand the report's overall layout structure and style requirements, providing layout and style guidance for subsequent report generation. The system then parses the obtained target layout description file to extract the row and column structure information and style tags. The row and column structure information specifies the arrangement and number of rows and columns in the report, while the style tags define the style characteristics of each report element, such as font, color, and borders. Parsing the row and column structure and style tags ensures that, when generating the report, data is accurately placed and report content is presented according to the predetermined layout and style requirements, ensuring the report's format and appearance meet the expectations. The system iterates through each element identifier in the element table. For each element identifier, the system uses the abstract syntax tree structure and third-party account code associated with the element identifier in the formula table to query the debit and credit data in the account balance table in real time. The third account code here is the account code associated with the formula configuration and is used to determine the specific account when querying the account balance table. By traversing the element table and querying the corresponding account balance data, the system can obtain the data required for each cell in the report, providing the basis for subsequent report data filling. Real-time querying of the account balance table ensures real-time and accurate data, ensuring that the report reflects the latest financial data. The queried account balance data is substituted into the formula represented by the abstract syntax tree for calculation to generate the corresponding cell value. Then, based on the row and column position relationship in the target layout description file, the calculated cell value is filled into the corresponding coordinate position in the report. For example, if the target layout description file specifies a cell in row 3, column 5, the system will fill the calculated cell value into the corresponding position in the report. By calculating the cell value and filling it according to the row and column position relationship in the layout description file, the system can generate complete report data content and ensure that the data is accurately positioned in the report, meeting the report layout requirements. The system retrieves the corresponding CSS style sheet based on the previously obtained CSS style sheet path. The CSS style sheet is then combined with the already populated report content to render the report. During the rendering process, the system applies style settings to various report elements, such as font style, color, border, and background, based on the style definitions in the CSS style sheet. Ultimately, the system generates a report with complete content and an aesthetically pleasing appearance. Obtaining the CSS style sheet and rendering the report ensures that the report is visually appealing and professional, meeting user requirements for report appearance and improving readability and usability.
[0113] The target layout description file and CSS style sheet path are accurately obtained through the target identifier, and the row and column structure and style tags therein are parsed, providing clear structural and style guidance for report generation, ensuring that the layout and appearance of the report meet expectations. Each element identifier in the element table is traversed, and the credit and debit data in the account balance table are queried in real time based on the abstract syntax tree structure and account code in the formula table. This on-demand query method avoids full table scans, improves the efficiency of data queries, and ensures the timeliness and accuracy of report data. The queried data is substituted into the formula of the abstract syntax tree for calculation, generating cell values, and filling the values into the corresponding coordinates according to the row and column position relationship in the target layout description file. This process ensures the accurate calculation and correct layout of report data, avoids data dislocation or calculation errors, and enables the report to clearly and accurately display data information.
[0114] 7 Optionally, the method further includes:
[0115] Parsing the structure of the abstract syntax tree in the formula table to extract all dependent fourth subject codes and calculation logic;
[0116] Reversely query the account balance table based on the fourth account code to obtain the original voucher number, amount and transaction date, and generate a list of original data sources;
[0117] Add a data traceability mark to each cell in the report, and when clicked, display a visual traceability path diagram, which includes the account calculation link and related voucher details;
[0118] Mark abnormal data nodes in the traceability path diagram and provide jump links to the original vouchers.
[0119] By parsing the abstract syntax tree (AST) structure in the formula table, the system can accurately extract all fourth-account codes and corresponding calculation logic required for report generation. This process is similar to parsing code. By analyzing the nodes and branches of the AST, the system can clearly understand the accounts involved in each formula and the operational relationships between them. For example, if a formula is "Credit Amount of Account A + Debit Amount of Account B," the system can extract the codes for Account A and Account B, as well as the addition logic, by parsing the AST. This extraction process ensures that the system accurately captures all account information relevant to the report calculation, providing accurate basic data for subsequent data queries and calculations. After extracting the fourth-account codes, the system uses these codes to perform a reverse query on the account balance table. The account balance table records information such as the debit and credit amounts, balances, and corresponding source document numbers and transaction dates for each account in different periods. Through reverse query, the system can obtain the source document information corresponding to each cell data in the report, including the document number, amount, and transaction date. This information is organized into a list of original data sources, providing detailed data support for report data traceability. For example, if the data in a report cell is calculated using the credit amount of Account A, the system can reverse-query the account balance sheet to find the original document number, amount, and transaction date corresponding to the credit amount and record this information in the original data source list. The system assigns a data traceability identifier to each report cell. When a user clicks a cell, a visual traceability diagram is displayed. This diagram graphically illustrates the entire data calculation chain from the original document to the report cell, including the calculation relationship between the accounts and the associated document details. For example, if the data in a report cell is calculated using Accounts A and B, the traceability diagram displays the calculation relationship between Accounts A and B, as well as the original document information related to these accounts. This visual traceability diagram helps users intuitively understand the source and calculation process of report data, enhancing the transparency and credibility of report data. The system marks anomalous data nodes in the traceability diagram, which may be caused by data errors, calculation anomalies, and other reasons. Users can quickly locate the anomalous data node by viewing the markers in the traceability diagram to understand the source and impact of the anomalous data. The system also provides a link to the original document. Users can click the link to jump directly to the corresponding original document and view the original document details. This function can help users quickly identify and resolve data anomalies and ensure the accuracy and reliability of report data.
[0120] By parsing the abstract syntax tree structure in the formula table and extracting all dependent fourth-account codes and calculation logic, the data sources and calculation rules required for report generation can be accurately determined. This ensures the accuracy and completeness of report data and provides clear guidance for subsequent data queries and calculations. Based on the fourth-account code, the account balance table is queried reversely to obtain the original document number, amount, and transaction date, generating a list of original data sources. This process ensures data traceability, allowing every data point in the report to be traced back to its original source, facilitating data verification and anomaly detection. Data traceability is assigned to each cell in the report. Clicking on a cell displays a visual traceability diagram that includes the account calculation chain and associated document details. This visual display allows users to intuitively understand the data source and calculation process, enhancing report transparency and credibility. Anomalous data nodes are marked in the traceability diagram and provided with a jump link to the original document. This allows users to quickly locate and address anomalous data, improving data processing efficiency and accuracy. By directly jumping to the original document, users can quickly verify and correct data, ensuring report accuracy.
[0121] In the embodiment of the present application, the front end transmits the ID of the report template, and the back end starts to render the data of this report. First, query the report element table to query the rows and columns that need to be rendered for this report, and then loop one by one according to the row order. For example, if you need to render the data of the first row and the first column, then the formula for querying the first row and the first column is the credit amount of subject A + the debit amount of subject B. Query the total amount of all credit amounts of subject A in the current account period in the account balance table in a loop, and query the total amount of all debit amounts of subject B in the current account period in the account balance table, and so on. The data rendering of this system is real-time. The advantage of this is that as long as the basic data remains unchanged, there is no need to change the code when the formula configuration changes. The report results can be correctly displayed according to the modified formula configuration. Another advantage is that by querying the account configuration of a certain row and a certain column, you can know the source of the data, and you can do data tracing, which is convenient for later verification.
[0122] This embodiment also discloses a report generation system that supports multiple layouts and multiple templates. Figure 9 This is a module diagram of a report generation system supporting multiple layouts and multiple templates disclosed in an embodiment of the present application. Figure 9 As shown, the system includes an identification module 901, a description module 902, a formula module 903, and an execution module 904, wherein:
[0123] Identification module 901 is configured to create a report template table to determine the core parameters and extended parameters of a target template, and to create a unique identifier of the target template based on the core parameters, the extended parameters, and a timestamp using a hash algorithm;
[0124] A description module 902 is configured to determine a layout code corresponding to the target template according to the identifier, select a target layout component from a preset layout component library according to the layout code to generate a layout description file, and generate a style sheet mapped to the identifier according to the layout description file;
[0125] Formula module 903, configured to construct an element relationship network based on the row and column position relationship in the layout description file, record the row and column coordinates and style tags of each report element to generate an element table, dynamically load the subject tree and provide a visual formula builder for formula configuration to generate a formula table;
[0126] Execution module 904 is configured to, after receiving a target identifier, obtain a row and column structure from the element table according to the target identifier, load calculation logic from the formula table, and obtain a layout description from the style sheet, and generate a report according to the row and column structure, the calculation logic, and the layout description.
[0127] Optionally, the description module 902 is configured to:
[0128] Querying a predefined layout rule library based on the identifier to obtain the layout code associated with the report type in the core parameter;
[0129] Matching a target layout component from a preset layout component library according to the layout code, wherein the preset layout component library includes XML structure definitions of a header layout and a footer layout;
[0130] Generate the layout description file according to the target layout component, wherein the layout description file includes row and column position relationships and style placeholders;
[0131] The layout description file is mapped to the identifier to generate a corresponding CSS style sheet path, and the path is stored in the style sheet.
[0132] Optionally, the formula module 903 is configured to:
[0133] Parse the XML structure in the layout description file and extract all row and column nodes and corresponding attributes;
[0134] Create an initial element table, create corresponding row records and column records in the initial element table according to the first-level relationship and coordinate information of the row and column nodes, and assign a unique element identifier to each cell;
[0135] A CSS style sheet is obtained from the style sheet according to the style placeholder, and the style tags are parsed and associated with corresponding element identifiers to generate an element table.
[0136] Optionally, the formula module 903 is configured to:
[0137] According to the account set identifier in the core parameters, the first account code and the second hierarchical relationship associated with the current account set are filtered out from the preset account database to generate a dynamic account tree;
[0138] Rendering the subject tree in a visual formula builder and receiving user operation instructions by dragging subject nodes and selecting debit and credit directions and operators;
[0139] An abstract syntax tree is generated according to the operation instruction, an initial public table is created, and the structure of the abstract syntax tree, the associated first subject code and the corresponding element identifier are bound and stored in the initial formula table to generate a formula table.
[0140] Optionally, the formula module 903 is configured to:
[0141] Parsing the second subject code, operator, and direction mark in the operation instruction to construct an initial syntax tree node;
[0142] Performing a validity check on the initial syntax tree nodes according to preset verification rules, wherein the validity check includes subject existence check, debit / credit direction conflict detection, and circular reference interception;
[0143] The verified initial syntax tree nodes are rearranged according to operator priority to generate an abstract syntax tree, and metadata is added to the abstract syntax tree, the metadata including the dependent account set identifier, report period and calculation precision parameter.
[0144] Optionally, the execution module 904 is configured to:
[0145] Obtaining a target layout description file and a CSS style sheet path from the style sheet according to the target identifier, and parsing row and column structures and style tags;
[0146] Traversing each element identifier in the element table, and querying the debit and credit data in the account balance table in real time according to the structure of the abstract syntax tree bound to the formula table and the third account code;
[0147] Substituting the query result into the formula of the abstract syntax tree for calculation, generating a cell value, and filling the cell value into the corresponding coordinate according to the row and column position relationship in the target layout description file;
[0148] The CSS style sheet is obtained according to the CSS style sheet path, and the CSS style sheet is combined with the filled data and rendered into the report.
[0149] Optionally, the system further includes a traceability module configured to:
[0150] Parsing the structure of the abstract syntax tree in the formula table to extract all dependent fourth subject codes and calculation logic;
[0151] Reversely query the account balance table based on the fourth account code to obtain the original voucher number, amount and transaction date, and generate a list of original data sources;
[0152] Add a data traceability mark to each cell in the report, and when clicked, display a visual traceability path diagram, which includes the account calculation link and related voucher details;
[0153] Mark abnormal data nodes in the traceability path diagram and provide jump links to the original vouchers.
[0154] It should be noted that the above embodiments provide devices that implement their functions using only the division of the above functional modules as examples. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiments are based on the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.
[0155] This embodiment also discloses an electronic device, referring to Figure 10 The electronic device may include: at least one processor 1001 , at least one communication bus 1002 , a user interface 1003 , a network interface 1004 , and at least one memory 1005 .
[0156] The communication bus 1002 is used to implement the connection and communication between these components.
[0157] The user interface 1003 may include a display screen (Display) and a camera (Camera). Optionally, the user interface 1003 may also include a standard wired interface and a wireless interface.
[0158] The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).
[0159] Processor 1001 may include one or more processing cores. Using various interfaces and circuits, processor 1001 connects to various components within the server. It executes instructions, programs, code sets, or instruction sets stored in memory 1005, as well as accesses data stored in memory 1005, to perform various server functions and process data. Optionally, processor 1001 may be implemented using at least one of the following hardware forms: a digital signal processing (DSP), a field-programmable gate array (FPGA), or a programmable logic array (PLA). Processor 1001 may integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. The CPU primarily processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing content displayed on the display; and the modem handles wireless communications. It is understood that the modem may not be integrated into processor 1001 but implemented as a separate chip.
[0160] Among them, the memory 1005 may include a random access memory (RAM) or a read-only memory (Read-Only Memory). Optionally, the memory 1005 includes a non-transitory computer-readable storage medium. The memory 1005 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 1005 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 1005 may optionally be at least one storage device located away from the aforementioned processor 1001. As Figure 10 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and an application program supporting a report generation method with multiple layouts and multiple templates.
[0161] exist Figure 10In the electronic device shown, the user interface 1003 is mainly used to provide an input interface for the user and obtain data input by the user; and the processor 1001 can be used to call the application program that supports the report generation method with multiple layouts and multiple templates stored in the memory 1005. When executed by one or more processors 1001, the electronic device executes one or more methods in the above-mentioned embodiments.
[0162] It should be noted that for the aforementioned method embodiments, for simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required for this application.
[0163] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0164] In the several embodiments provided in this application, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are merely schematic, such as the division of units, which is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some service interface, and the indirect coupling or communication connection of devices or units can be electrical or other forms.
[0165] Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0166] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0167] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of this application, or the portion that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory 1005 and includes several instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the various embodiments of the method of this application. The aforementioned memory 1005 includes various media that can store program code, such as a USB flash drive, a mobile hard drive, a magnetic disk, or an optical disk.
[0168] The above is only an exemplary embodiment of the present disclosure and cannot be used to limit the scope of the present disclosure. That is, any equivalent changes and modifications made according to the teachings of the present disclosure are still within the scope of the present disclosure. After considering the disclosure of the specification, those skilled in the art will easily think of other embodiments of the present disclosure. This application is intended to cover any variations, uses or adaptive changes of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary technical means in the technical field that are not recorded in the present disclosure. The description and examples are to be regarded as exemplary only, and the scope and spirit of the present disclosure are defined by the claims.
Claims
1. A report generation method supporting multiple layouts and multiple templates, characterized in that: Applied to a report generation platform, the method includes: Creating a report template table to determine core parameters and extended parameters of a target template, and using a hash algorithm to create a unique identifier for the target template based on the core parameters, the extended parameters, and a timestamp; Determining a layout code corresponding to the target template according to the unique identifier, selecting a target layout component from a preset layout component library according to the layout code to generate a layout description file, and generating a style sheet having a mapping relationship with the unique identifier according to the layout description file; Construct an element relationship network based on the row and column position relationship in the layout description file, record the row and column coordinates and style tags of each report element to generate an element table, dynamically load the subject tree and provide a visual formula builder to configure the formula to generate a formula table; After receiving the target identifier, the row and column structure is obtained from the element table according to the target identifier, the calculation logic is loaded from the formula table, and the layout description is obtained from the style sheet, and a report is generated according to the row and column structure, the calculation logic and the layout description.
2. The report generation method supporting multiple layouts and multiple templates according to claim 1, characterized in that: The steps of determining a layout code corresponding to the target template according to the unique identifier, selecting a target layout component from a preset layout component library according to the layout code to generate a layout description file, and generating a style sheet having a mapping relationship with the unique identifier according to the layout description file include: Querying a predefined layout rule library based on the unique identifier to obtain the layout code associated with the report type in the core parameters; Matching a target layout component from a preset layout component library according to the layout code, wherein the preset layout component library includes XML structure definitions of a header layout and a footer layout; Generate the layout description file according to the target layout component, wherein the layout description file includes row and column position relationships and style placeholders; The layout description file is mapped to the unique identifier to generate a corresponding CSS style sheet path, and the path is stored in the style sheet.
3. The report generation method supporting multiple layouts and multiple templates according to claim 2, characterized in that: The step of constructing an element relationship network based on the row and column position relationship in the layout description file to record the row and column coordinates and style tags of each report element to generate an element table includes: Parse the XML structure in the layout description file and extract all row and column nodes and corresponding attributes; Create an initial element table, create corresponding row records and column records in the initial element table according to the first-level relationship and coordinate information of the row and column nodes, and assign a unique element identifier to each cell; A CSS style sheet is obtained from the style sheet according to the style placeholder, and the style tags are parsed and associated with corresponding element identifiers to generate an element table.
4. The report generation method supporting multiple layouts and multiple templates according to claim 1, characterized in that: The method of dynamically loading a subject tree and providing a visual formula builder for formula configuration to generate a formula table includes: According to the account set identifier in the core parameters, the first account code and the second hierarchical relationship associated with the current account set are filtered out from the preset account database to generate a dynamic account tree; Rendering the dynamic subject tree in a visual formula builder and receiving user operation instructions by dragging subject nodes, selecting debit and credit directions, and operators; An abstract syntax tree is generated according to the operation instruction, an initial formula table is created, and the structure of the abstract syntax tree, the associated first subject code and the corresponding element identifier are bound and stored in the initial formula table to generate a formula table.
5. The report generation method supporting multiple layouts and multiple templates according to claim 4, characterized in that: Generating an abstract syntax tree according to the operation instruction includes: Parsing the second subject code, operator, and direction mark in the operation instruction to construct an initial syntax tree node; Performing a validity check on the initial syntax tree nodes according to preset verification rules, wherein the validity check includes subject existence check, debit / credit direction conflict detection, and circular reference interception; The verified initial syntax tree nodes are rearranged according to operator priority to generate an abstract syntax tree, and metadata is added to the abstract syntax tree, the metadata including the dependent account set identifier, report period and calculation precision parameter.
6. The report generation method supporting multiple layouts and multiple templates according to claim 4, characterized in that: The acquiring of a row and column structure from the element table according to the target identifier, loading calculation logic from the formula table, and acquiring a layout description from the style sheet, and generating a report according to the row and column structure, the calculation logic, and the layout description includes: Obtaining a target layout description file and a CSS style sheet path from the style sheet according to the target identifier, and parsing row and column structures and style tags; Traversing each element identifier in the element table, and querying the debit and credit data in the account balance table in real time according to the structure of the abstract syntax tree bound to the formula table and the third account code; Substituting the query result into the formula of the abstract syntax tree for calculation, generating a cell value, and filling the cell value into the corresponding coordinate according to the row and column position relationship in the target layout description file; The CSS style sheet is obtained according to the CSS style sheet path, and the CSS style sheet is combined with the filled data and rendered into the report.
7. The report generation method supporting multiple layouts and multiple templates according to claim 1, characterized in that: The method further comprises: Parsing the structure of the abstract syntax tree in the formula table to extract all dependent fourth subject codes and calculation logic; Reversely query the account balance table based on the fourth account code to obtain the original voucher number, amount and transaction date, and generate a list of original data sources; Add a data traceability mark to each cell in the report, and when clicked, display a visual traceability path diagram, which includes the account calculation link and related voucher details; Mark abnormal data nodes in the traceability path diagram and provide jump links to the original vouchers.
8. A report generation system supporting multiple layouts and multiple templates, characterized in that: It includes an identification module, a description module, a formula module, and an execution module, wherein: an identification module configured to create a report template table to determine core parameters and extended parameters of a target template, and to create a unique identification of the target template based on the core parameters, the extended parameters, and a timestamp using a hash algorithm; a description module configured to determine a layout code corresponding to the target template based on the unique identifier, select a target layout component from a preset layout component library based on the layout code to generate a layout description file, and generate a style sheet having a mapping relationship with the unique identifier based on the layout description file; A formula module is configured to construct an element relationship network based on the row and column position relationship in the layout description file, record the row and column coordinates and style tags of each report element to generate an element table, dynamically load the subject tree and provide a visual formula builder for formula configuration to generate a formula table; The execution module is configured to receive a target identifier, obtain a row and column structure from the element table according to the target identifier, load calculation logic from the formula table, and obtain a layout description from the style sheet, and generate a report according to the row and column structure, the calculation logic, and the layout description.
9. An electronic device, characterized in that: The electronic device comprises a processor, a memory, a user interface and a network interface, wherein the memory is used to store instructions, the user interface and the network interface are both used to communicate with other devices, and the processor is used to execute the instructions stored in the memory so that the electronic device executes the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores instructions, and when the instructions are executed, the method according to any one of claims 1 to 7 is executed.
Citation Information
Patent Citations
Analytical report generation method, device and system and storage medium
CN117009417A
Method, system and program for joining source table rows with target table rows
US20060224551A1