Electricity charge calculation method and device, computer equipment and storage medium

By combining message queue Kafka, streaming computing engine Flink and Redis cluster, an efficient and scalable real-time electricity bill calculation system is built, which solves the problem of high latency of traditional electricity bill calculations and realizes the high timeliness and complex computing requirements of electricity bill calculations.

CN120258920APending Publication Date: 2025-07-04GUANGDONG ELECTRIC POWER COMM CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510378556.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-28
Publication Date
2025-07-04

AI Technical Summary

Technical Problem

When traditional electricity bill calculation mode processes large-scale data sets, there are scenarios where processing delays are high and cannot meet the requirements of real-time.

Method used

The message queue Kafka is used to obtain electricity bill metering data, calculate electricity bills through the streaming calculation engine Flink, and store the results in the Redis cluster. It uses multi-threaded concurrent processing and partitioning characteristics to build an efficient and scalable real-time electricity bill computing system.

Benefits of technology

It realizes the second-level update of the electricity bill calculation results, which is suitable for real-time electricity bill monitoring and dynamic electricity price adjustment scenarios, can process massive data and ensure the accuracy and efficiency of the calculation results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120258920A_ABST
    Figure CN120258920A_ABST
Patent Text Reader

Abstract

The invention relates to an electric charge calculation method and device, computer equipment and a storage medium. The method comprises the following steps: acquiring electricity charge metering data based on a message queue Kafka to obtain an electricity charge metering message; wherein the electricity charge metering message comprises a user identifier, electricity consumption and electricity consumption time; the electricity charge metering message is consumed based on a streaming computation engine Flink, electricity charge calculation is carried out, and an electricity charge calculation result is obtained; and the electric charge calculation result is stored in a Redis cluster through a stream-oriented calculation engine Flink. According to the electric charge calculation method provided by the invention, an efficient and extensible real-time electric charge calculation system can be formed by fusing the message queue Kafka, the streaming calculation engine Flink and the Redis cluster and using the multi-thread concurrent processing and partition characteristics, so that the requirements of high timeliness and complex calculation of electric charge calculation are met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of electricity bill calculation, and particularly to an electricity bill calculation method, device, computer device, and storage medium. Background Art

[0002] With the development of power technology, the number of users has gradually increased, and the requirements for electricity bill calculation have also become higher and higher. In traditional technologies, when calculating electricity bills, it is usually based on a batch calculation mode, that is, first collect data, store it in a database, and then take it out for analysis. However, in dealing with large-scale data sets, this mode may have a high processing delay due to the limitations of data reading and writing efficiency and computing resources, and cannot meet scenarios with high real-time requirements. Summary of the Invention

[0003] Based on this, it is necessary to provide an electricity bill calculation method, device, computer device, and storage medium with high real-time performance for the above technical problems.

[0004] In a first aspect, this application provides an electricity bill calculation method. The method includes: obtaining electricity consumption measurement data based on the message queue Kafka to obtain an electricity consumption measurement message; wherein, the electricity consumption measurement message includes: user identification, electricity consumption, and electricity consumption time; consuming the electricity consumption measurement message by a streaming computing engine Flink and performing electricity bill calculation to obtain an electricity bill calculation result; storing the electricity bill calculation result in a Redis cluster through the streaming computing engine Flink.

[0005] In one embodiment, before the step of obtaining electricity consumption measurement data based on the message queue Kafka, the method further includes: obtaining initial measurement data from the Redis cluster; performing data verification on the initial measurement data through a microservice to obtain the electricity consumption measurement data.

[0006] In one embodiment, the step of consuming the electricity consumption measurement message by a streaming computing engine Flink and performing electricity bill calculation includes: obtaining an electricity bill operator through the streaming computing engine Flink; wherein, the electricity bill operator includes: keyed state and operator state; performing electricity bill calculation on the electricity consumption measurement message based on the electricity bill operator.

[0007] In one embodiment, the message queue Kafka includes multiple server nodes Broker, and each server node Broker includes multiple message partitions, and the electricity consumption measurement message is stored in multiple message partitions in the form of messages.

[0008] In one embodiment, the streaming computing engine Flink includes multiple task slots, and each task slot is used to perform an electricity charge calculation task.

