**Background:** The integration of Internet of Things (IoT) technology with dairy farm management offers potential for data-driven decision-making. However, most dairy farms lack systems that effectively integrate diverse data streams (e.g., RFID, TMR feeding, environmental sensors, DHI records) to improve production efficiency, reduce environmental impact, and enable disease prediction. This study aimed to develop a Smart Dairy Farm System (SDFS) and demonstrate its utility through two applications: nutritional grouping for improved performance and reduced greenhouse gas (GHG) emissions, and mastitis risk prediction using DHI data.
**Methods:** A dairy farm in the Beijing area with 2500 cows (1256 lactating) was equipped with an intelligent sensor network including RFID ear tags, weighing systems, TMR precision feeding, UAV photography, and environmental sensors (temperature, humidity, wind speed, CH4, CO2). Data were transmitted to the SDFS database for analysis. For nutritional grouping, 270 lactating cows were divided into 9 pens via cluster analysis (using hclust in R) based on parity, days in milk, DMI, metabolic protein (MP), and metabolizable energy (ME). The control group (OG) consisted of 9 pens of 30 cows each grouped by lactation stage. Diets were formulated using NDS software (CNCPS 6.55). Methane and carbon dioxide emissions were estimated by the CNCPS system. For mastitis prediction, 2555 DHI records from January 2019 to December 2021 were used. Somatic cell count (SCC) was transformed to somatic cell score (SCS). Cows with SCC ≤ 200,000/mL were classified as healthy; SCC > 200,000/mL as mastitis risk. Logistic regression with bidirectional elimination stepwise regression was applied to a 70% training set, using parity, DIM, and milk indicators from the previous 4 lactation months as independent variables. Model performance was assessed on a 30% validation set using ROC curve analysis.
**Key Results:** Nutritional grouping significantly increased milk production across nearly all parity and lactation stage groups (p < 0.05), with the exception of mid-lactation second-parity cows (p = 0.165). For example, first-parity early-lactation cows produced 39.28 ± 2.90 kg/d (NG) vs. 37.45 ± 3.45 kg/d (OG) (p = 0.031). N efficiency increased by an average of 1.98% across groups, with N production significantly higher in NG (p < 0.001 for most groups). Methane emissions were reduced by 0.14% to 1.24% across pens, and CO2 emissions by 0.15% to 1.25%. For mastitis prediction, significant risk factors included milk yield in the second lactation month (OR = 1.15, p = 0.031), fat percentage in the first (OR = 6.72, p = 0.036) and third (OR = 3.32, p = 0.003) lactation months, lactose percentage in the fourth lactation month (OR = 0.02, p < 0.001), fat/protein ratio in the third lactation month (OR = 0.08, p = 0.043), and natural month in the fifth lactation month (OR = 1.15, p = 0.021). The model achieved an AUC of 0.773, accuracy of 89.9%, specificity of 70.2%, and sensitivity of 76.3%.
**Clinical Implications:** The SDFS demonstrates that precision nutritional grouping based on individual cow requirements can simultaneously improve milk production and reduce GHG emissions, addressing both economic and environmental goals in dairy farming. The mastitis prediction model, using routinely collected DHI data, can identify cows at risk of mastitis up to two months in advance, enabling targeted preventive measures and reducing economic losses (mastitis accounts for 38% of direct costs of common production diseases). The study highlights the value of integrating multiple data streams within a single platform for data-driven farm management. Limitations include the use of predicted (not directly measured) GHG emissions, the exclusion of factors like bedding hygiene and udder conformation from the mastitis model, and the farm-specific nature of the prediction equation, which may limit generalizability. Future work should focus on incorporating additional variables and developing self-updating models.