Dynamic generation method of comprehensive report based on SQL (Structured Query Language) statement

By optimizing SQL query sequences through AI technology and Monte Carlo tree search, the problem of rigid report generation in existing technologies has been solved, enabling dynamic adaptation of report content and matching of user preferences to generate high-quality, customized comprehensive reports.

CN121387933APending Publication Date: 2026-01-23GUANGZHOU WEIYI SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511560548.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-29
Publication Date
2026-01-23

AI Technical Summary

Technical Problem

Existing SQL-based report generation technologies lack the ability to intelligently perceive the state of data and cannot dynamically adjust the analysis dimensions and depth according to real-time data characteristics. This results in rigid report content, a single analytical perspective, and difficulty in adapting to data changes and complex analysis needs.

Method used

By employing AI technology combined with multi-model collaborative optimization and Monte Carlo tree search, a paragraph relationship graph is constructed by parsing the report template, generating semantically rich paragraph representation vectors. Multi-angle candidate SQLs are generated in parallel for cross-review and debate. Finally, the globally optimal SQL query execution sequence is searched through MCTS to achieve dynamic adaptation between report content and data status.

Benefits of technology

It enhances the flexibility, data consistency, and narrative coherence of reports, generating higher-quality, customized reports that meet user preferences, and ensuring the reliability and efficiency of the generation process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121387933A_ABST
    Figure CN121387933A_ABST
Patent Text Reader

Abstract

The invention relates to an SQL statement-based comprehensive report dynamic generation method, and belongs to the technical field of comprehensive report generation. The method comprises the following steps: constructing a paragraph relation graph through an analysis report template, determining an optimal paragraph generation sequence, and modeling a multi-dimensional context by using a deep learning model to generate a paragraph representation vector; generating multi-angle candidate SQL (Structured Query Language) in parallel through multiple models, optimizing through cross review and debate, and searching a globally optimal SQL query execution sequence by utilizing an MCTS (Multi-Model Transport Stream) artificial intelligence algorithm; executing query according to the optimal SQL query execution sequence to generate paragraph content; paragraph contents are intelligently assembled according to templates, transition sentences are inserted, the format is adjusted, and a complete and coherent customized report conforming to user preferences is output. According to the method, context awareness and a dynamic SQL generation technology are realized through an AI technology, and dynamic adaptation of report contents and data states is realized in combination with multi-model collaborative optimization and Monte Carlo tree search.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the technical field of comprehensive report generation, and particularly relates to a comprehensive report dynamic generation method based on SQL statements. BACKGROUND

[0002] In the field of information system management, it is often necessary to generate fixed-format comprehensive report documents based on various dynamic business data. At present, the automatic report generation technology based on SQL (Structured Query Language) has been widely used in the fields of data analysis and business intelligence. In order to maintain the real-time and accuracy of the report content, the staff must repeatedly perform complex data statistics and SQL query work, which not only involves complex operations such as multi-table association and aggregation calculation, but also faces the dynamic changes of data dependency relationship and business logic, becoming the bottleneck restricting the improvement of work efficiency.

[0003] The existing report generation technology based on SQL mainly adopts the method of predefining query templates, which can realize basic data extraction and document output, but does not involve the core problem of how to dynamically organize and analyze the content according to the real-time data characteristics and optimize the query logic. The existing technology lacks intelligent perception ability of data state, and cannot automatically adjust the analysis dimension and depth according to the data distribution characteristics, resulting in rigid report content and single analysis perspective, which is difficult to adapt to data changes and complex analysis requirements. Therefore, it is urgent to introduce artificial intelligence (AI) technology to enable the report generation process to have the ability of dynamic perception, intelligent decision and autonomous optimization. SUMMARY

[0004] In order to solve the above problems existing in the prior art, the application provides a comprehensive report dynamic generation method based on SQL statements, which realizes context perception and dynamic SQL generation technology through AI technology, and realizes dynamic adaptation of report content and data state by combining multi-model collaborative optimization and Monte Carlo tree search.