[0009] In one embodiment, the number of message partitions of the message queue Kafka is equal to the number of task slots of the streaming computing engine Flink.

[0010] In one embodiment, the method further includes: obtaining performance metrics of the streaming computing engine Flink; where the performance metrics include: throughput, latency, and resource utilization rate; and adjusting the parallelism of the streaming computing engine Flink based on the performance metrics.

[0011] In a second aspect, the present application also provides an electricity charge calculation device. The device includes: a message acquisition module, configured to obtain electricity charge measurement data based on the message queue Kafka to obtain an electricity charge measurement message; where the electricity charge measurement message includes: user identification, electricity consumption, and power consumption time; an electricity charge calculation module, configured to consume the electricity charge measurement message based on the streaming computing engine Flink and perform electricity charge calculation to obtain an electricity charge calculation result; and a result storage module, configured to store the electricity charge calculation result in a Redis cluster through the streaming computing engine Flink.

[0012] In a third aspect, the present application also provides a computer device. The computer device includes a memory and a processor, the memory stores a computer program, and when the processor executes the computer program, the steps of the above method are implemented.

[0013] In a fourth aspect, the present application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, and when the computer program is executed by a processor, the steps of the above method are implemented.

[0014] The above electricity charge calculation method, device, computer device, and storage medium obtain electricity charge measurement data through the message queue Kafka to obtain an electricity charge measurement message, then consume the electricity charge measurement message based on the streaming computing engine Flink and perform electricity charge calculation to obtain an electricity charge calculation result, and finally store the electricity charge calculation result in a Redis cluster through the streaming computing engine Flink, which is convenient for users to query in real time. The electricity charge calculation method of the present application can form an efficient and scalable real-time electricity charge calculation system by integrating the message queue Kafka, the streaming computing engine Flink, and the Redis cluster, and using its multi-threaded concurrent processing and partitioning characteristics, so as to meet the high timeliness requirements of electricity charge calculation and complex calculation needs. Description of the Drawings

[0015] Figure 1 It is an application environment diagram of the electricity bill calculation method in an embodiment;

[0016] Figure 2 It is a schematic flow diagram of the electricity bill calculation method in an embodiment;

[0017] Figure 3 It is a schematic flow diagram of obtaining electricity bill measurement data in an embodiment;

[0018] Figure 4 It is a schematic flow diagram of calculating the electricity bill in an embodiment;

[0019] Figure 5 It is a schematic diagram of the electricity bill calculation architecture in an embodiment;

[0020] Figure 6 It is a schematic flow diagram of adjusting the parallelism in an embodiment;

[0021] Figure 7 It is a schematic module diagram of the electricity bill calculation device in an embodiment;

[0022] Figure 8 It is the internal structure diagram of a computer device in an embodiment. Specific Embodiments

[0023] In order to make the objectives, technical solutions and advantages of this application clearer, the following further elaborates on this application in combination with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not used to limit this application.

[0024] First, several terms involved in this application are parsed:

[0025] Kafka: It is a high-performance distributed stream processing platform used to build real-time data pipelines and streaming applications. As a message middleware, it supports producers to publish messages and consumers to subscribe to messages to achieve system decoupling, and it can provide streaming data processing capabilities, supporting operations such as real-time aggregation, transformation, and window calculation.

[0026] Flink: It is a distributed stream processing framework used to build stateful real-time stream applications. As the core of stream processing, it can consume data from message queues such as Kafka and perform real-time logical calculations.

[0027] Redis: It is an open-source in-memory data structure storage system with the advantages of high performance and low latency. It is widely used in scenarios such as real-time data caching, message queues, and distributed locks. It can store the real-time calculation results of computing engines such as Flink for front-end applications to quickly query.

[0028] The electricity bill calculation method provided by the embodiments of this application can be applied to an application environment as Figure 1 shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or placed in the cloud or other network servers. The server 104 integrates the message queue Kafka, the streaming computing engine Flink, and the Redis cluster to calculate the electricity bill and store the electricity bill calculation result. The terminal 102 can obtain the electricity bill calculation result from the server 104. Among them, the terminal 102 can be, but is not limited to, various personal computers, laptop computers, smart phones, tablet computers, Internet of Things devices, and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, etc. The portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 104 can be implemented by an independent server or a server cluster composed of multiple servers.

