Yi 2 сар өмнө
parent
commit
20cd5a082d

+ 2 - 2
model/cow.go

@@ -367,7 +367,7 @@ func NewCow(pastureId int64, req *pasturePb.EventEnterRequest, penMap map[int32]
 	}
 }
 
-func NewCalfCow(motherId int64, fatherNumber string, calf *CalvingCalf) *Cow {
+func NewCalfCow(motherNumber, fatherNumber string, calf *CalvingCalf) *Cow {
 	return &Cow{
 		PastureId:       calf.PastureId,
 		Sex:             calf.Sex,
@@ -381,7 +381,7 @@ func NewCalfCow(motherId int64, fatherNumber string, calf *CalvingCalf) *Cow {
 		BirthAt:         calf.BirthAt,
 		SourceId:        pasturePb.CowSource_Calving, // 产犊方式
 		FatherNumber:    fatherNumber,
-		MotherNumber:    fmt.Sprintf("%d", motherId),
+		MotherNumber:    motherNumber,
 		AdmissionStatus: pasturePb.AdmissionStatus_Admission,
 		IsPregnant:      pasturePb.IsShow_No,
 		AdmissionAt:     calf.BirthAt,

+ 4 - 4
module/backend/event_breed.go

@@ -123,16 +123,16 @@ func (s *StoreEntry) CalvingCreate(ctx context.Context, req *pasturePb.EventCalv
 				continue
 			}
 
-			newCow := model.NewCalfCow(cow.Id, cow.LastBullNumber, newCalvingCalf)
-			if err = tx.Create(newCow).Error; err != nil {
+			newCalfCow := model.NewCalfCow(cow.NeckRingNumber, cow.LastBullNumber, newCalvingCalf)
+			if err = tx.Create(newCalfCow).Error; err != nil {
 				return xerr.WithStack(err)
 			}
-			if err = tx.Model(new(model.CalvingCalf)).Where("id = ?", newCalvingCalf.Id).Update("cow_id", newCow.Id).Error; err != nil {
+			if err = tx.Model(new(model.CalvingCalf)).Where("id = ?", newCalvingCalf.Id).Update("cow_id", newCalfCow.Id).Error; err != nil {
 				return xerr.WithStack(err)
 			}
 
 			// 犊牛日志
-			cowLogs := s.SubmitEventLog(ctx, userModel.AppPasture.Id, newCow, pasturePb.EventType_Birth, pasturePb.ExposeEstrusType_Invalid, calf)
+			cowLogs := s.SubmitEventLog(ctx, userModel.AppPasture.Id, newCalfCow, pasturePb.EventType_Birth, pasturePb.ExposeEstrusType_Invalid, calf)
 			if err = tx.Table(cowLogs.TableName()).Create(cowLogs).Error; err != nil {
 				return xerr.WithStack(err)
 			}

+ 1 - 1
module/backend/event_cow_log.go

@@ -112,7 +112,7 @@ func (s *StoreEntry) SubmitEventLog(
 		remarks = data.Remarks
 	case pasturePb.EventType_Birth:
 		eventAt = cow.BirthAt
-		desc = fmt.Sprintf("出生体重: %s KG;母号:%s;父号: %s", strconv.FormatFloat(float64(cow.BirthWeight)/1000, 'f', 2, 64), cow.MotherNumber, cow.LastBullNumber)
+		desc = fmt.Sprintf("出生体重: %s KG;母号:%s;父号: %s", strconv.FormatFloat(float64(cow.BirthWeight)/1000, 'f', 2, 64), cow.MotherNumber, cow.FatherNumber)
 	case pasturePb.EventType_Death:
 		data := req.(*model.EventDeparture)
 		eventAt = data.DepartureAt