|
@@ -14,6 +14,7 @@ import (
|
|
"go.uber.org/zap"
|
|
"go.uber.org/zap"
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+// HealthWarning 健康预警 create_jbq_update_2024
|
|
func (e *Entry) HealthWarning(pastureId int64, processIds []int64) {
|
|
func (e *Entry) HealthWarning(pastureId int64, processIds []int64) {
|
|
newNeckActiveHabitList := make([]*model.NeckActiveHabit, 0)
|
|
newNeckActiveHabitList := make([]*model.NeckActiveHabit, 0)
|
|
if err := e.DB.Model(new(model.NeckActiveHabit)).
|
|
if err := e.DB.Model(new(model.NeckActiveHabit)).
|
|
@@ -236,7 +237,18 @@ func (e *Entry) FindNewNeckRingHealthWarning(pastureId int64, healthValue int32)
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if e.FindNeckRingError(pastureId, cowInfo.NeckRingNumber) {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+
|
|
newNeckRingHealthWarning := model.NewNeckRingHealthWarning(pastureId, v, cowInfo, newScore)
|
|
newNeckRingHealthWarning := model.NewNeckRingHealthWarning(pastureId, v, cowInfo, newScore)
|
|
|
|
+ zaplog.Info("newNeckRingHealthWarning",
|
|
|
|
+ zap.Any("newNeckRingHealthWarning", newNeckRingHealthWarning),
|
|
|
|
+ zap.Any("pastureId", pastureId),
|
|
|
|
+ zap.Any("neckRingHealth", v),
|
|
|
|
+ zap.Any("cowInfo", cowInfo),
|
|
|
|
+ zap.Any("newScore", newScore),
|
|
|
|
+ )
|
|
newNeckRingHealthWarningList = append(newNeckRingHealthWarningList, newNeckRingHealthWarning)
|
|
newNeckRingHealthWarningList = append(newNeckRingHealthWarningList, newNeckRingHealthWarning)
|
|
}
|
|
}
|
|
return newNeckRingHealthWarningList, nil
|
|
return newNeckRingHealthWarningList, nil
|
|
@@ -248,7 +260,20 @@ func (e *Entry) HistoryNeckRingHealthWarning(pastureId int64, neckRingNumber str
|
|
Where("pasture_id = ?", pastureId).
|
|
Where("pasture_id = ?", pastureId).
|
|
Where("neck_ring_number = ?", neckRingNumber).
|
|
Where("neck_ring_number = ?", neckRingNumber).
|
|
Where("heat_date = ?", heatDate).
|
|
Where("heat_date = ?", heatDate).
|
|
- Where("is_show = ?", pasturePb.IsShow_No).
|
|
|
|
|
|
+ Where("is_show = ?", pasturePb.IsShow_Ok).
|
|
|
|
+ Count(&count).Error; err != nil {
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ return count > 0
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (e *Entry) FindNeckRingError(pastureId int64, neckRingNumber string) bool {
|
|
|
|
+ var count int64
|
|
|
|
+ if err := e.DB.Model(new(model.NeckRing)).
|
|
|
|
+ Where("pasture_id = ?", pastureId).
|
|
|
|
+ Where("neck_ring_number = ?", neckRingNumber).
|
|
|
|
+ Where("status = ?", pasturePb.IsShow_No).
|
|
|
|
+ Where("error_kind = ?", pasturePb.NeckRingNumberError_Suspected_Fall_Off).
|
|
Count(&count).Error; err != nil {
|
|
Count(&count).Error; err != nil {
|
|
return false
|
|
return false
|
|
}
|
|
}
|