[0005] The object of the application can be achieved by the following technical solutions: The disclosure provides a comprehensive report dynamic generation method based on SQL statements, comprising the following steps: S1, report structure analysis: constructing a paragraph relationship graph by analyzing a report template, identifying dependency relationships to determine the optimal paragraph generation sequence, and modeling multi-dimensional context to generate a paragraph representation vector rich in semantics; S2, dynamic SQL candidate generation: generating multi-angle candidate SQL through multi-model parallel based on the paragraph representation vector, optimizing through cross review and debate, and searching for the globally optimal SQL query execution sequence by using MCTS; S3, comprehensive report assembly and output: execute the query generation paragraph content according to the optimal SQL query execution sequence, and monitor and handle exceptions in real time; Assemble the paragraph content according to the template, insert the transition sentence and adjust the format, and output the complete, coherent and customized report according to the user's preference; The report structure is parsed, including the following steps: S11, paragraph relationship graph construction: the target report template is structurally parsed and split into multiple independent paragraphs, the structured paragraph definition table is obtained by identifying paragraph boundaries, type markers and format requirements, and the paragraph relationship graph is constructed by analyzing the dependency relationship between paragraphs; S12, multi-dimensional context relationship modeling: construct a multi-dimensional context environment for each paragraph to be generated, extract historical generated content, database schema structure, user preference settings and business rule constraints, and use relationship perception encoder to analyze and fuse the extracted context elements in depth, generating paragraph representation vectors rich in semantic information.

[0006] Further, the paragraph definition table includes paragraph ID, type, content requirements and format specifications, and the constructed paragraph relationship graph includes: Dependency relationship identification: Data dependency relationship: by analyzing the data requirements and outputs of the paragraph, the flow direction of data from the source paragraph to the target paragraph is determined; Logical dependency relationship: identify the conditional relationship between premise paragraphs and inference paragraphs, and define strict generation sequence constraints; Semantic association relationship: identify the paragraph sequence that needs to be closely connected in content, and the paragraph set that must maintain consistent terminology, definition and conclusion reference.

[0007] Further, the constructed paragraph relationship graph further includes: Relationship graph construction: Each paragraph is abstracted as a node containing paragraph ID, type, content requirements and format specifications, and directed edges are established between nodes according to data dependency relationship, explicitly representing data supply, logical premise and semantic association information; By calculating the in-degree and out-degree indicators of the nodes, the network structure is quantitatively analyzed, the key path and bottleneck node in the network are identified, and the paragraph generation sequence strategy is obtained.

[0008] Further, the dynamic SQL candidate generation includes the following steps: S21, multi-model candidate set generation: for each paragraph requirement, input the paragraph representation vector to start multiple generation engines to generate candidate SQL from different angles in parallel, cross-review and debate the generated candidate SQL through different specialized language models, identify the advantages and disadvantages of each through viewpoint collision, and modify and improve them; S22, searching for an optimal query sequence: modeling report generation as a sequential decision problem, building a state space based on candidate SQL, defining states, actions, and transition functions, running MCTS search, finding the optimal SQL query execution sequence based on the paragraph relationship graph through selection-expansion-simulation-backtracking.

[0009] Further, the different angles include basic data extraction, comparative analysis, trend prediction, and deep drilling; The parallel generation of candidate SQL includes: Based on the semantic type of the paragraph and user preferences, configure multiple generation angle strategies, initialize multiple dedicated SQL generation engines in parallel, distribute context-rich paragraph representation vectors and database schema information to each engine, and inject data permissions and business rules for collaborative generation; Standardize and annotate the output of the diversified candidate SQL, and output a structured candidate set with generation angles, confidence scores, and estimated execution costs.

