Query method and device of power transaction data and computer program product
By storing power transaction data in a distributed database and using chain structures to correlate data, efficient tracking and querying of power transaction data is achieved, and the problem of insufficient query capabilities in the existing technology is solved.
Patent Information
- Application Number
- CN202411754455.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-04-15
AI Technical Summary
In the prior art, the ability to track and query power transaction data is weak, and it is impossible to track and query power transaction data efficiently.
By saving the power transaction data and its corresponding summary values in a distributed database, different power transaction data are associated with using a chain structure, and querying power transaction data and its associated data from the chain structure based on the query data, and tracking and querying transaction data.
It realizes efficient tracking and querying of power transaction data, and solves the problem of how to efficiently query power transaction data in related technologies.
Smart Images

Figure CN119829802A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of electric power, and more specifically, to a method, device and computer program product for querying electric power transaction data. Background Art
[0002] With the transformation of the global energy structure, the power market is gradually developing towards a more open and competitive model. Therefore, the accuracy and transparency of power trading data are particularly important. Power market participants such as power generation companies, power sales companies and users buy and sell electricity through various trading mechanisms. As a result, a large amount of power trading data is generated. As the core information of power market operation, the accuracy, completeness and traceability of power trading data are of great significance for maintaining market order, ensuring fair transactions and promoting the sustainable development of the power industry. However, in the existing technology, the ability to track and query power trading data is weak, and it is impossible to track power trading data efficiently.
[0003] Therefore, in the related technology, there is a problem of how to efficiently track and query the electricity trading data.
[0004] Regarding the problem of how to efficiently track and query power transaction data in related technologies, no effective solution has been proposed so far.
[0005] Therefore, it is necessary to improve the related technology to overcome the above-mentioned defects in the related technology. Summary of the invention
[0006] The embodiments of the present application provide a method, device and computer program product for querying electricity trading data, so as to at least solve the problem in the related art of how to efficiently track and query electricity trading data.
[0007] According to one aspect of an embodiment of the present application, a method for querying power trading data is provided, comprising: receiving query data from a user end of a power trading system, the query data comprising a query field and a query value; querying first power trading data from a distributed database according to the query data, wherein the distributed database is composed of a chain structure, the chain structure is composed of multiple power trading data, each power trading data comprises a summary value of a previous power trading data, and the first power trading data represents power trading data whose field value of the query field comprises the query value; obtaining a power trading data summary value corresponding to second power trading data from the first power trading data, wherein the second power trading data represents a previous power trading data of the first power trading data; querying the second power trading data from the distributed database according to the power trading data summary value corresponding to the second power trading data; and sending a query result generated based on the first power trading data and the second power trading data to the user end.
[0008] In an exemplary embodiment, before receiving query data from a user end of the power trading system, the method further includes: determining a data structure and data fields for storing power trading data, wherein the data fields correspond to field values; serializing data objects to obtain text sequences, wherein the data objects are obtained by encoding the power trading data according to the data structure; performing one-way compression processing on the text sequence through a summary algorithm to obtain a summary value of the power trading data; and saving the summary value of the power trading data and the power trading data to the distributed database.
[0009] In an exemplary embodiment, the power transaction data includes a data identification field. After determining the data structure and data field for storing the power transaction data, the method further includes: generating a data identification field value of the power transaction data based on the current timestamp and initial timestamp of the distributed database, the data center identifier of the distributed database, the machine identifier and the serial number, wherein the machine identifier represents the machine identifier of the machine where the power transaction data occurs, and the serial number represents the serial number generated by the machine where the power transaction data occurs.
[0010] In an exemplary embodiment, the method further includes: generating a binary sequence based on the electricity user information, performing one-way compression processing on the binary sequence through the summary algorithm to obtain a binary sequence summary value; generating a key-value pair based on the electricity transaction data summary value and the binary sequence summary value, wherein the key part of the key-value pair corresponds to the binary sequence summary value, and the value part of the key-value pair corresponds to the electricity transaction data summary value; and querying the electricity transaction data corresponding to the electricity user information from the distributed database through the key-value pair.
[0011] In an exemplary embodiment, a query result generated based on the first power trading data and the second power trading data is sent to the user end, including: generating a first random number, and determining the first random number as the private key of the server end of the power trading system; calculating the first random number according to a key exchange algorithm to obtain the public key of the server end; sending a digital certificate to the user end, and receiving the public key of the user end sent by the user end after verifying the digital certificate, wherein the digital certificate includes the public key of the server end and the key exchange algorithm, and the public key of the user end is calculated by using the key exchange algorithm to calculate the second random number generated by the user end, and the second random number is the private key of the user end; through the key exchange algorithm, the public key of the user end and the private key of the server end are used to calculate a session key; and encrypted communication is performed with the user end according to the session key to send the query result to the user end.
[0012] In an exemplary embodiment, before receiving query data from a user end of the power trading system, the method further includes: determining the predictive query data of the user end based on the historical query records of the user end; querying from the distributed database based on the predictive query data to obtain predictive query results, and caching the predictive query results.
[0013] According to another aspect of an embodiment of the present application, a device for querying power trading data is also provided, including: a receiving module, used to receive query data from a user end of a power trading system, the query data including a query field and a query value; a first query module, used to query first power trading data from a distributed database according to the query data, wherein the distributed database is composed of a chain structure, the chain structure is composed of multiple power trading data, each power trading data includes a summary value of a previous power trading data, and the first power trading data represents power trading data whose field value of the query field includes the query value; an acquisition module, used to obtain a power trading data summary value corresponding to second power trading data from the first power trading data, wherein the second power trading data represents a previous power trading data of the first power trading data; a second query module, used to query the second power trading data from the distributed database according to the power trading data summary value corresponding to the second power trading data; a sending module, used to send the query result generated based on the first power trading data and the second power trading data to the user end.
[0014] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the above-mentioned method for querying power trading data when running.
[0015] According to another aspect of an embodiment of the present application, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the method for querying electricity trading data through the computer program.
[0016] According to another aspect of the embodiments of the present application, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps of the method described in each embodiment of the present application are implemented.
[0017] Through this application, the power transaction data and the summary value corresponding to the power transaction data can be stored in a distributed database, and different power transaction data can be associated through a chain structure. Then, according to the query data, the power transaction data and its associated power transaction data can be queried from the chain structure, thereby realizing the tracking and query of the transaction data. This solves the problem of how to efficiently track and query the power transaction data in the related technology, and realizes the effect of efficiently tracking and querying the power transaction data. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0019] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0020] Figure 1 It is a hardware structure block diagram of a computer terminal of a method for querying power transaction data in an embodiment of the present application;
[0021] Figure 2 is a flow chart of a method for querying power transaction data according to an embodiment of the present application;
[0022] Figure 3 is a schematic flow chart of a method for querying power transaction data according to an embodiment of the present application;
[0023] Figure 4 It is a structural block diagram of a device for querying power transaction data according to an embodiment of the present application. DETAILED DESCRIPTION
[0024] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0025] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0026] The method embodiments provided in the embodiments of the present application can be executed in a computer terminal or a similar computing device. Taking running on a computer terminal as an example, Figure 1 1 is a hardware structure block diagram of a computer terminal for querying power transaction data in an embodiment of the present application. Figure 1 As shown, the computer terminal may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor (Central Processing Unit, MCU) or a programmable logic device (Field Programmable Gate Array, FPGA)) and a memory 104 for storing data, wherein the above-mentioned computer terminal may also include a transmission device 106 and an input and output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above-mentioned computer terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0027] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the query method of power trading data in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0028] A wireless network provided by a communication provider of a computer terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (Radio Frequency, referred to as RF) module, which is used to communicate with the Internet wirelessly.
[0029] In this embodiment, a method for querying power transaction data is provided. Figure 2 is a flow chart of a method for querying power transaction data according to an embodiment of the present application. Figure 2 As shown, the process includes the following steps:
[0030] Step S202, receiving query data from a user end of the power trading system, wherein the query data includes a query field and a query value;
[0031] Optionally, in the above step S202, the query data of the user side may be that the user retrieves a specific electricity transaction record by entering a keyword, or obtains a list of transaction records matching specific conditions. The user side may provide a query function based on transaction ID, timestamp or electricity user information keyword.
[0032] Step S204, querying first power transaction data from a distributed database according to the query data, wherein the distributed database is composed of a chain structure, the chain structure is composed of multiple power transaction data, each power transaction data includes a summary value of a previous power transaction data, and the first power transaction data represents power transaction data whose field value of the query field includes the query value;
[0033] Step S206, obtaining a power transaction data summary value corresponding to second power transaction data from the first power transaction data, wherein the second power transaction data represents a previous power transaction data of the first power transaction data;
[0034] Step S208, querying the second power transaction data from the distributed database according to the power transaction data summary value corresponding to the second power transaction data;
[0035] Step S210: sending the query result generated based on the first power transaction data and the second power transaction data to the user end.
[0036] Through the above steps, the power transaction data and the summary value corresponding to the power transaction data can be stored in a distributed database, and different power transaction data can be associated through a chain structure. Then, according to the query data, the power transaction data and its associated power transaction data can be queried from the chain structure, thereby realizing the tracking and query of the transaction data. This solves the problem of how to efficiently track and query the power transaction data in the related technology, and realizes the effect of efficiently tracking and querying the power transaction data.
[0037] In an exemplary embodiment, before receiving query data from a user end of the power trading system, the method further includes: determining a data structure and data fields for storing power trading data, wherein the data fields correspond to field values; serializing data objects to obtain text sequences, wherein the data objects are obtained by encoding the power trading data according to the data structure; performing one-way compression processing on the text sequence through a summary algorithm to obtain a summary value of the power trading data; and saving the summary value of the power trading data and the power trading data to the distributed database.
[0038] Optionally, in the above embodiment, for example, the key data fields of the power transaction are first defined according to the JSON format (a data structure), and the key data fields include but are not limited to the transaction ID, timestamp, power supplier, power user, price and status, etc. When conducting power transactions, the power transaction data is generated into a JSON format data group according to the key data fields in the JSON format, and the JSON serialization function provided by the programming language is used to convert the data group into a string in the JSON format (equivalent to a text sequence), and the JSON string is processed by a hash algorithm (equivalent to a digest algorithm) to obtain a string of unique hash values (equivalent to the power transaction data digest value), and the power transaction data and its hash value are stored in the blockchain (equivalent to a distributed database). In the blockchain, a chain structure is constructed using hash values, and each power transaction data contains the hash value of the previous power transaction data, thereby forming a complete traceable transaction tracking chain.
[0039] Optionally, in the above embodiment, the steps of performing hash algorithm processing on the JSON string are as follows:
[0040] Data padding: Supplement the data to a length of 448 bits and add 64 bits of the original data length;
[0041] Blocking: Divide the padded data into 512-bit blocks;
[0042] Initialize hash value: use 8 32-bit initial hash values;
[0043] Message expansion: convert 512-bit blocks into 64 32-bit words;
[0044] Loop compression: Initialize 8 working variables to the current hash value, use 64 rounds of calculation for each word, and update the working variables;
[0045] Update hash value: After processing each block, add the value of the working variable to the initial hash value to get a new hash value;
[0046] Output result: The hash value of each processed block is concatenated to obtain the final hash value, forming a 256-bit output.
[0047] Optionally, in the above embodiment, before storing the electricity transaction data in the blockchain or distributed database, the electricity transaction data can be encrypted and access control can be performed to implement a two-way identity confirmation access mechanism. When querying the electricity transaction data, the query efficiency can be improved through asynchronous processing and caching mechanisms.
[0048] In an exemplary embodiment, the power transaction data includes a data identification field. After determining the data structure and data field for storing the power transaction data, the method further includes: generating a data identification field value of the power transaction data based on the current timestamp and initial timestamp of the distributed database, the data center identifier of the distributed database, the machine identifier and the serial number, wherein the machine identifier represents the machine identifier of the machine where the power transaction data occurs, and the serial number represents the serial number generated by the machine where the power transaction data occurs.
[0049] Optionally, in the above embodiment, the transaction ID (equivalent to the data identification field) of the power transaction data can be generated by the snowflake algorithm, and the transaction ID includes the following structure: sign bit, set to 0; timestamp, which is the current timestamp; data center ID, the identification of the data center; machine ID, the identification of the machine; serial number, the serial number generated by each machine within the same millisecond. Among them, the data center ID and machine ID determine the ID of the data center and the machine according to the distributed database or blockchain, and need to be configured when the distributed system is deployed, and ensure that they are unique in the entire distributed system.
[0050] Optionally, in the above embodiment, the calculation formula of the snowflake algorithm is as follows:
[0051] Generated transaction ID = (timestamp - initial timestamp) << number of left shifts | data center ID << number of left shifts of data center ID | machine ID << number of left shifts of machine ID | sequence number;
[0052] Sequence number (sequence_bits):
[0053] Value: 12.
[0054] Meaning: The serial number part occupies 12 digits.
[0055] Machine ID shift (machine_id_shift) calculation:
[0056] machine_id_shift=sequence_bitsmachine_id_shift=sequence_bits.
[0057] Value: machine_id_shift=12.
[0058] Meaning: The machine ID shift indicates the number of bits that the machine ID portion occupies in the 64-bit ID. This shift amount is used to determine the starting position of the machine ID in the ID.
[0059] Data center ID shift (datacenter_id_shift) calculation:
[0060] datacenter_id_shift=sequence_bits+machine_id_bits.
[0061] Value: datacenter_id_shift=12+5=17.
[0062] Meaning: The data center ID shift indicates the number of bits that the data center ID portion occupies in the 64-bit ID. This shift amount is used to determine the starting position of the data center ID in the ID.
[0063] Timestamp shift (timestamp_shift) calculation:
[0064] timestamp_shift=sequence_bits+datacenter_id_bits+machine_id_bits.
[0065] Value: timestamp_shift = 12 + 5 + 5 = 22.
[0066] Meaning: The timestamp shift indicates the number of bits that the timestamp part occupies in the 64-bit ID. This shift amount is used to determine the starting position of the timestamp in the ID.
[0067] The above shift calculation ensures that in the 64-bit ID, the timestamp, data center ID, machine ID, and serial number each occupy a specific number of bits, thereby generating a globally unique ID. This ID generation strategy can ensure that each generated ID is unique in a distributed system even in high concurrency situations.
[0068] In an exemplary embodiment, the method further includes: generating a binary sequence based on the electricity user information, performing one-way compression processing on the binary sequence through the summary algorithm to obtain a binary sequence summary value; generating a key-value pair based on the electricity transaction data summary value and the binary sequence summary value, wherein the key part of the key-value pair corresponds to the binary sequence summary value, and the value part of the key-value pair corresponds to the electricity transaction data summary value; and querying the electricity transaction data corresponding to the electricity user information from the distributed database through the key-value pair.
[0069] Optionally, in the above embodiment, constructing a hash key-value pair through the electricity user information can more conveniently track and query the electricity transaction information of the electricity user. The construction process of the hash key-value pair is as follows:
[0070] First, a binary sequence is generated according to the information of the electricity user, and then a hash key-value pair is generated through the division hash method or the multiplication hash method, so as to facilitate the connection of all electricity transaction information of the same electricity user;
[0071] The formula of the division hash method is: hash(key)=keymonM, where key is the input keyword or data, that is, the binary sequence of the electricity user information, and M is a positive integer, usually a prime number. The input data is mapped to a smaller range through the modulus operation to generate a hash key;
[0072] The formula of the multiplication hash method is: hash(key)=floor(M / W*(a*keymonW)), where M and W are both positive integers, M is set to a power of 2, W is the computer word length, also a power of 2, a is a constant close to W but not equal to W, and floor represents the floor function. Certain features of the input data are extracted through multiplication and modulo operations to generate a hash key.
[0073] After the hash key is generated, a hash value is generated according to the summary value of the power transaction data to obtain a hash key-value pair.
[0074] In an exemplary embodiment, a query result generated based on the first power trading data and the second power trading data is sent to the user end, including: generating a first random number, and determining the first random number as the private key of the server end of the power trading system; calculating the first random number according to a key exchange algorithm to obtain the public key of the server end; sending a digital certificate to the user end, and receiving the public key of the user end sent by the user end after verifying the digital certificate, wherein the digital certificate includes the public key of the server end and the key exchange algorithm, and the public key of the user end is calculated by using the key exchange algorithm to calculate the second random number generated by the user end, and the second random number is the private key of the user end; through the key exchange algorithm, the public key of the user end and the private key of the server end are used to calculate a session key; and encrypted communication is performed with the user end according to the session key to send the query result to the user end.
[0075] Optionally, in the above embodiment, before the power transaction data is stored in the blockchain or distributed database, the data-encoded power transaction data may be encrypted using the SSL encryption protocol, and a symmetric encryption algorithm is used. The specific process is as follows:
[0076] Encryption process: select three keys K1, K2 and K3;
[0077] Initial permutation: Perform initial permutation on the plaintext P;
[0078] Loop processing: 16 rounds of processing are performed, each round includes: splitting the data into a left half L and a right half R; using the F function (a specific function used in a specific encryption algorithm) to calculate a new right half and perform an XOR operation with the left half; swapping the left and right parts, which is only performed at the end of each round;
[0079] Inverse permutation: After all rounds are completed, perform the inverse initial permutation;
[0080] Assuming P is plaintext, C is ciphertext, E and D are encryption and decryption functions respectively, the encryption process can be expressed as: C = E K3 (DK2 (E K1 (P))); the decryption process is the inverse process of the encryption process, and the decryption process is expressed as: P = D K1 (E K2 (D K3 (C))).
[0081] Optionally, in the above embodiment, different user roles have different data access permissions, so when the user end requests to query data from the server end, two-way identity authentication is required to ensure that only authorized users can view or operate specific data. The specific identity authentication process is as follows:
[0082] 1. The server generates a random number as a private key and uses a key exchange algorithm to calculate the private key to obtain the server's public key.
[0083] 2. The client and the server establish a secure connection through a TLS handshake. The process includes: the client sends the supported TLS version and encryption suite information to the server; the server responds and selects the most appropriate TLS version and encryption suite; the server sends its digital certificate to the client for identity authentication; the client verifies the server's certificate and generates a random number as the client's private key, uses a key exchange algorithm to calculate the private key to obtain the client's public key, and then uses the server's public key to encrypt the random number and send it to the server.
[0084] 3. The client and server use a shared key exchange algorithm, the other party's public key and their own private key to calculate and generate a session key.
[0085] 4. After the session key is generated, the client and server use the session key for encrypted communication.
[0086] 5. After the communication is completed, the TLS connection is securely closed.
[0087] Through the above embodiments, encryption algorithms and data encoding technologies are used to improve data security and privacy protection capabilities, effectively prevent the risks of attacks and data leakage, and set identity authentication when querying and accessing data, further improving data security;
[0088] In an exemplary embodiment, before receiving query data from a user end of the power trading system, the method further includes: determining the predictive query data of the user end based on the historical query records of the user end; querying from the distributed database based on the predictive query data to obtain predictive query results, and caching the predictive query results.
[0089] Optionally, in the above embodiment, the cache mechanism predicts the user's query content through a prediction algorithm, and the prediction algorithm is as follows:
[0090]
[0091] Among them, P(AB) represents the probability of event A occurring when it is known that event B has occurred, P(BA) represents the probability of event B occurring when event A has occurred, P(A) represents the prior probability of event A, and P(B) represents the marginal probability of event B. By predicting the probabilities of other items in the power trading data that will be queried subsequently for one item in the power trading data that is queried first, the data with a high query probability is cached.
[0092] Through the above embodiments, the introduction of cache to store the data of the prediction query can reduce the burden on the database, speed up data access, realize fast retrieval and efficient processing of data, and meet the needs of real-time analysis of power trading data.
[0093] Obviously, the above-described embodiments are only a part of the embodiments of the present application, not all of the embodiments. In order to better understand the above-mentioned method for determining the power generation area, the above-mentioned process is described below in conjunction with the embodiments, but it is not intended to limit the technical solutions of the embodiments of the present application, specifically:
[0094] In an optional embodiment, in combination Figure 3 The query method of the power transaction data of this application is further explained. Figure 3 As shown, the specific steps include:
[0095] S301: Specifying data fields of power transaction data: defining key data fields of power transaction according to JSON format, the key data fields include transaction ID, timestamp, power supplier, power user, price and status;
[0096] S302: Formatting data encoding processing of power transaction data: When conducting power transactions, the power transaction data is generated into a data group according to key data fields in JSON format, and then the transaction data is converted into a JSON string;
[0097] S303: Perform hashing algorithm processing on the JSON string: Perform hashing algorithm processing on the JSON string to obtain a string of unique hash values, and store the power transaction data and its hash value in a blockchain or distributed database;
[0098] S304: Tracking and querying the power transaction data: Using hash values to build a chain structure, the power transaction data are all connected to the hash value of the previous power transaction data, thus forming a complete tracking chain;
[0099] S305: Customer query of power transaction data: Customers can retrieve specific power transaction records by entering keywords, or obtain a list of transaction records matching specific conditions, providing a query function based on transaction ID, timestamp or power user information keywords;
[0100] S306: Data security and privacy protection: Before storing the power transaction data in the blockchain or distributed database, the power transaction data is encrypted and access control is performed to achieve identity confirmation of both parties. When querying the power transaction data, the query efficiency is improved through asynchronous processing and caching mechanisms.
[0101] Through the above-mentioned embodiments, the power transaction data can be encoded and processed, and a chain structure can be constructed according to the hash value, so that a complete tracking chain can be formed when the power transaction data is tracked, thereby realizing the full tracking and real-time monitoring of the power transaction data and improving the query efficiency of the power transaction data.
[0102] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods of each embodiment of the present application.
[0103] In this embodiment, a query device for power trading data is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware for a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0104] Figure 4 : is a structural block diagram of a device for querying power transaction data according to an embodiment of the present application, the device comprising:
[0105] The receiving module 41 is used to receive query data from the user end of the power trading system, wherein the query data includes a query field and a query value;
[0106] A first query module 42 is used to query first power transaction data from a distributed database according to the query data, wherein the distributed database is composed of a chain structure, the chain structure is composed of multiple power transaction data, each power transaction data includes a summary value of a previous power transaction data, and the first power transaction data represents power transaction data whose field value of the query field includes the query value;
[0107] An acquisition module 43 is used to acquire a power transaction data summary value corresponding to second power transaction data from the first power transaction data, wherein the second power transaction data represents a previous power transaction data of the first power transaction data;
[0108] A second query module 44, configured to query the second power transaction data from the distributed database according to the power transaction data summary value corresponding to the second power transaction data;
[0109] The sending module 45 is used to send the query result generated based on the first power transaction data and the second power transaction data to the user end.
[0110] Through the above device, the power transaction data and the summary value corresponding to the power transaction data can be stored in a distributed database, and different power transaction data can be associated through a chain structure. Then, according to the query data, the power transaction data and its associated power transaction data can be queried from the chain structure, thereby realizing the tracking and query of the transaction data. This solves the problem of how to efficiently track and query the power transaction data in the related technology, and realizes the effect of efficiently tracking and querying the power transaction data.
[0111] In an exemplary embodiment, the device is also used to: determine a data structure and data fields for storing power transaction data, wherein the data fields correspond to field values; serialize data objects to obtain text sequences, wherein the data objects are obtained by encoding the power transaction data according to the data structure; perform one-way compression processing on the text sequence through a summary algorithm to obtain a summary value of the power transaction data; and save the summary value of the power transaction data and the power transaction data to the distributed database.
[0112] In an exemplary embodiment, the electricity transaction data includes a data identification field, and the device is also used to: generate a data identification field value of the electricity transaction data based on the current timestamp and initial timestamp of the distributed database, the data center identifier of the distributed database, the machine identifier and the serial number, wherein the machine identifier represents the machine identifier of the machine where the electricity transaction data occurs, and the serial number represents the serial number generated by the machine where the electricity transaction data occurs.
[0113] In an exemplary embodiment, the device is also used to: generate a binary number series based on the electricity user information, perform one-way compression processing on the binary number series through the summary algorithm to obtain a binary number series summary value; generate a key-value pair based on the electricity transaction data summary value and the binary number series summary value, wherein the key part of the key-value pair corresponds to the binary number series summary value, and the value part of the key-value pair corresponds to the electricity transaction data summary value; and query the electricity transaction data corresponding to the electricity user information from the distributed database through the key-value pair.
[0114] In an exemplary embodiment, the sending module 45 is also used to: generate a first random number, determine the first random number as the private key of the server of the power trading system; calculate the first random number according to the key exchange algorithm to obtain the public key of the server; send a digital certificate to the user, and receive the public key of the user sent by the user after verifying the digital certificate, wherein the digital certificate includes the public key of the server and the key exchange algorithm, and the public key of the user is calculated by the key exchange algorithm on the second random number generated by the user, and the second random number is the private key of the user; through the key exchange algorithm, the public key of the user and the private key of the server are used to calculate a session key; and perform encrypted communication with the user according to the session key to send the query result to the user.
[0115] In an exemplary embodiment, the device is also used to: determine the predicted query data of the user terminal based on the historical query records of the user terminal; query from the distributed database based on the predicted query data to obtain the predicted query results, and cache the predicted query results.
[0116] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when run.
[0117] Optionally, in this embodiment, the storage medium may be configured to store a computer program for performing the following steps:
[0118] S1, receiving query data from a user end of a power trading system, wherein the query data includes a query field and a query value;
[0119] S2, querying first power transaction data from a distributed database according to the query data, wherein the distributed database is composed of a chain structure, the chain structure is composed of multiple power transaction data, each power transaction data includes a summary value of a previous power transaction data, and the first power transaction data represents power transaction data whose field value of the query field includes the query value;
[0120] S3, acquiring a power transaction data summary value corresponding to second power transaction data from the first power transaction data, wherein the second power transaction data represents a previous power transaction data of the first power transaction data;
[0121] S4, querying the second power transaction data from the distributed database according to the power transaction data summary value corresponding to the second power transaction data;
[0122] S5: Sending the query result generated based on the first power transaction data and the second power transaction data to the user end.
[0123] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0124] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.
[0125] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0126] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:
[0127] S1, receiving query data from a user end of a power trading system, wherein the query data includes a query field and a query value;
[0128] S2, querying first power transaction data from a distributed database according to the query data, wherein the distributed database is composed of a chain structure, the chain structure is composed of multiple power transaction data, each power transaction data includes a summary value of a previous power transaction data, and the first power transaction data represents power transaction data whose field value of the query field includes the query value;
[0129] S3, acquiring a power transaction data summary value corresponding to second power transaction data from the first power transaction data, wherein the second power transaction data represents a previous power transaction data of the first power transaction data;
[0130] S4, querying the second power transaction data from the distributed database according to the power transaction data summary value corresponding to the second power transaction data;
[0131] S5: Sending the query result generated based on the first power transaction data and the second power transaction data to the user end.
[0132] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0133] An embodiment of the present application further provides a computer program product, comprising a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program product, and when the computer program is executed by a processor, the steps of the method described in each embodiment of the present application are implemented.
[0134] Optionally, in this embodiment, the above computer program may be configured to implement the following steps when executed by a processor:
[0135] S1, receiving query data from a user end of a power trading system, wherein the query data includes a query field and a query value;
[0136] S2, querying first power transaction data from a distributed database according to the query data, wherein the distributed database is composed of a chain structure, the chain structure is composed of multiple power transaction data, each power transaction data includes a summary value of a previous power transaction data, and the first power transaction data represents power transaction data whose field value of the query field includes the query value;
[0137] S3, acquiring a power transaction data summary value corresponding to second power transaction data from the first power transaction data, wherein the second power transaction data represents a previous power transaction data of the first power transaction data;
[0138] S4, querying the second power transaction data from the distributed database according to the power transaction data summary value corresponding to the second power transaction data;
[0139] S5: Sending the query result generated based on the first power transaction data and the second power transaction data to the user end.
[0140] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.
[0141] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.
[0142] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for querying power transaction data, characterized in that: include: Receiving query data from a user end of the power trading system, the query data including a query field and a query value; According to the query data, first power transaction data is queried from a distributed database, wherein the distributed database is composed of a chain structure, the chain structure is composed of a plurality of power transaction data, each power transaction data includes a summary value of a previous power transaction data, and the first power transaction data represents power transaction data whose field value of the query field includes the query value; Acquire a power transaction data summary value corresponding to second power transaction data from the first power transaction data, wherein the second power transaction data represents a previous power transaction data of the first power transaction data; querying the second power transaction data from the distributed database according to the power transaction data summary value corresponding to the second power transaction data; The query result generated based on the first power transaction data and the second power transaction data is sent to the user end.
2. The method according to claim 1, characterized in that Before receiving the query data from the user end of the power trading system, the method further includes: Determine a data structure and data fields for storing power transaction data, wherein the data fields correspond to field values; Serializing the data object to obtain a text sequence, wherein the data object is obtained by encoding the power transaction data according to the data structure; Performing one-way compression processing on the text sequence by using a summary algorithm to obtain a summary value of the power transaction data; The power transaction data summary value and the power transaction data are saved in the distributed database.
3. The method according to claim 2, characterized in that The power transaction data includes a data identification field. After determining the data structure and data field for storing the power transaction data, the method further includes: generating a data identification field value for the power transaction data based on the current timestamp and initial timestamp of the distributed database, the data center identifier of the distributed database, a machine identifier and a serial number, wherein the machine identifier represents the machine identifier of the machine where the power transaction data occurs, and the serial number represents a serial number generated by the machine where the power transaction data occurs.
4. The method according to claim 2, characterized in that: The method further comprises: Generate a binary number sequence according to the electricity user information, and perform one-way compression processing on the binary number sequence through the summary algorithm to obtain a summary value of the binary number sequence; Generate a key-value pair based on the power transaction data summary value and the binary number sequence summary value, wherein the key portion of the key-value pair corresponds to the binary number sequence summary value, and the value portion of the key-value pair corresponds to the power transaction data summary value; The power transaction data corresponding to the power user information is queried from the distributed database through the key-value pair.
5. The method according to claim 1, characterized in that: Sending a query result generated based on the first power transaction data and the second power transaction data to the user end includes: Generate a first random number, and determine the first random number as a private key of a service end of the power trading system; Calculate the first random number according to a key exchange algorithm to obtain a public key of the server; Sending a digital certificate to a client, and receiving a public key of the client sent by the client after verifying the digital certificate, wherein the digital certificate includes a public key of the server and a key exchange algorithm, the public key of the client is calculated by using the key exchange algorithm on a second random number generated by the client, and the second random number is a private key of the client; The session key is calculated using the public key of the user end and the private key of the server end through the key exchange algorithm; Encrypted communication is performed with the user terminal according to the session key to send the query result to the user terminal.
6. The method according to claim 1, characterized in that Before receiving the query data from the user end of the power trading system, the method further includes: Determining predicted query data of the user terminal according to the historical query records of the user terminal; The distributed database is queried according to the prediction query data to obtain a prediction query result, and the prediction query result is cached.
7. A device for querying power transaction data, characterized in that: include: A receiving module, used for receiving query data from a user end of the power trading system, wherein the query data includes a query field and a query value; a first query module, configured to query first power transaction data from a distributed database according to the query data, wherein the distributed database is composed of a chain structure, the chain structure is composed of a plurality of power transaction data, each power transaction data includes a summary value of a previous power transaction data, and the first power transaction data indicates power transaction data whose field value of the query field includes the query value; an acquisition module, configured to acquire a power transaction data summary value corresponding to second power transaction data from the first power transaction data, wherein the second power transaction data represents a previous power transaction data of the first power transaction data; A second query module, configured to query the second power transaction data from the distributed database according to the power transaction data summary value corresponding to the second power transaction data; A sending module is used to send the query result generated based on the first power transaction data and the second power transaction data to the user end.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein the program executes the method according to any one of claims 1 to 6 when executed.
9. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 6 through the computer program.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.