cow.go 20 KB

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