A method and system for optimizing terminal network printing services
By using queue data structures and shared memory, the problems of lost and duplicate orders on terminal devices during peak periods were solved, printing efficiency was improved and memory consumption was reduced, thus achieving a high-efficiency terminal network printing service.
Patent Information
- Application Number
- CN202211371480.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-03
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2042-11-03
AI Technical Summary
During peak user periods, terminal devices experience issues such as lost and duplicate orders due to the large volume of document printing demands. Furthermore, existing technologies consume significant amounts of memory, impacting printing efficiency and terminal performance.
The system uses a queue data structure to send document data. The sending end periodically checks the unprinted status and adds the documents back to the print queue. The receiving end maintains the print list and filters duplicate documents. The printing end and the receiving end share memory to reduce memory consumption.
It effectively avoids lost and duplicate orders, reduces memory consumption, and improves printing efficiency and terminal performance.
Smart Images

Figure CN115729486B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of terminal network printing service technology, and in particular to an optimization method and system for terminal network printing services. Background Technology
[0002] Currently, restaurants and entertainment venues, which cater to a large number of customers, need to print numerous receipts after customers purchase products for purposes such as checkout, product dispensing, and billing information. Among these, the dispensing slip is the most crucial. Multiple terminals may have multiple dispensing points, and each item purchased by a customer will be printed from its corresponding dispensing point, with each item dispensed according to the dispensing slip. In this context, printing dispensing slips at various dispensing points is particularly important. However, due to the large number of dispensing points, printing dispensing slips via the network often faces anomalies such as lost or duplicate orders. Furthermore, during peak business hours, the large number of slips that need to be printed simultaneously puts significant pressure on the performance of each terminal, easily leading to terminal lag and other problems that affect other business operations.
[0003] In addition, the current printing service requires terminal devices to monitor printing status, which consumes a lot of memory. At the same time, a thread needs to be created for each printing order. When there are a large number of printing orders, multiple threads need to be created, which consumes a lot of memory and is prone to device lag. This not only affects printing efficiency but also easily leads to problems such as lost or duplicate orders. Summary of the Invention
[0004] The technical problem to be solved by the present invention is to provide an optimization method and system for terminal network printing services, which can effectively avoid the loss and duplicate printing of documents.
[0005] In a first aspect, the present invention provides an optimization method for terminal network printing service, wherein document data is sent from the sending end to the receiving end using a queue data structure, and the printing end obtains the document data from the receiving end for printing.
[0006] The sending end periodically checks the database for unprinted document data. If the document data is still unprinted after exceeding the first preset time limit threshold, it is determined that the document data is abnormal. The abnormal document data is then added back to the end of the print queue and sent to the receiving end.
[0007] The receiving end maintains a print list. Each time the receiving end receives new document data, it records the new document data information in the print list and checks whether the print list already contains the same document data. If so, the new document data is filtered out; otherwise, the document data is added to the print list.
[0008] Secondly, the present invention provides an optimization system for terminal network printing services, including a sending end, a receiving end and a printing end. Document data is sent from the sending end to the receiving end using a queue data structure, and the printing end obtains the document data from the receiving end for printing.
[0009] The sending end periodically checks the database for unprinted document data. If the document data is still unprinted after exceeding the first preset time limit threshold, it is determined that the document data is abnormal. The abnormal document data is then added back to the end of the print queue and sent to the receiving end.
[0010] The receiving end maintains a print list. Each time the receiving end receives new document data, it records the new document data information in the print list and checks whether the print list already contains the same document data. If so, the new document data is filtered out; otherwise, the document data is added to the print list.
[0011] One or more technical solutions provided in the embodiments of the present invention have at least the following technical effects or advantages:
[0012] The sending end periodically checks the database for unprinted documents. If a document is still unprinted after a first preset time limit threshold, it will be added back to the print queue and sent to the receiving end, thus solving the problem of lost documents.
[0013] Each time the receiving end retrieves a new document, it checks the print queue to see if the same document data already exists. If so, the new document data is filtered out, thus effectively avoiding duplicate documents.
[0014] The receiving end manages document data through a print queue. Only one thread is needed for all printing operations, which greatly reduces the memory consumption of the receiving end and improves printing efficiency.
[0015] The sending end splits the document data to be printed into multiple parts and sends them to each receiving end, allowing multiple receiving ends to work simultaneously, which also improves printing efficiency.
[0016] The receiving and printing ends share memory and can run in the same process. There is no need for them to send document data to each other, which greatly reduces the memory consumption and performance loss of each terminal, allowing the terminals to have more time to process other business.
[0017] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and in order to make the above and other objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description
[0018] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0019] Figure 1 This is a schematic diagram of the system framework of the present invention;
[0020] Figure 2 This is a flowchart of the method in Embodiment 1 of the present invention. Detailed Implementation
[0021] This application provides an optimization method and system for terminal network printing services, which can effectively avoid lost or duplicate printing of documents.
[0022] The technical solution in this application embodiment has the following general idea: the printing status of document data is maintained in a database. The sending end periodically searches the database for unprinted documents. If the document data is still in an unprinted state after exceeding a first preset time limit threshold, it will be added back to the printing queue and sent to the receiving end, thus solving the problem of lost documents. After the printing end retrieves new document data, it will check whether the printing list already contains the same document data information. If so, the new document data will be filtered out, thus effectively avoiding duplicate orders.
[0023] Before introducing specific embodiments, the system framework corresponding to the method in the embodiments of this application will be introduced first, such as... Figure 1 As shown, the system can be roughly divided into three parts:
[0024] The sending end is used to send document data to the receiving end and maintain the printing status of each document in the database. It periodically searches for unprinted document data in the database and adds document data that is still unprinted after exceeding the first preset time limit threshold back into the printing queue and sends it to the receiving end, thereby solving the problem of lost documents.
[0025] The receiving end is used to receive document data sent by the sending end and maintain a print list. Each time the receiving end receives new document data, it saves it to shared memory and records the new document data information in the print list. The receiving end also checks whether the print list already contains the same document data information. If so, the new document data is filtered out; otherwise, the document data is added to the print list.
[0026] The printing end is used to retrieve document data from shared memory for printing.
[0027] Example 1
[0028] like Figure 2 As shown, this embodiment provides an optimization method for terminal network printing services, including:
[0029] The document data is sent from the sending end to the receiving end using a queue data structure, and the printing end retrieves the document data from the receiving end for printing.
[0030] The sending end periodically checks the database for unprinted document data. If the document data is still unprinted after exceeding the first preset time limit threshold, it is determined to be abnormal document data, and the abnormal document data processing procedure is initiated. The abnormal document data processing procedure is to add the abnormal document data back to the end of the waiting queue and send it to the receiving end, thus solving the problem of lost documents.
[0031] The receiving end maintains a print list. Each time the receiving end receives new document data, it records the new document data information in the print list and checks whether the print list already contains the same document data. If so, the new document data is filtered out; otherwise, the document data is added to the print list, thus effectively avoiding duplicate printing.
[0032] Example 2
[0033] like Figure 2 As shown, this embodiment provides an optimization method for terminal network printing services, which is a further improvement on Embodiment 1, and includes the following process:
[0034] The document data is sent from the sending end to the receiving end using a queue data structure, and the printing end retrieves the document data from the receiving end for printing.
[0035] The sending end periodically checks the database for unprinted document data. If the document data is still unprinted after exceeding the first preset time limit threshold, it is determined to be abnormal document data, and the abnormal document data processing procedure is initiated. The abnormal document data processing procedure is to add the abnormal document data back to the end of the waiting queue and send it to the receiving end, thus solving the problem of lost documents.
[0036] The receiving end maintains a print list. Each time the receiving end receives new document data, it records the new document data information in the print list and checks whether the print list already contains the same document data. If so, the new document data is filtered out; otherwise, the document data is added to the print list, thus effectively avoiding duplicate printing.
[0037] The receiving end also has a listening thread to monitor the printing results from the printing end. When the receiving end detects that the printing is successful, it returns a printing completion status message to the sending end, which then updates the printing status of the corresponding document data in the database. When the receiving end detects that the printing has failed, it adds the failed document data back to the end of the print queue.
[0038] The receiving end saves the received document data to a print list in shared memory, and the printing end retrieves the document data from shared memory for printing. This allows the receiving and printing ends to run in a single process, resulting in faster processing speeds.
[0039] The printing status of the document data is maintained by the sending end. That is, after the printing end finishes printing each document data, it returns the printing completion status information to the sending end, which then updates the printing status of the corresponding document data, so that the printing status of each document data in the database can be updated in a timely manner.
[0040] The receiving end adds document data to the print list and records the time when the new document data is added. It periodically checks the print list for any document data that has exceeded a second preset time limit threshold and has not yet been printed. If any such document data is found, it is deleted from the print list. For example, if the second preset time limit threshold is set to two minutes, and the receiving end finds any document data in the print list that has exceeded two minutes without being printed, it will treat it as an abnormal document and delete it from the print list. This prevents other documents from being unable to be printed due to the first document being unable to be printed. This deleted document data will also be detected by the sending end through periodic queries and treated as an abnormal document, as detailed below:
[0041] If the first preset time limit threshold is greater than the second preset time limit threshold, the deleted document data will remain in an unprinted state in the sending end's database because the preset time limit threshold has been exceeded. Therefore, the sending end will initiate the abnormal document data processing procedure. For example, setting the first preset time limit threshold to 3 minutes and the second preset time limit threshold to 2 minutes means that when the receiving end deletes document data from the print list, it does not need to notify the sending end. Instead, the sending end automatically detects the data in the database based on the first preset time limit threshold, thereby reducing data interaction between the receiving and sending ends and significantly saving memory consumption and performance loss.
[0042] The sending end maintains a queue to be printed, while the receiving end maintains a print list. Both the queue and the print list are arrays based on a single-threaded linked list structure. Each document consists of multiple nodes. When retrieving data, both the sending and printing ends simply retrieve the head node of the document from the single-threaded linked list. After successfully sending a document, the sending end removes all nodes of that document from the queue; similarly, after successfully retrieving a document, the printing end removes all nodes of that document from the print list. Since the printer prints one document at a time, a queue structure is used, changing the task processing from multi-threaded to a single-threaded queue structure. This eliminates the need for extensive data addition and deletion operations in the queue. Retrieving data only involves retrieving the head node, which is then automatically removed from the list. Therefore, maintaining an array based on a linked list structure in the queue significantly reduces terminal memory usage and performance loss.
[0043] One preferred approach is to have more than one receiving end, with one receiving end corresponding to one printing end. The sending end splits the document data to be printed and sends it to each receiving end, so that the printing end corresponding to each receiving end can print synchronously, greatly improving printing efficiency.
[0044] Based on the same inventive concept, this application also provides a system corresponding to the method in Embodiment 1, as detailed in Embodiment 3.
[0045] Example 3
[0046] like Figure 1 As shown, this embodiment provides an optimization system for terminal network printing services, including a sending end, a receiving end, and a printing end. Document data is sent from the sending end to the receiving end using a queue data structure, saved by the receiving end to shared memory, and then retrieved from the shared memory by the printing end for printing. The printing status of the document data is maintained in a database.
[0047] The sending end periodically searches the database for unprinted documents. If the document data is still unprinted after exceeding the first preset time limit threshold, it is determined that the document data is abnormal and the abnormal document data processing procedure is initiated. The abnormal document data processing procedure is to add the abnormal document data back to the printing queue and send it to the receiving end.
[0048] The receiving end maintains a print list. Each time a new document is retrieved, the new document data information is recorded. The receiving end then checks whether the same document data already exists in the print list. If it does, the new document data is filtered out; otherwise, it is added to the print list.
[0049] The printing status of the document data is maintained by the sending end. That is, after the receiving end detects that the printing end has finished printing each document data, the receiving end returns the printing completion status information to the sending end, and the sending end updates the printing status of the corresponding document data, so that the printing status of each document data in the database can be updated in a timely manner.
[0050] The receiving end adds document data to the print list and records the time when the new document data is added. It periodically checks the print list for any document data that has exceeded a second preset time limit and has not yet been printed. If any such document data is found, it is deleted from the print list. For example, if the receiving end finds that a document data in the print list has not been printed for more than two minutes, it will treat it as an abnormal document and delete it from the print list to prevent other documents from being unable to be printed due to the first document being unable to be printed. This deleted document data will also be detected by the sending end through periodic queries and treated as an abnormal document, as detailed below:
[0051] If the first preset time limit threshold is greater than the second preset time limit threshold, the deleted document data will remain in an unprinted state because the preset time limit threshold has been exceeded. This prompts the sending end to initiate the abnormal document data processing procedure. For example, setting the first preset time limit threshold to 3 minutes and the second preset time limit threshold to 2 minutes means that when the receiving end deletes document data from the print list, it does not need to notify the sending end. Instead, the sending end automatically detects the data from the database based on the first preset time limit threshold, thereby reducing data interaction between the receiving and sending ends and significantly saving memory consumption and performance loss.
[0052] The print queue and print list are arrays based on a single-threaded linked list structure. Each document consists of multiple nodes. When retrieving data, both the sending and printing ends only retrieve the head node of the document from the single-threaded linked list structure. After successfully sending a document, the sending end removes all nodes of the corresponding document from the print queue; after successfully retrieving a document, the printing end removes all nodes of the corresponding document from the print list. Since the printer prints documents one by one, a queue structure is used, and the task processing of the original sending and receiving ends is changed from multi-threaded to a single-threaded queue structure. Data retrieval only involves retrieving the head node. Therefore, maintaining an array based on a linked list structure in the queue can significantly reduce the terminal's memory usage and performance loss.
[0053] Since the system described in Embodiment 2 of the present invention is an apparatus used to implement the method of Embodiment 1 of the present invention, those skilled in the art can understand the specific structure and variations of the apparatus based on the method described in Embodiment 1 of the present invention, and therefore will not be described again here. All apparatuses used in the method of Embodiment 1 of the present invention fall within the scope of protection of the present invention.
[0054] While specific embodiments of the present invention have been described above, those skilled in the art should understand that the specific embodiments described are merely illustrative and not intended to limit the scope of the present invention. Equivalent modifications and variations made by those skilled in the art in accordance with the spirit of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A method for providing printing services, characterized in that: The document data is sent from the sending end to the receiving end using a queue data structure, and the printing end retrieves the document data from the receiving end for printing. The sending end periodically checks the database for unprinted document data. If the document data is still unprinted after exceeding the first preset time limit threshold, it is determined that the document data is abnormal. The abnormal document data is then added back to the end of the print queue and sent to the receiving end. The receiving end maintains a print list. Each time the receiving end receives new document data, it records the new document data information in the print list and checks whether the print list already contains the same document data. If so, the new document data is filtered out; otherwise, the document data is added to the print list.
2. The printing service provision method according to claim 1, characterized in that: The receiving end also sets up a listening thread to monitor the printing execution results from the printing end.
3. The printing service provision method according to claim 2, characterized in that: When the receiving end detects that the printing end has successfully printed, it returns the printing completion status information to the sending end, which then updates the printing status of the corresponding document data in the database. When the receiving end detects a printing failure at the printing end, it adds the failed document data back to the end of the print queue.
4. The printing service provision method according to claim 1, characterized in that: The receiving end saves the received document data to the print list in the shared memory, and the printing end retrieves the print document data from the shared memory for printing.
5. The printing service provision method according to claim 1, characterized in that: The receiving end adds the document data to the print list at the same time as adding the new document data to the print list; The system periodically checks the print list for any documents that have not been printed after exceeding the second preset time limit. If any such documents are found, they are removed from the print list.
6. The printing service provision method according to claim 5, characterized in that: If the first preset time limit threshold is greater than the second preset time limit threshold, the document data deleted from the print list will remain in an unprinted state in the print database because the first preset time limit threshold has been exceeded. The sending end will then send the document data back to the receiving end.
7. The printing service provision method according to claim 1, characterized in that: The queue to be printed and the print list are arrays based on a single-threaded linked list structure. Each document data consists of multiple nodes. When the sending end and the printing end retrieve data, they only take the head node of the document data from the single-threaded linked list structure. After successfully sending a document, the sending end removes all nodes of the corresponding document data from the print queue. After successfully retrieving a document, the printing end removes all nodes of the corresponding document data from the print list.
8. The method for providing printing services according to claim 1, characterized in that: There is one or more receiving ends, and each receiving end corresponds to one printing end. The sending end splits the document data to be printed and sends it to each receiving end.
9. An optimization system for terminal network printing services, characterized in that: It includes a sending end, a receiving end, and a printing end. The document data is sent from the sending end to the receiving end using a queue data structure, and the printing end retrieves the document data from the receiving end for printing. The sending end periodically checks the database for unprinted document data. If the document data is still unprinted after exceeding the first preset time limit threshold, it is determined that the document data is abnormal. The abnormal document data is then added back to the end of the print queue and sent to the receiving end. The receiving end maintains a print list. Each time the receiving end receives new document data, it records the new document data information in the print list and checks whether the print list already contains the same document data. If so, the new document data is filtered out; otherwise, the document data is added to the print list.
Citation Information
Patent Citations
Document printing method and device based on cloud technology, equipment and storage medium
CN114637479A
Printing data processing method and system based on block chain and electronic equipment
CN115145498A