A WebSocket-based online report generation method and system

By using the WebSocket protocol to generate reports online, the problems of delay and inaccuracy in report generation under the HTTP protocol are solved, enabling real-time data synchronization and accurate report generation, and supporting timely optimization of production decisions.

CN119939066BActive Publication Date: 2025-11-14NANJING BESTWAY AUTOMATION SYST
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510007241.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-03
Publication Date
2025-11-14
Estimated Expiration
2045-01-03

AI Technical Summary

Technical Problem

In existing technologies, report generation methods based on the HTTP protocol result in delays in real-time data acquisition and untimely data synchronization, leading to lagging and inaccurate report information, which affects the timeliness and accuracy of production decisions.

Method used

The WebSocket protocol is used for data communication between the client and the server. The WebSocket server stores all data at a preset frequency and pushes change messages to achieve real-time data synchronization and push, ensuring the consistency and accuracy of data on each client.

Benefits of technology

It improves the timeliness and accuracy of report generation, reduces data transmission latency and memory usage, ensures data reliability and integrity, and supports anomaly analysis and rapid data updates.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119939066B_ABST
    Figure CN119939066B_ABST
Patent Text Reader

Abstract

This invention belongs to the field of data processing technology and provides a method and system for online report generation based on WebSocket. The method includes: storing full data at a first preset frequency; when a WebSocket client modifies the full data, pushing a change message to other clients; storing full data of the monitored target at a second preset frequency within a preset time period; periodically pushing change messages to clients that have not sent response messages until a corresponding response message is received or the change message cached by the server expires; establishing a connection after receiving a connection request from a new client; and, if the change message has not expired, pushing the change message and the full data of the monitored target stored at the second preset frequency within the preset time period to the new WebSocket client; each WebSocket client generating a report based on the original full data or the full data containing the changed data. This invention achieves efficient data transmission based on the WebSocket protocol, improving the real-time performance and accuracy of the generated reports.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, and specifically to a method and system for online report generation based on WebSocket. Background Technology

[0002] In various production processes, reports can dynamically summarize and display production data in chart form, thereby providing an important basis for adjusting and optimizing production decisions.

[0003] To achieve online report generation, firstly, a data transmission link needs to be established between the client and the corresponding server; then, real-time data from each monitored device or location will be transmitted to the client through the corresponding server; subsequently, the acquired real-time data will be processed based on the corresponding report generation tool to obtain specific reports.

[0004] However, in existing technologies, on the one hand, data transmission between the client and the corresponding server is based on the HTTP protocol. HTTP is a request-based data transmission protocol; that is, data transmission from the server to the client is only triggered when the client sends a data retrieval request to the corresponding server. Consequently, during report generation, the latency of real-time data retrieval leads to delays in report information. On the other hand, each associated client retrieves data independently, resulting in a failure to synchronize data when data is abnormal or changes occur, leading to inaccurate report information. This, in turn, affects the timeliness and accuracy of production decision adjustments or optimization processes, preventing the decisions made from achieving optimal results. Summary of the Invention

[0005] The purpose of this invention is to provide an online report generation method based on WebSocket, so as to improve the technical problem that the delay and asynchrony of the existing real-time data acquisition leads to the lag and inaccuracy of report information, which in turn makes it difficult to optimize production decisions.

[0006] To achieve the above objectives, the present invention proposes the following technical solution:

[0007] Firstly, this technical solution provides an online report generation method based on WebSocket, which is based on data communication between a WebSocket client and a WebSocket server; including:

[0008] The WebSocket server stores the full data of the monitored target in a MySQL database at a first preset frequency so that all WebSocket clients in the associated client list can access the full data; wherein, the associated client list is created and stored in a Redis database to store the attribute information of all WebSocket clients with the same monitored target;

[0009] When any WebSocket client is determined to have modified the full data, a change message is pushed to the remaining WebSocket clients in the corresponding associated client list. Simultaneously, the full data of the monitored target is stored in the MySQL database at a second preset frequency within a preset time period. The change message includes: the modified data, the corresponding original data, and the ID of the WebSocket client that modified the data. The change message is cached on the WebSocket server. The second preset frequency is greater than the first preset frequency.

[0010] Obtain the response message from any other WebSocket client to change the response status of the corresponding WebSocket client in the associated client list, and push the change message to any other WebSocket client that has not sent a response message at a third preset frequency until the corresponding response message is received or the change message cached in the WebSocket server expires;

