CN109508344B - Service data query method and device, electronic equipment and storage medium - Google Patents

Service data query method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN109508344B
CN109508344B CN201811151266.0A CN201811151266A CN109508344B CN 109508344 B CN109508344 B CN 109508344B CN 201811151266 A CN201811151266 A CN 201811151266A CN 109508344 B CN109508344 B CN 109508344B
Authority
CN
China
Prior art keywords
query
database
application
request
service
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811151266.0A
Other languages
Chinese (zh)
Other versions
CN109508344A (en
Inventor
胡博
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Life Insurance Company of China Ltd
Original Assignee
Ping An Life Insurance Company of China Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Life Insurance Company of China Ltd filed Critical Ping An Life Insurance Company of China Ltd
Priority to CN201811151266.0A priority Critical patent/CN109508344B/en
Publication of CN109508344A publication Critical patent/CN109508344A/en
Application granted granted Critical
Publication of CN109508344B publication Critical patent/CN109508344B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

A business data query method, comprising: establishing a database connection pool corresponding to a plurality of application systems; receiving an externally input query application, wherein the query application comprises one or more business item query requests; inquiring services from different databases in the database connection pool according to the inquiry application, and acquiring inquiry results; and displaying the query results obtained from the databases corresponding to the plurality of application systems into the same table. The invention also provides a service data query device, electronic equipment and a storage medium. The invention can realize the SQL query request configuration items of databases of different types of different systems, display the business items in the databases of different types of different systems in the WEB display page of a table, and realize the optimization of the business process.

Description

Service data query method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a service data query method, a device, an electronic device, and a storage medium.
Background
Currently, there are various report systems in the industry, and these report systems generally support that SQL configuration items of one system database correspond to WEB display pages of one table, but no query SQL configuration items of different types of databases of multiple different systems correspond to WEB display pages of one table yet, and OVS visualization systems provide such a function: the real-time automatic analysis of the core service item index of the service system can be applied to the aspects of service statistics and data analysis during abnormal service periods and holidays, and the like, operation and maintenance personnel are usually required to finish in a short time in the process of processing system accidents or daily service statistics reports, and count from each database one by one in a manual mode, so that the efficiency is lower, and the requirements cannot be met.
In addition, the existing core service item statistics tool is generally executed in series according to the inspection items, so that service data query time is too long, meanwhile, the database performance problem is not considered, and when tens of service items are selected to relate to a plurality of databases, the databases are affected.
Disclosure of Invention
In view of the foregoing, it is necessary to provide a service data query method, a device, an electronic device, and a storage medium, which implement a WEB display in which service items in databases of different types of different systems are displayed in a form through SQL query request configuration items of the databases of different types of different systems.
The first aspect of the present invention provides a service data query method, which includes:
establishing a database connection pool corresponding to a plurality of application systems;
receiving an externally input query application, wherein the query application comprises one or more business item query requests;
inquiring services from different databases in the database connection pool according to the inquiry application, and acquiring inquiry results; and
and displaying the query results obtained from the databases corresponding to the plurality of application systems into the same table.
Preferably, the step of querying the service from different databases in the database connection pool according to the query application and obtaining the query result specifically includes:
(a) Analyzing the information in the query application to obtain a database operation command;
(b) Determining a database as an operation object according to the database operation command and configuration information, wherein the configuration information comprises database types of a plurality of databases;
(c) Establishing a parallel query mechanism to send the query application to a determined database;
(d) And calling a database connection from a connection pool corresponding to the determined database, transmitting the database operation command to the determined database by applying the database connection, and receiving a query result from the determined database.
Preferably, the step (d) includes:
judging whether an idle database connection exists in a connection pool corresponding to the determined database;
when the connection pool corresponding to the determined database has idle database connection, directly calling an idle database connection from the connection pool;
and transmitting a database operation command to a database by using the database connection, and receiving a query result from the database.
Preferably, the step (d) further comprises:
when no free database connection exists in the connection pool corresponding to the determined database, judging whether the number of database connections reaches a preset maximum value;
When the number of the database connections reaches a preset maximum value, delaying for a preset period of time, and then judging whether the connection pool has idle database connections;
when the number of the database connections does not reach a preset maximum value, creating a new database connection;
and transmitting a database operation command to a database by applying the new database connection, and receiving a query result from the database.
Preferably, the method further includes a step of judging whether the time of the service item query request query service in the query application is overtime, the step includes:
setting a time threshold of a service item query request query service in the query application, and judging whether the time of the service item query request query service is greater than the time threshold;
if the time for inquiring the service item inquiry request is determined to be greater than the time threshold, sending an inquiry termination request to a database corresponding to the service item inquiry request to stop inquiring;
and if the time of the service item query request query service is less than or equal to the time threshold, continuing to query.
Preferably, the method further comprises the step of setting a maximum number of parallel requests allocated by the service item query requests in the query application in a preset time period.
Preferably, the service item query requests are configured by SQL, one service item query request corresponds to one SQL query request, and one SQL query request corresponds to one database.
A second aspect of the present invention provides a service data query device, the device comprising:
the determining module is used for determining an entry statement to be called in the packet storage process;
the establishing module is used for establishing database connection pools corresponding to a plurality of application systems;
the receiving module is used for receiving an externally input query application, wherein the query application comprises one or more business item query requests;
the query module is used for querying services from different databases in the database connection pool according to the query application and obtaining query results; and
and the display module is used for displaying the query results obtained from the databases corresponding to the plurality of application systems into the same table.
A third aspect of the present invention provides an electronic device comprising a processor and a memory, the processor being configured to implement the service data querying method when executing a computer program stored in the memory.
A fourth aspect of the present invention provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the service data query method.
The invention discloses a service data query method, a service data query device, electronic equipment and a storage medium. SQL query request configuration items of databases of different types of different systems can be realized, and service items in the databases of different types of different systems are displayed in a WEB display page of a table. And the number of inquired people in the same time period is not limited, the inquiry speed is relatively high, the influence of a database is negligible, and great help can be provided for fortune and development staff.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only embodiments of the present invention, and that other drawings can be obtained according to the provided drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flowchart of a service data query method according to an embodiment of the present invention.
Fig. 2 is a detailed flowchart of step S3 in the service data query method according to the first embodiment of the present invention.
Fig. 3 is a detailed flowchart of step S34 in the service data query method according to the first embodiment of the present invention.
Fig. 4 is a functional block diagram of a service data query device according to a second embodiment of the present invention.
Fig. 5 is a schematic diagram of an electronic device according to a third embodiment of the present invention.
The invention will be further described in the following detailed description in conjunction with the above-described figures.
Detailed Description
In order that the above-recited objects, features and advantages of the present invention will be more clearly understood, a more particular description of the invention will be rendered by reference to specific embodiments thereof which are illustrated in the appended drawings. It should be noted that, without conflict, the embodiments of the present invention and features in the embodiments may be combined with each other.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present invention, and the described embodiments are merely some, rather than all, embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terminology used herein in the description of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention.
The terms first, second, third and the like in the description and in the claims of the invention and in the above-described figures, are used for distinguishing between different objects and not for describing a particular sequential order. Furthermore, the term "include" and any variations thereof is intended to cover a non-exclusive inclusion. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those listed steps or elements but may include other steps or elements not listed or inherent to such process, method, article, or apparatus.
The business data query method of the embodiment of the invention is applied to one or more electronic devices. The service data query method can also be applied to a hardware environment formed by the electronic equipment and a server connected with the electronic equipment through a network. Networks include, but are not limited to: a wide area network, a metropolitan area network, or a local area network. The service data query method of the embodiment of the invention can be executed by a server or by electronic equipment; or may be performed by both the server and the electronic device.
The electronic device which needs to perform the service data query method can integrate the query function provided by the method of the invention directly on the electronic device or install a client for realizing the method of the invention. For another example, the method provided by the invention can also be operated on devices such as a server in the form of a software development kit (Software Development Kit, SDK), an interface of a service data query function is provided in the form of the SDK, and the electronic device or other devices can realize the query of the service data through the provided interface.
Example 1
Fig. 1 is a flowchart of a service data query method according to an embodiment of the present invention. The order of execution in the flowcharts may be changed, and certain steps may be omitted, according to different needs.
And step S1, establishing a database connection pool corresponding to a plurality of application systems.
The basic principle of the database connection pool is to maintain a certain number of database connections in an internal object pool and expose a database connection acquisition and return method to the outside. Such as: the external user can acquire the connection through the getConnection method, and return the connection through the releaseConnection method after the use is finished, and notice that the connection is not closed at this time, but is recovered by the connection pool manager and is ready for the next use. The method specifically comprises the following steps:
a. Creating a ConnectionPool instance, and initializing and creating preset values (such as 10) connections;
b. achieving getConnection () to obtain an available connection from the connection library;
c. returnConnection (conn) provides a method of placing connections back into the connection pool.
The database connection pool is responsible for distributing, managing and releasing database connections corresponding to a plurality of application systems, and allows the application systems to repeatedly use an existing database connection instead of rebuilding a database connection, thereby avoiding a great deal of performance overhead caused by frequently creating and releasing the connection.
In this embodiment, the database connection pool may include, but is not limited to, a Druid database connection pool, a DBCP data connection pool, and the like.
In this embodiment, the application system may include a safe life insurance system, a safe caretaker, a safe pocket bank, a safe insurance inquiry system, a safe claim settlement system, an endowment insurance sponsoring service system, and the like.
Preferably, each application system corresponds to at least one database, and each database may also correspond to a plurality of application systems.
Preferably, the method may further set a maximum connection number of the database connection pool.
When a large number of users inquire through the client side at the same time, the database connection pool limits the connection request according to the maximum connection number so as to prevent the instant rise of the SESSION (SESSION) of a certain database and further influence the service inquiry. And, for clients that do not have SESSIONs (SESSIONs) split into the database, the client will be forced to wait until there are SESSIONs (SESSIONs) available in the database connection pool, and if the waiting time exceeds a preset time (such as one minute), a prompt of "waiting timeout" is sent to the client.
Step S2, receiving an externally input query application, wherein the query application comprises one or more business item query requests.
In this embodiment, the query application may be entered by the user via a user interface. The user may select a plurality of business items corresponding to a plurality of application systems or databases through a multi-choice drop down box provided on the user interface. The business item corresponds to a plurality of indexes, and the indexes comprise: the system name, the key service index name, the time period, the current service volume, the service volume of the same time period before the starting time, the service volume of the whole day before the starting time, the service volume of the same time period before the week before the starting and ending time, the comparison of the service volumes of the same time period before the week, the change rate of the same time period before the day, the influence on the whole day proportion and the like.
The index also comprises the same period change ratio of the previous day, the whole period change ratio of the previous day, the same period change ratio of the last week and the whole period change ratio of the last week.
In this embodiment, the service item query requests are configured by SQL, one service item query request corresponds to one SQL query request, and one SQL query request corresponds to one database.
The SQL query request is configured with script information. For example, an SQL query request is configured by entering select count (1) from table where businesstype = '1' and date > = $ { start_date } and date < = $ { end_date }. Where $ { start_date } and $ { end_date } are page query parameters used to input the time of a particular query. For example, when the user selects a time on the page, the system will automatically change the SQL query request to select count (1) from table where businesstype = '1' and date > = $ { start_date } and date < = $ { end_date } union all select count (1) from table where businesstype = '1' and date > = $ { start_date } -1and date < = $ { end_date } -1union all select count (1) from table where businesstype = '1' and date > = $ { start_date } -7and date < = $ { end_date } -7), with $ { start_date } and $ { end_date } replaced with the selected time to make the query.
In this embodiment, the above-mentioned index of the application system in a predetermined period (such as a system abnormality period and a holiday period) may be queried according to the query period input in the query application.
And step S3, inquiring the service from different databases in the database connection pool according to the inquiry application, and acquiring an inquiry result.
In this embodiment, referring to fig. 2, the step of querying a service from different databases in the database connection pool according to the query application and obtaining a query result includes:
and S31, analyzing the information in the query application to obtain a database operation command. The database operation instruction comprises reading business item data in a database.
Step S32, determining a database as an operation object according to the database operation command and configuration information, wherein the configuration information comprises database types of a plurality of databases. The configuration information may also include information such as a name, an IP address, and a port of the database. The database name is the name of the database used by the system, such as the database used by safe life insurance. The database stores various business data, user information and other contents.
Step S33, a parallel query mechanism is established to send the query application to a determined database.
Specifically, the method for establishing a parallel query mechanism to send the query application to the determined database comprises the following steps:
1) And sending the service item query request in the query application to a SPRINGMVC framework according to a specific mechanism. In this embodiment, the specific mechanism is set by the JS profile specification. For example, when the user selects to query 7 service items, the request transmission manner set by the JS profile specification is: and (3) sending 1-5 service item query requests to SPRINGMVC in parallel, wherein if the 3 rd service item query request firstly requests to return a data result (service data is returned in normal time and abnormal description is returned in abnormal time), the JS PROMISE automatically sends the 6 th service item query request. And then if the 2 nd business item query request returns a data result, the JS PROMISE automatically sends the 7 th business item query request until all the business item query requests return data. The method simply transmits the request to carry out parallel inquiry in an asynchronous and synchronous mode, so that the inquiry efficiency can be improved.
2) And after receiving the service item query request, the SPRINGMVC framework carries out parameter setting on SQL configuration in the query application. The parameter settings include substitutions and modifications to SQL, such as modifying query time.
3) And sending the service item query requests to the database connection pool one by one through a mybatis framework.
And step S34, calling the database connection from the connection pool corresponding to the determined database, transmitting a database operation command to the determined database by applying the database connection, and receiving a query result from the database.
Specifically, referring to fig. 3, the step S34 may further include the following steps:
step S340: judging whether the connection pool corresponding to the determined database has free database connection, if yes, executing step S341, and if no, executing step S342.
Step S341: a free database connection is directly invoked from the connection pool, and step S345 is performed.
Step S342: whether the number of database connections reaches the preset maximum value is determined, if yes, step S343 is executed, and if no, step S344 is executed. The preset maximum value can be adjusted by using a configuration file according to actual working requirements.
Step S343: after a predetermined time, the process returns to step S340 to re-determine whether there is any free database connection in the connection pool.
Step S344: a new database connection is created and step S345 is performed.
Step S345: and transmitting a database operation command to a database by using the database connection, and receiving a query result from the database.
Preferably, the method can also set the maximum parallel request number allocated by the service item query request in the query application in a preset time period. Specifically, after a user selects a large number of service items to query, the system allocates the maximum number of parallel requests, and each parallel request in the maximum number of parallel requests operates independently and returns a query result in time. The function of not sending excessive business item query requests to the corresponding databases even if the selected query items are excessive is realized.
For example, the user selects 20 business items to query, when the user clicks on the query, the system processes the 1 st to 5 th requests to query the business items, and when a certain request is finished, the system returns the result to the front page display immediately, then processes the 6 th request, and when another request is finished, the system returns the result to the front page display immediately, then processes the 7 th request, and so on until all the 20 business items are queried. That is, there are 5 requests at each time to process query terms until all query terms have been processed.
Preferably, the method further comprises the step of judging whether the time of the service item query request query service in the query application is overtime.
Specifically, the method for judging whether the service item inquiry request inquiry service time in the inquiry application is overtime comprises the following steps:
a. setting a time threshold of a service item query request query service in the query application, and judging whether the time of the service item query request query service is greater than the time threshold (for example, 5 minutes);
b. if the time for inquiring the service item inquiry request is determined to be greater than the time threshold, sending an inquiry termination request to a database corresponding to the service item inquiry request to stop inquiring;
c. and if the time of the service item query request query service is less than or equal to the time threshold, continuing to query.
And S4, displaying query results obtained from databases corresponding to the plurality of application systems into the same table.
In this embodiment, each SQL query request may display a query result in a corresponding display page table, where the content of one row includes only one service item, and the content of multiple rows includes multiple service items. That is, when a user selects a plurality of service items and performs a query, the query results of the plurality of service items may be presented in a form of a plurality of rows in a table of a presentation page.
For example, by configuring an SQL query request to query and count "current traffic", the query results of the "current traffic" will be presented in the form of a numerical value in the first row and column of the table. While statistics of other columns in this row may be used to show "current traffic" over different time periods. For example, by automatically changing the value of $ { start_date } to $ { start_date } -1 or $ { start_date } -7 when configuring the SQL query request, the system queries out data that was last day or 7 days ago.
Preferably, the query result is displayed in the page table according to the length of the query time. For example, the query results returned by the short-time SQL query request are displayed first, and the query results returned by the long-time SQL query request are displayed later, i.e. the query results of each row in the page table are displayed at different speeds.
In addition, if the time of the SQL query request query service is determined to be greater than the time threshold, sending a query termination request to a corresponding database to stop the query, and displaying query timeout on the corresponding row of the page table to prompt a user.
In summary, in the service data query method provided by the invention, a database connection pool corresponding to a plurality of application systems is established; receiving an externally input query application, wherein the query application comprises one or more business item query requests; inquiring services from different databases in the database connection pool according to the inquiry application, and acquiring inquiry results; and displaying the query results obtained from the databases corresponding to different systems into the same table. Therefore, SQL query request configuration items of databases of different types of different systems are realized, and service items in the databases of different types of different systems are displayed in a WEB display page of a table. And the number of inquired people in the same time period is not limited, the inquiry speed is relatively high, the influence of a database is negligible, and great help can be provided for fortune and development staff.
While the invention has been described with reference to specific embodiments, it will be understood by those skilled in the art that various changes in form and detail may be made therein without departing from the spirit and scope of the invention.
The functional modules and hardware structures of the electronic device for implementing the service data query method are described below with reference to fig. 4 to 5.
Example two
Fig. 4 is a functional block diagram of a service data query device according to a preferred embodiment of the present invention.
In some embodiments, the service data querying device 40 operates in an electronic device. The service data querying means 40 may comprise a plurality of functional modules consisting of program code segments. Program code for each program segment in the service data querying device 40 may be stored in a memory and executed by at least one processor to perform (see fig. 1 and its associated description for details) a query of service data.
In this embodiment, the service data query device 40 may be divided into a plurality of functional modules according to the functions performed by the service data query device. The functional module may include: the system comprises a building module 401, a receiving module 402, a query module 403 and a display module 404. The module referred to in the present invention refers to a series of computer program segments capable of being executed by at least one processor and of performing a fixed function, stored in a memory. In some embodiments, the function of each module will be described in detail in the following embodiments.
The establishing module 401 is configured to establish a database connection pool corresponding to a plurality of application systems.
The basic principle of the database connection pool is to maintain a certain number of database connections in an internal object pool and expose a database connection acquisition and return method to the outside. Such as: the external user can acquire the connection through the getConnection method, and return the connection through the releaseConnection method after the use is finished, and notice that the connection is not closed at this time, but is recovered by the connection pool manager and is ready for the next use. The method specifically comprises the following steps:
a. creating a ConnectionPool instance, and initializing and creating preset values (such as 10) connections;
b. achieving getConnection () to obtain an available connection from the connection library;
c. returnConnection (conn) provides a method of placing connections back into the connection pool.
The database connection pool is responsible for distributing, managing and releasing database connections corresponding to a plurality of application systems, and allows the application systems to repeatedly use an existing database connection instead of rebuilding a database connection, thereby avoiding a great deal of performance overhead caused by frequently creating and releasing the connection.
In this embodiment, the database connection pool may include, but is not limited to, a Druid database connection pool, a DBCP data connection pool, and the like.
In this embodiment, the application system may include a safe life insurance system, a safe caretaker, a safe pocket bank, a safe insurance inquiry system, a safe claim settlement system, an endowment insurance sponsoring service system, and the like.
Preferably, each application system corresponds to at least one database, and each database may also correspond to a plurality of application systems.
Preferably, the establishing module 401 may further set a maximum connection number of the database connection pool.
When a large number of users inquire through the client side at the same time, the database connection pool limits the connection request according to the maximum connection number so as to prevent the instant rise of the SESSION (SESSION) of a certain database and further influence the service inquiry. And, for clients that do not have SESSIONs (SESSIONs) split into the database, the client will be forced to wait until there are SESSIONs (SESSIONs) available in the database connection pool, and if the waiting time exceeds a preset time (such as one minute), a prompt of "waiting timeout" is sent to the client.
The receiving module 402 is configured to receive an externally input query application, where the query application includes one or more service item query requests.
In this embodiment, the query application may be entered by the user via a user interface. The user may select a plurality of business items corresponding to a plurality of application systems or databases through a multi-choice drop down box provided on the user interface. The business item corresponds to a plurality of indexes, and the indexes comprise: the system name, the key service index name, the time period, the current service volume, the service volume of the same time period before the starting time, the service volume of the whole day before the starting time, the service volume of the same time period before the week before the starting and ending time, the comparison of the service volumes of the same time period before the week, the change rate of the same time period before the day, the influence on the whole day proportion and the like.
The index also comprises the same period change ratio of the previous day, the whole period change ratio of the previous day, the same period change ratio of the last week and the whole period change ratio of the last week.
In this embodiment, the service item query requests are configured by SQL, one service item query request corresponds to one SQL query request, and one SQL query request corresponds to one database.
The SQL query request is configured with script information. For example, an SQL query request is configured by entering select count (1) from table where businesstype = '1' and date > = $ { start_date } and date < = $ { end_date }. Where $ { start_date } and $ { end_date } are page query parameters used to input the time of a particular query. For example, when the user selects a time on the page, the system will automatically change the SQL query request to select count (1) from table where businesstype = '1' and date > = $ { start_date } and date < = $ { end_date } union all select count (1) from table where businesstype = '1' and date > = $ { start_date } -1and date < = $ { end_date } -1union all select count (1) from table where businesstype = '1' and date > = $ { start_date } -7and date < = $ { end_date } -7), with $ { start_date } and $ { end_date } replaced with the selected time to make the query.
In this embodiment, the above-mentioned index of the application system in a predetermined period (such as a system abnormality period and a holiday period) may be queried according to the query period input in the query application.
The query module 403 is configured to query a service from different databases in the database connection pool according to the query application, and obtain a query result.
In this embodiment, the step of querying the service from different databases in the database connection pool according to the query application and obtaining the query result includes:
the query module 403 analyzes the information in the query application to obtain a database operation command; the database operation instruction comprises reading business item data in a database.
The query module 403 determines a database as an operation object according to a database operation command and configuration information, wherein the configuration information comprises database types of a plurality of databases; the configuration information may also include information such as a name, an IP address, and a port of the database. The database name is the name of the database used by the system, such as the database used by safe life insurance. The database stores various business data, user information and other contents.
The query module 403 establishes a parallel query mechanism to send the query application to a determined database;
specifically, the method for establishing a parallel query mechanism to send the query application to the determined database comprises the following steps:
1) And sending the service item query request in the query application to a SPRINGMVC framework according to a specific mechanism. In this embodiment, the specific mechanism is set by the JS profile specification. For example, when the user selects to query 7 service items, the request transmission manner set by the JS profile specification is: and (3) sending 1-5 service item query requests to SPRINGMVC in parallel, wherein if the 3 rd service item query request firstly requests to return a data result (service data is returned in normal time and abnormal description is returned in abnormal time), the JS PROMISE automatically sends the 6 th service item query request. And then if the 2 nd business item query request returns a data result, the JS PROMISE automatically sends the 7 th business item query request until all the business item query requests return data. The method simply transmits the request to carry out parallel inquiry in an asynchronous and synchronous mode, so that the inquiry efficiency can be improved.
2) And after receiving the service item query request, the SPRINGMVC framework carries out parameter setting on SQL configuration in the query application. The parameter settings include substitutions and modifications to SQL, such as modifying query time.
3) And sending the service item query requests to the database connection pool one by one through a mybatis framework.
The query module 403 retrieves a database connection from a connection pool corresponding to the determined database, applies the database connection to send a database operation command to the determined database, and receives a query result from the database.
Specifically, the step of retrieving a database connection from a connection pool corresponding to the determined database, applying the database connection to send a database operation command to the determined database, and receiving a query result from the database includes the steps of:
step (a) judges whether the connection pool corresponding to the determined database has free database connection, if yes, step (b) is executed, and if no, step (c) is executed.
Step (b): directly calling a free database connection from the connection pool, and executing the step (f).
Step (c): judging whether the number of database connections reaches a preset maximum value, if so, executing the step (d), and if not, executing the step (e). The preset maximum value can be adjusted by using a configuration file according to actual working requirements.
Step (d): and (c) returning to the step (a) after delaying for a preset time to re-judge whether the connection pool has free database connection.
Step (e): creating a new database connection, and executing step (f).
Step (f): and transmitting a database operation command to a database by using the database connection, and receiving a query result from the database.
Preferably, the service data query device 40 may further set a maximum number of parallel requests allocated to the service item query requests in the query application in a preset time period. Specifically, after a user selects a large number of service items to query, the system allocates the maximum number of parallel requests, and each parallel request in the maximum number of parallel requests operates independently and returns a query result in time. The function of not sending excessive business item query requests to the corresponding databases even if the selected query items are excessive is realized.
For example, the user selects 20 business items to query, when the user clicks on the query, the system processes the 1 st to 5 th requests to query the business items, and when a certain request is finished, the system returns the result to the front page display immediately, then processes the 6 th request, and when another request is finished, the system returns the result to the front page display immediately, then processes the 7 th request, and so on until all the 20 business items are queried. That is, there are 5 requests at each time to process query terms until all query terms have been processed.
Preferably, the query module 403 may further determine whether the time of the service item query request query service in the query application is timeout.
Specifically, the method for judging whether the service item inquiry request inquiry service time in the inquiry application is overtime comprises the following steps:
a. setting a time threshold of a service item query request query service in the query application, and judging whether the time of the service item query request query service is greater than the time threshold (for example, 5 minutes);
b. if the time for inquiring the service item inquiry request is determined to be greater than the time threshold, sending an inquiry termination request to a database corresponding to the service item inquiry request to stop inquiring;
c. and if the time of the service item query request query service is less than or equal to the time threshold, continuing to query.
The display module 404 is configured to display query results obtained from databases corresponding to the multiple application systems into the same table.
In this embodiment, each SQL query request may display a query result in a corresponding display page table, where the content of one row includes only one service item, and the content of multiple rows includes multiple service items. That is, when a user selects a plurality of service items and performs a query, the query results of the plurality of service items may be presented in a form of a plurality of rows in a table of a presentation page.
For example, by configuring an SQL query request to query and count "current traffic", the query results of the "current traffic" will be presented in the form of a numerical value in the first row and column of the table. While statistics of other columns in this row may be used to show "current traffic" over different time periods. For example, by automatically changing the value of $ { start_date } to $ { start_date } -1 or $ { start_date } -7 when configuring the SQL query request, the system queries out data that was last day or 7 days ago.
Preferably, the query result is displayed in the page table according to the length of the query time. For example, the query results returned by the short-time SQL query request are displayed first, and the query results returned by the long-time SQL query request are displayed later, i.e. the query results of each row in the page table are displayed at different speeds.
In addition, if the time of the SQL query request query service is determined to be greater than the time threshold, sending a query termination request to a corresponding database to stop the query, and displaying query timeout on the corresponding row of the page table to prompt a user.
In summary, the service data query device 40 of the present invention includes a building module 401, a receiving module 402, a query module 403, and a display module 404. The establishing module 401 establishes a database connection pool corresponding to a plurality of application systems; the receiving module 402 receives an externally input query application, where the query application includes one or more business item query requests; the query module 403 queries services from different databases in the database connection pool according to the query application, and obtains a query result; the display module 404 displays the query results obtained from the databases corresponding to different systems into the same table. Therefore, SQL query request configuration items of databases of different types of different systems are realized, and service items in the databases of different types of different systems are displayed in a WEB display page of a table. And the number of inquired people in the same time period is not limited, the inquiry speed is relatively high, the influence of a database is negligible, and great help can be provided for fortune and development staff.
The integrated units implemented in the form of software functional modules described above may be stored in a computer readable storage medium. The software functional modules described above are stored in a storage medium and include instructions for causing a computer device (which may be a personal computer, a dual-screen device, or a network device, etc.) or processor (processor) to perform portions of the methods described in the various embodiments of the invention.
Example III
Fig. 5 is a schematic diagram of an electronic device according to a third embodiment of the present invention.
The electronic device 5 includes: a memory 51, at least one processor 52, a computer program 53 stored in the memory 51 and executable on the at least one processor 52, and at least one communication bus 54.
The at least one processor 52, when executing the computer program 53, implements the steps of the business data query method embodiments described above.
Illustratively, the computer program 53 may be partitioned into one or more modules/units that are stored in the memory 51 and executed by the at least one processor 52 to complete the present invention. The one or more modules/units may be a series of computer program instruction segments capable of performing the specified functions for describing the execution of the computer program 53 in the electronic device 5.
The electronic device 5 may be a mobile phone, a tablet computer, a personal digital assistant (Personal Digital Assistant, PDA) or the like, which is provided with an application program. It will be appreciated by those skilled in the art that the schematic diagram 5 is merely an example of the electronic device 5 and is not meant to be limiting of the electronic device 5, and may include more or fewer components than shown, or may combine certain components, or different components, e.g., the electronic device 5 may further include input-output devices, network access devices, buses, etc.
The at least one processor 52 may be a central processing unit (Central Processing Unit, CPU), but may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), off-the-shelf programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. The processor 52 may be a microprocessor or the processor 52 may be any conventional processor or the like, the processor 52 being a control center of the electronic device 5, the various interfaces and lines being utilized to connect the various parts of the overall electronic device 5.
The memory 51 may be used to store the computer program 53 and/or modules/units, and the processor 52 may implement various functions of the electronic device 5 by executing or executing the computer program and/or modules/units stored in the memory 51, and invoking data stored in the memory 51. The memory 51 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program (such as a sound playing function, an image playing function, etc.) required for at least one function, and the like; the storage data area may store data created according to the use of the electronic device 5 (such as audio data, phonebooks, etc.), and the like. In addition, the memory 51 may include a high-speed random access memory, and may also include a nonvolatile memory such as a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash Card (Flash Card), at least one disk storage device, a Flash memory device, or other volatile solid-state storage device.
The memory 51 has stored therein program code, and the at least one processor 52 can invoke the program code stored in the memory 51 to perform related functions. For example, the modules (the establishing module 401, the receiving module 402, the querying module 403 and the displaying module 404) shown in fig. 5 are program codes stored in the memory 51 and executed by the at least one processor 52, so as to implement the functions of the modules to achieve the purpose of service data query.
The establishing module 401 is configured to establish a database connection pool corresponding to a plurality of application systems;
the receiving module 402 is configured to receive an externally input query application, where the query application includes one or more service item query requests;
the query module 403 is configured to query a service from different databases in the database connection pool according to the query application, and obtain a query result; and
the display module 404 is configured to display query results obtained from databases corresponding to the multiple application systems into the same table.
Preferably, the query module 403 is configured to query a service from different databases in the database connection pool according to the query application, and the obtaining a query result specifically includes:
(a) Analyzing the information in the query application to obtain a database operation command;
(b) Determining a database as an operation object according to the database operation command and configuration information, wherein the configuration information comprises database types of a plurality of databases;
(c) Establishing a parallel query mechanism to send the query application to a determined database;
(d) And calling a database connection from a connection pool corresponding to the determined database, transmitting the database operation command to the determined database by applying the database connection, and receiving a query result from the determined database.
Preferably, the step (d) includes:
judging whether an idle database connection exists in a connection pool corresponding to the determined database;
when the connection pool corresponding to the determined database has idle database connection, directly calling an idle database connection from the connection pool;
and transmitting a database operation command to a database by using the database connection, and receiving a query result from the database.
Preferably, the step (d) further comprises:
when no free database connection exists in the connection pool corresponding to the determined database, judging whether the number of database connections reaches a preset maximum value;
when the number of the database connections reaches a preset maximum value, delaying for a preset period of time, and then judging whether the connection pool has idle database connections;
when the number of the database connections does not reach a preset maximum value, creating a new database connection;
and transmitting a database operation command to a database by applying the new database connection, and receiving a query result from the database.
Preferably, the electronic device 5 may further determine whether the time of the service item query request query service in the query application is timeout, which specifically includes:
Setting a time threshold of a service item query request query service in the query application, and judging whether the time of the service item query request query service is greater than the time threshold;
if the time for inquiring the service item inquiry request is determined to be greater than the time threshold, sending an inquiry termination request to a database corresponding to the service item inquiry request to stop inquiring;
and if the time of the service item query request query service is less than or equal to the time threshold, continuing to query.
Preferably, the electronic device 5 may further set a maximum number of parallel requests allocated by the service item query requests in the query application in a preset period of time.
Preferably, the service item query requests are configured by SQL, one service item query request corresponds to one SQL query request, and one SQL query request corresponds to one database.
The modules/units integrated in the electronic device 5 may be stored in a computer readable storage medium if implemented in the form of software functional units and sold or used as separate products. Based on such understanding, the present invention may implement all or part of the flow of the method of the above embodiment, or may be implemented by a computer program to instruct related hardware, where the computer program may be stored in a computer readable storage medium, where the computer program, when executed by a processor, may implement the steps of each of the method embodiments described above. Wherein the computer program comprises computer program code which may be in source code form, object code form, executable file or some intermediate form etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), an electrical carrier signal, a telecommunications signal, a software distribution medium, and so forth. It should be noted that the computer readable medium contains content that can be appropriately scaled according to the requirements of jurisdictions in which such content is subject to legislation and patent practice, such as in certain jurisdictions in which such content is subject to legislation and patent practice, the computer readable medium does not include electrical carrier signals and telecommunication signals.
In the several embodiments provided in the present invention, it should be understood that the disclosed electronic device and method may be implemented in other manners. For example, the above-described embodiments of the electronic device are merely illustrative, and for example, the division of the units is merely a logical function division, and there may be other manners of division when actually implemented.
In addition, each functional unit in the embodiments of the present invention may be integrated in the same processing unit, or each unit may exist alone physically, or two or more units may be integrated in the same unit. The integrated units can be realized in a form of hardware or a form of hardware and a form of software functional modules.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential characteristics thereof. The present embodiments are, therefore, to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference sign in a claim should not be construed as limiting the claim concerned. Furthermore, it will be obvious that the term "comprising" does not exclude other elements or that the singular does not exclude a plurality. A plurality of units or means recited in the system claims can also be implemented by means of software or hardware by means of one unit or means. The terms first, second, etc. are used to denote a name, but not any particular order.
Finally, it should be noted that the above-mentioned embodiments are merely for illustrating the technical solution of the present invention and not for limiting the same, and although the present invention has been described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications and equivalents may be made to the technical solution of the present invention without departing from the spirit and scope of the technical solution of the present invention.

