Blockchain-based agricultural product flow traceability method, device, equipment and medium
By using a blockchain-based agricultural product traceability method, and leveraging cryptographic signatures and adaptable quantification models, traceability processes and data display templates are generated, solving the data security and adaptability issues of traditional traceability systems and achieving efficient and flexible agricultural product traceability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANGDONG VOCATIONAL COLLEGE OF SCI & TRADE
- Filing Date
- 2026-04-29
- Publication Date
- 2026-07-10
AI Technical Summary
Traditional agricultural product traceability systems suffer from low data security and credibility, poor system adaptability and flexibility, inability to adapt to dynamic changes in the agricultural product supply chain, and prominent information silo problems, making it difficult to achieve friendly interaction among multiple roles.
A blockchain-based agricultural product traceability method is adopted. Multi-source IoT data is processed through encrypted signatures to generate traceability metadata, which is then encapsulated into on-chain transactions through a blockchain SDK. The transaction is verified using a pre-set consensus node cluster, and a traceability process and data display template corresponding to the agricultural product category to be traced are generated. This achieves full traceability and tamper-proof data, and is combined with an adaptive quantification model for matching calculation and display.
It improves the credibility and traceability efficiency of agricultural product traceability data, achieves high system flexibility and adaptability, supports multi-role interaction, solves the data security and adaptability problems of traditional traceability systems, and is adaptable to different agricultural product categories and supply chain scenarios.
Smart Images