[0011] After receiving a connection request from a new WebSocket client, if the total number of connected clients is less than the connection threshold, a connection is established with the new WebSocket client, and the attribute information of the new WebSocket client is cached in the corresponding associated client list in the Redis database.

[0012] If it is determined that the change message has not expired, the change message and the full data of the monitoring target stored at a second preset frequency within a preset time period are pushed to the new WebSocket client;

[0013] At this time, each WebSocket client in the associated client list, including the new WebSocket client, generates a report based on the original full data of the call, or the full data containing the changed data.

[0014] Furthermore, the associated client list includes each WebSocket client, including the new WebSocket client, which generates reports based on the original full data from the call, or the full data containing changed data; including:

[0015] Each WebSocket client retrieves the report template and the associated attribute configuration template from the report component database.

[0016] Based on the attribute configuration template, target data is extracted from the original full data or the full data containing the changed data;

[0017] The target data is populated into the report template to generate the target report, and both the target data and the target report are stored in the business database.

[0018] The target report is displayed on the front end, and the target data of the corresponding segment is retrieved from the business database and displayed on the front end based on the operation of any report item or report area in the target report.

[0019] Furthermore, including:

[0020] When the WebSocket server determines that it receives a Ping message from any WebSocket client within the valid time of the client, it sends a Pong message back to the client and resets the timestamp corresponding to the Ping message to the initial time point of the client in the associated client list; wherein, the valid time of the client is the first preset time period after the initial time point.

[0021] Conversely, a close frame is sent to any of the WebSocket clients, and any of the WebSocket clients is removed from the list of associated clients.

[0022] Furthermore, including:

[0023] If no Ping message is received from any WebSocket client within the second preset time period preceding the termination time, the list of associated clients is traversed to point the pointer to any WebSocket client.

[0024] Send a connection request to any of the WebSocket clients, and if a response or Ping message is received within the valid time, reset the timestamp corresponding to the response or Ping message to the initial time point of any of the WebSocket clients in the associated client list; otherwise, delete any of the WebSocket clients from the associated client list based on the pointer pointing to deletion.

[0025] The inquiry feedback is used to keep the connection in order.

[0026] Furthermore, after obtaining the connection request from the new WebSocket client, if the total number of connected clients is less than the connection threshold, a connection is established with the new WebSocket client, and the attribute information of the new WebSocket client is cached in the corresponding associated client list in the Redis database; this includes:

[0027] After determining that a number of new WebSocket client connection requests are obtained within the second preset time period, if the total number of clients is not less than the number threshold when a connection is established with each new WebSocket client, a connection is established with each new WebSocket client in sequence according to the preset priority order.

[0028] The priority order is as follows: the connection priority of a new WebSocket client that reconnects after being abnormally disconnected due to network reasons is higher than the connection priority of a new WebSocket client that requests a connection based on the request sending timestamp.

[0029] The connection status between the WebSocket server and any WebSocket client is monitored in real time by the corresponding WebSocket client.

[0030] Secondly, this technical solution provides an online report generation system based on WebSocket, which relies on data communication between a WebSocket client and a WebSocket server; including:

[0031] The first storage module is used to enable the WebSocket server to store the full data of the monitoring target into a MySQL database at a first preset frequency so that all WebSocket clients in the associated client list can access the full data; wherein, the associated client list is created and stored in a Redis database to store the attribute information of all WebSocket clients with the same monitoring target;

[0032] The first push module is used to determine when any WebSocket client modifies the full data, and then push a change message to the other WebSocket clients in the corresponding associated client list. Simultaneously, it triggers the storage of the full data of the monitored target into a MySQL database at a second preset frequency within a preset time period. The change message includes: the modified data, the corresponding original data, and the ID of the WebSocket client that modified the data. The change message is cached on the WebSocket server. The second preset frequency is greater than the first preset frequency.

[0033] The second push module is used to obtain the response message of any other WebSocket client to change the response status of the corresponding WebSocket client in the associated client list, and push the change message to any other WebSocket client that has not sent a response message at a third preset frequency until the corresponding response message is received or the change message cached in the WebSocket server expires.

[0034] The connection establishment module is used to obtain a connection request from a new WebSocket client, determine if the total number of connected clients is less than the connection number threshold, establish a connection with the new WebSocket client, and cache the attribute information of the new WebSocket client in the corresponding associated client list in the Redis database.

