Intelligent production scheduling and dynamic traceability blockchain management system for short-keeping food

By using an intelligent production scheduling and dynamic traceability blockchain management system, the degree of contamination during the production process of short-shelf-life foods can be detected and quantified in real time. This solves the problem of excessively large recall ranges for products within contaminated zones in existing technologies, achieving precise location and quantification of contamination levels, reducing economic losses and improving the reliability of the traceability system.

CN122222342APending Publication Date: 2026-06-16TIANJIN JINCHAO VERY CREATIVE TECHNOLOGY CO LTD +1

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
TIANJIN JINCHAO VERY CREATIVE TECHNOLOGY CO LTD
Filing Date
2026-05-20
Publication Date
2026-06-16

AI Technical Summary

Technical Problem

Existing food traceability systems cannot accurately pinpoint the degree of contamination of each smallest packaging unit within the contamination zone during the production of short-shelf-life foods, resulting in the innocent recall or destruction of a large number of qualified products, causing economic losses and food waste.

Method used

The system employs an intelligent production scheduling and dynamic traceability blockchain management system. The concentration detection module collects residual concentration data in real time, the pollution calculation module calculates the dynamic pollution time interval, the segmentation module divides mixed pollution micro-batch, the evidence storage module generates blockchain evidence storage records, the production scheduling feedback module quantifies the risk cost of cross-contamination, and the Kalman filter algorithm and dynamic programming algorithm are used to optimize the production sequence and cleaning strategy.

🎯Benefits of technology

It achieves precise location of traceability from the whole batch to the individual product, quantifies the degree of contamination, reduces the scope of recall, and forms a closed-loop feedback mechanism between production scheduling and traceability to ensure the authenticity and integrity of traceability data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122222342A_ABST
    Figure CN122222342A_ABST
Patent Text Reader

Abstract

The application provides an intelligent production scheduling and dynamic traceability blockchain management system for short-keeping food, and relates to the technical field of food management. The system comprises a concentration detection module, a pollution calculation module, a segmentation module and a storage module. The concentration detection module is used to collect concentration data of residues on the surface of equipment in real time during the production switching and cleaning process after switching from a first variety to a second variety. The pollution calculation module is used to calculate a dynamic pollution time interval, which starts at the time when the second variety starts to be produced and ends at the time when the concentration data of the residues on the surface of the equipment decays to a preset safety threshold. The segmentation module is used to divide the continuous product flow produced in the dynamic pollution time interval into mixed pollution micro-batches. The storage module is used to generate an independent blockchain storage record for each minimum packaging unit in the mixed pollution micro-batches. The production scheduling feedback module is used to quantify the pollution probability value as a cross-contamination risk cost, which is a weighted term of the production scheduling optimization objective function and constitutes a comprehensive cost together with the production time cost.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of food management technology, specifically relating to an intelligent production scheduling and dynamic traceability blockchain management system for short-shelf-life foods. Background Technology

[0002] In the production of short-shelf-life foods (such as shortbread, mung bean cake, and peach shortbread), different varieties are frequently switched continuously on the same production line. When switching from the first variety (such as red bean paste shortbread) to the second variety (such as lotus seed paste shortbread), residues of dough, oil, and other substances from the first variety remain on the equipment surface. Because short-shelf-life foods have extremely short shelf lives (usually 3-7 days), the production line has very limited downtime for cleaning, allowing only brief water rinsing or scraper cleaning, which cannot completely remove the residues. This leads to a real and long-overlooked technical problem: the residues gradually decrease in concentration over time and mix into the second variety of product produced subsequently, forming a mixed contamination zone. Each bag of product within this contamination zone actually contains components from both the first and second varieties, with the degree of contamination gradually decreasing from high to low.

[0003] However, existing food traceability systems generally use the "entire batch" as the smallest traceability unit. This means that all products produced after a production change are categorized into a second-variety batch and uniformly labeled with the same batch code. This binary classification method completely fails to identify the actual differences in contamination among different products within a contaminated zone. When a quality and safety issue arises in the first-variety batch (such as excessive microbial levels or unlabeled allergens), the existing system can only classify the entire second-variety batch as "potentially contaminated," when in fact only a small number of products within the contaminated zone are actually contaminated. This leads to the unnecessary recall or destruction of a large number of qualified products, causing significant economic losses and food waste. Therefore, accurately locating the degree of contamination of each smallest packaging unit within a contaminated zone and treating it as an independent traceability object is a pressing technical problem that needs to be solved in this field. Summary of the Invention

[0004] In view of the above-mentioned defects or deficiencies in the prior art, a smart production scheduling and dynamic traceability blockchain management system for short-shelf-life foods is provided, comprising: The concentration detection module is configured to collect real-time concentration data of residues on the equipment surface during the production line changeover cleaning process after switching from the first product to the second product. The pollution calculation module is configured to calculate the dynamic pollution time interval based on the change of the concentration data over time. The dynamic pollution time interval starts at the moment when the second product begins production and ends at the moment when the concentration data of the residue on the equipment surface decays to a preset safety threshold. A segmentation module is configured to divide the continuous product stream produced within the dynamic contamination time interval into mixed contamination micro-batches. The evidence storage module is configured to generate an independent blockchain evidence storage record for each smallest packaging unit in the mixed contamination micro-batch. Each record includes the production timestamp of the smallest packaging unit, the associated first variety batch identifier and second variety batch identifier, and the contamination probability value calculated based on the concentration data of residues on the equipment surface. The production scheduling feedback module is connected to the evidence storage module and is configured to read the contamination probability value and quantify it as cross-contamination risk cost. The cross-contamination risk cost is a weighted term in the production scheduling optimization objective function and together with the production time cost constitutes the comprehensive cost. The production scheduling algorithm aims to minimize the comprehensive cost and outputs the production sequence and cleaning strategy for each product.

[0005] According to the technical solution provided in this application, the preset safety threshold is dynamically generated by a smart contract on the blockchain based on the comparison results of the allergen list of the second product and the allergens contained in the first product. When the second product does not contain any of the allergens contained in the first product, the smart contract sets the preset safety threshold to a zero-tolerance value lower than the specified detection limit; When the second product contains at least one allergen contained in the first product, the smart contract relaxes the preset safety threshold to the maximum allowable residual amount of the allergen in the second product or the background content of the product itself.

[0006] According to the technical solution provided in this application, the production scheduling feedback module is specifically configured for: The continuous time axis within the dynamic pollution time interval is discretized into equally spaced time segments, and each time segment corresponds to the production time of a minimum packaging unit. For each time segment, the Kalman filter algorithm is used to fuse multiple residual concentration samples within the segment to filter out instantaneous concentration fluctuations caused by sensor noise and equipment vibration, and obtain the filtered concentration value corresponding to the segment. Divide the filtered concentration value by the preset safety threshold and map it to the (0,1) interval using a logistic function to obtain the contamination probability value of the smallest packaging unit; The process noise covariance and measurement noise covariance of the Kalman filter algorithm are obtained offline by training based on historical production change data stored on the blockchain, and the parameters are read from the blockchain each time a production change occurs.

[0007] According to the technical solution provided in this application, the production scheduling feedback module is further configured to: When the production plan includes three or more varieties that are scheduled for production consecutively, the dynamic programming algorithm is used to calculate the total cost of chain cross-contamination risk under any candidate variety arrangement order. The total cost of chain cross-contamination risk is defined as follows:

[0008] In the formula, n is the total number of product types to be sorted, and s k and s j L(s) represents the k-th and j-th varieties in the permutation order, respectively. k ,s j ) for variety s k For variety s j The direct pollution risk cost, w j k The attenuation weighting coefficient is w. d+1 =α w d , where 0 < α < 1; The attenuation weighting coefficient is used to characterize that the ability of the residue of the first variety to contaminate subsequent varieties decreases exponentially after continuous production and multiple cleanings of multiple intermediate varieties. The production scheduling feedback module aims to minimize the sum of the total cost of chain cross-contamination risk and the production time cost. It outputs the optimal production sequence of each product and the corresponding cleaning strategy for each production changeover through dynamic programming.

[0009] According to the technical solution provided in this application, the evidence storage module is further configured to: Arrange all the smallest packaging units within the mixed contamination micro-batch according to the production sequence, and calculate the contamination probability difference between adjacent units; When the difference in contamination probability between a minimum packaging unit and its preceding unit exceeds a preset rate of change threshold, the evidence storage module automatically triggers an abnormal anchoring, packaging the hash values ​​of the three evidence storage records of the unit and the units before and after it onto the blockchain. When the difference in the contamination probability of all adjacent units does not exceed the threshold, the evidence storage module only puts the hash values ​​of the evidence storage records of the starting and ending units of the entire mixed contamination micro-batch on the blockchain, while the intermediate units are only stored in the local database.

[0010] According to the technical solution provided in this application, the pollution calculation module is further configured to: While using Kalman filtering to filter the concentration data of residues on the device surface, the original sampled value sequence is preserved, and the presence of isolated pulses in the sequence is detected in real time. If the isolated pulse exists, and the isolated pulse is verified by a dual verification mechanism of cross-verification by multiple source sensors and matching of the characteristic waveform of the subsequent pulse, then it is determined that a blocky shedding event has occurred during the production change cleaning process. If a blocky shedding event occurs during the production change and cleaning process, the original dynamic contamination time interval will be revised.

[0011] According to the technical solution provided in this application, the pollution calculation module is further configured to: Mark the sampling time corresponding to the isolated pulse that triggers the verification as the dropout time; For consecutive products that are after the detachment time and outside the original dynamic contamination time interval, the contamination probability value is recalculated according to the ratio of the original concentration value of the isolated pulse to the preset safety threshold, and the original dynamic contamination time interval is extended to include these products. The newly added product information within the extended dynamic pollution time interval is synchronized to the evidence storage module, which then generates supplementary evidence storage records and uploads them to the blockchain.

[0012] According to the technical solution provided in this application, the dual verification mechanism includes: Multi-source sensor cross-validation: Compare the raw concentration data collected at the same time by at least two sensors with different physical principles. When the raw data of the two sensors both show pulses exceeding a preset multiple of their respective filter values ​​within the same preset time window, the multi-source sensor cross-validation is deemed to have passed. The two sensors with different physical principles include the concentration detection module and a redundant sensor installed in a different location. Post-pulse characteristic waveform matching: Analyze the original concentration data within a preset continuous time window after the occurrence of an isolated pulse, and detect whether there is a characteristic waveform that first drops sharply and then slowly recovers; when the characteristic waveform is detected, it is determined that the post-pulse characteristic waveform matching is passed. The pollution calculation module only determines that a block shedding event has occurred when both the cross-validation of the multi-source sensors and the matching of the post-pulse characteristic waveforms pass.

[0013] According to the technical solution provided in this application, an aggregated index smart contract is also deployed on the blockchain. The aggregated index smart contract maintains a key-value pair mapping table. The key of the mapping table is the variety combination identifier, and the value is a statistical summary of the contamination probability values ​​in all historical evidence records under the combination. The statistical summary includes: the total number of records, the sum of contamination probability values, the sum of squares of contamination probability values, and the most recent update timestamp. The aggregated index smart contract is configured such that whenever the evidence storage module uploads a new evidence storage record to the chain, the aggregated index smart contract is automatically triggered to execute, locate the corresponding key according to the first variety batch identifier and the second variety batch identifier in the record, and atomically update the statistical summary corresponding to the key. The atomic update includes: incrementing the record number by 1, accumulating the contamination probability value, accumulating the sum of squares of the contamination probability values, and updating the most recent update timestamp to the current time.

