Idle period calculation method and related device

By establishing a priority queue and heap sorting method based on the working period start time in large enterprises, the public idle time period is calculated, and the problem of inefficient computing in the prior art is solved, and efficient idle time period determination is achieved.

CN120387600APending Publication Date: 2025-07-29TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410129377.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-01-29
Publication Date
2025-07-29

AI Technical Summary

Technical Problem

In large enterprises, existing brute force traversal algorithms are used to calculate employees' public idle time periods, resulting in CPU and memory overload and inefficient computing.

Method used

By establishing a priority queue based on the start time of the working period, using the heap sorting method to build a priority heap, setting parameter variables to determine the idle period, gradually moving out of the working period and updating the parameter variables until the queue is empty, and calculating the public idle time.

Benefits of technology

It effectively reduces the CPU computing volume, improves the computing efficiency, and reduces the use of computing resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120387600A_ABST
    Figure CN120387600A_ABST
Patent Text Reader

Abstract

The invention provides an idle period calculation method and a related device. The method comprises the following steps: in response to a calculation instruction for an idle period, obtaining working periods corresponding to a plurality of target objects, and establishing a priority queue; initializing the first variable according to the starting time of the first working period in the queue; then updating the first variable based on the end time of the first working period in the priority queue; if the first variable is smaller than the starting time of the secondary working time period in the priority queue, determining the time period from the first variable to the starting time of the secondary working time period as an idle time period; and after the first working period is removed from the priority queue, re-determining the first variable until the priority queue is empty, and finally outputting all idle periods. According to the embodiment of the invention, the first variable is set, and the idle period is determined based on the size relationship between the first variable and other parameters, so that the calculation amount can be effectively reduced, and the calculation efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of automated office, and particularly relates to a method for calculating idle time periods and related devices. Background Art

[0002] Automated office is a new type of office method that combines modern office and computer technology. Scheduling refers to reasonably arranging the working hours and shifts of employees according to the needs and resources of an enterprise to improve work efficiency and meet business requirements. In automated office, an administrator can schedule each employee through office software. When scheduling, calculating the common idle time of multiple employees is a common requirement. For example, when multiple employees need to jointly complete a project or task, calculating the common idle time can find a time period when everyone is free for team meetings, discussions, or collaborative work; when the work content is on-duty, calculating the common idle time period can avoid having no employees scheduled for duty during a certain time period.

[0003] To calculate the idle time period, the currently commonly used method is the brute-force traversal algorithm, which finds the common idle time period by comparing the schedule of each employee one by one. For small enterprises, since the number of employees is relatively small, this algorithm may still operate well. However, in large enterprises, due to the large number of employees, the brute-force traversal algorithm may face performance problems, causing the CPU and memory of the machine to be overloaded. Summary of the Invention

[0004] The embodiments of this application provide a method for calculating idle time periods and related devices, which are used to reduce the CPU calculation amount and improve the calculation efficiency.

[0005] The first aspect of this application provides a method for calculating idle time periods, including:

[0006] In response to a calculation request from an operation object to calculate the idle time periods of multiple target objects, obtain the working time periods corresponding to the multiple target objects, where the working time periods include start time and end time;

[0007] Based on the order of the start times, establish a priority queue, where the priority queue indicates the sorting of the multiple working time periods;

[0008] Initialize a first variable, and the initial value of the first variable is the start time of the working time period at the head of the priority queue;

[0009] Determine the first variable based on a first parameter. If the first variable is less than the first parameter, update the first variable to the first parameter, where the first parameter indicates the end time of the working time period at the head of the priority queue;

[0010] If the determined first variable is less than the second parameter, the time period between the determined first variable and the second parameter is determined as the idle time period of multiple objects, and the second parameter indicates the start time of the working time period ranked second in the priority queue;

[0011] Remove the working time period ranked first from the priority queue;

[0012] Redetermine the first variable until the priority queue is empty;

[0013] Output the idle time period to the operating object.

[0014] In a possible implementation method, if the working time period includes a first time period and a second time period, and the start time of the first time period is less than the start time of the second time period, the priority queue specifically indicates the sorting of multiple first time periods;

[0015] Before redetermining the first variable, it further includes:

[0016] If the working time period removed from the priority queue is the first time period, add the corresponding second time period to the priority queue and update the priority queue.

[0017] In a possible implementation method, based on the order of start times, establishing a priority queue includes:

[0018] Based on the start time, use the heap sort method to construct multiple working time periods into a priority heap, where the start time of the working time period corresponding to the top node of the priority heap is the earliest, and the priority heap indicates the priority queue;

[0019] Removing the working time period ranked first from the priority queue includes:

[0020] After removing the top node of the priority heap, perform heap sort on the remaining nodes in the priority heap to obtain an updated priority heap.

[0021] In a possible implementation method, after removing the top node of the priority heap, performing heap sort on the remaining nodes in the priority heap includes:

[0022] Exchange the top node of the priority heap with the tail node of the heap;

[0023] After removing the tail node of the priority heap, perform heap sort on the remaining nodes in the priority heap.

[0024] In a possible implementation method, before obtaining the working time periods corresponding to multiple target objects in response to a calculation request from an operating object to calculate the idle time periods of multiple target objects, it further includes:

[0025] Obtain the scheduling data under the target group. The target group includes multiple target objects, and the scheduling data includes the working periods corresponding to each target object;

[0026] Store the scheduling data in the cache server;

[0027] In response to a calculation request from an operating object to calculate the idle periods of multiple target objects, obtain the working periods corresponding to the multiple target objects, including:

[0028] In response to the calculation request, obtain the scheduling data from the cache server;

[0029] Obtain the working periods of multiple target objects according to the scheduling data.

[0030] In a possible implementation method, before obtaining the scheduling data under the target group, it further includes:

[0031] Create a target task in the message queue. The target task instructs to obtain the scheduling data under the target group based on a preset frequency.

[0032] In a possible implementation method, before storing the scheduling data in the cache server, it further includes:

[0033] Based on the target group, perform group labeling on the scheduling data;

[0034] Store the scheduling data including group labeling in the cache server;

[0035] Obtain the scheduling data from the cache server, including:

[0036] Based on the group labeling, obtain the scheduling data from the cache server.

[0037] In a possible implementation method, in response to the calculation request, obtain the scheduling data from the cache server, including:

[0038] In response to a calculation request from an operating object for idle periods, perform permission verification on the operating object;

[0039] If the operating object passes the permission verification, obtain the scheduling data from the cache server.

[0040] In a possible implementation method, obtain the working periods of multiple target objects according to the scheduling data, including:

[0041] Visualize the scheduling data;

[0042] In response to a selection operation of an operating object on multiple target objects, obtain the working periods of the multiple target objects.

[0043] In a possible implementation method, outputting idle periods to an operation object includes:

[0044] Visualizing and displaying the idle periods through the terminal device corresponding to the operation object.

[0045] In a possible implementation method, storing scheduling data in a cache server includes:

[0046] Serializing the scheduling data to obtain corresponding string data;

[0047] Storing the string data in the cache server;

[0048] Obtaining scheduling data from the cache server includes:

[0049] Obtaining the string data from the cache server;

[0050] Deserializing the string data to obtain the scheduling data.

[0051] A second aspect of the present application provides a calculation device for idle periods, including:

