123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266 |
- package backend
- import (
- "context"
- "encoding/json"
- "errors"
- "kpt-pasture/model"
- pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
- "gorm.io/gorm"
- "gitee.com/xuyiping_admin/pkg/logger/zaplog"
- "go.uber.org/zap"
- "gitee.com/xuyiping_admin/pkg/xerr"
- )
- func (s *StoreEntry) CowNeckRingNumberBound(ctx context.Context, pagination *pasturePb.PaginationModel) error {
- userModel, err := s.GetUserModel(ctx)
- if err != nil {
- return xerr.WithStack(err)
- }
- lastNeckRing := &model.NeckRing{}
- if err = s.DB.Model(new(model.NeckRing)).
- Order("cow_id desc").
- First(lastNeckRing).Error; err != nil {
- return xerr.WithStack(err)
- }
- cowList := make([]*model.Cow, 0)
- if err = s.DB.Model(new(model.Cow)).
- Where("id > ?", lastNeckRing.CowId).
- Limit(int(pagination.PageSize)).
- Offset(int(pagination.PageOffset)).
- Find(&cowList).Error; err != nil {
- return xerr.WithStack(err)
- }
- newNeckRingList := make([]*model.NeckRing, 0)
- newNeckRingBindLogList := make([]*model.NeckRingBindLog, 0)
- for _, cow := range cowList {
- newNeckRing := model.NewNeckRing(userModel.AppPasture.Id, cow.NeckRingNumber, cow, userModel.SystemUser)
- newNeckRingList = append(newNeckRingList, newNeckRing)
- newNeckRingBindLog := model.NewNeckRingBindLog(userModel.AppPasture.Id, cow.NeckRingNumber, cow, userModel.SystemUser, "")
- newNeckRingBindLogList = append(newNeckRingBindLogList, newNeckRingBindLog)
- }
- if err = s.DB.Model(new(model.NeckRing)).
- Create(newNeckRingList).Error; err != nil {
- zaplog.Error("CowNeckRingNumberBound-NewNeckRing", zap.Any("error", err))
- }
- if err = s.DB.Model(new(model.NeckRingBindLog)).
- Create(newNeckRingBindLogList).Error; err != nil {
- zaplog.Error("CowNeckRingNumberBound-NeckRingBindLog", zap.Any("error", err))
- }
- return nil
- }
- func (s *StoreEntry) CowNeckRingNumberBound2(ctx context.Context, pagination *pasturePb.PaginationModel) error {
- userModel, err := s.GetUserModel(ctx)
- if err != nil {
- return xerr.WithStack(err)
- }
- cowList := make([]*model.Cow, 0)
- if err = s.DB.Model(new(model.Cow)).
- Where("pasture_id = ?", userModel.AppPasture.Id).
- Where("neck_ring_number != ?", "").
- Limit(int(pagination.PageSize)).
- Offset(int(pagination.PageOffset)).
- Find(&cowList).Error; err != nil {
- return xerr.WithStack(err)
- }
- for _, cow := range cowList {
- newNeckRing := model.NewNeckRing(userModel.AppPasture.Id, cow.NeckRingNumber, cow, userModel.SystemUser)
- oldNeckRing := &model.NeckRing{}
- if err = s.DB.Model(new(model.NeckRing)).
- Where("pasture_id = ?", userModel.AppPasture.Id).
- Where("neck_ring_number = ?", cow.NeckRingNumber).
- First(oldNeckRing).Error; err != nil {
- if errors.Is(err, gorm.ErrRecordNotFound) {
- if err = s.DB.Model(new(model.NeckRing)).Create(newNeckRing).Error; err != nil {
- zaplog.Error("CowNeckRingNumberBound2-NewNeckRing", zap.Any("error", err))
- }
- } else {
- continue
- }
- }
- if oldNeckRing.Id > 0 {
- if err = s.DB.Model(new(model.NeckRing)).
- Where("id = ?", oldNeckRing.Id).Updates(map[string]interface{}{
- "cow_id": cow.Id,
- "ear_number": cow.EarNumber,
- "is_bind": pasturePb.NeckRingIsBind_Bind,
- }).Error; err != nil {
- zaplog.Error("CowNeckRingNumberBound2-OldNeckRing", zap.Any("error", err))
- }
- }
- }
- return nil
- }
- func (s *StoreEntry) UpdateCowPen(ctx context.Context, pagination *pasturePb.PaginationModel) error {
- cowList := make([]*model.Cow, 0)
- if err := s.DB.Model(new(model.Cow)).
- Where("pen_name = ?", "").
- Limit(int(pagination.PageSize)).
- Offset(int(pagination.PageOffset)).
- Find(&cowList).Error; err != nil {
- return xerr.WithStack(err)
- }
- penMap := s.PenMap(ctx, 1)
- for _, v := range cowList {
- pen := penMap[v.PenId]
- if pen == nil {
- continue
- }
- if err := s.DB.Model(new(model.Cow)).
- Where("id = ?", v.Id).
- Update("pen_name", pen.Name).Error; err != nil {
- zaplog.Error("UpdateCowPen", zap.Any("error", err))
- }
- }
- return nil
- }
- func (s *StoreEntry) PastureInit(ctx context.Context, pastureId int64) error {
- userModel, err := s.GetUserModel(ctx)
- if err != nil {
- return xerr.WithStack(err)
- }
- if pastureId <= 0 {
- return xerr.New("pastureId invalid")
- }
- pasture := &model.AppPastureList{}
- if err = s.DB.Model(new(model.AppPastureList)).
- Where("id = ?", pastureId).
- First(pasture).Error; err != nil {
- return xerr.Customf("该牧场不存在:%d", pastureId)
- }
- deptList := make([]*model.SystemDept, 0)
- if err = s.DB.Model(new(model.SystemDept)).
- Where("id = ?", pasture.Id).
- Find(&deptList).Error; err != nil {
- return xerr.Customf("牧场初始化数据失败:%s", err.Error())
- }
- if len(deptList) > 0 {
- return xerr.Customf("该牧场已初始化:%d", pastureId)
- }
- dataWaringTypeEnumList := s.DataWaringTypeEnumList(userModel, "all")
- dataWarningList := model.DataWarningInitData(pastureId, dataWaringTypeEnumList)
- if err = s.DB.Transaction(func(tx *gorm.DB) error {
- for _, dataWarning := range dataWarningList {
- if err = tx.Model(new(model.DataWarning)).
- Create(dataWarning).Error; err != nil {
- zaplog.Error("PastureInit-DataWarning", zap.Any("error", err))
- }
- dataWarningItemsList := model.DataWarningItemsInitData(pastureId, dataWarning)
- if err = tx.Model(new(model.DataWarningItems)).
- Create(dataWarningItemsList).Error; err != nil {
- zaplog.Error("PastureInit-DataWarningItems", zap.Any("error", err))
- }
- }
- nackRingConfigureList := model.NeckRingConfigureInit(pastureId)
- if err = tx.Model(new(model.NeckRingConfigure)).
- Create(nackRingConfigureList).Error; err != nil {
- zaplog.Error("PastureInit-NeckRingConfigure", zap.Any("error", err))
- }
- // 初始化牧场和部门数据
- newSystemPastureDept := model.NewSystemPastureDeptInit(pasture)
- if err = tx.Model(new(model.SystemDept)).
- Create(newSystemPastureDept).Error; err != nil {
- zaplog.Error("PastureInit-SystemDept", zap.Any("error", err))
- }
- newSystemDept := model.NewSystemDeptInit(pasture.Id, newSystemPastureDept.Id)
- if err = tx.Model(new(model.SystemDept)).
- Create(newSystemDept).Error; err != nil {
- zaplog.Error("PastureInit-SystemDept", zap.Any("error", err))
- }
- // 初始化菜单
- systemMenuList := make([]*model.SystemPastureMenu, 0)
- if err = tx.Model(new(model.SystemPastureMenu)).
- Where("pasture_id = ?", 0).
- Find(&systemMenuList).Error; err != nil {
- zaplog.Error("PastureInit-SystemMenu", zap.Any("error", err))
- }
- newSystemMenuList := make([]*model.SystemPastureMenu, 0)
- for _, systemMenu := range systemMenuList {
- newSystemMenu := &model.SystemPastureMenu{
- PastureId: pastureId,
- MenuId: systemMenu.Id,
- }
- newSystemMenuList = append(newSystemMenuList, newSystemMenu)
- }
- if err = tx.Model(new(model.SystemPastureMenu)).
- Create(newSystemMenuList).Error; err != nil {
- zaplog.Error("PastureInit-SystemMenu", zap.Any("error", err))
- }
- // 初始化用户和角色 todo
- return nil
- }); err != nil {
- return xerr.WithStack(err)
- }
- return nil
- }
- func (s *StoreEntry) AdmissionAge(ctx context.Context) error {
- /*for k, v := range admissionAgeMap {
- cowInfo, err := s.GetCowInfoByEarNumber(ctx, 4, k)
- if err != nil {
- zaplog.Error("CalvingAge", zap.Any("k", k), zap.Any("v", v), zap.Any("err", err))
- continue
- }
- admissionAt, _ := util.TimeParseLocal(model.LayoutTime2, v)
- if !admissionAt.IsZero() {
- cowInfo.AdmissionAt = admissionAt.Unix()
- cowInfo.AdmissionAge = cowInfo.GetAdmissionAge()
- if err = s.DB.Model(new(model.Cow)).
- Where("id = ?", cowInfo.Id).
- Updates(map[string]interface{}{
- "admission_at": cowInfo.AdmissionAt,
- "admission_age": cowInfo.AdmissionAge,
- }).Error; err != nil {
- zaplog.Error("CalvingAge", zap.Any("err", err))
- }
- }
- }*/
- return nil
- }
- func (s *StoreEntry) CalvingAge(ctx context.Context) error {
- /*for k, v := range calvingAgeMap {
- if v == "" {
- continue
- }
- cowInfo, err := s.GetCowInfoByEarNumber(ctx, 4, k)
- if err != nil {
- zaplog.Error("CalvingAge", zap.Any("k", k), zap.Any("v", v), zap.Any("err", err))
- continue
- }
- calvingAt, _ := util.TimeParseLocal(model.LayoutTime2, v)
- if !calvingAt.IsZero() {
- cowInfo.LastCalvingAt = calvingAt.Unix()
- cowInfo.LactationAge = cowInfo.GetLactationDays()
- if err = s.DB.Model(new(model.Cow)).
- Where("id = ?", cowInfo.Id).
- Updates(map[string]interface{}{
- "last_calving_at": cowInfo.LastCalvingAt,
- "lactation_age": cowInfo.LactationAge,
- }).Error; err != nil {
- zaplog.Error("CalvingAge", zap.Any("err", err))
- }
- }
- }*/
- return nil
- }
- func (s *StoreEntry) SystemMenuInit(ctx context.Context) error {
- items := menuDataInit()
- if err := s.DB.Transaction(func(tx *gorm.DB) error {
- if err := s.InsertCurrentMenuItem(tx, items, 0); err != nil {
- zaplog.Error("SystemMenuInit", zap.Any("err", err))
- return xerr.WithStack(err)
- }
- return nil
- }); err != nil {
- zaplog.Error("SystemMenuInit", zap.Any("err", err))
- }
- return nil
- }
- func (s *StoreEntry) InsertCurrentMenuItem(tx *gorm.DB, menuList []*model.MenuItem, parentId int64) error {
- for _, menu := range menuList {
- showLink := pasturePb.IsShow_Ok
- if menu.Meta.Hidden || !menu.Meta.ShowLink {
- showLink = pasturePb.IsShow_No
- }
- newSystemMenu := &model.SystemMenu{
- Name: menu.Name,
- Path: menu.Path,
- Title: menu.Meta.Title,
- MenuType: 1, // menu_type: 1 (menu)
- ParentId: parentId,
- FrameSrc: "", // frame_src
- FrameLoading: 1, // frame_loading
- Keepalive: 2, // keepalive
- HiddenTag: 2, // hidden_tag
- ShowLink: showLink,
- ShowParent: 2, // show_parent
- Icon: menu.Meta.Icon,
- Component: "", // component
- Redirect: "", // redirect
- Auths: "", // auths
- Rank: menu.Meta.Rank,
- ExtraIcon: "", // extra_icon
- EnterTransition: "", // enter_transition
- //"", // leave_transition
- ActivePath: "", // active_path
- IsShow: 1, // is_show
- IsDelete: 1, // is_delete
- }
- if err := tx.Model(new(model.SystemMenu)).
- Create(newSystemMenu).Error; err != nil {
- zaplog.Error("SystemMenuInit", zap.Any("error", err))
- return xerr.WithStack(err)
- }
- if len(menu.Children) > 0 {
- if err := s.InsertCurrentMenuItem(tx, menu.Children, newSystemMenu.Id); err != nil {
- zaplog.Error("SystemMenuInit", zap.Any("error", err))
- return xerr.WithStack(err)
- }
- }
- }
- return nil
- }
- func menuDataInit() []*model.MenuItem {
- menuData := `[
- {
- "path": "/event",
- "name": "Event",
- "meta": {
- "icon": "carbon:cics-sit-overrides",
- "title": "menus.KptEvent",
- "rank": 12
- },
- "children": [
- {
- "path": "/event/base",
- "meta": {
- "title": "menus.KptBaseEvent"
- },
- "children": [
- {
- "path": "/event/base/enter/index",
- "name": "EnterEvent",
- "meta": {
- "title": "menus.KptEnterEvent"
- }
- },
- {
- "path": "/event/base/group_transfer/index",
- "name": "GroupTransferEvent",
- "meta": {
- "title": "menus.KptGroupTransferEvent"
- }
- },
- {
- "path": "/event/base/add_group/index",
- "name": "add_group",
- "hidden": true,
- "meta": {
- "title": "",
- "showLink": false
- }
- },
- {
- "path": "/event/base/weight/index",
- "name": "Weight",
- "meta": {
- "title": "menus.KptWeight"
- }
- },
- {
- "path": "/event/base/add_weight/index",
- "name": "add_weight",
- "hidden": true,
- "meta": {
- "title": "",
- "showLink": false
- }
- },
- {
- "path": "/event/base/die/index",
- "name": "Die",
- "meta": {
- "title": "menus.KptDie"
- }
- },
- {
- "path": "/event/base/add_die/index",
- "name": "add_die",
- "hidden": true,
- "meta": {
- "title": "",
- "showLink": false
- }
- }
- ]
- },
- {
- "path": "/event/breed",
- "meta": {
- "title": "menus.KptBreedEvent"
- },
- "children": [
- {
- "path": "/event/breed/estrus/index",
- "name": "estrusEvent",
- "meta": {
- "title": "menus.KptEstrusEvent"
- }
- },
- {
- "path": "/event/breed/mating/index",
- "name": "MatingEvent",
- "meta": {
- "title": "menus.KptMatingEvent"
- }
- },
- {
- "path": "/event/breed/add_mating/index",
- "name": "add_mating",
- "hidden": true,
- "meta": {
- "title": "",
- "showLink": false
- }
- },
- {
- "path": "/event/breed/pregnant_check/index",
- "name": "PregnantCheckEvent",
- "meta": {
- "title": "menus.KptPregnantCheckEvent"
- }
- },
- {
- "path": "/event/breed/add_pregnant/index",
- "name": "add_pregnant",
- "hidden": true,
- "meta": {
- "title": "",
- "showLink": false
- }
- },
- {
- "path": "/event/breed/add_estrus/index",
- "name": "add_estrus",
- "hidden": true,
- "meta": {
- "title": "",
- "showLink": false
- }
- },
- {
- "path": "/event/breed/process/index",
- "name": "Process",
- "meta": {
- "title": "menus.Process"
- }
- },
- {
- "path": "/event/breed/add_process/index",
- "name": "add_process",
- "hidden": true,
- "meta": {
- "title": "",
- "showLink": false
- }
- },
- {
- "path": "/event/breed/forbidden/index",
- "name": "forbidden",
- "meta": {
- "title": "menus.forbidden"
- }
- },
- {
- "path": "/event/breed/add_forbidden/index",
- "name": "add_forbidde",
- "hidden": true,
- "meta": {
- "title": "",
- "showLink": false
- }
- }
- ]
- },
- {
- "path": "/event/vet",
- "meta": {
- "title": "menus.KptVetEvent"
- },
- "children": [
- {
- "path": "/event/vet/illness/index",
- "name": "IllNessEvent",
- "meta": {
- "title": "menus.KptIllNessEvent"
- }
- },
- {
- "path": "/event/vet/add_deworm/index",
- "name": "add_deworm",
- "hidden": true,
- "meta": {
- "title": "",
- "showLink": false
- }
- }
- ]
- },
- {
- "path": "/event/other",
- "meta": {
- "title": "menus.KptOtherEvent"
- },
- "children": [
- {
- "path": "/event/other/saleMange/index",
- "name": "saleMangeEvent",
- "meta": {
- "title": "menus.KptsaleMange"
- }
- }
- ]
- }
- ]
- },
- {
- "path": "/goods",
- "redirect": "/goods/drugs/index",
- "name": "Goods",
- "meta": {
- "title": "menus.KptGoods",
- "icon": "ep:goods",
- "rank": 23
- },
- "children": [
- {
- "path": "/goods/vetGoods",
- "meta": {
- "title": "menus.KptVetGoods"
- },
- "children": [
- {
- "path": "/goods/drugs/index",
- "name": "Drugs",
- "meta": {
- "title": "menus.KptDrugs",
- "roles": [
- "admin"
- ]
- }
- },
- {
- "path": "/goods/medical_devices/index",
- "name": "MedicalDevices",
- "meta": {
- "title": "menus.KptMedicalDevices",
- "roles": [
- "admin"
- ]
- }
- }
- ]
- },
- {
- "path": "/goods/hardWareGoods",
- "meta": {
- "title": "menus.KpthardWareGoods"
- },
- "children": [
- {
- "path": "/goods/nech_ring/index",
- "name": "NechRingManage",
- "meta": {
- "title": "menus.KptNechRingManage",
- "roles": [
- "admin"
- ]
- }
- }
- ]
- },
- {
- "path": "/goods/application",
- "meta": {
- "title": "menus.KptApplication"
- },
- "children": [
- {
- "path": "/goods/application_goods/index",
- "name": "ApplicatGoods",
- "meta": {
- "title": "menus.KptApplicatGoods",
- "roles": [
- "admin"
- ]
- }
- }
- ]
- },
- {
- "path": "/goods/otherGoods",
- "meta": {
- "title": "menus.KptOtherGoods"
- },
- "children": [
- {
- "path": "/goods/frozen_semen/index",
- "name": "FrozenSemen",
- "meta": {
- "title": "menus.KptFrozenSemen",
- "roles": [
- "admin"
- ]
- }
- }
- ]
- }
- ]
- },
- {
- "path": "/pasture",
- "redirect": "/pasture/barn/index",
- "name": "Pasture",
- "meta": {
- "title": "menus.kptPasture",
- "icon": "emojione-monotone:cow",
- "rank": 25
- },
- "children": [
- {
- "path": "/pasture/barn",
- "meta": {
- "title": "menus.kptPastureBarn"
- },
- "children": [
- {
- "path": "/pasture/barn/index",
- "name": "BarnManage",
- "meta": {
- "title": "menus.kptPastureInfo",
- "roles": [
- "admin"
- ]
- }
- }
- ]
- },
- {
- "path": "/pasture/disease",
- "meta": {
- "title": "menus.KptDisease"
- },
- "children": [
- {
- "path": "/pasture/disease/disease/index",
- "name": "DiseaseManage",
- "meta": {
- "title": "menus.KptDiseaseInfo",
- "roles": [
- "admin"
- ]
- }
- },
- {
- "path": "/pasture/disease/prescription/index",
- "name": "PrescriptionManage",
- "meta": {
- "title": "menus.KptPrescription",
- "roles": [
- "admin"
- ]
- }
- }
- ]
- },
- {
- "path": "/pasture/health",
- "meta": {
- "title": "menus.kptPastureHealth"
- },
- "children": [
- {
- "path": "/pasture/immunization/index",
- "name": "ImmunizationhManage",
- "meta": {
- "title": "menus.KptImmunization",
- "roles": [
- "admin"
- ]
- }
- },
- {
- "path": "/pasture/health/index",
- "name": "HealthManage",
- "meta": {
- "title": "menus.KptHealth",
- "roles": [
- "admin"
- ],
- "showLink": false
- }
- },
- {
- "path": "/pasture/same_time/index",
- "name": "SameTime",
- "meta": {
- "title": "menus.KptSameTime",
- "roles": [
- "admin"
- ]
- }
- }
- ]
- },
- {
- "path": "/pasture/basic_setting/index",
- "name": "BasicSetting",
- "meta": {
- "title": "menus.KptBasicSettingTitle",
- "roles": [
- "admin"
- ]
- },
- "children": [
- {
- "path": "/pasture/basic_setting/index",
- "name": "BasicSettingIndex",
- "meta": {
- "title": "menus.KptBasicSetting",
- "roles": [
- "admin"
- ]
- }
- }
- ]
- }
- ]
- },
- {
- "path": "/analysis",
- "redirect": "/analysis/BreedIndicators",
- "name": "Analysis",
- "meta": {
- "title": "menus.KptAnalysis",
- "icon": "carbon:analytics-custom",
- "rank": 16
- },
- "children": [
- {
- "path": "/analysis/BreedIndicators",
- "meta": {
- "title": "menus.KptBreedIndicators"
- },
- "children": [
- {
- "path": "/analysis/21pregnancy_Rate/index",
- "name": "21PregnancyRate",
- "meta": {
- "title": "menus.Kpt21PregnancyRate",
- "roles": [
- "admin"
- ]
- }
- },
- {
- "path": "/analysis/miscarriage_Rate/index",
- "name": "MiscarriageRate",
- "meta": {
- "title": "menus.KptMiscarriageRate",
- "roles": [
- "admin"
- ]
- }
- },
- {
- "path": "/analysis/pregnancy_report/index",
- "name": "pregnancyReport",
- "meta": {
- "title": "menus.KptPregnancyReport",
- "roles": [
- "admin"
- ]
- }
- },
- {
- "path": "/analysis/timely_breed/index",
- "name": "timelyBreed",
- "meta": {
- "title": "menus.KpttimelyBreed",
- "roles": [
- "admin"
- ]
- }
- },
- {
- "path": "/analysis/single_factor_conception/index",
- "name": "SingleFactorConception",
- "meta": {
- "title": "menus.KptSingleFactorConception",
- "roles": [
- "admin"
- ]
- }
- },
- {
- "path": "/analysis/multiple_factor_conception/index",
- "name": "MultidimensionalConception",
- "meta": {
- "title": "menus.KptMultidimensionalConception",
- "roles": [
- "admin"
- ]
- }
- }
- ]
- },
- {
- "path": "/analysis/VetIndicators",
- "meta": {
- "title": "menus.KptVetIndicators"
- },
- "children": [
- {
- "path": "/analysis/disease_cure/index",
- "name": "DiseaseCure",
- "meta": {
- "title": "menus.KptDiseaseCure",
- "roles": [
- "admin"
- ]
- }
- },
- {
- "path": "/analysis/production_report/index",
- "name": "productionReport",
- "meta": {
- "title": "menus.KptproductionReport",
- "roles": [
- "admin"
- ]
- }
- }
- ]
- },
- {
- "path": "/analysis/FatIndicators",
- "meta": {
- "title": "menus.KptFatIndicators"
- },
- "children": [
- {
- "path": "/analysis/growth_curve/index",
- "name": "GrowthCurve",
- "meta": {
- "title": "menus.KptGrowthCurve",
- "roles": [
- "admin"
- ]
- }
- },
- {
- "path": "/analysis/weight_distribution/index",
- "name": "WeightDistribution",
- "meta": {
- "title": "menus.KptWeightDistribution",
- "roles": [
- "admin"
- ]
- }
- },
- {
- "path": "/analysis/weight_Fance/index",
- "name": "WeightFance",
- "meta": {
- "title": "menus.KptWeightByFance",
- "roles": [
- "admin"
- ]
- }
- }
- ]
- },
- {
- "path": "/analysis/OtherIndicators",
- "meta": {
- "title": "menus.KptOtherIndicators"
- },
- "children": [
- {
- "path": "/analysis/cattleSales_Report/index",
- "name": "CattleSalesReport",
- "meta": {
- "title": "menus.KptCattleSalesReport",
- "roles": [
- "admin"
- ]
- }
- },
- {
- "path": "/analysis/behavior_curve/index",
- "name": "PenGrowthCurve",
- "meta": {
- "title": "menus.KptBehaviorCurve",
- "roles": [
- "admin"
- ]
- }
- },
- {
- "path": "/analysis/pen_behavior_monitor/index",
- "name": "PenBehaviorMonitor",
- "meta": {
- "title": "menus.KptPenBehaviorMonitor",
- "roles": [
- "admin"
- ]
- }
- },
- {
- "path": "/analysis/cowBehavior/index",
- "name": "CowBehavior",
- "meta": {
- "title": "menus.KptCowBehavior",
- "roles": [
- "admin"
- ]
- }
- }
- ]
- }
- ]
- },
- {
- "path": "/information",
- "redirect": "/information/cow/index",
- "name": "Information",
- "meta": {
- "title": "menus.KptInformationQuery",
- "icon": "carbon:document-preliminary",
- "rank": 17
- },
- "children": [
- {
- "path": "/information/cow",
- "meta": {
- "title": "menus.KptCowIndexQuery"
- },
- "children": [
- {
- "path": "/information/cowQuery/index",
- "name": "CowQuery",
- "meta": {
- "title": "menus.KptCowQuery",
- "roles": [
- "admin"
- ]
- }
- },
- {
- "path": "/information/groupQuery/index",
- "name": "groupCow",
- "meta": {
- "title": "menus.KptGroupCowQuery",
- "roles": [
- "admin"
- ]
- }
- },
- {
- "path": "/information/longTermInfertility/index",
- "name": "LongTermInfertility",
- "meta": {
- "title": "menus.KptLongTermInfertility",
- "roles": [
- "admin"
- ]
- }
- },
- {
- "path": "/information/overdueNoMating/index",
- "name": "OverdueNoMating",
- "meta": {
- "title": "menus.KptOverdueNoMating",
- "roles": [
- "admin"
- ]
- }
- }
- ]
- },
- {
- "path": "/information/moreQuery",
- "meta": {
- "title": "menus.KptMoreQuery"
- },
- "children": [
- {
- "path": "/information/indicatorComparisonQuery/index",
- "name": "indicatorComparisonQuery",
- "meta": {
- "title": "menus.KptIndicatorComparisonQuery",
- "roles": [
- "admin"
- ]
- }
- }
- ]
- }
- ]
- },
- {
- "path": "/work",
- "redirect": "/work/calendar/index",
- "name": "Work",
- "meta": {
- "icon": "streamline:code-monitor-1",
- "title": "menus.KptRoutine",
- "rank": 13
- },
- "children": [
- {
- "path": "/work/workplan",
- "meta": {
- "title": "menus.KptWorkplan"
- },
- "children": [
- {
- "path": "/work/calendar/index",
- "name": "Calendar",
- "meta": {
- "title": "menus.KptCalendar",
- "roles": [
- "admin"
- ]
- }
- }
- ]
- },
- {
- "path": "/work/breedPlan",
- "meta": {
- "title": "menus.KptBreedPlan"
- },
- "children": [
- {
- "path": "/work/samePeriod/index",
- "name": "samePeriod",
- "meta": {
- "title": "menus.KptsamePeriod",
- "roles": [
- "admin"
- ]
- }
- },
- {
- "path": "/work/pregnancyTest/index",
- "name": "PregnancyTest",
- "meta": {
- "title": "menus.KptPregnancyTest",
- "roles": [
- "admin"
- ]
- }
- },
- {
- "path": "/work/breedList/index",
- "name": "BreedList",
- "meta": {
- "title": "menus.KptBreedList",
- "roles": [
- "admin"
- ]
- }
- },
- {
- "path": "/work/weanList/index",
- "name": "WeanList",
- "meta": {
- "title": "menus.KptWeanList",
- "roles": [
- "admin"
- ]
- }
- },
- {
- "path": "/work/calving/index",
- "name": "CalvingList",
- "meta": {
- "title": "menus.KptCalvingEvent"
- }
- }
- ]
- },
- {
- "path": "/work/vetPlan",
- "meta": {
- "title": "menus.KptVetPlan"
- },
- "children": [
- {
- "path": "/work/illnessList/index",
- "name": "illnessList",
- "meta": {
- "title": "menus.KptillnessList",
- "roles": [
- "admin"
- ]
- }
- },
- {
- "path": "/work/immunitytList/index",
- "name": "immunitytList",
- "meta": {
- "title": "menus.KptImmunitytList",
- "roles": [
- "admin"
- ]
- }
- }
- ]
- }
- ]
- },
- {
- "path": "/earlyWarn",
- "redirect": "/earlyWarn/estrueList/index",
- "name": "earlyWarn",
- "meta": {
- "title": "menus.KptEarlyWarnManagementRoter",
- "icon": "ri:alarm-warning-line",
- "rank": 26
- },
- "children": [
- {
- "path": "/earlyWarn/RingWarn",
- "meta": {
- "title": "menus.kptRingEarlyWarn"
- },
- "children": [
- {
- "path": "/earlyWarn/estrueList/index",
- "name": "estrueList",
- "meta": {
- "title": "menus.KptEstrueList",
- "roles": [
- "admin"
- ]
- }
- },
- {
- "path": "/earlyWarn/abortWarn/index",
- "name": "abortWarn",
- "meta": {
- "title": "menus.KptabortWarn",
- "roles": [
- "admin"
- ]
- }
- },
- {
- "path": "/earlyWarn/healthWarn/index",
- "name": "healthWarn",
- "meta": {
- "title": "menus.KptHealthWarn",
- "roles": [
- "admin"
- ]
- }
- },
- {
- "path": "/earlyWarn/stressWarn/index",
- "name": "stressWarn",
- "meta": {
- "title": "menus.KptStressWarn",
- "roles": [
- "admin"
- ]
- }
- }
- ]
- }
- ]
- },
- {
- "path": "/system",
- "redirect": "/system/user/index",
- "name": "System",
- "meta": {
- "icon": "ri:settings-3-line",
- "title": "menus.pureSysManagement",
- "rank": 32
- },
- "children": [
- {
- "path": "/system/all",
- "meta": {
- "title": "menus.sysManagement"
- },
- "children": [
- {
- "path": "/system/user/index",
- "name": "SystemUser",
- "meta": {
- "title": "menus.pureUser",
- "roles": [
- "admin"
- ]
- }
- },
- {
- "path": "/system/role/index",
- "name": "SystemRole",
- "meta": {
- "title": "menus.pureRole",
- "roles": [
- "admin"
- ]
- }
- },
- {
- "path": "/system/menu/index",
- "name": "SystemMenu",
- "meta": {
- "title": "menus.pureSystemMenu",
- "roles": [
- "admin"
- ]
- }
- },
- {
- "path": "/system/dept/index",
- "name": "SystemDept",
- "meta": {
- "title": "menus.pureDept",
- "roles": [
- "admin"
- ]
- }
- }
- ]
- }
- ]
- }
- ]`
- menuList := make([]*model.MenuItem, 0)
- if err := json.Unmarshal([]byte(menuData), &menuList); err != nil {
- zaplog.Error("menuDataInit", zap.Any("err", err))
- }
- return menuList
- }
|