[0014] According to the technical solution provided in this application, the production scheduling feedback module is configured for: When it is necessary to calculate the cross-contamination risk cost, the query interface of the aggregated index smart contract is directly called, the target variety combination identifier is passed in, the corresponding statistical summary is read from the key-value pair mapping table, and the historical average contamination probability value of the variety combination is calculated based on the sum of the contamination probability values ​​in the statistical summary and the total number of records. The historical average contamination probability value is used as the weighting coefficient of the cross-contamination risk cost in the production scheduling optimization objective function.

[0015] Compared with the prior art, the beneficial effects of this application are as follows: I. Traceability granularity refined from the entire batch to individual products: Through real-time concentration detection and dynamic range calculation, each smallest packaging unit within the contaminated zone is independently marked and assigned a contamination probability value, thus refining the traceability granularity from the entire batch to the individual product. When upstream products experience quality issues, the scope of affected products is narrowed from the entire downstream batch to specific units within the contaminated zone, fundamentally resolving the precision contradiction between large batches and small contaminations in short-shelf-life food production change scenarios.

[0016] II. Continuous Quantification of Contamination Levels Instead of Binary Judgment: By calculating the ratio of the concentration detection value to the safety threshold and mapping it through a logistic function, a continuous contamination probability value between 0 and 1 is output for each product. This quantification provides a mathematical basis for subsequent differentiated handling: products with different probability ranges can be handled according to different strategies such as destruction, downgrading, or release, avoiding excessive recall or missed recall caused by a one-size-fits-all approach based on binary judgment.

[0017] Third, a closed-loop feedback mechanism between production scheduling and source traceability is established: The production scheduling feedback module reads historical contamination probability values ​​from the blockchain and quantifies them as risk costs, incorporating them as weighted terms into the production scheduling objective function. This allows the production scheduling algorithm to proactively weigh contamination risks when selecting product order and cleaning strategies. Thus, source traceability data drives production scheduling decisions in reverse, forming a closed loop of "historical contamination → risk quantification → production scheduling optimization → reducing future contamination," enabling the system to continuously self-optimize.

[0018] IV. Blockchain ensures the immutability and auditability of pollution data: Information such as the pollution probability value, product association, and timestamp for each product is written into the blockchain. Leveraging its immutability, the authenticity and integrity of traceability data are ensured. The pollution history of any product can be independently verified via the blockchain, without relying on potentially problematic local records provided by the company. Attached Figure Description

[0019] Other features, objects, and advantages of this application will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings: Figure 1This is a schematic diagram of the intelligent production scheduling and dynamic traceability blockchain management system for short-shelf-life foods provided in this application.

[0020] The diagram is marked as follows: 1. Concentration detection module; 2. Pollution calculation module; 3. Segmentation module; 4. Evidence storage module; 5. Production scheduling feedback module. Detailed Implementation

[0021] The present application will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, only the parts relevant to the invention are shown in the accompanying drawings.

[0022] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.

[0023] As mentioned in the background section regarding technical issues, this application proposes an intelligent production scheduling and dynamic traceability blockchain management system for short-shelf-life foods, such as... Figure 1 As shown, it includes: Concentration detection module 1 is configured to collect real-time concentration data of residues on the surface of equipment during the changeover cleaning process after the production line switches from the first product to the second product. Pollution calculation module 2 is configured to calculate a dynamic pollution time interval based on the change of the concentration data over time. The dynamic pollution time interval starts at the moment when the second product begins production and ends at the moment when the concentration data of the residue on the equipment surface decays to a preset safety threshold. Segmentation module 3 is configured to divide the continuous product stream produced within the dynamic contamination time interval into mixed contamination micro-batches; The evidence storage module 4 is configured to generate an independent blockchain evidence storage record for each smallest packaging unit in the mixed contamination micro-batch. Each record includes the production timestamp of the smallest packaging unit, the associated first variety batch identifier and second variety batch identifier, and the contamination probability value calculated based on the concentration data of residues on the equipment surface. The production scheduling feedback module 5 is connected to the evidence storage module 4 and is configured to read the contamination probability value and quantify it as cross-contamination risk cost. The cross-contamination risk cost is a weighted term in the production scheduling optimization objective function and together with the production time cost constitutes the comprehensive cost. The production scheduling algorithm aims to minimize the comprehensive cost and outputs the production sequence and cleaning strategy for each product.

[0024] Specifically, the concentration detection module 1 is used to collect real-time concentration data of residues on the equipment surface during the changeover cleaning process after switching from the first product to the second product on the production line. Here, the first and second products refer to different products processed sequentially on the same production line in short-shelf-life food production; for example, the first product is red bean paste pastry dough, and the second product is lotus seed paste pastry dough. The concentration detection module 1 can include one or more non-contact near-infrared spectral sensors. These sensors are installed at key locations such as the mixing tank outlet, above the conveyor belt, or the mold inlet. The sampling frequency of the sensors is set to 1 Hz, meaning one concentration reading is collected per second. To avoid data loss due to a single sensor failure, two independent sensors can also be installed at different locations on the equipment surface. The concentration data is transmitted to the controller in the form of an electrical signal. The controller converts the analog signal into a digital concentration value, expressed in milligrams per kilogram or relative fluorescence intensity. During the changeover cleaning process, while the operator starts water rinsing or scraper cleaning, the concentration detection module 1 automatically begins collecting residue concentration data until the production of the second product is completed.

[0025] The pollution calculation module 2 is communicatively connected to the concentration detection module 1 and is used to calculate the dynamic pollution time interval based on the changes in concentration data over time. The dynamic pollution time interval is a continuous time period, starting at the moment the second product begins production and ending at the moment the concentration of residues on the equipment surface decays to a preset safety threshold. The preset safety threshold is a concentration limit; when the residue concentration is below this threshold, the risk of cross-contamination of subsequent products is considered acceptable. In this embodiment, the pollution calculation module 2 first receives time-series data from the concentration detection module 1, such as a series of concentration values ​​recorded in seconds. Since the decay of residues usually follows an exponential law, the module incorporates a double exponential decay model: C(t) = A1exp(λ1t) + A2exp(λ2t), where C(t) is the residual concentration at time t, A1 and A2 are the initial amplitudes, and λ1 and λ2 are decay rate constants. The module uses a recursive least squares method to fit the model parameters online, updating the fitted curve each time new concentration data is received. Then, the time required for the concentration to drop to the preset safety threshold is calculated based on the fitted curve. The interval between this time and the start of production of the second product is the dynamic contamination time interval. For example, if the second product starts production at 8:00:00, and the fitted curve predicts that the concentration will drop below the safety threshold at 8:08:30, then the dynamic contamination time interval is [8:00:00, 8:08:30]. It is worth noting that the dynamic contamination time interval may be dynamically adjusted as subsequent sampling data are added; for example, if the actual concentration decreases rapidly, the termination point may be earlier.

[0026] The segmentation module 3 is used to divide the continuous product stream produced within the dynamic contamination time interval into mixed-contamination micro-lots. A mixed-contamination micro-lot refers to the collection of all the smallest packaging units produced within this time interval, which contain ingredients of both the first and second varieties due to residue contamination. The smallest packaging unit is the smallest independent package of short-shelf-life food products for sale, such as an individually packaged shortbread or an individually packaged mung bean cake. In this embodiment, photoelectric encoders or proximity switches are installed on the production line to detect the conveyor belt speed and product passage signals in real time. Whenever a smallest packaging unit completes sealing or comes off the line, the controller records the moment. The segmentation module 3 compares the dynamic contamination time interval with these moments: any smallest packaging unit whose off-line moment falls within the dynamic contamination time interval is classified into a mixed-contamination micro-lot. For example, if the dynamic contamination time interval is from 8:00:00 to 8:08:30, and the 100th pastry rolls off the production line at 8:00:12 and the 200th pastry rolls off the production line at 8:08:45, then pastries 100 to 199 belong to the mixed-contamination micro-batch, while pastry 200 and beyond do not. The segmentation module 3 outputs a list containing the unique serial number of each smallest packaging unit in the mixed-contamination micro-batch and its corresponding production time.

[0027] The evidence storage module 4 generates an independent blockchain evidence storage record for each smallest packaging unit in the mixed contamination micro-batch. Each record contains at least the following fields: the production timestamp of the smallest packaging unit (accurate to milliseconds), the associated first-variety batch identifier (e.g., batch number BATCH-240501-01), the associated second-variety batch identifier (e.g., batch number BATCH-240501-02), and a contamination probability value calculated based on the concentration data of residues on the equipment surface. The contamination probability value is calculated as follows: For each smallest packaging unit, the average value of all concentration samples within the unit's production time window (or using the Kalman filter value described later) is taken. This average value is divided by a preset safety threshold to obtain a ratio. This ratio is then mapped to a value between 0 and 1 using the logistic function P = 1 / (1+exp(-k×(ratio-0.5))), where k is the steepness coefficient. A probability value closer to 1 indicates more severe contamination, and a value closer to 0 indicates less severe contamination. The evidence storage module 4 packages each record into a transaction and submits it to the blockchain network. This embodiment uses the Hyperledger Fabric consortium blockchain. Each transaction is verified by endorsing nodes, sorted, packaged into blocks, and broadcast to all nodes. The hash value of each record serves as an immutable contamination file for the product.

[0028] The production scheduling feedback module 5 is connected to the evidence storage module 4 to read the contamination probability value and quantify it into cross-contamination risk cost. Cross-contamination risk cost refers to the quantified economic cost, such as recalls, compensation, and brand damage, that may result from contaminants from the first product entering the second product due to production relocation residues. Specifically, the production scheduling feedback module 5 obtains the contamination probability values ​​of all combinations of the first and second products in historical data through a blockchain query interface and calculates their statistical average.

[0029] Step 1: Define basic variables and prepare data: Production scheduling feedback module 5 reads historical records from the blockchain and statistically analyzes the historical contamination characteristics of each pair of varieties. Here, a pair of varieties refers to the order in which the first and second varieties are produced. For example, producing variety A first and then variety B is considered one pair, while producing variety B first and then variety A is considered a different pair. For each pair of varieties, the module calculates the following statistics: The first statistic is the historical average contamination probability value. It is equal to the arithmetic mean of the contamination probability values ​​of all the smallest packaging units within a mixed contamination micro-lot across all historical production change records. This value reflects, on average, the degree of contamination per product when this pair of varieties is produced in this order.

[0030] The second statistic is the historical average contamination band length, measured in units. It equals the average number of the smallest packaging units contained in a mixed contamination micro-batch. This length reflects the number of products produced within the time required for the residue concentration to decay from its initial value to a safe threshold under typical cleaning operations. For example, an average contamination band length of 400 units means that approximately 400 products will be detectably contaminated after a production change.