[0010] Further, the cross-review and debate includes: Initialize the debate environment, assign review roles to different specialized language models and develop debate rules, perform multiple rounds of cross-review, each model first independently evaluates the candidate SQL and generates a review report, then through opinion exchange and focus debate, the controversial points are discussed in depth to build consensus; Based on the debate insights, the SQL with defects is optimized and corrected or triggered to regenerate, and finally the candidate set is ranked comprehensively through a weighted scoring model, and an optimized SQL set is output.

[0011] Further, the MCTS search includes: Perform structured Monte Carlo tree search on the constructed state space, starting from the root node, balancing value estimation and exploration degree to select branches, until reaching an expandable node; Expand the expandable node, use the fast strategy to simulate the entire report generation from the state to get the estimated global reward, propagate the global reward back along the search path, update the value estimates of all passing state-action pairs, through a large number of "selection-expansion-simulation-backtracking" cycles, finally converge to a paragraph with the optimal value in the global perspective, and get the SQL generation sequence.

[0012] Further, the comprehensive report assembly and output includes the following steps: S31, executing and fault-tolerant processing: executing the progressive content generation according to the optimal SQL query execution sequence to execute each paragraph query to generate paragraph content, monitoring the execution state in real time and maintaining data consistency, establishing a multi-layer abnormality detection and processing mechanism, including automatic repair and rollback strategies in the case of SQL execution abnormality, result quality not meeting the standard and coherence conflict; S32, content splicing output: intelligently assembling the generated paragraph content according to the document template, inserting transition sentences and unifying data presentation formats, and performing personalized adjustment on the final report based on user preferences.

[0013] Further, the progressive content generation comprises: By executing the selected SQL queries of each paragraph in sequence by the execution engine, the execution state and result of each query are monitored in real time during the execution process, and the generated content is spliced into the report in real time, while the shared context is dynamically updated.

[0014] Further, the multi-layer abnormality detection and processing mechanism comprises: By continuously detecting execution abnormalities, result quality deviations or logical coherence conflicts through predefined validators, once the threshold is triggered, automatic repair is first attempted, and if the repair fails, the preset rollback strategy is activated.

[0015] The beneficial effects of the present application are: The present application realizes the intelligentization and adaptive optimization of report generation by dynamically generating SQL query sequences based on AI technology, combining context perception models and Monte Carlo tree search; the method improves the flexibility, data consistency and narrative coherence of the report, ensures the query quality through multi-model parallel generation and cross-review, and finds the globally optimal paragraph combination sequence using MCTS search, thereby generating a customized report with higher quality and user preferences, while the reliability of the generation process is ensured through the fault-tolerant mechanism. BRIEF DESCRIPTION OF DRAWINGS

[0016] In order to facilitate understanding by those skilled in the art, the present application will be further described below with reference to the accompanying drawings.

[0017] Figure 1 A step schematic diagram of a comprehensive report dynamic generation method based on SQL statements provided for an embodiment of the present application; Figure 2 A step schematic diagram of report structure analysis provided for an embodiment of the present application; Figure 3 A step schematic diagram of dynamic SQL candidate generation provided for an embodiment of the present application; Figure 4 A step schematic diagram of comprehensive report assembly and output provided for an embodiment of the present application. DETAILED DESCRIPTION

[0018] To further illustrate the technical means and effects adopted by the present application to achieve the predetermined inventive purpose, the specific embodiments, structures, features and effects according to the present application are described in detail below in combination with the drawings and preferred embodiments.