[0029] In one embodiment, as Figure 2 shown, a method for calculating the electricity bill is provided. Taking the server 104 in Figure 1 as an example, the method includes the following steps:

[0030] Step S210, obtain electricity consumption measurement data based on the message queue Kafka to obtain an electricity consumption measurement message.

[0031] Specifically, in the process of calculating the electricity bill, the server 104 first obtains the electricity consumption measurement data based on the message queue Kafka and stores it, so as to obtain an electricity consumption measurement message. Among them, the electricity consumption measurement message includes: user identification, electricity consumption, power consumption time, etc. The message queue Kafka, as a real-time data pipeline, can obtain electricity consumption measurement data from various data sources such as Internet of Things devices, databases, and microservices, and partition and store it to obtain an electricity consumption measurement message. In the electricity consumption measurement message, the user identification can be the user ID or the electricity meter number; the electricity consumption is the electricity consumption collected by the electricity meter; the power consumption time can be accurate to the timestamp to support the real-time calculation of the electricity bill in the subsequent steps. The message queue Kafka has high throughput and persistence characteristics, ensuring the reliable transmission of data and being able to stably receive electricity consumption measurement data even in high-concurrency scenarios.

[0032] Step S220, consume the electricity consumption measurement message based on the streaming computing engine Flink and perform electricity bill calculation to obtain an electricity bill calculation result.

[0033] Specifically, the streaming computing engine Flink can consume the electricity charge measurement messages in the message queue Kafka in real time. The streaming computing engine Flink can associate the electricity price policy (such as time-of-use electricity price, ladder electricity price, etc.) according to the user identification, and combine the electricity consumption and the electricity usage time to calculate the electricity charge, so as to obtain the electricity charge calculation result. In some embodiments, the streaming computing engine Flink can also support the dynamic loading of complex rules (such as peak-valley electricity price, seasonal adjustment). The streaming computing engine Flink has the capabilities of event-level processing and state management, which can ensure the output of the electricity charge calculation result with low latency.

[0034] Step S230, store the electricity charge calculation result in the Redis cluster through the streaming computing engine Flink.

[0035] Specifically, after the streaming computing engine Flink calculates the electricity charge calculation result, it stores the electricity charge calculation result in the Redis cluster. When the Redis cluster stores the electricity charge calculation result, it can use the user identification as the key and the electricity charge data as the value for data storage. The Redis cluster has high-performance read and write capabilities, and it supports fast query and subsequent business processing (such as bill generation, user notification, etc.).

[0036] The above electricity charge calculation method realizes end-to-end low-latency processing by integrating the message queue Kafka and the streaming computing engine Flink, enabling the electricity charge calculation result to be updated within seconds, and can be applied to scenarios that require real-time electricity charge monitoring or dynamic electricity price adjustment. At the same time, the message queue Kafka supports horizontal expansion and can process a large amount of electricity charge measurement data. The distributed computing capabilities of the streaming computing engine Flink can handle complex calculation logics and the calculation of large-scale data streams. The Redis cluster can provide high availability and sharded storage, thus ensuring the reliability of the data. The electricity charge calculation method of the present application, by integrating the message queue Kafka, the streaming computing engine Flink and the Redis cluster, and using its multi-threaded concurrent processing and partitioning characteristics, can form an efficient and scalable real-time electricity charge calculation system, so as to meet the high timeliness requirements of electricity charge calculation and the needs of complex calculations.

[0037] In one embodiment, as Figure 3 shown, before the step of obtaining the electricity charge measurement data based on the message queue Kafka, the electricity charge calculation method further includes:

[0038] Step S240, obtain the initial measurement data from the Redis cluster.

[0039] Specifically, in this embodiment, the electricity charge measurement data obtained by the message queue Kafka is retrieved from the database. The Redis cluster can obtain data from electricity meters or metering devices to obtain the initial measurement data. The initial measurement data also includes: user identification, power consumption, power consumption time, etc.

[0040] Step S250, perform data verification on the initial measurement data through a microservice to obtain the electricity charge measurement data.