[0052] An acquisition module, configured to respond to a calculation request of an operation object for calculating idle periods of multiple target objects, and acquire the working periods corresponding to the multiple target objects, where the working periods include start time and end time;

[0053] A table building module, configured to establish a priority queue based on the chronological order of the start times, where the priority queue indicates the sorting of the multiple working periods;

[0054] An initialization module, configured to initialize a first variable, and the initial value of the first variable is the start time of the working period at the head of the priority queue;

[0055] A parameter determination module, configured to determine the first variable based on a first parameter, and if the first variable is less than the first parameter, update the first variable to the first parameter, where the first parameter indicates the end time of the working period at the head of the priority queue;

[0056] A period determination module, configured to, if the determined first variable is less than a second parameter, determine the period between the determined first variable and the second parameter as the idle periods of the multiple objects, where the second parameter indicates the start time of the working period at the second place in the priority queue;

[0057] A loop module, configured to remove the working period at the head of the priority queue, and re-determine the first variable until the priority queue is empty.

[0058] In a possible implementation method, if the working period includes a first period and a second period, and the start time of the first period is less than the start time of the second period, the priority queue specifically indicates the sorting of multiple first periods;

[0059] A loop module, specifically used to, if the working period removed from the priority queue is a first period, add the corresponding second period to the priority queue and update the priority queue; re-determine the first variable until the priority queue is empty;

[0060] An output module, used to output the idle period to the operating object.

[0061] In a possible implementation method, a table building module, specifically used to build multiple working periods into a priority heap based on the start time using the heap sort method, where the start time of the working period corresponding to the top node of the priority heap is the earliest, and the priority heap indicates the priority queue;

[0062] A loop module, specifically used to, after removing the top node in the priority heap, perform heap sort on the remaining nodes in the priority heap to obtain an updated priority heap; re-determine the first variable until the priority queue is empty.

[0063] In a possible implementation method, in the loop module, after removing the top node in the priority heap, performing heap sort on the remaining nodes in the priority heap includes:

[0064] Exchanging the top node in the priority heap with the tail node; after removing the tail node in the priority heap, performing heap sort on the remaining nodes in the priority heap.

[0065] In a possible implementation method, it further includes:

[0066] A pre-storage module, used to obtain the scheduling data under the target group, the target group includes multiple target objects, and the scheduling data includes the working periods corresponding to each target object;

[0067] Storing the scheduling data in the cache server;

[0068] An obtaining module, specifically used to, in response to a calculation request for the idle period by the operating object, obtain the scheduling data from the cache server; obtain the working periods of multiple target objects according to the scheduling data.

[0069] In a possible implementation method, it further includes:

[0070] A task creation module, used to create a target task in the message queue, and the target task indicates obtaining the scheduling data under the target group based on a preset frequency.

[0071] In a possible implementation method, it further includes:

[0072] A labeling module, configured to label the scheduling data based on a target group; and store the scheduling data including the group label in a cache server.

[0073] An obtaining module, specifically configured to obtain the scheduling data from the cache server based on the group label.

[0074] In a possible implementation method, the obtaining module is specifically configured to perform permission verification on an operating object in response to a calculation request for an idle period of the operating object; if the operating object passes the permission verification, obtain the scheduling data from the cache server.

[0075] In a possible implementation method, the obtaining module is specifically configured to visually display the scheduling data; and obtain the working periods of multiple target objects in response to a selection operation of the multiple target objects by the operating object.

[0076] In a possible implementation method, an output module is configured to visually display the idle period through a terminal device corresponding to the operating object.

[0077] In a possible implementation method, a pre-storage module is specifically configured to serialize the scheduling data to obtain corresponding string data; and store the string data in the cache server.

[0078] The obtaining module is specifically configured to obtain the string data from the cache server; and deserialize the string data to obtain the scheduling data.

[0079] A third aspect of this application provides a computer device, including:

[0080] A memory, a transceiver, a processor, and a bus system;

[0081] Wherein, the memory is used to store a program;

[0082] The processor is used to execute the program in the memory, including executing the methods in the above aspects;

[0083] The bus system is used to connect the memory and the processor to enable communication between the memory and the processor.

[0084] A fourth aspect of this application provides a computer-readable storage medium, in which instructions are stored, and when the instructions run on a computer, the computer is enabled to execute the methods in the above aspects.

[0085] A fifth aspect of the present application provides a computer program product or a computer program. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the methods provided in the above aspects.

[0086] As can be seen from the above technical solutions, the embodiments of the present application have the following advantages:

[0087] The present application provides a method for calculating idle time periods and related devices. First, in response to a calculation request from an operation object to calculate the idle time periods of multiple target objects, the working time periods corresponding to the multiple target objects are obtained, where the working time periods include start times and end times; a priority queue is established based on the order of the start times of each working time period. In this priority queue, the working time period with an earlier start time is sorted closer to the head of the queue; then a parameter variable is determined, and the parameter variable is used to determine the start time of the idle time period; if the parameter variable is less than the end time of the working time period at the top of the priority queue, the parameter variable is updated to the end time. It can be understood that if the parameter variable is not less than the end time, the parameter variable is not changed; after determining the value of the parameter variable, it is determined whether the determined parameter variable is less than the start time of the working time period at the second position in the priority queue. If it is less, it means that there is an idle time period before the working time period at the second position, and the idle time period is the period between the value of the parameter variable and the start time of the working time period at the second position; after removing the working time period at the top from the priority queue, the above steps of determining the parameter variable are returned, and again through the operations of determining the idle time period based on size comparison and removing the head from the queue until all the working time periods in the priority queue are removed. The idle time period determined through the above steps is the common idle time period of the multiple target objects. By setting a first variable and then assigning a value to the variable based on the size relationship between the first variable and other parameters, this method determines the idle time period. Compared with the brute-force traversal algorithm in the prior art, this method can effectively reduce the CPU calculation amount and improve the CPU calculation efficiency. Description of the Drawings

[0088] Figures 1a to 1e It is a schematic diagram of the corresponding interface of the shift scheduling management function in an office software;

[0089] Figure 2 It is an application environment diagram of the method for calculating idle time periods in the embodiments of the present application;

[0090] Figure 3 It is a method flow chart of the method for calculating idle time periods provided by the embodiments of the present application;

[0091] Figure 4a It is a schematic diagram of the working periods of each target object in the embodiments of the present application;

[0092] Figure 4b It is a schematic diagram for sorting the working periods of each target object in the embodiments of the present application;

[0093] Figures 5a to 5e It is a schematic diagram of the heap adjustment process based on the heap sort algorithm in the embodiments of the present application;

[0094] Figures 6a to 6m It is a schematic diagram for calculating idle periods based on a priority heap in the embodiments of the present application;

[0095] Figure 7 It is a flowchart of the method for calculating idle periods provided by the embodiments of the present application;

[0096] Figure 8 It is a schematic diagram of the operation of a message queue;

[0097] Figure 9 It is a signaling diagram for transmitting the method for calculating idle periods provided by the embodiments of the present application;

[0098] Figure 10 It is a schematic diagram of the scheduling data provided by the embodiments of the present application;

[0099] Figure 11 It is a schematic diagram of the device for calculating idle periods in the embodiments of the present application;

