cow_same_time_detail.go 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. package model
  2. import (
  3. pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  4. )
  5. type CowSameTimeDetail struct {
  6. Id int64 `json:"id"`
  7. CowId int64 `json:"cowId"`
  8. PenId int32 `json:"penId"`
  9. PenName string `json:"penName"`
  10. Lact int32 `json:"lact"`
  11. SameTimeId int64 `json:"sameTimeId"`
  12. SameTimeType pasturePb.SameTimeType_Kind `json:"sameTimeType"`
  13. PlanDay string `json:"planDay"`
  14. EndDay string `json:"endDay"`
  15. RealityDay string `json:"realityDay"`
  16. Status pasturePb.IsShow_Kind `json:"status"`
  17. DrugsId int64 `json:"drugsId"`
  18. Unit pasturePb.Unit_Kind `json:"unit"`
  19. Usage int32 `json:"usage"`
  20. OperationId int64 `json:"operationId"`
  21. OperationName string `json:"operationName"`
  22. CreatedAt int64 `json:"createdAt"`
  23. UpdatedAt int64 `json:"updatedAt"`
  24. }
  25. func (s *CowSameTimeDetail) TableName() string {
  26. return "cow_same_time_detail"
  27. }
  28. func NewCowSameTimeDetailList(cowList []*Cow, sameTimeId int64, planTime string, sameTimeType pasturePb.SameTimeType_Kind) []*CowSameTimeDetail {
  29. res := make([]*CowSameTimeDetail, len(cowList))
  30. for i, cow := range cowList {
  31. res[i] = &CowSameTimeDetail{
  32. CowId: cow.Id,
  33. Lact: cow.Lact,
  34. PenId: cow.PenId,
  35. SameTimeId: sameTimeId,
  36. SameTimeType: sameTimeType,
  37. Status: pasturePb.IsShow_No,
  38. PlanDay: planTime,
  39. EndDay: planTime,
  40. }
  41. }
  42. return res
  43. }
  44. type SameTimeHeader struct {
  45. Id string `json:"id"`
  46. CowId string `json:"cowId"`
  47. CowType string `json:"cowType"`
  48. CowTypeName string `json:"cowTypeName"`
  49. BreedStatus string `json:"breedStatus"`
  50. BreedStatusName string `json:"breedStatusName"`
  51. PenId string `json:"penId"`
  52. PenName string `json:"penName"`
  53. Lact string `json:"lact"`
  54. CalvingAge string `json:"calvingAge"`
  55. AbortionAge string `json:"abortionAge"`
  56. DayAge string `json:"dayAge"`
  57. Status string `json:"status"`
  58. }
  59. type SameTimeBody struct {
  60. Id int64 `json:"id"`
  61. CowId int64 `json:"cowId"`
  62. BreedStatus pasturePb.BreedStatus_Kind `json:"breedStatus"`
  63. BreedStatusName string `json:"breedStatusName"`
  64. CowType pasturePb.CowType_Kind `json:"cowType"`
  65. CowTypeName string `json:"cowTypeName"`
  66. PenId int32 `json:"penId"`
  67. PenName string `json:"penName"`
  68. Lact int32 `json:"lact"`
  69. CalvingAge int32 `json:"calvingAge"`
  70. AbortionAge int32 `json:"abortionAge"`
  71. DayAge int32 `json:"dayAge"`
  72. Status pasturePb.IsShow_Kind `json:"status"`
  73. }
  74. type SameTimeBodySlice []*SameTimeBody
  75. func (s SameTimeBodySlice) ToPB(
  76. cowTypeMap map[pasturePb.CowType_Kind]string,
  77. breedStatusMap map[pasturePb.BreedStatus_Kind]string,
  78. penMap map[int32]*Pen,
  79. ) []*SameTimeBody {
  80. res := make([]*SameTimeBody, len(s))
  81. for i, v := range s {
  82. res[i] = &SameTimeBody{
  83. Id: v.Id,
  84. CowId: v.CowId,
  85. CowType: v.CowType,
  86. CowTypeName: cowTypeMap[v.CowType],
  87. BreedStatus: v.BreedStatus,
  88. BreedStatusName: breedStatusMap[v.BreedStatus],
  89. PenName: penMap[v.PenId].Name,
  90. PenId: v.PenId,
  91. Lact: v.Lact,
  92. CalvingAge: v.CalvingAge,
  93. AbortionAge: v.AbortionAge,
  94. DayAge: v.DayAge,
  95. Status: v.Status,
  96. }
  97. }
  98. return res
  99. }