| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 | 
							- package model
 
- import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
 
- type CalvingCalf struct {
 
- 	Id            int64                  `json:"id"`
 
- 	PastureId     int64                  `json:"pastureId"`
 
- 	CalvingId     int64                  `json:"calvingId"`
 
- 	CowId         int64                  `json:"cow_id"`
 
- 	BirthAt       int64                  `json:"birthAt"`
 
- 	MotherId      int64                  `json:"motherId"`
 
- 	EarNumber     string                 `json:"earNumber"`
 
- 	Sex           pasturePb.Genders_Kind `json:"sex"`
 
- 	CowKind       pasturePb.CowKind_Kind `json:"cowKind"`
 
- 	BirthWeight   int64                  `json:"birthWeight"`
 
- 	IsLive        pasturePb.IsShow_Kind  `json:"isLive"`
 
- 	IsAdoption    pasturePb.IsShow_Kind  `json:"isAdoption"`
 
- 	PenId         int32                  `json:"penId"`
 
- 	PenName       string                 `json:"penName"`
 
- 	WeaningAt     int64                  `json:"weaningAt"`
 
- 	CurrentWeight int64                  `json:"currentWeight"`
 
- 	Remarks       string                 `json:"remarks"`
 
- 	CreatedAt     int64                  `json:"createdAt"`
 
- 	UpdatedAt     int64                  `json:"updatedAt"`
 
- }
 
- func (e *CalvingCalf) TableName() string {
 
- 	return "calving_calf"
 
- }
 
- func NewEventCalvingCalf(pastureId, calvingId, calvingAt int64, motherInfo *Cow, penMap map[int32]*Pen, req *pasturePb.CalfItem) *CalvingCalf {
 
- 	isAdoption := req.IsAdoption
 
- 	if req.IsLive == pasturePb.IsShow_No {
 
- 		isAdoption = pasturePb.IsShow_No
 
- 	}
 
- 	penId := int32(0)
 
- 	penName := ""
 
- 	if req.PenId > 0 {
 
- 		pen := penMap[req.PenId]
 
- 		penId = pen.Id
 
- 		penName = pen.Name
 
- 	}
 
- 	return &CalvingCalf{
 
- 		PastureId:     pastureId,
 
- 		EarNumber:     req.EarNumber,
 
- 		CalvingId:     calvingId,
 
- 		CowId:         int64(req.CowId),
 
- 		BirthAt:       calvingAt,
 
- 		PenId:         penId,
 
- 		PenName:       penName,
 
- 		BirthWeight:   int64(req.Weight * 1000),
 
- 		CurrentWeight: int64(req.Weight * 1000),
 
- 		Sex:           req.Sex,
 
- 		MotherId:      motherInfo.Id,
 
- 		Remarks:       req.Remarks,
 
- 		IsAdoption:    isAdoption,
 
- 		IsLive:        req.IsLive,
 
- 		CowKind:       motherInfo.CowKind,
 
- 	}
 
- }
 
 
  |