Claims (8)

1. A business data query method, the method comprising:
establishing a database connection pool corresponding to a plurality of application systems;
receiving an externally input query application, wherein the query application comprises one or more business item query requests;
setting the maximum parallel request number distributed in a preset time period by the service item query request in the query application;
inquiring services from different databases in the database connection pool according to the inquiry application and the maximum parallel request number, and acquiring inquiry results, wherein each parallel request in the maximum parallel request number operates independently and returns the inquiry results in time, and the steps of inquiring services from different databases in the database connection pool according to the inquiry application, and acquiring the inquiry results specifically comprise:
(a) Analyzing the information in the query application to obtain a database operation command;
(b) Determining a database as an operation object according to the database operation command and configuration information, wherein the configuration information comprises database types of a plurality of databases;
(c) Establishing a parallel query mechanism to send the query application to a determined database;
(d) The database connection is called from the connection pool corresponding to the determined database, the database connection is applied to send the database operation command to the determined database, and a query result is received from the determined database; and
and displaying the query results obtained from the databases corresponding to the plurality of application systems into the same table.
2. The service data query method of claim 1, wherein the step (d) comprises:
judging whether an idle database connection exists in a connection pool corresponding to the determined database;
when the connection pool corresponding to the determined database has idle database connection, directly calling an idle database connection from the connection pool;
and transmitting a database operation command to a database by using the database connection, and receiving a query result from the database.
3. The service data query method of claim 2, wherein the step (d) further comprises:
when no free database connection exists in the connection pool corresponding to the determined database, judging whether the number of database connections reaches a preset maximum value;
when the number of the database connections reaches a preset maximum value, delaying for a preset period of time, and then judging whether the connection pool has idle database connections;
when the number of the database connections does not reach a preset maximum value, creating a new database connection;
and transmitting a database operation command to a database by applying the new database connection, and receiving a query result from the database.
4. The service data query method as claimed in claim 1, wherein said method further comprises a step of judging whether a time for querying a service item query request in a query application is overtime, said step comprising:
setting a time threshold of a service item query request query service in the query application, and judging whether the time of the service item query request query service is greater than the time threshold;
if the time for inquiring the service item inquiry request is determined to be greater than the time threshold, sending an inquiry termination request to a database corresponding to the service item inquiry request to stop inquiring;
And if the time of the service item query request query service is less than or equal to the time threshold, continuing to query.
5. The business data query method of claim 1, wherein said business item query requests are configured by SQL, one business item query request corresponding to one SQL query request, one said SQL query request corresponding to one database.
6. A business data query device, the device comprising:
the establishing module is used for establishing database connection pools corresponding to a plurality of application systems;
the system comprises a receiving module, a processing module and a processing module, wherein the receiving module is used for receiving an externally input query application, the query application comprises one or more service item query requests, and the maximum parallel request number distributed in a preset time period of the service item query requests in the query application is set;
the query module is used for querying services from different databases in the database connection pool according to the query application and obtaining query results, wherein each parallel request in the maximum parallel request number operates independently and returns the query results in time, and the query module is used for querying services from different databases in the database connection pool according to the query application and obtaining the query results specifically comprises:
(a) Analyzing the information in the query application to obtain a database operation command;
(b) Determining a database as an operation object according to the database operation command and configuration information, wherein the configuration information comprises database types of a plurality of databases;
(c) Establishing a parallel query mechanism to send the query application to a determined database;
(d) The database connection is called from the connection pool corresponding to the determined database, the database connection is applied to send the database operation command to the determined database, and a query result is received from the determined database; and
and the display module is used for displaying the query results obtained from the databases corresponding to the plurality of application systems into the same table.
7. An electronic device comprising a processor and a memory, wherein the processor is configured to implement the business data query method of any of claims 1 to 5 when executing a computer program stored in the memory.
8. A computer readable storage medium having stored thereon a computer program, wherein the computer program when executed by a processor implements the business data query method of any of claims 1 to 5.
CN201811151266.0A 2018-09-29 2018-09-29 Service data query method and device, electronic equipment and storage medium Active CN109508344B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811151266.0A CN109508344B (en) 2018-09-29 2018-09-29 Service data query method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811151266.0A CN109508344B (en) 2018-09-29 2018-09-29 Service data query method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN109508344A CN109508344A (en) 2019-03-22
CN109508344B true CN109508344B (en) 2024-03-12

