Beverage production whole process tracing method
The raw material usage ratio is represented by timestamp marking and edge weights, and combined with the graph database and time series database, a traceability chain diagram structure for beverage production is established, which solves the difficulty of correlation between raw materials and production data, realizes the traceability from finished products to raw materials, and improves the The efficiency and accuracy of beverage production traceability ensures data quality and product controllability.
Patent Information
- Application Number
- CN202410979398.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-22
- Publication Date
- 2024-12-24
AI Technical Summary
During the entire process of beverage production, it is difficult to integrate and correlate raw material traceability information and production data automatically, resulting in the inability to establish a complete traceability chain, and it is difficult to quickly locate specific raw materials and production batches when quality problems occur.
The node attribute data structure and edge weight marked with timestamps represent the usage ratio of raw materials in different production batches, forming a correlation diagram of raw materials, and storing traceability data through the graph database and time series database, combining multiple linear regression and batch correlation Algorithm, establish a quality correlation scoring model and calculate the degree of influence of raw material batches on finished product quality.
It realizes step-by-step traceability from finished products to raw materials, improves the efficiency and accuracy of beverage production traceability, ensures data quality, builds an efficient full-link traceability query system, enhances the controllability of product quality and consumer trust Spend.
Smart Images

Figure CN119180661A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information technology, and in particular to a method for tracing the entire process of beverage production. Background Art
[0002] The whole process traceability system of beverage production faces the technical difficulties of raw material information integration and production data association. First, the raw material traceability information from different batches and origins needs to be merged, but it is difficult to achieve automatic integration due to differences in data format and structure. Secondly, there is a lack of effective association mechanism between the merged raw material traceability data and the processing parameters collected in real time during the production process, which makes it impossible to establish a complete traceability chain from raw materials to finished products. Specifically, raw material traceability information usually contains static data such as batch number, origin, and supplier, while parameters such as temperature, pressure, and flow in the production process are dynamically changing. How to associate and match these two types of heterogeneous data in real time while ensuring data integrity and accuracy is an urgent problem to be solved. In addition, when there are quality problems in the product, how to quickly locate the specific raw material batch and production batch, and filter out the key data related to the quality problem from the massive production parameters is also a major challenge faced by the system. The solution to these technical problems not only involves the optimization of data integration and association algorithms, but also needs to consider multiple aspects such as data storage, real-time processing, and query efficiency to achieve accurate traceability and rapid problem location throughout the beverage production process. Summary of the invention
[0003] The purpose of the present invention is to overcome the shortcomings of the processing efficiency of the prior art and provide a method for tracing the entire process of beverage production to achieve accurate tracing and rapid problem location in the entire process of beverage production.
[0004] A method for tracing the entire process of beverage production, the method comprising:
[0005] A node attribute data structure is established based on the batch number and production line number of the beverage raw materials. Timestamps are used to mark the time when the raw materials enter the warehouse and the start of production. Edge weights are used to represent the usage ratio of raw materials in different production batches, and a preliminary raw material-finished product association graph is obtained.
[0006] For the processing procedures, the dynamic parameters of temperature, pressure and flow are collected from the production line, and the collected data are divided into time windows and synchronized to obtain the production process data stream corresponding to the timestamp of the raw material batch. The time window is divided into a sliding window of fixed size, and the window size is determined according to the production cycle. Synchronization is achieved by aligning the timestamps of each parameter.
[0007] A graph database is used to store the association graph of beverage raw materials and finished products. The corresponding relationship between raw material batches and production batches is established through the processing process attributes of the edges between nodes, forming a complete traceability chain graph structure.
[0008] In view of the heterogeneous data in the traceability chain graph structure, a time series database is used to store dynamic production parameters, and a mapping relationship is established between raw material batches and production parameters of the corresponding time period through a time window algorithm;
[0009] Starting from the finished product batch node, trace back to the raw material batch node step by step through the edge attributes in the graph database, and extract the production parameters within the corresponding time window to obtain a preliminary traceability data set;
[0010] Analyze the quality indicators in the traceability data set, extract key parameters that are highly correlated with quality issues, and establish a quality correlation scoring model. The model uses a multiple linear regression method, with quality indicators as dependent variables and key parameters as independent variables, to calculate the weight of each parameter's impact on quality.
[0011] The batch correlation algorithm is used to calculate the impact of different raw material batches on the quality of the finished product, and to obtain the correlation strength between the raw material batch and the quality problem. The batch correlation algorithm is based on the path analysis in the graph structure and combines the edge weight to calculate the contribution of the raw material batch to the finished product.
[0012] According to the quality correlation scoring model and batch correlation algorithm results, the nodes in the traceability chain are ranked in importance, key nodes are screened out, and the optimal traceability path is determined. According to the traceability depth and key nodes, the production parameters of the corresponding time window are extracted from the time series database, combined with the raw material batch information, to generate a complete traceability data set;
[0013] The generated beverage traceability dataset is cleaned and standardized to remove outliers and redundant data to ensure data quality. Columnar storage technology is used to compress the processed traceability dataset, a distributed index is established to accelerate query, and cache pre-loaded key node data with high frequency access, to build an efficient full-link traceability query system.
[0014] Moreover, the node attribute data structure is established according to the beverage raw material batch number and production line number, the raw material storage and production start time are marked with timestamps, and the usage ratio of raw materials in different production batches is represented by edge weights to obtain a preliminary raw material-finished product association diagram, including:
[0015] Construct a node attribute data structure according to the batch number and production line number of the beverage raw material, wherein the node attribute data structure includes the raw material name, batch number, production line number, storage timestamp and production start timestamp;
[0016] Obtain usage ratio data of the raw materials in different production batches, represent the usage ratio of the raw materials by edge weights, connect the raw material nodes with the finished product nodes, and the edge attributes include usage ratio values and timestamp information;
[0017] A depth-first search algorithm is used to traverse the graph structure, starting from each raw material node, recursively traversing the edges and nodes connected to it, recording the node ID and edge weight on the traversal path, and if a finished product node is encountered, the complete path is stored in a result set;
[0018] According to the raw material-finished product association path, the proportion of each batch of raw materials in the final finished product is calculated, and for each of the association paths, the edge weight values are accumulated to obtain the total usage ratio of the raw materials in the finished product;
[0019] The ratio information is added to the attributes of the raw material node for quick query and analysis to form a complete raw material-finished product association diagram.
[0020] Moreover, for the processing procedure, the temperature, pressure and flow dynamic parameters are collected from the production line, and the collected data is divided into time windows and synchronized to obtain the production process data stream corresponding to the raw material batch timestamp. The time window division adopts a sliding window of fixed size, and the window size is determined according to the production cycle. The synchronization is achieved by aligning the timestamps of each parameter, including:
[0021] Acquire dynamic parameters such as temperature, pressure and flow of the production line, with the acquisition frequency of the dynamic parameters being once per second;
[0022] The dynamic parameter is divided into time windows using a sliding window, the window size of the sliding window is 10 minutes, and the sliding step length of the sliding window is 1 minute;
[0023] Aligning the timestamps of the dynamic parameters and combining them into a vector within the time window, wherein the vector includes a temperature value, a pressure value, a flow value and a timestamp;
[0024] Matching the vector with a raw material batch timestamp, wherein the raw material batch timestamp includes a batch start timestamp and a batch end timestamp;
[0025] A mapping table is established, wherein the key of the mapping table is the raw material batch number, the value of the mapping table is a vector list corresponding to the raw material batch number, and the vector list contains all vectors whose timestamps are between the raw material batch start timestamp and the batch end timestamp.
[0026] Moreover, the graph database is used to store the beverage raw material finished product association graph, and the corresponding relationship between the raw material batch and the production batch is established through the processing procedure attributes of the edges between the nodes, forming a complete traceability chain graph structure, including:
[0027] Constructing the graph database nodes, wherein the node attributes include information such as the name, batch number and production date of the raw material or finished product, and different nodes are distinguished by unique identifiers;
[0028] Defining edge types in the graph database, wherein the edge attributes include information such as a processing procedure name, processing time, and processing parameters, and are used to represent a processing relationship between a raw material node and a finished product node;
[0029] Sort the edges between adjacent nodes by time. If a node has multiple input edges, the raw material batches corresponding to these edges together constitute the production batch of the intermediate product or finished product represented by the node;
[0030] Using the depth-first search algorithm, starting from each raw material node, recursively traverse the edges and nodes connected to it, and record all node IDs and edge attributes on the current path during the traversal process;
[0031] When a finished product node is encountered, the complete path is stored in the result set, and all possible paths are explored by backtracking to obtain a complete traceability chain;
[0032] Use Cypher query language to implement fast association query between raw material batches and production batches, and write query statements such as MATCH(raw material: RawMaterial)-[r:PROCESSED_TO*]->(finished product: Product) WHERE raw material.batch number = the batch number RETURN raw material, r, finished product, return the complete path from a specific raw material batch to all related finished products, and output the complete traceability chain graph structure including all intermediate processing steps.
[0033] Moreover, for the heterogeneous data in the traceability chain graph structure, a time series database is used to store dynamic production parameters, and a mapping relationship is established between raw material batches and production parameters of corresponding time periods through a time window algorithm, including:
[0034] Acquire heterogeneous data from the traceability chain graph structure, wherein the heterogeneous data includes raw material batch information, production parameters and timestamp;
[0035] The heterogeneous data is standardized to obtain unified data in a format supported by a time series database, wherein non-numeric data is converted into metadata and stored in a relational database;
[0036] According to the production time of the raw material batches, the unified data is segmented using a sliding time window algorithm, where the window size of the sliding time window is the production cycle and the step length is a preset time interval;
[0037] Using the sliding time window algorithm, an association is established between the raw material batch and the dynamic parameter, and a batch-parameter mapping table is generated, wherein the batch-parameter mapping table includes the batch number, parameter type, time range and statistical value;
[0038] The dynamic parameter data corresponding to the batch number and time range are obtained through the query interface of the time series database, and the dynamic parameter data form a complete batch-parameter correspondence relationship.
[0039] Moreover, starting from the finished product batch node, the edge attributes in the graph database are traced back to the raw material batch node step by step, and the production parameters in the corresponding time window are extracted to obtain a preliminary traceability data set, including:
[0040] Locate the finished product node in the graph database according to the finished product batch number, and traverse the graph structure using a depth-first search algorithm to obtain all nodes on the traceability path;
[0041] For each node on the traceability path, extract the production parameters within the time window corresponding to the node from the time series database, where the time window is determined by the start time and end time of the node;
[0042] Using a data fusion algorithm to create a nested data structure, the nested data structure includes node attributes in the graph database and parameter statistics extracted from the time series database;
[0043] Using a batch association algorithm, starting from the finished product node, tracing back along the edge to the raw material node, and recording the weight of each edge on the path;
[0044] By multiplying the weights, the proportion of each raw material batch in the finished product is calculated, the corresponding relationship between the finished product batch and the raw material batch is determined, and a traceability data set containing complete production process and parameter information is obtained.
[0045] Furthermore, the quality indicators in the traceability data set are analyzed, key parameters highly correlated with quality issues are extracted, and a quality correlation scoring model is established. The model uses a multiple linear regression method, takes the quality indicators as dependent variables and the key parameters as independent variables, and calculates the influence weight of each parameter on the quality, including:
[0046] Acquire quality indicators and production parameters from a traceability data set, wherein the traceability data set contains outliers and missing values;
[0047] Perform data cleaning based on the acquired quality indicators and production parameters to obtain a preprocessed data set;
[0048] The Pearson correlation coefficient calculation method is used to analyze the correlation between the quality index and each production parameter in the pre-processed data set, and determine the key parameter set that is highly correlated with the quality index;
[0049] Calculating the variance inflation factor of each parameter in the key parameter set, and if the variance inflation factor of a parameter is greater than a preset threshold, removing the parameter from the key parameter set;
[0050] Constructing a multiple linear regression model based on the key parameter set, wherein the multiple linear regression model uses the quality index as a dependent variable and the key parameter as an independent variable;
[0051] The multivariate linear regression model is regressed stepwise using a forward selection method, wherein the forward selection method starts from an empty model and each time a variable that best improves the model fit is added;
[0052] The optimal parameter combination is selected according to the stepwise regression results to obtain a quality correlation scoring model.
[0053] Moreover, the batch correlation algorithm is used to calculate the influence of different raw material batches on the quality of the finished product, and obtain the correlation strength between the raw material batch and the quality problem. The batch correlation algorithm is based on the path analysis in the graph structure and combines the edge weight to calculate the contribution of the raw material batch to the finished product, including:
[0054] Receiving a traceability request message carrying a finished product batch node identifier, the traceability request message being sent by a quality control system;
[0055] According to the traceability request information, a depth-first search algorithm is used to trace back from the finished product batch node to the raw material batch node, and all possible traceability paths are recorded, wherein the traceability path includes a node sequence and a corresponding edge weight;
[0056] Obtain the traceability paths, process all paths simultaneously using a parallel computing method, and distribute the traceability paths to different processing units for calculation;
[0057] For each of the traceability paths, the path weight is calculated by multiplying the edge weights, and the path weight is equal to the product of all edge weights on the path;
[0058] For each raw material batch, obtain the weights of all paths including the batch, and use the weighted sum method to calculate the overall contribution of the raw material batch to the finished product, where the overall contribution is equal to the weighted sum of the path weight multiplied by the reciprocal of the path length divided by the sum of the reciprocals of the path lengths;
[0059] According to the finished product quality score and the raw material batch contribution, the Pearson correlation coefficient is used to calculate the correlation strength between the raw material batch and the quality problem. The correlation strength value range is between negative one and one. The larger the absolute value of the correlation strength is, the stronger the correlation is.
[0060] The higher the association strength value is, the greater the impact of the raw material batch on the quality problem is.
[0061] Moreover, according to the quality correlation scoring model and the batch correlation algorithm results, the nodes in the traceability chain are ranked in importance, the key nodes are screened out, the optimal traceability path is determined, and the production parameters of the corresponding time window are extracted from the time series database according to the traceability depth and key nodes. Combined with the raw material batch information, a complete traceability data set is generated, including:
[0062] Calculate the comprehensive importance score of the node, where the comprehensive importance score is equal to 0.6 multiplied by the quality impact score plus 0.4 multiplied by the node contribution;
[0063] Filtering nodes with a value higher than a preset threshold as key nodes according to the comprehensive importance score;
[0064] The Dijkstra algorithm is used to set the key nodes as necessary points, and the shortest paths from the raw material batch to the first key node, between key nodes, and from the last key node to the finished product batch are calculated to obtain the optimal traceability path;
[0065] Extracting production parameter data within the time window corresponding to the key node from a time series database, wherein the production parameter data includes time series data of key indicators such as temperature, pressure and flow rate;
[0066] A multi-source heterogeneous data fusion method is used to integrate node attributes, edge attributes, timing parameters and batch information into a unified probability model. If the formats of the node attributes, edge attributes, timing parameters and batch information are inconsistent, the data from different sources are unified in format and then integrated to obtain a traceability data set containing complete information.
[0067] In addition, the generated beverage traceability data set is cleaned and standardized to remove outliers and redundant data to ensure data quality. Column storage technology is used to compress the processed traceability data set, a distributed index is established to accelerate query, and high-frequency access key node data is cached and preloaded to build an efficient full-link traceability query system, including:
[0068] Obtain a beverage traceability data set, and calculate a standard deviation based on the data set;
[0069] If a data point deviates from the mean by more than three standard deviations, it is considered an outlier and removed;
[0070] Standardizing the cleaned data set, calculating the covariance matrix and solving the eigenvalues and eigenvectors;
[0071] Selecting a principal component whose cumulative contribution rate reaches a preset threshold, and reconstructing the data set through the principal component;
[0072] The reconstructed traceability data set is stored in columnar format using Apache Parquet, and corresponding compression algorithms are used for different data types.
[0073] The compression algorithm includes: using dictionary encoding for integer data, using delta encoding for floating point data, and using prefix compression for string data;
[0074] Constructing a distributed index structure, and sharding the compressed data to multiple nodes through a consistent hashing algorithm;
[0075] Use B+ trees to build local indexes in each node, and use distributed B+ trees for cross-node queries;
[0076] Design a RESTful API interface that supports multi-dimensional queries such as batch number, time range, and product type;
[0077] The GraphQL query language is used to allow the client to specify the specific fields required and obtain the corresponding traceability data from the distributed index structure.
[0078] The advantages and beneficial effects of the present invention are:
[0079] 1. The whole process traceability method of beverage production of the present invention has established a set of detailed data structures and processing procedures for the traceability problem between raw materials and finished products in the beverage production process. In the present invention, a node attribute data structure is first established according to the batch number of the beverage raw material and the production line number, and a timestamp is used to mark the raw material storage and production start time. The usage ratio of raw materials in different production batches is represented by edge weights, and a raw material-finished product association graph is preliminarily established. For this business scenario, the present invention stores the raw material-finished product association graph through a graph database, effectively forming a complete traceability chain graph structure, so that starting from the finished product batch node, it can be traced back to the raw material batch node step by step.
[0080] In order to collect dynamic parameters such as temperature, pressure, and flow rate in the processing process, the present invention collects these dynamic parameters from the production line, and divides and synchronizes the collected data into time windows through a fixed-size sliding window to ensure that the timestamp of the data corresponds to the timestamp of the raw material batch, thereby obtaining a production process data stream corresponding to the raw material batch. This process not only improves the real-time and accuracy of data collection, but also lays the foundation for subsequent data analysis.
[0081] 2. The beverage production whole process traceability method of the present invention uses a time series database to store dynamic production parameters, and establishes a mapping relationship between raw material batches and production parameters of corresponding time periods through a time window algorithm, thereby enhancing the relevance and traceability of the data. By analyzing the association between quality indicators and production parameters in the traceability data set, the present invention establishes a quality correlation scoring model, and uses a multivariate linear regression method to calculate the weight of the impact of each parameter on the quality. In addition, the present invention also uses a batch correlation algorithm to calculate the degree of impact of different raw material batches on the quality of the finished product, further enhancing the analysis depth of the traceability data.
[0082] 3. The beverage production whole process traceability method of the present invention removes outliers and redundant data through data cleaning and standardization to ensure data quality. Column storage technology is used to compress the processed traceability data set, establish distributed index to accelerate query, cache and preload the key node data with high frequency access, and build an efficient full-link traceability query system.
[0083] 4. The beverage production whole process traceability method of the present invention constructs a complete traceability chain diagram structure, realizes step-by-step traceability from finished products to raw materials, and significantly improves the efficiency and accuracy of beverage production traceability through efficient data processing and analysis mechanisms. Through the present invention, both manufacturers and consumers can obtain transparent information about beverage production, enhancing the controllability of product quality and consumer trust. BRIEF DESCRIPTION OF THE DRAWINGS
[0084] Figure 1 The present invention is a flow chart of a method for tracing the entire beverage production process.
[0085] Figure 2 It is a schematic diagram of a beverage production whole process traceability method of the present invention.
[0086] Figure 3 This is another schematic diagram of a beverage production whole process traceability method according to the present invention. DETAILED DESCRIPTION
[0087] The present invention is further described in detail below through specific examples. The following examples are only illustrative and not restrictive, and the protection scope of the present invention cannot be limited thereto.
[0088] like Figure 1-3 In this embodiment, a beverage production whole process traceability method may specifically include:
[0089] S101. Establish a node attribute data structure based on the beverage raw material batch number and production line number, use timestamps to mark the raw material storage and production start time, use edge weights to represent the usage ratio of raw materials in different production batches, and obtain a preliminary raw material-finished product association diagram.
[0090] A node attribute data structure is constructed according to the batch number and production line number of the beverage raw materials, and the node attribute data structure includes the raw material name, batch number, production line number, storage timestamp and production start timestamp; the usage ratio data of the raw materials in different production batches are obtained, the raw material usage ratio is represented by the edge weight, the raw material node and the finished product node are connected, and the edge attribute includes the usage ratio value and timestamp information; a depth-first search algorithm is used to traverse the graph structure, starting from each raw material node, recursively traversing the edges and nodes connected to it, recording the node ID and edge weight on the traversal path, and if a finished product node is encountered, the complete path is stored in the result set; according to the raw material-finished product association path, the proportion of each batch of raw materials in the final finished product is calculated, and for each of the association paths, the edge weight values are accumulated to obtain the total usage ratio of the raw material in the finished product; the ratio information is added to the attributes of the raw material node for fast query and analysis to form a complete raw material-finished product association graph.
[0091] Exemplarily, a node attribute data structure is constructed according to the batch number and production line number of the beverage raw material. The node attributes include the raw material name, batch number, production line number, storage timestamp and production start timestamp, and the graph data model is used to store the node information. The usage ratio data of the raw materials in different production batches are obtained, and the raw material usage ratio is represented by the edge weight. The raw material node and the finished product node are connected, and the edge attribute includes the usage ratio value and timestamp information. The graph structure is traversed using the depth-first search algorithm. Starting from each raw material node, the edges and nodes connected to it are recursively traversed, and the node ID and edge weight on the traversal path are recorded. When a finished product node is encountered, the complete path is stored in the result set, and all possible paths are explored by backtracking to obtain the raw material finished product association path. According to the raw material finished product association path, the proportion of each batch of raw materials in the final finished product is calculated. For each association path, the edge weight value is accumulated to obtain the total usage ratio of the raw material in the finished product. This ratio information is added to the attributes of the raw material node for fast query and analysis to form a complete raw material finished product association graph.
[0092] The beverage production management system builds a node attribute data structure, associates the raw material A001 batch with the production line L01, and records the storage time 2024-07-19 08:30:00 and the production start time 2024-07-2009:15:00. The graph data model stores node information, and the raw material node contains attributes: name "apple concentrate", batch number A001, production line number L01, storage timestamp 1689724200, and production start timestamp 1689813300. Get the raw material usage ratio data, the edge weight indicates that the usage ratio of raw material A001 in the finished product batch P001 is 0.15, connect the raw material node A001 and the finished product node P001, and the edge attribute contains the usage ratio value 0.15 and the timestamp 1689813300. The depth-first search algorithm traverses the graph structure, starting from the raw material node A001, recursively traverses the connected edges and nodes, and records the path: A001→P001→P002, with node IDs of 1, 2, and 3, and edge weights of 0.15 and 0.8. When the finished product node P002 is encountered, the complete path {1,2,3} is stored in the result set. All paths are backtracked to obtain the set of raw material-finished product association paths. The proportion of each batch of raw materials in the final finished product is calculated. For the association path A001→P001→P002, the edge weight value 0.15*0.8=0.12 is accumulated to obtain the total usage ratio of raw material A001 in finished product P002. The ratio 0.12 is added to the attributes of the raw material node A001 for quick query and analysis. Finally, a complete raw material-finished product association graph is formed, showing the usage and proportion of raw material A001 in finished product P002 through intermediate product P001.
[0093] S102. For the processing procedures, the temperature, pressure and flow dynamic parameters are collected from the production line, and the collected data is divided into time windows and synchronized to obtain the production process data stream corresponding to the raw material batch timestamp. The time window division adopts a sliding window of fixed size, and the window size is determined according to the production cycle. The synchronization is achieved by aligning the timestamps of each parameter.
[0094] The temperature, pressure, flow rate and other dynamic parameters of the production line are obtained, and the collection frequency of the dynamic parameters is once per second; the dynamic parameters are divided into time windows using a sliding window, the window size of the sliding window is 10 minutes, and the sliding step of the sliding window is 1 minute; the timestamps of the dynamic parameters are aligned and combined into a vector within the time window, and the vector includes the temperature value, the pressure value, the flow rate value and the timestamp; the vector is matched with the raw material batch timestamp, and the raw material batch timestamp includes the batch start timestamp and the batch end timestamp; a mapping table is established, the key of the mapping table is the raw material batch number, and the value of the mapping table is the vector list corresponding to the raw material batch number, and the vector list includes all vectors with timestamps between the raw material batch start timestamp and the batch end timestamp.
[0095] Exemplarily, data collection points are set according to the processing procedures, and dynamic parameters such as temperature, pressure, and flow are obtained from the production line. The collection frequency is set to once per second to obtain a raw data sequence containing parameter values and timestamps. A fixed-size sliding window is used to divide the collected data into time windows. The window size is determined to be 10 minutes based on the production cycle, and the sliding step is set to 1 minute. The raw data sequence is divided into windows. The first window contains data from 0-10 minutes, the second window contains data from 1-11 minutes, and so on. Data synchronization is achieved by aligning the timestamps of each parameter. In each 10-minute time window, the data points with the closest timestamps in the temperature, pressure, and flow data are found, and these data points are combined into a vector in the form of [temperature value, pressure value, flow value, timestamp]. This process is repeated for each time window to form a time-aligned multidimensional parameter sequence. Match the time-aligned multidimensional parameter sequence with the raw material batch timestamp, find all data vectors with timestamps between the start and end of the raw material batch, these vectors constitute the production process data flow of the batch, establish a mapping table with the key as the raw material batch number and the value as the corresponding data vector list, and finally establish the association between the raw material batch and the production process data.
[0096] Multiple data collection points are set up on the beverage production line to collect temperature, pressure, and flow parameters at a frequency of once per second. Taking the apple juice production line as an example, from 9:00:00 to 9:00:59, the temperature data [20.5, 20.6, 20.7, ..., 21.4] ℃, the pressure data [101.3, 101.4, 101.3, ..., 101.5] kPa, and the flow data [5.2, 5.3, 5.2, ..., 5.4] L / s are collected, and each data point has a corresponding timestamp. A sliding window with a fixed size of 10 minutes and a sliding step of 1 minute is used to segment the original data. The first window contains data from 9:00:00 to 9:09:59, the second window contains data from 9:01:00 to 9:10:59, and so on. In each 10-minute window, the nearest neighbor algorithm is used to find the point with the closest timestamp in the temperature, pressure, and flow data, such as the data vector at 9:05:00 is [21.0℃, 101.4kPa, 5.3L / s, 1689728700]. Repeat this process for each window to form a time-aligned multidimensional parameter sequence. Assuming that the production time of raw material batch A001 is from 9:00:00 to 9:30:00, all data vectors within these 30 minutes are extracted to form the production process data stream of this batch. A mapping table is established, such as {A001: [[21.0, 101.4, 5.3, 1689728700], ...]}, to achieve the association between raw material batches and production process data. This association enables the specific production parameter changes of each batch of products to be traced in subsequent analysis.
[0097] S103. Use a graph database to store the beverage raw material and finished product association graph, establish the correspondence between raw material batches and production batches through the processing procedure attributes of the edges between nodes, and form a complete traceability chain graph structure.
[0098] Construct the graph database node, wherein the node attributes include the name, batch number, production date and other information of the raw material or finished product, and distinguish different nodes by a unique identifier. Define the edge type in the graph database, wherein the edge attributes include information such as the name of the processing procedure, processing time, processing parameters, etc., which are used to represent the processing relationship between the raw material node and the finished product node. Sort the edges between adjacent nodes by time. If a node has multiple input edges, the raw material batches corresponding to these edges together constitute the production batch of the intermediate product or finished product represented by the node. Use a depth-first search algorithm, starting from each raw material node, recursively traverse the edges and nodes connected to it, and record all node IDs and edge attributes on the current path during the traversal process. When encountering a finished product node, store the complete path in the result set, explore all possible paths by backtracking, and obtain a complete traceability chain. Use Cypher query language to implement fast association query between raw material batches and production batches, and write query statements such as MATCH(raw material: RawMaterial)-[r:PROCESSED_TO*]->(finished product: Product) WHERE raw material.batch number = the batch number RETURN raw material, r, finished product, return the complete path from a specific raw material batch to all related finished products, and output the complete traceability chain graph structure including all intermediate processing steps.
[0099] Exemplarily, based on the information of beverage raw materials and finished products, a graph database node is constructed. The node attributes include the name, batch number, production date and other information of the raw materials or finished products, and different nodes are distinguished by unique identifiers. The edge type in the graph database is defined, and the edge attributes include information such as the name of the processing procedure, processing time, and processing parameters, which are used to represent the processing relationship between the raw material node and the finished product node. According to the time sequence of the processing procedure, the edges between adjacent nodes are sorted by time. If a node has multiple input edges, the raw material batches corresponding to these edges together constitute the production batch of the intermediate product or finished product represented by the node, and the corresponding relationship between the raw material batch and the production batch is clearly expressed in the graph structure. Using the depth-first search algorithm, starting from each raw material node, recursively traverse the edges and nodes connected to it, record all node IDs and edge attributes on the current path during the traversal process, and when encountering a finished product node, store the complete path in the result set, explore all possible paths by backtracking, and obtain a complete traceability chain. Use Cypher query language to implement fast association query between raw material batches and production batches. Write query statements such as MATCH(raw material: RawMaterial)-[r:PROCESSED_TO*]->(finished product: Product)WHERE raw material.batch number = 'A001'RETURN raw material, r, finished product, return the complete path from a specific raw material batch to all related finished products, and output the complete traceability chain graph structure including all intermediate processing steps.
[0100] In the beverage production traceability system, when building a graph database node, take apple juice production as an example, create a raw material node "apple", the attributes include batch number A001, storage date 2024-07-19, supplier ID and other information, the unique identifier is RAW_A001. The attributes of the finished product node "apple juice" include batch number P001, production date 2024-07-20, shelf life and other information, the unique identifier is PROD_P001. Define the edge type "juice extraction", the attributes include process name, start time 2024-07-2009:00, end time 2024-07-2011:00, temperature 40℃, pressure 2MPa and other parameters. According to the time sequence, sort the edges RAW_A001 to PROD_P001 from 09:00 to 11:00. If PROD_P001 has multiple input edges, such as RAW_A001 and RAW_A002, then A001 and A002 together constitute the production batch of P001. Using the depth-first search algorithm, recursively traverse from RAW_A001 and record the path [RAW_A001, PROD_P001] and edge attributes. Backtrack and explore all paths to obtain the complete traceability chain [RAW_A001--(juice)-->PROD_P001]. Use the Cypher query language MATCH (raw material: RawMaterial)-[r:PROCESSED_TO*]->(finished product: Product) WHERE raw material.batch number = 'A001' RETURN raw material, r, finished product, return the complete path from A001 to all related finished products, output the traceability chain graph structure, and show the entire processing process from raw material apple A001 to finished apple juice P001, including detailed information such as time, temperature, and pressure of the intermediate steps.
[0101] S104. For heterogeneous data in the traceability chain graph structure, a time series database is used to store dynamic production parameters, and a mapping relationship is established between raw material batches and production parameters of corresponding time periods through a time window algorithm.
[0102] Heterogeneous data is obtained from the traceability chain graph structure, and the heterogeneous data includes raw material batch information, production parameters and timestamps; the heterogeneous data is standardized to obtain unified data in a format supported by a time series database, wherein non-numeric data is converted into metadata and stored in a relational database; according to the production time of the raw material batch, the unified data is segmented using a sliding time window algorithm, and the window size of the sliding time window is the production cycle, and the step size is a preset time interval; using the sliding time window algorithm, an association between the raw material batch and the dynamic parameter is established, and a batch-parameter mapping table is generated, and the batch-parameter mapping table includes batch number, parameter type, time range and statistical value; through the query interface of the time series database, the dynamic parameter data corresponding to the batch number and time range are obtained, and the dynamic parameter data forms a complete batch-parameter correspondence relationship.
[0103] Exemplarily, heterogeneous data including raw material batch information, production parameters and timestamps are extracted from the traceability chain graph structure, and dynamic production parameters are stored in the time series database in time series, recording parameter types, values and corresponding time points. The extracted heterogeneous data is standardized, and data from different sources and formats are uniformly converted into a format supported by the time series database, such as timestamp-value pairs. For non-numeric data, such as raw material batch information, it is converted into metadata and stored in a separate relational database, and associated with the time series data through a unique identifier. According to the production start time and end time of the raw material batch, the time window range is set, and the sliding time window algorithm is used. The window size is set to 8 hours for the production cycle, and the step length is 10 minutes. From the start time of production, it slides forward 10 minutes each time, extracts all parameter data within 8 hours, and divides the time series data. Using the time window algorithm, each raw material batch is associated with the dynamic parameters within its production time period, and a batch-parameter mapping table is generated, which contains the fields batch number, parameter type, start time, end time, minimum value, maximum value, and average value. The parameter data in each time window is counted and the corresponding fields are filled. Through the query interface of the time series database, using specific query languages such as InfluxDB's Flux language, rapid retrieval of raw material batches and production parameters can be achieved. By inputting the batch number and time range, all dynamic parameter data within the corresponding period is returned to form a complete batch-parameter correspondence.
[0104] In the beverage production traceability system, heterogeneous data is extracted from the traceability chain graph structure, such as apple concentrate of raw material batch A001, production parameters of temperature 40℃ and pressure 2MPa, and the corresponding timestamp 2024-07-2009:00:00. These data are standardized and converted into a format supported by the time series database, such as {timestamp:1626748800,temperature:40,pressure:2}. At the same time, the raw material batch A001 information is stored as metadata in the relational database and associated through the unique identifier UID_A001. The sliding time window algorithm is used, and the window size is set to an 8-hour production cycle with a step size of 10 minutes. Starting from 09:00:00, it slides forward 10 minutes each time to extract all parameter data within 8 hours. For example, the first window is 09:00:00-17:00:00, and the second is 09:10:00-17:10:00. Count the data in each window and generate a batch-parameter mapping table, such as {batch:A001,param:temperature,start:1626748800,end:1626777600,min:38,max:42,avg:40}. Use a time series database query language, such as InfluxDB's Flux, to write queries.
[0105] from(bucket:"production_data")|>range(start:1626748800,stop:1626777600)|>filter(fn:(r)=>r.batchID=="A001")|>yield(), obtain all dynamic parameter data of batch A001 within the specified time range, and realize the complete correspondence between raw material batches and production parameters.
[0106] S105. Starting from the finished product batch node, trace back to the raw material batch node step by step through the edge attributes in the graph database, and extract the production parameters within the corresponding time window to obtain a preliminary traceability data set.
[0107] The finished product node is located in the graph database according to the finished product batch number, and the graph structure is traversed by a depth-first search algorithm to obtain all nodes on the traceability path; for each node on the traceability path, the production parameters within the time window corresponding to the node are extracted from the time series database, and the time window is determined by the start time and the end time of the node; a nested data structure is created by a data fusion algorithm, and the nested data structure includes node attributes in the graph database and parameter statistical information extracted from the time series database; using a batch association algorithm, starting from the finished product node, trace back along the edge to the raw material node, and record the weight of each edge on the path; by multiplying the weights, the proportion of each raw material batch in the finished product is calculated, the corresponding relationship between the finished product batch and the raw material batch is determined, and a traceability data set containing complete production process and parameter information is obtained.
[0108] Exemplarily, the finished product node is located in the graph database according to the finished product batch number, and the graph structure is traversed by the depth-first search algorithm. The graph is traced upward step by step along the direction of the edge, and all the nodes and edge attributes along the way are recorded until the raw material batch node is reached. For each node on the traceability path, the production parameters in the corresponding time window are extracted from the time series database. The time window range is determined by the start time and end time of the node. The parameter types include temperature, pressure, and flow. The range query function of the time series database is used to specify the time range and parameter type, and the minimum, maximum, average, and standard deviation of the production parameters corresponding to each node are extracted. A data fusion algorithm is used to create a nested data structure. Each node contains the attributes in the graph database and the parameter statistics extracted from the time series database. The node ID is used as the key to organize the information into a hierarchical dictionary or JSON object. The node and edge attributes in the graph database are integrated with the production parameters extracted from the time series database to form a data structure containing a complete production process and parameter information. Using the batch association algorithm, starting from the finished product node, trace back along the edge to the raw material node, record the weight of each edge on the path, and calculate the proportion of each raw material batch in the final finished product by multiplying these weights. Establish the corresponding relationship between the finished product batch and the raw material batch, and combine the production parameters of each node to generate a preliminary traceability data set.
[0109] In the beverage production traceability system, taking apple juice with batch number P001 as an example, the finished product node is located through the graph database, and the production chain is traced using the depth-first search algorithm. Starting from the P001 node, the edge attribute "juice" is traced back to the intermediate product node M001, and then the "concentrate" edge is traced back to the raw material node R001. For each node, such as M001, the parameters within its production time window (such as 2024-07-2009:00:00 to 2024-07-2011:00:00) are extracted from the time series database. Use range query to obtain the statistical values of temperature parameters: minimum value 38℃, maximum value 42℃, average value 40℃, standard deviation 1℃. The pressure parameters are obtained in the same way. The data fusion algorithm integrates the graph database node attributes (such as the batch number and production time of M001) with the parameter statistics to form a JSON structure: {"id":"M001","type":"intermediate product","batch":"M001","start_time":"2024-07-2009:00:00","end_time":"2024-07-2011:00:00","temperature":{"min":38,"max":42,"avg":40,"std":1},"pressure":{...}}. The batch association algorithm calculates the proportion of raw materials. For example, if the weight of the edge R001 to M001 is 0.5 and the weight of M001 to P001 is 0.8, then the proportion of R001 in P001 is 0.5*0.8=0.4. Finally, a traceability data set containing the complete traceability chain, production parameters of each node and the proportion of raw materials is generated.
[0110] S106. Analyze the quality indicators in the traceability data set, extract key parameters that are highly correlated with quality issues, and establish a quality correlation scoring model. The model uses a multiple linear regression method, with quality indicators as dependent variables and key parameters as independent variables, to calculate the weight of each parameter's impact on quality.
[0111] Quality indicators and production parameters are obtained from a traceability data set, wherein the traceability data set contains outliers and missing values; data cleaning is performed according to the obtained quality indicators and production parameters to obtain a preprocessed data set; the Pearson correlation coefficient calculation method is used to analyze the correlation between the quality indicators and the production parameters in the preprocessed data set, and a set of key parameters that are highly correlated with the quality indicators is determined; the variance inflation factor of each parameter in the key parameter set is calculated, and if the variance inflation factor of a parameter is greater than a preset threshold, the parameter is removed from the key parameter set; a multivariate linear regression model is constructed based on the key parameter set, wherein the multivariate linear regression model uses the quality indicators as dependent variables and the key parameters as independent variables; a forward selection method is used to perform stepwise regression on the multivariate linear regression model, wherein the forward selection method starts from an empty model and adds a variable that best improves the model fit each time; an optimal parameter combination is selected according to the stepwise regression results to obtain a quality correlation scoring model.
[0112] Exemplarily, quality indicators and production parameters are extracted from the traceability data set, outliers and missing values are removed through data cleaning, outliers are detected using the quartile method, data exceeding Q3+1.5IQR or less than Q1-1.5IQR are marked as abnormal, missing values are filled with the mean or median, continuous variables are standardized using the Z-score method, and categorical variables are converted into dummy variables to obtain the preprocessed data set. The Pearson correlation coefficient calculation method is used to analyze the correlation between quality indicators and various production parameters, and the correlation coefficient threshold is set to 0.5 to screen out a set of key parameters that are highly correlated with quality indicators. The variance inflation factor is calculated, and variables with VIF greater than 10 are removed to avoid the high correlation between independent variables affecting the stability of the model. Based on the screened key parameter set, a multivariate linear regression model is constructed, with quality indicators as dependent variables and key parameters as independent variables. The least squares estimation is solved by the normal equation β=(X^TX)^(-1)X^T y to obtain the weight of each parameter on quality. The forward selection method was used for stepwise regression, starting from the empty model. One variable that could best improve the model fit was added each time, and the contribution of each variable was evaluated using the F test until no variable could significantly improve the model performance. The optimal combination of parameters was selected based on evaluation indicators such as the coefficient of determination and the Akaike information criterion to form the final quality relevance scoring model.
[0113] In the beverage quality control system, the quality indicators (such as sugar content) and production parameters (such as temperature, pressure, and stirring speed) of apple juice products are extracted from the traceability data set. The quartile method is used to handle outliers. For example, if the temperature data Q1 = 35 ° C, Q3 = 45 ° C, and IQR = 10 ° C, the data below 20 ° C or above 60 ° C are marked as abnormal. Missing values are filled with the mean, such as the pressure average value 2MPa. Z-score standardization is used to convert the temperature of 40 ° C to (40-μ) / σ. The Pearson correlation coefficient is calculated. For example, the correlation coefficient between temperature and sugar content is 0.7, pressure is 0.3, and stirring speed is 0.6. Temperature and stirring speed are selected as key parameters. VIF is calculated. Temperature VIF = 2.5 and stirring speed VIF = 3.2, both less than 10, and these two variables are retained. A multivariate linear regression model is constructed with sugar content as the dependent variable and temperature and stirring speed as the independent variables. The regression coefficient is obtained by solving the normal equation: sugar content = 0.5 temperature + 0.3 stirring speed + 10. The forward selection method was used for stepwise regression. The temperature variable was first added, with an F value of 25 and a p value of <0.01, which was significant. Then the stirring speed was added, with an F value of 15 and a p value of <0.05, which was also significant. The final model determination coefficient R 2 =0.85, AIC=120, forming a quality correlation scoring model: quality score=0.5 standardized temperature+0.3 standardized stirring speed.
[0114] S107. Use a batch correlation algorithm to calculate the degree of influence of different raw material batches on the quality of the finished product, and obtain the correlation strength between the raw material batch and the quality problem. The batch correlation algorithm is based on the path analysis in the graph structure and combines the edge weight to calculate the contribution of the raw material batch to the finished product.
[0115] Receive the traceability request information carrying the finished product batch node identifier, the traceability request information is issued by the quality control system; according to the traceability request information, use the depth-first search algorithm to trace back from the finished product batch node to the raw material batch node, and record all possible traceability paths, the traceability path includes a node sequence and a corresponding edge weight; obtain the traceability path, use a parallel computing method to process all paths at the same time, and distribute the traceability path to different processing units for calculation; for each traceability path, use the edge weight multiplication method to calculate the path weight, and the path weight is equal to all edge weights on the path for each raw material batch, obtain the weights of all paths containing the batch, and use the weighted sum method to calculate the overall contribution of the raw material batch to the finished product, the overall contribution is equal to the weighted sum of the path weight multiplied by the inverse of the path length divided by the sum of the inverse of the path length; based on the finished product quality score and the raw material batch contribution, use the Pearson correlation coefficient to calculate the strength of the association between the raw material batch and the quality problem, the numerical range of the association strength is between negative one and one, the larger the absolute value of the association strength, the stronger the association; the higher the association strength value, the greater the impact of the raw material batch on the quality problem.
[0116] Exemplarily, according to the node relationship in the graph structure, a depth-first search algorithm is used to trace back from the finished product batch node to the raw material batch node, and all possible traceability paths are recorded, each path containing a node sequence and a corresponding edge weight. When there are multiple paths from raw materials to finished products, a parallel computing method is used to process all paths simultaneously, and the paths are assigned to different processing units for calculation to improve the efficiency of the algorithm. For each traceability path, the path weight is calculated, and the edge weight is multiplied in a continuous manner. The path weight is equal to the product of all edge weights on the path, indicating the degree of influence of the raw material batch on the finished product through the path. For each raw material batch, the weights of all paths containing the batch are summarized, and the weighted summation method is used to calculate the overall contribution of the raw material batch to the finished product. The total contribution is equal to the weighted sum of the path weight multiplied by the reciprocal of the path length divided by the sum of the reciprocal of the path length. Combined with the finished product quality score and the raw material batch contribution, the Pearson correlation coefficient is used to calculate the strength of the association between the raw material batch and the quality problem. The value range is between -1 and 1. The larger the absolute value, the stronger the association. The higher the association strength value, the greater the impact of the raw material batch on the quality problem.
[0117] In the beverage production traceability system, starting from the finished apple juice batch P001, the depth-first search algorithm is used to trace the raw material batch. The system finds two traceability paths: P001->M001->R001 and P001->M002->R002, where M001 and M002 are intermediate products. The parallel processing unit calculates the weights of these two paths simultaneously. The edge weights of the P001->M001->R001 path are 0.8 and 0.7, respectively, and the path weight is 0.80.7=0.56; the edge weights of the P001->M002->R002 path are 0.6 and 0.9, respectively, and the path weight is 0.60.9=0.54. For the raw material batch R001, its total contribution is calculated as (0.561 / 2) / (1 / 2)=0.56; for R002, the total contribution is (0.541 / 2) / (1 / 2)=0.54. Assuming that the quality score of finished product P001 is 85 points (out of 100 points), the Pearson correlation coefficient is used to calculate the correlation between the raw material batch contribution and the quality score. The correlation coefficient of R001 is 0.75, and the correlation coefficient of R002 is 0.62, indicating that R001 is more closely related to quality issues. Based on this, the system determines that R001 has a greater impact on the quality of P001, prompting quality management personnel to focus on the quality control of the R001 batch of raw materials.
[0118] S108. According to the quality correlation scoring model and batch correlation algorithm results, the nodes in the traceability chain are ranked by importance, key nodes are screened out, and the optimal traceability path is determined. According to the traceability depth and key nodes, the production parameters of the corresponding time window are extracted from the time series database, and combined with the raw material batch information, a complete traceability data set is generated.
[0119] Calculate the comprehensive importance score of the node, where the comprehensive importance score is equal to 0.6 multiplied by the quality impact score plus 0.4 multiplied by the node contribution; select nodes above the preset threshold as key nodes based on the comprehensive importance score; use the Dijkstra algorithm to set the key nodes as must-pass points, calculate the shortest path from the raw material batch to the first key node, between key nodes, and from the last key node to the finished product batch, and obtain the optimal traceability path; extract the production parameter data within the time window corresponding to the key node from the time series database, and the production parameter data includes time series data of key indicators such as temperature, pressure, and flow; use a multi-source heterogeneous data fusion method to integrate node attributes, edge attributes, time series parameters, and batch information into a unified probability model. If the formats of the node attributes, edge attributes, time series parameters, and batch information are inconsistent, the data from different sources are unified in format and then integrated to obtain a traceability data set containing complete information.
[0120] Exemplarily, the quality impact score of each node is calculated according to the quality correlation scoring model, and the node contribution obtained by the batch correlation algorithm is combined. The weighted average method is used to calculate the comprehensive importance score of the node. The comprehensive importance score is equal to 0.6 multiplied by the quality impact score plus 0.4 multiplied by the node contribution. All nodes in the traceability chain are sorted in descending order. The importance threshold is set, and the nodes with a comprehensive importance score higher than the threshold are selected as key nodes. The Dijkstra algorithm is used to set the key nodes as necessary points, and the shortest paths from the raw material batch to the first key node, between key nodes, and from the last key node to the finished product batch are calculated. These paths are connected to form the optimal traceability path. The traceability depth is determined according to the optimal traceability path, and the production parameters in the time window corresponding to the key node are extracted from the time series database, including time series data of key indicators such as temperature, pressure, and flow. The extracted production parameter data are detected for outliers and filled with missing values. The box plot method is used to identify outliers, and the linear interpolation method is used to fill missing values to ensure data quality. The processed production parameter data is integrated with the raw material batch information. A multi-source heterogeneous data fusion method is adopted. First, the data from different sources are unified in format. Then, a joint probability distribution model is used to integrate the node attributes, edge attributes, timing parameters and batch information into a unified probability model to generate a traceability data set containing complete information.
[0121] In the beverage production traceability system, taking apple juice production as an example, the quality correlation scoring model calculates that the quality impact score of raw material A is 0.8, the batch correlation algorithm calculates that its node contribution is 0.7, and the comprehensive importance score is 0.80.6+0.70.4=0.76. The threshold is set to 0.7, and three key nodes, raw material A, processing B and packaging C, are screened out. The Dijkstra algorithm is used to calculate the shortest path, and the optimal traceability path of raw material A→processing B→packaging C→finished product D is obtained, with a total length of 4. The production parameters of these nodes during 2024-07-2008:00 to 18:00 are extracted from the time series database, such as temperature data [20,21,22,23,22,21]℃. The temperature anomaly of 25℃ is detected using the box plot method and corrected to 23℃ by linear interpolation. The processed time series data is integrated with the raw material batch A001 information. A multi-source heterogeneous data fusion method is adopted to unify the data format into one data point per hour. A joint probability distribution model is used to integrate node attributes (such as raw material name, batch number), edge attributes (such as processing technology, time), time series parameters (such as temperature curve) and batch information (such as supplier, warehousing time). Finally, a traceability data set containing comprehensive information is generated to achieve complete quality traceability from raw materials to finished products.
[0122] S109. Clean and standardize the generated beverage traceability data set to remove outliers and redundant data to ensure data quality. Use column storage technology to compress the processed traceability data set, establish distributed indexes to accelerate queries, cache and preload high-frequency access key node data, and build an efficient full-link traceability query system.
[0123] Obtain a beverage traceability data set, and calculate the standard deviation based on the data set; if a data point deviates from the mean by more than three times the standard deviation, it is determined as an outlier and removed. Standardize the cleaned data set, calculate the covariance matrix, and solve the eigenvalues and eigenvectors; select the principal component whose cumulative contribution rate reaches the preset threshold, and reconstruct the data set through the principal component. Use the Apache Parquet format to store the reconstructed traceability data set in column format, and use corresponding compression algorithms for different data types; the compression algorithm includes: using dictionary encoding for integer data, using delta encoding for floating-point data, and using prefix compression for string data. Construct a distributed index structure, and shard the compressed data into multiple nodes through a consistent hashing algorithm; use B+ trees to build local indexes in each node, and use distributed B+ trees for cross-node queries. Design a RESTfulAPI interface, which supports multi-dimensional queries by batch number, time range, product type, etc.; use the GraphQL query language to allow the client to specify the required specific fields and obtain the corresponding traceability data from the distributed index structure.
[0124] For example, the beverage traceability data set is cleaned, the triple standard deviation method is used to detect and remove outliers, and the principal component analysis method is used to remove redundant data. First, the data is standardized, the covariance matrix is calculated, the eigenvalues and eigenvectors are solved, and the principal components with a cumulative contribution rate of 95% are selected. The data is reconstructed through the principal components, and redundant information is removed. Finally, the numerical data is standardized by the Z-score method to ensure data quality and consistency. The column storage technology is implemented using the ApacheParquet format, and the processed traceability data set is reconstructed. The data is stored in blocks by column, and corresponding compression algorithms are used for different data types, such as dictionary encoding for integer data, delta encoding for floating-point data, and prefix compression for string data. For basically monotonically increasing timestamp data, differential encoding is used in combination with variable-length integer encoding. Build a distributed index structure, use consistent hashing algorithm to shard data into multiple nodes, use B+ tree to build local index in each node, use distributed B+ tree for cross-node queries, copy the upper nodes of the tree to all servers, store actual data only in leaf nodes, create secondary index for high-frequency query fields to improve query efficiency. Implement cache preloading mechanism, identify key node data with high frequency access through access frequency statistics algorithm, preload this data into distributed cache, use LRU (least recently used) strategy to manage cache, and improve access speed of hot data. Design RESTful API interface, support multi-dimensional query by batch number, time range, product type, etc., implement paging and sorting functions, use GraphQL query language, allow clients to flexibly specify specific fields required, reduce data transmission volume, and build an efficient full-link traceability query system.
[0125] In the beverage traceability system, when cleaning the original data set, the triple standard deviation method was used to detect the abnormal value of 45°C in the temperature data (normal range 20-30°C) and remove it. The principal component analysis method was used to calculate the eigenvalues [5.2, 1.8, 0.6, 0.4], and the first two principal components (cumulative contribution rate 95.2%) were selected to reconstruct the data and remove redundant information. The pH value of 6.5 was standardized to 0.8 using the Z-score method. The processed data was stored in Apache Parquet format, and the production date column was compressed using differential encoding, such as [2024-07-01, 2024-07-02, 2024-07-03] was compressed to [1657062805, 1, 1]. The consistent hashing algorithm was used to divide the data into 3 nodes, and each node built a B+ tree local index. The root node and internal nodes of the tree were replicated to all servers. The cache preloading mechanism recognizes that the "apple juice" product has the highest access frequency (accounting for 60%), and preloads its related data into the distributed cache. Design RESTful APIs, such as " / api / v1 / trace? batchNo=B001&startDate=2024-07-01&endDate=2024-07-31", to support multi-dimensional queries. Using the GraphQL query language, clients are allowed to request "{product(id:123){name,batchNo,productionDate}}", returning only the specified fields, optimizing data transmission efficiency, and achieving efficient full-link traceability queries.
[0126] Although the embodiments and drawings of the present invention are disclosed for illustrative purposes, those skilled in the art will appreciate that various substitutions, changes and modifications are possible without departing from the spirit and scope of the present invention and the appended claims. Therefore, the scope of the present invention is not limited to the contents disclosed in the embodiments and drawings.
Claims
1. A method for tracing the entire process of beverage production, characterized in that: The method comprises: A node attribute data structure is established based on the batch number and production line number of the beverage raw materials. Timestamps are used to mark the time when the raw materials enter the warehouse and the start of production. Edge weights are used to represent the usage ratio of raw materials in different production batches, and a preliminary raw material-finished product association graph is obtained. For the processing procedures, the dynamic parameters of temperature, pressure and flow are collected from the production line, and the collected data are divided into time windows and synchronized to obtain the production process data stream corresponding to the timestamp of the raw material batch. The time window is divided into a sliding window of fixed size, and the window size is determined according to the production cycle. Synchronization is achieved by aligning the timestamps of each parameter. A graph database is used to store the association graph of beverage raw materials and finished products. The corresponding relationship between raw material batches and production batches is established through the processing process attributes of the edges between nodes, forming a complete traceability chain graph structure. In view of the heterogeneous data in the traceability chain graph structure, a time series database is used to store dynamic production parameters, and a mapping relationship is established between raw material batches and production parameters of the corresponding time period through a time window algorithm; Starting from the finished product batch node, trace back to the raw material batch node step by step through the edge attributes in the graph database, and extract the production parameters within the corresponding time window to obtain a preliminary traceability data set; Analyze the quality indicators in the traceability data set, extract key parameters that are highly correlated with quality issues, and establish a quality correlation scoring model. The model uses a multiple linear regression method, with quality indicators as dependent variables and key parameters as independent variables, to calculate the weight of each parameter's impact on quality. The batch correlation algorithm is used to calculate the impact of different raw material batches on the quality of the finished product, and to obtain the correlation strength between the raw material batch and the quality problem. The batch correlation algorithm is based on the path analysis in the graph structure and combines the edge weight to calculate the contribution of the raw material batch to the finished product. According to the quality correlation scoring model and batch correlation algorithm results, the nodes in the traceability chain are ranked in importance, key nodes are screened out, and the optimal traceability path is determined. According to the traceability depth and key nodes, the production parameters of the corresponding time window are extracted from the time series database, combined with the raw material batch information, to generate a complete traceability data set; The generated beverage traceability dataset is cleaned and standardized to remove outliers and redundant data to ensure data quality. Columnar storage technology is used to compress the processed traceability dataset, a distributed index is established to accelerate query, and cache pre-loaded key node data with high frequency access, to build an efficient full-link traceability query system.
2. The beverage production whole process traceability method according to claim 1, wherein: The node attribute data structure is established according to the beverage raw material batch number and production line number, the raw material storage and production start time are marked with timestamps, and the use ratio of raw materials in different production batches is represented by edge weights to obtain a preliminary raw material-finished product association diagram, including: Construct a node attribute data structure according to the batch number and production line number of the beverage raw material, wherein the node attribute data structure includes the raw material name, batch number, production line number, storage timestamp and production start timestamp; Obtain usage ratio data of the raw materials in different production batches, represent the usage ratio of the raw materials by edge weights, connect the raw material nodes with the finished product nodes, and the edge attributes include usage ratio values and timestamp information; A depth-first search algorithm is used to traverse the graph structure, starting from each raw material node, recursively traversing the edges and nodes connected to it, recording the node ID and edge weight on the traversal path, and if a finished product node is encountered, the complete path is stored in a result set; According to the raw material-finished product association path, the proportion of each batch of raw materials in the final finished product is calculated, and for each of the association paths, the edge weight values are accumulated to obtain the total usage ratio of the raw materials in the finished product; The ratio information is added to the attributes of the raw material node for quick query and analysis to form a complete raw material-finished product association diagram.
3. The beverage production whole process traceability method according to claim 1, wherein: For the processing procedure, the temperature, pressure and flow dynamic parameters are collected from the production line, and the collected data is divided into time windows and synchronized to obtain the production process data stream corresponding to the raw material batch timestamp. The time window division adopts a sliding window of fixed size, and the window size is determined according to the production cycle. The synchronization is achieved by aligning the timestamps of each parameter, including: Acquire dynamic parameters such as temperature, pressure and flow of the production line, with the acquisition frequency of the dynamic parameters being once per second; The dynamic parameter is divided into time windows using a sliding window, the window size of the sliding window is 10 minutes, and the sliding step length of the sliding window is 1 minute; Aligning the timestamps of the dynamic parameters and combining them into a vector within the time window, wherein the vector includes a temperature value, a pressure value, a flow value and a timestamp; Matching the vector with a raw material batch timestamp, wherein the raw material batch timestamp includes a batch start timestamp and a batch end timestamp; A mapping table is established, wherein the key of the mapping table is the raw material batch number, the value of the mapping table is a vector list corresponding to the raw material batch number, and the vector list contains all vectors whose timestamps are between the raw material batch start timestamp and the batch end timestamp.
4. The beverage production whole process traceability method according to claim 1, wherein: The graph database is used to store the beverage raw material and finished product association graph, and the corresponding relationship between the raw material batch and the production batch is established through the processing process attributes of the edges between the nodes to form a complete traceability chain graph structure, including: Constructing the graph database nodes, wherein the node attributes include information such as the name, batch number and production date of the raw material or finished product, and different nodes are distinguished by unique identifiers; Defining edge types in the graph database, wherein the edge attributes include information such as a processing procedure name, processing time, and processing parameters, and are used to represent a processing relationship between a raw material node and a finished product node; Sort the edges between adjacent nodes by time. If a node has multiple input edges, the raw material batches corresponding to these edges together constitute the production batch of the intermediate product or finished product represented by the node; Using the depth-first search algorithm, starting from each raw material node, recursively traverse the edges and nodes connected to it, and record all node IDs and edge attributes on the current path during the traversal process; When a finished product node is encountered, the complete path is stored in the result set, and all possible paths are explored by backtracking to obtain a complete traceability chain; Use Cypher query language to implement fast association query between raw material batches and production batches, and write query statements such as MATCH(raw material: RawMaterial)-[r:PROCESSED_TO*]->(finished product: Product) WHERE raw material.batch number = the batch number RETURN raw material, r, finished product, return the complete path from a specific raw material batch to all related finished products, and output the complete traceability chain graph structure including all intermediate processing steps.
5. The beverage production whole process traceability method according to claim 1, wherein: For heterogeneous data in the traceability chain graph structure, a time series database is used to store dynamic production parameters, and a mapping relationship is established between raw material batches and production parameters of corresponding time periods through a time window algorithm, including: Acquire heterogeneous data from the traceability chain graph structure, wherein the heterogeneous data includes raw material batch information, production parameters and timestamp; The heterogeneous data is standardized to obtain unified data in a format supported by a time series database, wherein non-numeric data is converted into metadata and stored in a relational database; According to the production time of the raw material batches, the unified data is segmented using a sliding time window algorithm, where the window size of the sliding time window is the production cycle and the step length is a preset time interval; Using the sliding time window algorithm, an association is established between the raw material batch and the dynamic parameter, and a batch-parameter mapping table is generated, wherein the batch-parameter mapping table includes the batch number, parameter type, time range and statistical value; The dynamic parameter data corresponding to the batch number and time range are obtained through the query interface of the time series database, and the dynamic parameter data form a complete batch-parameter correspondence relationship.
6. The beverage production whole process traceability method according to claim 1, wherein: Starting from the finished product batch node, the edge attributes in the graph database are traced back to the raw material batch node step by step, and the production parameters in the corresponding time window are extracted to obtain a preliminary traceability data set, including: Locate the finished product node in the graph database according to the finished product batch number, and traverse the graph structure using a depth-first search algorithm to obtain all nodes on the traceability path; For each node on the traceability path, extract the production parameters within the time window corresponding to the node from the time series database, where the time window is determined by the start time and end time of the node; Using a data fusion algorithm to create a nested data structure, the nested data structure includes node attributes in the graph database and parameter statistics extracted from the time series database; Using a batch association algorithm, starting from the finished product node, tracing back along the edge to the raw material node, and recording the weight of each edge on the path; By multiplying the weights, the proportion of each raw material batch in the finished product is calculated, the corresponding relationship between the finished product batch and the raw material batch is determined, and a traceability data set containing complete production process and parameter information is obtained.
7. The beverage production whole process traceability method according to claim 1, wherein: The quality indicators in the traceability data set are analyzed, key parameters highly related to quality issues are extracted, and a quality correlation scoring model is established. The model uses a multiple linear regression method, takes the quality indicators as the dependent variable and the key parameters as the independent variable, and calculates the influence weight of each parameter on the quality, including: Acquire quality indicators and production parameters from a traceability data set, wherein the traceability data set contains outliers and missing values; Perform data cleaning based on the acquired quality indicators and production parameters to obtain a preprocessed data set; The Pearson correlation coefficient calculation method is used to analyze the correlation between the quality index and each production parameter in the pre-processed data set, and determine the key parameter set that is highly correlated with the quality index; Calculating the variance inflation factor of each parameter in the key parameter set, and if the variance inflation factor of a parameter is greater than a preset threshold, removing the parameter from the key parameter set; Constructing a multiple linear regression model based on the key parameter set, wherein the multiple linear regression model uses the quality index as a dependent variable and the key parameter as an independent variable; Performing stepwise regression on the multiple linear regression model using a forward selection method, wherein the forward selection method starts from an empty model and adds one variable at a time that best improves the model fit; The optimal parameter combination is selected according to the stepwise regression results to obtain a quality correlation scoring model.
8. The beverage production whole process traceability method according to claim 1, wherein: The batch correlation algorithm is used to calculate the influence of different raw material batches on the quality of the finished product, and obtain the correlation strength between the raw material batch and the quality problem. The batch correlation algorithm is based on the path analysis in the graph structure and combines the edge weight to calculate the contribution of the raw material batch to the finished product, including: Receiving a traceability request message carrying a finished product batch node identifier, the traceability request message being sent by a quality control system; According to the traceability request information, a depth-first search algorithm is used to trace back from the finished product batch node to the raw material batch node, and all possible traceability paths are recorded, wherein the traceability path includes a node sequence and a corresponding edge weight; Obtain the traceability paths, process all paths simultaneously using a parallel computing method, and distribute the traceability paths to different processing units for calculation; For each of the traceability paths, the path weight is calculated by multiplying the edge weights, and the path weight is equal to the product of all edge weights on the path; For each raw material batch, obtain the weights of all paths including the batch, and use the weighted sum method to calculate the overall contribution of the raw material batch to the finished product, where the overall contribution is equal to the weighted sum of the path weight multiplied by the reciprocal of the path length divided by the sum of the reciprocals of the path lengths; According to the finished product quality score and the raw material batch contribution, the Pearson correlation coefficient is used to calculate the correlation strength between the raw material batch and the quality problem. The correlation strength value range is between negative one and one. The larger the absolute value of the correlation strength is, the stronger the correlation is. The higher the association strength value is, the greater the impact of the raw material batch on the quality problem is.
9. The beverage production whole process traceability method according to claim 1, wherein: According to the quality correlation scoring model and batch correlation algorithm results, the nodes in the traceability chain are ranked in importance, key nodes are screened out, and the optimal traceability path is determined. According to the traceability depth and key nodes, the production parameters of the corresponding time window are extracted from the time series database, and combined with the raw material batch information, a complete traceability data set is generated, including: Calculate the comprehensive importance score of the node, where the comprehensive importance score is equal to 0.6 multiplied by the quality impact score plus 0.4 multiplied by the node contribution; Filtering nodes with a value higher than a preset threshold as key nodes according to the comprehensive importance score; The Dijkstra algorithm is used to set the key nodes as necessary points, and the shortest paths from the raw material batch to the first key node, between key nodes, and from the last key node to the finished product batch are calculated to obtain the optimal traceability path; Extracting production parameter data within the time window corresponding to the key node from a time series database, wherein the production parameter data includes time series data of key indicators such as temperature, pressure and flow rate; A multi-source heterogeneous data fusion method is used to integrate node attributes, edge attributes, timing parameters and batch information into a unified probability model. If the formats of the node attributes, edge attributes, timing parameters and batch information are inconsistent, the data from different sources are unified in format and then integrated to obtain a traceability data set containing complete information.
10. The beverage production whole process traceability method according to claim 1, wherein: The generated beverage traceability data set is cleaned and standardized to remove outliers and redundant data to ensure data quality. Column storage technology is used to compress the processed traceability data set, a distributed index is established to accelerate query, and high-frequency access key node data is cached and preloaded to build an efficient full-link traceability query system, including: Obtain a beverage traceability data set, and calculate a standard deviation based on the data set; If a data point deviates from the mean by more than three standard deviations, it is considered an outlier and removed; Standardizing the cleaned data set, calculating the covariance matrix and solving the eigenvalues and eigenvectors; Selecting a principal component whose cumulative contribution rate reaches a preset threshold, and reconstructing the data set through the principal component; The reconstructed traceability data set is stored in columnar format using Apache Parquet, and corresponding compression algorithms are used for different data types. The compression algorithm includes: using dictionary encoding for integer data, using delta encoding for floating point data, and using prefix compression for string data; Constructing a distributed index structure, and sharding the compressed data to multiple nodes through a consistent hashing algorithm; Use B+ trees to build local indexes in each node, and use distributed B+ trees for cross-node queries; Design a RESTful API interface that supports multi-dimensional queries such as batch number, time range, and product type; The GraphQL query language is used to allow the client to specify the specific fields required and obtain the corresponding traceability data from the distributed index structure.
Citation Information
Cited By
Method and system for detecting component content of agricultural and sideline products
CN119479882A
Anti-counterfeiting traceability method for gravure water-based ink printing production information
CN119624484A
An anti-counterfeiting and traceability method for the production information of intaglio water-based ink printing
CN119624484B
Production quality control method and equipment for vegetable protein beverage and medium
CN119831445A
Wire harness production control system based on big data analysis
CN119886962A