[0019] The present application is based on the dynamic generation of comprehensive reports based on SQL statements, and adopts "document disassembly + SQL splicing" as the basic framework. SQL (Structured Query Language) is a field-specific programming language designed specifically for managing and operating relational databases. The present embodiment aims to dynamically adjust the query logic according to the data, and to address the problems of lack of flexibility and intelligence in pre-defined SQL. By modeling the report generation as a dynamic structured generation process, each report paragraph can have different generation options (i.e. different SQL queries). Through a context-aware model, it understands which query should be selected at the moment, and through MCTS, it searches for the optimal paragraph combination and order to generate a higher quality report. Specifically, the method for dynamically generating comprehensive reports based on SQL statements is described in detail as follows: The present embodiment provides a method for dynamically generating comprehensive reports based on SQL statements, as shown in Figure 1 The method comprises the following steps: S1, report structure analysis: by analyzing the report template to build a paragraph relationship graph, identify the dependency relationship to determine the optimal paragraph generation sequence, and model the multi-dimensional context to generate a paragraph representation vector rich in semantics, as shown in Figure 2 The method comprises the following steps: S11, paragraph relationship graph construction: the target report template (such as a Word document, JSON configuration or template definition in a database) is structurally parsed and split into multiple independent paragraphs. By identifying paragraph boundaries, type markers and format requirements, a structured paragraph definition table is obtained. Then, by analyzing the dependency relationship between paragraphs, a paragraph relationship graph is constructed. The paragraph definition table includes paragraph ID, type, content requirements and format specifications, etc. The paragraph relationship graph is constructed, including: Dependency relationship identification: Data dependency relationship: by analyzing the data requirements and outputs of the paragraphs, a data lineage graph is constructed to clearly define the flow direction of data from the source paragraph to the target paragraph, for example, the detailed data paragraph must be executed before the summary paragraph that depends on it for aggregation calculation; Logical dependency relationship: identify the conditional relationship between the premise paragraph and the inference paragraph, and define strict generation sequence constraints to ensure the integrity of the argument chain; Semantic relationship: identify the sequence of paragraphs that need to be closely connected in content, as well as the set of paragraphs that must maintain consistent terminology, definitions, and conclusion references.

[0020] Relationship graph construction: Each paragraph is abstracted as a node containing attributes such as paragraph ID, type, content requirements, and format specifications. Directed edges are established between nodes based on data dependency relationships, explicitly representing data supply, logical premises, and semantic association information. By calculating graph theory indicators such as node in-degree and out-degree, the network structure is quantitatively analyzed to identify key paths and bottleneck nodes in the network, resulting in a paragraph generation sequence strategy. The direct output of this analysis is to determine an optimal paragraph generation sequence strategy that must meet all data and logical dependency constraints while minimizing overall waiting time or computational load during generation.

[0021] It should be noted that the report is an organic whole, and paragraphs are not isolated. By explicitly modeling paragraph relationships, the accuracy of data references and the smoothness of narrative logic in the final report are ensured, preventing content inconsistencies or logical gaps. At the same time, based on the relationship graph, the optimal paragraph generation sequence strategy is obtained, and an intelligent scheduling scheme is implemented through a combination of serial and parallel methods, aiming to maximize global generation efficiency.

[0022] S12, multi-dimensional context relationship modeling: construct a multi-dimensional context environment for each paragraph to be generated, extract historical generated content, database schema structure, user preference settings, and business rule constraints, and use relationship-aware encoders (such as graph neural networks) to perform deep analysis and fusion of extracted context elements, generating paragraph representation vectors rich in semantic information.

[0023] Specifically, constructing a multi-dimensional context environment includes: Extract key data and conclusions from generated content, parse table structure and relationships from database schema, read personalized preferences from user configuration, and internalize computational logic and compliance constraints from business rules. The purpose of this step is to collect and digitize all external influencing factors required for the generation process, providing a rich, three-dimensional raw data foundation for subsequent intelligent decision-making, ensuring that the generated content is not isolated, but deeply compatible with the overall report, user needs, and business environment.

[0024] Deep analysis and fusion include: The encoder based on the graph neural network and the attention mechanism is used to perform deep analysis and semantic alignment on heterogeneous information such as historical content, database mode and user preference, to construct a multi-relationship graph that can reveal complex correlations between elements, and finally generate a paragraph representation vector rich in context information. The purpose of this step is to refine the scattered "data raw materials" into a "generative blueprint" with guiding significance, so as to convert complex context information into semantic guidance signals that can be directly and accurately used by the generation engine, thereby fundamentally improving the relevance and accuracy of the generated SQL at the semantic level.