[0031] The third statistic is the historical contamination probability distribution parameter, specifically referring to the shape of the curve showing how the contamination probability value changes over time or with the sequential position of the product. This curve typically exhibits an exponential decay pattern: the probability of contamination is higher for products at the beginning of the contamination zone, gradually decreases in the middle, and approaches zero at the end. This curve is used to infer the specific degree of contamination of products at different locations within the contamination zone.

[0032] Simultaneously, the module also needs to acquire the enterprise's pre-set economic parameters. These parameters include unit recall cost and unit downgrade loss. Unit recall cost refers to the sum of all expenses incurred for a single product from the recall notification to its final destruction, specifically including product destruction and processing fees, logistics recall fees, labor processing fees, and average compensation costs, measured in yuan per unit. Unit downgrade loss refers to the value loss obtained when a product does not meet direct sales standards but can be downgraded for use as feed or industrial raw materials, calculated by subtracting the downgraded selling price from the original selling price.

[0033] Step 2: Calculate the cross-contamination risk cost for a candidate production scheduling plan: The production scheduling algorithm needs to evaluate the production order of each candidate product. Assume that in the candidate order, product A is immediately followed by product B, meaning A is produced before B. The risk cost for this production change from A to B is calculated as follows.

[0034] Since production hasn't actually started at the time of scheduling, the actual length of the contamination zone for this production change is unknown. Therefore, an expected value model based on historical data is adopted. The module first reads the historical average contamination probability value and the historical average contamination zone length obtained in the first step. Then, it assumes that the length of the contamination zone for this production change follows a certain statistical distribution with the historical average contamination zone length as the mean, such as a Poisson distribution or a normal distribution. Simultaneously, the company can set different risk attitudes: if the company adopts a risk-neutral strategy, it directly uses the historical average contamination zone length as the expected quantity of products within the contamination zone; if the company adopts a risk-averse strategy, such as hoping to avoid huge losses caused by extreme events, it uses the quantiles of historical data as the expected value, for example, taking the 90th percentile, meaning that the contamination zone length does not exceed this value in 90% of historical production changes.

[0035] In the basic model, the cost of cross-contamination risk is calculated by multiplying the historical average contamination probability by the expected number of products within the contaminated zone, and then multiplying by the unit recall cost. This basic model assumes that all products within the contaminated zone have the same average contamination probability and that all require recall.

[0036] For a more refined model, a tiered calculation approach can be used. This is because the probability of product contamination varies at different locations within the contamination zone: products at the beginning have a high probability of contamination, those in the middle have a lower probability, and those at the end have a very low probability, even below the safety threshold. The specific method for tiered calculation is as follows: for each product from the first to the Nth product within the contamination zone, first predict the probability of contamination at that location based on historical typical decay curves, and then determine the disposal method based on this probability. The disposal method can be set as follows: if the contamination probability is greater than 0.7, destruction is carried out, with the corresponding disposal cost being the unit recall cost; if the contamination probability is between 0.3 and 0.7, downgrading is carried out, with the corresponding disposal cost being the unit downgrading loss; if the contamination probability is less than or equal to 0.3, normal release is carried out, with the corresponding disposal cost being zero. Finally, the disposal costs of all products within the contamination zone are summed to obtain the total risk cost. Here, summation means adding the disposal costs of each product sequentially, starting from the first product, until the Nth product. This refined model requires the shape parameters of the historical decay curves, which can be extracted from typical product replacement events stored on the blockchain.

[0037] Step 3: Introduce the cleaning strategy as a decision variable: Production scheduling algorithms not only need to determine the production sequence of product varieties, but also the cleaning strategy for each production changeover. The cleaning strategy can be represented by a variable, such as cleaning duration in seconds; or by a cleaning intensity coefficient, ranging from 0 to 1, where 0 represents no cleaning and 1 represents deep cleaning. Cleaning duration or intensity directly affects the length of the contamination zone: the more thorough the cleaning, the lower the initial concentration of residue, and the shorter the contamination zone. This relationship can be fitted using empirical formulas or machine learning models.

[0038] Taking cleaning time as an example, for a changeover from product A to product B, the relationship between the length of the contaminated zone and the cleaning time can be modeled as: N(t) = N_max·e (-βt) Here, N_max is the length of the contaminated zone without cleaning (t=0), which is the amount of product produced in the time required for the residue to naturally decay to a safe threshold without any cleaning operation. This value is determined by factors such as equipment surface characteristics, residue adhesion, and product flow rate, and can be calibrated through a single no-clean experiment. β is the cleaning efficiency coefficient, measured in negative first seconds. The larger the β, the higher the efficiency of the cleaning operation in removing residues, and the greater the reduction in the length of the contaminated zone for the same cleaning time. The value of β depends on the cleaning method (water rinsing, foam cleaning, manual scraping), water temperature, cleaning agent concentration, etc., and can be obtained from historical production changeover data through curve fitting. t is the cleaning duration, measured in seconds.

[0039] For a given cleaning duration, the cross-contamination risk cost is calculated using the previous method, simply by replacing the expected number of products within the contaminated zone with the length of the contaminated zone corresponding to the current cleaning duration. Meanwhile, the cleaning operation itself incurs production time costs, including energy consumption from equipment idling, labor hours, and production line downtime losses. These costs are typically proportional to the cleaning duration, but may also exhibit a non-linear relationship (e.g., the longer the cleaning time, the higher the energy consumption per unit time).

[0040] Step 4: Minimize overall cost: For the entire production plan, the total cost equals the sum of the production time cost and cross-contamination risk cost of all production changeover stages, plus the production time cost of each product itself. The production time cost of each product is a fixed value, independent of the product order, and can be ignored during optimization comparisons because all candidate orders include the same product's own production time.

[0041] The production scheduling algorithm needs to simultaneously select the production order of product varieties and the cleaning time for each production changeover to minimize the total cost. In a typical short-shelf-life food production scenario, the number of product varieties to be produced in a day is usually no more than twenty, so the number of production changeovers is no more than nineteen. To reduce the difficulty of solving the problem, the cleaning time can be discretized into several levels, such as zero seconds, thirty seconds, sixty seconds, ninety seconds, one hundred and twenty seconds, etc.

[0042] The production scheduling feedback module 5 uses dynamic programming to solve the problem. Dynamic programming decomposes the problem into multiple stages, and the state of each stage is defined by two pieces of information: the set of varieties that have already been produced, and the last variety produced. During state transition, starting from the current state, the algorithm enumerates the next variety to be produced, and simultaneously enumerates the available cleaning time levels for this changeover, calculating the increased costs (including cleaning time costs and expected contamination risk costs), and then transitions to the new state. After traversing all possible state combinations, the algorithm finds the path that minimizes the total cost, outputting the optimal production order of varieties and the corresponding cleaning time for each changeover.

[0043] Step 5: Dynamic Updates and Feedback The production scheduling plan is not fixed after a single calculation. In this embodiment, the production scheduling plan is recalculated every thirty minutes to respond to dynamic changes in the production site, such as equipment failures, raw material delays, and emergency orders.

[0044] After each actual production cycle, the system writes the real data of this production change to the blockchain. This data includes: the actual observed length of the contamination zone, the actual change sequence of the contamination probability with the product's sequential position, and the actual cleaning time. Upon receiving this new data, the blockchain automatically updates the historical statistics collected in the first step, including the historical average contamination probability value, the historical average contamination zone length, and the decay curve shape parameters. Simultaneously, the cleaning efficiency coefficient β is refitted based on the new correspondence between cleaning time and contamination zone length, making the model more accurate.

[0045] As production data accumulates, the accuracy of risk and cost estimation during subsequent production scheduling will continue to improve, and the scheduling plan will become increasingly optimized, forming a closed loop of continuous self-improvement. This mechanism enables the system to adapt to differences caused by different seasons, different batches of raw materials, and different operators, and always maintains optimal production scheduling decisions.

[0046] The technical principle of this solution lies in the following: By real-time monitoring of the concentration decay process of production transition residues, the continuous product flow is dynamically segmented according to the actual contamination boundary, allowing the contamination level of each smallest packaging unit to be independently quantified and stored on the blockchain. Simultaneously, accumulated historical contamination data is fed back into the production scheduling optimization model, enabling production decisions to proactively avoid high-risk product combinations while pursuing efficiency. The resulting technical effects are: First, when a quality problem occurs in the first product, the specific product unit within the mixed contamination micro-batch can be precisely identified, narrowing the recall scope from the entire second product batch to a few products within the contamination zone, reducing economic losses from recalls; Second, the production scheduling system can automatically learn which product combinations are prone to high contamination risks and stagger or insert them into deep cleaning processes in subsequent production, reducing the frequency of cross-contamination events from the source; Third, all contamination data is stored on the blockchain, making it tamper-proof and facilitating regulatory auditing.

[0047] In a preferred embodiment, the preset safety threshold is dynamically generated by a smart contract on the blockchain based on the comparison results between the allergen list of the second product and the allergens contained in the first product; When the second product does not contain any of the allergens contained in the first product, the smart contract sets the preset safety threshold to a zero-tolerance value lower than the specified detection limit; When the second product contains at least one allergen contained in the first product, the smart contract relaxes the preset safety threshold to the maximum allowable residual amount of the allergen in the second product or the background content of the product itself.

[0048] Specifically, this embodiment further defines the dynamic generation method of the preset safety threshold. The preset safety threshold is a concentration limit used to determine whether the cleaning process during product switching is qualified. When the residue concentration is below this threshold, the risk of cross-contamination is considered acceptable. In the prior art, this threshold is usually a fixed value, for example, uniformly set at 10 mg / kg, regardless of the product being switched. This approach has obvious drawbacks: when switching from a product containing an allergen to one that does not, the fixed threshold may be too high, resulting in residue exceeding the limit and going undetected; conversely, when two products contain the same allergen, the fixed threshold may be too low, causing unnecessary over-cleaning. This embodiment solves the above problems by dynamically adjusting the threshold based on the allergen comparison results using a blockchain smart contract.

[0049] The specific implementation is as follows. First, an allergen matching smart contract is deployed on the blockchain. This smart contract is an automatically executing program code written in Solidity and deployed in an Ethereum or Hyperledger Fabric chaincode environment. The smart contract maintains a global allergen database, which records a complete list of allergens for all of the company's product varieties. The allergen list for each variety includes all substances in the product's formula that may cause allergic reactions, such as peanut protein, egg protein, milk protein, soy protein, gluten, nuts, etc. When the quality management department releases a new product formula or modifies an existing formula, it needs to submit the corresponding allergen list to the blockchain in the form of a transaction. After multi-party signature verification, the data is written into the smart contract's storage area to ensure that the data is immutable and traceable.

[0050] When the production execution system prepares to switch production from product type one to product type two, the system automatically calls the query interface of the smart contract, passing in the identifiers of product type one and product type two. The smart contract reads the allergen lists for these two products from the on-chain database and then executes an aggregated comparison algorithm. The comparison result is divided into two cases.

