chart_common.go 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "eta/eta_chart_lib/models"
  5. "eta/eta_chart_lib/models/data_manage"
  6. cross_varietyReq "eta/eta_chart_lib/models/data_manage/cross_variety/request"
  7. "eta/eta_chart_lib/models/data_manage/future_good"
  8. "eta/eta_chart_lib/models/data_manage/future_good/request"
  9. "eta/eta_chart_lib/models/data_manage/future_good/response"
  10. line_equationReq "eta/eta_chart_lib/models/data_manage/line_equation/request"
  11. line_featureReq "eta/eta_chart_lib/models/data_manage/line_feature/request"
  12. "eta/eta_chart_lib/services/data"
  13. correlationServ "eta/eta_chart_lib/services/data/correlation"
  14. "eta/eta_chart_lib/services/data/cross_variety"
  15. "eta/eta_chart_lib/services/data/excel"
  16. future_goodServ "eta/eta_chart_lib/services/data/future_good"
  17. "eta/eta_chart_lib/services/data/line_equation"
  18. lineFeatureServ "eta/eta_chart_lib/services/data/line_feature"
  19. "eta/eta_chart_lib/services/data/range_analysis"
  20. dwmini "eta/eta_chart_lib/services/dw_mini"
  21. "eta/eta_chart_lib/utils"
  22. "fmt"
  23. "strconv"
  24. "strings"
  25. "time"
  26. )
  27. // CommonChartInfoDetailFromUniqueCode
  28. // @Title 根据编码获取图表详情
  29. // @Description 根据编码获取图表详情接口
  30. // @Param UniqueCode query int true "图表唯一编码,如果是管理后台访问,传固定字符串:7c69b590249049942070ae9dcd5bf6dc"
  31. // @Param IsCache query bool true "是否走缓存,默认false"
  32. // @Param Token query string true "东吴小程序token"
  33. // @Param AuthToken query string true "图表权限鉴权token"
  34. // @Param Source query int true "查询来源 1:东吴"
  35. // @Success 200 {object} data_manage.ChartInfoDetailFromUniqueCodeResp
  36. // @router /common/detail [get]
  37. func (this *ChartController) CommonChartInfoDetailFromUniqueCode() {
  38. br := new(models.BaseResponse).Init()
  39. defer func() {
  40. this.Data["json"] = br
  41. this.ServeJSON()
  42. }()
  43. uniqueCode := this.GetString("UniqueCode")
  44. token := this.GetString("Token")
  45. source, _ := this.GetInt("Source")
  46. authToken := this.GetString("AuthToken")
  47. if uniqueCode == "" {
  48. br.Msg = "参数错误"
  49. br.ErrMsg = "参数错误,uniqueCode is empty"
  50. return
  51. }
  52. key := utils.HZ_CHART_LIB_DETAIL + uniqueCode
  53. resp := new(models.ChartInfoDetailResp)
  54. chartInfo, err := models.GetChartInfoByUniqueCode(uniqueCode)
  55. if err != nil {
  56. if err.Error() == utils.ErrNoRow() {
  57. br.Msg = "该图已被删除,请刷新页面"
  58. br.ErrMsg = "该图已被删除,请刷新页面,Err:" + err.Error()
  59. return
  60. }
  61. br.Msg = "获取失败"
  62. br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
  63. return
  64. }
  65. // 图表水印
  66. conf, e := models.GetBusinessConf()
  67. if e != nil {
  68. br.Msg = "获取失败"
  69. br.ErrMsg = "获取配置信息失败, Err: " + e.Error()
  70. return
  71. }
  72. // 图表有效期是否开启
  73. if conf[models.BusinessConfIsOpenChartExpired] == "true" {
  74. resp.ChartInfo = chartInfo
  75. br.Data = resp
  76. if authToken == `` {
  77. br.Ret = 200
  78. br.Success = true
  79. br.Msg = "无鉴权"
  80. return
  81. }
  82. tmpKey := fmt.Sprint(utils.CACHE_CHART_AUTH, authToken)
  83. redisChartCode, err := utils.Rc.RedisString(tmpKey)
  84. if err != nil {
  85. br.Ret = 200
  86. br.Success = true
  87. br.Msg = "获取成功"
  88. return
  89. }
  90. if redisChartCode != uniqueCode {
  91. br.Ret = 200
  92. br.Msg = "获取失败"
  93. br.ErrMsg = "获取失败"
  94. return
  95. }
  96. }
  97. var isCollect bool
  98. if source == utils.CHART_SOURCE_DW && token != "" {
  99. tmpIsCollect, err := dwmini.GetMyChartIsCollect(token, uniqueCode)
  100. if err != nil {
  101. br.Msg = "获取失败"
  102. br.ErrMsg = "获取收藏状态失败,Err:" + err.Error()
  103. return
  104. }
  105. isCollect = tmpIsCollect
  106. }
  107. //判断是否有缓存
  108. if utils.Re == nil {
  109. if utils.Re == nil && utils.Rc.IsExist(key) {
  110. if data, err1 := utils.Rc.RedisBytes(key); err1 == nil {
  111. err := json.Unmarshal(data, &resp)
  112. if err == nil && resp != nil {
  113. if conf[models.BusinessConfWatermarkChart] == "true" && conf[models.BusinessConfCompanyWatermark] != "" {
  114. resp.WaterMark = conf[models.BusinessConfCompanyWatermark]
  115. }
  116. if isCollect {
  117. resp.IsCollect = isCollect
  118. }
  119. resp.IsAuth = true
  120. br.Ret = 200
  121. br.Success = true
  122. br.Msg = "获取成功"
  123. br.Data = resp
  124. fmt.Println("source redis")
  125. return
  126. }
  127. }
  128. }
  129. }
  130. //var resp interface{}
  131. var isOk bool
  132. var msg, errMsg string
  133. switch chartInfo.Source {
  134. case utils.CHART_SOURCE_DEFAULT:
  135. resp, isOk, msg, errMsg = GetChartInfoDetailFromUniqueCode(chartInfo, key)
  136. case utils.CHART_SOURCE_FUTURE_GOOD:
  137. resp, isOk, msg, errMsg = GetFutureGoodChartInfoDetailFromUniqueCode(chartInfo, key)
  138. case utils.CHART_SOURCE_FUTURE_GOOD_PROFIT:
  139. resp, isOk, msg, errMsg = GetFutureGoodProfitChartInfoDetailFromUniqueCode(chartInfo, key)
  140. case utils.CHART_SOURCE_CORRELATION, utils.CHART_SOURCE_ROLLING_CORRELATION:
  141. resp, isOk, msg, errMsg = GetCorrelationChartInfoDetailFromUniqueCode(chartInfo, key)
  142. case utils.CHART_SOURCE_LINE_EQUATION:
  143. resp, isOk, msg, errMsg = GetLineEquationChartInfoDetailFromUniqueCode(chartInfo, key)
  144. case utils.CHART_SOURCE_LINE_FEATURE_STANDARD_DEVIATION, utils.CHART_SOURCE_LINE_FEATURE_PERCENTILE, utils.CHART_SOURCE_LINE_FEATURE_FREQUENCY:
  145. resp, isOk, msg, errMsg = GetLineFeatureChartInfoDetailFromUniqueCode(chartInfo, key)
  146. case utils.CHART_SOURCE_CROSS_HEDGING:
  147. resp, isOk, msg, errMsg = GetCrossVarietyChartInfoDetailFromUniqueCode(chartInfo, key)
  148. case utils.CHART_SOURCE_BALANCE_EXCEL:
  149. resp, isOk, msg, errMsg = GetBalanceChartInfoDetailFromUniqueCode(chartInfo, key, this.Lang)
  150. if !isOk {
  151. br.Msg = msg
  152. br.ErrMsg = errMsg
  153. return
  154. }
  155. case utils.CHART_SOURCE_RANGE_ANALYSIS:
  156. resp, isOk, msg, errMsg = GetRangeAnalysisChartInfoDetailFromUniqueCode(chartInfo, key, this.Lang)
  157. if !isOk {
  158. br.Msg = msg
  159. br.ErrMsg = errMsg
  160. return
  161. }
  162. default:
  163. br.Msg = "错误的图表"
  164. br.ErrMsg = "错误的图表"
  165. return
  166. }
  167. if !isOk {
  168. br.Msg = msg
  169. br.ErrMsg = errMsg
  170. return
  171. }
  172. if isCollect {
  173. resp.IsCollect = isCollect
  174. }
  175. if conf[models.BusinessConfWatermarkChart] == "true" && conf[models.BusinessConfCompanyWatermark] != "" {
  176. resp.WaterMark = conf[models.BusinessConfCompanyWatermark]
  177. }
  178. resp.IsAuth = true
  179. br.Ret = 200
  180. br.Success = true
  181. br.Msg = "获取成功"
  182. br.Data = resp
  183. }
  184. // GetFutureGoodChartInfoDetailFromUniqueCode 根据编码获取图表详情
  185. func GetFutureGoodChartInfoDetailFromUniqueCode(chartInfo *models.ChartInfo, key string) (resp *models.ChartInfoDetailResp, isOk bool, msg, errMsg string) {
  186. resp = new(models.ChartInfoDetailResp)
  187. // 获取主题样式
  188. chartTheme, err := data.GetChartThemeConfig(chartInfo.ChartThemeId, utils.CHART_SOURCE_DEFAULT, 1)
  189. if err != nil {
  190. msg = "获取失败"
  191. errMsg = "获取主题信息失败,Err:" + err.Error()
  192. return
  193. }
  194. chartInfo.ChartThemeStyle = chartTheme.Config
  195. chartInfo.ChartThemeId = chartTheme.ChartThemeId
  196. chartInfoId := chartInfo.ChartInfoId
  197. startDate := chartInfo.StartDate
  198. endDate := chartInfo.EndDate
  199. // 兼容日期错误
  200. {
  201. if strings.Count(startDate, "-") == 1 {
  202. startDate = startDate + "-01"
  203. }
  204. if strings.Count(endDate, "-") == 1 {
  205. endDate = endDate + "-01"
  206. }
  207. }
  208. edbInfoMappingList, err := models.GetEtaEdbChartEdbMappingList(chartInfoId)
  209. if err != nil {
  210. msg = "获取失败"
  211. errMsg = "获取图表,现货指标信息失败,Err:" + err.Error()
  212. return
  213. }
  214. futureGoodEdbInfoMapping, err := models.GetFutureGoodEdbChartEdbMapping(chartInfoId)
  215. if err != nil {
  216. msg = "获取失败"
  217. errMsg = "获取图表的期货商品指标信息失败,Err:" + err.Error()
  218. return
  219. }
  220. // 商品价格曲线图的一些配置
  221. var barConfig data_manage.FutureGoodBarChartInfoReq
  222. //barChartInfoSort := data_manage.BarChartInfoSortReq{}
  223. if chartInfo.BarConfig == `` {
  224. msg = "商品价格曲线图未配置"
  225. errMsg = "商品价格曲线图未配置"
  226. return
  227. }
  228. err = json.Unmarshal([]byte(chartInfo.BarConfig), &barConfig)
  229. if err != nil {
  230. msg = "商品价格曲线图配置异常"
  231. errMsg = "商品价格曲线图配置异常"
  232. return
  233. }
  234. baseEdbInfoId := barConfig.BaseEdbInfoId
  235. var baseEdbInfoMapping *models.ChartEdbInfoMapping
  236. // todo 兼容历史数据,
  237. if baseEdbInfoId == 0 {
  238. // 默认取第一个现货指标
  239. baseEdbInfoId = edbInfoMappingList[0].EdbInfoId
  240. baseEdbInfoMapping = edbInfoMappingList[0]
  241. barConfig.BaseEdbInfoId = baseEdbInfoId
  242. } else {
  243. baseEdbInfoMapping, err = models.GetChartEdbMappingByEdbInfoId(baseEdbInfoId)
  244. if err != nil {
  245. msg = "获取失败"
  246. errMsg = "获取图表,指标信息失败,Err:" + err.Error()
  247. return
  248. }
  249. }
  250. // 获取图表中的指标数据
  251. barConfigEdbInfoIdList, edbList, xEdbIdValue, xDataList, yDataList, err := future_goodServ.GetChartEdbData(chartInfoId, startDate, endDate, baseEdbInfoMapping, edbInfoMappingList, futureGoodEdbInfoMapping, barConfig, true)
  252. if err != nil {
  253. msg = "获取失败"
  254. errMsg = "获取图表,指标信息失败,Err:" + err.Error()
  255. return
  256. }
  257. warnEdbList := make([]string, 0)
  258. if len(edbList) <= 0 {
  259. msg = "商品价格曲线图表指标异常"
  260. errMsg = "商品价格曲线图表异常"
  261. return
  262. }
  263. baseEdbInfo := edbList[0] //现货指标
  264. for _, v := range edbList {
  265. if v.IsNullData {
  266. warnEdbList = append(warnEdbList, v.EdbName+"("+v.EdbCode+")")
  267. }
  268. // 指标别名
  269. if barConfigEdbInfoIdList != nil && len(barConfigEdbInfoIdList) > 0 {
  270. for _, reqEdb := range barConfigEdbInfoIdList {
  271. if v.EdbInfoId == reqEdb.EdbInfoId {
  272. v.EdbAliasName = reqEdb.Name
  273. v.EdbAliasNameEn = reqEdb.NameEn
  274. }
  275. }
  276. }
  277. if v.Source == 0 {
  278. name := strings.Split(v.EdbName, "(")
  279. if barConfig.FutureGoodEdbName != "" {
  280. name[0] = barConfig.FutureGoodEdbName
  281. }
  282. v.EdbName = name[0]
  283. if len(name) > 1 {
  284. v.EdbName = v.EdbName + "(" + name[1]
  285. }
  286. //英文
  287. // 编译正则表达式,匹配一个或多个数字
  288. if v.EdbNameEn != "" {
  289. name = strings.Split(v.EdbNameEn, "(")
  290. if barConfig.FutureGoodEdbNameEn != "" {
  291. name[0] = barConfig.FutureGoodEdbNameEn
  292. }
  293. v.EdbNameEn = name[0]
  294. if len(name) > 1 {
  295. v.EdbNameEn = v.EdbNameEn + "(" + name[1]
  296. }
  297. }
  298. }
  299. }
  300. chartInfo.UnitEn = baseEdbInfo.UnitEn
  301. // 图表的指标来源
  302. sourceNameList, sourceNameEnList := data.GetEdbSourceByEdbInfoIdList(edbList)
  303. chartInfo.ChartSource = strings.Join(sourceNameList, ",")
  304. chartInfo.ChartSourceEn = strings.Join(sourceNameEnList, ",")
  305. xDataListFinal := make([]models.XData, 0)
  306. for _, v := range xDataList {
  307. tmp := models.XData{
  308. Name: v.Name,
  309. NameEn: v.NameEn,
  310. IsHide: v.IsHide,
  311. }
  312. xDataListFinal = append(xDataListFinal, tmp)
  313. }
  314. resp.ChartInfo = chartInfo
  315. resp.EdbInfoList = edbList
  316. resp.XEdbIdValue = xEdbIdValue
  317. resp.YDataList = yDataList
  318. resp.XDataList = xDataListFinal
  319. //resp.BarChartInfo = barConfig
  320. //resp.Status = true
  321. // 将数据加入缓存
  322. if utils.Re == nil {
  323. data, _ := json.Marshal(resp)
  324. utils.Rc.Put(key, data, 2*time.Hour)
  325. }
  326. isOk = true
  327. return
  328. }
  329. // GetFutureGoodProfitChartInfoDetailFromUniqueCode 根据编码获取商品利润图表详情
  330. func GetFutureGoodProfitChartInfoDetailFromUniqueCode(chartInfo *models.ChartInfo, key string) (resp *models.ChartInfoDetailResp, isOk bool, msg, errMsg string) {
  331. resp = new(models.ChartInfoDetailResp)
  332. chartInfoId := chartInfo.ChartInfoId
  333. // 获取主题样式
  334. chartTheme, err := data.GetChartThemeConfig(chartInfo.ChartThemeId, utils.CHART_SOURCE_DEFAULT, 1)
  335. if err != nil {
  336. msg = "获取失败"
  337. errMsg = "获取主题信息失败,Err:" + err.Error()
  338. return
  339. }
  340. chartInfo.ChartThemeStyle = chartTheme.Config
  341. chartInfo.ChartThemeId = chartTheme.ChartThemeId
  342. // 商品利润曲线图的一些配置
  343. var extraConf request.ChartInfoReq
  344. err = json.Unmarshal([]byte(chartInfo.ExtraConfig), &extraConf)
  345. if err != nil {
  346. msg = "商品利润曲线图配置异常"
  347. errMsg = "商品利润曲线图配置异常,Err:" + err.Error()
  348. return
  349. }
  350. if len(extraConf.EdbInfoIdList) == 0 {
  351. extraConf.EdbInfoIdList = append(extraConf.EdbInfoIdList, extraConf.BaseEdbInfoId)
  352. }
  353. edbList := make([]*models.ChartEdbInfoMapping, 0)
  354. edbInfoMappingList, err := models.GetEtaEdbChartEdbMappingList(chartInfoId)
  355. if err != nil {
  356. msg = "获取失败"
  357. errMsg = "获取商品利润图表,基础指标信息失败,Err:" + err.Error()
  358. return
  359. }
  360. baseEdbInfo := new(models.ChartEdbInfoMapping)
  361. for _, v := range edbInfoMappingList {
  362. if v.EdbInfoId == extraConf.BaseEdbInfoId {
  363. baseEdbInfo = v
  364. }
  365. }
  366. edbList = edbInfoMappingList
  367. futureGoodEdbInfoMappingList, err := models.GetFutureGoodEdbChartEdbMappingList(chartInfoId)
  368. if err != nil {
  369. msg = "获取失败"
  370. errMsg = "获取商品利润图表,商品指标信息失败,Err:" + err.Error()
  371. return
  372. }
  373. edbList = append(edbList, futureGoodEdbInfoMappingList...)
  374. if len(edbList) <= 0 {
  375. msg = "商品利润曲线图表指标异常"
  376. errMsg = "商品利润曲线图表指标异常"
  377. return
  378. }
  379. xDataList := make([]models.XData, 0)
  380. yDataList := make([]models.YData, 0)
  381. // 查找商品利润图表的扩展信息
  382. chartInfoFutureGoodProfit := new(future_good.ChartInfoFutureGoodProfit)
  383. if err = chartInfoFutureGoodProfit.GetItemById(chartInfo.ChartInfoId); err != nil {
  384. msg = "获取失败"
  385. errMsg = "获取基础相关性图表信息失败, Err: " + err.Error()
  386. return
  387. }
  388. err = json.Unmarshal([]byte(chartInfoFutureGoodProfit.XValue), &xDataList)
  389. if err != nil {
  390. msg = "获取失败"
  391. errMsg = "转换X轴数据失败, Err: " + err.Error()
  392. return
  393. }
  394. err = json.Unmarshal([]byte(chartInfoFutureGoodProfit.YValue), &yDataList)
  395. if err != nil {
  396. msg = "获取失败"
  397. errMsg = "转换Y轴数据失败, Err: " + err.Error()
  398. return
  399. }
  400. warnEdbList := make([]string, 0)
  401. for _, v := range edbList {
  402. if v.IsNullData {
  403. warnEdbList = append(warnEdbList, v.EdbName+"("+v.EdbCode+")")
  404. }
  405. }
  406. chartInfo.UnitEn = baseEdbInfo.UnitEn
  407. resp.ChartInfo = chartInfo
  408. resp.EdbInfoList = edbList
  409. resp.DataResp = response.ProfitFutureGoodChartResp{
  410. YDataList: yDataList,
  411. XDataList: xDataList,
  412. ProfitName: chartInfoFutureGoodProfit.ProfitName,
  413. ProfitNameEn: chartInfoFutureGoodProfit.ProfitNameEn,
  414. Extra: extraConf,
  415. }
  416. // 将数据加入缓存
  417. if utils.Re == nil {
  418. data, _ := json.Marshal(resp)
  419. utils.Rc.Put(key, data, 2*time.Hour)
  420. }
  421. isOk = true
  422. return
  423. }
  424. // GetLineEquationChartInfoDetailFromUniqueCode 根据编码获取拟合方程图表详情
  425. func GetLineEquationChartInfoDetailFromUniqueCode(chartInfo *models.ChartInfo, key string) (resp *models.ChartInfoDetailResp, isOk bool, msg, errMsg string) {
  426. resp = new(models.ChartInfoDetailResp)
  427. // 获取主题样式
  428. chartTheme, err := data.GetChartThemeConfig(chartInfo.ChartThemeId, utils.CHART_SOURCE_DEFAULT, 1)
  429. if err != nil {
  430. msg = "获取失败"
  431. errMsg = "获取主题信息失败,Err:" + err.Error()
  432. return
  433. }
  434. chartInfo.ChartThemeStyle = chartTheme.Config
  435. chartInfo.ChartThemeId = chartTheme.ChartThemeId
  436. //chartInfoId := chartInfo.ChartInfoId
  437. if chartInfo.ExtraConfig == `` {
  438. msg = "获取失败"
  439. errMsg = "获取配置信息失败"
  440. return
  441. }
  442. var lineChartInfoConfig line_equationReq.LineChartInfoReq
  443. err = json.Unmarshal([]byte(chartInfo.ExtraConfig), &lineChartInfoConfig)
  444. if err != nil {
  445. msg = "获取失败"
  446. errMsg = "获取图表配置信息失败, Err:" + err.Error()
  447. return
  448. }
  449. var getAData, getBData, getR2Data bool
  450. switch lineChartInfoConfig.Source {
  451. case utils.CHART_MULTIPLE_GRAPH_LINE_EQUATION_ONE:
  452. getAData = true
  453. case utils.CHART_MULTIPLE_GRAPH_LINE_EQUATION_TWO:
  454. getBData = true
  455. case utils.CHART_MULTIPLE_GRAPH_LINE_EQUATION_THREE:
  456. getR2Data = true
  457. }
  458. edbList, dataResp, err, errMsg := line_equation.GetChartEdbData(chartInfo.ChartInfoId, lineChartInfoConfig, getAData, getBData, getR2Data)
  459. if err != nil {
  460. if errMsg == `` {
  461. errMsg = "获取失败"
  462. }
  463. return
  464. }
  465. var resultResp interface{}
  466. switch lineChartInfoConfig.Source {
  467. case utils.CHART_MULTIPLE_GRAPH_LINE_EQUATION_ONE:
  468. resultResp = dataResp.AData
  469. case utils.CHART_MULTIPLE_GRAPH_LINE_EQUATION_TWO:
  470. resultResp = dataResp.BData
  471. case utils.CHART_MULTIPLE_GRAPH_LINE_EQUATION_THREE:
  472. resultResp = dataResp.R2Data
  473. }
  474. //chartInfo.UnitEn = baseEdbInfo.UnitEn
  475. // 图表的指标来源
  476. sourceNameList, sourceNameEnList := data.GetEdbSourceByEdbInfoIdList(edbList)
  477. chartInfo.ChartSource = strings.Join(sourceNameList, ",")
  478. chartInfo.ChartSourceEn = strings.Join(sourceNameEnList, ",")
  479. resp.ChartInfo = chartInfo
  480. resp.DataResp = resultResp
  481. resp.EdbInfoList = edbList
  482. // 将数据加入缓存
  483. if utils.Re == nil {
  484. data, _ := json.Marshal(resp)
  485. utils.Rc.Put(key, data, 2*time.Hour)
  486. }
  487. isOk = true
  488. return
  489. }
  490. // GetLineFeatureChartInfoDetailFromUniqueCode 根据编码获取统计特征图表详情
  491. func GetLineFeatureChartInfoDetailFromUniqueCode(chartInfo *models.ChartInfo, key string) (resp *models.ChartInfoDetailResp, isOk bool, msg, errMsg string) {
  492. resp = new(models.ChartInfoDetailResp)
  493. // 获取主题样式
  494. chartTheme, err := data.GetChartThemeConfig(chartInfo.ChartThemeId, utils.CHART_SOURCE_DEFAULT, 1)
  495. if err != nil {
  496. msg = "获取失败"
  497. errMsg = "获取主题信息失败,Err:" + err.Error()
  498. return
  499. }
  500. chartInfo.ChartThemeStyle = chartTheme.Config
  501. chartInfo.ChartThemeId = chartTheme.ChartThemeId
  502. // 获取图表关联指标
  503. edbMappingList, err := models.GetChartEdbMappingList(chartInfo.ChartInfoId)
  504. if err != nil {
  505. msg = "获取失败"
  506. errMsg = "获取图表关联指标信息失败,Err:" + err.Error()
  507. return
  508. }
  509. if len(edbMappingList) != 1 {
  510. msg = "获取失败"
  511. errMsg = fmt.Sprint("获取图表关联指标信息异常,数量:", len(edbMappingList))
  512. return
  513. }
  514. edbMapping := edbMappingList[0]
  515. var edbList []*models.ChartEdbInfoMapping
  516. var resultResp interface{}
  517. switch chartInfo.Source {
  518. case utils.CHART_SOURCE_LINE_FEATURE_STANDARD_DEVIATION:
  519. calculateValue, tmpErr := strconv.Atoi(chartInfo.ExtraConfig)
  520. if tmpErr != nil {
  521. msg = "获取失败"
  522. errMsg = "格式化配置项失败,Err:" + tmpErr.Error()
  523. return
  524. }
  525. startDate, endDate := utils.GetDateByDateType(chartInfo.DateType, chartInfo.StartDate, chartInfo.EndDate)
  526. edbList, resultResp, err, msg = lineFeatureServ.GetStandardDeviationData(chartInfo.ChartInfoId, startDate, endDate, edbMapping, calculateValue)
  527. case utils.CHART_SOURCE_LINE_FEATURE_PERCENTILE:
  528. var percentileConfig line_featureReq.Percentile
  529. err = json.Unmarshal([]byte(chartInfo.ExtraConfig), &percentileConfig)
  530. if err != nil {
  531. msg = "获取失败"
  532. errMsg = "格式化配置项失败,Err:" + err.Error()
  533. return
  534. }
  535. startDate, endDate := utils.GetDateByDateType(chartInfo.DateType, chartInfo.StartDate, chartInfo.EndDate)
  536. edbList, resultResp, err, msg = lineFeatureServ.GetPercentileData(chartInfo.ChartInfoId, startDate, endDate, edbMapping, percentileConfig.CalculateValue, percentileConfig.CalculateUnit, percentileConfig.PercentType)
  537. case utils.CHART_SOURCE_LINE_FEATURE_FREQUENCY:
  538. var frequencyDistributionConfig line_featureReq.FrequencyDistribution
  539. err = json.Unmarshal([]byte(chartInfo.ExtraConfig), &frequencyDistributionConfig)
  540. if err != nil {
  541. msg = "获取失败"
  542. errMsg = "格式化配置项失败,Err:" + err.Error()
  543. return
  544. }
  545. // 获取图表中的指标数据
  546. edbList, resultResp, err, errMsg = lineFeatureServ.GetFrequencyDistributionData(0, edbMapping, frequencyDistributionConfig.DateType, frequencyDistributionConfig.FrequencyValue, frequencyDistributionConfig.StartDate, frequencyDistributionConfig.EndDate)
  547. default:
  548. msg = `错误的图表`
  549. errMsg = fmt.Sprint("错误的图表来源,source", chartInfo.Source)
  550. return
  551. }
  552. if err != nil {
  553. if msg == `` {
  554. msg = "获取失败"
  555. }
  556. errMsg = "获取图表,指标信息失败,Err:" + err.Error()
  557. return
  558. }
  559. //chartInfo.UnitEn = baseEdbInfo.UnitEn
  560. // 图表的指标来源
  561. sourceNameList, sourceNameEnList := data.GetEdbSourceByEdbInfoIdList(edbList)
  562. chartInfo.ChartSource = strings.Join(sourceNameList, ",")
  563. chartInfo.ChartSourceEn = strings.Join(sourceNameEnList, ",")
  564. resp.ChartInfo = chartInfo
  565. resp.DataResp = resultResp
  566. resp.EdbInfoList = edbList
  567. // 将数据加入缓存
  568. if utils.Re == nil {
  569. data, _ := json.Marshal(resp)
  570. utils.Rc.Put(key, data, 2*time.Hour)
  571. }
  572. isOk = true
  573. return
  574. }
  575. // GetCrossVarietyChartInfoDetailFromUniqueCode 根据编码获取图表详情
  576. func GetCrossVarietyChartInfoDetailFromUniqueCode(chartInfo *models.ChartInfo, key string) (resp *models.ChartInfoDetailResp, isOk bool, msg, errMsg string) {
  577. resp = new(models.ChartInfoDetailResp)
  578. // 获取主题样式
  579. chartTheme, err := data.GetChartThemeConfig(chartInfo.ChartThemeId, utils.CHART_SOURCE_DEFAULT, 5)
  580. if err != nil {
  581. msg = "获取失败"
  582. errMsg = "获取主题信息失败,Err:" + err.Error()
  583. return
  584. }
  585. chartInfo.ChartThemeStyle = chartTheme.Config
  586. chartInfo.ChartThemeId = chartTheme.ChartThemeId
  587. if chartInfo.ExtraConfig == `` {
  588. msg = "图表配置信息异常"
  589. errMsg = "图表配置信息异常"
  590. return
  591. }
  592. var config cross_varietyReq.ChartConfigReq
  593. err = json.Unmarshal([]byte(chartInfo.ExtraConfig), &config)
  594. if err != nil {
  595. msg = "解析跨品种分析配置失败"
  596. errMsg = "解析跨品种分析配置失败,Err:" + err.Error()
  597. return
  598. }
  599. // 获取图表x轴y轴
  600. edbList, dataResp, err, msg, _ := cross_variety.GetChartData(0, config)
  601. if err != nil {
  602. errMsg = "获取图表,指标信息失败,Err:" + err.Error()
  603. return
  604. }
  605. //判断是否需要展示英文标识
  606. //chartInfo.IsEnChart = data.CheckIsEnChart(chartInfo.ChartNameEn, edbList[0:1], chartInfo.Source, chartInfo.ChartType)
  607. //chartInfo.UnitEn = edbInfoMappingA.UnitEn
  608. // 另存为
  609. resp.ChartInfo = chartInfo
  610. resp.DataResp = dataResp
  611. resp.EdbInfoList = edbList
  612. // 图表的指标来源
  613. sourceNameList, sourceNameEnList := data.GetEdbSourceByEdbInfoIdList(edbList)
  614. chartInfo.ChartSource = strings.Join(sourceNameList, ",")
  615. chartInfo.ChartSourceEn = strings.Join(sourceNameEnList, ",")
  616. // 将数据加入缓存
  617. if utils.Re == nil {
  618. d, _ := json.Marshal(resp)
  619. _ = utils.Rc.Put(key, d, 2*time.Hour)
  620. }
  621. isOk = true
  622. return
  623. }
  624. func GetBalanceChartInfoDetailFromUniqueCode(chartInfo *models.ChartInfo, key, lang string) (resp *models.ChartInfoDetailResp, isOk bool, msg, errMsg string) {
  625. resp = new(models.ChartInfoDetailResp)
  626. msg = `获取失败`
  627. var err error
  628. defer func() {
  629. if err != nil {
  630. if errMsg != "" {
  631. msg = errMsg
  632. }
  633. errMsg = err.Error()
  634. }
  635. }()
  636. // 相关联指标
  637. mappingListTmp, dataListMap, err, errMsg := excel.GetBalanceExcelChartSingle(chartInfo.ChartInfoId, 0, lang)
  638. if err != nil {
  639. errMsg = "获取失败"
  640. err = fmt.Errorf(" 获取图表,指标信息失败 Err:%s", err.Error())
  641. return
  642. }
  643. var chartInfoResp *models.ChartInfoDetailResp
  644. chartInfoResp, err, errMsg = data.GetBalanceExcelChartDetail(chartInfo, mappingListTmp, dataListMap)
  645. if err != nil {
  646. msg = "查询图表详情失败"
  647. errMsg = "查询图表详情失败,Err:" + err.Error()
  648. return
  649. }
  650. resp = &models.ChartInfoDetailResp{
  651. ChartInfo: chartInfoResp.ChartInfo,
  652. EdbInfoList: chartInfoResp.EdbInfoList,
  653. XEdbIdValue: chartInfoResp.XEdbIdValue,
  654. YDataList: chartInfoResp.YDataList,
  655. XDataList: chartInfoResp.XDataList,
  656. CorrelationChartInfo: chartInfoResp.CorrelationChartInfo,
  657. DataResp: chartInfoResp.DataResp,
  658. }
  659. if utils.Re == nil {
  660. jsonData, _ := json.Marshal(resp)
  661. utils.Rc.Put(key, jsonData, 10*time.Minute)
  662. }
  663. isOk = true
  664. return
  665. }
  666. // FutureGoodChartInfoRefresh
  667. // @Title 商品价格图表刷新接口
  668. // @Description 商品价格图表刷新接口
  669. // @Param UniqueCode query string true "图表唯一编码,如果是管理后台访问,传固定字符串:7c69b590249049942070ae9dcd5bf6dc"
  670. // @Success Ret=200 刷新成功
  671. // @router /future_good/refresh [get]
  672. func (this *ChartController) FutureGoodChartInfoRefresh() {
  673. br := new(models.BaseResponse).Init()
  674. chartId := 0
  675. defer func() {
  676. // 添加日志
  677. if chartId > 0 {
  678. shareChartRefreshLogInfo := &models.ShareChartRefreshLog{
  679. Ip: this.Ctx.Input.IP(),
  680. ChartId: chartId,
  681. CreateTime: time.Now(),
  682. }
  683. models.AddShareChartRefreshLog(shareChartRefreshLogInfo)
  684. }
  685. this.Data["json"] = br
  686. this.ServeJSON()
  687. }()
  688. uniqueCode := this.GetString("UniqueCode")
  689. if uniqueCode == "" {
  690. br.Msg = "参数错误"
  691. br.ErrMsg = "参数错误,uniqueCode is empty"
  692. return
  693. }
  694. chartInfo, err := models.GetChartInfoByUniqueCode(uniqueCode)
  695. if err != nil {
  696. if err.Error() == utils.ErrNoRow() {
  697. br.Msg = "该图已被删除,请刷新页面"
  698. br.ErrMsg = "该图已被删除,请刷新页面,Err:" + err.Error()
  699. return
  700. }
  701. br.Msg = "获取失败"
  702. br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
  703. return
  704. }
  705. chartId = chartInfo.ChartInfoId
  706. err = future_goodServ.FutureGoodChartInfoRefresh(chartInfo.ChartInfoId)
  707. if err != nil {
  708. br.Msg = "刷新失败"
  709. br.ErrMsg = "刷新图表关联指标信息失败,Err:" + err.Error()
  710. return
  711. }
  712. //err = data.ChartInfoRefresh(chartInfo.ChartInfoId)
  713. //if err != nil {
  714. // br.Msg = "刷新失败"
  715. // br.ErrMsg = "刷新图表关联指标信息失败,Err:" + err.Error()
  716. // return
  717. //}
  718. //err = data.ChartInfoRefreshV2(chartInfo.ChartInfoId)
  719. //if err != nil {
  720. // br.Msg = "刷新失败"
  721. // br.ErrMsg = "刷新图表关联指标信息失败,Err:" + err.Error()
  722. // return
  723. //}
  724. //清除数据缓存
  725. key := utils.HZ_CHART_LIB_DETAIL + uniqueCode
  726. if utils.Re == nil {
  727. utils.Rc.Delete(key)
  728. }
  729. br.Ret = 200
  730. br.Success = true
  731. br.Msg = "刷新成功"
  732. }
  733. // GetCorrelationChartInfoDetailFromUniqueCode 根据编码获取相关性图表详情
  734. func GetCorrelationChartInfoDetailFromUniqueCode(chartInfo *models.ChartInfo, key string) (resp *models.ChartInfoDetailResp, isOk bool, msg, errMsg string) {
  735. resp = new(models.ChartInfoDetailResp)
  736. // 获取主题样式
  737. chartTheme, err := data.GetChartThemeConfig(chartInfo.ChartThemeId, utils.CHART_SOURCE_DEFAULT, 1)
  738. if err != nil {
  739. msg = "获取失败"
  740. errMsg = "获取主题信息失败,Err:" + err.Error()
  741. return
  742. }
  743. chartInfo.ChartThemeStyle = chartTheme.Config
  744. chartInfo.ChartThemeId = chartTheme.ChartThemeId
  745. chartInfoId := chartInfo.ChartInfoId
  746. startDate := chartInfo.StartDate
  747. endDate := chartInfo.EndDate
  748. // 兼容日期错误
  749. {
  750. if strings.Count(startDate, "-") == 1 {
  751. startDate = startDate + "-01"
  752. }
  753. if strings.Count(endDate, "-") == 1 {
  754. endDate = endDate + "-01"
  755. }
  756. }
  757. // 相关性图表信息
  758. correlationChart := new(data_manage.ChartInfoCorrelation)
  759. if e := correlationChart.GetItemById(chartInfoId); e != nil {
  760. msg = "获取失败"
  761. errMsg = "获取图表相关性信息失败, Err:" + e.Error()
  762. return
  763. }
  764. // 获取指标信息
  765. edbInfoMappingA, e := models.GetChartEdbMappingByEdbInfoId(correlationChart.EdbInfoIdFirst)
  766. if e != nil {
  767. msg = "获取失败"
  768. errMsg = "获取相关性图表, A指标mapping信息失败, Err:" + e.Error()
  769. return
  770. }
  771. edbInfoMappingB := new(models.ChartEdbInfoMapping)
  772. if correlationChart.AnalysisMode != 1 {
  773. edbInfoMappingB, e = models.GetChartEdbMappingByEdbInfoId(correlationChart.EdbInfoIdSecond)
  774. if e != nil {
  775. msg = "获取失败"
  776. errMsg = "获取相关性图表, B指标mapping信息失败, Err:" + e.Error()
  777. return
  778. }
  779. }
  780. var dataResp interface{} // 绘图数据返回(目前是滚动相关性的图)
  781. var xEdbIdValue []int
  782. var yDataList []models.YData
  783. if correlationChart.AnalysisMode != 1 {
  784. switch chartInfo.Source {
  785. case utils.CHART_SOURCE_CORRELATION: // 相关性图
  786. moveUnitDays, ok := utils.FrequencyDaysMap[correlationChart.CalculateUnit]
  787. if !ok {
  788. msg = "错误的分析周期"
  789. errMsg = "相关性图表数据有误"
  790. return
  791. }
  792. st := time.Now().AddDate(0, 0, -correlationChart.CalculateValue*moveUnitDays).Format(utils.FormatDate)
  793. ed := time.Now().Format(utils.FormatDate)
  794. xEdbIdValue, yDataList, e = correlationServ.GetChartDataByEdbInfo(edbInfoMappingA, edbInfoMappingB, correlationChart.LeadValue, correlationChart.LeadUnit, st, ed, chartInfo.ExtraConfig)
  795. if e != nil {
  796. msg = "获取失败"
  797. errMsg = "获取相关性图表, 图表计算值失败, Err:" + e.Error()
  798. return
  799. }
  800. case utils.CHART_SOURCE_ROLLING_CORRELATION: // 滚动相关性图
  801. st, ed := utils.GetDateByDateType(correlationChart.DateType, correlationChart.StartDate.Format(utils.FormatDate), correlationChart.EndDate.Format(utils.FormatDate))
  802. dataResp, e = correlationServ.GetRollingCorrelationChartDataByEdbInfo(edbInfoMappingA, edbInfoMappingB, correlationChart.LeadValue, correlationChart.LeadUnit, correlationChart.CalculateValue, correlationChart.CalculateUnit, st, ed, chartInfo.ChartName, chartInfo.ChartNameEn)
  803. }
  804. } else {
  805. xEdbIdValue, yDataList, e = correlationServ.GetFactorChartDataByChartId(chartInfoId, chartInfo.ExtraConfig)
  806. if e != nil {
  807. msg = "获取失败"
  808. errMsg = "获取相关性图表, 图表计算值失败, Err:" + e.Error()
  809. return
  810. }
  811. }
  812. // 完善指标信息
  813. edbList, e := correlationServ.GetChartEdbInfoFormat(chartInfo.ChartInfoId, edbInfoMappingA, edbInfoMappingB)
  814. if e != nil {
  815. msg = "获取失败"
  816. errMsg = "获取相关性图表, 完善指标信息失败, Err:" + e.Error()
  817. return
  818. }
  819. // 图表的指标来源
  820. sourceNameList, sourceNameEnList := data.GetEdbSourceByEdbInfoIdList(edbList)
  821. chartInfo.ChartSource = strings.Join(sourceNameList, ",")
  822. chartInfo.ChartSourceEn = strings.Join(sourceNameEnList, ",")
  823. correlationInfo := new(models.CorrelationInfo)
  824. correlationInfo.LeadValue = correlationChart.LeadValue
  825. correlationInfo.LeadUnit = correlationChart.LeadUnit
  826. correlationInfo.StartDate = correlationChart.StartDate.Format(utils.FormatDate)
  827. correlationInfo.EndDate = correlationChart.EndDate.Format(utils.FormatDate)
  828. correlationInfo.LeadValue = correlationChart.LeadValue
  829. correlationInfo.EdbInfoIdFirst = correlationChart.EdbInfoIdFirst
  830. correlationInfo.EdbInfoIdSecond = correlationChart.EdbInfoIdSecond
  831. correlationInfo.AnalysisMode = correlationChart.AnalysisMode
  832. resp.ChartInfo = chartInfo
  833. resp.EdbInfoList = edbList
  834. resp.XEdbIdValue = xEdbIdValue
  835. resp.YDataList = yDataList
  836. resp.CorrelationChartInfo = correlationInfo
  837. resp.DataResp = dataResp
  838. // 将数据加入缓存
  839. if utils.Re == nil {
  840. d, _ := json.Marshal(resp)
  841. _ = utils.Rc.Put(key, d, 2*time.Hour)
  842. }
  843. isOk = true
  844. return
  845. }
  846. // CorrelationChartInfoRefresh
  847. // @Title 商品价格图表刷新接口
  848. // @Description 商品价格图表刷新接口
  849. // @Param UniqueCode query string true "图表唯一编码,如果是管理后台访问,传固定字符串:7c69b590249049942070ae9dcd5bf6dc"
  850. // @Success Ret=200 刷新成功
  851. // @router /correlation/refresh [get]
  852. func (this *ChartController) CorrelationChartInfoRefresh() {
  853. br := new(models.BaseResponse).Init()
  854. chartId := 0
  855. defer func() {
  856. // 添加日志
  857. if chartId > 0 {
  858. shareChartRefreshLogInfo := &models.ShareChartRefreshLog{
  859. Ip: this.Ctx.Input.IP(),
  860. ChartId: chartId,
  861. CreateTime: time.Now(),
  862. }
  863. models.AddShareChartRefreshLog(shareChartRefreshLogInfo)
  864. }
  865. this.Data["json"] = br
  866. this.ServeJSON()
  867. }()
  868. uniqueCode := this.GetString("UniqueCode")
  869. if uniqueCode == "" {
  870. br.Msg = "参数错误"
  871. br.ErrMsg = "参数错误,uniqueCode is empty"
  872. return
  873. }
  874. chartInfo, err := models.GetChartInfoByUniqueCode(uniqueCode)
  875. if err != nil {
  876. if err.Error() == utils.ErrNoRow() {
  877. br.Msg = "该图已被删除,请刷新页面"
  878. br.ErrMsg = "该图已被删除,请刷新页面,Err:" + err.Error()
  879. return
  880. }
  881. br.Msg = "获取失败"
  882. br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
  883. return
  884. }
  885. chartId = chartInfo.ChartInfoId
  886. err = data.ChartInfoRefreshV2(chartInfo.ChartInfoId)
  887. if err != nil {
  888. br.Msg = "刷新失败"
  889. br.ErrMsg = "刷新图表关联指标信息失败,Err:" + err.Error()
  890. return
  891. }
  892. //// 刷新相关性图表
  893. //if e := correlationServ.ChartInfoRefresh(chartInfo.ChartInfoId); e != nil {
  894. // br.Msg = "刷新失败"
  895. // br.ErrMsg = "刷新相关性图表失败, Err:" + e.Error()
  896. // return
  897. //}
  898. //清除数据缓存
  899. key := utils.HZ_CHART_LIB_DETAIL + uniqueCode
  900. if utils.Re == nil {
  901. _ = utils.Rc.Delete(key)
  902. }
  903. br.Ret = 200
  904. br.Success = true
  905. br.Msg = "刷新成功"
  906. }
  907. // GetRangeAnalysisChartInfoDetailFromUniqueCode 根据编码获取区间计算图表详情
  908. func GetRangeAnalysisChartInfoDetailFromUniqueCode(chartInfo *models.ChartInfo, key, lang string) (resp *models.ChartInfoDetailResp, isOk bool, msg, errMsg string) {
  909. resp = new(models.ChartInfoDetailResp)
  910. // 获取主题样式
  911. chartTheme, err := data.GetChartThemeConfig(chartInfo.ChartThemeId, utils.CHART_SOURCE_DEFAULT, 1)
  912. if err != nil {
  913. msg = "获取失败"
  914. errMsg = "获取主题信息失败,Err:" + err.Error()
  915. return
  916. }
  917. chartInfo.ChartThemeStyle = chartTheme.Config
  918. chartInfo.ChartThemeId = chartTheme.ChartThemeId
  919. chartInfoId := chartInfo.ChartInfoId
  920. // 获取指标信息
  921. //chartInfo.CorrelationLeadUnit = req.LeadUnit
  922. edbInfoMappingList, err := models.GetChartEdbMappingList(chartInfoId)
  923. if err != nil {
  924. msg = "获取失败"
  925. errMsg = "获取图表,指标信息失败,Err:" + err.Error()
  926. return
  927. }
  928. dateType := chartInfo.DateType
  929. // 开始/结束日期
  930. startYear := chartInfo.StartYear
  931. startDate := chartInfo.StartDate
  932. endDate := chartInfo.EndDate
  933. // 区间计算图表配置校验
  934. var extraConfig models.ChartRangeAnalysisExtraConf
  935. if chartInfo.ExtraConfig == `` {
  936. msg = "配置信息错误"
  937. return
  938. }
  939. err = json.Unmarshal([]byte(chartInfo.ExtraConfig), &extraConfig)
  940. if err != nil {
  941. msg = "配置信息错误"
  942. errMsg = "图表配置信息错误,Err:" + err.Error()
  943. return
  944. }
  945. // 获取图表数据
  946. if len(edbInfoMappingList) == 0 {
  947. msg = "获取失败"
  948. errMsg = "图表没有指标,无法计算"
  949. return
  950. }
  951. // 获取图表x轴y轴
  952. edbList, xEdbIdValue, dataResp, e := range_analysis.GetChartDataByEdbInfoList(chartInfoId, dateType, startYear, startDate, endDate, edbInfoMappingList, &extraConfig)
  953. if e != nil {
  954. msg = "获取失败"
  955. errMsg = "获取区间计算图表, 图表计算值失败, Err:" + e.Error()
  956. return
  957. }
  958. // 图表的指标来源
  959. sourceNameList, sourceNameEnList := data.GetEdbSourceByEdbInfoIdList(edbList)
  960. chartInfo.ChartSource = strings.Join(sourceNameList, ",")
  961. chartInfo.ChartSourceEn = strings.Join(sourceNameEnList, ",")
  962. resp.ChartInfo = chartInfo
  963. resp.EdbInfoList = edbList
  964. resp.XEdbIdValue = xEdbIdValue
  965. resp.DataResp = dataResp
  966. if utils.Re == nil {
  967. jsonData, _ := json.Marshal(resp)
  968. utils.Rc.Put(key, jsonData, 10*time.Minute)
  969. }
  970. isOk = true
  971. return
  972. }