12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262 |
- 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 {
- 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("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))
- }
- // 初始化用户和角色
- 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
- }
|