|
@@ -1,9 +1,14 @@
|
|
package model
|
|
package model
|
|
|
|
|
|
-import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
|
|
|
|
|
|
+import (
|
|
|
|
+ "time"
|
|
|
|
+
|
|
|
|
+ pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
|
|
|
|
+)
|
|
|
|
|
|
type EventWeight struct {
|
|
type EventWeight struct {
|
|
ID int64 `json:"id"`
|
|
ID int64 `json:"id"`
|
|
|
|
+ PastureId int64 `json:"pastureId"`
|
|
CowId int64 `json:"cowId"`
|
|
CowId int64 `json:"cowId"`
|
|
EarNumber string `json:"earNumber"`
|
|
EarNumber string `json:"earNumber"`
|
|
DayAge int32 `json:"dayAge"`
|
|
DayAge int32 `json:"dayAge"`
|
|
@@ -28,6 +33,7 @@ func (c *EventWeight) TableName() string {
|
|
|
|
|
|
func NewEventWeight(cow *Cow, currentUser *SystemUser, weight, height int32, req *pasturePb.EventWeight) *EventWeight {
|
|
func NewEventWeight(cow *Cow, currentUser *SystemUser, weight, height int32, req *pasturePb.EventWeight) *EventWeight {
|
|
return &EventWeight{
|
|
return &EventWeight{
|
|
|
|
+ PastureId: currentUser.PastureId,
|
|
CowId: cow.Id,
|
|
CowId: cow.Id,
|
|
EarNumber: cow.EarNumber,
|
|
EarNumber: cow.EarNumber,
|
|
Weight: weight,
|
|
Weight: weight,
|
|
@@ -42,3 +48,24 @@ func NewEventWeight(cow *Cow, currentUser *SystemUser, weight, height int32, req
|
|
OperationName: req.OperationName,
|
|
OperationName: req.OperationName,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+type EventWeightSlice []*EventWeight
|
|
|
|
+
|
|
|
|
+func (e EventWeightSlice) ToPB() []*pasturePb.CowGrowthCurveData {
|
|
|
|
+ res := make([]*pasturePb.CowGrowthCurveData, len(e))
|
|
|
|
+ for i, v := range e {
|
|
|
|
+ weightAtFormat := ""
|
|
|
|
+ if v.WeightAt > 0 {
|
|
|
|
+ weightAtFormat = time.Unix(v.WeightAt, 0).Format(LayoutTime)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ res[i] = &pasturePb.CowGrowthCurveData{
|
|
|
|
+ Weight: float32(v.Weight) / 1000,
|
|
|
|
+ WeightAtFormat: weightAtFormat,
|
|
|
|
+ AvgWeight: 0, // 平均体重
|
|
|
|
+ DayAddWeight: 0, // 日增重
|
|
|
|
+ AvgDayAddWeight: 0, // 平均日增重
|
|
|
|
+ MonthAddWeight: 0, // 月增重
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|