Food detection data processing system and method based on block chain
By using blockchain technology to calculate the splitting index S of food sub-batches and generate traceability IDs, the problem of the inability to accurately manage local risks in traditional food testing is solved, the refined management and dynamic traceability of food safety risks are realized, and the accuracy and traceability of food safety supervision are improved.
Patent Information
- Application Number
- CN202510817156.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-18
- Publication Date
- 2025-10-03
AI Technical Summary
Traditional food inspection processes make it difficult to flexibly segment and manage problems in certain batches or local areas, resulting in the inability to accurately block goods with potential quality risks, expanding the scope of recalls or wasting qualified materials, and a lack of independent traceability and precise supervision of sub-batches.
Through the blockchain-based food inspection data processing system, including the food data collection module, the sub-batch abnormal data monitoring module, the contract triggering and batch re-labeling module and the batch comprehensive evaluation module, the food sub-batch splitting index S is calculated, and the sub-batch splitting task is triggered by dynamic matching using smart contracts. A traceability ID is assigned to each split food sub-batch, and a comprehensive segmentation score CSS is generated to determine the isolation execution result.
It achieves refined management of food safety risks, avoids excessive processing of entire batch recalls, ensures traceability and auditing of split operations, and dynamically evaluates food safety status based on historical data, thereby improving the accuracy and flexibility of food safety supervision and reducing recall costs.
Smart Images

