package model import ( "kpt-pasture/util" "strconv" "time" 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"` 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"` 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(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 } func NewEventWeaning(pastureId int64, cowInfo *Cow) *EventWeaning { motherId, _ := strconv.ParseInt(cowInfo.MotherNumber, 10, 64) return &EventWeaning{ PastureId: pastureId, MotherId: motherId, BullNumber: cowInfo.LastBullNumber, CowId: cowInfo.Id, PlanDay: util.TimeParseLocalUnix(time.Now().Format(LayoutDate2)), EndDay: util.TimeParseLocalEndUnix(time.Now().Format(LayoutDate2)), Status: pasturePb.IsShow_No, BeforePenId: cowInfo.PenId, Weight: 0, } } func NewEventWeaningList(pastureId int64, cowList []*Cow) []*EventWeaning { var weaningList = make([]*EventWeaning, 0) for _, cow := range cowList { weaningList = append(weaningList, NewEventWeaning(pastureId, cow)) } return weaningList }