chart_info.go 11 KB

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