| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 | 
							- package model
 
- import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
 
- type CowCalving struct {
 
- 	Id                int32                  `json:"id"`
 
- 	PastureId         int64                  `json:"pastureId"`
 
- 	DateTime          string                 `json:"dateTime"`
 
- 	CowId             int64                  `json:"cowId"`
 
- 	Lact              int32                  `json:"lact"`
 
- 	EarNumber         string                 `json:"earNumber"`
 
- 	NeckRingNumber    string                 `json:"neckRingNumber"`
 
- 	CowType           pasturePb.CowType_Kind `json:"cowType"`
 
- 	CowKind           pasturePb.CowKind_Kind `json:"cowKind"`
 
- 	CalvingAge        int32                  `json:"calvingAge"`
 
- 	MatingAge         int32                  `json:"matingAge"`
 
- 	IsMating          pasturePb.IsShow_Kind  `json:"isMating"`
 
- 	IsPregnantCheck   pasturePb.IsShow_Kind  `json:"isPregnantCheck"`
 
- 	PregnantCheckDate string                 `json:"pregnantCheckDate"`
 
- 	IsAbortion        pasturePb.IsShow_Kind  `json:"isAbortion"`
 
- 	IsDeparture       pasturePb.IsShow_Kind  `json:"isDeparture"`
 
- 	IsForbidden       pasturePb.IsShow_Kind  `json:"isForbidden"`
 
- 	CreatedAt         int64                  `json:"createdAt"`
 
- 	UpdatedAt         int64                  `json:"updatedAt"`
 
- }
 
- func (e *CowCalving) TableName() string {
 
- 	return "cow_calving"
 
- }
 
- func NewEveryDayCalving(pastureId int64, dateTime string, cowInfo *Cow) *CowCalving {
 
- 	isMating, isPregnantCheck, isAbortion, isDeparture, isForbidden := pasturePb.IsShow_No, pasturePb.IsShow_No, pasturePb.IsShow_No, pasturePb.IsShow_No, pasturePb.IsShow_No
 
- 	switch cowInfo.BreedStatus {
 
- 	case pasturePb.BreedStatus_Abort:
 
- 		isAbortion = pasturePb.IsShow_Ok
 
- 	case pasturePb.BreedStatus_Breeding:
 
- 		isMating = pasturePb.IsShow_Ok
 
- 	case pasturePb.BreedStatus_Pregnant, pasturePb.BreedStatus_Empty:
 
- 		isPregnantCheck = pasturePb.IsShow_Ok
 
- 	case pasturePb.BreedStatus_No_Mating:
 
- 		isPregnantCheck = pasturePb.IsShow_Ok
 
- 	}
 
- 	if cowInfo.AdmissionStatus != pasturePb.AdmissionStatus_Admission {
 
- 		isDeparture = pasturePb.IsShow_Ok
 
- 	}
 
- 	return &CowCalving{
 
- 		PastureId:         pastureId,
 
- 		DateTime:          dateTime,
 
- 		CowId:             cowInfo.Id,
 
- 		Lact:              cowInfo.Lact,
 
- 		EarNumber:         cowInfo.EarNumber,
 
- 		NeckRingNumber:    cowInfo.NeckRingNumber,
 
- 		CowType:           cowInfo.CowType,
 
- 		CowKind:           cowInfo.CowKind,
 
- 		CalvingAge:        cowInfo.CalvingAge,
 
- 		MatingAge:         cowInfo.MatingAge,
 
- 		IsMating:          isMating,
 
- 		IsPregnantCheck:   isPregnantCheck,
 
- 		PregnantCheckDate: "",
 
- 		IsAbortion:        isAbortion,
 
- 		IsDeparture:       isDeparture,
 
- 		IsForbidden:       isForbidden,
 
- 	}
 
- }
 
- func NewEveryDayCalvingList(pastureId int64, dateTime string, cowList []*Cow) []*CowCalving {
 
- 	res := make([]*CowCalving, 0)
 
- 	for _, cow := range cowList {
 
- 		res = append(res, NewEveryDayCalving(pastureId, dateTime, cow))
 
- 	}
 
- 	return res
 
- }
 
- type CowCalvingSlice []*CowCalving
 
- func (c CowCalvingSlice) ToPB() []*pasturePb.TwentyOnePregnantItems {
 
- 	res := make([]*pasturePb.TwentyOnePregnantItems, 0)
 
- 	for _, v := range c {
 
- 		res = append(res, &pasturePb.TwentyOnePregnantItems{
 
- 			CowId:     int32(v.CowId),
 
- 			Lact:      v.Lact,
 
- 			EarNumber: v.EarNumber,
 
- 			//CowTypeName: v.CowType,
 
- 		})
 
- 	}
 
- 	return res
 
- }
 
 
  |