Figure CN122367508A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of product traceability technology, and in particular to a blockchain-based method, apparatus, equipment and medium for tracing the process of agricultural products. Background Technology
[0002] As consumers continue to pay increasing attention to the quality and safety of agricultural products, agricultural product traceability systems have become an important support for safeguarding food safety and strengthening consumer trust. Traditional agricultural product traceability systems generally use a centralized database architecture to store traceability data, which has significant shortcomings in data security and reliability. The centralized storage model is prone to the risk of data tampering, and some market entities, driven by profit, arbitrarily modify traceability information, directly leading to distorted traceability results and failing to play the actual regulatory role of traceability. At the same time, traditional systems are mostly customized designs for single categories and fixed processes, with poor system adaptability and flexibility. They cannot meet the actual needs of the dynamic changes and diverse categories of the agricultural product supply chain, and the data of each link such as production, processing, logistics, and sales are fragmented, resulting in prominent information silos and low efficiency in data integration and sharing.
[0003] Blockchain technology, with its decentralized, immutable, and fully traceable characteristics, provides a new technological path for agricultural product supply chain traceability. Related application research is gradually underway, but existing solutions still have many limitations. Most solutions focus only on data storage on the blockchain, failing to fully adapt to the complex and dynamic characteristics of the agricultural product supply chain. Smart contracts have limited functionality and cannot support flexible and configurable traceability processes. The systems are not sufficiently integrated with actual agricultural production scenarios, and the access and application of multi-source IoT data are inadequate. Furthermore, there is a lack of user-friendly interactive designs for farmers, businesses, regulatory agencies, and consumers. Against this backdrop, developing an agricultural product traceability solution that combines high data reliability, high system flexibility, and deep integration with IoT data has become a critical issue that urgently needs to be addressed in the field of agricultural product quality and safety management. Summary of the Invention
[0004] In order to overcome the shortcomings of the existing technology, the purpose of this invention is to provide a blockchain-based method, device, equipment and medium for tracing agricultural products, which aims to improve the credibility of data and increase traceability efficiency.
[0005] The first aspect of this invention provides a blockchain-based method for tracing agricultural products, comprising: acquiring preprocessed data; performing encryption and signature processing on the preprocessed data to obtain encrypted signature data; acquiring preset traceability business rules; generating traceability metadata based on the traceability business rules; encapsulating the encrypted signature data and the traceability metadata into an on-chain transaction using a blockchain SDK; verifying the on-chain transaction using a preset blockchain consensus node cluster; if the verification is successful, writing the on-chain transaction into a distributed ledger to obtain on-chain traceability data; acquiring the category of agricultural product to be traced; calling a pre-trained adaptive quantification model to perform matching calculations based on the category of agricultural product to be traced and the traceability metadata to generate a traceability process and data display template corresponding to the category of agricultural product to be traced; and retrieving and displaying the corresponding target on-chain traceability data from the distributed ledger based on the traceability process and the data display template.
[0006] Optionally, in a first implementation of the first aspect of the present invention, the step of obtaining preprocessed data and performing encrypted signature processing on the preprocessed data to obtain encrypted signature data includes: obtaining multi-source IoT data; performing noise reduction processing on the multi-source IoT data using a noise reduction algorithm to obtain noise-reduced data; performing normalization processing on the noise-reduced data using a normalization algorithm to obtain the preprocessed data; obtaining a preset unique private key; and performing digital signature processing on the preprocessed data using a hash algorithm and an asymmetric encryption algorithm based on the unique private key to obtain the encrypted signature data.
[0007] Optionally, in a second implementation of the first aspect of the present invention, the step of obtaining preset traceability business rules and generating traceability metadata based on the traceability business rules includes: obtaining a visual process orchestration instruction; defining a traceability step list, data template fields, audit rules, and chaincode version number based on the visual process orchestration instruction; integrating the traceability step list, the data template fields, the audit rules, and the chaincode version number to obtain the traceability business rules; and using a data serialization algorithm to perform structured encapsulation processing on the traceability business rules to obtain the traceability metadata.
[0008] Optionally, in a third implementation of the first aspect of the present invention, the step of encapsulating the encrypted signature data and the traceability metadata into an on-chain transaction via a blockchain SDK includes: using a serialization algorithm to convert the encrypted signature data and the traceability metadata into a blockchain-recognizable byte stream format to obtain transaction payload data; calling the transaction proposal construction interface of the blockchain SDK to construct a transaction proposal based on the transaction payload data; and calling the transaction encapsulation interface of the blockchain SDK to encapsulate the transaction proposal into the on-chain transaction.
[0009] Optionally, in the fourth implementation of the first aspect of the present invention, the step of verifying the on-chain transaction through a preset blockchain consensus node cluster, and writing the on-chain transaction into a distributed ledger to obtain on-chain traceability data if the verification passes, includes: sending the on-chain transaction to the preset blockchain consensus node cluster, performing multi-node verification of the on-chain transaction using a consensus algorithm; if the verification passes, packaging the on-chain transaction into a block using a sorting node block generation algorithm; and writing the block into the distributed ledger in a hash chain structure using a hash algorithm to obtain the on-chain traceability data.
[0010] Optionally, in a fifth implementation of the first aspect of the present invention, the adaptation quantification model includes a process link matching calculation module, a template adaptation calculation module, a rule support evaluation module, a category adaptation calculation module, and a traceability scheme generation module. The process link matching calculation module, the template adaptation calculation module, and the rule support evaluation module are respectively connected to the category adaptation calculation module, and the category adaptation calculation module is connected to the traceability scheme generation module. The step of calling the pre-trained adaptation quantification model to perform matching calculations based on the category of the agricultural product to be traced and the traceability metadata to generate a traceability process and data display template corresponding to the category of the agricultural product to be traced includes: performing matching calculations based on the process link matching calculation module on the... The process alignment and matching calculation between the agricultural product category to be traced and the traceability metadata is performed to obtain the process alignment degree; based on the template adaptability calculation module, the data field compatibility adaptation calculation between the agricultural product category to be traced and the traceability metadata is performed to obtain the data template adaptability degree; based on the rule support evaluation module, the business rule compliance calculation between the agricultural product category to be traced and the traceability metadata is performed to obtain the rule support degree; the process alignment degree, the data template adaptability degree, and the rule support degree are input into the category adaptability calculation module for weighted fusion calculation to obtain the category adaptability degree; based on the traceability scheme generation module, the category adaptability degree is used to generate a scheme to obtain the traceability process and the data display template.
[0011] Optionally, in a sixth implementation of the first aspect of the present invention, the step of retrieving and displaying the corresponding target chain traceability data from the distributed ledger based on the traceability process and the data display template includes: obtaining current operation role information, calling a pre-trained permission model, and determining the data permission range based on the current operation role information; retrieving the target chain traceability data corresponding to the data permission range from the distributed ledger based on the traceability process and the data display template; and generating and displaying a visual traceability map based on the target chain traceability data.
[0012] A second aspect of the present invention provides a blockchain-based agricultural product traceability device, comprising: an encryption signature module for acquiring preprocessed data and performing encryption signature processing on the preprocessed data to obtain encrypted signature data; a traceability metadata generation module for acquiring preset traceability business rules and generating traceability metadata based on the traceability business rules; a verification module for encapsulating the encrypted signature data and the traceability metadata into an on-chain transaction using a blockchain SDK, verifying the on-chain transaction through a preset blockchain consensus node cluster, and writing the on-chain transaction into a distributed ledger if the verification is successful to obtain on-chain traceability data; a matching calculation module for acquiring the category of agricultural product to be traced, calling a pre-trained adaptation metric model to perform matching calculations based on the category of agricultural product to be traced and the traceability metadata, and generating a traceability process and data display template corresponding to the category of agricultural product to be traced; and a display module for retrieving the corresponding target on-chain traceability data from the distributed ledger based on the traceability process and the data display template and displaying it.
[0013] A third aspect of the present invention provides a blockchain-based agricultural product process traceability device, the blockchain-based agricultural product process traceability device comprising: a memory and at least one processor, the memory storing instructions; at least one processor calling the instructions in the memory to cause the blockchain-based agricultural product process traceability device to execute each step of the blockchain-based agricultural product process traceability method described above.
[0014] A fourth aspect of the present invention provides a computer-readable storage medium storing instructions that, when executed by a processor, implement the steps of the blockchain-based agricultural product process traceability method described in any of the preceding claims.
[0015] In the technical solution of this invention, preprocessed data is first acquired, and then encrypted and signed to obtain encrypted signature data. Pre-defined traceability business rules are acquired, and traceability metadata is generated based on the traceability business rules. Then, the encrypted signature data and traceability metadata are encapsulated into an on-chain transaction through a blockchain SDK. The on-chain transaction is verified through a pre-defined blockchain consensus node cluster. If the verification is successful, the on-chain transaction is written into a distributed ledger to obtain on-chain traceability data. Subsequently, the category of agricultural product to be traced is acquired, and a pre-trained adaptive metric model is called to perform matching calculations based on the category of agricultural product to be traced and the traceability metadata to generate a traceability process and data display template corresponding to the category of agricultural product to be traced. Finally, based on the traceability process and data display template, the corresponding target on-chain traceability data is retrieved from the distributed ledger and displayed, aiming to improve data credibility and traceability efficiency. Attached Figure Description
[0016] Figure 1 A logical flowchart of the blockchain-based agricultural product traceability method provided in this embodiment of the invention; Figure 2 A schematic diagram of the structure of a blockchain-based agricultural product process traceability device provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of the structure of a blockchain-based agricultural product process traceability device provided in an embodiment of the present invention. Detailed Implementation
[0017] This invention provides a blockchain-based method, apparatus, device, and medium for agricultural product process traceability. In this invention, the terms "first," "second," "third," "fourth," etc. (if applicable) in the specification, claims, and accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be implemented in a sequence other than that illustrated or described herein. Furthermore, the terms "comprising" or "having" and any variations thereof are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or device that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or devices.
[0018] For ease of understanding, the specific process of the embodiments of the present invention is described below. Please refer to [link / reference]. Figure 1 One embodiment of the blockchain-based agricultural product traceability method in this invention includes: 101. Obtain preprocessed data, and perform encryption and signature processing on the preprocessed data to obtain encrypted signature data; In this embodiment, the preprocessed data originates from multi-source IoT data across the entire agricultural product supply chain, collected by devices such as temperature and humidity sensors, pH sensors, GPS positioning modules, RFID electronic tags, and industrial cameras. This data covers growth environment data, processing data, logistics data, quality inspection data, and main business data. Noise reduction processing is performed on the multi-source IoT data to eliminate noise interference, and a normalization algorithm is used to eliminate dimensional differences between different indicators, mapping the original collected values to a unified range to obtain standardized preprocessed data. Based on the network environment and access control provided by the flexible layered modular consortium blockchain network, and relying on the node identity identification system under the multi-organization networking mode, a unique private key preset by the collection device is obtained. Combining hash algorithms and asymmetric encryption algorithms, digital signature processing is performed on the preprocessed data. A data digest is generated through the hash algorithm, and then the digest is encrypted using an asymmetric encryption algorithm to form an unforgeable signature information, ultimately obtaining encrypted signature data. By employing a digital signature method that combines a unique private key with hash algorithms and asymmetric encryption algorithms, and integrating it with the identity system managed by the MSP member services of the consortium blockchain, end-to-end data tamper-proofing and forgery prevention are achieved. This ensures the integrity and trustworthiness of pre-processed data, while also guaranteeing the security of data transmission and subsequent on-chain processes. This prevents data from being maliciously tampered with or forged, providing underlying support for the credibility of agricultural product traceability. The modular networking design allows the data collection and signature process to be expanded as needed, adapting to different agricultural product categories and supply chain scenarios, thus enhancing the system's flexibility and adaptability.
[0019] 102. Obtain preset traceability business rules, and generate traceability metadata based on the traceability business rules; In this embodiment, the preset traceability business rules are generated based on visual process orchestration instructions. Administrators issue visual process orchestration instructions through a graphical interface, and based on these instructions, define the traceability link list, data template fields, audit rules, and chaincode version number. These elements are integrated to form complete traceability business rules. Then, a data serialization algorithm is used to perform structured encapsulation processing on the traceability business rules to generate traceability metadata. This process is supported by a modular design of smart contract groups. Five core contracts—collection and verification contracts, audit and on-chain contracts, query and parsing contracts, early warning trigger contracts, and feedback processing contracts—are linked in an event-driven manner, providing modular capabilities for the definition and execution of traceability business rules. The generated traceability metadata can be parsed in real time by the underlying chaincode, and business rules can be switched without restarting the service, achieving dynamic scheduling of multiple rules adapted to a single chaincode.
[0020] 103. The encrypted signature data and the traceability metadata are encapsulated into an on-chain transaction using a blockchain SDK. The on-chain transaction is verified by a preset blockchain consensus node cluster. If the verification is successful, the on-chain transaction is written into a distributed ledger to obtain on-chain traceability data. In this embodiment, a serialization algorithm is used to convert the encrypted signature data and traceability metadata into a blockchain-recognizable byte stream format to obtain transaction payload data. The transaction proposal construction interface of the blockchain SDK is then called to construct a transaction proposal based on the transaction payload data. Finally, the transaction encapsulation interface is called to encapsulate the transaction proposal into an on-chain transaction. A trusted transaction is initiated via the Fabric SDK. The transaction structure integrates the encrypted signature data, preprocessed data, traceability metadata, timestamp, and batch ID to form a complete transaction carrier. The on-chain transaction is sent to a pre-defined blockchain consensus node cluster. The Kafka-Raft high-efficiency consensus mechanism is used to perform multi-node verification. Through multi-node collaborative verification of the transaction's legality and integrity, the consensus efficiency is determined by the number of consensus nodes, node message latency, and transaction concurrency, ensuring efficient and consistent transaction verification. If the verification passes, the on-chain transactions are packaged into blocks, and the blocks are written into the distributed ledger in a hash chain structure using the SHA-256 hash algorithm. The current block hash is generated by the hash of the previous block and the hash of the current block's transaction list. Any data modification will cause the hash chain to break, achieving three-level verification of data, blocks, and the ledger. Ultimately, immutable on-chain traceability data is obtained, realizing full traceability and tamper-proof data. The three-level verification mechanism further enhances the credibility and security of the data, providing reliable underlying data support for subsequent flexible traceability and multi-role interaction. The distributed ledger's storage mode avoids the tampering risk of centralized storage, ensuring the long-term credibility of traceability data.
[0021] 104. Obtain the category of agricultural product to be traced, call the pre-trained adaptive quantification model to perform matching calculations based on the category of agricultural product to be traced and the traceability metadata, and generate the traceability process and data display template corresponding to the category of agricultural product to be traced; In this embodiment, the category of agricultural product to be traced is obtained, and a pre-trained adaptation quantification model is invoked. This model includes a process link matching calculation module, a template adaptation calculation module, a rule support evaluation module, a category adaptation calculation module, and a traceability scheme generation module. The process link matching calculation module, the template adaptation calculation module, and the rule support evaluation module are respectively connected to the category adaptation calculation module, and the category adaptation calculation module is connected to the traceability scheme generation module. The process link matching calculation module performs process link alignment and matching calculations between the agricultural product category to be traced and the traceability metadata. First, it extracts a sequence of links covering the entire chain of production, processing, logistics, and sales from the business scenario of the agricultural product category to be traced. Simultaneously, it extracts a predefined list of traceability links from the traceability metadata. The two types of link sequences are aligned and matched one by one, counting the number of links with completely overlapping business meanings and calculating the overlap ratio. Then, the longest common subsequence algorithm is used to analyze the sequential consistency of the link sequences and calculate the sequence fit ratio. Finally, the process link matching degree is obtained by multiplying the overlap ratio by the sequence fit ratio. The template adaptation calculation module performs data field compatibility adaptation calculations between the agricultural product category to be traced and the traceability metadata. It extracts the required set of data fields from the collection requirements of the agricultural product category to be traced, and simultaneously extracts a predefined set of data template fields from the traceability metadata. The two types of field sets are matched and compared, counting the number of fields with completely matching business meanings and calculating the field matching ratio. Finally, format compatibility checks are performed on each matched field, and the average format is calculated. The format compatibility score is calculated, and the data template fit is obtained by multiplying the field matching degree ratio by the average format compatibility score. Based on the rule support assessment module, the business rule compliance calculation is performed on the agricultural product category to be traced and the traceability metadata. The required set of audit rules is extracted from the business control requirements of the agricultural product category to be traced, and the predefined set of audit rules is extracted from the traceability metadata. The two sets of rules are matched and compared, the number of rules with completely consistent control objectives is counted and the rule coverage ratio is calculated, and then the logical matching degree is checked for each covered rule and the average rule matching degree score is calculated. Finally, the rule support is obtained by multiplying the rule coverage ratio by the average rule matching score. The process link matching degree, data template fit, and rule support are input into the category fit calculation module, and a weighted fusion calculation is performed according to the category weight coefficient, where the weight coefficient satisfies the constraint that the sum is 1. The category fit is obtained through the weighted summation formula. Then, the traceability scheme generation module performs scheme generation processing on the category fit to obtain the traceability process and data display template corresponding to the agricultural product category to be traced.By employing multi-dimensional, refined calculations and weighted fusion to achieve category adaptation, this approach differs from traditional, simple matching methods, significantly improving the accuracy and rationality of the adaptation results. The design of category rules, based on traceability metadata, within the same underlying chain enables multi-chain traceability and large-scale deployment. This overcomes the limitations of traditional traceability systems that are customized for single categories, greatly enhancing the system's flexibility and scalability. The adapted flexible traceability process also provides personalized query and input interfaces for subsequent multi-role interactions, effectively improving user experience and solving the problems of fixed processes, poor adaptability, insufficient flexibility, and difficulty in adapting to dynamic changes in the supply chain inherent in traditional traceability systems.
[0022] 105. Based on the traceability process and the data display template, retrieve the corresponding target chain traceability data from the distributed ledger and display it.
[0023] In this embodiment, the current operating role information is obtained, a pre-trained permission model is invoked, and based on the RBAC permission hierarchical control mechanism, combined with the triple permission definition of role, data scope, and operation permission, the data permission scope is determined according to the current operating role information. This ensures that different roles can only access data within their authorized scope, protecting business privacy. Based on the adapted traceability process and data display template, the target chain traceability data corresponding to the data permission scope is retrieved from the distributed ledger. A simplified QR code query entry is provided for the consumer role, automatically parsing the batch identifier and matching the corresponding traceability process and template. A visual traceability map can be generated and displayed without manual input.
[0024] After generating and displaying a visual traceability map based on the target chain's traceability data, the system further undertakes multi-role interaction and regulatory value-added needs: receiving feedback data submitted by multiple roles, including quality problem reports submitted by consumers after scanning codes, production anomaly information reported by production entities, and verification opinions proposed by regulatory agencies. The system performs compliance review on the feedback content, and encapsulates the approved feedback data into a structure containing feedback content, submission timestamp, submitting user identifier, and review results. After being verified by blockchain consensus, it is written into the distributed ledger to form an immutable closed-loop feedback data. This feedback data can automatically trigger supplier rating updates and quality anomaly warnings. Quality monitoring is conducted based on on-chain traceability data and closed-loop feedback data. Preprocessed data consists of standardized data obtained by denoising and normalizing the original IoT data corresponding to the on-chain traceability data to eliminate dimensional differences. This preprocessed data is then compared with preset quality and safety thresholds based on national and industry quality and safety standards and production control regulations for different agricultural product categories. Simultaneously, the compliance audit results of the closed-loop feedback data are considered. If the preprocessed data exceeds the corresponding threshold range or the closed-loop feedback data points to a clear quality problem, a quality anomaly warning is triggered; otherwise, no warning is triggered, achieving more accurate automatic monitoring and proactive alerting of quality anomalies. Furthermore, correlation analysis is performed between the growth environment data and quality inspection data in the on-chain traceability data, using a Peel method. The correlation coefficient is used to calculate the correlation between two factors. By quantifying the linear relationship between growth environmental factors (such as temperature and humidity, soil pH, light duration, and water and fertilizer application) and agricultural product quality indicators (such as pesticide residues, heavy metal content, nutrient components, and microbial indicators), it accurately identifies key environmental variables affecting product quality and clarifies the positive or negative impact of fluctuations in different environmental parameters on quality indicators. This provides a quantifiable scientific basis for optimizing agricultural production processes, controlling environmental parameters, and improving planting and breeding techniques. Irrigation frequency, cold chain temperature control range, or light duration can be adjusted based on the correlation results to reduce quality anomalies at the source. Simultaneously, the optimized environmental control rules are updated to traceability metadata, achieving a closed-loop iteration of production optimization and traceability rules. When a quality warning or feedback anomaly is triggered, the problem batch is automatically located through a smart contract, locking the corresponding block height, transaction identifier, and product identifier. Combined with the aforementioned correlation analysis results, the specific environmental anomaly that caused the quality problem can be quickly traced, enabling precise traceability and efficient emergency recall of problematic agricultural products. This also provides a clear direction for targeted rectification of subsequent production processes.
[0025] In this embodiment of the invention, the step of obtaining preprocessed data and performing encrypted signature processing on the preprocessed data to obtain encrypted signature data includes: obtaining multi-source IoT data; performing noise reduction processing on the multi-source IoT data using a noise reduction algorithm to obtain noise-reduced data; performing normalization processing on the noise-reduced data using a normalization algorithm to obtain the preprocessed data; obtaining a preset unique private key; and performing digital signature processing on the preprocessed data using a hash algorithm and an asymmetric encryption algorithm based on the unique private key to obtain the encrypted signature data.
[0026] In this embodiment, multi-source IoT data is acquired. This data originates from agricultural product end-to-end information collected by devices such as temperature and humidity sensors, pH sensors, GPS positioning modules, RFID electronic tags, and industrial cameras. It covers growth environment data, processing data, logistics data, quality inspection data, and main business registration data. A noise reduction algorithm is used to perform noise reduction processing on the multi-source IoT data. Sliding window mean filtering, median filtering, or wavelet denoising algorithms can be selected to eliminate noise interference in the original data, resulting in denoised data. A normalization algorithm is then used to normalize the denoised data, specifically the min-max normalization algorithm, mapping the original collected values to a unified range to eliminate dimensional differences between different indicators. The original collected values are the denoised data, and the upper and lower limits of the indicator thresholds are preset reasonable ranges for the corresponding data types. Finally, preprocessed data is obtained, providing a standardized data foundation for subsequent blockchain transaction encapsulation and compatibility calculation. Then, a pre-defined unique private key is obtained. This private key is an exclusive elliptic curve private key pre-allocated by the MSP member service management system during the consortium blockchain networking phase. It is bound to the device's physical identifier PeerID and stored in a hardware encryption module or security chip. It cannot be exported and uniquely corresponds to one collection device, used to identify the identity of the data collection entity, ensuring the non-repudiation and traceability of the signature operation. A hash algorithm and an asymmetric encryption algorithm are used to perform digital signature processing. Specifically, the SHA-256 hash algorithm and the ECC asymmetric encryption algorithm are selected. The signature formula is as follows: , in, This represents the generated cryptographic signature data. This indicates ECC asymmetric encryption operation. This represents the device's unique private key. express Hash algorithms This indicates that the preprocessed data to be signed is first processed through... A hash algorithm generates a 256-bit fixed-length digest of the preprocessed data. This digest is then encrypted using the device's unique private key via ECC asymmetric encryption, creating a signature that is uniquely linked to the data acquisition device and cannot be forged. This device-specific private key ensures end-to-end data tamper-proofing and forgery prevention, guaranteeing the integrity, reliability, and verifiability of the preprocessed data and preventing malicious alteration or forgery during transmission. Edge nodes perform data preprocessing and signing operations, effectively reducing the computational burden on cloud and blockchain nodes, improving the overall efficiency of data processing and on-chain processing, and providing high-quality, high-security underlying data support for the entire agricultural product traceability system. This also ensures the entire data process from acquisition to on-chain reliability and controllability.
[0027] In this embodiment of the invention, obtaining preset traceability business rules and generating traceability metadata based on the traceability business rules includes: obtaining a visual process orchestration instruction; defining a traceability step list, data template fields, audit rules, and chaincode version number based on the visual process orchestration instruction; integrating the traceability step list, the data template fields, the audit rules, and the chaincode version number to obtain the traceability business rules; and using a data serialization algorithm to perform structured encapsulation processing on the traceability business rules to obtain the traceability metadata.
[0028] In this embodiment, a visual process orchestration instruction is obtained. This instruction is a business configuration instruction issued by the operator through a graphical interactive interface. The logical definition of the entire agricultural product traceability process is completed by dragging and dropping components and configuring parameters. The process can be quickly built and adjusted without writing code. Based on this instruction, the following steps are defined: First, a traceability list is defined, which involves identifying and defining key links throughout the entire supply chain from production, processing, logistics to sales, based on the agricultural product category and supply chain characteristics. This forms an ordered set of links. For example, for fruits and vegetables, this can be defined as planting, harvesting, cleaning, packaging, cold chain transportation, and terminal sales, clearly defining the sequence and executing entity of each link. Second, data template fields are defined, which involves configuring the required data items and format specifications for each traceability link. For example, the planting link needs to include fields such as temperature and humidity, soil pH value, and fertilization records, while the processing link needs to include fields such as batch number, processing time, and operator identification, clearly defining field types, data formats, and whether they are mandatory. Next, audit rules are defined, which involves setting verification logic and access conditions for data collection and on-chain operations. For example, temperature and humidity data must be within a preset threshold range, and quality inspection data must meet the qualification standards before proceeding to the next link, clearly defining the triggering conditions and verification logic of the rules. Finally, a chaincode version number is defined, which specifies the smart contract version identifier corresponding to the current business rule, used to distinguish different versions of chaincode implementation, facilitating version iteration and backtracking management. The above-mentioned traceability step list, data template fields, audit rules, and chaincode version number are integrated to form complete traceability business rules. The traceability business rules are then subjected to structured encapsulation processing using a data serialization algorithm, such as Protobuf or JSON serialization algorithm, to convert the rules into a structured data format that the blockchain can recognize, thus obtaining traceability metadata.
[0029] In this embodiment of the invention, the step of encapsulating the encrypted signature data and the traceability metadata into an on-chain transaction using a blockchain SDK includes: using a serialization algorithm to convert the encrypted signature data and the traceability metadata into a blockchain-recognizable byte stream format to obtain transaction payload data; calling the transaction proposal construction interface of the blockchain SDK to construct a transaction proposal based on the transaction payload data; and calling the transaction encapsulation interface of the blockchain SDK to encapsulate the transaction proposal into the on-chain transaction.
[0030] In this embodiment, a serialization algorithm is used to convert the encrypted signature data and traceability metadata into a blockchain-recognizable byte stream format to obtain transaction payload data. The serialization algorithm can be either Protobuf or JSON serialization, converting heterogeneous signature data, metadata, and other structured information into a byte stream format to adapt to the transmission and parsing requirements of the underlying blockchain network. The transaction payload data integrates encrypted signature data, preprocessed standardized IoT data, traceability metadata, transaction timestamps, and agricultural product batch identifiers. The blockchain SDK's transaction proposal construction interface is called to construct a transaction proposal based on the transaction payload data. Specifically, the target channel and chaincode information are specified through the Fabric SDK, and the transaction payload data is used as input parameters for chaincode calls to generate an unsigned transaction proposal containing a transaction identifier, operation instructions, and payload data. Identity authentication information is also attached to ensure that the proposal is initiated only by an authorized entity. The blockchain SDK's transaction encapsulation interface is called to encapsulate the transaction proposal into an on-chain transaction. Specifically, a signing operation is performed on the transaction proposal, and the signed proposal, along with the transaction payload, timestamp, batch identifier, and other information, is integrated into an on-chain transaction conforming to the consortium blockchain specification, forming a structurally complete transaction object that can be verified by consensus nodes. The SDK-based encapsulation process ensures the security and legality of transaction generation, avoids formatting errors and security risks that may arise from manually constructing transactions, and provides a reliable transaction carrier for multi-node consensus verification and distributed ledger writing, thereby improving the efficiency and credibility of data on-chaining in the entire traceability system.
[0031] In this embodiment of the invention, the step of verifying the on-chain transaction through a preset blockchain consensus node cluster, and writing the on-chain transaction into a distributed ledger if the verification is successful, to obtain on-chain traceability data, includes: sending the on-chain transaction to the preset blockchain consensus node cluster, performing multi-node verification of the on-chain transaction using a consensus algorithm; if the verification is successful, packaging the on-chain transaction into a block using a sorting node block generation algorithm; and writing the block into the distributed ledger in a hash chain structure using a hash algorithm to obtain the on-chain traceability data.
[0032] In this embodiment, the on-chain transaction is sent to a pre-defined blockchain consensus node cluster. This cluster is a multi-node set pre-planned and deployed during the consortium blockchain networking phase. It consists of authorized nodes from multiple parties involved in agricultural product traceability, such as production entities, processing entities, logistics entities, and regulatory agencies. Each node completes identity authentication and permission allocation through the MSP member service management system, binding a unique organizational identifier and role permissions. The nodes use point-to-point communication to build a distributed consensus network. Under the Kafka-Raft consensus mechanism, the nodes in the cluster are divided into endorsement nodes and ordering nodes. The endorsement nodes are responsible for verifying the legality of transaction signatures and business rules, while the ordering nodes rely on the Kafka message queue to realize transaction time-series ordering and block encapsulation. The Raft protocol elects a leader node to coordinate the consensus process and ensure the consistency of state among multiple nodes.
[0033] In this embodiment, the Kafka-Raft consensus algorithm is used to perform multi-node verification. This algorithm combines the high-throughput message queue of Kafka with the distributed consistency characteristics of Raft, improving transaction concurrency processing capabilities while ensuring distributed consistency. Its consensus efficiency can be evaluated and optimized using a quantitative formula, the expression of which is: , in, This represents the total time required to complete consensus on a batch of transactions, and is used to measure consensus efficiency. This represents the number of consensus nodes, i.e., the total number of nodes participating in consensus verification within the cluster. The more nodes there are, the stronger the consensus's resistance to tampering and the higher its security. Node message latency refers to the average delay time for transmitting consensus messages between nodes within a cluster, which directly affects the efficiency of inter-node communication. The number of concurrent transactions represents the total number of on-chain transactions to be processed by the cluster per unit of time, reflecting the system's concurrent carrying capacity. This formula provides a quantitative basis for node configuration, network bandwidth optimization, and transaction concurrency control during the system deployment phase by quantifying the impact of node scale, message latency, and transaction concurrency on consensus time, thereby achieving a dynamic balance between consensus security and operational efficiency.
[0034] During the multi-node verification phase, on-chain transactions are broadcast to the endorsing nodes within the cluster. Each endorsing node independently performs dual verification: first, verifying the transaction's cryptographic signature by decrypting the signature using the device's public key and comparing it with the data hash digest to confirm that the data has not been tampered with and that the collecting entity is legitimate; second, verifying the transaction's business rules by comparing it with the audit rules in the traceability metadata to verify whether the data meets the category threshold and process logic. Upon successful verification, an endorsement signature is generated. When more than a preset threshold of valid endorsement signatures are collected, the transactions enter the sorting and packaging process. The sorting nodes rely on the Kafka message queue to perform time-order sorting of valid transactions, aggregating transactions according to a preset block capacity or time window to form candidate blocks. Then, a leader node is elected through the Raft protocol to coordinate the sorting nodes within the cluster to achieve consistent synchronization of the block state, ensuring that all nodes reach a consensus on the block content and order. After successful verification, the block is written to the distributed ledger in a hash chain structure using the SHA-256 hash algorithm. The block hash calculation follows the formula: , in, This represents the hash value of the current block. This represents the hash value of the preceding block, used to chain blocks together to ensure the coherence between them. This represents the aggregated hash list of all transactions within the current block. This formula enables hash chaining between blocks, and the hash of a single transaction is synchronously uploaded to the chain. A three-level verification mechanism of data, blocks, and ledger is constructed. Modification of any data or block will cause the hash chain to break, achieving data immutability and traceability. The multi-node storage mode of the distributed ledger further avoids the single point of failure and tampering risk of centralized storage, improving the robustness of the system and the credibility of the data.
[0035] In this embodiment of the invention, the adaptation quantification model includes a process step matching calculation module, a template adaptation calculation module, a rule support evaluation module, a category adaptation calculation module, and a traceability scheme generation module. The process step matching calculation module, the template adaptation calculation module, and the rule support evaluation module are respectively connected to the category adaptation calculation module, and the category adaptation calculation module is connected to the traceability scheme generation module. The step of calling the pre-trained adaptation quantification model to perform matching calculations based on the category of the agricultural product to be traced and the traceability metadata, generating a traceability process and data display template corresponding to the category of the agricultural product to be traced, includes: based on the process step matching calculation module, matching the category of the agricultural product to be traced... The process alignment and matching calculation between the category and the traceability metadata is performed to obtain the process alignment degree; based on the template adaptability calculation module, the data field compatibility adaptation calculation between the agricultural product category to be traced and the traceability metadata is performed to obtain the data template adaptability degree; based on the rule support evaluation module, the business rule compliance calculation between the agricultural product category to be traced and the traceability metadata is performed to obtain the rule support degree; the process alignment degree, the data template adaptability degree, and the rule support degree are input into the category adaptability calculation module for weighted fusion calculation to obtain the category adaptability degree; based on the traceability scheme generation module, the category adaptability degree is used to generate a scheme to obtain the traceability process and the data display template.
[0036] In this embodiment, a pre-trained adaptive quantification model is invoked to perform matching calculations based on the product category to be traced and the traceability metadata, generating a traceability process and data display template corresponding to the product category. Specifically, the process link matching calculation module performs process link alignment matching calculations between the product category to be traced and the traceability metadata. First, a sequence of links covering the entire chain of production, processing, logistics, and sales is extracted from the business scenario of the product category to be traced. At the same time, a predefined traceability link list is extracted from the traceability metadata. This list is a set of standardized traceability execution links pre-configured in the traceability metadata, covering the entire life cycle of agricultural products, including production... The process involves fixed traceability steps and their execution order, such as processing, logistics, sales, and quality inspection. Two types of step sequences are aligned and matched one by one. The number of steps with completely overlapping business meanings and execution functions is counted, and the overlap ratio is calculated by dividing the number of overlapping steps by the total number of steps. Then, the longest common subsequence algorithm is used to analyze the sequential consistency of the two types of step sequences and calculate the sequence fit ratio. This algorithm accurately identifies the sequence arrangement fit, ensuring the accuracy and reliability of the sequence consistency analysis results. Finally, the process step matching degree is obtained by multiplying the step overlap ratio by the sequence fit ratio. This matching degree reflects the production of the agricultural product category to be traced. The overlap and sequential fit between the entire supply chain, including processing and logistics, and the defined stages in the traceability metadata are analyzed. Based on the template compatibility calculation module, data field compatibility calculations are performed between the agricultural product category to be traced and the traceability metadata. The required set of data fields is extracted from the collection requirements of the agricultural product category to be traced. This set consists of business data items that must be collected for each traceability stage, including specific data items such as environmental parameters, processing parameters, logistics information, and quality inspection results. The business meaning and collection specifications of each field are clearly defined. Simultaneously, a predefined set of data template fields is extracted from the traceability metadata. This set is pre-standardized and configured within the traceability metadata. A set of general traceability data collection fields adapted to multiple categories of agricultural products, including basic traceability data items with unified format and standardization. The two sets of fields are matched and compared, the number of fields that completely match the business meaning is counted and the field matching degree ratio is calculated. Then, the format compatibility of each matching field is checked and the average format compatibility score is calculated. The format compatibility check covers the full dimensions of data format, data type, and data unit. Finally, the field matching degree ratio is multiplied by the average format compatibility score to obtain the data template fit degree. This fit degree reflects the degree of matching and format compatibility between the data fields required to be collected for the agricultural product category to be traced and the data template fields in the traceability metadata.The rule support assessment module calculates the compliance of business rules between the agricultural product category to be traced and the traceability metadata. It extracts the required set of audit rules from the business control requirements of the agricultural product category to be traced. This set consists of specific rules for data verification and process control, formulated according to industry standards, regulatory requirements, and production specifications. Simultaneously, it extracts a predefined set of audit rules from the traceability metadata. This set consists of general traceability data verification and process access rules pre-configured in the traceability metadata, used to ensure traceability data compliance and process standardization. The two sets of rules are matched and compared. The number of rules with completely consistent control objectives is counted, and the rule coverage ratio is calculated. Then, each covered rule undergoes logical matching verification, and the average rule matching score is calculated. Finally, the rule support ratio is multiplied by the average rule matching score to obtain the rule support score. This support score reflects the degree of conformity between the business control requirements of the agricultural product category to be traced and the audit rules in the traceability metadata.
[0037] In this embodiment, the matching degree of process steps, the adaptability of data templates, and the support of rules are input into the category adaptability calculation module for weighted fusion calculation to obtain the category adaptability. The weighted fusion formula is as follows: , in, Indicates category suitability. Indicates the degree of matching between process steps. Indicates the data template fit. Indicates the degree of rule support. , and This represents the category weight coefficient, corresponding to the weights of process matching, data template adaptability, and rule support. The values are dynamically adjusted based on the characteristics of different agricultural product categories, and the sum of the three is 1 to ensure a balanced contribution from each dimension. The traceability scheme generation module processes the category adaptability to generate a scheme. When the category adaptability reaches a preset threshold, a traceability process and data display template highly matching the agricultural product category to be traced are generated. If the adaptability does not meet the standard, rule iteration and optimization are triggered.
[0038] In this embodiment, the adaptation measurement model is built using TensorFlow or PyTorch deep learning frameworks. The training dataset covers historical traceability data of various agricultural products, including fruits, vegetables, grains, and meats, and includes process configurations, data template fields, business rules, and corresponding labels for actual adaptation effects. The training process first preprocesses the data, vectorizing process matching degree, data template adaptation degree, rule support degree, and category weight coefficients to construct a standardized feature dataset. Then, the dataset is divided into training, validation, and test sets. Supervised learning is employed, using adaptation results from actual business scenarios as supervision labels to construct a mean squared error loss function, which is then optimized using a backpropagation algorithm. , and The model's value is chosen to minimize the error between the predicted and actual category fit values. During training, model performance is evaluated using a validation set, and hyperparameters such as the learning rate and batch size are adjusted until the model converges, meaning the loss function no longer decreases significantly. This results in a pre-trained, quantifiable model of fit, which dynamically outputs the optimal category weight coefficients for different traceable agricultural product categories, achieving accurate process adaptation and solution generation. The model's training framework is based on supervised learning to optimize weight coefficients, making the fit calculation more aligned with actual business scenarios. This improves the generation quality of traceability processes and data display templates. The adapted flexible traceability process provides personalized query and input interfaces for subsequent multi-role interactions, effectively enhancing user experience. This fundamentally solves the problems of insufficient flexibility and difficulty in adapting to dynamic changes in the supply chain inherent in traditional traceability systems, providing core technical support for the flexible and scalable development of agricultural product traceability systems.
[0039] In this embodiment of the invention, the step of retrieving and displaying the corresponding target chain traceability data from the distributed ledger based on the traceability process and the data display template includes: obtaining current operation role information, calling a pre-trained permission model, and determining the data permission range based on the current operation role information; retrieving the target chain traceability data corresponding to the data permission range from the distributed ledger based on the traceability process and the data display template; and generating and displaying a visual traceability map based on the target chain traceability data.
[0040] In this embodiment, the current operation role information is obtained, and a pre-trained permission model is invoked. This model is built based on the RBAC permission hierarchical control mechanism, and the role permission formula is as follows: , in, This represents the set of permissions a role possesses. This indicates the current operational role, encompassing various entities including consumers, producers, and regulatory agencies. This indicates the scope of data that the role can access, limiting the role to viewing only datasets related to its own business or those permitted by its permissions. This indicates the types of data operations that a role can perform, such as querying, data entry, and approval. Different roles can only access data within their authorized scope, effectively protecting business privacy and data security. The permission model is built using the PyTorch deep learning framework. The training dataset covers historical operation logs of multiple roles, permission configuration records, and labels from actual business scenarios. The training process first performs one-hot encoding and vectorization of role information, data range, and operation type to construct a standardized feature dataset. The dataset is then divided into training, validation, and test sets in an 8:1:1 ratio. Supervised learning is adopted, using permission allocation results from actual business scenarios as supervision labels. A cross-entropy loss function is constructed, and the model weight parameters are iteratively optimized through backpropagation to minimize the error between the permission prediction results and the actual allocation results. During training, the model's accuracy and generalization ability are evaluated using the validation set. Hyperparameters such as learning rate, batch size, and hidden layer dimension are dynamically adjusted until the model loss function converges and the validation set accuracy stabilizes above a preset threshold. Finally, a pre-trained permission model is obtained, which can accurately determine the data permission range based on the current operating role information.
[0041] In this embodiment, based on the adapted traceability process and data display template, the target on-chain traceability data corresponding to the data permission scope is retrieved from the distributed ledger. Specifically, the process involves parsing the link nodes and data dependencies defined in the traceability process, combining the data range constraints output by the permission model, and constructing ledger query filtering conditions that include role permissions, batch identifiers, and link fields. A request is sent to the distributed ledger through the read-only query interface of the blockchain node to filter out only the batch data and related business fields that are within the current role permissions and match the traceability process, thus completing the compliant data retrieval and ensuring the accuracy and security of data access. Based on the traceability data on the target chain, a visual traceability map is generated and displayed. A simplified QR code query entry is provided for consumers. Consumers can scan the batch identifier on the product packaging, automatically parsing the batch ID and matching it with the corresponding traceability process and data display template. No manual input is required. The system structures the traceability data on the target chain according to the sequence of traceability processes, intuitively presenting the time nodes, executing entities, and core data information of each stage in a graph format of nodes and connections. For example, the planting stage displays temperature and humidity, soil pH value, and fertilization records; the processing stage displays the batch number, processing time, and operator identification; and the logistics stage displays the transportation trajectory, cold chain temperature, and receipt information, forming a full-chain visual traceability map. This allows users to quickly understand the complete traceability information of the product from production to sales. RBAC hierarchical permission control and a pre-trained permission model enable refined control of data access for multiple roles, ensuring both commercial data privacy and data security while meeting the traceability query needs of different roles, improving the flexibility and security of the system's permission management. The visual traceability map, combined with the simplified QR code query mode for consumers, simplifies the traceability operation process, improves information transparency and user experience, and strengthens consumer trust.
[0042] The above describes the blockchain-based agricultural product process traceability method in the embodiments of the present invention. The following describes the blockchain-based agricultural product process traceability device in the embodiments of the present invention. Please refer to [link / reference]. Figure 2 One embodiment of the blockchain-based agricultural product traceability device of the present invention includes: Encryption signature module 201: used to acquire preprocessed data, perform encryption signature processing on the preprocessed data, and obtain encrypted signature data; Traceability metadata generation module 202: used to obtain preset traceability business rules and generate traceability metadata based on the traceability business rules; Verification module 203: is used to encapsulate the encrypted signature data and the traceability metadata into an on-chain transaction through the blockchain SDK, verify the on-chain transaction through a preset blockchain consensus node cluster, and if the verification is successful, write the on-chain transaction into the distributed ledger to obtain on-chain traceability data; Matching calculation module 204: used to obtain the category of agricultural products to be traced, call the pre-trained adaptive quantification model to perform matching calculation based on the category of agricultural products to be traced and the traceability metadata, and generate the traceability process and data display template corresponding to the category of agricultural products to be traced; Display module 205: used to retrieve and display the corresponding target chain traceability data from the distributed ledger based on the traceability process and the data display template.
[0043] Based on the same ideas as the methods in the above embodiments, the apparatus provided in this application can implement the methods in the above embodiments.
[0044] above Figure 2 The blockchain-based agricultural product process traceability device in this embodiment of the invention is described in detail from the perspective of modular functional entities. The following describes the blockchain-based agricultural product process traceability device in this embodiment of the invention in detail from the perspective of hardware processing.
[0045] Figure 3 This is a schematic diagram of the structure of a blockchain-based agricultural product traceability device 300 provided in an embodiment of the present invention. The blockchain-based agricultural product traceability device 300 can vary significantly due to different configurations or performance. It may include one or more central processing units (CPUs) 310 (e.g., one or more processors) and a memory 320, and one or more storage media 330 (e.g., one or more mass storage devices) for storing application programs 333 or data 332. The memory 320 and storage media 330 can be temporary or persistent storage. The program stored in the storage media 330 may include one or more modules (not shown in the diagram), each module may include a series of instruction operations on the blockchain-based agricultural product traceability device 300. Furthermore, the processor 310 may be configured to communicate with the storage media 330 and execute a series of instruction operations in the storage media 330 on the blockchain-based agricultural product traceability device 300 to implement the steps of the blockchain-based agricultural product traceability method provided in the above-described method embodiments.
[0046] The blockchain-based agricultural product traceability device 300 may also include one or more power supplies 340, one or more wired or wireless network interfaces 350, one or more input / output interfaces 360, and / or one or more operating systems 331, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, etc. Those skilled in the art will understand that... Figure 3The illustrated structure of the blockchain-based agricultural product process traceability device does not constitute a limitation on the blockchain-based agricultural product process traceability device. It may include more or fewer components than illustrated, or combine certain components, or have different component arrangements.
[0047] The present invention also provides a computer-readable storage medium, which can be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium, wherein the computer-readable storage medium stores instructions that, when executed on a computer, cause the computer to perform the steps of a blockchain-based agricultural product traceability method.
[0048] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the system, device, or unit described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0049] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0050] Finally, it should be noted that the above descriptions are merely preferred embodiments of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A blockchain-based method for tracing the process of agricultural products, characterized in that, include: Obtain preprocessed data, and perform encryption and signature processing on the preprocessed data to obtain encrypted and signed data; Obtain preset traceability business rules, and generate traceability metadata based on the traceability business rules; The encrypted signature data and the traceability metadata are encapsulated into an on-chain transaction using a blockchain SDK. The on-chain transaction is verified by a preset blockchain consensus node cluster. If the verification is successful, the on-chain transaction is written into a distributed ledger to obtain on-chain traceability data. Obtain the category of agricultural product to be traced, call the pre-trained adaptive quantification model to perform matching calculations based on the category of agricultural product to be traced and the traceability metadata, and generate the traceability process and data display template corresponding to the category of agricultural product to be traced; Based on the traceability process and the data display template, the corresponding target chain traceability data is retrieved from the distributed ledger and displayed.
2. The blockchain-based agricultural product process traceability method according to claim 1, characterized in that, The process of obtaining preprocessed data and performing encryption and signature processing on the preprocessed data to obtain encrypted and signed data includes: Acquire multi-source IoT data, and use a noise reduction algorithm to perform noise reduction processing on the multi-source IoT data to obtain noise-reduced data; The noise-reduced data is normalized using a normalization algorithm to obtain the preprocessed data; Obtain a preset unique private key, and use a hash algorithm and an asymmetric encryption algorithm to perform digital signature processing on the preprocessed data based on the unique private key to obtain the encrypted signature data.
3. The blockchain-based agricultural product process traceability method according to claim 1, characterized in that, The step of obtaining preset traceability business rules and generating traceability metadata based on the traceability business rules includes: Obtain visual process orchestration instructions, and define a traceability list, data template fields, audit rules, and chaincode version number based on the visual process orchestration instructions; By integrating the traceability list, the data template fields, the audit rules, and the chaincode version number, the traceability business rules are obtained. The traceability business rules are structured and encapsulated using a data serialization algorithm to obtain the traceability metadata.
4. The blockchain-based agricultural product process traceability method according to claim 1, characterized in that, The step of encapsulating the encrypted signature data and the traceability metadata into an on-chain transaction using a blockchain SDK includes: The encrypted signature data and the traceability metadata are converted into a blockchain-recognizable byte stream format using a serialization algorithm to obtain the transaction payload data; Call the transaction proposal construction interface of the blockchain SDK to construct a transaction proposal based on the transaction payload data; The transaction encapsulation interface of the blockchain SDK is invoked to encapsulate the transaction proposal into the on-chain transaction.
5. The blockchain-based agricultural product process traceability method according to claim 1, characterized in that, The on-chain transaction is verified through a pre-set blockchain consensus node cluster. If the verification passes, the on-chain transaction is written into the distributed ledger to obtain on-chain traceability data, including: The on-chain transaction is sent to a preset blockchain consensus node cluster, and the consensus algorithm is used to perform multi-node verification on the on-chain transaction; If the verification passes, the on-chain transaction will be packaged into a block using the sorting node block generation algorithm; The blocks are written into the distributed ledger in a hash chain structure using a hash algorithm to obtain the on-chain traceability data.
6. The blockchain-based agricultural product process traceability method according to claim 1, characterized in that, The adaptation quantification model includes a process step matching calculation module, a template adaptation calculation module, a rule support evaluation module, a category adaptation calculation module, and a traceability scheme generation module. The process step matching calculation module, the template adaptation calculation module, and the rule support evaluation module are respectively connected to the category adaptation calculation module, and the category adaptation calculation module is connected to the traceability scheme generation module. The step of calling the pre-trained adaptation quantification model performs matching calculations based on the category of the agricultural product to be traced and the traceability metadata to generate a traceability process and data display template corresponding to the category of the agricultural product to be traced, including: Based on the process link matching calculation module, the process link alignment and matching calculation is performed between the agricultural product category to be traced and the traceability metadata to obtain the process link matching degree. Based on the template adaptation calculation module, the data field compatibility adaptation calculation is performed between the agricultural product category to be traced and the traceability metadata to obtain the data template adaptation degree. Based on the rule support evaluation module, the business rule compliance calculation is performed on the product category to be traced and the traceability metadata to obtain the rule support. The matching degree of the process link, the adaptability of the data template, and the support of the rule are input into the category adaptability calculation module for weighted fusion calculation to obtain the category adaptability. Based on the traceability scheme generation module, the category adaptability is processed to generate a scheme, resulting in the traceability process and the data display template.
7. The blockchain-based agricultural product process traceability method according to claim 1, characterized in that, The step of retrieving and displaying the corresponding target chain traceability data from the distributed ledger based on the traceability process and the data display template includes: Obtain the current operation role information, call the pre-trained permission model, and determine the data permission range based on the current operation role information; Based on the tracing process and the data display template, retrieve the target chain tracing data corresponding to the data permission scope from the distributed ledger; A visual traceability map is generated and displayed based on the traceability data on the target chain.
8. A blockchain-based agricultural product process traceability device, characterized in that, include: Encryption and signature module: used to acquire preprocessed data, perform encryption and signature processing on the preprocessed data, and obtain encrypted signature data; Traceability metadata generation module: used to obtain preset traceability business rules and generate traceability metadata based on the traceability business rules; Verification module: used to encapsulate the encrypted signature data and the traceability metadata into an on-chain transaction through the blockchain SDK, verify the on-chain transaction through a preset blockchain consensus node cluster, and if the verification is successful, write the on-chain transaction into the distributed ledger to obtain on-chain traceability data; Matching calculation module: used to obtain the category of agricultural products to be traced, call the pre-trained adaptive quantification model to perform matching calculation based on the category of agricultural products to be traced and the traceability metadata, and generate the traceability process and data display template corresponding to the category of agricultural products to be traced; Display module: used to retrieve and display the corresponding target chain traceability data from the distributed ledger based on the traceability process and the data display template.
9. A blockchain-based agricultural product process traceability device, characterized in that, The blockchain-based agricultural product traceability device includes: a memory and at least one processor, wherein the memory stores instructions; At least one of the processors invokes the instructions in the memory to cause the blockchain-based agricultural product process traceability device to perform the steps of the blockchain-based agricultural product process traceability method as described in any one of claims 1-7.
10. A computer-readable storage medium storing instructions thereon, characterized in that, When the instructions are executed by the processor, they implement each step of the blockchain-based agricultural product process traceability method as described in any one of claims 1-7.