소스 검색

cow: BehaviorCurve 活动量曲线

Yi 5 일 전
부모
커밋
bf5d34ec87
5개의 변경된 파일21개의 추가작업 그리고 9개의 파일을 삭제
  1. 1 1
      go.mod
  2. 4 0
      go.sum
  3. 1 1
      model/cow.go
  4. 3 3
      model/neck_active_habit.go
  5. 12 4
      module/backend/cow.go

+ 1 - 1
go.mod

@@ -3,7 +3,7 @@ module kpt-pasture
 go 1.17
 
 require (
-	gitee.com/xuyiping_admin/go_proto v0.0.0-20250416102510-604a13fe9d52
+	gitee.com/xuyiping_admin/go_proto v0.0.0-20250418054121-409ac98e3475
 	gitee.com/xuyiping_admin/pkg v0.0.0-20241108060137-caea58c59f5b
 	github.com/dgrijalva/jwt-go v3.2.0+incompatible
 	github.com/eclipse/paho.mqtt.golang v1.4.3

+ 4 - 0
go.sum

@@ -40,6 +40,8 @@ gitee.com/xuyiping_admin/go_proto v0.0.0-20250416085805-501c91e70d45 h1:O4vnwyLd
 gitee.com/xuyiping_admin/go_proto v0.0.0-20250416085805-501c91e70d45/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
 gitee.com/xuyiping_admin/go_proto v0.0.0-20250416102510-604a13fe9d52 h1:aCqqT2Y/po3OtkUqzogDOIjqwny03iu1rp47CU1yiz0=
 gitee.com/xuyiping_admin/go_proto v0.0.0-20250416102510-604a13fe9d52/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20250418054121-409ac98e3475 h1:zGCW7bHN9o67VxxK3eZr0k0h5HB+twDjx4cIc9q3dEI=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20250418054121-409ac98e3475/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
 gitee.com/xuyiping_admin/pkg v0.0.0-20241108060137-caea58c59f5b h1:w05MxH7yqveRlaRbxHhbif5YjPrJFodRPfOjYhXn7Zk=
 gitee.com/xuyiping_admin/pkg v0.0.0-20241108060137-caea58c59f5b/go.mod h1:8tF25X6pE9WkFCczlNAC0K2mrjwKvhhp02I7o0HtDxY=
 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
@@ -175,6 +177,7 @@ github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vb
 github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
 github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
 github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
+github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
 github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
 github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
 github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs=
@@ -613,6 +616,7 @@ go.uber.org/dig v1.15.0/go.mod h1:pKHs0wMynzL6brANhB2hLMro+zalv1osARTviTcqHLM=
 go.uber.org/goleak v0.10.0/go.mod h1:VCZuO8V8mFPlL0F5J5GK1rtHV3DrFcQ1R8ryq7FK0aI=
 go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
 go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
+go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
 go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
 go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
 go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=

+ 1 - 1
model/cow.go

@@ -798,7 +798,7 @@ type CowBehaviorCurveData struct {
 	SumChewList      []int32                                 `json:"sumChewList"`      // 累计24小时咀嚼
 	DateTimeList     []string                                `json:"dateTimeList"`     // 时间数据
 	EstrusList       map[pasturePb.EstrusLevel_Kind][]string `json:"estrusList"`       // 发情预警
-	EventList        map[string][]string                     `json:"eventList"`        // 事件数据
+	EventList        []*pasturePb.CowEvent                   `json:"eventList"`        // 事件数据
 	EventMap         map[pasturePb.EventType_Kind]string     `json:"eventMap"`         // 所有事件
 	RuminaChange     []int32                                 `json:"ruminaChange"`     // 反刍变化
 	LowActivity      int32                                   `json:"lowActivity"`      // 低活动量参数

+ 3 - 3
model/neck_active_habit.go

@@ -135,7 +135,7 @@ func (n NeckActiveHabitSlice) ToPB(curveName string) *CowBehaviorCurveData {
 		SumDateList:      make([]int32, 0),
 		DateTimeList:     make([]string, 0),
 		EstrusList:       make(map[pasturePb.EstrusLevel_Kind][]string),
-		EventList:        make(map[string][]string),
+		EventList:        make([]*pasturePb.CowEvent, 0),
 		EventMap:         make(map[pasturePb.EventType_Kind]string),
 		RuminaChange:     make([]int32, 0),
 	}
@@ -209,8 +209,8 @@ func (n NeckActiveHabitSlice) ToPB(curveName string) *CowBehaviorCurveData {
 			res.SumDateList = append(res.SumDateList, v.SumInactive)
 		case "chew": // 咀嚼
 			res.OriginalDateList = append(res.OriginalDateList, v.Rumina+v.Intake)
-			res.ChangeDateList = append(res.ChangeDateList, v.ChangeChew)
-			res.SumDateList = append(res.ChangeDateList, v.SumRumina+v.SumIntake)
+			res.ChangeDateList = append(res.ChangeDateList, v.ChewFilter)
+			res.SumDateList = append(res.SumDateList, v.SumRumina+v.SumIntake)
 		case "immobility": // 静止
 			res.OriginalDateList = append(res.OriginalDateList, 120-v.Active)
 			res.SumDateList = append(res.SumDateList, 60*24-v.SumActive)

+ 12 - 4
module/backend/cow.go

@@ -259,11 +259,19 @@ func (s *StoreEntry) BehaviorCurve(ctx context.Context, req *pasturePb.CowBehavi
 			v.EventType == pasturePb.EventType_Castrated {
 			continue
 		}
-		eventAt := time.Unix(v.EventAt, 0).Local()
-		if data.EventList[v.EventTypeName] == nil {
-			data.EventList[v.EventTypeName] = make([]string, 0)
+
+		if v.EventAt <= 0 {
+			continue
 		}
-		data.EventList[v.EventTypeName] = append(data.EventList[v.EventTypeName], fmt.Sprintf("%s 09", eventAt.Format(model.LayoutDate2)))
+
+		eventAt := time.Unix(v.EventAt, 0).Local()
+		data.EventList = append(data.EventList, &pasturePb.CowEvent{
+			EventTypeKind:    v.EventType,
+			EventTypeName:    v.EventTypeName,
+			EventDescription: v.EventDescription,
+			Remarks:          v.Remarks,
+			EventAtFormat:    fmt.Sprintf("%s 09", eventAt.Format(model.LayoutDate2)),
+		})
 	}
 
 	// 发情数据