[0035] The third push module determines that the change message has not expired, and pushes the change message and the full data of the monitoring target stored at a second preset frequency within a preset time period to the new WebSocket client. At this time, each WebSocket client in the associated client list, including the new WebSocket client, generates a report based on the original full data or the full data containing the change data.

[0036] Furthermore, including:

[0037] The template acquisition module is used to enable each WebSocket client to automatically acquire the report template from the report component database, as well as the attribute configuration template associated with the report template;

[0038] The data extraction module is used to extract target data from the original full data or the full data containing changed data based on the attribute configuration template.

[0039] The second storage module is used to fill the target data into the report template to generate the target report, and at the same time, both the target data and the target report are stored in the business database.

[0040] The display module is used to display the target report on the display front end, and to retrieve the target data of the corresponding segment from the business database to the display front end based on the operation of any report item or report area in the target report.

[0041] Furthermore, including:

[0042] The online monitoring module is used to enable the WebSocket server to send a Pong message back to any WebSocket client when it receives a Ping message from any WebSocket client within the effective time of the client, and to reset the timestamp corresponding to the Ping message to the initial time point of any WebSocket client in the associated client list; wherein, the effective time of any WebSocket client is the first preset time period after the initial time point;

[0043] Conversely, a close frame is sent to any of the WebSocket clients, and any of the WebSocket clients is removed from the list of associated clients.

[0044] Thirdly, this technical solution provides an electronic device including at least one processor coupled to a memory, the memory storing a computer program configured to be executed by the processor when it is run.

[0045] Fourthly, this technical solution provides a computer-readable storage medium, characterized in that it stores a computer program thereon, the computer program being executed by a processor to implement the method described thereon.

[0046] Beneficial effects:

[0047] As can be seen from the above technical solutions, the technical solution of the present invention provides a WebSocket-based online report generation method to improve the existing technical problems of delayed and inaccurate report information.

[0048] The method includes: First, the WebSocket server stores the full data of the monitoring target in a MySQL database at a first preset frequency for all WebSocket clients in the associated client list to access the full data; wherein, the associated client list is created and stored in a Redis database to store attribute information of all WebSocket clients with the same monitoring target. Second, when any WebSocket client modifies the full data, a change message is pushed to the remaining WebSocket clients in the corresponding associated client list, and simultaneously, the full data of the monitoring target is stored in the MySQL database at a second preset frequency within a preset time period; wherein, the change message includes: modified data, corresponding original data, and the ID of the WebSocket client that modified the data; the change message is cached in the WebSocket server; the second preset frequency is greater than the first preset frequency. Then, the response message of any other WebSocket client is obtained to change the response status of the corresponding WebSocket client in the associated client list, and the change message is pushed to any other WebSocket client that has not sent a response message at a third preset frequency until a corresponding response message is received or the change message cached in the WebSocket server expires.

[0049] Furthermore, after receiving a connection request from a new WebSocket client, if the total number of connected clients is less than a connection threshold, a connection is established with the new WebSocket client, and the attribute information of the new WebSocket client is cached in the corresponding associated client list in the Redis database. Simultaneously, if the change message has not expired, the change message and the full data of the monitoring target stored at a second preset frequency within a preset time period are pushed to the new WebSocket client. At this point, each WebSocket client in the associated client list, including the new WebSocket client, can generate reports based on the original full data or the full data containing the change data.

[0050] In summary, this embodiment introduces the WebSocket protocol into the data transmission between the client and server to avoid data transmission delays caused by request-based data transmission. It also establishes a data synchronization mechanism for each client, ensuring that any data modification on one client is synchronized to other clients, thus guaranteeing the reliability of the data obtained by each client. Furthermore, it retrieves and saves data near the modified data for easier anomaly analysis. Additionally, it pushes changed data to newly established clients to ensure the integrity of their acquired data, and sets a timeliness ratio for changed data to avoid the overhead of long-term storage. Overall, this effectively improves the timeliness and accuracy of the final generated reports.

[0051] It should be understood that all combinations of the foregoing concepts and the additional concepts described in more detail below can be considered part of the inventive subject matter of this disclosure, provided that such concepts do not contradict each other.

[0052] The foregoing and other aspects, embodiments, and features of the teachings of the present invention will be more fully understood from the following description in conjunction with the accompanying drawings. Other additional aspects of the invention, such as features and / or beneficial effects of exemplary embodiments, will become apparent from the following description or may be learned through practice of specific embodiments according to the teachings of the present invention. Attached Figure Description

