package model import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow" type NeckRingEstrusWarning struct { Id int64 `json:"id"` NeckRingEstrusId int64 `json:"neckRingEstrusId"` PastureId int64 `json:"pastureId"` CowId int64 `json:"cowId"` EarNumber string `json:"earNumber"` FirstTime string `json:"firstTime"` DateTime string `json:"dateTime"` LastTime string `json:"lastTime"` IsPeak pasturePb.IsShow_Kind `json:"isPeak"` WarningKind pasturePb.Warning_Kind `json:"warningKind"` Level pasturePb.EstrusLevel_Kind `json:"level"` HighChange string `json:"highChange"` IsShow pasturePb.IsShow_Kind `json:"isShow"` CreatedAt int64 `json:"createdAt"` UpdatedAt int64 `json:"updatedAt"` } func (n *NeckRingEstrusWarning) TableName() string { return "neck_ring_estrus_warning" } func NewNeckRingEstrusWarning( neckRingEstrusId, pastureId, cowId int64, earNumber, firstTime, dateTime, lastTime string, warningKind pasturePb.Warning_Kind, level pasturePb.EstrusLevel_Kind, ) *NeckRingEstrusWarning { return &NeckRingEstrusWarning{ NeckRingEstrusId: neckRingEstrusId, PastureId: pastureId, CowId: cowId, EarNumber: earNumber, FirstTime: firstTime, DateTime: dateTime, LastTime: lastTime, WarningKind: warningKind, Level: level, IsShow: pasturePb.IsShow_Ok, } } type NeckRingEstrusWarningSlice []*NeckRingEstrusWarning func (n NeckRingEstrusWarningSlice) ToPB(cowMap map[int64]*Cow, eventLogMap map[int64]string) []*pasturePb.EstrusItems { res := make([]*pasturePb.EstrusItems, len(n)) for i, v := range n { cow, ok := cowMap[v.CowId] if !ok { cow = &Cow{Id: v.CowId} } lastBreedEventDetails := "" desc, ok := eventLogMap[cow.Id] if ok { lastBreedEventDetails = desc } res[i] = &pasturePb.EstrusItems{ Id: int32(v.Id), CowId: int32(v.CowId), EarNumber: v.EarNumber, PenId: cow.PenId, PenName: cow.PenName, DayAge: cow.DayAge, MatingTimes: cow.MatingTimes, Lact: cow.Lact, CalvingAge: cow.CalvingAge, AbortionAge: cow.AbortionAge, OptimumMatingStartTime: "", OptimumMatingEndTime: "", LastBreedEventDetails: lastBreedEventDetails, Level: v.Level, EstrusInterval: 0, } } return res } const ( Nb1 = 12 Nb2 = 8 MinNb1 = 10 ) type EstrusWarning struct { NeckRingEstrusId int64 `json:"neckRingEstrusId"` HighChange string `json:"highChange"` CowId int64 `json:"cowId"` DateTime string `json:"dateTime"` Nb1 int32 `json:"nb1"` Nb2 int32 `json:"nb2"` }