12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- package model
- import (
- pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
- )
- type NeckRingEstrus struct {
- Id int64 `json:"id"`
- PastureId int64 `json:"pastureId"`
- CowId int64 `json:"cowId"`
- NeckRingNumber string `json:"neckRingNumber"`
- EarNumber string `json:"earNumber"`
- Lact int32 `json:"lact"`
- ExposeEstrusType pasturePb.ExposeEstrusType_Kind `json:"exposeEstrusType"`
- EstrusStartDate string `json:"estrusStartDate"`
- ActiveDate string `json:"activeDate"`
- LastEstrusDate string `json:"lastEstrusDate"`
- Level pasturePb.EstrusLevel_Kind `json:"level"`
- IsPeak pasturePb.IsShow_Kind `json:"isPeak"`
- DayHigh int32 `json:"dayHigh"`
- MaxHigh int32 `json:"maxHigh"`
- CheckResult pasturePb.CheckResult_Kind `json:"checkResult"`
- Remarks string `json:"remarks"`
- IsShow pasturePb.IsShow_Kind `json:"isShow"`
- CreatedAt int64 `json:"createdAt"`
- UpdatedAt int64 `json:"updatedAt"`
- }
- func (n *NeckRingEstrus) TableName() string {
- return "neck_ring_estrus"
- }
- func NewNeckRingEstrus(
- pastureId int64,
- cow *Cow,
- exposeEstrusType pasturePb.ExposeEstrusType_Kind,
- level pasturePb.EstrusLevel_Kind,
- checkResult pasturePb.CheckResult_Kind,
- isShow pasturePb.IsShow_Kind,
- ) *NeckRingEstrus {
- return &NeckRingEstrus{
- PastureId: pastureId,
- CowId: cow.Id,
- NeckRingNumber: cow.NeckRingNumber,
- EarNumber: cow.EarNumber,
- Lact: cow.Lact,
- ExposeEstrusType: exposeEstrusType,
- Level: level,
- IsShow: isShow,
- CheckResult: checkResult,
- }
- }
- type NeckRingEstrusSlice []*NeckRingEstrus
- func (n NeckRingEstrusSlice) 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
- }
|