package backend import ( "kpt-pasture/model" pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow" "gitee.com/xuyiping_admin/pkg/logger/zaplog" "go.uber.org/zap" ) func (s *StoreEntry) LactEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList { configLactList := make([]*model.ConfigLact, 0) pref := s.DB.Model(new(model.ConfigLact)). Where("is_show =? ", pasturePb.IsShow_Ok). Where("pasture_id =? ", userModel.AppPasture.Id) if isAll == model.IsAllYes { pref = pref.Where("kind >= ?", 0) } else { pref = pref.Where("kind > ?", 0) } if err := pref.Order("kind ASC"). Find(&configLactList).Error; err != nil { zaplog.Error("LactEnumList", zap.Any("err", err)) return make([]*pasturePb.ConfigOptionsList, 0) } return model.ConfigLactSlice(configLactList).ToPB(userModel.Language) /* configOptions = append(configOptions, &pasturePb.ConfigOptionsList{ Value: int32(1), Label: "1", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(2), Label: "2", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(3), Label: "3", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(4), Label: ">3", Disabled: true, }) return configOptions */ } func (s *StoreEntry) DiseaseAnalysisMethodEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList { dataList := make([]*model.ConfigDiseaseAnalysisMethod, 0) pref := s.DB.Model(new(model.ConfigDiseaseAnalysisMethod)). Where("is_show =? ", pasturePb.IsShow_Ok). Where("pasture_id =? ", userModel.AppPasture.Id) if isAll == model.IsAllYes { pref = pref.Where("kind >= ?", pasturePb.DiseaseAnalysisMethod_Invalid) } else { pref = pref.Where("kind > ?", pasturePb.DiseaseAnalysisMethod_Invalid) } if err := pref.Order("kind ASC"). Find(&dataList).Error; err != nil { zaplog.Error("DiseaseAnalysisMethodEnumList", zap.Any("err", err)) return make([]*pasturePb.ConfigOptionsList, 0) } return model.ConfigDiseaseAnalysisMethodSlice(dataList).ToPB(userModel.Language) /* configOptions = append(configOptions, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.DiseaseAnalysisMethod_Months), Label: "按月份", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.DiseaseAnalysisMethod_Disease_Category), Label: "疾病分类", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.DiseaseAnalysisMethod_Disease), Label: "疾病名称", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.DiseaseAnalysisMethod_Operator), Label: "兽医", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.DiseaseAnalysisMethod_Prescription), Label: "处方", Disabled: true, }) return configOptions */ } func (s *StoreEntry) diseaseTypeEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList { configDiseaseTypeList := make([]*model.ConfigDiseaseType, 0) if err := s.DB.Model(new(model.ConfigDiseaseType)). Where("pasture_id = ?", userModel.AppPasture.Id). Where("is_show = ?", pasturePb.IsShow_Ok). Find(&configDiseaseTypeList).Error; err != nil { zaplog.Error("diseaseTypeEnumList", zap.Any("Find", err)) return make([]*pasturePb.ConfigOptionsList, 0) } return model.ConfigDiseaseTypeSlice(configDiseaseTypeList).ToPB3(userModel.Language) } func (s *StoreEntry) SingleFactorAnalysisMethodEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList { dataList := make([]*model.ConfigSingleFactorAnalysisMethod, 0) pref := s.DB.Model(new(model.ConfigSingleFactorAnalysisMethod)). Where("is_show =? ", pasturePb.IsShow_Ok). Where("pasture_id =? ", userModel.AppPasture.Id) if isAll == model.IsAllYes { pref = pref.Where("kind >= ?", pasturePb.DiseaseAnalysisMethod_Invalid) } else { pref = pref.Where("kind > ?", pasturePb.DiseaseAnalysisMethod_Invalid) } if err := pref.Order("kind ASC"). Find(&dataList).Error; err != nil { zaplog.Error("SingleFactorAnalysisMethodEnumList", zap.Any("err", err)) return make([]*pasturePb.ConfigOptionsList, 0) } return model.ConfigSingleFactorAnalysisMethodSlice(dataList).ToPB(userModel.Language) /* func (s *StoreEntry) SingleFactorAnalysisMethodEnumList(isAll string) []*pasturePb.ConfigOptionsList { configOptions := make([]*pasturePb.ConfigOptionsList, 0) configOptions = append(configOptions, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.SingleFactorAnalysisMethod_Cycle), Label: "按周期分析", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.SingleFactorAnalysisMethod_Months), Label: "按月份分析", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.SingleFactorAnalysisMethod_Mating_Times), Label: "按配种次数分析", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.SingleFactorAnalysisMethod_Breeding_Method), Label: "按配种方式分析", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.SingleFactorAnalysisMethod_Breeding_Company), Label: "按育种公司分析", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.SingleFactorAnalysisMethod_Operation), Label: "按兽医人员分析", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.SingleFactorAnalysisMethod_Mating_Interval), Label: "按配种间隔分析", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.SingleFactorAnalysisMethod_Bull), Label: "按公牛号分析", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.SingleFactorAnalysisMethod_Breeding_Cycle), Label: "按配种周期分析", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.SingleFactorAnalysisMethod_Week), Label: "按星期分析", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.SingleFactorAnalysisMethod_Lact), Label: "按胎次分析", Disabled: true, }) return configOptions */ } func (s *StoreEntry) LactIntervalSymbolEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList { dataList := make([]*model.ConfigLactIntervalSymbol, 0) pref := s.DB.Model(new(model.ConfigLactIntervalSymbol)). Where("is_show =? ", pasturePb.IsShow_Ok). Where("pasture_id =? ", userModel.AppPasture.Id) if isAll == model.IsAllYes { pref = pref.Where("kind >= ?", pasturePb.CompareSymbol_Invalid) } else { pref = pref.Where("kind > ?", pasturePb.CompareSymbol_Invalid) } if err := pref.Order("kind ASC"). Find(&dataList).Error; err != nil { zaplog.Error("LactIntervalSymbolEnumList", zap.Any("err", err)) return make([]*pasturePb.ConfigOptionsList, 0) } return model.ConfigLactIntervalSymbolSlice(dataList).ToPB(userModel.Language) /*configOptions := make([]*pasturePb.ConfigOptionsList, 0) configOptions = append(configOptions, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.CompareSymbol_Less_Than), Label: "<", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.CompareSymbol_Less_Than_Or_Equal_To), Label: "<=", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.CompareSymbol_Greater_Than), Label: ">", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.CompareSymbol_Greater_Than_Or_Equal_To), Label: ">=", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.CompareSymbol_Equal_To), Label: "=", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.CompareSymbol_Not_Equal_To), Label: "!=", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.CompareSymbol_Between), Label: "区间", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.CompareSymbol_Include), Label: "包含", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.CompareSymbol_Not_Include), Label: "不包含", Disabled: true, }) return configOptions*/ } func (s *StoreEntry) MultiFactorAnalysisMethodEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList { dataList := make([]*model.ConfigMultiFactorAnalysisMethod, 0) pref := s.DB.Model(new(model.ConfigMultiFactorAnalysisMethod)). Where("is_show =? ", pasturePb.IsShow_Ok). Where("pasture_id =? ", userModel.AppPasture.Id) if isAll == model.IsAllYes { pref = pref.Where("kind >= ?", pasturePb.CompareSymbol_Invalid) } else { pref = pref.Where("kind > ?", pasturePb.CompareSymbol_Invalid) } if err := pref.Order("kind ASC"). Find(&dataList).Error; err != nil { zaplog.Error("LactIntervalSymbolEnumList", zap.Any("err", err)) return make([]*pasturePb.ConfigOptionsList, 0) } return model.ConfigMultiFactorAnalysisMethodSlice(dataList).ToPB(userModel.Language) /*configOptions := make([]*pasturePb.ConfigOptionsList, 0) configOptions = append(configOptions, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.MultiFactorAnalysisMethod_Months), Label: "月份", Props: "months", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.MultiFactorAnalysisMethod_Week), Label: "周", Props: "week", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.MultiFactorAnalysisMethod_Operation), Label: "配种员", Props: "operationName", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.MultiFactorAnalysisMethod_Bull), Label: "公牛", Props: "bull", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.MultiFactorAnalysisMethod_Lact), Label: "胎次", Props: "lact", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.MultiFactorAnalysisMethod_Mating_Times), Label: "配次", Props: "matingTimes", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.MultiFactorAnalysisMethod_Breeding_Method), Label: "配种方式", Props: "exposeEstrusType", Disabled: true, }) return configOptions*/ } func (s *StoreEntry) SaleCowAnalysisMethodEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList { dataList := make([]*model.ConfigSaleCowAnalysisMethod, 0) pref := s.DB.Model(new(model.ConfigSaleCowAnalysisMethod)). Where("is_show =? ", pasturePb.IsShow_Ok). Where("pasture_id =? ", userModel.AppPasture.Id) if isAll == model.IsAllYes { pref = pref.Where("kind >= ?", pasturePb.CompareSymbol_Invalid) } else { pref = pref.Where("kind > ?", pasturePb.CompareSymbol_Invalid) } if err := pref.Order("kind ASC"). Find(&dataList).Error; err != nil { zaplog.Error("LactIntervalSymbolEnumList", zap.Any("err", err)) return make([]*pasturePb.ConfigOptionsList, 0) } return model.ConfigSaleCowAnalysisMethodSlice(dataList).ToPB(userModel.Language) /*configOptions := make([]*pasturePb.ConfigOptionsList, 0) configOptions = append(configOptions, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.SaleCowAnalysisMethod_Months), Label: "月份", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.SaleCowAnalysisMethod_Dealer), Label: "经销商", Disabled: true, }) return configOptions*/ } func (s *StoreEntry) NeckRingIsBindEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList { dataList := make([]*model.ConfigNeckRingIsBind, 0) pref := s.DB.Model(new(model.ConfigNeckRingStatus)). Where("is_show =? ", pasturePb.IsShow_Ok). Where("pasture_id =? ", userModel.AppPasture.Id) if isAll == model.IsAllYes { pref = pref.Where("kind >= ?", pasturePb.NeckRingIsBind_Invalid) } else { pref = pref.Where("kind > ?", pasturePb.NeckRingIsBind_Invalid) } if err := pref.Order("kind ASC"). Find(&dataList).Error; err != nil { zaplog.Error("NeckRingIsBindEnumList", zap.Any("err", err)) return make([]*pasturePb.ConfigOptionsList, 0) } return model.ConfigNeckRingIsBindSlice(dataList).ToPB(userModel.Language) /*configOptions := make([]*pasturePb.ConfigOptionsList, 0) if isAll == model.IsAllYes { configOptions = append(configOptions, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.NeckRingIsBind_Invalid), Label: "全部", Disabled: true, }) } configOptions = append(configOptions, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.NeckRingIsBind_Bind), Label: "已绑定", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.NeckRingIsBind_Unbind), Label: "未绑定", Disabled: true, }) return configOptions*/ } func (s *StoreEntry) NeckRingStatusEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList { dataList := make([]*model.ConfigNeckRingStatus, 0) pref := s.DB.Model(new(model.ConfigNeckRingStatus)). Where("is_show =? ", pasturePb.IsShow_Ok). Where("pasture_id =? ", userModel.AppPasture.Id) if isAll == model.IsAllYes { pref = pref.Where("kind >= ?", pasturePb.NeckRingStatus_Invalid) } else { pref = pref.Where("kind > ?", pasturePb.NeckRingStatus_Invalid) } if err := pref.Order("kind ASC"). Find(&dataList).Error; err != nil { zaplog.Error("NeckRingStatusEnumList", zap.Any("err", err)) return make([]*pasturePb.ConfigOptionsList, 0) } return model.ConfigNeckRingStatusSlice(dataList).ToPB(userModel.Language) /*configOptions := make([]*pasturePb.ConfigOptionsList, 0) if isAll == model.IsAllYes { configOptions = append(configOptions, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.NeckRingStatus_Invalid), Label: "全部", Disabled: true, }) } configOptions = append(configOptions, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.NeckRingStatus_Normal), Label: "正常", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.NeckRingStatus_Abnormal), Label: "异常", Disabled: true, }) return configOptions*/ } func (s *StoreEntry) CalendarTypeEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList { dataList := make([]*model.ConfigCalendarType, 0) pref := s.DB.Model(new(model.ConfigCalendarType)). Where("is_show =? ", pasturePb.IsShow_Ok). Where("pasture_id =? ", userModel.AppPasture.Id) if isAll == model.IsAllYes { pref = pref.Where("kind >= ?", pasturePb.CalendarType_Invalid) } else { pref = pref.Where("kind > ?", pasturePb.CalendarType_Invalid) } if err := pref.Order("kind ASC"). Find(&dataList).Error; err != nil { zaplog.Error("CalendarTypeEnumList", zap.Any("err", err)) return make([]*pasturePb.ConfigOptionsList, 0) } return model.ConfigCalendarTypeSlice(dataList).ToPB(userModel.Language) /*configOptions := make([]*pasturePb.ConfigOptionsList, 0) if isAll == model.IsAllYes { configOptions = append(configOptions, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.CalendarType_Invalid), Label: "全部", Disabled: true, }) } configOptions = append(configOptions, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.CalendarType_Immunisation), Label: "免疫", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.CalendarType_PG), Label: "同期PG", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.CalendarType_RnGH), Label: "同期RnGH", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.CalendarType_Pregnancy_Check), Label: "孕检", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.CalendarType_Weaning), Label: "断奶", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.CalendarType_Disease), Label: "疾病", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.CalendarType_Mating), Label: "配种", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.CalendarType_Calving), Label: "产犊", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.CalendarType_DryMilk), Label: "干奶", Disabled: true, }) return configOptions*/ } func (s *StoreEntry) AbortionReasonsEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList { dataList := make([]*model.ConfigAbortionReasons, 0) pref := s.DB.Model(new(model.ConfigAbortionReasons)). Where("is_show =? ", pasturePb.IsShow_Ok). Where("pasture_id =? ", userModel.AppPasture.Id) if isAll == model.IsAllYes { pref = pref.Where("kind >= ?", pasturePb.AbortionReasons_Invalid) } else { pref = pref.Where("kind > ?", pasturePb.AbortionReasons_Invalid) } if err := pref.Order("kind ASC"). Find(&dataList).Error; err != nil { zaplog.Error("AbortionReasonsEnumList", zap.Any("err", err)) return make([]*pasturePb.ConfigOptionsList, 0) } return model.ConfigAbortionReasonsSlice(dataList).ToPB(userModel.Language) } func (s *StoreEntry) CalvingAnalysisMethodEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList { dataList := make([]*model.ConfigCalvingAnalysisMethod, 0) pref := s.DB.Model(new(model.ConfigCalvingAnalysisMethod)). Where("is_show =? ", pasturePb.IsShow_Ok). Where("pasture_id =? ", userModel.AppPasture.Id) if isAll == model.IsAllYes { pref = pref.Where("kind >= ?", pasturePb.CalvingAnalysisMethod_Invalid) } else { pref = pref.Where("kind > ?", pasturePb.CalvingAnalysisMethod_Invalid) } if err := pref.Order("kind ASC"). Find(&dataList).Error; err != nil { zaplog.Error("CalvingAnalysisMethodEnumList", zap.Any("err", err)) return make([]*pasturePb.ConfigOptionsList, 0) } return model.ConfigCalvingAnalysisMethodSlice(dataList).ToPB(userModel.Language) /*configOptions := make([]*pasturePb.ConfigOptionsList, 0) if isAll == model.IsAllYes { configOptions = append(configOptions, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.CalvingAnalysisMethod_Invalid), Label: "全部", Disabled: true, }) } configOptions = append(configOptions, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.CalvingAnalysisMethod_Months), Label: "按月份统计", Disabled: true, }, &pasturePb.ConfigOptionsList{ Value: int32(pasturePb.CalvingAnalysisMethod_CowKind), Label: "按照品种统计", Disabled: true, }) return configOptions*/ }