package model import ( "fmt" pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow" ) const ( InitChangeFilter = -10000 DefaultChangeFilter = -99 DefaultFilterCorrect = 100 DefaultWeeklyActive = 1500 ) type NeckActiveHabit struct { Id int64 `json:"id"` PastureId int64 `json:"pastureId"` NeckRingNumber string `json:"neckRingNumber"` ActiveTime string `json:"activeTime"` Frameid int32 `json:"frameid"` HeatDate string `json:"heatDate"` Rumina int32 `json:"rumina"` Intake int32 `json:"intake"` Inactive int32 `json:"inactive"` Gasp int32 `json:"gasp"` Other int32 `json:"other"` High int32 `json:"high"` Active int32 `json:"active"` FilterHigh int32 `json:"filterHigh"` FilterRumina int32 `json:"filterRumina"` FilterChew int32 `json:"filterChew"` WeekHigh int32 `json:"weekHigh"` AvgHighHabit int32 `json:"avgHighHabit"` AvgRuminaHabit int32 `json:"avgRuminaHabit"` AvgIntakeHabit int32 `json:"avgIntakeHabit"` AvgChewHabit int32 `json:"avgChewHabit"` AvgInactiveHabit int32 `json:"avgInactiveHabit"` AvgOtherHabit int32 `json:"avgOtherHabit"` ChangeHigh int32 `json:"changeHigh"` ChangeRumina int32 `json:"changeRumina"` ChangeChew int32 `json:"changeChew"` ChangeAdjust int32 `json:"changeAdjust"` ChangeFilter int32 `json:"changeFilter"` RuminaFilter int32 `json:"ruminaFilter"` ChewFilter int32 `json:"chewFilter"` FilterCorrect int32 `json:"filterCorrect"` SumRumina int32 `json:"sumRumina"` SumIntake int32 `json:"sumIntake"` SumInactive int32 `json:"sumInactive"` SumAct int32 `json:"sumAct"` SumMinHigh int32 `json:"sumMinHigh"` SumMaxHigh int32 `json:"sumMaxHigh"` SumMinChew int32 `json:"SumMinChew"` SumRuminaBeforeThreeDay int32 `json:"sumRuminaBeforeThreeDay"` SumIntakeBeforeThreeDay int32 `json:"sumIntakeBeforeThreeDay"` Score int32 `json:"score"` IsMaxTime pasturePb.IsShow_Kind `json:"isMaxTime"` IsShow pasturePb.IsShow_Kind `json:"isShow"` RecordCount int32 `json:"recordCount"` CreatedAt int64 `json:"createdAt"` UpdatedAt int64 `json:"updatedAt"` } func (n *NeckActiveHabit) TableName() string { return "neck_active_habit" } func NewNeckActiveHabit(data *NeckRingOriginalMerge) *NeckActiveHabit { return &NeckActiveHabit{ PastureId: data.PastureId, Frameid: data.XframeId, HeatDate: data.ActiveDate, NeckRingNumber: data.NeckRingNumber, Active: data.Active, Gasp: data.Gasp, High: data.High, Inactive: data.Inactive, Intake: data.Intake, Other: data.Other, Rumina: data.Rumina, WeekHigh: DefaultWeeklyActive, IsShow: pasturePb.IsShow_No, IsMaxTime: pasturePb.IsShow_No, ChangeFilter: InitChangeFilter, FilterCorrect: DefaultFilterCorrect, RuminaFilter: InitChangeFilter, ChewFilter: InitChangeFilter, ActiveTime: fmt.Sprintf("%s %02d:00:00", data.ActiveDate, data.XframeId*2), RecordCount: data.RecordCount, } } func (n *NeckActiveHabit) SumAvg() { n.Rumina = n.Rumina / n.RecordCount * n.RecordCount n.Inactive = n.Inactive / n.RecordCount * n.RecordCount n.Active = n.Active / n.RecordCount * n.RecordCount n.Intake = n.Intake / n.RecordCount * n.RecordCount n.Other = n.Other / n.RecordCount * n.RecordCount n.Gasp = n.Gasp / n.RecordCount * n.RecordCount n.High = n.High / n.RecordCount * n.RecordCount } type MaxHabitIdModel struct { Id int64 `json:"id"` }