[0041] Specifically, after obtaining the initial measurement data from the Redis cluster, a pre-designed microservice (such as a Spring Boot application) is used to perform data verification on the initial measurement data, thereby obtaining the processed electricity charge measurement data. In some embodiments, the data verification performed by the preset microservice may include: data integrity check (such as whether a field is missing), data range check (such as whether the power consumption is negative), timestamp rationality check (such as whether the recording time is in the future), electricity meter status check (such as whether it is in an abnormal state), etc. In this embodiment, by setting up a microservice to perform data verification, the accuracy of the electricity charge measurement data can be ensured, and incorrect data can be prevented from entering the subsequent calculation process.

[0042] In one embodiment, as Figure 4 shown, in step S220, the steps of consuming the electricity charge measurement message and performing electricity charge calculation based on the streaming computing engine Flink include:

[0043] Step S221, obtain the electricity charge operator through the streaming computing engine Flink.

[0044] Specifically, during the process of performing electricity charge calculation by the streaming computing engine Flink, the electricity charge operator is first obtained. The electricity charge operator includes: keyed state and operator state. The electricity charge operator manages the state information in the calculation process through the keyed state and operator state, thereby achieving efficient and accurate electricity charge calculation. The keyed state is used to store the state information associated with a specific key (such as user ID), such as the cumulative power consumption of the user, the last electricity charge calculation time, etc. The operator state is used to store the global state information related to the operator instance, such as the global electricity price policy, system configuration parameters, etc. In some embodiments, the keyed state includes: value state, used to store a single value, such as cumulative power; list state, used to store a list, such as historical power consumption records; map state, used to store key-value pairs, such as the costs of different electricity price brackets; aggregation state, used to automatically aggregate data, such as the total cost.

[0045] Step S222, perform electricity charge calculation on the electricity charge measurement message based on the electricity charge operator.

[0046] Specifically, after obtaining the electricity fee operator, the electricity fee calculation is performed on the electricity fee measurement message based on the obtained electricity fee operator. In some embodiments, first, the data is keyed (KeyBy) according to the user ID to ensure that the data of the same user is routed to the same operator instance. Then, the keyed state is used to store and update the cumulative electricity consumption of the user, and the operator state is used to obtain the global electricity price policy. Finally, the real-time electricity consumption and the electricity price policy are combined to perform the electricity fee calculation and obtain the electricity fee calculation result. In this embodiment, the electricity fee operator including the keyed state and the operator state obtained by the streaming computing engine Flink can efficiently manage the state information in the user dimension and the global dimension, realize real-time and accurate electricity fee calculation, and is applicable to various complex electricity fee calculation scenarios.

[0047] In one embodiment, as Figure 5 shown, the message queue Kafka includes multiple server nodes Broker, and each server node Broker includes multiple message partitions. The electricity fee measurement message is stored in multiple message partitions in the form of messages. Specifically, the server nodes Broker and the message partitions in the message queue Kafka are core components, which directly affect the storage, distribution, and consumption efficiency of messages. The server node Broker is an independent server node in the message queue Kafka, which is used to store message partitions and process the requests of producers and consumers. The data of each message partition is replicated to multiple server nodes Broker. By setting multiple server nodes Broker to disperse the processing of client requests, single-point overload can be avoided. And multiple server nodes Broker support higher concurrent requests and are more suitable for the data stream generated in real-time electricity fee calculation. The message partition is the basic unit for storing the electricity fee measurement message. Different message partitions can be written and read in parallel to improve the throughput. The electricity fee measurement message can be dispersed and stored in the message partitions on different server nodes Broker to avoid a single partition becoming a performance bottleneck and improve the overall throughput of the system. In this embodiment, for the storage requirement of the electricity fee measurement message, the message queue Kafka is set to an architecture with multiple server nodes Broker and multiple message partitions, so as to achieve high throughput, high availability, and horizontal scalability.

[0048] In one embodiment, as Figure 5As shown in the figure, the streaming computing engine Flink includes multiple task slots, and each task slot is used to perform an electricity bill calculation task. Specifically, the task slot (Task Slot) in the streaming computing engine Flink is the core unit of resource allocation, which affects the parallelism of tasks and resource utilization. Each subtask occupies a task slot, and the parallelism of the streaming computing engine Flink can determine the allocation method of task slots, that is, determine the number of parallel instances of the Flink job of the streaming computing engine. In this embodiment, by setting one task slot to perform one electricity bill calculation task, the performance of the electricity bill calculation task can be guaranteed, and it is more suitable for the resource-intensive task of electricity bill calculation.

