A food safety traceability system and traceability method
By building a food safety traceability system, using the food data collection device and traceability server to generate food relationship chains and encrypted data units, the problem of accessing blockchain technology in the food safety data traceability system is solved, efficient data processing and storage is achieved, and implementation costs are reduced.
Patent Information
- Application Number
- CN202411878904.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-19
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2044-12-19
AI Technical Summary
The existing blockchain technology has a high access threshold for food safety data traceability systems, which leads to the inability to directly connect to the digital systems of each link, and the pressure of massive data processing and storage is high, which increases the cost of deployment and implementation.
Design a food safety traceability system, including a food data collection device, a node server and a traceability server, generate food safety traceability data by analyzing the original food data, build a food relationship chain and encrypted data unit, and use hash values to realize data transmission and storage of upstream and downstream nodes, reducing deployment costs.
It effectively improves the traceability of food safety data, reduces the cost of deployment and implementation, and realizes efficient processing and storage of food safety data.
Smart Images

Figure CN119722107B_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 a major public health concern. To address this, various technologies have been developed to improve food safety traceability, including the use of blockchain technology to enhance the traceability and reliability of food safety data. However, in practice, these technologies face significant challenges in implementation and widespread adoption. This is primarily due to the high barrier to entry for blockchain, making it difficult to directly integrate existing digital systems across the food supply chain, leading to high development costs. Furthermore, to ensure data security and reliability, blockchain technology requires a complete redundant ledger for each participating node. To ensure traceability, every link in the food supply chain must be connected to the system. The massive volume of food safety data places significant pressure on traceability systems 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 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 provides a food safety traceability system, comprising a food data collection device for collecting food data, a node server connected to the food collection device for storing food data, and a food safety traceability server for generating and querying food safety traceability data, wherein the food safety traceability server is configured to:
[0005] Receiving original food data submitted by the node server, wherein the original food data is data of food or food-related materials;
[0006] Parsing the raw food data to obtain an attribute data set for 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 attribute content;
[0007] 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;
[0008] Determining the upstream node server and / or downstream node server corresponding to the original food data according to the food relationship chain;
[0009] 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,
[0010] 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 unit are sent to the node server that submitted the original food data, the upstream and downstream relationship unit includes the upstream relationship unit and / or the downstream relationship unit, and the upstream and downstream encrypted data unit includes the upstream encrypted data unit and / or the downstream encrypted data unit.
[0011] Furthermore, in the step of parsing the raw food data, the food safety traceability server is configured to:
[0012] Determining whether the original food data contains a unique identification code for the upstream food or upstream food-related materials;
[0013] When the original food data contains unique identification codes of upstream food or upstream food-related materials, determine the number of unique identification codes of upstream food or upstream food-related materials contained in the original food data. ;
[0014] Extracting a unique identification code for each upstream food or upstream food-related material from the raw food data;
[0015] Generate a unique identification code with the number Correspondingly, the attribute data uses the unique identification code of the upstream food or upstream food-related materials as the attribute content.
[0016] Furthermore, in the step of generating food safety traceability data based on the attribute data set, the food safety traceability server is configured to:
[0017] When the original food data contains the unique identification code of the upstream food or the upstream food related material, a relationship unit instance count variable for instantiating the relationship unit instance is constructed and calculated. ;
[0018] Generate a corresponding relationship unit instance count variable based on the pre-built relationship unit object Instance of a relational unit;
[0019] 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 the current encrypted data unit;
[0020] The physical state change relationship and / or 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.
[0021] Furthermore, 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:
[0022] Constructing a relational unit instance count variable , and initialize it to ;
[0023] From 1 to Traverse each upstream food or upstream food related material;
[0024] Determine the traversed upstream food or upstream food-related materials as target materials;
[0025] Identify the physical state change relationship and associated subject change relationship between the target material and the current food or food-related material;
[0026] 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;
[0027] 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.
[0028] Furthermore, in the step of identifying the physical state change relationship and the associated subject change relationship between the target material and the current food or food-related material, the food safety traceability server is configured to:
[0029] Determine the target node server corresponding to the target material;
[0030] Obtaining a target encrypted data unit corresponding to the target material from the target node server;
[0031] 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;
[0032] Obtaining 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;
[0033] 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
[0034] An associated subject change relationship between the target material and the current food or food-associated material is generated based on the first associated subject attribute and the second associated subject attribute.
[0035] Furthermore, 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:
[0036] Determining whether the first material type attribute and the second material type attribute are the same;
[0037] 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;
[0038] 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.
[0039] Furthermore, in the step of generating an association subject change relationship between the target material and the current food or food-associated material based on the first association subject attribute and the second association subject attribute, the food safety traceability server is configured to:
[0040] Determining whether the first association subject attribute and the second association subject attribute are the same;
[0041] 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;
[0042] 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.
[0043] Furthermore, after the step of writing the physical state change relationship and / or the associated subject change relationship, as well as 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 to:
[0044] Determining whether there is a food relationship chain with the first hash value as the end node;
[0045] When there is a food relationship chain with the first hash value as an end node, adding the physical state change relationship and / or associated subject change relationship and the second hash value to the end of the food relationship chain;
[0046] When there is no food relationship chain with the first Hash value as the end node, a new food relationship chain is generated with the first Hash value as the start node and the second Hash value as the end node.
[0047] Furthermore, the food safety traceability server is further configured to:
[0048] Receive 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;
[0049] 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;
[0050] Querying a database for a food relationship chain containing the hash value, wherein the food relationship chain is composed of food and / or food-related materials at each node and the relationship units between the nodes are interconnected, wherein each node in the food relationship chain is represented by the hash value of its encrypted data unit, and the relationship units between nodes are used to represent the physical state change relationship or the associated subject change relationship between the food or food-related materials from one node to another;
[0051] When a food relationship chain containing the hash value exists 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;
[0052] Determine the corresponding node server according to the hash value of the encrypted data unit;
[0053] Obtaining encrypted data units of on-chain food or on-chain food-related materials in the food relationship chain from the determined node server;
[0054] parsing the encrypted data unit to obtain target attribute data to be displayed;
[0055] 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.
[0056] A second aspect of the present invention provides a food safety traceability method, comprising:
[0057] 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;
[0058] 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;
[0059] Querying a database for a food relationship chain containing the hash value, wherein the food relationship chain is composed of food and / or food-related materials at each node and the relationship units between the nodes are interconnected, wherein each node in the food relationship chain is represented by the hash value of its encrypted data unit, and the relationship units between nodes are used to represent the physical state change relationship or the associated subject change relationship between the food or food-related materials from one node to another;
[0060] When a food relationship chain containing the hash value exists 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;
[0061] Determine the corresponding node server according to the hash value of the encrypted data unit;
[0062] Obtaining encrypted data units of on-chain food or on-chain food-related materials in the food relationship chain from the determined node server;
[0063] parsing the encrypted data unit to obtain target attribute data to be displayed;
[0064] 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.
[0065] The present invention proposes a food safety traceability system and traceability method, which generates food safety traceability data by parsing original food data submitted by a node server, wherein 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 based on the food relationship chain, and 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 submitted the original food data. This system can effectively improve the traceability capability of food safety data and reduce the cost of deployment and implementation. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] Figure 1 This is a schematic block diagram of a food safety traceability system provided by one embodiment of the present invention;
[0067] Figure 2This is a flow chart of a food safety traceability method provided by one embodiment of the present invention;
[0068] Figure 3 This is a flowchart of a food safety traceability method provided by another embodiment of the present invention. DETAILED DESCRIPTION
[0069] In order to more clearly understand the above-mentioned objects, 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, in the absence of conflict, the embodiments of the present application and the features therein can be combined with each other.
[0070] 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 scope of protection of the present invention is not limited to the specific embodiments disclosed below.
[0071] In the description of the present invention, the term "plurality" refers to two or more. Unless otherwise specified, the terms "upper" and "lower" are based on the orientations or positional relationships shown in the accompanying drawings and are intended solely to facilitate and simplify the description of the present invention. They are not intended to indicate or imply that the devices or components referred to must have a specific orientation, be constructed, or operate in a specific manner. Therefore, they should not be construed as limiting the present invention. The terms "connected," "mounted," and "fixed," etc., should be interpreted broadly. For example, "connected" can refer to fixed, removable, or integral connections; directly or indirectly through an intermediary. A person of ordinary skill in the art will understand the specific meanings of these terms in the present invention based on the specific circumstances. Furthermore, the terms "first," "second," etc., etc., are used for descriptive purposes only and should not be construed to indicate or imply relative importance or to implicitly specify the number of the technical features indicated. Therefore, a feature designated "first," "second," etc., may explicitly or implicitly include one or more of such features. In the description of the present invention, unless otherwise specified, "plurality" means two or more.
[0072] Throughout this specification, terms such as "one embodiment," "some implementations," and "specific examples" indicate that the specific features, structures, materials, or characteristics described in conjunction with that embodiment or example are included in at least one embodiment or example of the present invention. In this specification, schematic representations of these terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
[0073] A food safety traceability system and method according to some embodiments of the present invention will be described below with reference to the accompanying drawings.
[0074] like Figure 1 As shown, the 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 connected to the food collection device for storing food data, and a food safety traceability server for generating and querying food safety traceability data.
[0075] Specifically, the food data collection device may be a barcode scanning device, a text entry device, a picture taking device, or the like, which is used to obtain data on food or food-related materials.
[0076] The node server can be a dedicated server or a computer device such as a personal computer or workstation. The food data collection device establishes a communication connection with the node server via wired or wireless communication to store the collected food or food-related material data in the node server. Each node server can be connected to one or more data collection devices to obtain food or food-related material data through the data collection devices.
[0077] 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.
[0078] 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.
[0079] 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:
[0080] Receiving original food data submitted by the node server, wherein the original food data is data of food or food-related materials;
[0081] Parsing the raw food data to obtain an attribute data set for 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 attribute content;
[0082] 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;
[0083] Determining the upstream node server and / or downstream node server corresponding to the original food data according to the food relationship chain;
[0084] 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,
[0085] 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 unit are sent to the node server that submitted the original food data, the upstream and downstream relationship unit includes the upstream relationship unit and / or the downstream relationship unit, and the upstream and downstream encrypted data unit includes the upstream encrypted data unit and / or the downstream encrypted data unit.
[0086] The raw food data is food raw materials, food packaging, or food data collected by the food data collection device and stored on the node server in a specific format. The data format of the raw food data varies depending on the food data collection device used and the service program that manages food data on the node server.
[0087] The attribute dataset is based on a single food ingredient, food packaging, or food product. The unit can be one, one, or one portion, etc., which can be determined based on the packaging or sales unit. The following is an example of an attribute dataset:
[0088] {ID: XXXXXXXXXXXXXXXX, Name: XX, Type: XX, Manufacturer: XXXXXXXX, Production Address: XXXXXXXX, …}
[0089] In the above attribute data set example, name, type, manufacturer, production address, etc. are attribute names, and their corresponding content is attribute content. The 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 numeric and alphanumeric characters.
[0090] The food relationship chain is an information chain used to store changes in the physical state of food and changes in associated entities. Physical state changes refer to the process by which food or food-related materials undergo various processing methods, changing from one form to another. This includes, but is not limited to, converting food ingredients and / or food packaging into food, or manufacturing or combining one food into another. Associated entity changes refer to changes in the entity responsible for the safety of food or food-related materials, including but not limited to manufacturers, carriers, wholesalers, and retailers.
[0091] 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. 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, the relationship unit between the two nodes contains at least one physical state change relationship and an associated subject change relationship.
[0092] For example, when a food ingredient flows from food ingredient producer A to food ingredient producer B to be made into a finished food product, food ingredient producer A and food ingredient producer B are considered two nodes in the food relationship chain. Between nodes A and B, there exists both a physical state change relationship (food ingredient -> food) and an associated entity change relationship (A -> B). For another example, when a food ingredient flows from food ingredient producer B to carrier C for transportation, food ingredient producer B and carrier C are considered two nodes in the food relationship chain. Between nodes B and C, there exists only an associated entity change relationship (B -> C), but no physical state change relationship.
[0093] 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 for each original food data of a 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.
[0094] 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.
[0095] In 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 its downstream encrypted data unit to the node server that submitted the original food data for associated storage. This allows any node server to 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 this embodiment, the networking between the node servers allows data communication to be established between the node servers, allowing food safety traceability to be completed without going through the food safety traceability server.
[0096] 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.
[0097] In the technical solution of the present invention, the node preceding a node in a food or food-related material's food relationship chain is referred to as an upstream node. Specifically, the upstream node refers to the adjacent node before the food or food-related material undergoes a physical change or a change in its associated entity. Accordingly, the relationship unit between the current node and the upstream node is referred to as an upstream relationship unit, the encrypted data packet corresponding to the upstream node is referred to as an upstream encrypted data packet, and the node server corresponding to the upstream node is referred to as an upstream node server.
[0098] Similarly, the node preceding a food or food-related material in the food relationship chain is called a downstream node. Specifically, a downstream node refers to the adjacent node after the food or food-related material undergoes a physical change or a change in its associated entity. Accordingly, 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.
[0099] In some possible situations, such as in the case of batch data submission or data supplementation, 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 the food or food-related material has a downstream node in the food relationship chain, so as to execute 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.
[0100] Furthermore, in the step of parsing the raw food data, the food safety traceability server is configured to:
[0101] Determining whether the original food data contains a unique identification code for the upstream food or upstream food-related materials;
[0102] When the original food data contains unique identification codes of upstream food or upstream food-related materials, determine the number of unique identification codes of upstream food or upstream food-related materials contained in the original food data. ;
[0103] Extracting a unique identification code for each upstream food or upstream food-related material from the raw food data;
[0104] Generate a unique identification code with the number Correspondingly, the attribute data uses the unique identification code of the upstream food or upstream food-related materials as the attribute content.
[0105] In the technical solution of the present invention, the raw food data may or may not include one or more unique identification codes of upstream foods or upstream food-related materials. When the raw food data includes unique identification codes of upstream foods 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 the upstream foods or upstream food-related materials, and the unique identification codes of the upstream foods or upstream food-related materials are simultaneously written into the attribute data set of the food or food-related materials for packaging into the encrypted data unit of the current food or food-related materials.
[0106] During the step of generating food safety traceability data based on the attribute dataset, the food safety traceability server stores the association 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 a database. Therefore, when the raw food data contains the unique identification code of an upstream food or upstream food-related material, the corresponding upstream node server can be determined based on the unique identification code of the upstream food or upstream food-related material. This allows for rapid location of the corresponding upstream node server during the step of determining the upstream node server corresponding to the raw food data based on the food relationship chain.
[0107] 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.
[0108] Furthermore, in the step of generating food safety traceability data based on the attribute data set, the food safety traceability server is configured to:
[0109] When the original food data contains the unique identification code of the upstream food or the upstream food related material, a relationship unit instance count variable for instantiating the relationship unit instance is constructed and calculated. ;
[0110] Generate a corresponding relationship unit instance count variable based on the pre-built relationship unit object Instance of a relational unit;
[0111] 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 the current encrypted data unit;
[0112] The physical state change relationship and / or 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.
[0113] In the technical solution of the present invention, each food and / or food-related material is considered a node, and the food relationship chain is composed of interconnected nodes and their relationship units. In the food relationship chain, each node is represented by the hash value of its encrypted data unit, and the relationship units between nodes are used to represent the physical state change relationship or the associated entity change relationship between the food or food-related material from one node to another.
[0114] Furthermore, 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:
[0115] Constructing a relational unit instance count variable , and initialize it to ;
[0116] From 1 to Traverse each upstream food or upstream food related material;
[0117] Determine the traversed upstream food or upstream food-related materials as target materials;
[0118] Identify the physical state change relationship and associated subject change relationship between the target material and the current food or food-related material;
[0119] 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;
[0120] 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.
[0121] 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 the same as the 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 based on 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.
[0122] In the technical solution of the above-mentioned embodiment, when a physical state change relationship or an associated subject change relationship exists between the target material and 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. In other words, for each upstream food or upstream food-related material with 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.
[0123] 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.
[0124] Furthermore, in the step of identifying the physical state change relationship and the associated subject change relationship between the target material and the current food or food-related material, the food safety traceability server is configured to:
[0125] Determine the target node server corresponding to the target material;
[0126] Obtaining a target encrypted data unit corresponding to the target material from the target node server;
[0127] 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;
[0128] Obtaining 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;
[0129] 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
[0130] An associated subject change relationship between the target material and the current food or food-associated material is generated based on the first associated subject attribute and the second associated subject attribute.
[0131] Specifically, the material type attribute is an attribute within the food or food-related material attribute dataset that reflects the physical form of the food or food-related material, typically represented by the type of food or food-related material, such as flour or cake. The associated entity attribute, on the other hand, reflects the attribute of the entity responsible for the safety of the food or food-related material within its current supply chain, typically represented by the company name of the manufacturer, carrier, wholesaler, or retailer. For ease of distinction, in the technical solutions of the aforementioned implementations, the first material type attribute and the first associated entity attribute are used to represent the material type attribute and associated entity attribute of the target material, while the second material type attribute and the second associated entity attribute are used to represent the material type attribute and associated entity attribute of the current food or food-related material.
[0132] In the technical solutions of some 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 material, including the material type attribute and the associated subject attribute information, in a database. Therefore, 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 material to complete the processing without reading and parsing the target encrypted data unit corresponding to the target material from the target node server.
[0133] Furthermore, 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:
[0134] Determining whether the first material type attribute and the second material type attribute are the same;
[0135] 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;
[0136] 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.
[0137] 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.
[0138] Furthermore, 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:
[0139] 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.
[0140] Furthermore, in the step of generating an association subject change relationship between the target material and the current food or food-associated material based on the first association subject attribute and the second association subject attribute, the food safety traceability server is configured to:
[0141] Determining whether the first association subject attribute and the second association subject attribute are the same;
[0142] 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;
[0143] 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.
[0144] Similarly, in the association subject change relationship instance, the writing order of the first association subject attribute and the second association subject attribute reflects the directional relationship between the two, that is, in the association subject change relationship instance, the first association subject attribute written first reflects the prior security responsibility subject in the association subject change relationship, and the second association subject attribute written later reflects the subsequent security responsibility subject in the association subject change relationship.
[0145] Furthermore, in the step of generating an association subject change relationship between the target material and the current food or food-associated material based on the first association subject attribute and the second association subject attribute, the food safety traceability server is configured to:
[0146] When the first associated subject attribute and the second associated subject attribute are the same, no associated subject change relationship is generated from the target material to the current food or food-associated material.
[0147] Furthermore, after the step of writing the physical state change relationship and / or the associated subject change relationship, as well as 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 to:
[0148] Determining whether there is a food relationship chain with the first hash value as the end node;
[0149] When there is a food relationship chain with the first hash value as an end node, adding the physical state change relationship and / or associated subject change relationship and the second hash value to the end of the food relationship chain;
[0150] When there is no food relationship chain with the first Hash value as the end node, a new food relationship chain is generated with the first Hash value as the start node and the second Hash value as the end node.
[0151] The food relationship chain uses hash values of encrypted data units of food or food-related materials as nodes, and nodes are connected by relationship units that represent physical state change relationships or associated subject change relationships. In the food relationship chain, each node has a temporal order relationship, and the physical state change relationship or associated subject change relationship represented by the relationship unit has a directional relationship between two nodes based on the temporal order relationship, that is, the relationship unit points from the temporally earlier node to the temporally later node.
[0152] Furthermore, the food safety traceability server is further configured to:
[0153] Receive 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;
[0154] 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;
[0155] Querying a database for a food relationship chain containing the hash value, wherein the food relationship chain is composed of food and / or food-related materials at each node and the relationship units between the nodes are interconnected, wherein each node in the food relationship chain is represented by the hash value of its encrypted data unit, and the relationship units between nodes are used to represent the physical state change relationship or the associated subject change relationship between the food or food-related materials from one node to another;
[0156] When a food relationship chain containing the hash value exists 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;
[0157] Determine the corresponding node server according to the hash value of the encrypted data unit;
[0158] Obtaining encrypted data units of on-chain food or on-chain food-related materials in the food relationship chain from the determined node server;
[0159] parsing the encrypted data unit to obtain target attribute data to be displayed;
[0160] 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.
[0161] 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.
[0162] 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.
[0163] 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 and the node server stored in the food relationship chain.
[0164] The target attribute data is pre-configured data corresponding to attribute fields for displaying food safety traceability results. For example, the name attribute, material type attribute, and associated subject attribute can be configured as attribute fields for displaying food safety traceability results, thereby displaying food safety traceability results in a visual manner.
[0165] 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 visual node, and each visual node can be connected with the corresponding physical state change relationship and / or associated subject change relationship to form a food safety traceability chain, so that the food safety traceability results can be displayed to the user more intuitively.
[0166] In the technical solutions of some embodiments of the present invention, the node server is configured as follows:
[0167] Receive 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;
[0168] 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;
[0169] Querying the hash value of the upstream encrypted data unit corresponding to the hash value of the encrypted data unit;
[0170] The food or food-related materials are traced forward according to the hash value of the upstream encrypted data unit.
[0171] 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 to:
[0172] Determine a corresponding upstream node server according to a hash value of the upstream encrypted data unit;
[0173] Trace back all the node servers on the same food relationship chain from the upstream node server;
[0174] 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;
[0175] parsing the encrypted data unit to obtain target attribute data to be displayed;
[0176] 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.
[0177] like Figure 3 As shown, the second aspect of the present invention provides a food safety traceability method, comprising:
[0178] 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;
[0179] 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;
[0180] Querying a database for a food relationship chain containing the hash value, wherein the food relationship chain is composed of food and / or food-related materials at each node and the relationship units between the nodes are interconnected, wherein each node in the food relationship chain is represented by the hash value of its encrypted data unit, and the relationship units between nodes are used to represent the physical state change relationship or the associated subject change relationship between the food or food-related materials from one node to another;
[0181] When a food relationship chain containing the hash value exists 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;
[0182] Determine the corresponding node server according to the hash value of the encrypted data unit;
[0183] Obtaining encrypted data units of on-chain food or on-chain food-related materials in the food relationship chain from the determined node server;
[0184] parsing the encrypted data unit to obtain target attribute data to be displayed;
[0185] 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.
[0186] 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.
[0187] 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.
[0188] 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 and the node server stored in the food relationship chain.
[0189] The target attribute data is pre-configured data corresponding to attribute fields for displaying food safety traceability results. For example, the name attribute, material type attribute, and associated subject attribute can be configured as attribute fields for displaying food safety traceability results, thereby displaying food safety traceability results in a visual manner.
[0190] 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 visual node, and each visual node can be connected with the corresponding physical state change relationship and / or associated subject change relationship to form a food safety traceability chain, so that the food safety traceability results can be displayed to the user more intuitively.
[0191] In the technical solutions of some embodiments of the present invention, the food safety traceability method further includes:
[0192] 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;
[0193] 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;
[0194] Querying the hash value of the upstream encrypted data unit corresponding to the hash value of the encrypted data unit;
[0195] The food or food-related materials are traced forward according to the hash value of the upstream encrypted data unit.
[0196] 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:
[0197] Determine a corresponding upstream node server according to a hash value of the upstream encrypted data unit;
[0198] Trace back all the node servers on the same food relationship chain from the upstream node server;
[0199] 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;
[0200] parsing the encrypted data unit to obtain target attribute data to be displayed;
[0201] 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.
[0202] Furthermore, before the food safety traceability server receives the food safety traceability request submitted by the user, the method further includes:
[0203] 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;
[0204] Parsing the raw food data to obtain an attribute data set for 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 attribute content;
[0205] 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;
[0206] Determining the upstream node server and / or downstream node server corresponding to the original food data according to the food relationship chain;
[0207] 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,
[0208] 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 unit are sent to the node server that submitted the original food data, the upstream and downstream relationship unit includes the upstream relationship unit and / or the downstream relationship unit, and the upstream and downstream encrypted data unit includes the upstream encrypted data unit and / or the downstream encrypted data unit.
[0209] The raw food data is food raw materials, food packaging, or food data collected by the food data collection device and stored on the node server in a specific format. The data format of the raw food data varies depending on the food data collection device used and the service program that manages food data on the node server.
[0210] The attribute dataset is based on a single food ingredient, food packaging, or food product. The unit can be one, one, or one portion, etc., which can be determined based on the packaging or sales unit. The following is an example of an attribute dataset:
[0211] {ID: XXXXXXXXXXXXXXXX, Name: XX, Type: XX, Manufacturer: XXXXXXXX, Production Address: XXXXXXXX, …}
[0212] In the above attribute data set example, name, type, manufacturer, production address, etc. are attribute names, and their corresponding content is attribute content. The 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 numeric and alphanumeric characters.
[0213] The food relationship chain is an information chain used to store changes in the physical state of food and changes in associated entities. Physical state changes refer to the process by which food or food-related materials undergo various processing methods, changing from one form to another. This includes, but is not limited to, converting food ingredients and / or food packaging into food, or manufacturing or combining one food into another. Associated entity changes refer to changes in the entity responsible for the safety of food or food-related materials, including but not limited to manufacturers, carriers, wholesalers, and retailers.
[0214] 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. 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, the relationship unit between the two nodes contains at least one physical state change relationship and an associated subject change relationship.
[0215] For example, when a food ingredient flows from food ingredient producer A to food ingredient producer B to be made into a finished food product, food ingredient producer A and food ingredient producer B are considered two nodes in the food relationship chain. Between nodes A and B, there exists both a physical state change relationship (food ingredient -> food) and an associated entity change relationship (A -> B). For another example, when a food ingredient flows from food ingredient producer B to carrier C for transportation, food ingredient producer B and carrier C are considered two nodes in the food relationship chain. Between nodes B and C, there exists only an associated entity change relationship (B -> C), but no physical state change relationship.
[0216] 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 for each original food data of a 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.
[0217] 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.
[0218] In 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 its downstream encrypted data unit to the node server that submitted the original food data for associated storage. This allows any node server to 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 this embodiment, the networking between the node servers allows data communication to be established between the node servers, allowing food safety traceability to be completed without going through the food safety traceability server.
[0219] 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.
[0220] In the technical solution of the present invention, the node preceding a node in a food or food-related material's food relationship chain is referred to as an upstream node. Specifically, the upstream node refers to the adjacent node before the food or food-related material undergoes a physical change or a change in its associated entity. Accordingly, the relationship unit between the current node and the upstream node is referred to as an upstream relationship unit, the encrypted data packet corresponding to the upstream node is referred to as an upstream encrypted data packet, and the node server corresponding to the upstream node is referred to as an upstream node server.
[0221] Similarly, the node preceding a food or food-related material in the food relationship chain is called a downstream node. Specifically, a downstream node refers to the adjacent node after the food or food-related material undergoes a physical change or a change in its associated entity. Accordingly, 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.
[0222] In some possible situations, such as in the case of batch data submission or data supplementation, 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 the food or food-related material has a downstream node in the food relationship chain, so as to execute 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.
[0223] Furthermore, the step of parsing the raw food data specifically includes:
[0224] Determining whether the original food data contains a unique identification code for the upstream food or upstream food-related materials;
[0225] When the original food data contains unique identification codes of upstream food or upstream food-related materials, determine the number of unique identification codes of upstream food or upstream food-related materials contained in the original food data. ;
[0226] Extracting a unique identification code for each upstream food or upstream food-related material from the raw food data;
[0227] Generate a unique identification code with the number Correspondingly, the attribute data uses the unique identification code of the upstream food or upstream food-related materials as the attribute content.
[0228] In the technical solution of the present invention, the raw food data may or may not include one or more unique identification codes of upstream foods or upstream food-related materials. When the raw food data includes unique identification codes of upstream foods 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 the upstream foods or upstream food-related materials, and the unique identification codes of the upstream foods or upstream food-related materials are simultaneously written into the attribute data set of the food or food-related materials for packaging into the encrypted data unit of the current food or food-related materials.
[0229] During the step of generating food safety traceability data based on the attribute dataset, the food safety traceability server stores the association 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 a database. Therefore, when the raw food data contains the unique identification code of an upstream food or upstream food-related material, the corresponding upstream node server can be determined based on the unique identification code of the upstream food or upstream food-related material. This allows for rapid location of the corresponding upstream node server during the step of determining the upstream node server corresponding to the raw food data based on the food relationship chain.
[0230] 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.
[0231] Furthermore, the step of generating food safety traceability data based on the attribute data set specifically includes:
[0232] When the original food data contains the unique identification code of the upstream food or the upstream food related material, a relationship unit instance count variable for instantiating the relationship unit instance is constructed and calculated. ;
[0233] Generate a corresponding relationship unit instance count variable based on the pre-built relationship unit object Instance of a relational unit;
[0234] 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 the current encrypted data unit;
[0235] The physical state change relationship and / or 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.
[0236] In the technical solution of the present invention, each food and / or food-related material is considered a node, and the food relationship chain is composed of interconnected nodes and their relationship units. In the food relationship chain, each node is represented by the hash value of its encrypted data unit, and the relationship units between nodes are used to represent the physical state change relationship or the associated entity change relationship between the food or food-related material from one node to another.
[0237] Furthermore, a relationship unit instance count variable is constructed and calculated for instantiating the relationship unit instance. The steps specifically include:
[0238] Constructing a relational unit instance count variable , and initialize it to ;
[0239] From 1 to Traverse each upstream food or upstream food related material;
[0240] Determine the traversed upstream food or upstream food-related materials as target materials;
[0241] Identify the physical state change relationship and associated subject change relationship between the target material and the current food or food-related material;
[0242] 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;
[0243] 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.
[0244] 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 the same as the 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 based on 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.
[0245] In the technical solution of the above-mentioned embodiment, when a physical state change relationship or an associated subject change relationship exists between the target material and 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. In other words, for each upstream food or upstream food-related material with 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.
[0246] 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.
[0247] Furthermore, the step of identifying the physical state change relationship and the associated subject change relationship between the target material and the current food or food-related material specifically includes:
[0248] Determine the target node server corresponding to the target material;
[0249] Obtaining a target encrypted data unit corresponding to the target material from the target node server;
[0250] 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;
[0251] Obtaining 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;
[0252] 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
[0253] An associated subject change relationship between the target material and the current food or food-associated material is generated based on the first associated subject attribute and the second associated subject attribute.
[0254] Specifically, the material type attribute is an attribute within the food or food-related material attribute dataset that reflects the physical form of the food or food-related material, typically represented by the type of food or food-related material, such as flour or cake. The associated entity attribute, on the other hand, reflects the attribute of the entity responsible for the safety of the food or food-related material within its current supply chain, typically represented by the company name of the manufacturer, carrier, wholesaler, or retailer. For ease of distinction, in the technical solutions of the aforementioned implementations, the first material type attribute and the first associated entity attribute are used to represent the material type attribute and associated entity attribute of the target material, while the second material type attribute and the second associated entity attribute are used to represent the material type attribute and associated entity attribute of the current food or food-related material.
[0255] In the technical solutions of some 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 material, including the material type attribute and the associated subject attribute information, in a database. Therefore, 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 material to complete the processing without reading and parsing the target encrypted data unit corresponding to the target material from the target node server.
[0256] 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:
[0257] Determining whether the first material type attribute and the second material type attribute are the same;
[0258] 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;
[0259] 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.
[0260] 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.
[0261] 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:
[0262] 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.
[0263] Furthermore, the step of generating an associated subject change relationship between the target material and the current food or food-associated material based on the first associated subject attribute and the second associated subject attribute specifically includes:
[0264] Determining whether the first association subject attribute and the second association subject attribute are the same;
[0265] 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;
[0266] 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.
[0267] Similarly, in the association subject change relationship instance, the writing order of the first association subject attribute and the second association subject attribute reflects the directional relationship between the two, that is, in the association subject change relationship instance, the first association subject attribute written first reflects the prior security responsibility subject in the association subject change relationship, and the second association subject attribute written later reflects the subsequent security responsibility subject in the association subject change relationship.
[0268] Furthermore, the step of generating an associated subject change relationship between the target material and the current food or food-associated material based on the first associated subject attribute and the second associated subject attribute specifically includes:
[0269] When the first associated subject attribute and the second associated subject attribute are the same, no associated subject change relationship is generated from the target material to the current food or food-associated material.
[0270] Furthermore, after the step of writing the physical state change relationship and / or the associated subject change relationship, as well as the first hash value and the second hash value into the relationship unit instance to obtain the corresponding relationship unit, the method further includes:
[0271] Determining whether there is a food relationship chain with the first hash value as the end node;
[0272] When there is a food relationship chain with the first hash value as an end node, adding the physical state change relationship and / or associated subject change relationship and the second hash value to the end of the food relationship chain;
[0273] When there is no food relationship chain with the first Hash value as the end node, a new food relationship chain is generated with the first Hash value as the start node and the second Hash value as the end node.
[0274] The food relationship chain uses hash values of encrypted data units of food or food-related materials as nodes, and nodes are connected by relationship units that represent physical state change relationships or associated subject change relationships. In the food relationship chain, each node has a temporal order relationship, and the physical state change relationship or associated subject change relationship represented by the relationship unit has a directional relationship between two nodes based on the temporal order relationship, that is, the relationship unit points from the temporally earlier node to the temporally later node.
[0275] It should be noted that, in this document, relational terms such as first and second, etc., are used only 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 "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus comprising the element.
[0276] While embodiments of the present invention have been described above, these embodiments do not exhaustively describe all details and do not limit the invention to the specific embodiments described. Obviously, many modifications and variations are possible based on the above description. These embodiments are selected and described in detail in this specification in order to better explain the principles and practical applications of the present invention, thereby enabling those skilled in the art to better utilize the present invention and its modifications. 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 system comprises a food data collection device for collecting food data, a node server connected to the food data collection device for storing food data, and a food safety traceability server for generating and querying food safety traceability data, wherein the food safety traceability server is configured to: Receiving original food data submitted by the node server, wherein the original food data is data of food or food-related materials; Parsing the raw food data to obtain an attribute data set for 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 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. The food relationship chain is an information chain for storing physical state changes of food and changes in associated entities. Each node of the food relationship chain is connected by a relationship unit, and each relationship unit contains a physical state change relationship or an associated entity change relationship. The encrypted data unit is a data packet obtained by encrypting the attribute data set using an encryption algorithm. Determining 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 unit are sent to the node server that submitted the original food data, the upstream and downstream relationship unit includes the upstream relationship unit and / or the downstream relationship unit, and the upstream and downstream encrypted data unit includes the upstream encrypted data unit and / or the 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 for the upstream food or upstream food-related materials; When the original food data contains a unique identification code of an upstream food or an upstream food-related material, determining the number nupper 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 for each upstream food or upstream food-related material from the raw food data; Generate attribute data corresponding to the number nupper of unique identification codes, with the unique identification code of the upstream food or upstream food-related material as 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 the unique identification code of the upstream food or the upstream food related material, a relationship unit instance count variable for instantiating the 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 the current encrypted data unit; The physical state change relationship and / or 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 relational unit instance count variable And initialize it to nupper; Traverse each upstream food or upstream food related material from 1 to nupper; Determine the traversed upstream food or upstream food-related materials as target materials; Identify the physical state change relationship and associated subject change relationship between the target material and 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 4, 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; Obtaining a 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; Obtaining 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 between the target material and the current food or 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: Determining 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 association subject change relationship between the target material and the current food or food-associated material based on the first association subject attribute and the second association 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, as well as 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 to: Determining whether there is a food relationship chain with the first hash value as the end node; When there is a food relationship chain with the first hash value as an end node, adding the physical state change relationship and / or 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 end node, a new food relationship chain is generated with the first Hash value as the start node and the second Hash value as the end node.
9. The food safety traceability system according to claim 1, characterized in that: The food safety traceability server is further configured to: Receive 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 database for a food relationship chain containing the hash value, wherein the food relationship chain is composed of food and / or food-related materials at each node and the relationship units between the nodes are interconnected, wherein each node in the food relationship chain is represented by the hash value of its encrypted data unit, and the relationship units between nodes are used to represent the physical state change relationship or the associated subject change relationship between the food or food-related materials from one node to another; When a food relationship chain containing the hash value exists 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 an encrypted data unit of the food to be traced based on the unique identification code of the food to be traced, wherein the encrypted data unit is a data packet obtained by encrypting the attribute data set of the food to be traced using an encryption algorithm; Querying a database for a food relationship chain containing the hash value, wherein the food relationship chain is composed of food and / or food-related materials at each node and the relationship units between the nodes are interconnected, wherein each node in the food relationship chain is represented by the hash value of its encrypted data unit, and the relationship units between nodes are used to represent the physical state change relationship or the associated subject change relationship between the food or food-related materials from one node to another; When a food relationship chain containing the hash value exists 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