[0053] The accompanying drawings are not intended to be drawn to scale. In the drawings, each identical or nearly identical component shown in the various figures may be denoted by the same reference numeral. For clarity, not every component is labeled in each figure. Embodiments of various aspects of the invention will now be described by way of example and with reference to the accompanying drawings, wherein:

[0054] Figure 1 This is a flowchart of the online report generation method based on WebSocket described in this embodiment;

[0055] Figure 2 Flowchart for handling multiple new WebSocket clients requesting connections simultaneously;

[0056] Figure 3 A flowchart for confirming connection status;

[0057] Figure 4 Another flowchart for confirming connection status;

[0058] Figure 5 A flowchart for generating reports;

[0059] Figure 6 This is a structural block diagram of the WebSocket-based online report generation system described in this embodiment;

[0060] Figure 7 This is a structural block diagram of the electronic device described in this embodiment. Detailed Implementation

[0061] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the described embodiments of the present invention without creative effort are within the scope of protection of the present invention. Unless otherwise defined, the technical or scientific terms used herein should have the ordinary meaning understood by those skilled in the art to which this invention pertains.

[0062] The terms "first," "second," and similar words used in this application specification and claims do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Similarly, unless the context clearly indicates otherwise, the singular forms of "an," "a," or "the," etc., do not indicate a quantity limitation, but rather indicate the presence of at least one. Terms such as "comprising" or "including" mean that the element or object preceding "comprising" encompasses the features, wholes, steps, operations, elements, and / or components listed following "comprising" or "including," and do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components, and / or sets thereof. Terms such as "upper," "lower," "left," and "right" are used only to indicate relative positional relationships; when the absolute position of the described object changes, the relative positional relationship may also change accordingly.

[0063] In various production processes, reports can dynamically summarize and display production data in chart form, providing crucial information for adjusting and optimizing production decisions. Traditional report generation methods typically rely on the HTTP protocol, which, due to its request-based data transmission, suffers from data interaction delays. Consequently, the latency in real-time data acquisition leads to lag in report information during generation. Furthermore, each associated client independently acquires data, resulting in a lack of data synchronization when data is abnormal or changed, leading to inaccurate report information. Therefore, this embodiment aims to provide an online report generation method based on WebSocket to address these technical shortcomings.

[0064] The following description, in conjunction with the accompanying drawings, details the online report generation method based on WebSocket described in this embodiment.

[0065] The method described in this embodiment is based on the WebSocket protocol between the WebSocket client and the WebSocket server for data communication and transmission. The WebSocket protocol allows bidirectional, real-time data transmission between the client and the server. The WebSocket client refers to the part of a web application that implements the WebSocket protocol, typically provided by a browser or other client program. The WebSocket server refers to the part of the server that implements the WebSocket protocol, responsible for managing the connection with the client, handling message reception and transmission, and maintaining real-time data interaction.

[0066] Combination Figure 1 As shown, the method includes:

[0067] Step S102: The WebSocket server stores the full data of the monitored target into the MySQL database at a first preset frequency so that all WebSocket clients in the associated client list can access the full data.

[0068] The associated client list is created and stored in a Redis database to store attribute information for all WebSocket clients with the same monitoring target. MySQL is an open-source relational database management system widely used for data storage and management. It uses Structured Query Language (SCL) for data creation, querying, updating, and deletion operations. Redis is an open-source, high-performance key-value store primarily used for caching and data storage. It supports various data structures, such as strings, hashes, lists, sets, and sorted sets, and is widely used in data access scenarios requiring high throughput and low latency.

[0069] In practice, each WebSocket client retrieves all data from the MySQL database based on the WebSocket server's server interface.

[0070] Step S104: When any WebSocket client modifies the full data, push the change message to the other WebSocket clients in the corresponding associated client list, and simultaneously trigger the storage of the full data of the monitoring target to the MySQL database at a second preset frequency within a preset time period.

[0071] In practice, the change message includes: the changed data, the corresponding original data, and the ID of the WebSocket client that modified the data. The change message is cached on the WebSocket server. The second preset frequency is greater than the first preset frequency.

[0072] Step S106: Obtain the response message from any other WebSocket client to change the response status of the corresponding WebSocket client in the associated client list, and push the change message to any other WebSocket client that has not sent a response message at a third preset frequency until the corresponding response message is received or the change message cached in the WebSocket server expires.

