A method and device for managing task processing progress
By sorting and encrypting the task identifiers, and generating strings are stored in the database as key names, it solves the problems of low efficiency and low accuracy in querying multiple tasks in the prior art, and realizes efficient and accurate task processing progress query.
Patent Information
- Application Number
- CN202111210121.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-18
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2041-10-18
AI Technical Summary
When querying the processing progress of multiple tasks, the query efficiency is low and the statistics speed is slow. Due to the update changes of data status, the accuracy of progress information is low.
By sorting and encrypting the task identifier, a string is generated as a key name to be stored in the database, ensuring that the key names generated by the same task are consistent, and shortening the character length of the key name, making it easier to batch query the task processing progress.
Improves query efficiency and accuracy of task processing progress, ensures the consistency of key names for the same task, and reduces the length of key name characters stored in the database.
Smart Images

Figure CN113868687B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and device for managing task processing progress. Background Art
[0002] For business systems, such as Web business systems, there are often scenarios where batch operations are performed and results are waiting to be returned. In order to display the processing progress of batch operations, the prior art usually uses a progress bar model. Specifically, the front end designs the style of the progress bar, and polls and calls the progress acquisition interface of the back end, and updates the progress bar according to the progress information returned by the progress acquisition interface; the back end retrieves the database according to the query conditions, obtains the corresponding data status, and then counts the progress information according to the data status and returns it to the front end. The data status of each task is stored in the database.
[0003] In the process of implementing the present invention, there are at least the following problems in the prior art:
[0004] When the processing progress of multiple tasks needs to be queried, it is necessary to query and count each task, which has low query efficiency and slow statistical speed. At the same time, due to the update and change of data status, the accuracy of the statistical progress information is low. Summary of the invention
[0005] In view of this, an embodiment of the present invention provides a method and device for managing task processing progress. The method generates a character string by sorting and encrypting tasks, and stores the character string as a key name in a database, thereby ensuring that the key names generated for the same task are the same and shortening the character length of the key name, thereby facilitating subsequent batch queries on task processing progress.
[0006] To achieve the above objective, according to one aspect of an embodiment of the present invention, a method for managing task processing progress is provided.
[0007] A method for managing task processing progress in an embodiment of the present invention includes: receiving a task execution request, sorting the task identifiers of multiple tasks in the task execution request to obtain sorting information; encrypting the sorting information using an encryption algorithm to generate a corresponding character string, using the character string as a key name, and storing the initial values set for the processing progress of the multiple tasks as corresponding key values in a database; repeatedly performing the following steps until the execution of the multiple tasks is completed: after a preset number of tasks among the multiple tasks are executed, updating the number of task executions, and calculating the current processing progress based on the number of task executions to update the key value of the corresponding key name in the database.
[0008] Optionally, the sorting of the task identifiers of multiple tasks in the task execution request includes: comparing the number of tasks included in the task execution request with a set threshold to obtain a comparison result; determining a sorting algorithm based on a set algorithm selection strategy and the comparison result, and using the sorting algorithm to sort the task identifiers of multiple tasks in the task execution request.
[0009] Optionally, the using an encryption algorithm to encrypt the sorting information to generate a corresponding string includes: using an MD5 algorithm to encrypt the sorting information to obtain encrypted information; and concatenating the encrypted information with address information of the task execution request to generate a corresponding string.
[0010] Optionally, the method also includes: receiving a progress query request, using the sorting algorithm to sort the task identifiers of multiple tasks in the progress query request to obtain target sorting information; using the encryption algorithm to encrypt the target sorting information to generate a corresponding first target character string; using the first target character string to query in the database and output a corresponding key value.
[0011] Optionally, the method also includes: receiving a progress query request, using the sorting algorithm to sort the task identifiers of multiple tasks in the progress query request to obtain target sorting information; using the MD5 algorithm to encrypt the target sorting information to obtain target encrypted information; concatenating the target encrypted information with the address information of the progress query request to generate a corresponding second target character string; using the second target character string to query in the database and output a corresponding key value.
[0012] Optionally, after the execution of the multiple tasks is completed, the method further includes: setting the validity period of the key name and the corresponding key value; after the step of using the first target string to query the database, the method further includes: determining whether the key name in the database that is identical to the first target string name is within the corresponding validity period; if the key name in the database that is identical to the first target string name is outside the corresponding validity period, returning a prompt message indicating that progress acquisition failed; outputting the corresponding key value includes: if the key name in the database that is identical to the first target string name is within the corresponding validity period, outputting the corresponding key value.
[0013] Optionally, after a preset number of tasks among the multiple tasks are executed, updating the number of executed tasks includes: after any one of the multiple tasks is executed, automatically increasing the number of executed tasks.
[0014] To achieve the above objective, according to another aspect of an embodiment of the present invention, a device for managing task processing progress is provided.
[0015] A task processing progress management device according to an embodiment of the present invention comprises: a task sorting module, which is used to receive a task execution request, sort the task identifiers of multiple tasks in the task execution request, and obtain sorting information; an initialization module, which is used to encrypt the sorting information using an encryption algorithm, generate a corresponding character string, use the character string as a key name, and store the initial values set for the processing progress of the multiple tasks as corresponding key values in a database; and a progress statistics module, which is used to repeatedly perform the following steps until the execution of the multiple tasks is completed: after a preset number of tasks among the multiple tasks are executed, updating the number of task executions, and calculating the current processing progress based on the number of task executions to update the key value of the corresponding key name in the database.
[0016] Optionally, the task sorting module is also used to compare the number of tasks contained in the task execution request with a set threshold to obtain a comparison result; determine a sorting algorithm based on a set algorithm selection strategy and the comparison result, and use the sorting algorithm to sort the task identifiers of multiple tasks in the task execution request.
[0017] Optionally, the initialization module is further used to encrypt the sorting information using an MD5 algorithm to obtain encrypted information; and concatenate the encrypted information with the address information of the task execution request to generate a corresponding character string.
[0018] Optionally, the device also includes: a first progress query module, used to receive a progress query request, use the sorting algorithm to sort the task identifiers of multiple tasks in the progress query request, and obtain target sorting information; use the encryption algorithm to encrypt the target sorting information to generate a corresponding first target character string; use the first target character string to query in the database and output a corresponding key value.
[0019] Optionally, the device also includes: a second progress query module, used to receive a progress query request, use the sorting algorithm to sort the task identifiers of multiple tasks in the progress query request, and obtain target sorting information; use the MD5 algorithm to encrypt the target sorting information to obtain target encrypted information; concatenate the target encrypted information with the address information of the progress query request to generate a corresponding second target character string; use the second target character string to query in the database and output the corresponding key value.
[0020] Optionally, the device further includes: a validity period setting module, used to set the validity period of the key name and the corresponding key value; the device further includes: a judgment processing module, used to judge whether the key name in the database that is the same as the first target string name is within the corresponding validity period; if the key name in the database that is the same as the first target string name is outside the corresponding validity period, a prompt message of progress acquisition failure is returned; the second progress query module is also used to output the corresponding key value if the key name in the database that is the same as the first target string name is within the corresponding validity period.
[0021] Optionally, the progress statistics module is further used to automatically increase the number of task executions after any one of the multiple tasks is completed.
[0022] To achieve the above objective, according to another aspect of an embodiment of the present invention, an electronic device is provided.
[0023] An electronic device according to an embodiment of the present invention comprises: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement a method for managing task processing progress according to an embodiment of the present invention.
[0024] To achieve the above objective, according to another aspect of the embodiments of the present invention, a computer readable medium is provided.
[0025] A computer-readable medium according to an embodiment of the present invention stores a computer program, and when the program is executed by a processor, a method for managing task processing progress according to an embodiment of the present invention is implemented.
[0026] An embodiment of the above invention has the following advantages or beneficial effects: by sorting and encrypting tasks to generate a string, and storing the string as a key name in the database, it is ensured that the key names generated for the same task are the same, and the character length of the key name is shortened, which is convenient for subsequent batch query of task processing progress. By comparing the number of tasks included in the progress statistics request with the set threshold, and then flexibly selecting the sorting algorithm according to the comparison result, the defects of each sorting algorithm itself are avoided and the accuracy is improved.
[0027] The MD5 algorithm is used for encryption, and then it is concatenated with the address information to form a string, making the encryption process simple and efficient. At the same time, it can ensure that the progress statistics requests from different machines do not affect each other and will not collide. The same sorting algorithm and encryption algorithm as the progress statistics link are used to process multiple tasks in the progress query request, which improves the query efficiency of the task processing progress.
[0028] By setting the validity period of the key name and key value after all tasks are executed, it can not only ensure that the task has not expired before the end of execution, but also re-acquire the processing progress in the case of client request timeout, concurrency, freeze, retry, etc. By updating the number of task executions after each task is executed, the accuracy of the statistical processing progress is guaranteed.
[0029] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0031] Figure 1 is a schematic diagram of the main steps of the task processing progress management method according to the first embodiment of the present invention;
[0032] Figure 2 It is a schematic diagram of the principle of encryption using the MD5 algorithm in the first embodiment of the present invention;
[0033] Figure 3 This is a schematic diagram of the Redis storage structure of the first embodiment of the present invention;
[0034] Figure 4 is a schematic diagram of the main flow of the task processing progress management method according to the second embodiment of the present invention;
[0035] Figure 5 is a schematic diagram of the main flow of a method for managing task processing progress according to a third embodiment of the present invention;
[0036] Figure 6 It is a schematic diagram of the principle of using the MD5 algorithm for encryption in the third embodiment of the present invention;
[0037] Figure 7 This is a schematic diagram of the Redis storage structure of the third embodiment of the present invention;
[0038] Figure 8 is a schematic diagram of the main flow of a method for managing task processing progress according to a fourth embodiment of the present invention;
[0039] Fig. 9 is a schematic diagram of main modules of a task processing progress management device according to an embodiment of the present invention;
[0040] Fig.10 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0041] Fig.11 It is a schematic diagram of the structure of a computer device suitable for implementing the electronic device of the embodiment of the present invention. DETAILED DESCRIPTION
[0042] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0043] The management process of task processing progress may include any one or more of the progress statistics link and the progress output link. Among them, the progress statistics link is mainly used to sort and encrypt multiple tasks, and after the task execution is completed, update the number of task executions and calculate the current processing progress. The progress output link is mainly used to sort and encrypt multiple tasks using the same sorting method and encryption method as the progress statistics link, and then query the processing progress of the multiple tasks and output them. The following is a detailed description with reference to the accompanying drawings.
[0044] Figure 1 FIG. 1 is a schematic diagram of the main steps of the task processing progress management method according to the first embodiment of the present invention. Figure 1 As shown, the task processing progress management method of the embodiment of the present invention belongs to the progress statistics link, which is implemented by the server and mainly includes the following steps:
[0045] Step S101: receiving a progress statistics request, sorting the task identifiers of multiple tasks in the progress statistics request, and obtaining sorting information. The progress statistics request includes the task identifiers of multiple tasks, where tasks refer to tasks that need to be executed in batches, such as the task of locating items in the warehouse in an order, the task of querying the quantity of items, etc.
[0046] After receiving the progress statistics request from the client, the server parses the progress statistics request and obtains the task identifiers of multiple tasks. Then the task identifiers are sorted, for example, from small to large or from large to small according to the size of the task identifiers. Taking the task of locating items in the warehouse in an order as an example, the task identifier is the order number. This step is used to sort the order numbers of multiple orders.
[0047] In a preferred embodiment, a sorting algorithm selector can be set up, and the sorting algorithm selector selects the sorting algorithm according to the task characteristics to complete the sorting. This method avoids the problem of different generated strings due to the same task not being sorted, and can avoid the defects of each sorting algorithm itself.
[0048] Specifically, the number of tasks included in the task execution request can be compared with the set threshold to obtain a comparison result; then, a sorting algorithm is determined according to the set algorithm selection strategy and the comparison result, and the task identifiers of multiple tasks in the task execution request are sorted using the sorting algorithm. The value of the threshold needs to be tested on each sorting algorithm and the test results are compared.
[0049] In the embodiment, when the number of tasks is less than or equal to the threshold, a direct insertion sort algorithm or a direct selection sort algorithm may be used; when the number of tasks is greater than the threshold, a quick sort algorithm or a heap sort algorithm may be used. The threshold may be, for example, 700, 750, etc.
[0050] Step S102: Encrypt the sorting information using an encryption algorithm to generate a corresponding string, use the string as a key name, and store the initial value set for the processing progress of the multiple tasks as a corresponding key value in the database. The purpose of using the encryption algorithm is to shorten the length of the task identifier splicing, which can be a message digest algorithm, an advanced encryption standard algorithm (AES), etc.
[0051] Taking the encryption algorithm as MD5 algorithm (Message Digest Algorithm 5, i.e., the fifth version of the message digest algorithm) as an example, this step uses the MD5 algorithm to encrypt the sorting information to obtain the encrypted information, and the encrypted information is used as a string. Then, the string is used as the key name, and the initial values set for the processing progress of multiple tasks are stored as corresponding key values in databases such as Redis and Memcached.
[0052] Figure 2 is a schematic diagram of the principle of encryption using the MD5 algorithm in the first embodiment of the present invention, Figure 3 Schematic diagram of the Redis storage structure of the first embodiment of the present invention. Figure 2 and Figure 3 As shown, the task is identified by the order number. After the order number is sorted, it is encrypted using the MD5 algorithm. The encrypted fixed-length string is used as the key (key name), and the initial value of the processing progress (the task has not started at this time, and the initial value can be recorded as "0", indicating that it has not started) is used as the initial value of the value (key value) and saved in the database.
[0053] It is understandable that the initial value of the processing progress is used to indicate that the task has not started execution, and in addition to "0", other symbols may be used to indicate it, such as "-", "*", etc.
[0054] Step S103: Repeat the following steps until the execution of the multiple tasks is completed: after the execution of a preset number of tasks among the multiple tasks is completed, the number of task executions is updated, and the current processing progress is calculated according to the number of task executions to update the key value of the corresponding key name in the database. The preset number can be customized, such as 1, 2, etc. Preferably, the preset number is 1, that is, after the execution of any one of the multiple tasks is completed, the number of task executions is automatically increased, that is, the number of task executions is increased by 1, so as to ensure the accuracy of the statistical processing progress.
[0055] After the preset number of tasks are completed, the number of tasks executed is updated, and the current processing progress is calculated. The key value of the corresponding key name in the database is updated with the calculated current processing progress. Then, it is determined whether all tasks have been completed. If not, continue to execute this step, otherwise end.
[0056] In an embodiment, the current processing progress can be calculated using the following formula:
[0057] Current processing progress = number of tasks executed / number of tasks
[0058] Formula 1
[0059] In the formula, the number of task executions refers to the number of tasks that have been executed among the tasks included in the progress statistics request, and the number of tasks refers to the total number of tasks included in the progress statistics request. In addition, in order to improve the accuracy of progress feedback, the current processing progress can be expressed in decimals, percentages, etc.
[0060] This embodiment generates a character string by sorting and encrypting tasks, uses the character string as the key name, and stores the processing progress as the corresponding key value in the database, thereby ensuring that the key names generated for the same task are the same and shortening the character length of the key name, which facilitates subsequent batch queries on the task processing progress.
[0061] Figure 4 FIG. 2 is a schematic diagram of the main flow chart of the task processing progress management method according to the second embodiment of the present invention. Figure 4 As shown, the task processing progress management method of the embodiment of the present invention belongs to the progress output link (with Figure 1 The progress statistics link corresponds to the progress statistics link), which is implemented by the server and mainly includes the following steps:
[0062] Step S401: Receive a progress query request, use the same sorting algorithm as the progress statistics link to sort the task identifiers of multiple tasks in the progress query request, and obtain target sorting information. In the case of needing to query the task processing progress, the client sends a progress query request, which includes the task identifier whose progress is to be queried.
[0063] After receiving the progress query request, the server parses the progress query request to obtain the task identifiers of multiple tasks, and then uses the same sorting algorithm as the progress statistics link to sort these task identifiers to obtain the target sorting information.
[0064] Step S402: Encrypt the target sorting information using the same encryption algorithm as the progress statistics link to generate a corresponding first target string. If the progress statistics link uses the MD5 algorithm for encryption, this step also uses the MD5 algorithm to encrypt the target sorting information, and the encrypted information obtained is the first target string.
[0065] Step S403: Use the first target string to query the database and output the corresponding key value. Use the first target string as the key to query the corresponding value in the database and return the queried value to the client. The client can customize the display format of the value, such as decimal, percentage, progress bar, digit selection, etc.
[0066] This embodiment uses the same sorting algorithm and encryption algorithm as the progress statistics link to process multiple tasks in the progress query request, thereby improving the query efficiency of the task processing progress.
[0067] In a preferred embodiment, after all tasks are executed, the validity period of the key name and key value in the database can be set, which can not only ensure that the task is not expired before the end of execution, but also re-acquire the processing progress in the case of client request timeout, concurrency, freeze, retry, etc. Specifically, the validity period can be calculated using the following formula:
[0068] Validity period = number of tasks / set value
[0069] Formula 2
[0070] The value can be customized to ensure that the key name and key value are valid for a period of time, for example, set to 100. The unit of validity period is minutes. If it is less than 1 minute, it will be counted as 1 minute. After the validity period expires, the key name and key value can be deleted to reduce the storage pressure of the database.
[0071] If the key name and key value in the database are set with an effective period, then after using the first target string to search in the database in step S403, it is also necessary to determine whether the key name in the database with the same name as the first target string is within the corresponding effective period. If the key name in the database with the same name as the first target string is outside the corresponding effective period, a prompt message indicating that the progress acquisition failed is returned; if the key name in the database with the same name as the first target string is within the corresponding effective period, the corresponding key value is output. The prompt message may be, for example, that the progress is invalid.
[0072] In the progress statistics link, if the encrypted information is directly stored in the database as a key string, there may be conflicts between the keys in the database, that is, the same key is generated for different tasks, resulting in the inability to query the correct results in the subsequent progress query link. In order to solve this problem, the following embodiment improves the generation of keys, as follows.
[0073] Figure 5 FIG. 2 is a schematic diagram of the main flow chart of the task processing progress management method according to the third embodiment of the present invention. Figure 5 As shown, the task processing progress management method of the embodiment of the present invention belongs to the progress statistics link, and mainly includes the following steps:
[0074] Step S501: receiving a progress statistics request, sorting the task identifiers of multiple tasks in the progress statistics request, and obtaining sorting information. The specific implementation of this step is shown in step S101, which will not be described in detail here.
[0075] Step S502: Use the MD5 algorithm to encrypt the sorting information to obtain encrypted information, and concatenate the encrypted information with the address information of the task execution request to generate a corresponding string. The address information of the task execution request refers to the address information of the client sending the task execution request, such as an IP address or a MAC address (ie, a physical address).
[0076] Figure 6 FIG. 1 is a schematic diagram of the principle of using the MD5 algorithm for encryption in the third embodiment of the present invention. Figure 6 As shown, the task identifier is the order number. After the order number is sorted, it is encrypted using the MD5 algorithm, and the encrypted fixed-length string is concatenated with the address information of the task execution request to obtain a string.
[0077] Step S503: using the character string as the key name, the initial values set for the processing progress of the multiple tasks are stored in the database as corresponding key values. Figure 7 The Redis storage structure diagram of the third embodiment of the present invention is shown in FIG. The string obtained in step S502 is used as the key, and the initial value of the processing progress (the task has not started to be executed at this time, and the initial value can be recorded as "0", indicating that it has not started) is used as the initial value of value, and is saved in the database.
[0078] Step S504: Repeat the following steps until the execution of multiple tasks is completed: after the execution of a preset number of tasks among the multiple tasks is completed, update the number of task executions, calculate the current processing progress according to the number of task executions, and update the key value of the corresponding key name in the database. The specific implementation of this step is shown in step S103, which will not be repeated here.
[0079] This embodiment uses the MD5 algorithm for encryption, and then concatenates it with the address information to form a character string, which makes the encryption process simple and efficient, and can also ensure that progress statistics requests from different machines do not affect each other and do not cause collisions.
[0080] Figure 8 FIG. 4 is a schematic diagram of the main flow chart of the task processing progress management method according to the fourth embodiment of the present invention. Figure 8 As shown, the task processing progress management method of the embodiment of the present invention belongs to the progress output link (with Figure 5 The main steps are as follows:
[0081] Step S801: receiving a progress query request, using the same sorting algorithm as the progress statistics link to sort the task identifiers of multiple tasks in the progress query request to obtain target sorting information. The specific implementation of this step is shown in step S401, which will not be repeated here.
[0082] Step S802: Use the MD5 algorithm to encrypt the target sorting information to obtain target encrypted information.
[0083] Step S803: Concatenate the target encrypted information with the address information of the progress query request to generate a corresponding second target character string. The address information of the progress query request refers to the address information of the client that sends the progress query request, such as an IP address or a MAC address. It is understandable that if step S502 uses the IP address for concatenation, the IP address is also used here; if step S502 uses the MAC address for concatenation, the MAC address is also used here.
[0084] Step S804: Use the second target string to search in the database and output the corresponding key value. Use the second target string as the key to search in the database for the corresponding value and return the searched value to the client.
[0085] In addition, if the key names and key values in the database are set with an expiration period, then after using the second target string to query the database in step S804, it is also necessary to determine whether the key name in the database that is the same as the second target string name is within the corresponding validity period; if the key name in the database that is the same as the second target string name is outside the corresponding validity period, a prompt message indicating that the progress acquisition failed is returned; if the key name in the database that is the same as the second target string name is within the corresponding validity period, the corresponding key value is output.
[0086] In a preferred embodiment, the database may be a Redis database, which stores data in key-value format and supports the storage of multiple value types, including strings, linked lists, sets, etc., and can calculate and update values in real time, with high storage speed and query efficiency.
[0087] The above embodiments can be applied to the progress statistics and query scenarios of batch positioning tasks in the warehouse management system (WMS). Among them, the WMS system is a management system that comprehensively uses batch management, material correspondence, inventory counting, quality inspection management, virtual warehouse management and real-time inventory management through functions such as warehousing business, outbound business, warehouse transfer, inventory transfer and virtual warehouse management. The positioning task is to match the shelf location information of the corresponding items in the inventory for the items in the order. The above embodiments can improve the accuracy of progress statistics and the efficiency of progress query in this scenario.
[0088] Fig. 9 FIG. 1 is a schematic diagram of the main modules of the task processing progress management device according to an embodiment of the present invention. Fig. 9 As shown, the task processing progress management device 900 of the embodiment of the present invention mainly includes:
[0089] The task sorting module 901 is used to receive a task execution request, sort the task identifiers of multiple tasks in the task execution request, and obtain sorting information. The progress statistics request includes the task identifiers of multiple tasks, where the tasks refer to tasks that need to be executed in batches, such as the task of locating items in the warehouse in an order, the task of querying the quantity of items, etc.
[0090] After receiving the progress statistics request from the client, the server parses the progress statistics request and obtains the task identifiers of multiple tasks. Then the task identifiers are sorted, for example, from small to large or from large to small according to the size of the task identifiers. Taking the task of locating items in the warehouse in an order as an example, the task identifier is the order number. This step is used to sort the order numbers of multiple orders.
[0091] Initialization module 902 is used to encrypt the sorting information using an encryption algorithm to generate a corresponding string, and use the string as a key name to store the initial value set for the processing progress of the multiple tasks as a corresponding key value in the database. The purpose of using the encryption algorithm is to shorten the length of the task identifier splicing, which can be a message digest algorithm, an advanced encryption standard algorithm, etc.
[0092] Taking the MD5 algorithm as an example, the module uses the MD5 algorithm to encrypt the sorting information, obtains the encrypted information, and uses the encrypted information as a string. Then, the string is used as the key name, and the initial values set for the processing progress of multiple tasks are stored as the corresponding key values in databases such as Redis and Memcached.
[0093] The progress statistics module 903 is used to repeatedly execute the following steps until the execution of the multiple tasks is completed: after the execution of a preset number of tasks among the multiple tasks is completed, the number of task executions is updated, and the current processing progress is calculated based on the number of task executions to update the key value of the corresponding key name in the database. After the execution of the preset number of tasks is completed, the number of task executions is updated, and the current processing progress is calculated, and the key value of the corresponding key name in the database is updated using the calculated current processing progress. Afterwards, it is determined whether all tasks have been executed. If not, this step is continued, otherwise it ends.
[0094] In addition, the task processing progress management device 900 of the embodiment of the present invention may also include: a first progress query module, a second progress query module, a validity period setting module and a judgment processing module ( Fig. 9 The first progress query module is used to receive a progress query request, use the sorting algorithm to sort the task identifiers of multiple tasks in the progress query request, and obtain target sorting information; use the encryption algorithm to encrypt the target sorting information to generate a corresponding first target string; use the first target string to query the database and output a corresponding key value.
[0095] The second progress query module is used to receive a progress query request, use the sorting algorithm to sort the task identifiers of multiple tasks in the progress query request, and obtain target sorting information; use the MD5 algorithm to encrypt the target sorting information to obtain target encrypted information; concatenate the target encrypted information with the address information of the progress query request to generate a corresponding second target character string; use the second target character string to query in the database and output a corresponding key value.
[0096] The validity period setting module is used to set the validity period of the key name and the corresponding key value. The judgment processing module is used to judge whether the key name in the database that is the same as the first target string name is within the corresponding validity period; if the key name in the database that is the same as the first target string name is outside the corresponding validity period, a prompt message indicating that the progress acquisition failed is returned.
[0097] From the above description, it can be seen that by sorting and encrypting the tasks to generate a string, and storing the string as the key name in the database, it is ensured that the key names generated for the same task are the same, and the character length of the key name is shortened, which is convenient for subsequent batch query of task processing progress.
[0098] Fig.10 An exemplary system architecture 1000 is shown to which the method for managing task processing progress or the device for managing task processing progress according to the embodiment of the present invention can be applied.
[0099] like Fig.10 As shown, the system architecture 1000 may include terminal devices 1001, 1002, 1003, a network 1004, and a server 1005. The network 1004 is used to provide a medium for communication links between the terminal devices 1001, 1002, 1003 and the server 1005. The network 1004 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.
[0100] Users can use terminal devices 1001, 1002, 1003 to interact with server 1005 through network 1004 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 1001, 1002, 1003, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0101] The terminal devices 1001 , 1002 , and 1003 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers, etc.
[0102] The server 1005 may be a server that provides various services, such as a background management server that processes task execution requests sent by users using terminal devices 1001, 1002, and 1003. The background management server may sort and encrypt the task identifiers of multiple tasks in the task execution request, generate a string and store it in the database as a key name. The initial value of the key value is the initial value set for the processing progress of the multiple tasks. During the task execution process, the current processing progress is calculated, the key value is updated, and the processing result (such as the updated key value) is fed back to the terminal device.
[0103] It should be noted that the task processing progress management method provided in the embodiment of the present application is generally executed by the server 1005 , and accordingly, the task processing progress management device is generally set in the server 1005 .
[0104] It should be understood that Fig.10The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0105] According to an embodiment of the present invention, the present invention also provides an electronic device and a computer-readable medium.
[0106] The electronic device of the present invention comprises: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement a method for managing task processing progress according to an embodiment of the present invention.
[0107] The computer-readable medium of the present invention stores a computer program thereon, and when the program is executed by a processor, a method for managing task processing progress according to an embodiment of the present invention is implemented.
[0108] Reference below Fig.11 , which shows a schematic diagram of the structure of a computer system 1100 suitable for implementing an electronic device of an embodiment of the present invention. Fig.11 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0109] like Fig.11 As shown, the computer system 1100 includes a central processing unit (CPU) 1101, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1102 or a program loaded from a storage part 1108 into a random access memory (RAM) 1103. In the RAM 1103, various programs and data required for the operation of the computer system 1100 are also stored. The CPU 1101, the ROM 1102, and the RAM 1103 are connected to each other via a bus 1104. An input / output (I / O) interface 1105 is also connected to the bus 1104.
[0110] The following components are connected to the I / O interface 1105: an input section 1106 including a keyboard, a mouse, etc.; an output section 1107 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1108 including a hard disk, etc.; and a communication section 1109 including a network interface card such as a LAN card, a modem, etc. The communication section 1109 performs communication processing via a network such as the Internet. A drive 1110 is also connected to the I / O interface 1105 as needed. A removable medium 1111, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1110 as needed, so that a computer program read therefrom is installed into the storage section 1108 as needed.
[0111] In particular, according to the embodiments disclosed in the present invention, the process described in the main step diagram above can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the main step diagram. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1109, and / or installed from the removable medium 1111. When the computer program is executed by the central processing unit (CPU) 1101, the above-mentioned functions defined in the system of the present invention are executed.
[0112] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0113] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0114] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be arranged in a processor, for example, they may be described as: a processor including a task sorting module, an initialization module and a progress statistics module. The names of these modules do not constitute limitations on the modules themselves in certain cases, for example, the task sorting module may also be described as "a module that receives a task execution request, sorts the task identifiers of multiple tasks in the task execution request, and obtains sorting information".
[0115] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently and not be assembled into the device. The above computer-readable medium carries one or more programs. When the above one or more programs are executed by a device, the device includes: receiving a task execution request, sorting the task identifiers of multiple tasks in the task execution request, and obtaining sorting information; encrypting the sorting information using an encryption algorithm, generating a corresponding string, using the string as a key name, and storing the initial value set for the processing progress of the multiple tasks as a corresponding key value in the database; repeating the following steps until the execution of the multiple tasks is completed: after the execution of a preset number of tasks in the multiple tasks is completed, updating the number of task executions, and calculating the current processing progress according to the number of task executions to update the key value of the corresponding key name in the database.
[0116] According to the technical solution of an embodiment of the present invention, tasks are sorted and encrypted to generate a character string, which is then stored in a database as a key name. This ensures that the key names generated for the same task are the same and shortens the character length of the key name, facilitating subsequent batch queries on the progress of task processing.
[0117] The above product can execute the method provided by the embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not described in detail in this embodiment, please refer to the method provided by the embodiment of the present invention.
[0118] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for managing task processing progress, characterized in that: include: receiving a task execution request, and sorting task identifiers of multiple tasks in the task execution request to obtain sorting information; Encrypting the sorting information using an encryption algorithm to generate a corresponding character string, using the character string as a key name, and storing the initial values set for the processing progress of the multiple tasks as corresponding key values in a database; Repeat the following steps until the execution of the multiple tasks is completed: after a preset number of tasks among the multiple tasks are executed, update the number of task executions, calculate the current processing progress based on the number of task executions, and update the key value of the corresponding key name in the database.
2. The method according to claim 1, characterized in that The sorting of the task identifiers of the multiple tasks in the task execution request includes: Compare the number of tasks included in the task execution request with a set threshold to obtain a comparison result; A sorting algorithm is determined according to a set algorithm selection strategy and the comparison result, and the task identifiers of the multiple tasks in the task execution request are sorted using the sorting algorithm.
3. The method according to claim 2, characterized in that The method of encrypting the sorting information using an encryption algorithm to generate a corresponding character string includes: Encrypt the sorting information using the MD5 algorithm to obtain encrypted information; The encrypted information is concatenated with the address information of the task execution request to generate a corresponding character string.
4. The method according to claim 2, characterized in that: The method further comprises: receiving a progress query request, and using the sorting algorithm to sort the task identifiers of multiple tasks in the progress query request to obtain target sorting information; Encrypt the target sorting information using the encryption algorithm to generate a corresponding first target character string; The first target character string is used to search the database and the corresponding key value is output.
5. The method according to claim 3, characterized in that: The method further comprises: receiving a progress query request, and using the sorting algorithm to sort the task identifiers of multiple tasks in the progress query request to obtain target sorting information; Encrypt the target sorting information using the MD5 algorithm to obtain target encrypted information; Concatenate the target encrypted information with the address information of the progress query request to generate a corresponding second target character string; The second target character string is used to search the database and the corresponding key value is output.
6. The method according to claim 4, characterized in that After the execution of the multiple tasks is completed, the method further includes: Set the validity period of the key name and the corresponding key value; After the step of using the first target character string to search the database, the method further includes: Determine whether the key name in the database that is identical to the first target character string is within the corresponding validity period; If the key name in the database that is identical to the first target string name is outside the corresponding validity period, a prompt message indicating that progress acquisition has failed is returned; The outputting the corresponding key value includes: if the key name in the database that is identical to the first target character string name is within the corresponding validity period, outputting the corresponding key value.
7. The method according to any one of claims 1 to 6, characterized in that: After a preset number of tasks among the plurality of tasks are executed, updating the number of tasks executed comprises: After any one of the multiple tasks is executed, the number of task executions is automatically increased.
8. A task processing progress management device, characterized in that: include: A task sorting module is used to receive a task execution request, sort the task identifiers of multiple tasks in the task execution request, and obtain sorting information; An initialization module, used to encrypt the sorting information using an encryption algorithm, generate a corresponding character string, use the character string as a key name, and store the initial values set for the processing progress of the multiple tasks as corresponding key values in a database; The progress statistics module is used to repeatedly execute the following steps until the execution of the multiple tasks is completed: after a preset number of tasks among the multiple tasks are executed, the number of task executions is updated, and the current processing progress is calculated based on the number of task executions to update the key value of the corresponding key name in the database.
9. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.
10. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Asynchronous task inquiry method and device
CN107798108A