Internet of Things data consistency control method and device, equipment and storage medium

By optimizing the data structure and logic within the IoT data consistency control system and using bitmap data structures to store consumption records, we solve the problems of high performance requirements and deployment difficulty in the existing technology, and achieve efficient and low-cost data consistency control. .

CN118796848APending Publication Date: 2024-10-18CHINA MOBILE M2M +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410580535.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-10
Publication Date
2024-10-18

AI Technical Summary

Technical Problem

Existing IoT data consistency control solutions have high system performance requirements and rely on external auxiliary systems, resulting in high investment costs and difficulty in deployment.

Method used

By optimizing the data structure and logic within the control system, using bitmap data structures to store consumption records of the IoT card, and making internal logical judgments, the dependence on external systems is reduced, storage space requirements are reduced and efficiency is improved.

Benefits of technology

It reduces the investment cost and deployment difficulty of the control system, improves the efficiency and accuracy of data consistency control, and reduces dependence on external auxiliary systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118796848A_ABST
    Figure CN118796848A_ABST
Patent Text Reader

Abstract

The invention discloses an Internet of Things data consistency control method and device, equipment and a storage medium, and belongs to the field of Internet of Things. The method comprises the steps that data of the Internet of Things card is acquired, the data comprises consumption records, the consumption records are stored in a bitmap data structure, the bitmap data structure is represented in a key value mode, keys represent time of the consumption records, and values represent consumption identifiers of the consumption records; and judging whether the preset key of the consumption record comprises the consumption identifier of the corresponding consumption record, when the judgment result is that the preset key comprises the consumption identifier of the corresponding consumption record, delaying preset time and then performing judgment again, and when the judgment result is that the preset key does not comprise the consumption identifier, adding a consumption service identifier for the Internet-of-Things card. According to the embodiment of the invention, the data information is identified by efficiently utilizing the memory in the system to determine the target data so as to perform efficient and accurate data consistency control, so that the data consistency is improved, and the input cost and deployment difficulty of the control system are reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of Internet of Things, and in particular, relates to a method, device, equipment, computer storage medium and computer program product for Internet of Things data consistency control. Background Art

[0002] With the rapid development of the Internet of Things, the number of IoT terminal users is also growing rapidly. Maintaining the accuracy of IoT data is crucial to promoting the sustainable development of the IoT industry and meeting the needs of various application scenarios. In the prior art, distributed data control solutions are often used to achieve data consistency control to meet the needs of data accuracy. However, the distributed data control solutions in the prior art have too high requirements on the performance of the control system and rely on external auxiliary systems, which have the problems of high investment costs and deployment difficulties. Summary of the invention

[0003] The embodiments of the present application provide an IoT data consistency control method, apparatus, device, computer storage medium, and computer program product to solve the problems of high resource overhead and complex deployment and maintenance of a data consistency control system.

[0004] In a first aspect, an embodiment of the present application provides a method for controlling consistency of IoT data, the method comprising:

[0005] Obtain the data of the IoT card, including consumption records. The consumption records are stored in a bitmap data structure, and the bitmap data structure is represented in a key-value format, where the key represents the time of the consumption record and the value represents the consumption identifier of the consumption record;

[0006] Using the target node corresponding to the IoT card, determining whether the first preset key of the consumption record of the IoT card includes the corresponding target value;

[0007] In the case where the first preset key of the consumption record does not include the corresponding target value, a target identifier is added to the IoT card, where the target identifier is used to indicate that the IoT card has enabled the consumption service function;

[0008] In the case where the first preset key of the consumption record includes the corresponding target value, determining whether the second preset key of the consumption record includes the corresponding target value; the time of the consumption record represented by the second preset key is after the time of the consumption record represented by the first preset key;

[0009] When the second preset key of the consumption record does not include the corresponding target value, a target identifier is added to the IoT card.

[0010] In one embodiment, after obtaining the data of the IoT card, the method further includes:

[0011] Create a consumption record with the unit time in the data as the key and the consumption ID corresponding to the unit time in the data as the value.

[0012] In one embodiment, the data further includes an IoT card number; before using the target node corresponding to the IoT card to determine whether the first preset key of the consumption record of the IoT card includes the corresponding target value, the method further includes:

[0013] Calculate the hash value of the IoT card number;

[0014] Map concurrency control service nodes to hash rings;

[0015] Determine the hash value interval where the hash value is located on the hash ring;

[0016] Determine the node corresponding to the hash value in the hash value interval and use the node as the target node.

[0017] In one embodiment, before using the target node corresponding to the IoT card to determine whether the first preset key of the consumption record of the IoT card includes the corresponding target value, the method further includes:

[0018] Detect the exclusive lock of the target node corresponding to the IoT card within the set time;

[0019] When an exclusive lock of a target node corresponding to the IoT card is detected within a set time, it is determined whether the first preset key of the consumption record includes the corresponding target value.

[0020] In one embodiment, the method further comprises:

[0021] If the exclusive lock of the target node corresponding to the IoT card is not detected within the set time,

[0022] It is determined whether the third preset key of the consumption record includes the corresponding target value; the time of the consumption record represented by the third preset key is after the time of the consumption record represented by the first preset key.

[0023] In one embodiment, the method further comprises:

[0024] The bitmap data of the consumption record before the time of the consumption record represented by the first preset key is cleaned up regularly.

[0025] In one embodiment, after adding the target identifier to the IoT card, the method further includes:

[0026] The data of the IoT card that has completed the consumption service is stored in the database.

[0027] In one embodiment, before storing the data of the IoT card that has completed the consumption function in the database, the method further includes: obtaining a timestamp of a message that has completed the consumption function;

[0028] When the database does not include a database update timestamp, update the database;

[0029] When the database includes a database update timestamp: when the timestamp of the message update is greater than or equal to the database update timestamp, the data of the IoT card that has completed the consumption service is stored in the database.

[0030] In a second aspect, an embodiment of the present application provides an IoT data consistency control device, the device comprising:

[0031] The acquisition module is used to acquire the data of the IoT card, the data including the consumption record, the consumption record is stored in a bitmap data structure, and the bitmap data structure is represented in a key-value manner, where the key represents the time of the consumption record and the value represents the consumption identifier of the consumption record;

[0032] A judgment module, used to judge whether the first preset key of the consumption record of the IoT card includes the corresponding target value by using the target node corresponding to the IoT card;

[0033] An adding module, used for adding a target identifier to the IoT card when the first preset key of the consumption record does not include the corresponding target value, the target identifier being used to indicate that the IoT card has enabled a consumption service function;

[0034] The judgment module is further used to judge whether the second preset key of the consumption record includes the corresponding target value when the first preset key of the consumption record includes the corresponding target value; the time of the consumption record represented by the second preset key is after the time of the consumption record represented by the first preset key;

[0035] The adding module is also used to add a target identifier to the IoT card when the second preset key of the consumption record does not include the corresponding target value.

[0036] In a third aspect, an embodiment of the present application provides an electronic device, the device comprising: a processor and a memory storing computer program instructions;

[0037] When the processor executes the computer program instructions, the Internet of Things data consistency control method as described in any one of the embodiments of the first aspect is implemented.

[0038] In a fourth aspect, an embodiment of the present application provides a computer storage medium, on which computer program instructions are stored. When the computer program instructions are executed by a processor, a method for controlling Internet of Things data consistency as in any one of the embodiments of the first aspect is implemented.

[0039] In a fifth aspect, an embodiment of the present application provides a computer program product. When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes the Internet of Things data consistency control method as in any one of the embodiments of the first aspect.

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

[0041] An IoT data consistency control method, apparatus, device, computer storage medium and computer program product of an embodiment of the present application first obtains data of an IoT card including consumption records, wherein the consumption records are stored in a bitmap data structure represented by a key value, and the key and value respectively represent the time and consumption identifier of the consumption record; then, by judging whether the preset key of the consumption record includes a target value, if the first preset key of the consumption record does not include the corresponding target value, a target identifier is added to the IoT card; if the first preset key of the consumption record includes the corresponding target value and the second preset key of the consumption record does not include the corresponding target value, a target identifier is added to the IoT card, and the time of the consumption record represented by the second preset key of the consumption record is after the time of the consumption record represented by the first preset key; the target identifier indicates that the consumption service function of the IoT card is enabled, and the consumption record of the IoT card with the target identifier added is recorded, so as to control the consistency of IoT data.