[0049] In one embodiment, the number of message partitions of the message queue Kafka is equal to the number of task slots of the streaming computing engine Flink. Specifically, in this embodiment, each message partition in the message queue Kafka corresponds to a task slot of the streaming computing engine Flink, that is, corresponds to an electricity bill calculation task, so that the message partitions and task slots correspond one by one, making full use of resources, and the messages in the same partition are processed by the same computing task, maintaining the order of messages. For a specific example, the number of message partitions of the message queue Kafka is set to 100, and correspondingly, the number of task slots of the streaming computing engine Flink is also set to 100. In some other embodiments, the number of message partitions of the message queue Kafka can also be set to be greater than or less than the number of task slots of the streaming computing engine Flink, that is, the data in multiple message partitions is processed by the electricity bill calculation task in one task slot, or the data in one message partition is processed by the electricity bill calculation tasks in multiple task slots.

[0050] In one embodiment, as Figure 6 shown, the electricity bill calculation method further includes the following steps:

[0051] Step S310, obtain the performance metrics of the streaming computing engine Flink;

[0052] Step S320, adjust the parallelism of the streaming computing engine Flink based on the performance metrics.

[0053] Specifically, in this embodiment, during the process of electricity cost calculation by the streaming computing engine Flink, the parallelism will be adjusted in real time according to the performance metrics of the streaming computing engine Flink to optimize the performance of the streaming computing engine Flink. The parallelism of the streaming computing engine Flink refers to the number of instances in which Flink tasks run simultaneously in the cluster. Increasing the parallelism can improve the processing capacity of tasks, but at the same time, it will also increase resource competition and communication overhead. The performance metrics of the streaming computing engine Flink include: throughput, latency, and resource utilization rate. Among them, the throughput usually increases with the increase in parallelism because more task instances can process more data simultaneously. However, when the parallelism exceeds a certain threshold, the throughput may no longer increase significantly and may even decrease. The latency usually decreases with the increase in parallelism because more task instances can process data faster. However, when the parallelism is too high, the latency may no longer decrease significantly and may even increase. The resource utilization rate usually increases with the increase in parallelism. However, when the parallelism is too high, the resource utilization rate may approach or exceed the capacity of the cluster, resulting in resource competition and task waiting.

[0054] In this embodiment, when obtaining the performance metrics of the streaming computing engine Flink, the monitoring tools of Flink (such as Flink Web UI, Metrics system) can be used to collect metrics such as throughput, latency, and resource utilization rate, so as to analyze whether there are bottlenecks or resource waste in the streaming computing engine Flink. When adjusting the parallelism of the streaming computing engine Flink based on the performance metrics, the balance point can be found among throughput, latency, and resource utilization rate by gradually increasing or decreasing the parallelism, so that the overall performance of the streaming computing engine Flink is optimal. For example, if the current throughput is low or the latency is high, the parallelism can be increased and the changes in throughput, latency, and resource utilization rate can be observed; if the current resource utilization rate is too high or the throughput no longer increases significantly, the parallelism can be decreased and the changes in resource utilization rate and throughput can be observed.

[0055] Specific example: When the Flink streaming computing engine calculates electricity bills, its initial parallelism is 4. Among the obtained performance metrics, the throughput is 1000 Records / sec, the latency is 50 ms, and the resource utilization rate (CPU utilization rate) is 60%. Through evaluation, it is determined that there is room for improvement in throughput and the latency can also be further reduced. At this time, the parallelism is first increased to 8. After the parallelism is adjusted to 8, the throughput increases to 1800 Records / sec, the latency decreases to 30 ms, and the resource utilization rate increases to 75%. Therefore, the parallelism is continued to be increased to 12. At this time, the throughput increases to 1900 Records / sec, the latency decreases to 25 ms, and the resource utilization rate increases to 90%. In this case, although the throughput is still increasing, the increase amplitude becomes smaller, and the decrease amplitude of the latency also becomes smaller, but the resource utilization rate is already relatively high. Therefore, the parallelism of 8 or 12 can be selected as the optimal configuration, which depends on the priority of the throughput and latency performance requirements.

