Food supply chain quality safety tracing method and system
By collecting, processing and integrating food data, logistics pattern identification and load analysis, and combining smart contract technology to realize data link structure connection and traceability encoding of the food supply chain, it solves the problems of data fragmentation and information asymmetry in traditional traceability systems, and achieves the improvement of full-process traceability and safety supervision of food.
Patent Information
- Application Number
- CN202411886534.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-04-11
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The traditional food supply chain traceability system has problems such as fragmentation of data, asymmetry of information, and incomplete traceability chains. It is impossible to achieve accurate tracking and real-time monitoring of the entire process of food from production to consumption, which seriously restricts the modernization process of food safety governance capabilities.
By collecting multi-source food data, timing alignment and feature fusion are performed to generate fused food feature data; then the data is recognized and load analysis is performed, adaptive shard storage is performed based on logistics load data, storage network topology is constructed, and data chain structure connection and traceability encoding are realized through smart contract deployment.
It has achieved full traceability of the food supply chain, improved the efficiency and transparency of food safety supervision, and ensured the safety and trust of consumers.
Smart Images

Figure CN119809664A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of food supply chain traceability, and in particular to a food supply chain quality and safety traceability method and system. Background Art
[0002] Traditional food supply chain traceability systems often have problems such as data fragmentation, information asymmetry, and incomplete traceability chains. They are unable to achieve accurate tracking and real-time monitoring of the entire process of food production to consumption, which seriously restricts the modernization of food safety governance capabilities. The complexity and diversity of the food supply chain make it difficult for traditional traceability methods to cope with the rapidly changing market environment. Especially in the context of globalization, data tracking and information integration in the food circulation link have become extremely difficult. Traditional technical routes are limited by practical obstacles such as information islands, inconsistent data standards, and high traceability costs. It is difficult to build an efficient, reliable, and real-time food safety traceability system, which not only affects the protection of consumer rights and interests, but also restricts the healthy development of the food industry. Summary of the invention
[0003] Based on this, it is necessary to provide a food supply chain quality and safety traceability method and system to solve at least one of the above technical problems.
[0004] To achieve the above purpose, a food supply chain quality and safety traceability method includes the following steps:
[0005] Step S1: collecting multi-source food data; performing time-series alignment on the multi-source food data to obtain synchronized food data; performing feature fusion processing on the synchronized food data to generate fused food feature data;
[0006] Step S2: Performing logistics pattern recognition on the fused food feature data to obtain a food logistics pattern; performing load analysis on the food logistics pattern to generate logistics load data;
[0007] Step S3: Adaptively sharding the fused food feature data based on the logistics load data to generate shard storage data; constructing a storage network for the shard storage data to generate a shard storage topology structure;
[0008] Step S4: Based on the shard storage topology, the shard storage data is connected in a chain structure to obtain an initial chain structure; smart contracts are deployed according to the initial chain structure to generate and run smart contracts;
[0009] Step S5: Construct a traceability coding system for the shard storage data based on the running smart contract and the initial chain structure to obtain a traceability code collection; perform quality and safety monitoring based on the traceability code collection to implement the food supply chain quality and safety traceability method.
[0010] The present invention can ensure the acquisition of rich food information by collecting and implementing multi-source food data. The synchronized food data obtained after time alignment provides a consistency basis for subsequent analysis. The implementation of feature fusion processing can integrate data from different sources. The generated fused food feature data provides a comprehensive perspective for subsequent logistics pattern recognition. The implementation of logistics pattern recognition on fused food feature data can reveal the behavioral characteristics of food in the logistics process. The generated food logistics pattern provides a basis for load analysis. The implementation of load analysis can quantify the load situation in the logistics process. The generated logistics load data lays the foundation for storage and distribution decisions. The implementation of adaptive sharding of fused food feature data based on logistics load data can optimize data storage and improve storage efficiency. The generated shard storage data provides a basis for subsequent network construction. The implementation of storage network construction on shard storage data can form an efficient data management structure. The generated shard storage topology structure provides an optimized path for data transmission. The implementation of chain structure connection of shard storage data based on shard storage topology structure can realize effective data linking. The obtained initial chain structure provides a framework for the deployment of smart contracts. The implementation of smart contract deployment based on the initial chain structure can realize automated data management and execution. The generated running smart contract provides a guarantee for the construction of a traceability coding system. The implementation of the traceability coding system for sharded storage data based on the running smart contract and the initial chain structure can achieve full traceability of food. The obtained traceability code collection provides an important basis for quality and safety monitoring. The implementation of quality and safety monitoring based on the traceability code collection can effectively implement the quality and safety traceability method of the food supply chain, improve the efficiency and transparency of food safety supervision, and ensure the safety and trust of consumers.
[0011] Preferably, step S1 comprises the following steps:
[0012] Step S11: collecting multi-source food data; performing time base calculation on the multi-source food data to obtain a time base line;
[0013] Step S12: performing time sequence alignment processing on multi-source food data according to the time reference line to obtain synchronized food data;
[0014] Step S13: extracting multi-dimensional feature vectors from the synchronized food data to obtain a food feature matrix;
[0015] Step S14: Perform feature fusion processing on the food feature matrix to generate fused food feature data.
[0016] The present invention can ensure the diversity and comprehensiveness of information sources by collecting and implementing multi-source food data. The implementation of time base calculation can provide a unified time reference for data analysis. The generated time base line provides a basis for subsequent timing alignment processing. The implementation of timing alignment processing can eliminate the time difference between different data sources. The obtained synchronized food data provides a consistency basis for subsequent analysis. The implementation of multi-dimensional feature vector extraction can deeply explore the diversified characteristics of food. The generated food feature matrix provides rich information for data analysis. The implementation of feature fusion processing can integrate features of different dimensions. The generated fused food feature data lays a foundation for subsequent logistics model analysis and quality monitoring, ensuring the efficiency and accuracy of the system in food supply chain quality and safety traceability.
[0017] Preferably, step S2 comprises the following steps:
[0018] Step S21: extracting the logistics track of the fused food feature data to obtain the food logistics track; performing logistics path analysis on the food logistics track to obtain a path feature set;
[0019] Step S22: performing logistics time sequence pattern recognition on the fused food feature data according to the path feature set to generate a food logistics pattern;
[0020] Step S23: Calculate the node capacity of the food logistics model to obtain node capacity data; perform flow distribution reasoning based on the node capacity data to generate flow distribution data;
[0021] Step S24: Perform load balance prediction based on the flow distribution data to generate logistics load data.
[0022] The present invention can clearly depict the movement route of food in the supply chain by implementing logistics trajectory extraction on fused food feature data, and the generated food logistics trajectory provides a dynamic perspective for subsequent analysis. The implementation of logistics path analysis can identify the characteristics of different logistics routes, and the obtained path feature set provides a basis for subsequent pattern recognition. The implementation of logistics time series pattern recognition based on the path feature set can reveal the behavior pattern of food in the logistics process, and the generated food logistics model provides a basis for optimizing supply chain management. The implementation of node capacity calculation on the food logistics model can quantify the carrying capacity of each node in logistics, and the obtained node capacity data provides important information for flow distribution reasoning. The implementation of flow distribution reasoning based on node capacity data can predict the flow distribution between different nodes, and the generated flow distribution data provides a basis for load balancing prediction. The implementation of load balancing prediction based on flow distribution data can achieve optimization and adjustment of the logistics system, and the generated logistics load data provides a scientific basis for subsequent resource allocation and management decisions, ensuring the efficient operation and resource utilization of the food supply chain in quality and safety traceability.
[0023] Preferably, step S24 comprises the following steps:
[0024] Perform time series decomposition on the traffic distribution data to obtain time series component data; perform time period traffic analysis on the time series component data to obtain time period traffic data;
[0025] Calculate the flow fluctuation of the time period flow data to obtain the fluctuation feature set; identify the peak and valley rules of the fluctuation feature set to generate flow rule data;
[0026] Carry out trend prediction modeling on flow pattern data to generate flow prediction model; use flow prediction model to predict flow change to obtain predicted flow change data;
[0027] Load mapping is performed based on predicted traffic change data to generate logistics load data.
[0028] The present invention can extract different time components of flow changes by implementing time series decomposition of flow distribution data, and the obtained time series component data provides a detailed foundation for subsequent flow analysis. The implementation of time period flow analysis can identify flow characteristics in different time periods, and the generated time period flow data provides a basis for flow fluctuation calculation. The implementation of flow fluctuation calculation can quantify flow fluctuations, and the obtained fluctuation feature set provides data support for further analysis of flow change laws. The implementation of peak and valley law identification of the fluctuation feature set can reveal the periodicity and trend of flow changes, and the generated flow law data provides an important basis for subsequent trend prediction modeling. The generation of flow prediction models can achieve effective prediction of future flow changes. The implementation of flow change prediction using flow prediction models can obtain predicted flow change data, which provides support for dynamic adjustment of logistics load. The implementation of load mapping based on predicted flow change data can generate accurate logistics load data, ensure the efficiency and reliability of the food supply chain in quality and safety traceability, and improve the intelligence level and responsiveness of overall logistics management.
[0029] Preferably, step S3 comprises the following steps:
[0030] Step S31: performing dynamic boundary calculation on the fused food feature data based on the logistics load data to obtain initial slice boundary data; performing conflict optimization on the initial slice boundary data to generate dynamic slice boundary data;
[0031] Step S32: Based on the dynamic shard boundary data, the fused food feature data is connected to each other through cross-shard communication to obtain a cross-shard communication route; and the dynamic shard boundary data is adaptively stored in slices according to the cross-shard communication route to generate slice storage data;
[0032] Step S33: Map the network topology structure of the shard storage data to obtain a network structure diagram; configure the node relationship based on the network structure diagram to obtain connection relationship data;
[0033] Step S34: construct a storage network for the shard storage data according to the connection relationship data to generate a shard storage topology structure.
[0034] The present invention can effectively determine the boundaries of data shards by implementing dynamic boundary calculation on fused food feature data based on logistics load data. The generated initial shard boundary data provides a basis for subsequent optimization. The implementation of conflict optimization on the initial shard boundary data can eliminate conflicts between data shards. The generated dynamic shard boundary data provides good support for cross-shard communication. The implementation of cross-shard communication connection on fused food feature data based on dynamic shard boundary data can realize data interaction between different shards. The obtained cross-shard communication route provides a basis for adaptive shard storage. Adaptive shard storage of dynamic shard boundary data is performed according to the cross-shard communication route. The implementation of storage can optimize the data storage method. The generated shard storage data lays the foundation for the subsequent network topology mapping. The implementation of network topology mapping of shard storage data can form a clear network structure diagram. The implementation of node relationship configuration based on the network structure diagram can clarify the connection relationship between each node. The obtained connection relationship data provides key data for the construction of the storage network. The implementation of storage network construction for shard storage data based on connection relationship data can generate an efficient shard storage topology structure, which improves the flexibility and efficiency of the food supply chain quality and safety traceability system in data management and resource utilization, and ensures the reliability and responsiveness of the system.
[0035] Preferably, step S32 includes the following steps:
[0036] Step S321: constructing a routing graph based on the dynamic shard boundary data to obtain a candidate routing set; assigning priorities to the candidate routing set according to a preset priority reference value to obtain priority data;
[0037] Step S322: Allocate bandwidth to the candidate route set based on the priority data to obtain bandwidth plan data; perform cross-shard communication connection on the fused food feature data according to the bandwidth plan data to obtain a cross-shard communication route;
[0038] Step S323: Identify load hot spots based on cross-shard communication routes to obtain communication load hot spots; pre-allocate storage space for dynamic shard boundary data according to the communication load hot spots to obtain a pre-allocation plan;
[0039] Step S324: Perform storage status monitoring based on the pre-allocation scheme to obtain storage status monitoring data; adjust and reorganize the dynamic sharding boundaries according to the storage status monitoring to generate sharding storage data.
[0040] The present invention can form a clear candidate route set by implementing the construction of the routing map based on the dynamic shard boundary data. The generated candidate route set provides a basis for subsequent priority allocation. The implementation of priority allocation to the candidate route set according to the preset priority reference value can effectively identify the optimal communication path. The obtained priority data provides guidance for bandwidth allocation. The implementation of bandwidth allocation to the candidate route set based on the priority data can ensure the efficiency and reliability of data transmission. The generated bandwidth plan data provides a reasonable basis for cross-shard communication connection. The implementation of cross-shard communication connection of fused food feature data according to the bandwidth plan data can realize efficient data interaction between different shards. The obtained cross-shard communication route provides data support for subsequent load identification. The implementation of load hotspot identification can accurately locate the key load areas in data transmission. The generated communication load hotspots provide a reference for the pre-allocation of storage space. The implementation of storage space pre-allocation of dynamic sharding boundary data according to communication load hotspots can optimize the utilization of storage resources. The obtained pre-allocation scheme provides a basis for storage status monitoring. The implementation of storage status monitoring based on the pre-allocation scheme can grasp the usage of storage resources in real time. The generated storage status monitoring data provides a basis for the adjustment and reorganization of dynamic sharding boundaries. The implementation of adjustment and reorganization of dynamic sharding boundaries according to storage status monitoring can generate optimized sharding storage data, which improves the flexibility and efficiency of the food supply chain quality and safety traceability system in data management and resource allocation, and ensures the stability and scalability of the system in practical applications.
[0041] Preferably, step S34 includes the following steps:
[0042] Perform hierarchical feature analysis on the connection relationship data to obtain a hierarchical feature collection; perform hierarchical configuration modeling on the hierarchical feature collection to generate a node hierarchical model;
[0043] Constructing a connection pattern for the node level model and generating connection pattern data;
[0044] Perform path redundancy evaluation on the connection mode data to obtain redundant path data; perform path optimization processing on the node hierarchy model based on the redundant path data to generate an optimized structure model;
[0045] Perform storage network topology analysis based on the optimized structure model to generate a sharded storage topology structure.
[0046] The present invention can extract feature information between different levels by implementing hierarchical feature analysis on connection relationship data, and the generated hierarchical feature collection provides a basis for subsequent modeling. The implementation of hierarchical configuration modeling on the hierarchical feature collection can form a clear node hierarchical model, and the generated node hierarchical model lays a foundation for understanding and managing data relationships. The implementation of connection mode construction on the node hierarchical model can define the connection mode between each node, and the generated connection mode data provides a basis for subsequent path evaluation. The implementation of path redundancy evaluation on the connection mode data can identify redundant paths, and the obtained redundant path data provides a reference for path optimization. The implementation of path optimization processing on the node hierarchical model based on redundant path data can improve the efficiency and stability of the network, and the generated optimized structure model provides a guarantee for the performance of the storage network. The implementation of storage network topology analysis based on the optimized structure model can form an efficient sharded storage topology structure, ensuring the flexibility and efficiency of the food supply chain quality and safety traceability system in data management and resource allocation, and improving the overall performance and responsiveness of the system.
[0047] Preferably, step S4 comprises the following steps:
[0048] Step S41: extracting connection point features from the shard storage topology structure to obtain a connection point feature set; evaluating the connection strength of the connection point feature set to generate a connection strength matrix;
[0049] Step S42: Connect the shard storage data in a chain structure based on the connection strength matrix to obtain an initial chain structure;
[0050] Step S43: Perform template matching mapping on the initial chain structure according to the preset contract template library to obtain a matching contract template;
[0051] Step S44: Deploy the smart contract on the initial chain structure based on the matching contract template to generate and run the smart contract.
[0052] The present invention can identify the key features between nodes by implementing connection point feature extraction on the shard storage topology structure, and the generated connection point feature set provides a data basis for subsequent evaluation. The implementation of connection strength evaluation on the connection point feature set can quantify the connection strength between nodes, and the generated connection strength matrix provides a basis for chain structure connection. The implementation of chain structure connection of shard storage data based on the connection strength matrix can form a preliminary network structure, and the obtained initial chain structure lays a foundation for the subsequent deployment of smart contracts. The implementation of template matching mapping of the initial chain structure according to the preset contract template library can ensure the adaptability and accuracy of the contract, and the generated matching contract template provides guidance for the deployment of smart contracts. The implementation of smart contract deployment of the initial chain structure based on the matching contract template can realize the automation of data management, and the generated running smart contract provides a guarantee for the transparency and traceability of the entire food supply chain, and improves the efficiency and reliability of food safety management.
[0053] Preferably, step S5 comprises the following steps:
[0054] Step S51: Design coding rules for the running smart contracts according to the initial chain structure to obtain a contract coding scheme; perform batch coding processing on the running smart contracts based on the contract coding scheme to generate a collection of traceability codes;
[0055] Step S52: Anomaly monitoring modeling is performed on the traceability code collection to obtain an anomaly monitoring model; risk stratification processing is performed based on the anomaly detection model to generate risk stratification data;
[0056] Step S53: Use the abnormal monitoring model to perform real-time quality monitoring on the traceability code collection to obtain real-time traceability code quality data;
[0057] Step S54: Perform a quality and safety comparison on the real-time traceability code quality data based on the risk stratification data, and issue a real-time risk warning to implement the food supply chain quality and safety traceability method.
[0058] The present invention can ensure the standardization and consistency of contract information by implementing the design of coding rules for running smart contracts according to the initial chain structure. The generated contract coding scheme provides clear guidance for subsequent coding processing. The implementation of batch coding processing for running smart contracts based on the contract coding scheme can form a systematic traceability code collection. The generated traceability code collection provides basic data for food traceability. The implementation of abnormal monitoring modeling for the traceability code collection can establish an effective monitoring mechanism. The obtained abnormal monitoring model provides support for subsequent risk management. The implementation of risk stratification processing based on the abnormal detection model can identify risks at different levels. The generated risk stratification data provides a basis for risk management. The implementation of real-time quality monitoring of the traceability code collection using the abnormal monitoring model can realize dynamic supervision of food quality. The obtained real-time traceability code quality data provides a real-time basis for quality assessment. The implementation of quality and safety comparison of real-time traceability code quality data based on risk stratification data can ensure food safety and compliance, and conduct real-time risk warning, thereby improving the response capability and management efficiency of the food supply chain and ensuring consumer safety and trust.
[0059] The present invention also provides a food supply chain quality and safety traceability system, which is used to execute the food supply chain quality and safety traceability method as described above. The food supply chain quality and safety traceability includes:
[0060] The data processing module is used to collect multi-source food data; perform time sequence alignment on the multi-source food data to obtain synchronized food data; perform feature fusion processing on the synchronized food data to generate fused food feature data;
[0061] The load analysis module is used to identify the logistics pattern of the fused food feature data to obtain the food logistics pattern; perform load analysis on the food logistics pattern to generate logistics load data;
[0062] A shard storage module is used to adaptively slice the fused food feature data based on the logistics load data to generate shard storage data; a storage network is constructed for the shard storage data to generate a shard storage topology structure;
[0063] The contract deployment module is used to connect the shard storage data in a chain structure based on the shard storage topology to obtain the initial chain structure; deploy the smart contract according to the initial chain structure to generate and run the smart contract;
[0064] The traceability monitoring module is used to construct a traceability coding system for shard storage data based on the running smart contract and the initial chain structure to obtain a collection of traceability codes; quality and safety monitoring is performed based on the collection of traceability codes to implement the food supply chain quality and safety traceability method.
[0065] The present invention can realize the efficient collection and processing of multi-source food data through the implementation of the data processing module. The synchronized food data obtained after time alignment provides a consistency basis for subsequent analysis. The implementation of feature fusion processing can integrate food features from different sources. The generated fused food feature data provides a comprehensive perspective for logistics pattern recognition. The implementation of the load analysis module can identify the behavioral characteristics of food in the logistics process. The generated logistics load data provides quantitative support for subsequent storage optimization. The implementation of the sharding storage module can perform adaptive sharding based on the logistics load data, improve the efficiency and flexibility of data storage, and the generated sharding storage data provides a basis for the construction of a storage network. The construction of the storage network can form an efficient data Management architecture, the generated shard storage topology provides an optimized path for data transmission, the implementation of the contract deployment module can connect the shard storage data in a chain structure to ensure the effective link of the data, and the generated initial chain structure provides a framework for the deployment of smart contracts. The generation of running smart contracts can realize the automation and efficiency of data management. The implementation of the traceability monitoring module can build a traceability coding system based on the running smart contracts to ensure the full traceability of food. The generated traceability code collection provides an important basis for quality and safety monitoring. The implementation of quality and safety monitoring based on the traceability code collection can effectively implement the quality and safety traceability method of the food supply chain, improve the efficiency and transparency of food safety supervision, and ensure the safety and trust of consumers. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] Figure 1 A schematic diagram of the steps of a food supply chain quality and safety traceability method;
[0067] Figure 2 Detailed implementation flow chart of step S2;
[0068] Figure 3 is a schematic diagram of a detailed implementation process of step S3;
[0069] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0070] The technical method of the present invention is described clearly and completely below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by technicians in this field without creative work are within the scope of protection of the present invention.
[0071] In addition, the accompanying drawings are only schematic illustrations of the present invention and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. The functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor methods and / or microcontroller methods.
[0072] It should be understood that, although the terms "first", "second", etc. may be used herein to describe various units, these units should not be limited by these terms. These terms are used only to distinguish one unit from another unit. For example, without departing from the scope of the exemplary embodiments, the first unit may be referred to as the second unit, and similarly the second unit may be referred to as the first unit. The term "and / or" used herein includes any and all combinations of one or more of the listed associated items.
[0073] To achieve this, please refer to Figures 1 to 3 , a food supply chain quality and safety traceability method, comprising the following steps:
[0074] Step S1: collecting multi-source food data; performing time-series alignment on the multi-source food data to obtain synchronized food data; performing feature fusion processing on the synchronized food data to generate fused food feature data;
[0075] Step S2: Performing logistics pattern recognition on the fused food feature data to obtain a food logistics pattern; performing load analysis on the food logistics pattern to generate logistics load data;
[0076] Step S3: Adaptively sharding the fused food feature data based on the logistics load data to generate shard storage data; constructing a storage network for the shard storage data to generate a shard storage topology structure;
[0077] Step S4: Based on the shard storage topology, the shard storage data is connected in a chain structure to obtain an initial chain structure; smart contracts are deployed according to the initial chain structure to generate and run smart contracts;
[0078] Step S5: Construct a traceability coding system for the shard storage data based on the running smart contract and the initial chain structure to obtain a collection of traceability codes; perform quality and safety monitoring based on the collection of traceability codes to implement the food supply chain quality and safety traceability method.
[0079] The present invention can ensure the acquisition of rich food information by collecting and implementing multi-source food data. The synchronized food data obtained after time alignment provides a consistency basis for subsequent analysis. The implementation of feature fusion processing can integrate data from different sources. The generated fused food feature data provides a comprehensive perspective for subsequent logistics pattern recognition. The implementation of logistics pattern recognition on fused food feature data can reveal the behavioral characteristics of food in the logistics process. The generated food logistics pattern provides a basis for load analysis. The implementation of load analysis can quantify the load situation in the logistics process. The generated logistics load data lays the foundation for storage and distribution decisions. The implementation of adaptive sharding of fused food feature data based on logistics load data can optimize data storage and improve storage efficiency. The generated shard storage data provides a basis for subsequent network construction. The implementation of storage network construction on shard storage data can form an efficient data management structure. The generated shard storage topology structure provides an optimized path for data transmission. The implementation of chain structure connection of shard storage data based on shard storage topology structure can realize effective data linking. The obtained initial chain structure provides a framework for the deployment of smart contracts. The implementation of smart contract deployment based on the initial chain structure can realize automated data management and execution. The generated running smart contract provides a guarantee for the construction of a traceability coding system. The implementation of the traceability coding system for sharded storage data based on the running smart contract and the initial chain structure can achieve full traceability of food. The obtained traceability code collection provides an important basis for quality and safety monitoring. The implementation of quality and safety monitoring based on the traceability code collection can effectively implement the quality and safety traceability method of the food supply chain, improve the efficiency and transparency of food safety supervision, and ensure the safety and trust of consumers.
[0080] In the embodiment of the present invention, refer to Figure 1 , is a schematic diagram of the steps of the food supply chain quality and safety traceability method of the present invention. In this example, the food supply chain quality and safety traceability method includes the following steps:
[0081] Step S1: collecting multi-source food data; performing time-series alignment on the multi-source food data to obtain synchronized food data; performing feature fusion processing on the synchronized food data to generate fused food feature data;
[0082] In this embodiment, real-time data is obtained from multiple links such as food production, processing, transportation, and warehousing through a variety of sensor devices, including temperature and humidity sensors, image acquisition devices, and quality monitoring instruments, and all data are recorded in a unified data format. For example, temperature and humidity data are recorded in CSV format, image data are stored in JPEG format, and quality monitoring data are stored in JSON format. When time-series alignment is performed on multi-source food data, a method based on timestamp matching is used to rearrange data from different sources in chronological order, and an interpolation algorithm is used to fill in missing time points to obtain synchronized food data. The time accuracy of the synchronized food data is controlled at the millisecond level. Subsequently, feature fusion processing is performed on the synchronized food data. The spatial features of food images are extracted through a convolutional neural network (CNN). At the same time, the numerical features of the quality monitoring data are combined with the image features in combination with a multimodal data fusion model to generate fused food feature data. The fused feature data is stored in a two-dimensional array format through a data structuring algorithm.
[0083] Step S2: Performing logistics pattern recognition on the fused food feature data to obtain a food logistics pattern; performing load analysis on the food logistics pattern to generate logistics load data;
[0084] In this embodiment, when the fused food feature data is subjected to logistics pattern recognition, a time series model based on LSTM (Long Short-Term Memory) is used to classify the food logistics information, and the data is divided into three categories according to the mode of transportation: cold chain transportation, normal temperature transportation, and special environment transportation. The logistics features are classified and the logistics pattern is identified through a pre-trained model to generate a food logistics pattern. The food logistics pattern is stored in a tabular form, which includes the transportation mode, time period, and transportation conditions of each mode. Subsequently, a load analysis is performed on the food logistics pattern. A logistics load calculation model is used to calculate the load data based on the transportation batch, cargo weight, and transportation path length under each mode. The load value is fitted by Gaussian distribution to generate logistics load data. The data is stored in a matrix form to guide subsequent data segmentation and optimize storage strategies.
[0085] Step S3: Adaptively sharding the fused food feature data based on the logistics load data to generate shard storage data; constructing a storage network for the shard storage data to generate a shard storage topology structure;
[0086] In this embodiment, the fused food feature data is adaptively sharded based on the logistics load data, and the fused food feature data is divided according to time periods and logistics modes through a sharding algorithm. When dividing, the shard size is dynamically adjusted according to the data load. For example, the shard size of cold chain transportation data is set to 64MB, and the shard size of normal temperature transportation data is set to 128MB. After sharding, shard storage data is generated. When the storage network is constructed for the shard storage data, a distributed hash table (DHT) is used to uniquely identify each data shard, and the shard storage data is distributed to multiple storage nodes. The node topology is generated by the Kademlia algorithm, and the storage network topology is represented by a graph data structure. Connections are established between nodes through hash values to generate a shard storage topology.
[0087] Step S4: Based on the shard storage topology, the shard storage data is connected in a chain structure to obtain an initial chain structure; smart contracts are deployed according to the initial chain structure to generate and run smart contracts;
[0088] In this embodiment, the shard storage data is connected in a chain structure based on the shard storage topology structure, a hash value is generated for each shard data through the hash chain technology, and the hash value is used as an identifier for the chain connection. The chain connection process is optimized through the Merkle Tree. The hash value of each shard is used as a leaf node of the Merkle tree, which is connected in sequence through the hash chain to generate an initial chain structure. When the smart contract is deployed according to the initial chain structure, the Solidity language is used to write the smart contract. The content of the smart contract includes shard data storage rules, access permission management, and data tracing logic. The smart contract is run through the Ethereum Virtual Machine (EVM). After deployment, a running smart contract is generated, and the address and related metadata of the running smart contract are stored in the initial chain structure.
[0089] Step S5: Construct a traceability coding system for the shard storage data based on the running smart contract and the initial chain structure to obtain a collection of traceability codes; perform quality and safety monitoring based on the collection of traceability codes to implement the food supply chain quality and safety traceability method.
[0090] In this embodiment, when constructing a traceability coding system for shard storage data according to the running smart contract and the initial chain structure, a unique traceability code is generated for each shard based on the BLAKE2 hash algorithm. The traceability code format includes the data source, shard location and chain connection information. All traceability codes are combined into a traceability code collection. The traceability code is recorded in JSON file format for subsequent quality and safety monitoring. When quality and safety monitoring is performed based on the traceability code collection, the chain connection information is periodically called by the smart contract to verify data integrity. During verification, a consistency check algorithm is used to compare the original traceability code and the hash value of the chain storage. The monitoring results are displayed in real time through a graphical interface, including the storage status of each shard, access records, and whether there are abnormalities. Finally, the food supply chain quality and safety traceability method is executed.
[0091] Preferably, step S1 comprises the following steps:
[0092] Step S11: collecting multi-source food data; performing time base calculation on the multi-source food data to obtain a time base line;
[0093] Step S12: performing time sequence alignment processing on multi-source food data according to the time reference line to obtain synchronized food data;
[0094] Step S13: extracting multi-dimensional feature vectors from the synchronized food data to obtain a food feature matrix;
[0095] Step S14: Perform feature fusion processing on the food feature matrix to generate fused food feature data.
[0096] In this embodiment, when collecting multi-source food data, a temperature and humidity sensor is used to obtain the ambient temperature and humidity data of the food, an image acquisition device is used to obtain an RGB image of the food appearance, a hyperspectral imager is used to obtain the spectral characteristics of the food, and an electronic nose device is used to collect the odor characteristics of the food. All data are transmitted to the data acquisition terminal through a unified Internet of Things gateway, the temperature and humidity data are stored in CSV format, the image data is saved in JPEG format, the hyperspectral data and the odor characteristics are stored in a local database in binary format, and when the collected data is calculated for time reference, a unified network time protocol (NTP) is used. The time of all devices is synchronized to millisecond accuracy by using the time baseline of all data, and the time offset between devices is calculated by comparing the acquisition timestamps. The linear regression model is used to fit the time baseline of all data. The generated time baseline is stored in the form of a time series array. When the multi-source food data is aligned according to the time baseline, the timestamps of all data are compared with the time baseline, and the data with time offset is interpolated and corrected. The interpolation adopts the cubic spline interpolation algorithm to ensure data continuity. At the same time, the abnormal data with an offset exceeding two times the standard deviation is deleted. After the time alignment is completed, the multi-source food data is reordered according to the time baseline to form synchronized food data. The synchronized food data includes time, temperature and humidity, image, hyperspectral and odor characteristics. The synchronized data is stored in the distributed file system in ascending time order. When extracting multi-dimensional feature vectors for synchronized food data, the spatial features of the image data are first extracted by a convolutional neural network (CNN), including edge, texture and color distribution information, and the image features are represented as 128-dimensional feature vectors. The hyperspectral data is analyzed using principal component analysis (PCA). Analysis was performed to reduce the dimension, retain the features with a cumulative contribution rate of 95%, express the hyperspectral features as a 64-dimensional feature vector, and analyze the odor features using a support vector machine (SVM,Support Vector Machine) classification model, represents the odor characteristics as a 32-dimensional feature vector, uses a time series analysis model for temperature and humidity data, extracts periodic and trend features, and represents them as a 16-dimensional feature vector. All feature vectors are integrated into a food feature matrix in dimensional order. The food feature matrix is stored in the form of a two-dimensional array. When the food feature matrix is subjected to feature fusion processing, an autoencoder is used to reduce the dimension and denoise the food feature matrix. The input of the autoencoder is the food feature matrix, the hidden layer dimension is set to 128, and the output is the feature data after dimensionality reduction. The reduced-dimensional feature data is subjected to multimodal feature fusion processing through a fully connected network. The weights of the fully connected network are optimized by the back propagation algorithm. The fused food feature data is stored in the form of a structured array. The fused data includes a comprehensive feature representation of each food for subsequent traceability analysis and quality monitoring. ,
[0097] Preferably, step S2 comprises the following steps:
[0098] Step S21: extracting the logistics track of the fused food feature data to obtain the food logistics track; performing logistics path analysis on the food logistics track to obtain a path feature set;
[0099] Step S22: performing logistics time sequence pattern recognition on the fused food feature data according to the path feature set to generate a food logistics pattern;
[0100] Step S23: Calculate the node capacity of the food logistics model to obtain node capacity data; perform flow distribution reasoning based on the node capacity data to generate flow distribution data;
[0101] Step S24: Perform load balance prediction based on the flow distribution data to generate logistics load data.
[0102] In this embodiment, when extracting the logistics trajectory of the fused food feature data, firstly, the additional geographic coordinates and timestamp information are extracted from the fused food feature data, and the trajectory reconstruction processing is performed using the Geographic Information System (GIS), and the entire flow process of the food from production to consumption is marked as a complete trajectory line, and the coordinates, time and logistics status of each node are stored in the form of a two-dimensional table. In the process of logistics path analysis, the Dijkstra algorithm is used to calculate the shortest path between all nodes, and the input is the node coordinates and the transportation distance matrix, and the output is the optimal path set. The analyzed path features are stored in JSON format, and each path contains information such as a node list, time consumption and logistics status. When the fused food feature data is subjected to logistics time series pattern recognition according to the path feature set, the long short-term memory network (LSTM) is used. The LSTM model learns the time series characteristics by training historical logistics data, and outputs the logistics mode label and the corresponding time distribution curve. The result is stored as a structured data table, which contains the mode label, time series and node information. The Adam optimizer is used for model training, and the learning rate is set to 0.001. The training data is cross-validated to improve the accuracy. When calculating the node capacity of the food logistics model, the M / M / 1 model in the queuing theory model is used based on the arrival frequency, residence time and departure frequency of each node. The input parameters include average arrival rate, service rate and number of nodes. The calculation results are output as the maximum load capacity and actual load ratio of each node. The node capacity data is stored in a CSV format table, including node identification, maximum load capacity, actual load ratio and other information. When the flow distribution is inferred based on the node capacity data, a probability model based on Bayesian reasoning is adopted. The input is node capacity data and historical flow distribution. The output is the predicted flow distribution of each node. The reasoning results are stored in JSON format. Each node corresponds to a predicted flow value and confidence interval. When load balancing prediction is performed based on flow distribution data, a neural network prediction model (ANN, Artificial Neural Network) is adopted. The input is flow distribution data and historical load data. The output is the load balance index of each node. The model structure includes an input layer, two hidden layers and an output layer. The activation function is ReLU. The training data is optimized by batch gradient descent method with a batch size of 64. The output of the model is stored in a CSV format table, including node identification, load balance index and prediction time. After the prediction is completed, the logistics load data is uploaded to the distributed data storage system for subsequent traceability and monitoring module calls.
[0103] Preferably, step S24 comprises the following steps:
[0104] Perform time series decomposition on the traffic distribution data to obtain time series component data; perform time period traffic analysis on the time series component data to obtain time period traffic data;
[0105] Calculate the flow fluctuation of the time period flow data to obtain the fluctuation feature set; identify the peak and valley rules of the fluctuation feature set to generate flow rule data;
[0106] Carry out trend prediction modeling on flow pattern data to generate flow prediction model; use flow prediction model to predict flow change to obtain predicted flow change data;
[0107] Load mapping is performed based on predicted traffic change data to generate logistics load data.
[0108] In this embodiment, when performing time series decomposition on the flow distribution data, an additive decomposition method is used to represent the flow data as a superposition of a long-term trend component, a seasonal component, and a random fluctuation component. The Holt-Winters Algorithm is used to decompose the time series data. The input is the time series data and the length of the seasonal cycle, and the output is an independent data sequence of three components. The decomposed time series component data is stored as a CSV format file, which contains the trend value, seasonal value, and random error value at each time point. When setting the initial value in the decomposition process, the trend item and the seasonal item are initialized respectively using the weighted moving average method. The decomposition result is used for subsequent flow characteristic analysis. When performing time period flow analysis on the time series component data, a fixed window segmentation method is used to segment the time series component data by time, and each segment is one week long. The segmented data is used to calculate statistical indicators such as the average value, maximum value, minimum value, and standard deviation, and the flow characteristics of each time period are analyzed. By statistically analyzing the flow distribution of each segment, the specific time position of the flow peak and trough is determined, and the time period flow is analyzed. The flow data is stored in JSON format files, which include statistical indicators for each time period and the corresponding time interval information. In the analysis process, Python's Pandas library is used to group and aggregate the data. When calculating the flow fluctuation of the time period flow data, the deviation calculation method is used to calculate the relative fluctuation amplitude and absolute fluctuation amplitude of each time period. The specific steps are to first obtain the mean flow value of each time period, subtract the flow value of each time point from the mean of the corresponding time period to calculate the deviation value, and then standardize the deviation value to obtain the relative fluctuation amplitude. The calculation result is stored in a two-dimensional array, which contains the deviation value and fluctuation amplitude of each time period. Python's NumPy library is used for matrix operations to improve the calculation efficiency. When identifying the peak and valley rules of the fluctuation feature set, the fast Fourier transform (FFT, Fast Fourier Transform) is used to analyze the frequency domain information of the fluctuation characteristic data, identify the main fluctuation cycle and its corresponding amplitude change characteristics, and perform inverse transformation on the identification results to determine the peak and valley positions in the time domain. Combined with the time range of each period, the specific time periods and corresponding flow characteristics where peaks and valleys frequently occur are marked. The flow law data is stored as a structured data file, and the Matplotlib library is used to generate a visual curve chart of the peak and valley law for subsequent verification. When the flow law data is modeled for trend prediction, the ARIMA model (Auto-Regressive Integrated Moving Average Model) in the time series prediction method is used. The input is the flow law data, and the difference processing method is used to make the sequence stable. Select p = 2, d = 1,The model parameter q=2 is used to model the sequence, and the trained model is used to predict the trend of the traffic law data for the next seven days. The generated traffic prediction model is stored in a binary file format. The prediction process is implemented using Python's Statsmodels library. When using the traffic prediction model to predict traffic changes, the future time series is used as input, and the model output is the traffic prediction value at the future time point. The predicted traffic change data is stored in a two-dimensional table format, including the time point and the predicted traffic value. When load mapping is performed based on the predicted traffic change data, the weight distribution method is used to map the traffic prediction value to each node in the logistics network, and the weight is redistributed according to the node capacity and the traffic change amount. The logistics load data is generated, and the final results are stored in the MySQL database for subsequent query and analysis. ,
[0109] Preferably, step S3 comprises the following steps:
[0110] Step S31: performing dynamic boundary calculation on the fused food feature data based on the logistics load data to obtain initial slice boundary data; performing conflict optimization on the initial slice boundary data to generate dynamic slice boundary data;
[0111] Step S32: Based on the dynamic shard boundary data, the fused food feature data is connected to each other through cross-shard communication to obtain a cross-shard communication route; and the dynamic shard boundary data is adaptively stored in slices according to the cross-shard communication route to generate slice storage data;
[0112] Step S33: Map the network topology structure of the shard storage data to obtain a network structure diagram; configure the node relationship based on the network structure diagram to obtain connection relationship data;
[0113] Step S34: construct a storage network for the shard storage data according to the connection relationship data to generate a shard storage topology structure.
[0114] In this embodiment, when the dynamic boundary calculation of the fused food feature data is performed based on the logistics load data, a distributed boundary calculation algorithm is used, the logistics load data is used as the weight input, and the food feature data is initially fragmented by the Voronoi diagram generation algorithm. During the calculation process, the geographic coordinates of the logistics node are used as seed points, and the fragmentation boundary is adjusted based on the load weight of each logistics node. The generated initial fragmentation boundary data is stored as a GeoJSON format file. Specifically, the Shapely library of Python is used to generate and operate the boundary polygons. The generated boundary data contains the boundary coordinates and node association information of each fragment. When the initial fragmentation boundary data is conflict optimized, the boundary overlap detection algorithm is used to analyze the boundary conflicts between the fragments. The conflict range is determined by detecting the overlapping area of the boundary polygons. The conflict area is optimized by using a boundary smoothing algorithm (Boundary Smoothing Algorithm) and weight redistribution strategy. In the specific implementation process, NumPy is used to smoothly interpolate the coordinates of the boundary points. The optimized dynamic shard boundary data is stored as a vector format file (SHP file), which contains the optimized coordinates of the shard boundary and its corresponding node weight information. When the fused food feature data is connected across shards based on the dynamic shard boundary data, the Dijkstra's shortest path algorithm (Dijkstra's Algorithm) is first used to calculate the communication path of each shard. The input is the dynamic shard boundary data and the communication weight between nodes. The weight value is determined by the weighted combination of logistics load and geographical distance. The output is the cross-shard communication routing data. The routing data is stored in XML format, including the starting node, the ending node, and the list of intermediate nodes passed in the path. When the dynamic shard boundary data is adaptively sharded according to the cross-shard communication route, the distributed storage strategy based on hash sharding is used to distribute the dynamic shard boundary data on different storage nodes according to the route. First, the hash value of each shard data is calculated, and the storage location is allocated according to the mapping relationship between the hash value and the storage node number. The storage node uses Mon The goDB database system is configured, and the resulting shard storage data is saved in BSON format, including the storage node address and shard index information of each shard. When mapping the network topology of the shard storage data, a graph generation algorithm based on node connection relationships is used to represent each shard storage node as a node in the graph, and the cross-shard communication route is used as the edge between the nodes. In the specific implementation, the NetworkX library is used to build and visualize the topology structure, and the output is an undirected weighted graph. The weight value represents the communication flow between nodes. The network structure diagram is stored in a GraphML format file, which contains the node ID, connection relationship and weight information. When configuring the node relationship based on the network structure diagram,The nodes in the topology graph are clustered using the community detection algorithm. The specific algorithm uses a multidimensional optimization method based on fuzzy clustering (Fuzzy C-Means Clustering) to divide the nodes into different relationship groups. Each group of nodes shares similar traffic characteristics and boundary characteristics. The output connection relationship data is stored in a CSV file. The file records the group identification of each node and the connection weight with other nodes. When the storage network of the shard storage data is constructed according to the connection relationship data, a storage topology design method based on a hierarchical architecture is adopted. First, the shard storage data is logically layered according to the connection relationship data. The highest layer is the backbone network between cluster groups, the middle layer is the local network within the cluster group, and the bottom layer is the independent storage unit of each node. The virtual storage network is constructed using the Mininet simulation tool. The generated shard storage topology structure is recorded in a JSON file, including the node identification, connection bandwidth and shard storage data index of each layer.
[0115] Preferably, step S32 includes the following steps:
[0116] Step S321: constructing a routing graph based on the dynamic shard boundary data to obtain a candidate routing set; assigning priorities to the candidate routing set according to a preset priority reference value to obtain priority data;
[0117] Step S322: Allocate bandwidth to the candidate route set based on the priority data to obtain bandwidth plan data; perform cross-shard communication connection on the fused food feature data according to the bandwidth plan data to obtain a cross-shard communication route;
[0118] Step S323: Identify load hot spots based on cross-shard communication routes to obtain communication load hot spots; pre-allocate storage space for dynamic shard boundary data according to the communication load hot spots to obtain a pre-allocation plan;
[0119] Step S324: Perform storage status monitoring based on the pre-allocation scheme to obtain storage status monitoring data; adjust and reorganize the dynamic sharding boundaries according to the storage status monitoring to generate sharding storage data.
[0120] In this embodiment, when constructing a routing graph based on dynamic sharding boundary data, a weighted graph model is used to represent the communication nodes and connection relationships in the dynamic sharding boundary. The attributes of the nodes include geographic location, load weight and storage status. The connection relationship is determined by the distance between nodes and the communication bandwidth. First, the NetworkX library in Python is used to create a graph structure, load the dynamic sharding boundary data, add the center point of each shard as a node to the graph, calculate the distance between adjacent nodes and use it as the weight of the edge, and export the generated routing graph to a GraphML format file as a candidate routing set. Then, the candidate routing set is prioritized according to a preset priority reference value. The priority reference value includes The load status, connection distance and edge weight of the node. In the specific operation, each path in the candidate route set is sorted according to the priority reference value, and the comprehensive priority score is calculated using the NumPy library. The high-priority path is marked as a first-level route, and the low-priority path is marked as a second-level route. The priority data is stored in a CSV format file. The file content includes the node start and end points, path weight and priority tag of each path. When allocating bandwidth to the candidate route set based on the priority data, the bandwidth allocation ratio of the high-priority route is first determined according to the priority reference value, with 50% of the bandwidth resources allocated to the first-level route, 30% to the second-level route, and the remaining bandwidth reserved as a backup resource. The bandwidth allocation algorithm is used to calculate each The allocation results of the routes are obtained. In the specific implementation process, the Pandas library is used to load the priority data, and the bandwidth allocation value is dynamically adjusted according to the route priority. The generated bandwidth plan data is stored in JSON format. The file includes the node information and the allocated bandwidth value of each path. According to the bandwidth plan data, the fused food feature data is connected across shards. The communication connection is implemented through a communication protocol based on Socket programming. The connection parameters include the source node address, the target node address and the transmission rate. The communication data is transmitted in the form of a binary stream. The cross-shard communication route is finally stored as a YAML file, which records the node pairs and transmission parameters of each communication path. The Prometheus monitoring system is used The transmission traffic data of cross-shard communication routes is systematically collected, and the traffic data is stored as a time series database. A threshold-based hotspot identification algorithm is used to mark the paths that exceed 90% of the communication load limit as hotspot paths. The output communication load hotspots are stored in JSON format, including the start and end nodes and traffic values of the hotspot paths. When pre-allocating storage space for dynamic shard boundary data based on communication load hotspots, a partition adjustment algorithm based on load balancing is used to spatially expand the partitions where the load hotspots are located. The Shapely library in Python is used to adjust the shard boundaries, and the expanded partition data is stored in GeoJSON format. The file content includes the adjusted boundary coordinates and node storage capacity of each partition.The ElasticSearch cluster is used to monitor the data writing rate and reading rate of the storage node, and the Kibana visualization tool is used to generate a storage status monitoring data report. The report content includes the storage capacity occupancy rate and data reading time of each partition. When adjusting and reorganizing the dynamic sharding boundary according to the storage status monitoring, a sharding reorganization method based on the Ant Colony Optimization Algorithm is adopted. First, cluster analysis is performed on the storage status monitoring data to determine the sharding group that needs to be adjusted, and then the sharding range is replanned according to the node connection relationship. Finally, the sharding storage data is generated and saved in ProtoBuf format. The file includes the node distribution, boundary coordinates and storage path of each shard. ,
[0121] Preferably, step S34 includes the following steps:
[0122] Perform hierarchical feature analysis on the connection relationship data to obtain a hierarchical feature collection; perform hierarchical configuration modeling on the hierarchical feature collection to generate a node hierarchical model;
[0123] Constructing a connection pattern for the node level model and generating connection pattern data;
[0124] Perform path redundancy evaluation on the connection mode data to obtain redundant path data; perform path optimization processing on the node hierarchy model based on the redundant path data to generate an optimized structure model;
[0125] Perform storage network topology analysis based on the optimized structure model to generate a sharded storage topology structure.
[0126] In this embodiment, the connection relationship of all nodes is represented as a directed graph, the nodes of the graph represent the logistics sites in the food supply chain, and the edges represent the transportation relationship between the sites. The NetworkX library in Python is used to load the connection relationship data and construct a directed graph. The basic properties of the graph, including node degree, in-degree distribution and out-degree distribution, are calculated. The nodes are graded by the Analytic Hierarchy Process (AHP) combined with the supply chain characteristics. Specifically, the connection weight, transmission frequency and transmission delay of the nodes are used as indicators. The hierarchical score of each node is calculated by the matrix decomposition method. The hierarchical score is divided into a three-layer structure, including a core layer, a distribution layer and an edge layer. The analysis results are stored in JSON format, and the hierarchical label and weight value of each node are recorded. When the hierarchical feature collection is hierarchically configured and modeled, the core layer, the distribution layer and the edge layer are respectively mapped to the sub-layer structure of the graph. The nodes of each layer are further refined and classified by a hierarchical clustering algorithm. Specifically, a density-based clustering algorithm (Density-Based Spatial Clustering of Applications with Noise, DBSCAN) analyzes the node location data and connection relationship, divides the cluster structure of each layer, models the nodes and internal connection relationship of each cluster as a hierarchical subgraph, and finally stores the generated node hierarchy model in GraphML format. The file content includes the node list, edge list and cluster center coordinate information of each layer. When constructing the connection mode of the node hierarchy model, the rule-based connection mode recognition method is used to determine the connection mode by analyzing the edge weight distribution law and connection strength mode of the nodes between layers. Specifically, the maximum flow path algorithm is used to calculate the optimal path set across layers and use it as the initial connection mode. Then the mode is optimized and the genetic algorithm (Genetic Algorithm,GA) iteratively adjusts the cross-layer edge weight distribution, generates connection pattern data, and stores the results in XML format. The file records the connection mode between the node groups of each layer and the optimized path set. When evaluating the path redundancy of the connection pattern data, the redundancy rate is calculated by comparing the actual connection path between the nodes with the shortest path. Specifically, the Floyd-Warshall algorithm is used to calculate all the shortest paths between the nodes, and the total number of paths in the current connection mode is compared with the total number of shortest paths to calculate the redundant path. The redundant path data is stored in text format, including the start and end nodes of the redundant path, the path length, and the corresponding redundancy rate. When the node hierarchical model is optimized based on the redundant path data, a path optimization method based on genetic algorithm is used to reduce the redundant path by adjusting the connection weight and the number of edges between the nodes. Specifically, the edge set of the redundant path is used as the initial population, and the objective function is used to minimize the redundancy rate. In each iteration, crossover and mutation operations are performed on the individuals to finally obtain the optimized structure model. The optimized structure model is stored in ProtoBuf format, and the file content includes the optimized node connection weight and edge list. When performing storage network topology analysis based on the optimized structure model, a distributed topology construction tool (such as Apache Kafka) simulates and analyzes the data transmission behavior between nodes, determines the storage shard distribution location of each node by comprehensively calculating the storage capacity and transmission performance of the nodes, and stores the analysis results as JSON files, recording the topological structure, transmission path and storage node capacity of each shard.
[0127] Preferably, step S4 comprises the following steps:
[0128] Step S41: extracting connection point features from the shard storage topology structure to obtain a connection point feature set; evaluating the connection strength of the connection point feature set to generate a connection strength matrix;
[0129] Step S42: Connect the shard storage data in a chain structure based on the connection strength matrix to obtain an initial chain structure;
[0130] Step S43: Perform template matching mapping on the initial chain structure according to the preset contract template library to obtain a matching contract template;
[0131] Step S44: Deploy the smart contract on the initial chain structure based on the matching contract template to generate and run the smart contract.
[0132] In this embodiment, when extracting connection point features for the shard storage topology structure, the shard storage topology structure is loaded as a graph data structure, the node represents the storage node, the edge represents the data transmission path, and the connection features of the node are analyzed using the graph computing tool Gephi. The extracted features include the degree, clustering coefficient, betweenness centrality and eigenvector centrality of the node. The above features are stored as a table file through the Pandas library in Python, and then the number of shortest paths and path strength between each node and other nodes are calculated based on the graph theory algorithm. These indicators are stored as a connection point feature set. The connection point feature set is stored in CSV format, and each row contains a node ID, a eigenvalue, and connection information with other nodes. When evaluating the connection strength of the connection point feature set, a weighted calculation method is used to comprehensively evaluate the node connection features, and the weight parameter is calculated by AHP (Analytic Hierarchy Process, hierarchical analysis method) to determine, comprehensively calculate the connection strength value of each node, the generation of the connection strength matrix is based on the Numpy library, each element of the matrix represents the connection strength between two nodes, the generated connection strength matrix is saved in the Numpy file format, and the connection strength value between each pair of nodes is recorded. When the shard storage data is connected in a chain structure based on the connection strength matrix, the connection strength matrix is used as input, and the Kruskal algorithm is used for the minimum spanning tree (Minimum Spanning Tree) The generated initial chain structure is saved in JSON format, including the order of link nodes, connection paths and weight values. When the template matching mapping is performed on the initial chain structure according to the preset contract template library, the link nodes and connection paths in the initial chain structure are loaded into the template matching algorithm module, and the template matching algorithm is used to analyze the node connection mode, and the node connection mode is matched with the standard contract structure in the preset contract template library for similarity. Each template in the contract template library includes the number of nodes, connection mode and data storage type. The matching process calculates the matching score based on cosine similarity, binds the initial chain structure to the contract template with the highest matching score, and stores the generated matching contract template in XML format, including template ID, template structure details and matching score. When the smart contract is deployed on the initial chain structure based on the matching contract template, the Ethereum network is used to compile and deploy the smart contract.First, use the Solidity language to write smart contract code according to the logical structure of the matching contract template, compile and test the code through the Truffle framework, and deploy the smart contract to the Ethereum network through the Web3.js tool after the test. When deploying, specify the node address in the initial chain structure as the execution node of the contract, and store the running status of the deployed smart contract as a log file. The file content includes the deployed contract address, node ID, execution record, and contract status update.
[0133] Preferably, step S5 comprises the following steps:
[0134] Step S51: Design coding rules for the running smart contracts according to the initial chain structure to obtain a contract coding scheme; perform batch coding processing on the running smart contracts based on the contract coding scheme to generate a collection of traceability codes;
[0135] Step S52: Anomaly monitoring modeling is performed on the traceability code collection to obtain an anomaly monitoring model; risk stratification processing is performed based on the anomaly detection model to generate risk stratification data;
[0136] Step S53: Use the abnormal monitoring model to perform real-time quality monitoring on the traceability code collection to obtain real-time traceability code quality data;
[0137] Step S54: Perform a quality and safety comparison on the real-time traceability code quality data based on the risk stratification data, and issue a real-time risk warning to implement the food supply chain quality and safety traceability method.
[0138] In this embodiment, when designing the coding rules for running smart contracts according to the initial chain structure, the calling, execution and storage behaviors of the contract are analyzed based on the Solidity contract logic analysis tool to determine the key parameters contained in the contract, including the transaction initiation node, the transaction timestamp, the execution result hash value, etc. The designed coding rules adopt a multi-level coding method, with the batch identification in the supply chain as the first layer of coding, the node information as the second layer of coding, and the transaction execution status as the third layer of coding. The coding scheme is saved in the form of a tree-structured JSON file. During batch coding, a Python script is used to encode the contract information of each data shard in the initial chain structure one by one according to the coding rules. The generated traceability code collection is stored as a CSV file, and the file content includes the batch number, node identification, timestamp and status code information. When performing abnormal monitoring modeling on the traceability code collection, the Python Scikit-learn library is used to construct a Random Forest (Random The anomaly detection model of Forest is used to train the model using a sample data set. The data set includes normal transaction data and abnormal transaction data. The feature selection includes transaction delay time, transaction hash value length and communication strength between nodes. After the model is trained, the model file is saved in Pickle format. When risk stratification is performed based on the anomaly detection model, the model is used to perform batch prediction on the traceability code collection, and the prediction results are divided into three levels: high risk, medium risk and low risk. The risk level of each traceability code is classified according to the risk score output by the model. The generated risk stratification data is stored in a JSON file, which contains the traceability code and its corresponding risk level. When the anomaly monitoring model is used to perform real-time quality monitoring on the traceability code collection, the real-time generated traceability code is transmitted to the anomaly monitoring module through the Kafka stream processing system, and the traceability code is The features are extracted one by one and input into the anomaly detection model. The output results of the model include normal and abnormal classification labels and risk scores. The real-time traceability code quality data is stored in the Elasticsearch database. The data content includes the traceability code number, timestamp, prediction result and risk score. The Kibana tool is used to visualize the real-time monitoring data and generate quality monitoring log files. When the quality and safety comparison of the real-time traceability code quality data is performed based on the risk stratification data, the SQL language is used to perform a joint table query on the real-time traceability code quality data and the risk stratification data to screen out the traceability codes with high risk levels, and compare their quality status labels to see if they are abnormal. The comparison results are recorded as warning information. The real-time risk warning is implemented through the Flask framework deployed in the link node, and the Twilio API interface is used to send risk warning SMS to the relevant supply chain nodes. The alarm content includes the traceability code number, node identifier and abnormality type. All warning records are written to the Redis cache database at the same time for subsequent calls.
[0139] The present invention also provides a food supply chain quality and safety traceability system, which is used to execute the food supply chain quality and safety traceability method as described above. The food supply chain quality and safety traceability includes:
[0140] The data processing module is used to collect multi-source food data; perform time sequence alignment on the multi-source food data to obtain synchronized food data; perform feature fusion processing on the synchronized food data to generate fused food feature data;
[0141] The load analysis module is used to identify the logistics mode of the fused food feature data to obtain the food logistics mode; perform load analysis on the food logistics mode to generate logistics load data;
[0142] A shard storage module is used to adaptively slice the fused food feature data based on the logistics load data to generate shard storage data; a storage network is constructed for the shard storage data to generate a shard storage topology structure;
[0143] The contract deployment module is used to connect the shard storage data in a chain structure based on the shard storage topology to obtain the initial chain structure; deploy the smart contract according to the initial chain structure to generate and run the smart contract;
[0144] The traceability monitoring module is used to construct a traceability coding system for shard storage data based on the running smart contract and the initial chain structure to obtain a collection of traceability codes; quality and safety monitoring is performed based on the collection of traceability codes to implement the food supply chain quality and safety traceability method.
[0145] The present invention can realize the efficient collection and processing of multi-source food data through the implementation of the data processing module. The synchronized food data obtained after time alignment provides a consistency basis for subsequent analysis. The implementation of feature fusion processing can integrate food features from different sources. The generated fused food feature data provides a comprehensive perspective for logistics pattern recognition. The implementation of the load analysis module can identify the behavioral characteristics of food in the logistics process. The generated logistics load data provides quantitative support for subsequent storage optimization. The implementation of the sharding storage module can perform adaptive sharding based on the logistics load data, improve the efficiency and flexibility of data storage, and the generated sharding storage data provides a basis for the construction of a storage network. The construction of the storage network can form an efficient data Management architecture, the generated shard storage topology provides an optimized path for data transmission, the implementation of the contract deployment module can connect the shard storage data in a chain structure to ensure the effective link of the data, and the generated initial chain structure provides a framework for the deployment of smart contracts. The generation of running smart contracts can realize the automation and efficiency of data management. The implementation of the traceability monitoring module can build a traceability coding system based on the running smart contracts to ensure the full traceability of food. The generated traceability code collection provides an important basis for quality and safety monitoring. The implementation of quality and safety monitoring based on the traceability code collection can effectively implement the quality and safety traceability method of the food supply chain, improve the efficiency and transparency of food safety supervision, and ensure the safety and trust of consumers.
[0146] Therefore, the embodiments should be regarded as illustrative and non-restrictive from all points, and the scope of the present invention is limited by the appended claims rather than the above description, and it is intended that all changes falling within the meaning and range of equivalent elements of the application documents are included in the present invention.
[0147] The above description is only a specific embodiment of the present invention, so that those skilled in the art can understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but should conform to the widest scope consistent with the principles and novel features invented herein.
Claims
1. A food supply chain quality and safety traceability method, characterized in that: The following steps are involved: Step S1: collecting multi-source food data; performing time-series alignment on the multi-source food data to obtain synchronized food data; performing feature fusion processing on the synchronized food data to generate fused food feature data; Step S2: Performing logistics pattern recognition on the fused food feature data to obtain a food logistics pattern; performing load analysis on the food logistics pattern to generate logistics load data; Step S3: Adaptively sharding the fused food feature data based on the logistics load data to generate shard storage data; Build a storage network for sharded storage data and generate a sharded storage topology structure; Step S4: Connect the shard storage data in a chain structure based on the shard storage topology structure to obtain an initial chain structure; Deploy smart contracts according to the initial chain structure and generate and run smart contracts; Step S5: Construct a traceability coding system for the shard storage data based on the running smart contract and the initial chain structure to obtain a collection of traceability codes; Quality and safety monitoring is carried out based on the traceability code collection to implement the food supply chain quality and safety traceability method.
2. The food supply chain quality and safety traceability method according to claim 1 is characterized in that: Step S1 includes the following steps: Step S11: collecting multi-source food data; performing time base calculation on the multi-source food data to obtain a time base line; Step S12: performing time sequence alignment processing on multi-source food data according to the time reference line to obtain synchronized food data; Step S13: extracting multi-dimensional feature vectors from the synchronized food data to obtain a food feature matrix; Step S14: Perform feature fusion processing on the food feature matrix to generate fused food feature data.
3. The food supply chain quality and safety traceability method according to claim 1 is characterized in that: Step S2 includes the following steps: Step S21: extracting the logistics track of the fused food feature data to obtain the food logistics track; performing logistics path analysis on the food logistics track to obtain a path feature set; Step S22: performing logistics time sequence pattern recognition on the fused food feature data according to the path feature set to generate a food logistics pattern; Step S23: Calculate the node capacity of the food logistics model to obtain node capacity data; perform flow distribution reasoning based on the node capacity data to generate flow distribution data; Step S24: Perform load balance prediction based on the flow distribution data to generate logistics load data.
4. The food supply chain quality and safety traceability method according to claim 3 is characterized in that: Step S24 includes the following steps: Perform time series decomposition on the traffic distribution data to obtain time series component data; perform time period traffic analysis on the time series component data to obtain time period traffic data; Calculate the flow fluctuation of the time period flow data to obtain the fluctuation feature set; identify the peak and valley rules of the fluctuation feature set to generate flow rule data; Carry out trend prediction modeling on flow pattern data to generate flow prediction model; use flow prediction model to predict flow change to obtain predicted flow change data; Load mapping is performed based on predicted traffic change data to generate logistics load data.
5. The food supply chain quality and safety traceability method according to claim 1 is characterized in that: Step S3 includes the following steps: Step S31: performing dynamic boundary calculation on the fused food feature data based on the logistics load data to obtain initial slice boundary data; performing conflict optimization on the initial slice boundary data to generate dynamic slice boundary data; Step S32: Based on the dynamic shard boundary data, the fused food feature data is connected to each other through cross-shard communication to obtain a cross-shard communication route; and the dynamic shard boundary data is adaptively stored in slices according to the cross-shard communication route to generate slice storage data; Step S33: Map the network topology structure of the shard storage data to obtain a network structure diagram; configure the node relationship based on the network structure diagram to obtain connection relationship data; Step S34: construct a storage network for the shard storage data according to the connection relationship data to generate a shard storage topology structure.
6. The food supply chain quality and safety traceability method according to claim 5 is characterized in that: Step S32 includes the following steps: Step S321: constructing a routing graph based on the dynamic shard boundary data to obtain a candidate routing set; assigning priorities to the candidate routing set according to a preset priority reference value to obtain priority data; Step S322: Allocate bandwidth to the candidate route set based on the priority data to obtain bandwidth plan data; perform cross-shard communication connection on the fused food feature data according to the bandwidth plan data to obtain a cross-shard communication route; Step S323: Identify load hot spots based on cross-shard communication routes to obtain communication load hot spots; pre-allocate storage space for dynamic shard boundary data according to the communication load hot spots to obtain a pre-allocation plan; Step S324: Perform storage status monitoring based on the pre-allocation scheme to obtain storage status monitoring data; adjust and reorganize the dynamic sharding boundaries according to the storage status monitoring to generate sharding storage data.
7. The food supply chain quality and safety traceability method according to claim 5, characterized in that: Step S34 includes the following steps: Perform hierarchical feature analysis on the connection relationship data to obtain a hierarchical feature collection; perform hierarchical configuration modeling on the hierarchical feature collection to generate a node hierarchical model; Constructing a connection pattern for the node level model and generating connection pattern data; Perform path redundancy evaluation on the connection mode data to obtain redundant path data; perform path optimization processing on the node hierarchy model based on the redundant path data to generate an optimized structure model; Perform storage network topology analysis based on the optimized structure model to generate a sharded storage topology structure.
8. The food supply chain quality and safety traceability method according to claim 1, characterized in that: Step S4 includes the following steps: Step S41: extracting connection point features from the shard storage topology structure to obtain a connection point feature set; evaluating the connection strength of the connection point feature set to generate a connection strength matrix; Step S42: Connect the shard storage data in a chain structure based on the connection strength matrix to obtain an initial chain structure; Step S43: Perform template matching mapping on the initial chain structure according to the preset contract template library to obtain a matching contract template; Step S44: Deploy the smart contract on the initial chain structure based on the matching contract template to generate and run the smart contract.
9. The food supply chain quality and safety traceability method according to claim 1, characterized in that: Step S5 includes the following steps: Step S51: Design coding rules for the running smart contracts according to the initial chain structure to obtain a contract coding scheme; perform batch coding processing on the running smart contracts based on the contract coding scheme to generate a collection of traceability codes; Step S52: Perform anomaly monitoring modeling on the traceability code collection to obtain an anomaly monitoring model; perform risk stratification processing based on the anomaly detection model to generate risk stratification data; Step S53: Use the abnormal monitoring model to perform real-time quality monitoring on the traceability code collection to obtain real-time traceability code quality data; Step S54: Perform a quality and safety comparison on the real-time traceability code quality data based on the risk stratification data, and issue a real-time risk warning to implement the food supply chain quality and safety traceability method.
10. A food supply chain quality and safety traceability system, characterized in that: Used to execute the food supply chain quality and safety traceability method as claimed in claim 1, the food supply chain quality and safety traceability comprises: The data processing module is used to collect multi-source food data; perform time sequence alignment on the multi-source food data to obtain synchronized food data; perform feature fusion processing on the synchronized food data to generate fused food feature data; The load analysis module is used to identify the logistics pattern of the fused food feature data to obtain the food logistics pattern; perform load analysis on the food logistics pattern to generate logistics load data; A shard storage module is used to adaptively slice the fused food feature data based on the logistics load data to generate shard storage data; a storage network is constructed for the shard storage data to generate a shard storage topology structure; The contract deployment module is used to connect the shard storage data in a chain structure based on the shard storage topology to obtain the initial chain structure; deploy the smart contract according to the initial chain structure to generate and run the smart contract; The traceability monitoring module is used to construct a traceability coding system for shard storage data based on the running smart contract and the initial chain structure to obtain a collection of traceability codes; quality and safety monitoring is performed based on the collection of traceability codes to implement the food supply chain quality and safety traceability method.
Citation Information
Cited By
Biological data visualization analysis system based on deep learning
CN120148655A
Grain logistics process data-based security assessment method and system
CN120672134A
Data processing method and system for grain depot collection and storage supervision cloud gateway
CN120687777A
Data analysis system and method for tracing information management platform
CN120822897A
Full-chain food safety monitoring method and system based on multi-modal data fusion and intelligent algorithm
CN120910698A