neck_ring_health_warning.go 2.8 KB

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