[0073] At this point, through steps S104 to S106, the synchronous push of changed data can be implemented on all WebSocket clients, ensuring the consistency of data across all clients. Simultaneously, all data within a preset time period is cached at a second preset frequency greater than the first preset frequency, facilitating the WebSocket's retrieval of nearby data and enabling fault tracing and handling when data changes occur due to data anomalies (missing data or reported anomalies). Furthermore, the push response mechanism facilitates verification of the accuracy of data extracted from each WebSocket client; the timeliness mechanism superimposed on the push response mechanism also avoids the technical drawbacks of high memory consumption leading to large overhead and reduced real-time data transmission.

[0074] Step S108: After obtaining the connection request of the new WebSocket client, if the total number of connected clients is less than the connection number threshold, establish a connection with the new WebSocket client and cache the attribute information of the new WebSocket client in the corresponding associated client list in the Redis database.

[0075] In practice, the connection request from the new WebSocket client is triggered when the user first opens the report page in the browser.

[0076] Combination Figure 2 As shown, considering the possibility of multiple new WebSocket client connection requests occurring simultaneously, step S108 further includes the following steps:

[0077] Step S10802: After determining that a number of new WebSocket client connection requests are obtained within the second preset time period, if the total number of clients is not less than the number threshold when a connection is established with each new WebSocket client, a connection is established with each new WebSocket client in sequence according to the preset priority order.

[0078] In practice, the connection status between the WebSocket server and any WebSocket client is monitored in real time by the corresponding WebSocket client. If the connection between the WebSocket server and the WebSocket client is lost due to network instability or other reasons, the WebSocket client will periodically attempt to re-establish contact with the WebSocket server over a period of time. In practice, the periodicity and number of attempts by the WebSocket client to re-establish the connection are adjustable. Furthermore, the response to re-establishing the connection is automatically sent by the client after confirming the connection loss, without requiring the user to open a report page in their browser.

[0079] To ensure data exchange between WebSocket clients that have already established communication in such situations, the priority order is set as follows: a new WebSocket client that re-requests a connection after an abnormal disconnection due to network reasons has a higher connection priority than a new WebSocket client that requests a connection based on its request timestamp. For example, WebSocket client A's request timestamp is later than WebSocket client B's, but WebSocket client A's request is a re-sent request after an abnormal disconnection due to network reasons; in this case, a connection is established with WebSocket client A first.

[0080] Step S110: If it is determined that the change message has not expired, push the change message and the full data of the monitoring target stored at a second preset frequency within a preset time period to the new WebSocket client.

[0081] At this point, step S110 ensures the integrity of the data obtained by the newly established WebSocket client.

[0082] As a preferred implementation, in order to monitor the communication status between the WebSocket client and the WebSocket server, thereby ensuring the timeliness of data transmission and report generation.

[0083] Combination Figure 3 As shown, it also includes the following steps:

[0084] Step S202: When the WebSocket server determines that it receives a Ping message from any WebSocket client within the valid time of the client, it sends a Pong message back to the WebSocket client and resets the timestamp corresponding to the Ping message to the initial time point of the WebSocket client in the associated client list; otherwise, it sends a close frame to the WebSocket client and deletes the WebSocket client from the associated client list.

[0085] The effective time of any WebSocket client is the first preset time period following the initial time point.

[0086] At this point, by setting the client connection timeout in step S202, the overhead caused by invalid clients connecting for a long time is avoided, and the legitimacy of the client is ensured by the mutual confirmation of Ping and Pong messages.

[0087] As a further preferred implementation method, combined with Figure 4 As shown, based on step S202, the following steps are also included:

[0088] Step S20202: If no Ping message is received from any WebSocket client within the second preset time period preceding the termination time, traverse the list of associated clients to point the pointer to any WebSocket client.

[0089] Step S20204: Send a connection request to any of the WebSocket clients, and if a response or Ping message is received within the valid time, reset the timestamp corresponding to the response or Ping message to the initial time point of any of the WebSocket clients in the associated client list; otherwise, delete any of the WebSocket clients from the associated client list based on the pointer pointing to deletion.

[0090] In practice, the inquiry feedback is used to maintain the connection status.