[0042] Moreover, the embodiments of the present application determine whether the preset key of the consumption record includes the target value. If the first preset key of the consumption record does not include the corresponding target value, a target identifier is added to the IoT card; or if the first preset key of the consumption record includes the corresponding target value and the second preset key of the consumption record does not include the corresponding target value, a target identifier is added to the IoT card. This is a determination made within the control system and does not require reliance on an external auxiliary system, thereby reducing the investment cost and deployment difficulty of the control system.

[0043] In addition, the embodiment of the present application utilizes a bitmap data structure to store the consumption records of the IoT card as bitmap data. The bitmap data structure is stored in bits, and each bit can represent the state of a data element. It also supports fast query operations, which can significantly reduce the storage space required for the control system and improve the efficiency of the control system, thereby reducing the investment cost of the control system. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the technical solution of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0045] Figure 1 This is a schematic diagram of an application scenario of an IoT data consistency control method provided by an embodiment of the present application;

[0046] Figure 2It is a flowchart of an IoT data consistency control method provided by an embodiment of the present application;

[0047] Figure 3 It is a schematic diagram of a preset key in a consumption record of an IoT card provided in an embodiment of the present application;

[0048] Figure 4 It is a flowchart of another IoT data consistency control method provided by an embodiment of the present application;

[0049] Figure 5 It is a flow chart of a method for sequentially storing data of an Internet of Things card into a database provided by an embodiment of the present application;

[0050] Figure 6 This is a system diagram of IoT data consistency control provided by an embodiment of the present application;

[0051] Figure 7 It is a flowchart of another IoT data consistency control method provided by an embodiment of the present application;

[0052] Figure 8 It is a structural diagram of an IoT data consistency control device provided in an embodiment of the present application;

[0053] Fig. 9 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0054] The features and exemplary embodiments of various aspects of the present application will be described in detail below. In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain the present application, rather than to limit the present application. For those skilled in the art, the present application can be implemented without the need for some of these specific details. The following description of the embodiments is only to provide a better understanding of the present application by illustrating the examples of the present application.

[0055] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "include..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0056] Data consistency control is a key process to ensure that data in multiple copies or components in a distributed system, database or application remains synchronized and consistent. IoT data consistency control is a key element to ensure that the data collected and processed by multiple devices and sensors in the IoT system remains accurate, reliable and synchronized. In the IoT environment, due to the large number of devices and sensors involved, data consistency is crucial to the normal operation and decision-making of the entire system. However, existing methods have high requirements on system memory and other performance to ensure data consistency control, and rely on other database components or middleware, etc., so there are problems of high investment cost and deployment difficulty.

[0057] In order to solve the defect that the control system depends on other database components or middleware, the embodiment of the present application takes the optimization of data structure and control logic within the control system as the starting point, and reduces the investment cost and deployment difficulty of the control system by performing logical judgment within the control system; in addition, by using a bitmap data structure for storage and taking advantage of the characteristics of the bitmap data structure that occupies a small memory space and supports fast query, the storage space required for the control system is reduced and the efficiency of the control system is improved, thereby reducing the investment cost of the control system.

[0058] As an important part of IoT technology, IoT cards are mainly used to provide network connection and data transmission for IoT devices. According to different classification standards, there are many types of IoT cards. In this embodiment, consumer-grade IoT cards, i.e., consumer IoT cards, are used as an example to control data consistency. Figure 1 FIG. 1 is a schematic diagram of an application scenario provided by this embodiment. Figure 1As shown, when a user needs to use a consumption card to make a purchase, such as making a consumption payment in a retail store or vending machine, in order to ensure data consistency, the control system analyzes and judges the data in the consumption card. The consumption card data contains consumption records. Whether the consumption record of the current consumption card includes a corresponding consumption identifier is used to confirm whether the consumption card is performing other consumption services at the same time. If no other consumption services are currently being performed, the current consumption service is executed. If other consumption services are currently being performed, reconfirmation is performed after a delay until it is confirmed that the consumption card is not currently performing other consumption services. In order to reduce the cost investment and deployment difficulty of the data consistency control system in the above embodiment, logical judgment can be performed within the control system and storage can be performed using a bitmap data structure.

[0059] In order to solve the problems of the prior art, the embodiments of the present application provide a method, device, equipment, computer storage medium and computer program product for controlling data consistency of the Internet of Things. The following first introduces the method for controlling data consistency of the Internet of Things provided by the embodiments of the present application.

[0060] like Figure 2 As shown, an Internet of Things data consistency control method provided in an embodiment of the present application includes the following steps: S210 to S250.

[0061] S210. Acquire data of the IoT card, where the data includes consumption records and is stored in a bitmap data structure. The bitmap data structure is represented in a key-value format, where the key represents the time of the consumption record and the value represents the consumption identifier of the consumption record.

[0062] IoT data is data generated by various IoT devices and sensors. IoT cards are key components for IoT devices to connect to the network and transmit data. They are dedicated SIM (Subscriber Identity Module) cards designed to meet the connection and data transmission needs of IoT devices. There are many types of IoT cards according to different classification standards. In this embodiment, consumer-grade IoT cards, i.e., consumer IoT cards, are used as examples.

[0063] In one embodiment, the method for obtaining the user data of the IoT card can be through the provider's data interface type and format, such as API interface, data push service, etc., and the corresponding docking code or configuration is written according to the interface type to stably obtain the user data of the IoT card.

[0064] In one embodiment, after obtaining the user data of the IoT card, the user data can also be parsed and preprocessed to parse the acquired original user data, extract fields related to consumption records, such as the time of consumption records, consumption identification, etc., clean and format the extracted data, remove invalid data or abnormal values, ensure the accuracy and consistency of the data, and finally perform necessary conversion or calculation on the data according to the business type and application scenario to prepare for subsequent storage and processing.

[0065] In one embodiment, when a user sends a consumption request to the system through an IoT card, the system will receive data from the IoT card. In this step, the system continuously obtains data from the IoT card, which can be in a known data format. These data cover the user's consumption records, which can specifically include: the time of the consumption record of the IoT card and the corresponding consumption identifier, and the consumption identifier indicates the consumption service situation at that time.

[0066] In one embodiment, the data of the IoT card also includes the IoT card number and consumption scenario, etc. The IoT card number is a special number or identification code for providing Internet access services for IoT devices. Each IoT card has its own unique ICCID (Integrate circuit card identity) number as an identification code. The ICCID number is equivalent to the "ID card" of the IoT card, which is used for identity recognition when recharging, querying, etc. the IoT card. It is understandable that the specific consumption record can also be changed according to different actual application scenarios.

[0067] The bitmap in the embodiment of the present application is a compact data structure, which is mainly used to represent the state of elements (existence or non-existence) in a set or sequence of a fixed size. It uses a bit array to represent the state of elements in the set, and each element corresponds to a bit, thereby achieving efficient space and time performance. The bitmap data structure is usually used to process a set of integer values ​​or Boolean values, such as set operations, data filtering, and counting.

[0068] In the embodiments of the present application, taking into account the scale of user data and query efficiency of the IoT card, technologies such as distributed storage or memory-mapped files can also be used to optimize the storage and access performance of the bitmap data structure.

[0069] In an embodiment of the present application, after the consumption record is stored in a bitmap data structure format and rules, the consumption record is represented by a key-value pair (Key-Value Pair) of a bitmap data structure, wherein the key (Key) represents the time of the consumption record, i.e., the time in the data of the IoT card, and the value (Value) represents the consumption identifier of the consumption record, i.e., the consumption identifier corresponding to the time in the data of the IoT card, and each key-value pair respectively represents the time of the consumption record represented by this key in the consumption record and the corresponding consumption identifier.

[0070] In one embodiment, the consumption record is stored in a bitmap data structure, which is represented in a key-value format, where the key represents the time of the consumption record and the value represents the consumption identifier of the consumption record. Each key corresponds to a value, i.e., the identifier of a specific consumption record. For example, when the value is 1, it indicates that the consumption identifier exists, i.e., the consumption service exists at the time corresponding to the current key. When the value is 0, it indicates that the consumption identifier does not exist, i.e., the consumption service does not exist at the time corresponding to the current key. The use of a bitmap data structure for storage supports very fast query operations, and can significantly reduce the storage space required for the control system and improve the efficiency of the control system, thereby reducing the investment cost of the control system.

[0071] S220: Use the target node corresponding to the IoT card to determine whether the first preset key of the consumption record of the IoT card includes the corresponding target value.

