|
@@ -10,19 +10,225 @@ import (
|
|
|
pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
|
|
|
)
|
|
|
|
|
|
-func (s *StoreEntry) BarnTypeOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
|
|
|
- configBarnTypeList := make([]*model.ConfigPenType, 0)
|
|
|
- if err := s.DB.Table(new(model.ConfigPenType).TableName()).Find(&configBarnTypeList).Error; err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
+func (s *StoreEntry) BarnTypeEnumList() []*pasturePb.ConfigOptionsList {
|
|
|
+ barnTypeList := make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
+ barnTypeList = append(barnTypeList, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.PenType_Lactating_Calves),
|
|
|
+ Label: "哺乳犊牛舍",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.PenType_Weaned_Calves),
|
|
|
+ Label: "断奶犊牛舍",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.PenType_Youth),
|
|
|
+ Label: "育成牛舍",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.PenType_Nurturing),
|
|
|
+ Label: "育成牛舍",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.PenType_Lactation),
|
|
|
+ Label: "泌乳牛舍",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.PenType_Peripartum),
|
|
|
+ Label: "围产牛舍",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.PenType_Dry_Milking),
|
|
|
+ Label: "干奶牛舍",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.PenType_Sick_Cow),
|
|
|
+ Label: "病牛舍",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.PenType_Eliminate),
|
|
|
+ Label: "淘汰牛舍",
|
|
|
+ Disabled: true,
|
|
|
+ })
|
|
|
+ return barnTypeList
|
|
|
+}
|
|
|
+func (s *StoreEntry) BreedStatusEnumList() []*pasturePb.ConfigOptionsList {
|
|
|
+ breedStatusList := make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
+ breedStatusList = append(breedStatusList, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.BreedStatus_Unmarried),
|
|
|
+ Label: "未配",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.BreedStatus_InCheck_Unpregnant),
|
|
|
+ Label: "初检无胎",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.BreedStatus_InCheck_Pregnant),
|
|
|
+ Label: "初检有胎",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.BreedStatus_Recheck_Unpregnant),
|
|
|
+ Label: "复检无胎",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.BreedStatus_Recheck_Pregnant),
|
|
|
+ Label: "复检有胎",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.BreedStatus_Pause_Pregnant),
|
|
|
+ Label: "停配",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.BreedStatus_No_Pregnant),
|
|
|
+ Label: "禁配",
|
|
|
+ Disabled: true,
|
|
|
+ })
|
|
|
+ return breedStatusList
|
|
|
+}
|
|
|
+
|
|
|
+func (s *StoreEntry) CowKindEnumList() []*pasturePb.ConfigOptionsList {
|
|
|
+ cowKindList := make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
+ cowKindList = append(cowKindList, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.CowKind_HST),
|
|
|
+ Label: "荷斯坦",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.CowKind_JSN),
|
|
|
+ Label: "娟姗牛",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.CowKind_SHN),
|
|
|
+ Label: "三河牛",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.CowKind_XJHN),
|
|
|
+ Label: "新疆褐牛",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.CowKind_MN),
|
|
|
+ Label: "牦牛",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.CowKind_XMTEN),
|
|
|
+ Label: "西门塔尔牛",
|
|
|
+ Disabled: true,
|
|
|
+ })
|
|
|
+ return cowKindList
|
|
|
+}
|
|
|
+
|
|
|
+func (s *StoreEntry) CowSourceEnumList() []*pasturePb.ConfigOptionsList {
|
|
|
+ cowSourceList := make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
+ cowSourceList = append(cowSourceList, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.CowSource_Calving),
|
|
|
+ Label: "产犊",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.CowSource_Transfer_In),
|
|
|
+ Label: "调入",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.CowSource_Buy),
|
|
|
+ Label: "购买",
|
|
|
+ Disabled: true,
|
|
|
+ })
|
|
|
+ return cowSourceList
|
|
|
+}
|
|
|
|
|
|
+func (s *StoreEntry) CowStatusEnumList() []*pasturePb.ConfigOptionsList {
|
|
|
+ cowStatusList := make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
+ cowStatusList = append(cowStatusList, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.CowStatus_Calving),
|
|
|
+ Label: "产犊",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.CowStatus_Empty),
|
|
|
+ Label: "空怀",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.CowStatus_Breeding),
|
|
|
+ Label: "配种",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.CowStatus_Pregnant),
|
|
|
+ Label: "怀孕",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.CowStatus_Dry_Milk),
|
|
|
+ Label: "干奶",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.CowStatus_Peripartum),
|
|
|
+ Label: "围产",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.CowStatus_No_Pregnant),
|
|
|
+ Label: "禁配",
|
|
|
+ Disabled: true,
|
|
|
+ })
|
|
|
+ return cowStatusList
|
|
|
+}
|
|
|
+
|
|
|
+func (s *StoreEntry) CowTypeEnumList() []*pasturePb.ConfigOptionsList {
|
|
|
+ cowTypeList := make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
+ cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.CowType_Lactating_Calf),
|
|
|
+ Label: "哺乳犊牛",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.CowType_Weaned_Calf),
|
|
|
+ Label: "断奶犊牛",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.CowType_Youth),
|
|
|
+ Label: "青年牛",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.CowType_Nurturing),
|
|
|
+ Label: "育成牛",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.CowType_Lactation),
|
|
|
+ Label: "泌乳牛",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.CowType_Dry_Milk),
|
|
|
+ Label: "干奶牛",
|
|
|
+ Disabled: true,
|
|
|
+ })
|
|
|
+ return cowTypeList
|
|
|
+}
|
|
|
+
|
|
|
+func (s *StoreEntry) TransferPenEnumList() []*pasturePb.ConfigOptionsList {
|
|
|
+ transferPenList := make([]*pasturePb.ConfigOptionsList, 0)
|
|
|
+ transferPenList = append(transferPenList, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.TransferPenReason_Normal),
|
|
|
+ Label: "正常转群",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.TransferPenReason_Feed),
|
|
|
+ Label: "饲喂转群",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.TransferPenReason_Dry_Milk),
|
|
|
+ Label: "干奶转群",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.TransferPenReason_Pregnant),
|
|
|
+ Label: "怀孕转群",
|
|
|
+ Disabled: true,
|
|
|
+ }, &pasturePb.ConfigOptionsList{
|
|
|
+ Value: int32(pasturePb.TransferPenReason_Overantibody),
|
|
|
+ Label: "过抗转群",
|
|
|
+ Disabled: true,
|
|
|
+ })
|
|
|
+ return transferPenList
|
|
|
+}
|
|
|
+func (s *StoreEntry) BarnTypeOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
|
|
|
return &pasturePb.ConfigOptionsListResponse{
|
|
|
Code: http.StatusOK,
|
|
|
Message: "ok",
|
|
|
- Data: model.ConfigBarnTypeSlice(configBarnTypeList).ToPB2(),
|
|
|
+ Data: s.BarnTypeEnumList(),
|
|
|
}, nil
|
|
|
}
|
|
|
-
|
|
|
func (s *StoreEntry) BarnListOptions(ctx context.Context, penType int) (*pasturePb.ConfigOptionsListResponse, error) {
|
|
|
penList := make([]*model.Pen, 0)
|
|
|
if err := s.DB.Table(new(model.Pen).TableName()).
|
|
@@ -32,87 +238,56 @@ func (s *StoreEntry) BarnListOptions(ctx context.Context, penType int) (*pasture
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
- configBarnTypeList := make([]*model.ConfigPenType, 0)
|
|
|
- if err := s.DB.Table(new(model.ConfigPenType).TableName()).Find(&configBarnTypeList).Error; err != nil {
|
|
|
- return nil, err
|
|
|
- }
|
|
|
-
|
|
|
return &pasturePb.ConfigOptionsListResponse{
|
|
|
Code: http.StatusOK,
|
|
|
Message: "ok",
|
|
|
- Data: model.PenSlice(penList).ToPB2(configBarnTypeList),
|
|
|
+ Data: model.PenSlice(penList).ToPB2(s.BarnTypeEnumList()),
|
|
|
}, nil
|
|
|
}
|
|
|
-
|
|
|
func (s *StoreEntry) BreedStatusOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
|
|
|
- configBreedStatusList := make([]*model.ConfigBreedStatus, 0)
|
|
|
- if err := s.DB.Table(new(model.ConfigBreedStatus).TableName()).Find(&configBreedStatusList).Error; err != nil {
|
|
|
- return nil, xxerr.WithStack(err)
|
|
|
- }
|
|
|
return &pasturePb.ConfigOptionsListResponse{
|
|
|
Code: http.StatusOK,
|
|
|
Message: "ok",
|
|
|
- Data: model.ConfigBreedStatusSlice(configBreedStatusList).ToPB2(),
|
|
|
+ Data: s.BreedStatusEnumList(),
|
|
|
}, nil
|
|
|
}
|
|
|
-
|
|
|
func (s *StoreEntry) CowKindOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
|
|
|
- configCowKindList := make([]*model.ConfigCowKind, 0)
|
|
|
- if err := s.DB.Table(new(model.ConfigCowKind).TableName()).Find(&configCowKindList).Error; err != nil {
|
|
|
- return nil, xxerr.WithStack(err)
|
|
|
- }
|
|
|
return &pasturePb.ConfigOptionsListResponse{
|
|
|
Code: http.StatusOK,
|
|
|
Message: "ok",
|
|
|
- Data: model.ConfigCowKindSlice(configCowKindList).ToPB2(),
|
|
|
+ Data: s.CowKindEnumList(),
|
|
|
}, nil
|
|
|
}
|
|
|
|
|
|
func (s *StoreEntry) CowSourceOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
|
|
|
- configCowSourceList := make([]*model.ConfigCowSource, 0)
|
|
|
- if err := s.DB.Table(new(model.ConfigCowSource).TableName()).Find(&configCowSourceList).Error; err != nil {
|
|
|
- return nil, xxerr.WithStack(err)
|
|
|
- }
|
|
|
return &pasturePb.ConfigOptionsListResponse{
|
|
|
Code: http.StatusOK,
|
|
|
Message: "ok",
|
|
|
- Data: model.ConfigCowSourceSlice(configCowSourceList).ToPB2(),
|
|
|
+ Data: s.CowSourceEnumList(),
|
|
|
}, nil
|
|
|
}
|
|
|
|
|
|
func (s *StoreEntry) CowStatusOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
|
|
|
- configCowStatusList := make([]*model.ConfigCowStatus, 0)
|
|
|
- if err := s.DB.Table(new(model.ConfigCowStatus).TableName()).Find(&configCowStatusList).Error; err != nil {
|
|
|
- return nil, xxerr.WithStack(err)
|
|
|
- }
|
|
|
return &pasturePb.ConfigOptionsListResponse{
|
|
|
Code: http.StatusOK,
|
|
|
Message: "ok",
|
|
|
- Data: model.ConfigCowStatusSlice(configCowStatusList).ToPB2(),
|
|
|
+ Data: s.CowStatusEnumList(),
|
|
|
}, nil
|
|
|
}
|
|
|
|
|
|
func (s *StoreEntry) CowTypeOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
|
|
|
- configCowTypeList := make([]*model.ConfigCowType, 0)
|
|
|
- if err := s.DB.Table(new(model.ConfigCowType).TableName()).Find(&configCowTypeList).Error; err != nil {
|
|
|
- return nil, xxerr.WithStack(err)
|
|
|
- }
|
|
|
return &pasturePb.ConfigOptionsListResponse{
|
|
|
Code: http.StatusOK,
|
|
|
Message: "ok",
|
|
|
- Data: model.ConfigCowTypeSlice(configCowTypeList).ToPB2(),
|
|
|
+ Data: s.CowTypeEnumList(),
|
|
|
}, nil
|
|
|
}
|
|
|
|
|
|
func (s *StoreEntry) CowTransferPenReasonOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
|
|
|
- configTransferPenReasonList := make([]*model.ConfigTransferPenReason, 0)
|
|
|
- if err := s.DB.Table(new(model.ConfigTransferPenReason).TableName()).Find(&configTransferPenReasonList).Error; err != nil {
|
|
|
- return nil, xxerr.WithStack(err)
|
|
|
- }
|
|
|
return &pasturePb.ConfigOptionsListResponse{
|
|
|
Code: http.StatusOK,
|
|
|
Message: "ok",
|
|
|
- Data: model.ConfigTransferPenReasonSlice(configTransferPenReasonList).ToPB2(),
|
|
|
+ Data: s.TransferPenEnumList(),
|
|
|
}, nil
|
|
|
}
|
|
|
|
|
@@ -138,19 +313,19 @@ func (s *StoreEntry) SystemBaseConfigOptions(ctx context.Context, optionsName st
|
|
|
case "childNumber":
|
|
|
configOptions = append(configOptions,
|
|
|
&pasturePb.ConfigOptionsList{
|
|
|
- Value: 1,
|
|
|
+ Value: int32(pasturePb.ChildNumber_One),
|
|
|
Label: "单胎",
|
|
|
Disabled: true,
|
|
|
}, &pasturePb.ConfigOptionsList{
|
|
|
- Value: 2,
|
|
|
+ Value: int32(pasturePb.ChildNumber_Two),
|
|
|
Label: "双胎",
|
|
|
Disabled: true,
|
|
|
}, &pasturePb.ConfigOptionsList{
|
|
|
- Value: 3,
|
|
|
+ Value: int32(pasturePb.ChildNumber_Three),
|
|
|
Label: "三胎",
|
|
|
Disabled: true,
|
|
|
}, &pasturePb.ConfigOptionsList{
|
|
|
- Value: 4,
|
|
|
+ Value: int32(pasturePb.ChildNumber_Four),
|
|
|
Label: "四胎",
|
|
|
Disabled: true,
|
|
|
})
|