neck_ring_health.go 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. EarNumber string `json:"earNumber"`
  12. CowId int64 `json:"cowId"`
  13. Lact int32 `json:"lact"`
  14. CalvingAge int32 `json:"calvingAge"`
  15. HeatDate string `json:"heatDate"`
  16. Frameid int32 `json:"frameid"`
  17. ActiveTime string `json:"activeTime"`
  18. ChangeFilter int32 `json:"changeFilter"`
  19. ChewFilter int32 `json:"chewFilter"`
  20. SumChew int32 `json:"sumChew"`
  21. SumInactive int32 `json:"sumInactive"`
  22. BeforeThreeSumChew int32 `json:"beforeThreeSumChew"`
  23. MinHigh int32 `json:"minHigh"`
  24. MaxHigh int32 `json:"maxHigh"`
  25. MinChew int32 `json:"minChew"`
  26. MinInactive int32 `json:"minInactive"`
  27. Score int32 `json:"score"`
  28. FilterMilk int32 `json:"filterMilk"`
  29. IsTransferGroup pasturePb.IsShow_Kind `json:"isTransferGroup"`
  30. IsDryMilk pasturePb.IsShow_Kind `json:"isDryMilk"`
  31. IsImmunization pasturePb.IsShow_Kind `json:"isImmunization"`
  32. IsWorse pasturePb.IsShow_Kind `json:"isWorse"`
  33. CheckResult pasturePb.CheckResult_Kind `json:"checkResult"`
  34. CheckUserId int64 `json:"checkUserId"`
  35. CheckUserName string `json:"checkUserName"`
  36. CheckAt int64 `json:"checkAt"`
  37. IsShow pasturePb.IsShow_Kind `json:"isShow"`
  38. CreatedAt int64 `json:"createdAt"`
  39. UpdatedAt int64 `json:"updatedAt"`
  40. }
  41. func (h *NeckRingHealth) TableName() string {
  42. return "neck_ring_health"
  43. }
  44. func NewNeckRingHealth(habit *NeckActiveHabit, sumChew, chew3dago int32) *NeckRingHealth {
  45. return &NeckRingHealth{
  46. PastureId: habit.PastureId,
  47. NeckRingNumber: habit.NeckRingNumber,
  48. EarNumber: habit.EarNumber,
  49. CowId: habit.CowId,
  50. Lact: habit.Lact,
  51. CalvingAge: habit.CalvingAge,
  52. HeatDate: habit.HeatDate,
  53. Frameid: habit.Frameid,
  54. ActiveTime: habit.ActiveTime,
  55. ChangeFilter: getAbleInt(habit.ChangeFilter),
  56. ChewFilter: getAbleInt(habit.ChewFilter),
  57. SumChew: sumChew,
  58. SumInactive: habit.SumInactive,
  59. BeforeThreeSumChew: chew3dago,
  60. MinHigh: getAbleInt(habit.SumMinHigh),
  61. MaxHigh: getAbleInt(habit.SumMaxHigh),
  62. MinChew: getAbleInt(habit.SumMinChew),
  63. MinInactive: getAbleInt(habit.SumInactive),
  64. Score: habit.Score,
  65. FilterMilk: 0,
  66. IsWorse: 0,
  67. IsTransferGroup: pasturePb.IsShow_No,
  68. IsDryMilk: pasturePb.IsShow_No,
  69. IsImmunization: pasturePb.IsShow_No,
  70. CheckResult: pasturePb.CheckResult_Pending,
  71. IsShow: pasturePb.IsShow_Ok,
  72. }
  73. }
  74. func getAbleInt(value int32) int32 {
  75. if value > -99 {
  76. return value
  77. }
  78. return 0
  79. }