|
@@ -86,8 +86,15 @@ func (e *Entry) FirstFilterUpdate(pastureId int64, xToDay *XToday) (processIds [
|
|
|
if limit <= 0 {
|
|
|
limit = defaultLimit
|
|
|
}
|
|
|
+
|
|
|
+ heatDate := time.Now().Local().AddDate(0, 0, -30).Format(model.LayoutDate2)
|
|
|
+ querySql := `SELECT * FROM neck_active_habit WHERE pasture_id = ? AND is_show = ? AND heat_date >= ? AND high >= ?
|
|
|
+ UNION
|
|
|
+ SELECT * FROM neck_active_habit WHERE pasture_id = ? AND is_show = ? AND heat_date >= ? AND rumina >= ?
|
|
|
+ ORDER BY heat_date, neck_ring_number, frameid LIMIT ?`
|
|
|
+
|
|
|
newNeckActiveHabitList := make([]*model.NeckActiveHabit, 0)
|
|
|
- if err = e.DB.Model(new(model.NeckActiveHabit)).
|
|
|
+ /*if err = e.DB.Model(new(model.NeckActiveHabit)).
|
|
|
Where("heat_date >= ?", time.Now().Local().AddDate(0, 0, -30).Format(model.LayoutDate2)).
|
|
|
Where("pasture_id = ?", pastureId).
|
|
|
Where("is_show = ?", pasturePb.IsShow_No).
|
|
@@ -96,6 +103,14 @@ func (e *Entry) FirstFilterUpdate(pastureId int64, xToDay *XToday) (processIds [
|
|
|
Limit(int(limit)).
|
|
|
Find(&newNeckActiveHabitList).Error; err != nil {
|
|
|
return nil, xerr.WithStack(err)
|
|
|
+ }*/
|
|
|
+ if err = e.DB.Raw(
|
|
|
+ querySql,
|
|
|
+ pastureId, pasturePb.IsShow_No, heatDate, xToDay.High,
|
|
|
+ pastureId, pasturePb.IsShow_No, heatDate, xToDay.Rumina,
|
|
|
+ limit,
|
|
|
+ ).Find(&newNeckActiveHabitList).Error; err != nil {
|
|
|
+ return nil, xerr.WithStack(err)
|
|
|
}
|
|
|
|
|
|
// 活动量滤波
|