[0056] The electricity bill calculation method proposed in this application disperses and stores data on multiple nodes through a Redis cluster, effectively reducing the risk of storage bottlenecks and improving computing efficiency. At the same time, parallel computing technology is adopted to decompose the electricity bill calculation task into multiple subtasks and perform calculations on multiple nodes. During the calculation process, the task allocation strategy can be dynamically adjusted, and tasks can be reasonably allocated according to the computing capabilities of different nodes, so as to make full use of resources, speed up the calculation speed, and improve computing efficiency. Through the electricity bill calculation method of this application, the single-household electricity bill calculation time can be less than 5 s, 600,000 user electricity bills can be calculated per minute on average, and the electricity bills of 100 million users across the network can be calculated within 3 hours, and the accuracy rate of the calculation results is guaranteed to reach 100%.

[0057] It should be understood that although the steps in the flowcharts involved in the above-described embodiments are displayed in sequence according to the arrows, these steps do not necessarily have to be executed in the order indicated by the arrows. Unless there is a clear indication in this article, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, at least some of the steps in the flowcharts involved in the above-described embodiments may include multiple steps or multiple stages. These steps or stages do not necessarily have to be executed at the same time, but can be executed at different times. The execution order of these steps or stages does not necessarily have to be sequential, but can be executed alternately or alternately with at least some of the steps or stages in other steps or other steps.

[0058] Based on the same inventive concept, an embodiment of the present application further provides an electricity charge calculation device for implementing the above-mentioned electricity charge calculation method. The implementation solution provided by this device for solving problems is similar to the implementation solution described in the above method. Therefore, the specific limitations in one or more embodiments of the electricity charge calculation device provided below can refer to the limitations on the electricity charge calculation method in the above text, and will not be repeated here.

[0059] In one embodiment, as Figure 7 shown, an electricity charge calculation device is provided, including: a message acquisition module 410, an electricity charge calculation module 420, and a result storage module 430, where:

[0060] The message acquisition module 410 is used to obtain electricity charge measurement data based on the message queue Kafka and obtain an electricity charge measurement message; wherein, the electricity charge measurement message includes: user identification, power consumption, and power consumption time;

[0061] The electricity charge calculation module 420 is used to consume the electricity charge measurement message based on the stream computing engine Flink and perform electricity charge calculation to obtain an electricity charge calculation result;

[0062] The result storage module 430 is used to store the electricity charge calculation result in the Redis cluster through the stream computing engine Flink.

[0063] In one embodiment, the message acquisition module 410 is further used to obtain initial measurement data from the Redis cluster; and perform data verification on the initial measurement data through a microservice to obtain electricity charge measurement data.

[0064] In one embodiment, the electricity charge calculation module 420 is further used to obtain an electricity charge operator through the stream computing engine Flink; wherein, the electricity charge operator includes: keyed state and operator state; and perform electricity charge calculation on the electricity charge measurement message based on the electricity charge operator.

[0065] In one embodiment, the message queue Kafka includes multiple server nodes Broker, and each server node Broker includes multiple message partitions, and the electricity charge measurement message is stored in the multiple message partitions in the form of messages.

[0066] In one embodiment, the stream computing engine Flink includes multiple task slots, and each task slot is used to perform an electricity charge calculation task.

[0067] In one embodiment, the number of message partitions of the message queue Kafka is equal to the number of task slots of the stream computing engine Flink.

[0068] In one embodiment, the electricity charge calculation device further includes: a parallelism adjustment module, configured to obtain performance metrics of the streaming computing engine Flink; wherein the performance metrics include: throughput, latency, and resource utilization rate; and to adjust the parallelism of the streaming computing engine Flink based on the performance metrics.

[0069] Each module in the above-mentioned electricity charge calculation device can be implemented in whole or in part by software, hardware, and their combination. Each of the above modules can be embedded in the processor of the computer device in hardware form or be independent of it, or can be stored in the memory of the computer device in software form, so as to facilitate the processor to call and execute the operations corresponding to each of the above modules.

