123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643 |
- package backend
- import (
- "kpt-pasture/model"
- "go.uber.org/zap"
- pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
- "gitee.com/xuyiping_admin/pkg/logger/zaplog"
- )
- func (s *StoreEntry) BarnTypeEnumList(excludeTypes []pasturePb.PenType_Kind) []*pasturePb.ConfigOptionsList {
- allBarnTypes := s.BarnTypeMap()
- barnTypeList := make([]*pasturePb.ConfigOptionsList, 0)
- for v1 := range allBarnTypes {
- var info bool
- for _, v2 := range excludeTypes {
- if v1 == v2 {
- info = true
- break
- }
- }
- if !info {
- barnTypeList = append(barnTypeList, &pasturePb.ConfigOptionsList{
- Value: int32(v1),
- Label: allBarnTypes[v1],
- Disabled: true,
- })
- }
- }
- return barnTypeList
- }
- func (s *StoreEntry) BreedStatusEnumList(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.SaleCowAnalysisMethod_Invalid)
- } else {
- pref = pref.Where("kind > ?", pasturePb.SaleCowAnalysisMethod_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)
- /*breedStatusList := make([]*pasturePb.ConfigOptionsList, 0)
- breedStatusList = append(breedStatusList, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.BreedStatus_UnBreed),
- Label: "未配",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.BreedStatus_Breeding),
- Label: "已配未检",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.BreedStatus_Pregnant),
- Label: "怀孕",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.BreedStatus_Empty),
- Label: "空怀",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.BreedStatus_Calving),
- Label: "产犊",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.BreedStatus_Abort),
- Label: "流产",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.BreedStatus_No_Mating),
- Label: "禁配",
- Disabled: true,
- })
- return breedStatusList*/
- }
- func (s *StoreEntry) CowKindEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
- dataList := make([]*model.ConfigCowKind, 0)
- pref := s.DB.Model(new(model.ConfigCowKind)).
- Where("is_show =? ", pasturePb.IsShow_Ok).
- Where("pasture_id =? ", userModel.AppPasture.Id)
- if isAll == model.IsAllYes {
- pref = pref.Where("kind >= ?", pasturePb.CowKind_Invalid)
- } else {
- pref = pref.Where("kind > ?", pasturePb.CowKind_Invalid)
- }
- if err := pref.Order("kind ASC").
- Find(&dataList).Error; err != nil {
- zaplog.Error("CowKindEnumList", zap.Any("err", err))
- return make([]*pasturePb.ConfigOptionsList, 0)
- }
- return model.ConfigCowKindSlice(dataList).ToPB2(userModel.Language)
- /*cowKindList := make([]*pasturePb.ConfigOptionsList, 0)
- cowKindList = append(cowKindList, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.CowKind_XMTEN),
- Label: "西门塔尔牛",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.CowKind_AGSN),
- Label: "安格斯牛",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.CowKind_XNLN),
- Label: "夏洛莱牛",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.CowKind_LMZN),
- Label: "利木赞牛",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.CowKind_HFTN),
- Label: "海福特牛",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.CowKind_HN),
- Label: "和牛",
- Disabled: true,
- })
- return cowKindList*/
- }
- func (s *StoreEntry) CowSourceEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
- dataList := make([]*model.ConfigCowSource, 0)
- pref := s.DB.Model(new(model.ConfigCowSource)).
- Where("is_show =? ", pasturePb.IsShow_Ok).
- Where("pasture_id =? ", userModel.AppPasture.Id)
- if isAll == model.IsAllYes {
- pref = pref.Where("kind >= ?", pasturePb.CowSource_Invalid)
- } else {
- pref = pref.Where("kind > ?", pasturePb.CowSource_Invalid)
- }
- if err := pref.Order("kind ASC").
- Find(&dataList).Error; err != nil {
- zaplog.Error("CowKindEnumList", zap.Any("err", err))
- return make([]*pasturePb.ConfigOptionsList, 0)
- }
- return model.ConfigCowSourceSlice(dataList).ToPB2(userModel.Language)
- /*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) CowTypeEnumList(optionName, isAll string) []*pasturePb.ConfigOptionsList {
- cowTypeList := make([]*pasturePb.ConfigOptionsList, 0)
- if isAll == model.IsAllYes {
- cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.CowType_Invalid),
- Label: "全部",
- Disabled: true,
- })
- }
- if optionName == "breed" {
- cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.CowType_Reserve_Calf),
- Label: "后备牛",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.CowType_Breeding_Calf),
- Label: "成母牛",
- Disabled: true,
- })
- return cowTypeList
- }
- 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_Calf),
- Label: "青年牛",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.CowType_Fattening_Calf),
- Label: "育肥牛",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.CowType_Reserve_Calf),
- Label: "后备牛",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.CowType_Breeding_Calf),
- Label: "成母牛",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.CowType_Breeding_Bull),
- Label: "种公牛",
- Disabled: true,
- })
- return cowTypeList
- }
- func (s *StoreEntry) SameTimeCowTypeEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
- dataList := make([]*model.ConfigSameTimeCowType, 0)
- pref := s.DB.Model(new(model.ConfigSameTimeCowType)).
- Where("is_show =? ", pasturePb.IsShow_Ok).
- Where("pasture_id =? ", userModel.AppPasture.Id)
- if isAll == model.IsAllYes {
- pref = pref.Where("kind >= ?", pasturePb.SameTimeCowType_Invalid)
- } else {
- pref = pref.Where("kind > ?", pasturePb.SameTimeCowType_Invalid)
- }
- if err := pref.Order("kind ASC").
- Find(&dataList).Error; err != nil {
- zaplog.Error("ConfigSameTimeCowType", zap.Any("err", err))
- return make([]*pasturePb.ConfigOptionsList, 0)
- }
- return model.ConfigSameTimeCowTypeSlice(dataList).ToPB(userModel.Language)
- /*cowTypeList := make([]*pasturePb.ConfigOptionsList, 0)
- if isAll == model.IsAllYes {
- cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.SameTimeCowType_Invalid),
- Label: "全部",
- Disabled: true,
- })
- }
- cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.SameTimeCowType_Empty),
- Label: "空怀牛",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.SameTimeCowType_Breeding_Calf),
- Label: "成母牛",
- Disabled: true,
- })
- return cowTypeList*/
- }
- func (s *StoreEntry) SameTimeTypeEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
- dataList := make([]*model.ConfigSameTimeType, 0)
- pref := s.DB.Model(new(model.ConfigSameTimeType)).
- Where("is_show =? ", pasturePb.IsShow_Ok).
- Where("pasture_id =? ", userModel.AppPasture.Id)
- if isAll == model.IsAllYes {
- pref = pref.Where("kind >= ?", pasturePb.SameTimeType_Invalid)
- } else {
- pref = pref.Where("kind > ?", pasturePb.SameTimeType_Invalid)
- }
- if err := pref.Order("kind ASC").
- Find(&dataList).Error; err != nil {
- zaplog.Error("SameTimeTypeEnumList", zap.Any("err", err))
- return make([]*pasturePb.ConfigOptionsList, 0)
- }
- return model.ConfigSameTimeTypeSlice(dataList).ToPB(userModel.Language)
- /*cowTypeList := make([]*pasturePb.ConfigOptionsList, 0)
- if isAll == model.IsAllYes {
- cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.SameTimeType_Invalid),
- Label: "全部",
- Disabled: true,
- })
- }
- cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.SameTimeType_PGBJ),
- Label: "PG保健",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.SameTimeType_PGTQ),
- Label: "PG同期",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.SameTimeType_RnGH),
- Label: "RnGH",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.SameTimeType_TAI),
- Label: "TAI输精",
- Disabled: true,
- })
- return cowTypeList*/
- }
- func (s *StoreEntry) ImmunizationCowTypeEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
- dataList := make([]*model.ConfigImmunizationCowType, 0)
- pref := s.DB.Model(new(model.ConfigImmunizationCowType)).
- Where("is_show =? ", pasturePb.IsShow_Ok).
- Where("pasture_id =? ", userModel.AppPasture.Id)
- if isAll == model.IsAllYes {
- pref = pref.Where("kind >= ?", pasturePb.CowKind_Invalid)
- } else {
- pref = pref.Where("kind > ?", pasturePb.CowKind_Invalid)
- }
- if err := pref.Order("kind ASC").
- Find(&dataList).Error; err != nil {
- zaplog.Error("SameTimeTypeEnumList", zap.Any("err", err))
- return make([]*pasturePb.ConfigOptionsList, 0)
- }
- return model.ConfigImmunizationCowTypeSlice(dataList).ToPB(userModel.Language)
- /*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_Calf),
- Label: "青年牛",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.CowType_Fattening_Calf),
- Label: "育肥牛",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.CowType_Reserve_Calf),
- Label: "后备牛",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.CowType_Breeding_Calf),
- Label: "成母牛",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.CowType_Breeding_Bull),
- Label: "种公牛",
- Disabled: true,
- })
- return cowTypeList*/
- }
- func (s *StoreEntry) ImmunizationConditionsEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
- dataList := make([]*model.ConfigImmunizationConditions, 0)
- pref := s.DB.Model(new(model.ConfigImmunizationConditions)).
- Where("is_show =? ", pasturePb.IsShow_Ok).
- Where("pasture_id =? ", userModel.AppPasture.Id)
- if isAll == model.IsAllYes {
- pref = pref.Where("kind >= ?", pasturePb.ImmunizationConditions_Invalid)
- } else {
- pref = pref.Where("kind > ?", pasturePb.ImmunizationConditions_Invalid)
- }
- if err := pref.Order("kind ASC").
- Find(&dataList).Error; err != nil {
- zaplog.Error("ImmunizationConditionsEnumList", zap.Any("err", err))
- return make([]*pasturePb.ConfigOptionsList, 0)
- }
- return model.ConfigImmunizationConditionsSlice(dataList).ToPB(userModel.Language)
- /*cowTypeList := make([]*pasturePb.ConfigOptionsList, 0)
- if isAll == model.IsAllYes {
- cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.ImmunizationConditions_Invalid),
- Label: "全部",
- Disabled: true,
- })
- }
- cowTypeList = append(cowTypeList, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.ImmunizationConditions_Days_Age),
- Label: "日龄",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.ImmunizationConditions_Days_After_Delivery),
- Label: "产后天数",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.ImmunizationConditions_Days_Of_Pregnancy),
- Label: "怀孕天数",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.ImmunizationConditions_Admission_Days),
- Label: "入场天数",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.ImmunizationConditions_Other_Vaccine_After),
- Label: "基于其他疫苗之后",
- Disabled: true,
- })
- return cowTypeList*/
- }
- func (s *StoreEntry) TransferPenEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
- dataList := make([]*model.ConfigTransferPenReason, 0)
- pref := s.DB.Model(new(model.ConfigTransferPenReason)).
- Where("is_show =? ", pasturePb.IsShow_Ok).
- Where("pasture_id =? ", userModel.AppPasture.Id)
- if isAll == model.IsAllYes {
- pref = pref.Where("kind >= ?", pasturePb.TransferPenReason_Invalid)
- } else {
- pref = pref.Where("kind > ?", pasturePb.TransferPenReason_Invalid)
- }
- if err := pref.Order("kind ASC").
- Find(&dataList).Error; err != nil {
- zaplog.Error("TransferPenEnumList", zap.Any("err", err))
- return make([]*pasturePb.ConfigOptionsList, 0)
- }
- return model.ConfigTransferPenReasonSlice(dataList).ToPB2(userModel.Language)
- /*transferPenList := make([]*pasturePb.ConfigOptionsList, 0)
- if isAll == model.IsAllYes {
- transferPenList = append(transferPenList, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.TransferPenReason_Invalid),
- Label: "全部",
- Disabled: true,
- })
- }
- 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) ChildNumberEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
- dataList := make([]*model.ConfigChildNumber, 0)
- pref := s.DB.Model(new(model.ConfigChildNumber)).
- Where("is_show =? ", pasturePb.IsShow_Ok).
- Where("pasture_id =? ", userModel.AppPasture.Id)
- if isAll == model.IsAllYes {
- pref = pref.Where("kind >= ?", pasturePb.ChildNumber_Invalid)
- } else {
- pref = pref.Where("kind > ?", pasturePb.ChildNumber_Invalid)
- }
- if err := pref.Order("kind ASC").
- Find(&dataList).Error; err != nil {
- zaplog.Error("ChildNumberEnumList", zap.Any("err", err))
- return make([]*pasturePb.ConfigOptionsList, 0)
- }
- return model.ConfigChildNumberSlice(dataList).ToPB(userModel.Language)
- /*configOptions := make([]*pasturePb.ConfigOptionsList, 0)
- if isAll == model.IsAllYes {
- configOptions = append(configOptions,
- &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.ChildNumber_Invalid),
- Label: "全部",
- Disabled: true,
- })
- }
- configOptions = append(configOptions,
- &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.ChildNumber_One),
- Label: "单胎",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.ChildNumber_Two),
- Label: "双胎",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.ChildNumber_Three),
- Label: "三胎",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.ChildNumber_Four),
- Label: "四胎",
- Disabled: true,
- })
- return configOptions*/
- }
- func (s *StoreEntry) CalvingLevelEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
- dataList := make([]*model.ConfigCalvingLevel, 0)
- pref := s.DB.Model(new(model.ConfigCalvingLevel)).
- Where("is_show =? ", pasturePb.IsShow_Ok).
- Where("pasture_id =? ", userModel.AppPasture.Id)
- if isAll == model.IsAllYes {
- pref = pref.Where("kind >= ?", pasturePb.CalvingLevel_Invalid)
- } else {
- pref = pref.Where("kind > ?", pasturePb.CalvingLevel_Invalid)
- }
- if err := pref.Order("kind ASC").
- Find(&dataList).Error; err != nil {
- zaplog.Error("CalvingLevelEnumList", zap.Any("err", err))
- return make([]*pasturePb.ConfigOptionsList, 0)
- }
- return model.ConfigCalvingLevelSlice(dataList).ToPB(userModel.Language)
- /*configOptions := make([]*pasturePb.ConfigOptionsList, 0)
- if isAll == model.IsAllYes {
- configOptions = append(configOptions,
- &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.CalvingLevel_Invalid),
- Label: "全部",
- Disabled: true,
- })
- }
- configOptions = append(configOptions,
- &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.CalvingLevel_Natural_Childbirth),
- Label: "自然分娩",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.CalvingLevel_Artificial_Midwifery1),
- Label: "人工助产(1-2人)",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.CalvingLevel_Artificial_Midwifery2),
- Label: "人工助产(3人以上)",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.CalvingLevel_Caesarean_Section),
- Label: "剖腹产",
- Disabled: true,
- })
- return configOptions*/
- }
- func (s *StoreEntry) DystociaReasonEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
- dataList := make([]*model.ConfigDystociaReason, 0)
- pref := s.DB.Model(new(model.ConfigDystociaReason)).
- Where("is_show =? ", pasturePb.IsShow_Ok).
- Where("pasture_id =? ", userModel.AppPasture.Id)
- if isAll == model.IsAllYes {
- pref = pref.Where("kind >= ?", pasturePb.DystociaReason_Invalid)
- } else {
- pref = pref.Where("kind > ?", pasturePb.DystociaReason_Invalid)
- }
- if err := pref.Order("kind ASC").
- Find(&dataList).Error; err != nil {
- zaplog.Error("CalvingLevelEnumList", zap.Any("err", err))
- return make([]*pasturePb.ConfigOptionsList, 0)
- }
- return model.ConfigDystociaReasonSlice(dataList).ToPB(userModel.Language)
- /*configOptions := make([]*pasturePb.ConfigOptionsList, 0)
- if isAll == model.IsAllYes {
- configOptions = append(configOptions,
- &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.DystociaReason_Invalid),
- Label: "全部",
- Disabled: true,
- })
- }
- configOptions = append(configOptions,
- &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.DystociaReason_Malposition),
- Label: "胎位不正",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.DystociaReason_Fetal_Overgrowth),
- Label: "胎儿过大",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.DystociaReason_Uterine_Atony),
- Label: "子宫收缩无力",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.DystociaReason_Pelvic_Stenosis),
- Label: "盆骨狭小",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.DystociaReason_Sub_Health),
- Label: "母牛亚健康状态",
- Disabled: true,
- })
- return configOptions*/
- }
- func (s *StoreEntry) PregnantCheckResultEnumList(userModel *model.UserModel, isAll string) []*pasturePb.ConfigOptionsList {
- dataList := make([]*model.ConfigPregnantCheckResult, 0)
- pref := s.DB.Model(new(model.ConfigPregnantCheckResult)).
- Where("is_show =? ", pasturePb.IsShow_Ok).
- Where("pasture_id =? ", userModel.AppPasture.Id)
- if isAll == model.IsAllYes {
- pref = pref.Where("kind >= ?", pasturePb.PregnantCheckResult_Invalid)
- } else {
- pref = pref.Where("kind > ?", pasturePb.PregnantCheckResult_Invalid)
- }
- if err := pref.Order("kind ASC").
- Find(&dataList).Error; err != nil {
- zaplog.Error("PregnantCheckResultEnumList", zap.Any("err", err))
- return make([]*pasturePb.ConfigOptionsList, 0)
- }
- return model.ConfigPregnantCheckResultSlice(dataList).ToPB(userModel.Language)
- /*configOptions := make([]*pasturePb.ConfigOptionsList, 0)
- if isAll == model.IsAllYes {
- configOptions = append(configOptions,
- &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.PregnantCheckResult_Invalid),
- Label: "全部",
- Disabled: true,
- })
- }
- configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.PregnantCheckResult_Pregnant),
- Label: "有胎",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.PregnantCheckResult_UnPregnant),
- Label: "无胎",
- Disabled: true,
- })
- return configOptions*/
- }
|