A double-chain fusion product quality tracing method and system applied to a production line
By integrating a dual-chain architecture and blockchain technology, the problems of unstable data collection and centralized operation and maintenance in the IoT traceability system have been solved, enabling efficient and reliable quality traceability of the electronic product manufacturing process and ensuring data integrity and security.
Patent Information
- Application Number
- CN202510262748.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-06
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2045-03-06
AI Technical Summary
Existing IoT traceability systems in electronic product manufacturing suffer from complex data acquisition links and unstable dynamic storage, making it difficult to accurately locate the source of process defects when the quality of finished products is abnormal. Furthermore, the centralized operation and maintenance model is susceptible to hardware failures and network attacks, and data integrity and credibility are insufficient.
Adopting a dual-chain fusion architecture, the production node cluster is optimized through reverse clustering and genetic algorithms to build a basic traceability chain and a quality traceability chain. Data fusion is performed by combining Bayesian networks and Kalman filter models, and blockchain technology is used to ensure that the data is tamper-proof and decentralized, thereby achieving reliable traceability of product quality.
It improves the reliability and system trust of product quality traceability, ensures data integrity and security, reduces the risk of single points of failure, and provides efficient end-to-end quality traceability capabilities.
Smart Images

Figure CN120146871B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of blockchains, and particularly relates to a double-chain fusion product quality tracing method and system applied to a production line. BACKGROUND
[0002] Under the deep penetration of the digital wave, new-generation information technologies such as 5G communication, smart finance and industrial interconnection accelerate evolution and promote explosive growth in various fields of society. In particular, in the field of electronic product manufacturing, the deep fusion of industrial Internet of Things technology restructures the traditional production mode. Due to the problems such as complex acquisition link and unstable dynamic storage of massive process data generated in the whole process of electronic product processing, key processing parameters are extremely likely to be missing in a chain, which makes it difficult to accurately locate the process defect source when the quality of finished products is abnormal.
[0003] In view of the above industry pain points, the current industry generally adopts an Internet of Things sensing network to build a whole-process monitoring system. Although such a system preliminarily realizes the visualized tracing of production data through device interconnection, the underlying architecture still adopts an intermediate proxy architecture or a master-slave architecture, and all terminal devices must complete identity authentication and data interaction through a centralized data center. This centralized operation and maintenance mode may not only cause the core database to crash and lead to the disappearance of historical data when encountering abnormal situations such as hardware failure and network attack, but also has the risk of malicious data tampering under the vulnerability of permission management, which makes the quality tracing report formed finally not only unable to meet the data integrity requirement, but also difficult to be generally accepted by the upstream and downstream of the supply chain. SUMMARY
[0004] The application provides a double-chain fusion product quality tracing method and system applied to a production line to solve the problem that the tracing result of product quality does not have reliability and lacks public credibility.
[0005] In a first aspect, the application provides a double-chain fusion product quality tracing method applied to a production line, which comprises the following steps:
[0006] Comprehensive production data and node attributes of a target product at multiple production nodes in different production stages are acquired, and the node attributes include a stage number unique to a production stage corresponding to a production node;
[0007] Multiple production nodes with different stage numbers are randomly selected as initial cluster centers, and the number of initial cluster centers is the same as the number of production stages;
[0008] Based on the node attributes and using a reverse clustering algorithm, all production nodes are clustered based on the initial cluster centers to obtain multiple production node clusters;
[0009] All production nodes in the same production node cluster are taken as blockchain nodes to construct a basic traceability chain, and all integrated production data are integrated to generate a basic blockchain ledger;
[0010] According to the node attribute, core nodes are selected from each basic traceability chain, and a quality traceability chain is constructed in combination with all the core nodes;
[0011] The corresponding basic blockchain ledger is updated through the core nodes, and the updated basic blockchain ledger is uploaded to the quality traceability chain;
[0012] The product quality traceability data of the target product are queried by using the quality traceability chain.
[0013] Optionally, the node attribute further includes a production capacity index and a production category number of the production node, the production category number of each production node is different, and all the production nodes are clustered based on the node attribute and by using a reverse clustering algorithm with an initial clustering center as a basis to obtain a plurality of production node clusters including the following steps:
[0014] The other all production nodes are clustered to the initial clustering center with the maximum difference of the stage number or the production category number as a clustering target to obtain a plurality of initial clustering clusters;
[0015] A first optimization target is generated in combination with the stage number and the production category number;
[0016] All the initial clustering clusters are coded as an initial first population, the initial first population is optimized according to the first optimization target and by using a genetic algorithm to obtain an optimal first population;
[0017] A second optimization target is generated based on the production capacity index;
[0018] The optimal first population is taken as an initial second population, the initial second population is optimized according to the second optimization target and by using the genetic algorithm to obtain an optimal second population;
[0019] The optimal second population is disassembled into a plurality of production node clusters in the form of clustering clusters.
[0020] Optionally, the expression formula of the first optimization target is as follows:
[0021]
[0022] In the formula, F1 represents the first optimization target, max(·) represents a maximum value function, N represents the number of initial clustering clusters in the initial first population, M n represents the number of nodes of the production node in the nth initial clustering cluster, represents the stage number of the mth production node in the nth initial clustering cluster, represents the average of the stage numbers of all generated nodes in the nth initial clustering cluster, represents the production category number of the mth generated node in the nth initial clustering cluster, represents the average of the production category numbers of all generated nodes in the nth initial clustering cluster.
[0023] Optionally, the expression formula of the second optimization target is as follows:
[0024]
[0025] In the formula: F2 represents the second optimization target, and min(·) represents the minimum value function, represents the average of the production capacity indexes of all generated nodes in the nth initial clustering cluster, represents the production capacity index of the mth generated node in the nth initial clustering cluster.
[0026] Optionally, all generated nodes in the same generated node cluster are taken as blockchain nodes to construct a basic traceability chain, and all integrated production data are integrated to generate a basic blockchain ledger, including the following steps:
[0027] The basic traceability chain is constructed in the form of an alliance chain by using all generated nodes in the generated node cluster;
[0028] The integrated production data corresponding to all generated nodes are uploaded to the basic traceability chain by creating a block transaction;
[0029] The same type of integrated production data is combined by using a Bayesian network and a Kalman filter model to obtain fused traceability data, and the fused traceability data includes public traceability data and private traceability data;
[0030] The private traceability data is encrypted into encrypted traceability data by using a preset encryption algorithm;
[0031] The public traceability data and the encrypted traceability data are broadcast to the basic traceability chain to generate a basic blockchain ledger of the basic traceability chain.
[0032] Optionally, the same type of integrated production data is combined by using a Bayesian network and a Kalman filter model to obtain fused traceability data, including the following steps:
[0033] The same type of integrated production data is processed by using a Kalman filter model to eliminate data errors of the integrated production data, and baseline production data is obtained;
[0034] The information gain of the baseline production data is calculated based on a probability distribution;
[0035] According to information gain, a target production data set is selected from the benchmark production data;
[0036] All data in the target production data set is fused by a Bayesian network to obtain fused traceability data.
[0037] Optionally, according to information gain, a target production data set is selected from the benchmark production data, including the following steps:
[0038] The data acquisition cost of the benchmark production data is obtained;
[0039] An optimal utility function is constructed by combining information gain and data acquisition cost;
[0040] The target production data set is selected from the benchmark production data by using the optimal utility function.
[0041] Optionally, the node attribute further includes a device attribute of an embedded device set by the production node, and the device attribute includes device storage space, device computing power and device bandwidth; the core node is selected from each basic traceability chain according to the node attribute, including the following steps:
[0042] Every preset interval time, the device attribute corresponding to all blockchain nodes at the current time is obtained;
[0043] All device attributes are normalized;
[0044] The normalized device attribute is assigned an index weight according to a preset weight distribution strategy;
[0045] The node state score of the blockchain node is obtained by combining the device attribute and the corresponding index weight and by weighted calculation;
[0046] The blockchain node with the highest node state score is selected as the core node at the current time.
[0047] Optionally, the node attribute further includes product category heat of a production category corresponding to the production node, and the method further includes the following steps:
[0048] An original Huffman tree in the basic blockchain ledger is extracted;
[0049] All tree nodes in the original Huffman tree are given a heat weight based on the product category heat, and the higher the product category heat, the greater the heat weight;
[0050] The original Huffman tree is reconstructed into a weighted Huffman tree according to the heat weight and by following the principle of weighted path minimization;
[0051] The original Huffman tree in the basic blockchain ledger is replaced by the weighted Huffman tree, and the basic blockchain ledger after the replacement is saved to the core node.
[0052] calculating the weighted huffman tree based on the heat weight and by the huffman algorithm to obtain a trunk depth of the weighted huffman tree;
[0053] screening out edge tree nodes in the weighted huffman tree according to the trunk depth to obtain a simplified weighted huffman tree;
[0054] replacing the weighted huffman tree in the basic blockchain account book with the simplified weighted huffman tree, and saving the basic blockchain account book after the replacement to all blockchain nodes except the core node in the basic traceability chain.
[0055] In a second aspect, the application further provides a double-chain fusion product quality traceability system applied to a production line, comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, and the processor implements the double-chain fusion product quality traceability method applied to the production line when executing the computer program.
[0056] The application has the following beneficial effects:
[0057] The product quality traceability method used in the application is based on the blockchain technology, and one of the core features of the blockchain is that data cannot be tampered with. Once a transaction or data record is added to the blockchain, it cannot be tampered with or deleted, ensuring the integrity and authenticity of the data. On the other hand, the blockchain is a decentralized distributed ledger technology that does not rely on a single central control node, reducing the risk of single point failure and improving the reliability and fault tolerance of the traceability process. Therefore, compared with the Internet of Things traceability method in the prior art which has poor reliability and lacks public trust, the product quality traceability based on the blockchain has significant advantages in data tamper-proofing, decentralization, data transparency, security, traceability, smart contract support, and data sharing, and can provide higher system reliability and trustworthiness. BRIEF DESCRIPTION OF DRAWINGS
[0058] Figure 1 The figure is a flowchart of the double-chain fusion product quality traceability method applied to a production line in one of the embodiments of the application.
[0059] Figure 2 The figure is a schematic diagram of the construction of the quality traceability chain in combination with multiple core nodes in one of the embodiments of the application. DETAILED DESCRIPTION
[0060] The technical solutions in the embodiments of the application will be described clearly below with reference to the drawings in the embodiments of the application. Obviously, the described embodiments are only some of the embodiments of the application, not all the embodiments. Based on the embodiments in the application, all other embodiments obtained by those of ordinary skill in the art belong to the scope of protection of the application.
[0061] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a particular order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally of a kind and do not limit the number of objects, for example, the first object can be one or more. In addition, "and / or" in the specification and claims indicates at least one of the connected objects, and the character " / " generally indicates that the objects before and after are in an "or" relationship.
[0062] Figure 1 A flowchart of a double-chain fusion product quality traceability method applied to a production line in an embodiment. It should be understood that, although Figure 1 The steps in the flowchart are displayed in sequence according to the direction of the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, the execution of these steps is not strictly limited in sequence, and these steps can be executed in other orders. Moreover, Figure 1 At least part of the steps in the flowchart can include multiple sub-steps or multiple stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily sequential, but can be executed in rotation or alternation with at least part of other steps or sub-steps or stages of other steps. As Figure 1 The double-chain fusion product quality traceability method disclosed by the present application specifically includes the following steps:
[0063] S101. Obtain comprehensive production data and node attributes of a target product at multiple production nodes in different production stages.
[0064] In the first step of product quality traceability, comprehensive production data and node attribute information of the target product at each production stage of the entire production line need to be collected. Comprehensive production data includes but is not limited to production parameters, quality test results, production environment data, equipment operating status and other multi-dimensional information. Node attributes mainly include the unique stage number of the production node corresponding to the production stage, which is used to clearly identify the specific location and processing stage of the product on the production line. For example, on a smart phone production line, there may be PCB manufacturing (stage number 01), chip packaging (stage number 02), screen assembly (stage number 03), battery installation (stage number 04), and whole machine testing (stage number 05) and other production stages. Each stage may contain multiple specific production nodes. Data acquisition is usually achieved through various channels such as Internet of Things sensors deployed on the production line, RFID tags, data interfaces provided by production equipment, and quality inspection equipment. These devices will collect various data in the production process in real time, such as temperature, humidity, pressure, voltage, production rate, and failure rate.
[0065] In actual implementation, a distributed data acquisition architecture can be used to deploy edge computing devices at each production node for preliminary data processing and storage. These data are transmitted to the central data processing center through industrial Ethernet or wireless communication technology (such as 5G, Wi-Fi6) to form a complete data set. The data acquisition frequency may vary from milliseconds to hours according to the production process requirements, ensuring the timeliness and integrity of the data. To ensure data quality, the collected raw data need to be preprocessed, including outlier detection, missing value processing and data standardization. Through these preprocessing steps, the data used for subsequent analysis have high quality and reliability, laying a solid data foundation for product quality traceability.
[0066] S102. Randomly select multiple production nodes with different stage numbers as initial cluster centers.
[0067] In the process of determining the initial cluster centers, a special random selection strategy is adopted, that is, one production node is selected from each production stage as the initial cluster center. This strategy ensures that the number of initial cluster centers is consistent with the number of production stages, and ensures that each initial cluster center comes from a different production stage, avoiding the situation that initial cluster centers are excessively concentrated in a certain production stage. In specific implementation, a stratified random sampling method can be used. First, all production nodes are grouped according to stage number to form multiple node subsets, each containing all nodes of the same production stage. Then, a node is randomly selected from each node subset as the representative of the stage to form the initial cluster center set. Random sampling can use a pseudo-random number generator, and the random index generated in this way can select the node at the corresponding position from the node list of each stage. In order to enhance randomness and avoid selection bias, random selection can be performed before each clustering, or the average effect of multiple random selections can be used.
[0068] The advantage of this selection method is that it can ensure that the initial cluster centers are representative in the spatial distribution of the production process, covering the entire production process. At the same time, since the process characteristics and data characteristics of each production stage may differ significantly, this selection method also helps to capture the feature differences of different production stages and improve the clustering effect. In addition, this method also avoids the local optimum problem that may be caused by the selection of initial cluster centers in the traditional K-means algorithm, because it forcibly ensures the diversity and dispersion of the initial cluster centers. In terms of implementation effect, this initial cluster center selection method can improve the convergence speed and clustering quality of the clustering algorithm, reducing the risk of the algorithm falling into local optimum, providing a good starting point for the subsequent reverse clustering algorithm, and thus more accurately identifying production node groups with similar characteristics.
[0069] S103. Based on the node attributes and using the reverse clustering algorithm, all production nodes are clustered based on the initial cluster centers to obtain multiple production node clusters.
[0070] In this step, all production nodes are grouped using a reverse clustering algorithm, which is fundamentally different from traditional clustering methods. Instead of grouping similar nodes together, the reverse clustering algorithm assigns nodes to different cluster centers based on their differences in attributes, aiming to maximize the differences between clusters. This method is particularly suitable for product quality traceability scenarios, as it ensures that each cluster contains production nodes with different characteristics, thereby improving the coverage and representativeness of the entire traceability system. The core idea of reverse clustering is to assign each node to be classified to the cluster center with the greatest difference. The specific algorithm process is as follows: first, based on the initial cluster centers selected in the previous step, calculate the difference degree of each unclassified node with all cluster centers; then, assign the node to the cluster where the cluster center with the greatest difference degree; then, update the cluster center of this cluster (the average attribute value of all nodes in the cluster can be used as the new cluster center); finally, repeat the above process until all nodes are assigned or the preset iteration number is reached.
[0071] To optimize the clustering results, a genetic algorithm can be introduced for multi-objective optimization. First, encode the initial clustering results as chromosomes, with each chromosome representing a possible clustering scheme. Then, define a fitness function to evaluate the quality of each clustering scheme, which can combine multiple objectives such as stage number difference, production category number difference, and production capacity index difference. Next, generate a new generation population through selection, crossover, and mutation operations, and continuously iterate and optimize until the optimal clustering scheme that meets the multi-objective optimization requirements is obtained. The implementation effect of this step is to form multiple production node clusters with high differences, each containing key nodes in the product production process. This clustering method provides a reasonable node grouping for subsequent construction of the basic traceability chain, ensuring that each basic traceability chain can cover the complete production process of the product, while also improving the robustness and reliability of the entire traceability system.
[0072] S104. Constructing a basic traceability chain by taking all production nodes in the same production node cluster as blockchain nodes, and integrating all comprehensive production data to generate a basic blockchain ledger.
[0073] After the clustering of production nodes is completed, the next step is to transform each production node cluster into an independent blockchain network, namely the underlying traceability chain. The core of this step is to map the nodes in the physical production environment to the nodes in the blockchain network and build the corresponding data structure and consensus mechanism to ensure the reliable recording and traceability of production data. Specifically, all production nodes in the same production node cluster will participate in the corresponding underlying traceability chain as blockchain nodes, forming a consortium chain structure. In the implementation process, first, each production node needs to be configured with blockchain node software, including distributed ledger, consensus algorithm module, smart contract execution environment, and other components. Considering the limited computing power and storage space of devices in the production environment, a lightweight blockchain framework such as Hyperledger Fabric or an optimized Ethereum private chain can be used. Each blockchain node will be assigned a pair of public and private keys for digital signature and identity verification.
[0074] Next, the comprehensive production data of the production nodes needs to be integrated and uploaded to the blockchain network. These data can be submitted by creating block transactions, each transaction containing production parameters, quality detection results, timestamps, and other information. To improve data processing efficiency, batch processing can be used to package production data within a certain time period (such as every hour or every shift) into a transaction. Before data upload, the production node needs to use the private key for digital signature to ensure the authenticity and non-repudiation of data sources.
[0075] To process the same type of comprehensive production data, the system combines Bayesian networks and Kalman filter models for data fusion. The Kalman filter model is mainly used to eliminate random noise and measurement errors in the data, while the Bayesian network is used to handle the probability dependency between multi-source data, describing the causal relationship between variables through the conditional probability table (CPT), and using Bayesian theorem for inference calculation. After data fusion, the system divides the fusion results into public traceability data and private traceability data. Public traceability data can be directly stored on the blockchain, while private traceability data needs to be encrypted through encryption algorithms (such as AES-256 or RSA) to generate encrypted traceability data. This separate storage method ensures data security and improves blockchain storage efficiency. Encrypted private data can be stored in an off-chain database, while the blockchain only saves the hash value and access control information of the data, and the integrity of the data is verified through the hash pointer.
[0076] In the consensus mechanism selection of the basic traceability chain, considering the limited number of nodes and the trusted identity in the production environment, high-efficiency consensus algorithms such as Practical Byzantine Fault Tolerance (PBFT) or Proof of Stake (PoS) can be used instead of the computationally intensive Proof of Work (PoW) algorithm. For example, in the PBFT consensus, when more than 2 / 3 of the nodes reach an agreement, the validity of a block can be confirmed. This consensus mechanism can ensure security while providing high transaction processing speed and deterministic finality, which meets the real-time requirements of product quality traceability. The data structure design of the basic blockchain ledger is also crucial. Each block contains two parts: the block header and the block body. The block header contains the hash value of the previous block, the timestamp, the Merkle tree root hash, and a random number. The block body contains multiple transaction records, each corresponding to a production data. To improve query efficiency, an index structure such as a B+ tree-based index or an inverted index can be constructed outside the blockchain to enable fast queries on specific products, specific production parameters, or specific time periods.
[0077] The implementation effect of this step is to form multiple parallel running basic traceability chains, each containing key nodes of the entire product production process and capable of independently recording and tracing product quality data. This distributed architecture improves the scalability and fault tolerance of the system, so that even if one basic traceability chain fails, the others can still operate normally. At the same time, due to the limited number of nodes in each basic traceability chain, the consensus process is more efficient, improving the overall performance of the system. In addition, the construction of the basic traceability chain also provides a reliable data foundation and technical support for the subsequent quality traceability chain.
[0078] S105. Select core nodes from each basic traceability chain based on node attributes, and construct a quality traceability chain by combining all core nodes.
[0079] Among them, refer to Figure 2 After constructing multiple basic traceability chains, core nodes need to be selected from these basic traceability chains and integrated into a higher-level quality traceability chain to achieve global quality traceability across basic traceability chains. The selection of core nodes is based on node attributes, and to ensure that the selected core nodes can represent the entire production process, the distribution of nodes in the production phase also needs to be considered. Ideally, at least one core node should be selected from each key production phase to ensure that the quality traceability chain covers the entire product production process.
[0080] After selecting the core nodes, these nodes need to be integrated into a quality traceability chain. The quality traceability chain adopts a hierarchical architecture, including a data layer, a network layer, a consensus layer, an incentive layer, a contract layer, and an application layer. The data layer is responsible for encrypted storage and access control of data; the network layer is responsible for communication and data transmission between nodes; the consensus layer adopts an improved Byzantine fault tolerance algorithm (PBFT) to ensure efficient consensus in a limited node environment; the incentive layer designs an incentive mechanism based on quality contribution to encourage nodes to provide high-quality data and services; the contract layer implements smart contracts related to quality traceability, such as quality data verification contracts and quality anomaly early warning contracts; and the application layer provides functional interfaces for quality traceability queries and quality analysis. During the construction of the quality traceability chain, the interoperability between core nodes needs to be addressed. This can be achieved through a unified data exchange format (such as JSON-LD) and cross-chain communication protocols. Each core node is both a participant in its underlying traceability chain and a maintainer of the quality traceability chain, acting as a bridge. Core nodes implement data conversion and synchronization from underlying traceability chains to the quality traceability chain through specific adapter modules.
[0081] The implementation effect of this step is to form a high-level quality traceability chain that integrates core nodes and key quality data from various underlying traceability chains, providing global perspective product quality traceability capabilities. The quality traceability chain not only can track the entire production process of a single product, but also can analyze the quality correlation between different products and batches, providing strong support for root cause analysis and prevention of quality problems. At the same time, since the quality traceability chain only contains core nodes and key data, it has higher efficiency and stronger scalability compared to complete underlying traceability chains.
[0082] S106. Update the corresponding underlying blockchain ledger through the core node, and upload the updated underlying blockchain ledger to the quality traceability chain.
[0083] After the mass traceability chain is constructed, an efficient mechanism is needed to enable the core node to continuously update the underlying blockchain ledger and synchronize the updated ledger information to the mass traceability chain, thereby achieving data consistency and information intercommunication between the underlying traceability chain and the mass traceability chain. This step is a key link in the normal operation of the entire traceability system, ensuring the effective flow and timely update of product quality data between different levels of blockchains. The process of the core node updating the underlying blockchain ledger adopts a two-way synchronization mechanism. First, as a participant in the underlying traceability chain, the core node can receive production data transactions submitted by other nodes on the same underlying traceability chain. When new production data is submitted, all nodes on the underlying traceability chain, including the core node, will verify the validity of the data through a consensus algorithm and package the validated data into blocks to be added to the underlying blockchain ledger. Second, the core node can also receive quality feedback information from the mass traceability chain, such as quality anomaly alerts and quality improvement suggestions, and convert this information into transactions to be submitted to the underlying traceability chain, triggering an update of the underlying blockchain ledger.
[0084] To improve update efficiency and reduce network load, the core node adopts an incremental update strategy, synchronizing only the newly added or modified data since the last update. Specifically, the Merkle tree difference comparison algorithm can be used: first, calculate the Merkle tree root hash of the current ledger state and the root hash at the time of the last synchronization; if they are different, start from the root node and recursively compare the hash values of the sub-trees until all changed leaf nodes are found, and the data corresponding to these leaf nodes is the incremental data that needs to be synchronized. When uploading the underlying blockchain ledger to the mass traceability chain, the core node needs to perform data processing and conversion. First, filter and aggregate the underlying ledger data, extracting only the key data related to product quality. Second, standardize the filtered data and convert it to the unified data format defined by the mass traceability chain. Finally, the core node uses its identity credentials on the mass traceability chain to package the processed data into transactions and submit them to the mass traceability chain.
[0085] To ensure data security and privacy protection, the core node will perform differential privacy processing before uploading the data. Differential privacy is a data publishing technique that adds carefully designed random noise to the original data, making the analysis results not significantly change with the addition or removal of any single individual, thereby protecting individual privacy. In practical applications, the core node's update frequency can be dynamically adjusted according to production rhythm and data importance. For high-value and high-risk products (such as medical devices and aviation components), real-time or near-real-time updates may be required; while for general consumer goods, batch update strategies such as hourly or shift updates may be used.
[0086] The implementation effect of this step is to establish a data bridge between the basic traceability chain and the quality traceability chain, realizing the information interconnection and data consistency of the multi-level blockchain system. Through the bidirectional synchronization mechanism of the core node, the detailed production data on the basic traceability chain can be refined and aggregated to form high-value quality information uploaded to the quality traceability chain; at the same time, the global quality analysis results and improvement suggestions on the quality traceability chain can also be fed back to the basic traceability chain to guide the optimization and adjustment of the production process. This bidirectional information flow mechanism greatly improves the data value and application effect of the entire traceability system.
[0087] S107. Query the product quality traceability data of the target product using the quality traceability chain.
[0088] Among them, after the construction and data synchronization of the quality traceability chain are completed, the final goal is to provide an efficient, safe and convenient query interface, so that users can obtain the complete quality traceability data of the target product through the quality traceability chain. This step is the application layer embodiment of the entire traceability system, directly serving the information needs of the end users, including quality management personnel within the production enterprise, regulatory agencies, downstream customers and end consumers, and other user groups. The query process first needs to confirm the identity and authority of the queryer. Using the attribute-based access control (ABAC) mechanism, according to the identity attributes of the queryer (such as organizational affiliation, position level), environmental attributes (such as query time, query location), resource attributes (such as data sensitivity level) and operation attributes (such as query type) and other multi-dimensional information, the access authority of the queryer to specific traceability data is dynamically judged. For example, enterprise internal quality management personnel may have access to all detailed quality data, while ordinary consumers may only be able to access product basic information and quality certification and other public data.
[0089] Identity verification adopts a multi-factor authentication method, combining digital certificates (X.509 standard), cryptographic proofs (such as zero-knowledge proofs) and biometric identification technologies to ensure the authenticity of the queryer's identity. For example, the elliptic curve digital signature algorithm (ECDSA) can be used for identity verification: the queryer uses a private key to sign a random challenge value, and the system uses the queryer's public key to verify the validity of the signature, thereby confirming the identity of the queryer.
[0090] In one embodiment, the node attribute further comprises a production capacity index of the production node and a production category number, and the production category number of each production node is different. Clustering all the production nodes based on the node attribute and using a reverse clustering algorithm with the initial clustering center to obtain a plurality of production node clusters comprises the following steps:
[0091] Maximizing the difference between the stage number or the production category number as a clustering target, clustering all other production nodes to the initial clustering center to obtain a plurality of initial clustering clusters;
[0092] Generating a first optimization target in combination with the stage number and the production category number;
[0093] Encoding all the initial clustering clusters as an initial first population, optimizing the initial first population according to the first optimization target and using a genetic algorithm to obtain an optimal first population;
[0094] Generating a second optimization target based on the production capacity index;
[0095] Taking the optimal first population as an initial second population, optimizing the initial second population according to the second optimization target and using a genetic algorithm to obtain an optimal second population;
[0096] Dissolving the optimal second population into a plurality of production node clusters in the form of clustering clusters.
[0097] In this embodiment, first, select K nodes with the largest difference between the stage number or the production category number from all the production nodes as the initial clustering center. The selection method of maximizing the difference is: calculate the number difference between all node pairs, and select the K nodes with the largest number difference. For example, if the stage numbers of the nodes are {1, 2, 3, 5, 8, 9}, when K = 3, select the nodes with numbers 1, 5, and 9 as the initial clustering center, because the difference between them is the largest. Then, for each remaining production node, calculate the distance between it and each initial clustering center, and assign it to the cluster where the nearest initial clustering center is located. The distance calculation uses the weighted Euclidean distance: d(i, j) = w1(S i -S j ) 2 +w2(C i -C j 2 , wherein S i and S j represent the stage numbers of nodes i and j, respectively, and C i and C j wherein w1 and w2 are weight coefficients. In this way, all production nodes are divided into K initial cluster clusters, each of which contains an initial cluster center and nodes around it. The implementation effect of this step is to form a preliminary node grouping, so that nodes of different stages or different production categories are divided into different clusters, laying the foundation for subsequent optimization.
[0098] Next, the first optimization target is generated in combination with the stage number and the production category number. The first optimization target aims to maximize the similarity of nodes within the cluster and minimize the similarity of nodes between different clusters. The expression formula of the first optimization target is as follows:
[0099]
[0100] In the formula, F1 represents the first optimization target, max(·) represents the maximum value function, N represents the number of initial cluster clusters in the initial generation population, M represents the number of production nodes in the nth initial cluster cluster, n represents the number of production nodes in the nth initial cluster cluster, represents the stage number of the mth production node in the nth initial cluster cluster, represents the average stage number of all production nodes in the nth initial cluster cluster, represents the production category number of the mth production node in the nth initial cluster cluster, represents the average production category number of all production nodes in the nth initial cluster cluster.
[0101] The initial clustering clusters are encoded as an initial population, and the initial population is optimized according to the first optimization target and by using a genetic algorithm to obtain an optimal population. In a specific implementation, first, each clustering scheme is encoded as a chromosome, and the length of the chromosome is equal to the total number of production nodes N. The value of each position represents the cluster number to which the corresponding node belongs. For example, the chromosome [1, 1, 2, 3, 2, 1] indicates that nodes 1, 2, and 6 belong to cluster 1, nodes 3 and 5 belong to cluster 2, and node 4 belongs to cluster 3. The initial population includes M chromosomes, corresponding to M different clustering schemes, including the initial clustering scheme obtained in the S1 step. The fitness function of the genetic algorithm directly uses the reciprocal of the first optimization target function F1: fitness = 1 / F1. The smaller the value of F1, the higher the fitness. The selection operation adopts the roulette wheel selection and elite reservation strategy, and the chromosomes with higher fitness are reserved to enter the next generation. The crossover operation adopts two-point crossover, randomly selects two crossover points, exchanges the fragments between the two parent chromosomes, and generates new child chromosomes. To maintain the effectiveness of the clustering, repair is needed after the crossover to ensure that each cluster contains at least one node. The mutation operation randomly selects certain positions on the chromosome and changes their values with a certain probability, that is, some nodes are re-assigned to different clusters. The selection, crossover, and mutation operations are iteratively performed until the preset termination condition (such as the maximum number of iterations or the convergence of fitness) is reached. Finally, the chromosome with the highest fitness is selected as the optimal population, representing the optimal clustering scheme in the production phase and production category dimensions. The implementation effect of this step is to obtain the optimal clustering result under the first optimization target, ensuring that the nodes in the same cluster have high similarity in the production phase and production category.
[0102] Next, the second optimization target is generated based on the production capacity index. The second optimization target aims to balance the production capacity of each cluster and avoid the situation where some clusters have excessive or insufficient production capacity. The expression formula of the second optimization target is as follows:
[0103]
[0104] In the formula: F2 represents the second optimization target, min(·) represents the minimum value function, represents the average production capacity index of all production nodes in the nth initial clustering cluster, represents the production capacity index of the mth production node in the nth initial clustering cluster. The second optimization target constructs a target function that can evaluate the balance of cluster production capacity, providing a new optimization direction for subsequent genetic algorithm optimization and ensuring the rationality of the clustering result in the production capacity dimension.
[0105] The optimal first generation population is used as the initial second generation population, and the initial second generation population is optimized according to the second optimization target and by using a genetic algorithm to obtain an optimal second generation population. In specific implementation, the optimal first generation population obtained in the previous step is used as part of the initial second generation population, and some new chromosomes are generated to increase population diversity. The fitness function of the genetic algorithm uses the reciprocal of the second optimization target function F2: fitness = 1 / F2, and the smaller the F2 value, the higher the fitness. In order to balance the first optimization target and the second optimization target, a weighted combination method can be used to define a comprehensive fitness function. The selection operation also uses the roulette wheel selection and elite reservation strategies. The crossover operation uses uniform crossover, and the values of each position of the two parent chromosomes are exchanged with a certain probability. The mutation operation uses an adaptive mutation rate, and the mutation probability is dynamically adjusted according to the diversity of the population: when the population diversity is low, the mutation rate is increased; when the population diversity is high, the mutation rate is decreased. The diversity can be measured by calculating the average Hamming distance between chromosomes in the population. The selection, crossover, and mutation operations are iteratively performed until the preset termination condition is reached. Finally, the chromosome with the highest fitness is selected as the optimal second generation population, representing the optimal clustering scheme after considering the stage number, production category number, and production capacity index. The implementation effect of this step is to obtain the optimal clustering result under the second optimization target, ensuring the balance of production capacity between clusters while maintaining the excellent characteristics of the first optimization target.
[0106] The optimal second generation population is disassembled into multiple production node clusters in the form of clustering. In specific implementation, according to the chromosome with the highest fitness in the optimal second generation population, all production nodes are divided into multiple node clusters. For the position with value i on the chromosome, the corresponding node is assigned to the ith node cluster. For example, for the chromosome [1, 1, 2, 3, 2, 1], nodes 1, 2, and 6 are assigned to the first node cluster, nodes 3 and 5 are assigned to the second node cluster, and node 4 is assigned to the third node cluster. In order to facilitate subsequent processing, a unique identifier can be assigned to each node cluster, and the information of all nodes in the cluster is recorded, including node ID, stage number, production category number, and production capacity index. In addition, the characteristic statistics of each node cluster can be calculated, such as the distribution of stage numbers, the distribution of production category numbers, the total production capacity index, and the average production capacity index, which helps to understand the characteristics of the node cluster. The final formed node cluster will serve as a basic unit for building a basic traceability chain, and each node cluster corresponds to a basic traceability chain. The implementation effect of this step is to convert the optimized clustering result into actual usable node clusters, which have internal similarity in stage number and production category number and achieve cross-cluster balance in production capacity, laying a foundation for subsequent construction of an efficient and reasonable multi-level block chain traceability system.
[0107] In one embodiment, all production nodes in the same production node cluster are constructed as blockchain nodes to build a basic traceability chain, and the integrated production data of all production nodes is integrated to generate a basic blockchain ledger, which includes the following steps:
[0108] All production nodes in the production node cluster are constructed as a consortium chain to build a basic traceability chain.
[0109] The integrated production data corresponding to all production nodes is uploaded to the basic traceability chain by creating a block transaction.
[0110] The integrated production data of the same type is fused by combining the Bayesian network and Kalman filter model to obtain fused traceability data, which includes public traceability data and private traceability data.
[0111] The private traceability data is encrypted into encrypted traceability data by a preset encryption algorithm.
[0112] The public traceability data and the encrypted traceability data are broadcast to the basic traceability chain to generate a basic blockchain ledger of the basic traceability chain.
[0113] In this embodiment, first, an independent consortium chain network is established for each production node cluster. The network adopts a permissioned blockchain architecture, and only production nodes within the cluster can participate in the consensus process as validation nodes. Each production node needs to be configured with a dedicated blockchain node server, install a unified blockchain client software, and connect to each other through a secure network protocol (such as TLS 1.3). The communication between nodes adopts a P2P network topology, and each node establishes a direct connection with at least 3-5 other nodes within the cluster to ensure the robustness of the network. The consensus mechanism of the consortium chain adopts the Practical Byzantine Fault Tolerance (PBFT) algorithm or a variant of Proof of Stake (PoS), in which the voting weight of the nodes can be weighted according to the production capacity index. The higher the production capacity index, the higher the voting weight. For example, if the production capacity index of node A is 100 and that of node B is 50, the voting weight of node A is twice that of node B. The block generation time of the consortium chain is set to 30 seconds, and each block can accommodate a maximum of 1000 transactions, with a block size limit of 2MB. To ensure the security of the chain, a multi-signature mechanism is implemented, requiring at least 2 / 3 of the nodes to sign to confirm the validity of the block. In addition, each basic traceability chain is also configured with a smart contract execution environment to support subsequent data verification and business logic execution.
[0114] Each production node needs to standardize the data generated in its production process to form structured comprehensive production data. The comprehensive production data includes but is not limited to: production batch number, production timestamp, raw material information, production parameters, quality test results, environmental monitoring data, etc. The data is organized in JSON format. Before the data is chained, the production node needs to use its private key to digitally sign the data to generate a signature value sig = Sign(Hash(data), privateKey), where Hash is the SHA-256 hash function and Sign is the ECDSA signature algorithm. Subsequently, the production node constructs a blockchain transaction, which includes: data sender address, data receiver address (usually smart contract address), comprehensive production data, digital signature, timestamp, transaction fee, etc. The transaction is sent to the consortium chain network through the RPC interface or special API, and the current round of block generation node collects and packs it into a block. To improve the efficiency of data chaining, a batch submission mechanism can be used to combine multiple production data generated in a short period of time into one transaction package, reducing the number of transactions. For large data (such as high-definition images, videos, etc.), a chain-offline storage and chain-online index method is used, that is, the data is stored in a distributed storage system such as IPFS, and only the data hash value is chained. The implementation effect of this step is to realize the tamper-proof record of production data and establish a data trust foundation from the production source, providing original data support for subsequent data fusion and traceability query.
[0115] The same type of comprehensive production data is fused by combining a Bayesian network and a Kalman filter model to obtain fused traceability data, which includes public traceability data and private traceability data. In specific implementation, first, a Bayesian network model is constructed to represent the probabilistic dependency between different production data. The Bayesian network is a directed acyclic graph (DAG), where nodes represent random variables (such as production parameters, quality indicators, etc.), and edges represent the conditional dependency between variables. For each node X, its conditional probability distribution P(X|Parents(X)) is defined, where Parents(X) represents the parent node set of X. For example, product quality Q may depend on raw material quality M and production temperature T, and P(Q|M,T) is defined. The Bayesian network learns these conditional probability distributions from historical data. At the same time, for time-series production data, a Kalman filter model is applied for state estimation and noise filtering. Kalman filtering includes two steps of prediction and update: the prediction step calculates the prior state estimate and the prior error covariance; the update step calculates the Kalman gain, the posterior state estimate and the posterior error covariance. In the data fusion process, first, the Kalman filter is used to filter the time-series data of each data source, and then the filtered data is used as the observation value of the Bayesian network to obtain the fusion result through probabilistic reasoning. The fused data is divided into public traceability data (such as product basic information, quality level, etc.) and private traceability data (such as detailed formula, accurate production parameters, etc.) according to the sensitivity. The implementation effect of this step is to improve the accuracy and reliability of the traceability data, eliminate the conflicts and noise between different data sources, and at the same time, prepare for data privacy protection.
[0116] Next, a multi-level encryption strategy is adopted to protect the privacy traceability data. First, symmetric encryption algorithm AES-256-GCM is used to encrypt the privacy data, generating ciphertext C = AES-Encrypt(K, IV, P, AAD), where K is the symmetric key, IV is the initialization vector, P is the plaintext data, and AAD is the additional authentication data. The encryption result includes the ciphertext and the authentication tag. The symmetric key K is randomly generated to ensure that different keys are used for each batch of data. Subsequently, the symmetric key K is encrypted again using Attribute-Based Encryption (ABE) technology to achieve fine-grained access control. The ABE encryption process is: Enc(K, A), where A is the access policy, such as "(role = regulatory agency OR role = quality inspection department) AND security level >= 3". This ensures that only users who meet certain attribute combinations can decrypt and obtain the symmetric key. To support traceable authorized access, a Proxy Re-Encryption (PRE) mechanism is also implemented, allowing data owners to generate re-encryption keys RK_A→B without exposing the original key, so that authorized party B can decrypt data that only A can decrypt. In the encryption process, a unique identifier UUID is generated for each piece of privacy data, and encryption metadata is recorded, including encryption algorithm version, access policy description, timestamp, etc. For particularly sensitive data, homomorphic encryption technology can also be applied, allowing certain calculations to be performed directly on the ciphertext without decryption. For example, using the Paillier encryption algorithm, the sum or average of the data can be calculated in an encrypted state. The implementation effect of this step is to ensure the security of the privacy traceability data during storage and transmission, while providing a flexible access control mechanism to meet the differentiated access needs of different roles.
[0117] Finally, the public traceability data and the encrypted traceability data are broadcast to the basic traceability chain to generate a basic blockchain ledger of the basic traceability chain. In implementation, first, a transaction structure containing the public traceability data and the encrypted traceability data is constructed. The transaction structure includes a transaction header (version number, timestamp, transaction type identifier, etc.), a data sender address, a smart contract address, a public traceability data field, an encrypted traceability data field, a data hash value, a digital signature, etc. The public traceability data is stored in plaintext, while the encrypted traceability data contains ciphertext and encryption metadata. After the transaction structure is constructed, the transaction is broadcast to all nodes of the basic traceability chain through the P2P broadcast protocol of the blockchain network. The broadcast adopts the Gossip protocol, and each node verifies the validity of the format and signature of the transaction after receiving the transaction, and then continues to propagate to other nodes. The current round value of the block generation node collects valid transactions within a certain time (such as 30 seconds), and packs the transactions into a block according to the predetermined rules (such as time sequence or transaction fee). The block structure includes a block header (previous block hash, timestamp, Merkle root, difficulty target, random number, etc.) and a block body (containing multiple transactions). After the block is generated, a consensus algorithm (such as PBFT) is used to reach an agreement in the network, and at least 2 / 3 of the validation nodes need to confirm that the block is valid. The confirmed block is added to the local ledger of each node to form the basic blockchain ledger. To improve query efficiency, the node also maintains an index database to record the mapping relationship of transaction ID, block height, timestamp, etc. In addition, a blockchain browser function is implemented to allow authorized users to query the public traceability data and (after authorization) decrypt and view the private traceability data through a Web interface. The implementation effect of this step is to form a distributed ledger containing complete traceability information, which not only ensures the openness and transparency of the data, but also protects the privacy and security of sensitive information, providing a solid foundation for the trusted traceability of the product throughout its life cycle.
[0118] In one embodiment, the same type of comprehensive production data is combined with a Bayesian network and a Kalman filter model to obtain fused traceability data, including the following steps:
[0119] The same type of comprehensive production data is processed using a Kalman filter model to eliminate data errors in the comprehensive production data and obtain reference production data.
[0120] The information gain of the reference production data is calculated based on the probability distribution.
[0121] According to the information gain, a target production data set is selected from the reference production data.
[0122] All data in the target production data set are fused through a Bayesian network to obtain fused traceability data.
[0123] In this embodiment, for the same data type of comprehensive production data, the comprehensive production data is processed by using the Kalman filter model to eliminate the data error of the comprehensive production data, and the reference production data is obtained. The Kalman filter model is a recursive algorithm that can estimate and correct noise and error in a dynamic system. Through the prediction and update steps, the estimated value of the data is continuously adjusted to obtain more accurate reference production data. In specific implementation, the comprehensive production data can be input into the Kalman filter model, and the prediction and update mechanism of the model can be used to gradually eliminate the error and noise in the data, and finally output stable and reliable reference production data.
[0124] The information gain of the reference production data is calculated based on the probability distribution. The principle of this step is to evaluate the contribution of each data point in the reference production data to the overall information amount through the concept of information gain in information theory. Information gain can be measured by calculating the change in entropy value of the data points in different states. In specific implementation, the probability distribution of the reference production data can be analyzed to calculate the change in entropy value of each data point, thereby determining its information gain. According to the information gain, the target production data set is selected from the reference production data. This step aims to select those data points that contribute most to the overall information amount, ensuring the efficiency and accuracy of subsequent data fusion. In specific implementation, according to the information gain value calculated in the previous step, a threshold value can be set or a sorting method can be used to select data points with higher information gain to form the target production data set.
[0125] All data in the target production data set is fused through the Bayesian network to obtain the fused traceability data. Bayesian network is a probabilistic graphical model that can represent and calculate the conditional dependence between variables. Through Bayesian inference, multiple data sources can be fused to obtain unified fusion data. In specific implementation, the target production data set can be input into the Bayesian network to construct the network structure and learn the parameters. Through Bayesian inference, different data points are fused to finally obtain fusion traceability data with high consistency and strong accuracy. Through these steps, production data can be effectively processed and fused to improve the reliability and consistency of the data, providing a solid data foundation for the traceability and management of the production process.
[0126] In one embodiment, the step of selecting the target production data set from the reference production data based on the information gain specifically includes the following steps:
[0127] Obtain the data acquisition cost of the reference production data;
[0128] Construct an optimal utility function combining information gain and data acquisition cost;
[0129] Select the target production data set from the reference production data using the optimal utility function.
[0130] In this embodiment, the data acquisition cost of the reference production data is obtained. The principle of this step is to evaluate various costs involved in collecting and processing the reference production data, including the use cost of sensors and equipment, data transmission cost, storage cost, and data processing and analysis cost, etc. In specific implementation, the acquisition process of each data point can be analyzed in detail, and the cost of each link is quantified, and finally the data acquisition cost of each data point is obtained. The optimal utility function is constructed by combining the information gain and the data acquisition cost. The principle of this step is to combine the information gain and the data acquisition cost to construct a comprehensive utility function, so as to consider the contribution of data to the amount of information and the cost of acquiring data when selecting data. In specific implementation, the information gain can be used as the benefit part of the utility function, and the data acquisition cost can be used as the cost part of the utility function. A comprehensive utility function is constructed by weighting or other mathematical methods.
[0131] The target production data set is selected from the reference production data by using the optimal utility function. The principle of this step is to select those data points that achieve the best balance between information gain and data acquisition cost by optimizing the optimal utility function, to ensure the efficiency and economy of the data. In specific implementation, the reference production data can be traversed or an optimization algorithm such as greedy algorithm, dynamic programming, etc. can be used to calculate the utility value of each data point, and the target production data set is selected according to the size of the utility value, to ensure that the selected data points achieve the optimal balance between information gain and acquisition cost. Through these steps, the data points with the highest value to the production process and the lowest acquisition cost can be effectively screened out, providing an efficient and economical data basis for subsequent data analysis and decision-making.
[0132] In one embodiment, the node attribute further includes a device attribute of an embedded device set by the production node, and the device attribute includes device storage space, device computing power and device bandwidth. Selecting the core node from each basic traceability chain according to the node attribute includes the following steps:
[0133] Every preset interval time, the device attribute corresponding to all blockchain nodes at the current time is obtained;
[0134] All device attributes are normalized;
[0135] According to a preset weight allocation strategy, an index weight is allocated to the normalized device attribute;
[0136] The node state score of the blockchain node is obtained by combining the device attribute and the corresponding index weight and by weighted calculation;
[0137] The blockchain node with the highest node state score is selected as the core node at the current time.
[0138] In the embodiment, the device storage space, the device computing capacity and the device bandwidth corresponding to all the blockchain nodes at the current time are obtained every preset interval, specifically by collecting the key performance indicators of each blockchain node in a timely manner, so as to perform subsequent performance evaluation and optimization. In the embodiment, monitoring software can be deployed on each blockchain node to collect and record the device storage space, computing capacity and bandwidth data in a timely manner, and these data are aggregated to the central management system through the network. The device storage space, the device computing capacity and the device bandwidth are normalized respectively, specifically by converting the performance indicators of different dimensions and ranges into standardized data of the same dimension and range through a normalization method, so as to facilitate subsequent weighted calculation. In the embodiment, the maximum-minimum normalization, Z-score standardization and other methods can be used to convert the storage space, computing capacity and bandwidth data of each node into standardized values between 0 and 1.
[0139] According to a preset weight allocation strategy, the normalized device storage space, the device computing capacity and the device bandwidth are allocated with index weights, specifically by determining the importance of each performance indicator in the overall evaluation through the preset weight allocation strategy. In the embodiment, the weight proportions of the storage space, the computing capacity and the bandwidth can be set according to system requirements and business scenarios, for example, the storage space weight is 0.3, the computing capacity weight is 0.4, and the bandwidth weight is 0.3, and then these weights are applied to the normalized data. Based on the index weights and in combination with the device storage space, the device computing capacity and the device bandwidth, the node state score of the blockchain node is obtained through weighted calculation, specifically by multiplying and accumulating the normalized values of each performance indicator and its corresponding weight to obtain the comprehensive state score of each blockchain node. In the embodiment, the normalized storage space, computing capacity and bandwidth values of each node are multiplied by their corresponding weights respectively, and then the weighted values are added to obtain the final state score of each node.
[0140] The blockchain node with the highest node state score is selected as the core node at the current time, specifically by comparing the state scores of the nodes to select the node with the best comprehensive performance as the core node to optimize the performance and stability of the blockchain network. In the embodiment, the state scores of all the nodes are sorted to select the node with the highest score and set it as the core node at the current time. In this way, the blockchain network can be dominated by the node with the best performance at each time, improving the overall efficiency and reliability of the network.
[0141] Based on the above embodiments, in one of the embodiments, the node attribute further includes a product category heat of the production node corresponding to the production category, and the double-chain fusion product quality tracing method applied to the production line further includes the following steps:
[0142] Extracting the original Huffman tree in the basic blockchain ledger;
[0143] Assigning a heat weight to all tree nodes in the original Huffman tree based on the product category heat, and the higher the product category heat, the greater the heat weight;
[0144] Reconstructing the original Huffman tree into a weighted Huffman tree according to the heat weight and following the principle of weighted path minimization;
[0145] Replacing the original Huffman tree in the basic blockchain ledger with the weighted Huffman tree, and saving the replaced basic blockchain ledger to the core node;
[0146] Calculating the trunk depth of the weighted Huffman tree based on the heat weight and through the Huffman algorithm;
[0147] Screening out the edge tree nodes in the weighted Huffman tree according to the trunk depth to obtain a simplified weighted Huffman tree;
[0148] Replacing the weighted Huffman tree in the basic blockchain ledger with the simplified weighted Huffman tree, and saving the replaced basic blockchain ledger to all blockchain nodes except the core node in the basic traceability chain.
[0149] In the present embodiment, the original Huffman tree in the basic blockchain ledger is extracted, specifically the basic Huffman tree structure used for data compression and encoding is obtained from the blockchain ledger for subsequent optimization processing. In the present embodiment, the data structure of the blockchain ledger can be parsed to locate and extract the part containing the original Huffman tree, which is loaded into the memory for further processing. Based on the product category heat, a heat weight is assigned to all tree nodes in the original Huffman tree, and the higher the product category heat, the greater the heat weight. Specifically, by analyzing the heat data of the product category, each node in the Huffman tree is assigned a corresponding weight to reflect its importance in actual application. In the present embodiment, the heat values of each category can be calculated by counting the access frequency or sales data of the product category, and then these heat values are assigned as weights to the corresponding nodes in the Huffman tree.
[0150] The original Huffman tree is reconstructed into a weighted Huffman tree according to the heat weight and the principle of weighted path minimization. Specifically, the structure of the Huffman tree is optimized by the principle of weighted path minimization, so that the path length of the high heat node is as short as possible, so as to improve the data access efficiency. In this embodiment, a weighted version of the Huffman algorithm can be used to reconstruct the Huffman tree, so that the nodes with higher heat weight are closer to the root node in the tree, thereby reducing the access path length. The original Huffman tree in the basic blockchain ledger is replaced by the weighted Huffman tree, and the basic blockchain ledger after the replacement is saved to the core node. Specifically, by applying the optimized Huffman tree to the blockchain ledger, the coding efficiency and data access performance of the ledger are improved. In this embodiment, the reconstructed weighted Huffman tree can replace the original Huffman tree, update the relevant part of the blockchain ledger, and save the updated ledger data to the core node to ensure the consistency and reliability of the data.
[0151] The stem depth of the weighted Huffman tree is calculated based on the heat weight and the Huffman algorithm. Specifically, the stem depth of the weighted Huffman tree is calculated to evaluate its structural characteristics and provide a basis for subsequent node screening. In this embodiment, the Huffman algorithm can be used to calculate the path length from the root node to each leaf node in the weighted Huffman tree to determine the maximum depth of the stem. The edge tree nodes in the weighted Huffman tree are screened out according to the stem depth to obtain a simplified weighted Huffman tree. Specifically, the structure of the Huffman tree is simplified by screening out edge nodes with large stem depth, thereby reducing the overhead of data storage and transmission. In this embodiment, a threshold can be set according to the stem depth calculated in the previous step to screen out edge nodes exceeding the threshold and retain main nodes to form a simplified weighted Huffman tree.
[0152] The weighted Huffman tree in the basic blockchain ledger is replaced by the simplified weighted Huffman tree, and the basic blockchain ledger after the replacement is saved to all blockchain nodes except the core node in the basic traceability chain. Specifically, the simplified Huffman tree is applied to the blockchain ledger to further optimize the storage and transmission efficiency of the ledger. In this embodiment, the weighted Huffman tree in the ledger can be replaced by the simplified weighted Huffman tree to update the ledger data, and the updated ledger is copied and distributed to all blockchain nodes except the core node to ensure the data consistency and efficiency of the entire blockchain network. Through these steps, the structure and performance of the blockchain ledger can be effectively optimized to improve the data access efficiency and the economy of storage and transmission.
[0153] The application further discloses a double-chain fusion product quality tracing system applied to a production line, which comprises a memory, a processor, and a computer program stored in the memory and capable of running on the processor, and the processor implements the double-chain fusion product quality tracing method applied to the production line when executing the computer program.
[0154] The processor can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., and the general-purpose processor can be a microprocessor or any conventional processor, etc.
[0155] The memory can be an internal storage unit of the computer device, for example, a hard disk or a memory of the computer device, or an external storage device of the computer device, for example, a plug-in hard disk, a smart memory card (SMC), a secure digital card (SD) or a flash memory card (FC) of the computer device, and the memory can also be a combination of the internal storage unit and the external storage device of the computer device, and the memory is used for storing the computer program and other programs and data required by the computer device, and can also be used for temporarily storing data that has been output or will be output, and the present application is not limited in this regard.
[0156] It should be understood by those skilled in the art that the above discussion of any embodiment is only exemplary and is not intended to imply that the protection scope of the present application is limited to these examples; under the idea of the present application, the above embodiments or technical features in different embodiments can also be combined, the steps can be implemented in any order, and there are many other changes of different aspects of one or more embodiments of the present application as described above, and they are not provided in details for the sake of brevity.
[0157] The present application is intended to cover all such alternatives, modifications, and variations of one or more embodiments of the present application falling within the broadest scope of the present application. Therefore, any omission, modification, equivalent replacement, improvement, etc. made in the spirit and principle of one or more embodiments of the present application should be included in the protection scope of the present application.
Claims
1. A double-stranded fusion product quality traceability method applied to a production line, characterized by, The method comprises the following steps: obtaining comprehensive production data and node attributes of multiple production nodes in different production stages of a target product, the node attributes including a stage number unique to a production stage corresponding to the production node, a production capacity index of the production node, and a production category number of the production node, and the production category number of each production node being different; randomly selecting multiple production nodes with different stage numbers as initial clustering centers, the number of the initial clustering centers being the same as the number of the production stages; maximizing the difference between the stage numbers or the production category numbers as a clustering target, clustering all other production nodes to the initial clustering centers to obtain multiple initial clustering clusters; generating a first optimization target in combination with the stage numbers and the production category numbers; encoding all the initial clustering clusters into an initial first population, optimizing the initial first population according to the first optimization target and by using a genetic algorithm to obtain an optimal first population; generating a second optimization target based on the production capacity index; taking the optimal first population as an initial second population, optimizing the initial second population according to the second optimization target and by using the genetic algorithm to obtain an optimal second population; dissolving the optimal second population into multiple production node clusters in the form of the clustering clusters; constructing a basic traceability chain by taking all the production nodes in the same production node cluster as blockchain nodes and generating a basic blockchain ledger by integrating all the comprehensive production data; selecting core nodes from each basic traceability chain according to the node attributes and constructing a quality traceability chain in combination with all the core nodes; updating the corresponding basic blockchain ledger through the core nodes and uploading the updated basic blockchain ledger to the quality traceability chain; querying product quality traceability data of the target product by using the quality traceability chain.
2. The double-stranded fusion product quality tracing method for a production line according to claim 1, characterized by, The expression formula of the first optimization target is as follows: , In the formula: This represents the first optimization objective. Represents the maximum value function. This indicates the number of clusters in the initial clustering of the first-generation population. Indicates the first The number of production nodes in the initial cluster. Indicates the first In the initial cluster, the first The stage number of each production node. Indicates the first The average stage number of all generated nodes in the initial cluster. Indicates the first In the initial cluster, the first Production category number of each production node Indicates the first The average production category number of all generated nodes in the initial cluster.
3. The double-stranded fusion product quality tracing method for a production line according to claim 2, characterized by, The expression formula of the second optimization target is as follows: , In the formula: , represents a second optimization target, represents a minimum value function, represents the mean value of the production capacity indexes of all production nodes in the initial clustering cluster, represents the mean value of the production capacity indexes of all production nodes in the initial clustering cluster, represents the production capacity index of the jth production node in the initial clustering cluster, represents the production capacity index of the jth production node in the initial clustering cluster, represents the production capacity index of the jth production node in the initial clustering cluster.
4. The double-stranded fusion product quality tracing method for a production line according to claim 1, characterized by, The method of constructing a basic traceability chain by taking all the production nodes in the same production node cluster as blockchain nodes and generating a basic blockchain ledger by integrating all the comprehensive production data comprises the following steps: constructing the basic traceability chain in the form of a consortium chain by taking all the production nodes in the production node cluster; uploading the comprehensive production data corresponding to all the production nodes to the basic traceability chain by creating a block transaction; combining a Bayesian network and a Kalman filtering model to perform data fusion on comprehensive production data of the same type to obtain fused traceability data, the fused traceability data including public traceability data and private traceability data; encrypting the private traceability data into encrypted traceability data through a preset encryption algorithm; broadcasting the public traceability data and the encrypted traceability data to the basic traceability chain to generate a basic blockchain ledger of the basic traceability chain.
5. The double-stranded fusion product quality tracing method for a production line according to claim 4, characterized by, The method of combining a Bayesian network and a Kalman filtering model to perform data fusion on comprehensive production data of the same type to obtain fused traceability data comprises the following steps: processing the comprehensive production data of the same type by using the Kalman filtering model to eliminate data errors of the comprehensive production data to obtain benchmark production data; calculating information gain of the benchmark production data based on a probability distribution; selecting a target production data set from the benchmark production data according to the information gain; performing data fusion on all the data in the target production data set by using the Bayesian network to obtain the fused traceability data.
6. The double-stranded fusion product quality tracing method for a production line according to claim 5, characterized by, The target production data set is selected from the benchmark production data according to information gain, including the following steps: Obtaining the data acquisition cost of the benchmark production data; Combining the information gain and the data acquisition cost to construct an optimal utility function; Selecting the target production data set from the benchmark production data by using the optimal utility function.
7. The double-stranded fusion product quality tracing method for a production line according to claim 1, characterized by, The node attribute also includes the device attribute of the embedded device set by the production node, and the device attribute includes device storage space, device computing power and device bandwidth; selecting the core node from each basic traceability chain according to the node attribute includes the following steps: Every time a preset interval time elapses, the device attribute corresponding to all blockchain nodes at the current time is obtained; All device attributes are normalized; According to a preset weight distribution strategy, an index weight is assigned to the normalized device attribute; The node state score of the blockchain node is obtained by combining the device attribute and the corresponding index weight and through weighted calculation; The blockchain node with the highest node state score is selected as the core node at the current time.
8. The double-stranded fusion product quality tracing method for a production line according to claim 7, characterized by, The node attribute also includes the product category heat of the production category corresponding to the production node, and the method further includes the following steps: Extracting the original Huffman tree in the basic blockchain ledger; Based on the product category heat, all tree nodes in the original Huffman tree are given a heat weight; According to the heat weight and the principle of minimizing the weighted path, the original Huffman tree is reconstructed into a weighted Huffman tree; The original Huffman tree in the basic blockchain ledger is replaced by the weighted Huffman tree, and the basic blockchain ledger after the replacement is saved to the core node; Based on the heat weight, the stem depth of the weighted Huffman tree is calculated through the Huffman algorithm; According to the stem depth, the edge tree nodes in the weighted Huffman tree are screened out to obtain a simplified weighted Huffman tree; The weighted Huffman tree in the basic blockchain ledger is replaced by the simplified weighted Huffman tree, and the basic blockchain ledger after the replacement is saved to all blockchain nodes in the basic traceability chain except the core node.
9. A double chain fusion product quality traceability system applied to a production line, comprising a memory, a processor, and a computer program stored on the memory and capable of running on the processor, characterized in that, The processor executes the computer program to implement the double-chain fusion product quality traceability method applied to the production line according to any one of claims 1-8.
Citation Information
Patent Citations
Blockchain-based grain and oil food full supply chain credible tracing model based on block chain and construction method
CN110516965A
IDPC algorithm-based industrial chain data feature reconstruction method
CN116881702A