Explorar el Código

crontab: estrus 更新发情ispeak字段

Yi hace 1 mes
padre
commit
6d8963db67
Se han modificado 1 ficheros con 3 adiciones y 5 borrados
  1. 3 5
      module/crontab/estrus_warning.go

+ 3 - 5
module/crontab/estrus_warning.go

@@ -92,11 +92,9 @@ func (e *Entry) UpdateNeckRingWarningIsPeak(pastureId, minId int64) {
 		zaplog.Error("UpdateNeckRingWarningIsPeak", zap.Any("err", err))
 	}
 
-	if err := e.DB.Table(fmt.Sprintf("%s as b", new(model.NeckRingEstrus).TableName())).
-		Joins(fmt.Sprintf("JOIN %s as a on b.neck_ring_estrus_id = a.id", new(model.NeckRingEstrusWarning).TableName())).
-		Where("b.pasture_id = ?", pastureId).
-		Where("a.is_peak = ?", pasturePb.IsShow_Ok).
-		Update("is_peak", pasturePb.IsShow_Ok).Error; err != nil {
+	// UPDATE v_v_hact v JOIN estrusact e ON v.inteaid=e.inteaid SET e.isPeak=1 WHERE v.isPeak=1;
+	if err := e.DB.Raw(`UPDATE neck_ring_estrus_warning v JOIN neck_ring_estrus e ON v.neck_ring_estrus_id = e.id SET e.is_peak = ? WHERE v.is_peak = ?`,
+		pasturePb.IsShow_Ok, pasturePb.IsShow_Ok).Error; err != nil {
 		zaplog.Error("UpdateNeckRingWarningIsPeak", zap.Any("err", err))
 	}
 }