《1 Introduction》

1 Introduction

In recent years, with economic growth and improvements in living standards, the public has demanded better quality and safety of agricultural products. Moreover, people consuming agricultural products such as grains, vegetables, and meat expect to have access to source information about the products, such as planting or feeding processes, including the types and dosages of fertilizers, pesticides, and feedstuff. This demand is partly because of modern consumers’ concerns involving food safety and also because consumers are better informed about the nutritional value of crops. Therefore, the construction of a quality safety traceability system for agricultural products is helpful in not only improving the integrity, awareness, and production management level of production enterprises, but also building a long-term mechanism for the quality and safety management of agricultural products. Traceability could be an important step in the implementation of responsibility management. In fact, many countries and regions have conducted research related to agricultural product traceability and its applications. For example, legal requirements for the traceability of agricultural products and food quality, such as the stipulations of Act No. 178/2002 in the European Union, the Food Safety Modernization Act in the US [1], the Food Traceability System in Japan [2], and Branding Canada for the Food and Agriculture Sector in Canada [3], have achieved good results in the research and application of agricultural product quality and safety traceability.

American scholars have proposed that a food traceability system has three dimensions—breadth, depth, and precision [4]. Breadth refers to the amount of traceable information; depth refers to the process areas traced in the production process of agricultural products; and accuracy refers to the accuracy of the traceable information. Among the existing quality and safety tracing systems for agricultural products, most have considered extensively the breadth and depth of agricultural products but have focused less on accuracy. This is mainly because the current systems are often designed for different scales, equipment, and farming methods in different enterprises or regions. The breadth and depth can be easily abstracted and quantified from the needs of producers and consumers. However, the scales of enterprises or regions, equipment, and work methods show variations, and it is difficult to define the accuracy of the traceability of agricultural products. Differing from the grid technology used in computing, the grid of spatial data in geographic information technology divides the space of the study area into grid squares of a size required by the research scale. This method is convenient for spatial analysis and processing [5,6]. It is also an important approach in geographic information technology and spatial analysis research. In the crop production process, irrigation, fertilization, picking, and harvesting are often carried out at different sites. Therefore, the grid theory of spatial data can be applied to the traceability system of crops to partition the agricultural production sites into many grid squares. The size of the square represents the scale of the traceability system, and the use of this arrangement can effectively solve the problem of the accuracy of crop traceability.

China began to build quality and safety traceability systems for agricultural products in 2002, and this has had a great impact on promoting the development of its modern industrial agriculture system. Furthermore, the existing systems have a predictable and practical significance of promoting international competitiveness for agricultural products from China. Many scholars have conducted research and have developed agricultural product traceability systems using computer technology and the Internet of Things (IoT). Examples include the vegetable safety production management and quality safety traceability system developed by Yang Xinting et al. [7]; the vegetable quality and safety traceability system in Suzhou developed by Zhang Qiang et al. [8]; and the quality and safety traceability system based on the agricultural product supply chain developed by Dong Yude et al. [9]. With Internet technology and traceability code technology, the traceability of agricultural product quality and safety on desktop and mobile platforms has been realized and can effectively regulate the production management of enterprises, increase the value of products, and achieve sizable economic and societal benefits. In combination with the latest mobile Internet technology, the application of spatial data gridding theory can continue to improve the convenience and intelligence of information collection, improve the depth and precision of agricultural product quality and safety traceability systems, and make the traceable unit flexible.

Based on the use of Internet technology, IoT technology, and geographic information technology, along with multisource data, such as images from resource satellites, ground sensor data, and on-site data collection, this study used the method of spatial data gridding, taking the production and sales of wolfberry in Zhong Ning County as an example. Further, it developed a set of quality safety traceability systems for the entire process from production through harvesting, sorting, packaging, and sales.

《2 Design of the overall framework》

2 Design of the overall framework

Taking wolfberry as an example, this study not only performs business logic abstraction for the agricultural product quality and safety traceability process, but also refines the core business needs. As a result, the user group is divided into three roles, namely—manager, producer, and consumer. The business process is divided into five main parts: production, harvesting, sorting, packaging, and sales.

