|
@@ -93,7 +93,7 @@ func (e *Entry) FirstFilterUpdate(pastureId int64, xToDay *XToday) (processIds [
|
|
|
}
|
|
|
newNeckActiveHabitList := make([]*model.NeckActiveHabit, 0)
|
|
|
if err = e.DB.Model(new(model.NeckActiveHabit)).
|
|
|
- Where("heat_date >= ?", time.Now().AddDate(0, 0, -1).Format(model.LayoutDate2)).
|
|
|
+ Where("heat_date >= ?", time.Now().AddDate(0, 0, -7).Format(model.LayoutDate2)).
|
|
|
Where("pasture_id = ?", pastureId).
|
|
|
Where("is_show = ?", pasturePb.IsShow_No).
|
|
|
Where(e.DB.Where("high >= ?", xToDay.High).Or("rumina >= ?", xToDay.Rumina)).
|
|
@@ -242,6 +242,9 @@ func (e *Entry) SecondUpdateChangeFilter(pastureId int64, processIds []int64, xT
|
|
|
discount *= 0.5
|
|
|
}
|
|
|
ruminaFilter = float64(secondFilterData.RuminaFilter)*(1-discount) + float64(v.ChangeRumina)*discount
|
|
|
+ if ruminaFilter > 50 {
|
|
|
+ ruminaFilter = 50
|
|
|
+ }
|
|
|
|
|
|
chewFilter := float64(v.ChewFilter)
|
|
|
chewFilterDiscount := float64(1)
|
|
@@ -249,13 +252,16 @@ func (e *Entry) SecondUpdateChangeFilter(pastureId int64, processIds []int64, xT
|
|
|
chewFilterDiscount = 0.5
|
|
|
}
|
|
|
chewFilter = float64(secondFilterData.ChewFilter)*(1-xRuminaDisc*chewFilterDiscount) + float64(v.ChangeChew)*xRuminaDisc*chewFilterDiscount
|
|
|
+ if chewFilter > 50 {
|
|
|
+ chewFilter = 50
|
|
|
+ }
|
|
|
if err := e.DB.Model(new(model.NeckActiveHabit)).
|
|
|
Select("change_filter", "rumina_filter", "chew_filter").
|
|
|
Where("id = ?", v.Id).
|
|
|
Updates(map[string]interface{}{
|
|
|
"change_filter": int32(changeFilter),
|
|
|
- "rumina_filter": int32(math.Min(50, ruminaFilter)),
|
|
|
- "chew_filter": int32(math.Min(50, chewFilter)),
|
|
|
+ "rumina_filter": int32(ruminaFilter),
|
|
|
+ "chew_filter": int32(chewFilter),
|
|
|
}).Error; err != nil {
|
|
|
zaplog.Error("SecondUpdateChangeFilter", zap.Any("error", err), zap.Any("secondFilterData", secondFilterData))
|
|
|
}
|