Family

ID=65746225

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811151266.0A Active CN109508344B (en) 2018-09-29 2018-09-29 Service data query method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN109508344B (en)

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110263129A (en) * 2019-06-25 2019-09-20 四川长虹电器股份有限公司 The method for carrying out slow inquiry operation statistics based on Mybatis frame
CN110347386A (en) * 2019-06-28 2019-10-18 北京淇瑀信息科技有限公司 A kind of method, apparatus and electronic equipment of the data visualization analysis based on SQL code editor
CN110727727B (en) * 2019-10-15 2023-01-10 深圳前海微众银行股份有限公司 Statistical method and device for database
CN111399997B (en) * 2020-02-25 2024-02-23 新浪技术(中国)有限公司 Overload protection method and device for MongoDB
CN111563125B (en) * 2020-05-08 2024-04-16 中国工商银行股份有限公司 Data storage system, data query method and device
CN111708848B (en) * 2020-06-12 2024-02-23 北京思特奇信息技术股份有限公司 Data query method, system and electronic equipment
CN111782872B (en) * 2020-06-30 2023-08-08 北京百度网讯科技有限公司 Query method, query device, electronic equipment and storage medium
CN112073492B (en) * 2020-08-31 2022-12-13 中国平安财产保险股份有限公司 Request execution method and device, electronic equipment and storage medium
CN112307066B (en) * 2020-11-03 2023-04-07 平安普惠企业管理有限公司 Distributed data aggregation method, system, device and storage medium
CN113821526A (en) * 2020-12-23 2021-12-21 京东科技信息技术有限公司 Method, device and equipment for querying data and storage medium
CN114564637A (en) * 2022-01-07 2022-05-31 支付宝(杭州)信息技术有限公司 Information processing method and device
CN115022254A (en) * 2022-06-02 2022-09-06 江苏新质信息科技有限公司 Strategy matching searching method and device based on FPGA

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103064960A (en) * 2012-12-31 2013-04-24 华为技术有限公司 Method and equipment for database query
CN103365929A (en) * 2012-04-10 2013-10-23 阿里巴巴集团控股有限公司 Management method and management system of database connection
CN105574052A (en) * 2014-11-06 2016-05-11 中兴通讯股份有限公司 Database query method and apparatus
CN105912624A (en) * 2016-04-07 2016-08-31 北京中安智达科技有限公司 Query method for distributed deployed heterogeneous database
CN106407244A (en) * 2016-06-21 2017-02-15 平安科技(深圳)有限公司 Multi-database-based data query method, system and apparatus
CN107609091A (en) * 2017-09-08 2018-01-19 国云科技股份有限公司 A kind of inter-library multilist conjunctive query system and its implementation
CN107622091A (en) * 2017-08-23 2018-01-23 阿里巴巴集团控股有限公司 A kind of data base query method and device
CN107818127A (en) * 2017-09-09 2018-03-20 国网浙江省电力公司 A kind of querying method and system for multi-source data

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8145611B2 (en) * 2005-09-20 2012-03-27 Teradata Us, Inc. Servicing queries in a database system

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103365929A (en) * 2012-04-10 2013-10-23 阿里巴巴集团控股有限公司 Management method and management system of database connection
CN103064960A (en) * 2012-12-31 2013-04-24 华为技术有限公司 Method and equipment for database query
CN105574052A (en) * 2014-11-06 2016-05-11 中兴通讯股份有限公司 Database query method and apparatus
CN105912624A (en) * 2016-04-07 2016-08-31 北京中安智达科技有限公司 Query method for distributed deployed heterogeneous database
CN106407244A (en) * 2016-06-21 2017-02-15 平安科技(深圳)有限公司 Multi-database-based data query method, system and apparatus
CN107622091A (en) * 2017-08-23 2018-01-23 阿里巴巴集团控股有限公司 A kind of data base query method and device
CN107609091A (en) * 2017-09-08 2018-01-19 国云科技股份有限公司 A kind of inter-library multilist conjunctive query system and its implementation
CN107818127A (en) * 2017-09-09 2018-03-20 国网浙江省电力公司 A kind of querying method and system for multi-source data

