cow.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  1. package model
  2. import (
  3. "fmt"
  4. "kpt-pasture/util"
  5. "math"
  6. "time"
  7. pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  8. )
  9. type Cow struct {
  10. Id int64 `json:"id"`
  11. PastureId int64 `json:"pastureId"` // 牧场id
  12. Sex pasturePb.Genders_Kind `json:"sex"` // 性别
  13. NeckRingNumber string `json:"neckRingNumber"` // 脖环号
  14. EarNumber string `json:"earNumber"` // 耳标号
  15. EarOldNumber string `json:"earOldNumber"` // 旧耳标号
  16. PenId int32 `json:"penId"` // 栏舍id
  17. PenName string `json:"penName"` // 栏舍名称
  18. Lact int32 `json:"lact"` // 胎次
  19. DayAge int32 `json:"dayAge"` // 日龄
  20. CalvingAge int32 `json:"calvingAge"` // 产后天使
  21. PregnancyAge int32 `json:"pregnancyAge"` // 怀孕天数 孕检结果有阳性更新,产犊后至0
  22. AdmissionAge int32 `json:"admissionAge"` // 入场日龄
  23. AbortionAge int32 `json:"abortionAge"` // 流产天数
  24. CowType pasturePb.CowType_Kind `json:"cowType"` // 牛只类型
  25. BreedStatus pasturePb.BreedStatus_Kind `json:"breedStatus"` // 繁殖状态
  26. CowKind pasturePb.CowKind_Kind `json:"cowKind"` // 牛只品种
  27. BirthWeight int64 `json:"birthWeight"` // 出生体重
  28. CurrentWeight int64 `json:"currentWeight"` // 当前体重
  29. AdmissionWeight int64 `json:"admissionWeight"` // 入场体重
  30. SourceId pasturePb.CowSource_Kind `json:"sourceId"` // 来源哪里
  31. FatherNumber string `json:"fatherNumber"` // 父号
  32. MotherNumber string `json:"motherNumber"` // 母号
  33. AdmissionStatus pasturePb.AdmissionStatus_Kind `json:"admissionStatus"` // 在场状态
  34. IsPregnant pasturePb.IsShow_Kind `json:"isPregnant"` // 是否怀孕
  35. HealthStatus pasturePb.HealthStatus_Kind `json:"healthStatus"` // 健康状态
  36. WeaningAt int64 `json:"weaningAt"` // 断奶时间
  37. BirthAt int64 `json:"birthAt"` // 出生时间
  38. AdmissionAt int64 `json:"admissionAt"` // 入场时间
  39. DepartureAt int64 `json:"departureAt"` // 离场时间
  40. FirstMatingAt int64 `json:"firstMatingAt"` // 首次配种时间
  41. MatingTimes int32 `json:"matingTimes"` // 配种次数
  42. WeeklyActive int32 `json:"weeklyActive"` // 每周活跃度
  43. LastEstrusAt int64 `json:"lastEstrusAt"` // 最后一次发情时间
  44. LastCalvingAt int64 `json:"lastCalvingAt"` // 最后一次产犊时间
  45. LastMatingAt int64 `json:"lastMatingAt"` // 最后一次配种时间
  46. LastBullNumber string `json:"lastBullNumber"` // 最后一次配种牛号
  47. LastPregnantCheckAt int64 `json:"lastPregnantCheckAt"` // 最后一次孕检时间
  48. LastDryMilkAt int64 `json:"lastDryMilkAt"` // 最近一次干奶日期
  49. LastSecondWeight int64 `json:"lastSecondWeight"` // 最后第二次称重
  50. LastSecondWeightAt int64 `json:"lastSecondWeightAt"` // 最后第二次称重时间
  51. LastAbortionAt int64 `json:"lastAbortionAt"` // 最近一次流产时间
  52. LastWeightAt int64 `json:"lastWeightAt"` // 最近一次称重时间
  53. CreatedAt int64 `json:"createdAt"`
  54. UpdatedAt int64 `json:"updatedAt"`
  55. }
  56. func (c *Cow) TableName() string {
  57. return "cow"
  58. }
  59. func (c *Cow) EventInfoUpdate() {
  60. c.DayAge = c.GetDayAge()
  61. c.CalvingAge = c.GetCalvingAge()
  62. c.PregnancyAge = c.GetDaysPregnant()
  63. c.AdmissionAge = c.GetAdmissionAge()
  64. c.AbortionAge = c.GetAbortionAge()
  65. if c.DayAge == 60 {
  66. c.CowType = pasturePb.CowType_Weaned_Calf
  67. }
  68. }
  69. // EventCalvingUpdate 产犊更新
  70. func (c *Cow) EventCalvingUpdate(calvingAt int64) {
  71. c.Lact += 1
  72. c.MatingTimes = 0
  73. c.PregnancyAge = 0
  74. c.BreedStatus = pasturePb.BreedStatus_Calving
  75. c.IsPregnant = pasturePb.IsShow_No
  76. c.LastCalvingAt = calvingAt
  77. c.CalvingAge = c.GetCalvingAge()
  78. }
  79. // EventWeaningUpdate 断奶更新
  80. func (c *Cow) EventWeaningUpdate(weaningAt int64, penId int32, currentWeight int64) {
  81. c.PenId = penId
  82. c.WeaningAt = weaningAt
  83. c.CurrentWeight = currentWeight
  84. c.LastWeightAt = weaningAt
  85. }
  86. // EventPregnantCheckUpdate 孕检更新
  87. func (c *Cow) EventPregnantCheckUpdate(breedStatus pasturePb.BreedStatus_Kind, pregnantCheckAt int64, isPregnant pasturePb.IsShow_Kind) {
  88. c.BreedStatus = breedStatus
  89. c.LastPregnantCheckAt = pregnantCheckAt
  90. c.IsPregnant = isPregnant
  91. }
  92. // EventAbortionUpdate 流产更新
  93. func (c *Cow) EventAbortionUpdate(abortionAt int64) {
  94. c.IsPregnant = pasturePb.IsShow_No
  95. c.LastAbortionAt = abortionAt
  96. c.BreedStatus = pasturePb.BreedStatus_Abort
  97. }
  98. // EventWeightUpdate 称重更新
  99. func (c *Cow) EventWeightUpdate(weight int64, weightAt int64) {
  100. c.LastSecondWeight = c.CurrentWeight
  101. c.LastSecondWeightAt = c.LastWeightAt
  102. c.LastWeightAt = weightAt
  103. c.CurrentWeight = weight
  104. }
  105. // EventHealthStatusUpdate 健康状态更新
  106. func (c *Cow) EventHealthStatusUpdate(healthStatus pasturePb.HealthStatus_Kind) {
  107. c.HealthStatus = healthStatus
  108. }
  109. // EventPenUpdate 更新栏舍
  110. func (c *Cow) EventPenUpdate(pen *Pen) {
  111. c.PenId = pen.Id
  112. c.PenName = pen.Name
  113. }
  114. // EventEarNumberUpdate 更新耳标号
  115. func (c *Cow) EventEarNumberUpdate(newEarNumber string) {
  116. c.EarOldNumber = c.EarNumber
  117. c.EarNumber = newEarNumber
  118. }
  119. // EventDepartureUpdate 更新牛只离场信息
  120. func (c *Cow) EventDepartureUpdate(departureAt int64, departureType pasturePb.DepartureType_Kind) {
  121. if departureType == pasturePb.DepartureType_Death {
  122. c.AdmissionStatus = pasturePb.AdmissionStatus_Die
  123. c.HealthStatus = pasturePb.HealthStatus_Dead
  124. }
  125. if departureType == pasturePb.DepartureType_Out {
  126. c.AdmissionStatus = pasturePb.AdmissionStatus_Out
  127. c.HealthStatus = pasturePb.HealthStatus_Out
  128. }
  129. c.DepartureAt = departureAt
  130. }
  131. // EventMatingUpdate 配种更新
  132. func (c *Cow) EventMatingUpdate(matingAt int64, bullNumber string, isReMating bool) {
  133. c.LastMatingAt = matingAt
  134. if c.LastBullNumber != "" {
  135. c.FirstMatingAt = matingAt
  136. }
  137. c.LastBullNumber = bullNumber
  138. c.IsPregnant = pasturePb.IsShow_No
  139. c.BreedStatus = pasturePb.BreedStatus_Breeding
  140. if !isReMating {
  141. c.MatingTimes += 1
  142. }
  143. }
  144. type CowSlice []*Cow
  145. func (c CowSlice) ToPB(
  146. penMap map[int32]*Pen,
  147. cowTypeMap map[pasturePb.CowType_Kind]string,
  148. breedStatusMap map[pasturePb.BreedStatus_Kind]string,
  149. cowKindMap map[pasturePb.CowKind_Kind]string,
  150. cowSourceMap map[pasturePb.CowSource_Kind]string,
  151. admissionStatusMap map[pasturePb.AdmissionStatus_Kind]string,
  152. healthStatusMap map[pasturePb.HealthStatus_Kind]string,
  153. ) []*pasturePb.CowDetails {
  154. res := make([]*pasturePb.CowDetails, len(c))
  155. for i, v := range c {
  156. penName := ""
  157. if pen, ok := penMap[v.PenId]; ok {
  158. penName = pen.Name
  159. }
  160. sex := "公"
  161. if v.Sex == pasturePb.Genders_Female {
  162. sex = "母"
  163. }
  164. lastWeightAtFormat := ""
  165. if v.LastWeightAt > 0 {
  166. lastWeightAtFormat = time.Unix(v.LastWeightAt, 0).Format(LayoutDate2)
  167. }
  168. isPregnantName := ""
  169. if v.IsPregnant == pasturePb.IsShow_Ok {
  170. isPregnantName = "已孕"
  171. } else {
  172. isPregnantName = "未孕"
  173. }
  174. admissionAtFormat := ""
  175. if v.AdmissionAt > 0 {
  176. admissionAtFormat = time.Unix(v.AdmissionAt, 0).Format(LayoutDate2)
  177. }
  178. birthAtFormat := ""
  179. if v.BirthAt > 0 {
  180. birthAtFormat = time.Unix(v.BirthAt, 0).Format(LayoutDate2)
  181. }
  182. weaningAtFormat := ""
  183. if v.WeaningAt > 0 {
  184. weaningAtFormat = time.Unix(v.WeaningAt, 0).Format(LayoutDate2)
  185. }
  186. firstMatingAtFormat := ""
  187. if v.FirstMatingAt > 0 {
  188. firstMatingAtFormat = time.Unix(v.FirstMatingAt, 0).Format(LayoutDate2)
  189. }
  190. lastMatingAtFormat := ""
  191. if v.LastMatingAt > 0 {
  192. lastMatingAtFormat = time.Unix(v.LastMatingAt, 0).Format(LayoutDate2)
  193. }
  194. lastPregnantCheckAtFormat := ""
  195. if v.LastPregnantCheckAt > 0 {
  196. lastPregnantCheckAtFormat = time.Unix(v.LastPregnantCheckAt, 0).Format(LayoutDate2)
  197. }
  198. lastCalvingAtFormat := ""
  199. if v.LastCalvingAt > 0 {
  200. lastCalvingAtFormat = time.Unix(v.LastCalvingAt, 0).Format(LayoutDate2)
  201. }
  202. lastAbortionAtFormat := ""
  203. if v.LastAbortionAt > 0 {
  204. lastAbortionAtFormat = time.Unix(v.LastAbortionAt, 0).Format(LayoutDate2)
  205. }
  206. lastSecondWeightAtFormat := ""
  207. if v.LastSecondWeightAt > 0 {
  208. lastSecondWeightAtFormat = time.Unix(v.LastSecondWeightAt, 0).Format(LayoutDate2)
  209. }
  210. res[i] = &pasturePb.CowDetails{
  211. CowId: int32(v.Id),
  212. Sex: sex,
  213. NeckRingNumber: v.NeckRingNumber,
  214. PenName: penName,
  215. Lact: v.Lact,
  216. CowTypeName: cowTypeMap[v.CowType],
  217. BreedStatusName: breedStatusMap[v.BreedStatus],
  218. CowKindName: cowKindMap[v.CowKind],
  219. EarNumber: v.EarNumber,
  220. BirthWeight: float32(v.BirthWeight) / 1000,
  221. CurrentWeight: float32(v.CurrentWeight) / 1000,
  222. DayAge: v.DayAge,
  223. SourceName: cowSourceMap[v.SourceId],
  224. MotherNumber: v.MotherNumber,
  225. FatherNumber: v.FatherNumber,
  226. AdmissionStatusName: admissionStatusMap[v.AdmissionStatus],
  227. HealthStatusName: healthStatusMap[v.HealthStatus],
  228. IsPregnantName: isPregnantName,
  229. AdmissionAtFormat: admissionAtFormat,
  230. BirthAtFormat: birthAtFormat,
  231. WeaningAtFormat: weaningAtFormat,
  232. CalvingAge: int32(v.GetCalvingAge()),
  233. AbortionAge: v.AbortionAge,
  234. MatingTimes: v.MatingTimes,
  235. FirstMatingAtFormat: firstMatingAtFormat,
  236. LastMatingAtFormat: lastMatingAtFormat,
  237. LastBullNumber: v.LastBullNumber,
  238. LastPregnantCheckAtFormat: lastPregnantCheckAtFormat,
  239. LastWeightAtFormat: lastWeightAtFormat,
  240. LastCalvingAtFormat: lastCalvingAtFormat,
  241. LastAbortionAtFormat: lastAbortionAtFormat,
  242. LastSecondWeight: float32(v.LastSecondWeight) / 1000,
  243. LastSecondWeightAtFormat: lastSecondWeightAtFormat,
  244. }
  245. }
  246. return res
  247. }
  248. func (c CowSlice) ToPB2(penMap map[int32]*Pen, penWeightSlice PenWeightSlice) []*pasturePb.CowList {
  249. res := make([]*pasturePb.CowList, len(c))
  250. for i, v := range c {
  251. penName := ""
  252. if pen, ok := penMap[v.PenId]; ok {
  253. penName = pen.Name
  254. }
  255. penWeight := penWeightSlice.GetPenWeight(v.PenId)
  256. lastWeightDay := util.Ceil(float64(v.LastWeightAt-v.LastSecondWeightAt) / 86400)
  257. penAvgWeight := float32(0)
  258. previousStageDailyWeight := float32(0)
  259. cowPenAvgWeightDiffValue := float32(0)
  260. if penWeight != nil {
  261. penAvgWeight = float32(penWeight.AvgWeight) / 1000
  262. cowPenAvgWeightDiffValue = float32(v.CurrentWeight-int64(penWeight.AvgWeight)) / 1000
  263. if lastWeightDay > 0 {
  264. previousStageDailyWeight = float32(v.CurrentWeight-v.LastSecondWeight) / 1000 / float32(lastWeightDay)
  265. }
  266. }
  267. res[i] = &pasturePb.CowList{
  268. CowId: int32(v.Id),
  269. DayAge: v.DayAge,
  270. DailyWeightGain: float32(v.GetDayWeight()),
  271. AverageDailyWeightGain: float32(v.GetAverageDailyWeight()),
  272. EarNumber: v.EarNumber,
  273. PenName: penName,
  274. BirthAt: int32(v.BirthAt),
  275. BirthWeight: float32(v.BirthWeight) / 1000,
  276. CurrentWeight: float32(v.CurrentWeight) / 1000,
  277. LastWeightAt: int32(v.LastWeightAt),
  278. AdmissionAge: v.AdmissionAge,
  279. AdmissionWeight: float32(v.AbortionAge) / 1000,
  280. PreviousStageDailyWeight: previousStageDailyWeight,
  281. PenAvgWeight: penAvgWeight,
  282. CowPenAvgWeightDiffValue: cowPenAvgWeightDiffValue,
  283. }
  284. }
  285. return res
  286. }
  287. func NewCow(pastureId int64, req *pasturePb.EventEnterRequest, penMap map[int32]*Pen) *Cow {
  288. var isPregnant = pasturePb.IsShow_No
  289. if req.BreedStatus == pasturePb.BreedStatus_Pregnant {
  290. isPregnant = pasturePb.IsShow_Ok
  291. }
  292. admissionAt := int64(0)
  293. switch req.CowSource {
  294. case pasturePb.CowSource_Calving:
  295. admissionAt = int64(req.BirthAt)
  296. case pasturePb.CowSource_Transfer_In:
  297. admissionAt = int64(req.EnterAt)
  298. case pasturePb.CowSource_Buy:
  299. admissionAt = int64(req.EnterAt)
  300. }
  301. return &Cow{
  302. PastureId: pastureId,
  303. Sex: req.Sex,
  304. EarNumber: req.EarNumber,
  305. PenId: req.PenId,
  306. PenName: penMap[req.PenId].Name,
  307. Lact: req.Lact,
  308. CowType: req.CowType,
  309. BreedStatus: req.BreedStatus,
  310. CowKind: req.CowKind,
  311. SourceId: req.CowSource,
  312. FatherNumber: req.FatherNumber,
  313. MotherNumber: req.MotherNumber,
  314. AdmissionStatus: pasturePb.AdmissionStatus_Admission,
  315. HealthStatus: pasturePb.HealthStatus_Health,
  316. IsPregnant: isPregnant,
  317. WeaningAt: int64(req.WeaningAt),
  318. BirthAt: int64(req.BirthAt),
  319. AdmissionWeight: int64(req.Weight * 1000),
  320. FirstMatingAt: int64(req.MatingAt),
  321. LastMatingAt: int64(req.MatingAt),
  322. LastPregnantCheckAt: int64(req.PregnancyCheckAt),
  323. AdmissionAt: admissionAt,
  324. BirthWeight: int64(req.Weight * 1000),
  325. LastWeightAt: int64(req.EstrusAt),
  326. CurrentWeight: int64(req.Weight * 1000),
  327. }
  328. }
  329. func NewCalfCow(motherId int64, fatherNumber string, calf *CalvingCalf) *Cow {
  330. return &Cow{
  331. Sex: calf.Sex,
  332. EarNumber: calf.EarNumber,
  333. PenId: calf.PenId,
  334. PenName: calf.PenName,
  335. CowType: pasturePb.CowType_Lactating_Calf, // 哺乳犊牛
  336. BreedStatus: pasturePb.BreedStatus_UnBreed, // 未配
  337. CowKind: calf.CowKind, // 牛只品种
  338. BirthWeight: calf.BirthWeight,
  339. BirthAt: calf.BirthAt,
  340. SourceId: pasturePb.CowSource_Calving, // 产犊方式
  341. FatherNumber: fatherNumber,
  342. MotherNumber: fmt.Sprintf("%d", motherId),
  343. AdmissionStatus: pasturePb.AdmissionStatus_Admission,
  344. IsPregnant: pasturePb.IsShow_No,
  345. AdmissionAt: calf.BirthAt,
  346. }
  347. }
  348. type BarCowStruct struct {
  349. Number int32 `json:"number"`
  350. TypeId pasturePb.CowType_Kind `json:"type_id"`
  351. }
  352. // BarCowStructSlice 首页牛群结构
  353. type BarCowStructSlice []*BarCowStruct
  354. func (b BarCowStructSlice) ToPB(cowTypeMap map[pasturePb.CowType_Kind]string, count int32) []*pasturePb.BarCowStruct {
  355. var pb []*pasturePb.BarCowStruct
  356. for _, v := range b {
  357. name := fmt.Sprintf("%s", cowTypeMap[v.TypeId])
  358. pb = append(pb, &pasturePb.BarCowStruct{Name: name, Value: v.Number})
  359. }
  360. return pb
  361. }
  362. // GetDayAge 日龄
  363. func (c *Cow) GetDayAge() int32 {
  364. if c.BirthAt <= 0 {
  365. return 0
  366. }
  367. return int32(math.Floor(float64(time.Now().Unix()-c.BirthAt) / 86400))
  368. }
  369. // GetCalvingAge 产后天数
  370. func (c *Cow) GetCalvingAge() int32 {
  371. if c.LastCalvingAt <= 0 {
  372. return 0
  373. }
  374. return int32(math.Floor(float64(time.Now().Unix()-c.LastCalvingAt) / 86400))
  375. }
  376. // GetDaysPregnant 怀孕天数
  377. func (c *Cow) GetDaysPregnant() int32 {
  378. if c.BreedStatus == pasturePb.BreedStatus_Pregnant &&
  379. c.AdmissionStatus == pasturePb.AdmissionStatus_Admission &&
  380. c.IsPregnant == pasturePb.IsShow_Ok {
  381. return int32(math.Floor(float64(time.Now().Unix()-c.LastMatingAt) / 86400))
  382. }
  383. return 0
  384. }
  385. // GetLactationDays 泌乳天数
  386. func (c *Cow) GetLactationDays() int32 {
  387. if c.BreedStatus == pasturePb.BreedStatus_Calving && c.AdmissionStatus == pasturePb.AdmissionStatus_Admission {
  388. return int32(math.Floor(float64(time.Now().Unix()-c.LastCalvingAt) / 86400))
  389. }
  390. return 0
  391. }
  392. // GetAdmissionAge 入场天数
  393. func (c *Cow) GetAdmissionAge() int32 {
  394. if c.AdmissionAt > 0 && c.AdmissionStatus == pasturePb.AdmissionStatus_Admission {
  395. return int32(math.Floor(float64(time.Now().Unix()-c.AdmissionAt) / 86400))
  396. }
  397. return 0
  398. }
  399. // GetDayWeight 日增重
  400. func (c *Cow) GetDayWeight() float64 {
  401. if c.CurrentWeight-c.LastSecondWeight > 0 && c.LastWeightAt > c.LastSecondWeightAt {
  402. days := int32(math.Floor(float64(c.LastWeightAt-c.LastSecondWeightAt) / 86400))
  403. if days <= 0 {
  404. return float64(c.CurrentWeight - c.LastSecondWeight)
  405. }
  406. dayWeight := math.Round(1.0 * float64(c.CurrentWeight-c.LastSecondWeight) / float64(days))
  407. return dayWeight / 1000
  408. }
  409. return 0
  410. }
  411. // GetAverageDailyWeight 平均日增重
  412. func (c *Cow) GetAverageDailyWeight() float64 {
  413. if c.CurrentWeight-c.BirthWeight > 0 && c.LastWeightAt > c.BirthAt {
  414. days := int32(math.Floor(float64(c.LastWeightAt-c.BirthAt) / 86400))
  415. if days <= 0 {
  416. return 0
  417. }
  418. dailyWeight := math.Round(1.0 * float64(c.CurrentWeight-c.BirthWeight) / float64(days))
  419. return dailyWeight / 1000
  420. }
  421. return 0
  422. }
  423. func (c *Cow) GetAbortionAge() int32 {
  424. if c.LastAbortionAt > 0 && c.AdmissionStatus == pasturePb.AdmissionStatus_Admission {
  425. return int32(math.Floor(float64(time.Now().Unix()-c.LastAbortionAt) / 86400))
  426. }
  427. return 0
  428. }
  429. type CowWeightRange struct {
  430. WeightRange string `json:"weight_range"`
  431. Count int32 `json:"count"`
  432. }
  433. func (c CowSlice) WeightRangeToPB(penMap map[int32]*Pen) []*pasturePb.CowList {
  434. res := make([]*pasturePb.CowList, len(c))
  435. for i, v := range c {
  436. penName := ""
  437. if pen, ok := penMap[v.PenId]; ok {
  438. penName = pen.Name
  439. }
  440. res[i] = &pasturePb.CowList{
  441. CowId: int32(v.Id),
  442. DayAge: v.DayAge,
  443. DailyWeightGain: float32(v.GetDayWeight()),
  444. AverageDailyWeightGain: float32(v.GetAverageDailyWeight()),
  445. EarNumber: v.EarNumber,
  446. PenName: penName,
  447. BirthAt: int32(v.BirthAt),
  448. BirthWeight: float32(v.BirthWeight) / 1000,
  449. CurrentWeight: float32(v.CurrentWeight) / 1000,
  450. LastWeightAt: int32(v.LastWeightAt),
  451. }
  452. }
  453. return res
  454. }
  455. // CowBehaviorCurveResponse 脖环行为数据
  456. type CowBehaviorCurveResponse struct {
  457. Code int32 `json:"code"`
  458. Msg string `json:"msg"`
  459. Data *CowBehaviorCurveData `json:"data"`
  460. }
  461. type CowBehaviorCurveData struct {
  462. OriginalDateList []int32 `json:"originalDateList"` // 原始行为数据
  463. ChangeDateList []int32 `json:"changeDateList"` // 变化数据
  464. SumDateList []int32 `json:"sumDateList"` // 累计24小时数据
  465. DateTimeList []string `json:"dateTimeList"` // 时间数据
  466. EstrusList map[pasturePb.EstrusLevel_Kind][]string `json:"estrusList"` // 发情预警
  467. EventList map[string][]string `json:"eventList"` // 事件数据
  468. EventMap map[pasturePb.EventType_Kind]string `json:"eventMap"` // 所有事件
  469. }