Task processing method, device, server and storage medium

By taking turns to select tasks from the packaging task queue, the problem of inefficient processing of multiple packaging tasks by a single device is solved, and more efficient task processing is achieved.

CN113238820BActive Publication Date: 2025-03-11BEIJING DAJIA INTERNET INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110516667.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-12
Publication Date
2025-03-11
Estimated Expiration
2041-05-12

AI Technical Summary

Technical Problem

In some business scenarios, when multiple packaging tasks need to be processed, the packaging equipment processing time in the prior art is longer, resulting in low task processing efficiency.

Method used

Select the corresponding package task from the package task queue through at least two package devices for processing. When one package device completes the task, continue to select the next task from the queue until all tasks are processed.

Benefits of technology

When a large number of packaging tasks occur, this method uses multiple packaging devices to process tasks, shorten the task processing time, improve task processing efficiency, and avoid inefficiency caused by a single device to process all tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113238820B_ABST
    Figure CN113238820B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a task processing method, device, server and storage medium, the method comprising: selecting corresponding packaging tasks from a packaging task queue for processing by at least two packaging devices; the packaging task queue is used to store the received packaging tasks according to the request time of the received packaging tasks; when at least one packaging device has processed the corresponding packaging task, the target packaging task is selected from the packaging task queue by the at least one packaging device for processing until the packaging tasks in the packaging task queue are processed; the target packaging task is the first packaging task in the packaging task queue that has not been selected. The adoption of this method is conducive to improving task processing efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a task processing method, device, electronic device and storage medium. Background Art

[0002] In some business scenarios, packaging tasks need to be processed, such as game packages.

[0003] In the related art, a packaging task is usually processed by a packaging device. When multiple packaging tasks need to be processed, the packaging device needs to consume a long processing time, resulting in low task processing efficiency. Summary of the invention

[0004] The present disclosure provides a task processing method, device, server and storage medium to at least solve the problem of low task processing efficiency in related technologies. The technical solution of the present disclosure is as follows:

[0005] According to a first aspect of an embodiment of the present disclosure, there is provided a task processing method, including:

[0006] Selecting corresponding packaging tasks from a packaging task queue for processing through at least two packaging devices; the packaging task queue is used to store the received packaging tasks according to the request time of the received packaging tasks;

[0007] When at least one packaging device has completed processing the corresponding packaging task, the at least one packaging device selects a target packaging task from the packaging task queue for processing until the packaging tasks in the packaging task queue are processed; the target packaging task is the first packaging task among the packaging tasks that have not been selected in the packaging task queue.

[0008] In an exemplary embodiment, before selecting corresponding packaging tasks from the packaging task queue for processing by at least two packaging devices, the method further includes:

[0009] Receive packaging tasks;

[0010] According to the request time of the packaging task, the packaging task is stored in the packaging task queue, and the task status of the packaging task is marked as unprocessed.

[0011] In an exemplary embodiment, after selecting corresponding packaging tasks from the packaging task queue for processing by at least two packaging devices, the method further includes:

[0012] Switching the task status of the selected packaging task in the packaging task queue from an unprocessed state to a processed state, and recording the device identifier of the packaging device that selected the packaging task;

[0013] Before taking out the target packaging task from the packaging task queue for processing by the at least one packaging device, the method further includes:

[0014] When at least one packaging device completes processing of a corresponding packaging task, the task status of the corresponding completed packaging task in the packaging task queue is switched from a processing status to a processing completed status.

[0015] In an exemplary embodiment, after selecting corresponding packaging tasks from the packaging task queue for processing by at least two packaging devices, the method further includes:

[0016] If the packaging device is restarted, query whether the packaging task queue stores a packaging task whose device identifier is the device identifier of the packaging device and whose task status is in a processing state;

[0017] If the packaging task queue stores a packaging task whose device identifier is the device identifier of the packaging device and whose task status is in a processing state, the packaging task is processed by the packaging device.

[0018] In an exemplary embodiment, if the packaging device is restarted, after querying whether the packaging task queue stores a packaging task whose device identifier is the device identifier of the packaging device and whose task status is in a processing state, the method further includes:

[0019] If the packaging task queue does not store a packaging task whose device identifier is the device identifier of the packaging device and whose task status is in a processing state, the packaging device reselects a target packaging task from the packaging task queue for processing.

[0020] In an exemplary embodiment, the method further comprises:

[0021] If the packing tasks in the packing task queue are processed, the packing device is controlled to enter a sleep state.

[0022] In an exemplary embodiment, after controlling the packaging device to enter the sleep state, the method further includes:

[0023] According to a preset frequency, detecting whether there is a packaging task with an unprocessed task status stored in the packaging task queue;

[0024] If the packaging task queue stores a packaging task whose task status is unprocessed, waking up the packaging device that has entered a sleeping state;

[0025] The packaging task whose task status is an unprocessed state is processed by the packaging device.

[0026] According to a second aspect of an embodiment of the present disclosure, there is provided a task processing device, including:

[0027] The first task processing unit is configured to execute, through at least two packaging devices, selecting corresponding packaging tasks from a packaging task queue for processing; the packaging task queue is used to store the received packaging tasks according to the request time of the received packaging tasks;

[0028] The second task processing unit is configured to execute, when at least one packaging device has completed processing the corresponding packaging task, selecting a target packaging task from the packaging task queue through the at least one packaging device for processing until the packaging tasks in the packaging task queue are processed; the target packaging task is the first packaging task among the packaging tasks that have not been selected in the packaging task queue.

[0029] In an exemplary embodiment, the task processing device also includes a task storage unit, which is configured to execute receiving a packaging task; store the packaging task in the packaging task queue according to the request time of the packaging task, and mark the task status of the packaging task as an unprocessed state.

[0030] In an exemplary embodiment, the task processing device further includes a first switching unit configured to switch the task state of the selected packaging task in the packaging task queue from an unprocessed state to a processed state, and record a device identifier of the packaging device that selected the packaging task;

[0031] The task processing device also includes a second switching unit configured to switch the task status of the corresponding completed packaging task in the packaging task queue from a processing state to a processing completed state when at least one packaging device completes processing of the corresponding packaging task.

[0032] In an exemplary embodiment, the task processing device also includes a task query unit, which is configured to execute, if the packaging device is restarted, to query whether the packaging task queue stores a packaging task whose device identifier is the device identifier of the packaging device and whose task status is a processing state; if the packaging task queue stores a packaging task whose device identifier is the device identifier of the packaging device and whose task status is a processing state, the packaging task is processed by the packaging device.

[0033] In an exemplary embodiment, the task processing device also includes a task selection unit, which is configured to execute if the packaging task queue does not store a packaging task with a device identifier of the packaging device and a task status of being processed, then re-select the target packaging task from the packaging task queue through the packaging device for processing.

[0034] In an exemplary embodiment, the task processing apparatus further includes a device control unit configured to control the packaging device to enter a sleep state if the packaging tasks in the packaging task queue are processed completely.

[0035] In an exemplary embodiment, the task processing device also includes a task detection unit, which is configured to execute, according to a preset frequency, detection of whether a packaging task with a task status of an unprocessed state is stored in the packaging task queue; if a packaging task with a task status of an unprocessed state is stored in the packaging task queue, waking up a packaging device that has entered a sleep state; and processing the packaging task with a task status of an unprocessed state through the packaging device.

[0036] According to a third aspect of an embodiment of the present disclosure, a server is provided, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement the task processing method as described in any one of the embodiments of the first aspect.

[0037] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, comprising: when instructions in the computer-readable storage medium are executed by a processor of a server, the server is enabled to execute the task processing method described in any one of the embodiments of the first aspect.

[0038] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, the computer program product comprising a computer program, the computer program being stored in a computer-readable storage medium, at least one processor of a device reading and executing the computer program from the computer-readable storage medium, so that the device performs the task processing method described in any one of the embodiments of the first aspect.

[0039] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects:

[0040] The corresponding packaging tasks are selected from the packaging task queue for processing by at least two packaging devices; the packaging task queue is used to store the received packaging tasks according to the request time of the received packaging tasks; when at least one packaging device has processed the corresponding packaging task, the target packaging task is selected from the packaging task queue by at least one packaging device for processing until the packaging tasks in the packaging task queue are processed; the target packaging task is the first packaging task among the packaging tasks that have not been selected in the packaging task queue; in this way, the purpose of processing the packaging tasks by multiple packaging devices in the case of a large number of packaging tasks is achieved, which is conducive to shortening the task processing time, thereby improving the task processing efficiency, and avoiding the defect of low task processing efficiency caused by processing all packaging tasks by one packaging device.

[0041] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.