[0072] In the embodiment of the present application, the node is a computer service node, also called a network node or a server node, which is an important component of a computer network. It mainly undertakes functions such as data transmission, processing, storage and distribution to ensure that information in the network can be transmitted accurately and efficiently. The target node can be one or more computer service nodes, and the service node is used to determine whether a preset key of the consumption record of the IoT card includes the corresponding target value.

[0073] In an embodiment of the present application, the preset key can be a time point or a time period, that is, a time point or a time period of the consumption record of the IoT card, and the consumption identifier of the consumption record is the target value corresponding to the preset key of the consumption record that needs to be determined whether to include it.

[0074] like Figure 3As shown, exemplarily, in the data of the IoT card, time is a key, and in the consumption record where the consumption identifier corresponding to the time in the data of the IoT card is a value, the time is a minute, the number represents the minute of the current time, the T period is the current period, 01 minutes is the T period, 00 minutes is the T-1 period, 02 minutes is the T+1 period, and so on, and other periods are not described in detail here. The first preset key can be the T-1 to T period. When judging whether the first preset key of the consumption record includes the corresponding target value, that is, judging whether the T-1 to T period of the consumption record includes the corresponding target value, when the value corresponding to the T-1 to T period of the consumption record is 1, it can be regarded that the T-1 to T period of the consumption record includes the corresponding target value, that is, there is a consumption identifier, and when the value corresponding to the T-1 to T period of the consumption record is 0, it can be regarded that the T-1 to T period of the consumption record does not include the corresponding target value, that is, there is no consumption identifier.

[0075] Among them, the first preset key is selected as the T-1 to T time period. The IoT card consumes services during the T-1 time period. The possible consumption services occur at the critical time of the T-1 and T time periods. The consumption services occurring during the T-1 time period of the IoT card are recorded in the consumption record of the IoT card in the T-1 and T time periods.

[0076] In one embodiment, a logic judgment rule is provided to realize data consistency control. A corresponding target node is assigned to the IoT card, and the target node can be one or more computer service nodes. The service node is used to judge whether a preset key of the consumption record of the IoT card includes the corresponding target value. The preset key can be a time point or a time period, that is, a time point or a time period of the consumption record of the IoT card. The consumption identifier of the consumption record is the target value corresponding to the preset key of the consumption record that needs to be judged whether it is included, that is, whether a time point or a time period of the consumption record of the IoT card includes the consumption identifier of the consumption record. For the convenience of distinguishing, the preset key mentioned here can be called the first preset key. This embodiment is a judgment within the control system, and does not need to rely on an external auxiliary system, which reduces the investment cost and deployment difficulty of the control system.

[0077] S230: When the first preset key of the consumption record does not include the corresponding target value, add a target identifier for the IoT card, where the target identifier is used to indicate that the consumption service function of the IoT card is enabled.

[0078] In the embodiment of the present application, the role of the target identifier is to indicate that the consumption service function of the IoT card has been activated and the IoT card can perform consumption services.

[0079] Exemplarily, adding a target identifier for the IoT card can update the values ​​corresponding to the T time period and T+1 time period in the consumption record of the IoT card to 1, and the current time period is the T time period, wherein when a consumption service occurs in the T time period of the IoT card, the consumption service may occur at the critical time of the T and T+1 time periods, and the consumption service occurring in the T time period of the IoT card is recorded in the T and T+1 time periods in the consumption record of the IoT card. Therefore, the values ​​corresponding to the T time period and T+1 time period of the consumption record of the IoT card are updated to 1, providing a basis for later determining whether there is a consumption identifier in the T+1 time period and T+2 time period of the consumption record of the IoT card.

[0080] The target node is used to determine whether the first preset key of the consumption record of the IoT card includes the corresponding target value to obtain a determination result. In one embodiment, when the determination result is that the first preset key of the consumption record of the IoT card does not include the corresponding target value, that is, when the first preset key of the consumption record of the IoT card does not have a consumption identifier, that is, the IoT card has not performed consumption services during the period covered by the first preset key, which means that the IoT card can perform consumption services during the current period, and a target identifier is added to the IoT card, which indicates that the consumption service function of the IoT card has been enabled during the current period, and the IoT card can perform data consumption services during the current period.

[0081] This embodiment ensures the orderly progress of consumption services and the consistency of data by adding a target identifier to the IoT card to indicate that the consumption service function of the IoT card has been activated in the current period when the first preset key of the consumption record of the IoT card does not include the corresponding target value.

[0082] S240. When the first preset key of the consumption record includes the corresponding target value, determine whether the second preset key of the consumption record includes the corresponding target value; the time of the consumption record represented by the second preset key is after the time of the consumption record represented by the first preset key.

[0083] In an embodiment of the present application, the second preset key can be a time point or a time period, that is, a time point or a time period of the consumption record of the IoT card. The consumption identifier of the consumption record is the target value corresponding to the preset key of the consumption record that needs to be determined whether to include it. The time of the consumption record represented by the second preset key is after the time of the consumption record represented by the first preset key.

[0084] For example, Figure 3As shown, relative to when the T period is the current period, the second preset key can be the T+2 to T+3 period, wherein the time interval between the first preset key and the second preset key is the T+1 period. According to step S230, when a consumption service record occurs in the T period of the IoT card, it is recorded in the T and T+1 periods in the consumption record of the IoT card. The values ​​corresponding to the T time period and the T+1 time period of the consumption record of the IoT card are updated to 1. When determining whether the second preset key of the consumption record includes the corresponding target value, it is not affected by the value corresponding to the T+1 period of the consumption record, thereby avoiding the problem of an infinite loop.

[0085] In one embodiment, when the judgment result is that the first preset key of the consumption record of the Internet of Things card includes the corresponding target value, that is, there is a consumption identifier in the first preset key of the consumption record of the Internet of Things card, that is to say, the Internet of Things card has performed consumption services within the time period covered by the first preset key, which means that the Internet of Things card cannot perform consumption services in the current time period. Therefore, it is necessary to check whether the second preset key of the consumption record of the Internet of Things card includes the corresponding target value. The time of the consumption record represented by the second preset key is after the time of the consumption record represented by the first preset key, that is, when the first preset key of the consumption record includes the corresponding target value, it is delayed to the time point or time period corresponding to the second preset key of the consumption record to judge whether it includes the corresponding target value. This judgment process is consistent with the logical process and judgment criteria in the implementation mode of steps S220 to S240, and will not be repeated here.

[0086] This embodiment ensures the orderly progress of consumption services and the consistency of data by delaying the judgment of whether the corresponding target value is included to the time point or time period corresponding to other preset keys of the consumption record when the first preset key of the consumption record of the Internet of Things card includes the corresponding target value.

[0087] S250: When the second preset key of the consumption record does not include the corresponding target value, add a target identifier to the IoT card.

[0088] For example, Figure 3 As shown, when the T period is the current period, the second preset key can be the T+2 to T+3 period. When the second preset key of the consumption record is delayed to determine whether it includes the corresponding target value, the T+3 period is the current period, which can also be understood as the new T period, that is, the second preset key is the T-1 to T period.

[0089] In one embodiment, when the judgment result is that the second preset key of the consumption record of the IoT card does not include the corresponding target value, that is, when the second preset key of the consumption record of the IoT card does not have a consumption identifier, that is, the IoT card has not performed consumption services during the period covered by the second preset key, which means that the IoT card can perform consumption services during the current period, and a target identifier is added to the IoT card, and the target identifier indicates that the consumption service function of the IoT card has been enabled during the current period. This process of adding a target identifier to the IoT card is consistent with the method described in the implementation method of step S230, and will not be repeated here.

[0090] This embodiment ensures the orderly progress of consumption services and the consistency of data by adding a target identifier to the IoT card to indicate that the consumption service function of the IoT card has been enabled in the current period when the second preset key of the consumption record of the IoT card does not include the corresponding target value.

[0091] In one embodiment, in steps S210 to S250, the process of determining whether the preset key of the consumption record of the IoT card includes the corresponding target value can be implemented by the following program logic: exist(msisdn)=BitMap T [msisdn]∨BitMap T-1 [msisdn]=false?false:true

[0092] Among them, msisdn represents the IoT card number, BitMap represents the bitmap data structure class, not a specific data structure, BitMap T [msisdn] indicates that the consumption record of the IoT card corresponding to the IoT card number represented by a bitmap data structure includes the corresponding consumption identifier at T time point or time period. T-1 [msisdn] indicates that the T-1 time point or time period in the consumption record of the IoT card corresponding to the number represented in a bitmap data structure includes the corresponding consumption identifier.

