|
@@ -258,8 +258,8 @@ func (s *StoreEntry) BehaviorCurve(ctx context.Context, req *pasturePb.CowBehavi
|
|
}
|
|
}
|
|
data.EventMap[k] = v
|
|
data.EventMap[k] = v
|
|
}
|
|
}
|
|
- data.LowActivity = 62
|
|
|
|
- data.MiddleActivity = 80
|
|
|
|
|
|
+ data.LowActivity = model.LowActivity
|
|
|
|
+ data.MiddleActivity = model.MiddleActivity
|
|
// 牛只事件列表
|
|
// 牛只事件列表
|
|
eventLogList := make([]*model.EventCowLog, 0)
|
|
eventLogList := make([]*model.EventCowLog, 0)
|
|
eventLog := &model.EventCowLog{CowId: cowInfo.Id}
|
|
eventLog := &model.EventCowLog{CowId: cowInfo.Id}
|
|
@@ -295,25 +295,22 @@ func (s *StoreEntry) BehaviorCurve(ctx context.Context, req *pasturePb.CowBehavi
|
|
}
|
|
}
|
|
|
|
|
|
// 发情数据
|
|
// 发情数据
|
|
- estrusList := make([]*model.EventEstrus, 0)
|
|
|
|
- if err = s.DB.Table(new(model.EventEstrus).TableName()).
|
|
|
|
|
|
+ estrusList := make([]*model.NeckRingEstrus, 0)
|
|
|
|
+ if err = s.DB.Model(new(model.NeckRingEstrus)).
|
|
|
|
+ Select("max(id) as id,active_level,active_time,is_peak").
|
|
Where("cow_id = ?", cowInfo.Id).
|
|
Where("cow_id = ?", cowInfo.Id).
|
|
Where("pasture_id = ?", userModel.AppPasture.Id).
|
|
Where("pasture_id = ?", userModel.AppPasture.Id).
|
|
- Where("reality_day BETWEEN ? AND ?", startDataTime, endDataTime).
|
|
|
|
- Order("reality_day").
|
|
|
|
|
|
+ Where("active_time BETWEEN ? AND ?", fmt.Sprintf("%s 00:00:00", startDataTime), fmt.Sprintf("%s 23:59:59", endDataTime)).
|
|
|
|
+ Where("is_peak = ?", pasturePb.IsShow_Ok).
|
|
Find(&estrusList).Error; err != nil {
|
|
Find(&estrusList).Error; err != nil {
|
|
return nil, xerr.WithStack(err)
|
|
return nil, xerr.WithStack(err)
|
|
}
|
|
}
|
|
|
|
|
|
for _, v := range estrusList {
|
|
for _, v := range estrusList {
|
|
- if data.EstrusList[v.Level] == nil {
|
|
|
|
- data.EstrusList[v.Level] = make([]string, 0)
|
|
|
|
- }
|
|
|
|
- if v.RealityDay > 0 {
|
|
|
|
- // 格式化为到小时的字符串
|
|
|
|
- hourStr := time.Unix(v.RealityDay, 0).Local().Format(model.LayoutHour)
|
|
|
|
- data.EstrusList[v.Level] = append(data.EstrusList[v.Level], hourStr)
|
|
|
|
|
|
+ if data.EstrusList[v.ActiveLevel] == nil {
|
|
|
|
+ data.EstrusList[v.ActiveLevel] = make([]string, 0)
|
|
}
|
|
}
|
|
|
|
+ data.EstrusList[v.ActiveLevel] = append(data.EstrusList[v.ActiveLevel], strings.TrimSuffix(v.ActiveTime, ":00:00"))
|
|
}
|
|
}
|
|
|
|
|
|
return &model.CowBehaviorCurveResponse{
|
|
return &model.CowBehaviorCurveResponse{
|