neck_ring_health.go 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. package model
  2. import (
  3. "time"
  4. pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  5. )
  6. const (
  7. MinScore = 1
  8. MaxScore = 84
  9. )
  10. type NeckRingHealth struct {
  11. Id int64 `json:"id"`
  12. PastureId int64 `json:"pastureId"`
  13. NeckRingNumber string `json:"neckRingNumber"`
  14. EarNumber string `json:"earNumber"`
  15. CowId int64 `json:"cowId"`
  16. Lact int32 `json:"lact"`
  17. CalvingAge int32 `json:"calvingAge"`
  18. HeatDate string `json:"heatDate"`
  19. Frameid int32 `json:"frameid"`
  20. ActiveTime string `json:"activeTime"`
  21. ChangeFilter int32 `json:"changeFilter"`
  22. ChewFilter int32 `json:"chewFilter"`
  23. SumChew int32 `json:"sumChew"`
  24. SumInactive int32 `json:"sumInactive"`
  25. BeforeThreeSumChew int32 `json:"beforeThreeSumChew"`
  26. MinHigh int32 `json:"minHigh"`
  27. MaxHigh int32 `json:"maxHigh"`
  28. MinChew int32 `json:"minChew"`
  29. MinInactive int32 `json:"minInactive"`
  30. Score int32 `json:"score"`
  31. FilterMilk int32 `json:"filterMilk"`
  32. IsTransferGroup pasturePb.IsShow_Kind `json:"isTransferGroup"`
  33. IsDryMilk pasturePb.IsShow_Kind `json:"isDryMilk"`
  34. IsImmunization pasturePb.IsShow_Kind `json:"isImmunization"`
  35. IsWorse pasturePb.IsShow_Kind `json:"isWorse"`
  36. CheckResult pasturePb.CheckResult_Kind `json:"checkResult"`
  37. CheckUserId int64 `json:"checkUserId"`
  38. CheckUserName string `json:"checkUserName"`
  39. CheckAt int64 `json:"checkAt"`
  40. IsShow pasturePb.IsShow_Kind `json:"isShow"`
  41. CreatedAt int64 `json:"createdAt"`
  42. UpdatedAt int64 `json:"updatedAt"`
  43. }
  44. func (n *NeckRingHealth) TableName() string {
  45. return "neck_ring_health"
  46. }
  47. func (n *NeckRingHealth) EventDiseaseUpdate(operationUser *SystemUser) {
  48. n.IsShow = pasturePb.IsShow_No
  49. n.CheckResult = pasturePb.CheckResult_Correct
  50. n.CheckUserId = operationUser.Id
  51. n.CheckUserName = operationUser.Name
  52. n.CreatedAt = time.Now().Local().Unix()
  53. }
  54. func NewNeckRingHealth(habit *NeckActiveHabit, sumChew, chew3dago int32) *NeckRingHealth {
  55. return &NeckRingHealth{
  56. PastureId: habit.PastureId,
  57. NeckRingNumber: habit.NeckRingNumber,
  58. EarNumber: habit.EarNumber,
  59. CowId: habit.CowId,
  60. Lact: habit.Lact,
  61. CalvingAge: habit.CalvingAge,
  62. HeatDate: habit.HeatDate,
  63. Frameid: habit.Frameid,
  64. ActiveTime: habit.ActiveTime,
  65. ChangeFilter: getAbleInt(habit.ChangeFilter),
  66. ChewFilter: getAbleInt(habit.ChewFilter),
  67. SumChew: sumChew,
  68. SumInactive: habit.SumInactive,
  69. BeforeThreeSumChew: chew3dago,
  70. MinHigh: getAbleInt(habit.SumMinHigh),
  71. MaxHigh: getAbleInt(habit.SumMaxHigh),
  72. MinChew: getAbleInt(habit.SumMinChew),
  73. MinInactive: getAbleInt(habit.SumInactive),
  74. Score: habit.Score,
  75. FilterMilk: 0,
  76. IsWorse: 0,
  77. IsTransferGroup: pasturePb.IsShow_No,
  78. IsDryMilk: pasturePb.IsShow_No,
  79. IsImmunization: pasturePb.IsShow_No,
  80. CheckResult: pasturePb.CheckResult_Pending,
  81. IsShow: pasturePb.IsShow_Ok,
  82. }
  83. }
  84. func getAbleInt(value int32) int32 {
  85. if value > -99 {
  86. return value
  87. }
  88. return 0
  89. }