Food safety traceability system and traceability method
By introducing food data collection devices, node servers and food safety traceability servers into the food safety traceability system, the original food data is parsed to generate food safety traceability data, and the problems of high access threshold and high deployment costs of existing systems are solved, and efficient food safety data traceability and storage are achieved.
Patent Information
- Application Number
- CN202411878904.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-19
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2044-12-19
AI Technical Summary
The existing food safety traceability system has high access thresholds and high deployment costs in its implementation and promotion application, and the massive data processing, storage and query of blockchain technology is under great pressure.
A food safety traceability system is proposed, including a food data collection device, a node server and a food safety traceability server. The system generates food safety traceability data by analyzing the original food data, including food relationship chains, encrypted data units and hash values, to achieve effective traceability and storage of data.
It effectively improves the traceability of food safety data, reduces the cost of deployment and implementation, and simplifies the access process of all links of the food supply chain.
Smart Images

Figure CN119722107A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of food safety traceability, and in particular to a food safety traceability system and a traceability method. Background Art
[0002] Food safety is an important livelihood issue. In order to solve this problem, people have developed various technologies to improve the traceability of food safety, including technologies that use blockchain technology to improve the traceability and reliability of food safety data. However, in actual applications, it is found that these technologies have great difficulties in implementation and promotion. On the one hand, because the access threshold of blockchain is high, the existing digital systems in various links of the food supply chain cannot be directly connected to it, and the cost of secondary development is high. On the other hand, in order to ensure the security and reliability of data, each participating node of blockchain technology needs to have a redundant copy of complete ledger data. In order to ensure the traceability of food safety data, all links of the food supply chain must be connected to the system. The massive amount of food safety data leads to great pressure on the traceability system to process, store and query food safety data. Summary of the invention
[0003] Based on the above problems, the present invention proposes a food safety traceability system and a traceability method, which can effectively improve the traceability capability of food safety data and reduce the cost of deployment and implementation.
[0004] In view of this, a first aspect of the present invention proposes a food safety traceability system, comprising a food data collection device for collecting food data, a node server for storing food data connected to the food collection device, and a food safety traceability server for generating and querying food safety traceability data, wherein the food safety traceability server is configured as follows: Receiving original food data submitted by the node server, wherein the original food data is data of food or food-related materials; Parsing the original food data to obtain an attribute data set of each food or food-related material, wherein the attribute data set includes attribute data associated with a unique identification code of the corresponding food or food-related material, and the attribute data includes an attribute name and an attribute content; Generate food safety traceability data based on the attribute data set, the food safety traceability data including a food relationship chain, an encrypted data unit, and a hash value of the encrypted data unit; Determine the upstream node server and / or downstream node server corresponding to the original food data according to the food relationship chain; Sending the upstream relationship unit of the food relationship chain and the hash value of the encrypted data unit to the upstream node server, and / or sending the downstream relationship unit of the food relationship chain and the hash value of the encrypted data unit to the downstream node server; and, The encrypted data unit, the hash value of the encrypted data unit, the upstream and downstream relationship unit and the hash value of the upstream and downstream encrypted data units are sent to the node server that submits the original food data, the upstream and downstream relationship unit includes an upstream relationship unit and / or a downstream relationship unit, and the upstream and downstream encrypted data units include an upstream encrypted data unit and / or a downstream encrypted data unit.
[0005] Furthermore, in the step of parsing the original food data, the food safety traceability server is configured to: Determining whether the original food data contains a unique identification code of an upstream food or an upstream food-related material; When the original food data contains a unique identification code of an upstream food or an upstream food-related material, determining the number of unique identification codes of the upstream food or the upstream food-related material contained in the original food data ; Extracting a unique identification code of each upstream food or upstream food-related material from the raw food data; Generate a unique identification code with the number Correspondingly, the attribute data has the unique identification code of the upstream food or upstream food-related materials as the attribute content.
[0006] Further, in the step of generating food safety traceability data based on the attribute data set, the food safety traceability server is configured to: When the original food data contains a unique identification code of an upstream food or an upstream food-related material, a relationship unit instance count variable for instantiating a relationship unit instance is constructed and calculated. ; Generate a count variable corresponding to the relationship unit instance based on the pre-built relationship unit object Instance of a relational unit; Obtaining a first hash value of an encrypted data unit corresponding to a unique identification code of each upstream food or upstream food-related material and a second hash value of a current encrypted data unit; The physical state change relationship and / or the associated subject change relationship, as well as the first hash value and the second hash value are written into the relationship unit instance to obtain a corresponding relationship unit.
[0007] Further, in constructing and calculating the relationship unit instance count variable used to instantiate the relationship unit instance In the step, the food safety traceability server is configured as follows: Constructing a relation unit instance count variable , and initialize it to ; From 1 to Traverse each upstream food or upstream food related material; Determine the traversed upstream food or upstream food-related materials as target materials; Identify the physical state change relationship and the associated subject change relationship from the target material to the current food or food-related material; When the target material has both a physical state change relationship and an associated subject change relationship with the current food or food-related material, let the relationship unit instance count variable The value of is increased by 1; When the target material has only one of a physical state change relationship and an associated subject change relationship with the current food or food-related material, the relationship unit instance count variable is maintained. The value of remains unchanged.
[0008] Furthermore, in the step of identifying the physical state change relationship and the associated subject change relationship from the target material to the current food or food-related material, the food safety traceability server is configured as follows: Determine the target node server corresponding to the target material; Acquire the target encrypted data unit corresponding to the target material from the target node server; Parsing the target encrypted data unit to obtain a first material type attribute and a first associated subject attribute in the attribute data set of the target material; Acquire a second material type attribute and a second associated subject attribute of the current food or food-related material from an attribute data set of the current food or food-related material; Generate a physical state change relationship from the target material to the current food or food-related material based on the first material type attribute and the second material type attribute; and An associated subject change relationship from the target material to the current food or the food-associated material is generated based on the first associated subject attribute and the second associated subject attribute.
[0009] Further, in the step of generating a physical state change relationship from the target material to the current food or food-related material based on the first material type attribute and the second material type attribute, the food safety traceability server is configured as follows: Determine whether the first material type attribute and the second material type attribute are the same; When the first material type attribute and the second material type attribute are different, generating a physical state change relationship instance based on a pre-built physical state change relationship object; The first material type attribute and the second material type attribute are sequentially written into the physical state change relationship instance to obtain the corresponding physical state change relationship.
[0010] Further, in the step of generating an associated subject change relationship from the target material to the current food or food-associated material based on the first associated subject attribute and the second associated subject attribute, the food safety traceability server is configured as follows: Determining whether the first association subject attribute and the second association subject attribute are the same; When the first association subject attribute and the second association subject attribute are different, generating an association subject change relationship instance based on a pre-built association subject change relationship object; The first association subject attribute and the second association subject attribute are sequentially written into the association subject change relationship instance to obtain a corresponding association subject change relationship.
[0011] Further, after the step of writing the physical state change relationship and / or the associated subject change relationship, and the first hash value and the second hash value into the relationship unit instance to obtain the corresponding relationship unit, the food safety traceability server is configured as follows: Determine whether there is a food relationship chain with the first hash value as the terminal node; When there is a food relationship chain with the first hash value as the terminal node, adding the physical state change relationship and / or the associated subject change relationship and the second hash value to the end of the food relationship chain; When there is no food relationship chain with the first Hash value as the terminal node, a new food relationship chain with the first Hash value as the starting node and the second Hash value as the terminal node is generated.
[0012] Furthermore, the food safety traceability server is also configured to: Receiving a food safety traceability request submitted by a user, wherein the food safety traceability request includes a unique identification code of the food to be traced; Obtaining a hash value of the encrypted data unit of the food to be traced according to the unique identification code of the food to be traced; Querying a food relationship chain containing the hash value in a database, wherein the food relationship chain is composed of food and / or food-related materials at various nodes and relationship units between nodes connected to each other, wherein each node in the food relationship chain is represented by the hash value of its encrypted data unit, and the relationship unit between nodes is used to represent the physical state change relationship or the associated subject change relationship between food or food-related materials from one node to another; When there is a food relationship chain containing the hash value in the database, extracting the hash value of the encrypted data unit of the food on the chain or the food-related material on the chain from the food relationship chain; Determine the corresponding node server according to the hash value of the encrypted data unit; Obtaining encrypted data units of on-chain food or on-chain food-related materials in the food relationship chain from the determined node server; parsing the encrypted data unit to obtain target attribute data to be displayed; The target attribute data is displayed in a visual manner in accordance with the time sequence in the food relationship chain in combination with the physical state change relationship and / or the associated subject change relationship in the food relationship chain.
[0013] A second aspect of the present invention provides a food safety traceability method, comprising: The food safety traceability server receives a food safety traceability request submitted by a user, wherein the food safety traceability request includes a unique identification code of the food to be traced; Obtaining a hash value of the encrypted data unit of the food to be traced according to the unique identification code of the food to be traced; Querying a food relationship chain containing the hash value in a database, wherein the food relationship chain is composed of food and / or food-related materials at various nodes and relationship units between nodes connected to each other, wherein each node in the food relationship chain is represented by the hash value of its encrypted data unit, and the relationship unit between nodes is used to represent the physical state change relationship or the associated subject change relationship between food or food-related materials from one node to another; When there is a food relationship chain containing the hash value in the database, extracting the hash value of the encrypted data unit of the food on the chain or the food-related material on the chain from the food relationship chain; Determine the corresponding node server according to the hash value of the encrypted data unit; Obtaining encrypted data units of on-chain food or on-chain food-related materials in the food relationship chain from the determined node server; parsing the encrypted data unit to obtain target attribute data to be displayed; The target attribute data is displayed in a visual manner in accordance with the time sequence in the food relationship chain in combination with the physical state change relationship and / or the associated subject change relationship in the food relationship chain.
[0014] The present invention proposes a food safety traceability system and a traceability method. The system generates food safety traceability data by parsing original food data submitted by a node server. The food safety traceability data includes a food relationship chain, an encrypted data unit, and a hash value of the encrypted data unit. An upstream node server and / or a downstream node server is determined according to the food relationship chain. The upstream relationship unit of the food relationship chain and the hash value of the encrypted data unit are sent to the upstream node server, and / or the downstream relationship unit of the food relationship chain and the hash value of the encrypted data unit are sent to the downstream node server. The encrypted data unit, the hash value of the encrypted data unit, the upstream and downstream relationship units, and the hash values of the upstream and downstream encrypted data units are sent to the node server that submits the original food data. The system can effectively improve the traceability capability of food safety data and reduce the cost of deployment and implementation. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 is a schematic block diagram of a food safety traceability system provided by an embodiment of the present invention; Figure 2 is a flow chart of a food safety traceability method provided by one embodiment of the present invention; Figure 3 It is a flow chart of a food safety traceability method provided by another embodiment of the present invention. DETAILED DESCRIPTION
[0016] In order to more clearly understand the above-mentioned purpose, features and advantages of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0017] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Therefore, the protection scope of the present invention is not limited to the specific embodiments disclosed below.
[0018] In the description of the present invention, the term "multiple" refers to two or more. Unless otherwise clearly defined, the orientation or positional relationship indicated by the terms "upper", "lower", etc. is based on the orientation or positional relationship shown in the drawings. It is only for the convenience of describing the present invention and simplifying the description, and does not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation. Therefore, it cannot be understood as a limitation of the present invention. The terms "connection", "installation", "fixation", etc. should be understood in a broad sense. For example, "connection" can be a fixed connection, a detachable connection, or an integral connection; it can be directly connected or indirectly connected through an intermediate medium. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to the specific circumstances. In addition, the terms "first", "second", etc. are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first", "second", etc. can explicitly or implicitly include one or more of the features. In the description of the present invention, unless otherwise specified, the meaning of "multiple" is two or more.
[0019] In the description of this specification, the description of the terms "one embodiment", "some implementations", "specific embodiments", etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0020] A food safety traceability system and traceability method provided according to some embodiments of the present invention will be described below with reference to the accompanying drawings.
[0021] like Figure 1 As shown, a first aspect of the present invention proposes a food safety traceability system, including a food data collection device for collecting food data, a node server for storing food data connected to the food collection device, and a food safety traceability server for generating and querying food safety traceability data.
[0022] Specifically, the food data collection device may be a barcode scanning device, a text input device, a picture taking device or the like, which is used to obtain data of food or food-related materials.
[0023] The node server may be a dedicated server, or a computer device such as a personal computer or a workstation. The food data acquisition device establishes a communication connection with the node server through a wired or wireless communication method to store the collected food or food-related material data in the node server. Each node server may be connected to one or more data acquisition devices to obtain food or food-related material data through the data acquisition device.
[0024] The food safety traceability server is deployed on the Internet and provides food safety traceability services to the Internet. The node server establishes a communication connection with the food safety traceability server via the Internet.
[0025] The food-related materials include food raw materials, food packaging, etc., and may also include additional items sold together with the food, such as preservatives or food ingredients.
[0026] like Figure 2 As shown, in the food safety traceability system provided by the first aspect of the present invention, the food safety traceability server is configured as follows: Receiving original food data submitted by the node server, wherein the original food data is data of food or food-related materials; Parsing the original food data to obtain an attribute data set of each food or food-related material, wherein the attribute data set includes attribute data associated with a unique identification code of the corresponding food or food-related material, and the attribute data includes an attribute name and an attribute content; Generate food safety traceability data based on the attribute data set, the food safety traceability data including a food relationship chain, an encrypted data unit, and a hash value of the encrypted data unit; Determine the upstream node server and / or downstream node server corresponding to the original food data according to the food relationship chain; Sending the upstream relationship unit of the food relationship chain and the hash value of the encrypted data unit to the upstream node server, and / or sending the downstream relationship unit of the food relationship chain and the hash value of the encrypted data unit to the downstream node server; and, The encrypted data unit, the hash value of the encrypted data unit, the upstream and downstream relationship unit and the hash value of the upstream and downstream encrypted data units are sent to the node server that submits the original food data, the upstream and downstream relationship unit includes an upstream relationship unit and / or a downstream relationship unit, and the upstream and downstream encrypted data units include an upstream encrypted data unit and / or a downstream encrypted data unit.
[0027] The original food data is food raw materials, food packaging or food data in a specific format collected by the food data collection device and stored on the node server. The data format of the original food data varies depending on the food data collection device used and the service program for managing food data in the node server.
[0028] The attribute data set is based on a single food ingredient, food packaging or food, and its unit can be one, one, one portion, etc., which can be determined based on the packaging or sales unit. The following is an example of an attribute data set: {ID: XXXXXXXXXXXXXXXX, Name: XX, Type: XX, Manufacturer: XXXXXXXX, Production Address: XXXXXXXX, …} In the above attribute data set example, name, type, manufacturer, production address, etc. are attribute names, and their corresponding contents are attribute contents, where ID is the unique identification code of the corresponding food or food-related material, which is usually a serial number consisting of pure numeric characters or a mixture of alphanumeric characters.
[0029] The food relationship chain is an information chain used to store the physical state changes of food and the changes of associated entities. The physical state change refers to the process in which the selling form of food or food-related materials changes from one item form to another after various processing methods, including but not limited to making food from food raw materials and / or food packaging, making or combining one food into another food, etc. The associated entity change refers to the change of the safety responsible entity of food or food-related materials, including but not limited to manufacturers, carriers, wholesalers and retailers, etc.
[0030] A complete food relationship chain is composed of several nodes connected to each other. In the technical solution of the present invention, each node of the food relationship chain is connected through a relationship unit, and each relationship unit contains a physical state change relationship or an associated subject change relationship. When food or food-related materials flow from one node to the next node, the relationship unit between the two nodes contains at least one physical state change relationship and an associated subject change relationship.
[0031] For example, when a food raw material flows from food raw material producer A to food producer B to be made into a finished food product, food raw material producer A and food producer B are regarded as two nodes in the food relationship chain. Between node A and node B, there is both a physical state change relationship (food raw material->food) and an associated subject change relationship (A->B). For another example, when a food flows from food producer B to carrier C for transportation, food producer B and carrier C are regarded as two nodes in the food relationship chain. Between node B and node C, there is only an associated subject change relationship (B->C), but no physical state change relationship.
[0032] The encrypted data unit is a data packet obtained by encrypting the attribute data set using an encryption algorithm. An encrypted data unit is generated corresponding to the original food data of each food or food-related material, that is, the unique identification code of the food or food-related material has a one-to-one correspondence with the encrypted data unit, and therefore the unique identification code of the food or food-related material has a one-to-one correspondence with the hash value of the encrypted data unit.
[0033] In the technical solutions of some embodiments of the present invention, after the food safety traceability server sends the encrypted data unit to the node server that submitted the original food data, the generated encrypted data unit is deleted in the food safety traceability server to save storage space.
[0034] In the technical solutions of some embodiments of the present invention, the food safety traceability server sends the hash value of the encrypted data unit, the hash value of its upstream encrypted data unit and / or the hash value of the downstream encrypted data unit to the node server that submitted the original food data for associated storage, so that any node server can use the hash value of its upstream encrypted data unit to trace the food or food-related materials forward, or use the hash value of its downstream encrypted data unit to trace the food or food-related materials backward. In the technical solution of this embodiment, through the networking between the node servers, after the node servers establish data communication with each other, food safety traceability can be completed without going through the food safety traceability server.
[0035] In the technical solutions of other embodiments of the present invention, the food safety traceability server stores a complete food relationship chain and the communication address of the node server corresponding to any node in the food relationship chain, so that any node server or other device can perform food safety traceability through the food safety traceability server.
[0036] In the technical solution of the present invention, the node before a node of a food or food-related material on the food relationship chain is called an upstream node, that is, the so-called upstream node refers to the adjacent node before the physical state change or the associated subject change of the food or food-related material. Correspondingly, the relationship unit between the current node and the upstream node is called an upstream relationship unit, the encrypted data packet corresponding to the upstream node is called an upstream encrypted data packet, and the node server corresponding to the upstream node is called an upstream node server.
[0037] Similarly, the node before a food or food-related material on the food relationship chain is called a downstream node, that is, the so-called downstream node refers to the adjacent node after the food or food-related material undergoes a physical state change or an associated subject change. Correspondingly, the relationship unit between the current node and the downstream node is called a downstream relationship unit, the encrypted data packet corresponding to the downstream node is called a downstream encrypted data packet, and the node server corresponding to the downstream node is called a downstream node server.
[0038] In some possible situations, such as in the case of batch data submission or data supplement, when the node server provides the data of a food or food-related material to the food safety traceability server for processing, the data of its downstream node has been sent to the food safety traceability server for processing in advance. After the food safety traceability server generates its food safety traceability data, it is necessary to determine whether there is a downstream node in the food relationship chain for the food or food-related material, so as to perform the steps of determining the downstream node server and sending the downstream relationship unit of the food relationship chain and the hash value of the encrypted data unit to the downstream node server.
[0039] Furthermore, in the step of parsing the original food data, the food safety traceability server is configured to: Determining whether the original food data contains a unique identification code of an upstream food or an upstream food-related material; When the original food data contains a unique identification code of an upstream food or an upstream food-related material, determining the number of unique identification codes of the upstream food or the upstream food-related material contained in the original food data ; Extracting a unique identification code of each upstream food or upstream food-related material from the raw food data; Generate a unique identification code with the number Correspondingly, the attribute data has the unique identification code of the upstream food or upstream food-related materials as the attribute content.
[0040] In the technical solution of the present invention, the original food data may contain one or more unique identification codes of upstream food or upstream food-related materials, or may not contain unique identification codes of upstream food or upstream food-related materials. When the original food data contains unique identification codes of upstream food or upstream food-related materials, in the step of generating food safety traceability data based on the attribute data set, the food relationship chain is generated based on the unique identification codes of upstream food or upstream food-related materials, and the unique identification codes of upstream food or upstream food-related materials are written into the attribute data set of food or food-related materials to be packaged into the encrypted data unit of the current food or food-related materials.
[0041] In the step of generating food safety traceability data based on the attribute data set, the food safety traceability server stores the association relationship between the hash value of the encrypted data unit corresponding to the unique identification code of the food or food-related material and the node server in the database. Therefore, when the original food data contains the unique identification code of the upstream food or the upstream food-related material, the corresponding upstream node server can be determined according to the unique identification code of the upstream food or the upstream food-related material, so that the corresponding upstream node server can be quickly located in the step of determining the upstream node server corresponding to the original food data according to the food relationship chain.
[0042] In the technical solutions of some embodiments of the present invention, the food safety traceability server stores the unique identification code of the upstream food or upstream food-related materials in association with the corresponding upstream encrypted data unit and its hash value in the upstream node server.
[0043] Further, in the step of generating food safety traceability data based on the attribute data set, the food safety traceability server is configured to: When the original food data contains a unique identification code of an upstream food or an upstream food-related material, a relationship unit instance count variable for instantiating a relationship unit instance is constructed and calculated. ; Generate a count variable corresponding to the relationship unit instance based on the pre-built relationship unit object Instance of a relational unit; Obtaining a first hash value of an encrypted data unit corresponding to a unique identification code of each upstream food or upstream food-related material and a second hash value of a current encrypted data unit; The physical state change relationship and / or the associated subject change relationship, as well as the first hash value and the second hash value are written into the relationship unit instance to obtain a corresponding relationship unit.
[0044] In the technical solution of the present invention, each food and / or food-related material is regarded as a node, and the food relationship chain is composed of each node and the relationship units between the nodes connected to each other. In the food relationship chain, each node is represented by the hash value of its encrypted data unit, and the relationship unit between nodes is used to represent the physical state change relationship or the associated subject change relationship between the food or food-related material from one node to another.
[0045] Further, in constructing and calculating the relationship unit instance count variable used to instantiate the relationship unit instance In the step, the food safety traceability server is configured as follows: Constructing a relation unit instance count variable , and initialize it to ; From 1 to Traverse each upstream food or upstream food related material; Determine the traversed upstream food or upstream food-related materials as target materials; Identify the physical state change relationship and the associated subject change relationship from the target material to the current food or food-related material; When the target material has both a physical state change relationship and an associated subject change relationship with the current food or food-related material, let the relationship unit instance count variable The value of is increased by 1; When the target material has only one of a physical state change relationship and an associated subject change relationship with the current food or food-related material, the relationship unit instance count variable is maintained. The value of remains unchanged.
[0046] Specifically, when constructing the relationship unit instance count variable , and initialize it to In the step of The value of the unique identification code is initially equal, and in the range from 1 to In the process of traversing each upstream food or upstream food-related material, the relationship unit instance counting variable is calculated according to the physical state change relationship and the associated subject change relationship between the traversed target material and the current food or food-related material. The value of is modified so that after traversing all upstream foods or upstream food-related materials of the current node, the relationship unit instance count variable The value of is consistent with the number of real relationship units between the current node and all its upstream foods or upstream food-related materials.
[0047] In the technical solution of the above implementation, when the target material has a physical state change relationship or an associated subject change relationship with the current food or food-related material, a corresponding relationship unit instance is generated for each change relationship, and each relationship unit instance is assigned a value to generate a relationship unit corresponding to each upstream food or upstream food-related material pointing to the current food or food-related material. That is, for each upstream food or upstream food-related material that has a physical state change relationship or an associated subject change relationship, it has at least one relationship unit pointing to the current food or food-related material.
[0048] It should be known that since there is at least one relationship unit between each node and its upstream node, in the step of identifying the physical state change relationship and the associated subject change relationship from the target material to the current food or food-related material, the situation where there is no physical state change relationship and no associated subject change relationship from the target material to the current food or food-related material will not occur.
[0049] Furthermore, in the step of identifying the physical state change relationship and the associated subject change relationship from the target material to the current food or food-related material, the food safety traceability server is configured as follows: Determine the target node server corresponding to the target material; Acquire the target encrypted data unit corresponding to the target material from the target node server; Parsing the target encrypted data unit to obtain a first material type attribute and a first associated subject attribute in the attribute data set of the target material; Acquire a second material type attribute and a second associated subject attribute of the current food or food-related material from an attribute data set of the current food or food-related material; Generate a physical state change relationship from the target material to the current food or food-related material based on the first material type attribute and the second material type attribute; and An associated subject change relationship from the target material to the current food or the food-associated material is generated based on the first associated subject attribute and the second associated subject attribute.
[0050] Specifically, the material type attribute is an attribute of the physical form of the food or food-related material in the attribute data set of the food or food-related material, which is usually expressed as the type of the food or food-related material, such as flour, cake, etc. The associated subject attribute is an attribute of the subject responsible for safety in the current supply link of the food or food-related material, which is usually expressed as the company name of the manufacturer, carrier, wholesaler or retailer. For the convenience of distinction, in the technical scheme of the above implementation method, the first material type attribute and the first associated subject attribute are used to represent the material type attribute and the associated subject attribute of the target material, and the second material type attribute and the second associated subject attribute are used to represent the material type attribute and the associated subject attribute of the current food or food-related material.
[0051] In the technical solutions of other embodiments of the present invention, after receiving the original food data submitted by each node and parsing the original food data to obtain the attribute data set of each food or food-related material, the food safety traceability server stores the basic attribute information of the food or food-related materials including the material type attribute and the associated subject attribute information in a database, so that in the step of identifying the physical state change relationship and the associated subject change relationship from the target material to the current food or food-related material, the food safety traceability server can use the stored basic attribute information of the food or food-related materials to complete the processing without reading and parsing the target encrypted data unit corresponding to the target material from the target node server.
[0052] Further, in the step of generating a physical state change relationship from the target material to the current food or food-related material based on the first material type attribute and the second material type attribute, the food safety traceability server is configured as follows: Determine whether the first material type attribute and the second material type attribute are the same; When the first material type attribute and the second material type attribute are different, generating a physical state change relationship instance based on a pre-built physical state change relationship object; The first material type attribute and the second material type attribute are sequentially written into the physical state change relationship instance to obtain the corresponding physical state change relationship.
[0053] Specifically, in the physical state change relationship instance, the writing order of the first material type attribute and the second material type attribute reflects the directional relationship between the two, that is, in the physical state change relationship instance, the first material type attribute written first reflects the prior physical state in the physical state change relationship, and the second material type attribute written later reflects the later physical state in the physical state change relationship.
[0054] Further, in the step of generating a physical state change relationship from the target material to the current food or food-related material based on the first material type attribute and the second material type attribute, the food safety traceability server is configured as follows: When the first material type attribute and the second material type attribute are the same, the physical state change relationship from the target material to the current food or food-related material is not generated.
[0055] Further, in the step of generating an associated subject change relationship from the target material to the current food or food-associated material based on the first associated subject attribute and the second associated subject attribute, the food safety traceability server is configured as follows: Determining whether the first association subject attribute and the second association subject attribute are the same; When the first association subject attribute and the second association subject attribute are different, generating an association subject change relationship instance based on a pre-built association subject change relationship object; The first association subject attribute and the second association subject attribute are sequentially written into the association subject change relationship instance to obtain a corresponding association subject change relationship.
[0056] Similarly, in the associated subject change relationship instance, the writing order of the first associated subject attribute and the second associated subject attribute reflects the directional relationship between the two, that is, in the associated subject change relationship instance, the first associated subject attribute written first reflects the prior security responsible subject in the associated subject change relationship, and the second associated subject attribute written later reflects the subsequent security responsible subject in the associated subject change relationship.
[0057] Further, in the step of generating an associated subject change relationship from the target material to the current food or food-associated material based on the first associated subject attribute and the second associated subject attribute, the food safety traceability server is configured as follows: When the first associated subject attribute and the second associated subject attribute are the same, an associated subject change relationship from the target material to the current food or food-associated material is not generated.
[0058] Further, after the step of writing the physical state change relationship and / or the associated subject change relationship, and the first hash value and the second hash value into the relationship unit instance to obtain the corresponding relationship unit, the food safety traceability server is configured as follows: Determine whether there is a food relationship chain with the first hash value as the terminal node; When there is a food relationship chain with the first hash value as the terminal node, adding the physical state change relationship and / or the associated subject change relationship and the second hash value to the end of the food relationship chain; When there is no food relationship chain with the first Hash value as the terminal node, a new food relationship chain with the first Hash value as the starting node and the second Hash value as the terminal node is generated.
[0059] The food relationship chain uses the hash value of the encrypted data unit of the food or food-related materials as a node, and the nodes are connected by the relationship unit used to represent the physical state change relationship or the associated subject change relationship. In the food relationship chain, each node has a temporal order relationship, and the physical state change relationship or the associated subject change relationship represented by the relationship unit has a directionality according to the temporal order relationship between two nodes, that is, the relationship unit points from the node that is earlier in time to the node that is later in time.
[0060] Furthermore, the food safety traceability server is also configured to: Receiving a food safety traceability request submitted by a user, wherein the food safety traceability request includes a unique identification code of the food to be traced; Obtaining a hash value of the encrypted data unit of the food to be traced according to the unique identification code of the food to be traced; Querying a food relationship chain containing the hash value in a database, wherein the food relationship chain is composed of food and / or food-related materials at various nodes and relationship units between nodes connected to each other, wherein each node in the food relationship chain is represented by the hash value of its encrypted data unit, and the relationship unit between nodes is used to represent the physical state change relationship or the associated subject change relationship between food or food-related materials from one node to another; When there is a food relationship chain containing the hash value in the database, extracting the hash value of the encrypted data unit of the food on the chain or the food-related material on the chain from the food relationship chain; Determine the corresponding node server according to the hash value of the encrypted data unit; Obtaining encrypted data units of on-chain food or on-chain food-related materials in the food relationship chain from the determined node server; parsing the encrypted data unit to obtain target attribute data to be displayed; The target attribute data is displayed in a visual manner in accordance with the time sequence in the food relationship chain in combination with the physical state change relationship and / or the associated subject change relationship in the food relationship chain.
[0061] Specifically, when the food safety traceability server generates food safety traceability data, the food safety traceability server stores the food relationship chain in the generated food safety traceability data in a database.
[0062] The on-chain food is the food whose hash value of the encrypted data unit exists in the food relationship chain. Similarly, the on-chain food-related materials are the food-related materials whose hash value of the encrypted data unit exists in the food relationship chain.
[0063] In the step of determining the corresponding node server according to the hash value of the encrypted data unit, the food safety traceability server determines the corresponding node server based on the association relationship between the hash value of the encrypted data unit stored in the food relationship chain and the node server.
[0064] The target attribute data is pre-configured data corresponding to the attribute fields for displaying the food safety traceability results. For example, the name attribute, material type attribute, and associated subject attribute can be configured as attribute fields for displaying the food safety traceability results, thereby displaying the food safety traceability results in a visual manner.
[0065] In the step of displaying the target attribute data in a visual manner in combination with the physical state change relationship and / or the associated subject change relationship in the food relationship chain according to the time sequence in the food relationship chain, each target attribute data can be displayed as a visualization node, and each visualization node is connected with the corresponding physical state change relationship and / or the associated subject change relationship to form a food safety traceability chain, so that the food safety traceability result can be displayed to the user more intuitively.
[0066] In the technical solutions of some embodiments of the present invention, the node server is configured as: Receiving a food safety traceability request submitted by a user, wherein the food safety traceability request includes a unique identification code of the food to be traced; Obtaining a hash value of the encrypted data unit of the food to be traced according to the unique identification code of the food to be traced; Querying a hash value of an upstream encrypted data unit corresponding to the hash value of the encrypted data unit; The food or food-related materials are traced forward according to the hash value of the upstream encrypted data unit.
[0067] Furthermore, in the step of tracing back the food or food-related materials according to the hash value of the upstream encrypted data unit, the node server is configured as follows: Determine a corresponding upstream node server according to a hash value of the upstream encrypted data unit; Trace back all the node servers on the same food relationship chain from the upstream node server; Obtaining encrypted data units of on-chain food or on-chain food-related materials in the food relationship chain from the on-chain node server; parsing the encrypted data unit to obtain target attribute data to be displayed; The target attribute data is displayed in a visual manner in accordance with the time sequence in the food relationship chain in combination with the physical state change relationship and / or the associated subject change relationship in the food relationship chain.
[0068] like Figure 3 As shown, the second aspect of the present invention proposes a food safety traceability method, comprising: The food safety traceability server receives a food safety traceability request submitted by a user, wherein the food safety traceability request includes a unique identification code of the food to be traced; Obtaining a hash value of the encrypted data unit of the food to be traced according to the unique identification code of the food to be traced; Querying a food relationship chain containing the hash value in a database, wherein the food relationship chain is composed of food and / or food-related materials at various nodes and relationship units between nodes connected to each other, wherein each node in the food relationship chain is represented by the hash value of its encrypted data unit, and the relationship unit between nodes is used to represent the physical state change relationship or the associated subject change relationship between food or food-related materials from one node to another; When there is a food relationship chain containing the hash value in the database, extracting the hash value of the encrypted data unit of the food on the chain or the food-related material on the chain from the food relationship chain; Determine the corresponding node server according to the hash value of the encrypted data unit; Obtaining encrypted data units of on-chain food or on-chain food-related materials in the food relationship chain from the determined node server; parsing the encrypted data unit to obtain target attribute data to be displayed; The target attribute data is displayed in a visual manner in accordance with the time sequence in the food relationship chain in combination with the physical state change relationship and / or the associated subject change relationship in the food relationship chain.
[0069] Specifically, when the food safety traceability server generates food safety traceability data, the food safety traceability server stores the food relationship chain in the generated food safety traceability data in a database.
[0070] The on-chain food is the food whose hash value of the encrypted data unit exists in the food relationship chain. Similarly, the on-chain food-related materials are the food-related materials whose hash value of the encrypted data unit exists in the food relationship chain.
[0071] In the step of determining the corresponding node server according to the hash value of the encrypted data unit, the food safety traceability server determines the corresponding node server based on the association relationship between the hash value of the encrypted data unit stored in the food relationship chain and the node server.
[0072] The target attribute data is pre-configured data corresponding to the attribute fields for displaying the food safety traceability results. For example, the name attribute, material type attribute, and associated subject attribute can be configured as attribute fields for displaying the food safety traceability results, thereby displaying the food safety traceability results in a visual manner.
[0073] In the step of displaying the target attribute data in a visual manner in combination with the physical state change relationship and / or the associated subject change relationship in the food relationship chain according to the time sequence in the food relationship chain, each target attribute data can be displayed as a visualization node, and each visualization node is connected with the corresponding physical state change relationship and / or the associated subject change relationship to form a food safety traceability chain, so that the food safety traceability result can be displayed to the user more intuitively.
[0074] In the technical solutions of some embodiments of the present invention, the food safety traceability method further includes: The node server receives a food safety traceability request submitted by a user, wherein the food safety traceability request includes a unique identification code of the food to be traced; Obtaining a hash value of the encrypted data unit of the food to be traced according to the unique identification code of the food to be traced; Querying a hash value of an upstream encrypted data unit corresponding to the hash value of the encrypted data unit; The food or food-related materials are traced forward according to the hash value of the upstream encrypted data unit.
[0075] Furthermore, the step of tracing back the food or food-related materials according to the hash value of the upstream encrypted data unit specifically includes: Determine a corresponding upstream node server according to a hash value of the upstream encrypted data unit; Trace back all the node servers on the same food relationship chain from the upstream node server; Obtaining encrypted data units of on-chain food or on-chain food-related materials in the food relationship chain from the on-chain node server; parsing the encrypted data unit to obtain target attribute data to be displayed; The target attribute data is displayed in a visual manner in accordance with the time sequence in the food relationship chain in combination with the physical state change relationship and / or the associated subject change relationship in the food relationship chain.
[0076] Furthermore, before the step of the food safety traceability server receiving the food safety traceability request submitted by the user, the method further includes: The food safety traceability server receives the original food data submitted by the node server, where the original food data is data of food or food-related materials; Parsing the original food data to obtain an attribute data set of each food or food-related material, wherein the attribute data set includes attribute data associated with a unique identification code of the corresponding food or food-related material, and the attribute data includes an attribute name and an attribute content; Generate food safety traceability data based on the attribute data set, the food safety traceability data including a food relationship chain, an encrypted data unit, and a hash value of the encrypted data unit; Determine the upstream node server and / or downstream node server corresponding to the original food data according to the food relationship chain; Sending the upstream relationship unit of the food relationship chain and the hash value of the encrypted data unit to the upstream node server, and / or sending the downstream relationship unit of the food relationship chain and the hash value of the encrypted data unit to the downstream node server; and, The encrypted data unit, the hash value of the encrypted data unit, the upstream and downstream relationship unit and the hash value of the upstream and downstream encrypted data units are sent to the node server that submits the original food data, the upstream and downstream relationship unit includes an upstream relationship unit and / or a downstream relationship unit, and the upstream and downstream encrypted data units include an upstream encrypted data unit and / or a downstream encrypted data unit.
[0077] The original food data is food raw materials, food packaging or food data in a specific format collected by the food data collection device and stored on the node server. The data format of the original food data varies depending on the food data collection device used and the service program for managing food data in the node server.
[0078] The attribute data set is based on a single food ingredient, food packaging or food, and its unit can be one, one, one portion, etc., which can be determined based on the packaging or sales unit. The following is an example of an attribute data set: {ID: XXXXXXXXXXXXXXXX, Name: XX, Type: XX, Manufacturer: XXXXXXXX, Production Address: XXXXXXXX, …} In the above attribute data set example, name, type, manufacturer, production address, etc. are attribute names, and their corresponding contents are attribute contents, where ID is the unique identification code of the corresponding food or food-related material, which is usually a serial number consisting of pure numeric characters or a mixture of alphanumeric characters.
[0079] The food relationship chain is an information chain used to store the physical state changes of food and the changes of associated entities. The physical state change refers to the process in which the selling form of food or food-related materials changes from one item form to another after various processing methods, including but not limited to making food from food raw materials and / or food packaging, making or combining one food into another food, etc. The associated entity change refers to the change of the safety responsible entity of food or food-related materials, including but not limited to manufacturers, carriers, wholesalers and retailers, etc.
[0080] A complete food relationship chain is composed of several nodes connected to each other. In the technical solution of the present invention, each node of the food relationship chain is connected through a relationship unit, and each relationship unit contains a physical state change relationship or an associated subject change relationship. When food or food-related materials flow from one node to the next node, the relationship unit between the two nodes contains at least one physical state change relationship and an associated subject change relationship.
[0081] For example, when a food raw material flows from food raw material producer A to food producer B to be made into a finished food product, food raw material producer A and food producer B are regarded as two nodes in the food relationship chain. Between node A and node B, there is both a physical state change relationship (food raw material->food) and an associated subject change relationship (A->B). For another example, when a food flows from food producer B to carrier C for transportation, food producer B and carrier C are regarded as two nodes in the food relationship chain. Between node B and node C, there is only an associated subject change relationship (B->C), but no physical state change relationship.
[0082] The encrypted data unit is a data packet obtained by encrypting the attribute data set using an encryption algorithm. An encrypted data unit is generated corresponding to the original food data of each food or food-related material, that is, the unique identification code of the food or food-related material has a one-to-one correspondence with the encrypted data unit, and therefore the unique identification code of the food or food-related material has a one-to-one correspondence with the hash value of the encrypted data unit.
[0083] In the technical solutions of some embodiments of the present invention, after the food safety traceability server sends the encrypted data unit to the node server that submitted the original food data, the generated encrypted data unit is deleted in the food safety traceability server to save storage space.
[0084] In the technical solutions of some embodiments of the present invention, the food safety traceability server sends the hash value of the encrypted data unit, the hash value of its upstream encrypted data unit and / or the hash value of the downstream encrypted data unit to the node server that submitted the original food data for associated storage, so that any node server can use the hash value of its upstream encrypted data unit to trace the food or food-related materials forward, or use the hash value of its downstream encrypted data unit to trace the food or food-related materials backward. In the technical solution of this embodiment, through the networking between the node servers, after the node servers establish data communication with each other, food safety traceability can be completed without going through the food safety traceability server.
[0085] In the technical solutions of other embodiments of the present invention, the food safety traceability server stores a complete food relationship chain and the communication address of the node server corresponding to any node in the food relationship chain, so that any node server or other device can perform food safety traceability through the food safety traceability server.
[0086] In the technical solution of the present invention, the node before a node of a food or food-related material on the food relationship chain is called an upstream node, that is, the so-called upstream node refers to the adjacent node before the physical state change or the associated subject change of the food or food-related material. Correspondingly, the relationship unit between the current node and the upstream node is called an upstream relationship unit, the encrypted data packet corresponding to the upstream node is called an upstream encrypted data packet, and the node server corresponding to the upstream node is called an upstream node server.
[0087] Similarly, the node before a food or food-related material on the food relationship chain is called a downstream node, that is, the so-called downstream node refers to the adjacent node after the food or food-related material undergoes a physical state change or an associated subject change. Correspondingly, the relationship unit between the current node and the downstream node is called a downstream relationship unit, the encrypted data packet corresponding to the downstream node is called a downstream encrypted data packet, and the node server corresponding to the downstream node is called a downstream node server.
[0088] In some possible situations, such as in the case of batch data submission or data supplement, when the node server provides the data of a food or food-related material to the food safety traceability server for processing, the data of its downstream node has been sent to the food safety traceability server for processing in advance. After the food safety traceability server generates its food safety traceability data, it is necessary to determine whether there is a downstream node in the food relationship chain for the food or food-related material, so as to perform the steps of determining the downstream node server and sending the downstream relationship unit of the food relationship chain and the hash value of the encrypted data unit to the downstream node server.
[0089] Furthermore, the step of parsing the original food data specifically includes: Determining whether the original food data contains a unique identification code of an upstream food or an upstream food-related material; When the original food data contains a unique identification code of an upstream food or an upstream food-related material, determining the number of unique identification codes of the upstream food or the upstream food-related material contained in the original food data ; Extracting a unique identification code of each upstream food or upstream food-related material from the raw food data; Generate a unique identification code with the number Correspondingly, the attribute data has the unique identification code of the upstream food or upstream food-related materials as the attribute content.
[0090] In the technical solution of the present invention, the original food data may contain one or more unique identification codes of upstream food or upstream food-related materials, or may not contain unique identification codes of upstream food or upstream food-related materials. When the original food data contains unique identification codes of upstream food or upstream food-related materials, in the step of generating food safety traceability data based on the attribute data set, the food relationship chain is generated based on the unique identification codes of upstream food or upstream food-related materials, and the unique identification codes of upstream food or upstream food-related materials are written into the attribute data set of food or food-related materials to be packaged into the encrypted data unit of the current food or food-related materials.
[0091] In the step of generating food safety traceability data based on the attribute data set, the food safety traceability server stores the association relationship between the hash value of the encrypted data unit corresponding to the unique identification code of the food or food-related material and the node server in the database. Therefore, when the original food data contains the unique identification code of the upstream food or the upstream food-related material, the corresponding upstream node server can be determined according to the unique identification code of the upstream food or the upstream food-related material, so that the corresponding upstream node server can be quickly located in the step of determining the upstream node server corresponding to the original food data according to the food relationship chain.
[0092] In the technical solutions of some embodiments of the present invention, the food safety traceability server stores the unique identification code of the upstream food or upstream food-related materials in association with the corresponding upstream encrypted data unit and its hash value in the upstream node server.
[0093] Furthermore, the step of generating food safety traceability data based on the attribute data set specifically includes: When the original food data contains a unique identification code of an upstream food or an upstream food-related material, a relationship unit instance count variable for instantiating a relationship unit instance is constructed and calculated. ; Generate a count variable corresponding to the relationship unit instance based on the pre-built relationship unit object Instance of a relational unit; Obtaining a first hash value of an encrypted data unit corresponding to a unique identification code of each upstream food or upstream food-related material and a second hash value of a current encrypted data unit; The physical state change relationship and / or the associated subject change relationship, as well as the first hash value and the second hash value are written into the relationship unit instance to obtain a corresponding relationship unit.
[0094] In the technical solution of the present invention, each food and / or food-related material is regarded as a node, and the food relationship chain is composed of each node and the relationship units between the nodes connected to each other. In the food relationship chain, each node is represented by the hash value of its encrypted data unit, and the relationship unit between nodes is used to represent the physical state change relationship or the associated subject change relationship between the food or food-related material from one node to another.
[0095] Further, a relationship unit instance count variable for instantiating a relationship unit instance is constructed and calculated. The steps specifically include: Constructing a relation unit instance count variable , and initialize it to ; From 1 to Traverse each upstream food or upstream food related material; Determine the traversed upstream food or upstream food-related materials as target materials; Identify the physical state change relationship and the associated subject change relationship from the target material to the current food or food-related material; When the target material has both a physical state change relationship and an associated subject change relationship with the current food or food-related material, let the relationship unit instance count variable The value of is increased by 1; When the target material has only one of a physical state change relationship and an associated subject change relationship with the current food or food-related material, the relationship unit instance count variable is maintained. The value of remains unchanged.
[0096] Specifically, when constructing the relationship unit instance count variable , and initialize it to In the step of The value of the unique identification code is initially equal, and in the range from 1 to In the process of traversing each upstream food or upstream food-related material, the relationship unit instance counting variable is calculated according to the physical state change relationship and the associated subject change relationship between the traversed target material and the current food or food-related material. The value of is modified so that after traversing all upstream foods or upstream food-related materials of the current node, the relationship unit instance count variable The value of is consistent with the number of real relationship units between the current node and all its upstream foods or upstream food-related materials.
[0097] In the technical solution of the above implementation, when the target material has a physical state change relationship or an associated subject change relationship with the current food or food-related material, a corresponding relationship unit instance is generated for each change relationship, and each relationship unit instance is assigned a value to generate a relationship unit corresponding to each upstream food or upstream food-related material pointing to the current food or food-related material. That is, for each upstream food or upstream food-related material that has a physical state change relationship or an associated subject change relationship, it has at least one relationship unit pointing to the current food or food-related material.
[0098] It should be known that since there is at least one relationship unit between each node and its upstream node, in the step of identifying the physical state change relationship and the associated subject change relationship from the target material to the current food or food-related material, the situation where there is no physical state change relationship and no associated subject change relationship from the target material to the current food or food-related material will not occur.
[0099] Furthermore, the step of identifying the physical state change relationship and the associated subject change relationship from the target material to the current food or food-related material specifically includes: Determine the target node server corresponding to the target material; Acquire the target encrypted data unit corresponding to the target material from the target node server; Parsing the target encrypted data unit to obtain a first material type attribute and a first associated subject attribute in the attribute data set of the target material; Acquire a second material type attribute and a second associated subject attribute of the current food or food-related material from an attribute data set of the current food or food-related material; Generate a physical state change relationship from the target material to the current food or food-related material based on the first material type attribute and the second material type attribute; and An associated subject change relationship from the target material to the current food or the food-associated material is generated based on the first associated subject attribute and the second associated subject attribute.
[0100] Specifically, the material type attribute is an attribute of the physical form of the food or food-related material in the attribute data set of the food or food-related material, which is usually expressed as the type of the food or food-related material, such as flour, cake, etc. The associated subject attribute is an attribute of the subject responsible for safety in the current supply link of the food or food-related material, which is usually expressed as the company name of the manufacturer, carrier, wholesaler or retailer. For the convenience of distinction, in the technical scheme of the above implementation method, the first material type attribute and the first associated subject attribute are used to represent the material type attribute and the associated subject attribute of the target material, and the second material type attribute and the second associated subject attribute are used to represent the material type attribute and the associated subject attribute of the current food or food-related material.
[0101] In the technical solutions of other embodiments of the present invention, after receiving the original food data submitted by each node and parsing the original food data to obtain the attribute data set of each food or food-related material, the food safety traceability server stores the basic attribute information of the food or food-related materials including the material type attribute and the associated subject attribute information in a database, so that in the step of identifying the physical state change relationship and the associated subject change relationship from the target material to the current food or food-related material, the food safety traceability server can use the stored basic attribute information of the food or food-related materials to complete the processing without reading and parsing the target encrypted data unit corresponding to the target material from the target node server.
[0102] Furthermore, the step of generating a physical state change relationship from the target material to the current food or food-related material based on the first material type attribute and the second material type attribute specifically includes: Determine whether the first material type attribute and the second material type attribute are the same; When the first material type attribute and the second material type attribute are different, generating a physical state change relationship instance based on a pre-built physical state change relationship object; The first material type attribute and the second material type attribute are sequentially written into the physical state change relationship instance to obtain the corresponding physical state change relationship.
[0103] Specifically, in the physical state change relationship instance, the writing order of the first material type attribute and the second material type attribute reflects the directional relationship between the two, that is, in the physical state change relationship instance, the first material type attribute written first reflects the prior physical state in the physical state change relationship, and the second material type attribute written later reflects the later physical state in the physical state change relationship.
[0104] Furthermore, the step of generating a physical state change relationship from the target material to the current food or food-related material based on the first material type attribute and the second material type attribute specifically includes: When the first material type attribute and the second material type attribute are the same, the physical state change relationship from the target material to the current food or food-related material is not generated.
[0105] Furthermore, the step of generating an associated subject change relationship from the target material to the current food or the food-associated material based on the first associated subject attribute and the second associated subject attribute specifically includes: Determining whether the first association subject attribute and the second association subject attribute are the same; When the first association subject attribute and the second association subject attribute are different, generating an association subject change relationship instance based on a pre-built association subject change relationship object; The first association subject attribute and the second association subject attribute are sequentially written into the association subject change relationship instance to obtain a corresponding association subject change relationship.
[0106] Similarly, in the associated subject change relationship instance, the writing order of the first associated subject attribute and the second associated subject attribute reflects the directional relationship between the two, that is, in the associated subject change relationship instance, the first associated subject attribute written first reflects the prior security responsible subject in the associated subject change relationship, and the second associated subject attribute written later reflects the subsequent security responsible subject in the associated subject change relationship.
[0107] Furthermore, the step of generating an associated subject change relationship from the target material to the current food or the food-associated material based on the first associated subject attribute and the second associated subject attribute specifically includes: When the first associated subject attribute and the second associated subject attribute are the same, an associated subject change relationship from the target material to the current food or food-associated material is not generated.
[0108] Furthermore, after the step of writing the physical state change relationship and / or the associated subject change relationship, and the first hash value and the second hash value into the relationship unit instance to obtain the corresponding relationship unit, the method further includes: Determine whether there is a food relationship chain with the first hash value as the terminal node; When there is a food relationship chain with the first hash value as the terminal node, adding the physical state change relationship and / or the associated subject change relationship and the second hash value to the end of the food relationship chain; When there is no food relationship chain with the first Hash value as the terminal node, a new food relationship chain with the first Hash value as the starting node and the second Hash value as the terminal node is generated.
[0109] The food relationship chain uses the hash value of the encrypted data unit of the food or food-related materials as a node, and the nodes are connected by the relationship unit used to represent the physical state change relationship or the associated subject change relationship. In the food relationship chain, each node has a temporal order relationship, and the physical state change relationship or the associated subject change relationship represented by the relationship unit has a directionality according to the temporal order relationship between two nodes, that is, the relationship unit points from the node that is earlier in time to the node that is later in time.
[0110] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0111] According to the embodiments of the present invention as described above, these embodiments do not describe all the details in detail, nor do they limit the invention to the specific embodiments described. Obviously, many modifications and changes can be made based on the above description. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present invention, so that those skilled in the art can make good use of the present invention and the modified use based on the present invention. The present invention is limited only by the claims and their full scope and equivalents.
Claims
1. A food safety traceability system, characterized in that: The invention comprises a food data collection device for collecting food data, a node server for storing food data connected to the food collection device, and a food safety traceability server for generating and querying food safety traceability data, wherein the food safety traceability server is configured as follows: Receiving original food data submitted by the node server, wherein the original food data is data of food or food-related materials; Parsing the original food data to obtain an attribute data set of each food or food-related material, wherein the attribute data set includes attribute data associated with a unique identification code of the corresponding food or food-related material, and the attribute data includes an attribute name and an attribute content; Generate food safety traceability data based on the attribute data set, the food safety traceability data including a food relationship chain, an encrypted data unit, and a hash value of the encrypted data unit; Determine the upstream node server and / or downstream node server corresponding to the original food data according to the food relationship chain; Sending the upstream relationship unit of the food relationship chain and the hash value of the encrypted data unit to the upstream node server, and / or sending the downstream relationship unit of the food relationship chain and the hash value of the encrypted data unit to the downstream node server; as well as, The encrypted data unit, the hash value of the encrypted data unit, the upstream and downstream relationship unit and the hash value of the upstream and downstream encrypted data units are sent to the node server that submits the original food data, the upstream and downstream relationship unit includes an upstream relationship unit and / or a downstream relationship unit, and the upstream and downstream encrypted data units include an upstream encrypted data unit and / or a downstream encrypted data unit.
2. The food safety traceability system according to claim 1, characterized in that: In the step of parsing the raw food data, the food safety traceability server is configured to: Determining whether the original food data contains a unique identification code of an upstream food or an upstream food-related material; When the original food data contains a unique identification code of an upstream food or an upstream food-related material, determining the number of unique identification codes of the upstream food or the upstream food-related material contained in the original food data ; Extracting a unique identification code of each upstream food or upstream food-related material from the raw food data; Generate a unique identification code with the number Correspondingly, the attribute data has the unique identification code of the upstream food or upstream food-related materials as the attribute content.
3. The food safety traceability system according to claim 2, characterized in that: In the step of generating food safety traceability data based on the attribute data set, the food safety traceability server is configured to: When the original food data contains a unique identification code of an upstream food or an upstream food-related material, a relationship unit instance count variable for instantiating a relationship unit instance is constructed and calculated. ; Generate a corresponding relationship unit instance count variable based on the pre-built relationship unit object Instance of a relational unit; Obtaining a first hash value of an encrypted data unit corresponding to a unique identification code of each upstream food or upstream food-related material and a second hash value of a current encrypted data unit; The physical state change relationship and / or the associated subject change relationship, as well as the first hash value and the second hash value are written into the relationship unit instance to obtain a corresponding relationship unit.
4. The food safety traceability system according to claim 3, characterized in that: When constructing and calculating the relationship unit instance count variable used to instantiate the relationship unit instance In the step, the food safety traceability server is configured as follows: Constructing a relation unit instance count variable , and initialize it to ; From 1 to Traverse each upstream food or upstream food related material; Determine the traversed upstream food or upstream food-related materials as target materials; Identify the physical state change relationship and the associated subject change relationship from the target material to the current food or food-related material; When the target material has both a physical state change relationship and an associated subject change relationship with the current food or food-related material, let the relationship unit instance count variable The value of is increased by 1; When the target material has only one of a physical state change relationship and an associated subject change relationship with the current food or food-related material, the relationship unit instance count variable is maintained. The value of remains unchanged.
5. The food safety traceability system according to claim 3, characterized in that: In the step of identifying the physical state change relationship and the associated subject change relationship from the target material to the current food or food-related material, the food safety traceability server is configured to: Determine the target node server corresponding to the target material; Acquire the target encrypted data unit corresponding to the target material from the target node server; Parsing the target encrypted data unit to obtain a first material type attribute and a first associated subject attribute in the attribute data set of the target material; Acquire a second material type attribute and a second associated subject attribute of the current food or food-related material from an attribute data set of the current food or food-related material; Generate a physical state change relationship from the target material to the current food or food-related material based on the first material type attribute and the second material type attribute; and An associated subject change relationship from the target material to the current food or the food-associated material is generated based on the first associated subject attribute and the second associated subject attribute.
6. The food safety traceability system according to claim 5, characterized in that: In the step of generating a physical state change relationship from the target material to the current food or food-related material based on the first material type attribute and the second material type attribute, the food safety traceability server is configured to: Determine whether the first material type attribute and the second material type attribute are the same; When the first material type attribute and the second material type attribute are different, generating a physical state change relationship instance based on a pre-built physical state change relationship object; The first material type attribute and the second material type attribute are sequentially written into the physical state change relationship instance to obtain the corresponding physical state change relationship.
7. The food safety traceability system according to claim 5, characterized in that: In the step of generating an associated subject change relationship from the target material to the current food or the food-associated material based on the first associated subject attribute and the second associated subject attribute, the food safety traceability server is configured to: Determining whether the first association subject attribute and the second association subject attribute are the same; When the first association subject attribute and the second association subject attribute are different, generating an association subject change relationship instance based on a pre-built association subject change relationship object; The first association subject attribute and the second association subject attribute are sequentially written into the association subject change relationship instance to obtain a corresponding association subject change relationship.
8. The food safety traceability system according to claim 3, characterized in that: After the step of writing the physical state change relationship and / or the associated subject change relationship, and the first hash value and the second hash value into the relationship unit instance to obtain the corresponding relationship unit, the food safety traceability server is configured as follows: Determine whether there is a food relationship chain with the first hash value as the terminal node; When there is a food relationship chain with the first hash value as the terminal node, adding the physical state change relationship and / or the associated subject change relationship and the second hash value to the end of the food relationship chain; When there is no food relationship chain with the first Hash value as the terminal node, a new food relationship chain with the first Hash value as the starting node and the second Hash value as the terminal node is generated.
9. The food safety traceability system according to claim 1, characterized in that: The food safety traceability server is also configured as follows: Receiving a food safety traceability request submitted by a user, wherein the food safety traceability request includes a unique identification code of the food to be traced; Obtaining a hash value of the encrypted data unit of the food to be traced according to the unique identification code of the food to be traced; Querying a food relationship chain containing the hash value in a database, wherein the food relationship chain is composed of food and / or food-related materials at various nodes and relationship units between nodes connected to each other, wherein each node in the food relationship chain is represented by the hash value of its encrypted data unit, and the relationship unit between nodes is used to represent the physical state change relationship or the associated subject change relationship between food or food-related materials from one node to another; When there is a food relationship chain containing the hash value in the database, extracting the hash value of the encrypted data unit of the food on the chain or the food-related material on the chain from the food relationship chain; Determine the corresponding node server according to the hash value of the encrypted data unit; Obtaining encrypted data units of on-chain food or on-chain food-related materials in the food relationship chain from the determined node server; parsing the encrypted data unit to obtain target attribute data to be displayed; The target attribute data is displayed in a visual manner in accordance with the time sequence in the food relationship chain in combination with the physical state change relationship and / or the associated subject change relationship in the food relationship chain.
10. A food safety traceability method, characterized in that: include: The food safety traceability server receives a food safety traceability request submitted by a user, wherein the food safety traceability request includes a unique identification code of the food to be traced; Obtaining a hash value of the encrypted data unit of the food to be traced according to the unique identification code of the food to be traced; Querying a food relationship chain containing the hash value in a database, wherein the food relationship chain is composed of food and / or food-related materials at various nodes and relationship units between nodes connected to each other, wherein each node in the food relationship chain is represented by the hash value of its encrypted data unit, and the relationship unit between nodes is used to represent the physical state change relationship or the associated subject change relationship between food or food-related materials from one node to another; When there is a food relationship chain containing the hash value in the database, extracting the hash value of the encrypted data unit of the food on the chain or the food-related material on the chain from the food relationship chain; Determine the corresponding node server according to the hash value of the encrypted data unit; Obtaining encrypted data units of on-chain food or on-chain food-related materials in the food relationship chain from the determined node server; parsing the encrypted data unit to obtain target attribute data to be displayed; The target attribute data is displayed in a visual manner in accordance with the time sequence in the food relationship chain in combination with the physical state change relationship and / or the associated subject change relationship in the food relationship chain.
Citation Information
Patent Citations
Food block chain tracing method and device and electronic equipment
CN108960863A
Article circulation link tracing method and device based on block chain and electronic equipment
CN110502922A
Blockchain-based grain and oil food full supply chain credible tracing model based on block chain and construction method
CN110516965A
Hotpot condiment product traceability method and system based on block chain
CN116611851A