The system can be divided into three types of clients and a cloud server. Specifically, the clients are the manager, producer, and consumer. First, the manager client provides an early warning threshold setting and manages the monitoring information for the field management department. Second, the producer client provides functions, such as pushing warning information and performing information collection for on-site workers, such as technicians and planters. Finally, the consumer client provides information such as tracking and browsing information using quick-response (QR) codes for consumers who purchase agricultural products. The main structure and functions of the cloud server and each client are as follows:

(1) The cloud server. The cloud server function is built using the Aliyun elastic computing service. The main business logic code is programmed in C# language. An SQL server database is used to ensure data persistence. The interaction between the cloud and the clients is achieved in two ways. First, client authentication, data collection/reception, news information, and other main functions use an Internet information services (IIS) web application server to provide a RESTful API, which interacts with the clients under the HTTP/HTTPS protocol. Second, an MPush module provides a real-time message push function between the cloud and clients, relaying any early warning information received from sensors and resource satellites.

(2) The manager client. The manager client uses crop calendars as the standard reference to monitor the growth environment and status of crops. It is used to monitor and control the quality of the agricultural products with weather and growth data, as well as that obtained from sensors. In addition, managers can use it to adjust the threshold for early warnings. For the convenience of the administrators, the manager client is designed using a .Net-Framework-based application that functions on the Windows operating system, which can run on any personal computer (PC). Its main functions include configuration of the interpolation service, QR code service, IoT early warning service, weather warning service, resource remote sensing warning service, and statistical analysis of crop growth parameters.

(3) The producer client. The producer client is a set of mobile applications that can be installed on Android or iOS devices. A lightweight user interface has been designed for managers, technicians, and workers. This interface includes not only a real-time monitoring function for crop farming, but also an information collection function for environmental variables and data related to growth, picking, and harvesting of crops. Generally, producers include technicians, workers, and others whose work processes are more complex and require working in the field for extended periods. When in the field, the application software installed on the mobile phone can improve the convenience of on-site work and information collection [10]. Therefore, the producer client has been developed as both an Android application and an iOS application. The Android application is implemented using Java in the Android Studio integrated development environment. It uses the SQLite lightweight database, along with the object relationship mapping module GreenDao for data persistence. The iOS application is implemented using Objective-C in the XCode integrated development environment. It uses the SQLite lightweight database with the CoreData object relationship mapping module for data persistence. The main functions of the producer client include garden management, and collection of information relating to local environment, field working, product sorting, product rating, and product packaging, among others.

(4) The consumer client. The consumer client is built on the WeChat Public Platform. The client uses the scanning function of WeChat to identify the QR code attached to the product package; this function can be used to link the production history of the products. After scanning the QR code, a request is sent to the cloud server. Specifically, the query request is submitted to the server by using the “post parameter” of HTTP to send the QR code information across. Then, the information pages are made available to the consumer. For this function, the user interface for the pages in the consumer client is designed as an HTML page. The pages include the origin information of the agricultural products, growth environment information, growth photos, rating information, sorting information, and packaging information.

The overall framework design of the agricultural product quality and safety traceability system based on grid management is illustrated in Fig. 1.

《Fig. 1》

Fig. 1  Overall framework design of agricultural product traceability system.

 

《3 Design of functions and modules》

3 Design of functions and modules

The agricultural product quality and safety traceability system based on grid management mainly includes the garden planning and design function, the information collection function, the monitoring and early warning function, and the agricultural product tracing function. The design of the functional modules is shown in Fig. 2.

《Fig. 2》

Fig. 2 Design of functional modules for agricultural product quality and safety traceability system.

 

《3.1 Garden planning and design function》

3.1 Garden planning and design function

The garden planning and design function mainly uses the gridding method to divide the garden into uniform grid squares for the design and planning of the spatial distribution and functional layout of the garden. The garden layout must be designed with due consideration of actual conditions, such as the deployment of irrigation equipment. First, the producer must use the producer client to input the basic information about the garden, such as the name of the garden, the person in charge, and the type of garden. Second, the user must draw the border of the garden on the electronic map and choose the size of the grids into which to the garden is to be divided. Finally, the garden is divided into squares by the system automatically, as shown in Fig. 3(a). The garden grid information is stored in the databases on the cloud server. Therefore, the functions in the system, such as early warning and product tracing, can regard the grid squares of the garden as the basic units of management.

