base_from_clarksons.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. package data
  2. import (
  3. "errors"
  4. "eta/eta_api/models/data_manage"
  5. "eta/eta_api/utils"
  6. "fmt"
  7. "github.com/rdlucklib/rdluck_tools/paging"
  8. "time"
  9. )
  10. func AddClarksonsClassify(classifyName string, parentId int) (ok bool, msg string, err error) {
  11. var count int
  12. count, err = data_manage.GetBaseFromClarksonsClassifyCount(classifyName, parentId)
  13. if err != nil {
  14. return
  15. }
  16. if count > 0 {
  17. return false, "分类已存在", nil
  18. }
  19. sort, err := data_manage.GetChildClarksonsClassifyMaxSortById(parentId)
  20. if err != nil {
  21. return false, "", err
  22. }
  23. if parentId > 0 {
  24. count, err = data_manage.GetClarksonsClassifyCountById(parentId)
  25. if err != nil {
  26. return false, "", err
  27. }
  28. if count == 0 {
  29. return false, "", errors.New("父分类不存在")
  30. }
  31. clarksonsClassify := &data_manage.BaseFromClarksonsClassify{
  32. ClassifyName: classifyName,
  33. ParentId: parentId,
  34. Level: 2,
  35. Sort: sort + 1,
  36. ModifyTime: time.Now(),
  37. CreateTime: time.Now(),
  38. }
  39. _, err = clarksonsClassify.Add()
  40. if err != nil {
  41. return
  42. }
  43. } else {
  44. clarksonsClassify := &data_manage.BaseFromClarksonsClassify{
  45. ClassifyName: classifyName,
  46. ParentId: 0,
  47. Level: 1,
  48. Sort: sort + 1,
  49. ModifyTime: time.Now(),
  50. CreateTime: time.Now(),
  51. }
  52. _, er := clarksonsClassify.Add()
  53. if er != nil {
  54. return false, "", er
  55. }
  56. }
  57. return true, "", nil
  58. }
  59. func DelClarksonsClassify(classifyId int) (err error) {
  60. classify, err := data_manage.GetClarksonsClassifyById(classifyId)
  61. if err != nil {
  62. return
  63. }
  64. var classifyIds []int
  65. classifyIds = append(classifyIds, classify.BaseFromClassifyId)
  66. if classify.ParentId == 0 {
  67. tmpClassifyIds, er := data_manage.GetChildClarksonsClassifyIdsById(classify.BaseFromClassifyId)
  68. if er != nil {
  69. err = er
  70. return
  71. }
  72. classifyIds = append(classifyIds, tmpClassifyIds...)
  73. }
  74. // 获取分类下的所有指标
  75. count, err := data_manage.GetClarksonsIndexCountByClassifyIds(classifyIds)
  76. if err != nil {
  77. err = errors.New("获取分类下的指标信息失败,Err:" + err.Error())
  78. return
  79. }
  80. if count > 0 {
  81. err = errors.New("该分类下有指标,不可删除")
  82. return
  83. }
  84. // 删除对应的分类
  85. err = data_manage.DeleteClarksonsClassifyByClassifyId(classifyIds)
  86. if err != nil {
  87. return
  88. }
  89. return
  90. }
  91. // ResetClarksonsIndex 指标数据清除分类接口
  92. func ResetClarksonsIndex(indexId int) (err error) {
  93. clarksonsIndex, err := data_manage.GetClarksonsIndexByIndexId(indexId)
  94. if err != nil {
  95. return
  96. }
  97. // 更新指标在未分类下的排序,永远排在未分类的最后一个
  98. //移动排序
  99. classifyId := 0
  100. updateCol := make([]string, 0)
  101. var currentSort, prevSort int
  102. currentSort = clarksonsIndex.Sort
  103. //未分类的最大的sort值
  104. prevSort, err = data_manage.GetClarksonsIndexMaxSortByClassifyId(classifyId)
  105. if err != nil {
  106. err = errors.New("获取上一个兄弟节点指标信息失败,Err:" + err.Error())
  107. return
  108. }
  109. //如果前面一个节点的sort值比当前大,则当前节点往下移动
  110. if prevSort >= currentSort {
  111. //往下移动
  112. err = data_manage.MoveDownSciIndexBySort(classifyId, prevSort, currentSort)
  113. if err != nil {
  114. err = errors.New("向下移动出错:" + err.Error())
  115. return
  116. }
  117. clarksonsIndex.Sort = prevSort
  118. }
  119. //更新
  120. clarksonsIndex.ModifyTime = time.Now()
  121. clarksonsIndex.ClassifyId = classifyId
  122. updateCol = append(updateCol, "Sort", "ModifyTime", "BaseFromClassifyId")
  123. err = clarksonsIndex.Update(updateCol)
  124. if err != nil {
  125. err = errors.New("移动失败,Err:" + err.Error())
  126. return
  127. }
  128. return
  129. }
  130. // 批量删除卓创红期指标
  131. func BatchDelClarksonsData(indexIds []int) (existIndex []*data_manage.BaseFromClarksonsIndex, err error) {
  132. clarksonsIndexList, err := data_manage.GetClarksonsIndexListByIndexIds(indexIds)
  133. if err != nil {
  134. return
  135. }
  136. indexCodes := make([]string, 0)
  137. codeToIndex := make(map[string]*data_manage.BaseFromClarksonsIndex)
  138. for _, v := range clarksonsIndexList {
  139. indexCodes = append(indexCodes, v.IndexCode)
  140. codeToIndex[v.IndexCode] = v
  141. }
  142. edbInfoList, err := data_manage.GetEdbInfoListByEdbCodes(utils.DATA_SOURCE_CLARKSONS, indexCodes)
  143. if err != nil {
  144. return
  145. }
  146. deleteIndexIds := make([]int, 0)
  147. for _, v := range edbInfoList {
  148. if index, ok := codeToIndex[v.EdbCode]; ok {
  149. existIndex = append(existIndex, index)
  150. delete(codeToIndex, v.EdbCode)
  151. }
  152. }
  153. for _, v := range codeToIndex {
  154. deleteIndexIds = append(deleteIndexIds, v.BaseFromClarksonsIndexId)
  155. }
  156. // 删除对应的指标
  157. err = data_manage.DeleteClarksonsIndexByIds(deleteIndexIds)
  158. if err != nil {
  159. return
  160. }
  161. return
  162. }
  163. // DelClarksonsData 删除卓创红期指标
  164. func DelClarksonsData(indexId int) (err error, errMsg string) {
  165. baseFromClarksonsIndex, err := data_manage.GetClarksonsIndexByIndexId(indexId)
  166. if err != nil {
  167. errMsg = `获取数据失败`
  168. if err.Error() == utils.ErrNoRow() {
  169. errMsg = `该指标未入库`
  170. err = nil
  171. }
  172. return
  173. }
  174. // 获取已经加入到EDB指标库的clarksons指标
  175. edbInfo, err := data_manage.GetEdbInfoByEdbCode(utils.DATA_SOURCE_CLARKSONS, baseFromClarksonsIndex.IndexCode)
  176. if err != nil && err.Error() != utils.ErrNoRow() {
  177. errMsg = "删除失败"
  178. err = errors.New("获取分类下的指标信息失败,Err:" + err.Error())
  179. return
  180. }
  181. if edbInfo != nil {
  182. errMsg = "当前指标已被引用,不可删除"
  183. err = nil
  184. return
  185. }
  186. // 删除对应的指标
  187. err = data_manage.DeleteClarksonsIndexById(indexId)
  188. if err != nil {
  189. return
  190. }
  191. return
  192. }
  193. // EditClarksonsIndex 编辑卓创红期指标
  194. func EditClarksonsIndex(indexId, classifyId int) (baseFromClarksonsIndex *data_manage.BaseFromClarksonsIndex, errMsg string, err error) {
  195. baseFromClarksonsIndex, err = data_manage.GetClarksonsIndexByIndexId(indexId)
  196. if err != nil {
  197. if err.Error() == utils.ErrNoRow() {
  198. errMsg = `该指标未入库`
  199. err = nil
  200. }
  201. return
  202. }
  203. classify, err := data_manage.GetClarksonsClassifyById(classifyId)
  204. if err != nil {
  205. if err.Error() == utils.ErrNoRow() {
  206. errMsg = `该分类不存在或已删除`
  207. err = nil
  208. }
  209. return
  210. }
  211. if classify.Level == 1 { // 顶级分类
  212. errMsg = `不合法的编辑`
  213. err = nil
  214. return
  215. }
  216. maxSort, err := data_manage.GetChildClarksonsClassifyMaxSortById(classifyId)
  217. if err != nil {
  218. return
  219. }
  220. baseFromClarksonsIndex.ClassifyId = classifyId
  221. baseFromClarksonsIndex.Sort = maxSort + 1
  222. baseFromClarksonsIndex.ModifyTime = time.Now()
  223. err = baseFromClarksonsIndex.Update([]string{"classify_id", "sort", "modify_time"})
  224. return
  225. }
  226. type ClarksonsIndexSource2EdbReq struct {
  227. EdbCode string
  228. EdbName string
  229. Frequency string
  230. Unit string
  231. ClassifyId int
  232. AdminId int
  233. AdminRealName string
  234. }
  235. // ClarksonsIndexSource2Edb 新增卓创红期数据从数据源到指标库
  236. func ClarksonsIndexSource2Edb(req ClarksonsIndexSource2EdbReq, lang string) (edb *data_manage.EdbInfo, errMsg string, skip bool, err error) {
  237. if req.EdbCode == "" {
  238. err = fmt.Errorf("指标ID为空")
  239. return
  240. }
  241. defer func() {
  242. if err != nil {
  243. tips := fmt.Sprintf("ClarksonsIndexSource2Edb新增失败, Err: %s", err.Error())
  244. fmt.Println(tips)
  245. utils.FileLog.Info(tips)
  246. }
  247. }()
  248. source := utils.DATA_SOURCE_CLARKSONS
  249. // 是否新增过指标
  250. exist, e := data_manage.GetEdbInfoByEdbCode(source, req.EdbCode)
  251. if e != nil && e.Error() != utils.ErrNoRow() {
  252. err = fmt.Errorf("获取指标是否存在失败, err: %s", e.Error())
  253. return
  254. }
  255. if exist != nil {
  256. skip = true
  257. return
  258. }
  259. // 开始结束时间
  260. var startDate, endDate string
  261. // 新增指标库
  262. edbInfo, e, msg, _ := EdbInfoAdd(source, utils.DATA_SUB_SOURCE_EDB, req.ClassifyId, req.EdbCode, req.EdbName, req.Frequency, req.Unit, startDate, endDate, req.AdminId, req.AdminRealName, lang)
  263. if e != nil {
  264. errMsg = msg
  265. err = fmt.Errorf("EdbInfo: 新增指标失败, err: %s", e.Error())
  266. return
  267. }
  268. edb = edbInfo
  269. return
  270. }
  271. // MoveClarksonsClassify 移动卓创红期分类
  272. func MoveClarksonsClassify(classifyId, parentClassifyId, prevClassifyId, nextClassifyId int) (err error, errMsg string) {
  273. //判断分类是否存在
  274. classifyInfo, err := data_manage.GetClarksonsClassifyById(classifyId)
  275. if err != nil {
  276. errMsg = "移动失败"
  277. err = errors.New("获取分类信息失败,Err:" + err.Error())
  278. return
  279. }
  280. updateCol := make([]string, 0)
  281. //判断上级id是否一致,如果不一致的话,那么需要移动该分类层级
  282. if classifyInfo.ParentId != parentClassifyId && parentClassifyId != 0 {
  283. parentClassifyInfo, tmpErr := data_manage.GetClarksonsClassifyById(parentClassifyId)
  284. if tmpErr != nil {
  285. errMsg = "移动失败"
  286. err = errors.New("获取上级分类信息失败,Err:" + tmpErr.Error())
  287. return
  288. }
  289. classifyInfo.ParentId = parentClassifyInfo.BaseFromClassifyId
  290. classifyInfo.Level = parentClassifyInfo.Level + 1
  291. updateCol = append(updateCol, "ParentId", "Level")
  292. }
  293. var currentSort, prevSort, nextSort int
  294. currentSort = classifyInfo.Sort
  295. var prevClassify *data_manage.BaseFromClarksonsClassify
  296. var nextClassify *data_manage.BaseFromClarksonsClassify
  297. //如果有传入 上一个兄弟节点分类id
  298. if prevClassifyId > 0 {
  299. prevClassify, err = data_manage.GetClarksonsClassifyById(prevClassifyId)
  300. if err != nil {
  301. if err.Error() == utils.ErrNoRow() {
  302. errMsg = "移动失败"
  303. err = errors.New("上一个兄弟节点分类信息不存在" + err.Error())
  304. return
  305. }
  306. errMsg = "移动失败"
  307. err = errors.New("获取上一个兄弟节点分类信息失败,Err:" + err.Error())
  308. return
  309. }
  310. prevSort = prevClassify.Sort
  311. }
  312. if nextClassifyId > 0 {
  313. //下一个兄弟节点
  314. nextClassify, err = data_manage.GetClarksonsClassifyById(nextClassifyId)
  315. if err != nil {
  316. if err.Error() == utils.ErrNoRow() {
  317. errMsg = "移动失败"
  318. err = errors.New("下一个兄弟节点分类信息不存在" + err.Error())
  319. return
  320. }
  321. errMsg = "移动失败"
  322. err = errors.New("获取下一个兄弟节点分类信息失败,Err:" + err.Error())
  323. return
  324. }
  325. nextSort = nextClassify.Sort
  326. }
  327. // 修改历史数据中的排序为0的情况
  328. if prevSort == 0 && nextSort == 0 { //目标是让当前分类处于目录的最顶部
  329. //更新为0排序的数据为当前最小排序
  330. if nextClassify != nil {
  331. minSort, e := data_manage.GetClarksonsIndexClassifyMinSort(parentClassifyId)
  332. if e != nil {
  333. errMsg = "移动失败"
  334. err = errors.New("获取下一个兄弟节点分类信息失败,Err:" + e.Error())
  335. return
  336. }
  337. if minSort > 1 {
  338. minSort -= 1
  339. }
  340. nextClassify.Sort = minSort
  341. err = nextClassify.Update([]string{"sort"})
  342. if err != nil {
  343. errMsg = "移动失败"
  344. err = errors.New("更新下一个兄弟节点分类信息失败,Err:" + err.Error())
  345. return
  346. }
  347. nextSort = minSort
  348. }
  349. }
  350. //移到两个排序值中间操作
  351. if prevSort >= currentSort {
  352. //往下移动
  353. err = data_manage.MoveDownClarksonsIndexClassifyBySort(parentClassifyId, prevSort, currentSort)
  354. if err != nil {
  355. err = errors.New("向下移动出错:" + err.Error())
  356. return
  357. }
  358. classifyInfo.Sort = prevSort
  359. } else if nextSort <= currentSort && nextSort != 0 {
  360. //往上移动
  361. err = data_manage.MoveUpClarksonsIndexClassifyBySort(parentClassifyId, nextSort, currentSort)
  362. if err != nil {
  363. err = errors.New("向上移动出错:" + err.Error())
  364. return
  365. }
  366. classifyInfo.Sort = nextSort
  367. }
  368. classifyInfo.ModifyTime = time.Now()
  369. updateCol = append(updateCol, "Sort", "ModifyTime")
  370. err = classifyInfo.Update(updateCol)
  371. if err != nil {
  372. errMsg = "移动失败"
  373. err = errors.New("修改失败,Err:" + err.Error())
  374. return
  375. }
  376. return
  377. }
  378. // MoveClarksonsData 移动卓创红期指标
  379. func MoveClarksonsData(indexId, classifyId, prevIndexId, nextIndexId int) (err error, errMsg string) {
  380. //分类信息
  381. clarksonsIndex, err := data_manage.GetClarksonsIndexByIndexId(indexId)
  382. if err != nil {
  383. errMsg = `获取数据失败`
  384. if err.Error() == utils.ErrNoRow() {
  385. errMsg = `该指标未入库`
  386. err = nil
  387. }
  388. return
  389. }
  390. //判断分类是否存在
  391. if classifyId > 0 {
  392. _, err = data_manage.GetClarksonsClassifyById(classifyId)
  393. if err != nil {
  394. errMsg = "移动失败"
  395. err = errors.New("获取分类信息失败,Err:" + err.Error())
  396. if err.Error() == utils.ErrNoRow() {
  397. errMsg = "找不到该分类"
  398. err = nil
  399. }
  400. return
  401. }
  402. }
  403. //如果改变了分类,那么移动该图表数据
  404. if clarksonsIndex.ClassifyId != classifyId {
  405. tmpErr := data_manage.MoveClarksonsIndex(indexId, classifyId)
  406. if tmpErr != nil {
  407. errMsg = "移动失败"
  408. err = errors.New("移动失败,Err:" + tmpErr.Error())
  409. return
  410. }
  411. }
  412. //移动排序
  413. updateCol := make([]string, 0)
  414. var currentSort, prevSort, nextSort int
  415. currentSort = clarksonsIndex.Sort
  416. //如果有传入 上一个兄弟节点分类id
  417. var prevIndex *data_manage.BaseFromClarksonsIndex
  418. var nextIndex *data_manage.BaseFromClarksonsIndex
  419. if prevIndexId > 0 {
  420. prevIndex, err = data_manage.GetClarksonsIndexByIndexId(prevIndexId)
  421. if err != nil {
  422. if err.Error() == utils.ErrNoRow() {
  423. errMsg = "移动失败"
  424. err = errors.New("上一个兄弟节点指标信息不存在" + err.Error())
  425. return
  426. }
  427. errMsg = "移动失败"
  428. err = errors.New("获取上一个兄弟节点指标信息失败,Err:" + err.Error())
  429. return
  430. }
  431. prevSort = prevIndex.Sort
  432. }
  433. if nextIndexId > 0 {
  434. //下一个兄弟节点
  435. nextIndex, err = data_manage.GetClarksonsIndexByIndexId(nextIndexId)
  436. if err != nil {
  437. if err.Error() == utils.ErrNoRow() {
  438. errMsg = "移动失败"
  439. err = errors.New("下一个兄弟节点指标信息不存在" + err.Error())
  440. return
  441. }
  442. errMsg = "移动失败"
  443. err = errors.New("获取下一个兄弟节点指标信息失败,Err:" + err.Error())
  444. return
  445. }
  446. nextSort = nextIndex.Sort
  447. }
  448. // 修改历史数据中的排序为0的情况
  449. if prevSort == 0 && nextSort == 0 { //目标是让当前分类处于目录的最顶部, 但是历史数据里下个节点的sort为0的情况
  450. //更新为0排序的数据为当前最小排序
  451. if nextIndex != nil {
  452. minSort, e := data_manage.GetClarksonsIndexMinSortByClassifyId(classifyId)
  453. if e != nil {
  454. errMsg = "移动失败"
  455. err = errors.New("获取下一个兄弟节点分类信息失败,Err:" + e.Error())
  456. return
  457. }
  458. if minSort > 1 {
  459. minSort -= 1
  460. }
  461. nextIndex.Sort = minSort
  462. err = nextIndex.Update([]string{"Sort"})
  463. if err != nil {
  464. errMsg = "移动失败"
  465. err = errors.New("更新下一个兄弟节点分类信息失败,Err:" + err.Error())
  466. return
  467. }
  468. nextSort = minSort
  469. }
  470. }
  471. //移到两个排序值中间操作
  472. if prevSort >= currentSort {
  473. //往下移动
  474. err = data_manage.MoveDownClarksonsIndexBySort(classifyId, prevSort, currentSort)
  475. if err != nil {
  476. err = errors.New("向下移动出错:" + err.Error())
  477. return
  478. }
  479. clarksonsIndex.Sort = prevSort
  480. } else if nextSort <= currentSort && nextSort != 0 {
  481. //往上移动
  482. err = data_manage.MoveUpClarksonsIndexBySort(classifyId, nextSort, currentSort)
  483. if err != nil {
  484. err = errors.New("向上移动出错:" + err.Error())
  485. return
  486. }
  487. clarksonsIndex.Sort = nextSort
  488. }
  489. //更新
  490. clarksonsIndex.ModifyTime = time.Now()
  491. updateCol = append(updateCol, "Sort", "ModifyTime")
  492. err = clarksonsIndex.Update(updateCol)
  493. if err != nil {
  494. errMsg = "移动失败"
  495. err = errors.New("修改失败,Err:" + err.Error())
  496. return
  497. }
  498. return
  499. }
  500. // GetClarksonsIndexInfo 获取指标信息-分页
  501. func GetClarksonsIndexInfo(keyWord string, classifyIdList []string, frequencyList []string, currentIndex, startSize, pageSize int) (rzdIndexInfoList *data_manage.BaseFromRzdIndexPage, err error) {
  502. // 获取指标
  503. var condition string
  504. var pars []interface{}
  505. if keyWord != "" {
  506. condition += ` AND (index_name like ? or index_code like ?)`
  507. pars = append(pars, "%"+keyWord+"%", "%"+keyWord+"%")
  508. }
  509. if len(classifyIdList) > 0 {
  510. condition += ` AND classify_id IN (`
  511. for _, v := range classifyIdList {
  512. condition += `?,`
  513. pars = append(pars, v)
  514. }
  515. condition = condition[:len(condition)-1] + `)`
  516. }
  517. if len(frequencyList) > 0 {
  518. condition += ` AND frequency IN (`
  519. for _, v := range frequencyList {
  520. condition += `?,`
  521. pars = append(pars, v)
  522. }
  523. condition = condition[:len(condition)-1] + `)`
  524. }
  525. count, err := data_manage.GetClarksonsIndexInfoCount(condition, pars)
  526. if err != nil {
  527. return nil, err
  528. }
  529. indexPage := data_manage.BaseFromRzdIndexPage{}
  530. page := paging.GetPaging(currentIndex, pageSize, count)
  531. if count <= 0 {
  532. indexPage.Paging = page
  533. return &indexPage, nil
  534. }
  535. condition += ` ORDER BY base_from_clarksons_index_id asc`
  536. // 分页
  537. condition += ` LIMIT ?, ?`
  538. pars = append(pars, startSize, pageSize)
  539. indexInfoPage, err := data_manage.GetClarksonsIndexInfoPage(condition, pars)
  540. if err != nil {
  541. return nil, err
  542. }
  543. var indexCodes []string
  544. for _, indexInfo := range indexInfoPage {
  545. indexCodes = append(indexCodes, indexInfo.IndexCode)
  546. }
  547. IndexDataList, err := data_manage.GetClarksonsLastUpdateTimeLastByIndexCode(indexCodes)
  548. if err != nil {
  549. return nil, err
  550. }
  551. var indexDataMap = make(map[string]*data_manage.BaseFromClarksonsData, 0)
  552. for _, data := range IndexDataList {
  553. indexDataMap[data.IndexCode] = data
  554. }
  555. for _, indexInfo := range indexInfoPage {
  556. if indexDataMap[indexInfo.IndexCode] == nil {
  557. continue
  558. }
  559. indexInfo.ModifyTimeMax = indexDataMap[indexInfo.IndexCode].DataTime
  560. indexInfo.Value = indexDataMap[indexInfo.IndexCode].Value
  561. }
  562. indexPage.List = indexInfoPage
  563. indexPage.Paging = page
  564. return &indexPage, nil
  565. }
  566. // GetClarkssonsIndexList 获取指标列表
  567. func GetClarkssonsIndexList(searchParams string) (rzdIndexInfoList []*data_manage.BaseFromRzdIndexList, err error) {
  568. // 获取指标
  569. var condition string
  570. var pars []interface{}
  571. if searchParams != "" {
  572. condition += ` and index_code like ? or index_name like ?`
  573. pars = append(pars, "%"+searchParams+"%", "%"+searchParams+"%")
  574. }
  575. rzdIndexList, err := data_manage.GetRzdIndex(condition, pars)
  576. if err != nil {
  577. return nil, err
  578. }
  579. return rzdIndexList, nil
  580. }