[0043] Figure 1 The present invention is an application environment diagram of a task processing method according to an exemplary embodiment.

[0044] Figure 2 The figure is a flowchart of a task processing method according to an exemplary embodiment.

[0045] Figure 3 The figure is a flowchart showing another task processing method according to an exemplary embodiment.

[0046] Figure 4 The figure is a flowchart of a method for processing tasks when a machine is restarted according to an exemplary embodiment.

[0047] Figure 5 The figure is a block diagram of a task processing device according to an exemplary embodiment.

[0048] Figure 6 It is a block diagram of a server according to an exemplary embodiment. DETAILED DESCRIPTION

[0049] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.

[0050] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0051] The task processing method provided by the present disclosure can be applied to Figure 1 In the application environment shown. The application environment includes a packaging system, and the packaging system includes multiple packaging devices 110, such as packaging device 110a, packaging device 110b, ... packaging device 110n, each packaging device is used to select a corresponding packaging task from a packaging task queue storing multiple packaging tasks for processing; specifically, refer to Figure 1 In the case of a large number of packaging tasks, at least two packaging devices 110 are used to select corresponding packaging tasks from the packaging task queue for processing; the packaging task queue is used to store the received packaging tasks according to the request time of the received packaging tasks; when at least one packaging device 110 has processed the corresponding packaging task, at least one packaging device 110 is used to select a target packaging task from the packaging task queue for processing until the packaging tasks in the packaging task queue are processed; the target packaging task is the first packaging task in the packaging task queue that has not been selected. Among them, the packaging device 110 refers to a computer device that processes packaging tasks, which can refer to a server, a physical machine that carries a packaging service, etc.

[0052] Figure 2 is a flowchart of a task processing method according to an exemplary embodiment. Figure 2 As shown, the task processing method is used as follows Figure 1 In the packaging device shown, the following steps are included:

[0053] In step S210, corresponding packaging tasks are selected from a packaging task queue for processing by at least two packaging devices; the packaging task queue is used to store the received packaging tasks according to the request time of the received packaging tasks.

[0054] The packaging task refers to the task of packaging a data packet, and the data packet refers to a data packet that needs to occupy a large amount of memory, such as a game packet. The request time of the packaging task refers to the time of requesting to execute the packaging task. It should be noted that at least two packaging devices refer to two or more packaging devices.

[0055] Among them, a plurality of packaging tasks are stored in the packaging task queue, and these packaging tasks are sorted in the order of the corresponding request time, such as packaging tasks with earlier request times are arranged in front, and packaging tasks with later request times are arranged in the back. For example, in the packaging task queue, the first one is packaging task 1, the second one is packaging task 2, and the third one is packaging task 3. It should be noted that after receiving the newly added packaging tasks, each packaging device stores the packaging tasks in the same packaging task queue according to the request time of the packaging tasks; and each time a new packaging task is added, there is only one packaging device that receives the newly added packaging task and stores it in the packaging task queue, which ensures the uniqueness of the packaging tasks in the packaging task queue.

[0056] Specifically, one of the at least two packaging devices receives the newly added packaging task, and stores the packaging task in the packaging task queue according to the corresponding request time, so as to store the received packaging tasks through the same packaging task queue; thereafter, each packaging device queries whether there is a packaging task to be executed by the device. If not, the corresponding packaging task is selected from the packaging task queue for processing.

[0057] It should be noted that when a packaging task is first executed, each packaging device selects a corresponding packaging task from the packaging task queue for processing; thereafter, after each packaging device completes the current packaging task, it selects a corresponding packaging task from the packaging task queue for processing.

[0058] In step S220, when at least one packaging device has completed processing the corresponding packaging task, at least one packaging device selects a target packaging task from the packaging task queue for processing until the packaging tasks in the packaging task queue are processed; the target packaging task is the first packaging task in the packaging task queue that has not been selected.

[0059] The unselected packaging tasks in the packaging task queue refer to packaging tasks that need to be selected and processed.

[0060] Specifically, after each packaging device selects a corresponding packaging task from the packaging task queue for processing, each packaging device monitors in real time whether the packaging task of the device has been completed. When at least one packaging device has completed processing of the corresponding packaging task, at least one packaging device selects the first packaging task from the packaging task queue that has not been selected for processing; and so on, until the packaging tasks in the packaging task queue are processed, all packaging devices enter a dormant state. In this way, the purpose of processing the packaging tasks by multiple packaging devices is achieved when a large number of packaging tasks appear, which is conducive to shortening the task processing time and thus improving the task processing efficiency.

