Saas system customization report generation method and device based on dynamic template configuration
Patent Information
- Application Number
- CN202511276361.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-08
- Publication Date
- 2026-09-18
- Estimated Expiration
- 2045-09-08
AI Technical Summary
这不仅造成代码库臃肿,而且任何细微的业务逻辑变更都需要在多处修改,使得代码维护极其困难
[0048] This invention provides a method for generating customized reports for SaaS systems based on dynamic template configuration. By introducing visual report templates and metadata description files, it successfully decouples report format definitions from business logic and data acquisition. Changes in tenant format requirements are limited to the template and metadata level, eliminating the need to modify, compile, and deploy any backend code, thus reducing system maintenance workload. Simultaneously, thanks to the decoupled design of a unified data interface that dynamically constructs query statements based on metadata, system functionality is completely decoupled from tenant requirements when new tenants join or existing tenants add report requests. No new code needs to be written; only templates designed according to requirements are required, and the system can automatically adapt, reducing the cost of new tenant integration and providing strong architectural support for the rapid scaling of SaaS platforms. Furthermore, this invention decouples the processing requirements for elements such as images and QR codes from business code by defining standardized structured markers, and these are standardized and pipelined by a dedicated hybrid rendering engine. This invention decouples data isolation strategies from scattered business code and centrally implements them at the unified data interface architectural layer. This interface enforces tenant ID filtering conditions when dynamically constructing SQL, making data isolation an automatically executed, business-independent architectural security feature. This fundamentally eliminates the risk of data leakage that might arise from coupling with business logic, enhancing system security and reliability. Finally, the dynamic location estimation algorithm is decoupled from business data, enabling layout prediction and adjustment based solely on metadata. Combined with efficient technologies such as zero-copy processing chains, this achieves architectural decoupling in report rendering. Not only is the functionality clear and easy to maintain, but it also significantly outperforms traditional coupled solutions, effectively improving rendering speed and perfectly supporting enterprise-level applications.
Smart Images

