chart_edb_mapping.go 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type ChartEdbMapping struct {
  7. ChartEdbMappingId int `orm:"column(chart_edb_mapping_id);pk"`
  8. ChartInfoId int `description:"图表id"`
  9. EdbInfoId int `description:"指标id"`
  10. CreateTime time.Time `description:"创建时间"`
  11. ModifyTime time.Time `description:"修改时间"`
  12. UniqueCode string `description:"唯一编码"`
  13. MaxData float64 `description:"上限"`
  14. MinData float64 `description:"下限"`
  15. IsOrder bool `description:"true:正序,false:逆序"`
  16. IsAxis int `description:"true:左轴,false:右轴"`
  17. EdbInfoType int `description:"true:标准指标,false:领先指标"`
  18. LeadValue int `description:"领先值"`
  19. LeadUnit string `description:"领先单位"`
  20. ChartStyle string `description:"图表类型"`
  21. ChartColor string `description:"颜色"`
  22. ChartWidth float64 `description:"线条大小"`
  23. Source int `description:"1:ETA图库;2:商品价格曲线"`
  24. }
  25. // GetChartEdbMappingListByEdbInfoId 根据指标id获取关联图表列表
  26. func GetChartEdbMappingListByEdbInfoId(edbInfoId int) (list []*ChartEdbMapping, err error) {
  27. o := orm.NewOrm()
  28. sql := ` SELECT *
  29. FROM chart_edb_mapping AS a
  30. WHERE edb_info_id=?
  31. ORDER BY chart_edb_mapping_id ASC `
  32. _, err = o.Raw(sql, edbInfoId).QueryRows(&list)
  33. return
  34. }
  35. // GetGroupChartEdbMappingListByEdbInfoId 根据指标id和来源分组获取关联图表列表
  36. func GetGroupChartEdbMappingListByEdbInfoId(edbInfoId, source int) (list []*ChartEdbMapping, err error) {
  37. o := orm.NewOrm()
  38. sql := ` SELECT *
  39. FROM chart_edb_mapping AS a
  40. WHERE edb_info_id=? AND source = ? GROUP BY chart_info_id `
  41. _, err = o.Raw(sql, edbInfoId, source).QueryRows(&list)
  42. return
  43. }
  44. type ChartEdbInfoMapping struct {
  45. EdbInfoId int `description:"指标id"`
  46. SourceName string `description:"来源名称"`
  47. Source int `description:"来源id"`
  48. SubSource int `description:"来源id"`
  49. EdbCode string `description:"指标编码"`
  50. EdbName string `description:"指标名称"`
  51. EdbAliasName string `description:"指标名称(别名)"`
  52. EdbNameEn string `description:"英文指标名称"`
  53. EdbAliasNameEn string `description:"英文指标名称(别名)"`
  54. EdbType int `description:"指标类型:1:基础指标,2:计算指标"`
  55. Frequency string `description:"频率"`
  56. FrequencyEn string `description:"英文频率"`
  57. Unit string `description:"单位"`
  58. UnitEn string `description:"英文单位"`
  59. StartDate string `description:"起始日期"`
  60. EndDate string `description:"终止日期"`
  61. ModifyTime string `description:"指标最后更新时间"`
  62. ChartEdbMappingId int `description:"图表指标id"`
  63. ChartInfoId int `description:"图表id"`
  64. MaxData float64 `description:"上限"`
  65. MinData float64 `description:"下限"`
  66. IsOrder bool `description:"true:正序,false:逆序"`
  67. IsAxis int `description:"1:左轴,0:右轴"`
  68. EdbInfoType int `description:"1:标准指标,0:领先指标"`
  69. EdbInfoCategoryType int `description:"0:普通指标,1:预测指标"`
  70. LeadValue int `description:"领先值"`
  71. LeadUnit string `description:"领先单位"`
  72. LeadUnitEn string `description:"领先英文单位"`
  73. ChartStyle string `description:"图表类型"`
  74. ChartColor string `description:"颜色"`
  75. PredictChartColor string `description:"预测数据的颜色"`
  76. ChartWidth float64 `description:"线条大小"`
  77. ChartType int `description:"生成样式:1:曲线图,2:季节性图,3:面积图,4:柱状图,5:散点图,6:组合图,7:柱方图,8:商品价格曲线图,9:相关性图"`
  78. LatestDate string `description:"数据最新日期"`
  79. LatestValue float64 `description:"数据最新值"`
  80. MoveLatestDate string `description:"移动后的数据最新日期"`
  81. UniqueCode string `description:"指标唯一编码"`
  82. MinValue float64 `json:"-" description:"最小值"`
  83. MaxValue float64 `json:"-" description:"最大值"`
  84. DataList interface{}
  85. IsNullData bool `json:"-" description:"是否空数据"`
  86. MappingSource int `description:"1:ETA图库;2:商品价格曲线"`
  87. RegionType string `description:"交易所来源,海外还是国内" json:"-"`
  88. ClassifyId int `description:"分类id"`
  89. SubSourceName string `description:"子数据来源名称"`
  90. IndicatorCode string `description:"指标代码"`
  91. IsConvert int `description:"是否数据转换 0不转 1转"`
  92. ConvertType int `description:"数据转换类型 1乘 2除 3对数"`
  93. ConvertValue float64 `description:"数据转换值"`
  94. ConvertUnit string `description:"数据转换单位"`
  95. ConvertEnUnit string `description:"数据转换单位"`
  96. IsJoinPermission int `description:"是否加入权限管控,0:不加入;1:加入;默认:0"`
  97. HaveOperaAuth bool `description:"是否有数据权限,默认:false"`
  98. UniqueFlag string `description:"唯一标识(与唯一编码不是一个东西)"`
  99. }
  100. // GetChartEdbMappingByEdbInfoId 根据指标id获取edb_mapping
  101. func GetChartEdbMappingByEdbInfoId(edbInfoId int) (item *ChartEdbInfoMapping, err error) {
  102. o := orm.NewOrm()
  103. sql := ` SELECT edb_info_id,source_name,classify_id,source,sub_source,edb_code,edb_name,edb_name_en,frequency,unit,unit_en,start_date,end_date,modify_time,latest_date,latest_value,unique_code,edb_info_type AS edb_info_category_type,edb_type,max_value,min_value,is_join_permission
  104. FROM edb_info
  105. WHERE edb_info_id = ? limit 1`
  106. err = o.Raw(sql, edbInfoId).QueryRow(&item)
  107. return
  108. }