Agricultural whole industry chain traceability method and system based on big data
By constructing a dynamic knowledge graph and optimizing risk propagation paths, the problem of static knowledge graphs being unable to adapt to environmental changes has been solved, enabling real-time traceability and risk management across the entire agricultural industry chain, and improving the accuracy of traceability and risk assessment.
Patent Information
- Application Number
- CN202511400260.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-28
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2045-09-28
AI Technical Summary
Existing agricultural whole-chain traceability technologies mostly rely on static knowledge graphs, which are difficult to adapt to environmental changes in real time. They also lack the ability to integrate multi-source heterogeneous data and lack effective probabilistic reasoning mechanisms, which limits the accuracy of traceability paths and risk prediction.
By collecting data in real time through IoT devices, a dynamic knowledge graph is constructed. An LSTM model is used to predict environmental changes, and reinforcement learning is combined to adjust weights and generate a dynamically updated knowledge graph. By combining Bayesian networks and random forest models to optimize risk propagation paths, NFT-based traceability data is generated and verified and traded on the blockchain.
It enables real-time traceability and risk management across the entire agricultural industry chain, improving traceability accuracy and risk assessment precision, and enhancing the accuracy of risk management and decision support capabilities.
Smart Images

Figure CN120894046B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of agricultural traceability, in particular to an agricultural full-industry-chain traceability method and system based on big data. BACKGROUND
[0002] In recent years, agricultural full-industry-chain traceability technology has made significant progress with the development of Internet of Things, big data analysis and blockchain technology. Traditional agricultural traceability mainly relies on paper records or centralized databases, gradually evolving into real-time data collection based on Internet of Things, obtaining data of production, processing, logistics and sales through sensors and data interfaces. In recent years, knowledge graph technology has been applied to agricultural traceability, integrating multi-source heterogeneous data through the construction of entity relationship network, improving data correlation and query efficiency. In addition, risk prediction technology is gradually integrated into the traceability system, using machine learning models to analyze meteorological, market and supply chain data to predict the impact of natural disasters or market fluctuations on the industry chain.
[0003] Although existing agricultural full-industry-chain traceability technology has made some progress in the field of agricultural traceability, there is still room for improvement. First, existing methods rely heavily on static knowledge graphs or fixed weights, making it difficult to adapt to environmental changes affecting the industry chain in real time, resulting in limited accuracy of traceability paths and risk prediction. In addition, although existing risk prediction models can handle single data sources, they lack the ability to integrate multi-source heterogeneous data and lack effective probabilistic reasoning mechanisms to quantify risk propagation paths, making it difficult to fully reflect the complex risk transmission relationships in the agricultural full-industry-chain. SUMMARY
[0004] In view of the above existing problems, the present application is proposed.
[0005] Therefore, the present application provides an agricultural full-industry-chain traceability method based on big data to solve the problem of relying too much on static knowledge graphs and lacking the ability to integrate multi-source heterogeneous data.
[0006] To solve the above technical problems, the present application provides the following technical solutions:
[0007] In a first aspect, the present application provides an agricultural full-industry-chain traceability method based on big data, comprising,
[0008] Collecting agricultural full-industry-chain data in real time through Internet of Things devices and data interfaces, and forming a full-chain data set after preprocessing;
[0009] Based on the full-chain data set, a static knowledge graph is constructed in a graph database, nodes, edges and initial weights are set and initialized, environmental changes are predicted through an LSTM model, node and edge weights are dynamically adjusted using reinforcement learning, and a dynamically updated knowledge graph is generated;
[0010] According to the dynamically updated knowledge graph, a multi-factor risk transmission matrix is constructed, an initial risk propagation path is defined, a Bayesian network model is used to integrate the whole chain data set, the conditional probability of the initial risk propagation path is calculated, an optimized risk propagation path is generated, the risk probability is predicted through the optimized risk propagation path using a random forest model, and when the risk probability exceeds a risk probability threshold, a risk warning and optimization measures are triggered, a Dijkstra algorithm is used to generate a traceability path in the dynamically updated knowledge graph, and risk warning and optimization measures are embedded to generate risk traceability data;
[0011] The risk traceability data is encapsulated as NFT, a smart contract is written using Solidity to generate NFT on the Polygon blockchain, consumers obtain a voucher by scanning a two-dimensional code to verify traceability information, and the NFT can be traded on a decentralized market to generate NFT traceability data.
[0012] Based on the NFT traceability data, consumers can query the traceability path and risk information of agricultural products through a two-dimensional code, generate a visual graph, and regulatory departments can verify the compliance of agricultural product production through a blockchain browser to complete the final traceability query.
[0013] As a preferred scheme of the agricultural full-industry-chain traceability method based on big data, the full-chain data set is formed, and the full-chain data set is formed by,
[0014] Through the Internet of Things devices and data interfaces, the production link data, processing link data, logistics link data, sales link data, market demand data and external environment data are collected in real time to form multi-source data, and the multi-source data contains an association identifier.
[0015] The multi-source data is subjected to data cleaning and outlier rejection, and after the missing data is completed by using the adjacent value interpolation method, the data is classified according to the association identifier and integrated into the full-chain data set.
[0016] As a preferred scheme of the agricultural full-industry-chain traceability method based on big data, the dynamically updated knowledge graph is generated, and the dynamically updated knowledge graph is generated by,
[0017] Based on the full-chain data set, a static knowledge graph is initialized in the cloud using a graph database Neo4j, the node and edge attributes are extracted from the full-chain data set to generate a static knowledge graph, based on the static knowledge graph, the initial weights of the nodes and edges are calculated using a weighted average method to generate a static knowledge graph with initial weights, and an environment change trend is predicted using an LSTM time series model to generate an environment change prediction result.
[0018] Based on the environmental change prediction result, the Q-learning reinforcement learning algorithm is used to dynamically adjust the node and edge weight, the state space is defined as the environmental factor, the action space is defined as the weight adjustment, the reward function is defined as the traceability accuracy, the Q table is updated iteratively, and the dynamically updated knowledge graph is generated.
[0019] As a preferred scheme of the agricultural full industry chain traceability method based on big data, the method comprises the following steps:
[0020] The dynamically updated knowledge graph is mapped into an industry chain network, the node represents an entity, the edge represents a flow relationship, and the weight reflects the environmental influence.
[0021] According to the multi-factor risk transmission matrix, the data of the whole chain data set is integrated using a Bayesian network model, a multi-source data set is generated through a Cypher query language, the conditional probability of the initial risk propagation path is calculated, optimization is performed using maximum likelihood estimation, and an optimized risk propagation path is generated.
[0022] As a preferred scheme of the agricultural full industry chain traceability method based on big data, the method comprises the following steps:
[0023] Based on the optimized risk propagation path, the conditional probability is extracted and organized into a conditional probability feature matrix.
[0024] The historical risk data is used as a training set to construct a decision tree with a maximum depth of H, and a mean square error is used as a loss function.
[0025] Based on the trained random forest model and the conditional probability feature matrix, the risk probability and the influence range are predicted, the risk prediction result is generated, and if the risk probability exceeds the risk probability threshold, the risk warning and optimization measures are triggered.
[0026] As a preferred scheme of the agricultural full industry chain traceability method based on big data, the method comprises the following steps:
[0027] Based on the dynamic updated knowledge graph, the Dijkstra algorithm is used to generate the traceability path, and the risk warning and optimization measures are embedded into the traceability path through the association identifier to generate the traceability path embedded with risks;
[0028] Based on the optimized risk propagation path, the ECharts is used to generate the risk transmission heat map, and the traceability path embedded with risks is merged in the cloud to generate the risk traceability data.
[0029] As a preferred scheme of the agricultural full industry chain traceability method based on big data, the NFT traceability data is generated, specifically,
[0030] The risk traceability data integrity is verified in the cloud, and the risk traceability data is extracted, based on the extracted risk traceability data, the IPFS-api library of Python is used to upload to IPFS to generate the metadata stored in IPFS;
[0031] Based on the metadata stored in IPFS, the NFT traceability data is generated on the Polygon blockchain by using the ERC-721 standard smart contract written by Solidity.
[0032] In the second aspect, the application provides an agricultural full industry chain traceability system based on big data, comprising,
[0033] The acquisition module acquires the agricultural full industry chain data in real time through the Internet of Things device and the data interface, and forms a full chain data set after preprocessing;
[0034] The graph module constructs a static knowledge graph in a graph database based on the full chain data set, sets and initializes nodes, edges and initial weights, predicts environmental changes through an LSTM model, dynamically adjusts node and edge weights using reinforcement learning, and generates a dynamically updated knowledge graph;
[0035] The risk module constructs a multi-factor risk transmission matrix according to the dynamically updated knowledge graph, defines an initial risk propagation path, integrates the full chain data set using a Bayesian network model, calculates the conditional probability of the initial risk propagation path, generates an optimized risk propagation path, predicts the risk probability through the optimized risk propagation path using a random forest model, and triggers a risk warning and optimization measures when the risk probability exceeds a risk probability threshold, generates a traceability path in the dynamically updated knowledge graph using the Dijkstra algorithm, embeds the risk warning and optimization measures, and generates risk traceability data;
[0036] An encapsulation module encapsulates risk traceability data as NFT, generates NFT on a Polygon blockchain using a smart contract written in Solidity, consumers obtain a certificate to verify traceability information by scanning a two-dimensional code, and the NFT can be traded on a decentralized market, generating NFT traceability data;
[0037] A traceability module based on NFT traceability data enables consumers to query the traceability path and risk information of agricultural products through a two-dimensional code, generate a visual map, and enable regulatory authorities to verify the compliance of agricultural product production through a blockchain browser to complete the final traceability query.
[0038] In a third aspect, the present application provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, and wherein the computer program, when executed by the processor, implements any step of the big data-based agricultural full-industry-chain traceability method according to the first aspect of the present application.
[0039] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements any step of the big data-based agricultural full-industry-chain traceability method according to the first aspect of the present application.
[0040] The present application has the following beneficial effects: based on the dynamically updated knowledge graph generated by the full-chain data set, the LSTM model and reinforcement learning, the structured modeling and dynamic optimization of the agricultural full-industry-chain entity and relationship are realized, the multi-source data is converted into a graph structure and the weight is updated in real time to reflect the environmental changes, the limitations of the static knowledge graph that cannot adapt to environmental changes are overcome, the adaptability and traceability accuracy of the dynamically updated knowledge graph are significantly improved, the dynamic adjustment of the weight makes the graph more reflect the real-time agricultural production conditions, and the accuracy of risk assessment is enhanced; in addition, the Bayesian network model and the random forest model are comprehensively used to realize the probability reasoning and risk prediction of multi-source data, the multi-factor risk transmission matrix and the optimized risk transmission path accurately quantify the risk transmission, the risk-embedded traceability path improves the comprehensiveness of the traceability information, and the precision of risk management and the decision support capability are significantly improved. BRIEF DESCRIPTION OF DRAWINGS
[0041] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced as follows. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0042] Fig. 1 The flowchart of the big data-based agricultural full-industry-chain traceability method.
[0043] Fig. 2 A dynamic environment weight knowledge graph structure.
[0044] Fig. 3 A flowchart generated for risk transmission and traceability path.
[0045] Fig. 4 An NFT and traceability verification architecture diagram. DETAILED DESCRIPTION
[0046] In order to make the above objectives, features and advantages of the present application more obvious and easy to understand, the specific embodiments of the present application will be described in detail below with reference to the accompanying drawings.
[0047] In the following description, a large number of specific details are set forth in order to facilitate a thorough understanding of the present application, but the present application can also be implemented in other ways different from those described herein, and those skilled in the art can make similar generalizations without departing from the concept of the present application, therefore the present application is not limited to the specific embodiments disclosed below.
[0048] Secondly, "one embodiment" or "embodiment" referred to herein means that a specific feature, structure or characteristic can be included in at least one implementation of the present application. "In one embodiment" appearing in different places in the specification does not mean the same embodiment, nor is it an embodiment that is separate or alternative to other embodiments.
[0049] REFERENCE Figs. 1-4 For one embodiment of the present application, the embodiment provides an agricultural full-industry-chain traceability method based on big data, comprising the following steps:
[0050] S1: Collecting agricultural full-industry-chain data in real time through Internet of Things devices and data interfaces, and forming a full-chain data set after preprocessing;
[0051] Specifically, the following steps are included,
[0052] S1.1: Collecting agricultural full-industry-chain data in real time through deployment of Internet of Things devices and data interfaces, covering soil humidity, soil temperature, soil pH value and pesticide use records in the production link, processing temperature, processing time, additive type and dosage in the processing link, temperature control data, transportation path in the logistics link, and retailer information and market demand data in the sales link, while obtaining external environment data, including weather warning (such as typhoon, drought) and market supply and demand data (such as price fluctuation, order quantity). The output is multi-source data, including production, processing, logistics, sales link and external environment data, which is not formatted, containing time stamp, data type, numerical value and association identifier (such as plot ID, batch number).
[0053] Based on multi-source data, use 5G network or LoRa protocol to transmit multi-source data to cloud server, ensure real-time and low delay, store multi-source data in cloud, standardize data format, convert to JSON format, ensure multi-source heterogeneous data uniformity, get JSON format multi-source data.
[0054] S1.2: Based on JSON format multi-source data, use Apache-Kafka stream processing platform in cloud for data cleaning, remove outliers and complete missing data. For outliers in multi-source data, identify and remove. Use adjacent value interpolation method to complete missing data, for example, when soil moisture is missing at a certain time point, fill according to the average value of the previous and next time points. Apache-Kafka stream processing platform processes data stream every 10 minutes to ensure real-time, cleaned data retains JSON format, gets cleaned JSON format multi-source data, which has removed outliers and completed missing values.
[0055] Based on cleaned JSON format multi-source data, integrate into unified data set and store in distributed file unit HDFS. The integration process classifies data by timestamp and association identifier (such as plot ID, batch number) to generate standardized full-chain data set.
[0056] S2: Based on standardized full-chain data set, build static knowledge graph in graph database, set and initialize nodes, edges and initial weights, predict environmental changes through LSTM model, dynamically adjust node and edge weights using reinforcement learning, and generate dynamically updated knowledge graph.
[0057] Specifically includes the following steps,
[0058] S2.1: Based on standardized full-chain data set, use graph database Neo4j in cloud to initialize static knowledge graph, covering entities and relationships of agricultural full-chain. In Neo4j, nodes are defined as plots (e.g. A001), crops, processing plants, logistics vehicles and retailers, and edges represent flow relationships such as plot A001 planting mangoes → processing plant C001. Node attributes include production parameters such as soil moisture 45.2%, soil temperature 25.3℃, yield 500kg; edge attributes include flow time (e.g. 2025-07-11T10:00:00) and transportation conditions (e.g. cold chain temperature 4℃). Nodes and edges are extracted from the full-chain data set. The output is a static knowledge graph containing nodes, edges and their attributes.
[0059] Based on the static knowledge graph, the initial weights of nodes and edges are calculated using the weighted average method to reflect the influence of each attribute on the agricultural full industry chain traceability. The weighted average method is based on historical data to extract soil moisture, rainfall, pesticide usage and yield data from the full chain data set in the past 12 months, and calculate the influence weight of each parameter on yield. For example, the initial weight of soil moisture on mango yield is 0.3, rainfall is 0.2, and pesticide usage is 0.1, based on statistical analysis of historical data. The initial weight of the edge is calculated according to the reliability of the flow relationship, for example, the initial weight of the edge of "Plot A001→Processing Plant C001" is set to 0.9 based on the historical transportation success rate (e.g. 98%). The initial weight of the edge is calculated in the cloud and stored in the node and edge attributes of Neo4j, ensuring consistency with the static knowledge graph structure. The output is a static knowledge graph with initial weights, including nodes, edges, attributes and initial weights.
[0060] S2.2: Based on the static knowledge graph with initial weights, real-time environmental data is extracted from the standardized full chain data set, and an LSTM time series model is used to predict environmental changes. The LSTM time series model analyzes soil moisture, soil temperature, rainfall and weather warning data updated every 10 minutes, and predicts the environmental trend in the next 24 hours, for example, detecting that Plot A001 has less than 5mm of rainfall, indicating a drought risk. The LSTM time series model takes time series data as input, is trained based on historical environmental data, and outputs environmental change prediction results, including soil moisture change trend, for example, soil moisture decreases by 10%, represented as "value": -10%, insufficient rainfall or weather warning, and outputs the environmental change prediction results in JSON format, containing timestamp, predicted value and associated identifier.
[0061] The training process of the LSTM time series model is as follows: the historical full chain data set is used as the training set and the validation set; the LSTM time series model adopts a long short-term memory network structure, including an input layer, an LSTM layer, a fully connected layer and an output layer, the input is time series data, and the output is the prediction result of environmental change in the next 24 hours; the LSTM time series model is trained in the cloud using historical environmental data, the mean square error is used as the loss function, the model parameters are optimized through back propagation, the training iteration is 100 times, the batch size is 64, the Adam optimizer is used to adjust the learning rate, and the training target is to make the LSTM time series model learn the time series pattern of environmental data. The validation set is used to evaluate the LSTM time series model, and when the target prediction error is less than 5%, it means that the LSTM time series model is trained.
[0062] S2.3: Based on the environmental change prediction results, use the Q-learning reinforcement learning algorithm to dynamically adjust the node and edge weights in the static knowledge graph with initial weights, the goal is to maximize the traceability accuracy, defined as the degree of coincidence between the traceability path and the actual production conditions, the target error is less than 5%. The Q-learning reinforcement learning algorithm is initialized in the cloud, the state space is defined as the environmental factors in the environmental change prediction results, the action space is the adjustment of the node weights and edge weights in the static knowledge graph with initial weights, the reward function is the traceability accuracy, the error is calculated by comparing the traceability path with the actual production data in the standardized full-chain data set, the Q table is initialized, the Q value is initially 0, the learning rate is set to 0.1, the discount factor is 0.9, and the exploration rate is 0.1.
[0063] The Q-learning reinforcement learning algorithm reads the environmental change prediction results, analyzes the influence of environmental factors on traceability, calculates the potential impact of node weight adjustment according to the environmental change prediction results, the correlation between node weight and environmental factors is determined by the correlation coefficient in historical data, the edge weight is adjusted according to the meteorological warning, and the state-action pair is generated and stored in JSON format. The Q-learning reinforcement learning algorithm updates the Q table through iteration to optimize the node and edge weights, selects an action at each iteration, calculates the new traceability accuracy, and the reward function is R=1-(error / actual value), and the Q value update formula is:
[0064] ;
[0065] wherein, represents the value of performing action in the current state , represents assignment, which means updating the new value calculated on the right side to the left side, replacing the old value, represents learning rate, represents immediate reward, represents discount factor, represents the value of all possible actions in the next state ;
[0066] Based on the optimization results of the Q-learning reinforcement learning algorithm, update the node and edge weights in the static knowledge graph with initial weights, and store the updated graph in Neo4j to ensure consistency of nodes, edges, properties and dynamic weights.
[0067] S3: Based on the dynamically updated knowledge graph, a multi-factor risk transmission matrix is constructed, an initial risk propagation path is defined, a Bayesian network model is used to integrate the whole chain data set, the conditional probability of the initial risk propagation path is calculated, an optimized risk propagation path is generated, the random forest model is used to predict the risk probability through the optimized risk propagation path, and when the risk probability exceeds the risk probability threshold, the risk warning and optimization measures are triggered, the Dijkstra algorithm is used to generate the traceability path in the dynamically updated knowledge graph, the risk warning and optimization measures are embedded, and the risk traceability data is generated;
[0068] Specifically, the following steps are included,
[0069] S3.1: Based on the dynamically updated knowledge graph, a graph database Neo4j is used in the cloud to map the nodes and edges of the dynamically updated knowledge graph into an industrial chain network, the nodes represent entities in the industrial chain, the edges represent the flow relationship between entities, and the weight reflects the environmental impact, such as drought leading to an increase in soil moisture weight. The industrial chain network retains the structure and attributes of the dynamically updated knowledge graph, ensures the consistency of the dynamic weights of the nodes and edges, and outputs the industrial chain network.
[0070] Based on the industrial chain network, a multi-factor risk transmission matrix is constructed to quantify the impact of natural disasters, market fluctuations, and supply chain dependence on the agricultural whole industry chain. The multi-factor risk transmission matrix is also the risk propagation path. The multi-factor risk transmission matrix is an n x n matrix (n is the number of nodes), and the elements represent the probability of risk transmission from one node to another node. Using the nodes and edges in the industrial chain network, the initial risk transmission probability is calculated based on the dynamic weight, and the expression is:
[0071] ;
[0072] wherein, represents the initial risk transmission probability, i.e. the probability of risk transmission from node to node , represents the dynamic weight of node , reflecting the influence of the node on risk transmission, represents the dynamic weight of edge , reflecting the stability of the flow relationship, represents the standardized value based on the correlation between the attributes of node and the attributes of edge , ranging from 0 to 1.
[0073] S3.2: Based on the multi-factor risk transmission matrix, the weather data, market data and supply chain data in the standardized full-chain data set are integrated using the Bayesian network model to quantify the propagation path of risks in the agricultural full industry chain and generate an optimized risk propagation path. The Bayesian network model reads the multi-factor risk transmission matrix in the cloud, extracts the initial risk transmission probability as the starting point of the conditional probability, and stores it in the temporary database. Extract the 10-minute updated weather data, market data and supply chain data from the standardized full-chain data set, associate them to the nodes of the multi-factor risk transmission matrix through the Cypher query language, and generate an integrated multi-source data set; the Bayesian network model is based on the integrated multi-source data set and the initial risk transmission probability to build a conditional probability table, taking nodes as variables, defining the conditional probability of risk propagation, initializing the probability distribution through the correlation coefficient in the historical data, adjusting the probability in combination with real-time data, and the calculation formula is:
[0074] ;
[0075] wherein, represents the conditional probability of the risk of node occurring under the condition of the risk of node and the multi-source data set , represents the joint probability of the risk of node , the risk of node and the multi-source data set , represents the joint probability of the risk of node and the multi-source data set ;
[0076] The Bayesian network model updates the conditional probability table through Bayesian inference, optimizes the initial risk transmission probability of the multi-factor risk transmission matrix, adjusts the initial risk transmission probability using maximum likelihood estimation combined with the joint probability distribution of the multi-source data set, generates a more accurate optimized risk propagation path, and stores it in JSON format. Contains updated conditional probability and associated identification, stored in the cloud distributed file system HDFS to ensure high availability, and the JSON data structure is consistent with the multi-factor risk transmission matrix.
[0077] S3.3: Based on the optimized risk propagation path, use the random forest model to predict the risk impact range and severity in the whole agricultural industry chain, generate risk warning and optimization measures. The optimized risk propagation path is stored in JSON format, containing conditional probability and associated identification between nodes, using Python's pandas library to read the optimized risk propagation path in the cloud, extracting conditional probability, representing the probability of risk from node to node , associated with the nodes of the whole agricultural industry chain (such as plots, processing plants, logistics vehicles, retailers), organized as a conditional probability feature matrix, each row representing a pair of nodes, and the columns containing probability values and node identifiers. Based on the conditional probability feature matrix, use the random forest model to train, with the historical risk data in the standardized whole chain dataset as the training set, containing meteorological data, market data and supply chain data, with a time span of the past 12 months, the training set is stored in JSON format, containing risk events, impact range and severity, the random forest model builds 100 decision trees with a maximum depth of 10, uses mean square error as the loss function, and optimizes the random forest model parameters through 5-fold cross-validation to learn the mapping relationship between conditional probability and risk impact, and generates the trained random forest model.
[0078] Based on the trained random forest model and the conditional probability feature matrix, predict the risk impact range and severity, specifically: the trained random forest model takes the conditional probability feature matrix as input, and based on the 100 decision trees, predicts the risk probability (range [0, 1]) of each pair of nodes, and obtains the risk probability through the average tree output. The risk impact range is calculated through the edge structure of the dynamically updated knowledge graph, filtering nodes with conditional probability higher than the conditional threshold (e.g. 0.5) to generate a list of affected nodes, such as [C001, R001], and the conditional threshold is determined by statistical analysis method; the severity is based on the prediction function of the trained random forest model, combined with the conditional probability and node attributes, outputting the intensity in percentage, such as 30% yield loss. The risk probability, risk impact range and severity are integrated into the risk prediction result. Through statistical analysis of historical risk data, set the risk probability threshold, based on the risk prediction result, if the risk probability exceeds the risk probability threshold, trigger the risk warning, through the cloud API to send short message or App push notification to the relevant parties, the risk warning contains the risk type (such as meteorological risk, supply chain risk) and probability, and recommends optimization measures, which are generated based on successful coping cases in historical risk data, the risk warning and optimization measures are stored in JSON format, containing risk type, probability, coping suggestion and associated identification.
[0079] S3.4: Based on the dynamically updated knowledge graph, the Dijkstra algorithm is used to generate the traceability path, and the risk information is embedded based on the risk warning and optimization measures. The risk transmission heat map is generated using ECharts. The path, risk information and visualization data are integrated to generate the traceability path embedded with risks and the risk transmission heat map. The dynamically updated knowledge graph is stored in Neo4j, including nodes, edges, attributes and dynamic weights. The Dijkstra algorithm takes the node weight and edge weight as the cost function to calculate the optimal path from the plot to the retailer, i.e. the traceability path. The cost function expression is:
[0080] ;
[0081] wherein, represents the total cost of the candidate path , represents the candidate path from the plot to the retailer, represents the edge in the candidate path , represents the dynamic weight of the edge , which is stored in the edge attribute of the dynamically updated knowledge graph, reflecting the stability of the flow relationship, represents the node in the candidate path , represents the dynamic weight of the node .
[0082] Based on the risk warning and optimization measures, the risk warning and optimization measures are associated with the nodes in the traceability path through the association identifier. After the association is completed, the risk warning and optimization measures are embedded in the JSON structure of the traceability path to generate the traceability path embedded with risks. The traceability path embedded with risks contains path, attributes and risk information. Through the cloud API, consumers can query the path and risk information of the batch through the two-dimensional code to generate the traceability path embedded with risks.
[0083] Based on the optimized risk transmission path, the risk transmission heat map is generated using ECharts. The conditional probability is read and displayed in the form of a two-dimensional matrix. The horizontal and vertical axes represent nodes, and the cell color reflects the risk transmission probability. The risk transmission heat map is stored in JSON format, containing visualization data, which can be viewed by the regulatory authorities through the dashboard to identify the weak links in the agricultural industry chain. Based on the traceability path embedded with risks and the risk transmission heat map, the path, attributes, risk information and visualization data are integrated. The JSON data is merged in the cloud to ensure consistency, and the output is the traceability path embedded with risks and the risk transmission heat map.
[0084] Based on the traceability path embedded with risks and the risk transmission heat map, the information in the risk warning, optimization measures and traceability path is integrated to generate risk traceability data.
[0085] S4: encapsulate risk traceability data as NFT, use Solidity to write smart contract to generate NFT on Polygon blockchain, producer holds NFT ownership, consumer obtains certificate to verify traceability information by scanning QR code, NFT can be traded on decentralized market, and income is automatically distributed through smart contract, generating NFT traceability data;
[0086] Specifically, the following steps are included,
[0087] Extract risk traceability data in the cloud, verify integrity, and store in the cloud temporary database after extraction. Based on the extracted risk traceability data, generate metadata and store in IPFS. Use Python's ipfs-api library to upload the extracted risk traceability data to IPFS, generate data hash value, ensure decentralized storage and high availability. The metadata remains in JSON format, the structure is consistent with the extracted risk traceability data, sensitive data (such as pesticide formula) is processed using RSA encryption, an encrypted field is generated and embedded in the metadata, IPFS returns the data hash value, records the metadata storage location, and stores in the cloud temporary database.
[0088] Based on the metadata stored in IPFS, use Solidity to write ERC-721 standard smart contract to generate NFT traceability data on Polygon blockchain. The ERC-721 standard smart contract defines the unique identification, ownership information and metadata link of NFT, records the IPFS data hash value, generates a timestamp and the blockchain address of the producer. The Solidity code is deployed through the node of Polygon blockchain, calls the mint function to generate NFT, and the NFT metadata points to the JSON data stored in IPFS. The ERC-721 standard smart contract sets access permissions, the producer holds the NFT ownership and controls the access to complete data; zk-SNARK is used to generate privacy-protected access proof to ensure that sensitive data is only visible to authorized parties, and NFT traceability data is generated in JSON format.
[0089] Based on the NFT-based traceability data, the ECC-encrypted lightweight certificate is generated for consumers, and the access permission is set for regulatory departments. The ECC-encrypted digital signature is generated using the cryptography library of Python, and part of the information of the NFT-based traceability data (such as batch number, origin and carbon footprint) is included. The lightweight certificate is generated, and the consumer obtains the certificate by scanning the product QR code to verify the traceability information without accessing sensitive data. The regulatory department obtains the complete NFT-based traceability data access permission through the authorization function of the ERC-721 standard smart contract, verifies the data integrity using zk-SNARK, and views the sensitive data for compliance check. The certificate and permission information are stored in IPFS, and the access log is recorded to generate the consumer certificate and regulatory permission. Based on the NFT-based traceability data, the transaction is carried out in the decentralized market such as OpenSea, and the ownership and use right are separated. The ERC-721 standard smart contract defines the transaction rules, and the producer sells the access right of the NFT-based traceability data through OpenSea while retaining the ownership. The Solidity code realizes the income distribution logic, for example, the farmer gets 50%, the processing plant gets 30%, and the platform gets 20%. The payment function of the smart contract automatically distributes the income to the producer's blockchain address. After the consumer purchases the NFT-based traceability data, they can display the "green certification" label on the e-commerce platform to increase the product premium rate by about 10%. The transaction record is stored in the Polygon blockchain, including transaction hash, buyer address and income distribution details. The NFT transaction record is generated, and the metadata, NFT-based traceability data, consumer certificate and regulatory permission, and NFT transaction record stored in IPFS are integrated in the cloud to generate the final output. The metadata, NFT information (NFT identification, data hash, ownership), certificate (ECC encrypted signature) and transaction record are combined into a unified JSON structure and stored in IPFS and Polygon blockchain to ensure decentralization and high availability. The output is the NFT-based traceability data.
[0090] S5: Based on the NFT-based traceability data, the consumer queries the traceability path and risk information of agricultural products through the QR code, generates a visual map, and the regulatory department verifies the compliance of agricultural product production through the blockchain browser to complete the final traceability query.
[0091] Specifically includes the following steps,
[0092] Based on the NFT-based traceability data, the consumer scans the product packaging QR code with the mobile phone to obtain the ECC-encrypted lightweight certificate. The lightweight certificate is stored in IPFS, and the end-to-end traceability platform verifies the digital signature using the cryptography library of Python. After confirming that the certificate is consistent with the NFT-based traceability data, the metadata in IPFS is queried, and the traceability path and risk information are returned to generate the consumer query result.
[0093] Through the consumer query result and the dynamic knowledge graph, the previous Dijkstra algorithm is used to generate the optimal traceability path, according to the consumer query result and the optimal traceability path, an interactive visualization graph is generated through D3.js, the visualization graph is generated in SVG format, embedded in the web page or App interface, supports multiple languages, displays the origin, processing technology, logistics path, carbon footprint and risk warning, and is stored in IPFS.
[0094] Based on the NFT-based traceability data, the regulatory department accesses the complete data through the blockchain browser and verifies compliance; enterprises query data in batches through RESTful-API to optimize supply chain management. The regulatory department uses the blockchain browser of Polygon blockchain, inputs the NFT identifier, calls the authorization function of the ERC-721 standard smart contract, obtains the metadata in IPFS, and uses zk-SNARK to verify the integrity of sensitive data. Enterprises call NFT-based traceability data in IPFS and Polygon blockchain through RESTful-API to obtain batch information in batches, and use Merkle tree to check the hash value of NFT-based traceability data to ensure that it cannot be tampered with. The verification and query results are stored in IPFS, and the output is the regulatory verification and enterprise query results, including compliance verification data and supply chain optimization data.
[0095] Based on the consumer query result, the optimal traceability path, the interactive visualization graph, the regulatory verification and the enterprise query result, the final traceability query result is integrated and generated.
[0096] The embodiment also provides an agricultural full-industry-chain traceability system based on big data, comprising:
[0097] The acquisition module acquires agricultural full-industry-chain data in real time through Internet of Things devices and data interfaces, and forms a full-chain data set after preprocessing;
[0098] The graph module constructs a static knowledge graph in a graph database based on the full-chain data set, sets and initializes nodes, edges and initial weights, predicts environmental changes through an LSTM model, dynamically adjusts node and edge weights using reinforcement learning, and generates a dynamically updated knowledge graph;
[0099] The risk module constructs a multi-factor risk transmission matrix according to the dynamically updated knowledge graph, defines an initial risk propagation path, integrates the full-chain data set using a Bayesian network model, calculates the conditional probability of the initial risk propagation path, generates an optimized risk propagation path, predicts the risk probability through the optimized risk propagation path using a random forest model, and triggers a risk warning and optimization measure when the risk probability exceeds a risk probability threshold, generates a traceability path in the dynamically updated knowledge graph using Dijkstra algorithm, embeds the risk warning and optimization measure, and generates risk traceability data;
[0100] The packaging module encapsulates the risk traceability data as an NFT, generates the NFT on a Polygon blockchain using a smart contract written in Solidity, and enables consumers to obtain a certificate by scanning a QR code to verify the traceability information. The NFT can be traded on a decentralized market, and the traceability data can be generated as an NFT.
[0101] The traceability module is based on the NFT-based traceability data, and consumers can query the traceability path and risk information of agricultural products through a QR code, generate a visual map, and verify the compliance of agricultural product production through a blockchain browser, and complete the final traceability query.
[0102] The embodiment also provides a computer device suitable for the big data-based agricultural full-industry-chain traceability method, which includes a memory and a processor; the memory is used to store computer executable instructions, and the processor is used to execute the computer executable instructions to realize the big data-based agricultural full-industry-chain traceability method as proposed in the above embodiment.
[0103] The computer device can be a terminal, and the computer device includes a processor, a memory, a communication interface, a display screen and an input device connected through a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with external terminals in a wired or wireless manner. The wireless manner can be achieved through WIFI, an operator network, NFC (near field communication) or other technologies. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer overlaid on the display screen, or a key, trackball or touchpad arranged on the shell of the computer device. In addition, the input device can be an external keyboard, touchpad or mouse, etc.
[0104] The embodiment also provides a storage medium on which a computer program is stored, the program being executed by a processor to implement the method for realizing agricultural whole industry chain traceability based on big data as proposed in the above embodiment; the storage medium can be realized by any type of volatile or non-volatile storage device or a combination thereof, such as a static random access memory (SRAM), an electrically erasable programmable read-only memory (EEPROM), an erasable programmable read-only memory (EPROM), a programmable read-only memory (PROM), a read-only memory (ROM), a magnetic memory, a flash memory, a magnetic disk or an optical disk.
[0105] To sum up, the present application: based on the dynamically updated knowledge graph generated by the whole chain data set, the LSTM model and reinforcement learning, realizes the structured modeling and dynamic optimization of the agricultural whole industry chain entity and relationship, converts the multi-source data into a graph structure and updates the weight in real time to reflect the environmental changes, overcomes the limitation that the static knowledge graph cannot adapt to environmental changes, significantly improves the adaptability and traceability accuracy of the dynamically updated knowledge graph, dynamically adjusts the weight so that the graph can better reflect the real-time agricultural production conditions, and enhances the accuracy of risk assessment; in addition, the Bayesian network model and the random forest model are comprehensively used to realize the probability reasoning and risk prediction of multi-source data, the multi-factor risk transmission matrix and the optimized risk transmission path accurately quantify the risk transmission, the traceability path embedded with risks improves the comprehensiveness of the traceability information, and the precision of risk management and the decision support capability are significantly improved.
[0106] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present application but not limit the present application, although the present application has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present application can be modified or replaced equivalently without departing from the spirit and scope of the technical solutions of the present application, and all should be covered in the scope of the claims of the present application.
Claims
1. A big data-based agricultural full-industry-chain traceability method, characterized in that: The application relates to a method for realizing risk traceability of agricultural products based on NFT, and belongs to the field of agricultural product traceability. Real-time collection of agricultural full-industry-chain data through an Internet of Things device and a data interface, and preprocessing to form a full-chain data set; Based on the full-chain data set, a static knowledge graph is constructed in a graph database, nodes, edges and initial weights are set and initialized, environmental changes are predicted through an LSTM model, node and edge weights are dynamically adjusted using reinforcement learning, and a dynamically updated knowledge graph is generated; According to the dynamically updated knowledge graph, a multi-factor risk transmission matrix is constructed, an initial risk propagation path is defined, a Bayesian network model is used to integrate the full-chain data set, the conditional probability of the initial risk propagation path is calculated, an optimized risk propagation path is generated, the risk probability is predicted through the optimized risk propagation path using a random forest model, and when the risk probability exceeds a risk probability threshold, a risk warning and optimization measure are triggered, a dynamic updating knowledge graph is generated using a Dijkstra algorithm, the risk warning and optimization measure are embedded, and risk traceability data is generated; The risk traceability data is encapsulated as NFT, a smart contract is written using Solidity to generate NFT on the Polygon blockchain, consumers obtain a voucher to verify traceability information by scanning a two-dimensional code, and the NFT can be traded on a decentralized market to generate NFT traceability data; Based on the NFT traceability data, consumers query the traceability path and risk information of agricultural products through a two-dimensional code, a visual graph is generated, and a regulatory department verifies the compliance of agricultural product production through a blockchain browser to complete the final traceability query.
2. The big data based agricultural whole industry chain traceability method according to claim 1, characterized in that: The full-chain data set is formed, specifically, Real-time collection of production link data, processing link data, logistics link data, sales link data, market demand data and external environment data through an Internet of Things device and a data interface to form multi-source data; the multi-source data contains an association identifier; The multi-source data is subjected to data cleaning and removal of abnormal values, missing data is completed using a neighboring value interpolation method, and then classified according to the association identifier to integrate into a full-chain data set. 3.The big data based agricultural whole industry chain traceability method according to claim 2, characterized in that: The dynamically updated knowledge graph is generated, specifically, Based on the full-chain data set, a static knowledge graph is initialized in the cloud using a graph database Neo4j, node and edge attributes are extracted from the full-chain data set to generate a static knowledge graph, based on the static knowledge graph, an initial weight of the node and the edge is calculated using a weighted average method to generate a static knowledge graph with an initial weight, and an environmental change trend is predicted using an LSTM time series model to generate an environmental change prediction result; Based on the environmental change prediction result, a Q-learning reinforcement learning algorithm is used to dynamically adjust the node and edge weights, the state space is defined as an environmental factor, the action space is defined as a weight adjustment, the reward function is defined as traceability accuracy, a Q table is updated through iteration, and a dynamically updated knowledge graph is generated.
4. The big data based agricultural whole industry chain traceability method according to claim 3, characterized in that: The optimized risk propagation path is generated, specifically, The dynamically updated knowledge graph is mapped into an industry chain network, nodes represent entities, edges represent flow relationship, and weights reflect environmental influence, based on the industry chain network, a multi-factor risk transmission matrix is constructed, an initial risk propagation path is defined, an initial risk transmission probability is calculated, and a multi-factor risk transmission matrix is generated; According to the multi-factor risk transmission matrix, the data of the whole chain data set is integrated using the Bayesian network model, the multi-source data set is generated by the Cypher query language, the conditional probability of the initial risk propagation path is calculated, the maximum likelihood estimation is optimized, and the optimized risk propagation path is generated.
5. The big data based agricultural whole industry chain traceability method according to claim 4, characterized in that: The optimized risk propagation path is used to predict the risk probability using a random forest model, and when the risk probability exceeds the risk probability threshold, a risk warning and optimization measure are triggered, specifically, Based on the optimized risk propagation path, the conditional probability is extracted and organized into a conditional probability feature matrix. Using historical risk data as the training set, a decision tree is constructed with a maximum depth of H, using mean square error as the loss function, and through cross-validation optimization, a trained random forest model is generated. Based on the trained random forest model and the conditional probability feature matrix, the risk probability and the impact range are predicted, and the risk prediction result is generated, and if the risk probability exceeds the risk probability threshold, a risk warning and optimization measure are triggered, and through the cloud API, a risk warning and optimization measure are generated. App push notification, generate risk warning and optimization measures.
6. The big data based agricultural whole industry chain traceability method according to claim 5, characterized in that: The Dijkstra algorithm is used to generate a dynamic updated knowledge graph, and the risk warning and optimization measure are embedded to generate risk traceability data, specifically, Based on the dynamically updated knowledge graph, the Dijkstra algorithm is used to generate the traceability path, and the risk warning and optimization measure are embedded in the traceability path through the association identifier to generate the traceability path embedded with the risk. Based on the optimized risk propagation path, the risk transmission heat map is generated using ECharts, and the traceability path embedded with the risk is merged in the cloud to generate risk traceability data.
7. The big data based agricultural whole industry chain traceability method according to claim 6, characterized in that: The NFT traceability data is generated, specifically, In the cloud, verify the integrity of the risk traceability data, and extract the risk traceability data, based on the extracted risk traceability data, use the ipfs-api library of Python to upload to IPFS, generate IPFS stored metadata; Based on the IPFS stored metadata, the ERC-721 standard smart contract written in Solidity is used to generate NFT traceability data on the Polygon blockchain.
8. A big data-based agricultural whole industry chain traceability system based on the big data-based agricultural whole industry chain traceability method of any one of claims 1-7. Including, The acquisition module acquires agricultural whole industry chain data in real time through Internet of Things devices and data interfaces, and forms a whole chain data set after preprocessing; The graph module constructs a static knowledge graph in the graph database based on the whole chain data set, sets and initializes nodes, edges and initial weights, predicts environmental changes using an LSTM model, dynamically adjusts node and edge weights using reinforcement learning, and generates a dynamically updated knowledge graph. The risk module constructs a multi-factor risk transmission matrix according to a dynamically updated knowledge graph, defines an initial risk propagation path, integrates a full-chain data set using a Bayesian network model, calculates the conditional probability of the initial risk propagation path, generates an optimized risk propagation path, predicts a risk probability using a random forest model through the optimized risk propagation path, triggers a risk warning and optimization measure when the risk probability exceeds a risk probability threshold, generates a traceability path in the dynamically updated knowledge graph using Dijkstra's algorithm, embeds the risk warning and optimization measure, and generates risk traceability data. The packaging module encapsulates the risk traceability data into NFT, generates NFT on the Polygon blockchain using a smart contract written in Solidity, consumers obtain a voucher to verify traceability information by scanning a QR code, and the NFT can be traded on a decentralized market to generate NFT-based traceability data. The traceability module, based on the NFT-based traceability data, enables consumers to query the traceability path and risk information of agricultural products through a QR code, generates a visual graph, and enables regulatory authorities to verify the compliance of agricultural product production through a blockchain browser to complete the final traceability query. 9.A computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the computer device is characterized in that: The processor executes the computer program to implement the steps of the agricultural full-industry-chain traceability method based on big data according to any one of claims 1-7.
10. A computer readable storage medium having stored thereon a computer program, characterized in that: The computer program is executed by the processor to implement the steps of the agricultural full-industry-chain traceability method based on big data according to any one of claims 1-7.
Citation Information
Patent Citations
Agricultural product quality abnormity propagation path prediction system and method based on graph neural network
CN119476669A
DDoS attack real-time detection and traceability analysis method based on knowledge graph
CN119728286A