A report configuration and query method and related device
Patent Information
- Application Number
- CN202611053254.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-15
- Publication Date
- 2026-10-16
AI Technical Summary
[0003]本发明的目的在于提供一种报表配置与查询方法及相关装置,以克服现有技术中存在的数据库适配困难、查询配置灵活性差以及缓存管理效率低的问题
本发明通过配置化的数据库驱动加载与密码动态解密机制,实现了对多种异构数据库的统一安全接入,解决了现有技术中数据库适配困难、安全性低的问题。通过动态参数化查询引擎,支持对时间区间、IN条件等多种类型参数占位符的自动解析与替换,将查询条件的配置权从开发人员转移至业务配置人员,实现了查询条件的零代码配置,解决了现有技术中查询条件配置灵活性差、维护成本高的问题。通过多级差异化智能缓存架构,针对不同类型数据实施差异化的缓存策略,并采用组合生成的缓存键确保缓存结果的准确性,同时通过定时任务清理闲置连接对象,有效提升了大数据量下的查询响应速度与系统资源利用率,解决了现有技术中查询效率低、资源管理混乱的问题。
Smart Images

Figure CN122925455A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of power production supervision data processing technology, specifically to a report configuration and query method and related apparatus. Background Technology
[0002] Currently, in power industry production monitoring scenarios, reporting systems typically need to interface with various heterogeneous databases to obtain data. However, existing reporting systems often use hard-coding for database adaptation, requiring the development of separate versions or the writing of specific connection code for different database types, resulting in poor system scalability and high maintenance costs. Furthermore, database connection passwords are often stored in plaintext in configuration files, posing a risk of information leakage. In addition, during report querying, query conditions are usually tightly coupled with code logic, preventing business personnel from flexibly configuring complex query parameters, especially for scenarios involving time ranges and multi-value filtering, where each change requires code modification and redeployment. Moreover, when facing large-volume regulatory report queries, existing systems lack effective caching management mechanisms, leading to significant query response delays, chaotic database connection object management, and low resource utilization. Therefore, there is an urgent need for a report configuration and query solution that can flexibly adapt to multiple databases, is secure and reliable, offers flexible query configuration, and possesses efficient caching management capabilities. Summary of the Invention
[0003] The purpose of this invention is to provide a report configuration and query method and related apparatus to overcome the problems of database adaptation difficulties, poor query configuration flexibility, and low cache management efficiency in existing technologies. This invention achieves adaptive and secure access to multiple databases, dynamic parameterized configuration of query conditions, and differentiated intelligent caching of query results.
[0004] To achieve the above objectives, the present invention adopts the following technical solution: A method for configuring and querying reports includes the following steps: S1. Obtain a report query request, wherein the report query request includes a report identifier and query parameters; S2. Load the corresponding database driver according to the configured database type identifier; S3. Obtain the encrypted database connection password and dynamically decrypt it when establishing a connection; S4. Identify parameter placeholders in the query statement, perform corresponding parsing and replacement operations according to the parameter placeholder type, and generate an executable query statement; S5. Implement a differentiated caching strategy for query results. The cache key is generated by combining the dataset identifier and the query parameter value. Different types of data correspond to different cache capacities and expiration strategies.
[0005] Further, loading the corresponding database driver based on the configured database type identifier includes: Read the database driver identifier, connection Uniform Resource Locator, username, and encrypted password from the configuration file; Determine the encryption switch flag; if encryption is enabled, decrypt the encrypted password to obtain the plaintext password. A data source object is constructed based on plaintext cryptography, and a database connection pool is established.
[0006] Furthermore, the loading of the corresponding database driver supports adaptive adaptation to multiple relational database types; the decryption of the encrypted password adopts a symmetric encryption algorithm, using a preset key and initialization vector for decryption; the method also includes: maintaining a consistent mapping between entity class field names and database table column names through a custom physical naming strategy.
[0007] Furthermore, the step of identifying parameter placeholders in the query statement and performing corresponding parsing and replacement operations based on the parameter placeholder type includes: Identify time interval condition placeholders, IN condition placeholders, and general parameter placeholders; Perform splitting and replacement on time interval condition placeholders, format conversion on IN condition placeholders, and value replacement on general parameter placeholders.
[0008] Furthermore, the splitting and replacement of the time interval condition placeholders includes: Identify time interval placeholders and split the value into start and end times, replacing them separately. The format conversion of the IN condition placeholder includes: when the placeholder is enclosed in quotes and has multiple values, converting the comma-separated multiple values into the IN query format; The step of performing value replacement on the general parameter placeholders includes replacing the parameter placeholders with the corresponding parameter values.
[0009] Furthermore, the implementation of a differentiated caching strategy for the query results includes: Implement differentiated caching strategies for different types of data, including capacity, expiration policies, and cache key generation rules; The cache key is generated by combining the dataset identifier and the query parameter value to ensure that the results of different query conditions are cached independently.
[0010] Furthermore, the differentiated caching strategy for different types of data includes: Set up independent caching components for dataset data, organizational data, data dictionary data, and indicator data respectively; Database connection objects are cached, and the last usage time of each connection is recorded. Connection objects that have not been used for more than a preset time are automatically cleaned up through scheduled tasks.
[0011] A report configuration and query system, comprising: The first module is used to obtain report query requests, which include report identifiers and query parameters. The second module is used to load the corresponding database driver based on the configured database type identifier. The third module is used to obtain the encrypted database connection password and dynamically decrypt it when establishing a connection. The fourth module is used to identify parameter placeholders in the query statement, perform corresponding parsing and replacement operations based on the parameter placeholder type, and generate an executable query statement. The fifth module is used to implement differentiated caching strategies for query results. The cache key is generated by combining the dataset identifier and the query parameter value. Different types of data correspond to different cache capacities and expiration strategies.
[0012] A computer device includes 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 steps of the report configuration and query method.
[0013] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the report configuration and query method.
[0014] Compared with the prior art, the present invention has the following beneficial technical effects: This invention achieves unified and secure access to various heterogeneous databases through a configurable database driver loading and dynamic password decryption mechanism, solving the problems of difficult database adaptation and low security in existing technologies. Through a dynamic parameterized query engine, it supports automatic parsing and replacement of various parameter placeholders such as time intervals and IN conditions, transferring the configuration authority of query conditions from developers to business configuration personnel, achieving zero-code configuration of query conditions, and solving the problems of poor flexibility and high maintenance costs in query condition configuration in existing technologies. Through a multi-level differentiated intelligent caching architecture, it implements differentiated caching strategies for different types of data, and uses a combined generated cache key to ensure the accuracy of cached results. Simultaneously, it effectively improves query response speed and system resource utilization under large data volumes through scheduled tasks to clean up idle connection objects, solving the problems of low query efficiency and chaotic resource management in existing technologies. Attached Figure Description
[0015] The accompanying drawings are provided to further understand the invention and constitute a part of this invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an improper limitation of the invention.
[0016] Figure 1 This is a schematic diagram of the overall platform interface according to an embodiment of the present invention; Figure 2 This is a schematic diagram of the database configuration interface according to an embodiment of the present invention; Figure 3 This is a dynamic parameterized query graph according to an embodiment of the present invention; Figure 4 This is a schematic diagram of a multi-level intelligent caching architecture according to an embodiment of the present invention; Figure 5 This is a flowchart of the method of the present invention. Detailed Implementation
[0017] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0018] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0019] Example 1 like Figure 5 As shown, this embodiment provides a method for configuring and querying reports. The method includes the following steps: Step S1: Obtain a report query request, which includes a report identifier and query parameters.
[0020] In this step, the report query request is initiated by the user through the report configuration and query platform interface. For example... Figure 1As shown, when a user views the "Reliability Capacity Report," selects "Thermal Power" as the energy type and "May 6, 2026 to May 13, 2026" as the time range, and clicks the query button, the front end encapsulates the report identifier and query parameters into a request and sends it to the backend server. The report identifier is used to uniquely identify the report template and dataset configuration that needs to be loaded, while the query parameters are used for subsequent data filtering and selection.
[0021] Step S2: Load the corresponding database driver according to the configured database type identifier.
[0022] The configured database type identifier is an identifier pre-stored in the system configuration file or database configuration table. When the system starts up or establishes a connection, it reads this identifier and dynamically loads the corresponding database driver using Java reflection or similar dynamic loading techniques. This configuration-driven approach eliminates the need for hard-coding the database type in the code, enabling flexible adaptation to various heterogeneous databases, including mainstream commercial databases such as MySQL and SQL Server. This effectively solves the problems of rigid database adaptation and poor scalability in existing technologies.
[0023] Step S3: Obtain the encrypted database connection password and dynamically decrypt it when establishing the connection.
[0024] Specifically, encrypted storage means that database connection passwords are not stored in plaintext in configuration files or the database itself, but rather as ciphertext processed by an encryption algorithm. When the system needs to establish a database connection, it reads this ciphertext and dynamically decrypts it using a decryption algorithm, restoring the plaintext password for connection authentication. This mechanism effectively prevents the risk of database password leakage due to configuration file leaks, thus improving system security. The decryption process occurs only momentarily in memory and is destroyed immediately after use, further reducing the risk.
[0025] Step S4: Identify parameter placeholders in the query statement, perform corresponding parsing and replacement operations according to the parameter placeholder type, and generate an executable query statement.
[0026] Specifically, the query statement can be an SQL statement or an API interface address, which embeds parameter placeholders. Parameter placeholders are special markers used to replace the actual query parameter values at runtime. Before executing the query, the system scans these parameter placeholders and executes different parsing logic based on the parameter placeholder type. In this way, business users can flexibly adjust query conditions through the configuration interface without modifying the code, achieving zero-code configuration of query conditions.
[0027] Step S5: Implement a differentiated caching strategy for the query results. The cache key is generated by combining the dataset identifier and the query parameter value. Different types of data correspond to different cache capacities and expiration strategies.
[0028] The differentiated caching strategy refers to a system that does not apply a uniform caching rule to all data. Instead, it sets independent caching configurations for different types of data based on factors such as data characteristics, update frequency, and data volume. For example, for organizational data with low update frequency, a longer expiration time can be set; for business data with high real-time requirements, a shorter expiration time or disabling caching is used. The cache key is a unique identifier for cached data, generated by combining the dataset identifier (such as dataset ID) with specific query parameter values (such as "thermal power" or "2026-05-06"). This combination ensures that results under different query conditions can be cached independently, avoiding caching errors caused by parameter changes. Through the differentiated caching strategy, the system maximizes query response speed and optimizes system resource utilization while ensuring data real-time performance.
[0029] Example 2 This embodiment, based on embodiment 1, provides a detailed explanation of the multi-database adaptive adaptation and secure connection mechanism.
[0030] Specifically, based on the configured database type identifier, the corresponding database driver is loaded, including: reading the database driver identifier, connection Uniform Resource Locator, username, and encryption password from the configuration file; determining the encryption switch flag, and if encryption is enabled, decrypting the encryption password to obtain the plaintext password; constructing a data source object based on the plaintext password and establishing a database connection pool.
[0031] The configuration file is typically stored in properties or yaml format and contains multiple database connection configuration items. Each configuration item includes a database driver identifier, a connection Uniform Resource Locator (URL), a username, and an encrypted password. The system obtains the necessary connection information by reading these configuration items when starting up or establishing a connection.
[0032] The encryption switch flag is a Boolean value used to control whether the password is decrypted. If encryption is enabled, the system calls a decryption algorithm to decrypt the encrypted password, restoring it to its plaintext form; if encryption is disabled, the plaintext password from the configuration file is used directly. This configuration-driven approach makes database connection information management more flexible, allowing switching between database connections without modifying code, thus reducing system maintenance costs. Simultaneously, the encrypted storage and dynamic decryption mechanism effectively prevents the risk of database password leakage due to configuration file leaks, enhancing system security.
[0033] Furthermore, the corresponding database driver is loaded to support adaptive adaptation to multiple relational database types; the encrypted password is decrypted using a symmetric encryption algorithm with a preset key and initialization vector; the method also includes: maintaining a consistent mapping between entity class field names and database table column names through a custom physical naming strategy.
[0034] Specifically, the system supports various relational database types, including mainstream commercial databases such as MySQL, SQL Server, DM, and OpenGauss, as well as domestic databases. Based on the database driver identifier in the configuration file, the system automatically loads the corresponding database driver class using Java reflection or similar dynamic loading techniques. This adaptive mechanism allows a single system codebase to support multiple heterogeneous databases simultaneously, meeting the database migration needs in scenarios such as domestic substitution. It eliminates the need to develop independent versions for different databases, significantly reducing development and maintenance costs.
[0035] For decrypting encrypted passwords, this embodiment employs a symmetric encryption algorithm, such as AES. The decryption process uses a preset key and initialization vector to decrypt the encrypted password. The preset key and initialization vector are typically stored in a secure location, such as a key management service or an encrypted configuration file, and are only temporarily read into memory for use during decryption. Symmetric encryption algorithms have the advantages of fast encryption and decryption speed and high efficiency, making them suitable for encrypting and protecting short texts such as database connection passwords.
[0036] Furthermore, in Object-Relational Mapping (ORM) frameworks, the default physical naming strategy typically converts camelCase entity class field names to lowercase underscores for database table column names. However, in power monitoring reporting systems, database table column names are usually uppercase or camelCase. Using the default mapping strategy would lead to a mismatch between field names and column names, resulting in query errors. Therefore, this embodiment uses a custom physical naming strategy to override the default naming conversion logic, maintaining a consistent mapping between entity class field names and database table column names. This design solves the incompatibility issue between the default mapping strategy of the ORM framework and the existing database table structure, avoids query errors caused by field name mismatches, and improves system compatibility and stability.
[0037] like Figure 2The diagram illustrates the database configuration interface. Users can configure information such as database type, driver class name, host IP, port, database name, username, and password on the interface, and perform connection tests. After receiving the configuration information, the system stores it in a configuration file or database configuration table. When a database connection needs to be established, the system reads the configuration information, checks the encryption switch flag, decrypts it if encryption is enabled, constructs a data source object, and establishes a database connection pool. Connection objects in the connection pool can be reused, avoiding the performance overhead of frequently creating and destroying connections, and improving database access efficiency.
[0038] Example 3: Identify parameter placeholders in the query statement and perform corresponding parsing and replacement operations based on the parameter type, including: identifying time interval condition placeholders, IN condition placeholders, and general parameter placeholders; performing split replacement on time interval condition placeholders, performing format conversion on IN condition placeholders, and performing value replacement on general parameter placeholders.
[0039] In this context, parameter placeholders are special markers embedded in the query statement, used to be replaced by the actual query parameter values at runtime. The parameter placeholders in this embodiment are not limited to a specific symbol format; for example, they can use ${parameter name}, #{parameter name}, or other custom formats, as long as they can be recognized and distinguished from ordinary text by the system. Before executing the query, the system scans these parameter placeholders in the query statement and executes different parsing logic based on the parameter type. This typed parsing mechanism allows business users to flexibly adjust query conditions through the configuration interface without modifying the code, achieving zero-code configuration of query conditions.
[0040] Furthermore, the time interval condition placeholders are split and replaced, including: identifying the time interval placeholders and splitting the values into start time and end time for replacement.
[0041] Specifically, time interval queries are a very common scenario in power regulatory reports. This embodiment allows business personnel to configure only one time interval parameter through time interval condition placeholders, and the system automatically splits it into start time and end time.
[0042] Furthermore, perform format conversion on IN condition placeholders, including: when the placeholder is enclosed in quotes and has multiple values, convert comma-separated multiple values to IN query format.
[0043] Specifically, the IN condition query is used to filter whether a field contains multiple values. In this example, the IN condition placeholders automatically convert comma-separated multiple values into a format that conforms to the SQL IN syntax. This approach ensures the correctness of the SQL syntax while effectively preventing SQL injection risks.
[0044] Furthermore, value replacement is performed on the general parameter placeholders, including replacing the parameter placeholders with the corresponding parameter values.
[0045] Specifically, the general parameter placeholder is used to handle simple single-value replacement scenarios. The system directly replaces the placeholder with the parameter value entered or selected by the business personnel.
[0046] like Figure 3 As shown, a dynamically parameterized query graph is presented. When editing a dataset, users can enter SQL statements containing parameter placeholders in the SQL statement editor.
[0047] This embodiment realizes the automatic parsing and replacement of placeholders for various types of parameters such as time intervals, IN conditions, and general parameters. It transfers the configuration authority of query conditions from developers to business configuration personnel, solving the problems of poor flexibility and high maintenance costs in query condition configuration in the prior art. At the same time, it effectively prevents SQL injection risks and ensures the correctness and security of query statements.
[0048] Example 4: Implement differentiated caching strategies for query results, including: implementing differentiated caching strategies for different types of data, including capacity, expiration strategies, and cache key generation rules; the cache key is generated by combining the dataset identifier and query parameter values to ensure that the results of different query conditions are cached independently.
[0049] The differentiated caching strategy refers to a system that does not adopt a uniform caching rule, but instead sets independent caching configurations for different types of data based on their business characteristics, update frequency, data volume, and access patterns. This design fully considers the heterogeneity of various types of data in the power monitoring reporting system. Data sets typically have large volumes and time-consuming queries, but relatively low update frequencies, making them suitable for larger cache capacities and moderate expiration times. In contrast, basic data such as organizational structure data and data dictionary data have small volumes, are frequently accessed, and rarely change, making them suitable for smaller cache capacities and longer expiration times. Through this refined differentiated configuration, the system maximizes cache hit rates and optimizes memory resource utilization while ensuring data real-time performance.
[0050] The generation rules for cache keys are the core mechanism for ensuring the accuracy of cached results. In this embodiment, the cache key is generated by combining a dataset identifier and a query parameter value. Specifically, the dataset identifier is used to distinguish different data sources, and the query parameter value is used to distinguish the result sets of the same data source under different query conditions. This combined generation method ensures that results under different query conditions can be cached independently, avoiding cache errors caused by parameter changes.
[0051] Furthermore, differentiated caching strategies are implemented for different types of data, including: setting up independent caching components for dataset data, organizational data, data dictionary data, and indicator data; caching database connection objects, recording the last usage time of each connection, and automatically cleaning up connection objects that have not been used for a preset time through scheduled tasks.
[0052] Specifically, this embodiment uses a high-performance caching library based on Caffeine to build six independent caching components. Each type of caching component is configured independently in terms of capacity limits, expiration policies, and key generation rules, without interfering with each other.
[0053] The first type is database dataset caching. This caching component stores the result sets of database queries, with a maximum configurable capacity of 100,000 records. It employs a post-access expiration strategy, with the expiration time dynamically adjustable via system configuration, defaulting to 10 minutes. The cache key is generated by combining the dataset ID and query parameter values, ensuring that results from different query conditions are cached independently. This caching component also supports batch cache clearing based on dataset ID prefix matching. When the data in a dataset changes, the system can quickly clear all caches related to that dataset, ensuring data consistency.
[0054] The second type is API dataset caching. This caching component stores API data retrieved via HTTP requests, with a maximum capacity of 100,000 records, employing an expiration strategy based on the number of records accessed. The cache key is generated by combining the API ID with request parameter values. Because API interfaces are affected by network latency and server-side processing time, resulting in significantly higher response latency than local queries, this caching component can significantly reduce the frequency of calls to external systems, improving the overall system response speed.
[0055] The third type is organizational data caching. This caching component stores tree-structured data of multi-level organizations such as groups, companies, power plants, and generating units, with a maximum configurable capacity of 2000 records. Because organizational data changes very infrequently, this caching component can employ long expiration times, or even manual clearing strategies. The cache key is generated by combining the organization type and energy type, for example, "Plant_HD,WIND," and supports queries based on combinations of organization type and energy type.
[0056] The fourth type is data dictionary caching. This caching component stores the encoding and name mapping relationships of the data dictionary, such as energy type, equipment type, and status code. Its maximum capacity is configurable to 2000 entries. The data dictionary is the system's fundamental configuration data, changing very infrequently, making it suitable for long-term caching. The cache key is the parent code of the data dictionary, such as "PlantEleType".
[0057] The fifth category is indicator data caching. This caching component stores indicator directory tree-structured data, with a maximum configurable capacity of 2000 records. The cache key is generated by a combination of five parameters: institution ID, institution type, energy type, whether to display the tree, and indicator name, supporting complex indicator tree query scenarios.
[0058] The sixth category is database connection object caching. Unlike the previous five categories of cached data, this caching component caches database connection objects such as JdbcTemplate, rather than business data. The cache key is the connection name, and the cached value is the connection object. Simultaneously, the system records the last usage time of each connection. Since database connection objects are valuable system resources, long-term idle connections will consume connection pool resources and may even lead to connection leaks. Therefore, this embodiment introduces a timed cleanup mechanism. The system uses a scheduled task, such as executing every 30 minutes, to scan all cached connection objects, calculate the difference between the last usage time of each connection and the current time, and if the difference exceeds a preset threshold (e.g., 1 hour), automatically clean up the connection object, releasing system resources. This design effectively solves the problems of chaotic connection object management and low resource utilization, improving the stability and reliability of the system.
[0059] like Figure 4 The diagram illustrates a multi-level intelligent caching architecture. Upon system startup, each caching component initializes a Caffeine cache object in its static block, reads the expiration time parameter from the system configuration, and creates a cache instance. When a business module requests data, it first queries the corresponding cache component based on the cache key. If the cache is hit, the cached data is returned directly, avoiding repeated database queries or API calls, significantly improving query efficiency. If the cache is not hit, a database query or API call is executed, the data is retrieved, written to the cache, and returned. Simultaneously, a scheduled task periodically scans the database connection object cache, cleans up idle connections, and optimizes resource management.
[0060] Example 5: This embodiment provides a report configuration and query system, including: The first module is used to obtain report query requests, which include report identifiers and query parameters. The second module is used to load the corresponding database driver based on the configured database type identifier. The third module is used to obtain the encrypted database connection password and dynamically decrypt it when establishing a connection. The fourth module is used to identify parameter placeholders in the query statement, perform corresponding parsing and replacement operations based on the parameter placeholder type, and generate an executable query statement. The fifth module is used to implement differentiated caching strategies for query results. The cache key is generated by combining the dataset identifier and the query parameter value. Different types of data correspond to different cache capacities and expiration strategies.
[0061] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0062] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0063] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0064] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1The steps of the function specified in one or more boxes.
[0065] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit its scope of protection. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that after reading the present invention, they can still make various changes, modifications or equivalent substitutions to the specific implementation of the invention, but these changes, modifications or equivalent substitutions are all within the scope of protection of the pending claims of the invention.
Claims
1. A method for configuring and querying reports, characterized in that, Includes the following steps: S1. Obtain a report query request, wherein the report query request includes a report identifier and query parameters; S2. Load the corresponding database driver according to the configured database type identifier; S3. Obtain the encrypted database connection password and dynamically decrypt it when establishing a connection; S4. Identify parameter placeholders in the query statement, perform corresponding parsing and replacement operations according to the parameter placeholder type, and generate an executable query statement; S5. Implement a differentiated caching strategy for query results. The cache key is generated by combining the dataset identifier and the query parameter value. Different types of data correspond to different cache capacities and expiration strategies.
2. The report configuration and query method according to claim 1, characterized in that, The step of loading the corresponding database driver based on the configured database type identifier includes: Read the database driver identifier, connection Uniform Resource Locator, username, and encrypted password from the configuration file; Determine the encryption switch flag; if encryption is enabled, decrypt the encrypted password to obtain the plaintext password. A data source object is constructed based on plaintext cryptography, and a database connection pool is established.
3. The report configuration and query method according to claim 2, characterized in that, The loading of the corresponding database driver supports adaptive adaptation to multiple relational database types; the decryption of the encrypted password adopts a symmetric encryption algorithm, using a preset key and initialization vector for decryption; the method also includes: maintaining a consistent mapping between entity class field names and database table column names through a custom physical naming strategy.
4. The report configuration and query method according to claim 1, characterized in that, The process of identifying parameter placeholders in the query statement and performing corresponding parsing and replacement operations based on the parameter placeholder type includes: Identify time interval condition placeholders, IN condition placeholders, and general parameter placeholders; Perform splitting and replacement on time interval condition placeholders, format conversion on IN condition placeholders, and value replacement on general parameter placeholders.
5. The report configuration and query method according to claim 4, characterized in that, The process of splitting and replacing the time interval condition placeholders includes: Identify time interval placeholders and split the value into start and end times, replacing them separately. The format conversion of the IN condition placeholder includes: when the placeholder is enclosed in quotes and has multiple values, converting the comma-separated multiple values into the IN query format; The step of performing value replacement on the general parameter placeholders includes replacing the parameter placeholders with the corresponding parameter values.
6. The report configuration and query method according to claim 1, characterized in that, The differentiated caching strategy for query results includes: Implement differentiated caching strategies for different types of data, including capacity, expiration policies, and cache key generation rules; The cache key is generated by combining the dataset identifier and the query parameter value to ensure that the results of different query conditions are cached independently.
7. The report configuration and query method according to claim 6, characterized in that, The differentiated caching strategy for different types of data includes: Set up independent caching components for dataset data, organizational data, data dictionary data, and indicator data respectively; Database connection objects are cached, and the last usage time of each connection is recorded. Connection objects that have not been used for more than a preset time are automatically cleaned up through scheduled tasks.
8. A report configuration and query system, characterized in that, include: The first module is used to obtain report query requests, which include report identifiers and query parameters. The second module is used to load the corresponding database driver based on the configured database type identifier. The third module is used to obtain the encrypted database connection password and dynamically decrypt it when establishing a connection. The fourth module is used to identify parameter placeholders in the query statement, perform corresponding parsing and replacement operations based on the parameter placeholder type, and generate an executable query statement. The fifth module is used to implement differentiated caching strategies for query results. The cache key is generated by combining the dataset identifier and the query parameter value. Different types of data correspond to different cache capacities and expiration strategies.
9. 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 steps of the report configuration and query method as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the report configuration and query method as described in any one of claims 1 to 7.