[0061] In the above task processing method, corresponding packaging tasks are selected from the packaging task queue for processing by at least two packaging devices; the packaging task queue is used to store the received packaging tasks according to the request time of the received packaging tasks; when at least one packaging device has processed the corresponding packaging task, a target packaging task is selected from the packaging task queue by at least one packaging device for processing until the packaging tasks in the packaging task queue are processed; the target packaging task is the first packaging task among the packaging tasks that have not been selected in the packaging task queue; in this way, the purpose of processing the packaging tasks by multiple packaging devices in the case of a large number of packaging tasks is achieved, which is conducive to shortening the task processing time, thereby improving the task processing efficiency, and avoiding the defect of low task processing efficiency caused by processing all packaging tasks by one packaging device.

[0062] In an exemplary embodiment, the above step S210, before selecting the corresponding packaging task from the packaging task queue for processing through at least two packaging devices, also includes: receiving the packaging task; storing the packaging task in the packaging task queue according to the request time of the packaging task, and marking the task status of the packaging task as unprocessed.

[0063] The task status is used to characterize the processing status of the packaging task, such as unprocessed status, processing status, and processing completed status.

[0064] Specifically, when a new packaging task appears, the packaging task is received by one of all packaging devices; for example, a certain packaging device is designated to receive the packaging task, or the packaging task can be received by a packaging device in an idle state; then, the packaging device stores the packaging task in the packaging task queue according to the request time of the packaging task, such as inserting the packaging task after the last packaging task in the packaging task queue; at the same time, the task status of the packaging task is marked as unprocessed, such as marking the task status of the packaging task as 0, and 0 is used to indicate that the packaging task is in an unprocessed state. In this way, the new packaging task can be stored through the same packaging task queue.

[0065] Of course, when a packaging task is sent to a packaging device, the packaging device will add the packaging task to the packaging task queue; for example, the packaging device receives a packaging request, parses the packaging request, obtains a newly added packaging task, and stores the newly added packaging task in the packaging task queue.

[0066] The technical solution provided by the embodiment of the present disclosure receives the newly added packaging task through one packaging device among all packaging devices when a new packaging task is added, and stores it in sequence in the same packaging task queue, which is conducive to ensuring the uniqueness of the packaging tasks stored in the packaging task queue.

[0067] In an exemplary embodiment, the above step S210, after selecting the corresponding packaging task from the packaging task queue for processing by at least two packaging devices, also includes: switching the task status of the selected packaging task in the packaging task queue from an unprocessed state to a processing state, and recording the device identification of the packaging device that selected the packaging task.

[0068] The device identification of the packaging device refers to the unique identification information of the packaging device, such as the device number, device name, etc.

[0069] Specifically, after the packaging device selects a corresponding packaging task from the packaging task queue and processes it, the packaging device switches the task status of the packaging task selected from the packaging task queue from an unprocessed state to a processing state, and obtains the device identification of the packaging device as the device identification corresponding to the packaging task.

[0070] For example, after packaging device A selects packaging task 3 from the packaging task queue and processes it, the task status of packaging task 3 in the packaging task queue is updated from 0 to 1, using 1 to indicate that packaging task 3 is in the processing state, and the device name of packaging device A is recorded, obtaining a data record: packaging task 3--1--packaging device A.

[0071] Furthermore, the above step S220, before taking out the target packaging task from the packaging task queue for processing by at least one packaging device, also includes: when at least one packaging device completes processing the corresponding packaging task, the task status of the corresponding completed packaging task in the packaging task queue is switched from the processing status to the processing completed status.

[0072] Specifically, when the packaging device completes processing of the corresponding packaging task, the packaging device switches the task status of the packaging task in the packaging task queue from the processing status to the processing completed status to indicate that the packaging task has been processed and does not need to be processed further.

[0073] For example, after packaging device A completes packaging task 3, it updates the task status of packaging task 3 in the packaging task queue from 1 to 2, using 2 to indicate that packaging task 3 is in a processing completion state, thereby obtaining a new data record: packaging task 3--2--packaging device A.