[0093] When exist(msisdn) in the above program logic returns true, it means that at least one time point or time period in the consumption record of the IoT card corresponding to the number at time point T or T-1 has a corresponding consumption identifier. When exist(msisdn) in the program logic returns false, it means that at no time point or time period in the consumption record of the IoT card corresponding to the number at time point T or T-1 does the corresponding consumption identifier exist.

[0094] The data consistency control method provided in the embodiment of the present application determines whether the preset key of the consumption record includes the target value. When the first preset key of the consumption record does not include the corresponding target value, a target identifier is added to the IoT card; or when the first preset key of the consumption record includes the corresponding target value and the second preset key of the consumption record does not include the corresponding target value, a target identifier is added to the IoT card. The determination is made within the control system and does not rely on other database components or external auxiliary systems such as middleware, thereby reducing the investment cost and deployment difficulty of the control system.

[0095] In addition, the embodiment of the present application uses a bitmap data structure to store the consumption record of the IoT card in bitmap data. The bitmap data structure is stored in bits, and each bit can represent the state of a data element. Taking a common bitmap as an example, the space required to store 2 billion integer data bit by bit is 2000000000 / 8 / 1024 / 1024 / 1024≈0.23G, while in a 32-bit operating system, using a common integer 4-byte data structure to store 2 billion integer data requires 2000000000*4 / 1024 / 1024 / 1024≈7.45G. Obviously, in this example, the data space stored bit by bit is about 3.09% of that stored in a common data structure, which effectively reduces the utilization rate of physical memory and reduces the investment in physical devices. At the same time, there is also an optimized data structure for bit by bit storage, such as an efficient compressed bitmap RoaringBitmap, which can further improve the efficiency of memory usage. It can significantly reduce the storage space required for the control system and improve the efficiency of the control system, reducing the investment cost of the control system.

[0096] As another implementation of the present application, after obtaining the data of the IoT card in step S210, the following steps may also be included:

[0097] Create a consumption record with the unit time in the data as the key and the consumption ID corresponding to the unit time in the data as the value.

[0098] In the embodiments of the present application, a timestamp refers to a number or a string of characters used to indicate the time when an event occurs, and is typically used in a computer system to record the time when a file is created or modified, or to record the time when data in a database is inserted or updated.

[0099] In one embodiment, after obtaining the data of the IoT card, a consumption record can also be created with the unit time in the IoT card data as the key and the consumption identifier corresponding to the unit time in the IoT card data as the value. Among them, the unit time in the IoT card data can be set according to the needs, for example, the unit time can be set to one minute, one second, etc. It can be understood that the specific unit time can also be changed according to different actual applications. In order to be able to efficiently store and query consumption records, a bitmap data structure format and rules are used to store the consumption record, and the consumption record is represented by a key-value pair (Key-Value Pair) of the bitmap data structure. Among them, the key (Key) represents the time of the consumption record, that is, the unit time in the IoT card data, and the value (Value) represents the consumption identifier of the consumption record, that is, the consumption identifier corresponding to the unit time in the IoT card data. Each key-value pair represents the time of the consumption record represented by this key in the consumption record and the corresponding consumption identifier.

[0100] Exemplarily, the timestamp of the consumption record can also be used as the key. Since the timestamp is unique, it can be ensured that each time in the consumption record has a unique key corresponding to it, and the consumption identifier of the consumption record is used as the value. Each key corresponds to a value, that is, the identifier of a specific consumption record. For example, the key is 2024-01-01 12:01, and the target value corresponding to this key is 1, indicating that the consumption service exists at 2024-01-01 12:01 in the consumption record.

[0101] The embodiment of the present application creates a consumption record with the unit time in the data as the key and the consumption identifier corresponding to the unit time in the data as the value, and utilizes the uniqueness of the key-value pair to improve the retrieval efficiency of consumption records, reduce data redundancy, support real-time updates and optimize queries, thereby optimizing the system processing efficiency and stability and ensuring the uniqueness of the data.

[0102] As another implementation of the present application, the data of the IoT card also includes the IoT card number; before step S220: using the target node corresponding to the IoT card to determine whether the first preset key of the consumption record of the IoT card includes the corresponding target value, the method may further include the following steps:

[0103] S260: Calculate the hash value of the IoT card number; map the concurrent control service node to the hash ring; determine the hash value interval where the hash value is located on the hash ring; determine the node corresponding to the hash value in the hash value interval, and use the node as the target node.

[0104] In an embodiment of the present application, the hash value of the IoT card number is a binary value of a fixed length obtained by calculating the IoT card number through a hash function. The hash function is a special function. No matter how long the input string of characters is, a fixed-length output value can be obtained through the hash function. It can be used to verify the integrity of the IoT card number and ensure that it has not been tampered with during transmission or storage.

[0105] In an embodiment of the present application, a hash ring is a data sharding scheme for evenly distributing data on multiple nodes. The basic principle of a hash ring is to map all nodes and data to a ring. Each node and data has a corresponding hash value on the ring, which can achieve efficient data storage and access in a distributed system. A hash interval is a data mapping mechanism based on a hash algorithm and a hash ring. It divides the entire hash value space into multiple small intervals. Each node or server is responsible for processing data or requests that fall within its corresponding interval, and divides the hash interval on the hash ring based on the range of hash values.

[0106] In the embodiments of the present application, the concurrency control service generally refers to the technology used to ensure the consistency and isolation of transactions when multiple users, processes or threads operate on the database at the same time. The concurrency control service node refers to one or more specific components or functional points in the concurrency control service, which is mainly responsible for managing and controlling multiple concurrent requests or operations, such as consumption requests of IoT cards, to ensure the consistency and integrity of the data.

[0107] In one embodiment, in addition to the consumption record, the data of the IoT card may also include an integrated circuit card identification code for identifying and distinguishing different IoT cards, that is, the IoT card number. The hash value of the IoT card number is calculated using a hash algorithm, and the IoT card number is converted into a hash value of a fixed length. The concurrent control service connection pool information is obtained, and the requests of different IoT cards are distributed to different concurrent control services. A hash function is defined to map the identifier of the concurrent control service node (such as an IP address, a host name, etc.) to a hash value. A hash ring is constructed using a consistent hash ring algorithm. According to the calculated node hash values, they are placed in order at corresponding positions on the hash ring. The hash value of the IoT card number is matched with the service node on the hash ring. First, the corresponding hash interval is determined on the hash ring according to the hash value of the IoT card number, and then the node corresponding to the hash value of the IoT card number is determined on the corresponding hash interval according to the hash value of the IoT card number. This node is the target node, and the target node is used to determine whether a preset key of the consumption record of the IoT card includes the corresponding target value.

[0108] For example, an IoT card number card123 has a hash value of 150. There are two concurrent control service nodes, whose identifiers are node1 and node2 respectively. A hash function is used to convert these node identifiers into hash values: hash(node1)=60, hash(node2)=160. These hash values ​​form a hash ring and are arranged in order from small to large. In order to determine the concurrent control service node corresponding to card123, start from the minimum value of the hash ring (or any fixed starting point), traverse the hash ring in a clockwise direction, and find the hash interval of 101 to 200 corresponding to the hash value 150 of the IoT card number, and find the hash value of the node within the hash value range of the hash interval. The hash value 160 of the identifier node2 is within this range, so the node corresponding to the identifier node2 is determined to be the target node.

[0109] The embodiment of the present application expands the scale of concurrent control services through the scale of IoT cards and their requests, reduces the memory pressure of a single service, and improves the high availability of the entire service system. At the same time, the consistent hash ring algorithm is used to evenly distribute the nodes and map them on the hash ring to ensure that each node can evenly process the requests of the IoT cards, avoiding excessive pressure on a single point and improving the high availability of the entire service system. Therefore, this embodiment can maximize the scalability and security of the overall service and enhance the uniqueness and consistency of the data.

[0110] As another implementation of the present application, before step S220, that is, before using the target node corresponding to the IoT card to determine whether the first preset key of the consumption record of the IoT card includes the corresponding target value, the method may further include the following steps:

[0111] S270: Detect the exclusive lock of the target node corresponding to the IoT card within a set time.

[0112] S280: When an exclusive lock of the target node corresponding to the IoT card is detected within a set time, it is determined whether the first preset key of the consumption record includes the corresponding target value.

