chart_common.go 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. package data_manage
  2. import (
  3. "eta/eta_api/controllers/data_manage/correlation"
  4. "eta/eta_api/controllers/data_manage/future_good"
  5. "eta/eta_api/controllers/data_manage/line_equation"
  6. "eta/eta_api/controllers/data_manage/line_feature"
  7. "eta/eta_api/models"
  8. "eta/eta_api/models/data_manage"
  9. "eta/eta_api/utils"
  10. )
  11. // CommonChartInfoDetailFromUniqueCode
  12. // @Title 根据编码获取图表详情
  13. // @Description 根据编码获取图表详情接口
  14. // @Param UniqueCode query int true "图表唯一编码,如果是管理后台访问,传固定字符串:7c69b590249049942070ae9dcd5bf6dc"
  15. // @Param IsCache query bool true "是否走缓存,默认false"
  16. // @Success 200 {object} data_manage.ChartInfoDetailFromUniqueCodeResp
  17. // @router /chart_info/common/detail/from_unique_code [get]
  18. func (this *ChartInfoController) CommonChartInfoDetailFromUniqueCode() {
  19. br := new(models.BaseResponse).Init()
  20. defer func() {
  21. this.Data["json"] = br
  22. this.ServeJSON()
  23. }()
  24. sysUser := this.SysUser
  25. if sysUser == nil {
  26. br.Msg = "请登录"
  27. br.ErrMsg = "请登录,SysUser Is Empty"
  28. br.Ret = 408
  29. return
  30. }
  31. uniqueCode := this.GetString("UniqueCode")
  32. if uniqueCode == "" {
  33. br.Msg = "参数错误"
  34. br.ErrMsg = "参数错误,uniqueCode is empty"
  35. return
  36. }
  37. //是否走缓存
  38. isCache, _ := this.GetBool("IsCache")
  39. status := true
  40. chartInfo, err := data_manage.GetChartInfoViewByUniqueCode(uniqueCode)
  41. if err != nil {
  42. if err.Error() == utils.ErrNoRow() {
  43. status = false
  44. } else {
  45. br.Msg = "获取失败"
  46. br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
  47. return
  48. }
  49. }
  50. if chartInfo == nil {
  51. status = false
  52. }
  53. if !status {
  54. resp := new(data_manage.ChartInfoDetailFromUniqueCodeResp)
  55. endInfoList := make([]*data_manage.ChartEdbInfoMapping, 0)
  56. resp.EdbInfoList = endInfoList
  57. resp.ChartInfo = chartInfo
  58. resp.Status = false
  59. br.Data = resp
  60. br.Ret = 200
  61. br.Success = true
  62. br.Msg = "获取成功"
  63. return
  64. }
  65. switch chartInfo.Source {
  66. case utils.CHART_SOURCE_DEFAULT:
  67. resp, isOk, msg, errMsg := GetChartInfoDetailFromUniqueCode(chartInfo, isCache, sysUser)
  68. if !isOk {
  69. br.Msg = msg
  70. br.ErrMsg = errMsg
  71. return
  72. }
  73. br.Ret = 200
  74. br.Success = true
  75. br.Msg = "获取成功"
  76. br.Data = resp
  77. case utils.CHART_SOURCE_FUTURE_GOOD:
  78. resp, isOk, msg, errMsg := future_good.GetChartInfoDetailFromUniqueCode(chartInfo, isCache, sysUser)
  79. if !isOk {
  80. br.Msg = msg
  81. br.ErrMsg = errMsg
  82. return
  83. }
  84. br.Ret = 200
  85. br.Success = true
  86. br.Msg = "获取成功"
  87. br.Data = resp
  88. case utils.CHART_SOURCE_FUTURE_GOOD_PROFIT:
  89. resp, isOk, msg, errMsg := future_good.GetFutureGoodProfitChartInfoDetailFromUniqueCode(chartInfo, isCache, sysUser)
  90. if !isOk {
  91. br.Msg = msg
  92. br.ErrMsg = errMsg
  93. return
  94. }
  95. br.Ret = 200
  96. br.Success = true
  97. br.Msg = "获取成功"
  98. br.Data = resp
  99. case utils.CHART_SOURCE_CORRELATION, utils.CHART_SOURCE_ROLLING_CORRELATION:
  100. resp, isOk, msg, errMsg := correlation.GetChartInfoDetailFromUniqueCode(chartInfo, isCache, sysUser)
  101. if !isOk {
  102. br.Msg = msg
  103. br.ErrMsg = errMsg
  104. return
  105. }
  106. br.Ret = 200
  107. br.Success = true
  108. br.Msg = "获取成功"
  109. br.Data = resp
  110. case utils.CHART_SOURCE_LINE_EQUATION:
  111. resp, isOk, msg, errMsg := line_equation.GetChartInfoDetailFromUniqueCode(chartInfo, isCache, sysUser)
  112. if !isOk {
  113. br.Msg = msg
  114. br.ErrMsg = errMsg
  115. return
  116. }
  117. br.Ret = 200
  118. br.Success = true
  119. br.Msg = "获取成功"
  120. br.Data = resp
  121. case utils.CHART_SOURCE_LINE_FEATURE_STANDARD_DEVIATION, utils.CHART_SOURCE_LINE_FEATURE_PERCENTILE, utils.CHART_SOURCE_LINE_FEATURE_FREQUENCY:
  122. resp, isOk, msg, errMsg := line_feature.GetChartInfoDetailFromUniqueCode(chartInfo, isCache, sysUser)
  123. if !isOk {
  124. br.Msg = msg
  125. br.ErrMsg = errMsg
  126. return
  127. }
  128. br.Ret = 200
  129. br.Success = true
  130. br.Msg = "获取成功"
  131. br.Data = resp
  132. default:
  133. br.Msg = "错误的图表"
  134. br.ErrMsg = "错误的图表"
  135. return
  136. }
  137. }