浏览代码

goods: searchNeckRing update

Yi 2 周之前
父节点
当前提交
599f172f4a
共有 7 个文件被更改,包括 59 次插入1 次删除
  1. 1 1
      go.mod
  2. 3 0
      go.sum
  3. 2 0
      model/event_death.go
  4. 2 0
      model/event_sale_cow.go
  5. 46 0
      module/backend/config_data_extend.go
  6. 1 0
      module/backend/enum_options.go
  7. 4 0
      module/backend/goods.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-20250515070041-363e94a8dbac
+	gitee.com/xuyiping_admin/go_proto v0.0.0-20250521021325-89e4fc71dd39
 	gitee.com/xuyiping_admin/pkg v0.0.0-20250514071642-f92d2ac9a85d
 	github.com/dgrijalva/jwt-go v3.2.0+incompatible
 	github.com/eclipse/paho.mqtt.golang v1.4.3

+ 3 - 0
go.sum

@@ -102,6 +102,9 @@ gitee.com/xuyiping_admin/go_proto v0.0.0-20250514085954-501d0d6cb26c h1:PkMErJiu
 gitee.com/xuyiping_admin/go_proto v0.0.0-20250514085954-501d0d6cb26c/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
 gitee.com/xuyiping_admin/go_proto v0.0.0-20250515070041-363e94a8dbac h1:i6cw9nC8OCbBR+3lB5XX8o4NabcVR6gJ04dbEQxkmC0=
 gitee.com/xuyiping_admin/go_proto v0.0.0-20250515070041-363e94a8dbac/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20250521020200-04806a79ad46/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20250521021325-89e4fc71dd39 h1:/7MllucrQJnIxXY9fapeEOucVejTYY1IxsyIe8tLhlA=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20250521021325-89e4fc71dd39/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=
 gitee.com/xuyiping_admin/pkg v0.0.0-20250514071642-f92d2ac9a85d h1:vBXmMRggF7mZVPGRDgavZ87igJgkezwX0a3v1/XtIMQ=

+ 2 - 0
model/event_death.go

@@ -8,6 +8,7 @@ type EventDeath struct {
 	EarNumber            string                          `json:"earNumber"`
 	CowId                int64                           `json:"cowId"`
 	Lact                 int32                           `json:"lact"`
+	CowType              pasturePb.CowType_Kind          `json:"cowType"`
 	DayAge               int32                           `json:"dayAge"`
 	PregnancyAge         int32                           `json:"pregnancyAge"`
 	CalvingAge           int32                           `json:"calvingAge"`
@@ -37,6 +38,7 @@ func NewEventDeath(pastureId int64, cow *Cow, req *pasturePb.EventDeath, current
 		CowId:                cow.Id,
 		EarNumber:            cow.EarNumber,
 		Lact:                 cow.Lact,
+		CowType:              cow.CowType,
 		DayAge:               cow.GetEventDayAge(int64(req.DeathAt)),
 		DeathAt:              int64(req.DeathAt),
 		DeathReasonKind:      req.DeathReasonKind,

+ 2 - 0
model/event_sale_cow.go

@@ -7,6 +7,7 @@ type EventSaleCow struct {
 	PastureId    int64                      `json:"pastureId"`
 	SaleId       int64                      `json:"saleId"`
 	CowId        int64                      `json:"cowId"`
+	CowType      pasturePb.CowType_Kind     `json:"cowType"`
 	EarNumber    string                     `json:"earNumber"`
 	DayAge       int32                      `json:"dayAge"`
 	Lact         int32                      `json:"lact"`
@@ -35,6 +36,7 @@ func NewEventSaleCow(pastureId int64, saleId, saleAt int64, cowInfo *Cow) *Event
 		LactationAge: cowInfo.LactationAge,
 		AdmissionAge: cowInfo.AdmissionAge,
 		DayAge:       cowInfo.GetEventDayAge(saleAt),
+		CowType:      cowInfo.CowType,
 	}
 }
 

+ 46 - 0
module/backend/config_data_extend.go

@@ -307,3 +307,49 @@ func (s *StoreEntry) DataWaringTypeEnumList(isAll string) []*pasturePb.ConfigOpt
 	})
 	return configOptions
 }
+
+func (s *StoreEntry) NeckRingErrorEnumList(isAll string) []*pasturePb.ConfigOptionsList {
+	configOptions := make([]*pasturePb.ConfigOptionsList, 0)
+	if isAll == model.IsAllYes {
+		configOptions = append(configOptions,
+			&pasturePb.ConfigOptionsList{
+				Value:    int32(0),
+				Label:    "全部",
+				Disabled: true,
+			})
+	}
+	configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.NeckRingNumberError_Suspected_Fall_Off),
+		Label:    "疑似脱落",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.NeckRingNumberError_No_Signal),
+		Label:    "无信号",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.NeckRingNumberError_Receiving_Less),
+		Label:    "接受数据过少",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.NeckRingNumberError_Low_Battery),
+		Label:    "低电量",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.NeckRingNumberError_Data_Latency),
+		Label:    "数据有延迟",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.NeckRingNumberError_Low_Activity_Level),
+		Label:    "活动量过低",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.NeckRingNumberError_Abnormal_Wearing),
+		Label:    "佩戴异常",
+		Disabled: true,
+	}, &pasturePb.ConfigOptionsList{
+		Value:    int32(pasturePb.NeckRingNumberError_Should_Associated),
+		Label:    "脖环号未绑定牛号",
+		Disabled: true,
+	})
+	return configOptions
+}

+ 1 - 0
module/backend/enum_options.go

@@ -223,6 +223,7 @@ func (s *StoreEntry) SystemBaseConfigOptions(ctx context.Context, optionsName, i
 		"warningHealthLevel":         s.WarningHealthLevel,
 		"behavior":                   s.Behavior,
 		"matingWindowPeriod":         s.MatingWindowPeriodEnumList,
+		"neckRingError":              s.NeckRingErrorEnumList,
 	}
 
 	getConfigFunc, ok := getConfigFuncMap[optionsName]

+ 4 - 0
module/backend/goods.go

@@ -249,6 +249,10 @@ func (s *StoreEntry) NeckRingList(ctx context.Context, req *pasturePb.SearchNeck
 		pref.Where("b.pen_id = ?", req.PenId)
 	}
 
+	if req.ErrorKind > 0 {
+		pref.Where("a.error_kind = ?", req.ErrorKind)
+	}
+
 	if err = pref.Order("a.id desc").
 		Count(&count).
 		Limit(int(pagination.PageSize)).