A method of dairy product traceability based on blockchain
By using a blockchain-based dairy product traceability method, which employs a spatiotemporal coupled self-organizing model and a grey relational algorithm to dynamically generate traceability links, the personalization and accuracy issues of existing dairy product traceability methods are solved. This achieves data credibility and link stability, and meets multi-level visualization requirements.
Patent Information
- Application Number
- CN202510947967.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-10
- Publication Date
- 2026-02-13
- Estimated Expiration
- 2045-07-10
AI Technical Summary
Existing dairy product traceability methods are difficult to adapt to the differentiated needs of different industry entities, lack personalized and precise traceability capabilities, and have a high rate of misjudgment of the traceability link, making it impossible to effectively distinguish between high-reliability traceability links and low-quality paths.
Using a blockchain-based approach, data from the dairy production process is collected and divided into data blocks. By combining a spatiotemporal coupled self-organizing model and a grey relational algorithm, traceability links are dynamically generated, applicability is evaluated and optimized, and multi-level visual traceability displays are supported.
It ensures data credibility and link stability in the dairy product traceability process, supports personalized responses and high-quality iterations, meets the visualization needs of different users, and enhances public trust.
Smart Images

Figure CN120851902B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of dairy products, in particular, to a method for dairy product traceability based on blockchain. BACKGROUND
[0002] Dairy products are foods processed from the milk secreted by milk animals, widely used in the food industry, common dairy products include milk, cheese, butter, yogurt, milk powder, etc., dairy products are usually rich in protein, fat, lactose, vitamins and minerals, and are an important part of many dietary structures. Its main nutritional components have important contribution to human health, especially in supporting bone health, and dairy products are one of the essential foods in people's daily diet. With the country's active advocacy, residents' awareness of drinking milk is gradually improving, and the future per capita dairy product consumption is expected to continue to increase, and the dairy product consumption market has broad prospects. However, as the dairy product industry chain becomes increasingly complex, the existing dairy product traceability method is increasingly unsatisfactory.
[0003] The existing dairy product traceability method is mostly a fixed template or a manually generated link rule, which is difficult to adapt to the differentiated needs of different industry subjects, cannot dynamically adjust the link generation strategy according to user roles, business tasks or actual process differences, and lacks a mechanism for objectively evaluating the applicability of the traceability chain, making it difficult to distinguish between high-trust links and low-quality paths, and lacking a link evaluation, sorting and optimization system based on data indicators and business rules, resulting in high link misjudgment rate and insufficient credibility. In view of the problems in the related art, no effective solution has been proposed so far. SUMMARY
[0004] The purpose of the present application is to provide a method for dairy product traceability based on blockchain to overcome the above technical problems existing in the prior art.
[0005] In order to achieve the above-mentioned purpose, the specific technical scheme adopted by the present application is as follows:
[0006] A method for dairy product traceability based on blockchain is provided, comprising the following steps:
[0007] S1, collecting dairy product production process data, dividing the dairy product production process data into a plurality of dairy product data blocks, and storing them in a blockchain database;
[0008] S2, analyzing dairy product traceability requirements, obtaining traceability characteristic parameters, presetting a weight database, assigning weights to the traceability characteristic parameters and dairy product data blocks, and matching based on the weight assignment results;
[0009] S3, generate a dynamic traceability link based on the matching result according to the spatiotemporal coupling self-organizing model.
[0010] S4, preset an applicability threshold rule library, and jointly use the applicability threshold rule in the applicability threshold rule library and the grey correlation algorithm to evaluate the applicability of the dairy product traceability link.
[0011] S5, based on the applicability evaluation result, optimize and adjust the dairy product traceability link, and update the applicability threshold rule.
[0012] S6, based on the optimized dairy product traceability link, trace the dairy product, and generate a multi-level visual traceability result according to the user permission level.
[0013] As a preferred scheme, analyzing the dairy product traceability demand, obtaining the traceability characteristic parameters, presetting a weight database, distributing weights to the traceability characteristic parameters and the dairy product data blocks, and matching based on the weight distribution result include the following steps:
[0014] S21, data cleaning is performed on the dairy product traceability information, and the traceability demand content is clarified;
[0015] S22, set the traceability characteristic parameter extraction rule based on the traceability demand, and extract the traceability characteristic parameters from the dairy product traceability information according to the rule;
[0016] S23, preset a weight database, and set a mapping relationship between the traceability characteristic parameters and the weights;
[0017] S24, according to the weight mapping relationship, map the weight values in the weight database to the traceability characteristic parameters and the dairy product data blocks;
[0018] S25, calculate the feature weight score and block weight score of the mapped traceability characteristic parameters and dairy product data blocks, and match the mapped traceability characteristic parameters and dairy product data blocks based on the score similarity.
[0019] As a preferred scheme, calculating the feature weight score and block weight score of the mapped traceability characteristic parameters and dairy product data blocks, and matching the mapped traceability characteristic parameters and dairy product data blocks based on the score similarity include the following steps:
[0020] S251, calculate the feature weight score of the traceability characteristic parameters according to the mapped weight values, and perform normalization processing;
[0021] S252, obtain the set of traceability characteristic parameters in the dairy product data block, and calculate the block weight score of the dairy product data block based on the standardized weight score of each characteristic parameter in the set of traceability characteristic parameters;
[0022] S253, constructing a feature weight score vector and a block weight score vector based on the feature weight score and the block weight score;
[0023] S254, calculating a score similarity of the feature weight score vector and the block weight score vector using a cosine similarity algorithm;
[0024] S255, presetting a score similarity judgment threshold, and when the score similarity is greater than or equal to the similarity judgment threshold, determining that the traceability feature parameter and the dairy product data block are in a matching relationship, and when the score similarity is less than the similarity judgment threshold, considering that they are not matched and feeding back optimization.
[0025] As a preferred solution, the dynamic traceability link generation mechanism is preset according to the spatiotemporal coupling self-organizing model, and the dairy product traceability link is generated based on the matching result, including the following steps:
[0026] S31, constructing a spatiotemporal coupling self-organizing model based on the time parameter and the space parameter in the dairy product data block;
[0027] S32, according to the score similarity matching result, screening out the successfully matched traceability feature parameters and dairy product data blocks, and constructing a traceability node set;
[0028] S33, setting a dynamic traceability link generation mechanism according to the spatiotemporal coupling self-organizing model, and generating a dairy product traceability link based on the dynamic traceability link generation mechanism;
[0029] S34, verifying the structural consistency between the traceability node set and the dairy product traceability link, and based on the verification result, performing self-organizing optimization processing on the dairy product traceability link;
[0030] S35, outputting the optimized dairy product traceability link.
[0031] As a preferred solution, the spatiotemporal coupling self-organizing model is constructed based on the time parameter and the space parameter in the dairy product data block, including the following steps:
[0032] S311, extracting the block time parameter and the block space parameter in the dairy product data block, and cleaning the extracted data;
[0033] S312, constructing a spatiotemporal feature matrix according to the cleaned block time parameter and the block space parameter;
[0034] S313, establishing a coupling relationship graph based on the time sequence and the spatial proximity of the block time parameter and the block space parameter;
[0035] S314, merging the spatiotemporal feature matrix and the coupling relationship graph, and setting a self-organizing rule to obtain a spatiotemporal coupling self-organizing model;
[0036] S315, verify and optimize the spatio-temporal coupling self-organizing model, and output the verified and optimized spatio-temporal coupling self-organizing model.
[0037] As a preferred solution, according to the score similarity matching result, the successfully matched traceability characteristic parameters and dairy product data blocks are screened out, and the traceability node set is constructed, including the following steps:
[0038] S321, obtain the score similarity matching result, and set a score threshold for successful matching;
[0039] S322, according to the score threshold, screen out the successfully matched traceability characteristic parameters and dairy product data blocks;
[0040] S323, based on the successfully matched traceability characteristic parameters and dairy product data blocks, extract node time parameters, node space parameters and node association attribute information, and construct a traceability node set;
[0041] S324, perform de-duplication processing and structure integrity checking on the traceability node set, and output the de-duplicated and checked traceability node set.
[0042] As a preferred solution, a dynamic traceability link generation mechanism is set according to the spatio-temporal coupling self-organizing model, and a dairy product traceability link is generated based on the dynamic traceability link generation mechanism, including the following steps:
[0043] S331, based on the spatio-temporal coupling self-organizing model and the process chain data in the dairy product data block, set a dynamic traceability link generation mechanism;
[0044] S332, according to the process chain data, determine the traceability source node and the traceability target node;
[0045] S333, generate an initial link path through the dynamic traceability link generation mechanism from the traceability source node to the traceability target node;
[0046] S334, perform reachability verification optimization adjustment on the initial link path, and output the optimized and adjusted initial link path as the dairy product traceability link.
[0047] As a preferred solution, a suitability threshold rule library is preset, and a suitability threshold rule in the suitability threshold rule library is used in combination with a grey correlation algorithm to evaluate the suitability of the dairy product traceability link, including the following steps:
[0048] S41, according to the dairy product traceability demand, construct a suitability threshold rule library, and set a rule matching strategy;
[0049] S42, based on the rule matching strategy, match the suitability threshold rules in the suitability threshold rule library with the dairy product data block to obtain a set of suitability threshold rules;
[0050] S43, extract the link feature index vector in the dairy product traceability link, and bring the link feature index vector into a grey correlation algorithm to evaluate the applicability of the dairy product link;
[0051] S44, compare the applicability threshold rule set with the applicability of the dairy product link to obtain an applicability evaluation result.
[0052] As a preferred scheme, the applicability threshold rules in the applicability threshold rule library are matched with the dairy product data block based on a rule matching strategy to obtain the applicability threshold rule set, including the following steps:
[0053] S421, analyze the block attribute parameters of the dairy product data block, and clean the block attribute parameters;
[0054] S422, match the cleaned block attribute parameters with the applicability threshold rules in the applicability threshold rule library based on a rule matching strategy;
[0055] S423, summarize the matched applicability threshold rules to obtain the applicability threshold rule set;
[0056] S424, verify and optimize the applicability threshold rule set, and output the verified and optimized applicability threshold rule set.
[0057] As a preferred scheme, the link feature index vector in the dairy product traceability link is extracted, and the link feature index vector is brought into a grey correlation algorithm to evaluate the applicability of the dairy product link, including the following steps:
[0058] S431, extract the node information and path information in the dairy product traceability link, and construct a link feature index vector based on the node information and path information;
[0059] S432, generate a reference link index vector for applicability comparison based on the historical applicability link;
[0060] S433, use a grey correlation algorithm to calculate the correlation degree between the link feature index vector and the reference link index vector to obtain a link applicability score of the dairy product traceability link;
[0061] S434, verify and optimize the link applicability score, and output the verified and optimized link applicability score as a basis for subsequent link applicability determination.
[0062] The beneficial effects of the present application are:
[0063] 1. The application encapsulates dairy product production process data as data blocks and stores them in a blockchain database, ensuring the integrity, traceability and tamper resistance of the traceability data, and enhancing the data credibility foundation in the dairy product traceability process, improving the authority of dairy product quality and safety supervision, and setting the weight mapping relationship between the traceability characteristic parameters and the dairy product data blocks, combining the cosine similarity algorithm for scoring matching, improving the feature adaptation accuracy of the traceability node, so as to realize the customized link construction logic, support the individualized response of various traceability requirements, and based on the time parameter and space parameter of the dairy product data, construct a space-time coupled self-organizing model, with the self-organizing ability and scalability of the model, the traceability link with reasonable structure and optimal path can be dynamically generated in the complex node network, improving the stability, scalability and timeliness of the link construction.
[0064] 2. The application predefines the applicability threshold rule library, and combines the grey correlation algorithm to perform multi-index comprehensive evaluation on the generated traceability link, realizes the quantitative evaluation of the link quality, and can also optimize the rule model through comparative analysis, and then support high-quality iteration and self-learning optimization of the traceability link, and generate multi-level visual traceability display scheme according to user permission level, meet the visual needs of different users such as supervision agencies, consumers and enterprises, realize transparent display, hierarchical authorization and easy readability of traceability information, and enhance the public trust. BRIEF DESCRIPTION OF DRAWINGS
[0065] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed in the embodiments. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without creative labor.
[0066] Figure 1 A method for dairy product traceability based on a blockchain according to an embodiment of the present application. DETAILED DESCRIPTION
[0067] The specific embodiments of the present application will be further described in detail below in combination with the drawings and embodiments. The following embodiments are used to illustrate the present application, but not to limit the scope of the present application.
[0068] Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the claimed application, but only represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.
[0069] The present application will be further described in combination with the drawings and specific embodiments, such asFigure 1 As shown, the method for dairy product traceability based on blockchain according to the embodiment of the application comprises the following steps:
[0070] S1, collecting dairy product production process data, dividing the dairy product production process data into a plurality of dairy product data blocks, and storing them in a blockchain database;
[0071] Specifically, the dairy product production process data includes process data and environmental data of multiple stages such as raw material receiving, processing and handling, quality inspection, packaging and sealing, warehousing, cold chain transportation, etc. Data is collected through PLC control modules, MES systems, code scanning equipment, quality inspection instruments, intelligent sensors, etc. deployed in the production site, including raw material batch number, sterilization temperature, stirring rate, fermentation time, PH value, packaging serial number, environmental temperature and humidity, GPS positioning, etc. Each collection device accesses the edge gateway through industrial Ethernet and synchronously uploads data. All collected data is time-stamped and device-identified to construct a complete traceability data structure.
[0072] The data can be divided according to production batch number, process stage node or time period. Each data block includes a block header and a block body. The block header contains block ID, generation timestamp, previous block hash, signature information, etc. The block body contains a collection data set, a data digest (such as a Merkle tree root), a data check code, etc. All data fields are standardized to ensure uniform data format. At the same time, to ensure data integrity and traceability, the data subject is digitally signed.
[0073] A blockchain platform based on a consortium chain architecture is used. Chaincode (smart contract) is used to write block hash, signature digest, index information, etc. into the ledger to realize data on-chain storage. For block body content with large data volume, a combination of on-chain and off-chain methods can be used. The main data is encrypted and stored off-chain, and is bound to the on-chain metadata through a hash reference. On-chain transactions are confirmed by a blockchain consensus mechanism to ensure the non-tamperability and distributed consistency of traceability data throughout its life cycle.
[0074] S2, analyzing dairy product traceability requirements, obtaining traceability feature parameters, presetting a weight database, assigning weights to traceability feature parameters and dairy product data blocks, and matching based on the weight assignment results;
[0075] Specifically, analyzing dairy product traceability requirements, obtaining traceability feature parameters, presetting a weight database, assigning weights to traceability feature parameters and dairy product data blocks, and matching based on the weight assignment results comprises the following steps:
[0076] S21, data cleaning of dairy product traceability information, and clear traceability requirement content;
[0077] Specifically, the collected raw data is denoised, de-duplicated, field standardized, outlier processed and missing value completed. First, the redundant records, inconsistent time stamps, non-uniform device numbers and other information in the raw data are cleaned and standardized. Second, a rule-based outlier identification method is used to detect whether the temperature, PH value and other indicators exceed the rated working range set by the device. In combination with the time sliding window method, the mutation points are identified. For the missing parameters, linear interpolation, Lagrange interpolation and other methods are used for data completion to ensure the integrity and continuity of the traceability information. Meanwhile, a field mapping dictionary is introduced to standardize and convert the unstructured or semi-structured data.
[0078] After the data cleaning is completed, the traceability demand content is determined through user input, task scene classification, industry standard model, etc. The traceability target type concerned by the user (such as consumer, regulatory agency, production enterprise) and application scene (such as quality accountability, abnormality investigation, supply chain monitoring) is analyzed. The traceability request input by the user is extracted through natural language analysis or parameterized configuration, and is converted into a structured demand form, which includes demand type, time range, traceability granularity, target attribute field, etc. The history traceability task record and industry typical traceability scene template can be referenced for demand clustering identification to assist the user in quickly modeling the traceability target.
[0079] S22, setting traceability feature parameter extraction rules based on traceability demand, and extracting traceability feature parameters from dairy product traceability information according to the rules;
[0080] Specifically, the traceability demand information input by the user is analyzed to identify the traceability scene type to which it belongs, such as product accountability, abnormality detection, flow monitoring, environmental compliance, etc. According to different traceability scenes, the corresponding parameter template is called from the preset feature parameter rule library, which contains field name, field alias, source module, whether optional, field data type, matching rule and other information. Meanwhile, the keywords or target field prompts in the user input are referred to for secondary filtering and adjustment of the template parameters to generate a set of traceability feature parameter extraction rules corresponding to the current task, and a parameter data source mapping relationship table is established.
[0081] According to the set traceability characteristic parameter extraction rule, field screening, matching and formatting processing are performed on the dairy product traceability information to extract the characteristic parameters related to the task. First, the fields in different sources are uniformly mapped through the field alias table to ensure that the sterilization temperature and other fields belong to the same characteristic dimension. Second, type standardization conversion is performed on the extracted fields, including timestamp format unification, unit conversion, numerical precision control, etc. Third, missing fields are filtered according to the rule-identified optional items. Missing but required fields will trigger a warning or completion mechanism. Historical average value, upstream and downstream interpolation, logical deduction, etc. are used for completion. Finally, a structured characteristic parameter set is formed, including field name, value, unit, source, credibility score, etc., providing input basis for subsequent traceability link generation.
[0082] S23, preset weight database, and set traceability characteristic parameter and weight mapping relationship;
[0083] Specifically, the preset weight database and the setting of the traceability characteristic parameter and the weight mapping relationship include: first, according to the traceability demand and the target scene, a set of weight database needs to be preset, which is composed of multiple weight dimensions, and each dimension corresponds to a different traceability characteristic parameter. The setting of the weight dimension is based on the importance, correlation, credibility, etc. of the traceability data, and combined with expert experience or industry standards, different weight values are allocated. An initial weight is specified for each traceability characteristic parameter, and the weight value range can be between 0 and 1, indicating the degree of influence of the characteristic on the final traceability result.
[0084] Next, the traceability characteristic parameters and the corresponding weight values are associated through mapping rules. First, according to different traceability scenes and target requirements, relevant traceability characteristic parameters (such as production temperature, batch number, delivery time, etc.) are selected. For each selected characteristic parameter, find the corresponding weight value from the preset weight database, and map the weight and the characteristic parameter one-to-one or many-to-one. Each characteristic parameter will be mapped to one or more related weight dimensions, for example, product quality score may depend on both sterilization temperature and production time, while logistics monitoring may depend on transportation temperature and storage time, etc. At the same time, the weight database should also contain a dynamic updating mechanism to respond to different traceability requirements or external environmental changes. For example, if the influence of a characteristic parameter such as cold chain monitoring on traceability demand increases, the weight value of the characteristic can be automatically adjusted according to historical data and analysis results, thereby affecting the subsequent traceability evaluation results. Finally, through the automatic rule engine or manual adjustment, the mapping relationship between the characteristic parameters and the weights is constructed to ensure the data matching accuracy and flexibility in different scenes.
[0085] S24, according to the weight mapping relationship, map the weight values in the weight database to the traceability characteristic parameters and the dairy product data blocks;
[0086] Specifically, mapping the weight values in the weight database to the traceability feature parameters and the dairy product data blocks according to the weight mapping relationship comprises: first, based on the feature parameter extraction rules set in advance, all feature parameter sets involved in the current traceability task are identified, and the weight template matched therewith is called from the weight database. Each template is determined by the traceability scene type and the task target, wherein the weight distribution of each feature parameter in the current task is defined, such as sterilization temperature of 0.85, transportation time of 0.6, etc. Each weight value in the template is matched with the corresponding traceability feature parameter one by one to construct a parameter weight mapping table.
[0087] Subsequently, the weight values are assigned to the actual dairy product data blocks according to the mapping table. Specifically, for each data block, the set of cleaned and structured fields therein is first extracted, and field matching is performed with the traceability feature parameters involved in the current task; the matched fields are attached with the corresponding weight values to form a data structure with weight annotations. Each data field can be encapsulated in the form of a four-tuple, including the field name, field value, field source module and field weight, and in the process of constructing this structure, field alias resolution, unit conversion and type unification processing are supported to ensure the consistency and accuracy of field identification. In the multi-block joint traceability task, a block weight coefficient mechanism is introduced, and a block weight coefficient is assigned to each data block according to its belonging process stage (such as processing, packaging, transportation) or trust level, for example, the processing block is set to 1.0, and the transportation block is set to 0.8. Finally, the comprehensive weight value of each field is calculated, which is determined by the field weight and the block weight, and is used for subsequent feature scoring, link sorting and applicability evaluation modules.
[0088] S25, calculating the feature weight score and block weight score of the mapped traceability feature parameters and dairy product data blocks, and matching the mapped traceability feature parameters and dairy product data blocks based on the score similarity.
[0089] Specifically, calculating the feature weight score and block weight score of the mapped traceability feature parameters and dairy product data blocks, and matching the mapped traceability feature parameters and dairy product data blocks based on the score similarity comprises the following steps:
[0090] S251, calculating the feature weight score of the traceability feature parameters according to the mapped weight values, and performing normalization processing;
[0091] Specifically, calculating the feature weight score of the traceability feature parameter according to the mapped weight value and performing normalization processing includes: first, for each feature parameter in the dairy product data block that has been mapped to the weight, extracting its field value, corresponding weight value and data validity identifier; then calculating the preliminary feature weight score of each feature parameter, the formula is feature weight score = parameter weight value x parameter validity factor, wherein the validity factor is used to dynamically adjust the score, and when the parameter data is complete, has no missing and has no abnormality, the validity factor is 1, and if the parameter has missing or abnormality, a decay value between 0 and 1 is given according to the severity.
[0092] Next, the preliminary weight scores of all feature parameters are summarized to obtain the sum of all parameter scores in the current task, and the score of each feature parameter is divided by the sum to perform normalization processing. After normalization, each feature weight score value falls within the interval of 0~1, and the sum of all scores is equal to 1, and the formula is expressed as:
[0093] ;
[0094] Wherein n is the total number of traceability feature parameters involved in the current task, and i is the i-th feature parameter currently being processed. The feature weight score after normalization processing can effectively reflect the relative importance of each parameter in the current traceability task, and avoid the problem of score imbalance due to different total amounts of feature weights in different scenarios. Finally, the normalized feature weight score is bound with the field information of the dairy product data block to form a feature vector structure with the maximum weight score.
[0095] S252, obtaining a set of traceability feature parameters in the dairy product data block, and calculating a block weight score of the dairy product data block based on the standardized weight score of each feature parameter in the set of traceability feature parameters;
[0096] Specifically, obtaining the set of traceability feature parameters in the dairy product data block includes: first, according to the pre-set traceability feature parameter extraction rule, traversing the structured field information stored in the block, and matching with the pre-set feature parameter mapping table one by one through the field name, alias or label, screening out the field set related to the current traceability demand, forming the set of traceability feature parameters in the data block. For the same parameter that may appear in multiple blocks or have multiple sources, the optimal value is selected through the field source credibility, time stamp newness degree and other dimensions to ensure the uniqueness and accuracy of the feature parameter set.
[0097] Based on the acquired set of traceability feature parameters, the standardized weight score corresponding to each feature parameter is extracted, which is obtained by normalizing the pre-stage single-parameter weight mapping x effectiveness factor, representing the relative influence degree of the parameter on the current traceability demand. The standardized weight scores of all feature parameters in the same data block are summarized in a weighted superposition manner to form the block weight score of the block, and the specific calculation formula is:
[0098] ;
[0099] where m represents the number of effective traceability feature parameters in the data block, and is the standardized weight score of the i-th feature parameter, is the optional feature parameter correction factor (such as considering upstream and downstream logical dependence or weight transmission), and if there is no correction, it is defaulted to 1. If the traceability demand involves multiple block comparisons, the block weight score of each data block can be calculated, and then a block level weight coefficient can be set according to the process stage or credibility of the block, and further superposition or weighted average can be performed to generate a multi-block comprehensive weight, which is used for subsequent traceability link ordering, applicability scoring and abnormal point positioning. Finally, the block weight score is bound with the metadata of the block (such as block ID, hash, timestamp) to generate complete block weight description information, which can be used as basic data support for intelligent traceability link generation, similarity calculation and visualization display.
[0100] S253, constructing a feature weight score vector and a block weight score vector based on the feature weight score and the block weight score;
[0101] Specifically, constructing the feature weight score vector includes: first, extracting the standardized traceability feature parameter weight score from the current dairy data block, and each score value represents the relative importance of the feature in this traceability task. According to the fixed order of the parameters (such as the field ID, dictionary table order or priority sequence), the normalized weight score of each parameter is sequentially arranged into a one-dimensional vector, denoted as the feature weight score vector (Feature, Weight, Score, Vector, abbreviated as FWSV). Each element in the vector represents a standardized weight score of a feature parameter. This vector is a dense vector with a dimension consistent with the number of traceability parameters, which is used for subsequent similarity comparison with other block features, vector distance calculation and other analysis operations.
[0102] Next, according to the constructed feature weight score vector and the metadata information in the block, the block weight score of the current data block is calculated. After obtaining the final score of a single block, it will be grouped with all other block scores to form a multi-dimensional block score vector, denoted as block weight score vector (Block, Weight, Score, Vector, abbreviated as BWSV). Each element in this vector represents the comprehensive weight score of a data block. The comprehensive weight score of each block is obtained by multiplying and adding the weight scores of all features in the block with the corresponding correction factor or credibility index. Finally, the feature weight score vector (FWSV) and the block weight score vector (BWSV) are used as two types of basic vector structures for traceability tasks, for feature similarity matching (through cosine similarity, etc.), multi-block score comparison (such as weight sorting, main chain selection), block visualization of traceability path display (such as drawing weight radar chart, score heat map, etc.).
[0103] S254, calculate the score similarity of the feature weight score vector and the block weight score vector using the cosine similarity algorithm;
[0104] Specifically, the cosine similarity is a measure of the cosine of the angle between two vectors. By calculating the cosine value, we can judge the directional similarity of two vectors. The value ranges from -1 to 1, and the specific meaning is as follows: 1 represents complete similarity (the direction of the two vectors is consistent), 0 represents no similarity (the two vectors are orthogonal, and there is no relationship in direction), -1 represents complete opposition (the direction of the two vectors is completely opposite), and the formula for calculating the cosine similarity is:
[0105] ;
[0106] where, is the cosine similarity, AB is the dot product (inner product) of vectors A and B, and is the modulus of vector A (i.e. the length of the vector), is the norm of vector B. Calculate the similarity between the feature weight score vector and the block weight score vector. Assume that FWSV (feature weight score vector) is a vector composed of the normalized weight scores of each feature parameter, and that the feature weight score vector (FWSV) has a weight score corresponding to each feature parameter, which will form a vector. BWSV (block weight score vector) is a vector composed of the comprehensive weight scores of each data block, and the block weight score vector (BWSV) also forms a vector with the comprehensive score of each block. Dot product (inner product) is to calculate the product of the corresponding position elements of two vectors and sum them up. For the feature weight score vector and the block weight score vector, the elements at the corresponding positions in the feature weight score vector and the block weight score vector are multiplied and summed. Then the norm of each vector is the square sum of its elements, and the norm of each vector is calculated. Finally, the similarity between the two vectors is calculated by the cosine similarity formula.
[0107] If the calculated cosine similarity is close to 1, it means that the two vectors are very similar in direction, i.e. their feature weight scores and block weight scores are highly consistent to some extent. If the calculated cosine similarity is close to 0, it means that the two vectors are orthogonal, i.e. there is no correlation or similarity between them. If the calculated cosine similarity is close to -1, it means that the directions of the two vectors are completely opposite, indicating that they have little similarity and may represent different traceability requirements or data patterns.
[0108] S255, a preset score similarity judgment threshold is set, and when the score similarity is greater than or equal to the similarity judgment threshold, the traceability feature parameter and the dairy product data block are determined to be in a matching relationship, and when the score similarity is less than the similarity judgment threshold, it is considered to be not matched, and feedback optimization is performed.
[0109] Specifically, when constructing the traceability matching model, a score similarity judgment threshold is set in advance to determine whether the feature weight score vector and the block weight score vector constitute a matching relationship. The meaning of this threshold is: when the calculated similarity is higher than or equal to this value, it is considered that the feature expressions of the two are similar enough, and it is determined to be matched; otherwise, it is not matched. This threshold is usually set in the following ways: experience setting, such as default value 0.80 or 0.85; based on the mean + standard deviation of the training set sample statistics; or based on the F1 score optimal solution of the validation set evaluation. If the threshold is set to 0.80, it means that the similarity is ≥ 0.80, otherwise it is considered to be not matched.
[0110] When a set of feature weight score vectors and a block weight score vector of a data block are obtained, the following judgment process is performed to calculate the cosine similarity. The similarity score between the feature weight score vector and the block weight score vector is calculated using the standard cosine similarity algorithm, with a value range of [-1, 1], and in practice, it is usually between [0, 1]. Then, threshold comparison is performed. If the score similarity is greater than or equal to a preset threshold, it is determined that the current feature and the block are in a matching relationship. The matching relationship is recorded in the task matching graph or the matching mapping table for link construction or label assignment. It can be used as a component node in the subsequent traceability path. If the score similarity is less than the preset threshold, it is determined as not matching. At the same time, a feedback optimization mechanism is entered to continuously improve the matching accuracy and robustness.
[0111] At the same time, in order to avoid false rejection or solidification bias, a feedback analysis process should be automatically triggered after each mismatch determination. The current score context is recorded, including feature weight score vector, block weight score vector, similarity value, task ID, block ID, timestamp, etc. Auxiliary information such as task type and business label can also be captured. The reason and context features are analyzed: whether the similarity is low due to missing feature dimensions (such as missing part of the feature score); whether individual high-weight feature values are abnormal in the block; whether the overall feature expression is offset, only close in numerical level but not in semantics; and strategy optimization (at least one of the following) is performed: dynamic threshold adjustment: if critical similarity false rejection frequently occurs in multiple tasks, the threshold can be slightly adjusted (such as 0.80-0.78); feature correction: for weight abnormal or expression error feature items, trigger rule repair or model retraining; data completion: if some important features are missing in the block, scheduling logic or interpolation filling can be used to form an optimization closed loop. Each mismatch record can be accumulated in the feedback optimization log library, and regular statistical analysis is triggered to drive the score mechanism to continuously evolve.
[0112] S3, presetting a dynamic traceability link generation mechanism based on the spatiotemporal coupling self-organizing model, and generating a dairy product traceability link based on the matching result;
[0113] Specifically, the presetting of the dynamic traceability link generation mechanism based on the spatiotemporal coupling self-organizing model and the generation of the dairy product traceability link based on the matching result include the following steps:
[0114] S31, constructing a spatiotemporal coupling self-organizing model based on the time parameter and the space parameter in the dairy product data block;
[0115] Specifically, the construction of the spatiotemporal coupling self-organizing model based on the time parameter and the space parameter in the dairy product data block includes the following steps:
[0116] S311, extracting the block time parameter and the block space parameter in the dairy product data block, and cleaning the extracted data;
[0117] Specifically, in the dairy product data block, there are usually structured metadata fields, such as processing time, transportation start and end time, packaging time, warehousing time, delivery time, temperature control collection time, etc., which belong to block time parameters; at the same time, the fields may also contain geographic or geographic identification related information, such as production place, storage place, departure place, destination, coordinate point, logistics track, etc., which belong to block space parameters.
[0118] And the specific extraction process is as follows: first, traverse all the fields in the data block, and combine the pre-set parameter naming mapping table to perform keyword matching, for example: time class field identification keywords: contain time, time, collection time, etc.; space class field identification keywords: contain address, place, location, coordinate, geographic code, etc., for the identified fields, further analyze whether the content format conforms to the expected data type: time field should be standard timestamp, date string or convertible format; space field should be address, coordinate pair or structured location identifier (such as administrative division code) that can be parsed. Then extract the confirmed fields into standard time parameters and space parameters format.
[0119] After extraction, in order to ensure the accuracy of subsequent analysis or similarity calculation, data cleaning needs to be performed on the original extraction results, mainly including filtering out time and space fields that are empty or placeholders (such as —, no, N / A); configurable whether to allow partial field missing, such as only keeping data blocks with time or time and space existing at the same time. Format standardization verification: all time fields are converted to a unified format, if the format is not compliant (such as 202307-33), it is excluded or recorded as an exception; coordinates need to be within a legal value range (latitude -90~90, longitude -180~180), otherwise it is considered invalid. Exception value elimination and correction suggestion: check if the time is earlier than the minimum allowed time (such as before 1970), or later than the current time; for repeated, too dense, and abnormal offset situations in coordinate set, record exceptions and suggest data source correction. Rename and field mapping uniformity: map the field name to a standard internal field identifier.
[0120] S312, constructing a space-time feature matrix according to the cleaned block time parameters and block space parameters;
[0121] Specifically, the time parameters and the space parameters of the block are mapped to structured numerical features for subsequent model training, similarity calculation, path reasoning or visual analysis. The cleaned dairy product data block often contains the following fields: time parameters (such as processing time, packaging time, warehousing time, delivery time, transportation start and end time, etc.); space parameters (such as latitude and longitude coordinates, location code of origin, storage location, transportation path start and end point, etc.); all time parameters are converted into a comparable numerical representation, such as converting into a timestamp or converting into a relative time (such as the number of seconds from the start of the task), and latitude and longitude coordinates are directly used or binned according to requirements (such as divided into regional grids) or mapped to administrative division codes, city IDs, grid numbers, etc. The straight-line distance between the start and end points can be calculated or the path offset angle, orientation and other directional features can be constructed. In combination with time and space, the following features can be extracted for modeling, such as time period x geographic location cross coding (for example: daytime transportation x high latitude area); active period statistics of specific areas; spatiotemporal continuity score (judging whether the path and time meet the flow logic); block spatiotemporal unique identifier (such as generated by block ID + timestamp + coordinate grid). The above extracted time and space numerical features are organized into a unified matrix structure, each row represents a data block, and each column is a spatiotemporal dimension feature, and the feature matrix can be used as model input or for scoring vectorization, spatiotemporal similarity matching, etc.
[0122] S313, based on the time sequence and space proximity of the block time parameters and the block space parameters, a coupling relationship graph is established;
[0123] Specifically, constructing a spatiotemporal coupling relationship graph according to the block time parameters and the block space parameters includes: first, extracting standardized time stamp and geographic coordinate information from the cleaned data block, ensuring that all time fields are of a comparable numerical type (such as Unix timestamp), and unifying the space fields to standard geographic coordinates (WGS84 coordinate system). Each block node will be assigned a unique time and space attribute label as the basic feature of the node in the graph.
[0124] Then all blocks are sorted according to the time sequence rule. For each pair of blocks with a time sequence relationship, it is determined whether the time difference is within a set acceptable window range (such as 0-72 hours). When the time flow logic is met, a time edge is established between the two blocks, the edge is a directed edge, the direction points to the block with later time, and can be attached with the time interval as the edge weight for subsequent sorting or shortest chain calculation, at the same time, the straight line distance between any two blocks is calculated based on the geographical coordinates in the spatial dimension. When the distance is less than the preset spatial proximity threshold (such as 5km or 10km), it is considered that the two blocks have spatial coupling. A spatial edge is added to the graph, which is an undirected edge, and the actual distance value or its reciprocal value is recorded as the edge weight to represent the coupling strength. Finally, all time edges and spatial edges are added to the spatiotemporal coupling graph to form a graph structure composed of nodes (blocks) and multiple types of edges (spatiotemporal). Each edge in the graph represents the possible transmission, flow or proximity relationship between two blocks. For edges that meet both the time sequence and spatial proximity, they can be marked as strong coupling edges, which are preferentially used in tasks such as traceability main path construction or abnormal path mining. If used in practice, the coupling relationship graph can be exported as a graph database (such as Neo4j) structure, or converted into a matrix expression for deep learning model graph input, supporting batch scoring, path prediction and visualization display operations.
[0125] S314, merge the spatiotemporal feature matrix and the coupling relationship graph, and set a self-organizing rule to obtain a spatiotemporal coupling self-organizing model;
[0126] Specifically, the merging of the spatiotemporal feature matrix and the coupling relationship graph, the spatiotemporal feature matrix is to convert the time parameters and spatial parameters of the dairy product data blocks into a structured numerical feature matrix, each row represents a block, and each column represents a feature dimension. For example, the columns of the matrix can include timestamp, geographical coordinates, time difference, distance, transportation duration, etc. The coupling relationship graph describes the time flow and spatial proximity relationship between different data blocks by constructing a directed graph and an undirected graph of spatiotemporal coupling. The nodes in the graph represent data blocks, and the edges represent the spatiotemporal relationship between the blocks.
[0127] The merging method includes node merging: each block node has a corresponding spatiotemporal feature vector in the graph. These features come from each row in the spatiotemporal feature matrix, so each row in the spatiotemporal feature matrix can be used as an attribute of the graph node to extend the existing coupling relationship graph. Or edge merging: the edges in the coupling relationship graph represent the spatiotemporal relationship between blocks, which can be enriched by adding spatiotemporal related features (such as time difference, spatial distance, etc.) to the attributes of the edges. The numerical values in the spatiotemporal feature matrix can be mapped to the edges in the coupling relationship graph, thereby enhancing the expression ability of the graph.
[0128] The design of the self-organizing rule aims to dynamically adjust the structure of the graph through the interaction of nodes and edges, and learn the potential spatio-temporal correlation pattern. By setting some rules, the nodes and edges in the graph are adjusted adaptively according to the local information, so as to continuously optimize the spatio-temporal coupling relationship, and the self-organizing rule design can be based on the feature vector of the graph node and the spatio-temporal relationship of the neighbor node. Common rules include: the feature vector of each node is updated by weighting the spatio-temporal features of the neighbor nodes, and the weight of the edge can be dynamically adjusted according to the similarity and coupling strength between nodes. For example, if two nodes are highly coupled in space and time (both in time sequence and spatial proximity), the weight of the edge between them can be increased. Self-organizing optimization includes local structure optimization: based on the features and similarity of adjacent nodes, the nodes and edges in the graph will be continuously adjusted to optimize the spatio-temporal coupling structure. For example, in some traceability chains, it may be necessary to strengthen the association strength between certain features to help the model better capture specific patterns. Or adopt global pattern discovery: as the self-organization proceeds, the global structure of the graph gradually presents a specific spatio-temporal coupling pattern, helping to explore deeper relationships between data blocks. For example, it may be found that certain production sites and storage sites have strong spatio-temporal coupling in a certain time period, thereby optimizing the traceability path. By merging the spatio-temporal feature matrix and the coupling relationship graph, and iteratively updating according to the self-organizing rule, a spatio-temporal coupling self-organizing model can be finally obtained.
[0129] S315, verifying and optimizing the spatio-temporal coupling self-organizing model, and outputting the verified and optimized spatio-temporal coupling self-organizing model.
[0130] Specifically, the verification and optimization of the spatio-temporal coupling self-organizing model includes: first, a set of dairy product data blocks with real traceability paths or labeled coupling relationships are prepared as a verification set. The real spatio-temporal path label (such as time sequence chain, spatial path node) of each block is extracted from the verification set and compared with the coupling graph structure generated by the model self-organization, which is used to evaluate the accuracy of the model inference path, the coverage rate of the coupling edge and the error association rate. Then a set of evaluation indicators are used to quantitatively evaluate the current model performance. Common indicators include: path matching rate (whether the nodes in the real path are completely correctly connected by the self-organizing model), edge accuracy (whether the model coupling edge actually exists), F1 score (considering both precision and recall), etc. At the same time, graph structure similarity metrics (such as graph edit distance, adjacency matrix similarity) can also be used as evaluation basis. If the model is low in some indicators, it indicates that there are problems such as overfitting, overconnection, and time sequence disorder.
[0131] According to the above results, the automatic optimization phase will be entered, and the feedback rules will be applied for self-organization correction: for example, adjusting the edge weight update rule (slowing down the reinforcement speed of unimportant edges), adjusting the node update strategy (improving the self-stability of important nodes), or setting an edge deletion threshold to remove redundant connections. Further, a supervised fine-tuning mechanism can be introduced to verify the set results to guide the model structure to converge to the real path direction, and to improve the structural robustness and interpretability. Finally, the optimized spatio-temporal coupling self-organizing model is output, which has the following characteristics: the coupling graph structure is closer to the real data flow logic, the distribution of spatio-temporal edges is more consistent with the actual link direction, the feature expression of key nodes is clearer, and the coupling path has stronger traceability readability. The model can be directly used for online deployment, or further integrated with downstream traceability analysis models (such as path prediction and anomaly detection) for use, forming a spatio-temporal intelligent closed-loop system.
[0132] S32, according to the scoring similarity matching result, screening out the successfully matched traceability feature parameters and dairy product data blocks, and constructing a traceability node set;
[0133] Specifically, according to the scoring similarity matching result, screening out the successfully matched traceability feature parameters and dairy product data blocks, and constructing a traceability node set includes the following steps:
[0134] S321, obtaining the scoring similarity matching result, and setting a scoring threshold for successful matching;
[0135] Specifically, after the construction of the feature weight scoring vector and the target data block feature vector, the scoring similarity between the two is obtained through a similarity calculation function (usually cosine similarity). The scoring value is a real number, ranging between [0, 1] and [0, 1], and the higher the value, the more consistent the feature distribution between the two vectors. This similarity value is the core basis for judging whether the traceability features match the target block. Next, a matching threshold for scoring similarity needs to be set in advance to determine the boundary between matching and non-matching. This threshold can be manually set according to actual business needs (such as 0.85), or the best value can be obtained based on statistical analysis of the validation set sample data (such as using the best segmentation point under the ROC curve). When the calculated similarity value is greater than or equal to the threshold, it is considered to be a successful match; otherwise, it is considered to be a failed match.
[0136] When performing the matching judgment, a matching result mark is output for each comparison object, including: a similarity score value, whether the matching is successful (a Boolean mark), a reference threshold, a related traceability feature name, and the like. The matching result is stored in a task cache or a result table for subsequent traceability path analysis or manual review and correction. In order to enhance robustness, the threshold mechanism can be set in layers, for example, a strong matching threshold and a weak matching threshold are introduced, and if the similarity is between the two, manual review or automatic optimization strategy is triggered. Through this mechanism, the matching accuracy can be guaranteed, and a flexible man-machine cooperation mechanism can be introduced in the gray area scenario, thereby improving the reliability and controllability of the overall traceability judgment.
[0137] S322, screening the successfully matched traceability feature parameters and dairy product data blocks according to the score threshold;
[0138] Specifically, after completing the similarity calculation between each group of traceability feature parameters and dairy product data blocks, a score similarity value is obtained, usually using cosine similarity or weighted vector angle calculation method, and the result value is between [0, 1] and [0, 1]. Each score result record contains: traceability feature ID, block ID, score similarity value, comparison time and the like. This score value reflects the matching degree of the feature and the target data block in structure and semantics, and then, according to the pre-set score threshold (such as 0.85), the matching judgment is performed. For each score result, if the similarity is greater than or equal to the set threshold, it is considered that the group of traceability feature parameters and the dairy product data block form a matching relationship; otherwise, it is considered as a non-matching relationship or a low confidence matching. The score threshold can be dynamically adjusted according to the task accuracy requirement, or a multi-level threshold (such as strong matching and weak matching) can be used for classification processing.
[0139] After the judgment is completed, all score similarities greater than or equal to the matching threshold are extracted as matching successful items. These records are usually organized as a structured output table containing fields: feature ID, block ID, score value, matching state, and the like, and written into a matching result set for subsequent traceability chain construction, visualization graph generation or manual checking. In order to improve transparency and automation capability, a matching distribution statistical chart or a matching confidence score hierarchical view can also be generated to help operation and maintenance personnel understand the matching accuracy, misjudgment risk and optimization space. In this way, while ensuring the accuracy of traceability, data support is also provided for model continuous iteration and strategy adjustment.
[0140] S323, based on the successfully matched traceability feature parameters and dairy product data blocks, extracting node time parameters, node space parameters and node associated attribute information, and constructing a traceability node set;
[0141] Specifically, after completing the scoring matching of the traceability feature parameters and the dairy product data blocks, and screening all matching records, a corresponding traceability node is constructed based on each matching pair. Each node represents a dairy product data block that is successfully identified as a traceability target, and its core features come from the space-time and attribute information of the block itself. First, the node time parameter and the node space parameter are extracted from each matching block. The time parameter usually includes event time, transit time or warehouse entry / exit time, etc., which needs to be converted into timestamp or standard time format; the space parameter mainly includes coordinate point geographic coding, ensuring the use of a unified coordinate system for subsequent spatial path restoration, visual trajectory drawing, etc.
[0142] Next, the associated attribute information of each node is extracted, including but not limited to: block ID, product batch number, supplier number, processing link type (such as packaging, inspection, transportation, etc.), data source identifier, upstream and downstream association ID, etc. These information helps to identify the semantic relationship between nodes when constructing the traceability graph, assisting in edge generation, path sorting and main chain extraction, etc. Finally, all nodes that meet the conditions are organized into a structured set, i.e. the traceability node set. Each node in the set has a unique identifier and complete time, space and attribute triple information
[0143] S324, performing de-duplication processing and structure integrity check on the traceability node set, and outputting the de-duplicated traceability node set.
[0144] Specifically, after completing the preliminary construction of the traceability node set, de-duplication processing needs to be performed to eliminate duplicate node records and avoid introducing redundant links or redundant paths in the subsequent graph structure. The de-duplication rule is usually based on the combination of block unique identifier, timestamp and coordinate, batch number and link type triplets, etc. If multiple records have the same core features or high similarity (such as time difference less than 1 second, coordinate error within acceptable range), keep the one with higher score or more complete data, and delete the other redundant nodes.
[0145] Next, structure integrity check will be performed on each node to ensure that the node contains complete time, space and attribute triple information. The check content includes: whether the time parameter is empty or illegal (such as negative timestamp, format error), whether the space parameter is missing or not within the legal range (longitude and latitude are not within the range of earth coordinates), whether the attribute field has key identifiers (such as batch number, processing type, etc.). For nodes with serious missing or format errors, mark them as structurally incomplete, which can be set as invalid nodes to be removed, or moved to the to-be-audited set for manual intervention.
[0146] After cleaning, a set of de-duplicated traceable nodes will be formed, each node having complete timestamp, standardized coordinates and necessary attribute identification, and no redundancy and conflict in the set. This set can be used as the basic input for final graph construction and path tracking, and also for advanced analysis processes such as multi-round feature training, path prediction and node clustering. This de-duplication process not only improves the structural accuracy of the traceable graph, but also lays a solid foundation for the stability and interpretability of subsequent models, ensuring the logical coherence and factual accuracy of the data chain.
[0147] S33, setting a dynamic traceable link generation mechanism according to the space-time coupling self-organizing model, and generating a dairy product traceable link based on the dynamic traceable link generation mechanism;
[0148] Specifically, setting a dynamic traceable link generation mechanism according to the space-time coupling self-organizing model, and generating a dairy product traceable link based on the dynamic traceable link generation mechanism includes the following steps:
[0149] S331, setting a dynamic traceable link generation mechanism based on the space-time coupling self-organizing model and the process chain data in the dairy product data block;
[0150] Specifically, the generation of the dynamic traceable link is based on the space-time coupling self-organizing model, and combines the process chain data (such as raw material receiving-pasteurization-filling-packaging-warehousing) marked or inferred in each dairy product data block for matching and guiding. First, according to the time sequence and spatial coordinates of each block in the node set, all coupling relationship edges are selected from the self-organizing model, and the process link types carried by these nodes are cross-verified as the starting point and candidate transfer point of the path.
[0151] Subsequently, the process chain logic constraint is applied to build a dynamic transfer rule, i.e., reverse flow jumps such as packaging-pasteurization are not allowed, and the process chain sequence relationship must be followed. Meanwhile, in each step of dynamic path expansion, factors such as time weight, spatial distance, coupling strength, and process logic compatibility are considered to build a scoring function to dynamically score each reachable path, and the path with the highest score is selected as the optimal transfer path at the current stage. The entire generation process uses the node-by-node iteration + scoring sorting method, and each newly generated node is used as the tail node of the current path to continue searching downward until the path end point (such as the terminal node of delivery / sales, etc.) is reached, or the set time span and spatial jump threshold are reached to stop generation. This mechanism ensures that the generated path conforms to the time and space logic in structure, follows the processing flow in semantics, and preferentially selects links with higher confidence in the scoring mechanism. Finally, the generated dynamic traceability links are organized into a directed graph path set, and each path represents a complete dairy product flow process. It can be used to automatically draw traceability trajectory maps, support abnormal node traceability, link breakpoint diagnosis, etc., and can also be output as a structured result for downstream model calling or audit interface use.
[0152] S332, determining the traceability source node and the traceability target node according to the process chain data;
[0153] Specifically, when analyzing the dairy product data blocks, the process chain link information such as raw material reception, pasteurization, canning, packaging, warehousing, delivery, transportation, and distribution is extracted from each block. By analyzing these process types and their time sequence, a complete process chain model can be established. The process chain is a directed sequence that gradually advances in the direction from production to sales, and node positioning can be performed accordingly.
[0154] In the determination of the traceability path, the traceability source node usually corresponds to the starting link of the process chain (such as raw material reception or the first processing), and this node is the earliest node on the traceability chain and has a traceable source. The traceability target node is the final link in the chain (such as delivery, terminal distribution, or consumer receipt), representing the end node of the dairy product reaching the final state. According to the link label and time stamp sorting results of each node, the earliest and latest nodes are selected as the source and target candidates. To improve accuracy, the structural relationship between upstream and downstream nodes can also be logically verified. For example, if a node is the earliest in time but the link type is transportation rather than raw material reception, it can be excluded from consideration as a source node. Only nodes that meet both the logical first link and the earliest time criteria can be identified as valid traceability source nodes. Similarly, the target node must be a combination of the consumer end or delivery end process and the latest time.
[0155] Finally, a unique source node and one or more target nodes will be output for subsequent dynamic path deduction, visual path tracking, and source determination. If there are multiple candidate target nodes (such as cross-regional outbound), multiple terminal nodes can be retained for parallel analysis. This method ensures that the traceability path structure is clear, the starting point is clear, and the ending point is reasonable, providing clear start and end coordinates for traceability link construction.
[0156] S333, generating an initial link path between the traceability source node and the traceability target node through a dynamic traceability link generation mechanism;
[0157] Specifically, after the starting point (source node) and the end point (target node) of the traceability are determined, a dynamic traceability link generation mechanism is started to construct an initial link path connecting the two. This mechanism takes the source node as the starting point of the path, continuously expands the candidate path through the graph structure in the space-time coupled self-organizing model, and follows the process chain order, time sequence logic, and spatial proximity constraints to ensure the generated path is real and feasible.
[0158] During path expansion, a directed path search algorithm (such as time-constrained breadth-first or depth-first traversal) is used. Each time, starting from the current node, the next node that meets the following conditions is found: later in time than the current node, not more than the maximum jump distance in space, and consistent with the process chain successor logic. For example, starting from the filling link, only nodes of the packaging or warehouse-in type are accepted as legal path expansion points. In order to improve the accuracy and efficiency of the path, each candidate path is dynamically scored, considering factors such as edge weight (time interval, distance), node matching score, process logic consistency, etc. The path with the highest score will be retained as the initial link path. If there are multiple paths with similar scores, multiple paths can be retained in parallel for subsequent verification.
[0159] The final generated initial link path will be output in the form of a node sequence, presenting a time-ordered chain that connects the source node to the target node step by step. This path has logical closure, space-time consistency, and semantic interpretability, and can be used as a basic framework for subsequent path optimization, anomaly judgment, and graph visualization. This mechanism realizes the precise traceability link generation logic from the starting point to the end point, adapting to dynamic and complex data scenarios.
[0160] S334, performing reachability verification optimization adjustment on the initial link path, and outputting the optimized initial link path as the dairy traceability link.
[0161] Specifically, after generating the initial link path, the overall connectivity and logical rationality of the path need to be checked for reachability. First, from both ends of the link, check whether the source node has at least one out-edge that can be expanded backward, and whether the target node can be connected by other nodes. If it is found that there is a path break or a node is suspended, the backtracking mechanism will be used to re-evaluate the connection edges at the breakpoint to determine whether the path is interrupted due to a large time difference, too far space jump, or inconsistent process steps.
[0162] Then, path integrity optimization adjustment is performed, that is, under the premise of not violating the process logic and space-time constraints, try to complete the missing jump at the breakpoint from the candidate node set. For example, if the path is missing the warehouse link and directly jumps from packaging to transportation, search for a high-score node with a warehouse process type between packaging and transportation in time to automatically fill in and enhance the business closed-loop nature of the path. The weight distribution of each edge in the link and the total confidence of the path are also evaluated. If there are some abnormal high time delay, too long space jump, or low similarity edges in some path segments, edge weight adjustment or path segment replacement is performed. At the same time, combined with the actual process chain constraints, the rule engine can be used to remove logically incorrect links, such as reverse sequence jumps from distribution to packaging.
[0163] Finally, the optimized and adjusted dairy product traceability link is output, which is a directed path set starting from the source node and connecting to the target node layer by layer. All path nodes have passed the space-time consistency check, process logic check, and scoring confidence evaluation, and have high readability and usability. This link can be directly used for downstream tasks such as graph visualization display, link backtracking analysis, and abnormal event positioning, achieving high-precision and high-confidence dynamic traceability.
[0164] S34, verifying the structural consistency between the traceability node set and the dairy product traceability link, and based on the verification result, performing self-organizing optimization processing on the dairy product traceability link;
[0165] Specifically, first, the structural consistency between the traceability node set and the dairy product traceability link needs to be verified. This process includes two aspects: node consistency and path consistency. Node consistency refers to whether each node in the traceability node set is correctly represented in the traceability link, that is, whether each block is correctly embedded in the link structure according to its time, space, process link, etc. Path consistency refers to whether the path in the traceability link conforms to the time sequence of the process chain, the spatial proximity, and the coupling relationship between nodes.
[0166] In the verification process, each node in the link will be checked first to ensure that the position of the node in the traceability link matches its characteristics in the node set, such as timestamp, process link, etc. If it is found that there are missing, repeated or wrong positions in the nodes in the link, it will be marked as inconsistent structure and the part that needs to be optimized will be recorded. Then, the path consistency check is carried out to ensure that the nodes in the link are correctly connected in time sequence and meet the flow logic of the process chain. Each edge in the path must represent a legal space-time transition, and each transition must meet the preset space-time proximity and process logic requirements. If a path that does not meet the conditions (such as reverse flow, crossing too far distance, etc.) is found, it is considered inconsistent and needs to be further optimized.
[0167] After the structure consistency verification, the self-organizing optimization processing stage is entered. Based on the verification results, the inconsistent parts in the link will be automatically adjusted. First, the node correction is carried out to ensure the integrity and accuracy of the node information. For the unmatched nodes, replacement or reordering will be carried out to ensure the consistency of the node information and meet the space-time continuity. For the non-compliant path, local repair will be carried out according to the space-time coupling relationship and process chain constraints. For example, for the problem of time fracture or large space jump in the path, adjacent nodes will be introduced, edge weights will be recalculated, and path connection order will be adjusted until the link structure that meets the actual flow is restored. In the self-organizing optimization process, a feedback mechanism is also used to continuously evaluate the correctness and optimization effect of the link structure after each adjustment to ensure that the final link is more consistent with the traceability requirements in the global.
[0168] S35, output the dairy product traceability link after optimization processing.
[0169] S4, preset the applicability threshold rule library, and use the applicability threshold rule in the applicability threshold rule library to evaluate the applicability of the dairy product traceability link in combination with the grey correlation algorithm;
[0170] Specifically, the applicability threshold rule library is preset, and the applicability threshold rule in the applicability threshold rule library is used to evaluate the applicability of the dairy product traceability link in combination with the grey correlation algorithm, which includes the following steps:
[0171] S41, according to the dairy product traceability requirements, construct the applicability threshold rule library, and set the rule matching strategy;
[0172] Specifically, an applicability threshold rule base needs to be constructed based on the business scenarios and core objectives of dairy product traceability. Applicability refers to the acceptability or trust level of a particular traceability node or path segment in the current traceability task. The rule base should set scoring thresholds around the following core dimensions: time difference threshold (e.g., the time interval between nodes should not exceed 48 hours); spatial jump distance (e.g., the straight-line distance between two nodes should not exceed 50 kilometers); logical legality of process steps (e.g., filling must occur after sterilization); lower limit of similarity score (e.g., feature matching degree ≥ 0.85); data credibility level (e.g., sensor / manual verification of labels takes precedence).
[0173] Next, a rule matching strategy needs to be defined so that these threshold rules can be dynamically referenced during the construction of the traceability chain. Common strategies include: node-by-node filtering strategy (i.e., comparing each threshold item by node feature and retaining only nodes that meet the rules); path scoring strategy (judging the validity of a path based on the average or minimum value of each scoring indicator in the entire path); and dynamic penalty mechanism (if a path segment violates a rule, a score decay is applied or it is marked as a weak link segment).
[0174] Furthermore, to adapt to different traceability objectives and data scenarios, the rule base should support custom configuration and a tiered loading mechanism. For example, a more lenient threshold range can be set for routine regulatory traceability, while a stricter rule set can be loaded for anomaly recall traceability to prioritize accuracy and the integrity of the chain of responsibility. Rule matching strategies can also be adjusted according to task type, prioritizing rapid link construction or high-confidence link verification. Ultimately, through the joint execution of the aforementioned rule base and matching strategies, the most suitable nodes and path segments can be automatically selected during the traceability chain construction process, improving the structural reliability and semantic rationality of the link, and providing flexible and robust technical support for the entire dairy product traceability chain.
[0175] S42. Based on the rule matching strategy, the applicability threshold rules in the applicability threshold rule base are matched with the dairy product data blocks to obtain the applicability threshold rule set;
[0176] Specifically, the process of matching the applicability threshold rules in the applicability threshold rule base with the dairy product data blocks based on the rule matching strategy to obtain the applicability threshold rule set includes the following steps:
[0177] S421. Parse the block attribute parameters of the dairy product data block and clean the block attribute parameters;
[0178] Specifically, the block attribute parameters need to be parsed from the original dairy product data block. These parameters usually include, but are not limited to, block unique identification, product batch number, processing technology type (such as sterilization, packaging, transportation), responsible subject (such as manufacturer or warehouse code), data source (such as manual record or sensor data), timestamp, spatial coordinates, etc. Structured extraction of these fields generates standardized data tables or feature vector representations, facilitating subsequent modeling and graph structure embedding.
[0179] Next, attribute parameter cleaning operation is performed, aiming to improve data quality, eliminate redundancy and abnormal items, and finally the cleaned block attribute parameters will have good consistency, integrity and interpretability, which can be used as standard input for subsequent traceability chain construction, graph generation and node coupling judgment. This step is the data foundation in the entire dairy product traceability modeling process, directly determining the accuracy and stability of link analysis and path judgment.
[0180] S422, based on the rule matching strategy, the cleaned block attribute parameters are matched with the applicability threshold rules in the applicability threshold rule library;
[0181] Specifically, after completing the parsing and cleaning of dairy block attributes, these standardized attribute parameters (such as process step type, timestamp, geographic coordinates, data source level, etc.) are encapsulated as structured objects for subsequent rule comparison. Each block will be a candidate node entering the rule matching module. At the same time, the pre-established applicability threshold rule library is called, which contains multi-dimensional rule items such as maximum time interval threshold, spatial jump upper limit, feature similarity bottom line, trusted data source level, etc. Next, the rule matching strategy engine is started, taking each cleaned block attribute parameter as input, and each rule in the rule library is matched and judged. The strategy is divided into hard matching and soft scoring: hard matching refers to strong constraint conditions such as time difference must be less than 48 hours, source level cannot be lower than B level, etc. If not met, it is marked as not matching; soft scoring quantifies the matching degree as a score, such as deducting 0.01 points per kilometer of position deviation, and finally all rule items are summarized to obtain the comprehensive applicability score.
[0182] According to the matching result, each block is labeled, such as complete match, partial match, and no match, and the corresponding matching score, violated rule items and specific parameter deviation information are recorded. For partially matched blocks, they can be selected into the pending node pool for manual confirmation, or set as suboptimal connection options (such as backup edges, low weight path segments) by path construction logic. Finally, the matched nodes are included as high applicability nodes in the subsequent traceability link generation, ensuring that each connected node is not only reasonable in data structure, but also reliable in business logic under rule constraints.
[0183] S423. Summarize and conclude the several matched applicability threshold rules to obtain the applicability threshold rule set;
[0184] Specifically, when constructing a traceability node or path, several rules are matched from the applicability threshold rule base according to the rule matching strategy. These rules involve multiple dimensions such as node time interval, spatial jump, process sequence, trusted data source level, and similarity score. Each rule represents a certain business constraint or tolerance. These activated and applied rules need to be archived, that is, the applicability threshold rule set for the current task needs to be constructed.
[0185] Next, these rules are structured and summarized, mainly including the following: rule name and type (e.g., time continuity rule, spatial jump limit); threshold settings (e.g., no more than 48 hours, distance no more than 50 kilometers); matching status (whether enabled / triggered); scope of impact (applicable to nodes, path segments, or the entire chain); severity level (e.g., whether a violation aborts path construction, or whether it is marked as a low-applicability path). Afterwards, these rules can be further unified and abstractly modeled, representing them as a set of constraint functions with priority and dependencies, constituting a complete set of applicability threshold rules. This set can be stored in a configuration file format for easy reuse, version control, or use for subsequent source tracing strategy comparison and analysis.
[0186] Ultimately, this rule set serves as the basis for evaluation and filtering throughout the entire traceability process, providing unified behavioral standards for execution node selection, path construction, and link optimization. It can also be exported or displayed to operations and maintenance personnel for auditing and adjustment, ensuring that the traceability chain generation process operates within a transparent, compliant, and controllable framework.
[0187] S424. Validate and optimize the applicability threshold rule set, and output the validated and optimized applicability threshold rule set.
[0188] Specifically, the existing set of applicability threshold rules needs to be validated to ensure that all threshold settings are feasible, effective, and do not lead to over-filtering or false positives in actual dairy product traceability tasks. The validation phase typically uses historical traceability cases or labeled datasets to replay existing links, applying each threshold from the rule set to each link, and statistically analyzing the pass rate, false filtering rate, and false retention rate. For example, if a rule with a time interval ≤ 48 hours causes too many actually valid nodes to be filtered out, it will be recorded as a potentially overly strict rule.
[0189] Next, the statistics collected in the verification phase will be analyzed, and a threshold optimization strategy will be implemented. This process can use manual adjustment or algorithm optimization (such as grid search, Bayesian optimization), aiming to balance strictness and coverage. For rule items with high false positive rates, the threshold can be appropriately relaxed; for rules that fail to filter out abnormal paths, the threshold can be tightened or new constraints can be added. Rule items will be labeled with optimization suggestions, and recommended threshold adjustment ranges will be automatically generated. Then, enter the rule set reconstruction phase, update the parameter values of each rule item according to the optimization suggestions, and remove redundant, conflicting or overfit sub-rules. For example, distinguish space jumps ≤50km and distribution links ≤100km as conditions in different process stages to avoid false filtering caused by a single global threshold. The reconstructed rule set will have higher task adaptability and more refined scene adaptability. Finally, the verification-optimized applicability threshold rule set will be output, which is a structured and versioned rule set containing: the name and type of each rule, the optimized parameter threshold, the applicable range and conditions, and the optimization reason and verification score. This rule set can be directly loaded into the traceability chain construction module, ensuring that the entire process of generating dairy traceability paths, node screening, and path scoring is based on verified and optimized threshold standards, thereby improving the accuracy and business usability of link generation.
[0190] S43, extract the link feature index vector in the dairy traceability link, and input the link feature index vector into the grey correlation algorithm to evaluate the applicability of the dairy traceability link;
[0191] Specifically, extracting the link feature index vector in the dairy traceability link and inputting the link feature index vector into the grey correlation algorithm to evaluate the applicability of the dairy traceability link includes the following steps:
[0192] S431, extract node information and path information in the dairy traceability link, and based on the node information and path information, construct a link feature index vector;
[0193] Specifically, first, node information needs to be extracted, that is, the core attributes of each node are obtained from the traceability link, including: node ID (unique identifier), process link type (such as sterilization, packaging, transportation, etc.), timestamp (event time), spatial coordinates (latitude and longitude or geographic code), data source credibility level (sensor, manual input, etc.), upstream and downstream node reference (previous link or next link ID), and each node is parsed into a structured object as the basis for subsequent index calculation. Next, path information, which describes the relationship between nodes, will be extracted. Path information mainly includes: path segment ID (unique identifier of node pair), start and end node ID, time interval (time difference between two nodes), spatial jump distance (straight-line or network distance between two nodes), process sequence legality identification (such as whether it meets the logic of sterilization before packaging), path confidence score (based on similarity and credibility comprehensive score), and these information is used to measure the continuity and reliability of the link.
[0194] After the node information and path information are extracted, link feature index vectors are constructed based on the two parts of data. Each link path can be represented as a set of multi-dimensional indexes, including: average time interval, maximum spatial jump, process link diversity (number of participating link types), average node credibility level, minimum path confidence score, total path length (number of nodes), etc., and each index is recorded in a numerical form, combined into a complete vector, which is an important input for link quality assessment, classification, and traceability decision. Finally, the link feature index vector set of each path is output, compared with the applicability threshold rule library, or input into the subsequent model analysis. This process ensures that the link is not only structurally correct, but also has clear interpretability in quantitative indexes, facilitating the monitoring and optimization of the dairy product whole-chain traceability process
[0195] S432、based on the historical applicability link, a reference link index vector for applicability comparison is generated;
[0196] Specifically, a batch of high-quality historical dairy product traceability links are selected, which are usually manually annotated, manually confirmed, or have high accuracy in actual tracing tasks, referred to as applicability link sample set. Each sample link contains its complete node sequence, path segment, space-time information, and process link, etc.
[0197] Next, a structured feature extraction operation is performed on these historical links, extracting the following key indicators from each link: average inter-node time interval (representing flow speed), average path hop distance (reflecting spatial continuity), number of process steps (measuring link completeness), minimum / maximum path confidence score, average data source rating (reflecting data reliability), and number of nodes (representing chain complexity). These feature values will be standardized and combined into a multi-dimensional vector, forming the suitability indicator vector of the link. Subsequently, the indicator vectors of all sample links are normalized and clustered, calculating the mean, variance, and adaptation range of different types of links. Finally, one or more reference indicator vectors are obtained, which represent the structural feature models that high-suitability links should possess under different process routes, logistics modes, or regulatory standards, i.e., the reference suitability indicator vector set.
[0198] S433, using the grey correlation algorithm, the correlation degree between the link feature indicator vector and the reference link indicator vector is calculated, and the link suitability score of the dairy product traceability link is obtained;
[0199] Specifically, two parts of input data are prepared: one is the link feature indicator vector to be evaluated, which describes the performance of the dairy product traceability link in time interval, spatial hop, process diversity, node reliability, path length, etc. multi-dimensional indicators; the second is the reference link indicator vector, which is a standard vector summarized from historical high-suitability links, serving as an ideal model for comparison. In order to eliminate the influence of dimension, all vectors will be normalized (such as min-max normalization or Z-score standardization) to ensure that each indicator is within a comparable range. Next, the core idea of the grey correlation algorithm is sequence similarity analysis, which calculates the absolute difference sequence of the two normalized vectors dimension by dimension, i.e. the numerical difference of each dimension, and then according to the grey correlation coefficient formula:
[0200] ;
[0201] where, is the value of the i-th indicator of the link to be evaluated, is the value of the same indicator of the reference link, and min and max are the minimum and maximum values of all differences, is the resolution coefficient (usually 0.5). This coefficient measures the similarity of the two links in this indicator, with a value range of [0, 1], and the closer to 1 indicates the closer to the reference model. Then, the correlation coefficients of all dimensions are weighted or equally averaged to obtain the overall grey correlation degree, and the formula is:
[0202] ;
[0203] where v is the number of indicator dimensions, The value of the correlation degree is also within the interval [0, 1], the higher the value represents the higher similarity to the reference link, and the higher the applicability. This correlation degree score is defined as the link applicability score of the dairy product traceability link. Finally, the link applicability score is output as a key indicator of traceability link evaluation, which is used to decide whether to accept the path as a high-trust traceability result, whether to further optimize, or for prioritization of traceability paths
[0204] S434, verifying and optimizing the link applicability score, and outputting the verified and optimized link applicability score as the basis for subsequent link applicability determination.
[0205] Specifically, the initial link applicability score obtained based on the grey correlation analysis is verified. This process relies on a batch of historical link data samples with true labels, each of which has been labeled as high applicability, medium applicability, or inapplicability, etc. These labeled links are compared with their respective applicability scores to build a score-result mapping relationship curve to evaluate the accuracy, discrimination ability, and misjudgment risk of the applicability score. Then, optimization and correction processing is performed. If it is found that there are more confusions and ambiguities in a certain score interval (such as 0.65-0.75), the score mechanism needs to be fine-tuned by adjusting the parameters of the grey correlation coefficient (such as the resolution coefficient p) or adding weight factors (assigning different weights to different dimensions). A regression fitting model or a classification auxiliary model can also be introduced to non-linearly calibrate the score and improve its fitting ability to the actual applicability.
[0206] After optimization, the new applicability score of each link is recalculated or mapped, and a score grading standard is established (such as ≥0.85 for high applicability, 0.70-0.85 for medium applicability, and <0.70 for not recommended path). The new score is closer to the actual business judgment result and has stronger explanatory and guiding ability.
[0207] S44, comparing the applicability threshold rule set with the dairy product link applicability to obtain the applicability evaluation result.
[0208] Specifically, the verified and optimized applicability threshold rule set is called, which defines the ideal threshold interval or lower limit requirement of each feature indicator of the link (such as average time interval ≤48 hours, spatial jump ≤50 kilometers, link similarity ≥0.85, etc.). At the same time, the final applicability score of each dairy traceability link is prepared, which is usually calculated and verified and optimized by the grey correlation degree and standardized to the interval [0, 1].
[0209] Next, the comparison strategy module is started, and the applicability score of the link is compared with the threshold requirements of the rule set one by one. If the rule is that the minimum applicability score is greater than or equal to 0.80, it is determined whether the current link score meets this lower limit. If the link score meets all the key rules (including the mandatory threshold and the preferred interval), it is marked as passing the evaluation. For links that do not meet the threshold, they are further divided into partial passing (close to the threshold, which can prompt optimization) or not passing (far below the threshold, which needs to be removed).
[0210] During the comparison process, the item-by-item matching results are recorded, not only the simple pass / fail label is output, but also the detailed comparison report is retained. For example: applicability score: 0.87, rule threshold: greater than or equal to 0.80, matching state: pass, exceed lower limit: +0.07, etc. This report facilitates subsequent manual review, quality traceability and model iteration. Finally, the output applicability evaluation results include link ID, final applicability score after verification and optimization, comparison state with each rule item, comprehensive evaluation label (such as high applicability can be accepted, medium applicability needs to be reviewed, and inapplicability should be removed). The evaluation results will be used as the standard input for subsequent link selection, queuing, pruning and quality control, to ensure that the dairy product traceability link is available in business, compliant in regulation, and interpretable in model.
[0211] S5, based on the applicability evaluation results, optimizing and adjusting the dairy product traceability link, and updating the applicability threshold rule;
[0212] Specifically, according to the applicability evaluation results obtained by the previous comparison, each link is classified and graded. Generally, it can be divided into three categories: high applicability link: the score is much higher than the rule threshold, which can be directly retained; medium applicability link: the score is close to the threshold boundary, which needs to be optimized or manually reviewed; low applicability link: the score is significantly lower than the threshold, which is preferentially removed or replaced. First, the medium and low applicability links are screened, and the source of the problem is determined, such as too large time interval, low path confidence or inconsistent process logic, etc.
[0213] Next, the link optimization adjustment mechanism is started, and local correction is performed on the links that can be improved. Node optimization: replace or supplement the partially missing or low-confidence nodes; path adjustment: reorder path segments, insert logical transition links, and reduce abnormal jumps; weight reevaluation: reweight important indicators (such as time continuity and spatial proximity) to improve the overall score. Through multiple iterations, it is ensured that the adjusted link is closer to the reference link model in the indicator dimension. After the link adjustment is completed, the gray correlation algorithm is applied again to recalculate the applicability score of the optimized link, and the results are compared with the original evaluation record. If the score is significantly improved, it proves that the adjustment is effective, and the link can be upgraded to high applicability or medium applicability, and is formally included in the subsequent traceability chain. Finally, based on the experience data of optimization verification, the applicability threshold rules are updated: fine-tune the rules that are too strict or too loose; adjust the indicator weight distribution according to new link samples; include new constraints (such as minimum node confidence) into the rule library. This updated rule set is saved in a versioned form and serves as the basis for the next round of traceability tasks, ensuring that link judgment is more scientific, flexible, and adaptable. Through this process, the continuous improvement of link quality and the dynamic iteration of threshold rules are realized, providing precise and reliable decision support for dairy product traceability.
[0214] S6, trace the dairy product based on the optimized dairy product traceability link, and generate multi-level visual traceability results according to user permission levels.
[0215] Specifically, based on the optimized link, precise traceability is performed. After the structure optimization, applicability evaluation and rule calibration of the dairy product traceability link are completed, the high applicability nodes and paths in the link are used as the basis to perform precise traceability tracking. From the end node of the target product (such as the consumer terminal or the outbound record), traceability is performed in reverse, and all upstream nodes are checked layer by layer according to the link path to form a complete product life cycle chain. This link not only contains basic time and process information, but also embeds data confidence level, spatial trajectory and other auxiliary information, laying a data foundation for the final traceability display.
[0216] A multi-level traceability view is constructed, and different user roles (such as consumers, regulators, and enterprise quality control personnel) will dynamically generate hierarchical visual traceability results according to role permissions and information needs. The consumer view focuses on simplicity and readability, and only shows key nodes (such as origin, production date, detection information, and transportation history); the regulatory view shows the complete path, time flow, data confidence level, and abnormal warning markers; the quality control personnel view also includes process parameters (temperature, sterilization time), node scores, and path confidence scores.
[0217] At the same time, the visualization result takes the atlas structure as the core, supplemented by interactive components such as a time axis, an event list, and a map trajectory, to form a unified traceability interface. The visible information range can be dynamically rendered according to the identity of the visitor, and data export and interactive query are supported, so as to meet the traceability investigation, compliance audit, and brand display requirements in different business scenarios. In addition, while the user is browsing the traceability link result, a feedback mechanism is supported to allow reporting of suspicious points or node abnormalities in the link, and the feedback result can be used reversely for link quality learning, dynamic rule adjustment, and retraining of the link applicability model, to form a data closed-loop optimization mechanism. This makes the dairy product traceability no longer a static output, but an adaptive and sustainable intelligent traceability system.
[0218] To sum up, by virtue of the technical scheme of the present application, the dairy product production process data is encapsulated as a data block and stored in a blockchain database, the integrity, traceability, and tamper resistance of the traceability data are ensured, the data credible basis in the dairy product traceability process is enhanced, the authority of the dairy product quality and safety supervision is improved, the weight mapping relationship between the traceability feature parameters and the dairy product data block is set, the cosine similarity algorithm is combined for scoring and matching, the feature adaptation accuracy of the traceability node is improved, the customized link construction logic is realized, the individualized response to various traceability requirements is supported, the time-space coupling self-organizing model is constructed based on the time parameter and the space parameter of the dairy product data, the self-organizing ability and the scalability of the model are used, and the traceability link with reasonable structure and optimal path can be dynamically generated in the complex node network, so that the stability, scalability, and timeliness of the link construction are improved.
[0219] In addition, the preset applicability threshold rule library is combined with the grey correlation algorithm to perform multi-index comprehensive evaluation on the generated traceability link, the quantitative evaluation of the link quality is realized, the optimized rule model is compared and analyzed, the high-quality iteration and self-learning optimization of the traceability link are further supported, and the multi-level visual traceability display scheme is generated according to the user permission level, so as to meet the visual needs of different users such as regulatory agencies, consumers, and enterprises, realize the transparent display, hierarchical authorization, and easy readability of the traceability information, and enhance the public trust.
[0220] The above merely describes preferred embodiments of the present application and is not intended to limit the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A method for tracing dairy products based on blockchain, characterized in that, Includes the following steps: S1. Collect dairy product production process data, divide the dairy product production process data into several dairy product data blocks, and store them in a blockchain database; S2. Analyze the traceability requirements of dairy products, obtain traceability feature parameters, preset a weight database, assign weights to traceability feature parameters and dairy product data blocks, and perform matching based on the weight assignment results; S3. Based on the spatiotemporal coupling self-organizing model, a dynamic traceability link generation mechanism is preset, and a dairy product traceability link is generated based on the matching results; S4. Preset an applicability threshold rule base, and use the applicability threshold rules in the applicability threshold rule base combined with the grey relational algorithm to evaluate the applicability of the dairy product traceability link; S5. Optimize and adjust the dairy product traceability chain based on the applicability assessment results, and update the applicability threshold rules; S6. Trace dairy products based on the optimized dairy product traceability link and generate multi-level visual traceability results according to user permission levels; The step of pre-setting a dynamic traceability link generation mechanism based on a spatiotemporal coupling self-organizing model and generating a dairy product traceability link based on the matching results includes the following steps: S31. Construct a spatiotemporally coupled self-organizing model based on the time and spatial parameters in the dairy product data block; S32. Based on the score similarity matching results, select the successfully matched traceability feature parameters and dairy product data blocks, and construct a traceability node set; S33. Set up a dynamic traceability link generation mechanism based on the spatiotemporal coupling self-organizing model, and generate dairy product traceability links based on the dynamic traceability link generation mechanism. S34. Verify the structural consistency between the traceability node set and the dairy product traceability link, and perform self-organizing optimization on the dairy product traceability link based on the verification results. S35. Output the optimized dairy product traceability link; The construction of the spatiotemporally coupled self-organizing model based on the time and spatial parameters in the dairy product data block includes the following steps: S311. Extract the block time parameters and block space parameters from the dairy product data block, and clean the extracted data; S312. Construct a spatiotemporal feature matrix based on the cleaned block time parameters and block spatial parameters; S313. Establish a coupling relationship diagram based on the temporal order and spatial proximity of block time parameters and block spatial parameters; S314. Merge the spatiotemporal feature matrix and the coupling relationship diagram, and set self-organizing rules to obtain a spatiotemporal coupled self-organizing model. S315. Verify and optimize the spatiotemporal coupling self-organizing model, and output the verified and optimized spatiotemporal coupling self-organizing model. The process of selecting successfully matched traceability feature parameters and dairy product data blocks based on the scoring similarity matching results, and constructing a traceability node set, includes the following steps: S321. Obtain the rating similarity matching results and set the rating threshold for successful matching; S322. Based on the scoring threshold, select the successfully matched traceability feature parameters and dairy product data blocks; S323. Based on the successfully matched traceability feature parameters and dairy product data blocks, extract node time parameters, node spatial parameters and node association attribute information to construct a traceability node set. S324. Perform deduplication and structural integrity checks on the source node set, and output the deduplication-checked source node set.
2. The method for tracing dairy products based on blockchain according to claim 1, characterized in that, The process of analyzing dairy product traceability requirements, obtaining traceability feature parameters, pre-setting a weight database, assigning weights to traceability feature parameters and dairy product data blocks, and matching based on the weight assignment results includes the following steps: S21. Clean the traceability information of dairy products and clarify the traceability requirements. S22. Based on the traceability requirements, set the rules for extracting traceability feature parameters, and extract traceability feature parameters from the traceability information of dairy products according to the rules; S23. Preset the weight database and set the mapping relationship between the traceability feature parameters and the weights; S24. Map the weight values in the weight database to the traceability feature parameters and dairy product data blocks according to the weight mapping relationship; S25. Calculate the feature weight score and block weight score of the mapped traceability feature parameters and dairy product data blocks, and match the mapped traceability feature parameters and dairy product data blocks based on the score similarity.
3. The method for tracing dairy products based on blockchain according to claim 2, characterized in that, The calculation of the mapped traceability feature parameters and the feature weight score and block weight score of the dairy product data block, and the matching of the mapped traceability feature parameters and the dairy product data block based on the score similarity, includes the following steps: S251. Calculate the feature weight score of the source feature parameter based on the mapping weight value, and perform normalization processing. S252. Obtain the traceability feature parameter set in the dairy product data block, and calculate the block weight score of the dairy product data block based on the standardized weight score of each feature parameter in the traceability feature parameter set. S253. Construct feature weight score vectors and block weight score vectors based on feature weight scores and block weight scores; S254. The cosine similarity algorithm is used to calculate the score similarity between the feature weight score vector and the block weight score vector. S255. A preset score similarity judgment threshold is set. When the score similarity is greater than or equal to the similarity judgment threshold, the traceability feature parameters and the dairy product data block are determined to be a matching relationship. When the score similarity is less than the similarity judgment threshold, it is considered a mismatch, and feedback optimization is performed.
4. The method for tracing dairy products based on blockchain according to claim 1, characterized in that, The steps of setting a dynamic traceability link generation mechanism based on the spatiotemporal coupling self-organizing model and generating a dairy product traceability link based on the dynamic traceability link generation mechanism include the following: S331. Based on the spatiotemporal coupling self-organizing model and the process chain data in the dairy product data block, a dynamic traceability link generation mechanism is set up. S332. Based on the process chain data, identify the source node and target node for traceability; S333. Generate an initial link path by using a dynamic tracing link generation mechanism to trace the source node and the target node. S334. Perform reachability verification and optimization on the initial link path, and use the optimized initial link path as the dairy product traceability link output.
5. The method for tracing dairy products based on blockchain according to claim 1, characterized in that, The preset applicability threshold rule base, and the use of the applicability threshold rules in the applicability threshold rule base combined with the grey relational algorithm to evaluate the applicability of the dairy product traceability chain, includes the following steps: S41. Based on the traceability requirements of dairy products, construct an applicability threshold rule base and set a rule matching strategy; S42. Based on the rule matching strategy, the applicability threshold rules in the applicability threshold rule base are matched with the dairy product data blocks to obtain the applicability threshold rule set; S43. Extract the link feature index vector from the dairy product traceability link, and use the link feature index vector into the grey relational algorithm to evaluate the applicability of the dairy product traceability link. S44. Compare the applicability threshold rule set with the applicability of the dairy product chain to obtain the applicability evaluation result.
6. The method for tracing dairy products based on blockchain according to claim 5, characterized in that, The rule-based matching strategy involves matching the applicability threshold rules in the applicability threshold rule base with the dairy product data blocks to obtain the applicability threshold rule set, which includes the following steps: S421. Parse the block attribute parameters of the dairy product data block and clean the block attribute parameters; S422. Based on the rule-based matching strategy, match the cleaned block attribute parameters with the applicability threshold rules in the applicability threshold rule base; S423. Summarize and conclude the several matched applicability threshold rules to obtain the applicability threshold rule set; S424. Validate and optimize the applicability threshold rule set, and output the validated and optimized applicability threshold rule set.
7. The method for tracing dairy products based on blockchain according to claim 5, characterized in that, The process of extracting link feature index vectors from the dairy product traceability chain and then using these vectors in a grey relational algorithm to evaluate the suitability of the dairy product traceability chain includes the following steps: S431. Extract node information and path information from the dairy product traceability chain, and construct a chain feature index vector based on the node information and path information; S432. Generate a reference link indicator vector for applicability comparison based on historical applicability links; S433. Using the grey relational algorithm, calculate the correlation between the link feature index vector and the reference link index vector to obtain the link applicability score of the dairy product traceability link. S434. Verify and optimize the link suitability score, and output the verified and optimized link suitability score as the basis for subsequent link suitability judgment.
Citation Information
Patent Citations
Big data processing method for authenticity verification and credible traceability and cloud server
CN112749181A
Emergency processing method and system based on multi-block chain cooperation technology
CN115842844A