|
@@ -270,8 +270,10 @@ func (e *Entry) UpdateEstrusFirstTime3(pastureId int64, xToday time.Time) {
|
|
|
|
|
|
func (e *Entry) UpdateEstrusIsPeak(pastureId int64) {
|
|
|
neckRingEstrusList := make([]*model.NeckRingEstrus, 0)
|
|
|
+ nowTime := time.Now().Local()
|
|
|
+ firstTime := fmt.Sprintf("%s 00:00:00", nowTime.AddDate(0, 0, -3).Format(model.LayoutDate2))
|
|
|
if err := e.DB.Model(new(model.NeckRingEstrus)).
|
|
|
- Where("first_time >= ?", time.Now().Local().AddDate(0, 0, -1).Format(model.LayoutTime)).
|
|
|
+ Where("first_time >= ?", firstTime).
|
|
|
Where("active_time != ?", "").
|
|
|
Where("pasture_id = ?", pastureId).
|
|
|
Find(&neckRingEstrusList).Error; err != nil {
|
|
@@ -291,7 +293,6 @@ func (e *Entry) UpdateEstrusIsPeak(pastureId int64) {
|
|
|
neckRingEstrusFirstMap[prefix] = append(neckRingEstrusFirstMap[prefix], v)
|
|
|
}
|
|
|
|
|
|
- nowTime := time.Now().Local()
|
|
|
peakIsShow := make([]int64, 0)
|
|
|
for _, estrusItems := range neckRingEstrusFirstMap {
|
|
|
eLen := len(estrusItems)
|
|
@@ -309,12 +310,16 @@ func (e *Entry) UpdateEstrusIsPeak(pastureId int64) {
|
|
|
if sub > 4 && lastItem.IsPeak == pasturePb.IsShow_No {
|
|
|
peakIsShow = append(peakIsShow, lastItem.Id)
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- zaplog.Info("UpdateEstrusIsPeak",
|
|
|
- zap.Any("pastureId", pastureId),
|
|
|
- zap.Any("peakIsShow", peakIsShow),
|
|
|
- )
|
|
|
+ zaplog.Info("UpdateEstrusIsPeak01",
|
|
|
+ zap.Any("pastureId", pastureId),
|
|
|
+ zap.Any("estrusItems", estrusItems),
|
|
|
+ zap.Any("peakIsShow", peakIsShow),
|
|
|
+ zap.Any("lastActiveTime", lastActiveTime),
|
|
|
+ zap.Any("sub", sub),
|
|
|
+ zap.Any("nowTime", nowTime.Format(model.LayoutTime)),
|
|
|
+ )
|
|
|
+ }
|
|
|
|
|
|
if len(peakIsShow) > 0 {
|
|
|
if err := e.DB.Model(new(model.NeckRingEstrus)).
|