[0100] Figure 12 It is a schematic diagram of a server structure provided by the embodiments of the present application. Detailed implementation manners

[0101] Terms such as "first", "second", "third", "fourth", etc. (if any) in the specification, claims and above-mentioned drawings of the present application 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 under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "comprising" and "corresponding to" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units does not necessarily limit to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.

[0102] Automated office is a new type of office method that combines modern office and computer technology. By using advanced technological means, it optimizes the traditional office process and brings great convenience to enterprises. Among them, shift scheduling management is an important part of automated office. Shift scheduling refers to reasonably arranging the working hours and shifts of employees according to the needs and resources of the enterprise to improve work efficiency and meet business requirements. In automated office, administrators can schedule each employee through corresponding office software.

[0103] As Figures 1a to 1e shown, Figures 1a to 1e it is a schematic diagram of the corresponding interface of the shift scheduling management function in an office software.

[0104] It can be understood that operators can allocate the working hours of employees through the relevant interfaces of the shift management function of the office software, and employees perform attendance according to the schedule. Punching is a way of attendance used to record the attendance time of employees.

[0105] As Figure 1a shown, after the operator enters the interface for editing punch rules, the interface displays the punch rules for going to work and getting off work in the current state. The interface includes the groups for which the operator can edit the punch rules. As Figure 1a shown, it includes two groups, "Science and Technology Park" and "Market Sales Center". Among them, "Smart Science and Technology Park" corresponds to the employees in the smart science and technology park, and "Market Sales Center" corresponds to the employees in the Southwest Sales Center and the South China Sales Center. The interface shows the work types, work or shift times, work locations, and overtime methods corresponding to each group.

[0106] As Figure 1b shown, when the operator clicks on the punch rules of the target group, a drop-down box will appear, showing: "Shift Scheduling" and "Edit Rules". Among them, "Shift Scheduling" indicates scheduling the employees in the target group, and "Edit Rules" refers to editing the punch rules of the target group, such as: punch location, whether an application is required for overtime, etc. For example, clicking on the "Market Sales Center" group allows editing of the shift scheduling and punch rules for this group.

[0107] As Figure 1c shown, when the operator clicks on "Shift Scheduling", the office software will pull the punch employees in the current group in real time and display the shift scheduling situation of each employee. For example, when scheduling by shift, one can choose from morning shift, night shift, and rest. To avoid having no employees scheduled for a certain period, it is necessary to calculate the common idle time periods of each employee. In the interface shown, the shift for Wang Wu on Wednesday has been selected, and one can click on the 3 shifts below to schedule Wang Wu's shift for that day.

[0108] As Figure 1dAs shown, in addition to scheduling according to morning and evening shifts, scheduling can also be done according to cycles.

[0109] As Figure 1e shown, when the operator clicks on Figure 1d "Add Scheduling Cycle" in Figure 1e the interface shown, the cycle name, cycle days, etc. can be set. Similarly, in order to avoid having no employees scheduled for duty during a certain period, it is necessary to calculate the common idle time periods of each employee.

[0110] It can be understood that calculating the common idle time periods of multiple employees is a common requirement.

[0111] To calculate the idle time periods, the currently commonly used method is the brute-force traversal algorithm, which finds the common idle time periods by comparing the schedule of each employee one by one. For small enterprises, due to the relatively small number of employees, this algorithm may still run well. However, in large enterprises, due to the large number of employees, the brute-force traversal algorithm may face performance problems, causing the CPU and memory of the machine to be overloaded.

[0112] To solve the above problems, the embodiment of the present application provides a method for calculating idle time periods, sets a queue based on the order of the start times of each employee's work, and then finds the common idle time according to the relationship between the intermediate variable and the work periods of each employee by setting an intermediate variable. The method for calculating idle time periods provided by the embodiment of the present application can significantly reduce the CPU calculation amount and improve the CPU calculation efficiency compared with the brute-force traversal algorithm in the prior art.

[0113] For ease of understanding, please refer to Figure 2 , Figure 2 which is the application environment diagram of the method for calculating idle time periods in the embodiment of the present application. As Figure 2 shown, the method for calculating idle time periods in the embodiment of the present application is applied to a scheduling system. The scheduling system includes: a server and a terminal device; wherein, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, Content Delivery Network (CDN), and big data and artificial intelligence platforms. The terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited thereto. The terminal and the server can be directly or indirectly connected through wired or wireless communication methods, and the embodiment of the present application does not make any restrictions here.

[0114] The server first obtains a calculation request for calculating the idle period of multiple target objects in response to an operation object, and the working periods corresponding to the multiple target objects, where the working period includes a start time and an end time; based on the order of the start times of each working period, a priority queue is established. In this priority queue, the working period with an earlier start time is sorted closer to the head; then a parameter variable is determined, and this parameter variable is used to determine the start time of the idle period; if the parameter variable is less than the end time of the working period at the top of the priority queue, then the parameter variable is updated to this end time. It can be understood that if the parameter variable is not less than this end time, the parameter variable remains unchanged; after determining the value of the parameter variable, it is judged whether the parameter variable is less than the start time of the working period at the second position in the priority queue. If it is less, it means that there is an idle period before the second working period, and this idle period is the period between the value of the parameter variable and the start time of the second working period; after removing the working period at the top from the priority queue, the above steps of determining the parameter variable are returned, and again through the operations of determining the idle period based on size comparison and removing the head from the queue until all the working periods in the priority queue are removed. The idle period determined through the above steps is the common idle period of the multiple target objects.

[0115] Next, from the perspective of the server, the method for calculating the idle period in this application will be introduced. Please refer to Figure 3 , Figure 3 which is the flowchart of the method for calculating the idle period provided by the embodiment of this application, including:

[0116] 301. In response to a calculation request from an operation object to calculate the idle period of multiple target objects, obtain the working periods corresponding to the multiple target objects, where the working period includes a start time and an end time.

[0117] The operation object refers to the entity responsible for managing and scheduling the working hours of the target object, which can be an employee manager or the operation terminal corresponding to the manager. The multiple target objects are the multiple enterprise employees for whom the common idle period needs to be calculated, and each employee can have one or more working periods, including a start time and an end time. For the sake of easy understanding, the embodiment of this application will be based on Figure 4a and Figure 4b to describe this method in detail.

[0118] Please refer to Figure 4a , Figure 4a which is the schematic diagram of the working periods of each target object in the embodiment of this application. The working period of each target object is represented by a start time (begintime) and an end time (endtime).

[0119] It can be understood that, as Figure 4aAs shown, the target objects include 6 employees, and the corresponding working periods are as follows:

[0120] Employee A: The working period is from 7:00 to 11:00;

[0121] Employee B; The working periods are from 6:00 to 10:00; from 12:00 to 13:00;

[0122] Employee C: The working period is from 5:00 to 7:00;

[0123] Employee D: The working periods are from 2:00 to 3:00; from 4:00 to 5:00;

[0124] Employee E: The working period is from 4:00 to 6:00;

[0125] Employee F: The working periods are from 1:00 to 2:00; from 5:00 to 6:00.

[0126] For employees with multiple working periods, they are sorted according to the order of the start and end times of each period.

[0127] 302. Based on the order of the start times, a priority queue is established, and the priority queue indicates the sorting of multiple working periods.