[0113] In the embodiment of the present application, an exclusive lock (Exclusive Lock, X lock) is a lock mechanism that only allows one transaction or thread to modify a data item. When a transaction or thread obtains an exclusive lock, other transactions or threads cannot obtain a shared lock or an exclusive lock, and can only wait for the transaction or thread to release the lock. ReentrantLock is a reentrant exclusive lock that allows the same thread to obtain the same lock multiple times without being blocked. In the embodiment of the present application, it is detected whether the target node corresponding to the IoT card holds an exclusive lock. The exclusive lock can be used to ensure that access to the target node is mutually exclusive, avoiding multiple operations from modifying the same resource at the same time.

[0114] In one embodiment, in order to ensure safe access and accurate processing of the data of the IoT card in a high concurrency environment, one or more exclusive locks are allocated to the service node according to the concurrency control requirements and different designs. Exemplarily, the exclusive lock can be a lightweight timeout waiting reentrant ReentrantLock lock. When the consumption record of the IoT card needs to be processed, that is, when the thread or process needs to access the target node, it will first detect whether the exclusive lock of the target node corresponding to the IoT card is available within the set time, and try to obtain the exclusive lock corresponding to the node. Exemplarily, the set time can be set according to actual business needs and system performance, such as 1 minute. If the exclusive lock of the target node corresponding to the IoT card is detected to be available within the set time, the exclusive lock is obtained, and the node can be used for data access and operation, and the node is used to determine whether the first preset key of the consumption record of the IoT card includes the corresponding target value. This judgment process is consistent with the logical process and judgment criteria in the implementation of steps S220 to S240, and will not be repeated here. After data access and operation are completed, the thread or process needs to release the exclusive lock so that other threads or processes can acquire the lock and access the target node.

[0115] In one embodiment, the lock granularity can be optimized and adjusted according to the access pattern and update frequency of the IoT card consumption record to reduce lock contention and improve concurrency performance. For example, a finer-grained lock mechanism such as a segmented lock or a read-write lock can be considered.

[0116] The embodiment of the present application uses an exclusive lock to protect the target node corresponding to the IoT card in a concurrent environment, ensuring that the target node will not be modified by other threads or processes when judging the consumption record of the IoT card, thereby improving the concurrent control performance and system stability, thereby ensuring the consistency and accuracy of the data.

[0117] As another implementation of the present application, after step S270, that is, after detecting the exclusive lock of the target node corresponding to the IoT card within the set time, the method may further include the following steps:

[0118] S290: If the exclusive lock of the target node corresponding to the IoT card is not detected within the set time, determine whether the third preset key of the consumption record includes the corresponding target value; the time of the consumption record represented by the third preset key is after the time of the consumption record represented by the first preset key.

[0119] In an embodiment of the present application, the third preset key can be a time point or a time period, that is, a time point or a time period of the consumption record of the IoT card. The consumption identifier of the consumption record is the target value corresponding to the preset key of the consumption record that needs to be determined whether to include it. The time of the consumption record represented by the third preset key is after the time of the consumption record represented by the first preset key.

[0120] For example, Figure 3 As shown, when the exclusive lock of the target node corresponding to the IoT card is detected, when the T period is the current period, the third preset key can be the T+2 to T+3 period. When the third preset key of the consumption record is delayed to determine whether it includes the corresponding target value, the T+3 period is the current period, which can also be understood as a new T period, that is, the third preset key is the T-1 to T period.

[0121] In one embodiment, if the exclusive lock of the target node corresponding to the IoT card is not detected to be available within the set time and the exclusive lock cannot be acquired, for example, the exclusive lock is already held by other threads, and it is determined whether the third preset key of the consumption record of the IoT card includes the corresponding target value. The time of the consumption record represented by the third preset key is after the time of the consumption record represented by the first preset key, that is, it is delayed to the time point or time period corresponding to the third preset key of the consumption record of the IoT card to determine whether it includes the corresponding target value. This judgment process is consistent with the logical process and judgment criteria in the implementation mode of steps S220 to S240, and will not be repeated here.

[0122] That is to say, if the exclusive lock of the target node corresponding to the IoT card is not obtained within the set time, the lock is re-detected and acquired at a time point or time period after the time point or time period corresponding to the first preset key of the consumption record of the IoT card until the exclusive lock is obtained. When the exclusive lock is obtained, the corresponding time point or time period in the consumption record of the IoT card is the third preset key of the consumption record of the IoT card.

[0123] The embodiment of the present application introduces a third preset key to process the consumption record of the IoT card in chronological order by considering the case where the exclusive lock of the target node corresponding to the IoT card is not detected within a set time, thereby enhancing the flexibility, scalability and data integrity of the system.

[0124] like Figure 4 As shown, in one embodiment, the provided method for controlling the consistency of IoT data includes the following steps:

[0125] S410: Acquire the data of the IoT card, including the consumption record and number of the IoT card. The consumption record is stored in a bitmap data structure represented by a key value.

[0126] When the user sends a consumption request to the system through the IoT card, the system continuously obtains the data of the IoT card, which can be in a known data format. These data cover the user's consumption record, which can specifically include: the time of the consumption record of the IoT card and the corresponding consumption identification, the consumption identification indicates the consumption service situation at that time, and the IoT card data can also include the IoT card number used to identify and distinguish different IoT cards. It is understandable that the specific IoT card data can also be changed according to different actual applications.

[0127] The consumption record is stored in the bitmap data structure format and rules, and the consumption record is represented by the key-value pair of the bitmap data structure. The key represents the time of the consumption record, that is, the unit time in the data of the IoT card, and the value represents the consumption identifier of the consumption record, that is, the consumption identifier corresponding to the unit time in the data of the IoT card. Each key-value pair represents the time of the consumption record represented by this key in the consumption record and the corresponding consumption identifier.

[0128] S420: Calculate the hash value of the IoT card number.

[0129] The hash value of the IoT card number is calculated using a hash algorithm, and the IoT card number is converted into a hash value of a fixed length.

[0130] S430: Acquire a concurrency control service node and map it to a hash ring.

[0131] Obtain the concurrency control service connection pool information, distribute the requests of different IoT cards to different concurrency control services, define a hash function to map the identifier of the concurrency control service node (such as IP address, host name, etc.) to a hash value, and use the consistent hash ring algorithm to build a hash ring. According to the calculated node hash values, place them in the corresponding positions on the hash ring in sequence.

[0132] S440: Connect the hash value of the IoT card number with the node in the hash ring to obtain a consumption service connection pool for determining the consumption service status of the IoT card.

[0133] Match the hash value of the IoT card number with the service node on the hash ring. First, determine the corresponding hash interval on the hash ring according to the hash value of the IoT card number. Then, determine the node corresponding to the hash value of the IoT card number in the corresponding hash interval according to the hash value of the IoT card number. This node is the target node. The target node is used to determine whether a preset key of the consumption record of the IoT card includes the corresponding target value. The node is used to determine the consumption service status of the IoT card. These nodes constitute a consumption service connection pool.

[0134] S450: Failed to obtain the exclusive lock of a node in the connection pool within a limited time.

[0135] One or more exclusive locks are allocated to the service node according to the concurrency control requirements and designs. For example, the exclusive lock can be a lightweight reentrant ReentrantLock lock with a timeout wait. When the consumption record of the IoT card needs to be processed, that is, when the thread or process needs to access the target node, the target node corresponding to the IoT card is found in the consumer service connection pool, and it is detected whether the exclusive lock of the target node corresponding to the IoT card is available within the set time, and an attempt is made to see whether the exclusive lock corresponding to the node can be successfully acquired.

[0136] S460: Determine whether there is a consumption mark within the set time in the consumption record.

[0137] It is detected within the set time that the exclusive lock of the target node corresponding to the IoT card is available, and the exclusive lock of the node in the connection pool is successfully obtained within a limited time. When the exclusive lock is obtained, it is determined whether a time point or a time period of the consumption record of the IoT card includes the consumption identifier of the corresponding consumption record.

[0138] S470: Put the device into a delay queue and delay for a preset time.

[0139] If the exclusive lock of the target node corresponding to the IoT card is not available within the set time and the exclusive lock cannot be obtained, that is, the exclusive lock of the node in the connection pool fails to be obtained within the limited time; or

[0140] The exclusive lock is acquired within the set time, and it is determined that a preset time point or a time period of the consumption record of the IoT card includes a consumption identifier of the corresponding consumption record.

