test_service.go 42 KB

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