chart_info.go 15 KB

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