[0141] When the above situation is met, the process of the node is terminated, and step S410 is restarted after delaying for a preset time using the delay queue.

[0142] S480: The IoT card has not been used for consumption services recently.

[0143] When a preset time point or time period of the consumption record of the IoT card does not include a consumption identifier of the consumption record, it means that the IoT card has not performed any consumption service recently.

[0144] S490: Mark the consumption record of the IoT card to indicate that the consumption service can be provided.

[0145] When the IoT card is capable of performing consumption services in the current time period, a target identifier is added to the IoT card, and the target identifier indicates that the consumption service function of the IoT card has been enabled in the current time period. Exemplarily, adding a target identifier to the IoT card can update the values ​​corresponding to the T time period and the T+1 time period in the consumption record of the IoT card to 1.

[0146] The embodiment of the present application stores the consumption record of the IoT card as bitmap data and represents the bitmap data structure in the form of key-value pairs, which can reduce the storage space required by the system and improve efficiency, thereby reducing the investment cost of the control system. In addition, the scale of concurrent control services is expanded according to the scale of IoT cards and their requests, reducing the memory pressure of a single service. At the same time, the consistent hash ring algorithm is used to evenly distribute the nodes and map them on the hash ring to ensure that each node can evenly process the request of the IoT card, thereby improving the high availability and security of the entire service system and enhancing the uniqueness of the data. In addition, the node corresponding to the IoT card is protected by an exclusive lock in a concurrent environment to ensure that the node will not be modified by other threads or processes when in use, thereby improving the concurrent control performance and system stability. By considering that the exclusive lock of the node corresponding to the IoT card is not detected within a set time, a third preset key is introduced to process the consumption record of the IoT card in chronological order, thereby enhancing the flexibility, scalability and data integrity of the system. Finally, the entire data consistency control process is performed within the control system, without relying on other database components or external auxiliary systems such as middleware, thereby reducing the investment cost and deployment difficulty of the control system.

[0147] As another implementation of the present application, the method may further include:

[0148] The bitmap data of the consumption record before the time of the consumption record represented by the first preset key is cleaned up regularly.

[0149] In an embodiment of the present application, scheduled cleaning can be to automatically execute cleaning tasks at predetermined time intervals to delete or organize unnecessary files, data or caches, etc., which can be achieved through a scheduled task or scheduling system in the computer.

[0150] In one embodiment, as data consistency control is continuously performed, the system memory utilization rate continues to increase, and the system timing scheduling service is used to delete or reset the bitmap data of the consumption record before the time of the consumption record represented by the first preset key at a predetermined time or period, clean up and release the memory, improve the memory utilization rate, and avoid the memory leakage problem caused by too much memory storage data. In actual applications, the specific cleaning strategy and time may be set based on business needs and data volume and other factors.

[0151] The embodiments of the present application can optimize system performance, reduce storage space usage, and ensure the timeliness and accuracy of data by regularly cleaning redundant data in memory.

[0152] As another implementation of the present application, in step S250: after the IoT card adds the target identifier, the method may further include:

[0153] The data of the IoT card that executes the consumption function is stored in the database.

[0154] In one embodiment, after the IoT card performs the consumer service function, the data of the IoT card is persistently stored in the database system. The database management system (DBMS) provides a mechanism for storing, retrieving, updating and deleting data. The data of the IoT card can be retrieved and used when needed.

[0155] Exemplarily, when processing the data of the IoT card, you can also choose a relational database (RDBMS) or a non-relational database (NoSQL) for persistence or caching. Depending on factors such as the characteristics of the data, query requirements, performance requirements, and data consistency, the combined use of relational and non-relational databases to process the data of the IoT card can bring significant results in terms of data processing performance, data consistency, system flexibility, stability, and operation and maintenance costs.

[0156] The embodiment of the present application achieves effective management and storage of IoT card data by storing the data of the IoT card that executes the consumption function in the database, ensuring data integrity, security and consistency, and providing strong support for data analysis and decision support.

[0157] As another implementation of the present application, before storing the data of the IoT card that performs the consumer service function in the database, the method may also include:

[0158] Obtain the timestamp of the message update that completes the consumption function; when the database does not include the database update timestamp, update the database; when the database includes the database update timestamp: when the timestamp of the message update is greater than or equal to the database update timestamp, store the data of the IoT card that completes the consumption service function to the database.

[0159] In one embodiment, when the IoT card completes the consumer service function, the timestamp of the message update is obtained. This timestamp is usually automatically generated when the IoT card completes the consumer service function, representing the specific time when the consumer service action is completed. The timestamp can be conveniently used to calculate and compare time differences. Check whether there is already an update timestamp in the database. This database update timestamp represents the specific time when the data was successfully stored in the database last time. If there is no update timestamp in the database, it means that this is the first time to store data or the timestamp in the database has been cleared. The database is updated, and a data update timestamp can be generated after the database is updated. If there is already an update timestamp in the database, compare the database update timestamp and the message update timestamp. If the message update timestamp is greater than or equal to the database update timestamp, it means that there is new data to be stored, and the data of the IoT card that has completed the consumer service function is stored in the database; if the message update timestamp is less than the database update timestamp, it means that the data in the database is already the latest, and the data of the IoT card that has completed the consumer service function cannot be stored in the database at this time.

[0160] like Figure 5 As shown, in one embodiment, before storing the data of the IoT card that executes the consumer service function into the database, the method may further include steps S510-S570.

[0161] S510: Acquire data of the IoT card that can be put into storage.

[0162] After the IoT card completes the consumer service function, in order to achieve effective management and storage of the IoT card data and ensure data integrity, security and consistency, the IoT card data needs to be stored in the database. Therefore, the IoT card data is first obtained, which includes the data after the IoT card completes the consumer service function.

[0163] S520: Obtain the message update timestamp in the data of the IoT card.

[0164] The timestamp of the message update is obtained from the IoT card data after the consumer service function is executed. This timestamp is usually automatically generated when the IoT card completes the consumer service function, and represents the specific time when the consumer service action is completed.

[0165] S530: Whether the database includes a database update timestamp.

[0166] Check whether there is already an update timestamp in the database. This database update timestamp represents the specific time when data was last successfully stored in the database.

[0167] S540: The message update timestamp is smaller than the database update timestamp.

[0168] If the update timestamp already exists in the database, compare the database update timestamp with the message update timestamp to determine whether the database update timestamp is less than the message update timestamp.

[0169] S550: discard the message data.

[0170] If the message update timestamp is less than the database update timestamp, it means that the data in the database is already the latest. At this time, the data of the IoT card that has completed the consumer service function cannot be stored in the database, and the message data in the IoT card data is discarded.

[0171] S560: Store the data of the IoT card in the database.

[0172] If the timestamp of the message update is greater than or equal to the database update timestamp, it means that there is new data to be stored, and the data of the IoT card that completes the consumer service function is stored in the database.

[0173] S570: Update the database.

[0174] When there is no update timestamp in the database, it means that this is the first time to store data or the timestamp in the database has been cleared. Update the database and generate a data update timestamp after the database is updated; or

[0175] After the data of the IoT card that has completed the consumer service function is stored in the database, the database is updated.

[0176] In the embodiment of the present application, by introducing a timestamp comparison mechanism, effective management and updating of IoT card data is achieved, the real-time performance of the data is improved, invalid operations are reduced, database consistency is maintained, and the stability of the system is enhanced.

[0177] like Figure 6 As shown in FIG. 1 , it is a schematic diagram of a system for controlling the consistency of IoT data provided by an embodiment of the present application. Figure 6 As shown, the system includes a data queue layer, a data consumption layer and a data storage layer.

[0178] Among them, the data queue layer includes a source data queue and a delayed data queue. The source data queue includes the IoT card source data received by the system when the IoT card sends a consumption request to the system. These source data cover the user's consumption record and IoT card number, etc. The consumption record can specifically include the time of the IoT card consumption record and the corresponding consumption identifier; the delayed data queue includes the IoT card source data that is delayed to avoid concurrent consumption, that is, when it is judged that there is a consumption identifier at the preset time of the consumption record in the IoT card source data, that is, when the IoT card has a consumption service within the preset time, it is necessary to delay the preset time and re-judge the consumption request of the IoT card based on the IoT card data. The data queue layer is used to send the acquired source data and the IoT card source data after the preset time delay to the data consumption layer.

