neck_ring_health.go 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. FilterMilk int32 `json:"filterMilk"`
  28. IsTransferGroup pasturePb.IsShow_Kind `json:"isTransferGroup"`
  29. IsDryMilk pasturePb.IsShow_Kind `json:"isDryMilk"`
  30. IsImmunization pasturePb.IsShow_Kind `json:"isImmunization"`
  31. IsWorse pasturePb.IsShow_Kind `json:"isWorse"`
  32. CheckResult pasturePb.CheckResult_Kind `json:"checkResult"`
  33. CheckUserId int64 `json:"checkUserId"`
  34. CheckUserName string `json:"checkUserName"`
  35. CheckAt int64 `json:"checkAt"`
  36. IsShow pasturePb.IsShow_Kind `json:"isShow"`
  37. CreatedAt int64 `json:"createdAt"`
  38. UpdatedAt int64 `json:"updatedAt"`
  39. }
  40. func (h *NeckRingHealth) TableName() string {
  41. return "neck_ring_health"
  42. }
  43. func NewNeckRingHealth(habit *NeckActiveHabit, sumChew, chew3dago int32) *NeckRingHealth {
  44. return &NeckRingHealth{
  45. PastureId: habit.PastureId,
  46. NeckRingNumber: habit.NeckRingNumber,
  47. CowId: habit.CowId,
  48. Lact: habit.Lact,
  49. CalvingAge: habit.CalvingAge,
  50. HeatDate: habit.HeatDate,
  51. Frameid: habit.Frameid,
  52. ActiveTime: habit.ActiveTime,
  53. ChangeFilter: getAbleInt(habit.ChangeFilter),
  54. ChewFilter: getAbleInt(habit.ChewFilter),
  55. SumChew: sumChew,
  56. SumInactive: habit.SumInactive,
  57. BeforeThreeSumChew: chew3dago,
  58. MinHigh: getAbleInt(habit.SumMinHigh),
  59. MaxHigh: getAbleInt(habit.SumMaxHigh),
  60. MinChew: getAbleInt(habit.SumMinChew),
  61. MinInactive: getAbleInt(habit.SumInactive),
  62. Score: habit.Score,
  63. FilterMilk: 0,
  64. IsWorse: 0,
  65. IsTransferGroup: pasturePb.IsShow_No,
  66. IsDryMilk: pasturePb.IsShow_No,
  67. IsImmunization: pasturePb.IsShow_No,
  68. CheckResult: pasturePb.CheckResult_Pending,
  69. IsShow: pasturePb.IsShow_Ok,
  70. }
  71. }
  72. func getAbleInt(value int32) int32 {
  73. if value > -99 {
  74. return value
  75. }
  76. return 0
  77. }