[0074] The technical solution provided by the embodiment of the present disclosure is that when the packaging device selects the corresponding packaging task from the packaging task queue for processing, the task status of the selected packaging task in the packaging task queue is switched from the unprocessed state to the processing state; when the packaging device completes processing of the corresponding packaging task, the task status of the corresponding completed packaging task in the packaging task queue is switched from the processing state to the processing completed state, which is conducive to ensuring the uniqueness of the task status of the packaging task stored in the packaging task queue; at the same time, by recording the device identification of the packaging device corresponding to the packaging task, it is conducive to continuing to complete the packaging task that has not been processed before through the same packaging device when an abnormal situation occurs, so as to avoid errors in the processing process of the packaging task.

[0075] In an exemplary embodiment, the above step S210, after selecting the corresponding packaging task from the packaging task queue for processing by at least two packaging devices, also includes: if the packaging device is restarted, querying whether the packaging task queue stores a packaging task with a device identifier of the packaging device and a task status of being in a processing state; if the packaging task queue stores a packaging task with a device identifier of the packaging device and a task status of being in a processing state, processing the packaging task through the packaging device.

[0076] The packaging device restart may be a restart of the packaging device itself, or a restart of the packaging program deployed on the packaging device.

[0077] The device identifier is the device identifier of the packaging device, and the packaging task with a task status of being in processing is the last unfinished packaging task on the packaging device.

[0078] Specifically, when the packaging device is restarted, the last packaging task of the packaging device is actually not completed, and there is always a packaging task in the packaging task queue with a device identifier of the packaging device and a task status of being processed; therefore, when the packaging device is restarted, there will be a pre-query step, such as first querying whether the packaging task queue stores a packaging task with a device identifier of the packaging device and a task status of being processed. If so, the packaging task continues to be processed through the packaging device, ensuring that in abnormal circumstances, all packaging tasks stored in the packaging task queue can be completed without omissions.

[0079] For example, when an exception occurs when packaging device A is processing packaging task 3, causing packaging device A to restart; then, when packaging device A restarts, packaging device A will first query whether there is a packaging task 3 stored in the packaging task queue with the device identifier of packaging device A and the task status marked as 1. If so, packaging device A will continue to process packaging task 3, such as directly processing the unprocessed tasks in packaging task 3.

[0080] The technical solution provided by the embodiment of the present disclosure is that when the packaging device is restarted, it is first queried whether there is a packaging task whose device identifier is the packaging device and whose task status is in the processing state stored in the packaging task queue. If so, the packaging task continues to be processed, thereby achieving the purpose of completing all the packaging tasks stored in the packaging task queue under abnormal circumstances.

[0081] In an exemplary embodiment, if the packaging device is restarted, after querying whether the packaging task queue stores a packaging task with a device identifier of the packaging device and a task status of being in a processing state, it also includes: if the packaging task queue does not store a packaging task with a device identifier of the packaging device and a task status of being in a processing state, the target packaging task is re-selected from the packaging task queue by the packaging device for processing.

[0082] Specifically, when the packaging device is restarted, and it is found that the packaging task queue does not store any packaging task with the device identifier of the packaging device and the task status is in the processing state, it means that before the packaging device is restarted, the packaging device has completed the packaging tasks it needs to process, then the first packaging task among the unselected packaging tasks is selected from the packaging task queue for processing, for example, the packaging task that was inserted first and marked with a task status of 0 is selected from the packaging task queue for processing, and after the processing of the packaging task begins, the task status of the packaging task is updated to 1.

[0083] According to the technical solution provided by the disclosed embodiment, when a packaging device is restarted and it is found that no packaging task with a device identifier of the packaging device and a task status of being in a processing state is stored in the packaging task queue, the corresponding packaging task is re-selected from the packaging task queue for processing, thereby avoiding the situation in which the packaging device processes a new packaging task after restarting before the previous packaging task on the packaging device is processed, and further ensuring that all packaging tasks stored in the packaging task queue can be completed.

[0084] In an exemplary embodiment, the task processing method provided by the present application further includes: if the packaging tasks in the packaging task queue are processed, controlling the packaging device to enter a sleep state.

[0085] For example, when there is no packaging task with a task status of 0 in the packaging task queue, it means that all packaging tasks in the packaging task queue have been processed, and the packaging device will enter the sleep state.

[0086] The technical solution provided by the embodiment of the present disclosure controls the packaging device to enter a sleep state when the packaging tasks in the packaging task queue are processed, which is beneficial to saving power of the packaging device and increasing the service life of the packaging device.

