neck_ring_health.go 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package model
  2. import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  3. const (
  4. MinScore = 1
  5. MaxScore = 84
  6. )
  7. type NeckRingHealth struct {
  8. Id int64 `json:"id"`
  9. PastureId int64 `json:"pastureId"`
  10. NeckRingNumber string `json:"neckRingNumber"`
  11. CowId int64 `json:"cowId"`
  12. Lact int32 `json:"lact"`
  13. CalvingAge int32 `json:"calvingAge"`
  14. HeatDate string `json:"heatDate"`
  15. Frameid int32 `json:"frameid"`
  16. ActiveTime string `json:"activeTime"`
  17. ChangeFilter int32 `json:"changeFilter"`
  18. ChewFilter int32 `json:"chewFilter"`
  19. SumChew int32 `json:"sumChew"`
  20. SumInactive int32 `json:"sumInactive"`
  21. BeforeThreeSumChew int32 `json:"beforeThreeSumChew"`
  22. MinHigh int32 `json:"minHigh"`
  23. MaxHigh int32 `json:"maxHigh"`
  24. MinChew int32 `json:"minChew"`
  25. MinInactive int32 `json:"minInactive"`
  26. Score int32 `json:"score"`
  27. IsWorse pasturePb.IsShow_Kind `json:"isWorse"`
  28. CheckResult pasturePb.CheckResult_Kind `json:"checkResult"`
  29. CreatedAt int64 `json:"createdAt"`
  30. UpdatedAt int64 `json:"updatedAt"`
  31. }
  32. func (h *NeckRingHealth) TableName() string {
  33. return "neck_ring_health"
  34. }
  35. func NewNeckRingHealth(habit *NeckActiveHabit, sumChew, chew3dago int32) *NeckRingHealth {
  36. return &NeckRingHealth{
  37. PastureId: habit.PastureId,
  38. NeckRingNumber: habit.NeckRingNumber,
  39. CowId: habit.CowId,
  40. Lact: habit.Lact,
  41. CalvingAge: habit.CalvingAge,
  42. HeatDate: habit.HeatDate,
  43. Frameid: habit.Frameid,
  44. ActiveTime: habit.ActiveTime,
  45. ChangeFilter: getAbleInt(habit.ChangeFilter),
  46. ChewFilter: getAbleInt(habit.ChewFilter),
  47. SumChew: sumChew,
  48. SumInactive: habit.SumInactive,
  49. BeforeThreeSumChew: chew3dago,
  50. MinHigh: getAbleInt(habit.SumMinHigh),
  51. MaxHigh: getAbleInt(habit.SumMaxHigh),
  52. MinChew: getAbleInt(habit.SumMinChew),
  53. MinInactive: getAbleInt(habit.SumInactive),
  54. Score: habit.Score,
  55. IsWorse: 0,
  56. CheckResult: pasturePb.CheckResult_Pending,
  57. }
  58. }
  59. func getAbleInt(value int32) int32 {
  60. if value > -99 {
  61. return value
  62. }
  63. return 0
  64. }