Browse Source

crontab: estrus update

ping 1 month ago
parent
commit
18f9b8ca04
1 changed files with 4 additions and 4 deletions
  1. 4 4
      module/crontab/sql.go

+ 4 - 4
module/crontab/sql.go

@@ -66,12 +66,12 @@ func (e *Entry) GetBeforeThreeDaysCowEstrus(cowId int64, activeTime string) *mod
 // GetTwoEstrus 判断最近50天内是否存在发情记录(发情等级>=2),如果18~25天@xadjust21,如果36~50天@xadjust42
 func (e *Entry) GetTwoEstrus(pastureId, cowId int64, startActiveTime, endActiveTime string) *CowEstrus {
 	newCowEstrus := &CowEstrus{}
-	if err := e.DB.Model(new(model.EventEstrus)).
-		Select("cow_id,MAX(active_date) as active_date").
+	if err := e.DB.Model(new(model.NeckRingEstrus)).
+		Select("cow_id,MAX(active_time) as active_date").
 		Where("cow_id = ?", cowId).
 		Where("pasture_id = ?", pastureId).
-		Where("active_date BETWEEN ? AND ?", startActiveTime, endActiveTime).
-		Where("level >= ?", pasturePb.EstrusLevel_Middle).
+		Where("active_time BETWEEN ? AND ?", startActiveTime, endActiveTime).
+		Where("active_level >= ?", pasturePb.EstrusLevel_Middle).
 		First(newCowEstrus).Error; err != nil {
 		return newCowEstrus
 	}