|
@@ -232,12 +232,12 @@ func CalculateScore(appPasture *model.AppPastureList, habit *model.NeckActiveHab
|
|
|
part1 = math.Min((float64(habit.SumRumina+habit.SumIntake)-(100+math.Min(7, float64(habit.CalvingAge))*60))/10*2, 0)
|
|
|
case habit.ChangeFilter > -99:
|
|
|
if appPasture.Category == pasturePb.PastureCategory_Beef {
|
|
|
- part1 = math.Min(0, math.Min(getValueOrDefault(float64(habit.ChangeFilter)-math.Min(float64(habit.ChangeAdjust), 0), 0), getValueOrDefault(float64(habit.SumMinHigh), 0)))*0.2 +
|
|
|
+ part1 = getBeefSoreV1(habit) +
|
|
|
getBeefSportsRuminaScore(habit) +
|
|
|
getBeefRuminaSumIntakeSumScore(habit) +
|
|
|
getBeefAdditionalScore(habit)
|
|
|
} else {
|
|
|
- part1 = math.Min(0, math.Min(getValueOrDefault(float64(habit.ChangeFilter), 0), getValueOrDefault(float64(habit.SumMinHigh), 0)))*0.2 +
|
|
|
+ part1 = getCowSoreV1(habit) +
|
|
|
getCowSportsRuminaScore(habit) +
|
|
|
getCowRuminaSumIntakeSumScore(habit) +
|
|
|
getCowAdditionalScore(habit)
|
|
@@ -246,6 +246,12 @@ func CalculateScore(appPasture *model.AppPastureList, habit *model.NeckActiveHab
|
|
|
part1 = -299
|
|
|
}
|
|
|
|
|
|
+ fmt.Println("part1", part1)
|
|
|
+ fmt.Println("v1", getBeefSoreV1(habit))
|
|
|
+ fmt.Println("v2", getBeefSportsRuminaScore(habit))
|
|
|
+ fmt.Println("v3", getBeefRuminaSumIntakeSumScore(habit))
|
|
|
+ fmt.Println("v4", getBeefAdditionalScore(habit))
|
|
|
+
|
|
|
// 第二部分逻辑
|
|
|
var part2 float64
|
|
|
versionMod := habit.FirmwareVersion % 100
|
|
@@ -268,6 +274,14 @@ func getValueOrDefault(value, defaultValue float64) float64 {
|
|
|
return defaultValue
|
|
|
}
|
|
|
|
|
|
+func getCowSoreV1(habit *model.NeckActiveHabit) float64 {
|
|
|
+ return math.Min(0, math.Min(getValueOrDefault(float64(habit.ChangeFilter), 0), getValueOrDefault(float64(habit.SumMinHigh), 0))) * 0.2
|
|
|
+}
|
|
|
+
|
|
|
+func getBeefSoreV1(habit *model.NeckActiveHabit) float64 {
|
|
|
+ return math.Min(0, math.Min(getValueOrDefault(float64(habit.ChangeFilter)-math.Min(float64(habit.ChangeAdjust), 0), 0), getValueOrDefault(float64(habit.SumMinHigh), 0))) * 0.2
|
|
|
+}
|
|
|
+
|
|
|
// 奶牛运动得反刍分
|
|
|
// LEAST(0, IF(h.chew_filter>-99, h.chew_filter, 0), IF(h.sum_min_chew>-99, h.sum_min_chew, 0))*0.2
|
|
|
func getCowSportsRuminaScore(habit *model.NeckActiveHabit) float64 {
|
|
@@ -297,7 +311,7 @@ func getCowRuminaSumIntakeSumScore(habit *model.NeckActiveHabit) float64 {
|
|
|
// 肉牛累计反刍得分
|
|
|
func getBeefRuminaSumIntakeSumScore(habit *model.NeckActiveHabit) float64 {
|
|
|
sum := float64(habit.SumRumina + habit.SumIntake)
|
|
|
- return math.Min(0, sum-380/10)
|
|
|
+ return math.Min(0, (sum-380)/10)
|
|
|
}
|
|
|
|
|
|
// 奶牛当前变化趋势是否是峰值
|
|
@@ -313,11 +327,15 @@ func getCowAdditionalScore(habit *model.NeckActiveHabit) float64 {
|
|
|
}
|
|
|
|
|
|
// 肉牛当前变化趋势是否是峰值
|
|
|
-// IF((h.change_filter -LEAST(h.change_adjust,0))<-30 AND (h.change_filter -LEAST(h.change_adjust,0))<=h.sum_min_high AND h.chew_filter<-30 AND h.chew_filter<=h.sum_min_chew, -5, 0)
|
|
|
+// + IF(((h.sum_rumina + h.sum_intake )<280 OR (h.sum_min_high +h.sum_min_chew)<-50) AND h.sum_max_high>50, 10, 0)
|
|
|
+// + IF((h.change_filter -LEAST(h.change_adjust,0))<-30 AND (h.change_filter -LEAST(h.change_adjust,0))<=h.sum_min_high AND h.chew_filter<-30 AND h.chew_filter<=h.sum_min_chew, -5, 0)
|
|
|
func getBeefAdditionalScore(habit *model.NeckActiveHabit) float64 {
|
|
|
var score float64
|
|
|
- if (float64(habit.ChangeFilter)-math.Min(float64(habit.ChangeAdjust), 0)) < -30 &&
|
|
|
- (float64(habit.ChangeFilter)-math.Min(float64(habit.ChangeAdjust), 0)) <= float64(habit.SumMinHigh) &&
|
|
|
+ if (habit.SumRumina+habit.SumIntake < 280 || habit.SumMinHigh+habit.SumMinChew < -50) && habit.SumMaxHigh > 50 {
|
|
|
+ score += 10
|
|
|
+ }
|
|
|
+ if float64(habit.ChangeFilter)-math.Min(float64(habit.ChangeAdjust), 0) < -30 &&
|
|
|
+ float64(habit.ChangeFilter)-math.Min(float64(habit.ChangeAdjust), 0) <= float64(habit.SumMinHigh) &&
|
|
|
habit.ChewFilter < -30 && habit.ChewFilter <= habit.SumMinChew {
|
|
|
score -= 5
|
|
|
}
|