[0091] At this point, based on steps S20202 to S20204, an active query message can be sent when the WebSocket client is about to expire, and the pointer can be pointed to the WebSocket client that is about to expire. The client can be kept alive by receiving no Ping messages or query responses from the WebSocket client, quickly deleting the expired WebSocket client from the associated client list, thereby improving efficiency and reducing overhead. This facilitates the smooth connection of other WebSocket clients waiting to connect and the efficient data transmission of WebSocket clients currently communicating.

[0092] Step S112: Each WebSocket client in the associated client list, including the new WebSocket client, generates a report based on the original full data of the call, or the full data containing the changed data.

[0093] As a specific implementation method, combined with Figure 5 The step S112 includes the following steps:

[0094] Step S11202: Each WebSocket client obtains the report template and the attribute configuration template associated with the report template from the report component database.

[0095] Step S11204: Extract target data from the original full data or the full data containing changed data based on the attribute configuration template.

[0096] Step S11206: Fill the target data into the report template to generate the target report, and store both the target data and the target report in the business database.

[0097] Step S11208: Display the target report on the display front end, and retrieve the target data of the corresponding segment from the business database to the display front end based on the operation of any report item or report area in the target report.

[0098] In practical implementation, the target reports are displayed using large-screen visualization technology, making it easier for users to quickly understand and analyze complex data. Furthermore, large-screen tile technology is used to acquire and display target data for corresponding sections, allowing users to quickly browse and obtain key information on a unified interface.

[0099] At this point, based on steps S11202 to S11208, reports can be quickly generated using preset report templates and attribute configuration modules bound to those templates. The corresponding report display and the method of retrieving regional data directly associated with the reports facilitate data analysis and utilization.

[0100] In summary, the method described in this embodiment, during client connection and data synchronization, firstly, sets a maximum threshold for the number of clients that can connect based on server configuration to prevent too many client connections from causing server crashes; secondly, it sets a client timeout to prevent memory leaks caused by unreleased server connections after abnormal client disconnections; and thirdly, it sets a client reconnection mechanism so that clients can automatically reconnect after server recovery from an anomaly to ensure normal communication. During report generation and data extraction, on the one hand, report templates are bound to attribute configuration templates, and reports are automatically generated and key data requiring attention is automatically extracted from the reports, reducing development costs and improving work efficiency.

[0101] The aforementioned program can run in a processor or be stored in memory (or a computer-readable storage medium). Computer-readable media includes both permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transfer medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include temporary computer-readable media, such as modulated data signals and carrier waves.

[0102] These computer programs 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 1 The steps for the functions specified in one or more boxes can be implemented using different modules, and different steps can be implemented using different modules.

[0103] This embodiment also provides an online report generation system based on WebSocket, which relies on data communication between a WebSocket client and a WebSocket server. Combined with... Figure 6 As shown, the system includes the following functional modules:

[0104] The first storage module is used to enable the WebSocket server to store the full data of the monitoring target into a MySQL database at a first preset frequency so that all WebSocket clients in the associated client list can access the full data; wherein, the associated client list is created and stored in a Redis database to store the attribute information of all WebSocket clients with the same monitoring target.

[0105] The first push module is used to determine when any WebSocket client modifies the full data, and push a change message to the other WebSocket clients in the corresponding associated client list. At the same time, it triggers the storage of the full data of the monitoring target to the MySQL database at a second preset frequency within a preset time period. The change message includes: the changed data, the corresponding original data, and the ID of the WebSocket client that modified the data. The change message is cached on the WebSocket server. The second preset frequency is greater than the first preset frequency.

[0106] The second push module is used to obtain the response message from any other WebSocket client to change the response status of the corresponding WebSocket client in the associated client list, and push the change message to any other WebSocket client that has not sent a response message at a third preset frequency until the corresponding response message is received or the change message cached in the WebSocket server expires.

[0107] The connection establishment module is used to obtain a connection request from a new WebSocket client, determine if the total number of connected clients is less than the connection number threshold, establish a connection with the new WebSocket client, and cache the attribute information of the new WebSocket client in the corresponding associated client list in the Redis database.

[0108] The third push module determines that the change message has not expired, and pushes the change message and the full data of the monitoring target stored at a second preset frequency within a preset time period to the new WebSocket client. At this time, each WebSocket client in the associated client list, including the new WebSocket client, generates a report based on the original full data or the full data containing the change data.

[0109] Since the system is built based on the method described above, it will not be repeated here.

[0110] For example, the system also includes the following functional modules:

