edb_classify.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. package data
  2. import (
  3. "errors"
  4. "fmt"
  5. "hongze/hz_crm_api/models"
  6. "hongze/hz_crm_api/models/data_manage"
  7. "hongze/hz_crm_api/models/system"
  8. "hongze/hz_crm_api/utils"
  9. "strconv"
  10. "time"
  11. )
  12. func EdbClassifyListMakeTree(allNode []*data_manage.EdbClassifyItems, node *data_manage.EdbClassifyItems) {
  13. childs, _ := edbClassifyHaveChild(allNode, node) //判断节点是否有子节点并返回
  14. allEdbInfo, _ := GetEdbClassifyEdbInfo()
  15. if len(childs) > 0 {
  16. node.Children = append(node.Children, childs[0:]...) //添加子节点
  17. for _, v := range childs { //查询子节点的子节点,并添加到子节点
  18. _, has := edbClassifyHaveChild(allNode, v)
  19. if has {
  20. EdbClassifyListMakeTree(allNode, v) //递归添加节点
  21. } else {
  22. edbInfoList := allEdbInfo[v.ClassifyId]
  23. v.Children = edbInfoList
  24. if v.Children == nil {
  25. childrenArr := make([]*data_manage.EdbClassifyItems, 0)
  26. v.Children = childrenArr
  27. }
  28. }
  29. }
  30. } else {
  31. childrenArr := make([]*data_manage.EdbClassifyItems, 0)
  32. node.Children = childrenArr
  33. }
  34. }
  35. func edbClassifyHaveChild(allNode []*data_manage.EdbClassifyItems, node *data_manage.EdbClassifyItems) (childs []*data_manage.EdbClassifyItems, yes bool) {
  36. for _, v := range allNode {
  37. if v.ParentId == node.ClassifyId {
  38. childs = append(childs, v)
  39. }
  40. }
  41. if len(childs) > 0 {
  42. yes = true
  43. }
  44. return
  45. }
  46. func GetEdbClassifyEdbInfo() (result map[int][]*data_manage.EdbClassifyItems, err error) {
  47. cMap := make(map[int][]*data_manage.EdbClassifyItems)
  48. items, err := data_manage.GetEdbInfoAll(0)
  49. if err != nil {
  50. return
  51. }
  52. for _, v := range items {
  53. childrenArr := make([]*data_manage.EdbClassifyItems, 0)
  54. v.Children = childrenArr
  55. if items, ok := cMap[v.ClassifyId]; ok {
  56. items = append(items, v)
  57. cMap[v.ClassifyId] = items
  58. } else {
  59. infoList := make([]*data_manage.EdbClassifyItems, 0)
  60. infoList = append(infoList, v)
  61. cMap[v.ClassifyId] = infoList
  62. }
  63. }
  64. result = cMap
  65. return
  66. }
  67. func EdbClassifyItemsMakeTree(allNode []*data_manage.EdbClassifyItems, node *data_manage.EdbClassifyItems) {
  68. childs, _ := edbClassifyHaveChild(allNode, node) //判断节点是否有子节点并返回
  69. if len(childs) > 0 {
  70. node.Children = append(node.Children, childs[0:]...) //添加子节点
  71. for _, v := range childs { //查询子节点的子节点,并添加到子节点
  72. _, has := edbClassifyHaveChild(allNode, v)
  73. if has {
  74. EdbClassifyItemsMakeTree(allNode, v) //递归添加节点
  75. } else {
  76. childrenArr := make([]*data_manage.EdbClassifyItems, 0)
  77. v.Children = childrenArr
  78. }
  79. }
  80. } else {
  81. childrenArr := make([]*data_manage.EdbClassifyItems, 0)
  82. node.Children = childrenArr
  83. }
  84. }
  85. // GetEdbClassifyListByAdminId 根据账户类型获取分类id集合
  86. func GetEdbClassifyListByAdminId(adminId int64) (classifyIdList []string, err error) {
  87. list, err := models.GetEdbdataClassify(adminId)
  88. if err != nil {
  89. return
  90. }
  91. for _, parent := range list {
  92. if parent.Child != nil {
  93. for _, classify := range parent.Child {
  94. classifyIdList = append(classifyIdList, fmt.Sprint(classify.ClassifyId))
  95. }
  96. }
  97. }
  98. return
  99. }
  100. // GetEdbClassifyNameListByAdminId 根据账户类型获取分类名称集合
  101. func GetEdbClassifyNameListByAdminId(adminId int64) (classifyNameList []string, edbDataClassifyMap map[string]*models.EdbdataClassify, err error) {
  102. list, err := models.GetEdbdataClassify(adminId)
  103. edbDataClassifyMap = make(map[string]*models.EdbdataClassify)
  104. if err != nil {
  105. return
  106. }
  107. for _, parent := range list {
  108. if parent.Child != nil {
  109. for _, classify := range parent.Child {
  110. classifyNameList = append(classifyNameList, classify.ClassifyName)
  111. edbDataClassifyMap[classify.ClassifyName] = classify
  112. }
  113. }
  114. }
  115. return
  116. }
  117. // AddEdbClassify 添加指标分类
  118. func AddEdbClassify(classifyName string, parentId, level int, classifyType uint8, sysUserId int, sysUserName string) (classifyInfo *data_manage.EdbClassify, err error, errMsg string) {
  119. count, err := data_manage.GetEdbClassifyCount(classifyName, parentId, classifyType)
  120. if err != nil {
  121. errMsg = `判断名称是否已存在失败`
  122. return
  123. }
  124. if count > 0 {
  125. errMsg = `分类名称已存在,请重新输入`
  126. return
  127. }
  128. //获取该层级下最大的排序数
  129. maxSort, err := data_manage.GetEdbClassifyMaxSort(parentId, classifyType)
  130. timestamp := strconv.FormatInt(time.Now().UnixNano(), 10)
  131. classifyInfo = &data_manage.EdbClassify{
  132. //ClassifyId: 0,
  133. ClassifyType: classifyType,
  134. ClassifyName: classifyName,
  135. ParentId: parentId,
  136. HasData: 0,
  137. CreateTime: time.Now(),
  138. ModifyTime: time.Now(),
  139. SysUserId: sysUserId,
  140. SysUserRealName: sysUserName,
  141. Level: level + 1,
  142. UniqueCode: utils.MD5(utils.DATA_PREFIX + "_" + timestamp),
  143. Sort: maxSort,
  144. }
  145. _, err = data_manage.AddEdbClassify(classifyInfo)
  146. if err != nil {
  147. errMsg = "保存分类失败"
  148. }
  149. return
  150. }
  151. // EditEdbClassify 编辑指标分类
  152. func EditEdbClassify(classifyId int, classifyName string) (err error, errMsg string) {
  153. item, err := data_manage.GetEdbClassifyById(classifyId)
  154. if err != nil {
  155. errMsg = `保存失败`
  156. return
  157. }
  158. // 名字相同,那么就直接返回
  159. if item.ClassifyName == classifyName {
  160. return
  161. }
  162. // 判断名称是否已存在
  163. count, err := data_manage.GetEdbClassifyCount(classifyName, item.ParentId, item.ClassifyType)
  164. if err != nil {
  165. errMsg = "判断名称是否已存在失败"
  166. return
  167. }
  168. if count > 0 {
  169. errMsg = "分类名称已存在,请重新输入"
  170. return
  171. }
  172. // 修改数据
  173. err = data_manage.EditEdbClassify(classifyId, classifyName)
  174. if err != nil {
  175. errMsg = "保存失败"
  176. }
  177. return
  178. }
  179. // DeleteCheck 删除检测
  180. func DeleteCheck(classifyId, edbInfoId int) (deleteStatus int, tipsMsg string, err error, errMsg string) {
  181. //删除分类
  182. if classifyId > 0 && edbInfoId == 0 {
  183. //判断分类下,是否含有指标
  184. count, tmpErr := data_manage.GetEdbInfoCountByClassifyId(classifyId)
  185. if tmpErr != nil {
  186. errMsg = "删除失败"
  187. err = errors.New("分类下是否含有指标失败,Err:" + tmpErr.Error())
  188. return
  189. }
  190. if count > 0 {
  191. deleteStatus = 1
  192. tipsMsg = "若目录关联指标不可删除"
  193. }
  194. }
  195. if deleteStatus != 1 && edbInfoId == 0 {
  196. classifyCount, tmpErr := data_manage.GetClassifyCountByClassifyId(classifyId)
  197. if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
  198. errMsg = "删除失败"
  199. err = errors.New("分类下是否含有指标失败,Err:" + tmpErr.Error())
  200. return
  201. }
  202. if classifyCount > 0 {
  203. deleteStatus = 2
  204. tipsMsg = "确认删除当前目录及包含的子目录吗"
  205. }
  206. }
  207. //删除指标
  208. if edbInfoId > 0 {
  209. //判断指标是否用于作图,如果用于作图,则不可删除
  210. chartCount, tmpErr := data_manage.GetChartEdbMappingCount(edbInfoId)
  211. if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
  212. errMsg = "删除失败"
  213. err = errors.New("判断指标是否被用于作图失败,Err:" + tmpErr.Error())
  214. return
  215. }
  216. if chartCount > 0 {
  217. deleteStatus = 3
  218. tipsMsg = "当前指标已用作画图,不可删除"
  219. }
  220. //判断指标是否用于计算
  221. {
  222. calculateCount, tmpErr := data_manage.GetEdbInfoCalculateMappingCount(edbInfoId)
  223. if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
  224. errMsg = "删除失败"
  225. err = errors.New("判断指标是否被用于计算失败,GetEdbInfoCalculateCount Err:" + tmpErr.Error())
  226. return
  227. }
  228. if calculateCount > 0 {
  229. deleteStatus = 4
  230. tipsMsg = "当前指标已用作,指标运算,不可删除"
  231. }
  232. }
  233. }
  234. return
  235. }
  236. // Delete 删除分类/指标
  237. func Delete(classifyId, edbInfoId, sysUserId int, sysUserName string, requestBody, requestUrl string) (nextItem *data_manage.EdbInfo, err error, errMsg string) {
  238. //删除分类
  239. if classifyId > 0 && edbInfoId == 0 {
  240. //判断是否含有指标
  241. count, tmpErr := data_manage.GetEdbInfoCountByClassifyId(classifyId)
  242. if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
  243. errMsg = "删除失败"
  244. err = errors.New("分类下是否含有指标失败,Err:" + tmpErr.Error())
  245. return
  246. }
  247. if count > 0 {
  248. errMsg = "该目录下存在关联指标,不可删除"
  249. return
  250. }
  251. tmpErr = data_manage.DeleteEdbClassify(classifyId)
  252. if tmpErr != nil {
  253. errMsg = "删除失败"
  254. err = errors.New("删除失败,Err:" + tmpErr.Error())
  255. return
  256. }
  257. }
  258. //删除指标
  259. if edbInfoId > 0 {
  260. edbInfo, tmpErr := data_manage.GetEdbInfoById(edbInfoId)
  261. if tmpErr != nil {
  262. if tmpErr.Error() == utils.ErrNoRow() {
  263. errMsg = "指标已删除,请刷新页面"
  264. err = errors.New("指标不存在,Err:" + tmpErr.Error())
  265. return
  266. } else {
  267. errMsg = "删除失败"
  268. err = errors.New("删除失败,获取指标信息失败,Err:" + tmpErr.Error())
  269. return
  270. }
  271. }
  272. if edbInfo == nil {
  273. errMsg = "指标已删除,请刷新页面"
  274. return
  275. }
  276. //判断指标是否用于作图,如果用于作图,则不可删除
  277. chartCount, tmpErr := data_manage.GetChartEdbMappingCount(edbInfoId)
  278. if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
  279. errMsg = "删除失败"
  280. err = errors.New("判断指标是否被用于作图失败,Err:" + tmpErr.Error())
  281. return
  282. }
  283. if chartCount > 0 {
  284. errMsg = "当前指标已用作画图,不可删除"
  285. return
  286. }
  287. //如果是普通指标,那么还需要判断是否被预测指标作为源指标
  288. if edbInfo.EdbInfoType == 0 {
  289. predictEdbInfoCount, tmpErr := data_manage.GetPredictEdbConfCount(edbInfoId)
  290. if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
  291. errMsg = "删除失败"
  292. err = errors.New("判断指标是否被用于预测指标失败,Err:" + tmpErr.Error())
  293. return
  294. }
  295. if predictEdbInfoCount > 0 {
  296. errMsg = "当前指标已用作预测指标,不可删除"
  297. return
  298. }
  299. }
  300. //判断指标是否用作其他指标的计算
  301. {
  302. calculateCount, tmpErr := data_manage.GetEdbInfoCalculateMappingCount(edbInfoId)
  303. if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
  304. errMsg = "删除失败"
  305. err = errors.New("判断指标是否被用于计算失败,GetEdbInfoCalculateCount Err:" + tmpErr.Error())
  306. return
  307. }
  308. if calculateCount > 0 {
  309. errMsg = "当前指标已用作,指标运算,不可删除"
  310. return
  311. }
  312. }
  313. //真实删除
  314. tmpErr = data_manage.DeleteEdbInfoAndData(edbInfo.EdbInfoId, edbInfo.Source)
  315. if tmpErr != nil {
  316. errMsg = "删除失败"
  317. err = errors.New("删除失败,Err:" + tmpErr.Error())
  318. return
  319. }
  320. // 返回下一个表格的信息
  321. {
  322. var condition string
  323. var pars []interface{}
  324. condition += " AND edb_info_type=? AND classify_id=? "
  325. pars = append(pars, edbInfo.EdbInfoType, edbInfo.ClassifyId)
  326. condition += " AND (sort>? OR (sort=? AND edb_info_id<?) ) "
  327. pars = append(pars, edbInfo.Sort, edbInfo.Sort, edbInfo.EdbInfoId)
  328. nextItem, tmpErr = data_manage.GetNextEdbInfoByCondition(condition, pars)
  329. if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
  330. errMsg = "删除失败"
  331. err = errors.New("获取下一级预测指标信息失败,Err:" + tmpErr.Error())
  332. return
  333. }
  334. // 如果没找到,那么查找下一个分类的第一个表格
  335. if nextItem == nil {
  336. currClassifyInfo, tmpErr := data_manage.GetEdbClassifyById(edbInfo.ClassifyId)
  337. if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
  338. errMsg = "删除失败"
  339. err = errors.New("获取当前预测指标分类信息失败,Err:" + tmpErr.Error())
  340. return
  341. }
  342. nextItem, err = data_manage.GetNextEdbInfo(edbInfo.ClassifyId, currClassifyInfo.Sort, int(currClassifyInfo.ClassifyType), edbInfo.EdbInfoType)
  343. if err != nil && err.Error() != utils.ErrNoRow() {
  344. errMsg = "删除失败"
  345. err = errors.New("获取下一级预测指标信息失败,Err:" + tmpErr.Error())
  346. return
  347. }
  348. }
  349. }
  350. //新增操作日志
  351. {
  352. edbLog := new(data_manage.EdbInfoLog)
  353. edbLog.EdbInfoId = edbInfo.EdbInfoId
  354. edbLog.SourceName = edbInfo.SourceName
  355. edbLog.Source = edbInfo.Source
  356. edbLog.EdbCode = edbInfo.EdbCode
  357. edbLog.EdbName = edbInfo.EdbName
  358. edbLog.ClassifyId = edbInfo.ClassifyId
  359. edbLog.SysUserId = sysUserId
  360. edbLog.SysUserRealName = sysUserName
  361. edbLog.CreateTime = time.Now()
  362. edbLog.Content = requestBody
  363. edbLog.Status = "删除指标"
  364. edbLog.Method = requestUrl
  365. go data_manage.AddEdbInfoLog(edbLog)
  366. }
  367. // 删除es中的数据
  368. DeleteEdbInfoToEs(edbInfoId)
  369. }
  370. return
  371. }
  372. // MoveEdbClassify 移动指标分类
  373. func MoveEdbClassify(classifyId, parentClassifyId, prevClassifyId, nextClassifyId int) (err error, errMsg string) {
  374. //判断分类是否存在
  375. edbClassifyInfo, err := data_manage.GetEdbClassifyById(classifyId)
  376. if err != nil {
  377. errMsg = "移动失败"
  378. err = errors.New("获取分类信息失败,Err:" + err.Error())
  379. return
  380. }
  381. updateCol := make([]string, 0)
  382. //判断上级id是否一致,如果不一致的话,那么需要移动该分类层级
  383. if edbClassifyInfo.ParentId != parentClassifyId && parentClassifyId != 0 {
  384. parentEdbClassifyInfo, tmpErr := data_manage.GetEdbClassifyById(parentClassifyId)
  385. if tmpErr != nil {
  386. errMsg = "移动失败"
  387. err = errors.New("获取上级分类信息失败,Err:" + tmpErr.Error())
  388. return
  389. }
  390. edbClassifyInfo.ParentId = parentEdbClassifyInfo.ClassifyId
  391. edbClassifyInfo.Level = parentEdbClassifyInfo.Level + 1
  392. edbClassifyInfo.ModifyTime = time.Now()
  393. updateCol = append(updateCol, "ParentId", "Level", "ModifyTime")
  394. }
  395. //如果有传入 上一个兄弟节点分类id
  396. if prevClassifyId > 0 {
  397. prevClassify, tmpErr := data_manage.GetEdbClassifyById(prevClassifyId)
  398. if tmpErr != nil {
  399. errMsg = "移动失败"
  400. err = errors.New("获取上一个兄弟节点分类信息失败,Err:" + tmpErr.Error())
  401. return
  402. }
  403. //如果是移动在两个兄弟节点之间
  404. if nextClassifyId > 0 {
  405. //下一个兄弟节点
  406. nextClassify, tmpErr := data_manage.GetEdbClassifyById(nextClassifyId)
  407. if tmpErr != nil {
  408. errMsg = "移动失败"
  409. err = errors.New("获取下一个兄弟节点分类信息失败,Err:" + tmpErr.Error())
  410. return
  411. }
  412. //如果上一个兄弟与下一个兄弟的排序权重是一致的,那么需要将下一个兄弟(以及下个兄弟的同样排序权重)的排序权重+2,自己变成上一个兄弟的排序权重+1
  413. if prevClassify.Sort == nextClassify.Sort || prevClassify.Sort == edbClassifyInfo.Sort {
  414. //变更兄弟节点的排序
  415. updateSortStr := `sort + 2`
  416. _ = data_manage.UpdateEdbClassifySortByParentId(prevClassify.ParentId, prevClassify.ClassifyId, prevClassify.Sort, updateSortStr, edbClassifyInfo.ClassifyType)
  417. } else {
  418. //如果下一个兄弟的排序权重正好是上个兄弟节点的下一层,那么需要再加一层了
  419. if nextClassify.Sort-prevClassify.Sort == 1 {
  420. //变更兄弟节点的排序
  421. updateSortStr := `sort + 1`
  422. _ = data_manage.UpdateEdbClassifySortByParentId(prevClassify.ParentId, 0, prevClassify.Sort, updateSortStr, edbClassifyInfo.ClassifyType)
  423. }
  424. }
  425. }
  426. edbClassifyInfo.Sort = prevClassify.Sort + 1
  427. edbClassifyInfo.ModifyTime = time.Now()
  428. updateCol = append(updateCol, "Sort", "ModifyTime")
  429. } else {
  430. firstClassify, tmpErr := data_manage.GetFirstEdbClassifyByParentId(edbClassifyInfo.ParentId)
  431. if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
  432. errMsg = "移动失败"
  433. err = errors.New("获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + tmpErr.Error())
  434. return
  435. }
  436. //如果该分类下存在其他分类,且第一个其他分类的排序等于0,那么需要调整排序
  437. if firstClassify != nil && firstClassify.Sort == 0 {
  438. updateSortStr := ` sort + 1 `
  439. _ = data_manage.UpdateEdbClassifySortByParentId(firstClassify.ParentId, firstClassify.ClassifyId-1, 0, updateSortStr, edbClassifyInfo.ClassifyType)
  440. }
  441. edbClassifyInfo.Sort = 0 //那就是排在第一位
  442. edbClassifyInfo.ModifyTime = time.Now()
  443. updateCol = append(updateCol, "Sort", "ModifyTime")
  444. }
  445. //更新
  446. if len(updateCol) > 0 {
  447. err = edbClassifyInfo.Update(updateCol)
  448. if err != nil {
  449. errMsg = "移动失败"
  450. err = errors.New("修改失败,Err:" + err.Error())
  451. return
  452. }
  453. }
  454. return
  455. }
  456. // GetEdbOpButton 获取ETA指标的操作权限
  457. func GetEdbOpButton(sysUser *system.Admin, belongUserId, edbType, edbInfoType int) (button data_manage.EdbClassifyItemsButton) {
  458. //2、用户对于自己添加的分类,有权限编辑、移动和删除该分类;
  459. //3、ficc管理员和超管对所有分类有编辑、移动和删除权限;
  460. if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_ADMIN || sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN || sysUser.AdminId == belongUserId || sysUser.EdbPermission == 1 {
  461. button.AddButton = true
  462. button.OpButton = true
  463. button.DeleteButton = true
  464. button.MoveButton = true
  465. // ETA指标的基础指标才允许插入值
  466. if edbInfoType == 0 && edbType == 1 {
  467. button.InsertNewDataButton = true
  468. }
  469. }
  470. button.ShowEdbRelation = true
  471. button.ShowChartRelation = true
  472. return
  473. }
  474. // GetEdbClassifyOpButton 获取ETA指标分类的操作权限
  475. func GetEdbClassifyOpButton(sysUser *system.Admin, belongUserId int) (button data_manage.EdbClassifyItemsButton) {
  476. //2、用户对于自己添加的分类,有权限编辑、移动和删除该分类;
  477. //3、ficc管理员和超管对所有分类有编辑、移动和删除权限;
  478. if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_ADMIN || sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN {
  479. button.AddButton = true
  480. button.OpButton = true
  481. button.DeleteButton = true
  482. button.MoveButton = true
  483. }
  484. return
  485. }
  486. // GetPredictEdbOpButton 获取ETA预测指标的操作权限
  487. func GetPredictEdbOpButton(sysUser *system.Admin, belongUserId int) (button data_manage.EdbClassifyItemsButton) {
  488. //预测指标的添加人对该预测指标有全部操作权限,ficc管理员、超管对所有预测指标有全部操作权限;
  489. if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_ADMIN || sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN || sysUser.AdminId == belongUserId || sysUser.PredictEdbPermission == 1 {
  490. button.AddButton = true
  491. button.OpButton = true
  492. button.DeleteButton = true
  493. button.MoveButton = true
  494. }
  495. button.ShowEdbRelation = true
  496. button.ShowChartRelation = true
  497. return
  498. }
  499. // GetPredictEdbClassifyOpButton 获取ETA预测指标分类的操作权限
  500. func GetPredictEdbClassifyOpButton(sysUser *system.Admin, belongUserId int) (button data_manage.EdbClassifyItemsButton) {
  501. //ficc管理员和超管有权限创建和管理分类,可以编辑分类名称(分类名称不允许重复),可以拖动分类,改变分类顺序,可以拖动分类下模型,改变顺序,可以删除分类,若分类下有预测指标,则不允许删除;
  502. if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_ADMIN || sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN {
  503. button.AddButton = true
  504. button.OpButton = true
  505. button.DeleteButton = true
  506. button.MoveButton = true
  507. }
  508. return
  509. }