Food detection multi-level early warning method and system based on standard data model
Patent Information
- Application Number
- CN202611280010.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-22
- Publication Date
- 2026-10-13
AI Technical Summary
与现有技术相比,本发明的有益效果包括:
Smart Images

Figure CN122905447A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of automatic food safety data judgment technology, specifically to a multi-level early warning method and system for food testing based on a standard data model, and particularly to a technology that digitizes national standard limit data, automatically executes graded judgments using a rule engine, and implements hard blocking of non-compliant data using database layer constraints. Background Technology
[0002] The interpretation of food safety test results and the handling of non-compliance are crucial aspects of food safety management. Existing technologies have the following technical shortcomings: (1) Judgment relies on manual labor, is inefficient and prone to errors. Taking pesticide residue limit standards as an example, they contain tens of thousands of limit indicators for hundreds of pesticides in hundreds of food categories. If the judgment of the compliance of test data relies on manual review of standard documents and comparison of each item, it is not only time-consuming, but also carries the risk of misjudgment due to errors or omissions in the review. (2) The handling of non-conformities relies on "soft control" and has loopholes in implementation. In the existing technology, the handling of non-conformities mainly relies on management system and manual execution (such as "notifying relevant personnel to handle" and "suspending shipments"), lacking technical enforcement measures. There is a risk of execution delay, human negligence, or even deliberate bypass of the handling steps. Non-conformity data may be manually entered into the inventory system. (3) The binary judgment lacks risk gradient. Existing technologies mostly adopt the binary judgment of "pass / fail", which lacks the critical identification of the situation where the detected value is close to the limit value but does not exceed the standard, and also lacks the special handling for the detection of prohibited substances and the cumulative escalation mechanism of the supplier's historical risks. (4) The standard is out of sync with the system. The national standard limit values change dynamically with each version revision. The judgment logic of the existing system is mostly fixed in the code. After the standard is revised, it needs to be redeveloped and deployed, resulting in a long update cycle. Summary of the Invention
[0003] Technical issues The technical problem to be solved by this invention is: how to provide a technical solution that automatically performs the comparison and judgment of test data with standard limit values, hard-blocks unqualified batches from entering the inventory system at the database level, and supports dynamic updates of limit standards and supplier risk accumulation upgrades.
[0004] Technical solution To solve the above-mentioned technical problems, the present invention adopts the following technical solution: Firstly, a multi-level early warning method for food testing based on a standard data model is provided, including: extracting the limit standard into a structured standard data model; receiving the test data uploaded by the testing terminal; retrieving the limit value according to the food category and test item and automatically outputting the grading judgment result; setting data verification constraints in the inventory data table write link to prevent write operations corresponding to the access level judgment result from being hard blocked; and hashing and storing the test data, judgment result and disposal action records on the blockchain. Secondly, a multi-level early warning system for food detection corresponding to the above method is provided. Thirdly, a computer-readable storage medium and an electronic device are provided.
[0005] Beneficial effects Compared with the prior art, the beneficial effects of the present invention include: (1) Automated judgment. After the detection data is input, the standard data model is automatically retrieved and the comparison is completed. The judgment of a single batch is completed in milliseconds, eliminating the time-consuming manual review and comparison and the risk of misjudgment. (2) Hard blocking of non-compliant data. By verifying and constraining the database write link, batches that are denied access are prevented from being written to the inventory data table from the data layer. Any direct database operation that bypasses the business interface is also constrained, thus fundamentally eliminating the execution vulnerability of "soft control". (3) Multi-level risk gradient. By using multiple levels of judgment such as qualified, watch, and unqualified, differentiated handling from critical identification to serious violations can be achieved; by upgrading the list of prohibited substances and historical trends, risk accumulation control at the supplier level can be achieved. (4) Standards can be hot-updated. The standard data model is stored independently of the judgment logic. After the limited standard is revised, it can be updated instantly through the management interface without recompiling and re-deploying, thus shortening the standard implementation cycle. Compared to existing technologies, this invention not only digitizes food safety limits into a hot-updateable standard data model, but more importantly, it sets database-level data validation constraints (such as BEFORE INSERT triggers or CHECK constraints) in the inventory data table write process. This allows the rejection-level judgment result to directly determine whether data can be written to the inventory data table. This hard control mechanism uses database transaction rollback as a technical means, and any direct database write operation that bypasses the business interface will be subject to the same constraint, fundamentally eliminating execution vulnerabilities caused by relying solely on manual notifications or soft controls at the business layer. Simultaneously, through a three-level judgment system (qualified, concerned, unqualified) and mechanisms such as historical trend escalation, prohibited substance lists, interval verification, and traceability-linked rejection, a risk gradient control system is formed across the entire chain, from critical identification to serious violations, and from single batches to suppliers. Attached Figure Description
[0006] Figure 1This is a schematic diagram of the standard data model structure and judgment process of this invention. Figure 2 This is a schematic diagram of the multi-level early warning and database hard control process of the present invention. Figure 3 This is a schematic diagram of the module composition of the system of the present invention. Detailed Implementation
[0007] The present invention will now be described in further detail with reference to the accompanying drawings and specific embodiments. Example 1: Automatic Judgment and Hard Blocking of Pesticide Residue Detection in Vegetables This example uses the detection of chlorpyrifos in a batch of celery as an example. In the standard data model, the food category is "leafy vegetables", the detection item is "chlorpyrifos", the limit value is 0.05 mg / kg, and the judgment comparison rules are as follows: the detection value ≤ 0.04 mg / kg (80% of the limit value) is considered qualified; the detection value > 0.04 mg / kg and ≤ 0.05 mg / kg is considered of concern; the detection value > 0.05 mg / kg is considered unqualified. The testing terminal uploads testing data: Food category = leafy vegetables, Testing item = chlorpyrifos, Detection value = 0.06 mg / kg. The grading and judgment module retrieves the standard data model, compares it, and outputs "Unqualified Level" (Rejected Admission Level). System execution: The insert trigger on the inventory data table checks the judgment result field to "Unqualified" before executing the write operation, throws an exception to terminate the insert, and the batch cannot obtain an inventory record; at the same time, an early warning message is generated and pushed to the supplier and warehouse manager; the testing data, judgment result, and handling action are written to the blockchain through hash calculation. Furthermore, a BEFORE INSERT trigger is defined on the inventory data table. Its pseudocode logic is as follows: read the food category identifier, test item identifier, and test value of the record to be inserted; call the grading judgment service to obtain the judgment result field; if the judgment result field is at the rejection admission level, throw an SQL exception and roll back the current transaction, preventing that batch from obtaining inventory records. Therefore, even if write operations are performed directly through means other than database management tools or business interfaces, they will be hard-blocked by the trigger constraint, avoiding manual bypassing of the business layer processing flow. Example 2: Detection of prohibited substances and suspension of supplier qualification Malachite green was detected in a batch of aquatic products. The classification and judgment module hit the list of prohibited substances, directly outputting the highest level judgment result and triggering the action of suspending the supply qualification of the aquaculture farm. At the same time, a formatted report (including test data, collection time, location information and video link of the testing process) was generated and submitted to the regulatory authorities. Example 3: Interval Verification and Hot Update For planted food products, the system calculates the earliest harvestable date based on the last pesticide application date and pesticide identification in the agricultural operation record, according to the safety interval data in the standard data model. If the detection and collection time is earlier than this date, even if the detection value meets the limit value, an admission rejection level will be output. When the limit standard is revised and released, the administrator updates the limit value record in the standard data model through the management interface. The update takes effect immediately, and subsequent judgments automatically adopt the new value without downtime. Example 4: Determining the Upgrade of Supplier Historical Trends Vegetable supplier A has had 5 batches assessed as "concern level" (with test values between 80% and 100% of the limit) consecutively within the past 30 days. According to the historical trend escalation judgment step described in claim 4, the system counts the number of consecutive "concern" instances for this supplier within a preset time window. When the number of consecutive "concern" instances reaches a preset threshold of 5, the "concern level" assessment result for the current batch is escalated to "rejection level," triggering a suspension of the supplier's supply qualification, and an escalation warning is pushed to the purchasing and quality control departments. Example 5: Source tracing and linkage rejection A primary batch B contains 10 secondary batches. Batch B-3 was found to contain malachite green (a prohibited substance) and was flagged as a rejection. The system traces the primary batch B to which batch B-3 belongs and counts the number of batches under that primary batch that have been flagged as rejections. When this number reaches a preset threshold of 2, the testing priority of the remaining untested batches under primary batch B is raised to a high-risk level, allowing for expedited retesting and interception to prevent the risk from spreading to other batches from the same source.
[0008] Industrial applicability This invention can be applied to the automatic judgment of testing data and inventory access control of fresh food e-commerce platforms, food supply chain management platforms, agricultural product wholesale markets, and food processing enterprises. It can also be connected to the data interface of government regulatory platforms, and has good industrial applicability.
Claims
1. A multi-level early warning method for food detection based on a standard data model, characterized in that, Includes the following steps: Step S1, Standard Data Modeling: The limit indicators in the food safety limit standards are extracted in a structured manner to establish a standard data model; the standard data model uses food category as the primary index and test item as the secondary index, and each record includes at least the food category identifier, test item identifier, limit value, judgment comparison rule and standard source identifier; Step S2, Data Access: Receive the detection data uploaded in real time by the detection terminal. The detection data includes at least the food category identifier, the detection item identifier, the detection value, and the collection time. Step S3, Automatic Grading Determination: Based on the food category identifier and test item identifier in the test data, retrieve the corresponding limit value from the standard data model, compare the test value with the limit value according to the judgment comparison rules, and output a grading determination result containing at least two levels; the at least two levels include an allowed access level and a denied access level; Step S4, Database hard control: Set data validation constraints in the write link of the inventory data table. When the inventory write operation is executed, the data validation constraints automatically read the hierarchical judgment result corresponding to the write operation. When the hierarchical judgment result is the rejection admission level, the write operation is prevented from being completed, so that the corresponding batch of data cannot enter the inventory data table. Step S5, handling and evidence storage: In response to the graded judgment result, generate and push the corresponding level of early warning information, and write the detection data, the graded judgment result and the handling action record into the blockchain for evidence storage after performing a hash operation.
2. The method according to claim 1, characterized in that, The judgment comparison rules in step S1 include: when the detected value is less than or equal to the limit value multiplied by a first preset ratio, it is judged as a qualified level; when the detected value is greater than the limit value multiplied by the first preset ratio and less than or equal to the limit value, it is judged as a concern level; when the detected value is greater than the limit value, it is judged as a non-qualified level; wherein, the qualified level and the concern level belong to the allowed access level, and the non-qualified level belongs to the rejected access level.
3. The method according to claim 2, characterized in that, The standard data model mentioned in step S1 also includes prohibited substance list data, which contains the identifiers of substances prohibited from being detected in food; in step S3, when the identifier of the detection item in the detection data matches the prohibited substance list data, the highest level judgment result is directly output. The highest level judgment result belongs to the rejection level and triggers the action of suspending the corresponding supplier's supply qualification.
4. The method according to claim 2, characterized in that, Step S3 also includes historical trend upgrade judgment: statistical analysis of the historical detection judgment results of the same source within a preset time window. When the continuous batch detection judgment results of the same source reach the preset number of consecutive attention, the attention level judgment result of the current batch is upgraded to the rejection level.
5. The method according to claim 1, characterized in that, The data validation constraint mentioned in step S4 is implemented through a database insert trigger: an insert trigger is defined on the inventory data table. Before the insert operation is executed, the insert trigger checks the judgment result field in the record to be inserted. When the value of the judgment result field is the rejection admission level, an exception is thrown to terminate the insert operation.
6. The method according to claim 1, characterized in that, It also includes an automatic interval verification step: for planted food, the earliest harvestable date is calculated based on the date and medication identification of the last application in the agricultural operation record, according to the safety interval data in the standard data model; for livestock food, the earliest marketable date is calculated based on the date and medication identification of the last application in the medication record; when the collection time of the detection operation is earlier than the earliest harvestable date or the earliest marketable date, even if the detection value meets the limit value, the rejection admission level judgment result is output.
7. The method according to claim 1, characterized in that, The standard data model supports hot updates: when the limit standard is revised, the records in the standard data model can be added, modified or deleted through the management interface. The update takes effect immediately after the update operation is completed, and the updated records are automatically used in subsequent judgments in step S3.
8. The method according to claim 1, characterized in that, It also includes a traceability linkage rejection step: when a batch of food is output with a rejection access level determination result, the parent batch identifier of the batch of food is traced, the number of batches under the parent batch identifier that are determined to be rejection access level is counted, and when the number reaches a preset threshold, the detection priority of the remaining untested batches under the parent batch identifier is raised to the high-risk level.
9. A multi-level early warning system for food detection based on a standard data model, characterized in that, include: The standard data modeling module is used to extract the limit indicators from the food safety limit standards in a structured manner and establish a standard data model with food category as the primary index and test item as the secondary index. The detection data access module is used to receive detection data uploaded in real time by the detection terminal; The grading and determination module is used to retrieve the limit values from the standard data model based on the food category identifier and the test item identifier in the test data, compare them according to the judgment comparison rules, and output the grading and determination results including the allowed access level and the rejected access level. The database hard control module is used to set data validation constraints in the write chain of the inventory data table. When the inventory write operation is executed, it automatically reads the corresponding hierarchical judgment result and prevents the write operation from completing when the judgment result is the rejection admission level. The disposal and evidence storage module is used to respond to the generation of graded judgment results and push the corresponding level of early warning information, and write the detection data, graded judgment results and disposal action records into the blockchain for evidence storage after hashing.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the multi-level early warning method for food detection based on the standard data model as described in any one of claims 1 to 8.
11. An electronic device, characterized in that, The device includes a processor, a memory, and a communication interface. The memory stores a computer program, and when the processor executes the computer program, it implements the multi-level early warning method for food detection based on a standard data model as described in any one of claims 1 to 8.