Disclosure of Invention
The invention mainly aims to provide an agricultural product traceability method, agricultural product traceability equipment, an agricultural product traceability storage medium and an agricultural product traceability device based on a block chain, and aims to solve the technical problem that agricultural products are difficult to trace in the prior art.
In order to achieve the above object, the present invention provides a block chain-based agricultural product tracing method, which comprises the following steps:
when a source tracing query instruction is received, determining batch information of the agricultural product to be queried according to the source tracing query instruction;
based on a preset intelligent contract, acquiring production information corresponding to agricultural products to be inquired on a block chain according to batch information;
and transmitting the production information to the tracing terminal so that the tracing terminal can display the production information.
Optionally, when the traceability query instruction is received, before determining the batch information of the agricultural product to be queried according to the traceability query instruction, the method further includes:
when an uplink request is received, agricultural product information is obtained according to the uplink request;
determining a target block chain according to the agricultural product information;
and acquiring current node information, and uploading the agricultural product information and the current node information to a target block chain.
Optionally, the obtaining current node information, and uploading the agricultural product information and the current node information to the target block chain includes:
obtaining a verification report in the agricultural product information;
generating a corresponding current check code according to the verification report based on a preset check algorithm;
and acquiring current node information, generating an uplink block according to the agricultural product information, the current check code and the current node information, and adding the uplink block to a target block chain.
Optionally, the obtaining current node information, generating a uplink block according to the agricultural product information, the current check code and the current node information, and adding the uplink block to the front of the target block chain further includes:
acquiring an original check code in a target block chain;
comparing the current check code with the original check code to obtain a comparison result;
and when the comparison result is that the current check code is consistent with the original check code, executing the steps of acquiring the current node information, generating an uplink block according to the agricultural product information, the current check code and the current node information, and adding the uplink block to the target block chain.
Optionally, comparing the current check code with the original check code, and after obtaining the comparison result, further comprising:
when the comparison result is that the current check code is inconsistent with the original check code, calling a preset consensus algorithm to determine a credible check code;
acquiring credible agricultural product information corresponding to the credible check code;
correspondingly, acquiring current node information, generating a cochain block according to the agricultural product information, the current check code and the current node information, and adding the cochain block to a target block chain, including:
and acquiring current node information, generating a uplink block according to the credible agricultural product information, the credible check code and the current node information, and adding the uplink block to a target block chain.
Optionally, when the traceability query instruction is received, determining batch information of the agricultural product to be queried according to the traceability query instruction, including:
when a source tracing query instruction is received, determining source tracing code information according to the source tracing query instruction;
determining corresponding agricultural products to be inquired and agricultural product numbers according to the tracing code information;
and searching corresponding batch information from a preset batch information table according to the agricultural product number.
Optionally, when the traceability query instruction is received, determining batch information of the agricultural product to be queried according to the traceability query instruction, including:
when a tracing query instruction is received, acquiring a secret key carried in the tracing query instruction;
determining agricultural products to be inquired according to the source tracing inquiry instruction;
and verifying the agricultural product information of the agricultural product to be inquired according to the secret key to obtain batch information corresponding to the agricultural product to be inquired.
In addition, in order to achieve the above object, the present invention further provides a block chain-based agricultural product traceability system, which includes:
the receiving module is used for determining batch information of the agricultural product to be inquired according to the source tracing inquiry instruction when the source tracing inquiry instruction is received;
the information calling module is used for acquiring production information corresponding to the agricultural products to be inquired on the block chain according to the batch information based on a preset intelligent contract;
and the feedback module is used for transmitting the production information to the tracing terminal so that the tracing terminal can display the production information.
In addition, in order to achieve the above object, the present invention further provides a block chain-based agricultural product traceability device, which includes: the agricultural product tracing method based on the blockchain comprises a memory, a processor and an agricultural product tracing program based on the blockchain, wherein the agricultural product tracing program based on the blockchain is stored in the memory and can run on the processor, and when being executed by the processor, the agricultural product tracing program based on the blockchain realizes the steps of the agricultural product tracing method based on the blockchain.
In addition, in order to achieve the above object, the present invention further provides a storage medium, where the storage medium stores a block chain-based agricultural product tracing program, and when the block chain-based agricultural product tracing program is executed by a processor, the block chain-based agricultural product tracing method as described above is implemented.
In addition, in order to achieve the above object, the present invention further provides a block chain-based agricultural product traceability device, including: .
In the invention, a traceability channel of the agricultural product is established by using a block chain technology, and the production data of the agricultural product is ensured not to be tampered by using the non-tampering property of the block chain, so that the reliability is improved. Meanwhile, the multicenter of the block chain is highly matched with the multi-node characteristics of agricultural product production, so that each processing flow of the agricultural product can form a data record, and the monitoring of the whole flow is facilitated. When tracing, the data on the block chain is searched, so that the corresponding production data can be quickly acquired, and the product tracing is more convenient and more reliable.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Referring to fig. 1, fig. 1 is a schematic structural diagram of an agricultural product tracing device based on a blockchain in a hardware operating environment according to an embodiment of the present invention.
As shown in fig. 1, the agricultural product tracing apparatus based on the blockchain may include: a processor 1001, such as a Central Processing Unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Wherein a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may include a Display screen (Display), and the optional user interface 1003 may further include a standard wired interface and a wireless interface, and the wired interface for the user interface 1003 may be a USB interface in the present invention. The network interface 1004 may optionally include a standard wired interface, a WIreless interface (e.g., a WIreless-FIdelity (WI-FI) interface). The Memory 1005 may be a Random Access Memory (RAM) Memory or a Non-volatile Memory (NVM), such as a disk Memory. The memory 1005 may alternatively be a storage device separate from the processor 1001.
Those skilled in the art will appreciate that the configuration shown in fig. 1 does not constitute a limitation of a blockchain-based agricultural product provenance apparatus, and may include more or fewer components than shown, or some components in combination, or a different arrangement of components.
As shown in FIG. 1, memory 1005, identified as a computer storage medium, may include an operating system, a network communication module, a user interface module, and a blockchain-based agricultural commodity prover.
In the agricultural product tracing apparatus based on the block chain shown in fig. 1, the network interface 1004 is mainly used for connecting a background server and performing data communication with the background server; the user interface 1003 is mainly used for connecting user equipment; the agricultural product tracing device based on the block chain calls an agricultural product tracing program based on the block chain stored in the memory 1005 through the processor 1001, and executes the agricultural product tracing method based on the block chain provided by the embodiment of the invention.
Based on the hardware structure, the embodiment of the agricultural product tracing method based on the block chain is provided.
Referring to fig. 2, fig. 2 is a schematic flow chart of a first embodiment of the agricultural product tracing method based on the blockchain of the present invention, and proposes the first embodiment of the agricultural product tracing method based on the blockchain of the present invention.
In a first embodiment, the agricultural product tracing method based on the blockchain comprises the following steps:
step S10: and when the source tracing query instruction is received, determining the batch information of the agricultural product to be queried according to the source tracing query instruction.
The main execution body of this embodiment is the agricultural product tracing apparatus based on the blockchain, where the agricultural product tracing apparatus based on the blockchain has functions of data processing, data communication, program operation, and the like, and the agricultural product tracing apparatus based on the blockchain may be a computer apparatus such as a server, and this embodiment takes the server as an example for description, and of course, other apparatuses having similar functions may also be used, and this embodiment is not limited thereto.
In order to facilitate implementation and maintenance of the process according to the present invention, a bas (block chain as a Service) platform system is configured on the server, and the bas platform may also be an execution subject of this embodiment. The Baas platform can comprise an application layer, a functional layer, a data acquisition layer and a data storage layer. As for the construction method of the Baas platform, a mature technology exists, and this embodiment is not described herein again.
The agricultural products may be honey, vegetables, and the like, and the honey is taken as an example in the present embodiment. For the convenience of management, the honey products are produced and sold with corresponding batch information, and the batch information is unique and corresponds to each honey product. Specifically, the batch information may include a shipment batch number, a canning batch number, and the like. The batch information may be a field composed of numbers and/or letters. The tracing query instruction carries information related to agricultural products to be queried, and batch information can be obtained by extracting and analyzing the information.
The source-tracing query instruction can be a web request, an operator can log in the Baas platform through the browser, the source-tracing query instruction is input based on a preset web page, and the server receives the source-tracing query instruction. Of course, the source query instruction may also be in other forms, which is not limited in this embodiment.
Generally, the trigger of the tracing query instruction can be a consumer, and after the consumer purchases the honey product, the consumer can trace the source of the purchased honey product. Thus, in a specific implementation, step S10 may be: when a source tracing query instruction is received, determining source tracing code information according to the source tracing query instruction; determining corresponding agricultural products to be inquired and agricultural product numbers according to the tracing code information; and searching corresponding batch information from a preset batch information table according to the agricultural product number. Of course, the source query instruction may also be triggered by a merchant or the like.
In the embodiment, after the agricultural products are produced, each agricultural product generates a unique traceability code, and the traceability code can be a bar code, a two-dimensional code or the like. For example, after honey filling is completed, a unique traceability code is generated for each honey gift box, and the traceability code is mainly used for providing traceability query information for consumers and identifying the honey gift box. The consumer may trigger a traceback query instruction by scanning the traceback code.
In practical application, each honey gift box has a unique agricultural product number, and the agricultural product number can be a field composed of numbers and/or letters. In generating the traceback code, an agricultural product number may be added to the traceback code. After receiving the traceability query instruction, the Baas platform can directly extract the agricultural product number from the traceability code information. The preset batch information table contains the corresponding relation between the agricultural product number and the batch information.
In addition, in order to keep the production information secret to a certain extent and avoid misuse of the production data, the traceability query can be encrypted. Thus, in a specific implementation, step S10 may be: when a tracing query instruction is received, acquiring a secret key carried in the tracing query instruction; determining agricultural products to be inquired according to the source tracing inquiry instruction; and verifying the agricultural product information of the agricultural product to be inquired according to the secret key to obtain batch information corresponding to the agricultural product to be inquired.
When a consumer triggers a tracing query instruction, the consumer also needs to input a secret key. The key may be stored in the Baas platform, and the consumer may obtain the key from the Baas platform through a proof of purchase after purchasing the goods. Thereby avoiding others to inquire the production data at will. After receiving the traceability query instruction, the Baas platform verifies the agricultural product to be queried according to the input secret key, judges whether the corresponding relationship between the agricultural product and the agricultural product is consistent with the preset corresponding relationship, if so, considers that the verification is passed, and extracts the corresponding batch information from the preset batch information table.
Step S20: and acquiring production information corresponding to the agricultural products to be inquired on the block chain according to the batch information based on a preset intelligent contract.
In this embodiment, the production data of agricultural products is stored in the form of a block chain, and each generation node of agricultural products can be used as one node in the block chain network. Taking honey production as an example, the block chain nodes can include a generation node, a honey collection node, a logistics node, a processing node, a sales node and the like. Each node may upload corresponding production information to the blockchain. Wherein the production information may include: production responsible person information, honey detection report, honey quantity, production time and other information.
The intelligent contract is used for realizing reading logic of the block chain data, and the Baas platform can only call the configured intelligent contract to complete the reading process of the data in the block chain. For the building method of the block chain and the intelligent contract, there are mature technologies, and this embodiment is not described herein.
It can be understood that the obtained generation information is only related to the information required by the source tracing inquiry instruction trigger, namely, only the production information of the agricultural products purchased by the consumer is inquired. A large amount of production information may exist in the block chain, such as production information of the honey gift box a, production information of the honey gift box C, and production information of the honey gift box C. When the agricultural product to be inquired is determined to be the honey gift box A, the corresponding production information is obtained according to the batch information corresponding to the honey gift box A, and the data obtaining efficiency is improved. Of course, there may be a plurality of agricultural products to be queried each time, and this embodiment is not limited thereto.
Step S30: and transmitting the production information to the tracing terminal so that the tracing terminal can display the production information.
The source tracing terminal is a trigger terminal of the source tracing query instruction, and the source tracing terminal may be a mobile phone, a tablet, a computer, or the like, and certainly may also be a dedicated source tracing query device. After a consumer triggers a traceability query instruction through the traceability terminal, the Baas platform queries relevant production information according to the traceability query instruction and feeds the queried production information back to the traceability terminal, so that the consumer can browse the whole production process of agricultural products, and authenticity of the agricultural products is distinguished. If the quality of the purchased agricultural products is found to be problematic, the source of the problems can be traced through the production information.
In the first embodiment, a traceability channel of an agricultural product is established by using a block chain technology, and the production data of the agricultural product is guaranteed not to be tampered by using the non-tampering property of the block chain, so that the reliability is improved. Meanwhile, the multicenter of the block chain is highly matched with the multi-node characteristics of agricultural product production, so that each processing flow of the agricultural product can form a data record, and the monitoring of the whole flow is facilitated. When tracing, the data on the block chain is searched, so that the corresponding production data can be quickly acquired, and the product tracing is more convenient and more reliable.
Referring to fig. 3, fig. 3 is a schematic flowchart of a traceability method of agricultural products based on a blockchain according to a second embodiment of the present invention.
In the second embodiment, a block chain construction flow involved in the production process of agricultural products is mainly explained. Before the step S10, the method further includes:
step S01: and when the uplink request is received, acquiring the agricultural product information according to the uplink request.
The uplink request may be a web request, which refers to a web request triggered when each production node of the agricultural product needs to upload agricultural product information to the blockchain after production before or after production. The agricultural product information may include: production responsible person information, honey detection report, honey quantity, production time and other information. Since the production nodes are different and the agricultural product information is also different, the embodiment takes honey production as an example for explanation.
The first node of honey production may be a production node. The node corresponds to a bee field from which honey is sourced, and a bee field manager periodically checks the bee field and uploads the checked information to a block chain. Specifically, the agricultural product information uploaded by the production node may include hive information, information of a person in charge of a bee space, information of a bee space, inspection information, information of an operator, and the like.
The second node of honey production may be a honey receiving node. The node is also in the bee field, but the honey collecting node only uploads the agricultural product information when honey is collected. Specifically, the agricultural product information uploaded by the honey receiving node may include honey receiving time, honey receiving weight, inspection information, operator information, and the like.
The subsequent nodes for honey production also comprise logistics nodes, processing nodes and sales nodes. Wherein, because honey needs a lot of transports in the in-process from production to selling, consequently, the commodity circulation node can set up a plurality of nodes according to the demand. Of course, other nodes may also be included, and the agricultural product information uploaded by each node may also be set according to requirements, which is not limited in this embodiment.
Step S02: and determining a target block chain according to the agricultural product information.
In order to facilitate management and query of data, a plurality of block chains can be constructed according to relevant conditions of agricultural products. For example, honey produced in region a is used as one blockchain, and honey produced in region B is used as another blockchain. Alternatively, the honey sold in region C is used as one blockchain, and the honey sold in region D is used as another blockchain. Of course, the block chain de-setting method may also refer to parameters such as time, which is not limited in this embodiment.
After receiving the uplink request, the Bass platform can inquire the existing block chain when preparing uplink, and judge whether the block chain corresponding to the agricultural product information of the current uplink exists. If yes, the block chain is used as a target block chain; if not, a new blockchain is generated. Generally, for intermediate nodes in the honey production flow, the target blockchain can be queried in the existing blockchain due to the existence of upstream production nodes. For the initial node of the honey production process, the situation that the target blockchain does not exist in the existing blockchain may exist, and a new blockchain is needed.
Step S03: and acquiring current node information, and uploading the agricultural product information and the current node information to a target block chain.
In order to further improve the production information of the agricultural products, the agricultural product information and the current node information can be uploaded to the target block chain at the same time. The current node information may be a location of the logistics node, administrator information, or the like, or a location of the sales node and salesman information, or the like. The current node information may be set according to the condition of the trigger node of the uplink request, which is not limited in this embodiment.
After integrating information (agricultural product information and current node information) to be linked, the Bass platform calls configured intelligent contracts, encryption algorithms and the like to generate new blocks, and then the new blocks are added to a target block chain. For the data uplink process, a mature technology is also available, and the detailed description of the embodiment is omitted here.
Generally, various tests are required in the production process of agricultural products to ensure the relevant standards of the symbols of the produced agricultural products. Such as a sample report, a sifted sample report, a blended sample report, an inner package sample report, an outer package sample report, and the like. The partial data is also the data which is most easily tampered in the traditional tracing. Therefore, in order to improve the reliability of the data, the agricultural product information uploaded by each node needs to be verified.
In a specific implementation, step S03 may be: obtaining a verification report in the agricultural product information; generating a corresponding current check code according to the verification report based on a preset check algorithm; and acquiring current node information, generating an uplink block according to the agricultural product information, the current check code and the current node information, and adding the uplink block to a target block chain.
In the embodiment, the verification report in the agricultural product information is verified during data chaining, so that the verification report is prevented from being tampered. The preset check algorithm can be a hash algorithm, and the current check code is a hash value obtained by calculating the verification report based on the hash algorithm. By linking the current check code together, the verification report can be verified in the subsequent process, and if the verification report is inconsistent, the verification report is falsified.
In the specific implementation, before acquiring the current node information, generating a uplink block according to the agricultural product information, the current check code and the current node information, and adding the uplink block to the target block chain, the method further includes: acquiring an original check code in a target block chain; comparing the current check code with the original check code to obtain a comparison result; and when the comparison result is that the current check code is consistent with the original check code, executing the steps of acquiring the current node information, generating an uplink block according to the agricultural product information, the current check code and the current node information, and adding the uplink block to the target block chain.
It will be appreciated that the original check code uses the same check algorithm as the current check code. If the current check code is consistent with the original check code, the verification report is not tampered, and the uplink operation can be executed. In addition, since each node in the honey production process may generate a new verification report, only the existing verification report is verified during verification. The current check code may include a check code of a newly generated report, and when the current check code is compared with the original check code, only the check codes corresponding to the common report are compared.
In this embodiment, after comparing the current check code with the original check code and obtaining a comparison result, the method further includes: when the comparison result is that the current check code is inconsistent with the original check code, calling a preset consensus algorithm to determine a credible check code; acquiring credible agricultural product information corresponding to the credible check code; correspondingly, acquiring current node information, generating a cochain block according to the agricultural product information, the current check code and the current node information, and adding the cochain block to a target block chain, including: and acquiring current node information, generating a uplink block according to the credible agricultural product information, the credible check code and the current node information, and adding the uplink block to a target block chain.
It can be understood that, if the comparison is inconsistent, it indicates that the verification report is tampered, at this time, a preset consensus algorithm is called to verify the verification report, and a trusted check code corresponding to the trusted verification report is obtained, where the trusted check code may be different from both the current check code and the original check code. The credibility verification report is used for correcting the tampered agricultural product information, so that the data in the block chain has higher credibility. The consensus algorithm may be a POW (work proof) algorithm, a POS (point of sale) algorithm, or a PBFT (Practical Byzantine fault tolerance) algorithm, and the consensus algorithm may be set as needed, which is not limited in this embodiment.
In a second embodiment, agricultural product information uploaded by each agricultural product production node by the Bass platform is added into a block chain, so that a traceability system based on the block chain is constructed. The agricultural products have high-feasibility production data, so that the traceability is more reliable. In the embodiment, important data in agricultural product production is verified, so that the reliability is further improved.
In addition, an embodiment of the present invention further provides a storage medium, where an agricultural product tracing program based on a blockchain is stored on the storage medium, and when executed by a processor, the agricultural product tracing program based on the blockchain implements the steps of the agricultural product tracing method based on the blockchain as described above.
Since the storage medium adopts all technical solutions of all the embodiments, at least all the beneficial effects brought by the technical solutions of the embodiments are achieved, and no further description is given here.
In addition, referring to fig. 4, fig. 4 is a structural block diagram of a first embodiment of the agricultural product traceability system based on the blockchain according to the present invention, and an embodiment of the present invention further provides an agricultural product traceability system based on the blockchain.
In this embodiment, the agricultural product traceability system based on the blockchain includes:
the receiving module 10 is configured to determine batch information of the agricultural product to be queried according to the traceability query instruction when the traceability query instruction is received;
the information invoking module 20 is configured to, based on a preset intelligent contract, obtain production information corresponding to the agricultural product to be queried on the block chain according to the batch information;
and the feedback module 30 is configured to transmit the production information to the tracing terminal, so that the tracing terminal displays the production information.
In the embodiment, a traceability channel of the agricultural product is established by using a block chain technology, and the production data of the agricultural product is ensured not to be tampered by using the non-tampering property of the block chain, so that the reliability is improved. Meanwhile, the multicenter of the block chain is highly matched with the multi-node characteristics of agricultural product production, so that each processing flow of the agricultural product can form a data record, and the monitoring of the whole flow is facilitated. When tracing, the data on the block chain is searched, so that the corresponding production data can be quickly acquired, and the product tracing is more convenient and more reliable.
In an embodiment, the block chain-based agricultural product traceability system further includes an uplink module, where the uplink module is configured to obtain agricultural product information according to an uplink request when the uplink request is received; determining a target block chain according to the agricultural product information; and acquiring current node information, and uploading the agricultural product information and the current node information to a target block chain.
In an embodiment, the uplink module is further configured to obtain a verification report in the agricultural product information; generating a corresponding current check code according to the verification report based on a preset check algorithm; and acquiring current node information, generating an uplink block according to the agricultural product information, the current check code and the current node information, and adding the uplink block to a target block chain.
In an embodiment, the uplink module is further configured to obtain an original check code in the target block chain; comparing the current check code with the original check code to obtain a comparison result; and when the comparison result is that the current check code is consistent with the original check code, executing the steps of acquiring the current node information, generating an uplink block according to the agricultural product information, the current check code and the current node information, and adding the uplink block to the target block chain.
In an embodiment, the uplink module is further configured to call a preset consensus algorithm to determine the trusted check code when the comparison result is that the current check code is inconsistent with the original check code; acquiring credible agricultural product information corresponding to the credible check code; and acquiring current node information, generating a uplink block according to the credible agricultural product information, the credible check code and the current node information, and adding the uplink block to a target block chain.
In an embodiment, the receiving module 10 is further configured to determine, when the source tracing query instruction is received, source tracing code information according to the source tracing query instruction; determining corresponding agricultural products to be inquired and agricultural product numbers according to the tracing code information; and searching corresponding batch information from a preset batch information table according to the agricultural product number.
In an embodiment, the receiving module 10 is further configured to, when receiving the source tracing query instruction, obtain an encryption key carried in the source tracing query instruction; determining agricultural products to be inquired according to the source tracing inquiry instruction; and verifying the agricultural product information of the agricultural product to be inquired according to the secret key to obtain batch information corresponding to the agricultural product to be inquired.
Other embodiments or specific implementation manners of the block chain-based agricultural product tracing apparatus according to the present invention may refer to the above method embodiments, and are not described herein again.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments. In the unit claims enumerating several means, several of these means may be embodied by one and the same item of hardware. The use of the words first, second, third, etc. do not denote any order, but rather the words first, second, third, etc. are to be interpreted as names.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present invention or a part contributing to the prior art may be embodied in the form of a software agricultural product, where the computer software agricultural product is stored in a storage medium (e.g., a Read Only Memory (ROM)/Random Access Memory (RAM), a magnetic disk, an optical disk), and includes a plurality of instructions for enabling a terminal device (which may be a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.