excel_info.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. package excel
  2. import (
  3. "encoding/json"
  4. "errors"
  5. "eta/eta_api/models"
  6. "eta/eta_api/models/data_manage"
  7. "eta/eta_api/models/data_manage/excel"
  8. "eta/eta_api/models/data_manage/excel/request"
  9. "eta/eta_api/models/data_manage/excel/response"
  10. "eta/eta_api/models/system"
  11. "eta/eta_api/services/data"
  12. "eta/eta_api/services/data/data_manage_permission"
  13. "eta/eta_api/utils"
  14. "fmt"
  15. "sort"
  16. "time"
  17. )
  18. // GetExcelDetailInfoByExcelInfoId 根据表格id获取表格详情
  19. func GetExcelDetailInfoByExcelInfoId(excelInfoId, sysUserId int, lang string) (excelDetail response.ExcelInfoDetail, errMsg string, err error) {
  20. errMsg = `获取失败`
  21. //获取eta表格信息
  22. excelInfo, err := excel.GetExcelInfoById(excelInfoId)
  23. if err != nil {
  24. err = errors.New("获取ETA表格信息失败,Err:" + err.Error())
  25. if err.Error() == utils.ErrNoRow() {
  26. errMsg = "ETA表格被删除,请刷新页面"
  27. err = errors.New("ETA表格被删除,请刷新页面,Err:" + err.Error())
  28. }
  29. return
  30. }
  31. return formatExcelInfo2Detail(excelInfo, sysUserId, lang)
  32. }
  33. // GetExcelDetailInfoByUnicode 根据表格编码获取表格详情
  34. func GetExcelDetailInfoByUnicode(unicode string, sysUserId int, lang string) (excelDetail response.ExcelInfoDetail, errMsg string, err error) {
  35. errMsg = `获取失败`
  36. // 获取eta表格信息
  37. excelInfo, err := excel.GetExcelInfoByUnicode(unicode)
  38. if err != nil {
  39. err = errors.New("获取ETA表格信息失败,Err:" + err.Error())
  40. if err.Error() == utils.ErrNoRow() {
  41. errMsg = "ETA表格被删除,请刷新页面"
  42. err = errors.New("ETA表格被删除,请刷新页面,Err:" + err.Error())
  43. }
  44. return
  45. }
  46. return formatExcelInfo2Detail(excelInfo, sysUserId, lang)
  47. }
  48. func formatExcelInfo2Detail(excelInfo *excel.ExcelInfo, sysUserId int, lang string) (excelDetail response.ExcelInfoDetail, errMsg string, err error) {
  49. checkExcelInfo := excelInfo
  50. if excelInfo.Source == utils.BALANCE_TABLE {
  51. checkExcelInfoId := excelInfo.ExcelInfoId
  52. if excelInfo.BalanceType == 1 {
  53. checkExcelInfoId = excelInfo.RelExcelInfoId
  54. } else {
  55. if excelInfo.ParentId > 0 {
  56. checkExcelInfoId = excelInfo.ParentId
  57. }
  58. }
  59. if checkExcelInfoId != excelInfo.ExcelInfoId {
  60. checkExcelInfo, err = excel.GetExcelInfoById(checkExcelInfoId)
  61. if err != nil {
  62. errMsg = "获取平衡表格信息失败"
  63. err = errors.New("获取平衡表格信息失败,Err:" + err.Error())
  64. return
  65. }
  66. }
  67. }
  68. // 数据权限
  69. haveOperaAuth, err := data_manage_permission.CheckExcelPermissionByExcelInfoId(checkExcelInfo.ExcelInfoId, checkExcelInfo.ExcelClassifyId, checkExcelInfo.IsJoinPermission, sysUserId)
  70. if err != nil {
  71. err = errors.New("获取表格权限信息失败,Err" + err.Error())
  72. return
  73. }
  74. excelDetail = response.ExcelInfoDetail{
  75. ExcelInfoId: excelInfo.ExcelInfoId,
  76. Source: excelInfo.Source,
  77. ExcelType: excelInfo.ExcelType,
  78. ExcelName: excelInfo.ExcelName,
  79. UniqueCode: excelInfo.UniqueCode,
  80. ExcelClassifyId: excelInfo.ExcelClassifyId,
  81. SysUserId: excelInfo.SysUserId,
  82. SysUserRealName: excelInfo.SysUserRealName,
  83. Content: excelInfo.Content,
  84. ExcelImage: excelInfo.ExcelImage,
  85. FileUrl: excelInfo.FileUrl,
  86. Sort: excelInfo.Sort,
  87. IsDelete: excelInfo.IsDelete,
  88. ModifyTime: excelInfo.ModifyTime,
  89. CreateTime: excelInfo.CreateTime,
  90. TableData: nil,
  91. HaveOperaAuth: haveOperaAuth,
  92. ParentId: excelInfo.ParentId,
  93. BalanceType: excelInfo.BalanceType,
  94. UpdateUserId: excelInfo.UpdateUserId,
  95. UpdateUserRealName: excelInfo.UpdateUserRealName,
  96. RelExcelInfoId: excelInfo.RelExcelInfoId,
  97. SourcesFrom: excelInfo.SourcesFrom,
  98. }
  99. // 无权限,不需要返回数据
  100. if !haveOperaAuth {
  101. return
  102. }
  103. switch excelInfo.Source {
  104. case utils.TIME_TABLE: // 时间序列表格
  105. var tableDataConfig TableDataConfig
  106. err = json.Unmarshal([]byte(excelDetail.Content), &tableDataConfig)
  107. if err != nil {
  108. err = errors.New("表格json转结构体失败,Err:" + err.Error())
  109. return
  110. }
  111. result, tmpErr := GetDataByTableDataConfig(tableDataConfig)
  112. if tmpErr != nil {
  113. err = errors.New("获取最新的表格数据失败,Err:" + tmpErr.Error())
  114. return
  115. }
  116. if len(result.EdbInfoIdList) > 0 {
  117. classifyIdList := make([]int, 0)
  118. for _, v := range result.Data {
  119. classifyIdList = append(classifyIdList, v.ClassifyId)
  120. }
  121. classifyMap := make(map[int]*data_manage.EdbClassify)
  122. classifyList, tmpErr := data_manage.GetEdbClassifyByIdList(classifyIdList)
  123. if tmpErr != nil {
  124. err = errors.New("获取分类列表失败,Err:" + tmpErr.Error())
  125. return
  126. }
  127. for _, v := range classifyList {
  128. classifyMap[v.ClassifyId] = v
  129. }
  130. // 获取所有有权限的指标和分类
  131. permissionEdbIdList, permissionClassifyIdList, tmpErr := data_manage_permission.GetUserEdbAndClassifyPermissionList(sysUserId, 0, 0)
  132. if err != nil {
  133. err = errors.New("获取所有有权限的指标和分类失败,Err:" + tmpErr.Error())
  134. return
  135. }
  136. for i, v := range result.Data {
  137. if currClassify, ok := classifyMap[v.ClassifyId]; ok {
  138. result.Data[i].HaveOperaAuth = data_manage_permission.CheckEdbPermissionByPermissionIdList(v.IsJoinPermission, currClassify.IsJoinPermission, v.EdbInfoId, v.ClassifyId, permissionEdbIdList, permissionClassifyIdList)
  139. }
  140. }
  141. }
  142. excelDetail.TableData = result
  143. case utils.MIXED_TABLE, utils.BALANCE_TABLE: // 混合表格 平衡表
  144. var result request.MixedTableReq
  145. err = json.Unmarshal([]byte(excelDetail.Content), &result)
  146. if err != nil {
  147. err = errors.New("表格json转结构体失败,Err:" + err.Error())
  148. return
  149. }
  150. newData, tmpErr, tmpErrMsg := GetMixedTableCellData(result, lang)
  151. if tmpErr != nil {
  152. errMsg = "获取失败"
  153. if tmpErrMsg != `` {
  154. errMsg = tmpErrMsg
  155. }
  156. err = errors.New("获取最新的数据失败,Err:" + tmpErr.Error())
  157. return
  158. }
  159. result.Data = newData
  160. excelDetail.TableData = result
  161. }
  162. if excelDetail.Source == utils.BALANCE_TABLE {
  163. excelDetail.Button = GetBalanceExcelInfoOpButton(sysUserId, checkExcelInfo.SysUserId, excelDetail.HaveOperaAuth, checkExcelInfo.ExcelInfoId)
  164. }
  165. return
  166. }
  167. // GetExcelInfoOpButton 获取ETA表格的操作权限
  168. func GetExcelInfoOpButton(sysUser *system.Admin, belongUserId, source int, haveOperaAuth bool) (button excel.ExcelInfoDetailButton) {
  169. // 如果没有数据权限,那么直接返回
  170. if !haveOperaAuth {
  171. return
  172. }
  173. //非管理员角色查看其他用户创建的表格,可刷新、另存为、下载表格;
  174. button.RefreshButton = true
  175. button.CopyButton = true
  176. button.DownloadButton = true
  177. // 1、本用户创建的表格,可编辑、刷新、另存为、下载、删除,删除需二次确认;
  178. // 2、管理员角色对所有表格有如上权限;
  179. // 3、在线excel所有人都能编辑
  180. if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_ADMIN || sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN || sysUser.AdminId == belongUserId || source == utils.EXCEL_DEFAULT {
  181. button.OpButton = true
  182. button.DeleteButton = true
  183. }
  184. // 自定义分析
  185. if source == utils.CUSTOM_ANALYSIS_TABLE {
  186. if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_ADMIN || sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN || sysUser.AdminId == belongUserId {
  187. button.OpEdbButton = true // 生成、查看指标按钮
  188. button.RefreshEdbButton = true // 刷新指标按钮
  189. }
  190. }
  191. return
  192. }
  193. // GetFirstEdbDataList 获取第一列的数据
  194. func GetFirstEdbDataList(edbInfo *data_manage.EdbInfo, num int, manualDateList []string) (resultDataList []request.ManualDataReq, err error) {
  195. var dataList []*data_manage.EdbDataList
  196. switch edbInfo.EdbInfoType {
  197. case 0:
  198. dataList, err = data_manage.GetEdbDataList(edbInfo.Source, edbInfo.SubSource, edbInfo.EdbInfoId, ``, ``)
  199. case 1:
  200. _, dataList, _, _, err, _ = data.GetPredictDataListByPredictEdbInfoId(edbInfo.EdbInfoId, ``, ``, false)
  201. default:
  202. err = errors.New(fmt.Sprint("获取失败,指标类型异常", edbInfo.EdbInfoType))
  203. }
  204. if err != nil {
  205. return
  206. }
  207. // 获取需要的期数
  208. lenData := len(dataList)
  209. if lenData <= 0 {
  210. return
  211. }
  212. tmpManualDateNum := 0 // 手工数据的期数
  213. lenManualDate := len(manualDateList)
  214. if lenManualDate > 0 {
  215. sortDateList := manualDateList
  216. baseDateList := utils.StrArr{}
  217. baseDateList = append(baseDateList, sortDateList...)
  218. sort.Sort(baseDateList)
  219. sortDateList = append([]string{}, baseDateList...)
  220. lastData := dataList[lenData-1]
  221. lastDataDate, tmpErr := time.ParseInLocation(utils.FormatDate, lastData.DataTime, time.Local)
  222. if tmpErr != nil {
  223. err = tmpErr
  224. return
  225. }
  226. // 遍历倒序后的日期,然后匹配在实际数据之后日期的个数
  227. for _, tmpDateStr := range sortDateList {
  228. tmpDate, tmpErr := time.ParseInLocation(utils.FormatDate, tmpDateStr, time.Local)
  229. if tmpErr != nil {
  230. err = tmpErr
  231. return
  232. }
  233. if tmpDate.After(lastDataDate) {
  234. tmpManualDateNum++
  235. continue
  236. }
  237. break
  238. }
  239. }
  240. // 需要的期数减去手工数据的期数,这才是A列指标需要的数据
  241. num = num - tmpManualDateNum
  242. if num > lenData {
  243. num = lenData
  244. }
  245. latestDateTime, _ := time.ParseInLocation(utils.FormatDate, edbInfo.LatestDate, time.Local)
  246. for i := 1; i <= num; i++ {
  247. dataTime, _ := time.ParseInLocation(utils.FormatDate, dataList[lenData-i].DataTime, time.Local)
  248. dataType := 1
  249. // 如果是预测指标,且当前值的日期,晚于实际日期,那么是预测值
  250. if edbInfo.EdbInfoType == 1 && dataTime.After(latestDateTime) {
  251. dataType = 5
  252. }
  253. resultDataList = append(resultDataList, request.ManualDataReq{
  254. DataType: dataType,
  255. DataTime: dataList[lenData-i].DataTime,
  256. ShowValue: fmt.Sprint(dataList[lenData-i].Value),
  257. Value: fmt.Sprint(dataList[lenData-i].Value),
  258. DataTimeType: 1,
  259. })
  260. }
  261. return
  262. }
  263. // GetOtherEdbDataList 获取其他列的数据
  264. func GetOtherEdbDataList(edbInfo *data_manage.EdbInfo, dateList []string) (resultDataList []request.ManualDataReq, err error) {
  265. lenDate := len(dateList)
  266. if lenDate <= 0 {
  267. return
  268. }
  269. sortDateList := dateList
  270. baseDateList := utils.StrArr{}
  271. baseDateList = append(baseDateList, sortDateList...)
  272. sort.Sort(baseDateList)
  273. sortDateList = append([]string{}, baseDateList...)
  274. endDateTime, err := time.ParseInLocation(utils.FormatDate, sortDateList[0], time.Local)
  275. if err != nil {
  276. return
  277. }
  278. firstDateTime, err := time.ParseInLocation(utils.FormatDate, sortDateList[lenDate-1], time.Local)
  279. if err != nil {
  280. return
  281. }
  282. var dataList []*data_manage.EdbDataList
  283. switch edbInfo.EdbInfoType {
  284. case 0:
  285. dataList, err = data_manage.GetEdbDataList(edbInfo.Source, edbInfo.SubSource, edbInfo.EdbInfoId, ``, ``)
  286. case 1:
  287. _, dataList, _, _, err, _ = data.GetPredictDataListByPredictEdbInfoId(edbInfo.EdbInfoId, ``, ``, false)
  288. default:
  289. err = errors.New(fmt.Sprint("获取失败,指标类型异常", edbInfo.EdbInfoType))
  290. }
  291. if err != nil {
  292. return
  293. }
  294. // 获取日期内的数据(包含开始日期前一个日期,以及 结束日期后一个日期,目的为了做空日期时的 插值法兼容)
  295. baseDataList := make([]*data_manage.EdbDataList, 0)
  296. var lastData *data_manage.EdbDataList
  297. var isInsert bool
  298. for _, data := range dataList {
  299. tmpDate := data.DataTime
  300. tmpDateTime, tmpErr := time.ParseInLocation(utils.FormatDate, tmpDate, time.Local)
  301. if tmpErr != nil {
  302. err = tmpErr
  303. return
  304. }
  305. if tmpDateTime.Before(firstDateTime) {
  306. lastData = data
  307. continue
  308. }
  309. // 如果是第一次写入数据
  310. if !isInsert && lastData != nil {
  311. baseDataList = append(baseDataList, lastData)
  312. }
  313. if tmpDateTime.After(endDateTime) {
  314. baseDataList = append(baseDataList, data)
  315. break
  316. }
  317. baseDataList = append(baseDataList, data)
  318. isInsert = true
  319. }
  320. // 实际数据的日期map
  321. realValMap := make(map[string]string)
  322. for _, v := range baseDataList {
  323. realValMap[v.DataTime] = v.DataTime
  324. }
  325. // 插值法处理
  326. handleDataMap := make(map[string]float64)
  327. err = data.HandleDataByLinearRegression(baseDataList, handleDataMap)
  328. if err != nil {
  329. return
  330. }
  331. latestDateTime, _ := time.ParseInLocation(utils.FormatDate, edbInfo.LatestDate, time.Local)
  332. // 对于不存在的数据做补充
  333. for _, date := range sortDateList {
  334. dataType := 1
  335. if _, ok := realValMap[date]; !ok {
  336. dataType = 2
  337. } else {
  338. dataTime, _ := time.ParseInLocation(utils.FormatDate, date, time.Local)
  339. // 如果是预测指标,且当前值的日期,晚于实际日期,那么是预测值
  340. if edbInfo.EdbInfoType == 1 && dataTime.After(latestDateTime) {
  341. dataType = 5
  342. }
  343. }
  344. var value, showValue string
  345. if tmpVal, ok := handleDataMap[date]; ok {
  346. value = fmt.Sprint(tmpVal)
  347. showValue = value
  348. } else {
  349. dataType = 3
  350. }
  351. resultDataList = append(resultDataList, request.ManualDataReq{
  352. DataType: dataType,
  353. DataTime: date,
  354. ShowValue: showValue,
  355. Value: value,
  356. })
  357. }
  358. return
  359. }
  360. // GetFirstHistoryEdbDataList 获取指标的历史的数据
  361. func GetFirstHistoryEdbDataList(edbInfo *data_manage.EdbInfo, num int, endDate string) (resultDataList []request.ManualDataReq, err error) {
  362. endDateTime, err := time.ParseInLocation(utils.FormatDate, endDate, time.Local)
  363. if err != nil {
  364. return
  365. }
  366. var dataList []*data_manage.EdbDataList
  367. switch edbInfo.EdbInfoType {
  368. case 0:
  369. dataList, err = data_manage.GetEdbDataList(edbInfo.Source, edbInfo.SubSource, edbInfo.EdbInfoId, ``, endDate)
  370. case 1:
  371. _, dataList, _, _, err, _ = data.GetPredictDataListByPredictEdbInfoId(edbInfo.EdbInfoId, ``, endDate, true)
  372. default:
  373. err = errors.New(fmt.Sprint("获取失败,指标类型异常", edbInfo.EdbInfoType))
  374. }
  375. if err != nil {
  376. return
  377. }
  378. // 获取需要的期数
  379. lenData := len(dataList)
  380. if lenData <= 0 {
  381. return
  382. }
  383. lastData := dataList[lenData-1]
  384. lastDataDateTime, err := time.ParseInLocation(utils.FormatDate, lastData.DataTime, time.Local)
  385. if err != nil {
  386. return
  387. }
  388. if endDateTime.Equal(lastDataDateTime) || lastDataDateTime.After(endDateTime) {
  389. dataList = dataList[:lenData-1]
  390. lenData = len(dataList)
  391. }
  392. if num > lenData {
  393. num = lenData
  394. }
  395. latestDateTime, _ := time.ParseInLocation(utils.FormatDate, edbInfo.LatestDate, time.Local)
  396. for i := 1; i <= num; i++ {
  397. dataTime, _ := time.ParseInLocation(utils.FormatDate, dataList[lenData-i].DataTime, time.Local)
  398. dataType := 1
  399. // 如果是预测指标,且当前值的日期,晚于实际日期,那么是预测值
  400. if edbInfo.EdbInfoType == 1 && dataTime.After(latestDateTime) {
  401. dataType = 5
  402. }
  403. resultDataList = append(resultDataList, request.ManualDataReq{
  404. DataType: dataType,
  405. DataTime: dataList[lenData-i].DataTime,
  406. ShowValue: fmt.Sprint(dataList[lenData-i].Value),
  407. Value: fmt.Sprint(dataList[lenData-i].Value),
  408. })
  409. }
  410. return
  411. }
  412. // GetEdbIdsFromExcelCodes 获取表格中的指标IDs
  413. func GetEdbIdsFromExcelCodes(excelCodes []string, sysUserId int, lang string) (edbIds []int, err error) {
  414. edbIds = make([]int, 0)
  415. edbIdExist := make(map[int]bool)
  416. for _, v := range excelCodes {
  417. // 表格详情
  418. detail, msg, e := GetExcelDetailInfoByUnicode(v, sysUserId, lang)
  419. if e != nil {
  420. err = fmt.Errorf("GetExcelDetailInfoByExcelInfoId err: %s, errMsg: %s", e.Error(), msg)
  421. return
  422. }
  423. // 自定义表格
  424. if detail.Source == utils.TIME_TABLE {
  425. jsonByte, e := json.Marshal(detail.TableData)
  426. if e != nil {
  427. err = fmt.Errorf("JSON格式化自定义表格数据失败, Err: %s", e.Error())
  428. return
  429. }
  430. var tableData request.TableDataReq
  431. if e = json.Unmarshal(jsonByte, &tableData); e != nil {
  432. err = fmt.Errorf("解析自定义表格数据失败, Err: %s", e.Error())
  433. return
  434. }
  435. for _, tv := range tableData.EdbInfoIdList {
  436. if edbIdExist[tv] {
  437. continue
  438. }
  439. edbIdExist[tv] = true
  440. edbIds = append(edbIds, tv)
  441. }
  442. }
  443. // 混合表格
  444. if detail.Source == utils.MIXED_TABLE {
  445. jsonByte, e := json.Marshal(detail.TableData)
  446. if e != nil {
  447. err = fmt.Errorf("JSON格式化混合表格数据失败, Err: %s", e.Error())
  448. return
  449. }
  450. var tableData request.MixedTableReq
  451. if e = json.Unmarshal(jsonByte, &tableData); e != nil {
  452. err = fmt.Errorf("解析混合表格数据失败, Err: %s", e.Error())
  453. return
  454. }
  455. if len(tableData.Data) > 0 {
  456. for _, td := range tableData.Data {
  457. for _, tv := range td {
  458. if tv.EdbInfoId > 0 && !edbIdExist[tv.EdbInfoId] {
  459. edbIdExist[tv.EdbInfoId] = true
  460. edbIds = append(edbIds, tv.EdbInfoId)
  461. }
  462. }
  463. }
  464. }
  465. }
  466. }
  467. return
  468. }
  469. // GetExcelEdbBatchRefreshKey 获取批量刷新表格指标缓存key
  470. func GetExcelEdbBatchRefreshKey(source string, primaryId, subId int) string {
  471. if source == `` {
  472. return ``
  473. }
  474. return fmt.Sprint("batch_refresh_excel_edb:", source, ":", primaryId, ":", subId)
  475. }
  476. // GetEdbSourceByEdbInfoIdList 获取关联指标的来源
  477. func GetEdbSourceByEdbInfoIdList(edbInfoIdList []int) (sourceNameList, sourceNameEnList []string,err error) {
  478. sourceNameList = make([]string, 0)
  479. sourceNameEnList = make([]string, 0)
  480. sourceMap := make(map[int]string)
  481. edbInfoList, tmpErr := data_manage.GetEdbInfoByIdList(edbInfoIdList)
  482. if tmpErr != nil {
  483. err = tmpErr
  484. return
  485. }
  486. for _, v := range edbInfoList {
  487. // 指标类型:1:基础指标,2:计算指标
  488. if v.EdbType == 2 {
  489. //sourceMap[0] = "弘则研究"
  490. baseEdbInfoArr, _, _ := data_manage.GetRefreshEdbInfoFromBase(v.EdbInfoId, v.Source)
  491. for _, baseEdbInfo := range baseEdbInfoArr {
  492. if baseEdbInfo.EdbInfoType == 0 { //普通指标才参与,预测指标不参与
  493. sourceMap[baseEdbInfo.Source] = baseEdbInfo.SourceName
  494. }
  495. }
  496. } else {
  497. sourceMap[v.Source] = v.SourceName
  498. }
  499. }
  500. for source, sourceName := range sourceMap {
  501. if utils.InArrayByInt([]int{utils.DATA_SOURCE_MANUAL, utils.DATA_SOURCE_MYSTEEL_CHEMICAL}, source) {
  502. continue
  503. }
  504. sourceNameList = append(sourceNameList, sourceName)
  505. sourceNameEn, ok := utils.DataSourceEnMap[source]
  506. if !ok {
  507. sourceNameEn = sourceName
  508. }
  509. sourceNameEnList = append(sourceNameEnList, sourceNameEn)
  510. }
  511. //sourceNameList = append(sourceNameList, utils.ChartDefaultNameCn)
  512. //sourceNameEnList = append(sourceNameEnList, utils.ChartDefaultNameEn)
  513. // 图表来源
  514. conf, e := models.GetBusinessConf()
  515. if e != nil {
  516. return
  517. }
  518. if conf[models.BusinessConfCompanyName] != "" {
  519. sourceNameList = append(sourceNameList, conf[models.BusinessConfCompanyName])
  520. sourceNameEnList = append(sourceNameEnList, conf[models.BusinessConfCompanyName])
  521. }
  522. return
  523. }