[0025] In this embodiment, the paragraph splitting result itself has no multiple variants, but is a fixed output determined by the template. Since there are dependency relationships (such as data dependency and logical dependency) between paragraphs, the order in which these paragraphs are generated will directly affect the coherence, data consistency and generation efficiency of the report. By constructing a paragraph relationship graph, the dependency relationships are analyzed to determine an optimal paragraph generation sequence strategy.

[0026] S2, dynamic SQL candidate generation: based on the paragraph representation vector, multiple model parallel generation is performed to generate multi-angle candidate SQL, which is optimized through cross review and debate, and then MCTS is used to search for the globally optimal SQL query execution sequence, as shown in Figure 3 The method comprises the following steps: S21, multi-model candidate set generation: for each paragraph requirement, the paragraph representation vector is input to start multiple generation engines to generate candidate SQL from different angles in parallel, and cross review and debate are performed on the generated candidate SQL by different specialized language models (such as AI language models), and the advantages and disadvantages of each are identified through viewpoint collision to modify and improve.

[0027] Different angles include basic data extraction, comparative analysis, trend prediction and deep drilling, etc.; and parallel generation of candidate SQL includes: first, based on the semantic type of the paragraph and the user preference, configure multiple generation angle strategies (such as for analytical paragraphs, generate same period comparison, target comparison query) such as basic data extraction, comparative analysis, trend prediction and deep drilling; then initialize multiple dedicated SQL generation engines in parallel, distribute the paragraph representation vector rich in context and database mode information to each engine, and inject data authority, business rules and other constraint conditions for collaborative generation; finally, standardize the diversified candidate SQL output and add metadata annotations, output a structured candidate set with generation angle, confidence score and estimated execution cost, laying a foundation for subsequent collaborative debate and optimization selection.

[0028] The cross review and debate includes: firstly, initializing a debate environment, assigning review roles such as accuracy, performance, integrity and readability to different specialized language models and formulating debate rules; then performing multiple rounds of cross review, each model first independently evaluates the candidate SQL and generates a review report, and then through opinion exchange and focus debate, the controversial points are discussed in depth to build consensus; based on the debate insight, the system optimizes and corrects the SQL with defects or triggers regeneration, finally through a weighted scoring model, the candidate set is comprehensively ranked, and the optimized SQL set verified by collective wisdom and the precipitated debate knowledge are output, which are used for feedback model improvement.

[0029] It should be noted that a single query perspective may not fully meet the analysis needs of the paragraph. By constructing a candidate query set with rich content and diverse perspectives, users are provided with more comprehensive data insight possibilities, avoiding the one-sidedness and limitations of the report.

[0030] S22, searching for an optimal query sequence: modeling the report generation as a sequential decision problem, constructing a state space based on the candidate SQL, defining states, actions and transition functions, running MCTS (Monte Carlo Tree) search, and finding the optimal SQL query execution sequence based on the paragraph relationship graph through selection-expansion-simulation-backtracking; The state space modeling includes the following steps: Define the "generated paragraph sequence and its quality evaluation" as the state, and "select a specific SQL query for the next paragraph" as the action, to build a complete state space; Integrate the paragraph dependency relationship and constraint conditions from the previous stage to standardize the legal state transition (the paragraph relationship graph is converted into state transition rules), and build a comprehensive value function that integrates content coverage, logical coherence and user preferences, thereby establishing a structured and computable decision model for subsequent search optimization.

[0031] The MCTS search includes the following steps: performing structured Monte Carlo tree search on the constructed state space, starting from the root node (initial state), selecting branches according to the balance between value estimation and exploration, until reaching an expandable node; then expand the node, i.e. perform a new action to generate a new state, and immediately simulate the completion of the entire report generation from this state using a fast strategy to obtain an estimated global reward; finally, propagate this simulated reward back along the search path, update the value estimates of all state-action pairs along the way, and through a large number of "selection-expansion-simulation-backtracking" cycles, finally converge to a paragraph-SQL generation sequence with the optimal value in the global perspective.