[0179] Data consumption layer, the data consumption layer includes data consumption service, concurrency control service, timing scheduling service and registration center. The concurrency control service is used to store the consumption record of the IoT card and expand the scale of the concurrency control service according to the scale of the IoT card and its request when the IoT card sends a consumption request to the system, and use the concurrency control service node allocated by the IoT card to judge whether the preset time of the consumption record of the IoT card includes the corresponding target value, that is, to judge whether the IoT card performs consumption service within the preset time. The data consumption service is used to execute the consumption service function of the IoT card and consume the data of the IoT card when there is no consumption service at the preset time of the consumption record of the data from the source data queue and the delayed data queue, that is, when the IoT card does not perform other consumption services. The timing scheduling service deletes or resets the bitmap data of the consumption record before the time of the consumption record represented by the first preset key at a predetermined time or period, that is, the data that is not needed in the data consistency control process. The registration center is used to provide service discovery capabilities for each service in the data consumption layer to facilitate communication scheduling between services. The RPC (Remote Procedure Call) communication protocol is used in the data consumption layer to improve the interface response efficiency. The data consumption layer is used to receive data from the data queue layer and send the data of the IoT card that has passed the consumption service to the data storage layer.

[0180] The data storage layer includes relational databases and non-relational databases. The data storage layer is used to store the received IoT card data persistently in the database system. In order to adapt to different data application scenarios, the received IoT card data can be stored in a relational database or a non-relational database.

[0181] like Figure 7 As shown, in one embodiment, the provided IoT data consistency control method includes steps S710-S750:

[0182] S710: IoT card source data.

[0183] When a user sends a consumption request to the system through an IoT card, the system will receive the IoT card source data. These IoT card source data are placed in the source data queue, and then sent to the concurrency control service to determine how to process the IoT card consumption request. These data cover the user's consumption records, which can specifically include: the time of the consumption record of the IoT card and the corresponding consumption identifier and consumption scene. In order to efficiently store and query consumption records, a bitmap data structure format and rules are used to store the consumption record, and the consumption record is represented by a key-value pair of the bitmap data structure. The key represents the time of the consumption record, that is, the unit time in the IoT card data, and the value represents the consumption identifier of the consumption record, that is, the consumption identifier corresponding to the unit time in the IoT card data. Each key-value pair represents the time of the consumption record represented by this key in the consumption record and the corresponding consumption identifier.

[0184] S720: Determine whether the IoT card has been used recently.

[0185] In order to improve the processing efficiency and scalability of the system, the requests of different IoT cards are distributed to different concurrent control services. The scale of concurrent control services is expanded according to the scale of IoT cards and their requests, the memory pressure of a single service is reduced, and the high availability of the entire service system is improved. The concurrent control service node allocated to the IoT card is used to judge whether a preset key of the consumption record of the IoT card includes the corresponding target value. The preset key can be a time point or a time period, that is, a time point or a time period of the consumption record of the IoT card. The consumption identifier of the consumption record is the target value corresponding to the preset key of the consumption record to be judged whether it is included, that is, whether a time point or a time period of the consumption record of the IoT card includes the consumption identifier of the consumption record.

[0186] For example, Figure 3As shown, in the consumption record created with the unit time in the data of the IoT card as the key and the consumption identifier corresponding to the unit time in the data of the IoT card as the value, the unit time is minutes, the number represents the minute of the current time, the T period is the current period, 01 minutes is the T period, 00 minutes is the T-1 period, 02 minutes is the T+1 period, and so on, and other periods are not described in detail here. The first preset key can be the T-1 to T period. When judging whether the first preset key of the consumption record includes the corresponding target value, that is, judging whether the T-1 to T period of the consumption record includes the corresponding target value, when the value corresponding to the T-1 to T period of the consumption record is 1, it can be regarded that the T-1 to T period of the consumption record includes the corresponding target value, that is, there is a consumption identifier, and there is consumption at the preset time of the IoT card. When the value corresponding to the T-1 to T period of the consumption record is 0, it can be regarded that the T-1 to T period of the consumption record does not include the corresponding target value, that is, there is no consumption identifier, and there is no consumption at the preset time of the IoT card.

[0187] S730: The IoT card has been used for consumption recently.

[0188] When the judgment result is that the first preset key of the consumption record of the IoT card includes the corresponding target value, that is, when the first preset key of the consumption record of the IoT card contains a consumption identifier, that is to say, the IoT card has performed consumption services during the period covered by the first preset key, which means that the IoT card cannot perform consumption services during the current period. At this time, the data of the IoT card is put into the delayed data queue, and after the preset delay time, the consumption request of the IoT card is re-judged based on the data of the IoT card. Exemplarily, the preset delay time can be 3 minutes.

[0189] S740: The IoT card has not been used recently.

[0190] When the judgment result is that the first preset key of the consumption record of the IoT card does not include the corresponding target value, that is, when the first preset key of the consumption record of the IoT card does not have a consumption identifier, that is, the IoT card has not performed consumption services during the period covered by the first preset key, which means that the IoT card can perform consumption services during the current period. In response to the consumption request of the IoT card, the consumption service function of the IoT card is executed.

[0191] S750: delayed IoT card data.

[0192] After a preset time, the delayed data of the IoT card is sent to the concurrency control service again by using the delay queue to determine how to process the consumption request of the IoT card. The process of determining the data of the IoT card by using the concurrency control service is as shown in steps S720 to S740.

[0193] S760: stores data of the IoT card.

[0194] After the IoT card has completed its consumer service function, the data of the IoT card is persistently stored in the database system. The database management system (DBMS) provides a mechanism for storing, retrieving, updating and deleting data. The data of the IoT card can be retrieved and used when needed.

[0195] Based on the same concept, the embodiment of the present application provides an IoT data consistency control device, which is applied to IoT devices in an IoT system; Figure 8 The Internet of Things data consistency control device provided in the embodiment of the present application is described in detail.

[0196] Figure 8 The present invention is a structural block diagram of a data consistency control device for an Internet of Things according to an exemplary embodiment.

[0197] like Figure 8 As shown, the IoT data consistency control device may include:

[0198] The acquisition module 810 is used to acquire data of the IoT card, the data including consumption records, the consumption records are stored in a bitmap data structure, and the bitmap data structure is represented in a key-value manner, wherein the key represents the time of the consumption record and the value represents the consumption identifier of the consumption record;

[0199] A determination module 820 is used to determine whether the first preset key of the consumption record of the IoT card includes the corresponding target value by using the target node corresponding to the IoT card;

[0200] An adding module 830 is used to add a target identifier to the IoT card when the first preset key of the consumption record does not include a corresponding target value, and the target identifier is used to indicate that the IoT card has enabled a consumption service function;

[0201] The judgment module 820 is further configured to judge whether the second preset key of the consumption record includes the corresponding target value when the first preset key of the consumption record includes the corresponding target value; the time of the consumption record represented by the second preset key is after the time of the consumption record represented by the first preset key;

[0202] The adding module 830 is also used to add a target identifier to the IoT card when the second preset key of the consumption record does not include the corresponding target value.

[0203] In one embodiment, the acquisition module 810 is further used to create a consumption record after acquiring the data of the IoT card, with the unit time in the data as the key and the consumption identifier corresponding to the unit time in the data as the value.

[0204] In one embodiment, the data also includes the IoT card number, and the judgment module 820 is also used to calculate the hash value of the IoT card number before using the target node corresponding to the IoT card to determine whether the first preset key of the consumption record of the IoT card includes the corresponding target value; map the concurrent control service node to the hash ring; determine the hash value interval where the hash value is located on the hash ring; determine the node corresponding to the hash value in the hash value interval, and use the node as the target node.

[0205] In one embodiment, the judgment module 820 is also used to detect the exclusive lock of the target node corresponding to the Internet of Things card within a set time before using the target node corresponding to the Internet of Things card to determine whether the first preset key of the consumption record of the Internet of Things card includes the corresponding target value; when the exclusive lock of the target node corresponding to the Internet of Things card is detected within the set time, it is determined whether the first preset key of the consumption record includes the corresponding target value.

[0206] In one embodiment, the judgment module 820 is also used to judge whether the third preset key of the consumption record includes the corresponding target value when the exclusive lock of the target node corresponding to the Internet of Things card is not detected within the set time; the time of the consumption record represented by the third preset key is after the time of the consumption record represented by the first preset key.