《Fig. 3》

Fig. 3  Main user interfaces of the agricultural product quality and safety traceability system.

 

《3.2 Information collection function》

3.2 Information collection function

The information collection function refers to the information collection of the entire process related to the production of agricultural products from the producer client. In grid technology, every piece of collected information is associated with a garden square, as shown in Fig. 3(b). In the process of system design, the producer client needs to be realized with the unified management of information on the three controls (production environment, production process, and product quality control) of agricultural products. The system integrates the three-control information into the entire process of agricultural production, as shown in Fig. 4. First, the production environment control function is realized by the new garden information management system and by collection of information regarding the background environment. Second, the production process control function is realized by the collection of pest and disease information, seedling information, fertilization and water application information, and phenology. Finally, the product quality control function is realized by the collection of product sorting, product rating, and product packaging information.

《Fig. 4》

Fig. 4 “Three-control” information management in the producer client of the agricultural products traceability system.

 

《3.3 Monitoring and early warning function》

3.3 Monitoring and early warning function

The monitoring and early warning function uses multisource data, such as satellite remote-sensing images, meteorological data, and on-site sensor data to monitor the growth environment and crop growth. When certain indexes exceed a custom threshold, the system pushes the information to the manager clients and producer clients to achieve the early-warning functionality.

The resource remote-sensing monitoring and early-warning function uses the data from remote-sensing satellites (e.g., the Terra Aqua and Landsat-series satellites) to retrieve vegetation indicators, such as the net primary productivity (NPP), normalized vegetation index (NDVI), and enhanced vegetation index (EVI) to monitor vegetation information. Additionally, the system can use these indicators to determine vegetation growth and identify pest and disease events, and to apply time-series analysis, ring-to-cycle analysis, or other crop diagnostic model methods. When the NPP or NDVI value exceeds a certain threshold, the system judges that there is poor growth of crops and pushes the information to the manager and producer clients for further processing by the decision makers concerned. The monitoring and early-warning function of the meteorological information uses weather data, such as temperature and precipitation, which is released in real time by the meteorological department. This function can push timely weather warnings and crop growth information. The system monitors whether the precipitation and current or future temperatures are higher or lower than a certain threshold. Thus, early warning information, such as high temperature, low temperature, flood, or drought warnings, is sent to the manager and producer clients.

The sensor monitoring and early warning function not only interpolates data regarding soil temperature, humidity, wind, wind direction, and carbon dioxide concentration obtained by on-site sensors, but also forms the data grid of the garden, as shown in Fig. 3(c). When the data for some regions are abnormal, that is, contain values higher or lower than a specific threshold, the related warning is sent to the manager and producer clients.

《3.4 Agricultural product tracing function 》

3.4 Agricultural product tracing function

The agricultural product tracing function uses a product identification code to help consumers acquire historical information regarding the product’s growth, grading, packaging, and so on by using a QR code as the carrier. In addition, the function includes the following submodules: product identification code distribution, QR code generation, QR code scanning, and product tracing.

The product identification code distribution and the QR code generation submodule can generate identification codes associated with the crop growth information based on a coding rule. Those identification codes are generated at the time of harvesting and sorting of agricultural products and are associated with the rating and sorting information at the time of harvesting. As a result, the agricultural products carry those identification codes during the subsequent rating and packaging processes. Therefore, when a consumer purchases an agricultural product, the QR code which contains the identification code is associated with information regarding the entire production process of the product.

QR code scanning and the product traceability module can provide information regarding the entire production process for the product through the QR code. The harvest, sorting, rating, and packaging data for agricultural products are directly related to the identification code in the QR code. Moreover, the growth information of the product is related to the garden squares. Specifically, the system uses the identification code in the QR code to query the related squares—the product source—of the products and then uses these squares to request the seedling, phenology, fertilization, water application, disease, insect, and pest information related to the product, as shown in Fig. 3(d).