[0051] Scenario 1: The allergen list of the second product does not include any of the allergens in the allergen list of the first product. This means that some allergens are present in the first product, but are not originally present in the second product. For example, the first product is peanut brittle, and its allergen list includes peanut protein; the second product is white-skinned brittle, and its allergen list does not include peanut protein. If residues from the first product are mixed into the second product, it will introduce foreign peanut allergens into the otherwise safe white toast, posing a serious health threat to consumers with peanut allergies. Therefore, the smart contract sets a preset safety threshold of zero tolerance, below the prescribed detection limit. The prescribed detection limit refers to the lowest detectable concentration of a certain allergen specified in national food safety standards or internal company standards. For example, the detection limit for peanut protein is usually 2.5 mg / kg. The zero tolerance value is set at half of this detection limit, i.e., 1.25 mg / kg. This means that cleaning is considered acceptable only when the residue concentration is below 1.25 mg / kg. This strict threshold forces the production line to perform thorough cleaning during product changeovers until the residue concentration is extremely low, thereby preventing foreign allergens from entering the product.

[0052] The second scenario: The allergen list of the second product contains at least one allergen from the allergen list of the first product. This means that the allergen in the first product was already present in the second product. For example, the first product is peanut brittle (containing peanut protein), and the second product is peanut-flavored mung bean cake (also containing peanut protein). In this case, even if a small amount of residue from the first product is mixed into the second product, since the second product already contains the allergen, it will not introduce a new type of allergen; it will only slightly increase the total content of the allergen. As long as the increase does not exceed the legally permissible range, the risk is acceptable. Therefore, the smart contract will relax the preset safety threshold to the smaller of the maximum permissible residue level of the allergen in the second product or the background content of the product itself. The maximum permissible residue level refers to the highest content of the allergen allowed in the final product according to national or industry standards. For example, the maximum permissible amount of peanut protein in baked goods is 10 mg per kilogram. The background content of the product itself refers to the normal content of the allergen in the second product's formula. For example, the peanut protein content contributed by peanut butter in peanut toast is 8 mg per kilogram. The smart contract sets a background content of 8 mg / kg as a safety threshold. This is because even if residue contamination slightly exceeds 8 mg, the product still meets the standard as long as it does not exceed 10 mg. This lenient setting avoids unnecessary deep cleaning, as residue contamination will not cause the content to exceed the limit, thus saving cleaning time and costs.

[0053] After the smart contract is executed, the calculated preset security threshold is recorded on the blockchain, along with the timestamp of this comparison, the caller's identity, the identifiers of the two varieties, and the comparison result. This record serves as immutable audit evidence for subsequent regulatory inquiries. Subsequently, pollution calculation module 2 reads this threshold from the blockchain to calculate the dynamic pollution time interval.

[0054] The technical principle of this solution lies in leveraging the automatic execution and data immutability of blockchain smart contracts to dynamically adjust the stringency of safety thresholds based on the allergen attributes of different product varieties. A zero-tolerance policy is adopted when there is a risk of external allergens, while a lenient threshold is used when there is no such risk. The technical effect is that, while ensuring allergen safety, the average cleaning time per product changeover is reduced because deep cleaning is only performed when truly necessary, avoiding the efficiency losses caused by applying a uniformly strict threshold to all product changes. Furthermore, since the generation and storage of thresholds are completed on the blockchain, the decision-making process is transparent and traceable. Regulatory authorities can verify at any time whether the company has reasonably set safety thresholds, preventing companies from deliberately relaxing thresholds to save costs.

[0055] In a preferred embodiment, the production scheduling feedback module 5 is specifically configured to: The continuous time axis within the dynamic pollution time interval is discretized into equally spaced time segments, and each time segment corresponds to the production time of a minimum packaging unit. For each time segment, the Kalman filter algorithm is used to fuse multiple residual concentration samples within the segment to filter out instantaneous concentration fluctuations caused by sensor noise and equipment vibration, and obtain the filtered concentration value corresponding to the segment. Divide the filtered concentration value by the preset safety threshold and map it to the (0,1) interval using a logistic function to obtain the contamination probability value of the smallest packaging unit; The process noise covariance and measurement noise covariance of the Kalman filter algorithm are obtained offline by training based on historical production change data stored on the blockchain, and the parameters are read from the blockchain each time a production change occurs.

[0056] Specifically, firstly, the production scheduling feedback module 5 needs to discretize the continuous time axis. The module obtains the real-time operating speed of the conveyor belt from the production line control system, in meters per second. It also obtains the length of a single smallest packaging unit, for example, the packaging length of a shortbread is 0.2 meters. Dividing the packaging length by the conveyor belt speed yields the production time of each smallest packaging unit, denoted as T. For example, when the speed is 1 meter per second and the length is 0.2 meters, T equals 0.2 seconds. Then, the dynamic contamination time interval is divided into multiple time segments according to T, with each segment corresponding to a specific smallest packaging unit. For example, if the dynamic contamination time interval is from 8:00:00 to 8:08:30, and T is 0.2 seconds, then a total of 2550 time segments can be divided, corresponding to 2550 bags of product.

[0057] For each time segment, the module needs to process multiple residual concentration samples within that segment. The sampling frequency of concentration detection module 1 is fixed, for example, 1 Hz, which means sampling once per second. When T is less than 1 second, there may be only zero or one sampling point in each time segment; when T is greater than 1 second, there may be multiple sampling points in each segment. To obtain the true average residual concentration within the segment, the module uses a Kalman filter algorithm to fuse all the sampled values ​​within the segment.

[0058] Kalman filtering is a recursive state estimation algorithm suitable for noisy dynamic systems. In this embodiment, the actual concentration of residue on the equipment surface is considered the system's state variable, and the concentration value collected by the sensor is considered the observed value. The state transition model assumes that the concentration changes little in a very short time, and a random walk model can be used, meaning that the actual concentration at the current moment equals the actual concentration at the previous moment plus process noise. Process noise reflects the fluctuations in the actual concentration caused by unpredictable factors such as equipment vibration and residue shedding. The measurement model assumes that the observed value equals the actual concentration plus measurement noise, which reflects the electronic noise and optical interference of the sensor itself.

[0059] Kalman filtering requires two key parameters: process noise covariance and measurement noise covariance. These two parameters are not fixed but are obtained offline through training using historical production change data stored on the blockchain. The training process is as follows: Raw concentration sampling value sequences of all production change events within the past three months are collected, and the true concentration values ​​at each moment are obtained through high-precision laboratory testing afterward as the ground truth. An expectation-maximization algorithm or a genetic algorithm is used to search for the optimal process noise covariance and measurement noise covariance, minimizing the mean square error between the Kalman filter output and the ground truth. The trained parameters, along with corresponding equipment models, product combinations, production line numbers, and other information, are packaged into a transaction and stored on the blockchain. During each production change, the production scheduling feedback module 5 reads the corresponding parameters from the blockchain based on the currently used equipment and product combination to initialize the Kalman filter.

[0060] For each time segment, the module performs the following Kalman filtering steps: First, if there are no sampled values ​​in the segment, the state estimate obtained from the prediction step is used as the filtered concentration value, i.e., the predicted value of the previous segment's filtering result is directly taken. If there are one or more sampled values ​​in the segment, each sampled value is processed sequentially: for each sampled value processed, the prediction step is executed first, then the Kalman gain is calculated, and finally the state estimate is updated with the observed value. After processing all sampled values ​​in the segment, the final state estimate output by the filter is the filtered concentration value for that segment. This filtering process can effectively suppress transient spikes caused by high-frequency noise and vibration, while preserving the true concentration decay trend.

[0061] After obtaining the filtered concentration value, the module divides this value by a preset safety threshold to obtain a ratio. For example, if the filtered concentration is 5 mg / kg and the safety threshold is 10 mg / kg, the ratio is 0.5. Then, the module maps this ratio to the 0-1 range using a logistic function to obtain the contamination probability value of the smallest packaging unit. The form of the logistic function is: the contamination probability value equals 1 divided by (1 plus the negative k of the natural constant e multiplied by (ratio minus 0.5)). Here, k is the steepness coefficient, typically set to 10. When the ratio is much less than 0.5, the contamination probability value approaches 0; when the ratio is much greater than 0.5, the contamination probability value approaches 1; and when the ratio equals 0.5, the contamination probability value equals 0.5. This S-shaped mapping allows the contamination probability value to transition smoothly around the safety threshold, avoiding the abrupt changes caused by simple threshold comparisons. For example, ratios of 0.49 and 0.51 correspond to probability values ​​of 0.48 and 0.52 respectively, which are continuous and reasonable.

[0062] In a preferred embodiment, the production scheduling feedback module 5 is further configured to: When the production plan includes three or more varieties that are scheduled for production consecutively, the dynamic programming algorithm is used to calculate the total cost of chain cross-contamination risk under any candidate variety arrangement order. The total cost of chain cross-contamination risk is defined as follows:

[0063] In the formula, n is the total number of product types to be sorted, and s k and s j L(s) represents the k-th and j-th varieties in the permutation order, respectively. k ,s j ) for variety s k For variety s j The direct pollution risk cost, w j k The attenuation weighting coefficient is w. d+1 =α w d , where 0 < α < 1; The attenuation weighting coefficient is used to characterize that the ability of the residue of the first variety to contaminate subsequent varieties decreases exponentially after continuous production and multiple cleanings of multiple intermediate varieties. The production scheduling feedback module 5 aims to minimize the sum of the total cost of chain cross-contamination risk and the production time cost. It outputs the optimal production sequence of each product and the corresponding cleaning strategy for each production change through dynamic programming.

[0064] Specifically, this embodiment further defines the method for calculating the risk cost of chain cross-contamination in the production scheduling feedback module 5 when handling three or more consecutively scheduled product varieties. Previously, the main focus was on direct contamination between two adjacent varieties. However, when the production plan includes three or more varieties, contamination can propagate along the production chain: residues from variety A contaminate variety B, and residues from variety B (which already contain components of A) contaminate variety C, forming a chain propagation. For example, first producing pepper-salt crisps, then sesame crisps, and finally jujube paste crisps. Residues from the pepper-salt crisps will first contaminate the sesame crisps, and after a production change and cleaning, some residues will continue to contaminate the jujube paste crisps. Existing technologies only consider adjacent contamination, ignoring this chain effect, leading to an underestimation of the risk of subsequent varieties. This embodiment solves this problem through a dynamic programming algorithm and a decay weighting coefficient.

[0065] The specific implementation is as follows. When the production plan includes three or more consecutively scheduled products, the scheduling feedback module 5 first obtains a list of all products to be produced. Assume there are n products in total, where n is greater than or equal to 3. The module needs to find the optimal permutation order from all possible arrangements, minimizing the sum of the total cost of chain cross-contamination risk and the production time cost. Since there are n factorial permutations of n products, and when n equals 10, the total number of permutations exceeds 3.6 million, it is impossible to enumerate them one by one. Therefore, a dynamic programming algorithm is required.

[0066] The core idea of ​​dynamic programming is to decompose a problem into subproblems. A state is defined as the set of varieties that have already been produced, and the last variety produced in that set. For example, the state (set S, last variety j) represents the state where all varieties in set S have been produced, and the last variety produced was j. Starting from this state, we can choose the next variety to produce, k (k is not in S), and transition to a new state (S∪{k}, k). The transition cost includes two parts: the production time cost of switching from variety j to variety k, and the risk cost of chain cross-contamination from j to k.

