predict_edb_classify.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. package data_manage
  2. import (
  3. "encoding/json"
  4. "eta/eta_api/controllers"
  5. "eta/eta_api/models"
  6. "eta/eta_api/models/data_manage"
  7. "eta/eta_api/models/system"
  8. "eta/eta_api/services/data"
  9. "eta/eta_api/utils"
  10. )
  11. // PredictEdbClassifyController 数据管理-预测指标分类模块
  12. type PredictEdbClassifyController struct {
  13. controllers.BaseAuthController
  14. }
  15. // List
  16. // @Title 预测指标分类列表
  17. // @Description 预测指标分类列表接口
  18. // @Param IsOnlyMe query bool false "是否只看我的"
  19. // @Success 200 {object} data_manage.EdbClassifyListResp
  20. // @router /predict_classify/list [get]
  21. func (this *PredictEdbClassifyController) List() {
  22. br := new(models.BaseResponse).Init()
  23. defer func() {
  24. this.Data["json"] = br
  25. this.ServeJSON()
  26. }()
  27. isOnlyMe, _ := this.GetBool("IsOnlyMe")
  28. rootList, err := data_manage.GetEdbClassifyByParentId(0, 1)
  29. if err != nil && err.Error() != utils.ErrNoRow() {
  30. br.Msg = "获取失败"
  31. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  32. return
  33. }
  34. // 获取当前账号的不可见指标
  35. obj := data_manage.EdbInfoNoPermissionAdmin{}
  36. confList, err := obj.GetAllListByAdminId(this.SysUser.AdminId)
  37. if err != nil && err.Error() != utils.ErrNoRow() {
  38. br.Msg = "获取失败"
  39. br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
  40. return
  41. }
  42. noPermissionEdbInfoIdMap := make(map[int]bool)
  43. for _, v := range confList {
  44. noPermissionEdbInfoIdMap[v.EdbInfoId] = true
  45. }
  46. allEdbInfo, err := data_manage.GetPredictEdbInfoAll(1)
  47. if err != nil && err.Error() != utils.ErrNoRow() {
  48. br.Msg = "获取失败"
  49. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  50. return
  51. }
  52. edbInfoMap := make(map[int][]*data_manage.EdbClassifyItems)
  53. for _, v := range allEdbInfo {
  54. // 如果指标不可见,那么就不返回该指标
  55. if _, ok := noPermissionEdbInfoIdMap[v.EdbInfoId]; ok {
  56. continue
  57. }
  58. button := data.GetPredictEdbOpButton(this.SysUser, v.SysUserId)
  59. button.AddButton = false //不管有没有权限,指标都是没有添加按钮的
  60. button.OpButton = false
  61. button.DeleteButton = false
  62. v.Button = button
  63. if isOnlyMe {
  64. if v.SysUserId == this.SysUser.AdminId {
  65. edbInfoMap[v.ClassifyId] = append(edbInfoMap[v.ClassifyId], v)
  66. }
  67. } else {
  68. edbInfoMap[v.ClassifyId] = append(edbInfoMap[v.ClassifyId], v)
  69. }
  70. }
  71. rootChildMap := make(map[int][]*data_manage.EdbClassifyItems)
  72. for _, v := range rootList {
  73. button := data.GetPredictEdbClassifyOpButton(this.SysUser, v.SysUserId)
  74. v.Button = button
  75. rootChildMap[v.ParentId] = append(rootChildMap[v.ParentId], v)
  76. if existItems, ok := edbInfoMap[v.ClassifyId]; ok {
  77. v.Children = existItems
  78. } else {
  79. items := make([]*data_manage.EdbClassifyItems, 0)
  80. v.Children = items
  81. }
  82. }
  83. nodeAll := make([]*data_manage.EdbClassifyItems, 0)
  84. for _, v := range rootList {
  85. nodeAll = append(nodeAll, v)
  86. }
  87. // 是否允许添加分类
  88. canOpClassify := true
  89. // 如果不是 超管 或者 ficc管理员 或者 ficc研究员,那么就没有权限
  90. //if !utils.InArrayByStr([]string{utils.ROLE_TYPE_CODE_ADMIN, utils.ROLE_TYPE_CODE_FICC_ADMIN, utils.ROLE_TYPE_CODE_RESEARCHR, utils.ROLE_TYPE_CODE_FICC_RESEARCHR}, this.SysUser.RoleTypeCode) {
  91. // canOpClassify = false
  92. //}
  93. language := `CN`
  94. // 指标显示的语言
  95. {
  96. configDetail, _ := system.GetConfigDetailByCode(this.SysUser.AdminId, system.PredictEdbLanguageVar)
  97. if configDetail != nil {
  98. language = configDetail.ConfigValue
  99. } else {
  100. configDetail, _ = system.GetDefaultConfigDetailByCode(system.PredictEdbLanguageVar)
  101. if configDetail != nil {
  102. language = configDetail.ConfigValue
  103. }
  104. }
  105. }
  106. resp := data_manage.EdbClassifyListResp{
  107. AllNodes: nodeAll,
  108. CanOpClassify: canOpClassify,
  109. Language: language,
  110. }
  111. br.Ret = 200
  112. br.Success = true
  113. br.Msg = "获取成功"
  114. br.Data = resp
  115. }
  116. // Items
  117. // @Title 获取所有预测指标分类接口-不包含指标
  118. // @Description 获取所有预测指标分类接口-不包含指标
  119. // @Success 200 {object} data_manage.EdbClassifyListResp
  120. // @router /predict_classify/items [get]
  121. func (this *PredictEdbClassifyController) Items() {
  122. br := new(models.BaseResponse).Init()
  123. defer func() {
  124. this.Data["json"] = br
  125. this.ServeJSON()
  126. }()
  127. rootList, err := data_manage.GetEdbClassifyByParentId(0, 1)
  128. if err != nil {
  129. br.Msg = "获取失败"
  130. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  131. return
  132. }
  133. resp := new(data_manage.EdbClassifyListResp)
  134. resp.AllNodes = rootList
  135. br.Ret = 200
  136. br.Success = true
  137. br.Msg = "获取成功"
  138. br.Data = resp
  139. }
  140. // Add
  141. // @Title 新增预测指标分类
  142. // @Description 新增预测指标分类接口
  143. // @Param request body data_manage.AddEdbClassifyReq true "type json string"
  144. // @Success 200 Ret=200 保存成功
  145. // @router /predict_classify/add [post]
  146. func (this *PredictEdbClassifyController) Add() {
  147. br := new(models.BaseResponse).Init()
  148. defer func() {
  149. this.Data["json"] = br
  150. this.ServeJSON()
  151. }()
  152. var req data_manage.AddEdbClassifyReq
  153. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  154. if err != nil {
  155. br.Msg = "参数解析异常!"
  156. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  157. return
  158. }
  159. if req.ClassifyName == "" {
  160. br.Msg = "请输入分类名称"
  161. br.IsSendEmail = false
  162. return
  163. }
  164. if req.ParentId < 0 {
  165. br.Msg = "参数错误"
  166. br.IsSendEmail = false
  167. return
  168. }
  169. button := data.GetPredictEdbClassifyOpButton(this.SysUser, 0)
  170. if !button.AddButton {
  171. br.Msg = "不允许添加分类"
  172. br.IsSendEmail = false
  173. return
  174. }
  175. // 添加指标分类
  176. _, err, errMsg := data.AddEdbClassify(req.ClassifyName, req.ParentId, req.Level, 1, this.SysUser.AdminId, this.SysUser.AdminName)
  177. if errMsg != `` {
  178. br.Msg = errMsg
  179. br.ErrMsg = errMsg
  180. if err != nil {
  181. br.ErrMsg = errMsg + ";Err:" + err.Error()
  182. } else {
  183. br.IsSendEmail = false
  184. }
  185. return
  186. }
  187. br.Ret = 200
  188. br.Msg = "保存成功"
  189. br.Success = true
  190. br.IsAddLog = true
  191. }
  192. // Edit
  193. // @Title 修改预测指标分类
  194. // @Description 修改预测指标分类接口
  195. // @Param request body data_manage.EditEdbClassifyReq true "type json string"
  196. // @Success 200 Ret=200 修改成功
  197. // @router /predict_classify/edit [post]
  198. func (this *PredictEdbClassifyController) Edit() {
  199. br := new(models.BaseResponse).Init()
  200. defer func() {
  201. this.Data["json"] = br
  202. this.ServeJSON()
  203. }()
  204. var req data_manage.EditEdbClassifyReq
  205. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  206. if err != nil {
  207. br.Msg = "参数解析异常!"
  208. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  209. return
  210. }
  211. if req.ClassifyName == "" {
  212. br.Msg = "请输入分类名称"
  213. br.IsSendEmail = false
  214. return
  215. }
  216. if req.ClassifyId < 0 {
  217. br.Msg = "参数错误"
  218. br.IsSendEmail = false
  219. return
  220. }
  221. err, errMsg := data.EditEdbClassify(req.ClassifyId, req.ClassifyName, this.SysUser)
  222. if errMsg != `` {
  223. br.Msg = errMsg
  224. br.ErrMsg = errMsg
  225. if err != nil {
  226. br.ErrMsg = errMsg + ";Err:" + err.Error()
  227. } else {
  228. br.IsSendEmail = false
  229. }
  230. return
  231. }
  232. br.Ret = 200
  233. br.Msg = "保存成功"
  234. br.Success = true
  235. }
  236. // DeleteCheck
  237. // @Title 删除检测接口
  238. // @Description 删除检测接口
  239. // @Param request body data_manage.ClassifyDeleteCheckReq true "type json string"
  240. // @Success 200 Ret=200 检测成功
  241. // @router /predict_classify/delete/check [post]
  242. func (this *PredictEdbClassifyController) DeleteCheck() {
  243. br := new(models.BaseResponse).Init()
  244. defer func() {
  245. this.Data["json"] = br
  246. this.ServeJSON()
  247. }()
  248. var req data_manage.ClassifyDeleteCheckReq
  249. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  250. if err != nil {
  251. br.Msg = "参数解析异常!"
  252. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  253. return
  254. }
  255. if req.ClassifyId < 0 && req.EdbInfoId <= 0 {
  256. br.Msg = "参数错误"
  257. br.IsSendEmail = false
  258. return
  259. }
  260. deleteStatus, tipsMsg, err, errMsg := data.DeleteCheck(req.ClassifyId, req.EdbInfoId, this.SysUser)
  261. if errMsg != `` {
  262. br.Msg = errMsg
  263. br.ErrMsg = errMsg
  264. if err != nil {
  265. br.ErrMsg = err.Error()
  266. } else {
  267. br.IsSendEmail = false
  268. }
  269. return
  270. }
  271. resp := new(data_manage.ClassifyDeleteCheckResp)
  272. resp.DeleteStatus = deleteStatus
  273. resp.TipsMsg = tipsMsg
  274. br.Ret = 200
  275. br.Msg = "检测成功"
  276. br.Success = true
  277. br.Data = resp
  278. }
  279. // Delete
  280. // @Title 删除分类/指标
  281. // @Description 删除分类/指标接口
  282. // @Param request body data_manage.DeleteEdbClassifyReq true "type json string"
  283. // @Success 200 Ret=200 新增成功
  284. // @router /predict_classify/delete [post]
  285. func (this *PredictEdbClassifyController) Delete() {
  286. br := new(models.BaseResponse).Init()
  287. defer func() {
  288. this.Data["json"] = br
  289. this.ServeJSON()
  290. }()
  291. sysUser := this.SysUser
  292. if sysUser == nil {
  293. br.Msg = "请登录"
  294. br.ErrMsg = "请登录,SysUser Is Empty"
  295. br.Ret = 408
  296. return
  297. }
  298. var req data_manage.DeleteEdbClassifyReq
  299. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  300. if err != nil {
  301. br.Msg = "参数解析异常!"
  302. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  303. return
  304. }
  305. if req.ClassifyId < 0 && req.EdbInfoId <= 0 {
  306. br.Msg = "参数错误"
  307. br.IsSendEmail = false
  308. return
  309. }
  310. nextItem, err, errMsg := data.Delete(req.ClassifyId, req.EdbInfoId, sysUser, string(this.Ctx.Input.RequestBody), this.Ctx.Input.URI())
  311. if errMsg != `` {
  312. br.Msg = errMsg
  313. br.ErrMsg = errMsg
  314. if err != nil {
  315. br.ErrMsg = err.Error()
  316. } else {
  317. br.IsSendEmail = false
  318. }
  319. return
  320. }
  321. resp := data_manage.AddEdbInfoResp{}
  322. if nextItem != nil {
  323. resp = data_manage.AddEdbInfoResp{
  324. EdbInfoId: nextItem.EdbInfoId,
  325. UniqueCode: nextItem.UniqueCode,
  326. ClassifyId: nextItem.ClassifyId,
  327. }
  328. }
  329. br.Ret = 200
  330. br.Msg = "删除成功"
  331. br.Success = true
  332. br.IsAddLog = true
  333. br.Data = resp
  334. }
  335. // Move
  336. // EdbClassifyMove
  337. // @Title 分类移动接口
  338. // @Description 分类移动接口
  339. // @Success 200 {object} data_manage.MoveEdbClassifyReq
  340. // @router /predict_classify/move [post]
  341. func (this *PredictEdbClassifyController) Move() {
  342. br := new(models.BaseResponse).Init()
  343. defer func() {
  344. this.Data["json"] = br
  345. this.ServeJSON()
  346. }()
  347. sysUser := this.SysUser
  348. if sysUser == nil {
  349. br.Msg = "请登录"
  350. br.ErrMsg = "请登录,SysUser Is Empty"
  351. br.Ret = 408
  352. return
  353. }
  354. var req data_manage.MoveEdbClassifyReq
  355. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  356. if err != nil {
  357. br.Msg = "参数解析异常!"
  358. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  359. return
  360. }
  361. if req.ClassifyId <= 0 {
  362. br.Msg = "参数错误"
  363. br.ErrMsg = "分类id小于等于0"
  364. return
  365. }
  366. err, errMsg := data.MoveEdbClassify(req.ClassifyId, req.ParentClassifyId, req.PrevClassifyId, req.NextClassifyId, sysUser)
  367. if errMsg != `` {
  368. br.Msg = errMsg
  369. br.ErrMsg = errMsg
  370. if err != nil {
  371. br.ErrMsg = err.Error()
  372. } else {
  373. br.IsSendEmail = false
  374. }
  375. return
  376. }
  377. ////判断分类是否存在
  378. //edbClassifyInfo, err := data_manage.GetEdbClassifyById(req.ClassifyId)
  379. //if err != nil {
  380. // br.Msg = "移动失败"
  381. // br.ErrMsg = "获取分类信息失败,Err:" + err.Error()
  382. // return
  383. //}
  384. //updateCol := make([]string, 0)
  385. //
  386. ////判断上级id是否一致,如果不一致的话,那么需要移动该分类层级
  387. //if edbClassifyInfo.ParentId != req.ParentClassifyId && req.ParentClassifyId != 0 {
  388. // parentEdbClassifyInfo, err := data_manage.GetEdbClassifyById(req.ParentClassifyId)
  389. // if err != nil {
  390. // br.Msg = "移动失败"
  391. // br.ErrMsg = "获取上级分类信息失败,Err:" + err.Error()
  392. // return
  393. // }
  394. // edbClassifyInfo.ParentId = parentEdbClassifyInfo.ClassifyId
  395. // edbClassifyInfo.Level = parentEdbClassifyInfo.Level + 1
  396. // edbClassifyInfo.ModifyTime = time.Now()
  397. // updateCol = append(updateCol, "ParentId", "Level", "ModifyTime")
  398. //}
  399. //
  400. ////如果有传入 上一个兄弟节点分类id
  401. //if req.PrevClassifyId > 0 {
  402. // prevClassify, err := data_manage.GetEdbClassifyById(req.PrevClassifyId)
  403. // if err != nil {
  404. // br.Msg = "移动失败"
  405. // br.ErrMsg = "获取上一个兄弟节点分类信息失败,Err:" + err.Error()
  406. // return
  407. // }
  408. //
  409. // //如果是移动在两个兄弟节点之间
  410. // if req.NextClassifyId > 0 {
  411. // //下一个兄弟节点
  412. // nextClassify, err := data_manage.GetEdbClassifyById(req.NextClassifyId)
  413. // if err != nil {
  414. // br.Msg = "移动失败"
  415. // br.ErrMsg = "获取下一个兄弟节点分类信息失败,Err:" + err.Error()
  416. // return
  417. // }
  418. // //如果上一个兄弟与下一个兄弟的排序权重是一致的,那么需要将下一个兄弟(以及下个兄弟的同样排序权重)的排序权重+2,自己变成上一个兄弟的排序权重+1
  419. // if prevClassify.Sort == nextClassify.Sort || prevClassify.Sort == edbClassifyInfo.Sort {
  420. // //变更兄弟节点的排序
  421. // updateSortStr := `sort + 2`
  422. // _ = data_manage.UpdateEdbClassifySortByParentId(prevClassify.ParentId, prevClassify.ClassifyId, prevClassify.Sort, updateSortStr)
  423. // } else {
  424. // //如果下一个兄弟的排序权重正好是上个兄弟节点的下一层,那么需要再加一层了
  425. // if nextClassify.Sort-prevClassify.Sort == 1 {
  426. // //变更兄弟节点的排序
  427. // updateSortStr := `sort + 1`
  428. // _ = data_manage.UpdateEdbClassifySortByParentId(prevClassify.ParentId, 0, prevClassify.Sort, updateSortStr)
  429. // }
  430. // }
  431. // }
  432. //
  433. // edbClassifyInfo.Sort = prevClassify.Sort + 1
  434. // edbClassifyInfo.ModifyTime = time.Now()
  435. // updateCol = append(updateCol, "Sort", "ModifyTime")
  436. //} else {
  437. // firstClassify, err := data_manage.GetFirstEdbClassifyByParentId(edbClassifyInfo.ParentId)
  438. // if err != nil && err.Error() != utils.ErrNoRow() {
  439. // br.Msg = "移动失败"
  440. // br.ErrMsg = "获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + err.Error()
  441. // return
  442. // }
  443. //
  444. // //如果该分类下存在其他分类,且第一个其他分类的排序等于0,那么需要调整排序
  445. // if firstClassify != nil && firstClassify.Sort == 0 {
  446. // updateSortStr := ` sort + 1 `
  447. // _ = data_manage.UpdateEdbClassifySortByParentId(firstClassify.ParentId, firstClassify.ClassifyId-1, 0, updateSortStr)
  448. // }
  449. //
  450. // edbClassifyInfo.Sort = 0 //那就是排在第一位
  451. // edbClassifyInfo.ModifyTime = time.Now()
  452. // updateCol = append(updateCol, "Sort", "ModifyTime")
  453. //}
  454. //
  455. ////更新
  456. //if len(updateCol) > 0 {
  457. // err = edbClassifyInfo.Update(updateCol)
  458. // if err != nil {
  459. // br.Msg = "移动失败"
  460. // br.ErrMsg = "修改失败,Err:" + err.Error()
  461. // return
  462. // }
  463. //}
  464. br.Ret = 200
  465. br.Success = true
  466. br.Msg = "移动成功"
  467. }
  468. // ListV2
  469. // @Title 预测指标分类列表
  470. // @Description 预测指标分类列表接口
  471. // @Param IsOnlyMe query bool false "是否只看我的"
  472. // @Success 200 {object} data_manage.EdbClassifyListResp
  473. // @router /predict_classify/list/v2 [get]
  474. func (this *PredictEdbClassifyController) ListV2() {
  475. br := new(models.BaseResponse).Init()
  476. defer func() {
  477. this.Data["json"] = br
  478. this.ServeJSON()
  479. }()
  480. isOnlyMe, _ := this.GetBool("IsOnlyMe")
  481. rootList, err := data_manage.GetEdbClassifyByParentId(0, 1)
  482. if err != nil && err.Error() != utils.ErrNoRow() {
  483. br.Msg = "获取失败"
  484. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  485. return
  486. }
  487. // 获取当前账号的不可见指标
  488. obj := data_manage.EdbInfoNoPermissionAdmin{}
  489. confList, err := obj.GetAllListByAdminId(this.SysUser.AdminId)
  490. if err != nil && err.Error() != utils.ErrNoRow() {
  491. br.Msg = "获取失败"
  492. br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
  493. return
  494. }
  495. noPermissionEdbInfoIdMap := make(map[int]bool)
  496. for _, v := range confList {
  497. noPermissionEdbInfoIdMap[v.EdbInfoId] = true
  498. }
  499. allEdbInfo, err := data_manage.GetPredictEdbInfoAll(1)
  500. if err != nil && err.Error() != utils.ErrNoRow() {
  501. br.Msg = "获取失败"
  502. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  503. return
  504. }
  505. edbInfoMap := make(map[int][]*data_manage.EdbClassifyItems)
  506. for _, v := range allEdbInfo {
  507. // 如果指标不可见,那么就不返回该指标
  508. if _, ok := noPermissionEdbInfoIdMap[v.EdbInfoId]; ok {
  509. continue
  510. }
  511. button := data.GetPredictEdbOpButton(this.SysUser, v.SysUserId)
  512. button.AddButton = false //不管有没有权限,指标都是没有添加按钮的
  513. button.OpButton = false
  514. button.DeleteButton = false
  515. v.Button = button
  516. if isOnlyMe {
  517. if v.SysUserId == this.SysUser.AdminId {
  518. edbInfoMap[v.ClassifyId] = append(edbInfoMap[v.ClassifyId], v)
  519. }
  520. } else {
  521. edbInfoMap[v.ClassifyId] = append(edbInfoMap[v.ClassifyId], v)
  522. }
  523. }
  524. rootTwoList, err := data_manage.GetEdbClassifyByParentIdTwo(1)
  525. if err != nil && err.Error() != utils.ErrNoRow() {
  526. br.Msg = "获取失败"
  527. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  528. return
  529. }
  530. classifyAll, err := data_manage.GetEdbClassifyAllV2(1)
  531. if err != nil && err.Error() != utils.ErrNoRow() {
  532. br.Msg = "获取失败"
  533. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  534. return
  535. }
  536. rootTwoMap := make(map[int][]*data_manage.EdbClassifyItems)
  537. for _, v := range rootTwoList {
  538. button := data.GetPredictEdbClassifyOpButton(this.SysUser, v.SysUserId)
  539. v.Button = button
  540. rootTwoMap[v.ParentId] = append(rootTwoMap[v.ParentId], v)
  541. }
  542. rootTwoChildMap := make(map[int][]*data_manage.EdbClassifyItems)
  543. for _, v := range classifyAll {
  544. button := data.GetPredictEdbClassifyOpButton(this.SysUser, v.SysUserId)
  545. v.Button = button
  546. if v.Level == 3 {
  547. rootTwoChildMap[v.ParentId] = append(rootTwoChildMap[v.ParentId], v)
  548. }
  549. }
  550. nodeAll := make([]*data_manage.EdbClassifyItems, 0)
  551. for _, v := range rootList {
  552. button := data.GetPredictEdbClassifyOpButton(this.SysUser, v.SysUserId)
  553. v.Button = button
  554. if existItems, ok := rootTwoMap[v.ClassifyId]; ok {
  555. v.Children = existItems
  556. for _, item := range existItems {
  557. item.Button = button
  558. if existItems, ok := rootTwoChildMap[item.ClassifyId]; ok {
  559. item.Children = existItems
  560. for _, existItem := range existItems {
  561. if _, ok := noPermissionEdbInfoIdMap[existItem.EdbInfoId]; ok {
  562. continue
  563. }
  564. button := data.GetPredictEdbClassifyOpButton(this.SysUser, v.SysUserId)
  565. button.AddButton = false //不管有没有权限,指标都是没有添加按钮的
  566. existItem.Button = button
  567. if isOnlyMe {
  568. if existItem.SysUserId == this.SysUser.AdminId {
  569. edbInfoMap[existItem.ClassifyId] = append(edbInfoMap[v.ClassifyId], v)
  570. }
  571. } else {
  572. edbInfoMap[v.ClassifyId] = append(edbInfoMap[v.ClassifyId], v)
  573. }
  574. }
  575. } else {
  576. items := make([]*data_manage.EdbClassifyItems, 0)
  577. item.Children = items
  578. }
  579. }
  580. } else {
  581. items := make([]*data_manage.EdbClassifyItems, 0)
  582. v.Children = items
  583. }
  584. nodeAll = append(nodeAll, v)
  585. }
  586. // 是否允许添加一级分类
  587. canOpClassify := true
  588. button := data.GetPredictEdbClassifyOpButton(this.SysUser, 0)
  589. if !button.AddButton {
  590. canOpClassify = false
  591. }
  592. language := `CN`
  593. // 指标显示的语言
  594. {
  595. configDetail, _ := system.GetConfigDetailByCode(this.SysUser.AdminId, system.PredictEdbLanguageVar)
  596. if configDetail != nil {
  597. language = configDetail.ConfigValue
  598. } else {
  599. configDetail, _ = system.GetDefaultConfigDetailByCode(system.PredictEdbLanguageVar)
  600. if configDetail != nil {
  601. language = configDetail.ConfigValue
  602. }
  603. }
  604. }
  605. resp := data_manage.EdbClassifyListResp{
  606. AllNodes: nodeAll,
  607. CanOpClassify: canOpClassify,
  608. Language: language,
  609. }
  610. br.Ret = 200
  611. br.Success = true
  612. br.Msg = "获取成功"
  613. br.Data = resp
  614. }