[0128] It can be understood that a priority queue is a data structure in which elements are sorted according to a specific priority order. When processing the working periods of multiple target objects, a priority queue can be established based on the order of the start times to indicate the sorting of multiple working segments.

[0129] When a certain target object includes multiple target periods, at this time, the priority queue sorts the periods that start first. Please refer to Figure 4b , Figure 4b This is a schematic diagram for sorting the working periods of each target object in the embodiment of the present application.

[0130] As Figure 4b shown, since the working periods of Employee D and Employee F include two segments, based on the first working period, they are put into the priority queue.

[0131] In a possible implementation method, this step 302 specifically includes:

[0132] Based on the start time, the heap sort method is used to construct multiple working periods into a priority heap, where the start time of the working period corresponding to the top node of the priority heap is the earliest, and the priority heap indicates the priority queue.

[0133] It can be understood that the underlying logic of the priority queue can be implemented based on the binary min heap in the heap sort algorithm. After visualizing the algorithm data, it is as Figures 5a to 5e shown.

[0134] As Figure 5a shown, after obtaining the working period data of the 6 employees as in Figure 4a , the first working periods corresponding to the 6 employees are arranged in the form of a binary heap. Then, through the process of sifting up the heap, a binary min-heap is obtained.

[0135] To sift up the heap, first locate the last parent node, that is, the last node with children, and start the sifting up search. The core of the search is: find the child node with a lower priority than the parent node, swap positions with the parent node, and recursively compare the priorities downward with the current parent node as the benchmark.

[0136] As Figure 5a shown, the last parent node is node C, and the children nodes of node C are node F. In the comparison of nodes F and C, the begintime of the parent node F is smaller, so the nodes F and C need to be swapped. The swapping result is as shown in Figure 5b .

[0137] After executing the parent node C, traverse backward to find the next parent node B and compare the priorities. It is found that the priority of node D is higher than that of node B (because the begintime is smaller), so swap the positions of node D and node B. After swapping positions, with B as the parent node, compare the priorities downward. Since B has no children nodes, the process ends, as shown in Figure 5c .

[0138] Similarly, traverse backward to find the next parent node A, and it is found that the priority of node F is higher than that of node A, so swap the positions of node A and node F, as shown in Figure 5d .

[0139] Since the swapped parent node A has a child node C after swapping, it is necessary to recursively compare downward. At this time, the priority of the child node C is higher than that of the parent node A, so the nodes A and C need to be swapped again, as shown in Figure 5e .

[0140] After traversing the last parent node, the final schematic diagram of the priority queue is obtained, and this priority queue is reflected in the form of a priority heap. It can be understood that in this priority heap, the priority of the parent node is higher than that of the child node.

[0141] 303. Initialize the first variable, and the initial value of the first variable is the start time of the working period at the head of the priority queue;

[0142] After determining the priority, the embodiment of the present application introduces a variable parameter, denoted as the first variable, which specifically indicates the start time of the idle period. First, an initial value is defined for the first variable. It can be understood that this initial value can indicate the start time of work during the complete working period. For example, for a certain job where employees need to be on duty from 8:00 am to 10:00 pm, the complete working period for this position is from 8:00 to 22:00, so the initial value of the first variable is 8.

[0143] It should be noted that the working periods indicated in the above embodiments are divided based on the actual start time and end time. In some positions, the working period divides the complete working time into multiple working hours. For example, still taking the complete working period from 8:00 to 22:00 as an example, which includes 14 hours, the administrator can define every half hour as a working hour, that is, the complete working period includes 28 working hours. Under this rule, the working periods of employees can be divided by working hours. For example:

[0144] 1) Taking the complete working period from 8:00 to 22:00 as an example, with every half hour as a working hour, if the working period of employee A is from 1 to 4, it means that the working period of employee A is from the 1st working hour to the 4th working hour. Converted to actual time, it means from 8:00 to 10:00. At this time, the initial value of the first variable is 1 (indicating that the start time of the first working hour is 8:00).

[0145] 2) Taking the complete working period from 20:00 to 10:00 the next day as an example, with every 1 hour as a working hour, if the working period of employee B is from 3 to 11, it means that the working period of employee B is from the 3rd working hour to the 4th working hour. Converted to actual time, it means from 22:00 to 6:00 the next day. At this time, the initial value of the first variable is still 1 (indicating that the start time of the first working hour is 20:00).

[0146] 304. Determine the first variable based on the first parameter. If the first variable is less than the first parameter, update the first variable to the first parameter, where the first parameter indicates the end time of the working period at the head of the priority queue.

[0147] It can be understood that since the working periods in the priority queue are sorted from early to late based on the start time of work, then if the target object corresponding to the working period at the head finishes work and there is no connection to the start time of the next working period, the time during this period is the idle period. Based on this principle, the embodiment of the present application defines the first variable as the start time of the idle period, and when the first variable is less than the end time (the first parameter) of the working period at the head of the priority queue, assign the end time of this head working period to the first variable.

[0148] 305. If the determined first variable is less than the second parameter, the time period between the determined first variable and the second parameter is determined as the idle time period of multiple objects, where the second parameter indicates the start time of the working time period in the second position in the priority queue.

[0149] It can be understood that, as described in step 304, after defining the first variable as the start time of the idle time period, if the first variable is less than the start time of the working time period in the second position in the priority queue (the second parameter), then it can be considered that there is no working time period from the time represented by the first variable until the time represented by the second parameter, so this time period is the idle time period.

[0150] 306. Remove the working time period in the first position from the priority queue.

[0151] It can be understood that after the comparison calculation in step 305, the idle time period (if any) between the first working time period and the second working time period in the priority queue is determined. The working time period in the first position is no longer needed in the subsequent calculation process, so it can be removed from the priority queue, and then the same method is used to calculate whether there are other idle time periods.

[0152] 307. Determine whether the priority queue is empty. If the priority queue is not empty, loop through steps 304 to 305; if the priority queue is empty, end the loop.

[0153] Remove the working time periods from the priority queue in turn, re-determine the first variable, and obtain other idle time periods through comparison operations until all the working time periods in the priority queue are removed.

[0154] It can be understood that when there are multiple working time periods, for example, including the first time period and the second time period, and the start time of the first time period is less than the start time of the second time period. At this time, if the working time period removed from the priority queue is the first time period, then add the corresponding second time period to the priority queue and update the priority queue.

[0155] For the sake of easy understanding, the embodiments of the present application are described in detail based on Figure 5e the priority heap obtained in

[0156] When the priority queue is embodied in the form of a priority heap, step 306 specifically includes:

[0157] After removing the top node of the priority heap, perform heap sorting on the remaining nodes in the priority heap to obtain an updated priority heap.

[0158] Please refer to Figures 6a to 6m , Figures 6a to 6mSchematic diagram of calculating idle time based on priority heap in the embodiments of the present application.

[0159] First, define an anchor (the first variable) for special record comparison, and set its initial value to 1, which is the smallest begintime among all employees. At the same time, define ans, where ans = (anchor, begintime), and begintime is the start time of the working period corresponding to the dequeued node, that is, record the final common space period. Only when anchor is less than the begintime of the next dequeued node can ans be regarded as the common idle time.

[0160] The algorithm for dequeueing the priority queue is: swap the top vertex of the heap with the last vertex, delete the last vertex, and then start sinking and adjusting the heap from the top vertex.