[0032] In this embodiment, the complex problem of report generation is transformed into a searchable and optimizable sequence decision-making process. Intelligent search efficiently finds the optimal solution within a vast space of possible combinations, automatically identifying and selecting the SQL execution sequences that are optimal overall in terms of content coverage, coherence, and readability, thus ensuring the overall quality of the final report. Monte Carlo Tree Search (MCTS) is a classic artificial intelligence search algorithm commonly used for sequence decision-making problems (such as game AI), and in this embodiment, it is used to globally optimize the SQL query sequence.

[0033] S3. Comprehensive Report Assembly and Output: The system executes queries according to the optimal SQL query execution sequence to generate paragraph content, and performs real-time monitoring and anomaly handling. The paragraph content is intelligently assembled according to a template, transition sentences are inserted, and formatting is adjusted. The final output is a complete, coherent, and customized report that meets user preferences, such as... Figure 4 As shown, it includes the following steps: S31. Execution and Fault Tolerance: The progressive content generation is executed according to the optimal SQL query execution sequence to generate paragraph content. The execution status is monitored in real time and data consistency is maintained. A multi-layered anomaly detection and handling mechanism is established, including automatic repair and rollback strategies for cases such as SQL execution anomalies, substandard result quality, and inconsistencies.

[0034] Progressive content generation includes the following steps: The system executes the selected SQL queries for each paragraph in strict sequence through the execution engine. During the process, the system monitors the execution status and results of each query in real time and immediately integrates the output into the report. At the same time, it dynamically updates the shared context (such as caching key data and recording generated conclusions) to ensure that subsequent paragraphs are generated based on the latest global information, thus guaranteeing the overall coherence and data consistency of the report.

[0035] A multi-layered anomaly detection and handling mechanism, specifically including: The system continuously detects execution anomalies, result quality deviations, or logical inconsistencies through a predefined validator. Once a threshold is triggered, it first attempts to automatically repair the issue (such as retrying, switching database replicas, or enabling standby SQL). If the repair fails, it activates a preset rollback strategy (such as downgrading to a simpler predefined query, filling in placeholder text, or ignoring the current paragraph). This allows the system to generate a complete and usable report even in the event of partial failure, and logs all events for subsequent system optimization.

[0036] S32. Content splicing output: The generated paragraph content is intelligently assembled according to the document template, and transition sentences are inserted to unify the data presentation format and enhance the overall readability; the final report is personalized based on user preferences, including control of the level of detail, highlighting of key information, and generation of multiple versions.

[0037] Specifically, all the paragraph contents generated in the previous stage are taken as input, and systematic assembly and formatting are performed according to a preset document template; through natural language generation technology, transitional sentences are automatically inserted between paragraphs, and unified standardization processing is performed on numbers, terms and chart references, and the like, so that the originally independent data results are finally integrated into a complete report document with strict structure, smooth writing and professional format. On the basis of the basic assembly of the report, final personalized rendering is performed according to the user's preset preference profile; this includes dynamically adjusting the degree of detail and omission of the content according to the user's role (such as generating an abstract for a manager and retaining details for an analyst), highlighting key indicators and core conclusions in the report, and possibly generating multiple versions of output according to different application scenarios (such as conference briefs and archival archives), so as to realize the real customization of the report.

[0038] The present application improves the report generation capability by introducing dynamic SQL generation and global optimization mechanism: according to the real-time data state, the context of the generated content and the user preference, the most suitable SQL query is dynamically constructed, which breaks the shackles of the predefined template and realizes the real "ad hoc" personalized analysis; through multi-model parallel generation and cross-review mechanism, rich data insights are generated from multiple dimensions such as basic extraction, comparative analysis and trend prediction, significantly improving the depth and breadth of the report; relying on the paragraph relationship graph and Monte Carlo tree search, the paragraph sequence is optimized at the global level to ensure the logical coherence and narrative fluency of the whole report; at the same time, the perfect fault tolerance processing and personalized output mechanism not only guarantees the robustness of the system in abnormal conditions, but also realizes the customized rendering based on the user's scene, finally realizing the coordinated improvement in flexibility, insight, coherence and user experience in four dimensions.