[0207] In one embodiment, the Internet of Things data consistency control device may further include: a cleaning module, which is used to periodically clean up the bitmap data of the consumption record before the time of the consumption record represented by the first preset key.

[0208] In one embodiment, the IoT data consistency control device may further include: a storage module, the storage module being used to store the data of the IoT card that has completed the consumption service in a database after adding a target identifier to the IoT card.

[0209] In one embodiment, the storage module is also used to obtain the timestamp of the message update that completes the consumption function before storing the data of the Internet of Things card that completes the consumption function in the database; when the database does not include the database update timestamp, update the database; when the database includes the database update timestamp: when the timestamp of the message update is greater than or equal to the database update timestamp, store the data of the Internet of Things card that completes the consumption service function in the database.

[0210] Figure 8 Each module in the device shown has the function of realizing Figure 2 , Figure 4 and Figure 7 The functions of each step in the process can achieve the corresponding technical effects, which will not be described in detail here for the sake of brevity.

[0211] Fig. 9A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application is shown.

[0212] The electronic device may include a processor 910 and a memory 920 storing computer program instructions.

[0213] Specifically, the processor 910 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.

[0214] The memory 920 may include a large capacity memory for data or instructions. By way of example and not limitation, the memory 920 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In appropriate cases, the memory 920 may include a removable or non-removable (or fixed) medium. In appropriate cases, the memory 920 may be inside or outside the integrated gateway disaster recovery device. In a specific embodiment, the memory 920 is a non-volatile solid-state memory.

[0215] The memory may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk storage medium device, an optical storage medium device, a flash memory device, an electrical, optical or other physical / tangible memory storage device. Therefore, generally, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., a memory device) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to one aspect of the present disclosure.

[0216] The processor 910 implements any one of the IoT data consistency control methods in the above embodiments by reading and executing computer program instructions stored in the memory 920.

[0217] In one example, the electronic device may further include a communication interface 930 and a bus 940. As shown in FIG9 , the processor 910, the memory 920, and the communication interface 930 are connected via the bus 940 and communicate with each other.

[0218] The communication interface 930 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiments of the present application.

[0219] Bus 940 includes hardware, software or both, and the parts of online data flow billing equipment are coupled to each other. For example, but not limitation, bus may include accelerated graphics port (AGP) or other graphics bus, enhanced industrial standard architecture (EISA) bus, front-side bus (FSB), hypertransport (HT) interconnection, industrial standard architecture (ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral component interconnection (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In appropriate cases, bus 910 may include one or more buses. Although the present application embodiment describes and shows a specific bus, the application considers any suitable bus or interconnection.

[0220] The electronic device can execute the Internet of Things data consistency control method in the embodiment of the present application, thereby realizing the combination Figure 2 , Figure 4 and Figure 7 The invention describes a method and device for controlling consistency of Internet of Things data.

[0221] In addition, in combination with the IoT data consistency control method in the above embodiment, the embodiment of the present application can provide a computer storage medium for implementation. The computer storage medium stores computer program instructions; when the computer program instructions are executed by the processor, any IoT data consistency control method in the above embodiment is implemented.

[0222] An embodiment of the present application also provides a computer program product, including a computer program, which, when executed, implements any one of the methods for controlling Internet of Things data consistency in the above embodiments.

[0223] It should be clear that the present application is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present application is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present application.

[0224] The functional blocks shown in the above-described block diagram can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present application are programs or code segments that are used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link by a data signal carried in a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, etc. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.

[0225] It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. However, this application is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiment, or in a different order from the embodiment, or several steps can be performed simultaneously.

[0226] Aspects of the present disclosure are described above with reference to the flowchart and / or block diagram of the method, device (system) and computer program product according to the embodiment of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device to produce a machine so that these instructions executed by the processor of the computer or other programmable data processing device enable the implementation of the function / action specified in one or more boxes of the flowchart and / or block diagram. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field programmable logic circuit. It can also be understood that each box in the block diagram and / or flowchart and the combination of boxes in the block diagram and / or flowchart can also be implemented by dedicated hardware that performs a specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions.

[0227] The above is only a specific implementation of the present application. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. It should be understood that the protection scope of the present application is not limited to this. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in this application, and these modifications or replacements should be included in the protection scope of this application.

Claims

1. A method for controlling consistency of Internet of Things data, characterized in that: include: Acquire data of the IoT card, the data including consumption records, the consumption records are stored in a bitmap data structure, the bitmap data structure is represented in a key-value manner, wherein the key represents the time of the consumption record, and the value represents the consumption identifier of the consumption record; Using the target node corresponding to the IoT card, determining whether the first preset key of the consumption record of the IoT card includes the corresponding target value; In the case where the first preset key of the consumption record does not include the corresponding target value, adding a target identifier to the IoT card, wherein the target identifier is used to indicate that the IoT card has enabled a consumption service function; In the case where the first preset key of the consumption record includes the corresponding target value, determining whether the second preset key of the consumption record includes the corresponding target value; the time of the consumption record represented by the second preset key is after the time of the consumption record represented by the first preset key; When the second preset key of the consumption record does not include the corresponding target value, the target identifier is added to the IoT card.

2. The method according to claim 1, characterized in that After obtaining the data of the IoT card, the method further includes: The consumption record is created with the unit time in the data as the key and the consumption identifier corresponding to the unit time in the data as the value.

3. The method according to claim 1, characterized in that The data also includes an IoT card number; before using the target node corresponding to the IoT card to determine whether the first preset key of the consumption record of the IoT card includes the corresponding target value, the method also includes: Calculate the hash value of the IoT card number; Map concurrency control service nodes to hash rings; Determine, on the hash ring, a hash value interval in which the hash value is located; A node corresponding to the hash value is determined in the hash value interval, and the node is used as the target node.

4. The method according to claim 3, characterized in that Before using the target node corresponding to the IoT card to determine whether the first preset key of the consumption record of the IoT card includes the corresponding target value, the method further includes: Detecting the exclusive lock of the target node corresponding to the IoT card within a set time; When an exclusive lock of the target node corresponding to the IoT card is detected within a set time, it is determined whether the first preset key of the consumption record includes the corresponding target value.

5. The method according to claim 4, characterized in that The method further comprises: If the exclusive lock of the target node corresponding to the IoT card is not detected within the set time, Determine whether the third preset key of the consumption record includes a corresponding target value; the time of the consumption record represented by the third preset key is after the time of the consumption record represented by the first preset key.

6. The method according to claim 2, characterized in that The method further comprises: The bitmap data of the consumption record before the time of the consumption record represented by the first preset key is cleaned up regularly.

7. The method according to claim 1, characterized in that After adding the target identifier to the IoT card, the method further includes: The data of the IoT card that has completed the consumption service is stored in the database.

8. The method according to claim 7, characterized in that Before storing the data of the IoT card that has completed the consumption function in the database, the method further includes: obtaining a timestamp of an update of the message that has completed the consumption function; When the database does not include a database update timestamp, updating the database; When the database includes a database update timestamp: when the timestamp of the message update is greater than or equal to the database update timestamp, the data of the IoT card that executes the consumer service function is stored in the database.

9. An IoT data consistency control device, characterized in that: The device comprises: An acquisition module is used to acquire data of the IoT card, wherein the data includes consumption records, and the consumption records are stored in a bitmap data structure, and the bitmap data structure is represented in a key-value manner, wherein the key represents the time of the consumption record, and the value represents the consumption identifier of the consumption record; A judgment module, used to judge whether the first preset key of the consumption record of the IoT card includes the corresponding target value by using the target node corresponding to the IoT card; An adding module, configured to add a target identifier to the IoT card when the first preset key of the consumption record does not include a corresponding target value, wherein the target identifier is used to indicate that the IoT card has enabled a consumption service function; The judgment module is further configured to judge whether the second preset key of the consumption record includes the corresponding target value when the first preset key of the consumption record includes the corresponding target value; the time of the consumption record represented by the second preset key is after the time of the consumption record represented by the first preset key; The adding module is further configured to add the target identifier to the IoT card when the second preset key of the consumption record does not include the corresponding target value.

10. An electronic device, characterized in that: The device comprises: a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, the method for controlling Internet of Things data consistency as described in any one of claims 1 to 8 is implemented.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by the processor, the method for controlling Internet of Things data consistency according to any one of claims 1 to 8 is implemented.

12. A computer program product, characterized in that When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes the Internet of Things data consistency control method as described in any one of claims 1 to 8.