A visual traceability system and method for the entire life cycle of vegetables
By uniquely identifying each minimum sales unit of vegetables and storing video traceability information throughout its life cycle, it solves the problems of opaque information and difficult traceability in traditional vegetable planting and circulation models, and achieves rapid tracking of the entire life cycle of vegetables. , effective visual traceability to meet the needs of modern consumers for safety and environmental protection.
Patent Information
- Application Number
- CN202410931318.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2044-07-12
AI Technical Summary
The traditional vegetable planting and circulation model has problems such as opaque information and difficult traceability. It is difficult to meet the needs of modern consumers for vegetable safety, environmental protection and health. In particular, it cannot provide quick response video information for visual traceability of the entire life cycle.
By uniquely identifying each minimum sales unit of vegetables, we can obtain and store video traceability information throughout its life cycle, including video information on production, processing, circulation and retail links, and directly call this information when consumers query it. , providing visual traceability information.
It achieves rapid and effective visual traceability of the entire life cycle of vegetables, meets consumers' needs for vegetable safety and origin, and improves information transparency and traceability efficiency.
Smart Images

Figure CN118469596B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of vegetable production and marketing management, and in particular relates to a visual tracing system and method for the entire life cycle of vegetables. Background Art
[0002] With the improvement of people's living standards and the increasing concern about food safety, consumers have put forward higher requirements on the quality and source of agricultural products such as vegetables. The traditional vegetable planting and circulation model has problems such as information opacity and difficulty in traceability, which makes it difficult to meet the modern consumers' demand for safe, environmentally friendly and healthy vegetables.
[0003] Traditional vegetable traceability methods for consumers can only provide partial text description information, cannot respond quickly to provide corresponding video information, and it is difficult to provide consumers with instant visual traceability information on vegetables throughout their life cycle. Summary of the invention
[0004] The purpose of the present invention is to provide a vegetable full life cycle visual tracing system and method, which can provide consumers with visual tracing information in a timely manner.
[0005] In order to solve the above technical problems, the present invention is achieved through the following technical solutions:
[0006] The present invention provides a method for visually tracing the entire life cycle of vegetables, comprising:
[0007] Uniquely identify each minimum sales unit vegetable to obtain an identification code for each minimum sales unit vegetable;
[0008] Obtain product traceability information of each supply link in the supply chain of vegetables throughout their life cycle, wherein the product traceability information includes circulation traceability information and video traceability information, and the supply links include production, processing, circulation, wholesale and retail;
[0009] The identification code of the smallest sales unit vegetable is obtained according to the identification code of the smallest sales unit vegetable and the flow traceability information, and the identification code of the smallest sales unit vegetable corresponds to the video traceability information fragment in each supply link;
[0010] Get traceability access request;
[0011] Parsing the traceability access request to obtain the identification code of the smallest sales unit of vegetables to be queried and specifying the supply link to be queried;
[0012] According to the identification code of the smallest sales unit vegetable to be queried and the identification code of the smallest sales unit vegetable to be traced back to the specified supply link to be queried, the video traceability information fragment corresponding to each supply link is obtained for the smallest sales unit vegetable to be queried in the specified supply link to be queried;
[0013] The video traceability information of the queried minimum sales unit vegetable in the designated queried supply link is sent to the requesting end of the traceability access request.
[0014] The present invention also discloses a method for visually tracing the entire life cycle of vegetables, comprising:
[0015] Bind the identification codes of several minimum sales units of vegetables;
[0016] Receive video traceability information of the smallest sales unit of vegetables in the binding range in the specified supply link;
[0017] Displays the video traceability information of the queried minimum sales unit vegetables within the binding scope in the specified queried supply link.
[0018] The present invention also discloses a method for visually tracing the entire life cycle of vegetables, comprising:
[0019] Read the identification code of the smallest sales unit of vegetables;
[0020] Set the specified supply link to be queried;
[0021] Sending a traceability access request, wherein the traceability access request includes the identification code of the smallest sales unit vegetable to be queried and specifies the supply link to be queried;
[0022] Receive video traceability information of the smallest sales unit of vegetables in the specified supply link;
[0023] Displays the video traceability information of the smallest sales unit of vegetables being queried in the specified supply link being queried.
[0024] The present invention also discloses a vegetable full life cycle visual tracing system, including a tracing control unit and a storage unit;
[0025] Wherein, the traceability control unit is used to uniquely identify each minimum sales unit vegetable to obtain an identification code for each minimum sales unit vegetable;
[0026] Obtain product traceability information of each supply link in the supply chain of vegetables throughout their life cycle, wherein the product traceability information includes circulation traceability information and video traceability information, and the supply links include production, processing, circulation, wholesale and retail;
[0027] The identification code of the smallest sales unit vegetable is obtained according to the identification code of the smallest sales unit vegetable and the flow traceability information, and the identification code of the smallest sales unit vegetable corresponds to the video traceability information fragment in each supply link;
[0028] Get traceability access request;
[0029] Parsing the traceability access request to obtain the identification code of the smallest sales unit of vegetables to be queried and specifying the supply link to be queried;
[0030] According to the identification code of the smallest sales unit vegetable to be queried and the identification code of the smallest sales unit vegetable to be traced back to the specified supply link to be queried, the video traceability information fragment corresponding to each supply link is obtained for the smallest sales unit vegetable to be queried in the specified supply link to be queried;
[0031] Sending the video traceability information of the smallest sales unit of vegetables being queried in the designated supply link being queried to the requesting end of the traceability access request;
[0032] The storage unit is used to store all product traceability information.
[0033] The present invention intercepts and encodes the video traceability information in the product traceability information, and directly calls the intercepted and transcoded video traceability information fragments when consumers make traceability inquiries, so as to provide visualized traceability information for consumers' traceability inquiries in a timely and effective manner.
[0034] Of course, any product implementing the present invention does not necessarily need to achieve all of the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for describing the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0036] Figure 1 A schematic diagram of an energy supply unit and information flow of a vegetable full life cycle visual traceability system in one embodiment of the present invention;
[0037] Figure 2 A schematic diagram of a process flow of a traceability control unit and a storage unit according to an embodiment of the present invention;
[0038] Figure 3 A schematic diagram of a process flow of a merchant terminal according to an embodiment of the present invention;
[0039] Figure 4 A schematic diagram of a process flow of a consumer end according to an embodiment of the present invention;
[0040] Figure 5 The step S3 of the present invention is a schematic diagram of a step flow in an embodiment. Figure 1 ;
[0041] Figure 6The step S3 of the present invention is a schematic diagram of a step flow in an embodiment. Figure 2 ;
[0042] Figure 7 The step S3 of the present invention is a schematic diagram of a step flow in an embodiment. Figure 3 ;
[0043] Figure 8 It is a schematic diagram of the step flow of step S310 in one embodiment of the present invention;
[0044] Fig. 9 This is a schematic diagram of the step flow of step S33 in one embodiment of the present invention;
[0045] Fig.10 This is a schematic diagram of a step flow chart of step S331 in an embodiment of the present invention;
[0046] In the accompanying drawings, the components represented by the reference numerals are listed as follows:
[0047] 1- traceability control unit, 2- storage unit, 3- merchant end, 4- consumer end. DETAILED DESCRIPTION
[0048] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0049] It should be noted that the terms "first", "second", etc. in this application are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0050] See also Figures 1 to 4 As shown, the present invention provides a visual traceability system for the entire life cycle of vegetables, which can be divided into a traceability control unit 1 and a storage unit 2 from the functional unit. The traceability control unit 1 receives and processes the traceability access request sent by the consumer and responds quickly. Prior to this, the traceability control unit 1 also intercepts and transcodes the video traceability information of each supply link, and pre-stores it in the storage unit 2, which can be quickly called and responded.
[0051] Due to the particularity of the vegetable production to sales link, vegetables are mostly packaged as minimum sales units in the form of pre-packaging, bundling, bagging, etc. For the convenience of management and identification, step S1 can be performed in the form of barcodes, QR codes, NFC tags, laser tags, etc. to uniquely identify each minimum sales unit vegetable to obtain the identification code of each minimum sales unit vegetable. Next, step S2 can be performed to obtain the product traceability information of each supply link in the supply chain of vegetables throughout the life cycle, wherein the product traceability information includes circulation traceability information and video traceability information. The circulation traceability information may include the origin information, fertilization status information, processing technology information, processing time information, recorded camera information, recorded time period information, etc. of vegetables in each supply link. Video traceability information can be a video produced by camera recording. The supply link includes production, processing, circulation, wholesale and retail.
[0052] The traceability control unit 1 then continues to execute step S3 to obtain the identification code of the minimum sales unit vegetable corresponding to the video traceability information segment in each supply link based on the identification code of the minimum sales unit vegetable and the flow traceability information. Since video interception and transcoding require a lot of computing resources, the video traceability information segment pre-processed in this solution can be directly called, which can respond to consumers' traceability access requests more quickly.
[0053] After executing step S4 to obtain the traceability access request, step S5 can be executed next to parse the traceability access request to obtain the identification code of the queried minimum sales unit vegetable and the specified queried supply link. Next, step S6 can be executed to trace the identification code of the queried minimum sales unit vegetable and the specified queried supply link to obtain the video traceability information of the queried minimum sales unit vegetable in the specified queried supply link according to the video traceability information fragment corresponding to each supply link. Finally, step S7 can be executed to send the video traceability information of the queried minimum sales unit vegetable in the specified queried supply link to the request end of the traceability access request, so that consumers can intuitively visualize the entire life cycle of the vegetables.
[0054] In this solution, the storage unit 2 is used to store all product traceability information including the identification code-video traceability information fragment association data, that is, to store the traceability information library and the temporary information library at the same time, which will be described in detail below.
[0055] See also Figure 3As shown, in order to facilitate consumers to view the traceability information of vegetables, a merchant terminal 3 can be set at the vegetable sales counter. The merchant terminal can be a display device with basic communication and computing functions. When working, the store staff first executes step S031 to bind the identification codes of several minimum sales units of vegetables, that is, input the identification codes of the vegetables in the area covered by the merchant terminal 3 into the merchant terminal 3.
[0056] Next, step S032 may be executed to receive the video traceability information of the smallest sales unit vegetables in the binding range in the specified queried supply link. Finally, step S033 may be executed to display the video traceability information of the smallest sales unit vegetables in the binding range in the specified queried supply link.
[0057] See also Figure 4 As shown, consumers can also use their own mobile phones to realize the traceability query function. First, they can install the APP of the consumer terminal 4 in the mobile phone, then scan the code to identify and execute step S041 to read the identification code of the smallest sales unit vegetable, and then execute step S042 to set the specified supply link to be queried. Then execute step S043 to issue a traceability access request, wherein the traceability access request includes the identification code of the smallest sales unit vegetable to be queried and the specified supply link to be queried.
[0058] After the traceability control unit 1 responds, the consumer end 4 executes step S044 to receive the video traceability information of the queried minimum sales unit vegetables in the specified queried supply link. Finally, step S045 is executed to display the video traceability information of the queried minimum sales unit vegetables in the specified queried supply link.
[0059] See also Figure 5 As shown, the information retrieval and video processing capabilities of the traceability control unit 1 are limited, and the sales status of different types of vegetables after they are put on the market is also different. For example, green leafy vegetables that are not resistant to storage usually enter the sales status quickly after they are put on the market, while vegetables such as potatoes and onions that are resistant to storage will enter the sales status a little later. In view of this, the urgency of processing and generating video traceability information fragments for different types of vegetables can be sorted to minimize the impact of the limited performance of the traceability control unit 1 on consumer traceability queries.
[0060] In the process of sorting, first, step S31 can be executed to obtain the product traceability information of each supply link and store it in the traceability information library. Next, step S32 can be executed to obtain the traceability query time distribution of each type of vegetables after each batch of vegetables has been put on the market for retail. Next, step S33 can be executed to obtain the traceability priority of each type of vegetables according to the traceability query time distribution of each type of vegetables after each batch of vegetables has been put on the market for retail. Next, step S34 can be executed to search the traceability information library in sequence according to the traceability priority of each type of vegetables, and obtain the distribution period of the video traceability information of the minimum sales unit vegetables in each supply link according to the identification code of the minimum sales unit vegetables and the flow traceability information, and intercept and transcode to obtain the video traceability information fragment corresponding to the identification code of the minimum sales unit vegetables in each supply link. Next, step S35 can be executed to store the video traceability information fragment corresponding to the intercepted and transcoded identification code of the minimum sales unit vegetables in each supply link in the temporary information library.
[0061] In order to achieve the effect of fast query and tracing, the temporary information database is searched first when executing the tracing query.
[0062] See also Figure 6 As shown, in actual sales, some storable fruits may also be purchased by consumers earlier, which results in the identification code of the queried minimum sales unit vegetable not being stored in the temporary information library. Therefore, step S36 can be executed next to directly retrieve the traceability information library, and the product traceability information corresponding to the queried minimum sales unit vegetable can be obtained according to the identification code of the queried minimum sales unit vegetable. Next, step S37 can be executed to obtain the distribution period of the video traceability information of the queried minimum sales unit vegetable in each supply link according to the flow traceability information in the product traceability information corresponding to the queried minimum sales unit vegetable, and the video traceability information fragment of the queried minimum sales unit vegetable in each supply link can be obtained by intercepting and transcoding. Next, step S38 can be executed to store the video traceability information fragment corresponding to the identification code of the queried minimum sales unit vegetable in each supply link in the temporary information library for subsequent direct call.
[0063] See also Figure 7As shown, since the capacity of the temporary information base is limited, and in order to improve the retrieval performance, the content of the temporary information base cannot be increased infinitely, the content that will no longer be traced back needs to be deleted in time. In the specific process, step S39 can be first executed to continuously obtain the traceability query time distribution of each type of vegetables after the current batch is put on the market for retail. Next, step S310 can be executed to determine whether each type of vegetable is no longer traced back according to the traceability query time distribution of each type of vegetables after the current batch is put on the market for retail. If so, then step S311 can be executed to delete the information of the identification code of the type of vegetables in the current batch in the temporary information base. If not, step S312 can be executed to retain.
[0064] In practice, a fixed time period can also be set, and the data will be deleted if it has not been traced back for more than the fixed time period.
[0065] See also Figure 8 As shown, since there is a trend effect in the sales of vegetables, it is possible to combine the traceability query time distribution of the current batch to determine whether the traceability query will continue in the future. Specifically, for each vegetable, step S3101 can be first executed to continuously obtain the fitting function of the number of tracebacks in each unit time period after the current batch is listed on the market based on the traceability query time distribution of each type of vegetables after the current batch is listed on the market, and the cumulative time after the current batch is listed on the market, wherein the unit time period includes 1 hour, 15 minutes or 1 minute. Next, step S3102 can be executed to estimate the estimated number of tracebacks in the next unit time period according to the fitting function. Next, step S3103 can be executed to obtain the actual number of tracebacks in the next time period. Next, step S3104 can be executed to determine whether the actual number of tracebacks in the next time period is greater than the estimated number of tracebacks. If so, step S3105 can be executed next to determine whether the type of vegetables continues to be traced back, that is, the actual sales query status is more than the expected status.
[0066] If not, it means that the actual sales query status is not good. If the expected actual sales query status of the next period is 0 at the same time, it means that no one buys this type of vegetable, or it has been sold out, and consumers will not make traceback inquiries. Specifically, step S3106 can be executed next to determine whether the actual traceback times in the next period is 0. If so, step S3107 can be executed next to determine whether traceback inquiries are no longer required for this type of vegetable. If not, step S3105 can be executed next to determine whether traceback inquiries are continued for this type of vegetable.
[0067] In order to supplement the implementation process of the above steps S3101 to S3107, the source code of some functional modules is provided, and the explanation is compared in the comment section. In order to avoid the leakage of data involving commercial secrets, some data that does not affect the implementation of the solution are desensitized, the same below.
[0068] #include <iostream>
[0069] #include <unordered_map>
[0070] #include <vector>
[0071] #include <string>
[0072] #include <numeric>
[0073] #include <cmath>
[0074] #include <algorithm>
[0075] / / Define the video source information structure
[0076] struct VideoTraceInfo {
[0077] std::string production;
[0078] std::string processing;
[0079] std::string distribution;
[0080] std::string wholesale;
[0081] std::string retail;
[0082] };
[0083] / / Define the traceability system class
[0084] class TraceabilitySystem {
[0085] private:
[0086] / / Store the identification code of each minimum sales unit vegetable and its corresponding video traceability information
[0087] std::unordered_map<std::string, VideoTraceInfo> traceInfoMap;
[0088] / / Store temporary information
[0089] std::unordered_map<std::string, VideoTraceInfo> tempInfoMap;
[0090] / / Store the traceability query time distribution of each type of vegetables after each batch is put on the market for retail sale
[0091] std::unordered_map <std::string, std::vector <int>>queryTimeDistribution;
[0092] / / Calculate the slope and intercept of the linear fit function
[0093] std::pair<double, double> linearFit(const std::vector <int>×) const {
[0094] int n = times.size();
[0095] if (n == 0) return {0, 0};
[0096] double x_sum = 0, y_sum = 0, xy_sum = 0, xx_sum = 0;
[0097] for (int i = 0; i < n; ++i) {
[0098] x_sum += i;
[0099] y_sum += times[i];
[0100] xy_sum += i * times[i];
[0101] xx_sum += i * i;
[0102] }
[0103] double slope = (n * xy_sum - x_sum * y_sum) / (n * xx_sum -x_sum * x_sum);
[0104] double intercept = (y_sum - slope * x_sum) / n;
[0105] return {slope, intercept};
[0106] }
[0107] public:
[0108] / / Generate a unique identifier for the vegetable and store the video traceability information
[0109] void addVegetable(const std::string& id, const VideoTraceInfo&info) {
[0110] traceInfoMap[id] = info;
[0111] }
[0112] / / Add query time distribution
[0113] void addQueryTimeDistribution(const std::string& type, conststd::vector <int>& times) {
[0114] queryTimeDistribution[type] = times;
[0115] }
[0116] / / Determine whether to continue tracing and updating the temporary information base
[0117] void updateTraceStatus() {
[0118] for (auto& pair : queryTimeDistribution) {
[0119] const std::string& type = pair.first;
[0120] std::vector <int>& times = pair.second;
[0121] / / Get the slope and intercept of the fitting function, using a linear relationship as an example
[0122] auto [slope, intercept] = linearFit(times);
[0123] / / Estimated number of tracebacks for the next period (unit period is 1 hour)
[0124] int nextTime = times.size();
[0125] double estimatedNextCount = slope * nextTime + intercept;
[0126] / / Get the actual number of tracebacks for the next period (this example gets the actual number of tracebacks)
[0127] int actualNextCount = rand() % 10; / / Simulated value, actually should be obtained from the data source
[0128] / / Determine whether to continue the traceback query
[0129] if (actualNextCount > estimatedNextCount) {
[0130] std::cout << "Continue tracing query: " << type << std::endl;
[0131] } else {
[0132] if (actualNextCount == 0) {
[0133] std::cout << "Stop tracing query: " << type << std::endl;
[0134] / / Delete the temporary information of this type of vegetables in the current batch
[0135] for (auto it = tempInfoMap.begin(); it !=tempInfoMap.end(); ) {
[0136] if (it->first.find(type) != std::string::npos) {
[0137] it = tempInfoMap.erase(it);
[0138] } else {
[0139] ++it;
[0140] }
[0141] }
[0142] } else {
[0143] std::cout << "Continue tracing query: " << type << std::endl;
[0144] }
[0145] }
[0146] / / Update query time distribution
[0147] times.push_back(actualNextCount);
[0148] }
[0149] }
[0150] / / Get the video traceability information fragment based on the identification code of the smallest sales unit vegetable and the flow traceability information
[0151] void generateVideoSegments(const std::string& id) {
[0152] if (traceInfoMap.find(id) == traceInfoMap.end())
[0153] {
[0154] std::cout << "Vegetable ID does not exist" << std::endl;
[0155] return;
[0156] }
[0157] const VideoTraceInfo& info = traceInfoMap.at(id);
[0158] VideoTraceInfo segments;
[0159] / / Simulate the process of intercepting and transcoding
[0160] segments.production = "Capture production video segments: " + info.production;
[0161] segments.processing = "Capture and process video segments: " + info.processing;
[0162] segments.distribution = "Intercept circulating video segments: " +info.distribution;
[0163] segments.wholesale = "Intercept wholesale video segments: " + info.wholesale;
[0164] segments.retail = "Capture retail video segments: " + info.retail;
[0165] / / Store in temporary repository
[0166] tempInfoMap[id] = segments;
[0167] }
[0168] / / Get the intercepted video traceability information fragment of the specified vegetable in the specified supply link
[0169] std::string getTempTraceInfo(const std::string& id, const std::string& stage) const {
[0170] if (tempInfoMap.find(id) == tempInfoMap.end()) {
[0171] return "Vegetable ID does not exist";
[0172] }
[0173] const VideoTraceInfo& info = tempInfoMap.at(id);
[0174] if (stage == "production") return info.production;
[0175] else if (stage == "processing") return info.processing;
[0176] else if (stage == "distribution") return info.distribution;
[0177] else if (stage == "wholesale") return info.wholesale;
[0178] else if (stage == "retail") return info.retail;
[0179] else return "supply link invalid";
[0180] }
[0181] };
[0182] int main() {
[0183] / / Create a traceability system instance
[0184] TraceabilitySystem system;
[0185] / / Add vegetables and their video traceability information
[0186] system.addVegetable("001", {"Production Video 1", "Processing Video 1", "Circulation Video 1", "Wholesale Video 1", "Retail Video 1"});
[0187] system.addVegetable("002", {"Production Video 2", "Processing Video 2", "Circulation Video 2", "Wholesale Video 2", "Retail Video 2"});
[0188] / / Add query time distribution
[0189] system.addQueryTimeDistribution("Vegetable A", {5, 3, 6, 2, 1});
[0190] system.addQueryTimeDistribution("Vegetable B", {4, 2, 3, 1, 0});
[0191] / / Generate video clip
[0192] system.generateVideoSegments("001");
[0193] / / Get and print video clip information
[0194] std::cout << system.getTempTraceInfo("001", "production") < <std::endl;
[0195] std::cout << system.getTempTraceInfo("001", "processing") < <std::endl;
[0196] / / Update the traceback status
[0197] system.updateTraceStatus();
[0198] return 0;
[0199] }
[0200] The above code implements a traceability system that can perform video traceability on the smallest sales unit of vegetables and continuously monitor the traceability query time distribution of each type of vegetables after the current batch is put on the market for retail. The system predicts the number of queries in the next period through a linear fitting function, and determines whether to continue the traceability query based on the actual number of queries. If the actual number of queries is zero, the relevant information in the temporary information database is deleted.
[0201] See also Fig. 9 As shown, in order to sort the traceability priority of different types of vegetables, the sales status or traceability query status of vegetables in the current sales season can be considered and used as the basis for sorting in turn. Specifically, step S331 can be first performed to obtain the current stable consumption date range of each type of vegetable according to the traceability query time distribution of each batch of vegetables after each type of vegetable is put on the market for retail, that is, the listing date range of this type of fruit, so that the sales query status of this type of vegetable can be more reasonably evaluated.
[0202] Next, step S332 can be executed to obtain the mean of the interval time of the first traceability query after each batch of each type of vegetables in the current stable consumption date range according to the traceability query time distribution after each batch of each type of vegetables in the current stable consumption date range is put on the market for retail sale as the traceability urgency coefficient of each type of vegetables in the current stable consumption date range. Finally, step S333 can be executed to arrange the traceability urgency coefficient from small to large to obtain the traceability priority order of each type of vegetables from priority to inferior order.
[0203] See also Fig.10 As shown, the current stable consumption date range can be manually input by the staff in combination with the date when the vegetables are put on the market, and of course it can also be automatically generated in combination with the sales query status. Specifically, step S3311 can be first executed to obtain the number of traceability queries for each type of vegetables after each batch of vegetables has been put on the market for retail sales based on the traceability query time distribution of each type of vegetables after each batch of vegetables has been put on the market for retail sales.
[0204] For each type of vegetable, first, step S3312 can be executed to calculate the standard deviation of the number of traceability queries after each batch of retail sales as the historical average query fluctuation value of each type of vegetable. Next, step S3313 can be executed to calculate in order from the most recent batch whether the standard deviation of the number of traceability queries after multiple batches of retail sales are less than the historical average query fluctuation value. If so, then step S3313 can be continued to calculate. Otherwise, step S3314 can be executed to use the date range of multiple batches of retail sales involved in the calculation as the current stable consumption date range. That is, the current stable consumption date range is continuously tried to be calculated in an iterative manner.
[0205] In order to provide additional explanation for the implementation process of the above-mentioned steps S3311 to S3314, the source code of some functional modules is provided, and a comparative explanation is given in the comment section.
[0206] #include <iostream>
[0207] #include <unordered_map>
[0208] #include <vector>
[0209] #include <string>
[0210] #include <numeric>
[0211] #include <cmath>
[0212] #include <algorithm>
[0213] / / Define the video source information structure
[0214] struct VideoTraceInfo {
[0215] std::string production;
[0216] std::string processing;
[0217] std::string distribution;
[0218] std::string wholesale;
[0219] std::string retail;
[0220] };
[0221] / / Define the traceability system class
[0222] class TraceabilitySystem {
[0223] private:
[0224] / / Store the identification code of each minimum sales unit vegetable and its corresponding video traceability information
[0225] std::unordered_map<std::string, VideoTraceInfo> traceInfoMap;
[0226] / / Store the traceability query time distribution of each type of vegetables after each batch is put on the market for retail sale
[0227] std::unordered_map <std::string, std::vector <int>>queryTimeDistribution;
[0228] / / Calculate the standard deviation
[0229] double calculateStandardDeviation(const std::vector <int>& data)const {
[0230] if (data.empty()) return 0.0;
[0231] double mean = std::accumulate(data.begin(), data.end(), 0.0) / data.size();
[0232] double sq_sum = std::inner_product(data.begin(), data.end(),data.begin(), 0.0);
[0233] return std::sqrt(sq_sum / data.size() - mean * mean);
[0234] }
[0235] / / Get the number of traceability queries for each type of vegetable after each batch was put on the market for retail sale
[0236] std::vector <int>getQueryCounts(const std::string& type) const {
[0237] if (queryTimeDistribution.find(type) ==queryTimeDistribution.end()) return {};
[0238] return queryTimeDistribution.at(type);
[0239] }
[0240] / / Calculate the current stable consumption date range
[0241] std::pair<int, int> getCurrentStableConsumptionRange(const std::string& type) const {
[0242] std::vector <int>queryCounts = getQueryCounts(type);
[0243] if (queryCounts.empty()) return {0, 0};
[0244] / / Calculate the historical average query fluctuation value (standard deviation)
[0245] double historicalStdDev = calculateStandardDeviation(queryCounts);
[0246] / / Calculate the standard deviation of multiple batches in order from near to far
[0247] int start = 0;
[0248] for (int end = 1; end <= queryCounts.size(); ++end) {
[0249] std::vector <int>subRange(queryCounts.begin(),queryCounts.begin() + end);
[0250] double currentStdDev = calculateStandardDeviation(subRange);
[0251] / / If the current standard deviation is greater than the historical average query fluctuation value, return the current range
[0252] if (currentStdDev > historicalStdDev) {
[0253] return {start, end - 1};
[0254] }
[0255] }
[0256] / / If the standard deviation of all batches is less than or equal to the historical average query fluctuation value, return the entire range
[0257] return {start, static_cast <int>(queryCounts.size())};
[0258] }
[0259] public:
[0260] / / Generate a unique identifier for the vegetable and store the video traceability information
[0261] void addVegetable(const std::string& id, const VideoTraceInfo&info) {
[0262] traceInfoMap[id] = info;
[0263] }
[0264] / / Add query time distribution
[0265] void addQueryTimeDistribution(const std::string& type, conststd::vector <int>& times) {
[0266] queryTimeDistribution[type] = times;
[0267] }
[0268] / / Get the traceability priority of each type of vegetable
[0269] std::vector <std::string>getTracePriorityOrder() const {
[0270] / / Store the traceability urgency coefficient for each type of vegetable
[0271] std::vector <std::pair<std::string, double> >urgencyCoefficients;
[0272] for (const auto& pair : queryTimeDistribution) {
[0273] const std::string& type = pair.first;
[0274] const std::vector <int>& times = pair.second;
[0275] / / Get the current stable consumption date range
[0276] auto [start, end] = getCurrentStableConsumptionRange(type);
[0277] / / Calculate the traceability urgency coefficient within the current stable consumption date range
[0278] if (end > start) {
[0279] double coefficient = calculateStandardDeviation(std::vector <int>(times.begin() + start, times.begin() + end));
[0280] urgencyCoefficients.emplace_back(type, coefficient);
[0281] }
[0282] }
[0283] / / Sort in ascending order by traceability urgency
[0284] std::sort(urgencyCoefficients.begin(),urgencyCoefficients.end(), [](const auto& a, const auto& b) {
[0285] return a.second < b.second;
[0286] });
[0287] / / Extract the sorted vegetable types
[0288] std::vector <std::string>priorityOrder;
[0289] for (const auto& pair : urgencyCoefficients) {
[0290] priorityOrder.push_back(pair.first);
[0291] }
[0292] return priorityOrder;
[0293] }
[0294] };
[0295] int main() {
[0296] / / Create a traceability system instance
[0297] TraceabilitySystem system;
[0298] / / Add vegetables and their video traceability information
[0299] system.addVegetable("001", {"Production Video 1", "Processing Video 1", "Circulation Video 1", "Wholesale Video 1", "Retail Video 1"});
[0300] system.addVegetable("002", {"Production Video 2", "Processing Video 2", "Circulation Video 2", "Wholesale Video 2", "Retail Video 2"});
[0301] / / Add query time distribution
[0302] system.addQueryTimeDistribution("Vegetable A", {5, 3, 6, 2, 1});
[0303] system.addQueryTimeDistribution("Vegetable B", {4, 2, 3, 1, 0});
[0304] / / Get and print the traceability priority
[0305] std::vector <std::string>priorityOrder =system.getTracePriorityOrder();
[0306] std::cout << "Tracing precedence: " << std::endl;
[0307] for (const auto& type : priorityOrder) {
[0308] std::cout << type << std::endl;
[0309] }
[0310] return 0;
[0311] }
[0312] The above code implements a vegetable traceability system, which records the traceability query time distribution of each type of vegetable after each batch of retail sales, calculates the current stable consumption date range, and calculates the traceability urgency coefficient based on the standard deviation of the query times, and finally obtains the traceability priority of each type of vegetable. The code implements in detail the whole process of adding vegetable information, adding query time distribution, calculating standard deviation, determining the stable consumption date range, and sorting by urgency coefficient to obtain the traceability priority.
[0313] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the device, system, method and computer program product according to multiple embodiments of the present application. In this regard, each square frame in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of the module, program segment or instruction includes one or more executable instructions for realizing the logical function of the specification. In some alternative implementations, the functions marked in the square frame can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square frames can actually be executed substantially in parallel, and they can also be executed in reverse order sometimes, depending on the functions involved.
[0314] It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart, can be implemented by hardware that performs the corresponding function or action, such as a circuit or ASIC (Application Specific Integrated Circuit), or can be implemented by a combination of hardware and software, such as firmware.
[0315] Although the present invention is described herein in conjunction with various embodiments, in the process of implementing the claimed invention, those skilled in the art may understand and implement other variations of the disclosed embodiments by viewing the drawings, the disclosure, and the appended claims. In the claims, the word "comprising" does not exclude other components or steps, and "a" or "an" does not exclude multiple situations. A single processor or other unit may implement several functions listed in the claims. Certain measures are recorded in different dependent claims, but this does not mean that these measures cannot be combined to produce good results.
[0316] The embodiments of the present application have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes are obvious to those of ordinary skill in the art without departing from the scope of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or improvements to the technology in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.< / std::string> < / std::string> < / int> < / int> < / std::string> < / int> < / int> < / int> < / int> < / int> < / int> < / int> < / algorithm> < / cmath> < / numeric> < / string> < / vector> < / iostream> < / int> < / int> < / int> < / int> < / algorithm> < / cmath> < / numeric> < / string> < / vector> < / iostream>
Claims
1. A visual traceability method for the entire life cycle of vegetables, characterized in that: include, Uniquely identify each minimum sales unit vegetable to obtain an identification code for each minimum sales unit vegetable; Obtain product traceability information of each supply link in the supply chain of vegetables throughout their life cycle, wherein the product traceability information includes circulation traceability information and video traceability information; The identification code of the smallest sales unit vegetable is obtained according to the identification code of the smallest sales unit vegetable and the flow traceability information, and the identification code of the smallest sales unit vegetable corresponds to the video traceability information fragment in each supply link; Get traceability access request; Parsing the traceability access request to obtain the identification code of the smallest sales unit of vegetables to be queried and specifying the supply link to be queried; According to the identification code of the smallest sales unit vegetable to be queried and the identification code of the smallest sales unit vegetable to be traced back to the specified supply link to be queried, the video traceability information of the smallest sales unit vegetable to be queried in the specified supply link to be queried is obtained; Sending the video traceability information of the smallest sales unit of vegetables being queried in the designated supply link being queried to the requesting end of the traceability access request; The step of obtaining the identification code of the smallest sales unit vegetable corresponding to the video traceability information fragment of each supply link according to the identification code of the smallest sales unit vegetable and the flow traceability information includes: Obtain product traceability information for each supply link and store it in the traceability information database; Obtain the traceability query time distribution of each type of vegetables after each batch is put on the market for retail sale; The traceability priority of each type of vegetable is obtained based on the traceability query time distribution after each batch of vegetables is put on the market for retail sale; According to the traceability priority of each type of vegetable, the traceability information database is searched in sequence, and the distribution period of the video traceability information of the minimum sales unit vegetable in each supply link is obtained according to the identification code of the minimum sales unit vegetable and the flow traceability information, and the video traceability information fragment corresponding to the identification code of the minimum sales unit vegetable in each supply link is intercepted and transcoded; The identification code of the intercepted and transcoded minimum sales unit vegetable is stored in a temporary information database corresponding to the video traceability information fragment in each supply link, wherein the temporary information database is searched first when performing a traceability query; The step of obtaining the identification code of the smallest sales unit vegetable corresponding to the video traceability information fragment of each supply link according to the identification code of the smallest sales unit vegetable and the flow traceability information also includes: When the minimum sales unit vegetables enter the retail stage, if the identification code of the queried minimum sales unit vegetables has not been stored in the temporary information database, the traceability information database is directly retrieved to obtain the product traceability information corresponding to the queried minimum sales unit vegetables according to the identification code of the queried minimum sales unit vegetables; According to the circulation traceability information in the product traceability information corresponding to the queried minimum sales unit vegetable, the distribution period of the video traceability information of the queried minimum sales unit vegetable in each supply link is obtained, and the video traceability information fragments of the queried minimum sales unit vegetable in each supply link are obtained by intercepting and transcoding; The identification code of the smallest sales unit of vegetables to be queried corresponds to the video traceability information fragment in each supply link and is stored in a temporary information database; The step of obtaining the traceability priority of each type of vegetables according to the traceability query time distribution after each batch of vegetables was put on the market for retail sale includes: The current stable consumption date range of each type of vegetable is obtained based on the traceability query time distribution after each batch of vegetables is put on the market for retail sale; According to the traceability query time distribution after each batch of each type of vegetables in the current stable consumption date range is put on the market for retail sale, the mean interval time of the first traceability query after each batch of each type of vegetables in the current stable consumption date range is obtained as the traceability urgency coefficient of each type of vegetables in the current stable consumption date range; Arrange the traceability priority of each type of vegetable from the highest to the lowest according to the value of the traceability urgency coefficient; The step of obtaining the current stable consumption date range of each type of vegetables according to the traceability query time distribution after each batch of each type of vegetables is put on the market for retail sale includes: According to the traceability query time distribution of each type of vegetables after each batch of vegetables were put on the market for retail sale, the number of traceability queries of each type of vegetables after each batch of vegetables were put on the market for retail sale was obtained; For each type of vegetable, The standard deviation of the number of traceability queries after each batch of vegetables was put on the market for retail sale was calculated as the historical average query fluctuation value of each type of vegetable. In order from the most recent to the most distant, the standard deviation of the number of traceability queries after multiple batches of retail sales is calculated in sequence, starting from the most recent batch, to see if it is less than the historical average query fluctuation value. If yes, continue the calculation; If not, the date range of the multiple batches of retail sales involved in the calculation will be used as the current stable consumption date range.
2. The method according to claim 1, characterized in that The step of obtaining the video traceability information fragment corresponding to the identification code of the minimum sales unit vegetable in each supply link according to the identification code of the minimum sales unit vegetable and the flow traceability information also includes: Continuously obtain the traceability query time distribution of each type of vegetable after the current batch is put on the market for retail; Determine whether each type of vegetable will no longer be subject to traceability query based on the traceability query time distribution of each type of vegetable after the current batch is put on the market for retail sale; If yes, then delete the information of the identification code of the current batch of vegetables of this type in the temporary information database; If not, keep it.
3. The method according to claim 2, characterized in that The step of judging whether to no longer conduct a traceability query for each type of vegetable based on the traceability query time distribution after the current batch of each type of vegetable is put on the market for retail sale includes: For each vegetable, Continuously obtain the fitting function of the number of traceability queries per unit time period after the current batch is put on the market with respect to the cumulative time after the current batch is put on the market according to the traceability query time distribution of each type of vegetables after the current batch is put on the market for retail; estimating the estimated number of tracing back within the next unit period according to the fitting function; Get the actual number of tracebacks in the next period; Determine whether the actual number of tracing back in the next period is greater than the estimated number of tracing back; If yes, then the vegetable of this type is judged to continue the traceability query; If not, determine whether the actual number of tracing back in the next period is 0; If yes, it is determined that no traceability query is required for this type of vegetable; If not, then determine that the type of vegetable continues to be traced back.
4. A visual traceability method for the entire life cycle of vegetables, characterized in that: include, Bind the identification codes of several minimum sales units of vegetables; Receiving video traceability information of the smallest sales unit vegetable being queried in the specified queried supply link in the method for visual tracing of the entire life cycle of vegetables as described in any one of claims 1 to 3 within the binding scope; Displays the video traceability information of the queried minimum sales unit vegetables within the binding scope in the specified queried supply link.
5. A visual traceability method for the entire life cycle of vegetables, characterized in that: include, Read the identification code of the smallest sales unit of vegetables; Set the specified supply link to be queried; Sending a traceability access request, wherein the traceability access request includes the identification code of the smallest sales unit vegetable to be queried and specifies the supply link to be queried; Receiving video traceability information of the smallest sales unit vegetable being queried in the designated supply link being queried in the method for visual tracing of the entire life cycle of vegetables as described in any one of claims 1 to 3; Displays the video traceability information of the smallest sales unit of vegetables being queried in the specified supply link being queried.
6. A visual traceability system for the entire life cycle of vegetables, characterized in that: Including, a traceability control unit and a storage unit; Wherein, the traceability control unit is used to uniquely identify each minimum sales unit vegetable to obtain an identification code for each minimum sales unit vegetable; Obtain product traceability information of each supply link in the supply chain of vegetables throughout their life cycle, wherein the product traceability information includes circulation traceability information and video traceability information; The identification code of the smallest sales unit vegetable is obtained according to the identification code of the smallest sales unit vegetable and the flow traceability information, and the identification code of the smallest sales unit vegetable corresponds to the video traceability information fragment in each supply link; Get traceability access request; Parsing the traceability access request to obtain the identification code of the smallest sales unit of vegetables to be queried and specifying the supply link to be queried; According to the identification code of the smallest sales unit vegetable to be queried and the identification code of the smallest sales unit vegetable to be traced back to the specified supply link to be queried, the video traceability information of the smallest sales unit vegetable to be queried in the specified supply link to be queried is obtained; Sending the video traceability information of the smallest sales unit of vegetables being queried in the designated supply link being queried to the requesting end of the traceability access request; The storage unit is used to store all product traceability information; The step of obtaining the identification code of the smallest sales unit vegetable corresponding to the video traceability information fragment of each supply link according to the identification code of the smallest sales unit vegetable and the flow traceability information includes: Obtain product traceability information for each supply link and store it in the traceability information database; Obtain the traceability query time distribution of each type of vegetables after each batch is put on the market for retail sale; The traceability priority of each type of vegetable is obtained based on the traceability query time distribution after each batch of vegetables is put on the market for retail sale; According to the traceability priority of each type of vegetable, the traceability information database is searched in sequence, and the distribution period of the video traceability information of the minimum sales unit vegetable in each supply link is obtained according to the identification code of the minimum sales unit vegetable and the flow traceability information, and the video traceability information fragment corresponding to the identification code of the minimum sales unit vegetable in each supply link is intercepted and transcoded; The identification code of the intercepted and transcoded minimum sales unit vegetable is stored in a temporary information database corresponding to the video traceability information fragment in each supply link, wherein the temporary information database is searched first when performing a traceability query; The step of obtaining the identification code of the smallest sales unit vegetable corresponding to the video traceability information fragment of each supply link according to the identification code of the smallest sales unit vegetable and the flow traceability information also includes: When the minimum sales unit vegetables enter the retail stage, if the identification code of the queried minimum sales unit vegetables has not been stored in the temporary information database, the traceability information database is directly retrieved to obtain the product traceability information corresponding to the queried minimum sales unit vegetables according to the identification code of the queried minimum sales unit vegetables; According to the circulation traceability information in the product traceability information corresponding to the queried minimum sales unit vegetable, the distribution period of the video traceability information of the queried minimum sales unit vegetable in each supply link is obtained, and the video traceability information fragments of the queried minimum sales unit vegetable in each supply link are obtained by intercepting and transcoding; The identification code of the smallest sales unit of vegetables to be queried corresponds to the video traceability information fragment in each supply link and is stored in a temporary information database; The step of obtaining the traceability priority of each type of vegetables according to the traceability query time distribution after each batch of vegetables was put on the market for retail sale includes: The current stable consumption date range of each type of vegetable is obtained based on the traceability query time distribution after each batch of vegetables is put on the market for retail sale; According to the traceability query time distribution after each batch of each type of vegetables in the current stable consumption date range is put on the market for retail sale, the mean interval time of the first traceability query after each batch of each type of vegetables in the current stable consumption date range is obtained as the traceability urgency coefficient of each type of vegetables in the current stable consumption date range; Arrange the traceability priority of each type of vegetable from the highest to the lowest according to the value of the traceability urgency coefficient; The step of obtaining the current stable consumption date range of each type of vegetables according to the traceability query time distribution after each batch of each type of vegetables is put on the market for retail sale includes: According to the traceability query time distribution of each type of vegetables after each batch of vegetables were put on the market for retail sale, the number of traceability queries of each type of vegetables after each batch of vegetables were put on the market for retail sale was obtained; For each type of vegetable, The standard deviation of the number of traceability queries after each batch of vegetables was put on the market for retail sale was calculated as the historical average query fluctuation value of each type of vegetable. In order from the most recent to the most distant, the standard deviation of the number of traceability queries after multiple batches of retail sales is calculated in sequence, starting from the most recent batch, to see if it is less than the historical average query fluctuation value. If yes, continue the calculation; If not, the date range of the multiple batches of retail sales involved in the calculation will be used as the current stable consumption date range.