[0161] As Figure 6a shown, first swap the top vertex F of the heap with the last vertex A. After the swap, the last vertex is vertex F, and then delete the last vertex F.

[0162] The begintime of the dequeued node F = 1. At this time, ans = (anchor, begintime) = (1, 1), indicating that there is no idle period currently. The endtime of node F = 2, which is greater than anchor, so assign endtime = 2 to anchor. At this time, anchor = 2. Then perform heap sorting on the remaining nodes in the priority heap.

[0163] Starting from vertex A, continuously sink and compare the priorities. The priority of the parent node A is smaller than that of the child node D, so A and D are swapped, as Figure 6b shown.

[0164] At this time, A is the parent node, and the priority of the parent node A is smaller than that of E, so A and E are swapped. Since E has no child nodes, the process ends, as Figure 6c shown.

[0165] Since there is still the next working period [5, 6] for the dequeued node F, after the first period of the dequeued node F is dequeued, the next working period needs to be enqueued. In this embodiment, the enqueue method for the next period is to link this working period to the last node, as Figure 6d shown.

[0166] Similarly, use the previous floating and adjusting heap algorithm to continuously exchange the priority nodes, as Figures 6e to 6f shown, and finally obtain the current priority queue. At this time, the top node of the heap is node D.

[0167] Repeat the above dequeue steps until all nodes are dequeued:

[0168] Node D dequeues, ans = (anchor, begintime) = (2, 2), indicating that there is no idle period currently. The endtime of Node D is 3, which is greater than anchor, so anchor = 3. Since the time period when Node D dequeues currently is the first working period, the second working period [4, 5] of Node D needs to be added at this time. Then the priority queue after floating up and adjusting the heap is as Figure 6h shown.

[0169] Node E dequeues, ans = (anchor, begintime) = (3, 4), indicating that there is an idle period currently, and this idle period will be recorded as ans1, ans1 = (3, 4). The endtime of Node E is 6, which is greater than anchor, so anchor = 6. After Node E dequeues, the priority queue after floating up and adjusting the heap is as Figure 6i shown.

[0170] Node D dequeues, ans = (anchor, begintime) = (6, 4), indicating that there is no idle period currently. The endtime of Node D is 5, which is less than anchor, so anchor remains 6. After Node D dequeues, the priority queue after floating up and adjusting the heap is as Figure 6j shown.

[0171] Node C dequeues, ans = (anchor, begintime) = (6, 5), indicating that there is no idle period currently. The endtime of Node C is 7, which is greater than anchor, so anchor = 7. After Node C dequeues, the priority queue after floating up and adjusting the heap is as Figure 6k shown.

[0172] Node F dequeues, ans = (anchor, begintime) = (7, 5), indicating that there is no idle period currently. The endtime of Node F is 6, which is less than anchor, so anchor remains 7. After Node F dequeues, the priority queue after floating up and adjusting the heap is as Figure 6l shown.

[0173] Node B dequeues; ans = (anchor, begintime) = (7, 6), indicating that there is no idle period currently. The endtime of Node B is 10, which is greater than anchor, so anchor = 10. Since the time period when Node B dequeues currently is the first working period, the second working period [12, 13] of Node B needs to be added at this time. Then the priority queue after floating up and adjusting the heap is as Figure 6m shown.

[0174] Node A dequeues, ans = (anchor, begintime) = (10, 7), indicating that there is no idle period currently. The endtime of Node A is 11, which is greater than anchor, so anchor = 11.

[0175] Finally, Node B dequeues, ans = (anchor, begintime) = (11, 12), indicating that there is an idle period currently, and this idle period will be recorded as ans2, ans2 = (11, 12).

[0176] At this time, all the nodes in the priority queue have been dequeued, and the finally obtained idle periods are ans1 = (3, 4) and ans2 = (11, 12). That is, the idle periods for the above-mentioned multiple target objects are from 3 o'clock to 4 o'clock and from 11 o'clock to 12 o'clock. By comparison Figure 4a , this time period is indeed the period when all employees are idle.

[0177] 308, output the idle period to the operation object.

[0178] It can be understood that after the above calculations, the obtained idle periods include ans1 = (3, 4) and ans2 = (11, 12). That is, from 3 o'clock to 4 o'clock and from 11 o'clock to 12 o'clock. At this time, the calculation results of this idle period can be output to the operation object, so as to facilitate the operation object to perform subsequent scheduling and other operations.

[0179] The calculation method for idle time provided by the embodiments of the present application first obtains the working hours corresponding to multiple target objects, where the working hours include a start time and an end time; based on the order of the start times of each working hour, a priority queue is established. In this priority queue, the working hour with an earlier start time is sorted closer to the head; then a parameter variable is determined, and this parameter variable is used to determine the start time of the idle time; if the parameter variable is less than the end time of the working hour at the top of the priority queue, then the parameter variable is updated to this end time. It can be understood that if the parameter variable is not less than this end time, the parameter variable remains unchanged; after determining the value of the parameter variable, it is judged whether the parameter variable is less than the start time of the working hour at the second position in the priority queue. If it is less, it means that there is an idle time before the second working hour, and this idle time is the time period between the value of the parameter variable and the start time of the second working hour; after removing the working hour at the top from the priority queue, return to the above step of determining the parameter variable, and perform the operations of determining the idle time based on size comparison and removing the head from the queue again until all the working hours in the priority queue are removed. The idle time determined through the above steps is the common idle time of multiple target objects. This method determines the idle time by setting a first variable and then assigning a value to the variable based on the size relationship between the first variable and other parameters. This method only determines two parameters for each employee, namely the start time of work and the end time of work. Compared with the brute-force traversal algorithm in the prior art, this method can effectively reduce the CPU calculation amount and improve the CPU calculation efficiency.

[0180] In the present application Figure 3 In an optional embodiment of the calculation method for idle time provided by the corresponding embodiment, please refer to Figure 7 , Figure 7 which is the flowchart of the calculation method for idle time provided by the embodiments of the present application, and includes:

[0181] 701. Create a target task in the message queue. The target task instructs to obtain the scheduling data of the target group at a preset frequency. The target group includes multiple target objects, and the scheduling data includes the working hours corresponding to each target object.

[0182] It can be understood that a message queue (MQ) is a mechanism for processing asynchronous tasks. After being combined with a timer, it can execute timed tasks asynchronously. For example Figure 8As shown in the figure, after encapsulating the task into a task, each task has a taskid: task ID number, uin: ID for routing to a certain machine, and cmdid: interface for specifically executing the task. After putting the task into the MQ queue, it will not be executed immediately. Instead, it waits in the queue, and after a fixed time, the consumer service starts to consume the task regularly, that is, execute the task.

[0183] The target group is the group corresponding to multiple target objects, which can specifically be the departments, positions, work parks, etc. where the multiple target objects are located.

[0184] The scheduling data includes the working periods corresponding to each target object. Figure 4a The data corresponding to the content shown is the scheduling data.

[0185] Please refer to Figure 9 , Figure 9 For the transmission signaling diagram of the calculation method of the idle period provided by the embodiment of the present application, in the embodiment of the present application, a target task can be created in the message queue (Mq), and the target task is used to instruct the process service (CrontabSvr) to regularly obtain the employee data and scheduling data under the rule from the database (DataBase). The employee data includes the identity identifier of each employee.