《4 System development and implementation》

4 System development and implementation

《4.1 Runtime environment》

4.1 Runtime environment

The runtime environments of the cloud server, manager client, producer client, and consumer client are as follows:

(1) The cloud environment. The minimum hardware configuration for the cloud is 2 GB RAM; the minimum Internet bandwidth required is 2 Mbps. The Windows operating system is required for the cloud end. The SQL Server 2008 database server and an IIS Web server are required to support the services.

(2) The manager client environment. The minimum hardware configuration for the manager is 1 GB of running memory and more than 500 MB of available hard disk space. The Windows operating system and .Net Framework 4.5 support are required to run the application.

(3) The producer client environment. There are two different applications on different platforms. The Android client requires a mobile phone or tablet running Android version 4.0 or above, as well as GPS and camera capabilities; a minimum of 512 MB of running memory and 1 GB of storage space should be available. The iOS client requires an iPhone or iPad device running iOS 8.0 or above, and a minimum of 1 GB of storage space is necessary.

(4) Consumer environment. A smartphone or tablet with a camera that can connect to the Internet is required. In addition, an application that can scan and recognize QR codes, such as WeChat, QQ, or Alipay, is required.

《4.2 Implementation of key techniques》

4.2 Implementation of key techniques

4.2.1 Location and map display

The positioning function of the system is based on the GPS module of mobile devices receiving GPS and GLONASS satellite signals. Moreover, the system combines the base station information with A-GPS positioning technology to increase positioning accuracy. In the Android and iOS systems, mobile devices can obtain geographic coordinates from the WGS-84 geographic coordinate system from the A-GPS positioning. Then, the geographic coordinates and location information are displayed by the OpenLayers module, which is an open source framework with a user interface for digital maps. The OpenLayers module must run on a web browser and is based on JavaScript and CSS. Furthermore, it contains a variety of classes used to manipulate maps, layers, data sources, and styles. The ol.layer.Image class and the ol.layer.Tile class can represent the grid layer. The ol.layer.Vector class represents the vector layer. Additionally, the objects of the classes can be inserted into the layer of the ol.Map class to control the layer. For the drawing function, the ol.interaction.Draw class is used to render the garden. However, the system must implement the interaction between map controls and local code, because of the different characteristics of different operating systems. This is because OpenLayers can only run on a browser. For iOS clients, the system uses an open source tool named Web View JavaScript Bridge for the interactive function of the Objective-C and JavaScript codes that run on the UIWebView control. For the Android client, the JavaScript Interface tool is used to allow interactions between Java codes and JavaScript codes running on Web View control.

4.2.2 Data gridding

Data gridding divides the managed garden into regular-sized squares, according to specific requirements. The data from different sources, such as a satellite remote sensing grid and sensor interpolation data, are used to match grids to achieve sky-ground linkage, high-precision monitoring, and management of the garden.

The grid generation technology is as follows. First, the northwest point coordinates of the envelope rectangle of the garden vector polygon must be found. Second, the system generates a series of data squares that can completely cover the envelope rectangle according to the custom grid density. Then, square by square, the system determines whether a square intersects with the polygon of the garden. Irrelevant squares—those that do not cover any part of the garden—are removed. Finally, the remaining data squares completely cover the garden, representing the smallest subset of the grid.

Some data, such as remote sensing satellite images and sensor interpolation data need to match with the garden grid described earlier. For sensor interpolation data, the sensors in different geographic locations form a cluster of sensors. Moreover, there is a unified data interface designed to connect with the cloud system. The cloud system can be interpolated by several methods, such as nearest-neighbor, bilinear, and three-convolution interpolation, which can be used to mesh the data transmitted by the cluster. For resource satellite remote sensing data, the system uses MODIS and Landsat series satellite data to retrieve indicators, such as NDVI and NPP, which are grid data. Then, the squares of each garden can be matched with a value through data resampling. Specifically, the spatial analysis methods, such as interpolation and resampling, are implemented by the Geospatial Data Abstraction Library (GDAL), which is an open source library. The system encapsulates these methods into a dynamic link library using C++. When the cloud system receives new image data from satellites, it automatically identifies the data type, along with its metadata, and calls the relevant dynamic link library for grid information.