Also Published As

Publication number Publication date
CN109508344A (en) 2019-03-22

Similar Documents

Publication Publication Date Title
CN109508344B (en) Service data query method and device, electronic equipment and storage medium
CN109408337B (en) Interface operation and maintenance method and device
CN110310034B (en) Service arrangement and business flow processing method and device applied to SaaS
CN109344170B (en) Stream data processing method, system, electronic device and readable storage medium
DE102012109629A1 (en) Mobile multi-mode customer care system
CN111049878A (en) Method, device, electronic device and storage medium for visualizing micro-service call chain
CN110224899B (en) TCP application call chain acquisition method and device
CN101710320A (en) Statistical index data processing method and device
CN111784318A (en) Data processing method and device, electronic equipment and storage medium
CN108363741B (en) Big data unified interface method, device, equipment and storage medium
CN110928681A (en) Data processing method and device, storage medium and electronic device
CN103297419B (en) Line rolls off the production line upper data fusion method and system
CN110941634A (en) Data processing method and device, storage medium and electronic device
CN110648105B (en) Recommendation method and device based on data processing, electronic equipment and storage medium
CN111047362A (en) Statistical management method and system for use activity of intelligent sound box
CN109829680B (en) Scheduling method, scheduling device, computer device and storage medium
CN111506644B (en) Application data processing method and device and electronic equipment
CN110555201B (en) Knowledge document generation method, device, electronic equipment and storage medium
EP3138273B1 (en) Method and apparatus for providing communication interaction visibility
CN111831720A (en) Data display method and system and electronic equipment
CN116385102B (en) Information recommendation method, device, computer equipment and storage medium
CN113765773B (en) Method and device for processing communication record
CN114143279B (en) Interactive recording sampling method and device and storage medium
CN111182029B (en) Information processing method, device, equipment and storage medium
CN115408393A (en) Data relation network mapping method, system, storage medium and computer equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant