Disclosure of Invention
The invention provides a report display method and a report display device, which are used for solving the problem that when the report data is displayed by inquiring a tree-shaped list, a user does not know which field of the tree-shaped list the inquiry keyword is in, so that the searching speed is too slow.
In order to achieve the purpose, the technical scheme of the invention is realized as follows:
in one aspect, the present invention provides a report display method, including:
receiving an inquiry request, wherein the inquiry request carries a report document number;
initializing a query field set according to the report document number;
dynamically spelling Structured Query Language (SQL) statements in a report database according to query condition information and report document numbers selected by a user in a query field set to obtain SQL query statements, wherein the SQL statements are registered in the report database, and each SQL statement corresponds to one report document number;
inquiring a corresponding result set in the report database according to the SQL inquiry statement, and processing data in the result set to obtain tree-shaped structure data with a superior-inferior relation;
and performing tree representation on the tree structure data in the result set in the report.
In another aspect, the present invention provides a report display apparatus, including:
the receiving unit is used for receiving an inquiry request, and the inquiry request carries a report document number;
the initialization unit is used for initializing the query field set according to the report document number;
the system comprises a spelling unit, a query unit and a report form database, wherein the spelling unit is used for dynamically spelling Structured Query Language (SQL) sentences in the report form database according to query condition information and report form document numbers selected by a user in a query field set to obtain SQL query sentences, the SQL sentences are registered in the report form database, and each SQL sentence corresponds to one report form document number;
the query processing unit is used for querying a corresponding result set in the report database according to the SQL query statement and processing data in the result set to obtain tree-shaped structure data with a superior-inferior relation;
and the display unit is used for performing tree display on the tree structure data in the result set in the report.
The invention has the beneficial effects that: the SQL sentences are registered in the report database, the query field set is dynamically initialized according to the report document number carried by the query request, so that a user can select the query keywords according to the requirement, the SQL query sentences are dynamically spelled according to the query keywords to query the result set, the data of the result set is processed according to the query keywords to obtain the tree-shaped structure data with the upper and lower level relations, the tree-shaped structure data is displayed in the report in a tree form, and the user only masters the keywords without knowing which field of the tree-shaped list the keywords are in, so that the aim of quickly searching is fulfilled.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail with reference to the accompanying drawings.
Fig. 1 is a flowchart of a report presentation method according to an embodiment of the present invention, and as shown in fig. 1, the method according to the embodiment includes:
s110, receiving an inquiry request, wherein the inquiry request carries a report document number.
And S120, initializing a query field set according to the report document number.
In this embodiment, the report form number is associated with an inquiry field set, and the inquiry field set includes all inquiry field information associated with the report form number. Exemplarily, if the report is a purchase report, if the query field information corresponding to the document number of the purchase report includes the name of an article, the model of the article, the purpose of the article, and the price of the article, the query field initialized according to the document number of the purchase report collectively includes the name of the article, the model of the article, the purpose of the article, and the price of the article; if the report is a personnel statistics report, if the query field information corresponding to the document number of the personnel statistics report comprises: and the inquiry field set initialized according to the bill number of the personnel statistical report comprises the employee name, the employee gender, the employee post and the employee leave-on date.
S130, dynamically spelling a Structured Query Language (SQL) statement in a report database according to Query condition information and a report document number selected by a user in a Query field set to obtain an SQL Query statement; SQL sentences are registered in the report database, and each SQL sentence corresponds to a report document number.
The report database of the embodiment is a database supporting SQL query.
S140, inquiring a corresponding result set in the report database according to the SQL inquiry statement, and processing the data in the result set to obtain the tree-structured data with the upper and lower level relations.
S150, tree-shaped display is carried out on the tree-shaped structure data in the result set in the report.
In this embodiment, the result set data is tree-displayed by using the query keyword in the query condition information as a root node, and if the data in the result set includes tree-structured data using a as the root node, tree-structured data using B as the root node, and tree-structured data using C as the root node, the report simultaneously displays the tree-structured data using A, B, C as the root node.
In the embodiment, SQL sentences are registered in the report database, the query field set is dynamically initialized according to the report document number carried by the query request, so that a user can select query keywords according to requirements, the SQL query sentences are dynamically spelled according to the query keywords to query the result set, the data of the result set is processed according to the query keywords to obtain tree-shaped structure data with an upper-level and lower-level relation, the tree-shaped structure data is displayed in the report in a tree form, and the user only needs to master the keywords without knowing which field of the tree-shaped list the keywords are in, so that the purpose of quick search is achieved.
The report query method of the embodiment is simple and convenient to operate, accords with user habits, and is wide in application range.
In one embodiment of the invention, SQL statements are registered in the report database by the following method:
splitting a pre-written SQL statement according to a selection query Select field, a table query From field, a query condition Where field and a query grouping group field, and storing split words obtained by splitting into four corresponding excel tables, wherein the four excel tables are associated through a report document number and respectively correspond to a main table, a sub table, a relation table and a query condition table in a report database; and importing the word segmentation corresponding to each excel table into the table corresponding to the report database.
Illustratively, taking splitting an SQL statement Select column name From table name Where condition name is 'value' group name as an example, splitting the SQL statement according to a Select field, a From field, a Where field and a group name field in sequence to divide 1-column name, divide 2-table name, divide 3-condition name 'value' and divide 4-group name, importing the divide 1-column name into a main table, importing the divide 2-table name into a sub-table, importing the divide 3-condition name 'value' into a relation table, and importing the divide 4-group name into a query condition table.
In practical application, a secondary developer writes a large and complete SQL statement of a statistical report in advance, and splits the written SQL statement into corresponding excel tables, where the four excel tables are associated by a report document number and are respectively a main table (FX _ ReportConfigGroupMain), a sub table (FX _ ReportConfigColSub), a relation table (FX _ fxrelationship) and a query condition table (FX _ confregroupware) in a report database, and may use a JSTL tool to import data corresponding to each excel table into a corresponding table in the report database, complete registration of SQL statement, and then encapsulate corresponding fields into SQL query statements for data query according to generated query fields and grouping fields.
In one embodiment of the present invention, the present embodiment initializes the set of query fields by:
acquiring a query field set corresponding to a report document number according to an initialization query method getSearchConditionByMenuCode (); initializing list head information of a pre-displayed form according to a query field set, wherein a keyword query frame and a condition query frame are arranged in the pre-displayed form.
For example, a pre-display table with table name JTable may be initialized in advance for display by the user, and a keyword query box and a condition query box are displayed in a query area of the JTable table. As shown in fig. 2, a keyword query box is set in the query area of the table shown in fig. 2, and the query area shown in fig. 2 does not display a condition query box, and at this time, the condition field may be defaulted to be a full field.
Correspondingly, dynamically spelling the SQL statement in the report database includes:
generating grouping information and condition information according to a query keyword input by a user in the keyword query box and a query condition input by a user in the condition query box, extracting four object values for spelling an SQL query statement according to report form number information, calling a statement query method getSQL according to the grouping information and the condition information, and spelling the SQL query statement corresponding to the query request based on the four object values.
The embodiment may invoke a data query method queryFilterData to respond to the selection operation of the user, and generate the group information and the condition information corresponding to the query keyword and the query condition by using a group mapping table attribute groupMap.
In practical application, the report presentation method can be realized by using CORE JAVA SWING, and various queries and presentations of the report are processed by using a unified parent class. In this embodiment, database query is performed in combination with information generated by a user selecting a foreground report and a background registered SQL statement, and a queried result set is processed into tree-structured data for data display in the report.
Illustratively, a report subclass, such as the report subclass BookFileCountUI (the report subclass is a report parent class of an abstract class such as report nested class reportnestui) may be used, and four object values VO for preparing a spelled SQL statement, i.e., a main table object value reportconfiggroupmainnvo, a sub table object value ReportConfigColSubVO, a relational table object value fxconcurgroupsvo, and a query condition object value confregroupwherevo, are extracted according to a report document number, at this time, a pre-display form is initialized by using a report tool JTable for a user to display, and a column displayed at this time of the initialized pre-display form is a large complete set of all fields in a query field set.
When a user opens a report to generate a query request, the embodiment acquires and queries all queryable query condition information according to the query request carrying the report document number, and completes initialization work before displaying a list. A user can input keywords or select keywords in the keyword query box shown in fig. 2 as required, when the user clicks a query button, the reportnestui parent class calls a data query method queryFilterData to respond to the query request of the user, and group information and condition information corresponding to the query keywords and the query conditions are generated by using the group table groupMap attributes.
And the report NestedUI parent class calls an acquisition method getSQL of the report NestedUI parent class according to the generated grouping information and condition information, acquires a corresponding SQL query statement by an inquiry nesting method queryNestedData () in a report class report Impl and a concateSQL method of a nesting class NestedSql, queries a corresponding result set and returns the result set to the report NestedUI method, and then processes data in the result set to obtain tree-shaped structure data taking a query keyword as a root node.
In the data processing of the result set, the data in the result set can be packaged by using a Java toolkit Bean and returned to the pre-display table, so that the multi-condition query is completed.
In this embodiment, before encapsulating the data, the data in the result set is subjected to service aggregation, and different processing modes are adopted according to different fields. The service summary function of this embodiment needs to be determined according to the requirement, as shown in fig. 2, a field "% Completed" indicates the process of averaging data, a field "Work" indicates the process of summing data, a field "Start" indicates the minimum value in the data, and a field "Finish" indicates the maximum value in the data.
Corresponding to the method embodiment, the invention also provides a report display device embodiment. Fig. 3 is a block diagram of a report presentation apparatus according to an embodiment of the present invention, and as shown in fig. 3, the apparatus includes:
the receiving unit 31 is configured to receive an inquiry request, where the inquiry request carries a report document number;
the initialization unit 32 is used for initializing the query field set according to the report document number;
the spelling unit 33 is used for dynamically spelling SQL sentences in the report database according to the query condition information and the report bill number selected by the user in the query field set to obtain SQL query sentences, wherein the SQL sentences are registered in the report database, and each SQL sentence corresponds to one report bill number;
the query processing unit 34 is configured to query a corresponding result set in the report database according to the SQL query statement, and process data in the result set to obtain tree-like structure data having a hierarchical relationship;
and the display unit 35 is used for performing tree display on the tree structure data in the result set in the report.
Preferably, in this embodiment, the apparatus in fig. 3 further includes a registration import unit;
the registration import unit is used for splitting a pre-written SQL sentence according to a Select field, a From field, a Where field and a group field, storing the split participles into four corresponding excel tables, wherein the four excel tables are associated through a report document number and respectively correspond to a main table, a sub-table, a relation table and a query condition table in a report database; and importing the word segmentation corresponding to each excel table into the table corresponding to the report database.
In an embodiment of the present invention, the initializing unit 32 is further configured to obtain a query field set corresponding to the report document number according to an initialization query method getsearccordinationbymenucode (); initializing list head information of a pre-displayed form according to the query field set, and setting a keyword query frame and a condition query frame in the pre-displayed form.
In another embodiment of the present invention, the spelling unit 33 is further configured to generate grouping information and condition information according to the query keyword in the keyword query box and the query condition in the condition query box; extracting four object values for spelling the SQL query statement according to the report document number information; and calling a statement query method getSQL according to the grouping information and the condition information, and spelling the SQL query statement corresponding to the query request based on the four object values.
The spelling unit 33 specifically calls a data query method queryFilterData to respond to a selection operation of a user, and generates grouping information and condition information corresponding to the query condition, the query keyword, and the query value by using a grouping table groupMap attribute.
To sum up, the embodiment of the invention provides a report presentation method and a device, SQL sentences are registered in a report database, a query field set is dynamically initialized according to report document numbers carried by query requests, so that a user can select query keywords according to needs, SQL query sentences are dynamically spelled according to the query keywords to query a result set, data of the result set are processed according to the query keywords to obtain tree-shaped structure data with a hierarchical relationship, the tree-shaped structure data are presented in the report, the user only grasps the keywords without knowing which fields of the tree-shaped list the keywords are in, and the purpose of quick search is achieved.
For the convenience of clearly describing the technical solutions of the embodiments of the present invention, in the embodiments of the present invention, the words "first", "second", and the like are used to distinguish the same items or similar items with basically the same functions and actions, and those skilled in the art can understand that the words "first", "second", and the like do not limit the quantity and execution order.
While the foregoing is directed to embodiments of the present invention, other modifications and variations of the present invention may be devised by those skilled in the art in light of the above teachings. It should be understood by those skilled in the art that the foregoing detailed description is for the purpose of better explaining the present invention, and the scope of the present invention should be determined by the scope of the appended claims.