| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 | package modelimport (	"kpt-pasture/util"	"strconv"	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow")type EventWeaning struct {	Id            int64                 `json:"id"`	PastureId     int64                 `json:"pastureId"`	CowId         int64                 `json:"cowId"`	EarNumber     string                `json:"earNumber"`	DayAge        int32                 `json:"dayAge"`	MotherId      int64                 `json:"motherId"`	BullNumber    string                `json:"bullNumber"`	PlanDay       int64                 `json:"planDay"`	EndDay        int64                 `json:"endDay"`	RealityDay    int64                 `json:"realityDay"`	Status        pasturePb.IsShow_Kind `json:"status"`	BeforePenId   int32                 `json:"beforePenId"`	AfterPenId    int32                 `json:"afterPenId"`	Weight        int32                 `json:"weight"`	BirthWeight   int32                 `json:"birthWeight"`	BirthAt       int64                 `json:"birthAt"`	Remarks       string                `json:"remarks"`	OperationId   int32                 `json:"operationId"`	OperationName string                `json:"operationName"`	MessageId     int32                 `json:"messageId"`	MessageName   string                `json:"messageName"`	CreatedAt     int64                 `json:"createdAt"`	UpdatedAt     int64                 `json:"updatedAt"`}func (e *EventWeaning) TableName() string {	return "event_weaning"}func (e *EventWeaning) EventUpdate(cowInfo *Cow, weaningAt int64, weight int32, remarks string, afterPenId int32, operationUser, currentUser *SystemUser) {	e.Status = pasturePb.IsShow_Ok	e.RealityDay = weaningAt	e.OperationId = int32(operationUser.Id)	e.OperationName = operationUser.Name	e.MessageId = int32(currentUser.Id)	e.MessageName = currentUser.Name	e.Remarks = remarks	e.AfterPenId = afterPenId	e.Weight = weight	e.DayAge = cowInfo.GetEventDayAge(weaningAt)	e.BirthWeight = int32(cowInfo.BirthWeight)	e.BirthAt = cowInfo.BirthAt}func NewEventWeaning(pastureId int64, cowInfo *Cow, startDay, endDay string) *EventWeaning {	motherId, _ := strconv.ParseInt(cowInfo.MotherNumber, 10, 64)	return &EventWeaning{		PastureId:   pastureId,		MotherId:    motherId,		BullNumber:  cowInfo.LastBullNumber,		CowId:       cowInfo.Id,		EarNumber:   cowInfo.EarNumber,		PlanDay:     util.TimeParseLocalUnix(startDay),		EndDay:      util.TimeParseLocalEndUnix(endDay),		Status:      pasturePb.IsShow_No,		BeforePenId: cowInfo.PenId,		Weight:      0,	}}func NewEventWeaningList(pastureId int64, cowList []*Cow, startDay, endDay string) []*EventWeaning {	var weaningList = make([]*EventWeaning, 0)	for _, cow := range cowList {		weaningList = append(weaningList, NewEventWeaning(pastureId, cow, startDay, endDay))	}	return weaningList}
 |