[0087] In an exemplary embodiment, after controlling the packaging device to enter a sleep state, it also includes: according to a preset frequency, detecting whether a packaging task with an unprocessed task status is stored in the packaging task queue; if a packaging task with an unprocessed task status is stored in the packaging task queue, waking up the packaging device that has entered the sleep state; and processing the packaging task with an unprocessed task status by the packaging device.

[0088] The preset frequency refers to the frequency of querying whether there are any packaging tasks with an unprocessed task status stored in the packaging task queue, for example, querying once a minute.

[0089] For example, after controlling the packaging device A to enter the sleep state, the packaging device A will periodically detect whether there are packaging tasks with a task status of 0 stored in the packaging task queue to see whether there are packaging tasks that need to be processed; if there are packaging tasks with a task status of 0 stored in the packaging task queue, the packaging device A will be awakened, and the packaging task that was inserted first and marked with a task status of 0 will be selected from the packaging task queue by the packaging device A for processing.

[0090] The technical solution provided by the embodiment of the present disclosure detects whether there are any packaging tasks with an unprocessed task status stored in the packaging task queue according to a preset frequency after controlling the packaging device to enter a sleep state, so that when there are packaging tasks with an unprocessed task status stored in the packaging task queue, they are processed immediately, which is beneficial to shortening the task processing time and further improving the task processing efficiency.

[0091] In an exemplary embodiment, if Figure 3 As shown, another task processing method is provided, which mainly includes the following contents: Figure 3 , each machine's server is started, and each server has an independent packaging status, which is used to monitor whether the machine has a packaging task at this time; when a new packaging task appears, a machine that receives the new packaging task will insert the packaging task into the same database and mark the task status of the packaging task as 0, forming a packaging task queue; at this time, the machine will check whether the machine has a packaging task to be executed. If not, it will query the database for a task with a task status of 0. If so, it will get the packaging task that was first inserted from the database and has a task status of 0 (task not started) to start packaging. After the packaging task starts, the task status of the packaging task is set to 1 (executing); thereafter, each time the machine completes a packaging task, it will mark the task status of the packaging task as 2 (packaging completed).

[0092] Further, refer to Figure 4 , when an abnormal state occurs, such as when the machine is restarted or the program is restarted, the last packaging task is not actually completed, and there will always be a packaging task with a task status of 1 in the database. Therefore, every time the task status of a packaging task is set from 0 to 1 in the database, the name of the corresponding packaging machine needs to be recorded. Since the machine name will never change, when the machine is restarted, a pre-query is performed first to check whether there is a packaging task with a task status of 1 and the packaging machine is this machine in the database. If so, continue to complete the previous packaging task to avoid errors; if not, obtain the packaging task with the task status of 0 that was first inserted from the database for processing.

[0093] The above-mentioned task processing method can achieve the following technical effects: (1) shorten the processing time of packaging tasks and improve the processing efficiency of packaging tasks; (2) ensure the uniqueness of packaging tasks in the packaging task queue; (3) ensure the uniqueness of each task status; (4) when the machine restarts or the code error causes the project to restart, find the tasks before the restart and continue to package them, ensuring that all packaging tasks in the packaging task queue can be processed.

[0094] It should be understood that although Figure 2 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.

[0095] Figure 5 is a block diagram of a task processing device according to an exemplary embodiment. Figure 5 , the device includes a first task processing unit 510 and a second task processing unit 520.

[0096] The first task processing unit 510 is configured to execute, through at least two packaging devices, selecting corresponding packaging tasks from a packaging task queue for processing; the packaging task queue is used to store the received packaging tasks according to the request time of the received packaging tasks.

[0097] The second task processing unit 520 is configured to execute when at least one packaging device completes processing of the corresponding packaging task, then selects a target packaging task from the packaging task queue through at least one packaging device for processing until the packaging tasks in the packaging task queue are processed; the target packaging task is the first packaging task in the packaging task queue that has not been selected.

[0098] In this embodiment, corresponding packing tasks are selected from the packing task queue for processing by at least two packing devices; the packing task queue is used to store the received packing tasks according to the request time of the received packing tasks; when at least one packing device has processed the corresponding packing task, a target packing task is selected from the packing task queue by at least one packing device for processing until the packing tasks in the packing task queue are processed; the target packing task is the first packing task among the packing tasks that have not been selected in the packing task queue; in this way, the purpose of processing the packing tasks by multiple packing devices is achieved when a large number of packing tasks appear, which is conducive to shortening the task processing time, thereby improving the task processing efficiency, and avoiding the defect of low task processing efficiency caused by processing all packing tasks by one packing device.

