|
@@ -747,6 +747,100 @@ func NewCalfCow(matherInfo *Cow, calf *CalvingCalf) *Cow {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// ExcelEnterCow excel导入入场新增牛只
|
|
|
+func ExcelEnterCow(pastureId int64, req *pasturePb.EventEnterRequest) *Cow {
|
|
|
+ var isPregnant = pasturePb.IsShow_No
|
|
|
+ if req.BreedStatus == pasturePb.BreedStatus_Pregnant {
|
|
|
+ isPregnant = pasturePb.IsShow_Ok
|
|
|
+ }
|
|
|
+
|
|
|
+ admissionAt := int64(0)
|
|
|
+ switch req.CowSource {
|
|
|
+ case pasturePb.CowSource_Calving:
|
|
|
+ admissionAt = int64(req.BirthAt)
|
|
|
+ case pasturePb.CowSource_Transfer_In:
|
|
|
+ admissionAt = int64(req.EnterAt)
|
|
|
+ case pasturePb.CowSource_Buy:
|
|
|
+ admissionAt = int64(req.EnterAt)
|
|
|
+ }
|
|
|
+
|
|
|
+ breedStatus := pasturePb.BreedStatus_Invalid
|
|
|
+ if req.Sex == pasturePb.Genders_Female {
|
|
|
+ if req.Lact == 0 && req.MatingAt <= 0 {
|
|
|
+ breedStatus = pasturePb.BreedStatus_UnBreed
|
|
|
+ }
|
|
|
+
|
|
|
+ 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.MatingAt > 0 && req.PregnantCheckResult == pasturePb.PregnantCheckResult_Pregnant &&
|
|
|
+ req.MatingAt >= req.CalvingAt && req.MatingAt >= req.AbortionAt {
|
|
|
+ breedStatus = pasturePb.BreedStatus_Pregnant
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.MatingAt > 0 && req.PregnantCheckResult == pasturePb.PregnantCheckResult_UnPregnant &&
|
|
|
+ req.MatingAt >= req.CalvingAt && req.MatingAt >= req.AbortionAt {
|
|
|
+ breedStatus = pasturePb.BreedStatus_Empty
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.CalvingAt > 0 && req.CalvingAt >= req.MatingAt && req.CalvingAt >= req.AbortionAt {
|
|
|
+ breedStatus = pasturePb.BreedStatus_Calving
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.AbortionAt > 0 && req.AbortionAt >= req.CalvingAt && req.AbortionAt >= req.MatingAt {
|
|
|
+ breedStatus = pasturePb.BreedStatus_Abort
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ cow := &Cow{
|
|
|
+ PastureId: pastureId,
|
|
|
+ Sex: req.Sex,
|
|
|
+ EarNumber: req.EarNumber,
|
|
|
+ PenId: req.PenId,
|
|
|
+ PenName: req.PenName,
|
|
|
+ Lact: req.Lact,
|
|
|
+ CowType: req.CowType,
|
|
|
+ BreedStatus: breedStatus,
|
|
|
+ CowKind: req.CowKind,
|
|
|
+ SourceKind: req.CowSource,
|
|
|
+ FatherNumber: req.FatherNumber,
|
|
|
+ MotherNumber: req.MotherNumber,
|
|
|
+ AdmissionStatus: pasturePb.AdmissionStatus_Admission,
|
|
|
+ HealthStatus: pasturePb.HealthStatus_Health,
|
|
|
+ PurposeKind: req.PurposeKind,
|
|
|
+ EleEarNumber: req.EleEarNumber,
|
|
|
+ IsPregnant: isPregnant,
|
|
|
+ IsForbiddenMating: req.IsForbiddenMatingKind,
|
|
|
+ WeaningAt: int64(req.WeaningAt),
|
|
|
+ BirthAt: int64(req.BirthAt),
|
|
|
+ AdmissionWeight: int64(req.Weight * 1000),
|
|
|
+ FirstMatingAt: int64(req.MatingAt),
|
|
|
+ LastMatingAt: int64(req.MatingAt),
|
|
|
+ LastPregnantCheckAt: int64(req.PregnancyCheckAt),
|
|
|
+ AdmissionAt: admissionAt,
|
|
|
+ BirthWeight: int64(req.Weight * 1000),
|
|
|
+ LastWeightAt: int64(req.EstrusAt),
|
|
|
+ CurrentWeight: int64(req.Weight * 1000),
|
|
|
+ LastDryMilkAt: int64(req.DryMilkAt),
|
|
|
+ MatingTimes: req.MatingTimes,
|
|
|
+ LastCalvingAt: int64(req.CalvingAt),
|
|
|
+ LastBullNumber: req.BullNumber,
|
|
|
+ LastAbortionAt: int64(req.AbortionAt),
|
|
|
+ AdmissionPrice: req.Price,
|
|
|
+ BatchNumber: req.BatchNumber,
|
|
|
+ NeckRingNumber: req.NeckRingNumber,
|
|
|
+ }
|
|
|
+ cow.AdmissionAge = cow.GetAdmissionAge()
|
|
|
+ cow.DayAge = cow.GetDayAge()
|
|
|
+ return cow
|
|
|
+}
|
|
|
+
|
|
|
type BarCowStruct struct {
|
|
|
Number int32 `json:"number"`
|
|
|
TypeId pasturePb.CowType_Kind `json:"type_id"`
|