[0039] The present application redefines the report generation from the traditional "static filling" paradigm to a "dynamic sequence decision" process, and realizes it through the construction of a closed-loop architecture of "context awareness-candidate generation-global search": first, the multi-dimensional context modeling is used to fuse discrete information such as database state and user preference into a unified paragraph representation vector, providing a semantic basis for dynamic decision-making; then, a multi-model is driven to generate a diversified SQL candidate set, and the cross-review mechanism is used to improve the query quality; finally, the Monte Carlo tree search is used to search for the optimal query execution sequence under the constraint of the paragraph relationship graph from a global perspective, and the search process guides the decision by repeatedly simulating the expected report quality of different sequences, so as to ensure that the system automatically finds the overall optimal generation path in terms of content coverage, logical coherence and the like under the premise of meeting various dependency constraints, and finally realizes the paradigm shift from rigid template to intelligent dynamic generation.

[0040] The above merely describes the preferred embodiments of the present application, and is not intended to limit the present application in any form. Although the present application has been disclosed with the preferred embodiments as above, it is not intended to limit the present application. Any person skilled in the art can make some changes or modifications to the above disclosed technical content to obtain equivalent embodiments with equivalent changes, as long as the changes or modifications do not deviate from the technical solution of the present application. Any modification, change, equivalent change and modification of the above embodiments made according to the technical essence of the present application still belong to the scope of the technical solution of the present application.

Claims

1. A method for dynamically generating comprehensive reports based on SQL statements, characterized in that: The method comprises the following steps: Report structure analysis: build a paragraph relationship graph by parsing the report template, identify the dependency relationship to determine the optimal paragraph generation sequence, and model the multi-dimensional context to generate a paragraph representation vector rich in semantic information; Dynamic SQL candidate generation: based on the paragraph representation vector, generate multi-angle candidate SQL through multi-model parallel, optimize through cross review and debate, and then search the global optimal SQL query execution sequence using MCTS; Comprehensive report assembly and output: execute the query to generate paragraph content according to the optimal SQL query execution sequence, and perform real-time monitoring and exception handling; intelligently assemble the paragraph content according to the template, insert transitional sentences and adjust the format, and output a complete, coherent and customized report that meets the user's preferences; The report structure analysis comprises the following steps: Paragraph relationship graph construction: the target report template is structurally parsed and split into multiple independent paragraphs, the structured paragraph definition table is obtained by identifying paragraph boundaries, type markers and format requirements, and the paragraph relationship graph is constructed by analyzing the dependency relationship between paragraphs; Multi-dimensional context relationship modeling: build a multi-dimensional context environment for each paragraph to be generated, extract historical generated content, database schema structure, user preference settings and business rule constraints, use a relationship-aware encoder to deeply analyze and fuse the extracted context elements, and generate a paragraph representation vector rich in semantic information.

2. The method of claim 1, wherein the method further comprises: The paragraph definition table includes paragraph ID, type, content requirements and format specifications, and the construction of the paragraph relationship graph comprises: Dependency relationship identification: Data dependency relationship: by analyzing the data requirements and outputs of the paragraph, the flow direction of data from the source paragraph to the target paragraph is determined; Logical dependency relationship: the conditional relationship between premise paragraphs and inference paragraphs is identified, and strict generation sequence constraints are defined; Semantic association relationship: identify the paragraph sequence that needs to be closely connected in content, and the paragraph set that must maintain consistent terminology, definitions and conclusion references.