[0099] In an exemplary embodiment, the task processing device provided by the present disclosure also includes a task storage unit, which is configured to execute receiving packaging tasks; store the packaging tasks in a packaging task queue according to the request time of the packaging tasks, and mark the task status of the packaging tasks as unprocessed.

[0100] In an exemplary embodiment, the task processing device provided by the present disclosure further includes a first switching unit, which is configured to execute switching the task state of the selected packaging task in the packaging task queue from an unprocessed state to a processed state, and record a device identifier of the packaging device of the selected packaging task;

[0101] The task processing device provided by the present disclosure also includes a second switching unit, which is configured to switch the task status of the corresponding completed packaging task in the packaging task queue from a processing state to a processing completed state when at least one packaging device completes processing of the corresponding packaging task.

[0102] In an exemplary embodiment, the task processing device provided by the present disclosure also includes a task query unit, which is configured to execute if the packaging device is restarted, to query whether a packaging task with a device identifier of the packaging device and a task status of being in a processing state is stored in the packaging task queue; if a packaging task with a device identifier of the packaging device and a task status of being in a processing state is stored in the packaging task queue, the packaging task is processed by the packaging device.

[0103] In an exemplary embodiment, the task processing device provided by the present disclosure also includes a task selection unit, which is configured to execute if the packaging task queue does not store a packaging task with a device identifier of a packaging device and the task status is a processing status, then re-select the target packaging task from the packaging task queue through the packaging device for processing.

[0104] In an exemplary embodiment, the task processing apparatus provided by the present disclosure further includes a device control unit configured to control the packaging device to enter a sleep state if the packaging tasks in the packaging task queue are processed.

[0105] In an exemplary embodiment, the task processing device provided by the present disclosure also includes a task detection unit, which is configured to execute, according to a preset frequency, detection of whether a packaging task with a task status of an unprocessed state is stored in a packaging task queue; if a packaging task with a task status of an unprocessed state is stored in the packaging task queue, waking up a packaging device that has entered a sleep state; and processing the packaging task with a task status of an unprocessed state through the packaging device.

[0106] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0107] Figure 6 6 is a block diagram of a device 600 for executing the above-mentioned task processing method according to an exemplary embodiment. For example, the device 600 may be a server. Figure 6, the device 600 includes a processing component 620, which further includes one or more processors, and a memory resource represented by a memory 622 for storing instructions, such as applications, that can be executed by the processing component 620. The application stored in the memory 622 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 620 is configured to execute instructions to perform the above-mentioned task processing method.

[0108] The device 600 may also include a power supply component 624 configured to perform power management of the device 600, a wired or wireless network interface 626 configured to connect the device 600 to a network, and an input / output (I / O) interface 628. The device 600 may operate based on an operating system stored in the memory 622, such as Windows 66erver, Mac O6 X, Unix, Linux, FreeBSD or the like.

[0109] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory 622 including instructions, which can be executed by a processor of the device 600 to perform the above method. For example, the computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0110] In an exemplary embodiment, a computer program product is also provided, which includes a computer program stored in a computer-readable storage medium, and at least one processor of a device reads and executes the computer program from the computer-readable storage medium, so that the device performs the task processing method described in any embodiment of the present disclosure.

[0111] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the claims.

[0112] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A task processing method, characterized in that: include: Selecting corresponding packaging tasks from the packaging task queue for processing by at least two packaging devices; The packaging task queue is used to store the received packaging tasks according to the request time of the received packaging tasks; each packaging device is also used to use the device identification of the packaging device as the device identification corresponding to the packaging task selected by the packaging device; When at least one packaging device has finished processing the corresponding packaging task, the at least one packaging device selects a target packaging task from the packaging task queue for processing until the packaging tasks in the packaging task queue are processed; The target packaging task is the first packaging task among the packaging tasks that have not been selected in the packaging task queue; The method further comprises: In the case that any packaging device is restarted, if the packaging task queue stores a packaging task whose corresponding device identifier is the device identifier of the restarted packaging device and whose corresponding task status is in the processing state, the restarted packaging device will process the packaging task whose corresponding device identifier is the device identifier of the restarted packaging device and whose corresponding task status is in the processing state.