[0067] The risk cost of chain cross-contamination here is not a simple one-to-one cost, but rather needs to consider the cumulative contamination of the current variety by all previous varieties. Specifically, when variety k is produced, each variety i (i belongs to S) preceding k may contaminate k through chain transmission of residues. The transmission path is: the residue of variety i first contaminates its directly following variety; after multiple production changes and cleaning, some residues still remain and continue to contaminate even later varieties. The transmission intensity decreases as the number of intermediate varieties increases. This implementation uses an exponential decay weight to quantify this decay: the weight of the contamination effect of variety i on variety k is equal to the decay coefficient raised to the power of (the number of varieties between k and i). For example, if there are 0 varieties between i and k (i.e. i is adjacent to k), the weight is 1; if there is 1 variety, the weight is α; if there are 2 varieties, the weight is α squared; and so on. The attenuation coefficient α is a number between 0 and 1, obtained by fitting historical data. It is usually between 0.3 and 0.7, indicating that after each production change and cleaning, the residual pollution capacity is reduced to 30% to 70% of the original.

[0068] Therefore, the chain cross-contamination risk cost of moving from the current state (S, j) to the next variety k is equal to: for each variety i in set S, multiplying the direct contamination risk cost of variety i to variety k by the corresponding attenuation weight, and then summing up the contributions of all varieties i. The direct contamination risk cost refers to the expected economic loss to k caused by the residue of i when i is produced immediately adjacent to k (with no other varieties in between). This direct cost can be obtained from historical data, for example, calculated using the historical average contamination probability value and average contamination band length described earlier. After summing, adding the direct contamination risk cost from j to k (since j is the preceding variety immediately adjacent to k, its weight is 1) yields the total chain contamination risk cost.

[0069] The production time cost depends only on the two adjacent varieties j and k and the selected cleaning time, and is independent of earlier varieties, so it can be directly read from the changeover cleaning time matrix.

[0070] The dynamic programming algorithm computes all states in ascending order of set size. The initial state is a set containing only one variety, with zero transfer cost. Then, the second and third varieties are added sequentially until the set contains all n varieties. Finally, among all complete sets where the last variety differs, the path with the minimum total cost is selected, backtracking to obtain the optimal production order. Simultaneously, at each transfer, the cleaning duration for that changeover needs to be determined (see the previously described cleaning strategy decision), incorporating the cleaning duration as a decision variable into the dynamic programming to minimize the overall cost.

[0071] The output includes: a list of optimal production sequences for each product, and the cleaning time for each production changeover (e.g., 30 seconds, 60 seconds, etc.). This production schedule is then sent to the production execution system to guide actual production.

[0072] The technical principle of this solution lies in: simulating the gradual decay of residues after multiple production changes and cleanings using exponentially decaying weights, and incorporating indirect contamination between non-adjacent varieties into cost calculations; and utilizing a dynamic programming algorithm to solve for the optimal permutation in polynomial time, avoiding full permutation enumeration. The technical effect is that, compared to traditional production scheduling that only considers adjacent contamination, this solution can identify and quantify chain transmission risks, avoiding cumulative contamination caused by scheduling high-allergen varieties before multiple low-allergen varieties. Practical application shows that after adopting the chain risk model, the production scheduling algorithm will choose to produce high-risk varieties as late as possible, or insert multiple low-risk varieties after high-risk varieties with appropriate cleaning, reducing the overall contamination risk by approximately 50%. Simultaneously, the computational complexity of the dynamic programming algorithm is n squared multiplied by 2 to the power of n, which can be completed within seconds for cases where n does not exceed 20, meeting the real-time requirements of short-shelf-life food production scheduling.

[0073] In a preferred embodiment, the evidence storage module 4 is further configured to: Arrange all the smallest packaging units within the mixed contamination micro-batch according to the production sequence, and calculate the contamination probability difference between adjacent units; When the difference in contamination probability between a minimum packaging unit and its preceding unit exceeds a preset rate of change threshold, the evidence storage module 4 automatically triggers an abnormal anchoring, packaging the hash values ​​of the three evidence storage records of the unit and the units before and after it onto the blockchain. When the difference in the contamination probability of all adjacent units does not exceed the threshold, the evidence storage module 4 only puts the hash values ​​of the evidence storage records of the starting and ending units of the entire mixed contamination micro-batch on the blockchain, while the intermediate units are only stored in the local database.

[0074] Specifically, this embodiment further defines the blockchain evidence storage strategy for the evidence storage module 4 for a large number of smallest packaging units within a mixed-contamination micro-batch. Previously, it was required to generate an independent blockchain evidence storage record for each smallest packaging unit in a mixed-contamination micro-batch. In actual production, a mixed-contamination micro-batch may contain hundreds or thousands of smallest packaging units; for example, a high-speed production line can produce approximately 500 bags of toast within an eight-minute contamination zone. If an independent blockchain transaction is generated and uploaded to the chain for each bag, it would lead to an explosion in on-chain data, a sharp increase in storage costs, a decrease in query efficiency, and a heavier burden on node synchronization. This embodiment solves this problem through an anomaly anchoring mechanism, significantly reducing the amount of data uploaded to the chain while ensuring data immutability.

[0075] The specific implementation is as follows. The evidence storage module 4 first obtains information on all the smallest packaging units in the mixed-contamination micro-batch from the contamination calculation module 2 and the segmentation module 3, including the production timestamp, product identifier, and contamination probability value for each unit. The evidence storage module 4 arranges these units according to the production order, forming a sequence whose order corresponds to the product's production line exit order. Then, the module sequentially calculates the contamination probability difference between adjacent units. For example, if the contamination probability value of the k-th unit is 0.52 and the contamination probability value of the (k+1)-th unit is 0.48, the difference is 0.04; if the k-th unit is 0.52 and the (k+1)-th unit is 0.73, the difference is 0.21. This difference reflects the drastic change in contamination probability between adjacent products.

[0076] The module has a preset change rate threshold, which is set by the enterprise based on production stability requirements, with a typical value of 0.1. If the difference in contamination probability between adjacent units exceeds this threshold, it indicates an abnormal jump in contamination probability. This jump can be caused by various reasons: a sudden increase in concentration due to the shedding of residue clumps, momentary interference to the sensor, equipment malfunction causing cleaning interruption, or human error, etc. Regardless of the cause, data near this jump point is of great value for post-event traceability and quality analysis and needs to be carefully protected.

[0077] When the difference in contamination probability between a minimum packaging unit and its preceding unit exceeds a preset change rate threshold, the evidence storage module 4 automatically triggers an anomaly anchoring. The specific operation of anomaly anchoring is as follows: The hash values ​​of the complete evidence storage records for the anomaly unit itself, its preceding adjacent unit, and its following adjacent unit (a total of three units) are calculated separately. These three hash values ​​are then packaged together to form a blockchain transaction and submitted to the chain. The reason for anchoring three units instead of just the anomaly unit is that anchoring only the anomaly unit cannot verify the authenticity of the jump, because a single value cannot prove its change relative to the preceding and following units. Anchoring the preceding unit provides the starting point benchmark for the jump, anchoring the anomaly unit provides the new value after the jump, and anchoring the following unit can determine whether the normal trend has been restored after the jump. If the difference between the following unit and the preceding unit is small, it indicates that the jump is an isolated pulse event; if the difference between the following unit and the anomaly unit is still large, it indicates that the contamination curve has undergone a continuous change. The three units constitute a minimal complete set, capable of completely capturing the starting point, mutation point, and recovery point of an anomaly jump.

[0078] If the difference in contamination probability between all adjacent units does not exceed the threshold, it indicates that the contamination probability decreases smoothly along the production sequence without any abnormal jumps. In this case, the evidence storage module 4 adopts a batch anchoring strategy: only the hash values ​​of the evidence storage records of the starting and ending units of the entire mixed contamination micro-batch are packaged and uploaded to the blockchain. The starting unit represents the beginning boundary of the micro-batch, and the ending unit represents the ending boundary. Intermediate units are not directly uploaded to the blockchain but are stored in the local database. To ensure the immutability of the intermediate unit data, the system constructs an implicit hash chain during storage: the hash value of the starting unit is known, and the evidence storage record of each intermediate unit contains not only its own data but also the hash value of the previous unit. Thus, the hash value of the last unit can be calculated sequentially. The hash value of the ending unit uploaded to the blockchain is the final hash of this implicit chain. If anyone tampers with the data of any intermediate unit, it will cause a mismatch in the hash value of the ending unit, thus being detected. Therefore, this strategy ensures data integrity while significantly reducing the amount of data uploaded to the blockchain.

[0079] The technical principle of this solution lies in leveraging the continuous nature of contamination probability in the physical process. Under normal circumstances, the difference in contamination probability between adjacent products is very small, and jumps only occur when abnormal events happen. For normal, smooth segments, head-and-tail hash anchoring is used, employing a hash chain to ensure the immutability of intermediate data. For abnormal jump segments, local fine-grained anchoring is used to record complete information before and after the jump. The technical effect is that, while ensuring data immutability and verifiability, the amount of data on the blockchain is reduced. Taking a contamination strip of 500 bags of products as an example, abnormal jumps typically occur no more than two to three times, thus reducing the number of transactions on the blockchain from 500 to 10 to 15, significantly decreasing blockchain storage costs and network bandwidth consumption. Simultaneously, query efficiency is significantly improved, and recall instructions can be generated in milliseconds. Furthermore, the abnormal anchoring records themselves become an important data source for quality analysis, which can be used to identify the timing of equipment failures, operational errors, and other problems.

[0080] Furthermore, by distinguishing different types of events from the waveform characteristics of abnormal anchoring records, intelligent diagnosis of equipment failures and operational errors is achieved.

[0081] The specific implementation is as follows. The system adds a quality analysis module outside the blockchain network. This module can be an independent background service process or integrated into the production scheduling feedback module 5. The quality analysis module has permission to read blockchain data and periodically pulls newly added anomaly anchor records from the blockchain. Each anomaly anchor record includes complete evidence information for three smallest packaging units: the previous unit (denoted as Unit A), the anomaly unit (denoted as Unit B), and the next unit (denoted as Unit C). The information for each unit includes at least a contamination probability value, a production timestamp, a product batch identifier, and an equipment number (obtainable from the production context).

[0082] For each abnormal anchoring record, the quality analysis module performs the following analysis steps.

[0083] Step 1: Calculate the difference and its sign. The module calculates the difference in contamination probability between unit B and unit A, denoted as ΔBA = P_B - P_A. Simultaneously, it calculates the difference in contamination probability between unit C and unit B, denoted as ΔCB = P_C - P_B. Record the signs of the two differences. Contamination probability values ​​are typically between 0 and 1, while the difference ranges from -1 to 1.

[0084] Step 2: Classify patterns based on the sign and absolute value of the difference. The module presets three thresholds: the first threshold is used to determine whether a single-step change is significant, with a typical value of 0.1; the second threshold is used to determine whether a decrease is significant, with a typical value of 0.08; and the third threshold is used to determine whether continuous changes in the same direction are significant, with a typical value of 0.1. These thresholds can be adjusted according to the stability of the production line, or automatically updated during operation based on the statistical distribution of historical data.