[0186] 702, obtain the scheduling data under the target group.

[0187] It can be understood that after the target task is executed in the message queue, the scheduling data under the target group can be obtained.

[0188] Such as Figure 9 As shown in the figure, after creating the target task, the process service (CrontabSvr) sorts out the parameters to facilitate regularly triggering the target task based on a preset frequency. The parameters that need to be sorted out include information such as enterprise ID, permission token, punch card rule ID, etc., which are used to accurately obtain the corresponding data from the database (DataBase).

[0189] 703, store the scheduling data in the cache server;

[0190] It can be understood that after obtaining the scheduling data, write it into the cache server, and the data can be quickly obtained during subsequent calculation of the idle period, improving the corresponding speed.

[0191] Such as Figure 9 As shown in the figure, after the database (DataBase) returns the employee data and scheduling data to the process service (CrontabSvr), the process service (CrontabSvr) writes them into the cache (Cache). At this time, the target task is completed.

[0192] 704. In response to a calculation request for idle time periods from an operating object, obtain scheduling data from the cache server;

[0193] It can be understood that when the operating object performs operation behaviors such as using the scheduling management function, a calculation request for idle time periods will be sent. After responding to this calculation request, scheduling data is obtained from the cache server.

[0194] Such as Figure 9 As shown, after the operating object clicks on relevant buttons such as viewing the clock-in rules, the interface at the user node (Node) end is triggered. After the Node end forms the request information into a request (Req) packet, it calls the background interface at the server (Svr) end to start requesting data for specific clock-in rules. The Svr end receives the Req request packet and forwards the Req packet to the actual logic processing (Logic) end for processing. The scheduling data is retrieved from the cache through the Logic end.

[0195] In a possible implementation method, step 704 specifically includes:

[0196] In response to a calculation request for idle time periods from an operating object, perform permission verification on the operating object;

[0197] If the operating object passes the permission verification, obtain scheduling data from the cache server.

[0198] It can be understood that after receiving the calculation request, permission verification can also be performed on the operating object to ensure that the operator has the permission to view the idle time periods or edit the attendance rules.

[0199] Such as Figure 9 As shown, after the Logic end receives the Req request packet, it starts to unpack it, parses out the specific parameters: enterprise ID, operator ID, operation Unix timestamp, operator's permissions, etc., and performs a non-zero verification on the parameters (if the required parameter is 0, an error is directly reported), and performs permission verification on the operator. Only when the permission verification passes will the scheduling data be queried and obtained from the cache.

[0200] In a possible implementation method, before step 703, it further includes:

[0201] Based on the target grouping, perform group labeling on the scheduling data;

[0202] Store the scheduling data including group labeling in the cache server;

[0203] At this time, step 704 specifically includes: In response to a calculation request for idle time periods from an operating object, obtain scheduling data from the cache server based on the group labeling

[0204] It can be understood that there may be multiple groups of scheduling data stored in the cache server. Therefore, before storing the scheduling data in the cache server, the scheduling data can be labeled based on the group, so that the scheduling data can also be extracted from the cache server based on the group label later.

[0205] In one possible implementation, step 703 specifically includes:

[0206] Serialize the scheduling data to obtain the corresponding string data;

[0207] Store the string data in the cache server;

[0208] At this time, step 704 specifically includes deserializing the string data to obtain the scheduling data.

[0209] It can be understood that serializing the data can improve the data's transportability, storability, efficiency, and security. At the same time, it also helps to achieve cross-platform and language interoperability and compatibility. Therefore, before storing the scheduling data in the cache, the scheduling data can also be serialized to obtain string data. Then, when extracting the scheduling data from the cache server, specifically extract the string data and then deserialize it to obtain the scheduling data.

[0210] Such as Figure 10 shown, Figure 10 is a schematic diagram of the scheduling data provided by the embodiments of the present application. The scheduling data of employees in multiple different groups of an enterprise are respectively recorded; before writing the scheduling data into the cache, it is serialized to obtain a serialized string stream; when the corresponding scheduling data is needed, the serialized string stream is deserialized to obtain the employee information of each employee, including the employee id and their corresponding work time arrangement (scheduling data).

[0211] 705. Obtain the working periods of multiple target objects according to the scheduling data.

[0212] It can be understood that after retrieving the scheduling data from the cache server, the scheduling data includes the storage data of the scheduling details of all employee objects in the entire target group. To calculate the idle periods of the specified multiple target objects, it is necessary to obtain the working periods of the specified multiple target objects from the scheduling data.

[0213] In one possible implementation method, step 705 specifically includes:

[0214] Visually display the scheduling data;

[0215] In response to a selection operation of an operating object on multiple target objects, obtain the working periods of the multiple target objects.

[0216] It can be understood that the multiple target objects can be employee objects specified by the operating object. Therefore, after obtaining the scheduling data under the target group, the scheduling data can be visually displayed, specifically by displaying each employee object under the target group. Based on the selection operation of the operating object on multiple target objects among each employee object, the working periods of the specified multiple target objects can be obtained to calculate the idle periods of the specified multiple target objects.

[0217] 706. Calculate the idle period based on the working periods of the multiple target objects.

[0218] It can be understood that step 706 is equivalent to Figure 3 Steps 301 to 307 in the corresponding embodiment. For specific descriptions, please refer to the above text and will not be elaborated here.

[0219] Such as Figure 9 shown, Figure 3 The corresponding embodiment of the steps in the corresponding embodiment is stored in the Algorithm Logic Server (AlgorithmSvr), and the common idle time of multiple target objects is obtained by executing the algorithm. In a possible implementation method, Figure 3 Step 308 in the corresponding embodiment may specifically include: visually displaying the idle period through the terminal device corresponding to the operating object.

[0220] It can be understood that after obtaining the idle period, the idle period can be returned to the user side and visually displayed to the operating object, so that the operating object can perform typesetting operations based on the idle period.

[0221] Such as Figure 9 shown, the Logic side returns the calculation result of the idle period to the Svr side, and the Svr side then returns it to the Node side. After being sorted out by the Node side, the common idle time period of the selected employees under the current rules can be displayed to the operating user.

[0222] The method provided in the embodiments of the present application, on the basis of Figure 3 the method provided in the corresponding embodiment, by means of the asynchronous MQ timed early pull and storage method, the scheduling data of the same group is sorted out and stored in the cache in advance; compared with the original real-time pull and storage data scheme, the data processing rate is effectively enhanced.

[0223] The following will describe in detail the calculation device for the idle period in the present application. Please refer to Figure 11 . Figure 11 FIG. is a schematic diagram of an embodiment of the calculation device 1100 for the idle period in the embodiments of the present application, including:

[0224] An acquisition module 1101, configured to acquire working periods corresponding to a plurality of target objects in response to a calculation request from an operation object for calculating idle periods of the plurality of target objects, where the working periods include start times and end times;

[0225] A table building module 1102, configured to build a priority queue based on the chronological order of the start times, where the priority queue indicates the sorting of the plurality of working periods;

[0226] An initialization module 1103, configured to initialize a first variable, where the initial value of the first variable is the start time of the working period at the head of the priority queue;