[0070] In one embodiment, a computer device is provided. The computer device can be a server, and its internal structure diagram can be as Figure 8 shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, abbreviated as I / O), and a communication interface. Among them, the processor, the memory, and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used for exchanging information between the processor and external devices. The communication interface of the computer device is used for communicating with external terminals through a network connection. When the computer program is executed by the processor, it implements an electricity charge calculation method.

[0071] Those skilled in the art can understand that Figure 8 the structure shown in

[0072] is only a block diagram of some structures related to the solution of this application, and does not constitute a limitation on the computer device to which the solution of this application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have a different component layout.

[0073] In one embodiment, a computer device is provided, including a memory and a processor. A computer program is stored in the memory, and when the processor executes the computer program, it implements the steps in the above method embodiments.

[0074] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, database, or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memories. Non-volatile memories can include read-only memory (ROM), magnetic tapes, floppy disks, flash memories, optical memories, high-density embedded non-volatile memories, resistive random access memories (ReRAM), magnetoresistive random access memories (MRAM), ferroelectric random access memories (FRAM), phase change memories (PCM), graphene memories, etc. Volatile memories can include random access memory (RAM) or external cache memories, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The databases involved in the embodiments provided in the present application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., without limitation. The processors involved in the embodiments provided in the present application can be general-purpose processors, central processors, graphics processors, digital signal processors, programmable logic devices, data processing logics based on quantum computing, etc., without limitation.

[0075] The technical features of the above embodiments can be combined arbitrarily. For the sake of concise description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope described in this specification.

[0076] The above-described embodiments merely represent several implementation manners of the present application. The description thereof is relatively specific and detailed, but it should not be construed as a limitation on the patent scope of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.

Claims

1. A method for calculating electricity charges, characterized in that, The method includes: Obtaining electricity charge measurement data based on the message queue Kafka to obtain an electricity charge measurement message; wherein, the electricity charge measurement message includes: user identification, electricity consumption, and electricity consumption time; Consuming the electricity charge measurement message based on the stream computing engine Flink and performing electricity charge calculation to obtain an electricity charge calculation result; Storing the electricity charge calculation result in the Redis cluster through the stream computing engine Flink.

2. The electricity charge calculation method according to claim 1, wherein Before the step of obtaining electricity charge measurement data based on the message queue Kafka, the method further includes: Obtaining initial measurement data from the Redis cluster; Performing data verification on the initial measurement data through a microservice to obtain the electricity charge measurement data.

3. The electricity charge calculation method according to claim 1, wherein The step of consuming the electricity charge measurement message based on the stream computing engine Flink and performing electricity charge calculation includes: Obtaining an electricity charge operator through the stream computing engine Flink; wherein, the electricity charge operator includes: keyed state and operator state; Performing electricity charge calculation on the electricity charge measurement message based on the electricity charge operator.

4. The electricity charge calculation method according to claim 1, characterized in that The message queue Kafka includes multiple server nodes Broker, and each server node Broker includes multiple message partitions, and the electricity charge measurement message is stored in the multiple message partitions in the form of messages.

5. The electricity charge calculation method according to claim 4, characterized in that, The stream computing engine Flink includes multiple task slots, and each task slot is used to perform an electricity charge calculation task.

6. The electricity charge calculation method according to claim 5, characterized in that The number of the message partitions of the message queue Kafka is equal to the number of the task slots of the stream computing engine Flink.

7. The electricity charge calculation method according to any one of claims 1 to 6, characterized in that, The method further includes: Obtaining performance metrics of the stream computing engine Flink; wherein, the performance metrics include: throughput, latency, and resource utilization rate; Adjusting the parallelism of the stream computing engine Flink based on the performance metrics.

8. An electricity charge calculation device, characterized in that, The device includes: A message acquisition module, configured to obtain electricity charge measurement data based on the message queue Kafka to obtain an electricity charge measurement message; wherein, the electricity charge measurement message includes: user identification, electricity consumption, and electricity consumption time; An electricity charge calculation module, configured to consume the electricity charge measurement message based on the stream computing engine Flink and perform electricity charge calculation to obtain an electricity charge calculation result; A result storage module, configured to store the electricity charge calculation result in the Redis cluster through the stream computing engine Flink.

9. A computer device, comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Flow charging system and method based on Flink

    CN121239510A

  • A flink-based traffic billing system and a billing method

    CN121239510B