2. The task processing method according to claim 1, characterized in that: Before selecting corresponding packaging tasks from the packaging task queue for processing by at least two packaging devices, the method further includes: Receive packaging tasks; According to the request time of the packaging task, the packaging task is stored in the packaging task queue, and the task status of the packaging task is marked as unprocessed.

3. The task processing method according to claim 2, characterized in that: After selecting corresponding packaging tasks from the packaging task queue for processing by at least two packaging devices, the method further includes: Switching the task status of the selected packaging task in the packaging task queue from an unprocessed state to a processed state, and recording the device identifier of the packaging device that selected the packaging task; Before taking out the target packaging task from the packaging task queue for processing by the at least one packaging device, the method further includes: When at least one packaging device completes processing of a corresponding packaging task, the task status of the corresponding completed packaging task in the packaging task queue is switched from a processing status to a processing completed status.

4. The task processing method according to claim 1, characterized in that: The method further comprises: If the packaging task queue does not store a packaging task whose device identifier is the device identifier of the packaging device and whose task status is in a processing state, the packaging device reselects a target packaging task from the packaging task queue for processing.

5. The task processing method according to claim 2, characterized in that: The method further comprises: If the packing tasks in the packing task queue are processed, the packing device is controlled to enter a sleep state.

6. The task processing method according to claim 5, characterized in that: After controlling the packaging device to enter the sleep state, the method further includes: According to a preset frequency, detecting whether there is a packaging task with an unprocessed task status stored in the packaging task queue; If the packaging task queue stores a packaging task whose task status is an unprocessed state, waking up the packaging device that has entered a sleeping state; The packaging task whose task status is an unprocessed state is processed by the packaging device.

7. A task processing device, characterized in that: include: A first task processing unit is configured to execute, through at least two packaging devices, selecting a corresponding packaging task from a packaging task queue for processing; The packaging task queue is used to store the received packaging tasks according to the request time of the received packaging tasks; each packaging device is also used to use the device identification of the packaging device as the device identification corresponding to the packaging task selected by the packaging device; The second task processing unit is configured to execute, when at least one packaging device completes processing of a corresponding packaging task, selecting a target packaging task from the packaging task queue through the at least one packaging device for processing until the packaging tasks in the packaging task queue are processed; the target packaging task is the first packaging task in the packaging task queue that has not been selected; The task processing device also includes a task query unit, which is configured to, when any packaging device is restarted, if the packaging task queue stores a packaging task whose corresponding device identifier is the device identifier of the restarted packaging device and whose corresponding task status is a processing state, then process the packaging task whose corresponding device identifier is the device identifier of the restarted packaging device and whose corresponding task status is a processing state through the restarted packaging device.

8. The task processing device according to claim 7, characterized in that: The task processing device also includes a task storage unit configured to execute receiving a packaging task; store the packaging task in the packaging task queue according to the request time of the packaging task, and mark the task status of the packaging task as an unprocessed status.

9. The task processing device according to claim 8, characterized in that: The task processing device further includes a first switching unit configured to switch the task state of the selected packaging task in the packaging task queue from an unprocessed state to a processed state, and record a device identifier of the packaging device that selected the packaging task; The task processing device also includes a second switching unit configured to switch the task status of the corresponding completed packaging task in the packaging task queue from a processing state to a processing completed state when at least one packaging device completes processing of the corresponding packaging task.

10. The task processing device according to claim 7, characterized in that: The task processing device also includes a task selection unit, which is configured to execute if the packaging task queue does not store a packaging task with a device identifier of the packaging device and a task status of being processed, then re-select the target packaging task from the packaging task queue through the packaging device for processing.

11. The task processing device according to claim 8, characterized in that: The task processing apparatus further includes a device control unit configured to control the packaging device to enter a sleep state if the packaging tasks in the packaging task queue are processed completely.

12. The task processing device according to claim 11, characterized in that: The task processing device also includes a task detection unit, which is configured to execute, according to a preset frequency, detection of whether a packaging task with an unprocessed task status is stored in the packaging task queue; if a packaging task with an unprocessed task status is stored in the packaging task queue, waking up a packaging device that has entered a sleeping state; and processing the packaging task with an unprocessed task status through the packaging device.

13. A server, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the task processing method according to any one of claims 1 to 6.

14. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of a server, the server is enabled to execute the task processing method according to any one of claims 1 to 6.

15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the task processing method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Extensible efficient APP channel package packing platform

    CN107580049A

  • Multi-task execution method and device

    CN111124648A