4.2.3 Early warning service and push technology

Early warning service and push technology refer to the real-time pushing of early warning information from the server to the clients. This consists of mainly two activities: early warning information generation, and message pushing.

For early warning information generation, the system refers to the multisource data collected from ground sensors, resource satellites, etc. The warning information is generated according to a custom threshold set by the manager. The data sources for early warning information are of two types: on-site sensors, and resource satellite remote sensors. For on-site sensors, various sensors that operate with different types of data are connected to the server through ZigBee low-power communication technology, and data are sent to the early warning service module at specified time intervals. The resource satellite downloads remote sensing data using an API provided by the National Aeronautics and Space Administration (NASA) on the Internet for image data, such as MODIS data. Then, the data preprocessing functions, such as geometric correction, radiometric correction, splicing and cutting through the GDAL open source library, and calculation of remote sensing indexes like NDVI, are transferred to the early warning service module. Next, the early warning service module includes the threshold parameters of the environmental variables and normal growth states and stages of crops such as wolfberry. The thresholds are categorized as reminder, warning, and critical warning thresholds. For example, the early warning service module sets the threshold of temperature, precipitation, and NDVI for the growth period of wolfberry in the seedling, budding, pruning, flowering, and fructification stages. When some state indicators of wolfberry exceed a certain threshold at a particular stage of the growth process, the early warning module will send early warning information to the push module. In addition, to avoid multiple pushes, the user can set the frequency of the alarms and can also ignore some early warning information based on the actual situation; this is because some indexes may continue generating alarm information for a fixed period after the critical threshold is crossed.

As for the message push technology, the client uses the Internet to push warning information to the system. To ensure the real-time performance of the warning information push, the system uses the transmission control protocol (TCP) to keep the server and the client connected for a long time. Owing to system limitations, it is necessary to utilize the Apple push service for iOS devices. In contrast, the producer client with Android devices uses the open source push module, called MPush, to push information. If the connection between the cloud and the producer is interrupted, the system promptly tries to reconnect with the server using the “heartbeat” mechanism even as it prompts the user. In the above manner, the online state of the client can always be maintained so that the warning information generated by the cloud can be pushed in a timely and effective manner.

4.2.4 QR code association and tracing

The association and traceability of QR codes is an important part of the system for tracing the entire process of an agricultural product. Traceable agricultural products are accompanied by a product identification code, which is coded using certain rules and printed using a Bluetooth printer. When the consumer scans the QR code, the system needs to extract the full process production information of the agricultural product in a certain way. In the above process, an encoding method, Bluetooth printing technology, and scanning code traceability technology are used.

(1) The coding method for the identification code. The coding principle of the system is to match all relevant database information with a smaller encoding length and to ensure the uniqueness of the coding. The background, growth, and sorting information of the system need to be coded, and the identification codes for the agricultural products need to generate a QR code that can be attached to the agricultural products. Therefore, this block of code contains the largest amount of information and is the most important. Taking wolfberry as an example, after product sorting, the characteristic of the product has been fixed; hence, the identification code for the agricultural product is generated. In addition, the information related to grading and packing after sorting is also attached to the identification code of the agricultural product. The agricultural product identification code is designed in such a way that it has a total of 15 digits, which represent the sorting time, operator number, and sorting number, as shown in Fig. 5. The sorting time is expressed in the form of two digits for the year and three digits for the Julian day. The operator number is expressed by a seven-digit number. The sorting number is a three-digit number starting from 001. Thus, the first two digits refer to the production year; and the next three digits refer to the Julian day of the production year. The seven digits in the second segment refer to the operator, and the final three digits refer to the sequential sorting number, which begins with 001.

《Fig. 5》

Fig. 5  Encoding rules for the agricultural product identification code.

 