[0085] The first mode: Transient spike-type anomaly. The criteria are: ΔBA is positive and its absolute value exceeds the first threshold, while ΔCB is negative and its absolute value exceeds the second threshold. The waveform characteristic of this mode is: the contamination probability suddenly increases, forming a spike, and then quickly drops back to near its original level. This spike is usually not caused by physical contamination, because actual residue detachment cannot be completely removed in a very short time. It is more likely a false signal caused by electromagnetic interference, electrostatic discharge, or transient failures in the data acquisition system. Therefore, the quality analysis module marks such events as "suspected sensor noise or electrical interference events."

[0086] The second mode: Step-like escalation anomaly. The criteria are: ΔBA is positive and its absolute value exceeds the first threshold, while ΔCB is also positive and its absolute value exceeds the third threshold. The waveform characteristic of this mode is that the contamination probability increases but does not decrease; instead, it remains at a high level, forming a new step. This corresponds to real physical changes: the shedding of residue in chunks releases a large amount of contaminants, leading to a persistently high contamination probability in subsequent products; or the cleaning operation is suddenly interrupted (e.g., a drop in water pressure, accidental valve closure), preventing the residue from being flushed away and causing an overall increase in contamination levels. Therefore, the module marks such events as "suspected residue chunk shedding or cleaning interruption event".

[0087] The third mode: Step-like drop anomaly. The criteria are: ΔBA is negative and its absolute value exceeds the first threshold, while ΔCB is also negative and its absolute value exceeds the third threshold. The waveform characteristic of this mode is: the contamination probability suddenly decreases and remains at a low level. This usually means a sudden increase in cleaning intensity (e.g., the operator activated high-pressure cleaning mode), or a zero-point drift of the sensor. Therefore, the module marks such events as "suspected cleaning intensity mutation or sensor drift event".

[0088] If none of the above three patterns match, for example, ΔBA is positive while ΔCB is close to zero, then it is marked as "unclassified anomaly" and left for manual analysis.

[0089] Step 3: Generate a quality analysis report and upload it to the blockchain. For each anomaly anchoring record, the quality analysis module associates the judgment result (event type) with the hash value of the anomaly anchoring record to generate a quality analysis record. This record includes at least: the hash value of the anomaly anchoring record (as a foreign key), the judged event type, the judgment timestamp, the involved device number, and the involved product combination. The quality analysis module packages these records into transactions and submits them to the blockchain for notarization. The advantage of this is that subsequent quality management personnel or algorithms can directly query the already categorized anomaly events on the blockchain without re-analyzing the original data; at the same time, the analysis results themselves are tamper-proof, facilitating auditing.

[0090] Step 4: Cumulative Statistics and Early Warning. The quality analysis module continuously accumulates the count of abnormal events for the same equipment or product combination in the background. For example, it maintains a sliding time window (e.g., the past 24 hours) to count the number of "residue block detachment or cleaning interruption events" that occurred on a certain mixing tank. If the number exceeds a preset threshold (e.g., more than 3 times in 24 hours), a maintenance alarm is triggered, prompting the equipment engineer to check whether there is severe residue buildup or wear on the internal surface of the equipment. If the same product combination frequently experiences "step-like increase anomalies," it may indicate that the formulation of that product has high viscosity, requiring adjustment of cleaning parameters or optimization of the production sequence. If the same equipment frequently experiences "instantaneous spike-type anomalies," it indicates that the electrical connection of the sensor may be loose, requiring inspection of the wiring or replacement of the sensor. Alarm information can be sent to relevant personnel via SMS, email, or production dashboard. Simultaneously, for anomalies caused by operational errors (e.g., cleaning interruptions), the system can automatically generate operation training prompts, recommending retraining for the operators on duty.

[0091] In a preferred embodiment, the pollution calculation module 2 is further configured to: While using Kalman filtering to filter the concentration data of residues on the device surface, the original sampled value sequence is preserved, and the presence of isolated pulses in the sequence is detected in real time. If the isolated pulse exists, and the isolated pulse is verified by a dual verification mechanism of cross-verification by multiple source sensors and matching of the characteristic waveform of the subsequent pulse, then it is determined that a blocky shedding event has occurred during the production change cleaning process. If a blocky shedding event occurs during the production change and cleaning process, the original dynamic contamination time interval will be revised.

[0092] Furthermore, the dual verification mechanism includes: Multi-source sensor cross-validation: Compare the raw concentration data collected at the same time by at least two sensors with different physical principles. When the raw data of the two sensors both show pulses exceeding a preset multiple of their respective filter values ​​within the same preset time window, it is determined that the multi-source sensor cross-validation has been passed. The two sensors with different physical principles include the concentration detection module 1 and a redundant sensor installed in a different position. Post-pulse characteristic waveform matching: Analyze the original concentration data within a preset continuous time window after the occurrence of an isolated pulse, and detect whether there is a characteristic waveform that first drops sharply and then slowly recovers; when the characteristic waveform is detected, it is determined that the post-pulse characteristic waveform matching is passed. The pollution calculation module 2 only determines that a block shedding event has occurred when both the cross-validation of the multi-source sensors and the matching of the post-pulse characteristic waveforms are passed.

[0093] Specifically, this embodiment further defines the detection and judgment method of the blocky shedding event occurring during the product changeover cleaning process by the contamination calculation module 2. Kalman filtering treats all high-frequency changes as noise, including concentration pulses caused by real physical events. One important type of real event is the blocky shedding of residue: dry or semi-dry dough residue adhering to equipment surfaces (such as the inner wall of the mixing tank, conveyor belt seams, and mold corners) suddenly detaches as a whole under the scouring of the cleaning water flow, forming an instantaneous high-concentration pulse. If this pulse is filtered out as noise by the filtering algorithm, the system will not see this detachment, thus incorrectly marking the contaminated product after detachment as a clean product, resulting in a missed detection. This embodiment solves the problem of distinguishing between real detachment and sensor noise by retaining the original sampled values ​​and designing a dual verification mechanism.

[0094] The specific implementation is as follows. Pollution calculation module 2 filters the concentration data using Kalman filtering while forcibly retaining the original sampled value sequence, without discarding any original data. The module scans the original sampled value sequence in real time to detect the presence of isolated pulses. An isolated pulse is defined as: the original concentration value of a sampling point is significantly higher than the concentration values ​​of multiple sampling points before and after it, exhibiting a "single-peak" pattern. A sliding window detection method can be used: for each sampling point, five points are taken (two before and two after it), and the average and standard deviation of these five points are calculated. If the original concentration value of the current sampling point exceeds the average plus three times the standard deviation, it is marked as a candidate isolated pulse. This statistical method is adaptable to different batch concentration levels and does not require manually setting an absolute threshold.

[0095] Candidate isolated pulses could be genuine block detachments, or they could be sensor noise, electrical interference, or vibration shocks. To distinguish between these two cases, the module initiates a dual verification mechanism. Dual verification includes two steps: cross-verification from multiple sensor sources and matching of post-pulse characteristic waveforms. Both steps must pass simultaneously to determine if it is a genuine block detachment.

[0096] The first layer of verification is cross-validation using multiple sensors. This system installs at least two sensors based on different physical principles at key locations on the production line. In addition to a near-infrared spectroscopy sensor, a fluorescent tracer detector is also installed. The fluorescent tracer is a non-toxic, edible fluorescent substance pre-added to the first-variety dough; its concentration in the washing residue can be measured by the fluorescence intensity under ultraviolet light excitation. Near-infrared spectroscopy and fluorescence detection are based on completely different physical principles, and the probability of the same pulse occurring simultaneously is extremely low. When a candidate isolated pulse is detected, the module queries the raw data from the other sensor at the same time. If both sensors detect pulses exceeding a preset multiple of their respective filter values ​​(e.g., exceeding twice the filter value) within the same preset time window (e.g., 0.5 seconds before and after the pulse sampling point), the first layer of verification is passed. This is because real blocky shedding will be detected by both sensors simultaneously, and the electronic noise of one sensor will not affect the other.

[0097] The second verification is the matching of the characteristic waveform after the pulse. After a real block detachment event occurs, the concentration curve will exhibit a specific physical characteristic waveform: a sharp drop followed by a slow recovery. The sharp drop is due to the large amount of residue carried away by the detachment, causing a rapid reduction in the amount of residue on the equipment surface; the slow recovery is due to the slow release of residue deeply adsorbed on the equipment surface under the subsequent water flow, resulting in a slight rebound in concentration. This "sharp drop followed by recovery" waveform is the unique fingerprint of a real detachment, a feature that noise pulses do not possess. After a candidate isolated pulse occurs, the module continues to collect raw concentration data within a subsequent preset continuous time window (e.g., five seconds after the pulse) and analyzes its trend. Specifically, the ratio of the concentration value of the first sampling point after the pulse point to the concentration value of the last sampling point before the pulse point is calculated. If it is less than 0.5 (i.e., the sharp drop exceeds half), the sharp drop condition is met; then, the ratio of the average concentration from the third to the fifth second after the pulse point to the concentration in the first second after the pulse point is calculated. If it is greater than 1.2 (i.e., there is some recovery), the recovery condition is met. When both the sudden drop condition and the recovery condition are met, the second verification is deemed successful.

[0098] Only when both the first and second verifications pass will the contamination calculation module 2 determine that a real block detachment event has occurred during the production changeover cleaning process. If either verification fails, the candidate isolated pulse is marked as sensor noise and no subsequent operation is triggered.

[0099] The technical principle of this solution lies in using dual-sensor cross-validation to eliminate misjudgments caused by noise from a single sensor, and using post-pulse characteristic waveform matching to distinguish between real detachment and random interference. The two validation methods are based on different physical principles and temporal characteristics, and their combined use results in an extremely low misjudgment rate. The technical effect is that the accuracy rate for identifying real block detachment events reaches over 99%, while the incidence of noise misjudged as detachment events is controlled to below one in a thousand. This enables the system to accurately identify and record every real residue detachment, providing a reliable basis for subsequent contamination range correction and production scheduling feedback, and avoiding food safety risks caused by underreporting or unnecessary operations caused by false alarms.

[0100] In a preferred embodiment, the pollution calculation module 2 is further configured to: Mark the sampling time corresponding to the isolated pulse that triggers the verification as the dropout time; For consecutive products that are after the detachment time and outside the original dynamic contamination time interval, the contamination probability value is recalculated according to the ratio of the original concentration value of the isolated pulse to the preset safety threshold, and the original dynamic contamination time interval is extended to include these products. The newly added product information within the extended dynamic pollution time interval is synchronized to the evidence storage module 4, and the evidence storage module 4 generates supplementary evidence storage records and uploads them to the blockchain.

[0101] Specifically, when the contamination calculation module 2 determines that a real block detachment event has occurred based on the dual verification mechanism, the module first locates the sampling time corresponding to the isolated pulse that triggered the verification and marks this time as the detachment time. The detachment time usually corresponds to the time when a bag of products is being produced. The module needs to determine which smallest packaging unit specifically corresponds to this detachment time. Since the production line's off-line time for each product is known, the module finds the smallest packaging unit whose off-line time is closest to the detachment time through time comparison and records it as the detachment unit.