3. The method of claim 2, wherein the method further comprises: The construction of the paragraph relationship graph further comprises: Relationship graph construction: Each paragraph is abstracted as a node containing paragraph ID, type, content requirements and format specifications, and directed edges are established between nodes according to data dependency relationships, explicitly representing data supply, logical premise and semantic association information; By calculating the in-degree and out-degree indicators of the nodes, the network structure is quantitatively analyzed to identify the key path and bottleneck nodes in the network to obtain the paragraph generation sequence strategy.

4. The method of claim 1, wherein the method further comprises: determining the SQL statement based on the report type; and generating the report based on the SQL statement. The dynamic SQL candidate generation comprises the following steps: Multi-model candidate set generation: for each paragraph requirement, input the paragraph representation vector to start multiple generation engines to generate candidate SQL from different angles in parallel, cross-review and debate the generated candidate SQL through different specialized language models, identify the advantages and disadvantages of each through viewpoint collision, and make corrections and improvements; Search for optimal query sequence: model the report generation as a sequence decision problem, build a state space based on the candidate SQL, define state, action and transition functions, run MCTS search, and find the optimal SQL query execution sequence based on the paragraph relationship graph through selection-expansion-simulation-backtracking.

5. The method of claim 4, wherein the method further comprises: The different angles include basic data extraction, comparative analysis, trend prediction, and deep drilling; The parallel generation of candidate SQL includes: Based on the semantic type of the paragraph and user preferences, configure multiple generation angle strategies, initialize multiple dedicated SQL generation engines in parallel, distribute the context-rich paragraph representation vector and database schema information to each engine, and inject data permissions and business rules for collaborative generation; The output of the diversified candidate SQL is standardized and annotated with metadata, and a structured candidate set is output with generation angle, confidence score, and estimated execution cost.

6. The method of claim 5, wherein the method further comprises: The cross-review and debate includes: Initialize the debate environment, assign review roles to different specialized language models and develop debate rules, perform multiple rounds of cross-review, each model independently evaluates the candidate SQL and generates a review report, then through opinion exchange and focus debate, the controversial points are discussed in depth to build consensus; Based on the debate insight, the SQL with defects is optimized and corrected or triggered to regenerate, and finally the candidate set is ranked by a weighted scoring model, and the optimized SQL set is output.

7. The method of claim 6, wherein the method further comprises: The MCTS search includes: Perform structured Monte Carlo tree search on the constructed state space, start from the root node, balance the value estimation and exploration degree to select branches, and reach an expandable node; Expand the expandable node, use the fast strategy to complete the generation of the entire report from the state simulation to get the estimated global reward, propagate the global reward along the search path in reverse, update the value estimation of all passing state-action pairs, and through a large number of "selection-expansion-simulation-backtracking" cycles, finally converge to a paragraph with the best value in the global perspective, and get the SQL generation sequence.

8. The method of claim 1, wherein the method further comprises: determining a SQL statement based on the report template; and generating the report based on the SQL statement. The comprehensive report assembly and output includes the following steps: Perform and fault-tolerant processing: Perform progressive content generation according to the optimal SQL query execution sequence to execute each paragraph query to generate paragraph content, monitor the execution state in real time and maintain data consistency, establish a multi-layer exception detection and processing mechanism, including SQL execution exceptions, result quality not meeting standards, and automatic repair and rollback strategies in the case of coherence conflicts; Content splicing output: The generated paragraph content is intelligently assembled according to the document template, transition sentences are inserted, and the data presentation format is unified, and the final report is personalized based on user preferences.

9. The method of claim 8, wherein the method further comprises: The progressive content generation includes: Execute the selected SQL queries of each paragraph in sequence through the execution engine, monitor the execution state and results of each query in real time during execution, and immediately splice the output content into the report while dynamically updating the shared context.

10. The method of claim 9, wherein the method further comprises: The multi-layer exception detection and processing mechanism includes: ​ Through predefined validators, continuously detect execution exceptions, result quality deviations, or logical coherence conflicts, and once the threshold is triggered, first attempt automatic repair, and if repair fails, activate the preset rollback strategy.