Shift appointment method and device and shift query method and device
By handling shift appointments and query requests in local cache and distributed cache, the slow response problem caused by frequent access to databases in the prior art is solved, and efficient and stable shift management services are achieved.
Patent Information
- Application Number
- CN202311013355.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-11
- Publication Date
- 2025-02-18
AI Technical Summary
In the prior art, frequent database read and write operations and lock controls lead to slow response and cannot provide highly available services when handling doctor shift appointments and queries.
Reduce direct access to the database by judging and updating unscheduled target shifts in the local cache and updating shift information asynchronously in the distributed cache.
It realizes stable and efficient processing of shift appointment requests, improves the response speed of shift query, improves the user experience, and ensures the data consistency between cache and database.
Smart Images

Figure CN119476536A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of Internet medical technology, and in particular to a method and device for shift booking and a method and device for shift query. Background Art
[0002] Internet hospitals can provide medical services at all times, that is, there are doctors on duty in each time period. Doctors need to make an appointment to get the opportunity to be on duty. Usually, after the shifts in the new time period are open for appointment, the shift appointment system will receive a large number of shift query requests and shift appointment requests sent by doctors in a short period of time. The shift information stored in the database is obtained according to the shift query request, and the shift information stored in the database is modified according to the shift appointment request.
[0003] In the process of implementing the present invention, the inventors found that the prior art has at least the following problems:
[0004] Frequent read and write operations on the database and control of concurrent access to shift information through locking result in slow response to shift booking, shift query and other processes, and fail to provide high-availability shift booking and shift query services. Summary of the invention
[0005] In view of this, the embodiments of the present invention provide a method and device for shift booking and a method and device for shift query, which can stably and efficiently process shift booking requests, quickly and accurately generate shift lists, and improve user experience.
[0006] To achieve the above object, according to a first aspect of an embodiment of the present invention, a method for shift booking is provided, comprising:
[0007] In response to receiving the shift reservation request, determining a corresponding target shift;
[0008] Determine whether the preset local cache includes the unbooked target shift;
[0009] In the case that the local cache includes an unreserved target shift, shift reservation information of the target shift is generated according to the shift reservation request, and the target shift in the local cache is updated.
[0010] Optionally, before receiving the shift reservation request, the method further includes: receiving shifts of one or more time periods, amplifying the received shifts, and storing the amplified shifts in the local cache;
[0011] Before generating the shift reservation information of the target shift according to the shift reservation request, the method further includes: determining that a preset distributed cache includes unreserved target shifts, and the number of target shifts in the distributed cache is equal to the total number of shift plans of the target shifts.
[0012] Optionally, after generating the shift reservation information of the target shift according to the shift reservation request, the method further includes:
[0013] The target shift in the distributed cache and the target shift stored in the database are updated asynchronously.
[0014] According to a second aspect of an embodiment of the present invention, a method for querying a shift is provided, comprising:
[0015] In response to receiving a shift query request, determining a corresponding query date;
[0016] In the case where the pre-set distributed cache includes shift reservation information and shift plan information, obtaining the shift reservation information and shift plan information corresponding to the shift query request from the distributed cache according to the query date, wherein the shift reservation information is generated according to any method of the first aspect of the embodiments of the present invention;
[0017] A shift list corresponding to the shift query request is generated according to the shift plan information corresponding to the shift query request and the shift reservation information.
[0018] Optionally, before receiving the shift query request, the method further includes:
[0019] Determining whether the distributed cache includes shift plan information and shift reservation information;
[0020] In the case that the distributed cache does not include the shift plan information and the shift reservation information, the corresponding shift plan information and the shift reservation information are acquired according to a preset query cycle, and the acquired shift plan information and the shift reservation information are stored in the distributed cache.
[0021] Optionally, the method further comprises:
[0022] In response to receiving the shift assignment request, determining a corresponding assigned shift;
[0023] Determine the number of the assigned shifts corresponding to each server in the server cluster according to the total number of shift plans of the assigned shifts and the pre-set configuration information of the server cluster;
[0024] According to the number of the allocated shifts corresponding to each server, the allocated shifts are distributed to one or more servers in the server cluster, and the one or more servers store the received allocated shifts in corresponding local caches.
[0025] Optionally, in the case where the server cluster includes a disabled server, the method further comprises: distributing the shifts included in the disabled server to servers in the server cluster other than the disabled server;
[0026] In the case where the server cluster includes a newly added server, the method further includes: distributing the shifts of one or more time periods included in at least one server in the server cluster except the newly added server to the newly added server.
[0027] Optionally, the method further comprises:
[0028] In response to receiving a shift booking request, the shift booking request is forwarded to a target server in a server cluster according to a preset load balancing strategy, and the target server processes the shift booking request using any method described in the first aspect of an embodiment of the present invention.
[0029] According to a third aspect of an embodiment of the present invention, there is provided a device for shift booking, comprising:
[0030] A determination module, configured to determine a corresponding target shift in response to receiving a shift reservation request;
[0031] A determination module, used to determine whether the preset local cache includes an unbooked target shift;
[0032] The reservation module is used to generate the shift reservation information of the target shift according to the shift reservation request and update the target shift in the local cache when the local cache includes an unreserved target shift.
[0033] Optionally, the device further comprises:
[0034] An amplification module, used for receiving shifts of one or more time periods, amplifying the received shifts, and storing the amplified shifts in the local cache;
[0035] The re-determination module is used to determine whether the preset distributed cache includes unreserved target shifts, and the number of target shifts in the distributed cache is equal to the total number of shift plans of the target shifts.
[0036] Optionally, the device further comprises:
[0037] An updating module is used for asynchronously updating the target shift in the distributed cache and the target shift stored in the database.
[0038] According to a fourth aspect of an embodiment of the present invention, a device for querying a shift is provided, comprising:
[0039] A determination module, configured to determine a corresponding query date in response to receiving a shift query request;
[0040] an acquisition module, configured to acquire, from the distributed cache according to the query date, the shift reservation information and the shift plan information corresponding to the shift query request, when the preset distributed cache includes shift reservation information and shift plan information, wherein the shift reservation information is generated according to any one of the methods of the first aspect of the embodiments of the present invention;
[0041] A generation module is used to generate a shift list corresponding to the shift query request according to the shift plan information and the shift reservation information corresponding to the shift query request.
[0042] Optionally, the device further comprises:
[0043] A determination module, used to determine whether the distributed cache includes shift plan information and shift reservation information;
[0044] A storage module is used to obtain the corresponding shift plan information and shift reservation information according to a preset query cycle when the distributed cache does not include the shift plan information and shift reservation information, and store the obtained shift plan information and shift reservation information in the distributed cache.
[0045] Optionally, the device further comprises:
[0046] a shift determination module, for determining a corresponding assigned shift in response to receiving a shift assignment request;
[0047] A quantity determination module, used to determine the quantity of the assigned shifts corresponding to each server in the server cluster according to the total number of shift plans of the assigned shifts and the preset configuration information of the server cluster;
[0048] The allocation module is used to distribute the allocation shifts to one or more servers in the server cluster according to the number of the allocation shifts corresponding to each server, and the one or more servers store the received allocation shifts in the corresponding local cache.
[0049] Optionally, the device further comprises:
[0050] A first reallocation module, configured to distribute the shifts included in the disabled server to servers other than the disabled server in the server cluster;
[0051] The second reallocation module is used to distribute the shifts of one or more time periods included in at least one server in the server cluster except the newly added server to the newly added server.
[0052] Optionally, the device further comprises:
[0053] A forwarding module is used to respond to receiving a shift booking request and forward the shift booking request to a target server in a server cluster according to a preset load balancing strategy, and the target server processes the shift booking request using any method described in the first aspect of the embodiment of the present invention.
[0054] According to a fifth aspect of an embodiment of the present invention, a system for shift processing is provided, comprising:
[0055] A server cluster, comprising a plurality of servers, for storing shifts of a plurality of time periods and processing any shift reservation request as described in the first aspect of the embodiment of the present invention;
[0056] A scheduling engine, used to adjust the usage status of the server, assign shifts to the server cluster, and process any shift query request described in the second aspect of the embodiment of the present invention;
[0057] A distributed cache, used to store shifts of multiple time periods, and the shift reservation information and shift plan information described in any one of the first aspect of the embodiment of the present invention and the second aspect of the embodiment of the present invention;
[0058] A database, used to store the shift reservation information and the shift plan information as described in any one of the first aspect of the embodiment of the present invention and the second aspect of the embodiment of the present invention;
[0059] The message middleware is used to asynchronously update the shift booking information in the database.
[0060] According to a sixth aspect of an embodiment of the present invention, there is provided an electronic device, including:
[0061] one or more processors;
[0062] a storage device for storing one or more programs,
[0063] When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any one of the above embodiments.
[0064] According to a seventh aspect of an embodiment of the present invention, there is provided a computer-readable medium on which a computer program is stored, and when the program is executed by a processor, the method described in any one of the above embodiments is implemented.
[0065] One embodiment of the above invention has the following advantages or beneficial effects: generating shift reservation information of the target shift based on the local cache, being able to stably and efficiently process shift reservation requests, saving system resources and improving the user experience; amplifying the received shifts, and then using the distributed cache to judge the target shifts, being able to always provide the number of scheduled shifts as planned when some servers are disabled or fail, avoiding the situation where there are unscheduled shifts but cannot be booked or the total number of shift reservations exceeds the total number of shift plans; asynchronously updating the distributed cache and the database can effectively ensure the data consistency between the cache and the database; storing the shift reservation information and the shift plan Loading information into the distributed cache in advance can improve the efficiency of shift queries and enhance the user experience; distributing shifts based on the total number of shift plans and the configuration information of the server cluster can enable each server to store an appropriate number of shifts, thereby improving the processing efficiency of shift reservation requests; distributing shifts included in deactivated servers and distributing shifts to newly added servers can adjust the shifts stored in each server in real time and flexibly, thereby improving the processing efficiency of shift reservation requests; distributing shift reservation requests to the target server based on the load balancing strategy can ensure that the target server handles an appropriate number of shift reservation requests, improve server resource utilization, and improve the processing efficiency of shift reservations.
[0066] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with specific implementation examples. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0068] Figure 1 is a schematic diagram of the main process of the method for shift booking according to an embodiment of the present invention;
[0069] Figure 2 It is a schematic diagram of the main process of a method for shift booking according to a reference embodiment of the present invention;
[0070] Figure 3 is a schematic diagram of the main process of the method for shift query according to an embodiment of the present invention;
[0071] Figure 4 It is a schematic diagram of the main process of a method for querying a shift according to a reference embodiment of the present invention;
[0072] Figure 5 is a schematic diagram of preloading of shift plan information according to a reference embodiment of the present invention;
[0073] Figure 6 is a schematic diagram of main modules of a device for shift booking according to an embodiment of the present invention;
[0074] Figure 7 is a schematic diagram of main modules of a device for querying shifts according to an embodiment of the present invention;
[0075] Figure 8 is a schematic diagram of the architecture of a system for shift processing according to a reference embodiment of the present invention;
[0076] Fig. 9 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0077] Fig.10 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0078] 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.
[0079] It should be noted that in the technical solution of the present invention, the collection, use, storage, sharing and transfer of user personal information involved are in compliance with the provisions of relevant laws and regulations, and it is necessary to inform the user and obtain the user's consent or authorization. When applicable, the user's personal information is de-identified and / or anonymized and / or encrypted.
[0080] Internet hospitals can provide medical services at all times, that is, there are doctors on duty in each time period. Doctors need to make an appointment to get the opportunity to be on duty. Usually, after the shifts in the new time period are open for appointment, the shift appointment system will receive a large number of shift query requests and shift appointment requests sent by doctors in a short period of time. The shift information stored in the database is obtained according to the shift query request, and the shift information stored in the database is modified according to the shift appointment request.
[0081] Frequent read and write operations on the database and control of concurrent access to shift information through locking result in slow response to shift booking, shift query and other processes, and fail to provide high-availability shift booking and shift query services.
[0082] In view of this, according to a first aspect of an embodiment of the present invention, a method for shift booking is provided.
[0083] Figure 1 FIG. 1 is a schematic diagram of the main process of the method for shift reservation according to an embodiment of the present invention. Figure 1As shown, the shift booking method according to the embodiment of the present invention mainly includes the following steps S101 to S103.
[0084] Step S101, in response to receiving a shift reservation request, determining a corresponding target shift.
[0085] A shift reservation request is a request to reserve a shift for one or more time periods. Shifts are obtained through scheduling. For example, in an Internet hospital, in order to ensure that there are doctors on duty 24 hours a day, the whole day is divided into 12 shifts, and the duration of each shift is 2 hours. After receiving the shift reservation request, the execution subject of the embodiment of the present invention parses the shift reservation request to obtain the target shift. The target shift includes: information such as the shift code, shift date, and shift time period that need to be booked. In different scenarios, the information included in the target shift is different. For example, in the hospital duty scenario, the target shift also includes: information such as the first-level department and the second-level department that need to be booked. In the enterprise duty scenario, the target shift also includes: information such as the first-level department and the second-level department that need to be booked. The target shift is a shift for one or more time periods, and the information included in different time periods is different.
[0086] Exemplarily, the received shift reservation request is parsed, and the obtained target shift includes "{'banId':'001'; 'date':'y1-m1-d1'; 'time':'1-2'; '1department':'Surgery'; '2department':'General Surgery'}", wherein "'banId':'001'" indicates that the shift number to be reserved is 001, "'date':'y1-m1-d1'" indicates that the shift date to be reserved is y1 year m1 month d1 day, "'time':'1-2'" indicates that the shift time period to be reserved is 1:00 to 2:00, "'1department':'Surgery'" indicates that the first-level department to be reserved is surgery, and "'2department':'General Surgery'" indicates that the second-level department to be reserved is general surgery.
[0087] Quickly determine the target shift to improve shift booking efficiency and enhance user experience.
[0088] Step S102, determining whether the preset local cache includes an unreserved target shift.
[0089] The local cache stores shifts of multiple time periods in advance, and the number of shifts in each time period is one or more. For example, there are 10 shifts in the time period from 2:00 to 3:00, which means that at most 10 users have successfully booked shifts in the time period from 2:00 to 3:00, that is, at most 10 users are on duty at the same time in this time period. Each shift has a status, such as unbooked, booked, expired, etc.; the status of the newly added shift is unbooked. For example, the execution subject of the embodiment of the present invention adds shifts for the next week at a fixed time every week. The status of the successfully booked shift is converted from unbooked to booked, and the status of the canceled shift is converted from booked to unbooked. The status of the canceled shift or the shift that has exceeded the booking time will be converted to expired. The local cache can be a cache tool such as Redis, Memcached, etc. For example, the data stored in the local cache uses the shift code as the key and the shift booking status as the value. The shift booking status of the corresponding shift can be quickly determined through the shift code.
[0090] After obtaining the target shift, the target shift is searched in the local cache according to the shift code, shift date, shift time and other information, the status of the target shift is determined, and it is judged whether there is a target shift with an unscheduled status. If there is a target shift with an unscheduled status, it means that the target shift has not been successfully booked. For example, the shift code of the target shift is 102, the shift date is y2 year m2 month d2 day, and the shift time is 3:00 to 5:00; query the local cache and get "{'101':'15-10-5'; '102':'14-5-9'; '103':'10-10-0'}", where "'101':'15-10-5'" means that there are 15 shifts with the shift code 101, and 10 shifts have been booked. "'102':'14-5-9'" means there are 14 shifts with shift code 102, 5 scheduled shifts, and 9 unreserved shifts, "'103':'10-10-0'" means there are 10 shifts with shift code 103, 10 scheduled shifts, and 0 unreserved shifts; since the shift code of the target shift is 102, there are 9 unreserved target shifts.
[0091] Storing the target shift in the local cache can quickly determine whether the target shift exists in the local cache, and the shift reservation status of the target shift if the target shift exists, avoiding direct read and write operations on the database and improving the query efficiency of the shift reservation status.
[0092] Step S103, when the local cache includes an unreserved target shift, generating shift reservation information of the target shift according to the shift reservation request, and updating the target shift in the local cache.
[0093] In the case where the local cache includes a target shift with a status of unbooked, it means that the target shift has not been fully booked. Then, the user information or organization information in the shift booking request is obtained to determine the initiator of the shift booking request. For example, in the hospital duty scenario, the user information includes the user code, user name, user title, user department, etc. In the scenario of booking an activity venue, each activity period of each activity venue is regarded as a shift. When booking an activity venue by department, the organization information obtained from the shift booking request includes: organization code, organization name, number of participants, etc. The target shift is booked according to the obtained user information or organization information to generate shift booking information. The shift booking information includes: the shift code of the target shift, the shift booking code, the user code or organization code, whether the shift booking information is valid, etc., wherein the shift booking code is used to indicate the shift booking information, and each shift booking information has a unique shift booking code. After the shift reservation information is generated, it means that the target shift has been successfully reserved, then the target shift in the local cache is updated, the number of reserved shifts corresponding to the target shift is increased by 1, and the number of unreserved shifts corresponding to the target shift is decreased by 1.
[0094] For example, the shift reservation request is parsed to obtain user information including "{'userId':'user100'; 'username':'qwer'; 'userTitle':'doctor'; 'userDept':'skin'}", where "'userId':'user100'" indicates that the user code is "user100", "'username':'qwer'" indicates that the user name is "qwer", "'userTitle':'doctor'" indicates that the user's title is "doctor", and "'userDept':'skin'" indicates that the user's department is Dermatology; the shift code of the target shift corresponding to the shift reservation request is "105", the number of scheduled shifts for the target shift is 9, and the number of unscheduled shifts is 3, so "{'banId':'b105'; 'userId':'user100'; 'scheduleId':'s111'; 'status':'1'}" is generated, where "'scheduleId':'s111'" indicates that the shift reservation code is "s111", and "'status':'1'" indicates that the shift reservation information is valid; the target shift in the local cache is updated, and the number of scheduled shifts for the updated target shift is 10, and the number of unscheduled shifts is 2.
[0095] Timely updating of the target shifts in the local cache can improve the updating efficiency of the target shifts and the accuracy of shift reservations.
[0096] According to a reference embodiment of the present invention, before receiving a shift reservation request, the method further includes: receiving shifts of one or more time periods, and amplifying the received shifts, for example, receiving 10 shifts A1 and 8 shifts A2, amplifying the number of shifts A1 to 15 and the number of shifts A2 to 12 according to a preset amplification ratio of 50%, or amplifying the number of shifts A1 to 12 and the number of shifts A2 to 10 according to a preset amplification constant of 2. The amplified shifts are stored in a local cache, so that the number of shifts stored in the local cache is greater than the number of received shifts.
[0097] Before generating the shift reservation information of the target shift according to the shift reservation request, there is still an unreserved target shift in the local cache, indicating that the target shift in the local cache is not full, and the method further includes: judging whether the pre-set distributed cache includes the unreserved target shift, the distributed cache pre-stores shifts of multiple time periods, and the number of shifts of multiple time periods stored in the distributed cache is equal to the total number of shift plans of the corresponding shifts, that is, the number of shifts stored in the distributed cache is the same as the number of shifts planned, and the shifts stored in the distributed cache have not been expanded in number. In the case that there is an unreserved target shift in the distributed cache, it means that the target shift in the distributed cache is not full either, therefore, continue to perform the subsequent steps, namely, generate the shift reservation information of the target shift according to the shift reservation request. In the case that there is no unreserved target shift in the distributed cache, it means that the target shift in the distributed cache is full, therefore, even if the target shift in the local cache is not full, the shift reservation information of the target shift cannot be generated according to the shift reservation request.
[0098] Exemplarily, the total number of target shifts is 10, of which 5 target shifts are distributed to execution entity B1 and 5 target shifts are distributed to execution entity B2; execution entity B1 receives 5 target shifts, and stores 15 target shifts in the corresponding local cache after the number is expanded, and execution entity B2 receives 5 target shifts, and also stores 15 target shifts in the corresponding local cache after the number is expanded; 10 target shifts are stored in the distributed cache, which is the same as the total number of target shift shifts; in the event that execution entity B1 fails and cannot process the shift reservation request, only execution entity B2 will make a reservation for the target shift, specifically, 15 target shifts can be successfully reserved in the local cache of execution entity B2, and 10 target shifts can be successfully reserved in the distributed cache, and the target shift reservation requests that are successfully reserved in both the local cache of execution entity B2 and the distributed cache are determined, and corresponding shift reservation information is generated according to the target shift reservation requests.
[0099] In the case where there are multiple execution entities in the embodiment of the present invention, each execution entity has a local cache, wherein multiple local caches store target shifts, and each execution entity receives shift reservation requests from different users and makes reservations for the target shifts; in the case where one or more execution entities fail to process the shift reservation requests, the target shift in the local cache of the execution entity that sent the failure cannot be successfully reserved, resulting in a reduction in the total number of reservations for the target shift, which is lower than the total number of shift plans for the target shift; expanding the number of shifts in the local cache can effectively avoid the situation where the total number of reservations for the target shift is lower than the total number of shift plans due to the inability of some execution entities to reserve the target shift, that is, avoid the situation where there are unreserved shifts that cannot be reserved.
[0100] According to another referenceable embodiment of the present invention, after generating the shift reservation information of the target shift according to the shift reservation request, the method further includes: asynchronously updating the target shift in the distributed cache and the target shift stored in the database.
[0101] The database stores relevant information of the target shift, such as shift code, shift date, shift period, number of reservations, number of unreserved reservations, shift reservation information, etc. After the shift reservation information of the target shift is generated, the message queue is used to asynchronously update the relevant information of the target shift in the distributed cache and the relevant information of the target shift stored in the database. The number of reservations and number of unreserved reservations of the target shift in the distributed cache is updated, and the corresponding shift reservation information is stored. Then, the updated number of reservations, number of unreserved reservations, shift reservation information, etc. of the target shift are sent to the message queue, and the database reads the relevant information of the target shift in the message queue, updates the number of reservations and number of unreserved reservations of the target shift in the database according to the relevant information read, and stores the shift reservation information in the database.
[0102] Exemplarily, the table structure for storing shift reservation information in the database is shown in Table 1. The shift reservation information includes 4 fields. The generated shift reservation information is stored in the distributed cache and sent to the message queue. The database periodically obtains the shift reservation information from the message queue and stores it in the corresponding database table.
[0103] Table 1
[0104]
[0105] Asynchronously updating the relevant information of the target shift in the distributed cache and database through the message queue can effectively ensure the data consistency of the distributed cache and the database, ensure the read and write performance of the database, and improve the stability of shift booking.
[0106] Figure 2 FIG. 1 is a schematic diagram of the main process of a method for shift booking according to a reference embodiment of the present invention. Figure 2 As shown, the shift booking method may include:
[0107] Step S201, receiving one or more shifts in time periods, and amplifying the received shifts;
[0108] Step S202, storing the expanded shifts in a local cache;
[0109] Step S203, in response to receiving the shift reservation request, determining a corresponding target shift;
[0110] Step S204, determining whether the local cache includes an unbooked target shift, if so, jump to step S205, otherwise, jump to step S208;
[0111] Step S205, determining whether the distributed cache includes an unbooked target shift, if so, jump to step S206, otherwise, jump to step S208;
[0112] Step S206, generating shift reservation information of the target shift according to the shift reservation request, and updating the target shift in the local cache;
[0113] Step S207, asynchronously updating the target shift in the distributed cache and the target shift stored in the database;
[0114] Step S208, generating a prompt message indicating that the target flight is full.
[0115] The specific implementation content of the shift booking method of the above-mentioned reference embodiment of the present invention has been described in detail in the above-mentioned shift booking method, so the repeated content will not be described again here.
[0116] According to a second aspect of an embodiment of the present invention, a method for querying shifts is provided.
[0117] Figure 3 FIG. 1 is a schematic diagram of the main process of the method for querying shifts according to an embodiment of the present invention. Figure 3 As shown, the method for shift query according to an embodiment of the present invention mainly includes the following steps S301 to S303.
[0118] Step S301, in response to receiving a shift query request, determining a corresponding query date.
[0119] The shift query request is a request for querying shifts in one or more time periods. The execution subject of the embodiment of the present invention parses the received shift query request to obtain the query date. The query date can be the date corresponding to an expired shift, the date corresponding to a shift that is in the reservation stage, or the date corresponding to a shift that is not open for reservation. For example, the execution subject of the embodiment of the present invention provides the user with a service of reserving shifts for the next week one week in advance. The default query date carried by the shift query request is seven days after the current date. The user can also customize the query date, for example, specify the start date and end date in the shift query request, or specify the query date of the past week, the past 3 days, etc. in the shift query.
[0120] Exemplarily, if the current date is April 1st, the shifts currently open for reservation are shifts in multiple time periods between April 1st and April 7th; if the received shift query request does not carry the query date, it is determined that the shift query request is a default shift query request, and the corresponding query dates are April 1st to April 7th; if the received shift query request carries the request parameter "startDate=4-1&finishDate=4-5", the start time of the query date is determined to be April 1st, and the end time of the query date is determined to be April 5th; if the received shift query request carries the request parameter "querydate=last-5", the query date is determined to be the past 5 days, that is, March 27th to March 31st.
[0121] The query date can be flexibly determined according to the shift query request, which is convenient for improving the efficiency of shift query and meeting various shift query needs.
[0122] Step S302, when the pre-set distributed cache includes shift reservation information and shift plan information, obtain the shift reservation information and shift plan information corresponding to the shift query request from the distributed cache according to the query date, and the shift reservation information is generated according to any method in the first aspect of the embodiment of the present invention.
[0123] After determining the query date, determine whether the distributed cache includes shift reservation information and shift plan information. If the distributed cache includes the corresponding shift reservation information and shift plan information, obtain the shift plan information and shift reservation information of the corresponding shift date according to the query date. Specifically, in the hospital duty scenario, the shift query request is parsed to obtain the query date and department information. For example, for the first-level department and the second-level department, the corresponding shift plan information and shift reservation information are queried according to the query date, the first-level department, and the second-level department; in the enterprise duty scenario, the shift query request is parsed to obtain the query date and department information. For example, for the first-level department and the second-level department, the corresponding shift plan information and shift reservation information are queried according to the query date, the first-level department, and the second-level department.
[0124] Exemplarily, the shift query request is parsed and the query date is obtained as: m4-d4-y4 to m4-d5-y4, the first-level department is the Department of Dermatology and Venereology, and the second-level department is the Department of Dermatology. When the distributed cache includes shift planning information and shift reservation information, the shift planning information and shift reservation information with shift dates between m4-d4-y4 and m4-d5-y4, the first-level department is the Department of Dermatology and Venereology, and the second-level department is the Department of Dermatology are obtained from the distributed cache.
[0125] Loading shift plan information and shift reservation information into the distributed cache in advance can improve the processing efficiency of shift query requests; avoid frequent read and write operations on the database to ensure the read and write performance of the database.
[0126] According to a reference embodiment of the present invention, before receiving a shift query request, the method further includes: determining whether the distributed cache includes shift plan information and shift reservation information, wherein the shift plan information is a shift that is planned to provide reservation services to users, and the shift plan information includes shift information of multiple time periods, specifically, the shift plan information includes: shift code, shift date, shift time period, total number of shifts, shift status, in the hospital duty scenario, the shift plan information also includes: information such as first-level departments and second-level departments, in the enterprise duty scenario, the shift plan information also includes: information such as first-level departments and second-level departments. In the case that the distributed cache does not include the shift plan information and shift reservation information, the corresponding shift plan information and shift reservation information are obtained according to a pre-set query cycle, for example, the query cycle coincides with the cycle of the shift open reservation, and in the case of a shift open reservation for the next week, the query cycle is set to the next week, and for another example, the current time is taken as the midpoint of the query cycle, and a query time is set before the current time and after the current time, so as to obtain the query cycle. The shift plan information and shift reservation information are stored in a database, and the shift plan information and shift reservation information corresponding to the query period are obtained from the database, and the obtained shift plan information and shift reservation information are stored in a distributed cache.
[0127] Exemplarily, in a hospital duty scenario, the table structure of the database storing shift plan information is shown in Table 2, and the shift plan information includes 9 fields; the shift plan information and shift reservation information of the corresponding shift date are obtained according to the query cycle, and the obtained shift plan information and shift reservation information are stored in a distributed cache, with the shift code as the key, the shift plan information and the shift reservation information as the value, and the key and the value are associated and stored in the distributed cache.
[0128] Table 2
[0129]
[0130] Before receiving a shift query request, the execution subject of the embodiment of the present invention loads the shift plan information into the distributed cache to improve the processing efficiency of the shift query request; avoid frequent read and write operations on the database, and ensure the read and write performance of the database.
[0131] Step S303: generating a shift list corresponding to the shift query request according to the shift plan information and the shift reservation information corresponding to the shift query request.
[0132] After obtaining the shift plan information and shift reservation information corresponding to the shift query request, a shift list is constructed in real time according to the total number of shift plans, department information or department information, shift date, shift time period, and the number of scheduled shifts and unscheduled shifts in the shift reservation information. The shift list includes: which shifts are available on the query date, the shift dates and shift time periods of these shifts, the reservation status of these shifts, the total number of shift plans of these shifts, etc. The constructed shift list is rendered to the front-end page and displayed to the initiator of the shift query request, so that the initiator of the shift query request can intuitively and clearly see the shift reservation status of each time period.
[0133] Exemplarily, the shift plan information includes: shift C1, shift C2 and shift C3, wherein the total number of shift plans for shift C1 is 20, the total number of shift plans for shift C2 is 25, and the total number of shift plans for shift C3 is 30; the shift reservation information includes: the number of scheduled shifts for shift C1 is 15, and the number of unscheduled shifts is 5, the number of scheduled shifts for shift C2 is 25, and the number of unscheduled shifts is 0, and the number of scheduled shifts for shift C3 is 15, and the number of unscheduled shifts is 15; a shift list as shown in Table 3 is constructed according to the shift plan information and the shift reservation information:
[0134] Table 3
[0135]
[0136] Based on the shift plan information and shift reservation information, the shift reservation status within the query date can be quickly constructed, and an accurate, clear and intuitive shift list can be constructed to improve the user experience.
[0137] According to a reference embodiment of the present invention, the method further includes: in response to receiving a shift allocation request, determining the corresponding allocated shift, the allocated shift includes one or more shifts in time periods that have not yet been opened for reservation; determining the total number of shift plans for the allocated shift and the configuration information of the pre-set server cluster, wherein the configuration information includes: the number of servers included in the server cluster and the server configuration information such as the memory size, number of cores, bandwidth, and processor model of each server. According to the configuration information of the server cluster, the number of allocated shifts corresponding to each server in the server cluster is determined, and the number of allocated shifts corresponding to each server can be zero, one, or more; according to the number of allocated shifts corresponding to each server, the allocated shifts are distributed to one or more servers in the server cluster, each server has a local cache, and the servers that receive the allocated shifts store the received allocated shifts in their respective local caches.
[0138] The execution subject of the embodiment of the present invention registers the servers in the server cluster, and when distributing shifts, examines the registered servers to determine the number of shifts to be distributed to the registered servers. The execution subject of the embodiment of the present invention sends information to the server once every cycle, and keeps the registered servers alive through the heartbeat mechanism.
[0139] Exemplarily, the allocated shifts are shifts on the same shift date and the same shift period, the total number of shift plans for the allocated shifts is 100, and the pre-set server cluster includes 10 servers (server D1 to server D10); when the server configuration of each server is the same, 10 allocated shifts are distributed to each server; when the server configurations of servers D1 to D5 are better than those of servers D6 to D10, 20 allocated shifts are distributed to each of servers D1 to D5, and no allocated shifts are distributed to the remaining servers; the servers that receive the allocated shifts store the received allocated shifts in their respective local caches.
[0140] Distributing shifts according to the total number of shift plans and the configuration information of the server cluster enables each server to store an appropriate number of shifts, thereby improving the processing efficiency of shift reservation requests.
[0141] According to another reference embodiment of the present invention, in the case where the server cluster includes a deactivated server, the method further includes: obtaining all shifts stored in the local cache of the deactivated server, distributing all shifts included in the deactivated server to other servers in the server cluster except the deactivated server, for example, distributing all shifts included in the deactivated server according to the configuration information of the other servers, or distributing all shifts included in the deactivated server according to the number of shifts stored on the other servers.
[0142] Exemplarily, the local cache of the deactivated server includes 100 unscheduled shifts and 50 scheduled shifts; other servers include: server E1 (including 50 unscheduled shifts and 50 scheduled shifts), server E2 (including 50 unscheduled shifts and 50 scheduled shifts) and server E3 (including 100 unscheduled shifts and 100 scheduled shifts). Since the number of shifts stored in server E1 and server E2 is small, the 50 unscheduled shifts and 25 scheduled shifts included in the deactivated server are distributed to server E1, and the other 50 unscheduled shifts and another 25 scheduled shifts included in the deactivated server are distributed to server E2; when the memory size, number of cores, bandwidth and other configurations of server E1 are better than those of the other two servers, all shifts included in the deactivated server are distributed to server E1.
[0143] In the case where the server cluster includes a newly added server, the method further includes: determining at least one server other than the newly added server in the server cluster, and distributing the shifts of one or more time periods included in the determined server to the newly added server. For example, the number of shifts distributed by other servers to the newly added server is determined based on the configuration information of the newly added server, or after the execution subject of the embodiment of the present invention has allocated shifts to the newly added server, the number of shifts distributed by other servers to the newly added server is determined based on the number of shifts stored on the newly added server.
[0144] Exemplarily, if no shifts are stored on the newly added server and the configuration information of the newly added server is the same as that of the remaining servers, part of the shifts on each remaining server will be distributed to the newly added server so that the number of shifts stored on the newly added server and the remaining servers after the shifts are distributed will be the same.
[0145] Distributing the shifts included in the deactivated servers and distributing the shifts to the newly added servers can adjust the shifts stored in each server flexibly and in real time, thereby improving the processing efficiency of the shift reservation requests.
[0146] According to another reference embodiment of the present invention, the method also includes: in response to receiving a shift reservation request, parsing the shift reservation request, determining the corresponding target shift, and then determining which servers have the target shift stored in their local caches; according to a pre-set load balancing strategy, determining the target server from the servers that have the target shift stored in their local caches, forwarding the shift reservation request to the target server in the server cluster, and the target server processing the shift reservation request using any of the methods described in the first aspect of the embodiments of the present invention.
[0147] Exemplarily, in a server cluster, the local cache of the server F1 package includes shifts G1 and G2, the local cache of the server F2 package includes shifts G2 and G3, and the local cache of the server F3 package includes shifts G3 and G4; the received shift reservation request is parsed, and the target shift is obtained as shift G2, then it is necessary to determine the target server in server F1 and server F2; since server F1 has processed three shift reservation requests in succession, and server F2 has been idle for a period of time, the above shift reservation request is forwarded to server F2, so that server F2 uses any method described in the first aspect of the embodiment of the present invention to process the above shift reservation request.
[0148] Distributing shift booking requests to the target server according to the load balancing strategy can ensure that the target server handles an appropriate number of shift booking requests, improve server resource utilization, and improve shift booking processing efficiency.
[0149] Figure 4FIG. 1 is a schematic diagram of the main process of a method for querying a shift according to a reference embodiment of the present invention. Figure 4 As shown, the shift booking method may include:
[0150] Step S401, in response to receiving a shift query request, determining a corresponding query date and a first-level department;
[0151] Step S402, determine whether there is shift reservation information and shift plan information in the distributed cache, if yes, jump to step S405, otherwise, jump to step S403;
[0152] Step S403, obtaining shift reservation information and shift plan information in the database according to a preset query cycle;
[0153] Step S404, updating the shift reservation information and shift plan information obtained from the database to the distributed cache;
[0154] Step S405, according to the query date and the first-level department, the shift reservation information and the shift plan information corresponding to the shift query request in the distributed cache are obtained;
[0155] Step S406, generating a shift list corresponding to the shift query request according to the shift plan information and the shift reservation information;
[0156] Step S407, rendering the shift list to the front-end page.
[0157] The specific implementation content of the method for querying the shifts of the above-mentioned reference embodiment of the present invention has been described in detail in the method for querying the shifts described above, so the repeated content will not be described here.
[0158] Figure 5 FIG. 1 is a schematic diagram of preloading shift plan information according to a reference embodiment of the present invention. Figure 5 As shown, the execution subject of the embodiment of the present invention starts the shift warm-up plan at 10 o'clock every day, first determines whether there is shift reservation information and shift collection information in the distributed cache, and when there is no shift reservation information and shift collection information in the distributed cache, obtains the shift reservation information and shift plan information in the database according to the preset query cycle, updates the shift reservation information and shift plan information obtained from the database to the distributed cache, and then ends the shift warm-up plan; when there is shift reservation information and shift collection information in the distributed cache, ends the shift warm-up plan directly.
[0159] According to a third aspect of an embodiment of the present invention, a device for shift booking is provided.
[0160] Figure 6is a schematic diagram of the main modules of the device for shift booking according to an embodiment of the present invention, such as Figure 6 As shown, the shift booking device 600 mainly includes:
[0161] A determination module 601 is used to determine a corresponding target shift in response to receiving a shift reservation request;
[0162] A determination module 602 is used to determine whether the preset local cache includes an unbooked target shift;
[0163] The reservation module 603 is used to generate the shift reservation information of the target shift according to the shift reservation request and update the target shift in the local cache when the local cache includes an unreserved target shift.
[0164] According to a reference embodiment of the present invention, the shift booking device 700 further includes:
[0165] An amplification module, used for receiving shifts of one or more time periods, amplifying the received shifts, and storing the amplified shifts in the local cache;
[0166] The re-determination module is used to determine whether the preset distributed cache includes unreserved target shifts, and the number of target shifts in the distributed cache is equal to the total number of shift plans of the target shifts.
[0167] According to another reference embodiment of the present invention, the shift booking device 700 further includes:
[0168] An updating module is used for asynchronously updating the target shift in the distributed cache and the target shift stored in the database.
[0169] It should be noted that the specific implementation content of the shift booking device in the embodiment of the present invention has been described in detail in the shift booking method described above, so the repeated content will not be described again here.
[0170] According to a fourth aspect of an embodiment of the present invention, a device for querying shifts is provided.
[0171] Figure 7 is a schematic diagram of the main modules of the device for querying the shift according to an embodiment of the present invention, such as Figure 7 As shown, the shift query device 700 mainly includes:
[0172] A determination module 701, configured to determine a corresponding query date in response to receiving a shift query request;
[0173] an acquisition module 702, configured to acquire, from the distributed cache according to the query date, the shift reservation information and the shift plan information corresponding to the shift query request, when the pre-set distributed cache includes shift reservation information and shift plan information, wherein the shift reservation information is generated according to any method of the first aspect of the embodiments of the present invention;
[0174] The generating module 703 is used to generate a shift list corresponding to the shift query request according to the shift plan information and the shift reservation information corresponding to the shift query request.
[0175] According to a reference embodiment of the present invention, the shift query device 800 further includes:
[0176] A determination module, used to determine whether the distributed cache includes shift plan information and shift reservation information;
[0177] A storage module is used to obtain the corresponding shift plan information and shift reservation information according to a preset query cycle when the distributed cache does not include the shift plan information and shift reservation information, and store the obtained shift plan information and shift reservation information in the distributed cache.
[0178] According to another reference embodiment of the present invention, the shift query device 800 further includes:
[0179] a shift determination module, for determining a corresponding assigned shift in response to receiving a shift assignment request;
[0180] A quantity determination module, used to determine the quantity of the assigned shifts corresponding to each server in the server cluster according to the total number of shift plans of the assigned shifts and the preset configuration information of the server cluster;
[0181] The allocation module is used to distribute the allocation shifts to one or more servers in the server cluster according to the number of the allocation shifts corresponding to each server, and the one or more servers store the received allocation shifts in the corresponding local cache.
[0182] According to another reference embodiment of the present invention, the shift query device 800 further includes:
[0183] A first reallocation module, configured to distribute the shifts included in the disabled server to servers other than the disabled server in the server cluster;
[0184] The second reallocation module is used to distribute the shifts of one or more time periods included in at least one server in the server cluster except the newly added server to the newly added server.
[0185] According to another reference embodiment of the present invention, the shift query device 800 further includes:
[0186] A forwarding module is used to respond to receiving a shift booking request and forward the shift booking request to a target server in a server cluster according to a preset load balancing strategy, and the target server processes the shift booking request using any method described in the first aspect of the embodiment of the present invention.
[0187] It should be noted that the specific implementation content of the device for querying the shift in the embodiment of the present invention has been described in detail in the method for querying the shift described above, so the repeated content will not be described again here.
[0188] According to the technical solution of the embodiment of the present invention, the shift reservation information of the target shift is generated based on the local cache, which can stably and efficiently process the shift reservation request, save system resources and improve the user experience; the received shift is amplified, and then the distributed cache is used to judge the target shift. In the case of partial server deactivation or failure, the number of scheduled shifts can always be provided as planned, avoiding the situation where there are unreserved shifts but cannot be booked or the total number of shift reservations exceeds the total number of shift plans; asynchronously updating the distributed cache and the database can effectively ensure the data consistency between the cache and the database; the shift reservation information and the shift plan information are updated in advance. Loading them into the distributed cache can improve the efficiency of shift queries and enhance the user experience; distributing shifts according to the total number of shift plans and the configuration information of the server cluster can enable each server to store an appropriate number of shifts, thereby improving the processing efficiency of shift reservation requests; distributing shifts included in deactivated servers and distributing shifts to newly added servers can adjust the shifts stored in each server in real time and flexibly, thereby improving the processing efficiency of shift reservation requests; distributing shift reservation requests to the target server according to the load balancing strategy can ensure that the target server handles an appropriate number of shift reservation requests, thereby improving the resource utilization of the server and the processing efficiency of shift reservations.
[0189] According to a fifth aspect of an embodiment of the present invention, a system for shift processing is provided, comprising:
[0190] A server cluster, comprising a plurality of servers, for storing shifts of a plurality of time periods and processing any shift reservation request as described in the first aspect of the embodiment of the present invention;
[0191] A scheduling engine, used to adjust the usage status of the server, assign shifts to the server cluster, and process any shift query request described in the second aspect of the embodiment of the present invention;
[0192] A distributed cache, used to store shifts of multiple time periods, and the shift reservation information and shift plan information described in any one of the first aspect of the embodiment of the present invention and the second aspect of the embodiment of the present invention;
[0193] A database, used to store the shift reservation information and the shift plan information as described in any one of the first aspect of the embodiment of the present invention and the second aspect of the embodiment of the present invention;
[0194] The message middleware is used to asynchronously update the shift booking information in the database.
[0195] Figure 8 FIG. 1 is a schematic diagram of the architecture of a system for shift processing according to a reference embodiment of the present invention. Figure 8 As shown, the architecture of the shift processing system includes a front-end interface, a scheduling engine, a server cluster, a message middleware, a distributed cache and a database, wherein the server cluster includes multiple servers, each server has a corresponding local cache; the call engine includes a registration center and a shift distribution module, the registration center is used to register servers in the server cluster, and the shift distribution module is used to distribute shifts to the registered servers in the server cluster; the front-end interface includes a shift query button and a shift reservation button, and clicking the shift reservation button generates a shift reservation request, and the scheduling engine forwards the shift reservation request to the target server in the server cluster, and the target server determines whether its local cache includes an unreserved target shift, and in the case of including an unreserved target shift, the request is forwarded to the target server in the server cluster. Under this condition, determine whether the distributed cache includes the unreserved target shift. If the distributed cache also includes the unreserved target shift, update the target shifts in the local cache and the distributed cache, and send the updated information to the message middleware. The database will regularly obtain the updated information in the message middleware, and then update the target shift in the database according to the updated information. Click the shift query button to generate a shift query request, call the engine to obtain the shift reservation information and shift plan information corresponding to the shift query request from the distributed cache, generate the corresponding shift list according to the obtained shift reservation information and shift plan information, and render it to the front-end page. The shift reservation information and shift plan information in the distributed cache are pre-loaded from the database to the distributed cache.
[0196] According to a sixth aspect of an embodiment of the present invention, there is provided an electronic device for shift booking, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method provided in the first aspect of the embodiment of the present invention and / or the second aspect of the embodiment of the present invention.
[0197] According to a seventh aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, the method provided by the first aspect of the embodiment of the present invention and / or the second aspect of the embodiment of the present invention is implemented.
[0198] Fig. 9 An exemplary system architecture 900 is shown to which the method and apparatus for shift booking or the method and apparatus for shift query according to the embodiments of the present invention may be applied.
[0199] like Fig. 9 As shown, system architecture 900 may include terminal devices 901, 902, 903, network 904 and server 905. Network 904 is used to provide a medium for communication links between terminal devices 901, 902, 903 and server 905. Network 904 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0200] The user can use the terminal devices 901, 902, 903 to interact with the server 905 through the network 904 to receive or send messages, etc. Various communication client applications can be installed on the terminal devices 901, 902, 903, such as: shift booking applications, shift query applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).
[0201] The terminal devices 901 , 902 , and 903 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.
[0202] The server 905 may be a server that provides various services, such as a backend management server that provides support for the shift reservation request or shift query request sent by the upstream terminal devices 901, 902, and 903 (for example only). The backend management server may determine the corresponding target shift in response to receiving the shift reservation request; determine whether the pre-set local cache includes the unreserved target shift; if the unreserved target shift is included in the local cache, generate the shift reservation information of the target shift according to the shift reservation request, update the target shift in the local cache; and feedback the shift reservation situation (for example only) to the terminal device. The backend management server may also determine the corresponding query date in response to receiving the shift query request; if the pre-set distributed cache includes the shift reservation information and the shift plan information, obtain the shift reservation information and the shift plan information corresponding to the shift query request from the distributed cache according to the query date; generate the shift list corresponding to the shift query request according to the shift plan information and the shift reservation information corresponding to the shift query request; and feedback the shift query situation (for example only) to the terminal device.
[0203] It should be noted that the shift booking method provided in the embodiment of the present invention is generally executed by the server 905, and accordingly, the shift booking device is generally set in the server 905. The shift booking method provided in the embodiment of the present invention can also be executed by the terminal devices 901, 902, and 903, and accordingly, the shift booking device can be set in the terminal devices 901, 902, and 903.
[0204] It should be noted that the method for querying the shift provided in the embodiment of the present invention is generally executed by the server 905, and accordingly, the device for querying the shift is generally set in the server 905. The method for querying the shift provided in the embodiment of the present invention can also be executed by the terminal devices 901, 902, and 903, and accordingly, the device for querying the shift can be set in the terminal devices 901, 902, and 903.
[0205] It should be understood that Fig. 9 The 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.
[0206] Reference below Fig.10 , which shows a schematic diagram of the structure of a computer system 1000 of a terminal device suitable for implementing an embodiment of the present invention. Fig.10 The terminal 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.
[0207] like Fig.10As shown, the computer system 1000 includes a central processing unit (CPU) 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage part 1008 into a random access memory (RAM) 1003. In the RAM 1003, various programs and data required for the operation of the system 1000 are also stored. The CPU 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.
[0208] The following components are connected to the I / O interface 1005: an input section 1006 including a keyboard, a mouse, etc.; an output section 1007 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN card, a modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the I / O interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1010 as needed, so that a computer program read therefrom is installed into the storage section 1008 as needed.
[0209] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1009, and / or installed from the removable medium 1011. When the computer program is executed by the central processing unit (CPU) 1001, the above-mentioned functions defined in the system of the embodiment of the present invention are executed.
[0210] It should be noted that the computer-readable medium shown in the embodiment of 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 an embodiment of 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 an embodiment of 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.
[0211] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program 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.
[0212] The modules involved in the embodiments of the present invention may be implemented in software or hardware. The modules described may also be set in a processor, for example, they may be described as: a processor including a determination module, a judgment module, and a reservation module, or a processor including a determination module, an acquisition module, and a generation module, wherein the names of these modules do not constitute a limitation on the modules themselves in certain circumstances, for example, the determination module may also be described as a "module for determining whether the local cache includes an unreserved target shift".
[0213] As another aspect, the embodiment of the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently and not 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 implements the following method: in response to receiving a shift reservation request, determine the corresponding target shift; determine whether the pre-set local cache includes an unreserved target shift; if the local cache includes an unreserved target shift, generate the shift reservation information of the target shift according to the shift reservation request, and update the target shift in the local cache. Alternatively, the device implements the following method: in response to receiving a shift query request, determine the corresponding query date; if the pre-set distributed cache includes shift reservation information and shift plan information, obtain the shift reservation information and shift plan information corresponding to the shift query request from the distributed cache according to the query date, and the shift reservation information is generated according to any method in the first aspect of the embodiment of the present invention; generate the shift list corresponding to the shift query request according to the shift plan information and the shift reservation information corresponding to the shift query request.
[0214] According to the technical solution of the embodiment of the present invention, the shift reservation information of the target shift is generated based on the local cache, which can stably and efficiently process the shift reservation request, save system resources and improve the user experience; the received shift is amplified, and then the distributed cache is used to judge the target shift. In the case of partial server deactivation or failure, the number of scheduled shifts can always be provided as planned, avoiding the situation where there are unreserved shifts but cannot be booked or the total number of shift reservations exceeds the total number of shift plans; asynchronously updating the distributed cache and the database can effectively ensure the data consistency between the cache and the database; the shift reservation information and the shift plan information are updated in advance. Loading them into the distributed cache can improve the efficiency of shift queries and enhance the user experience; distributing shifts according to the total number of shift plans and the configuration information of the server cluster can enable each server to store an appropriate number of shifts, thereby improving the processing efficiency of shift reservation requests; distributing shifts included in deactivated servers and distributing shifts to newly added servers can adjust the shifts stored in each server in real time and flexibly, thereby improving the processing efficiency of shift reservation requests; distributing shift reservation requests to the target server according to the load balancing strategy can ensure that the target server handles an appropriate number of shift reservation requests, thereby improving the resource utilization of the server and the processing efficiency of shift reservations.
[0215] The above specific implementations do not constitute a limitation on the protection scope of the embodiments 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 modifications, equivalent substitutions and improvements made within the spirit and principles of the embodiments of the present invention should be included in the protection scope of the embodiments of the present invention.
Claims
1. A method for shift booking, characterized in that: include: In response to receiving the shift reservation request, determining a corresponding target shift; Determine whether the preset local cache includes the unbooked target shift; In the case that the local cache includes an unreserved target shift, shift reservation information of the target shift is generated according to the shift reservation request, and the target shift in the local cache is updated.
2. The method according to claim 1, characterized in that Before receiving the shift reservation request, the method further includes: receiving shifts of one or more time periods, amplifying the received shifts, and storing the amplified shifts in the local cache; Before generating the shift reservation information of the target shift according to the shift reservation request, the method further includes: determining that a preset distributed cache includes unreserved target shifts, and the number of target shifts in the distributed cache is equal to the total number of shift plans of the target shifts.
3. The method according to claim 2, characterized in that After generating the shift reservation information of the target shift according to the shift reservation request, the method further includes: The target shift in the distributed cache and the target shift stored in the database are updated asynchronously.
4. A method for querying shifts, characterized in that: include: In response to receiving a shift query request, determining a corresponding query date; In the case where the pre-set distributed cache includes shift reservation information and shift plan information, obtaining the shift reservation information and shift plan information corresponding to the shift query request from the distributed cache according to the query date, wherein the shift reservation information is generated according to any one of the methods described in claims 1 to 3; A shift list corresponding to the shift query request is generated according to the shift plan information corresponding to the shift query request and the shift reservation information.
5. The method according to claim 4, characterized in that Before receiving the shift query request, the method further includes: Determining whether the distributed cache includes shift plan information and shift reservation information; In the case that the distributed cache does not include the shift plan information and the shift reservation information, the corresponding shift plan information and the shift reservation information are acquired according to a preset query cycle, and the acquired shift plan information and the shift reservation information are stored in the distributed cache.
6. The method according to claim 4, characterized in that The method further comprises: In response to receiving the shift assignment request, determining a corresponding assigned shift; Determine the number of the assigned shifts corresponding to each server in the server cluster according to the total number of shift plans of the assigned shifts and the pre-set configuration information of the server cluster; According to the number of the allocated shifts corresponding to each server, the allocated shifts are distributed to one or more servers in the server cluster, and the one or more servers store the received allocated shifts in corresponding local caches.
7. The method according to claim 6, characterized in that In the case where the server cluster includes a disabled server, the method further includes: distributing the shifts included in the disabled server to servers in the server cluster other than the disabled server; In the case where the server cluster includes a newly added server, the method further includes: distributing the shifts of one or more time periods included in at least one server in the server cluster except the newly added server to the newly added server.
8. The method according to claim 4, characterized in that The method further comprises: In response to receiving a shift booking request, the shift booking request is forwarded to a target server in a server cluster according to a preset load balancing strategy, and the target server processes the shift booking request using any method described in claims 1 to 3.
9. A shift booking device, characterized in that: include: A determination module, configured to determine a corresponding target shift in response to receiving a shift reservation request; A determination module, used to determine whether the preset local cache includes an unbooked target shift; The reservation module is used to generate the shift reservation information of the target shift according to the shift reservation request and update the target shift in the local cache when the local cache includes an unreserved target shift.
10. A device for querying shifts, characterized in that: include: A determination module, configured to determine a corresponding query date in response to receiving a shift query request; an acquisition module, for acquiring the shift appointment information and the shift plan information corresponding to the shift query request from the distributed cache according to the query date, when the pre-set distributed cache includes the shift appointment information and the shift plan information, wherein the shift appointment information is generated according to any one of the methods described in claims 1 to 3; A generation module is used to generate a shift list corresponding to the shift query request according to the shift plan information and the shift reservation information corresponding to the shift query request.
11. A system for shift processing, characterized in that: include: A server cluster, comprising a plurality of servers, for storing shifts of a plurality of time periods and processing a shift reservation request as claimed in any one of claims 1 to 3; A scheduling engine, for adjusting the usage status of the server, assigning shifts to the server cluster, and processing the shift query request as described in any one of claims 4 to 8; A distributed cache for storing shifts in multiple time periods and the shift reservation information and shift plan information as described in any one of claims 1 to 8; A database for storing the shift reservation information and shift plan information as described in any one of claims 1 to 8; The message middleware is used to asynchronously update the shift booking information in the database.
12. 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 8.
13. 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 8 is implemented.