浏览代码

crontab: cow health 牛只健康

Yi 1 月之前
父节点
当前提交
efb6810608
共有 1 个文件被更改,包括 23 次插入4 次删除
  1. 23 4
      module/crontab/health_warning.go

+ 23 - 4
module/crontab/health_warning.go

@@ -27,21 +27,40 @@ func (e *Entry) HealthWarning(pastureId int64, processIds []int64) {
 		lastScore         int32
 		lastScore         int32
 		healthWarningList []*model.NeckRingHealth
 		healthWarningList []*model.NeckRingHealth
 	)
 	)
+
 	for _, habit := range newNeckActiveHabitList {
 	for _, habit := range newNeckActiveHabitList {
-		// 计算 sumChew 和 chew3dago
+		if habit.ChangeFilter <= -99 {
+			habit.ChangeFilter = 0
+		}
+
+		if habit.ChewFilter <= -99 {
+			habit.ChewFilter = 0
+		}
+
+		if habit.SumMinHigh <= -99 {
+			habit.SumMinHigh = 0
+		}
+
+		if habit.SumMaxHigh <= -99 {
+			habit.SumMaxHigh = 0
+		}
+
+		if habit.SumMinChew <= -99 {
+			habit.SumMinChew = 0
+		}
+
 		sumChew := habit.SumRumina + habit.SumIntake
 		sumChew := habit.SumRumina + habit.SumIntake
 		chew3dago := habit.BeforeThreeSumRumina + habit.BeforeThreeSumIntake
 		chew3dago := habit.BeforeThreeSumRumina + habit.BeforeThreeSumIntake
-		// 判断是否满足 isWorse 条件
+
 		isWorse := 1
 		isWorse := 1
 		if habit.CowId == lastCowID && habit.HeatDate == lastHeatDate && habit.Score >= lastScore {
 		if habit.CowId == lastCowID && habit.HeatDate == lastHeatDate && habit.Score >= lastScore {
 			isWorse = 0
 			isWorse = 0
 		}
 		}
-		// 更新状态
+
 		lastCowID = habit.CowId
 		lastCowID = habit.CowId
 		lastHeatDate = habit.HeatDate
 		lastHeatDate = habit.HeatDate
 		lastScore = habit.Score
 		lastScore = habit.Score
 
 
-		// 如果满足条件,添加到结果中
 		if isWorse == 1 {
 		if isWorse == 1 {
 			newHealthWarning := model.NewNeckRingHealth(habit, sumChew, chew3dago)
 			newHealthWarning := model.NewNeckRingHealth(habit, sumChew, chew3dago)
 			if count := e.FindHealthWarning(pastureId, newHealthWarning); count <= 0 {
 			if count := e.FindHealthWarning(pastureId, newHealthWarning); count <= 0 {