|
@@ -1,5 +1,7 @@
|
|
|
package model
|
|
|
|
|
|
+import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
|
|
|
+
|
|
|
type PenBehaviorDay struct {
|
|
|
Id int64 `json:"id"`
|
|
|
PastureId int64 `json:"pastureId"`
|
|
@@ -46,3 +48,49 @@ func NewPenBehaviorDay(pastureId int64, heatDate string, penId int32, penName st
|
|
|
}
|
|
|
|
|
|
type PenBehaviorDaySlice []*PenBehaviorDay
|
|
|
+
|
|
|
+type PenBehaviorDayModel struct {
|
|
|
+ HeatDate string `json:"heatDate"`
|
|
|
+ PenId int32 `json:"penId"`
|
|
|
+ PenName string `json:"penName"`
|
|
|
+ CowCount int32 `json:"cowCount"`
|
|
|
+ DayMilk float32 `json:"dayMilk"`
|
|
|
+ DayHigh int32 `json:"dayHigh"`
|
|
|
+ DayRumina int32 `json:"dayRumina"`
|
|
|
+ DayIntake int32 `json:"dayIntake"`
|
|
|
+ DayInactive int32 `json:"dayInactive"`
|
|
|
+ DayChew int32 `json:"dayChew"`
|
|
|
+ DayActive int32 `json:"dayActive"`
|
|
|
+ DayImmobility int32 `json:"dayImmobility"`
|
|
|
+ RuminaStd int32 `json:"ruminaStd"`
|
|
|
+}
|
|
|
+
|
|
|
+type PenBehaviorDayModelSlice []*PenBehaviorDayModel
|
|
|
+
|
|
|
+func (p PenBehaviorDayModelSlice) ToPB(dataTimeRange []string) *pasturePb.BarnMonitorItem {
|
|
|
+ res := &pasturePb.BarnMonitorItem{
|
|
|
+ Headers: dataTimeRange,
|
|
|
+ DateTime: make([]string, 0),
|
|
|
+ DayMilk: make([]float32, 0),
|
|
|
+ DayRumina: make([]int32, 0),
|
|
|
+ DayIntake: make([]int32, 0),
|
|
|
+ DayImmobility: make([]int32, 0),
|
|
|
+ DayGasp: make([]int32, 0),
|
|
|
+ DayChew: make([]int32, 0),
|
|
|
+ DayStd: make([]int32, 0),
|
|
|
+ }
|
|
|
+ for _, dt := range dataTimeRange {
|
|
|
+ for _, v := range p {
|
|
|
+ if dt == v.HeatDate {
|
|
|
+ res.DateTime = append(res.DateTime, v.HeatDate)
|
|
|
+ res.DayMilk = append(res.DayMilk, v.DayMilk)
|
|
|
+ res.DayRumina = append(res.DayRumina, v.DayRumina)
|
|
|
+ res.DayIntake = append(res.DayIntake, v.DayIntake)
|
|
|
+ res.DayImmobility = append(res.DayImmobility, v.DayImmobility)
|
|
|
+ res.DayChew = append(res.DayChew, v.DayChew)
|
|
|
+ res.DayStd = append(res.DayStd, v.RuminaStd)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return res
|
|
|
+}
|