Calendar data downloading method and device, equipment and medium
Through the device shadow mechanism, the problem of frequent query of devices when they are not online in the traditional calendar download method is solved, and the effect of simplifying program logic and reducing database pressure is achieved.
Patent Information
- Application Number
- CN202411862421.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-17
- Publication Date
- 2025-04-25
AI Technical Summary
In the traditional access control system calendar download method, when the device is not online, it is necessary to frequently check whether it is online, resulting in complex writing of the download module and low efficiency, high database pressure, and untimely downloading.
Through the device shadow mechanism, the pre-entered calendar download command is obtained, the device shadow is determined based on the calendar code, and whether the expected value of the shadow is the same as the reported value. If it is not the same, the calendar data packet is obtained based on the expected value and sent to the device.
Reduces multiple queries to the database when downloading calendar data, reduces database pressure, simplifies program logic, and ensures that the calendar data on the device is updated in the calendar editing sequence.
Smart Images

Figure CN119892819A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of Internet of Things, and in particular to a calendar data downloading method, device, equipment and medium. Background Art
[0002] In the traditional access control system calendar download method, there will be a calendar download module dedicated to downloading calendar data to the device. When the calendar is edited, the calendar management module sends a notification to the download module, and the download module will ask the device service whether the device is online. If the device is online, it will download. If the device is not online, then the download module needs to ask whether the device is online every certain period of time (usually a few minutes). This method is very cumbersome, and the download module may not be timely even if the timing interval is configured to be very small.
[0003] This approach has the following disadvantages: (1) The download module is complex to write, requires regular inquiries, and has low efficiency; (2) Each device needs to query a large amount of data from the database when downloading data, which puts a lot of pressure on the database and occupies computer resources; (3) Downloading is not timely. Summary of the invention
[0004] The present invention provides a calendar data downloading method to solve the problem that each time a device requests to download calendar data, the database pressure increases due to repeated query of data.
[0005] In a first aspect, the present invention provides a calendar data downloading method, the method comprising: Obtaining a pre-input calendar download instruction, wherein the calendar download instruction includes a calendar code and a calendar tag value; Determine a device shadow according to the calendar code and a device service module, wherein the device shadow includes an expected value and a reported value, wherein the device service module is provided with a device shadow corresponding to each device; The calendar tag value is used as the new expected value of the device shadow, wherein the device service module determines whether the expected value of the device shadow is the same as the reported value. If they are not the same, a first URL address is determined according to the expected value of the device shadow, a first calendar data packet is obtained from the first URL address, and the first calendar data packet is sent to the device.
[0006] In a second aspect, the present invention provides a calendar data downloading device, comprising: An acquisition module, used to acquire a pre-input calendar download instruction, wherein the calendar download instruction includes a calendar code and a calendar tag value; A determination module, configured to determine a device shadow according to the calendar code and a device service module, wherein the device shadow includes an expected value and a reported value, wherein the device service module is provided with a device shadow corresponding to each device; An assignment module is used to use the calendar tag value as the new expected value of the device shadow, wherein the device service module determines whether the expected value of the device shadow is the same as the reported value. If not, a first URL address is determined according to the expected value of the device shadow, a first calendar data packet is obtained from the first URL address, and the first calendar data packet is sent to the device.
[0007] In a third aspect, an electronic device is provided, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; Memory, used to store computer programs; The processor is used to implement the steps of the calendar data downloading method described in any embodiment of the first aspect when executing the program stored in the memory.
[0008] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the calendar data downloading method as described in any embodiment of the first aspect are implemented.
[0009] The above technical solution provided by the embodiment of the present invention has the following advantages compared with the prior art: Generate calendar data package files to avoid multiple database reads when downloading calendar data to the device, greatly reducing database pressure. Database calendar data does not need to save history, ensuring that the calendar data on the device is in the editing sequence of the calendar. The shadow mechanism can avoid writing scheduled tasks, making the program simpler. The device calendar status promptly feeds back the data download results to keep the calendar data status in hardware and software consistent. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0011] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0012] Figure 1 A schematic diagram of a flow chart of a calendar data downloading method provided by an embodiment of the present invention; Figure 2 A schematic diagram of a sub-process of a calendar data downloading method provided by an embodiment of the present invention; Figure 3 A schematic diagram of a sub-process of a calendar data downloading method provided by an embodiment of the present invention; Figure 4 A schematic diagram of the structure of a calendar data downloading device provided by an embodiment of the present invention; Figure 5 A schematic diagram of the structure of a computer device provided by an embodiment of the present invention; Figure 6 A schematic diagram of a flow chart of another calendar data downloading method provided by an embodiment of the present invention; Figure 7 A schematic flow chart of another calendar data downloading method provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0013] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0014] Example A calendar data downloading method provided by an embodiment of the present invention is applied in an access control system. Calendar data (defining which day is a working day or a rest day in an enterprise) is system public data. Multiple sets of calendars can be defined, and different devices can specify the use of different calendars. When the calendar data is changed or added, it needs to be downloaded to the access control device, and the access control device will make corresponding controls according to whether the date specified in the calendar is a day of the week or a holiday. This includes switching the access control mode (normally open, normally closed, swiping the card to open the door) according to the time period of the day of the week, and controlling the door opening authority according to the day of the week. For example: some high-security doors are controlled not to open on rest days.
[0015] See also Figure 6-7 , the access control system involves the following modules: calendar management module ( Figure 6 Calendar management module in ), device management module ( Figure 6 Access control equipment management in), equipment service module ( Figure 6 Equipment services in Figure 7The device communication module in the device communication module). Among them, the calendar management module is used to send calendar data change messages to the device management module and package calendar data; the device management module is used to execute the calendar data download method; the device service module is used to detect device shadow changes, pull data from the calendar management module, and send data to the device; the calendar management module, the device management module, and the device service module are linked to each other to complete the download processing of calendar data.
[0016] Calendar data is stored in the database. In the traditional method, the access control system also includes a download module. As long as the calendar data changes, the device is notified to download. If the device is not online, the software will remember it and notify it again when the device is online. This method is more complex, and each time the device requests a download, the data will be queried repeatedly, causing greater pressure on the database.
[0017] Figure 1 The present invention provides a method for downloading calendar data. Figure 1 , the calendar data downloading method includes the following steps S101-S103.
[0018] S101, obtaining a pre-input calendar download instruction, where the calendar download instruction includes a calendar code and a calendar tag value.
[0019] In specific implementation, pre-input includes manual input by staff and pre-set trigger conditions, for example, the calendar approval process of the calendar management module is pre-set to be automatically triggered when it passes. The calendar code is used to distinguish multiple sets of calendar data, and the calendar tag value is used to identify the iterative changes of a set of calendar data.
[0020] In one embodiment, see Figure 2 , Figure 2 A schematic diagram of a sub-process of a calendar data downloading method provided by an embodiment of the present invention. Before the above step S101, it also includes S201-S202: S201, the calendar approval module determines whether the pre-input second calendar data package meets expectations; S202: If yes, the calendar approval module issues the calendar download instruction, where the calendar download instruction includes the calendar code of the second calendar data packet and its calendar tag value.
[0021] In one embodiment, the step S201 includes: storing the second calendar data packet to a second URL address, wherein the second URL address is determined according to the calendar code of the second calendar data packet and its calendar tag value.
[0022] In the specific implementation, the enterprise date maintainer ( Figure 6Calendar maintainer in the enterprise selects a set of calendars through the calendar management module, sets the calendars for the following months, for example, sets the days of the week or holidays, and submits the set calendars as the second calendar data package for approval. Figure 6 The calendar approver in the calendar approval module selects the calendar item to be approved through the calendar approval module, determines whether the second calendar data package meets expectations, and if approved, uploads the second calendar data package to the specified directory of the file server through the calendar management module, and issues a calendar download instruction for the calendar to be downloaded ( Figure 6 In the download notification message in the calendar download instruction, the calendar download instruction includes: a calendar code and a calendar tag value. In one embodiment, the calendar tag value includes a timestamp, and the timestamp (the number of seconds from January 1, 1970) is converted into a human-readable date and time format, and the calendar tag value includes the date and time format information. Taking the approval of the C1 calendar at 15:10:20 on August 7, 2024 as an example, the second calendar data packet will be uploaded to the location \calendar\2024\C1-20240807151020.dat through the calendar management module, where C1-20240807151020.dat is the second calendar data packet. The issued calendar download instruction contains the following data: Calendar code: C1; Calendar tag value: C1-20240807151020.
[0023] It should be noted that the approval by the enterprise date approver to determine whether the pre-input second calendar data package meets expectations is only an example. Those skilled in the art can also pre-set verification rules, train data models for verification and output judgment results, which does not exceed the scope of protection of the present invention.
[0024] S102, determining a device shadow according to the calendar code and a device service module, wherein the device shadow includes an expected value and a report value, wherein the device service module is provided with a device shadow corresponding to each device.
[0025] In the specific implementation, the device service module is provided with a device shadow corresponding to each device ( Figure 7 The shadow in the figure is short for device shadow. The device shadow includes the expected value ( Figure 7 desire value in ) and the reported value ( Figure 7 The report value in the , expected value, is assigned by the device management module, and the report value is used to identify the actual value of the device. The device shadow that applies the calendar code can be filtered according to the calendar code, which facilitates subsequent devices to download the calendar data.
[0026] S103, using the calendar tag value as the new expected value of the device shadow, wherein the device service module determines whether the expected value of the device shadow is the same as the reported value; if not, determining a first URL address based on the expected value of the device shadow, obtaining a first calendar data packet from the first URL address, and sending the first calendar data packet to the device.
[0027] In the specific implementation, the device service module monitors in real time whether the device shadow has changed. After taking the calendar tag value as the new expected value of the device shadow, the device service module detects the change of the device shadow and executes the step of determining whether the expected value of the device shadow is the same as the reported value. If the expected value of the device shadow is different from the reported value, a first URL address is determined according to the expected value of the device shadow, a first calendar data packet is obtained from the first URL address, and the first calendar data packet is sent to the device. For example: the device shadow is named CalendarTag. The shadow processing submodule in the device service assigns the calendar tag value (C1-20240807151020) to the expected value of the device shadow. The new expected value of the device shadow is C1-20240807151020. The device communication submodule in the device service detects that the expected value of the device shadow has changed to C1-20240807151020. According to C1-20240807151020, it searches for the corresponding file C1-20240807151020.dat from the file service and sends the data in the file package to the device. At this point, the device has completed the download of the calendar data.
[0028] In one embodiment, see Figure 3 , Figure 3 A schematic diagram of a sub-process of a calendar data downloading method provided by an embodiment of the present invention. The above step S103 includes steps S301-S302: S301, determining whether the calendar tag value is the same as the report value.
[0029] In the specific implementation, the calendar tag value is first compared with the report value. If the calendar tag value is the same as the report value, it means that the device has downloaded the set of calendar data, and there is no need to execute the step of using the calendar tag value as the new expected value of the device shadow, thereby avoiding the device from repeatedly downloading the set of calendar data.
[0030] S302: If they are not the same, the calendar tag value is used as the new expected value of the device shadow.
[0031] In a specific implementation, if the calendar tag value is different from the reported value, it means that the device has not downloaded the set of calendar data, and a step of using the calendar tag value as the new expected value of the device shadow needs to be executed.
[0032] In one embodiment, step S103 further includes: the device service module receives a download success message sent by the device, and uses the calendar tag value as a new report value of the device shadow.
[0033] In the specific implementation, the data packet file is sent to the device. After the device downloads successfully, it will report a download success message. After the device service module receives the device's download success message, it uses the calendar tag value as the new report value of the device shadow. At this point, the expected value of the device shadow is the same as the report value, indicating that the device download is successful.
[0034] In one embodiment, the device service module further includes: acquiring a third calendar data packet from a preset database according to an expected value of the device shadow, and sending the third calendar data packet to the device.
[0035] In a specific implementation, a device service module may also be pre-set. When the device service module detects that the expected value of the device shadow has changed, it obtains a third calendar data packet from a preset database according to the expected value of the device shadow, and sends the third calendar data packet to the device, thereby achieving the goal of not generating a data packet file and directly reading the database to download calendar data.
[0036] The embodiments of the present invention can achieve the following advantages: Generate calendar data package files to avoid multiple database reads when downloading calendar data to the device, greatly reducing database pressure. Database calendar data does not need to save history, ensuring that the calendar data on the device is in the editing sequence of the calendar. The shadow mechanism can avoid writing scheduled tasks, making the program simpler. The device calendar status promptly feeds back the data download results to keep the calendar data status in hardware and software consistent.
[0037] The calendar management module is very simple: the calendar module sends messages and packages calendar data, which is the module's job, avoiding adding computational burden; Functional cohesion of the device management module: The calendar data download method is applied to the device management module, which is responsible for the business data of the device and is used to verify what calendar the device uses; The functions of each module are very clear: the device service module is responsible for device communication, and receiving device shadow changes is an inherent function of the device service. With the help of shadow changes, files are pulled and downloaded to the device. The process is very clear.
[0038] See also Figure 4 The embodiment of the present invention further provides a calendar data downloading device 400 , which includes an acquiring unit 401 , a determining unit 402 and an assigning unit 403 .
[0039] The acquisition unit 401 is used to acquire a pre-input calendar download instruction, wherein the calendar download instruction includes a calendar code and a calendar tag value; In one embodiment, before obtaining the pre-input calendar download instruction, the method further includes: The calendar approval module determines whether the pre-input second calendar data packet meets expectations; If so, the calendar approval module issues the calendar download instruction, and the calendar download instruction includes the calendar code of the second calendar data packet and its calendar tag value.
[0040] In one embodiment, the calendar download instruction is issued by the calendar approval module, including: The second calendar data packet is stored in a second URL address, where the second URL address is determined according to the calendar code of the second calendar data packet and its calendar tag value.
[0041] In one embodiment, the calendar tag value includes a timestamp.
[0042] A determining unit 402, configured to determine a device shadow according to the calendar code and a device service module, wherein the device shadow includes an expected value and a reported value, wherein the device service module is provided with a device shadow corresponding to each device; The assignment unit 403 is used to use the calendar tag value as the new expected value of the device shadow, wherein the device service module determines whether the expected value of the device shadow is the same as the reported value. If they are not the same, a first URL address is determined according to the expected value of the device shadow, a first calendar data packet is obtained from the first URL address, and the first calendar data packet is sent to the device.
[0043] In one embodiment, the using the calendar tag value as the new expected value of the device shadow includes: determining whether the calendar tag value is the same as the reported value; If they are not the same, the calendar tag value is used as the new expected value of the device shadow.
[0044] In one embodiment, sending the first calendar data packet to the device includes: The device service module receives a download success message sent by the device, and uses the calendar tag value as a new report value of the device shadow.
[0045] In one embodiment, the device service module further includes: A third calendar data packet is obtained from a preset database according to an expected value of the device shadow, and the third calendar data packet is sent to the device.
[0046] like Figure 5 As shown, Figure 55 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device 500 may be a terminal or a server, wherein the terminal may be an electronic device with communication functions such as a smart phone, a tablet computer, a laptop computer, a desktop computer, a personal digital assistant, and a wearable device. The server may be an independent server or a server cluster composed of multiple servers.
[0047] The computer device 500 includes a processor 502 , a memory, and a network interface 505 connected via a system bus 501 , wherein the memory may include a non-volatile storage medium 503 and an internal memory 504 .
[0048] The non-volatile storage medium 503 can store an operating system 5031 and a computer program 5032. When the computer program 5032 is executed, the processor 502 can execute a calendar data downloading method.
[0049] The processor 502 is used to provide computing and control capabilities to support the operation of the entire computer device 500 .
[0050] The internal memory 504 provides an environment for the operation of the computer program 5032 in the non-volatile storage medium 503. When the computer program 5032 is executed by the processor 502, the processor 502 can execute a calendar data downloading method.
[0051] The network interface 505 is used to communicate with other devices over the network. Those skilled in the art will appreciate that the above structure is only a block diagram of a portion of the structure related to the present application solution, and does not constitute a limitation on the computer device 500 to which the present application solution is applied. The specific computer device 500 may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0052] It should be understood that in the embodiment of the present application, the processor 502 may be a central processing unit (CPU), and the processor 502 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0053] It is understood by those skilled in the art that all or part of the processes in the method for implementing the above embodiment can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a storage medium, which is a computer-readable storage medium. The computer program is executed by at least one processor in the computer system to implement the process steps of the embodiment of the above method.
[0054] Therefore, the present invention also provides a storage medium. The storage medium may be a computer-readable storage medium. The storage medium stores a computer program.
[0055] The storage medium is a physical, non-transient storage medium, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disk, etc., which can store program codes. The computer-readable storage medium can be non-volatile or volatile.
[0056] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0057] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of each unit is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0058] The steps in the method of the embodiment of the present invention can be adjusted in order, combined and deleted according to actual needs. The units in the device of the embodiment of the present invention can be combined, divided and deleted according to actual needs. In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0059] If 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 storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, terminal, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention.
[0060] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0061] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
[0062] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A calendar data downloading method, characterized in that: The method comprises: Obtaining a pre-input calendar download instruction, wherein the calendar download instruction includes a calendar code and a calendar tag value; Determine a device shadow according to the calendar code and a device service module, wherein the device shadow includes an expected value and a reported value, wherein the device service module is provided with a device shadow corresponding to each device; The calendar tag value is used as the new expected value of the device shadow, wherein the device service module determines whether the expected value of the device shadow is the same as the reported value. If they are not the same, a first URL address is determined according to the expected value of the device shadow, a first calendar data packet is obtained from the first URL address, and the first calendar data packet is sent to the device.
2. The method according to claim 1, characterized in that Before obtaining the pre-input calendar download instruction, the method further includes: The calendar approval module determines whether the pre-input second calendar data packet meets expectations; If so, the calendar approval module issues the calendar download instruction, and the calendar download instruction includes the calendar code of the second calendar data packet and its calendar tag value.
3. The method according to claim 2, characterized in that The calendar download instruction is issued by the calendar approval module, including: The second calendar data packet is stored in a second URL address, where the second URL address is determined according to the calendar code of the second calendar data packet and its calendar tag value.
4. The method according to claim 3, characterized in that The calendar tag value includes a timestamp.
5. The method according to claim 1, characterized in that The using the calendar tag value as a new expected value of the device shadow includes: determining whether the calendar tag value is the same as the reported value; If they are not the same, the calendar tag value is used as the new expected value of the device shadow.
6. The method according to claim 5, characterized in that The sending the first calendar data packet to the device includes: The device service module receives a download success message sent by the device, and uses the calendar tag value as a new report value of the device shadow.
7. The method according to claim 1, characterized in that The device service module further includes: A third calendar data packet is obtained from a preset database according to an expected value of the device shadow, and the third calendar data packet is sent to the device.
8. A calendar data downloading device, characterized in that: include: An acquiring unit, used for acquiring a pre-input calendar download instruction, wherein the calendar download instruction includes a calendar code and a calendar tag value; a determining unit, configured to determine a device shadow according to the calendar code and a device service module, wherein the device shadow includes an expected value and a reported value, wherein the device service module is provided with a device shadow corresponding to each device; An assignment unit is used to use the calendar tag value as the new expected value of the device shadow, wherein the device service module determines whether the expected value of the device shadow is the same as the reported value. If they are not the same, a first URL address is determined according to the expected value of the device shadow, a first calendar data packet is obtained from the first URL address, and the first calendar data packet is sent to the device.
9. A computer device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the steps of the method described in any one of claims 1 to 7 when executing a program stored in a memory.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.