[0111] The template acquisition module is used to enable each WebSocket client to automatically acquire report templates from the report component database, as well as attribute configuration templates associated with the report templates.

[0112] The data extraction module is used to extract target data from the original full data or the full data containing changed data based on the attribute configuration template.

[0113] The second storage module is used to fill the target data into the report template to generate the target report, and at the same time, both the target data and the target report are stored in the business database.

[0114] The display module is used to display the target report on the display front end, and to retrieve the target data of the corresponding segment from the business database to the display front end based on the operation of any report item or report area in the target report.

[0115] For example, the system also includes the following functional modules:

[0116] The online monitoring module enables the WebSocket server to send a Pong message to any WebSocket client when it receives a Ping message within the valid time of the client, and reset the timestamp corresponding to the Ping message to the initial time point of any WebSocket client in the associated client list; wherein, the valid time of any WebSocket client is the first preset time period after the initial time point; otherwise, a close frame is sent to any WebSocket client, and the client is deleted from the associated client list.

[0117] This embodiment also provides an electronic device, combined with Figure 7 As shown, it includes at least one processor coupled to a memory storing a computer program configured to be executed by the processor when run.

[0118] In addition, this embodiment also provides a computer-readable storage medium, characterized in that it stores a computer program thereon, the computer program being executed by a processor to implement the method described thereon.

[0119] Since the system, electronic device, and computer-readable storage medium are all used to execute the method or are built based on the method, they also have the advantages of generating reports quickly and accurately, thus assisting in the optimal adjustment of production decisions.

[0120] While the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the invention. Those skilled in the art can make various modifications and refinements without departing from the spirit and scope of the invention. Therefore, the scope of protection of the present invention shall be determined by the claims.

Claims

1. A method for online report generation based on WebSocket, characterized in that, Data communication is based on the WebSocket client and the WebSocket server; including: The WebSocket server stores the full data of the monitored target in a MySQL database at a first preset frequency so that all WebSocket clients in the associated client list can access the full data; wherein, the associated client list is created and stored in a Redis database to store the attribute information of all WebSocket clients with the same monitored target; When any WebSocket client is determined to have modified the full data, a change message is pushed to the remaining WebSocket clients in the corresponding associated client list. Simultaneously, the full data of the monitored target is stored in the MySQL database at a second preset frequency within a preset time period. The change message includes: the modified data, the corresponding original data, and the ID of the WebSocket client that modified the data. The change message is cached on the WebSocket server. The second preset frequency is greater than the first preset frequency. Obtain the response message from any other WebSocket client to change the response status of the corresponding WebSocket client in the associated client list, and push the change message to any other WebSocket client that has not sent a response message at a third preset frequency until the corresponding response message is received or the change message cached in the WebSocket server expires; After receiving a connection request from a new WebSocket client, if the total number of connected clients is less than the connection threshold, a connection is established with the new WebSocket client, and the attribute information of the new WebSocket client is cached in the corresponding associated client list in the Redis database. If it is determined that the change message has not expired, the change message and the full data of the monitoring target stored at a second preset frequency within a preset time period are pushed to the new WebSocket client; At this time, each WebSocket client in the associated client list, including the new WebSocket client, generates a report based on the original full data of the call, or the full data containing the changed data.

2. The online report generation method based on WebSocket according to claim 1, characterized in that, The associated client list includes the new WebSocket client, and each WebSocket client generates reports based on the original full data from the call, or the full data including changed data; including: Each WebSocket client retrieves the report template and the associated attribute configuration template from the report component database. Based on the attribute configuration template, target data is extracted from the original full data or the full data containing the changed data; The target data is populated into the report template to generate the target report, and both the target data and the target report are stored in the business database. The target report is displayed on the front end, and the target data of the corresponding segment is retrieved from the business database and displayed on the front end based on the operation of any report item or report area in the target report.

3. The online report generation method based on WebSocket according to claim 1, characterized in that, include: When the WebSocket server determines that it receives a Ping message from any WebSocket client within the valid time of the client, it sends a Pong message back to the client and resets the timestamp corresponding to the Ping message to the initial time point of the client in the associated client list; wherein, the valid time of the client is the first preset time period after the initial time point. Conversely, a close frame is sent to any of the WebSocket clients, and any of the WebSocket clients is removed from the list of associated clients.

