|
@@ -64,31 +64,99 @@ func (c CowSlice) ToPB(
|
|
cowTypeMap map[pasturePb.CowType_Kind]string,
|
|
cowTypeMap map[pasturePb.CowType_Kind]string,
|
|
breedStatusMap map[pasturePb.BreedStatus_Kind]string,
|
|
breedStatusMap map[pasturePb.BreedStatus_Kind]string,
|
|
cowKindMap map[pasturePb.CowKind_Kind]string,
|
|
cowKindMap map[pasturePb.CowKind_Kind]string,
|
|
-) []*pasturePb.SearchCowList {
|
|
|
|
- res := make([]*pasturePb.SearchCowList, len(c))
|
|
|
|
|
|
+ cowSourceMap map[pasturePb.CowSource_Kind]string,
|
|
|
|
+ admissionStatusMap map[pasturePb.AdmissionStatus_Kind]string,
|
|
|
|
+ healthStatusMap map[pasturePb.HealthStatus_Kind]string,
|
|
|
|
+) []*pasturePb.CowDetails {
|
|
|
|
+ res := make([]*pasturePb.CowDetails, len(c))
|
|
for i, v := range c {
|
|
for i, v := range c {
|
|
penName := ""
|
|
penName := ""
|
|
if pen, ok := penMap[v.PenId]; ok {
|
|
if pen, ok := penMap[v.PenId]; ok {
|
|
penName = pen.Name
|
|
penName = pen.Name
|
|
}
|
|
}
|
|
- res[i] = &pasturePb.SearchCowList{
|
|
|
|
- CowId: int32(v.Id),
|
|
|
|
- Sex: v.Sex,
|
|
|
|
- NeckRingNumber: v.NeckRingNumber,
|
|
|
|
- EarNumber: v.EarNumber,
|
|
|
|
- PenId: v.PenId,
|
|
|
|
- PenName: penName,
|
|
|
|
- CowType: int32(v.CowType),
|
|
|
|
- Lact: v.Lact,
|
|
|
|
- CowTypeName: cowTypeMap[v.CowType],
|
|
|
|
- BreedStatus: v.BreedStatus,
|
|
|
|
- BreedStatusName: breedStatusMap[v.BreedStatus],
|
|
|
|
- CowKind: v.CowKind,
|
|
|
|
- CowKindName: cowKindMap[v.CowKind],
|
|
|
|
- BirthAt: int32(v.BirthAt),
|
|
|
|
- BirthWeight: int32(v.BirthWeight) / 1000,
|
|
|
|
- CurrentWeight: int32(v.CurrentWeight) / 1000,
|
|
|
|
- LastWeightAt: int32(v.LastWeightAt),
|
|
|
|
|
|
+
|
|
|
|
+ sex := "公"
|
|
|
|
+ if v.Sex == pasturePb.Genders_Female {
|
|
|
|
+ sex = "母"
|
|
|
|
+ }
|
|
|
|
+ lastWeightAtFormat := ""
|
|
|
|
+ if v.LastWeightAt > 0 {
|
|
|
|
+ lastWeightAtFormat = time.Unix(v.LastWeightAt, 0).Format(LayoutDate2)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ isPregnantName := ""
|
|
|
|
+ if v.IsPregnant == pasturePb.IsShow_Ok {
|
|
|
|
+ isPregnantName = "已孕"
|
|
|
|
+ } else {
|
|
|
|
+ isPregnantName = "未孕"
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ admissionAtFormat := ""
|
|
|
|
+ if v.AdmissionAt > 0 {
|
|
|
|
+ admissionAtFormat = time.Unix(v.AdmissionAt, 0).Format(LayoutDate2)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ birthAtFormat := ""
|
|
|
|
+ if v.BirthAt > 0 {
|
|
|
|
+ birthAtFormat = time.Unix(v.BirthAt, 0).Format(LayoutDate2)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ weaningAtFormat := ""
|
|
|
|
+ if v.WeaningAt > 0 {
|
|
|
|
+ weaningAtFormat = time.Unix(v.WeaningAt, 0).Format(LayoutDate2)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ firstMatingAtFormat := ""
|
|
|
|
+ if v.FirstMatingAt > 0 {
|
|
|
|
+ firstMatingAtFormat = time.Unix(v.FirstMatingAt, 0).Format(LayoutDate2)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ lastMatingAtFormat := ""
|
|
|
|
+ if v.LastMatingAt > 0 {
|
|
|
|
+ lastMatingAtFormat = time.Unix(v.LastMatingAt, 0).Format(LayoutDate2)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ lastPregnantCheckAtFormat := ""
|
|
|
|
+ if v.LastPregnantCheckAt > 0 {
|
|
|
|
+ lastPregnantCheckAtFormat = time.Unix(v.LastPregnantCheckAt, 0).Format(LayoutDate2)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ lastCalvingAtFormat := ""
|
|
|
|
+ if v.LastCalvingAt > 0 {
|
|
|
|
+ lastCalvingAtFormat = time.Unix(v.LastCalvingAt, 0).Format(LayoutDate2)
|
|
|
|
+ }
|
|
|
|
+ res[i] = &pasturePb.CowDetails{
|
|
|
|
+ CowId: int32(v.Id),
|
|
|
|
+ Sex: sex,
|
|
|
|
+ NeckRingNumber: v.NeckRingNumber,
|
|
|
|
+ PenName: penName,
|
|
|
|
+ Lact: v.Lact,
|
|
|
|
+ CowTypeName: cowTypeMap[v.CowType],
|
|
|
|
+ BreedStatusName: breedStatusMap[v.BreedStatus],
|
|
|
|
+ CowKindName: cowKindMap[v.CowKind],
|
|
|
|
+ EarNumber: v.EarNumber,
|
|
|
|
+ BirthWeight: float32(v.BirthWeight) / 1000,
|
|
|
|
+ CurrentWeight: float32(v.CurrentWeight) / 1000,
|
|
|
|
+ DayAge: v.DayAge,
|
|
|
|
+ SourceName: cowSourceMap[v.SourceId],
|
|
|
|
+ MontherNumber: v.MotherNumber,
|
|
|
|
+ FatherNumber: v.FatherNumber,
|
|
|
|
+ AdmissionStatusName: admissionStatusMap[v.AdmissionStatus],
|
|
|
|
+ HealthStatusName: healthStatusMap[v.HealthStatus],
|
|
|
|
+ IsPregnantName: isPregnantName,
|
|
|
|
+ AdmissionAtFormat: admissionAtFormat,
|
|
|
|
+ BirthAtFormat: birthAtFormat,
|
|
|
|
+ WeaningAtFormat: weaningAtFormat,
|
|
|
|
+ CalvingAge: int32(v.GetCalvingAge()),
|
|
|
|
+ AbortionAge: int32(v.AbortionAge),
|
|
|
|
+ MatingTimes: v.MatingTimes,
|
|
|
|
+ FirstMatingAtFormat: firstMatingAtFormat,
|
|
|
|
+ LastMatingAtFormat: lastMatingAtFormat,
|
|
|
|
+ LastBullNumber: v.LastBullNumber,
|
|
|
|
+ LastPregnantCheckAtFormat: lastPregnantCheckAtFormat,
|
|
|
|
+ LastWeightAtFormat: lastWeightAtFormat,
|
|
|
|
+ LastCalvingAtFormat: lastCalvingAtFormat,
|
|
|
|
+ //PregnancyAge: v.PregnancyAge,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return res
|
|
return res
|