123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438 |
- package backend
- import (
- "context"
- "kpt-pasture/model"
- "net/http"
- xxerr "gitee.com/xuyiping_admin/pkg/xerr"
- pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
- )
- 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) ChildNumberEnumList() []*pasturePb.ConfigOptionsList {
- configOptions := make([]*pasturePb.ConfigOptionsList, 0)
- 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() []*pasturePb.ConfigOptionsList {
- configOptions := make([]*pasturePb.ConfigOptionsList, 0)
- 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),
- Label: "剖腹产",
- Disabled: true,
- })
- return configOptions
- }
- func (s *StoreEntry) DystociaReason() []*pasturePb.ConfigOptionsList {
- configOptions := make([]*pasturePb.ConfigOptionsList, 0)
- 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) PregnantCheckResult() []*pasturePb.ConfigOptionsList {
- configOptions := make([]*pasturePb.ConfigOptionsList, 0)
- configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.PregnantCheckResult_InCheck_UnPregnant),
- Label: "初检未孕",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.PregnantCheckResult_InCheck_Pregnant),
- Label: "初检已孕",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.PregnantCheckResult_Recheck_UnPregnant),
- Label: "复检未孕",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.PregnantCheckResult_Recheck_Pregnant),
- Label: "初检已孕",
- Disabled: true,
- })
- return configOptions
- }
- func (s *StoreEntry) PregnantCheckMethod() []*pasturePb.ConfigOptionsList {
- configOptions := make([]*pasturePb.ConfigOptionsList, 0)
- configOptions = append(configOptions, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.PregnantCheckMethod_B_Ultrasound),
- Label: "B超",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.PregnantCheckMethod_Blood_Testing),
- Label: "血检",
- Disabled: true,
- }, &pasturePb.ConfigOptionsList{
- Value: int32(pasturePb.PregnantCheckMethod_Manual_Inspection),
- Label: "人工检查",
- Disabled: true,
- })
- return configOptions
- }
- func (s *StoreEntry) BarnTypeOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
- return &pasturePb.ConfigOptionsListResponse{
- Code: http.StatusOK,
- Message: "ok",
- 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()).
- Where("is_delete = ?", pasturePb.IsShow_Ok).
- Where("pen_type = ?", penType).
- Find(&penList).Error; err != nil {
- return nil, err
- }
- return &pasturePb.ConfigOptionsListResponse{
- Code: http.StatusOK,
- Message: "ok",
- Data: model.PenSlice(penList).ToPB2(s.BarnTypeEnumList()),
- }, nil
- }
- func (s *StoreEntry) BreedStatusOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
- return &pasturePb.ConfigOptionsListResponse{
- Code: http.StatusOK,
- Message: "ok",
- Data: s.BreedStatusEnumList(),
- }, nil
- }
- func (s *StoreEntry) CowKindOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
- return &pasturePb.ConfigOptionsListResponse{
- Code: http.StatusOK,
- Message: "ok",
- Data: s.CowKindEnumList(),
- }, nil
- }
- func (s *StoreEntry) CowSourceOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
- return &pasturePb.ConfigOptionsListResponse{
- Code: http.StatusOK,
- Message: "ok",
- Data: s.CowSourceEnumList(),
- }, nil
- }
- func (s *StoreEntry) CowStatusOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
- return &pasturePb.ConfigOptionsListResponse{
- Code: http.StatusOK,
- Message: "ok",
- Data: s.CowStatusEnumList(),
- }, nil
- }
- func (s *StoreEntry) CowTypeOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
- return &pasturePb.ConfigOptionsListResponse{
- Code: http.StatusOK,
- Message: "ok",
- Data: s.CowTypeEnumList(),
- }, nil
- }
- func (s *StoreEntry) CowTransferPenReasonOptions(ctx context.Context) (*pasturePb.ConfigOptionsListResponse, error) {
- return &pasturePb.ConfigOptionsListResponse{
- Code: http.StatusOK,
- Message: "ok",
- Data: s.TransferPenEnumList(),
- }, nil
- }
- func (s *StoreEntry) SystemUserOptions(ctx context.Context, depId int) (*pasturePb.ConfigOptionsListResponse, error) {
- systemUserList := make([]*model.SystemUser, 0)
- pref := s.DB.Table(new(model.SystemUser).TableName())
- if depId != -1 && depId > 0 {
- pref = pref.Where("dep_id = ?", depId)
- }
- if err := pref.Find(&systemUserList).Error; err != nil {
- return nil, xxerr.WithStack(err)
- }
- return &pasturePb.ConfigOptionsListResponse{
- Code: http.StatusOK,
- Message: "ok",
- Data: model.SystemUserSlice(systemUserList).ToPB2(),
- }, nil
- }
- func (s *StoreEntry) SystemBaseConfigOptions(ctx context.Context, optionsName string) (*pasturePb.ConfigOptionsListResponse, error) {
- configOptions := make([]*pasturePb.ConfigOptionsList, 0)
- switch optionsName {
- case "childNumber":
- configOptions = s.ChildNumberEnumList()
- case "calvingLevel":
- configOptions = s.CalvingLevelEnumList()
- case "dystociaReason":
- configOptions = s.DystociaReason()
- }
- return &pasturePb.ConfigOptionsListResponse{
- Code: http.StatusOK,
- Message: "ok",
- Data: configOptions,
- }, nil
- }
|