|  | @@ -10,47 +10,47 @@ import (
 | 
											
												
													
														|  |  )
 |  |  )
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  type Cow struct {
 |  |  type Cow struct {
 | 
											
												
													
														|  | -	Id                  int64                       `json:"id"`
 |  | 
 | 
											
												
													
														|  | -	Sex                 pasturePb.Genders_Kind      `json:"sex"`
 |  | 
 | 
											
												
													
														|  | -	NeckRingNumber      string                      `json:"neckRingNumber"`
 |  | 
 | 
											
												
													
														|  | -	EarNumber           string                      `json:"earNumber"`
 |  | 
 | 
											
												
													
														|  | -	EarOldNumber        string                      `json:"earOldNumber"`
 |  | 
 | 
											
												
													
														|  | -	PenId               int32                       `json:"penId"`
 |  | 
 | 
											
												
													
														|  | -	Lact                int32                       `json:"lact"`
 |  | 
 | 
											
												
													
														|  | -	DayAge              int32                       `json:"dayAge"`
 |  | 
 | 
											
												
													
														|  | -	CalvingAge          int64                       `json:"calvingAge"`
 |  | 
 | 
											
												
													
														|  | -	PregnancyAge        int64                       `json:"pregnancyAge"` // 怀孕天数 孕检结果有阳性更新,产犊后至0
 |  | 
 | 
											
												
													
														|  | -	AdmissionAge        int64                       `json:"admissionAge"`
 |  | 
 | 
											
												
													
														|  | -	AbortionAge         int64                       `json:"abortionAge"` // 流产天数
 |  | 
 | 
											
												
													
														|  | -	CowType             pasturePb.CowType_Kind      `json:"cowType"`
 |  | 
 | 
											
												
													
														|  | -	BreedStatus         pasturePb.BreedStatus_Kind  `json:"breedStatus"`
 |  | 
 | 
											
												
													
														|  | -	CowKind             pasturePb.CowKind_Kind      `json:"cowKind"`
 |  | 
 | 
											
												
													
														|  | -	BirthWeight         int64                       `json:"birthWeight"`
 |  | 
 | 
											
												
													
														|  | -	CurrentWeight       int64                       `json:"currentWeight"`
 |  | 
 | 
											
												
													
														|  | -	AdmissionWeight     int64                       `json:"admissionWeight"`
 |  | 
 | 
											
												
													
														|  | -	SourceId            pasturePb.CowSource_Kind    `json:"sourceId"`
 |  | 
 | 
											
												
													
														|  | -	FatherNumber        string                      `json:"fatherNumber"`
 |  | 
 | 
											
												
													
														|  | -	MotherNumber        string                      `json:"motherNumber"`
 |  | 
 | 
											
												
													
														|  | -	IsRemove            pasturePb.IsShow_Kind       `json:"isRemove"`
 |  | 
 | 
											
												
													
														|  | -	IsPregnant          pasturePb.IsShow_Kind       `json:"isPregnant"`
 |  | 
 | 
											
												
													
														|  | -	HealthStatus        pasturePb.HealthStatus_Kind `json:"healthStatus"`
 |  | 
 | 
											
												
													
														|  | -	WeaningAt           int64                       `json:"weaningAt"`
 |  | 
 | 
											
												
													
														|  | -	CalvingAt           int64                       `json:"calvingAt"`
 |  | 
 | 
											
												
													
														|  | -	BirthAt             int64                       `json:"birthAti"`
 |  | 
 | 
											
												
													
														|  | -	AdmissionAt         int64                       `json:"admissionAt"`
 |  | 
 | 
											
												
													
														|  | -	FirstMatingAt       int64                       `json:"firstMatingAt"`
 |  | 
 | 
											
												
													
														|  | -	LastEstrusAt        int64                       `json:"lastEstrusAt"`
 |  | 
 | 
											
												
													
														|  | -	LastCalvingAt       int64                       `json:"lastCalvingAt"`
 |  | 
 | 
											
												
													
														|  | -	LastMatingAt        int64                       `json:"lastMatingAt"`
 |  | 
 | 
											
												
													
														|  | -	LastBullNumber      string                      `json:"lastBullNumber"`
 |  | 
 | 
											
												
													
														|  | -	LastPregnantCheckAt int64                       `json:"lastPregnantCheckAt"`
 |  | 
 | 
											
												
													
														|  | -	LastDryMilkAt       int64                       `json:"lastDryMilkAt"`
 |  | 
 | 
											
												
													
														|  | -	LastSecondWeight    int64                       `json:"lastSecondWeight"`
 |  | 
 | 
											
												
													
														|  | -	LastSecondWeightAt  int64                       `json:"lastSecondWeightAt"`
 |  | 
 | 
											
												
													
														|  | -	LastAbortionAt      int64                       `json:"lastAbortionAt"`
 |  | 
 | 
											
												
													
														|  | -	LastWeightAt        int64                       `json:"lastWeightAt"`
 |  | 
 | 
											
												
													
														|  | -	CreatedAt           int64                       `json:"createdAt"`
 |  | 
 | 
											
												
													
														|  | -	UpdatedAt           int64                       `json:"updatedAt"`
 |  | 
 | 
											
												
													
														|  | 
 |  | +	Id                  int64                          `json:"id"`
 | 
											
												
													
														|  | 
 |  | +	Sex                 pasturePb.Genders_Kind         `json:"sex"`
 | 
											
												
													
														|  | 
 |  | +	NeckRingNumber      string                         `json:"neckRingNumber"`
 | 
											
												
													
														|  | 
 |  | +	EarNumber           string                         `json:"earNumber"`
 | 
											
												
													
														|  | 
 |  | +	EarOldNumber        string                         `json:"earOldNumber"`
 | 
											
												
													
														|  | 
 |  | +	PenId               int32                          `json:"penId"`
 | 
											
												
													
														|  | 
 |  | +	Lact                int32                          `json:"lact"`
 | 
											
												
													
														|  | 
 |  | +	DayAge              int32                          `json:"dayAge"`
 | 
											
												
													
														|  | 
 |  | +	CalvingAge          int64                          `json:"calvingAge"`
 | 
											
												
													
														|  | 
 |  | +	PregnancyAge        int32                          `json:"pregnancyAge"` // 怀孕天数 孕检结果有阳性更新,产犊后至0
 | 
											
												
													
														|  | 
 |  | +	AdmissionAge        int32                          `json:"admissionAge"`
 | 
											
												
													
														|  | 
 |  | +	AbortionAge         int64                          `json:"abortionAge"` // 流产天数
 | 
											
												
													
														|  | 
 |  | +	CowType             pasturePb.CowType_Kind         `json:"cowType"`
 | 
											
												
													
														|  | 
 |  | +	BreedStatus         pasturePb.BreedStatus_Kind     `json:"breedStatus"`
 | 
											
												
													
														|  | 
 |  | +	CowKind             pasturePb.CowKind_Kind         `json:"cowKind"`
 | 
											
												
													
														|  | 
 |  | +	BirthWeight         int64                          `json:"birthWeight"`
 | 
											
												
													
														|  | 
 |  | +	CurrentWeight       int64                          `json:"currentWeight"`
 | 
											
												
													
														|  | 
 |  | +	AdmissionWeight     int64                          `json:"admissionWeight"`
 | 
											
												
													
														|  | 
 |  | +	SourceId            pasturePb.CowSource_Kind       `json:"sourceId"`
 | 
											
												
													
														|  | 
 |  | +	FatherNumber        string                         `json:"fatherNumber"`
 | 
											
												
													
														|  | 
 |  | +	MotherNumber        string                         `json:"motherNumber"`
 | 
											
												
													
														|  | 
 |  | +	AdmissionStatus     pasturePb.AdmissionStatus_Kind `json:"admissionStatus"`
 | 
											
												
													
														|  | 
 |  | +	IsPregnant          pasturePb.IsShow_Kind          `json:"isPregnant"`
 | 
											
												
													
														|  | 
 |  | +	HealthStatus        pasturePb.HealthStatus_Kind    `json:"healthStatus"`
 | 
											
												
													
														|  | 
 |  | +	WeaningAt           int64                          `json:"weaningAt"`
 | 
											
												
													
														|  | 
 |  | +	CalvingAt           int64                          `json:"calvingAt"`
 | 
											
												
													
														|  | 
 |  | +	BirthAt             int64                          `json:"birthAti"`
 | 
											
												
													
														|  | 
 |  | +	AdmissionAt         int64                          `json:"admissionAt"`
 | 
											
												
													
														|  | 
 |  | +	FirstMatingAt       int64                          `json:"firstMatingAt"`
 | 
											
												
													
														|  | 
 |  | +	LastEstrusAt        int64                          `json:"lastEstrusAt"`
 | 
											
												
													
														|  | 
 |  | +	LastCalvingAt       int64                          `json:"lastCalvingAt"`
 | 
											
												
													
														|  | 
 |  | +	LastMatingAt        int64                          `json:"lastMatingAt"`
 | 
											
												
													
														|  | 
 |  | +	LastBullNumber      string                         `json:"lastBullNumber"`
 | 
											
												
													
														|  | 
 |  | +	LastPregnantCheckAt int64                          `json:"lastPregnantCheckAt"`
 | 
											
												
													
														|  | 
 |  | +	LastDryMilkAt       int64                          `json:"lastDryMilkAt"`
 | 
											
												
													
														|  | 
 |  | +	LastSecondWeight    int64                          `json:"lastSecondWeight"`
 | 
											
												
													
														|  | 
 |  | +	LastSecondWeightAt  int64                          `json:"lastSecondWeightAt"`
 | 
											
												
													
														|  | 
 |  | +	LastAbortionAt      int64                          `json:"lastAbortionAt"`
 | 
											
												
													
														|  | 
 |  | +	LastWeightAt        int64                          `json:"lastWeightAt"`
 | 
											
												
													
														|  | 
 |  | +	CreatedAt           int64                          `json:"createdAt"`
 | 
											
												
													
														|  | 
 |  | +	UpdatedAt           int64                          `json:"updatedAt"`
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  func (c *Cow) TableName() string {
 |  |  func (c *Cow) TableName() string {
 | 
											
										
											
												
													
														|  | @@ -153,7 +153,7 @@ func NewCow(req *pasturePb.EventEnterRequest) *Cow {
 | 
											
												
													
														|  |  		SourceId:            req.CowSource,
 |  |  		SourceId:            req.CowSource,
 | 
											
												
													
														|  |  		FatherNumber:        req.FatherNumber,
 |  |  		FatherNumber:        req.FatherNumber,
 | 
											
												
													
														|  |  		MotherNumber:        req.MotherNumber,
 |  |  		MotherNumber:        req.MotherNumber,
 | 
											
												
													
														|  | -		IsRemove:            pasturePb.IsShow_Ok,
 |  | 
 | 
											
												
													
														|  | 
 |  | +		AdmissionStatus:     pasturePb.AdmissionStatus_Admission,
 | 
											
												
													
														|  |  		HealthStatus:        pasturePb.HealthStatus_Health,
 |  |  		HealthStatus:        pasturePb.HealthStatus_Health,
 | 
											
												
													
														|  |  		IsPregnant:          isPregnant,
 |  |  		IsPregnant:          isPregnant,
 | 
											
												
													
														|  |  		WeaningAt:           int64(req.WeaningAt),
 |  |  		WeaningAt:           int64(req.WeaningAt),
 | 
											
										
											
												
													
														|  | @@ -167,19 +167,19 @@ func NewCow(req *pasturePb.EventEnterRequest) *Cow {
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  func NewCalfCow(motherId int64, fatherNumber string, calf *CalvingCalf) *Cow {
 |  |  func NewCalfCow(motherId int64, fatherNumber string, calf *CalvingCalf) *Cow {
 | 
											
												
													
														|  |  	return &Cow{
 |  |  	return &Cow{
 | 
											
												
													
														|  | -		Sex:          calf.Sex,
 |  | 
 | 
											
												
													
														|  | -		EarNumber:    calf.EarNumber,
 |  | 
 | 
											
												
													
														|  | -		PenId:        calf.PenId,
 |  | 
 | 
											
												
													
														|  | -		CowType:      pasturePb.CowType_Lactating_Calf, // 哺乳犊牛
 |  | 
 | 
											
												
													
														|  | -		BreedStatus:  pasturePb.BreedStatus_UnBreed,    // 未配
 |  | 
 | 
											
												
													
														|  | -		CowKind:      calf.CowKind,                     // 牛只品种
 |  | 
 | 
											
												
													
														|  | -		BirthWeight:  calf.BirthWeight,
 |  | 
 | 
											
												
													
														|  | -		BirthAt:      calf.BirthAt,
 |  | 
 | 
											
												
													
														|  | -		SourceId:     pasturePb.CowSource_Calving, // 产犊方式
 |  | 
 | 
											
												
													
														|  | -		FatherNumber: fatherNumber,
 |  | 
 | 
											
												
													
														|  | -		MotherNumber: fmt.Sprintf("%d", motherId),
 |  | 
 | 
											
												
													
														|  | -		IsRemove:     pasturePb.IsShow_Ok,
 |  | 
 | 
											
												
													
														|  | -		IsPregnant:   pasturePb.IsShow_No,
 |  | 
 | 
											
												
													
														|  | 
 |  | +		Sex:             calf.Sex,
 | 
											
												
													
														|  | 
 |  | +		EarNumber:       calf.EarNumber,
 | 
											
												
													
														|  | 
 |  | +		PenId:           calf.PenId,
 | 
											
												
													
														|  | 
 |  | +		CowType:         pasturePb.CowType_Lactating_Calf, // 哺乳犊牛
 | 
											
												
													
														|  | 
 |  | +		BreedStatus:     pasturePb.BreedStatus_UnBreed,    // 未配
 | 
											
												
													
														|  | 
 |  | +		CowKind:         calf.CowKind,                     // 牛只品种
 | 
											
												
													
														|  | 
 |  | +		BirthWeight:     calf.BirthWeight,
 | 
											
												
													
														|  | 
 |  | +		BirthAt:         calf.BirthAt,
 | 
											
												
													
														|  | 
 |  | +		SourceId:        pasturePb.CowSource_Calving, // 产犊方式
 | 
											
												
													
														|  | 
 |  | +		FatherNumber:    fatherNumber,
 | 
											
												
													
														|  | 
 |  | +		MotherNumber:    fmt.Sprintf("%d", motherId),
 | 
											
												
													
														|  | 
 |  | +		AdmissionStatus: pasturePb.AdmissionStatus_Admission,
 | 
											
												
													
														|  | 
 |  | +		IsPregnant:      pasturePb.IsShow_No,
 | 
											
												
													
														|  |  	}
 |  |  	}
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -218,7 +218,9 @@ func (c *Cow) GetCalvingAge() int64 {
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  // GetDaysPregnant 怀孕天数
 |  |  // GetDaysPregnant 怀孕天数
 | 
											
												
													
														|  |  func (c *Cow) GetDaysPregnant() int32 {
 |  |  func (c *Cow) GetDaysPregnant() int32 {
 | 
											
												
													
														|  | -	if c.BreedStatus == pasturePb.BreedStatus_Pregnant && c.IsRemove == pasturePb.IsShow_No && c.IsPregnant == pasturePb.IsShow_Ok {
 |  | 
 | 
											
												
													
														|  | 
 |  | +	if c.BreedStatus == pasturePb.BreedStatus_Pregnant &&
 | 
											
												
													
														|  | 
 |  | +		c.AdmissionStatus == pasturePb.AdmissionStatus_Admission &&
 | 
											
												
													
														|  | 
 |  | +		c.IsPregnant == pasturePb.IsShow_Ok {
 | 
											
												
													
														|  |  		return int32(math.Floor(float64(time.Now().Unix()-c.LastMatingAt) / 86400))
 |  |  		return int32(math.Floor(float64(time.Now().Unix()-c.LastMatingAt) / 86400))
 | 
											
												
													
														|  |  	}
 |  |  	}
 | 
											
												
													
														|  |  	return 0
 |  |  	return 0
 | 
											
										
											
												
													
														|  | @@ -226,7 +228,7 @@ func (c *Cow) GetDaysPregnant() int32 {
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  // GetLactationDays 泌乳天数
 |  |  // GetLactationDays 泌乳天数
 | 
											
												
													
														|  |  func (c *Cow) GetLactationDays() int32 {
 |  |  func (c *Cow) GetLactationDays() int32 {
 | 
											
												
													
														|  | -	if c.BreedStatus == pasturePb.BreedStatus_Calving && c.IsRemove == pasturePb.IsShow_Ok {
 |  | 
 | 
											
												
													
														|  | 
 |  | +	if c.BreedStatus == pasturePb.BreedStatus_Calving && c.AdmissionStatus == pasturePb.AdmissionStatus_Admission {
 | 
											
												
													
														|  |  		return int32(math.Floor(float64(time.Now().Unix()-c.LastCalvingAt) / 86400))
 |  |  		return int32(math.Floor(float64(time.Now().Unix()-c.LastCalvingAt) / 86400))
 | 
											
												
													
														|  |  	}
 |  |  	}
 | 
											
												
													
														|  |  	return 0
 |  |  	return 0
 | 
											
										
											
												
													
														|  | @@ -234,7 +236,7 @@ func (c *Cow) GetLactationDays() int32 {
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  // GetAdmissionAge 入场天数
 |  |  // GetAdmissionAge 入场天数
 | 
											
												
													
														|  |  func (c *Cow) GetAdmissionAge() int32 {
 |  |  func (c *Cow) GetAdmissionAge() int32 {
 | 
											
												
													
														|  | -	if c.AdmissionAt > 0 && c.IsRemove == pasturePb.IsShow_Ok {
 |  | 
 | 
											
												
													
														|  | 
 |  | +	if c.AdmissionAt > 0 && c.AdmissionStatus == pasturePb.AdmissionStatus_Admission {
 | 
											
												
													
														|  |  		return int32(math.Floor(float64(time.Now().Unix()-c.AdmissionAt) / 86400))
 |  |  		return int32(math.Floor(float64(time.Now().Unix()-c.AdmissionAt) / 86400))
 | 
											
												
													
														|  |  	}
 |  |  	}
 | 
											
												
													
														|  |  	return 0
 |  |  	return 0
 | 
											
										
											
												
													
														|  | @@ -267,7 +269,7 @@ func (c *Cow) GetAverageDailyWeight() float64 {
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  func (c *Cow) GetAbortionAge() int32 {
 |  |  func (c *Cow) GetAbortionAge() int32 {
 | 
											
												
													
														|  | -	if c.LastAbortionAt > 0 && c.IsRemove == pasturePb.IsShow_Ok {
 |  | 
 | 
											
												
													
														|  | 
 |  | +	if c.LastAbortionAt > 0 && c.AdmissionStatus == pasturePb.AdmissionStatus_Admission {
 | 
											
												
													
														|  |  		return int32(math.Floor(float64(time.Now().Unix()-c.LastAbortionAt) / 86400))
 |  |  		return int32(math.Floor(float64(time.Now().Unix()-c.LastAbortionAt) / 86400))
 | 
											
												
													
														|  |  	}
 |  |  	}
 | 
											
												
													
														|  |  	return 0
 |  |  	return 0
 |