chart_info.go 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. package data_manage
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. )
  5. type ChartEdbInfoMapping struct {
  6. EdbInfoId int `description:"指标id"`
  7. SourceName string `description:"来源名称"`
  8. Source int `description:"来源id"`
  9. EdbCode string `description:"指标编码"`
  10. EdbName string `description:"指标名称"`
  11. EdbAliasName string `description:"指标名称(别名)"`
  12. EdbNameEn string `description:"英文指标名称"`
  13. EdbAliasNameEn string `description:"英文指标名称(别名)"`
  14. EdbType int `description:"指标类型:1:基础指标,2:计算指标"`
  15. Frequency string `description:"频率"`
  16. FrequencyEn string `description:"英文频率"`
  17. Unit string `description:"单位"`
  18. UnitEn string `description:"英文单位"`
  19. StartDate string `description:"起始日期"`
  20. EndDate string `description:"终止日期"`
  21. ModifyTime string `description:"指标最后更新时间"`
  22. ChartEdbMappingId int `description:"图表指标id"`
  23. ChartInfoId int `description:"图表id"`
  24. MaxData float64 `description:"上限"`
  25. MinData float64 `description:"下限"`
  26. IsOrder bool `description:"true:正序,false:逆序"`
  27. IsAxis int `description:"1:左轴,0:右轴"`
  28. EdbInfoType int `description:"1:标准指标,0:领先指标"`
  29. EdbInfoCategoryType int `description:"0:普通指标,1:预测指标"`
  30. LeadValue int `description:"领先值"`
  31. LeadUnit string `description:"领先单位"`
  32. LeadUnitEn string `description:"领先英文单位"`
  33. ChartStyle string `description:"图表类型"`
  34. ChartColor string `description:"颜色"`
  35. PredictChartColor string `description:"预测数据的颜色"`
  36. ChartWidth float64 `description:"线条大小"`
  37. ChartType int `description:"生成样式:1:曲线图,2:季节性图,3:面积图,4:柱状图,5:散点图,6:组合图"`
  38. LatestDate string `description:"数据最新日期"`
  39. LatestValue float64 `description:"数据最新值"`
  40. UniqueCode string `description:"指标唯一编码"`
  41. MinValue float64 `json:"-" description:"最小值"`
  42. MaxValue float64 `json:"-" description:"最大值"`
  43. DataList interface{}
  44. IsNullData bool `json:"-" description:"是否空数据"`
  45. }
  46. func GetChartEdbMappingList(chartInfoId int) (list []*ChartEdbInfoMapping, err error) {
  47. o := orm.NewOrmUsingDB("data")
  48. sql := ` SELECT a.*,b.source_name,b.source,b.edb_code,b.edb_name,b.edb_name_en,b.frequency,b.unit,b.unit_en,b.start_date,b.end_date,b.modify_time,b.latest_date,b.latest_value,b.unique_code,b.edb_info_type AS edb_info_category_type
  49. FROM chart_edb_mapping AS a
  50. INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
  51. WHERE chart_info_id=?
  52. ORDER BY chart_edb_mapping_id ASC `
  53. _, err = o.Raw(sql, chartInfoId).QueryRows(&list)
  54. return
  55. }
  56. // BarChartInfoReq 柱方图预览请求数据
  57. type BarChartInfoReq struct {
  58. EdbInfoIdList []BarChartInfoEdbItemReq `description:"指标信息"`
  59. DateList []BarChartInfoDateReq `description:"日期配置"`
  60. Sort BarChartInfoSortReq `description:"排序"`
  61. Unit string `description:"中文单位名称"`
  62. UnitEn string `description:"英文单位名称"`
  63. }
  64. type FutureGoodBarChartInfoReq struct {
  65. EdbInfoIdList []BarChartInfoEdbItemReq `description:"指标信息"`
  66. DateList []BarChartInfoDateReq `description:"日期配置"`
  67. XDataList []XData `description:"横轴配置"`
  68. BaseEdbInfoId int `description:"日期基准指标id"`
  69. FutureGoodEdbName string `description:"期货名称"`
  70. FutureGoodEdbNameEn string `description:"期货英文名称"`
  71. }
  72. // XData 商品价格曲线的的x轴数据
  73. type XData struct {
  74. Name string `description:"别名"`
  75. NameEn string `description:"英文别名"`
  76. IsHide int `description:"是否隐藏,0不隐藏,1隐藏"`
  77. }
  78. // BarChartInfoEdbItemReq 柱方图预览请求数据(指标相关)
  79. type BarChartInfoEdbItemReq struct {
  80. EdbInfoId int `description:"指标ID"`
  81. Name string `description:"别名"`
  82. NameEn string `description:"英文别名"`
  83. Source int `description:"1:ETA图库;2:商品价格"`
  84. IsHide int `description:"是否隐藏该项,0不隐藏,1隐藏"`
  85. }
  86. // BarChartInfoDateReq 柱方图预览请求数据(日期相关)
  87. type BarChartInfoDateReq struct {
  88. Type int `description:"配置类型"`
  89. Date string `description:"固定日期"`
  90. Value int `description:"N天的值"`
  91. Color string `description:"颜色"`
  92. Name string `description:"别名"`
  93. }
  94. // BarChartInfoSortReq 柱方图预览请求数据(排序相关)
  95. type BarChartInfoSortReq struct {
  96. Sort int `description:"排序类型,0:默认,1:升序,2:降序"`
  97. DateIndex int `description:"日期数据的下标,从0开始"`
  98. }
  99. // SectionScatterReq 截面散点请求
  100. type SectionScatterReq struct {
  101. XName string `description:"x轴名称"`
  102. XNameEn string `description:"x轴名称(英文)"`
  103. XUnitName string `description:"x轴单位名称"`
  104. XUnitNameEn string `description:"x轴单位名称(英文)"`
  105. YName string `description:"y轴名称"`
  106. YNameEn string `description:"y轴名称(英文)"`
  107. YUnitName string `description:"y轴单位名称"`
  108. YUnitNameEn string `description:"y轴单位名称(英文)"`
  109. XMinValue string `description:"X轴的最小值"`
  110. XMaxValue string `description:"X轴的最大值"`
  111. YMinValue string `description:"Y轴的最小值"`
  112. YMaxValue string `description:"Y轴的最大值"`
  113. //EdbList []SectionScatterEdbItemReq `description:"指标数据"`
  114. SeriesList []SectionScatterSeriesItemReq `description:"系列数据"`
  115. }
  116. // SectionScatterSeriesItemReq 系列的请求
  117. type SectionScatterSeriesItemReq struct {
  118. Name string `description:"系列名"`
  119. NameEn string `description:"系列名(英文)"`
  120. Color string `description:"颜色"`
  121. EdbInfoList []SectionScatterEdbItemReq
  122. ShowTrendLine bool `description:"是否展示趋势线"`
  123. ShowFitEquation bool `description:"是否展示方程式"`
  124. ShowRSquare bool `description:"是否展示R平方"`
  125. }
  126. // SectionScatterEdbItemReq 截面散点请求的指标
  127. type SectionScatterEdbItemReq struct {
  128. XEdbInfoId int `description:"X轴的指标ID"`
  129. YEdbInfoId int `description:"Y轴的指标ID"`
  130. Name string `description:"别名"`
  131. NameEn string `description:"英文别名"`
  132. XDateType int `description:"X轴的日期配置类型"`
  133. XDate string `description:"X轴的日期固定日期"`
  134. XDateValue int `description:"X轴的日期N天的值"`
  135. YDateType int `description:"Y轴的日期配置类型"`
  136. YDate string `description:"Y轴的日期固定日期"`
  137. YDateValue int `description:"Y轴的日期N天的值"`
  138. IsShow bool `description:"是否展示"`
  139. }
  140. // SectionScatterInfoResp 截面散点图数据
  141. type SectionScatterInfoResp struct {
  142. XName string `description:"x轴名称"`
  143. XNameEn string `description:"x轴名称(英文)"`
  144. XUnitName string `description:"x轴单位名称"`
  145. XUnitNameEn string `description:"x轴单位名称(英文)"`
  146. YName string `description:"y轴名称"`
  147. YNameEn string `description:"y轴名称(英文)"`
  148. YUnitName string `description:"y轴单位名称"`
  149. YUnitNameEn string `description:"y轴单位名称(英文)"`
  150. XMinValue string `description:"X轴的最小值"`
  151. XMaxValue string `description:"X轴的最大值"`
  152. YMinValue string `description:"Y轴的最小值"`
  153. YMaxValue string `description:"Y轴的最大值"`
  154. DataList []SectionScatterSeriesItemResp `description:"数据列"`
  155. }
  156. // SectionScatterSeriesItemResp 系列的返回
  157. type SectionScatterSeriesItemResp struct {
  158. Name string `description:"系列名"`
  159. NameEn string `description:"系列名(英文)"`
  160. Color string `description:"颜色"`
  161. EdbInfoList []SectionScatterEdbItemResp
  162. ShowTrendLine bool `description:"是否展示趋势线"`
  163. ShowFitEquation bool `description:"是否展示方程式"`
  164. ShowRSquare bool `description:"是否展示R平方"`
  165. TrendLine string `description:"方程式"`
  166. RSquare string `description:"R平方的值(决定系数R2)"`
  167. TrendLimitData []CoordinatePoint `description:"趋势线的前后坐标点"`
  168. }
  169. // SectionScatterEdbItemResp 截面散点的返回参数
  170. type SectionScatterEdbItemResp struct {
  171. XEdbInfoId int `description:"X轴指标id"`
  172. XDate string `description:"X轴指标实际日期"`
  173. XName string `description:"X轴指标名称"`
  174. XNameEn string `description:"X轴指标英文名称"`
  175. XValue float64 `description:"X轴实际值"`
  176. YEdbInfoId int `description:"Y轴指标id"`
  177. YDate string `description:"Y轴指标实际日期"`
  178. YName string `description:"Y轴指标名称"`
  179. YNameEn string `description:"Y轴指标英文名称"`
  180. YValue float64 `description:"Y轴实际值"`
  181. IsShow bool `description:"是否展示"`
  182. Name string `description:"标签名称"`
  183. NameEn string `description:"英文标签名称"`
  184. }
  185. // CoordinatePoint 坐标点
  186. type CoordinatePoint struct {
  187. X float64
  188. Y float64
  189. }
  190. // RadarChartInfoReq 雷达图预览请求数据
  191. type RadarChartInfoReq struct {
  192. DateList []RadarChartInfoDateReq `description:"日期配置"`
  193. }
  194. // RadarChartInfoEdbItemReq 雷达图预览请求数据(指标相关)
  195. type RadarChartInfoEdbItemReq struct {
  196. EdbInfoId int `description:"指标ID"`
  197. Name string `description:"别名"`
  198. //NameEn string `description:"英文别名"`
  199. //Source int `description:"1:ETA图库;2:商品价格"`
  200. }
  201. // RadarChartInfoDateReq 雷达图预览请求数据(日期相关)
  202. type RadarChartInfoDateReq struct {
  203. Type int `description:"配置类型"`
  204. Date string `description:"固定日期"`
  205. Value int `description:"N天的值"`
  206. Color string `description:"颜色"`
  207. Name string `description:"别名"`
  208. }
  209. // RadarChartInfoResp 雷达图数据
  210. type RadarChartInfoResp struct {
  211. YDataList []RadarYData `description:"数据列"`
  212. XEdbIdValue []int
  213. }
  214. // RadarYData 雷达图的y轴数据
  215. type RadarYData struct {
  216. Date string `description:"数据日期"`
  217. Color string `description:"数据颜色"`
  218. Name string `description:"别名"`
  219. Value []float64 `description:"每个指标的值"`
  220. }