|
@@ -476,13 +476,60 @@ func NewEnterCow(pastureId int64, req *pasturePb.EventEnterRequest, penMap map[i
|
|
|
admissionAt = int64(req.EnterAt)
|
|
|
}
|
|
|
|
|
|
+ breedStatus := pasturePb.BreedStatus_Invalid
|
|
|
isForbiddenMating := pasturePb.IsShow_No
|
|
|
- if req.BreedStatus == pasturePb.BreedStatus_No_Mating {
|
|
|
- isForbiddenMating = pasturePb.IsShow_Ok
|
|
|
+ cowType := pasturePb.CowType_Invalid
|
|
|
+ if req.Sex == pasturePb.Genders_Female {
|
|
|
+
|
|
|
+ if req.Lact == 0 && req.MatingAt <= 0 {
|
|
|
+ breedStatus = pasturePb.BreedStatus_UnBreed
|
|
|
+ cowType = pasturePb.CowType_Reserve_Calf
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.MatingAt > 0 && (req.PregnantCheckResult != pasturePb.PregnantCheckResult_Pregnant &&
|
|
|
+ req.PregnantCheckResult != pasturePb.PregnantCheckResult_UnPregnant) &&
|
|
|
+ req.MatingAt >= req.CalvingAt && req.MatingAt >= req.AbortionAt {
|
|
|
+ breedStatus = pasturePb.BreedStatus_Breeding
|
|
|
+ if req.Lact == 0 {
|
|
|
+ cowType = pasturePb.CowType_Reserve_Calf
|
|
|
+ } else {
|
|
|
+ cowType = pasturePb.CowType_Breeding_Calf
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.MatingAt > 0 && req.PregnantCheckResult == pasturePb.PregnantCheckResult_Pregnant &&
|
|
|
+ req.MatingAt >= req.CalvingAt && req.MatingAt >= req.AbortionAt {
|
|
|
+ breedStatus = pasturePb.BreedStatus_Pregnant
|
|
|
+ if req.Lact == 0 {
|
|
|
+ cowType = pasturePb.CowType_Reserve_Calf
|
|
|
+ } else {
|
|
|
+ cowType = pasturePb.CowType_Breeding_Calf
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.MatingAt > 0 && req.PregnantCheckResult == pasturePb.PregnantCheckResult_UnPregnant &&
|
|
|
+ req.MatingAt >= req.CalvingAt && req.MatingAt >= req.AbortionAt {
|
|
|
+ breedStatus = pasturePb.BreedStatus_Empty
|
|
|
+ if req.Lact == 0 {
|
|
|
+ cowType = pasturePb.CowType_Reserve_Calf
|
|
|
+ } else {
|
|
|
+ cowType = pasturePb.CowType_Breeding_Calf
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.CalvingAt > 0 && req.CalvingAt >= req.MatingAt && req.CalvingAt >= req.AbortionAt {
|
|
|
+ breedStatus = pasturePb.BreedStatus_Calving
|
|
|
+ cowType = pasturePb.CowType_Breeding_Calf
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.AbortionAt > 0 && req.AbortionAt >= req.CalvingAt && req.AbortionAt >= req.MatingAt {
|
|
|
+ breedStatus = pasturePb.BreedStatus_Abort
|
|
|
+ cowType = pasturePb.CowType_Breeding_Calf
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- if req.PregnantCheckResult == pasturePb.PregnantCheckResult_Pregnant {
|
|
|
- req.BreedStatus = pasturePb.BreedStatus_Pregnant
|
|
|
+ if breedStatus == pasturePb.BreedStatus_No_Mating {
|
|
|
+ isForbiddenMating = pasturePb.IsShow_Ok
|
|
|
}
|
|
|
|
|
|
cow := &Cow{
|
|
@@ -492,8 +539,8 @@ func NewEnterCow(pastureId int64, req *pasturePb.EventEnterRequest, penMap map[i
|
|
|
PenId: req.PenId,
|
|
|
PenName: penMap[req.PenId].Name,
|
|
|
Lact: req.Lact,
|
|
|
- CowType: req.CowType,
|
|
|
- BreedStatus: req.BreedStatus,
|
|
|
+ CowType: cowType,
|
|
|
+ BreedStatus: breedStatus,
|
|
|
CowKind: req.CowKind,
|
|
|
SourceKind: req.CowSource,
|
|
|
FatherNumber: req.FatherNumber,
|
|
@@ -725,6 +772,7 @@ func (c CowSlice) LongTermInfertilityToPB(breedStatusMap map[pasturePb.BreedStat
|
|
|
CalvingAge: v.CalvingAge,
|
|
|
PenName: v.PenName,
|
|
|
BreedStatusName: breedStatusName,
|
|
|
+ BreedStatus: v.BreedStatus,
|
|
|
LastCalvingAtFormat: lastCalvingAtFormat,
|
|
|
LastAbortionAtFormat: lastAbortionAtFormat,
|
|
|
LastMatingAtFormat: lastMatingAtFormat,
|