소스 검색

event: 入场增加牧场Id字段

Yi 2 달 전
부모
커밋
c03cf0841b
3개의 변경된 파일4개의 추가작업 그리고 3개의 파일을 삭제
  1. 2 1
      model/cow.go
  2. 1 1
      module/backend/event_base.go
  3. 1 1
      module/crontab/neck_ring_estrus.go

+ 2 - 1
model/cow.go

@@ -319,12 +319,13 @@ func (c CowSlice) ToPB2(penMap map[int32]*Pen, penWeightSlice PenWeightSlice) []
 	return res
 }
 
-func NewCow(req *pasturePb.EventEnterRequest) *Cow {
+func NewCow(current *SystemUser, req *pasturePb.EventEnterRequest) *Cow {
 	var isPregnant = pasturePb.IsShow_No
 	if req.BreedStatus == pasturePb.BreedStatus_Pregnant {
 		isPregnant = pasturePb.IsShow_Ok
 	}
 	return &Cow{
+		PastureId:           current.PastureId,
 		Sex:                 req.Sex,
 		EarNumber:           req.EarNumber,
 		PenId:               req.PenId,

+ 1 - 1
module/backend/event_base.go

@@ -90,7 +90,7 @@ func (s *StoreEntry) CreateEnter(ctx context.Context, req *pasturePb.EventEnterR
 		req.OperationName = systemUser.Name
 	}
 
-	newCowData := model.NewCow(req)
+	newCowData := model.NewCow(currentUser, req)
 	newEventEnter := model.NewEventEnter(currentUser.PastureId, newCowData.Id, req)
 	if err = s.DB.Transaction(func(tx *gorm.DB) error {
 		if err = tx.Create(newCowData).Error; err != nil {

+ 1 - 1
module/crontab/neck_ring_estrus.go

@@ -57,7 +57,7 @@ func (e *Entry) EntryCowEstrus(pastureId int64) (err error) {
 
 	// 将历史发情预警数据更新为已过期
 	if err = e.DB.Model(new(model.EventEstrus)).
-		Where("estrus_start_date >= ?", time.Now().AddDate(0, 0, -4).Format(model.LayoutTime)).
+		Where("estrus_start_date <= ?", time.Now().AddDate(0, 0, -4).Format(model.LayoutTime)).
 		Update("is_show", pasturePb.IsShow_No).Error; err != nil {
 		zaplog.Error("EntryCowEstrus", zap.Any("UpdateEventEstrus", err))
 	}