test_service.go 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266
  1. package backend
  2. import (
  3. "context"
  4. "encoding/json"
  5. "errors"
  6. "kpt-pasture/model"
  7. pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  8. "gorm.io/gorm"
  9. "gitee.com/xuyiping_admin/pkg/logger/zaplog"
  10. "go.uber.org/zap"
  11. "gitee.com/xuyiping_admin/pkg/xerr"
  12. )
  13. func (s *StoreEntry) CowNeckRingNumberBound(ctx context.Context, pagination *pasturePb.PaginationModel) error {
  14. userModel, err := s.GetUserModel(ctx)
  15. if err != nil {
  16. return xerr.WithStack(err)
  17. }
  18. lastNeckRing := &model.NeckRing{}
  19. if err = s.DB.Model(new(model.NeckRing)).
  20. Order("cow_id desc").
  21. First(lastNeckRing).Error; err != nil {
  22. return xerr.WithStack(err)
  23. }
  24. cowList := make([]*model.Cow, 0)
  25. if err = s.DB.Model(new(model.Cow)).
  26. Where("id > ?", lastNeckRing.CowId).
  27. Limit(int(pagination.PageSize)).
  28. Offset(int(pagination.PageOffset)).
  29. Find(&cowList).Error; err != nil {
  30. return xerr.WithStack(err)
  31. }
  32. newNeckRingList := make([]*model.NeckRing, 0)
  33. newNeckRingBindLogList := make([]*model.NeckRingBindLog, 0)
  34. for _, cow := range cowList {
  35. newNeckRing := model.NewNeckRing(userModel.AppPasture.Id, cow.NeckRingNumber, cow, userModel.SystemUser)
  36. newNeckRingList = append(newNeckRingList, newNeckRing)
  37. newNeckRingBindLog := model.NewNeckRingBindLog(userModel.AppPasture.Id, cow.NeckRingNumber, cow, userModel.SystemUser, "")
  38. newNeckRingBindLogList = append(newNeckRingBindLogList, newNeckRingBindLog)
  39. }
  40. if err = s.DB.Model(new(model.NeckRing)).
  41. Create(newNeckRingList).Error; err != nil {
  42. zaplog.Error("CowNeckRingNumberBound-NewNeckRing", zap.Any("error", err))
  43. }
  44. if err = s.DB.Model(new(model.NeckRingBindLog)).
  45. Create(newNeckRingBindLogList).Error; err != nil {
  46. zaplog.Error("CowNeckRingNumberBound-NeckRingBindLog", zap.Any("error", err))
  47. }
  48. return nil
  49. }
  50. func (s *StoreEntry) CowNeckRingNumberBound2(ctx context.Context, pagination *pasturePb.PaginationModel) error {
  51. userModel, err := s.GetUserModel(ctx)
  52. if err != nil {
  53. return xerr.WithStack(err)
  54. }
  55. cowList := make([]*model.Cow, 0)
  56. if err = s.DB.Model(new(model.Cow)).
  57. Where("pasture_id = ?", userModel.AppPasture.Id).
  58. Where("neck_ring_number != ?", "").
  59. Limit(int(pagination.PageSize)).
  60. Offset(int(pagination.PageOffset)).
  61. Find(&cowList).Error; err != nil {
  62. return xerr.WithStack(err)
  63. }
  64. for _, cow := range cowList {
  65. newNeckRing := model.NewNeckRing(userModel.AppPasture.Id, cow.NeckRingNumber, cow, userModel.SystemUser)
  66. oldNeckRing := &model.NeckRing{}
  67. if err = s.DB.Model(new(model.NeckRing)).
  68. Where("pasture_id = ?", userModel.AppPasture.Id).
  69. Where("neck_ring_number = ?", cow.NeckRingNumber).
  70. First(oldNeckRing).Error; err != nil {
  71. if errors.Is(err, gorm.ErrRecordNotFound) {
  72. if err = s.DB.Model(new(model.NeckRing)).Create(newNeckRing).Error; err != nil {
  73. zaplog.Error("CowNeckRingNumberBound2-NewNeckRing", zap.Any("error", err))
  74. }
  75. } else {
  76. continue
  77. }
  78. }
  79. if oldNeckRing.Id > 0 {
  80. if err = s.DB.Model(new(model.NeckRing)).
  81. Where("id = ?", oldNeckRing.Id).Updates(map[string]interface{}{
  82. "cow_id": cow.Id,
  83. "ear_number": cow.EarNumber,
  84. "is_bind": pasturePb.NeckRingIsBind_Bind,
  85. }).Error; err != nil {
  86. zaplog.Error("CowNeckRingNumberBound2-OldNeckRing", zap.Any("error", err))
  87. }
  88. }
  89. }
  90. return nil
  91. }
  92. func (s *StoreEntry) UpdateCowPen(ctx context.Context, pagination *pasturePb.PaginationModel) error {
  93. cowList := make([]*model.Cow, 0)
  94. if err := s.DB.Model(new(model.Cow)).
  95. Where("pen_name = ?", "").
  96. Limit(int(pagination.PageSize)).
  97. Offset(int(pagination.PageOffset)).
  98. Find(&cowList).Error; err != nil {
  99. return xerr.WithStack(err)
  100. }
  101. penMap := s.PenMap(ctx, 1)
  102. for _, v := range cowList {
  103. pen := penMap[v.PenId]
  104. if pen == nil {
  105. continue
  106. }
  107. if err := s.DB.Model(new(model.Cow)).
  108. Where("id = ?", v.Id).
  109. Update("pen_name", pen.Name).Error; err != nil {
  110. zaplog.Error("UpdateCowPen", zap.Any("error", err))
  111. }
  112. }
  113. return nil
  114. }
  115. func (s *StoreEntry) PastureInit(ctx context.Context, pastureId int64) error {
  116. userModel, err := s.GetUserModel(ctx)
  117. if err != nil {
  118. return xerr.WithStack(err)
  119. }
  120. if pastureId <= 0 {
  121. return xerr.New("pastureId invalid")
  122. }
  123. pasture := &model.AppPastureList{}
  124. if err = s.DB.Model(new(model.AppPastureList)).
  125. Where("id = ?", pastureId).
  126. First(pasture).Error; err != nil {
  127. return xerr.Customf("该牧场不存在:%d", pastureId)
  128. }
  129. deptList := make([]*model.SystemDept, 0)
  130. if err = s.DB.Model(new(model.SystemDept)).
  131. Where("id = ?", pasture.Id).
  132. Find(&deptList).Error; err != nil {
  133. return xerr.Customf("牧场初始化数据失败:%s", err.Error())
  134. }
  135. if len(deptList) > 0 {
  136. return xerr.Customf("该牧场已初始化:%d", pastureId)
  137. }
  138. dataWaringTypeEnumList := s.DataWaringTypeEnumList(userModel, "all")
  139. dataWarningList := model.DataWarningInitData(pastureId, dataWaringTypeEnumList)
  140. if err = s.DB.Transaction(func(tx *gorm.DB) error {
  141. for _, dataWarning := range dataWarningList {
  142. if err = tx.Model(new(model.DataWarning)).
  143. Create(dataWarning).Error; err != nil {
  144. zaplog.Error("PastureInit-DataWarning", zap.Any("error", err))
  145. }
  146. dataWarningItemsList := model.DataWarningItemsInitData(pastureId, dataWarning)
  147. if err = tx.Model(new(model.DataWarningItems)).
  148. Create(dataWarningItemsList).Error; err != nil {
  149. zaplog.Error("PastureInit-DataWarningItems", zap.Any("error", err))
  150. }
  151. }
  152. nackRingConfigureList := model.NeckRingConfigureInit(pastureId)
  153. if err = tx.Model(new(model.NeckRingConfigure)).
  154. Create(nackRingConfigureList).Error; err != nil {
  155. zaplog.Error("PastureInit-NeckRingConfigure", zap.Any("error", err))
  156. }
  157. // 初始化牧场和部门数据
  158. newSystemPastureDept := model.NewSystemPastureDeptInit(pasture)
  159. if err = tx.Model(new(model.SystemDept)).
  160. Create(newSystemPastureDept).Error; err != nil {
  161. zaplog.Error("PastureInit-SystemDept", zap.Any("error", err))
  162. }
  163. newSystemDept := model.NewSystemDeptInit(pasture.Id, newSystemPastureDept.Id)
  164. if err = tx.Model(new(model.SystemDept)).
  165. Create(newSystemDept).Error; err != nil {
  166. zaplog.Error("PastureInit-SystemDept", zap.Any("error", err))
  167. }
  168. // 初始化菜单
  169. systemMenuList := make([]*model.SystemPastureMenu, 0)
  170. if err = tx.Model(new(model.SystemPastureMenu)).
  171. Where("pasture_id = ?", 0).
  172. Find(&systemMenuList).Error; err != nil {
  173. zaplog.Error("PastureInit-SystemMenu", zap.Any("error", err))
  174. }
  175. newSystemMenuList := make([]*model.SystemPastureMenu, 0)
  176. for _, systemMenu := range systemMenuList {
  177. newSystemMenu := &model.SystemPastureMenu{
  178. PastureId: pastureId,
  179. MenuId: systemMenu.Id,
  180. }
  181. newSystemMenuList = append(newSystemMenuList, newSystemMenu)
  182. }
  183. if err = tx.Model(new(model.SystemPastureMenu)).
  184. Create(newSystemMenuList).Error; err != nil {
  185. zaplog.Error("PastureInit-SystemMenu", zap.Any("error", err))
  186. }
  187. // 初始化用户和角色 todo
  188. return nil
  189. }); err != nil {
  190. return xerr.WithStack(err)
  191. }
  192. return nil
  193. }
  194. func (s *StoreEntry) AdmissionAge(ctx context.Context) error {
  195. /*for k, v := range admissionAgeMap {
  196. cowInfo, err := s.GetCowInfoByEarNumber(ctx, 4, k)
  197. if err != nil {
  198. zaplog.Error("CalvingAge", zap.Any("k", k), zap.Any("v", v), zap.Any("err", err))
  199. continue
  200. }
  201. admissionAt, _ := util.TimeParseLocal(model.LayoutTime2, v)
  202. if !admissionAt.IsZero() {
  203. cowInfo.AdmissionAt = admissionAt.Unix()
  204. cowInfo.AdmissionAge = cowInfo.GetAdmissionAge()
  205. if err = s.DB.Model(new(model.Cow)).
  206. Where("id = ?", cowInfo.Id).
  207. Updates(map[string]interface{}{
  208. "admission_at": cowInfo.AdmissionAt,
  209. "admission_age": cowInfo.AdmissionAge,
  210. }).Error; err != nil {
  211. zaplog.Error("CalvingAge", zap.Any("err", err))
  212. }
  213. }
  214. }*/
  215. return nil
  216. }
  217. func (s *StoreEntry) CalvingAge(ctx context.Context) error {
  218. /*for k, v := range calvingAgeMap {
  219. if v == "" {
  220. continue
  221. }
  222. cowInfo, err := s.GetCowInfoByEarNumber(ctx, 4, k)
  223. if err != nil {
  224. zaplog.Error("CalvingAge", zap.Any("k", k), zap.Any("v", v), zap.Any("err", err))
  225. continue
  226. }
  227. calvingAt, _ := util.TimeParseLocal(model.LayoutTime2, v)
  228. if !calvingAt.IsZero() {
  229. cowInfo.LastCalvingAt = calvingAt.Unix()
  230. cowInfo.LactationAge = cowInfo.GetLactationDays()
  231. if err = s.DB.Model(new(model.Cow)).
  232. Where("id = ?", cowInfo.Id).
  233. Updates(map[string]interface{}{
  234. "last_calving_at": cowInfo.LastCalvingAt,
  235. "lactation_age": cowInfo.LactationAge,
  236. }).Error; err != nil {
  237. zaplog.Error("CalvingAge", zap.Any("err", err))
  238. }
  239. }
  240. }*/
  241. return nil
  242. }
  243. func (s *StoreEntry) SystemMenuInit(ctx context.Context) error {
  244. items := menuDataInit()
  245. if err := s.DB.Transaction(func(tx *gorm.DB) error {
  246. if err := s.InsertCurrentMenuItem(tx, items, 0); err != nil {
  247. zaplog.Error("SystemMenuInit", zap.Any("err", err))
  248. return xerr.WithStack(err)
  249. }
  250. return nil
  251. }); err != nil {
  252. zaplog.Error("SystemMenuInit", zap.Any("err", err))
  253. }
  254. return nil
  255. }
  256. func (s *StoreEntry) InsertCurrentMenuItem(tx *gorm.DB, menuList []*model.MenuItem, parentId int64) error {
  257. for _, menu := range menuList {
  258. showLink := pasturePb.IsShow_Ok
  259. if menu.Meta.Hidden || !menu.Meta.ShowLink {
  260. showLink = pasturePb.IsShow_No
  261. }
  262. newSystemMenu := &model.SystemMenu{
  263. Name: menu.Name,
  264. Path: menu.Path,
  265. Title: menu.Meta.Title,
  266. MenuType: 1, // menu_type: 1 (menu)
  267. ParentId: parentId,
  268. FrameSrc: "", // frame_src
  269. FrameLoading: 1, // frame_loading
  270. Keepalive: 2, // keepalive
  271. HiddenTag: 2, // hidden_tag
  272. ShowLink: showLink,
  273. ShowParent: 2, // show_parent
  274. Icon: menu.Meta.Icon,
  275. Component: "", // component
  276. Redirect: "", // redirect
  277. Auths: "", // auths
  278. Rank: menu.Meta.Rank,
  279. ExtraIcon: "", // extra_icon
  280. EnterTransition: "", // enter_transition
  281. //"", // leave_transition
  282. ActivePath: "", // active_path
  283. IsShow: 1, // is_show
  284. IsDelete: 1, // is_delete
  285. }
  286. if err := tx.Model(new(model.SystemMenu)).
  287. Create(newSystemMenu).Error; err != nil {
  288. zaplog.Error("SystemMenuInit", zap.Any("error", err))
  289. return xerr.WithStack(err)
  290. }
  291. if len(menu.Children) > 0 {
  292. if err := s.InsertCurrentMenuItem(tx, menu.Children, newSystemMenu.Id); err != nil {
  293. zaplog.Error("SystemMenuInit", zap.Any("error", err))
  294. return xerr.WithStack(err)
  295. }
  296. }
  297. }
  298. return nil
  299. }
  300. func menuDataInit() []*model.MenuItem {
  301. menuData := `[
  302. {
  303. "path": "/event",
  304. "name": "Event",
  305. "meta": {
  306. "icon": "carbon:cics-sit-overrides",
  307. "title": "menus.KptEvent",
  308. "rank": 12
  309. },
  310. "children": [
  311. {
  312. "path": "/event/base",
  313. "meta": {
  314. "title": "menus.KptBaseEvent"
  315. },
  316. "children": [
  317. {
  318. "path": "/event/base/enter/index",
  319. "name": "EnterEvent",
  320. "meta": {
  321. "title": "menus.KptEnterEvent"
  322. }
  323. },
  324. {
  325. "path": "/event/base/group_transfer/index",
  326. "name": "GroupTransferEvent",
  327. "meta": {
  328. "title": "menus.KptGroupTransferEvent"
  329. }
  330. },
  331. {
  332. "path": "/event/base/add_group/index",
  333. "name": "add_group",
  334. "hidden": true,
  335. "meta": {
  336. "title": "",
  337. "showLink": false
  338. }
  339. },
  340. {
  341. "path": "/event/base/weight/index",
  342. "name": "Weight",
  343. "meta": {
  344. "title": "menus.KptWeight"
  345. }
  346. },
  347. {
  348. "path": "/event/base/add_weight/index",
  349. "name": "add_weight",
  350. "hidden": true,
  351. "meta": {
  352. "title": "",
  353. "showLink": false
  354. }
  355. },
  356. {
  357. "path": "/event/base/die/index",
  358. "name": "Die",
  359. "meta": {
  360. "title": "menus.KptDie"
  361. }
  362. },
  363. {
  364. "path": "/event/base/add_die/index",
  365. "name": "add_die",
  366. "hidden": true,
  367. "meta": {
  368. "title": "",
  369. "showLink": false
  370. }
  371. }
  372. ]
  373. },
  374. {
  375. "path": "/event/breed",
  376. "meta": {
  377. "title": "menus.KptBreedEvent"
  378. },
  379. "children": [
  380. {
  381. "path": "/event/breed/estrus/index",
  382. "name": "estrusEvent",
  383. "meta": {
  384. "title": "menus.KptEstrusEvent"
  385. }
  386. },
  387. {
  388. "path": "/event/breed/mating/index",
  389. "name": "MatingEvent",
  390. "meta": {
  391. "title": "menus.KptMatingEvent"
  392. }
  393. },
  394. {
  395. "path": "/event/breed/add_mating/index",
  396. "name": "add_mating",
  397. "hidden": true,
  398. "meta": {
  399. "title": "",
  400. "showLink": false
  401. }
  402. },
  403. {
  404. "path": "/event/breed/pregnant_check/index",
  405. "name": "PregnantCheckEvent",
  406. "meta": {
  407. "title": "menus.KptPregnantCheckEvent"
  408. }
  409. },
  410. {
  411. "path": "/event/breed/add_pregnant/index",
  412. "name": "add_pregnant",
  413. "hidden": true,
  414. "meta": {
  415. "title": "",
  416. "showLink": false
  417. }
  418. },
  419. {
  420. "path": "/event/breed/add_estrus/index",
  421. "name": "add_estrus",
  422. "hidden": true,
  423. "meta": {
  424. "title": "",
  425. "showLink": false
  426. }
  427. },
  428. {
  429. "path": "/event/breed/process/index",
  430. "name": "Process",
  431. "meta": {
  432. "title": "menus.Process"
  433. }
  434. },
  435. {
  436. "path": "/event/breed/add_process/index",
  437. "name": "add_process",
  438. "hidden": true,
  439. "meta": {
  440. "title": "",
  441. "showLink": false
  442. }
  443. },
  444. {
  445. "path": "/event/breed/forbidden/index",
  446. "name": "forbidden",
  447. "meta": {
  448. "title": "menus.forbidden"
  449. }
  450. },
  451. {
  452. "path": "/event/breed/add_forbidden/index",
  453. "name": "add_forbidde",
  454. "hidden": true,
  455. "meta": {
  456. "title": "",
  457. "showLink": false
  458. }
  459. }
  460. ]
  461. },
  462. {
  463. "path": "/event/vet",
  464. "meta": {
  465. "title": "menus.KptVetEvent"
  466. },
  467. "children": [
  468. {
  469. "path": "/event/vet/illness/index",
  470. "name": "IllNessEvent",
  471. "meta": {
  472. "title": "menus.KptIllNessEvent"
  473. }
  474. },
  475. {
  476. "path": "/event/vet/add_deworm/index",
  477. "name": "add_deworm",
  478. "hidden": true,
  479. "meta": {
  480. "title": "",
  481. "showLink": false
  482. }
  483. }
  484. ]
  485. },
  486. {
  487. "path": "/event/other",
  488. "meta": {
  489. "title": "menus.KptOtherEvent"
  490. },
  491. "children": [
  492. {
  493. "path": "/event/other/saleMange/index",
  494. "name": "saleMangeEvent",
  495. "meta": {
  496. "title": "menus.KptsaleMange"
  497. }
  498. }
  499. ]
  500. }
  501. ]
  502. },
  503. {
  504. "path": "/goods",
  505. "redirect": "/goods/drugs/index",
  506. "name": "Goods",
  507. "meta": {
  508. "title": "menus.KptGoods",
  509. "icon": "ep:goods",
  510. "rank": 23
  511. },
  512. "children": [
  513. {
  514. "path": "/goods/vetGoods",
  515. "meta": {
  516. "title": "menus.KptVetGoods"
  517. },
  518. "children": [
  519. {
  520. "path": "/goods/drugs/index",
  521. "name": "Drugs",
  522. "meta": {
  523. "title": "menus.KptDrugs",
  524. "roles": [
  525. "admin"
  526. ]
  527. }
  528. },
  529. {
  530. "path": "/goods/medical_devices/index",
  531. "name": "MedicalDevices",
  532. "meta": {
  533. "title": "menus.KptMedicalDevices",
  534. "roles": [
  535. "admin"
  536. ]
  537. }
  538. }
  539. ]
  540. },
  541. {
  542. "path": "/goods/hardWareGoods",
  543. "meta": {
  544. "title": "menus.KpthardWareGoods"
  545. },
  546. "children": [
  547. {
  548. "path": "/goods/nech_ring/index",
  549. "name": "NechRingManage",
  550. "meta": {
  551. "title": "menus.KptNechRingManage",
  552. "roles": [
  553. "admin"
  554. ]
  555. }
  556. }
  557. ]
  558. },
  559. {
  560. "path": "/goods/application",
  561. "meta": {
  562. "title": "menus.KptApplication"
  563. },
  564. "children": [
  565. {
  566. "path": "/goods/application_goods/index",
  567. "name": "ApplicatGoods",
  568. "meta": {
  569. "title": "menus.KptApplicatGoods",
  570. "roles": [
  571. "admin"
  572. ]
  573. }
  574. }
  575. ]
  576. },
  577. {
  578. "path": "/goods/otherGoods",
  579. "meta": {
  580. "title": "menus.KptOtherGoods"
  581. },
  582. "children": [
  583. {
  584. "path": "/goods/frozen_semen/index",
  585. "name": "FrozenSemen",
  586. "meta": {
  587. "title": "menus.KptFrozenSemen",
  588. "roles": [
  589. "admin"
  590. ]
  591. }
  592. }
  593. ]
  594. }
  595. ]
  596. },
  597. {
  598. "path": "/pasture",
  599. "redirect": "/pasture/barn/index",
  600. "name": "Pasture",
  601. "meta": {
  602. "title": "menus.kptPasture",
  603. "icon": "emojione-monotone:cow",
  604. "rank": 25
  605. },
  606. "children": [
  607. {
  608. "path": "/pasture/barn",
  609. "meta": {
  610. "title": "menus.kptPastureBarn"
  611. },
  612. "children": [
  613. {
  614. "path": "/pasture/barn/index",
  615. "name": "BarnManage",
  616. "meta": {
  617. "title": "menus.kptPastureInfo",
  618. "roles": [
  619. "admin"
  620. ]
  621. }
  622. }
  623. ]
  624. },
  625. {
  626. "path": "/pasture/disease",
  627. "meta": {
  628. "title": "menus.KptDisease"
  629. },
  630. "children": [
  631. {
  632. "path": "/pasture/disease/disease/index",
  633. "name": "DiseaseManage",
  634. "meta": {
  635. "title": "menus.KptDiseaseInfo",
  636. "roles": [
  637. "admin"
  638. ]
  639. }
  640. },
  641. {
  642. "path": "/pasture/disease/prescription/index",
  643. "name": "PrescriptionManage",
  644. "meta": {
  645. "title": "menus.KptPrescription",
  646. "roles": [
  647. "admin"
  648. ]
  649. }
  650. }
  651. ]
  652. },
  653. {
  654. "path": "/pasture/health",
  655. "meta": {
  656. "title": "menus.kptPastureHealth"
  657. },
  658. "children": [
  659. {
  660. "path": "/pasture/immunization/index",
  661. "name": "ImmunizationhManage",
  662. "meta": {
  663. "title": "menus.KptImmunization",
  664. "roles": [
  665. "admin"
  666. ]
  667. }
  668. },
  669. {
  670. "path": "/pasture/health/index",
  671. "name": "HealthManage",
  672. "meta": {
  673. "title": "menus.KptHealth",
  674. "roles": [
  675. "admin"
  676. ],
  677. "showLink": false
  678. }
  679. },
  680. {
  681. "path": "/pasture/same_time/index",
  682. "name": "SameTime",
  683. "meta": {
  684. "title": "menus.KptSameTime",
  685. "roles": [
  686. "admin"
  687. ]
  688. }
  689. }
  690. ]
  691. },
  692. {
  693. "path": "/pasture/basic_setting/index",
  694. "name": "BasicSetting",
  695. "meta": {
  696. "title": "menus.KptBasicSettingTitle",
  697. "roles": [
  698. "admin"
  699. ]
  700. },
  701. "children": [
  702. {
  703. "path": "/pasture/basic_setting/index",
  704. "name": "BasicSettingIndex",
  705. "meta": {
  706. "title": "menus.KptBasicSetting",
  707. "roles": [
  708. "admin"
  709. ]
  710. }
  711. }
  712. ]
  713. }
  714. ]
  715. },
  716. {
  717. "path": "/analysis",
  718. "redirect": "/analysis/BreedIndicators",
  719. "name": "Analysis",
  720. "meta": {
  721. "title": "menus.KptAnalysis",
  722. "icon": "carbon:analytics-custom",
  723. "rank": 16
  724. },
  725. "children": [
  726. {
  727. "path": "/analysis/BreedIndicators",
  728. "meta": {
  729. "title": "menus.KptBreedIndicators"
  730. },
  731. "children": [
  732. {
  733. "path": "/analysis/21pregnancy_Rate/index",
  734. "name": "21PregnancyRate",
  735. "meta": {
  736. "title": "menus.Kpt21PregnancyRate",
  737. "roles": [
  738. "admin"
  739. ]
  740. }
  741. },
  742. {
  743. "path": "/analysis/miscarriage_Rate/index",
  744. "name": "MiscarriageRate",
  745. "meta": {
  746. "title": "menus.KptMiscarriageRate",
  747. "roles": [
  748. "admin"
  749. ]
  750. }
  751. },
  752. {
  753. "path": "/analysis/pregnancy_report/index",
  754. "name": "pregnancyReport",
  755. "meta": {
  756. "title": "menus.KptPregnancyReport",
  757. "roles": [
  758. "admin"
  759. ]
  760. }
  761. },
  762. {
  763. "path": "/analysis/timely_breed/index",
  764. "name": "timelyBreed",
  765. "meta": {
  766. "title": "menus.KpttimelyBreed",
  767. "roles": [
  768. "admin"
  769. ]
  770. }
  771. },
  772. {
  773. "path": "/analysis/single_factor_conception/index",
  774. "name": "SingleFactorConception",
  775. "meta": {
  776. "title": "menus.KptSingleFactorConception",
  777. "roles": [
  778. "admin"
  779. ]
  780. }
  781. },
  782. {
  783. "path": "/analysis/multiple_factor_conception/index",
  784. "name": "MultidimensionalConception",
  785. "meta": {
  786. "title": "menus.KptMultidimensionalConception",
  787. "roles": [
  788. "admin"
  789. ]
  790. }
  791. }
  792. ]
  793. },
  794. {
  795. "path": "/analysis/VetIndicators",
  796. "meta": {
  797. "title": "menus.KptVetIndicators"
  798. },
  799. "children": [
  800. {
  801. "path": "/analysis/disease_cure/index",
  802. "name": "DiseaseCure",
  803. "meta": {
  804. "title": "menus.KptDiseaseCure",
  805. "roles": [
  806. "admin"
  807. ]
  808. }
  809. },
  810. {
  811. "path": "/analysis/production_report/index",
  812. "name": "productionReport",
  813. "meta": {
  814. "title": "menus.KptproductionReport",
  815. "roles": [
  816. "admin"
  817. ]
  818. }
  819. }
  820. ]
  821. },
  822. {
  823. "path": "/analysis/FatIndicators",
  824. "meta": {
  825. "title": "menus.KptFatIndicators"
  826. },
  827. "children": [
  828. {
  829. "path": "/analysis/growth_curve/index",
  830. "name": "GrowthCurve",
  831. "meta": {
  832. "title": "menus.KptGrowthCurve",
  833. "roles": [
  834. "admin"
  835. ]
  836. }
  837. },
  838. {
  839. "path": "/analysis/weight_distribution/index",
  840. "name": "WeightDistribution",
  841. "meta": {
  842. "title": "menus.KptWeightDistribution",
  843. "roles": [
  844. "admin"
  845. ]
  846. }
  847. },
  848. {
  849. "path": "/analysis/weight_Fance/index",
  850. "name": "WeightFance",
  851. "meta": {
  852. "title": "menus.KptWeightByFance",
  853. "roles": [
  854. "admin"
  855. ]
  856. }
  857. }
  858. ]
  859. },
  860. {
  861. "path": "/analysis/OtherIndicators",
  862. "meta": {
  863. "title": "menus.KptOtherIndicators"
  864. },
  865. "children": [
  866. {
  867. "path": "/analysis/cattleSales_Report/index",
  868. "name": "CattleSalesReport",
  869. "meta": {
  870. "title": "menus.KptCattleSalesReport",
  871. "roles": [
  872. "admin"
  873. ]
  874. }
  875. },
  876. {
  877. "path": "/analysis/behavior_curve/index",
  878. "name": "PenGrowthCurve",
  879. "meta": {
  880. "title": "menus.KptBehaviorCurve",
  881. "roles": [
  882. "admin"
  883. ]
  884. }
  885. },
  886. {
  887. "path": "/analysis/pen_behavior_monitor/index",
  888. "name": "PenBehaviorMonitor",
  889. "meta": {
  890. "title": "menus.KptPenBehaviorMonitor",
  891. "roles": [
  892. "admin"
  893. ]
  894. }
  895. },
  896. {
  897. "path": "/analysis/cowBehavior/index",
  898. "name": "CowBehavior",
  899. "meta": {
  900. "title": "menus.KptCowBehavior",
  901. "roles": [
  902. "admin"
  903. ]
  904. }
  905. }
  906. ]
  907. }
  908. ]
  909. },
  910. {
  911. "path": "/information",
  912. "redirect": "/information/cow/index",
  913. "name": "Information",
  914. "meta": {
  915. "title": "menus.KptInformationQuery",
  916. "icon": "carbon:document-preliminary",
  917. "rank": 17
  918. },
  919. "children": [
  920. {
  921. "path": "/information/cow",
  922. "meta": {
  923. "title": "menus.KptCowIndexQuery"
  924. },
  925. "children": [
  926. {
  927. "path": "/information/cowQuery/index",
  928. "name": "CowQuery",
  929. "meta": {
  930. "title": "menus.KptCowQuery",
  931. "roles": [
  932. "admin"
  933. ]
  934. }
  935. },
  936. {
  937. "path": "/information/groupQuery/index",
  938. "name": "groupCow",
  939. "meta": {
  940. "title": "menus.KptGroupCowQuery",
  941. "roles": [
  942. "admin"
  943. ]
  944. }
  945. },
  946. {
  947. "path": "/information/longTermInfertility/index",
  948. "name": "LongTermInfertility",
  949. "meta": {
  950. "title": "menus.KptLongTermInfertility",
  951. "roles": [
  952. "admin"
  953. ]
  954. }
  955. },
  956. {
  957. "path": "/information/overdueNoMating/index",
  958. "name": "OverdueNoMating",
  959. "meta": {
  960. "title": "menus.KptOverdueNoMating",
  961. "roles": [
  962. "admin"
  963. ]
  964. }
  965. }
  966. ]
  967. },
  968. {
  969. "path": "/information/moreQuery",
  970. "meta": {
  971. "title": "menus.KptMoreQuery"
  972. },
  973. "children": [
  974. {
  975. "path": "/information/indicatorComparisonQuery/index",
  976. "name": "indicatorComparisonQuery",
  977. "meta": {
  978. "title": "menus.KptIndicatorComparisonQuery",
  979. "roles": [
  980. "admin"
  981. ]
  982. }
  983. }
  984. ]
  985. }
  986. ]
  987. },
  988. {
  989. "path": "/work",
  990. "redirect": "/work/calendar/index",
  991. "name": "Work",
  992. "meta": {
  993. "icon": "streamline:code-monitor-1",
  994. "title": "menus.KptRoutine",
  995. "rank": 13
  996. },
  997. "children": [
  998. {
  999. "path": "/work/workplan",
  1000. "meta": {
  1001. "title": "menus.KptWorkplan"
  1002. },
  1003. "children": [
  1004. {
  1005. "path": "/work/calendar/index",
  1006. "name": "Calendar",
  1007. "meta": {
  1008. "title": "menus.KptCalendar",
  1009. "roles": [
  1010. "admin"
  1011. ]
  1012. }
  1013. }
  1014. ]
  1015. },
  1016. {
  1017. "path": "/work/breedPlan",
  1018. "meta": {
  1019. "title": "menus.KptBreedPlan"
  1020. },
  1021. "children": [
  1022. {
  1023. "path": "/work/samePeriod/index",
  1024. "name": "samePeriod",
  1025. "meta": {
  1026. "title": "menus.KptsamePeriod",
  1027. "roles": [
  1028. "admin"
  1029. ]
  1030. }
  1031. },
  1032. {
  1033. "path": "/work/pregnancyTest/index",
  1034. "name": "PregnancyTest",
  1035. "meta": {
  1036. "title": "menus.KptPregnancyTest",
  1037. "roles": [
  1038. "admin"
  1039. ]
  1040. }
  1041. },
  1042. {
  1043. "path": "/work/breedList/index",
  1044. "name": "BreedList",
  1045. "meta": {
  1046. "title": "menus.KptBreedList",
  1047. "roles": [
  1048. "admin"
  1049. ]
  1050. }
  1051. },
  1052. {
  1053. "path": "/work/weanList/index",
  1054. "name": "WeanList",
  1055. "meta": {
  1056. "title": "menus.KptWeanList",
  1057. "roles": [
  1058. "admin"
  1059. ]
  1060. }
  1061. },
  1062. {
  1063. "path": "/work/calving/index",
  1064. "name": "CalvingList",
  1065. "meta": {
  1066. "title": "menus.KptCalvingEvent"
  1067. }
  1068. }
  1069. ]
  1070. },
  1071. {
  1072. "path": "/work/vetPlan",
  1073. "meta": {
  1074. "title": "menus.KptVetPlan"
  1075. },
  1076. "children": [
  1077. {
  1078. "path": "/work/illnessList/index",
  1079. "name": "illnessList",
  1080. "meta": {
  1081. "title": "menus.KptillnessList",
  1082. "roles": [
  1083. "admin"
  1084. ]
  1085. }
  1086. },
  1087. {
  1088. "path": "/work/immunitytList/index",
  1089. "name": "immunitytList",
  1090. "meta": {
  1091. "title": "menus.KptImmunitytList",
  1092. "roles": [
  1093. "admin"
  1094. ]
  1095. }
  1096. }
  1097. ]
  1098. }
  1099. ]
  1100. },
  1101. {
  1102. "path": "/earlyWarn",
  1103. "redirect": "/earlyWarn/estrueList/index",
  1104. "name": "earlyWarn",
  1105. "meta": {
  1106. "title": "menus.KptEarlyWarnManagementRoter",
  1107. "icon": "ri:alarm-warning-line",
  1108. "rank": 26
  1109. },
  1110. "children": [
  1111. {
  1112. "path": "/earlyWarn/RingWarn",
  1113. "meta": {
  1114. "title": "menus.kptRingEarlyWarn"
  1115. },
  1116. "children": [
  1117. {
  1118. "path": "/earlyWarn/estrueList/index",
  1119. "name": "estrueList",
  1120. "meta": {
  1121. "title": "menus.KptEstrueList",
  1122. "roles": [
  1123. "admin"
  1124. ]
  1125. }
  1126. },
  1127. {
  1128. "path": "/earlyWarn/abortWarn/index",
  1129. "name": "abortWarn",
  1130. "meta": {
  1131. "title": "menus.KptabortWarn",
  1132. "roles": [
  1133. "admin"
  1134. ]
  1135. }
  1136. },
  1137. {
  1138. "path": "/earlyWarn/healthWarn/index",
  1139. "name": "healthWarn",
  1140. "meta": {
  1141. "title": "menus.KptHealthWarn",
  1142. "roles": [
  1143. "admin"
  1144. ]
  1145. }
  1146. },
  1147. {
  1148. "path": "/earlyWarn/stressWarn/index",
  1149. "name": "stressWarn",
  1150. "meta": {
  1151. "title": "menus.KptStressWarn",
  1152. "roles": [
  1153. "admin"
  1154. ]
  1155. }
  1156. }
  1157. ]
  1158. }
  1159. ]
  1160. },
  1161. {
  1162. "path": "/system",
  1163. "redirect": "/system/user/index",
  1164. "name": "System",
  1165. "meta": {
  1166. "icon": "ri:settings-3-line",
  1167. "title": "menus.pureSysManagement",
  1168. "rank": 32
  1169. },
  1170. "children": [
  1171. {
  1172. "path": "/system/all",
  1173. "meta": {
  1174. "title": "menus.sysManagement"
  1175. },
  1176. "children": [
  1177. {
  1178. "path": "/system/user/index",
  1179. "name": "SystemUser",
  1180. "meta": {
  1181. "title": "menus.pureUser",
  1182. "roles": [
  1183. "admin"
  1184. ]
  1185. }
  1186. },
  1187. {
  1188. "path": "/system/role/index",
  1189. "name": "SystemRole",
  1190. "meta": {
  1191. "title": "menus.pureRole",
  1192. "roles": [
  1193. "admin"
  1194. ]
  1195. }
  1196. },
  1197. {
  1198. "path": "/system/menu/index",
  1199. "name": "SystemMenu",
  1200. "meta": {
  1201. "title": "menus.pureSystemMenu",
  1202. "roles": [
  1203. "admin"
  1204. ]
  1205. }
  1206. },
  1207. {
  1208. "path": "/system/dept/index",
  1209. "name": "SystemDept",
  1210. "meta": {
  1211. "title": "menus.pureDept",
  1212. "roles": [
  1213. "admin"
  1214. ]
  1215. }
  1216. }
  1217. ]
  1218. }
  1219. ]
  1220. }
  1221. ]`
  1222. menuList := make([]*model.MenuItem, 0)
  1223. if err := json.Unmarshal([]byte(menuData), &menuList); err != nil {
  1224. zaplog.Error("menuDataInit", zap.Any("err", err))
  1225. }
  1226. return menuList
  1227. }