event_estrus.go 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package model
  2. import (
  3. pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  4. )
  5. type EventEstrus struct {
  6. Id int64 `json:"id"`
  7. PastureId int64 `json:"pastureId"`
  8. CowId int64 `json:"cowId"`
  9. NeckRingNumber string `json:"neckRingNumber"`
  10. EarNumber string `json:"earNumber"`
  11. Lact int32 `json:"lact"`
  12. DayAge int32 `json:"dayAge"`
  13. CalvingAge int32 `json:"calvingAge"`
  14. ExposeEstrusType pasturePb.ExposeEstrusType_Kind `json:"exposeEstrusType"`
  15. LastEstrusDay int64 `json:"lastEstrusDay"`
  16. PlanDay int64 `json:"planDay"`
  17. RealityDay int64 `json:"realityDay"`
  18. EndDay int64 `json:"endDay"`
  19. IsMating pasturePb.IsShow_Kind `json:"isMating"`
  20. UnMatingReasonsKind pasturePb.UnMatingReasons_Kind `json:"unMatingReasonsKind"`
  21. UnMatingReasonsName string `json:"unMatingReasonsName"`
  22. Level pasturePb.EstrusLevel_Kind `json:"level"`
  23. Remarks string `json:"remarks"`
  24. IsShow pasturePb.IsShow_Kind `json:"isShow"`
  25. OperationId int64 `json:"operationId"`
  26. OperationName string `json:"operationName"`
  27. MessageId int64 `json:"messageId"`
  28. MessageName string `json:"messageName"`
  29. CreatedAt int64 `json:"createdAt"`
  30. UpdatedAt int64 `json:"updatedAt"`
  31. }
  32. func (e *EventEstrus) TableName() string {
  33. return "event_estrus"
  34. }
  35. func NewEventEstrus(
  36. pastureId int64,
  37. cow *Cow,
  38. exposeEstrusType pasturePb.ExposeEstrusType_Kind,
  39. isShow pasturePb.IsShow_Kind,
  40. isMating pasturePb.IsShow_Kind,
  41. PlanDay int64,
  42. operationUser, currentUser *SystemUser,
  43. ) *EventEstrus {
  44. return &EventEstrus{
  45. PastureId: pastureId,
  46. CowId: cow.Id,
  47. Lact: cow.Lact,
  48. DayAge: cow.DayAge,
  49. CalvingAge: cow.CalvingAge,
  50. NeckRingNumber: cow.NeckRingNumber,
  51. EarNumber: cow.EarNumber,
  52. ExposeEstrusType: exposeEstrusType,
  53. PlanDay: PlanDay,
  54. RealityDay: PlanDay,
  55. IsMating: isMating,
  56. IsShow: isShow,
  57. OperationId: operationUser.Id,
  58. OperationName: operationUser.Name,
  59. MessageId: currentUser.Id,
  60. MessageName: currentUser.Name,
  61. }
  62. }
  63. type EventEstrusSlice []*EventEstrus
  64. func (e EventEstrusSlice) ToPB() []*pasturePb.SearchEventEstrusList {
  65. res := make([]*pasturePb.SearchEventEstrusList, len(e))
  66. for i, v := range e {
  67. res[i] = &pasturePb.SearchEventEstrusList{
  68. Id: int32(v.Id),
  69. CowId: int32(v.CowId),
  70. EarNumber: v.EarNumber,
  71. DayAge: v.DayAge,
  72. Lact: v.Lact,
  73. EstrusAt: int32(v.RealityDay),
  74. IsMating: v.IsMating,
  75. UnMatingReasons: v.UnMatingReasonsName,
  76. OperationName: v.OperationName,
  77. Remarks: v.Remarks,
  78. CreatedAt: int32(v.CreatedAt),
  79. UpdatedAt: int32(v.UpdatedAt),
  80. }
  81. }
  82. return res
  83. }