(2) Bluetooth printing technology. Because the QR code of the system needs to be printed when sorting, it is necessary to use a printer suitable for outdoor work. Fortunately, the Bluetooth printer is compact and easy to carry, and it can connect with Android and iOS mobile terminals to print quickly in real time in the field. The specific process is as follows. First, the system uses the ESC instruction set designated by the American Epson Co., Ltd. to perform the data transmission and printer control. Second, the binary code is transmitted to the printer via Bluetooth. Finally, the QR code images generated by the mobile phone can be transmitted to the printer for output.

(3) Scanning code traceability technology. When the consumer scans the QR code, the system first queries the sorting, rating, packaging, and other information of the product; the sorting information includes the grid square numbers where the crop was picked. The grid square numbers can be used to query various types of information about the growth environment and crop calendar.

《4.3 Demonstration of application》

4.3 Demonstration of application

In this study, the quality safety traceability system of agricultural products was debugged and deployed on many servers, including an Aliyun server, and many mobile devices, such as a Meizu MX6, an iPhone, and an iPad. In 2017, in cooperation with Ningxia Geodetic Co., Limited, a wolfberry garden was applied and demonstrated in the Zhong Ning County of Zhong Wei City, situated in the Ningxia Hui Autonomous Region of China. The area is located on the banks of the Yellow River and is the transitional zone between the Inner Mongolia plateau and the Loess plateau. Additionally, it lies in the northern temperate continental monsoon climate zone. As a result, the diurnal temperature range is large. Its unique geographical and climatic conditions ensure that the region’s wolfberry is of superior quality and enjoys large sales volumes. Therefore, it is of great significance to demonstrate the effectiveness of the quality and safety traceability system for the wolfberry garden in Zhong Ning County.

During the process of demonstration and application in 2017, the application of the system covered the entire production and sales process of wolfberry, from cultivation to the seedling stage, followed by sprouting, irrigation, pruning, weeding, sorting, rating, packaging, and sales, and finally, on-site inspection clearance and project acceptance. The demonstration application verified that the system could meet the basic needs of managers, producers, and consumers, as well as make new breakthroughs in the information and intelligence related to agricultural production. To a certain extent, it ensures the quality and safety of wolfberry, and it has good application and demonstration value.

《5 Conclusions and prospects》

5 Conclusions and prospects

Based on technologies such as the Internet, IoT, and geographic information technology combined with multisource data such as resource satellite images, data from ground sensors, and information collected from workers in the field, this study used the method of spatial data gridding, utilizing the production and sales of wolfberry in the Zhong Ning County as an example, to develop a set of quality safety traceability systems for the entire process from production to harvest, sorting, packaging, and sales. The system was implemented using a wolfberry garden in the Ningxia Hui Autonomous Region of China to verify its feasibility and effectiveness. The main conclusions are as follows:

(1) A grid management function for agricultural products with different square sizes and product traceability was developed. As a result, the precision of product traceability can be changed with the grid scale. Thus, a food traceability system that includes three dimensions—breadth, depth, and accuracy—has been established.

(2) The software combines multisource data, such as satellite remote sensing data, meteorological data, on-site sensors, and “three-control” information data recorded by the producer; this effectively traces the entire process of production, harvest, sorting, packaging, and sale of agricultural products.

(3) Using multisource satellite remote sensing data, meteorological data, and field sensor data, the system enables an early-warning push function with customizable early warning thresholds. The tests showed that this feature helps managers and producers to monitor and warns of problems in the growth environment, as well as in the growth of agricultural products in real time, and can improve the production quality and efficiency of agricultural products.

Although the traceability system based on gridding management has the advantages mentioned above, there remain various problems in the current system that require attention. For instance, the system business process and the collection of information on the three controls and coding system focus on only one cash crop—wolfberry. In the future, we need to study and establish unified national guidelines for more crops, such as grains and vegetables, and even for information related to the quality and safety of other agricultural products, such as livestock and aquatic products. Additionally, the monitoring and early warning function uses only resource satellite remote sensing and IoT data to monitor and warn about crop growth. Future monitoring, analysis, and early warning at the level of largescale regions such as counties, cities, provinces, and even states can further strengthen the producer’s comprehensive understanding of the whole market, thereby enabling a more scientific and purposeful adjustment to the production and sale of agricultural products.