[0102] Next, the module needs to determine the original dynamic contamination time interval. This interval is calculated by the contamination calculation module 2 based on the concentration decay curve, starting from the moment the second product begins production and ending when the residue concentration decays to a preset safety threshold. Because the Kalman filter may have smoothed out the pulses when clumps detach, causing the system to mistakenly believe the concentration is below the safety threshold, the end point of the original dynamic contamination time interval may be earlier than the detachment moment. In reality, for a period after the detachment moment, the concentration will rise again and exceed the safety threshold due to the large amount of residue released by the detachment event itself, thus extending the contamination zone.

[0103] The module performs an interval expansion operation. The specific steps are as follows: Starting from the shedding moment, it continues to monitor subsequent concentration data (including filtered and original values). Since the shedding event has already occurred, the subsequent concentration curve will exhibit a characteristic of a sharp drop followed by a slow recovery. The module needs to find the moment when the concentration decays again below the safe threshold. Because the concentration decay after shedding still follows an exponential law, the module uses the concentration at the shedding moment as the initial value, refits the decay curve, and calculates the time required for the concentration to drop to the safe threshold. The interval between this time point and the shedding moment is the expansion segment. The module extends the original dynamic pollution time interval from the original termination point to the newly calculated termination point, forming the corrected dynamic pollution time interval.

[0104] For continuous products included within the extended segment, the module recalculates the contamination probability value. It's important to note that the detachment unit corresponding to the detachment time is already within the original contamination range (because the detachment time occurs within or near the boundary of the contamination range) and does not require reprocessing. New products within the extended segment refer to those produced after the original range's termination point but before the corrected range's termination point. For these products, the module uses the pulse concentration value at the detachment time as input, combined with the subsequent decay curve, to calculate the contamination probability value for each product. Due to the high concentration of contamination caused by the detachment event, these products typically have a high contamination probability value and need to be correctly labeled.

[0105] Finally, the module synchronizes the newly added product information within the expanded dynamic contamination time interval to the evidence storage module 4. Upon receiving this information, the evidence storage module 4 generates a supplementary evidence record for each newly added minimum packaging unit. The format of the supplementary evidence record includes a production timestamp, the associated first and second batch identifiers, and a recalculated contamination probability value. In addition, the supplementary record includes an extra field indicating that it was generated due to a block detachment event, and includes a summary of the detachment time and the verified result. These supplementary records are submitted to the blockchain in the form of blockchain transactions and stored alongside the original evidence records, together forming a complete contamination traceability archive.

[0106] The technical principle of this solution lies in identifying actual block-like detachment events, reintroducing key physical events that were incorrectly smoothed out by the filtering algorithm into the contaminated area, and supplementing the evidence records of the contaminated products. The technical effect is to avoid underreporting of contamination caused by filtering, ensuring that detached segments that would otherwise be incorrectly marked as clean products are correctly marked as contaminated products, thus guaranteeing the integrity of the recall decision. In actual production, although block-like detachment events are infrequent (occurring approximately once every ten to twenty production changes), once they occur, their impact can reach dozens of products. Without this correction mechanism, these products would completely escape the traceability system, and if upstream products experience safety issues, these contaminated products would enter the market, causing food safety incidents. Through this mechanism, the contamination records of these products are completed, allowing for precise location during recalls and eliminating this hidden safety hazard. Simultaneously, the detachment event information in the supplementary evidence records can also be used for equipment maintenance analysis, helping to identify which equipment parts are prone to residue buildup, thereby optimizing cleaning procedures and equipment design.

[0107] In a preferred embodiment, the blockchain is further deployed with an aggregated index smart contract, which maintains a key-value pair mapping table. The key of the mapping table is a variety combination identifier, and the value is a statistical summary of the contamination probability values ​​of all historical evidence records under that combination. The statistical summary includes: the total number of records, the sum of contamination probability values, the sum of squares of contamination probability values, and the most recent update timestamp. The aggregated index smart contract is configured such that whenever the evidence storage module 4 uploads a new evidence storage record to the chain, the aggregated index smart contract is automatically triggered to execute. The corresponding key is located according to the first variety batch identifier and the second variety batch identifier in the record, and the statistical summary corresponding to the key is atomically updated. The atomic update includes: incrementing the record number by 1, accumulating the contamination probability value, accumulating the sum of squares of the contamination probability value, and updating the most recent update timestamp to the current time.

[0108] Specifically, the evidence storage module 4 generates an independent blockchain evidence storage record for each smallest packaging unit. The production scheduling feedback module 5 needs to read the contamination probability values ​​from these records to calculate the historical average contamination probability. As production continues, the number of evidence storage records grows rapidly. In traditional solutions, whenever the production scheduling feedback module 5 needs to calculate the historical average contamination probability of a certain product combination, it must traverse all relevant evidence storage records on the blockchain, parsing and accumulating each one. When the number of evidence storage records reaches hundreds of thousands or even millions, this traversal query can take several seconds or even tens of seconds, which cannot meet the real-time requirements of short-shelf-life food production scheduling. This implementation solves the problem of low efficiency in historical data query by deploying an aggregated index smart contract on the blockchain and incrementally updating the statistical summary while the evidence storage records are on the chain.

[0109] The specific implementation is as follows. First, a clustered index smart contract is deployed on the blockchain. This smart contract is independent of the evidence storage module 4, but the two are linked through blockchain transactions. The clustered index smart contract internally maintains a key-value pair mapping table, which is stored in the smart contract's persistent storage area and has the same immutability as blockchain data. The key of the mapping table is the variety combination identifier, which is formed by concatenating the first variety batch identifier and the second variety batch identifier in a fixed order. For example, connecting the ID of the first variety and the ID of the second variety with an underscore is denoted as "Variety A_Variety B". It is important to note that the variety combination has an order; "Variety A_Variety B" indicates that A was produced before B, and it is a different key from "Variety B_Variety A".

[0110] The mapping table's value is a statistical summary structure containing four fields: the first field is the total number of records, representing the number of on-chain records for this product combination; the second field is the sum of contamination probability values, representing the cumulative sum of contamination probability values ​​across all records; the third field is the sum of squared contamination probability values, representing the cumulative sum of squared contamination probability values ​​across all records; and the fourth field is the most recent update timestamp, indicating the time of the last update to this summary. The total number of records, the sum of probabilities, and the sum of squares are sufficient to calculate commonly used statistics such as the average, variance, and standard deviation of historical contamination probabilities for this product combination. For example, the historical average contamination probability value equals the sum of probabilities divided by the total number of records; the historical variance equals (sum of squares divided by the total number of records) minus the square of the average. These statistics can be directly used for risk cost calculation in production scheduling feedback module 5.

[0111] The aggregated index smart contract is configured with a trigger. Whenever the evidence storage module 4 successfully uploads a new evidence storage record to the chain (i.e., the record is packaged into a block and confirmed by consensus), the blockchain network automatically calls the update interface of the smart contract. The triggering method can employ the blockchain's event listening mechanism: the evidence storage module 4 attaches an event to the transaction submitting the evidence storage record. This event contains the new record's commodity combination identifier and contamination probability value. The aggregated index smart contract subscribes to this event, and once the event is triggered, the smart contract immediately executes the update logic. The update logic includes the following steps: First, based on the commodity combination identifier in the event, search for the corresponding statistical summary in the mapping table; if the key does not exist (i.e., the commodity combination is encountered for the first time), create a new statistical summary structure and initialize all fields to zero. Second, atomically update the summary: increment the total number of records by one, accumulate the contamination probability value to the probability sum field, accumulate the square of the contamination probability value to the square sum field, and update the most recent update timestamp to the timestamp of the current block. Atomicity means that these four update operations either all succeed or all fail, without any intermediate state of partial updates. The atomicity of smart contracts is guaranteed by the blockchain's transaction mechanism: if any error occurs during the update process (such as insufficient storage space), the entire transaction will be rolled back, and the summary will be restored to the state before the update.

[0112] The aggregated index smart contract also provides a query interface for the production scheduling feedback module 5 or other authorized modules to call. The parameter of the query interface is the variety combination identifier, and it returns the corresponding statistical summary structure. Since the mapping table is a key-value pair structure, the time complexity of the query operation is O(1), that is, no matter how large the amount of historical data is, the query time is constant, usually within milliseconds.

[0113] The technical principle of this solution lies in shifting aggregation calculations from query time to on-chain time. Utilizing the automatic triggering mechanism of smart contracts, the statistical summary is incrementally updated simultaneously with the generation of each new record. Queries directly read the pre-calculated results, avoiding the overhead of repetitive calculations that traverse all historical data for each query. The technical effect is that the query response time for the historical average contamination probability value is reduced from tens of seconds to milliseconds, meeting the rigid real-time requirements of short-shelf-life food production scheduling decisions. Simultaneously, because the statistical summary is stored on the blockchain, it possesses the same immutability as the original evidence records, eliminating concerns about data tampering or inaccurate statistical results for the production scheduling feedback module 5. Furthermore, the storage of the sum of squares allows the system to calculate variance and standard deviation, providing richer statistical information for probabilistic risk cost modeling; for example, the risk aversion coefficient can be adjusted based on the volatility of historical data.

[0114] In a preferred embodiment, the production scheduling feedback module 5 is configured to: When it is necessary to calculate the cross-contamination risk cost, the query interface of the aggregated index smart contract is directly called, the target variety combination identifier is passed in, the corresponding statistical summary is read from the key-value pair mapping table, and the historical average contamination probability value of the variety combination is calculated based on the sum of the contamination probability values ​​in the statistical summary and the total number of records. The historical average contamination probability value is used as the weighting coefficient of the cross-contamination risk cost in the production scheduling optimization objective function.

[0115] Specifically, before performing production scheduling optimization, the production scheduling feedback module 5 needs to obtain the historical average contamination probability value for each pair of varieties. These values ​​will be used to calculate the expected contamination probability in the cross-contamination risk cost. The module first obtains a list of varieties to be scheduled for production, assuming there are m varieties in total. For any two varieties X and Y in the list (X is produced before Y), the module needs to calculate the historical average contamination probability value from X to Y.

[0116] The module calls the query interface of the aggregated index smart contract, passing in the variety combination identifier "X_Y". The query interface returns a statistical summary corresponding to the combination, including the total number of records N and the sum of contamination probability values ​​S. If the total number of records N is greater than zero, the historical average contamination probability value P_avg is equal to S divided by N. If the total number of records N is equal to zero, it means that the combination X to Y has never been produced historically, and the module cannot obtain the average value from historical data. In this case, the module can use a default value or an interpolation method based on similar varieties. For example, it can query the historical average value of X to a variety Z that is similar to Y, or use the global average value of all variety combinations. In this embodiment, a conservative strategy is adopted: when there is no historical data, P_avg is set to a high default value (e.g., 0.5) to encourage the production scheduling algorithm to treat the unfamiliar combination cautiously and avoid underestimating the risk due to missing data.