[0227] A parameter determination module 1104, configured to determine the first variable based on a first parameter, and if the first variable is less than the first parameter, update the first variable to the first parameter, where the first parameter indicates the end time of the working period at the head of the priority queue;

[0228] A period determination module 1105, configured to, if the determined first variable is less than a second parameter, determine the period between the determined first variable and the second parameter as the idle periods of the plurality of objects, where the second parameter indicates the start time of the working period at the second place in the priority queue;

[0229] A loop module 1106, configured to remove the working period at the head from the priority queue and re-determine the first variable until the priority queue is empty;

[0230] An output module 1107, configured to output the idle periods to the operation object.

[0231] The calculation device for idle time provided by the embodiments of the present application first obtains the working hours corresponding to multiple target objects, where the working hours include a start time and an end time; based on the order of the start times of each working hour, a priority queue is established. In this priority queue, the working hour with an earlier start time is sorted closer to the head; then a parameter variable is determined, and this parameter variable is used to determine the start time of the idle time; if the parameter variable is less than the end time of the working hour at the top of the priority queue, then the parameter variable is updated to this end time. It can be understood that if the parameter variable is not less than this end time, the parameter variable remains unchanged; after determining the value of the parameter variable, it is judged whether the parameter variable is less than the start time of the working hour at the second position in the priority queue. If it is less, it means that there is an idle time before the second working hour, and this idle time is the time period between the value of the parameter variable and the start time of the second working hour; after removing the working hour at the top from the priority queue, return to the above step of determining the parameter variable, and again determine the idle time based on size comparison and remove the head from the queue until all the working hours in the priority queue are removed. The idle time determined through the above steps is the common idle time of multiple target objects. This method determines the idle time by setting a first variable and then assigning a value to the variable based on the size relationship between the first variable and other parameters. Compared with the brute-force traversal algorithm in the prior art, this method can effectively reduce the CPU calculation amount and improve the CPU calculation efficiency.

[0232] In a possible implementation method, if the working hours include a first period and a second period, and the start time of the first period is less than the start time of the second period, then the priority queue specifically indicates the sorting of multiple first periods;

[0233] The loop module 1106 is specifically configured to, if the working hour removed from the priority queue is the first period, add the corresponding second period to the priority queue and update the priority queue; re-determine the first variable until the priority queue is empty.

[0234] In this embodiment, when the working time period includes multiple time periods, first, the first working time period is put into the priority queue as a basis. When the first working time period is removed, the next working time period is continued to be put in until all the multiple working time periods are removed.

[0235] In a possible implementation method, the table building module 1102 is specifically configured to use the heap sorting method to construct multiple working hours into a priority heap based on the start time, where the start time of the working hour corresponding to the top node of the priority heap is the earliest, and the priority heap indicates the priority queue;

[0236] The loop module 1106 is specifically configured to perform heap sorting on the remaining nodes in the priority heap after removing the top node of the priority heap, so as to obtain an updated priority heap; re-determine the first variable until the priority queue is empty.

[0237] In this embodiment, the priority queue is implemented by using the heap sorting method at the underlying layer. The priority queue is embodied in the form of a heap. Removing the working period from the priority queue specifically means removing the corresponding top node of the heap.

[0238] In a possible implementation method, in the loop module 1106, after removing the top node of the priority heap, performing heap sorting on the remaining nodes in the priority heap includes:

[0239] Exchanging the top node of the priority heap with the tail node of the heap; after removing the tail node of the priority heap, performing heap sorting on the remaining nodes in the priority heap.

[0240] In this embodiment, when the priority queue is embodied in the form of a heap, specifically, the top node is first exchanged with the bottom node of the heap, and then the bottom node is removed to facilitate continued heap adjustment.

[0241] In a possible implementation method, it further includes:

[0242] The pre-storage module is used to obtain the scheduling data under the target group. The target group includes multiple target objects, and the scheduling data includes the working periods corresponding to each target object;

[0243] Storing the scheduling data in the cache server;

[0244] The acquisition module 1101 is specifically configured to, in response to a calculation request for the idle period by the operating object, obtain the scheduling data from the cache server; obtain the working periods of multiple target objects according to the scheduling data.

[0245] In this embodiment, the working periods of multiple target objects are stored in the cache server in the form of scheduling data. When the idle period calculation is required, it is directly retrieved from the cache server.

[0246] In a possible implementation method, it further includes:

[0247] The task creation module is used to create a target task in the message queue. The target task indicates obtaining the scheduling data under the target group based on a preset frequency.

[0248] In this embodiment, the form of the message queue is used to pull and store in advance regularly, and the scheduling data of the same group is sorted out and stored in the cache in advance; compared with the original real-time pulling and storing data scheme, the data processing rate is effectively enhanced.

[0249] In a possible implementation method, it further includes:

[0250] A labeling module, configured to label the shift scheduling data based on the target grouping, and store the shift scheduling data including the group label in the cache server.

[0251] The obtaining module 1101 is specifically configured to obtain the shift scheduling data from the cache server based on the group label.

[0252] In this embodiment, there may be shift scheduling data of multiple groups stored in the cache server. Therefore, before storing the shift scheduling data in the cache server, the shift scheduling data can be labeled based on the group, so that the shift scheduling data can also be extracted from the cache server based on the group label later.

[0253] In a possible implementation method, the obtaining module 1101 is specifically configured to perform permission verification on the operation object in response to a calculation request for the idle period by the operation object; if the operation object passes the permission verification, obtain the shift scheduling data from the cache server.

[0254] In this embodiment, after obtaining the calculation request, permission verification can also be performed on the operation object to ensure that the operator has the permission to view the idle period or edit the attendance rules.

[0255] In a possible implementation method, the obtaining module 1101 is specifically configured to visually display the shift scheduling data; and obtain the working periods of multiple target objects in response to a selection operation of multiple target objects by the operation object.

[0256] In this embodiment, the multiple target objects may be employee objects specified by the operation object. Therefore, after obtaining the shift scheduling data under the target grouping, the shift scheduling data can be visually displayed, and based on the selection operation of the multiple target objects by the operation object among the employee objects, the working periods of the specified multiple target objects can be obtained to calculate the idle periods of the specified multiple target objects.

[0257] In a possible implementation method, the output module 1107 is specifically configured to visually display the idle period through the terminal device corresponding to the operation object.

[0258] In this embodiment, after obtaining the idle period, the idle period can be returned to the user side and visually displayed to the operation object, so that the operation object can perform typesetting operations based on the idle period.

[0259] In a possible implementation method, the pre-storage module is specifically configured to serialize the shift scheduling data to obtain corresponding string data, and store the string data in the cache server.

[0260] An acquisition module 1101 is specifically configured to obtain string data from a cache server; deserialize the string data to obtain shift scheduling data.

[0261] In this embodiment, serializing the data can improve the data's transportability, storability, efficiency, and security. At the same time, it also helps to achieve cross-platform and language interoperability and compatibility. Therefore, before storing the shift scheduling data in the cache, the shift scheduling data can also be serialized. When extracting the shift scheduling data from the cache server, specifically, the string data is extracted and then deserialized to obtain the shift scheduling data.

