neck_active_habit.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. package model
  2. import (
  3. "fmt"
  4. pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  5. )
  6. const (
  7. DefaultChangeFilter = -10000
  8. DefaultRuminaFilter = -10000
  9. DefaultChewFilter = -10000
  10. DefaultFilterCorrect = 100
  11. DefaultWeeklyActive = 105
  12. )
  13. type NeckActiveHabit struct {
  14. Id int64 `json:"id"`
  15. CowId int64 `json:"cowId"`
  16. NeckRingNumber string `json:"neckRingNumber"`
  17. ActiveTime string `json:"activeTime"`
  18. Frameid int32 `json:"frameid"`
  19. HeatDate string `json:"heatDate"`
  20. Rumina int32 `json:"rumina"`
  21. Intake int32 `json:"intake"`
  22. Inactive int32 `json:"inactive"`
  23. Gasp int32 `json:"gasp"`
  24. Other int32 `json:"other"`
  25. High int32 `json:"high"`
  26. Active int32 `json:"active"`
  27. FilterHigh int32 `json:"filterHigh"`
  28. FilterRumina int32 `json:"filterRumina"`
  29. FilterChew int32 `json:"filterChew"`
  30. WeekHigh int32 `json:"weekHigh"`
  31. AvgHighHabit int32 `json:"avgHighHabit"`
  32. AvgRuminaHabit int32 `json:"avgRuminaHabit"`
  33. AvgIntakeHabit int32 `json:"avgIntakeHabit"`
  34. AvgChewHabit int32 `json:"avgChewHabit"`
  35. AvgInactiveHabit int32 `json:"avgInactiveHabit"`
  36. AvgOtherHabit int32 `json:"avgOtherHabit"`
  37. ChangeHigh int32 `json:"changeHigh"`
  38. ChangeRumina int32 `json:"changeRumina"`
  39. ChangeChew int32 `json:"changeChew"`
  40. ChangeAdjust int32 `json:"changeAdjust"`
  41. ChangeFilter int32 `json:"changeFilter"`
  42. RuminaFilter int32 `json:"ruminaFilter"`
  43. ChewFilter int32 `json:"chewFilter"`
  44. FilterCorrect int32 `json:"filterCorrect"`
  45. SumRumina int32 `json:"sumRumina"`
  46. SumIntake int32 `json:"sumIntake"`
  47. SumInactive int32 `json:"sumInactive"`
  48. SumAct int32 `json:"sumAct"`
  49. SumMinHigh int32 `json:"sumMinHigh"`
  50. SumMaxHigh int32 `json:"sumMaxHigh"`
  51. SumMinChew int32 `json:"SumMinChew"`
  52. SumRuminaBeforeThreeDay int32 `json:"sumRuminaBeforeThreeDay"`
  53. SumIntakeBeforeThreeDay int32 `json:"sumIntakeBeforeThreeDay"`
  54. Score int32 `json:"score"`
  55. IsMaxTime pasturePb.IsShow_Kind `json:"isMaxTime"`
  56. IsShow pasturePb.IsShow_Kind `json:"isShow"`
  57. ReceiveNumber int32 `json:"receiveNumber"`
  58. RecordCount int32 `json:"recordCount"`
  59. CreatedAt int64 `json:"createdAt"`
  60. UpdatedAt int64 `json:"updatedAt"`
  61. }
  62. func (n *NeckActiveHabit) TableName() string {
  63. return "neck_active_habit"
  64. }
  65. func NewNeckActiveHabit(frameId int32, heatDate, neckRingNumber string, data *NeckRingOriginalMerge) *NeckActiveHabit {
  66. return &NeckActiveHabit{
  67. Frameid: frameId,
  68. HeatDate: heatDate,
  69. NeckRingNumber: neckRingNumber,
  70. Active: data.Active,
  71. Gasp: data.Gasp,
  72. High: data.High,
  73. Inactive: data.Inactive,
  74. Intake: data.Intake,
  75. Other: data.Other,
  76. Rumina: data.Rumina,
  77. WeekHigh: DefaultWeeklyActive,
  78. IsShow: pasturePb.IsShow_No,
  79. IsMaxTime: pasturePb.IsShow_No,
  80. ChangeFilter: DefaultChangeFilter,
  81. FilterCorrect: DefaultFilterCorrect,
  82. RuminaFilter: DefaultRuminaFilter,
  83. ChewFilter: DefaultChewFilter,
  84. ActiveTime: fmt.Sprintf("%s %02d:00:00", heatDate, frameId),
  85. }
  86. }
  87. func (n *NeckActiveHabit) MergeData(data *NeckActiveHabit) {
  88. n.Rumina += data.Rumina
  89. n.Inactive += data.Inactive
  90. n.Active += data.Active
  91. n.Intake += data.Intake
  92. n.Other += data.Other
  93. n.Gasp += data.Gasp
  94. n.High += data.High
  95. }