Figure CN121168434B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of Software as a Service (SaaS) technology, specifically to a method and apparatus for generating customized reports for a SaaS system based on dynamic template configuration. Background Technology
[0002] In traditional Software as a Service (SaaS) system report development, report export functionality is typically implemented using hard-coding. This means that developers need to write dedicated data query, processing, and export modules to meet the personalized report format requirements of different tenants. This approach suffers from the following significant technical bottlenecks:
[0003] 1. Code redundancy and poor maintainability: The different report formats for each tenant require the development of a separate set of export logic, leading to an exponential increase in system code size. For example, developing 10 different order report formats for 10 tenants might require maintaining 10 different code paths. This not only makes the codebase bloated, but also requires modifications in multiple places for even minor business logic changes, making code maintenance extremely difficult.
[0004] 2. Insufficient system scalability: When new tenants or existing tenants request new report formats, developers must rewrite the report generation logic, test, and deploy it online. The system's functionality is highly coupled with tenant needs, making it unable to quickly respond to market changes and severely restricting the scalable expansion of the SaaS business.
[0005] 3. Weak support for dynamic content: Traditional technical solutions (such as simple POI operations or some reporting tools) struggle to flexibly and efficiently support the embedding of unstructured data such as images and QR codes. Implementing this functionality often requires writing complex and non-versatile underlying code, failing to meet the widespread demand of modern enterprise reports for rich content presentation.
[0006] 4. Complex implementation of multi-tenant data isolation: In the traditional hard-coded model, ensuring the security of data isolation between different tenants requires explicitly adding fixed-format conditions to every data query code. Developers are prone to overlooking these conditions, which poses a risk of unauthorized data access. Furthermore, this security strategy is scattered throughout the code, making it difficult to audit and manage uniformly.
[0007] Some existing solutions, such as using professional reporting tools (like JasperReports) or template engines, have alleviated the problem of separating style and logic to some extent, but they still have problems such as high learning costs, complex configuration, and poor compatibility with commonly used office spreadsheet ecosystems, and have failed to fundamentally solve the above-mentioned technical defects. Summary of the Invention
[0008] To address the shortcomings of existing technologies, this invention proposes a method for generating customized reports for SaaS systems based on dynamic template configuration, comprising:
[0009] Obtain customized visual report templates for decoupling business data;
[0010] The report template is edited using a preset editor to generate a template configuration file;
[0011] Parse the structured tags in the template configuration file to generate a metadata description file;
[0012] Based on the data requirements defined in the metadata description file, the business database is queried through the unified data interface to obtain and assemble customized business data corresponding to the tenant ID;
[0013] Based at least on the customized business data, the rendering process is controlled by a dynamic position calculation algorithm to dynamically fill the data into the corresponding position of the report template to generate a customized report.
[0014] In one embodiment, the above-described method of editing the report template based on a preset editor to generate a template configuration file includes:
[0015] Based on the tenant's first input operation to the preset editor, structured markers are inserted into the cells of the report template. These markers include field markers, image markers, and coded graphic markers.
[0016] The dynamic region boundary is determined based on the tenant's second input operation to the preset editor;
[0017] A template configuration file is generated based at least on the structured markers and dynamic region boundaries.
[0018] In one embodiment, the process of parsing the structured markers in the template configuration file to generate a metadata description file includes:
[0019] Control the metadata parser to perform the following operations:
[0020] Based on a predefined semantic rule base and mapping relationship, pattern matching is performed on the field names in the field identifier to determine the data type and validation rules corresponding to the matching results;
[0021] Based on the type of the encoded graphic marker, an optimized default fault tolerance level is assigned to it;
[0022] Based on the size of the cell containing the image marker and the layout of the surrounding cells, calculate its maximum size constraint;
[0023] Based on the positional context of the grouping marker in the report template, the expansion direction of its dynamic area is intelligently determined.
[0024] In one embodiment, the step of querying the business database through a unified data interface to obtain and assemble customized business data corresponding to the tenant ID based on the data requirements defined in the metadata description file includes:
[0025] Parse the metadata description file and extract the list of field names and data grouping instructions defined therein;
[0026] The list of field names is mapped and validated against a predefined whitelist of field names to generate a secure set of database query field names.
[0027] The SQL statement is dynamically constructed, wherein the select clause of the SQL statement is based on the set of query field names, the where clause contains a filtering statement based on the current tenant ID, and the group by clause is generated based on the data grouping instruction;
[0028] Execute the SQL statement to retrieve the original dataset from the business database;
[0029] The original dataset is encapsulated according to the field structure defined in the metadata description file and assembled into a customized business data object in key-value pair form for use by the rendering engine.
[0030] In one embodiment, the step of controlling the rendering process through a dynamic position calculation algorithm based at least on the customized business data to dynamically fill the data into the corresponding positions of the report template to generate a customized report specifically involves:
[0031] Based on the metadata description file and the customized business data, the data is dynamically filled into the corresponding positions of the report template through a hybrid rendering engine; wherein, the filling process is controlled by a dynamic position calculation algorithm to automatically adjust the template layout according to the amount of data and generate a customized report.
[0032] In one embodiment, the dynamic position estimation algorithm includes:
[0033] Based on the field types in the metadata description file, the dataset in the dynamic area is intelligently grouped, and the number of rows required for each group is predicted.
[0034] Based on the predicted row count, perform a matrix splitting operation on cells marked as dynamic regions to expand the physical space and automatically inherit the styles of the original template;
[0035] Create a report element dependency graph, calculate the displacement caused by dynamic area expansion, and translate and rewrite the coordinates of all affected downstream cells, charts, and formulas to avoid layout conflicts.
[0036] In one embodiment, the hybrid rendering engine is used for:
[0037] It identifies nested expression syntax in field markers, constructs an abstract syntax tree through a recursive descent parsing algorithm and performs depth-first traversal calculations, while simultaneously establishing a real-time listener for expression fields;
[0038] The system intercepts requests for images or encoded graphic markers, performs a zero-copy processing chain on the binary stream including size scaling, format conversion, and watermark overlay, and ensures data integrity through a stream fingerprint verification algorithm.
[0039] The system intercepts dangerous functions through a syntax sandbox, protects cells containing expressions using cell locking technology, records formula modification event chains, and restores the system to the most recent valid snapshot via a version rollback when illegal tampering is detected.
[0040] This invention also provides a customized report generation device for a SaaS system based on dynamic template configuration, comprising:
[0041] The first acquisition module is used to acquire customized visual report templates for decoupling business data;
[0042] The first generation module is used to edit the report template based on a preset editor and generate a template configuration file.
[0043] The second generation module is used to parse the structured markers in the template configuration file and generate a metadata description file;
[0044] The second acquisition module is used to query the business database through a unified data interface according to the data requirements defined in the metadata description file, and to acquire and assemble customized business data corresponding to the tenant ID.
[0045] The third generation module is used to control the rendering process based on the customized business data through a dynamic position calculation algorithm, and dynamically fill the data into the corresponding position of the report template to generate a customized report.
[0046] The present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the above-described method for generating customized reports for a SaaS system based on dynamic template configuration.
[0047] The present invention also provides a computer storage medium storing a computer program that, when executed by a processor, implements the above-described method for generating customized reports for a SaaS system based on dynamic template configuration.
[0048] This invention provides a method for generating customized reports for SaaS systems based on dynamic template configuration. By introducing visual report templates and metadata description files, it successfully decouples report format definitions from business logic and data acquisition. Changes in tenant format requirements are limited to the template and metadata level, eliminating the need to modify, compile, and deploy any backend code, thus reducing system maintenance workload. Simultaneously, thanks to the decoupled design of a unified data interface that dynamically constructs query statements based on metadata, system functionality is completely decoupled from tenant requirements when new tenants join or existing tenants add report requests. No new code needs to be written; only templates designed according to requirements are required, and the system can automatically adapt, reducing the cost of new tenant integration and providing strong architectural support for the rapid scaling of SaaS platforms. Furthermore, this invention decouples the processing requirements for elements such as images and QR codes from business code by defining standardized structured markers, and these are standardized and pipelined by a dedicated hybrid rendering engine. This invention decouples data isolation strategies from scattered business code and centrally implements them at the unified data interface architectural layer. This interface enforces tenant ID filtering conditions when dynamically constructing SQL, making data isolation an automatically executed, business-independent architectural security feature. This fundamentally eliminates the risk of data leakage that might arise from coupling with business logic, enhancing system security and reliability. Finally, the dynamic location estimation algorithm is decoupled from business data, enabling layout prediction and adjustment based solely on metadata. Combined with efficient technologies such as zero-copy processing chains, this achieves architectural decoupling in report rendering. Not only is the functionality clear and easy to maintain, but it also significantly outperforms traditional coupled solutions, effectively improving rendering speed and perfectly supporting enterprise-level applications. Attached Figure Description
[0049] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0050] Figure 1 This is a flowchart of the method for generating customized reports for a SaaS system based on dynamic template configuration according to the first embodiment of the present invention;
[0051] Figure 2 This is a schematic diagram of the management interface of the visual report template of the present invention;
[0052] Figure 3 For Figure 2 A diagram showing the selection of the corresponding template on the interface;
[0053] Figure 4 This is a detailed flowchart of S12 in the first embodiment of the present invention;
[0054] Figure 5 This is one of the detailed flowcharts of S13 in the first embodiment of the present invention;
[0055] Figure 6 This is one of the detailed flowcharts of S14 in the first embodiment of the present invention;
[0056] Figure 7 This is one of the detailed flowcharts of S15 in the first embodiment of the present invention;
[0057] Figure 8 For corresponding Figure 2 A screenshot of the interface for a customized report;
[0058] Figure 9 A structural block diagram of the SAAS system customized report generation device based on dynamic template configuration according to the second embodiment of the present invention;
[0059] Figure 10 This is a schematic diagram of the internal structure of a computer according to another embodiment of the present invention. Detailed Implementation
[0060] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Well-known modules, units, and their connections, links, communications, or operations are not shown or described in detail. Furthermore, the described features, architectures, or functions can be combined in any way in one or more embodiments. Those skilled in the art should understand that the various embodiments described below are for illustrative purposes only and are not intended to limit the scope of protection of the present invention. It is also readily understood that the modules, units, or processing methods in the various embodiments described herein and shown in the accompanying drawings can be combined and designed in various different configurations. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0061] First embodiment:
[0062] Please refer to Figures 1 to 9 As shown, this embodiment of the invention discloses a method for generating multi-tenant reports for a SaaS system based on dynamic template configuration, including S11-S15, wherein:
[0063] S11, obtain a customized visual report template for decoupling business data.
[0064] Please refer to Figure 2 The image shows the management interface of the visual report template (public template) of this invention. Tenants can select the corresponding visual report template, download or delete their own template (My Templates).
[0065] In this step, for example, tenants can access the online system and select or design their own report templates from the template library. The template can be an Excel file containing pre-defined table styles, header rows, total rows, and other fixed elements. Tenants can then personalize the design based on this template, achieving complete decoupling of business data from the presentation format.
[0066] Please refer to Figure 3 As shown, users can enter the template management and editing interface by selecting the corresponding template. In this embodiment, the report template comes with a preset editor.
[0067] S12, edit the report template based on the preset editor to generate a template configuration file.
[0068] In this embodiment, the preset editor is provided as a preferred option rather than a limitation. Please refer to [reference needed] in this embodiment. Figure 4 As shown, this step S12 includes S121-S123, wherein:
[0069] S121, based on the tenant's first input operation to the preset editor (such as text / voice / script input), insert structured markers into the cells of the report template. The markers include field markers (such as {{sales_total}}, total sales), image markers (such as {@product_image}, product image), and coded graphic markers (such as {#order_qrcode}, QR code).
[0070] S122, based on the tenant's second input operation on the preset editor (such as mouse drag to select an area or text input), determine the dynamic area boundary and mark the area that needs to be dynamically expanded according to the amount of data;
[0071] S123, at least based on the structured identifier and dynamic region boundary, generate a template configuration file (which may be a template configuration snapshot) and store it in a multi-tenant isolated cloud storage space.
[0072] Steps S121-S123 above significantly reduce the configuration threshold for tenants by clearly defining the specific process of inserting structured markers and determining dynamic area boundaries based on a preset editor to generate template configuration files. Tenants do not need to have coding knowledge; they can complete the customization of report templates simply by performing input operations in the preset editor (such as inserting markers and defining dynamic areas). Compared with the traditional solution that requires developers to write thousands of lines of code, configuration efficiency is effectively improved, and the time for building new tenant report templates is effectively shortened. At the same time, the categorized insertion of structured markers (field / image / encoded graphic markers) can clearly distinguish the presentation requirements of different types of data. The manual confirmation of dynamic area boundaries can avoid the system misjudging the range of dynamic data and reduce the report misalignment problem caused by marker confusion or ambiguous area definition during subsequent rendering. In addition, the above steps lay the foundation for multi-tenant isolation in S1221-S123. Subsequently, the template configuration files generated in this step can be associated with tenant IDs to achieve isolated storage. The clear configuration elements (markers, dynamic areas) also make template reuse between tenants more convenient, while avoiding mutual interference between different tenant configurations, taking into account the standardization and personalization needs of SaaS systems.
[0073] S13, parse the structured tags in the template configuration file and generate a metadata description file.
[0074] As a preferred option and not a limitation, in this embodiment, please refer to... Figure 5 As shown, this step S13 includes S131-S134, wherein:
[0075] S131, based on a predefined semantic rule base and mapping relationship, perform pattern matching on the field names in the field identifier to determine the data type and validation rules corresponding to the matching results; for example, if the field name contains "amount", it will automatically be assigned the attributes "type":"currency" and "validation":"positive".
[0076] S132 assigns an optimized default fault tolerance level to the type of the encoded graphic marker; for example, it automatically sets "error_correction":"H" for QR code markers.
[0077] S133, calculate the maximum size constraint based on the size of the cell containing the image marker and the layout of the surrounding cells; for example, automatically set "max_dimension":"500x500" based on a cell width of 200 pixels.
[0078] S134, intelligently determine the expansion direction of the dynamic area based on the position context of the grouping marker in the report template; if the marker is located in the table header row, it is determined to be vertical expansion ("expand_direction":"vertical").
[0079] For example, when a tenant's (tenant_id:"T001") template configuration file contains "Total Sales (currency type, must be positive)", "Product Image (maximum size 500x500)" and a dynamic data area that extends vertically downwards starting from the 5th row and 2nd column, the system will dynamically generate the following JSON-LD metadata description file, with the following structure:
[0080] {
[0081] "tenant_id":"T001",
[0082] "fields":[
[0083] {"name":"sales_total","type":"currency","validation":"positive"}
[0084] ],
[0085] "media":[
[0086] {"name":"product_image","type":"image","max_dimension":"500x500"},
[0087] {"name":"product_qrcode","type":"qrcode","error_correction":"H"}
[0088] ],
[0089] "dynamic_regions":[
[0090] {"start_row":5,"start_col":2,"expand_direction":"vertical"} ]
[0092] }
[0093] Among them, L (Low, approximately 7% fault tolerance), M (Medium, approximately 15% fault tolerance), Q (Quartile, approximately 25% fault tolerance), and H (High, approximately 30% fault tolerance).
[0094] Steps S131-S134 above perform pattern matching on field markers based on a semantic rule base and determine data types and validation rules. This can filter invalid or erroneous fields in advance (e.g., directly prompting if a field of the corresponding data type cannot be matched), avoiding null values or incorrect data filling due to field mismatches during subsequent data queries, thus improving the accuracy of report data. Secondly, steps S131-S134 above assign an optimized default fault tolerance level to the coded graphic markers (e.g., automatically adapting the QR code ECC fault tolerance level according to the tenant's business scenario), which can ensure the recognition success rate of coded graphics in different printing and scanning scenarios, effectively reducing the recognition failure rate compared to a fixed fault tolerance level solution. Thirdly, calculating the maximum size constraint of image markers based on cell size and surrounding layout can prevent images from obscuring other report elements or exceeding cell boundaries after insertion, eliminating the need for tenants to manually adjust image size. Finally, combining the context of group marker positions to determine the dynamic area expansion direction can ensure that dynamic data (e.g., grouped statistical results) expands in a reasonable direction (vertical / horizontal), avoiding report layout chaos caused by incorrect expansion direction, especially suitable for complex multi-group report scenarios, improving the stability of report generation.
[0095] S14. Based on the data requirements defined in the metadata description file, query the business database through the unified data interface to obtain and assemble customized business data corresponding to the tenant ID.
[0096] As a preferred option and not a limitation, in this embodiment, please refer to... Figure 6 As shown, this step S14 includes S141-S145, wherein:
[0097] S141, parse the metadata description file and extract the list of field names and data grouping instructions defined therein;
[0098] S142, Map and verify the list of field names with the predefined whitelist of field names to generate a secure set of database query field names;
[0099] S143, dynamically construct an SQL statement, wherein the SELECT clause of the SQL statement is based on the set of query field names, the WHERE clause contains a filtering statement based on the current tenant ID (such as WHERE tenant_id = 'T001'), and the GROUP BY clause is generated based on the data grouping instruction;
[0100] S144, Execute the SQL statement to obtain the original dataset from the business database;
[0101] S145, the original dataset is encapsulated according to the field structure defined in the metadata description file and assembled into a customized business data object in key-value pair form for use by the rendering engine.
[0102] Steps S141-S145 above generate a set of secure query field names through field name whitelist mapping and verification, which can intercept illegal field query requests (such as tenants attempting to query sensitive fields beyond their permissions). At the same time, the tenant ID filter is forcibly added to the WHERE clause of the SQL statement, fundamentally preventing unauthorized access to data between multiple tenants, meeting the data isolation requirements of SaaS systems, and reducing the risk of data leakage to near zero. In addition, the dynamically constructed SQL statements strictly follow the field list and grouping instructions of the metadata description file, avoiding syntax errors or logical deviations when manually writing SQL. The original dataset is encapsulated into key-value pairs of business data objects according to the field structure, which can directly adapt to the call requirements of subsequent rendering engines, reducing errors in the data format conversion process, and achieving a data encapsulation accuracy of 100%. Finally, steps S141-S145 above unify the data interface and automate the SQL construction and data encapsulation process, replacing the traditional method of manually connecting to data sources and processing data formats. The data acquisition and assembly time is shortened from tens of minutes to minutes, especially suitable for scenarios with millions of data volumes, significantly improving the efficiency of report generation.
[0103] S15, at least based on the customized business data, the rendering process is controlled by a dynamic position calculation algorithm to dynamically fill the data into the corresponding position of the report template to generate a customized report.
[0104] Specifically, this step involves: based on the metadata description file and the customized business data, dynamically filling the data into the corresponding positions of the report template using a hybrid rendering engine; wherein, the filling process is controlled by a dynamic position calculation algorithm to automatically adjust the template layout according to the amount of data and generate a customized report.
[0105] like Figure 7 As shown, this corresponds to Figure 3 Customized report for "Page Production Order 4" in the middle.
[0106] As a preferred option and not a limitation, in this embodiment, please refer to... Figure 8 As shown, this step S15 includes S151-S153, wherein:
[0107] S151, the dynamic position estimation algorithm performs the following operations:
[0108] Based on the field types in the metadata description file, the dataset in the dynamic area is intelligently grouped, and the number of rows required for each group is predicted.
[0109] Based on the predicted row count, perform a matrix splitting operation on cells marked as dynamic regions to expand the physical space and automatically inherit the styles of the original template;
[0110] Create a report element dependency graph, calculate the displacement caused by dynamic area expansion, and translate and rewrite the coordinates of all affected downstream cells, charts, and formulas.
[0111] S152, the hybrid rendering engine performs the following operations:
[0112] Recognize nested expression syntax (such as {{=SUM({{sales}}*{{tax_rate}})}}) in field markers, construct an abstract syntax tree using a recursive descent parsing algorithm, and perform depth-first traversal calculations;
[0113] The system intercepts requests for images or encoded graphic markers, performs a zero-copy processing chain on the binary stream including size scaling, format conversion, and watermark overlay, and ensures data integrity through the SHA256 stream fingerprint verification algorithm.
[0114] The system intercepts dangerous functions through a syntax sandbox, protects cells containing expressions using cell locking techniques, and records the event chain of formula modifications.
[0115] S153, based on the coordinate information provided by the metadata description file, accurately fills the processed data into the specified position in the template to generate the final report.
[0116] The hybrid rendering engine can accurately identify the matching relationship between metadata and business data, ensuring that different types of data (text, values, images, etc.) are accurately filled into the corresponding positions in the template, avoiding data errors and omissions, and improving the report filling accuracy to over 99%. The dynamic position calculation algorithm automatically adjusts the template layout according to the data volume, solving the problems of element misalignment and content occlusion that occur when the data volume fluctuates (such as the number of data rows in the dynamic area exceeds expectations) in traditional fixed templates. It is especially suitable for multi-group and large-volume report scenarios, and the report layout integrity reaches 100%. This embodiment deeply coordinates data preparation and rendering layout. Compared with the solution of separating data and layout processing, it reduces the time and errors in intermediate data transmission links, improves the overall report generation efficiency by 50%, and the generated customized reports can perfectly adapt to the tenant's business scenarios (such as the report format requirements of different industries), improving the tenant's user experience.
[0117] This invention provides a method for generating customized reports for SaaS systems based on dynamic template configuration. By introducing visual report templates and metadata description files, it successfully decouples report format definitions from business logic and data acquisition. Changes in tenant format requirements are limited to the template and metadata level, eliminating the need to modify, compile, and deploy any backend code, thus reducing system maintenance workload. Simultaneously, thanks to the decoupled design of a unified data interface that dynamically constructs query statements based on metadata, system functionality is completely decoupled from tenant requirements when new tenants join or existing tenants add report requests. No new code needs to be written; only templates designed according to requirements are required, and the system can automatically adapt, reducing the cost of new tenant integration and providing strong architectural support for the rapid scaling of SaaS platforms. Furthermore, this invention decouples the processing requirements for elements such as images and QR codes from business code by defining standardized structured markers, and these are standardized and pipelined by a dedicated hybrid rendering engine. This invention decouples data isolation strategies from scattered business code and centrally implements them at the unified data interface architectural layer. This interface enforces tenant ID filtering conditions when dynamically constructing SQL, making data isolation an automatically executed, business-independent architectural security feature. This fundamentally eliminates the risk of data leakage that might arise from coupling with business logic, enhancing system security and reliability. Finally, the dynamic location estimation algorithm is decoupled from business data, enabling layout prediction and adjustment based solely on metadata. Combined with efficient technologies such as zero-copy processing chains, this achieves architectural decoupling in report rendering. Not only is the functionality clear and easy to maintain, but it also significantly outperforms traditional coupled solutions, effectively improving rendering speed and perfectly supporting enterprise-level applications.
[0118] Second embodiment:
[0119] Please refer to Figure 9 As shown, the present invention also provides a customized report generation device 100 for a SaaS system based on dynamic template configuration, comprising:
[0120] The first acquisition module 110 is used to acquire a customized visual report template for achieving business data decoupling;
[0121] The first generation module 120 is used to edit the report template based on a preset editor and generate a template configuration file.
[0122] The second generation module 130 is used to parse the structured markers in the template configuration file and generate a metadata description file;
[0123] The second acquisition module 140 is used to query the business database through a unified data interface according to the data requirements defined in the metadata description file, and to acquire and assemble customized business data corresponding to the tenant ID.
[0124] The third generation module 150 is used to dynamically fill the data into the corresponding position of the report template to generate a customized report, based at least on the customized business data, by controlling the rendering process through a dynamic position calculation algorithm.
[0125] The modules in this embodiment are the same as the corresponding steps in the first embodiment described above, and will not be repeated here.
[0126] This invention provides a method for generating customized reports for SaaS systems based on dynamic template configuration. By introducing visual report templates and metadata description files, it successfully decouples report format definitions from business logic and data acquisition. Changes in tenant format requirements are limited to the template and metadata level, eliminating the need to modify, compile, and deploy any backend code, thus reducing system maintenance workload. Simultaneously, thanks to the decoupled design of a unified data interface that dynamically constructs query statements based on metadata, system functionality is completely decoupled from tenant requirements when new tenants join or existing tenants add report requests. No new code needs to be written; only templates designed according to requirements are required, and the system can automatically adapt, reducing the cost of new tenant integration and providing strong architectural support for the rapid scaling of SaaS platforms. Furthermore, this invention decouples the processing requirements for elements such as images and QR codes from business code by defining standardized structured markers, and these are standardized and pipelined by a dedicated hybrid rendering engine. This invention decouples data isolation strategies from scattered business code and centrally implements them at the unified data interface architectural layer. This interface enforces tenant ID filtering conditions when dynamically constructing SQL, making data isolation an automatically executed, business-independent architectural security feature. This fundamentally eliminates the risk of data leakage that might arise from coupling with business logic, enhancing system security and reliability. Finally, the dynamic location estimation algorithm is decoupled from business data, enabling layout prediction and adjustment based solely on metadata. Combined with efficient technologies such as zero-copy processing chains, this achieves architectural decoupling in report rendering. Not only is the functionality clear and easy to maintain, but it also significantly outperforms traditional coupled solutions, effectively improving rendering speed and perfectly supporting enterprise-level applications.
[0127] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional modules is used as an example. In practical 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. The specific working process of the system, device, and unit described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0128] This invention also provides a computer storage medium storing a computer program that, when executed by a processor, implements the method for generating customized reports for a SaaS system based on dynamic template configuration as described in the above embodiments.
[0129] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the customized report generation method for SaaS systems based on dynamic template configuration described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0130] Alternatively, if the integrated units of this invention are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this invention, or the parts that contribute to related technologies, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, terminal, or network device, etc.) to execute all or part of the methods of the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, RAM, ROM, magnetic disks, or optical disks.
[0131] Corresponding to the computer storage medium described above, one embodiment also provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the SaaS system customized report generation method based on dynamic template configuration as described in the above embodiments.
[0132] This computer device can be a terminal, and its internal structure diagram can be as follows: Figure 10 As shown, the computer device includes a processor, memory, network interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used to communicate with external terminals via a network connection. When the computer program is executed by the processor, it implements a method for generating customized reports for a SaaS system based on dynamic template configuration. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad mounted on the computer device casing, or an external keyboard, touchpad, or mouse.
[0133] This invention provides a method for generating customized reports for SaaS systems based on dynamic template configuration. By introducing visual report templates and metadata description files, it successfully decouples report format definitions from business logic and data acquisition. Changes in tenant format requirements are limited to the template and metadata level, eliminating the need to modify, compile, and deploy any backend code, thus reducing system maintenance workload. Simultaneously, thanks to the decoupled design of a unified data interface that dynamically constructs query statements based on metadata, system functionality is completely decoupled from tenant requirements when new tenants join or existing tenants add report requests. No new code needs to be written; only templates designed according to requirements are required, and the system can automatically adapt, reducing the cost of new tenant integration and providing strong architectural support for the rapid scaling of SaaS platforms. Furthermore, this invention decouples the processing requirements for elements such as images and QR codes from business code by defining standardized structured markers, and these are standardized and pipelined by a dedicated hybrid rendering engine. This invention decouples data isolation strategies from scattered business code and centrally implements them at the unified data interface architectural layer. This interface enforces tenant ID filtering conditions when dynamically constructing SQL, making data isolation an automatically executed, business-independent architectural security feature. This fundamentally eliminates the risk of data leakage that might arise from coupling with business logic, enhancing system security and reliability. Finally, the dynamic location estimation algorithm is decoupled from business data, enabling layout prediction and adjustment based solely on metadata. Combined with efficient technologies such as zero-copy processing chains, this achieves architectural decoupling in report rendering. Not only is the functionality clear and easy to maintain, but it also significantly outperforms traditional coupled solutions, effectively improving rendering speed and perfectly supporting enterprise-level applications.
[0134] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0135] The above embodiments merely illustrate several implementation methods of the present invention, and their descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these all fall within the protection scope of the present invention. Therefore, the protection scope of this invention patent should be determined by the appended claims.
Claims
1. A method for generating customized reports for a SaaS system based on dynamic template configuration, characterized in that, include: Obtain customized visual report templates for decoupling business data; The report template is edited using a preset editor to generate a template configuration file; Parse the structured tags in the template configuration file to generate a metadata description file; Based on the data requirements defined in the metadata description file, the business database is queried through the unified data interface to obtain and assemble customized business data corresponding to the tenant ID; Based at least on the customized business data, the rendering process is controlled by a dynamic position calculation algorithm to dynamically fill the data into the corresponding position of the report template to generate a customized report. The structured markers in the parsed template configuration file are used to generate a metadata description file, including: Control the metadata parser to perform the following operations: Based on a predefined semantic rule base and mapping relationship, pattern matching is performed on the field names in the field identifier to determine the data type and validation rules corresponding to the matching results; Based on the type of the encoded graphic marker, an optimized default fault tolerance level is assigned to it; Based on the size of the cell containing the image marker and the layout of the surrounding cells, calculate its maximum size constraint; Based on the positional context of the grouping marker in the report template, the expansion direction of its dynamic area is intelligently determined; The step of querying the business database through a unified data interface to obtain and assemble customized business data corresponding to the tenant ID, based on the data requirements defined in the metadata description file, includes: Parse the metadata description file and extract the list of field names and data grouping instructions defined therein; The list of field names is mapped and validated against a predefined whitelist of field names to generate a secure set of database query field names. The SQL statement is dynamically constructed, wherein the select clause of the SQL statement is based on the set of query field names, the where clause contains a filtering statement based on the current tenant ID, and the group by clause is generated based on the data grouping instruction; Execute the SQL statement to retrieve the original dataset from the business database; The original dataset is encapsulated according to the field structure defined in the metadata description file and assembled into a customized business data object in key-value pair form for use by the rendering engine.
2. The method according to claim 1, characterized in that, The step of editing the report template based on a preset editor to generate a template configuration file includes: Based on the tenant's first input operation to the preset editor, structured markers are inserted into the cells of the report template. These markers include field markers, image markers, and coded graphic markers. The dynamic region boundary is determined based on the tenant's second input operation to the preset editor; A template configuration file is generated based at least on the structured markers and dynamic region boundaries.
3. The method as described in claim 1, characterized in that, The process of dynamically filling data into the corresponding positions of the report template to generate a customized report, based at least on the customized business data and using a dynamic position calculation algorithm, specifically involves: Based on the metadata description file and the customized business data, the data is dynamically filled into the corresponding positions of the report template through a hybrid rendering engine; wherein, the filling process is controlled by a dynamic position calculation algorithm to automatically adjust the template layout according to the amount of data and generate a customized report.
4. The method as described in claim 3, characterized in that, The dynamic position estimation algorithm includes: Based on the field types in the metadata description file, the dataset in the dynamic area is intelligently grouped, and the number of rows required for each group is predicted. Based on the predicted row count, perform a matrix splitting operation on cells marked as dynamic regions to expand the physical space and automatically inherit the styles of the original template; Create a report element dependency graph, calculate the displacement caused by dynamic area expansion, and translate and rewrite the coordinates of all affected downstream cells, charts, and formulas to avoid layout conflicts.
5. The method as described in claim 4, characterized in that, The hybrid rendering engine is used for: It identifies nested expression syntax in field markers, constructs an abstract syntax tree through a recursive descent parsing algorithm and performs depth-first traversal calculations, while simultaneously establishing a real-time listener for expression fields; The system intercepts requests for images or encoded graphic markers, performs a zero-copy processing chain on the binary stream including size scaling, format conversion, and watermark overlay, and ensures data integrity through a stream fingerprint verification algorithm. The system intercepts dangerous functions through a syntax sandbox, protects cells containing expressions using cell locking technology, records formula modification event chains, and restores the system to the most recent valid snapshot via a version rollback when illegal tampering is detected.
6. A customized report generation device for a SaaS system based on dynamic template configuration, characterized in that, include: The first acquisition module is used to acquire customized visual report templates for decoupling business data; The first generation module is used to edit the report template based on a preset editor and generate a template configuration file. The second generation module is used to parse the structured markers in the template configuration file and generate a metadata description file; The second acquisition module is used to query the business database through a unified data interface according to the data requirements defined in the metadata description file, and to acquire and assemble customized business data corresponding to the tenant ID. The third generation module is used to control the rendering process based on the customized business data through a dynamic position calculation algorithm, and dynamically fill the data into the corresponding position of the report template to generate a customized report. The structured markers in the parsed template configuration file are used to generate a metadata description file, including: Control the metadata parser to perform the following operations: Based on a predefined semantic rule base and mapping relationship, pattern matching is performed on the field names in the field identifier to determine the data type and validation rules corresponding to the matching results; Based on the type of the encoded graphic marker, an optimized default fault tolerance level is assigned to it; Based on the size of the cell containing the image marker and the layout of the surrounding cells, calculate its maximum size constraint; Based on the positional context of the grouping marker in the report template, the expansion direction of its dynamic area is intelligently determined; The step of querying the business database through a unified data interface to obtain and assemble customized business data corresponding to the tenant ID, based on the data requirements defined in the metadata description file, includes: Parse the metadata description file and extract the list of field names and data grouping instructions defined therein; The list of field names is mapped and validated against a predefined whitelist of field names to generate a secure set of database query field names. The SQL statement is dynamically constructed, wherein the select clause of the SQL statement is based on the set of query field names, the where clause contains a filtering statement based on the current tenant ID, and the group by clause is generated based on the data grouping instruction; Execute the SQL statement to retrieve the original dataset from the business database; The original dataset is encapsulated according to the field structure defined in the metadata description file and assembled into a customized business data object in key-value pair form for use by the rendering engine.
7. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method for generating customized reports for a SaaS system based on dynamic template configuration as described in any one of claims 1 to 5.
8. A computer storage medium having a computer program stored thereon, characterized in that, When executed by the processor, the program implements the method for generating customized reports for a SaaS system based on dynamic template configuration as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Report filling and displaying method based on Excel template and front-end interaction
CN116611412A
Report generation method and system based on visual configuration report template
CN119718290A