[0262] Figure 12 FIG. is a schematic structural diagram of a server provided by an embodiment of the present application. The server 300 may vary greatly due to configuration or performance differences and may include one or more central processing units (CPUs) 322 (for example, one or more processors) and a memory 332, and one or more storage media 330 (for example, one or more mass storage devices) for storing application programs 342 or data 344. Among them, the memory 332 and the storage media 330 can be transient storage or persistent storage. The program stored in the storage media 330 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Further, the central processing unit 322 may be configured to communicate with the storage media 330 and execute a series of instruction operations in the storage media 330 on the server 300.

[0263] The server 300 may further include one or more power supplies 326, one or more wired or wireless network interfaces 350, one or more input / output interfaces 358, and / or one or more operating systems 341, such as Windows Server TM , Mac OS X TM , Unix TM , Linux TM , FreeBSD TM and so on.

[0264] The steps performed by the server in the above embodiments may be based on the Figure 12 server structure shown.

[0265] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the systems, devices, and units described above can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated herein.

[0266] In the embodiments of the present application, the term "module" or "unit" refers to a computer program with a predetermined function or a part of a computer program, which works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as a processing circuit or a memory), or a combination thereof. Similarly, one processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be a part of an overall module or unit that includes the function of that module or unit.

[0267] In several embodiments provided by the present application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection between each other can be through some interfaces, and the indirect coupling or communication connection of devices or units can be in electrical, mechanical, or other forms.

[0268] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they can be located in one place, or can be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0269] In addition, the functional units in each embodiment of the present application can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above integrated units can be implemented in the form of hardware or in the form of software functional units.

[0270] When the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods in various embodiments of this application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical discs.

[0271] As mentioned above, the above embodiments are only used to illustrate the technical solution of this application, rather than to limit it; although this application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of various embodiments of this application.

Claims

1. A method for calculating an idle period, characterized in that, Including: In response to a calculation request from an operating object to calculate idle periods for multiple target objects, obtain the working periods corresponding to the multiple target objects, where the working periods include start times and end times; Based on the chronological order of the start times, establish a priority queue, where the priority queue indicates the sorting of the multiple working periods; Initialize a first variable, where the initial value of the first variable is the start time of the working period at the head of the priority queue; Determine the first variable based on a first parameter. If the first variable is less than the first parameter, update the first variable to the first parameter, where the first parameter indicates the end time of the working period at the head of the priority queue; If the determined first variable is less than a second parameter, determine the period between the determined first variable and the second parameter as the idle period of the multiple objects, where the second parameter indicates the start time of the working period at the second position in the priority queue; Remove the working period at the head of the priority queue from the priority queue; Redetermine the first variable until the priority queue is empty; Output the idle period to the operating object.

2. The method according to claim 1, wherein If the working period includes a first period and a second period, and the start time of the first period is less than the start time of the second period, the priority queue specifically indicates the sorting of the multiple first periods; Before the redetermining the first variable, it further includes: If the working period removed from the priority queue is the first period, add the corresponding second period to the priority queue and update the priority queue.

3. The method according to claim 1, characterized in that The establishing a priority queue based on the chronological order of the start times includes: Based on the start times, use the heap sort method to construct the multiple working periods into a priority heap, where the start time of the working period corresponding to the top node of the priority heap is the earliest, and the priority heap indicates the priority queue; The removing the working period at the head of the priority queue from the priority queue includes: After removing the top node from the priority heap, perform heap sort on the remaining nodes in the priority heap to obtain the updated priority heap.

4. The method according to claim 3, wherein After removing the top node from the priority heap, the performing heap sort on the remaining nodes in the priority heap includes: Exchange the top node and the tail node in the priority heap; After removing the tail node from the priority heap, perform heap sort on the remaining nodes in the priority heap.

5. The method according to claim 1, wherein Before the in response to a calculation request from an operating object to calculate idle periods for multiple target objects, obtain the working periods corresponding to the multiple target objects, it further includes: Obtain the scheduling data under the target group, where the target group includes multiple target objects, and the scheduling data includes the working periods corresponding to each target object; Store the scheduling data in a cache server; The in response to a calculation request from an operating object to calculate idle periods for multiple target objects, obtain the working periods corresponding to the multiple target objects, includes: In response to the calculation request, obtain the shift scheduling data from the cache server; Obtain the working periods of the multiple target objects according to the shift scheduling data.

6. The method according to claim 5, characterized in that, Before obtaining the shift scheduling data of the target group, it further includes: Create a target task in the message queue, where the target task indicates obtaining the shift scheduling data of the target group based on a preset frequency.

7. The method according to claim 5, wherein Before storing the shift scheduling data into the cache server, it further includes: Based on the target group, perform group annotation on the shift scheduling data; Store the shift scheduling data including the group annotation into the cache server; The obtaining the shift scheduling data from the cache server includes: Based on the group annotation, obtain the shift scheduling data from the cache server.

8. The method according to claim 5, characterized in that, The responding to the calculation request and obtaining the shift scheduling data from the cache server includes: In response to the calculation request, perform permission verification on the operating object; If the operating object passes the permission verification, obtain the shift scheduling data from the cache server.

9. The method according to claim 8, characterized in that The obtaining the working periods of the multiple target objects according to the shift scheduling data includes: Visually display the shift scheduling data; In response to the selection operation of the operating object on the multiple target objects, obtain the working periods of the multiple target objects.

10. The method according to claim 8, characterized in that The outputting the idle period to the operating object includes: Visually display the idle period through the terminal device corresponding to the operating object.

11. The method according to claim 5, characterized in that, The storing the shift scheduling data into the cache server includes: Serialize the shift scheduling data to obtain corresponding string data; Store the string data into the cache server; The obtaining the shift scheduling data from the cache server includes: Obtain the string data from the cache server; Deserialize the string data to obtain the shift scheduling data.

12. A calculation device for idle time periods, characterized in that, It includes: An obtaining module, configured to, in response to a calculation request of an operating object to calculate the idle periods of multiple target objects, obtain the working periods corresponding to the multiple target objects, where the working periods include start time and end time; A table building module, configured to establish a priority queue based on the sequence of start times, where the priority queue indicates the sorting of multiple working periods; An initialization module, configured to initialize a first variable, and the initial value of the first variable is the start time of the working period at the head of the priority queue; A parameter determination module, configured to determine the first variable based on a first parameter, and if the first variable is less than the first parameter, update the first variable to the first parameter, where the first parameter indicates the end time of the working period at the head of the priority queue; A period determination module, configured to, if the determined first variable is less than a second parameter, determine the period between the determined first variable and the second parameter as the idle periods of the multiple objects, where the second parameter indicates the start time of the working period at the second place in the priority queue; A loop module, configured to remove the working period at the head of the priority queue, and re-determine the first variable until the priority queue is empty; An output module, configured to output the idle period to the operating object.

13. A computer device, characterized in that: include: memories, transceivers, processors, and bus systems; Wherein, the memory is used to store programs; The processor is configured to execute the program in the memory, including executing the idle period calculation method according to any one of claims 1 to 11; The bus system is used to connect the memory and the processor so that the memory and the processor can communicate with each other.

14. A computer-readable storage medium, characterized in that The invention comprises instructions, which, when executed on a computer, enable the computer to execute the idle period calculation method according to any one of claims 1 to 11.

15. A computer program product comprising a computer program, characterized in that The computer program is used by a processor to execute the idle period calculation method according to any one of claims 1 to 11.