Food safety supervision method and system for large canteen
Patent Information
- Application Number
- CN202611116301.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-27
- Publication Date
- 2026-10-13
AI Technical Summary
[0003]现有食品安全监管技术在处理多环节业务关联关系时,主要依赖固定规则或单一数据关联方式,难以根据食品流转过程中的业务阶段变化建立动态关联关系,导致风险事件与关联对象之间的传播路径识别精度不足
(1)本发明通过采集食品采购、验收、检测、存储、加工、留样和巡检过程中的食品安全业务数据,构建食品安全知识图谱,将食品安全监管对象、业务事件和风险事件建立关联关系,实现食品流转过程的数据关联管理,提高食品安全业务信息的追溯能力,解决现有技术中多环节业务数据关联不足的问题;
Smart Images

Figure CN122905500A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of food safety supervision technology, and in particular to a food safety supervision method and system for large canteens. Background Technology
[0002] As large-scale canteen catering expands, the amount of business data generated during food procurement, acceptance, testing, storage, processing, sampling, and inspection is constantly increasing, leading to a gradual shift in existing food safety supervision methods towards digital management. Current technologies primarily collect food circulation records through information management platforms, combining rule verification, anomaly record queries, and manual review to achieve food safety supervision. Some technologies utilize data association methods to establish connections between food circulation information, enabling food source tracking and risk event queries.
[0003] Existing food safety regulatory technologies, when handling multi-stage business relationships, primarily rely on fixed rules or single data association methods. This makes it difficult to establish dynamic relationships based on changes in the business stages of food circulation, resulting in insufficient accuracy in identifying the propagation paths between risk events and related objects. Current knowledge graph applications often rely on static entity and relationship features for information propagation, failing to consider the food safety business status, relationship timeliness, and business continuity constraints. This easily leads to the inclusion of topologically connected but business-irrelevant relationship information in risk reasoning, affecting the results of risk source localization.
[0004] To address the challenges of complex interrelationships and difficulty in accurately identifying risk propagation relationships in the food safety supervision of large canteens, it is necessary to construct a risk reasoning method that combines food circulation processes, business status characteristics, and relationship transfer constraints. This method would enable dynamic updates of the food safety knowledge graph and risk correlation analysis, thereby improving the risk identification and task generation capabilities in the food safety supervision process.
[0005] Therefore, how to provide a food safety supervision method and system for large canteens is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0006] One objective of this invention is to propose a food safety supervision method and system for large canteens. This invention collects food safety business data, constructs a food safety knowledge graph, introduces relational state vectors and relational transition constraints to describe changes in business state during food circulation, and performs risk association analysis through an improved CompGCN to achieve risk source identification and regulatory task generation. This invention integrates food safety business management, supply chain information traceability, and graph neural network inference technology, which can improve the accuracy of food safety risk identification, the ability to locate risk sources, and the efficiency of regulatory response.
[0007] A food safety supervision method for a large canteen according to an embodiment of the present invention includes the following steps: Collect food safety business data from large canteens and preprocess it to generate standardized regulatory data; Based on standardized regulatory data, identify food safety regulatory targets and business events, establish the relationship between regulatory targets and business events according to the food circulation sequence, and generate a food safety knowledge graph; Read the business status corresponding to the relationship edge in the food safety knowledge graph, map the degree of business anomaly and the timeliness of the relationship to the relationship features, and generate a relationship status vector; Verify business continuity based on the business objects, business stages, and order of occurrence of adjacent relationships; construct relationship transfer constraints; and generate valid relationship combinations. The food safety knowledge graph, relation state vector, and effective relation combinations are input into CompGCN. Combination operations are performed on adjacent entity features and relation features. Business constraint coefficients are generated based on relation state vectors and relation transition constraints. Combination messages are filtered and adjusted using business constraint coefficients. Effective combination messages are aggregated to update entity features. Relation features are updated synchronously based on entity update results to generate an improved CompGCN. Training samples are constructed based on historical risk events and review results. The training samples are then input into the improved CompGCN to perform multi-layer propagation and parameter iteration, generating a food safety risk inference model. By inputting the food safety knowledge graph into the food safety risk reasoning model, the risk association results are obtained. The effective relationship combinations are traced back to determine the source of risk and the scope of association, and regulatory tasks are generated. The food safety knowledge graph is updated based on the task handling results.
[0008] Optionally, the preprocessing includes: Analyze food safety business data to extract business object identifiers, business event identifiers, and occurrence times; Bind business records according to business object identifiers, align them according to execution sequence based on the time of occurrence, and remove duplicate records, records with missing identifiers, and records with conflicting sequences; Verify the integrity of the association between business objects and business events, and generate standardized regulatory data.
[0009] Optionally, the process of generating a food safety knowledge graph includes: Map food safety regulatory objects in standardized regulatory data to regulatory object nodes, business records to business event nodes, and business events that are confirmed as abnormal after review to risk event nodes; Establish a directed relationship between the regulatory target node and the business event node according to the food circulation sequence, and establish a risk-oriented relationship between the business event node and the risk event node. Establish reverse relationships for directed and risk-oriented relationships, write node attributes and relationship attributes, and generate a food safety knowledge graph.
[0010] Optionally, the generated relational state vector includes: Read the business records corresponding to the relation edges, compare the business status with the preset normal status, obtain the status deviation value, and calculate the field integrity rate and the number of duplicate anomalies of the business records. The business anomaly level is obtained by normalizing and weighting the status deviation value, field missing rate, and number of repeated anomalies. Calculate the time interval between the occurrence time of the business event corresponding to the relation edge and the current regulatory time. Then, perform attenuation mapping on the time interval according to the effective regulatory period corresponding to the relation type to obtain the relation validity period. Relationship types are encoded as relationship type features, and the degree of business anomalies and relationship timeliness are mapped to the feature space where the relationship type features are located. The result is a relationship state vector generated by concatenating the features.
[0011] Optionally, the construction relation transfer constraints include: Traverse the adjacent relationships in the food safety knowledge graph where the terminal node is the same as the starting node, and determine the previous relationship and the current relationship according to the relationship direction; Read the business object identifiers of the nodes associated with the previous and current relationships, determine whether the previous and current relationships belong to the same food circulation process based on the binding relationship of the business object identifiers, and generate continuous object states; The business stage is determined based on the event type of the corresponding business event node according to the preceding and current relationships, and the order and occurrence time of the business stages are compared. When the current business stage is no earlier than the previous business stage, and the current relationship occurs no earlier than the previous relationship occurs, a sequential continuous state is generated. When both the continuous state and the sequential continuous state of the object are valid, the preceding relation and the current relation are combined into a valid relation combination and the transition value is set to 1; when either state is invalid, the preceding relation and the current relation are combined into an invalid relation combination and the transition value is set to 0; the relation combinations and corresponding transition values are summarized to generate relation transition constraints.
[0012] Optionally, the process of filtering and adjusting the combined messages using business constraint coefficients includes: Read the relationship combinations one by one, extract the business anomaly level and relationship timeliness from the relationship state vector corresponding to the current relationship, and read the corresponding transfer value from the relationship transfer constraint; After adding 1 to the business anomaly level, multiply it by the relationship timeliness and transfer value to generate the business constraint coefficient corresponding to the relationship combination; Read the entity features of the current relationship starting node as the adjacent entity features, perform CompGCN combination operation on the adjacent entity features and the current relationship features, and generate candidate combination messages corresponding to the relationship combination; When the transition value is 1, the business constraint coefficient is multiplied by the candidate combined message to obtain the adjusted combined message; when the transition value is 0, the corresponding candidate combined message is blocked. Retain the adjusted combined message, bind the preceding relationship, the current relationship, and the termination node of the current relationship, and generate a valid combined message.
[0013] Optionally, the process of generating the improved CompGCN includes: Group the valid combined messages according to the current relationship termination node, select the direction transformation parameters according to the relationship direction of the current relationship, and perform a linear transformation on the valid combined messages; The results of linear transformations in the same group are summed and normalized according to the number of effective combined messages. The normalized results are then linearly mapped to the entity features of the current relation termination node and added together. After activation processing, the updated entity features are obtained. For each current relation, the entity features updated after the termination node are subtracted from the entity features updated after the start node. The result is then mapped to the same dimension as the current relation features and the relation state vector, and added to them. After activation processing, the updated relation features are obtained. The updated entity features and relation features are used as input to the next graph convolutional layer. Candidate combination message generation, business constraint coefficient adjustment, effective combination message generation, entity feature update and relation feature update are re-executed until the preset number of graph convolutional layers is reached. The entity features and relation features output from the final graph convolutional layer are used as risk association representations to generate an improved CompGCN.
[0014] Optionally, the process of generating the food safety risk reasoning model includes: The positive sample consists of risk events that have been verified to have a risk association and the risk source objects. The negative sample consists of food safety regulatory objects that have been verified to have no risk association within the same business stage and the same effective regulatory cycle and the corresponding risk events. Positive samples, negative samples, and a food safety knowledge graph are input into the improved CompGCN to perform multi-layer propagation and calculate the risk association prediction value between risk events and food safety regulatory objects based on risk association representation. The risk association discrimination loss is calculated based on the risk association prediction value and sample label. The business transfer constraint loss is calculated based on the propagation contribution of the candidate combination message corresponding to the invalid relationship combination. For positive samples, the risk source consistency loss is calculated based on the predicted risk source and the verified risk source. The loss from risk association discrimination, loss from business transfer constraint, and loss from consistency of risk source are weighted and synthesized, and the entity transformation parameters, relationship update parameters, and direction transformation parameters are updated based on the synthesis results. Repeatedly perform multi-layer propagation, loss calculation, and parameter updates until the preset training termination condition is met to generate a food safety risk inference model.
[0015] Optionally, the process of updating the food safety knowledge graph includes: Calculate the predicted risk correlation between risk events and food safety regulatory targets, and screen candidate risk targets that reach a preset threshold; Read the valid combined messages and binding relationships retained by each graph convolutional layer, trace back from the risk event node to the candidate risk object node, and determine the candidate risk object with the largest risk association prediction value as the risk source object; Based on the business object identifier of the risk source object, retrieve the food safety supervision object in the same food circulation process, determine the scope of association, and generate supervision tasks based on the business stage of the business event node in the backtracking path. Read the results of the handling of regulatory tasks to determine the risk confirmation or risk elimination results; When a risk is identified, the risk-directing relationship between business event nodes and risk event nodes is established or updated; when a risk is eliminated, the risk elimination result and the time of disposal are written into the business event node corresponding to the regulatory task; the node attributes and relationship attributes are updated to generate an updated food safety knowledge graph.
[0016] A food safety supervision system for a large canteen according to an embodiment of the present invention includes the following modules: The data processing module is used to collect and preprocess food safety business data to generate standardized regulatory data; The knowledge graph construction module is used to identify food safety regulatory targets and business events, establish relationships, and generate a food safety knowledge graph. The relationship status module is used to calculate the degree of business anomalies and relationship timeliness, and generate relationship status vectors; The relationship constraint module is used to verify the business continuity of adjacent relationships, generate relationship transfer constraints and valid relationship combinations; The graph convolution module is used to adjust the combined message based on the relation state vector and relation transition constraints, update entity features and relation features, and generate an improved CompGCN; The model training module is used to train the improved CompGCN based on historical risk events and review results, and generate a food safety risk reasoning model. The risk monitoring module is used to generate risk correlation results, determine the source and scope of risk, generate regulatory tasks, and update the food safety knowledge graph based on the task handling results.
[0017] The beneficial effects of this invention are: (1) This invention collects food safety business data during the food procurement, acceptance, testing, storage, processing, sampling and inspection process, constructs a food safety knowledge graph, establishes a correlation between food safety regulatory objects, business events and risk events, realizes data association management of the food circulation process, improves the traceability of food safety business information, and solves the problem of insufficient association of business data in multiple links in the prior art; (2) This invention introduces the degree of business anomaly and the timeliness of relationships into the relationship state vector, and generates relationship transfer constraints in combination with business continuity verification. It integrates the relationship state and business flow rules into the CompGCN propagation process, and reduces the impact of no business relationship on the risk reasoning results by filtering and adjusting the combined messages through business constraint coefficients, thereby improving the accuracy of risk association analysis. (3) This invention constructs a food safety risk reasoning model through an improved CompGCN, backtracks the effective relationship combination based on the risk association results, determines the source of risk and the scope of association, and updates the food safety knowledge graph based on the results of regulatory task handling, thereby realizing a closed loop of food safety risk identification, source location and knowledge update, and improving the intelligent level of food safety supervision in large canteens. Attached Figure Description
[0018] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings: Figure 1 This is a flowchart of a food safety supervision method for a large canteen proposed in this invention; Figure 2 This is a schematic diagram of the improved CompGCN structure for a food safety supervision method for large canteens proposed in this invention. Figure 3 This is a module connection diagram of a food safety supervision system for a large canteen proposed in this invention; Figure 4 This is a schematic diagram of the food safety risk supervision architecture based on business constraints CompGCN proposed in this invention. Detailed Implementation
[0019] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.
[0020] refer to Figures 1-4 A food safety supervision method for large canteens includes the following steps: Collect food safety business data from large canteens and preprocess it to generate standardized regulatory data; Based on standardized regulatory data, identify food safety regulatory targets and business events, establish the relationship between regulatory targets and business events according to the food circulation sequence, and generate a food safety knowledge graph; Read the business status corresponding to the relationship edge in the food safety knowledge graph, map the degree of business anomaly and the timeliness of the relationship to the relationship features, and generate a relationship status vector; Verify business continuity based on the business objects, business stages, and order of occurrence of adjacent relationships; construct relationship transfer constraints; and generate valid relationship combinations. The food safety knowledge graph, relation state vector, and effective relation combinations are input into CompGCN. Combination operations are performed on adjacent entity features and relation features. Business constraint coefficients are generated based on relation state vectors and relation transition constraints. Combination messages are filtered and adjusted using business constraint coefficients. Effective combination messages are aggregated to update entity features. Relation features are updated synchronously based on entity update results to generate an improved CompGCN. Training samples are constructed based on historical risk events and review results. The training samples are then input into the improved CompGCN to perform multi-layer propagation and parameter iteration, generating a food safety risk inference model. By inputting the food safety knowledge graph into the food safety risk reasoning model, the risk association results are obtained. The effective relationship combinations are traced back to determine the source of risk and the scope of association, and regulatory tasks are generated. The food safety knowledge graph is updated based on the task handling results.
[0021] In this embodiment, the preprocessing includes: Analyze food safety business data to extract business object identifiers, business event identifiers, and occurrence times; Food safety business data consists of structured records generated by large canteens during food circulation and food safety supervision. It includes at least the following fields: business object field, business event field, time of occurrence field, and business status field. The business object field records the monitored batches of ingredients, processing records, dishes, sample retention records, and risk events during food circulation. The business event field records the corresponding acceptance, testing, storage, requisition, processing, sample retention, inspection, and risk handling actions for each business object. The time of occurrence field uses a unified time format of year, month, day, hour, minute, and second. The business status field uses enumerated values such as normal, abnormal, in progress, completed, and reviewed.
[0022] Specifically, food safety business data is stored in a manner where one business event corresponds to one data record. Each data record includes at least the business object identifier, business event identifier, event type, occurrence time, event status, and data source. Data uploaded from different business terminals is uniformly converted to preset field names and data formats, detection values are uniformly retained to three decimal places, time precision is uniformly uniformly to the second, and quantity data is uniformly converted to preset units of measurement.
[0023] Bind business records according to business object identifiers, align them according to execution sequence based on the time of occurrence, and remove duplicate records, records with missing identifiers, and records with conflicting sequences; The business object identifier is a code used to uniquely identify the object under food safety supervision. It consists of an object type code, a business date code, and an object serial number code. The object type code distinguishes between food batches, processing records, dishes, sample retention records, and risk events. The business date code uses eight date characters, and the object serial number code uses six sequential characters.
[0024] In one implementation, the business object identifier is represented by an 18-character string. The first four characters are the object type code, the middle eight characters are the business date code, and the last six characters are the object serial number code. Business records belonging to the same food circulation process use the business object identifier corresponding to the same ingredient batch. After the ingredient batch enters the processing stage, the source ingredient batch identifier is stored in the business object identifier corresponding to the processing record to establish the association between the ingredient batch, processing record, dish, and sample retention record.
[0025] A business event identifier is a code used to uniquely identify a single food safety business operation. It consists of an event type code, a business object sequence code, and an event sequence code. The event type code distinguishes between acceptance events, testing events, storage events, requisition events, processing events, sample retention events, inspection events, and risk management events. Each business event identifier is bound to only one business object identifier, but the same business object identifier can be bound to multiple business event identifiers based on the time of occurrence.
[0026] Specifically, the business object identifier and the business event identifier are written to the same data record, and an index relationship is established between the business object identifier field and the business event identifier field. When a duplicate business event identifier is detected, the occurrence time, event type and event status are compared. If the field contents are consistent, a record is retained. If the field contents are inconsistent, the corresponding record is marked as a conflict record.
[0027] Verify the integrity of the association between business objects and business events, and generate standardized regulatory data.
[0028] Verifying the integrity of the association between business objects and business events includes verifying the integrity of the identifier, uniqueness, association direction, and business sequence. The identifier integrity check is used to determine whether each business event record contains the business object identifier, business event identifier, and occurrence time simultaneously; if any field is empty, the corresponding business event record is marked as an identifier missing record; Uniqueness verification is used to determine whether each business event identifier corresponds to only one business object identifier; when the same business event identifier corresponds to two or more business object identifiers, the corresponding business event record is marked as an object conflict record. Association direction validation is used to determine whether the business event type matches the business object type. Detection events should be associated with ingredient batches, requisition events should be associated with ingredient batches and processing records, sample retention events should be associated with dishes and sample retention records, and risk disposal events should be associated with risk events. When the business event type does not match the business object type, the corresponding business event record will be marked as an association error record. Business sequence verification is used to check the order of business events in the same food circulation process according to their occurrence time. The occurrence time of an acceptance event must not be later than the occurrence time of the corresponding requisition event, the occurrence time of a requisition event must not be later than the occurrence time of the corresponding processing event, and the occurrence time of a processing event must not be later than the occurrence time of the corresponding sample retention event. Adjacent business events with the same occurrence time but different data sources are sorted according to the order of data reception; adjacent business events with a occurrence time difference of no more than five seconds and whose event types conform to the food circulation sequence are grouped into the same business processing cycle; records whose occurrence order is opposite to the food circulation sequence are marked as sequence conflict records. After completing the above verification, records with missing identifiers, object conflicts, incorrect associations, and time sequence conflicts are removed; the verified business event records are retained, aggregated according to business object identifiers, and sorted in ascending order by occurrence time to generate standardized regulatory data.
[0029] In this embodiment, the process of generating a food safety knowledge graph includes: Map food safety regulatory objects in standardized regulatory data to regulatory object nodes, business records to business event nodes, and business events that are confirmed as abnormal after review to risk event nodes; Read the business object identifiers from the standardized regulatory data, establish a regulatory object node for each different business object identifier, and use the business object identifier as the unique index of the regulatory object node; read the business event identifiers, establish a business event node for each different business event identifier, and use the business event identifier as the unique index of the business event node; When a business record simultaneously has a business object identifier, a business event identifier, and an occurrence time, the business record is mapped to the corresponding business event node. When the same business event identifier corresponds to multiple business records, the latest record is retained according to the occurrence time, and the business status of the business event node is updated using the latest record.
[0030] When the review result field records an anomaly, and also records the reviewer's identifier, review time, and anomaly type, the corresponding business event is mapped to a risk event node. The risk event node uses the risk event identifier as a unique index, which consists of the corresponding business event identifier and a two-digit risk sequence number. When the review result field records a normal result or the review information is incomplete, a risk event node is not created.
[0031] Establish a directed relationship between the regulatory target node and the business event node according to the food circulation sequence, and establish a risk-oriented relationship between the business event node and the risk event node. Based on the binding relationship between business object identifiers and business event identifiers, the regulatory object node is set as the starting node and the corresponding business event node is set as the ending node, thus establishing a directed relationship between object events. When the same food circulation process contains multiple business event nodes, the business event nodes are arranged in ascending order according to the time of occurrence, and a directed relationship between adjacent business event nodes is established.
[0032] When adjacent business event nodes occur at the same time but have different business event identifiers, the relationship direction is determined according to the preset order of food circulation stages. The food circulation stages are set sequentially as acceptance, testing, storage, requisition, processing, sampling, inspection, and disposal. A directed event sequence relationship is established when the current business stage follows the previous business stage; no directed event sequence relationship is established when the business stages are in reverse order.
[0033] When a business event is mapped to a risk event node, the business event node is set as the starting node and the risk event node is set as the ending node, a risk pointing relationship is established, and the review time is written into the occurrence time attribute of the risk pointing relationship.
[0034] Establish reverse relationships for directed and risk-oriented relationships, write node attributes and relationship attributes, and generate a food safety knowledge graph.
[0035] Specifically, it iterates through the directed relationships of object events, the directed relationships of event order, and the risk-oriented relationships, swapping the start and end nodes of each relationship to generate corresponding reverse relationships. Reverse relationships and original relationships use different relationship type identifiers, establishing a one-to-one correspondence through the original relationship identifier. When the original relationship is deleted or updated, the corresponding reverse relationship is simultaneously deleted or updated.
[0036] The regulatory object node contains the business object identifier and object type; the business event node contains the business event identifier, event type, occurrence time, and business status; and the risk event node contains the risk event identifier, anomaly type, review time, and review result.
[0037] Each relationship is recorded with a relationship identifier, relationship type, relationship direction, start node identifier, end node identifier, and occurrence time. The relationship identifier is generated by concatenating the start node identifier, relationship type code, and end node identifier; only one relationship with the same start node identifier, relationship type code, and end node identifier is retained.
[0038] After the nodes and relationships are written, a node set is formed by regulatory object nodes, business event nodes, and risk event nodes, and a relationship set is formed by object event directed relationships, event sequence directed relationships, risk pointing relationships, and corresponding reverse relationships, thus generating a food safety knowledge graph.
[0039] In this embodiment, generating the relational state vector includes: Read the business records corresponding to the relation edges, compare the business status with the preset normal status, obtain the status deviation value, and calculate the field integrity rate and the number of duplicate anomalies of the business records. The business record corresponding to the relationship edge is the business event record on which the relationship edge is based. Normal status, required fields and abnormal statistics period are pre-configured according to the relationship type. The business status in the business record is compared with the corresponding normal status.
[0040] When business status is recorded numerically, the absolute value of the difference between the business status value and the normal status value is calculated and divided by the corresponding allowable deviation to obtain the status deviation value; if the result is greater than 1, it is set to 1. When business status is recorded in a categorized form, the status deviation value corresponding to the normal status is set to 0, the status deviation value corresponding to the pending status is set to 0.5, and the status deviation value corresponding to the abnormal status is set to 1.
[0041] The field completeness rate is the ratio of the number of non-empty required fields in a business record to the total number of required fields. Required fields must include at least the business object identifier, business event identifier, event type, occurrence time, and business status. If one of the five required fields is empty, the field completeness rate is 0.8.
[0042] The number of repeated anomalies is the number of times the same business object identifier exhibits the same abnormal state within a preset anomaly statistics period. In one implementation, the anomaly statistics period is set to 24 hours, and if the number of repeated anomalies reaches 3 times, it is counted as 3 times.
[0043] The business anomaly level is obtained by normalizing and weighting the status deviation value, field missing rate, and number of repeated anomalies. The state deviation value is limited to between 0 and 1. The field missing rate is set to 1 minus the field complete rate. The number of duplicate anomalies is divided by 3 and the calculation result is limited to between 0 and 1 to obtain the duplicate anomaly normalization value.
[0044] Specifically, the degree of business anomaly can be calculated using the following formula: Degree of Business Anomaly = 0.5 × State Deviation Value + 0.2 × Field Missing Rate + 0.3 × Duplicate Anomaly Normalization Value; the value of the degree of business anomaly ranges from 0 to 1. The closer the degree of business anomaly is to 1, the more obvious the abnormal state of the business record corresponding to the relation edge. The above weights can be adjusted based on the risk review results in the training samples, and the sum of the three weights after adjustment remains at 1.
[0045] Calculate the time interval between the occurrence time of the business event corresponding to the relation edge and the current regulatory time. Then, perform attenuation mapping on the time interval according to the effective regulatory period corresponding to the relation type to obtain the relation validity period. The current regulatory time is the unified time recorded during risk reasoning. The time interval, measured in hours, is obtained by subtracting the occurrence time of the corresponding business event from the current regulatory time. When the time interval is less than 0, the corresponding relationship edge is marked as a time-series abnormal relationship edge and does not participate in the relationship validity calculation. The effective regulatory period is configured according to the relationship type. In one implementation, the effective regulatory period for object-event directed relationships is set to 72 hours, the effective regulatory period for event-sequential directed relationships is set to 48 hours, the effective regulatory period for risk-directed relationships is set to 24 hours, and reverse relationships use the effective regulatory period of the corresponding original relationship.
[0046] The relationship duration is calculated using an exponential decay method based on the ratio of the time interval to the effective regulatory period: ; in, Representing relation edges The time limit of the relationship Representing relation edges The time interval between the occurrence of the corresponding business event and the current regulatory moment. This indicates the effective regulatory period corresponding to the relationship type; when the time interval is 0, the relationship validity period is 1; when the time interval reaches one effective regulatory period, the relationship validity period is approximately 0.368; when the relationship validity period is less than 0.05, the corresponding relationship edge is set as a low-validity relationship edge.
[0047] Relationship types are encoded as relationship type features, and the degree of business anomalies and relationship timeliness are mapped to the feature space where the relationship type features are located. The result is a relationship state vector generated by concatenating the features.
[0048] Relationship type codes are set according to the directed relationship of object events, the directed relationship of event sequence, the risk-oriented relationship, and the corresponding reverse relationship. The relationship type codes are input into the trainable embedding layer to generate relationship type features.
[0049] For example, in one implementation, the dimension of the relationship type feature is set to 32. The business anomaly level and relationship timeliness are input into the linear mapping layer, respectively, and converted into 32-dimensional anomaly features and 32-dimensional timeliness features. The relationship type feature, anomaly feature, and timeliness feature are concatenated according to the dimensional direction to obtain a 96-dimensional relationship state vector. The relationship state vector is bound one-to-one with the relationship edges in the food safety knowledge graph, serving as the input for the improved CompGCN to perform combination operations and message regulation on the relationship features.
[0050] In this embodiment, constructing relation transfer constraints includes: Traverse the adjacent relationships in the food safety knowledge graph where the terminal node is the same as the starting node, and determine the previous relationship and the current relationship according to the relationship direction; An adjacency relationship consists of two edges that connect the beginning and end of the relationship. For the first and second relationship edges, if the ending node of the first relationship edge is the same as the starting node of the second relationship edge, the first relationship edge is determined as the previous relationship, and the second relationship edge is determined as the current relationship.
[0051] The reverse relationships in the food safety knowledge graph are used by CompGCN to perform bidirectional feature propagation and do not participate in the verification of food circulation order. When constructing relationship transfer constraints, the adjacent relationships are traversed according to the original direction of the object event directed relationship, the event sequence directed relationship, and the risk pointing relationship to avoid reverse relationships causing the business stage to be reversed.
[0052] Read the business object identifiers of the nodes associated with the previous and current relationships, determine whether the previous and current relationships belong to the same food circulation process based on the binding relationship of the business object identifiers, and generate continuous object states; Read the business object identifiers associated with the start node of the preceding relationship, the end node of the preceding relationship, and the end node of the current relationship respectively; when two business event nodes are associated with the same business object identifier, determine that the preceding relationship and the current relationship belong to the same food circulation process.
[0053] When two business event nodes are associated with different business object identifiers, the binding relationship between business object identifiers in standardized regulatory data is queried. If one business object identifier is the source object of another business object identifier, the two business object identifiers are determined to have a direct binding relationship; if a continuous query along the source object direction can trace back to the same business object identifier at no more than four levels, the two business object identifiers are determined to have a continuous binding relationship; if the business object identifiers are the same, have a direct binding relationship, or have a continuous binding relationship, the object continuity status is set to 1; if no such binding relationship is found, the object continuity status is set to 0.
[0054] The business stage is determined based on the event type of the corresponding business event node according to the preceding and current relationships, and the order and occurrence time of the business stages are compared. A mapping table between event types and business stages is pre-established, mapping acceptance events, testing events, storage events, requisition events, processing events, sample retention events, inspection events, and disposal events to the first to eighth business stages in sequence.
[0055] Read the event types of the corresponding business event nodes in the preceding and current relationships, and obtain the sequence numbers of the preceding and current business stages according to the mapping table. If the sequence number of the current business stage is greater than that of the preceding business stage, the business stage order is deemed valid; if the two business stage sequence numbers are the same, proceed to the same stage for order verification; if the sequence number of the current business stage is less than that of the preceding business stage, the business stage order is deemed invalid.
[0056] The risk event node corresponding to the risk pointing relationship uses the review time as the occurrence time and is set after the business stage where the corresponding abnormal business event is located, without changing the preset order of subsequent food circulation stages.
[0057] When the current business stage is no earlier than the previous business stage, and the current relationship occurs no earlier than the previous relationship occurs, a sequential continuous state is generated. The occurrence time of an object event in a directed relationship is taken from the occurrence time of the corresponding business event node; the occurrence time of an event sequence in a directed relationship is taken from the occurrence time of the termination business event node; and the occurrence time of a risk-directed relationship is taken from the review time of the risk event node.
[0058] If the current relationship occurs later than the preceding relationship, the order of occurrence is considered valid. If the current relationship occurs at the same time as the preceding relationship, and the current business stage number is not less than the preceding business stage number, the order of occurrence is considered valid. If the current relationship occurs earlier than the preceding relationship, the order of occurrence is considered invalid.
[0059] When both the continuous state and the sequential continuous state of the object are valid, the preceding relation and the current relation are combined into a valid relation combination and the transition value is set to 1; when either state is invalid, the preceding relation and the current relation are combined into an invalid relation combination and the transition value is set to 0; the relation combinations and corresponding transition values are summarized to generate relation transition constraints.
[0060] In this embodiment, the process of filtering and adjusting combined messages using business constraint coefficients includes: Read the relationship combinations one by one, extract the business anomaly level and relationship timeliness from the relationship state vector corresponding to the current relationship, and read the corresponding transfer value from the relationship transfer constraint; Relationship combinations are read based on the preceding and current relationship identifiers, and the combination result of the two relationship identifiers is used as the relationship combination index. The corresponding relationship state vector is queried based on the current relationship identifier, and the business anomaly level and relationship duration (ranging from 0 to 1) are read. The relationship transition constraints are queried based on the relationship combination index, and the transition values (0 or 1) are read. Each relationship combination corresponds to a set of business anomaly level, relationship duration, and transition values.
[0061] After adding 1 to the business anomaly level, multiply it by the relationship timeliness and transfer value to generate the business constraint coefficient corresponding to the relationship combination; First, increment the business anomaly level by 1 to bring the anomaly level adjustment item between 1 and 2. Then, multiply by the relationship duration and the transfer value sequentially to obtain the business constraint coefficient. When the transfer value is 0, the business constraint coefficient is 0; when the transfer value is 1, the business constraint coefficient increases with the increase of the business anomaly level and decreases with the decrease of the relationship duration. The business constraint coefficient ranges from 0 to 2, and the calculation result is rounded to four decimal places. For example, in one implementation, when the business anomaly level is 0.8, the relationship duration is 0.6, and the transfer value is 1, the business constraint coefficient is 1.08; when the transfer value is adjusted to 0, the business constraint coefficient is 0.
[0062] Read the entity features of the current relationship starting node as the adjacent entity features, perform CompGCN combination operation on the adjacent entity features and the current relationship features, and generate candidate combination messages corresponding to the relationship combination; The entity features in the current graph convolutional layer are read based on the starting node identifier of the current relation, and the relation features in the same graph convolutional layer are read based on the current relation identifier. The entity features and relation features are then input into CompGCN for combination operations. For example, in one implementation, both entity features and relation features are set to 64 dimensions. Element-wise multiplication is used to complete the combination operation, and then a 64-dimensional candidate combination message is obtained through a linear transformation corresponding to the current relation direction. The candidate combination message is bound to the preceding relation identifier, the current relation identifier, and the current relation termination node identifier, so that each candidate combination message corresponds one-to-one with a relation combination.
[0063] When the transition value is 1, the business constraint coefficient is multiplied by the candidate combined message to obtain the adjusted combined message; when the transition value is 0, the corresponding candidate combined message is blocked. When the transition value is 1, the business constraint coefficient is applied to each feature value in the candidate combined message to obtain the adjusted combined message. A business constraint coefficient greater than 1 enhances the propagation contribution of the candidate combined message, while a business constraint coefficient less than 1 reduces the propagation contribution of the candidate combined message. When the transition value is 0, the candidate combined message is not passed to the current relation termination node, and the corresponding candidate combined message is marked as blocked. Candidate combined messages in the blocked state do not participate in subsequent entity feature aggregation.
[0064] Retain the adjusted combined message, bind the preceding relationship, the current relationship, and the termination node of the current relationship, and generate a valid combined message.
[0065] In this embodiment, the process of generating the improved CompGCN includes: Group the valid combined messages according to the current relationship termination node, select the direction transformation parameters according to the relationship direction of the current relationship, and perform a linear transformation on the valid combined messages; Read the current relationship termination node identifier bound to each valid combined message, and group valid combined messages with the same termination node identifier into the same message group. Configure forward relationship transformation parameters and reverse relationship transformation parameters according to the relationship direction of the current relationship. Forward relationships use forward relationship transformation parameters, and reverse relationships use reverse relationship transformation parameters.
[0066] For example, the effective combined message has a dimension of 64, and the orientation transformation parameters use a 64×64 dimensional trainable parameter matrix. Multiplying the effective combined message by the corresponding orientation transformation parameters yields the 64-dimensional orientation transformation result. The orientation transformation parameters are updated during model training as the loss is backpropagated.
[0067] The results of linear transformations in the same group are summed and normalized according to the number of effective combined messages. The normalized results are then linearly mapped to the entity features of the current relation termination node and added together. After activation processing, the updated entity features are obtained. The number of valid combined messages in each message group is counted. The direction transformation results of the same group are summed dimension by dimension and then divided by the number of valid combined messages to obtain the message aggregation result of the corresponding termination node. This avoids the characteristic amplitude shift caused by the difference in the number of valid combined messages.
[0068] For example, both the message aggregation result and the current entity feature of the termination node are 64-dimensional. They are transformed by independent 64×64-dimensional linear mapping parameters and then added dimension by dimension. Finally, the ReLU activation function is used to generate the updated 64-dimensional entity feature. When the termination node does not receive a valid combined message, message aggregation is not performed. Instead, the current entity feature of the termination node is processed by the corresponding linear mapping and activation as the updated entity feature, ensuring that each entity node has entity feature output in each graph convolutional layer.
[0069] For each current relation, the entity features updated after the termination node are subtracted from the entity features updated after the start node. The result is then mapped to the same dimension as the current relation features and the relation state vector, and added to them. After activation processing, the updated relation features are obtained. Based on the start and end node identifiers of the current relationship, the updated entity features of the start and end nodes are read from the same graph convolutional layer. The entity features of the start node are subtracted dimension-wise from the entity features of the end node to obtain the entity change features along the current relationship direction. Both the entity change features and the current relationship features are 64-dimensional, and the relationship state vector is 96-dimensional. The entity change features and the current relationship features are input into a 64×64-dimensional linear mapping layer, and the relationship state vector is input into a 96×64-dimensional linear mapping layer, resulting in three 64-dimensional mapping results. These three mapping results are then added dimension-wise and activated using the ReLU function to obtain the updated 64-dimensional relationship features.
[0070] Through the above processing, the relationship features retain the current relationship type information and synchronously write the entity change status between the start node and the end node, as well as the degree of business anomaly and the relationship timeliness.
[0071] The updated entity features and relation features are used as input to the next graph convolutional layer. Candidate combination message generation, business constraint coefficient adjustment, effective combination message generation, entity feature update and relation feature update are re-executed until the preset number of graph convolutional layers is reached. After updating the entity features and relation features of the current graph convolutional layer, replace the current entity features with the updated entity features and replace the current relation features with the updated relation features, while keeping the node connection relationships, relation state vectors and relation transition constraints of the food safety knowledge graph unchanged.
[0072] The next convolutional layer re-executes the CompGCN combination operation based on the updated entity features and relation features, and regenerates candidate combination messages and valid combination messages according to the business constraint coefficient processing method, without using the candidate combination messages and valid combination messages generated by the previous convolutional layer.
[0073] In one implementation, the improved CompGCN is configured as a three-layer graph convolutional structure, where the entity features and relational features of each graph convolutional layer are both 64-dimensional. When the number of training samples is less than 10,000, it is configured as two layers, and when it reaches 10,000, it is configured as three layers to prevent the node features from converging due to too many graph convolutional layers.
[0074] The entity features and relation features output from the final graph convolutional layer are used as risk association representations to generate an improved CompGCN.
[0075] In this embodiment, the process of generating a food safety risk reasoning model includes: The positive sample consists of risk events that have been verified to have a risk association and the risk source objects. The negative sample consists of food safety regulatory objects that have been verified to have no risk association within the same business stage and the same effective regulatory cycle and the corresponding risk events. Read the review results corresponding to the risk event nodes, and form a positive sample by combining the risk source object and the risk event recorded in the review results, and set the sample label to 1. Using the same risk event as an index, select food safety regulatory objects that are in the same business stage as the risk source object and whose occurrence time is in the same effective regulatory cycle, and form a negative sample by selecting food safety regulatory objects whose review results are risk excluded, and set the sample label to 0.
[0076] Each positive sample is configured with three negative samples; if there are fewer than three negative samples, all eligible negative samples are retained. The training samples are divided into training, validation, and test sets in a 7:2:1 ratio. Positive and negative samples corresponding to the same risk event are assigned to the same dataset to avoid the same risk event being distributed across different datasets.
[0077] Positive samples, negative samples, and a food safety knowledge graph are input into the improved CompGCN to perform multi-layer propagation and calculate the risk association prediction value between risk events and food safety regulatory objects based on risk association representation. Centered on each risk event node, the associated food safety regulatory object nodes, business event nodes, risk event nodes, and relational edges within the range of a preset number of convolutional layers are extracted to form a training subgraph. The improved CompGCN performs multi-layer propagation on the training subgraph, outputting the risk association representations corresponding to risk event nodes and food safety regulatory object nodes.
[0078] The risk association representations of risk event nodes and food safety regulatory object nodes are concatenated and input into a fully connected layer. The resulting value is then converted into a risk association prediction value between 0 and 1 using a Sigmoid function. The closer the predicted risk association value is to 1, the stronger the association between the food safety regulatory object and the risk event. The extraction range of the training subgraph can be set to three hops. When a single training subgraph contains more than 200 nodes, 200 nodes are retained sequentially based on their graph distance from the risk event nodes and the timeliness of their relationship.
[0079] The risk association discrimination loss is calculated based on the risk association prediction value and sample label. The business transfer constraint loss is calculated based on the propagation contribution of the candidate combination message corresponding to the invalid relationship combination. For positive samples, the risk source consistency loss is calculated based on the predicted risk source and the verified risk source. The risk association discrimination loss adopts the binary cross-entropy loss, which is calculated based on the risk association prediction values of positive and negative samples and the corresponding sample labels.
[0080] When calculating the business transfer constraint loss, candidate combination messages are retained before setting the business constraint coefficients corresponding to invalid relationship combinations to 0. The sum of squares of the feature values of each dimension of the candidate combination messages is calculated, and the average value of the calculation results corresponding to invalid relationship combinations within the same training batch is taken as the business transfer constraint loss to reduce the propagation contribution of invalid relationship combinations. When calculating the risk source consistency loss, only positive samples are used. The food safety regulatory object with the highest risk association prediction value corresponding to the same risk event is determined as the predicted risk source, and the predicted risk source is compared with the verified risk source. If the two are consistent, the risk source consistency loss is not increased; if the two are inconsistent, the risk source consistency loss is increased based on the difference in risk association prediction values between the verified risk source and the predicted risk source.
[0081] The loss from risk association discrimination, loss from business transfer constraint, and loss from consistency of risk source are weighted and synthesized, and the entity transformation parameters, relationship update parameters, and direction transformation parameters are updated based on the synthesis results. In this implementation, the weights of the risk association discrimination loss, business transfer constraint loss, and risk source consistency loss are set to 0.6, 0.2, and 0.2, respectively. The sum of the three weights is 1. The Adam optimizer is used to perform parameter updates, with an initial learning rate set to 0.001, and each training batch contains 64 training samples. Backpropagation is performed based on the weighted composite loss to update the entity transformation parameters, relation update parameters, and direction transformation parameters in the improved CompGCN.
[0082] The process of multi-layer propagation, loss calculation, and parameter updates is repeated until a preset training termination condition is met, generating a food safety risk inference model. Specifically, after each training round, the validation loss is calculated using the validation set. The maximum number of training rounds is set to 200. Training stops when the validation loss does not decrease for 10 consecutive rounds, and the entity transformation parameters, relation update parameters, direction transformation parameters, and fully connected layer parameters corresponding to the round with the lowest validation loss are retained to generate the food safety risk inference model.
[0083] In this embodiment, the process of updating the food safety knowledge graph includes: Calculate the predicted risk correlation between risk events and food safety regulatory targets, and screen candidate risk targets that reach a preset threshold; The food safety knowledge graph is input into the food safety risk reasoning model to read the risk association representations of risk event nodes and food safety regulatory object nodes. Specifically, a preset threshold is set to 0.60, and food safety regulatory objects with a risk association prediction value of not less than 0.60 are retained and sorted in descending order of risk association prediction value; when there are more than 10 candidate risk objects, the top 10 are retained.
[0084] Read the valid combined messages and binding relationships retained by each graph convolutional layer, trace back from the risk event node to the candidate risk object node, and determine the candidate risk object with the largest risk association prediction value as the risk source object; When generating a valid combined message at each graph convolutional layer, the graph convolutional layer number, preceding relation identifier, current relation identifier, starting node identifier, ending node identifier, and business constraint coefficient are recorded synchronously. During risk backtracking, starting from the risk event node, the corresponding valid combined message is queried according to the ending node identifier, and then the search is performed layer by layer in the reverse direction of the current relation and preceding relation.
[0085] The number of backtracking layers does not exceed the number of graph convolutional layers in the improved CompGCN. In one implementation, the number of graph convolutional layers is three, and the longest backtracking path contains three sets of valid relationship combinations. A valid backtracking path is determined to exist when it is possible to continuously backtrack from a risk event node to a candidate risk object node; when multiple valid backtracking paths exist, the path with the larger product of business constraint coefficients is prioritized. The candidate risk object with a valid backtracking path and the largest risk correlation prediction value is identified as the risk source object.
[0086] Based on the business object identifier of the risk source object, retrieve the food safety supervision object in the same food circulation process, determine the scope of association, and generate supervision tasks based on the business stage of the business event node in the backtracking path. The system reads the business object identifier of the risk source object and, based on the binding relationship of the business object identifiers in the standardized regulatory data, retrieves food safety regulatory objects directly or continuously bound to the risk source object along the food circulation direction. The retrieved food safety regulatory objects and their corresponding business event nodes are grouped into an association scope; in one embodiment, the retrieval depth of the association scope is set to four levels; the retrieval stops when the risk disposal is completed, the food circulation is terminated, or there are no subsequent bound objects. If the same food safety regulatory object is retrieved repeatedly, it is retained only once.
[0087] Read the business event nodes closest to the risk source object in the backtracking path, and determine the corresponding business stage based on the event type. The regulatory task must at least include the risk event identifier, risk source object identifier, business stage, scope of association, task generation time, and handling deadline. Specifically, batch verification tasks are generated during the acceptance, testing, and storage phases; processing verification tasks are generated during the requisition and processing phases; sample retention re-inspection tasks are generated during the sample retention phase; on-site verification tasks are generated during the inspection phase; and disposal result verification tasks are generated during the disposal phase. When the risk correlation prediction value is not lower than 0.80, the disposal period is set to 2 hours; when the risk correlation prediction value is lower than 0.80, the disposal period is set to 24 hours.
[0088] The system reads the handling results of regulatory tasks to determine whether a risk is confirmed or eliminated. Upon completion of a regulatory task, it reads the task status, handling conclusion, handling time, and reviewer identification. A risk confirmation result is determined when the handling conclusion is recorded as the source of risk established and the task status is "completed." A risk elimination result is determined when the handling conclusion is recorded as the source of risk not established and the task status is "completed." The food safety knowledge graph is not updated when the handling conclusion is empty or the task status is not completed.
[0089] When a risk is identified, the risk-directing relationship between business event nodes and risk event nodes is established or updated; when a risk is eliminated, the risk elimination result and the time of disposal are written into the business event node corresponding to the regulatory task; the node attributes and relationship attributes are updated to generate an updated food safety knowledge graph.
[0090] During risk confirmation, the corresponding business event node is determined based on the risk source object identifier in the regulatory task. If there is no risk-pointing relationship between the business event node and the risk event node, a risk-pointing relationship is established, and the risk confirmation result and handling time are written in. If a risk-pointing relationship already exists, the review result and handling time in the relationship attribute are updated. During risk elimination, the corresponding risk event identifier, risk elimination result, and handling time are written into the node attribute of the corresponding business event node in the regulatory task. No risk-pointing relationship is established, and the original business event record is not deleted. After the update is completed, the relationship state vector is regenerated for the newly added or changed node attributes and relationship attributes, forming the updated food safety knowledge graph.
[0091] A food safety supervision system for a large canteen according to an embodiment of the present invention includes the following modules: The data processing module is used to collect and preprocess food safety business data to generate standardized regulatory data; The knowledge graph construction module is used to identify food safety regulatory targets and business events, establish relationships, and generate a food safety knowledge graph. The relationship status module is used to calculate the degree of business anomalies and relationship timeliness, and generate relationship status vectors; The relationship constraint module is used to verify the business continuity of adjacent relationships, generate relationship transfer constraints and valid relationship combinations; The graph convolution module is used to adjust the combined message based on the relation state vector and relation transition constraints, update entity features and relation features, and generate an improved CompGCN; The model training module is used to train the improved CompGCN based on historical risk events and review results, and generate a food safety risk reasoning model. The risk monitoring module is used to generate risk correlation results, determine the source and scope of risk, generate regulatory tasks, and update the food safety knowledge graph based on the task handling results.
[0092] Example 1: To verify the feasibility of this invention in practice, it was applied to a food safety supervision scenario encompassing the entire process of food procurement, acceptance, storage, processing, sampling, and inspection. Large canteens generate a large amount of food safety business data during daily operations, including food supply records, food batch information, testing records, processing records, sampling records, inspection records, and risk handling records. Traditional supervision methods mainly rely on manual querying of business records and fixed rules to determine risk correlations. When facing multi-stage food circulation processes, this approach suffers from incomplete business record correlations, difficulty in tracing risk propagation paths, and insufficient efficiency in locating risk sources.
[0093] In this embodiment, after collecting food safety business data, the business object identifier, business event identifier, and occurrence time in the data are parsed. Business records in the same food circulation process are bound according to the business object identifier, and time sequence alignment is performed according to the occurrence time. Duplicate records, records with missing object identifiers, and records with time conflicts are removed to generate standardized regulatory data. During the implementation, a total of 18,650 food safety business records were collected, including 4,200 food batch records, 3,850 testing records, 5,100 processing records, 2,600 sample retention records, 2,100 inspection records, and 800 risk disposal records. After preprocessing, 17,480 valid regulatory data records were retained, and the data integrity rate was improved from the original 93.7% to 98.4%.
[0094] Based on standardized regulatory data, food safety regulatory targets and business events are identified. Food batches, processing stages, sample retention stages, inspection stages, and risk events are mapped to nodes in a knowledge graph. Business relationships between procurement, circulation, processing, testing, sample retention, and inspection are mapped to relationship edges. A food safety knowledge graph is established according to the food circulation sequence. The food safety knowledge graph constructed in this embodiment contains 8620 regulatory target nodes, 12450 business event nodes, 430 risk event nodes, and 35680 relationship edges. This knowledge graph structure can preserve the complete path of food association from its entry into the canteen to the occurrence of a risk event.
[0095] For the business states corresponding to different relation edges in the knowledge graph, this embodiment reads the business anomaly level and relationship duration corresponding to the relation edge, maps the business anomaly level, relationship duration, and relationship type features to a unified feature space, and generates a relation state vector. The business anomaly level is calculated based on the business record missingness, state deviation, and anomaly event marking, while the relation duration is calculated based on the time interval between the occurrence of the business event and the regulatory time. After processing, each relation edge has a corresponding relation state vector, enabling the same business relationship to exhibit different propagation characteristics based on the actual food safety status.
[0096] During the risk relationship propagation process, this embodiment reads the business objects, business stages, and occurrence order corresponding to adjacent relationships, and verifies the business continuity between the preceding and current relationships. When two relationships correspond to the same food circulation object, the business stages conform to the food circulation order, and the occurrence time of the current relationship is no earlier than the occurrence time of the preceding relationship, the corresponding relationship combination is retained, generating a valid relationship combination; when there are cases of mismatched business objects, reversed business stages, or abnormal time order, the propagation of the corresponding relationship combination is blocked. After relationship transfer constraint processing, out of the original 35,680 relationship combinations, 28,640 valid relationship combinations are retained, reducing 7,040 non-business-related relationships.
[0097] The improved CompGCN inputs a food safety knowledge graph, relation state vectors, and valid relation combinations to perform entity and relation feature combination operations. The model generates business constraint coefficients based on relation state vectors and relation transition constraints, filters and adjusts combined messages, retaining those that satisfy the continuity of food circulation business, and updates entity and relation features. During training, historical risk events and review results are used to construct training samples, including 420 risk confirmation samples and 1260 risk exclusion samples, forming a total of 1680 training samples. These training samples are then input into the improved CompGCN to perform multi-level propagation and parameter iteration, generating a food safety risk inference model.
[0098] After model training is completed, the food safety knowledge graph is input into the food safety risk reasoning model to calculate the predicted risk correlation between risk events and food safety regulatory targets. Based on the prediction results, candidate risk targets are screened, and valid relationship combinations retained during the propagation process are retrieved for backtracking to determine the source of the risk and its associated scope. For the identified source of the risk, regulatory tasks are generated according to the corresponding business stage, and the handling results are mapped to risk confirmation or risk exclusion results, thus updating the food safety knowledge graph.
[0099] To verify the regulatory effectiveness of this invention, its method was compared with traditional rule-matching-based regulatory methods and static knowledge graph analysis methods. Using the same food safety business data as test data, the accuracy of risk source identification, average time for risk path location, proportion of invalid relationship propagation, and knowledge graph update completeness were tested. Test results show that this invention, through relation state vectors, relation transition constraints, and an improved CompGCN, achieves business association reasoning, reducing invalid relationship propagation and improving risk source identification capabilities compared to traditional methods. Specific test results are shown in Table 1 below.
[0100] Table 1: Comparison of the Effectiveness of Food Safety Supervision Methods in Large Canteens Based on the comparative data of food safety supervision effects in large canteens shown in Table 1, it can be seen that the food safety supervision method based on the improved CompGCN proposed in this invention has achieved good results in risk source identification, risk path location, invalid relationship suppression, and knowledge graph updating.
[0101] Analysis of the accuracy of risk source identification shows that the rule-matching-based regulatory method has an accuracy of 82.6%, mainly relying on preset rules to match abnormal food safety information, which is difficult to handle multi-level associations in complex food circulation relationships. The method based on static knowledge graph analysis improves the accuracy to 88.4%, and can perform association analysis using entity relationships, but it does not incorporate changes in food safety business status and relationship transfer constraints. This invention constructs a food safety knowledge graph, introduces relationship state vectors and business constraint coefficients, and integrates information on the degree of business anomalies, relationship timeliness, and business continuity into the CompGCN propagation process, achieving a risk source identification accuracy of 96.3% and improving the risk association analysis capability in complex food circulation scenarios.
[0102] From the perspective of risk path location efficiency analysis, rule-matching-based regulatory methods take an average of 46.8 minutes to complete risk path location, while methods based on static knowledge graph analysis take an average of 32.6 minutes. This invention utilizes an improved CompGCN to propagate effective relationship combinations and retains effective combination messages during the risk propagation process. By tracing back the risk source through effective relationship combinations, the average time for risk path location is reduced to 12.4 minutes, achieving rapid risk source location.
[0103] Analysis of the propagation rate of invalid relationships shows that rule-matching-based regulatory methods exhibit 21.5% invalid relationship propagation, while static knowledge graph analysis methods show 14.2%. This invention verifies business continuity by considering business objects, business stages, and the order of occurrence, generating relationship transfer constraints to restrict relationship combinations that do not satisfy the logic of food circulation. This reduces the invalid relationship propagation rate to 5.1%, minimizing the impact of information without business relevance on the risk reasoning process.
[0104] Analysis of the knowledge graph update completeness rate shows that the rule-matching-based regulatory method has an update completeness rate of 86.3%, while the static knowledge graph analysis method has an update completeness rate of 91.7%. This invention updates risk event nodes, business event nodes, and relationship attributes based on the results of regulatory task handling, enabling the food safety knowledge graph to be continuously updated according to actual regulatory results. The knowledge graph update completeness rate reaches 98.6%, improving the continuous maintenance capability of food safety regulatory data.
[0105] Through the above data comparison, this invention utilizes food safety knowledge graphs, relational state vectors, relational transition constraints, and an improved CompGCN risk reasoning model to achieve closed-loop processing of food safety business data association, risk path analysis, and regulatory result feedback, thereby improving the accuracy of risk identification and the efficiency of regulatory response compared to existing technologies.
[0106] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. A method for food safety supervision in a large canteen, characterized in that, Includes the following steps: Collect food safety business data from large canteens and preprocess it to generate standardized regulatory data; Based on standardized regulatory data, identify food safety regulatory targets and business events, establish the relationship between regulatory targets and business events according to the food circulation sequence, and generate a food safety knowledge graph; Read the business status corresponding to the relationship edge in the food safety knowledge graph, map the degree of business anomaly and the timeliness of the relationship to the relationship features, and generate a relationship status vector; Verify business continuity based on the business objects, business stages, and order of occurrence of adjacent relationships; construct relationship transfer constraints; and generate valid relationship combinations. The food safety knowledge graph, relation state vector, and effective relation combinations are input into CompGCN. Combination operations are performed on adjacent entity features and relation features. Business constraint coefficients are generated based on relation state vectors and relation transition constraints. Combination messages are filtered and adjusted using business constraint coefficients. Effective combination messages are aggregated to update entity features. Relation features are updated synchronously based on entity update results to generate an improved CompGCN. Training samples are constructed based on historical risk events and review results. The training samples are then input into the improved CompGCN to perform multi-layer propagation and parameter iteration, generating a food safety risk inference model. By inputting the food safety knowledge graph into the food safety risk reasoning model, the risk association results are obtained. The effective relationship combinations are traced back to determine the source of risk and the scope of association, and regulatory tasks are generated. The food safety knowledge graph is updated based on the task handling results.
2. The food safety supervision method for a large canteen according to claim 1, characterized in that, The preprocessing includes: Analyze food safety business data to extract business object identifiers, business event identifiers, and occurrence times; Bind business records according to business object identifiers, align them according to execution sequence based on the time of occurrence, and remove duplicate records, records with missing identifiers, and records with conflicting sequences; Verify the integrity of the association between business objects and business events, and generate standardized regulatory data.
3. The food safety supervision method for a large canteen according to claim 2, characterized in that, The process of generating the food safety knowledge graph includes: Map food safety regulatory objects in standardized regulatory data to regulatory object nodes, business records to business event nodes, and business events that are confirmed as abnormal after review to risk event nodes; Establish a directed relationship between the regulatory target node and the business event node according to the food circulation sequence, and establish a risk-oriented relationship between the business event node and the risk event node. Establish reverse relationships for directed and risk-oriented relationships, write node attributes and relationship attributes, and generate a food safety knowledge graph.
4. A food safety supervision method for a large canteen according to claim 3, characterized in that, The generated relation state vector includes: Read the business records corresponding to the relation edges, compare the business status with the preset normal status, obtain the status deviation value, and calculate the field integrity rate and the number of duplicate anomalies of the business records. The business anomaly level is obtained by normalizing and weighting the status deviation value, field missing rate, and number of repeated anomalies. Calculate the time interval between the occurrence time of the business event corresponding to the relation edge and the current regulatory time. Then, perform attenuation mapping on the time interval according to the effective regulatory period corresponding to the relation type to obtain the relation validity period. Relationship types are encoded as relationship type features, and the degree of business anomalies and relationship timeliness are mapped to the feature space where the relationship type features are located. The result is a relationship state vector generated by concatenating the features.
5. A food safety supervision method for a large canteen according to claim 4, characterized in that, The relationship transfer constraints include: Traverse the adjacent relationships in the food safety knowledge graph where the terminal node is the same as the starting node, and determine the previous relationship and the current relationship according to the relationship direction; Read the business object identifiers of the nodes associated with the previous and current relationships, determine whether the previous and current relationships belong to the same food circulation process based on the binding relationship of the business object identifiers, and generate continuous object states; The business stage is determined based on the event type of the corresponding business event node according to the preceding and current relationships, and the order and occurrence time of the business stages are compared. When the current business stage is no earlier than the previous business stage, and the current relationship occurs no earlier than the previous relationship occurs, a sequential continuous state is generated. When both the continuous state and the sequential continuous state of the object are valid, the preceding relation and the current relation are combined into a valid relation combination and the transition value is set to 1; when either state is invalid, the preceding relation and the current relation are combined into an invalid relation combination and the transition value is set to 0; the relation combinations and corresponding transition values are summarized to generate relation transition constraints.
6. A food safety supervision method for a large canteen according to claim 5, characterized in that, The process of filtering and adjusting combined messages using business constraint coefficients includes: Read the relationship combinations one by one, extract the business anomaly level and relationship timeliness from the relationship state vector corresponding to the current relationship, and read the corresponding transfer value from the relationship transfer constraint; After adding 1 to the business anomaly level, multiply it by the relationship timeliness and transfer value to generate the business constraint coefficient corresponding to the relationship combination; Read the entity features of the current relationship starting node as the adjacent entity features, perform CompGCN combination operation on the adjacent entity features and the current relationship features, and generate candidate combination messages corresponding to the relationship combination; When the transition value is 1, the business constraint coefficient is multiplied by the candidate combined message to obtain the adjusted combined message; when the transition value is 0, the corresponding candidate combined message is blocked. Retain the adjusted combined message, bind the preceding relationship, the current relationship, and the termination node of the current relationship, and generate a valid combined message.
7. A food safety supervision method for a large canteen according to claim 6, characterized in that, The process of generating the improved CompGCN includes: Group the valid combined messages according to the current relationship termination node, select the direction transformation parameters according to the relationship direction of the current relationship, and perform a linear transformation on the valid combined messages; The results of linear transformations in the same group are summed and normalized according to the number of effective combined messages. The normalized results are then linearly mapped to the entity features of the current relation termination node and added together. After activation processing, the updated entity features are obtained. For each current relation, the entity features updated after the termination node are subtracted from the entity features updated after the start node. The result is then mapped to the same dimension as the current relation features and the relation state vector, and added to them. After activation processing, the updated relation features are obtained. The updated entity features and relation features are used as input to the next graph convolutional layer. Candidate combination message generation, business constraint coefficient adjustment, effective combination message generation, entity feature update and relation feature update are re-executed until the preset number of graph convolutional layers is reached. The entity features and relation features output from the final graph convolutional layer are used as risk association representations to generate an improved CompGCN.
8. A food safety supervision method for a large canteen according to claim 7, characterized in that, The process of generating the food safety risk reasoning model includes: The positive sample consists of risk events that have been verified to have a risk association and the risk source objects. The negative sample consists of food safety regulatory objects that have been verified to have no risk association within the same business stage and the same effective regulatory cycle and the corresponding risk events. Positive samples, negative samples, and a food safety knowledge graph are input into the improved CompGCN to perform multi-layer propagation and calculate the risk association prediction value between risk events and food safety regulatory objects based on risk association representation. The risk association discrimination loss is calculated based on the risk association prediction value and sample label. The business transfer constraint loss is calculated based on the propagation contribution of the candidate combination message corresponding to the invalid relationship combination. For positive samples, the risk source consistency loss is calculated based on the predicted risk source and the verified risk source. The loss from risk association discrimination, loss from business transfer constraints, and loss from consistency of risk sources are weighted and synthesized, and the entity transformation parameters, relationship update parameters, and direction transformation parameters are updated based on the synthesis results. Repeatedly perform multi-layer propagation, loss calculation, and parameter updates until the preset training termination condition is met to generate a food safety risk inference model.
9. A food safety supervision method for a large canteen according to claim 8, characterized in that, The process of updating the food safety knowledge graph includes: Calculate the predicted risk correlation between risk events and food safety regulatory targets, and screen candidate risk targets that reach a preset threshold; Read the valid combined messages and binding relationships retained by each graph convolutional layer, trace back from the risk event node to the candidate risk object node, and determine the candidate risk object with the largest risk association prediction value as the risk source object; Based on the business object identifier of the risk source object, retrieve the food safety supervision object in the same food circulation process, determine the scope of association, and generate supervision tasks based on the business stage of the business event node in the backtracking path. Read the results of the handling of regulatory tasks to determine the risk confirmation or risk elimination results; When a risk is identified, the risk-directing relationship between business event nodes and risk event nodes is established or updated; when a risk is eliminated, the risk elimination result and the time of disposal are written into the business event node corresponding to the regulatory task; the node attributes and relationship attributes are updated to generate an updated food safety knowledge graph.
10. A food safety supervision system for a large canteen, applied to the food safety supervision method for a large canteen as described in any one of claims 1 to 9, characterized in that, Includes the following modules: The data processing module is used to collect and preprocess food safety business data to generate standardized regulatory data; The knowledge graph construction module is used to identify food safety regulatory targets and business events, establish relationships, and generate a food safety knowledge graph. The relationship status module is used to calculate the degree of business anomalies and relationship timeliness, and generate relationship status vectors; The relationship constraint module is used to verify the business continuity of adjacent relationships, generate relationship transfer constraints and valid relationship combinations; The graph convolution module is used to adjust the combined message based on the relation state vector and relation transition constraints, update entity features and relation features, and generate an improved CompGCN; The model training module is used to train the improved CompGCN based on historical risk events and review results, and generate a food safety risk reasoning model. The risk monitoring module is used to generate risk correlation results, determine the source and scope of risk correlation, generate regulatory tasks, and update the food safety knowledge graph based on the task handling results.