[0117] After obtaining the historical average contamination probability value P_avg, the production scheduling feedback module 5 uses it as a weighting coefficient for the cross-contamination risk cost. Specifically, in the previously described cross-contamination risk cost calculation formula, it was originally necessary to calculate based on the actual contamination probability value of this production change, but since production has not yet commenced at the time of scheduling, the actual value cannot be obtained. This implementation uses the historical average value as an estimate of the actual value. That is, for a production change from product X to product Y, the cross-contamination risk cost R(X→Y) equals P_avg multiplied by the expected quantity of products within the contamination zone and then multiplied by the unit recall cost. The expected quantity of products within the contamination zone can be obtained based on the historical average contamination zone length or the cleaning strategy model. Using P_avg as a weighting coefficient means that product combinations with more severe historical contamination are assigned a higher risk cost during production scheduling, and the algorithm will tend to avoid arranging them adjacently or forcibly inserting them into deep cleaning.

[0118] Furthermore, the production scheduling feedback module 5 can also calculate the variance or standard deviation using the sum of squares field in the statistical summary. If the historical contamination probability variance of a certain product combination is large, it indicates that the contamination level of the combination is unstable, sometimes very low and sometimes very high. For such highly volatile combinations, risk-averse companies can adopt a more conservative estimate, such as using the average plus one standard deviation as a substitute for P_avg, which makes the risk cost higher and the production scheduling plan more cautious. In this embodiment, the module allows companies to configure risk coefficients; when the risk coefficient is neutral, the average is used, and when the risk coefficient is conservative, the average plus the standard deviation is used.

[0119] After calculating the historical average contamination probability values ​​for all possible variety combinations, the production scheduling feedback module 5 fills these values ​​into an m x m matrix, where the i-th row and j-th column of the matrix represents the average contamination probability from variety i to variety j. This matrix is ​​passed as input parameters to the production scheduling algorithm (e.g., mixed-integer linear programming or dynamic programming). When calculating the overall cost, the production scheduling algorithm reads the weighting coefficients of the corresponding combinations from the matrix, multiplies them by the corresponding expected contamination band length and recall cost, and obtains the risk cost term. Finally, it outputs the optimal variety order and cleaning strategy.

[0120] After each actual production cycle, a new record is uploaded to the blockchain, and the aggregated index smart contract automatically updates the statistical summary. Therefore, the P_avg queried by the production scheduling feedback module 5 each time it executes production scheduling is the latest historical average value up to the current moment, reflecting the latest production status. For example, if the probability of contamination during recent production changes from X to Y has significantly increased, P_avg will increase accordingly, and subsequent production scheduling will automatically increase the risk weight of this combination, achieving continuous self-optimization.

[0121] The above description is merely a preferred embodiment of this application and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of the invention involved in this application is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the inventive concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features with similar functions disclosed in this application.

Claims

1. A blockchain management system for intelligent production scheduling and dynamic traceability of short-shelf-life foods, characterized in that, include: Concentration detection module (1) is configured to collect the concentration data of residues on the surface of equipment in real time during the production change cleaning process after the production line switches from the first product to the second product; Pollution calculation module (2) is configured to calculate the dynamic pollution time interval based on the change of the concentration data over time. The dynamic pollution time interval starts at the moment when the second product begins production and ends at the moment when the concentration data of the residue on the equipment surface decays to a preset safety threshold. The segmentation module (3) is configured to divide the continuous product stream produced within the dynamic contamination time interval into mixed contamination micro-batches; The evidence storage module (4) is configured to generate an independent blockchain evidence storage record for each smallest packaging unit in the mixed contamination micro-batch. Each record includes the production timestamp of the smallest packaging unit, the associated first variety batch identifier and second variety batch identifier, and the contamination probability value calculated based on the concentration data of the residue on the equipment surface. The production scheduling feedback module (5) is connected to the evidence storage module (4) and is configured to read the contamination probability value and quantify it as cross-contamination risk cost. The cross-contamination risk cost is a weighted term of the production scheduling optimization objective function and together with the production time cost constitutes the comprehensive cost. The production scheduling algorithm aims to minimize the comprehensive cost and outputs the product production sequence and cleaning strategy.

2. The intelligent production scheduling and dynamic traceability blockchain management system for short-shelf-life foods according to claim 1, characterized in that, The preset safety threshold is dynamically generated by a smart contract on the blockchain based on the comparison results of the allergen list of the second product and the allergens contained in the first product. When the second product does not contain any of the allergens contained in the first product, the smart contract sets the preset safety threshold to a zero-tolerance value lower than the specified detection limit; When the second product contains at least one allergen contained in the first product, the smart contract relaxes the preset safety threshold to the maximum allowable residual amount of the allergen in the second product or the background content of the product itself.

3. The intelligent production scheduling and dynamic traceability blockchain management system for short-shelf-life foods according to claim 1, characterized in that, The production scheduling feedback module (5) is specifically configured for: The continuous time axis within the dynamic pollution time interval is discretized into equally spaced time segments, and each time segment corresponds to the production time of a minimum packaging unit. For each time segment, the Kalman filter algorithm is used to fuse multiple residual concentration samples within the segment to filter out instantaneous concentration fluctuations caused by sensor noise and equipment vibration, and obtain the filtered concentration value corresponding to the segment. Divide the filtered concentration value by the preset safety threshold and map it to the (0,1) interval using a logistic function to obtain the contamination probability value of the smallest packaging unit; The process noise covariance and measurement noise covariance of the Kalman filter algorithm are obtained offline by training based on historical production change data stored on the blockchain, and the parameters are read from the blockchain each time a production change occurs.

4. The intelligent production scheduling and dynamic traceability blockchain management system for short-shelf-life foods according to claim 1, characterized in that, The production scheduling feedback module (5) is also configured to: When the production plan includes three or more varieties that are scheduled for production consecutively, the dynamic programming algorithm is used to calculate the total cost of chain cross-contamination risk under any candidate variety arrangement order. The total cost of chain cross-contamination risk is defined as follows: In the formula, n is the total number of product types to be sorted, and s k and s j L(s) represents the k-th and j-th varieties in the permutation order, respectively. k ,s j ) for variety s k For variety s j The direct pollution risk cost, w j k The attenuation weighting coefficient is w. d+1 =α w d , where 0 < α < 1; The attenuation weighting coefficient is used to characterize that the ability of the residue of the first variety to contaminate subsequent varieties decreases exponentially after continuous production and multiple cleanings of multiple intermediate varieties. The production scheduling feedback module (5) aims to minimize the sum of the total cost of the chain cross-contamination risk and the production time cost, and outputs the optimal production sequence and corresponding cleaning strategies for each production change through dynamic programming.

5. The intelligent production scheduling and dynamic traceability blockchain management system for short-shelf-life foods according to claim 1, characterized in that, The evidence storage module (4) is also configured to: Arrange all the smallest packaging units within the mixed contamination micro-batch according to the production sequence, and calculate the contamination probability difference between adjacent units; When the difference in contamination probability between a minimum packaging unit and its preceding unit exceeds a preset change rate threshold, the evidence storage module (4) automatically triggers an abnormal anchoring, packaging the hash values ​​of the three evidence storage records of the unit and the preceding and following units onto the blockchain. When the difference in the contamination probability of all adjacent units does not exceed the threshold, the evidence storage module (4) only puts the evidence storage record hash values ​​of the starting and ending units of the entire mixed contamination micro-batch on the chain, and the intermediate units are only stored in the local database.

6. The intelligent production scheduling and dynamic traceability blockchain management system for short-shelf-life foods according to claim 1, characterized in that, The pollution calculation module (2) is also configured to: While using Kalman filtering to filter the concentration data of residues on the device surface, the original sampled value sequence is preserved, and the presence of isolated pulses in the sequence is detected in real time. If the isolated pulse exists, and the isolated pulse is verified by a dual verification mechanism of cross-verification by multiple source sensors and matching of the characteristic waveform of the subsequent pulse, then it is determined that a blocky shedding event has occurred during the production change cleaning process. If a blocky shedding event occurs during the production change and cleaning process, the original dynamic contamination time interval will be revised.

7. The intelligent production scheduling and dynamic traceability blockchain management system for short-shelf-life foods according to claim 6, characterized in that, The pollution calculation module (2) is also configured to: Mark the sampling time corresponding to the isolated pulse that triggers the verification as the dropout time; For consecutive products that are after the detachment time and outside the original dynamic contamination time interval, the contamination probability value is recalculated according to the ratio of the original concentration value of the isolated pulse to the preset safety threshold, and the original dynamic contamination time interval is extended to include these products. The newly added product information within the extended dynamic pollution time interval is synchronized to the evidence storage module (4), and the evidence storage module (4) generates supplementary evidence storage records and uploads them to the blockchain.

8. The intelligent production scheduling and dynamic traceability blockchain management system for short-shelf-life foods according to claim 6, characterized in that, The dual verification mechanism includes: Multi-source sensor cross-validation: Compare the raw concentration data collected at the same time by at least two sensors with different physical principles. When the raw data of the two sensors both show pulses exceeding a preset multiple of their respective filter values ​​within the same preset time window, it is determined that the multi-source sensor cross-validation has been passed. Among them, the two sensors with different physical principles include the concentration detection module (1) and a redundant sensor with a different installation position. Post-pulse characteristic waveform matching: Analyze the original concentration data within a preset continuous time window after the occurrence of an isolated pulse, and detect whether there is a characteristic waveform that first drops sharply and then slowly recovers; when the characteristic waveform is detected, it is determined that the post-pulse characteristic waveform matching is passed. The pollution calculation module (2) only determines that a block shedding event has occurred when both the cross-validation of the multi-source sensors and the matching of the post-pulse characteristic waveforms are passed.

9. The intelligent production scheduling and dynamic traceability blockchain management system for short-shelf-life foods according to claim 1, characterized in that, The blockchain also deploys an aggregated index smart contract, which maintains a key-value pair mapping table. The key of the mapping table is the variety combination identifier, and the value is a statistical summary of the contamination probability values ​​of all historical evidence records under that combination. The statistical summary includes: the total number of records, the sum of contamination probability values, the sum of squares of contamination probability values, and the most recent update timestamp. The aggregated index smart contract is configured as follows: whenever the evidence storage module (4) uploads a new evidence storage record to the chain, the aggregated index smart contract is automatically triggered to execute, locate the corresponding key according to the first variety batch identifier and the second variety batch identifier in the record, and atomically update the statistical summary corresponding to the key, wherein the atomic update includes: incrementing the record number by 1, accumulating the pollution probability value, accumulating the square sum of the pollution probability values, and updating the most recent update timestamp to the current time.

10. The intelligent production scheduling and dynamic traceability blockchain management system for short-shelf-life foods according to claim 9, characterized in that, The production scheduling feedback module (5) is configured to: When it is necessary to calculate the cross-contamination risk cost, the query interface of the aggregated index smart contract is directly called, the target variety combination identifier is passed in, the corresponding statistical summary is read from the key-value pair mapping table, and the historical average contamination probability value of the variety combination is calculated based on the sum of the contamination probability values ​​in the statistical summary and the total number of records. The historical average contamination probability value is used as the weighting coefficient of the cross-contamination risk cost in the production scheduling optimization objective function.