Figure CN120746366A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain technology, and in particular to a blockchain-based food inspection data processing system and method. Background Art
[0002] With the rapid penetration of information technology across various industries, blockchain technology has gradually become a core support tool for data management and traceability, attracting widespread attention. In the more specialized field of food safety regulation, the application of distributed ledgers to food quality testing, data sharing, and supply chain management can achieve multiple advantages, including open and transparent information, immutability, and real-time traceability. Consequently, more targeted solutions have emerged around the collection, processing, and transmission of "food testing data," aiming to help companies and regulators build secure and reliable food management systems.
[0003] In the invention of national patent application number CN202311706905.6, a blockchain-based food testing data processing method is disclosed. The method includes: obtaining food testing data on a node chain based on an electronic contract as a certificate; parsing the food testing data to determine the food category; determining the safety standard data corresponding to the food testing data based on the food category; comparing the food testing data with the safety standard data to obtain a comparison result, and inputting the comparison result into a food safety assessment model to obtain a food safety index; and broadcasting the food safety index on the main chain. This invention can improve the processing efficiency of food testing data and make the processing of food testing data more transparent.
[0004] It can be seen that in the traditional food testing process, it is often necessary to rely on manual or centralized systems to reach a unified conclusion on whether food batches are qualified or not. Once the test results are unqualified, the entire batch of food is often forced to be recalled on a large scale or undergo secondary testing. However, this model makes it difficult to flexibly segment and manage problems that arise in "partial batches" or "local areas." Due to the lack of refined disposal methods, companies are unable to accurately block the part of the goods that truly pose potential quality risks, resulting in either expanding the scope of the recall, wasting qualified materials that can be sold normally, or missing a small amount of food with real problems and continuing to enter the market. For regulatory authorities, the traditional process lacks independent tracking and traceability of specific sub-batches, which is not conducive to accurate supervision and accountability in the later stage. Summary of the Invention
[0005] In response to the shortcomings of the existing technology, the present invention provides a blockchain-based food inspection data processing system and method, which solves the problems mentioned in the background technology.
[0006] To achieve the above objectives, the present invention is implemented through the following technical solutions: a blockchain-based food inspection data processing system, a food data collection module, a sub-batch abnormal data monitoring module, a contract triggering and batch re-labeling module, and a batch comprehensive evaluation module;
[0007] The food data collection module verifies the source of food through the data reporting node in the blockchain network. After verification, it extracts the food status data and forms the food feature vector V;
[0008] The sub-batch abnormal data monitoring module performs sub-batch sampling inspections on food based on the obtained food feature vector V, obtains the abnormal potential value AP, then summarizes all the abnormal potential values AP of the sub-batch to generate the potential value trend index APsub, and calculates the food sub-batch split index S based on the potential value trend index APsub;
[0009] The contract triggering and batch re-marking module matches the split index S with the trigger threshold Sthe, and performs the sub-batch splitting task based on the matching result. It then assigns a traceability ID to the sub-batch and calculates the initial security index Sinit before uploading it to the blockchain.
[0010] The batch comprehensive evaluation module retrieves the historical inspection data of the sub-batch through the blockchain based on the traceability ID, generates a comprehensive segmentation score CSS, and judges the isolation execution result based on the comprehensive segmentation score CSS to generate an execution decision vector Dexec.
[0011] Preferably, the food data collection module includes a verification unit and a construction unit;
[0012] The verification unit verifies the unique identity information of the food batch and the production enterprise through the data reporting node in the blockchain network. Specifically, it receives the food batch identifier BID and the upload node identifier NID provided in the previous link, queries the probe device and data reporting node information of the upload node identifier NID in the blockchain, verifies whether the signature and authorization are valid, and obtains the verification result VF;
[0013] When the verification result VF=true, it means that the verification signature and authorization are valid, and the work content of the construction unit is executed; when the verification result VF=false, it means that the verification signature and authorization are invalid, the food batch is timestamped and combined with the invalid result, the system anomaly is reported and written to the side chain for traceability and auditing.
[0014] Preferably, when the verification result VF=true, the construction unit obtains food status data of the food batch from the integrated sensor and detection equipment, and pre-processes it to form a food feature vector V;
[0015] Food status data includes food storage temperature T, ambient temperature H, pesticide residue Q, microbial count M and retention time △t;
[0016] Preprocessing includes data removal of extreme invalid values and data standardization; removal of extreme invalid values includes the use of the interquartile range method and the upper and lower limit elimination method, and data standardization includes the use of Min-Max normalization and Z-score normalization methods;
[0017] The retention time △t is obtained by calculating the timestamps of adjacent nodes on the blockchain;
[0018] Sensors and detection equipment include temperature sensors and microbial detectors.
[0019] Preferably, the sub-batch abnormal data monitoring module includes an abnormality calculation unit and a summary and splitting unit;
[0020] The anomaly calculation unit performs sub-batch sampling inspection on the food according to the obtained food feature vector V, calculates the abnormal potential value AP of each sample in the food sub-batch through the food feature vector V, and forms a set of abnormal potential values of all sample samples in the sub-batch;
[0021] The abnormal potential value AP is obtained by the following calculation formula:
[0022]
[0023] Where AP(i) represents the abnormal potential value of the i-th sample, Q(i) represents the pesticide residue of the i-th sample, M(i) represents the microbial count of the i-th sample, T(i) represents the storage temperature of the i-th sample, H(i) represents the ambient temperature of the i-th sample, △t(i) represents the retention time of the i-th sample, and Tref(i) represents the ideal reference temperature of the i-th sample.
[0024] Preferably, the aggregation and splitting unit aggregates the abnormal potential values AP of all sampled samples in the acquired abnormal potential value set to generate a potential value trend index APsub of the sub-batch, and calculates a splitting index S of the food sub-batch based on the potential value trend index APsub;
[0025] The potential value trend index APsub is obtained by the following calculation formula:
[0026]
[0027] Where n represents the total number of random inspection samples in the sub-batch;
[0028] The split index S is obtained by the following calculation formula:
[0029] S = APsub*ln(1+σ(AP));
[0030] Where ln represents the natural logarithm function, and σ(AP) represents the standard deviation of the abnormal potential value AP of all sampled samples in the abnormal potential value set.
[0031] Preferably, the contract triggering and batch re-marking module includes a matching and splitting unit and a re-marking and chaining unit;
[0032] The matching and splitting unit matches the preset trigger threshold Sthe with the obtained splitting index S, obtains the trigger matching result, and executes the sub-batch splitting task according to the trigger matching result;
[0033] The trigger matching results are obtained through the following matching methods:
[0034] When the split index S ≥ the trigger threshold Sthe, the trigger matching result is obtained as the trigger result, and the sub-batch splitting task is executed, including marking the food batch identifier BID and the upload node identifier NID of the sub-batch. At the same time, according to the food batch identifier BID and the upload node identifier NID, the storage location, current inventory and food-related data in the blockchain are extracted to form a sub-batch split original data group, and the re-labeling on-chain unit is triggered synchronously;
[0035] When the split index S is less than the trigger threshold Sthe, the trigger matching result is obtained as a non-trigger result, and the sub-batch splitting task is not executed.
[0036] Preferably, the re-labeling and uploading unit splits the original data group of the acquired sub-batch into a new traceability ID for the sub-batch, and simultaneously marks the association between the traceability ID and the food batch identifier BID, and calculates the preliminary safety index Sinit for the sub-batch. The sub-batch split original data group, the traceability ID, and the preliminary safety index Sinit are then integrated to form an upload data packet. After marking the upload data packet with timestamp information and operation node information, the upload data packet is uploaded to the blockchain, and the food batch identifier BID of the sub-batch is simultaneously updated to a split state.
[0037] The new traceability ID is generated in the following way:
[0038] ID=Hash(BID||TimeStamp||RandSeed);
[0039] Where Hash represents the hash function, || represents the concatenation operator, TimeStamp represents the timestamp of the current operation, and RandSeed represents the random factor, which is specifically used to prevent the method ID from being repeated.
[0040] The preliminary safety index Sinit is obtained by the calculation formula Sinit=ln(1+S).
[0041] Preferably, the batch comprehensive evaluation module includes a decision generation unit;
[0042] The decision generation unit retrieves the historical test data of the food type to which the sub-batch belongs through the blockchain based on the traceability ID, specifically the food feature vector V and split index S uploaded on the previous blockchain, and generates a comprehensive split score CSS based on the historical test data. Based on the comprehensive split score CSS, the isolation execution result is judged and marked as the isolation execution status GS, and an execution decision vector Dexec is generated according to the isolation execution status GS, including confirming the execution of the sub-batch splitting task and secondary verification of the sub-batch splitting task;
[0043] The comprehensive segmentation score CSS is obtained by the following calculation formula:
[0044]
[0045] Where exp represents the exponential function, m represents the total number of all random samples in the sub-batch of the previous blockchain, △t(j) represents the retention time of the j-th random sample, T(j) represents the storage temperature of the j-th random sample, Tref(j) represents the ideal reference temperature of the j-th random sample, and M(j) represents the microbial count of the j-th random sample.
[0046] Preferably, the isolation execution state GS is obtained in the following manner:
[0047] When the comprehensive segmentation score CSS>0, the isolation execution status GS=true is generated, indicating that the food with the current traceability ID is different from the food with normal storage and transportation background. The execution of the sub-batch splitting task is confirmed, and the execution decision vector Dexec is generated, including the isolation execution status GS of the sub-batch splitting task, the traceability ID and the current operation timestamp TimeStamp;
[0048] When the comprehensive segmentation score CSS≤0, the isolated execution status GS=false is generated, indicating that the food batch identification BID of the current traceability ID is similar to the food batch with normal storage and transportation background. The sub-batch splitting task is verified twice, the sub-batch splitting task is suspended, and the trigger threshold Sthe is synchronously executed after the ratio is reduced. The execution splitting index S is obtained twice. If the food batch identification BID of the current traceability ID generates the isolated execution status GS=false again, the food batch identification BID of the current traceability ID is marked as a warning state, the sub-batch splitting task is initialized, the traceability ID is synchronously retained and associated with the food batch identification BID, and a new upload data packet is generated by obtaining the execution splitting index S for the second time to replace the upload data packet generated after the execution splitting index S is first obtained in the blockchain. The execution decision vector Dexec is generated, including the isolated execution status GS of the sub-batch splitting task, the traceability ID and the current operation timestamp TimeStamp.
[0049] A food inspection data processing method based on blockchain, comprising the following steps:
[0050] Step 1: Verify the source of food through the data reporting node in the blockchain network. After verification, extract the food status data to form the food feature vector V;
[0051] Step 2: Perform random inspections on sub-batches of food based on the obtained food feature vector V to obtain abnormal potential values AP, then summarize all abnormal potential values AP of the sub-batches to generate a potential value trend index APsub, and calculate the food sub-batch splitting index S based on the potential value trend index APsub;
[0052] Step 3: Match the split index S with the trigger threshold Sthe, execute the sub-batch splitting task based on the matching result, assign a traceability ID to the sub-batch, calculate the initial security index Sinit, and upload it to the blockchain;
[0053] Step 4: Retrieve the historical inspection data of the sub-batch through the blockchain based on the traceability ID, generate a comprehensive segmentation score CSS, and judge the isolation execution result based on the comprehensive segmentation score CSS to generate an execution decision vector Dexec.
[0054] The present invention provides a food inspection data processing system and method based on blockchain, which has the following beneficial effects:
[0055] (1) By calculating the split index S of food sub-batches, refined management of food safety risks is achieved, avoiding the problem of local contamination hazards not being discovered in time due to the traditional large-batch detection model. Subsequently, the contract triggering and batch re-labeling module uses smart contracts to ensure the dynamic matching of the split index S and the trigger threshold Sthe, accurately triggering the sub-batch splitting task, assigning a traceability ID to each split food sub-batch, and calculating the initial safety index Sinit, making sub-batch management more flexible and avoiding the problem of excessive processing of the entire batch recall due to a single batch exceeding the standard. Based on this, the isolation execution result is judged and the execution decision vector Dexec is finally generated, which realizes the real-time isolation of defective food sub-batches, avoiding the impact of the overall recall on the enterprise and the supply chain, and can also fully record each subsequent splitting or merging operation, thereby achieving more refined and traceable food quality control.
[0056] (2) By matching the trigger threshold Sthe with the split index S, it is ensured that the sub-batch splitting task will only be executed when the split index S of the food sub-batch is higher than the set safety threshold Sthe, thereby avoiding the problem of erroneous splitting or missed splitting caused by manual decision-making or fixed rules in traditional methods. When the split is triggered, the unit will not only mark the food batch identifier BID and the upload node identifier NID, but also extract the storage location, inventory and food-related data from the blockchain to form a sub-batch splitting original data group, providing more refined data support for subsequent traceability and supervision. Secondly, after obtaining the sub-batch splitting original data group, the re-labeling chain unit generates a unique traceability ID for the entire network and automatically establishes an on-chain association between the traceability ID and the food batch identifier BID to ensure that all splitting operations can be traced and audited. Not only does it ensure that the sub-batch splitting operation is dynamically executed based on real-time calculation and preset safety thresholds, but it can also accurately trace the historical changes of each sub-batch through the automatically generated traceability ID, eliminating the problems of batch data confusion, high food recall costs and difficulty in tracing responsibilities caused by the lack of refined management in the traditional food supply chain.
[0057] (3) The historical test data of the food type to which the sub-batch belongs is retrieved in the blockchain through the traceability ID, including the food feature vector V and the split index S, and the comprehensive segmentation score CSS is calculated, so that the food safety assessment not only relies on the current test data, but also can dynamically evaluate the safety status of the sub-batch in combination with the historical data trend. This method effectively avoids the misjudgment problem caused by the fluctuation of single test data, ensuring that the sub-batch isolation decision is more scientific and reasonable. Secondly, the comprehensive segmentation score CSS is used to generate the isolation execution status GS to achieve precise isolation and intelligent adjustment. By executing the decision vector Dexec, all isolation decisions, traceability IDs and operation timestamps are recorded and managed, achieving full traceability, automatic adjustment and dynamic optimization of food batches, which completely changes the problems of the traditional food safety isolation method such as lack of review mechanism, difficulty in adaptive adjustment and insensitivity to changes in environmental factors, making food safety supervision more accurate, flexible and traceable. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] Figure 1 This is a schematic diagram of a food inspection data processing system based on blockchain in the present invention;
[0059] Figure 2 This is a schematic diagram of the steps of a blockchain-based food testing data processing method of the present invention;
[0060] Figure 3 Schematic diagram of data processing flow and trigger mechanism. DETAILED DESCRIPTION
[0061] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0062] Example 1
[0063] The present invention provides a food inspection data processing system based on blockchain, please refer to Figure 1 , food data collection module, sub-batch abnormal data monitoring module, contract triggering and batch re-labeling module and batch comprehensive evaluation module;
[0064] The food data collection module verifies the source of food through the data reporting node in the blockchain network. After verification, it extracts the food status data and forms the food feature vector V;
[0065] The sub-batch abnormal data monitoring module performs sub-batch sampling inspections on food based on the obtained food feature vector V, obtains the abnormal potential value AP, then summarizes all the abnormal potential values AP of the sub-batch to generate the potential value trend index APsub, and calculates the food sub-batch split index S based on the potential value trend index APsub;
[0066] The contract triggering and batch re-marking module matches the split index S with the trigger threshold Sthe, and performs the sub-batch splitting task based on the matching result. It then assigns a traceability ID to the sub-batch and calculates the initial security index Sinit before uploading it to the blockchain.
[0067] The batch comprehensive evaluation module retrieves the historical inspection data of the sub-batch through the blockchain based on the traceability ID, generates a comprehensive segmentation score CSS, and judges the isolation execution result based on the comprehensive segmentation score CSS to generate an execution decision vector Dexec.
[0068] In this embodiment, through the collaborative work of the food data acquisition module, the sub-batch abnormal data monitoring module, the contract trigger and batch re-labeling module and the batch comprehensive evaluation module, a precise, dynamic and traceable food inspection data processing system is constructed, which effectively makes up for the many shortcomings of the traditional food safety management method. First, the food data acquisition module relies on the data reporting node in the blockchain network to ensure the authenticity of the food source, and extracts the food status data, and then forms the food feature vector V, which solves the shortcomings of the traditional system in data authenticity and integrity. Secondly, the sub-batch abnormal data monitoring module conducts sub-batch sampling of food based on the food feature vector V, calculates the abnormal potential value AP, and further summarizes and generates the potential value trend index APsub, and finally calculates the food sub-batch splitting index S, thereby realizing the refined management of food safety risks and avoiding the problem of local contamination hazards not being discovered in time due to the traditional large-batch detection mode. Subsequently, the contract triggering and batch relabeling module utilizes smart contracts to ensure the dynamic matching of the split index S and the trigger threshold Sthe, accurately triggering the sub-batch splitting task, assigning a traceability ID to each split food sub-batch, and calculating the initial safety index Sinit. This allows for greater flexibility in sub-batch management and avoids the over-processing of entire batch recalls due to a single batch exceeding the standard. Finally, the batch comprehensive evaluation module retrieves the sub-batch's historical inspection data through the blockchain network based on the traceability ID, calculates the comprehensive segmentation score CSS, and uses this score to determine the isolation execution outcome. Ultimately, it generates the execution decision vector Dexec, enabling dynamic feedback and adaptive optimization for food safety management, effectively overcoming the static evaluation, lack of historical data reference, and inability to adjust control strategies inherent in traditional approaches. Leveraging the decentralized, immutable, and fully traceable nature of blockchain, this system not only improves the accuracy of food safety supervision but also reduces food recall costs and shortens food safety decision response times through dynamic segmentation, smart contract execution, and historical data optimization, providing new technical support for the safety and control of the food supply chain.
[0069] Although some existing blockchain cases have attempted to trace, query, and record overall on-chain, they still cannot support the dynamic segmentation and independent traceability of "partially abnormal food batches," nor can they promptly assign new batch IDs and risk tags when exceeding standards or quality issues occur. The result is that even if a decentralized ledger is adopted, it can only simply archive the entire batch of data, but it is impossible to truly split and handle risky sub-batches separately the moment the problem occurs. The "instant dynamic 'batch segmentation' and separate marking technology for exceeding standards batches" proposed in this innovation is precisely to solve such pain points: it can not only isolate defective food sub-batches in real time, avoiding the impact of overall recalls on enterprises and supply chains, but also fully record each subsequent segmentation or merging operation, thereby achieving more refined and traceable food quality control, which is a technical effect that is difficult to achieve in existing similar cases.
[0070] Example 2
[0071] This embodiment is explained in Example 1, please refer to Figure 1 ,Specifically: the food data collection module includes a verification unit and a ,construction unit;
[0072] The verification unit verifies the unique identity information of the food batch and the production enterprise through the data reporting node in the blockchain network. Specifically, it receives the food batch identifier BID and the upload node identifier NID provided in the previous link, queries the probe device and data reporting node information of the upload node identifier NID in the blockchain, verifies whether the signature and authorization are valid, and obtains the verification result VF;
[0073] When the verification result VF=true, it means that the verification signature and authorization are valid, and the work content of the construction unit is executed; when the verification result VF=false, it means that the verification signature and authorization are invalid, the food batch is timestamped and combined with the invalid result, the system anomaly is reported and written to the side chain for traceability and auditing.
[0074] When the verification result VF = true, the construction unit obtains the food status data of the food batch from the integrated sensor and detection equipment, and preprocesses it to form a food feature vector V;
[0075] Food status data includes food storage temperature T, ambient temperature H, pesticide residue Q, microbial count M and retention time △t;
[0076] Preprocessing includes data removal of extreme invalid values and data standardization; removal of extreme invalid values includes the use of the interquartile range method and the upper and lower limit elimination method, and data standardization includes the use of Min-Max normalization and Z-score normalization methods;
[0077] The retention time △t is obtained by calculating the timestamps of adjacent nodes on the blockchain;
[0078] Sensors and detection equipment include temperature sensors and microbial detectors.
[0079] In this embodiment, the collaborative operation of the verification unit and the construction unit ensures the credibility, integrity, and standardization of food batch data, providing a high-quality data foundation for subsequent food safety assessments. First, the verification unit relies on the data reporting node in the blockchain network and uses a dual authentication mechanism based on the food batch identifier (BID) and the upload node identifier (NID) to accurately identify the authenticity of food batches and production enterprises and the credibility of the data submitter. This effectively prevents the distortion of food traceability data caused by the forgery or tampering of the upload node identity in traditional food safety data systems. Second, when the verification result VF = true, the construction unit collects core status data of food storage temperature T, ambient temperature H, pesticide residue Q, microbial count M, and retention time Δt from devices such as temperature sensors, humidity sensors, and microbial detectors. The interquartile range method and upper and lower limit elimination methods are used to eliminate extreme invalid values. The data is then standardized by combining the Min-Max normalization and Z-score normalization methods, thereby avoiding the problem of food testing data being affected by outlier interference or data scale imbalance, which affects the accuracy of subsequent calculations. Furthermore, the system calculates the retention time Δt by calculating the timestamps of adjacent nodes on the blockchain, accurately measuring the food's stay at each link in the supply chain and preventing the tampering of food storage durations caused by data lags or manual entry errors in traditional storage or logistics management methods. Compared to traditional food inspection data collection models, this module not only relies on blockchain technology to ensure the authenticity and tamper-proofing of data sources, but also improves the accuracy and computational stability of the food feature vector V through automated data preprocessing mechanisms. Ultimately, it establishes a food safety data collection system with reliable data, comprehensive status, anomaly self-detection, and consistent standards, effectively improving the reliability and accuracy of subsequent sub-batch anomaly data monitoring and food safety assessments.
[0080] Example 3
[0081] This embodiment is explained in Example 2, please refer to Figure 1 ,Specifically: the sub-batch abnormal data monitoring module includes an abnormal ,calculation unit and a summary and splitting unit;
[0082] The anomaly calculation unit performs sub-batch sampling inspection on the food according to the obtained food feature vector V, calculates the abnormal potential value AP of each sample in the food sub-batch through the food feature vector V, and forms a set of abnormal potential values of all sample samples in the sub-batch;
[0083] The abnormal potential value AP is obtained by the following calculation formula:
[0084]
[0085] Where AP(i) represents the abnormal potential value of the i-th sample, Q(i) represents the pesticide residue of the i-th sample, M(i) represents the microbial count of the i-th sample, T(i) represents the storage temperature of the i-th sample, H(i) represents the ambient temperature of the i-th sample, △t(i) represents the retention time of the i-th sample, and Tref(i) represents the ideal reference temperature of the i-th sample.
[0086] Specific examples:
[0087] Pesticide residue Q(i) of the i-th sample: 0.3; Microbial count M(i) of the i-th sample: 0.6; Storage temperature T(i) of the i-th sample: 0.5; Ambient temperature H(i) of the i-th sample: 0.5; Ideal reference temperature of the i-th sample: 0.4; Retention time △t(i) of the i-th sample: 0.7;
[0088] According to the calculation formula of abnormal potential value AP:
[0089]
[0090] Calculate the logarithmic term: ln(1+0.3)≈0.262;
[0091] Compute the square root term:
[0092] Calculation of detention duration:
[0093] Calculate the abnormal potential value AP(i) = 0.262 + 0.608 + 0.467 ≈ 0.403;
[0094] The aggregation and splitting unit aggregates the abnormal potential values AP of all the sampled samples in the acquired abnormal potential value set to generate a potential value trend index APsub of the sub-batch, and calculates a splitting index S of the food sub-batch based on the potential value trend index APsub;
[0095] The potential value trend index APsub is obtained by the following calculation formula:
[0096]
[0097] Where n represents the total number of random inspection samples in the sub-batch;
[0098] The split index S is obtained by the following calculation formula:
[0099] S = APsub*ln(1+σ(AP));
[0100] Where ln represents the natural logarithm function, σ(AP) represents the standard deviation of the abnormal potential value AP of all sampled samples in the abnormal potential value set;
[0101] The standard deviation σ(AP) is obtained by Obtain the calculation formula.
[0102] In this embodiment, the coordinated work of the anomaly calculation unit and the aggregation and splitting unit enables refined assessment and dynamic risk assessment of food sub-batch testing, effectively overcoming the inability to identify local high-risk areas and the difficulty in accurately quantifying the degree of anomalies in traditional food testing methods. First, the anomaly calculation unit performs sub-batch sampling of food based on the food feature vector V, calculates the anomaly potential value AP for each sample, and constructs a set of anomaly potential values for all sampled samples in the sub-batch. This ensures that food safety assessments do not rely solely on overall mean judgments, but instead delve into the individual sample level within each sub-batch to achieve accurate anomaly identification. This method not only fully considers multiple factors affecting food safety, such as pesticide residue Q, microbial count M, storage temperature T, ambient temperature H, retention time Δt, and ideal reference storage temperature Tref, but also performs quantitative calculations through the anomaly potential value calculation formula, ensuring that the degree of anomaly in different food sub-batches can be scientifically and quantifiably measured, avoiding the misjudgment problem caused by relying on fixed experience or a single indicator. Secondly, the summary and splitting unit calculates the potential value trend index APsub of the sub-batch based on the abnormal potential value set, and further calculates the splitting index S of the food sub-batch. Compared with the traditional whole-batch detection mode, this module can actively discover local abnormal areas during the detection stage and dynamically adjust the sub-batch splitting strategy according to the data distribution, effectively reducing the economic losses caused by the misjudgment or overall recall of the entire food batch due to the contamination of a single sample, and improving the targeted, accurate and responsiveness of food safety management and control in the food supply chain.
[0103] Example 4
[0104] This embodiment is explained in Example 3, please refer to Figure 1 ,Specifically: the contract triggering and batch re-marking module includes a matching ,splitting unit and a re-marking on-chain unit;
[0105] The matching and splitting unit matches the preset trigger threshold Sthe with the obtained splitting index S, obtains the trigger matching result, and executes the sub-batch splitting task according to the trigger matching result;
[0106] The trigger matching results are obtained through the following matching methods:
[0107] When the split index S ≥ the trigger threshold Sthe, the trigger matching result is obtained as the trigger result, and the sub-batch splitting task is executed, including marking the food batch identifier BID and the upload node identifier NID of the sub-batch. At the same time, according to the food batch identifier BID and the upload node identifier NID, the storage location, current inventory and food-related data in the blockchain are extracted to form a sub-batch split original data group, and the re-labeling on-chain unit is triggered synchronously;
[0108] When the split index S is less than the trigger threshold Sthe, the trigger matching result is obtained as a non-trigger result, and the sub-batch splitting task is not executed.
[0109] The re-labeling and chain-uploading unit splits the original data group according to the obtained sub-batch, generates a new traceability ID for the sub-batch, and marks the association between the traceability ID and the food batch identification BID. It also calculates the preliminary safety index Sinit for the sub-batch, and then integrates the sub-batch split original data group, traceability ID and preliminary safety index Sinit to form an upload data packet. After marking the upload data packet with timestamp information and operation node information, the upload data packet is uploaded to the blockchain, and the sub-batch food batch identification BID is simultaneously updated to the split state;
[0110] The new traceability ID is generated in the following way:
[0111] ID=Hash(BID||TimeStamp||RandSeed);
[0112] Where Hash represents the hash function, || represents the concatenation operator, TimeStamp represents the timestamp of the current operation, and RandSeed represents the random factor, which is specifically used to prevent the method ID from being repeated.
[0113] The preliminary safety index Sinit is obtained by the calculation formula Sinit=ln(1+S), where ln(1+S) is used to amplify the split index S, highlight the index changes of high-risk batches, and avoid abnormal situations when the split index S=0.
[0114] In this embodiment, through the efficient collaboration of the matching and splitting unit and the relabeling and chaining unit, the precise triggering, dynamic management, and tamper-proof on-chain evidence of food sub-batch splitting are achieved, effectively addressing the problems of the traditional food traceability system, such as the lack of automation in sub-batch management, the inability to dynamically adjust the food batch safety index, and the opaque splitting decision-making process. First, the matching and splitting unit ensures that the sub-batch splitting task is only executed when the splitting index S of the food sub-batch is higher than the set safety threshold Sthe, thereby avoiding the problems of erroneous or missed splitting caused by manual decision-making or fixed rules in traditional methods. When the split is triggered, the unit not only marks the food batch identifier BID and the upload node identifier NID, but also extracts the storage location, inventory quantity, and food-related data from the blockchain to form a sub-batch split raw data set, providing more refined data support for subsequent traceability and supervision. Second, after obtaining the sub-batch split raw data set, the relabeling and chaining unit generates a unique traceability ID for the entire network and automatically establishes an on-chain association between the traceability ID and the food batch identifier BID, ensuring that all splitting operations can be traced and audited. Through the index amplification mechanism, the safety warning level of high-risk food sub-batches is highlighted, and the problem of calculation anomalies when the split index S is too low is effectively avoided. Finally, all sub-batch split original data groups, traceability IDs and preliminary safety indexes Sinit are integrated into the uploaded data package, and uploaded to the blockchain after adding timestamps and operation node information. The sub-batch food batch identification BID is simultaneously updated to the split state, ensuring that all sub-batch splitting processes are tamper-proof, timestamp-verified and auditable on the chain. Compared with traditional food traceability methods, this module not only ensures that the sub-batch splitting operation is dynamically executed based on real-time calculations and preset safety thresholds, but also accurately traces the historical changes of each sub-batch through automatically generated traceability IDs, eliminating the problems of batch data confusion, high food recall costs and difficulty in tracing responsibilities caused by the lack of refined management in the traditional food supply chain, and ultimately greatly improving the automation level, security and transparency of food supply chain management.
[0115] Example 5
[0116] This embodiment is explained in Example 4. Please refer to Figure 1 ,Specifically: the batch comprehensive evaluation module includes a ,decision generation unit;
[0117] The decision generation unit retrieves the historical test data of the food type to which the sub-batch belongs through the blockchain based on the traceability ID, specifically the food feature vector V and split index S uploaded on the previous blockchain, and generates a comprehensive split score CSS based on the historical test data. Based on the comprehensive split score CSS, the isolation execution result is judged and marked as the isolation execution status GS, and an execution decision vector Dexec is generated according to the isolation execution status GS, including confirming the execution of the sub-batch splitting task and secondary verification of the sub-batch splitting task;
[0118] The comprehensive segmentation score CSS is obtained by the following calculation formula:
[0119]
[0120] Where exp represents the exponential function, m represents the total number of all random samples in the sub-batch of the previous blockchain, △t(j) represents the retention time of the j-th random sample, T(j) represents the storage temperature of the j-th random sample, Tref(j) represents the ideal reference temperature of the j-th random sample, and M(j) represents the microbial count of the j-th random sample.
[0121] The isolated execution status GS is obtained in the following ways:
[0122] When the comprehensive segmentation score CSS>0, the isolation execution status GS=true is generated, indicating that the food with the current traceability ID is different from the food with normal storage and transportation background. The execution of the sub-batch splitting task is confirmed, and the execution decision vector Dexec is generated, including the isolation execution status GS of the sub-batch splitting task, the traceability ID and the current operation timestamp TimeStamp;
[0123] When the comprehensive segmentation score CSS≤0, the isolated execution status GS=false is generated, indicating that the food batch identification BID of the current traceability ID is similar to the food batch with normal storage and transportation background. The sub-batch splitting task is verified twice, the sub-batch splitting task is suspended, and the trigger threshold Sthe is synchronously executed after the ratio is reduced. The execution splitting index S is obtained twice. If the food batch identification BID of the current traceability ID generates the isolated execution status GS=false again, the food batch identification BID of the current traceability ID is marked as a warning state, the sub-batch splitting task is initialized, the traceability ID is synchronously retained and associated with the food batch identification BID, and a new upload data packet is generated by obtaining the execution splitting index S for the second time to replace the upload data packet generated after the execution splitting index S is first obtained in the blockchain. The execution decision vector Dexec is generated, including the isolated execution status GS of the sub-batch splitting task, the traceability ID and the current operation timestamp TimeStamp.
[0124] In this embodiment, dynamic optimization and accurate decision-making of sub-batch isolation management are achieved through the calculation and feedback of the decision-making generation unit, which effectively compensates for the problems of fixed isolation standards, high false isolation rate, and inability to perform secondary verification in traditional food safety management and control. First, the module retrieves the historical detection data of the food type to which the sub-batch belongs in the blockchain based on the traceability ID, including the food feature vector V and the splitting index S, and calculates the comprehensive segmentation score CSS, so that the food safety assessment not only depends on the current detection data, but also can dynamically evaluate the safety status of the sub-batch in combination with the historical data trend. This method effectively avoids the problem of misjudgment caused by fluctuations in single detection data, and ensures that the sub-batch isolation decision is more scientific and reasonable. Secondly, the comprehensive segmentation score CSS is used to generate the isolation execution status GS to achieve precise isolation and intelligent adjustment. When the comprehensive segmentation score CSS>0, the isolation execution status GS=true is directly generated, ensuring that high-risk foods are immediately subject to sub-batch splitting tasks, reducing the possibility of high-risk foods entering the market. When the comprehensive segmentation score CSS≤0, the system does not directly terminate the isolation, but instead triggers a secondary verification mechanism, synchronously lowering the trigger threshold Sthe, recalculating the execution split index SSS, and marking the sub-batch verification failure as a warning state to prevent food from being misclassified as safe due to environmental changes or detection fluctuations. This dynamic adjustment mechanism ensures that food safety assessments are not only immediate but also stable and adaptable, effectively reducing misjudgments or omissions caused by a single calculation method. Ultimately, the module records and manages all isolation decisions, traceability IDs, and operation timestamps through the execution decision vector Dexec, achieving full traceability, automated adjustment, and dynamic optimization of food batches. This completely changes the problems of traditional food safety isolation methods such as the lack of a review mechanism, difficulty in adaptive adjustment, and insensitivity to changes in environmental factors, making food safety supervision more accurate, flexible, and traceable.
[0125] Example 6
[0126] A food testing data processing method based on blockchain, please refer to Figure 2 , specifically: including the following steps:
[0127] Step 1: Verify the source of food through the data reporting node in the blockchain network. After verification, extract the food status data to form the food feature vector V;
[0128] Step 2: Perform random inspections on sub-batches of food based on the obtained food feature vector V to obtain abnormal potential values AP, then summarize all abnormal potential values AP of the sub-batches to generate a potential value trend index APsub, and calculate the food sub-batch splitting index S based on the potential value trend index APsub;
[0129] Step 3: Match the split index S with the trigger threshold Sthe, execute the sub-batch splitting task based on the matching result, assign a traceability ID to the sub-batch, calculate the initial security index Sinit, and upload it to the blockchain;
[0130] Step 4: Retrieve the historical inspection data of the sub-batch through the blockchain based on the traceability ID, generate a comprehensive segmentation score CSS, and judge the isolation execution result based on the comprehensive segmentation score CSS to generate an execution decision vector Dexec.
[0131] While embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions, and variations may be made to these embodiments without departing from the principles and spirit of the invention, and that the scope of the invention is defined by the appended claims and their equivalents.
Claims
1. A food inspection data processing system based on blockchain, characterized by: Food data collection module, sub-batch abnormal data monitoring module, contract triggering and batch re-labeling module and batch comprehensive evaluation module; The food data collection module verifies the source of food through the data reporting node in the blockchain network. After verification, it extracts the food status data and forms the food feature vector V; The sub-batch abnormal data monitoring module performs sub-batch sampling inspections on food based on the obtained food feature vector V, obtains the abnormal potential value AP, then summarizes all the abnormal potential values AP of the sub-batch to generate the potential value trend index APsub, and calculates the food sub-batch split index S based on the potential value trend index APsub; The contract triggering and batch re-marking module matches the split index S with the trigger threshold Sthe, and performs the sub-batch splitting task based on the matching result. It then assigns a traceability ID to the sub-batch and calculates the initial security index Sinit before uploading it to the blockchain. The batch comprehensive evaluation module retrieves the historical inspection data of the sub-batch through the blockchain based on the traceability ID, generates a comprehensive segmentation score CSS, and judges the isolation execution result based on the comprehensive segmentation score CSS to generate an execution decision vector Dexec.
2. The blockchain-based food testing data processing system according to claim 1, characterized in that: The food data collection module includes a verification unit and a construction unit; The verification unit verifies the unique identity information of the food batch and the production enterprise through the data reporting node in the blockchain network. Specifically, it receives the food batch identifier BID and the upload node identifier NID provided in the previous link, queries the probe device and data reporting node information of the upload node identifier NID in the blockchain, verifies whether the signature and authorization are valid, and obtains the verification result VF; When the verification result VF=true, it means that the verification signature and authorization are valid, and the work content of the construction unit is executed; when the verification result VF=false, it means that the verification signature and authorization are invalid, the food batch is timestamped and combined with the invalid result, the system anomaly is reported and written to the side chain for traceability and auditing.
3. The blockchain-based food testing data processing system according to claim 2, characterized in that: When the verification result VF = true, the construction unit obtains the food status data of the food batch from the integrated sensor and detection equipment, and preprocesses it to form a food feature vector V; Food status data includes food storage temperature T, ambient temperature H, pesticide residue Q, microbial count M and retention time △t; Preprocessing includes data removal of extreme invalid values and data standardization; removal of extreme invalid values includes the use of the interquartile range method and the upper and lower limit elimination method, and data standardization includes the use of Min-Max normalization and Z-score normalization methods; The retention time △t is obtained by calculating the timestamps of adjacent nodes on the blockchain; Sensors and detection equipment include temperature sensors and microbial detectors.
4. The blockchain-based food testing data processing system according to claim 3, characterized in that: The sub-batch abnormal data monitoring module includes an abnormality calculation unit and a summary and splitting unit; The anomaly calculation unit performs sub-batch sampling inspection on the food according to the obtained food feature vector V, calculates the abnormal potential value AP of each sample in the food sub-batch through the food feature vector V, and forms a set of abnormal potential values of all sample samples in the sub-batch; The abnormal potential value AP is obtained by the following calculation formula: Where AP(i) represents the abnormal potential value of the i-th sample, Q(i) represents the pesticide residue of the i-th sample, M(i) represents the microbial count of the i-th sample, T(i) represents the storage temperature of the i-th sample, H(i) represents the ambient temperature of the i-th sample, △t(i) represents the retention time of the i-th sample, and Tref(i) represents the ideal reference temperature of the i-th sample.
5. The blockchain-based food testing data processing system according to claim 4, characterized in that: The aggregation and splitting unit aggregates the abnormal potential values AP of all the sampled samples in the acquired abnormal potential value set to generate a potential value trend index APsub of the sub-batch, and calculates a splitting index S of the food sub-batch based on the potential value trend index APsub; The potential value trend index APsub is obtained by the following calculation formula: Where n represents the total number of random inspection samples in the sub-batch; The split index S is obtained by the following calculation formula: S = APsub*ln(1+σ(AP)); Where ln represents the natural logarithm function, and σ(AP) represents the standard deviation of the abnormal potential value AP of all sampled samples in the abnormal potential value set.
6. The blockchain-based food testing data processing system according to claim 5, characterized in that: The contract triggering and batch re-marking module includes a matching and splitting unit and a re-marking and chaining unit; The matching and splitting unit matches the preset trigger threshold Sthe with the obtained splitting index S, obtains the trigger matching result, and executes the sub-batch splitting task according to the trigger matching result; The trigger matching results are obtained through the following matching methods: When the split index S ≥ the trigger threshold Sthe, the trigger matching result is obtained as the trigger result, and the sub-batch splitting task is executed, including marking the food batch identifier BID and the upload node identifier NID of the sub-batch. At the same time, according to the food batch identifier BID and the upload node identifier NID, the storage location, current inventory and food-related data in the blockchain are extracted to form a sub-batch split original data group, and the re-labeling on-chain unit is triggered synchronously; When the split index S is less than the trigger threshold Sthe, the trigger matching result is obtained as a non-trigger result, and the sub-batch splitting task is not executed.
7. The blockchain-based food testing data processing system according to claim 6, characterized in that: The re-labeling and chain-uploading unit splits the original data group according to the obtained sub-batch, generates a new traceability ID for the sub-batch, and marks the association between the traceability ID and the food batch identification BID. It also calculates the preliminary safety index Sinit for the sub-batch, and then integrates the sub-batch split original data group, traceability ID and preliminary safety index Sinit to form an upload data packet. After marking the upload data packet with timestamp information and operation node information, the upload data packet is uploaded to the blockchain, and the sub-batch food batch identification BID is simultaneously updated to the split state; The new traceability ID is generated in the following way: ID=Hash(BID||TimeStamp||RandSeed); Where Hash represents the hash function, || represents the concatenation operator, TimeStamp represents the timestamp of the current operation, and RandSeed represents the random factor, which is specifically used to prevent the method ID from being repeated. The preliminary safety index Sinit is obtained by the calculation formula Sinit=ln(1+S).
8. The blockchain-based food testing data processing system according to claim 7, characterized in that: The batch comprehensive evaluation module includes a decision generation unit; The decision generation unit retrieves the historical test data of the food type to which the sub-batch belongs through the blockchain based on the traceability ID, specifically the food feature vector V and split index S uploaded on the previous blockchain, and generates a comprehensive split score CSS based on the historical test data. Based on the comprehensive split score CSS, the isolation execution result is judged and marked as the isolation execution status GS, and an execution decision vector Dexec is generated according to the isolation execution status GS, including confirming the execution of the sub-batch splitting task and secondary verification of the sub-batch splitting task; The comprehensive segmentation score CSS is obtained by the following calculation formula: Where exp represents the exponential function, m represents the total number of all random samples in the sub-batch of the previous blockchain, △t(j) represents the retention time of the j-th random sample, T(j) represents the storage temperature of the j-th random sample, Tref(j) represents the ideal reference temperature of the j-th random sample, and M(j) represents the microbial count of the j-th random sample.
9. The blockchain-based food testing data processing system according to claim 8, characterized in that: The isolated execution status GS is obtained in the following ways: When the comprehensive segmentation score CSS>0, the isolation execution status GS=true is generated, indicating that the food with the current traceability ID is different from the food with normal storage and transportation background. The execution of the sub-batch splitting task is confirmed, and the execution decision vector Dexec is generated, including the isolation execution status GS of the sub-batch splitting task, the traceability ID and the current operation timestamp TimeStamp; When the comprehensive segmentation score CSS≤0, the isolated execution status GS=false is generated, indicating that the food batch identification BID of the current traceability ID is similar to the food batch with normal storage and transportation background. The sub-batch splitting task is verified twice, the sub-batch splitting task is suspended, and the trigger threshold Sthe is synchronously executed after the ratio is reduced. The execution splitting index S is obtained twice. If the food batch identification BID of the current traceability ID generates the isolated execution status GS=false again, the food batch identification BID of the current traceability ID is marked as a warning state, the sub-batch splitting task is initialized, the traceability ID is synchronously retained and associated with the food batch identification BID, and a new upload data packet is generated by obtaining the execution splitting index S for the second time to replace the upload data packet generated after the execution splitting index S is first obtained in the blockchain. The execution decision vector Dexec is generated, including the isolated execution status GS of the sub-batch splitting task, the traceability ID and the current operation timestamp TimeStamp.
10. A blockchain-based food inspection data processing method, applied to a blockchain-based food inspection data processing system according to any one of claims 1 to 9, characterized in that: The following steps are involved: Step 1: Verify the source of food through the data reporting node in the blockchain network. After verification, extract the food status data to form the food feature vector V; Step 2: Perform random inspections on sub-batches of food based on the obtained food feature vector V to obtain abnormal potential values AP, then summarize all abnormal potential values AP of the sub-batches to generate a potential value trend index APsub, and calculate the food sub-batch splitting index S based on the potential value trend index APsub; Step 3: Match the split index S with the trigger threshold Sthe, execute the sub-batch splitting task based on the matching result, assign a traceability ID to the sub-batch, calculate the initial security index Sinit, and upload it to the blockchain; Step 4: Retrieve the historical inspection data of the sub-batch through the blockchain based on the traceability ID, generate a comprehensive segmentation score CSS, and judge the isolation execution result based on the comprehensive segmentation score CSS to generate an execution decision vector Dexec.
Citation Information
Patent Citations
Food testing data processing method based on blockchain
CN117390143B