4. The online report generation method based on WebSocket according to claim 3, characterized in that, include: If no Ping message is received from any WebSocket client within the second preset time period preceding the termination time, the list of associated clients is traversed to point the pointer to any WebSocket client. Send a connection request to any of the WebSocket clients, and if a response or Ping message is received within a valid time, reset the timestamp corresponding to the response or Ping message to the initial time point of any of the WebSocket clients in the associated client list; Conversely, based on the pointer pointing to the deletion, any WebSocket client is deleted from the list of associated clients; The inquiry feedback is used to keep the connection in order.

5. The online report generation method based on WebSocket according to claim 1, characterized in that, After obtaining a connection request from a new WebSocket client, if the total number of connected clients is less than a connection threshold, a connection is established with the new WebSocket client, and the attribute information of the new WebSocket client is cached in the corresponding associated client list in the Redis database; including: After determining that a number of new WebSocket client connection requests are obtained within the second preset time period, if the total number of clients is not less than the number threshold when a connection is established with each new WebSocket client, a connection is established with each new WebSocket client in sequence according to the preset priority order. The priority order is as follows: the connection priority of a new WebSocket client that reconnects after being abnormally disconnected due to network reasons is higher than the connection priority of a new WebSocket client that requests a connection based on the request sending timestamp. The connection status between the WebSocket server and any WebSocket client is monitored in real time by the corresponding WebSocket client.

6. An online report generation system based on WebSocket, characterized in that, Data communication is based on the WebSocket client and the WebSocket server; including: The first storage module is used to enable the WebSocket server to store the full data of the monitoring target into a MySQL database at a first preset frequency so that all WebSocket clients in the associated client list can access the full data; wherein, the associated client list is created and stored in a Redis database to store the attribute information of all WebSocket clients with the same monitoring target; The first push module is used to determine when any WebSocket client modifies the full data, and then push a change message to the other WebSocket clients in the corresponding associated client list. Simultaneously, it triggers the storage of the full data of the monitored target into a MySQL database at a second preset frequency within a preset time period. The change message includes: the modified data, the corresponding original data, and the ID of the WebSocket client that modified the data. The change message is cached on the WebSocket server. The second preset frequency is greater than the first preset frequency. The second push module is used to obtain the response message of any other WebSocket client to change the response status of the corresponding WebSocket client in the associated client list, and push the change message to any other WebSocket client that has not sent a response message at a third preset frequency until the corresponding response message is received or the change message cached in the WebSocket server expires. The connection establishment module is used to obtain a connection request from a new WebSocket client, determine if the total number of connected clients is less than the connection number threshold, establish a connection with the new WebSocket client, and cache the attribute information of the new WebSocket client in the corresponding associated client list in the Redis database. The third push module determines that the change message has not expired, and pushes the change message and the full data of the monitoring target stored at a second preset frequency within a preset time period to the new WebSocket client. At this time, each WebSocket client in the associated client list, including the new WebSocket client, generates a report based on the original full data or the full data containing the change data.

7. The online report generation system based on WebSocket according to claim 6, characterized in that, include: The template acquisition module is used to enable each WebSocket client to automatically acquire the report template from the report component database, as well as the attribute configuration template associated with the report template; The data extraction module is used to extract target data from the original full data or the full data containing changed data based on the attribute configuration template. The second storage module is used to fill the target data into the report template to generate the target report, and at the same time, both the target data and the target report are stored in the business database. The display module is used to display the target report on the display front end, and to retrieve the target data of the corresponding segment from the business database to the display front end based on the operation of any report item or report area in the target report.

8. The online report generation system based on WebSocket according to claim 6, characterized in that, include: The online monitoring module is used to enable the WebSocket server to send a Pong message back to any WebSocket client when it receives a Ping message from any WebSocket client within the effective time of the client, and to reset the timestamp corresponding to the Ping message to the initial time point of any WebSocket client in the associated client list; wherein, the effective time of any WebSocket client is the first preset time period after the initial time point; Conversely, a close frame is sent to any of the WebSocket clients, and any of the WebSocket clients is removed from the list of associated clients.

9. An electronic device, characterized in that, It includes at least one processor coupled to a memory storing a computer program configured to be executed by the processor to perform the method of any one of claims 1-5.

10. A computer-readable storage medium, characterized in that, It stores a computer program thereon, which is used to be executed by a processor to implement the method of any one of claims 1-5.

Citation Information

Patent Citations

  • Voice alarm method and system based on WebSocket

    CN112583638A

  • Instant messaging method, device, system and equipment and storage medium

    CN115514746A