chart_edb_mapping.go 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. package data_manage
  2. import (
  3. "eta_gn/eta_task/global"
  4. "time"
  5. )
  6. type ChartEdbMapping struct {
  7. ChartEdbMappingId int `gorm:"column:chart_edb_mapping_id;primaryKey"` // `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. PredictChartColor string `description:"预测数据的颜色"`
  23. ChartWidth float64 `description:"线条大小"`
  24. Source int `description:"1:ETA图库;2:商品价格曲线"`
  25. EdbAliasName string `description:"中文别名"`
  26. IsConvert int `description:"是否数据转换 0不转 1转"`
  27. ConvertType int `description:"数据转换类型 1乘 2除 3对数"`
  28. ConvertValue float64 `description:"数据转换值"`
  29. ConvertUnit string `description:"数据转换单位"`
  30. ConvertEnUnit string `description:"数据转换单位"`
  31. }
  32. func GetChartEdbMappingTotal() (total int, err error) {
  33. //o := orm.NewOrmUsingDB("data")
  34. sql := ` SELECT COUNT(1) AS count FROM chart_edb_mapping `
  35. //err = o.Raw(sql).QueryRow(&total)
  36. err = global.DmSQL["data"].Raw(sql).Scan(&total).Error
  37. return
  38. }
  39. func GetChartEdbMappingList(startSize, pageSize int) (items []*ChartEdbMapping, err error) {
  40. //o := orm.NewOrmUsingDB("data")
  41. sql := ` SELECT * FROM chart_edb_mapping WHERE 1=1 `
  42. sql += " LIMIT ?,? "
  43. //_, err = o.Raw(sql, startSize, pageSize).QueryRows(&items)
  44. err = global.DEFAULT_DmSQL.Raw(sql, startSize, pageSize).Find(&items).Error
  45. return
  46. }
  47. type ChartEdbInfoMapping struct {
  48. EdbInfoId int `description:"指标id"`
  49. SourceName string `description:"来源名称"`
  50. Source int `description:"来源id"`
  51. SubSource int `description:"来源id"`
  52. EdbCode string `description:"指标编码"`
  53. EdbName string `description:"指标名称"`
  54. EdbAliasName string `description:"指标名称(别名)"`
  55. EdbNameEn string `description:"英文指标名称"`
  56. EdbAliasNameEn string `description:"英文指标名称(别名)"`
  57. EdbType int `description:"指标类型:1:基础指标,2:计算指标"`
  58. Frequency string `description:"频率"`
  59. FrequencyEn string `description:"英文频率"`
  60. Unit string `description:"单位"`
  61. UnitEn string `description:"英文单位"`
  62. StartDate string `description:"起始日期"`
  63. EndDate string `description:"终止日期"`
  64. ModifyTime string `description:"指标最后更新时间"`
  65. ChartEdbMappingId int `description:"图表指标id"`
  66. ChartInfoId int `description:"图表id"`
  67. MaxData float64 `description:"上限"`
  68. MinData float64 `description:"下限"`
  69. IsOrder bool `description:"true:正序,false:逆序"`
  70. IsAxis int `description:"1:左轴,0:右轴"`
  71. EdbInfoType int `description:"1:标准指标,0:领先指标"`
  72. EdbInfoCategoryType int `description:"0:普通指标,1:预测指标"`
  73. LeadValue int `description:"领先值"`
  74. LeadUnit string `description:"领先单位"`
  75. LeadUnitEn string `description:"领先英文单位"`
  76. ChartStyle string `description:"图表类型"`
  77. ChartColor string `description:"颜色"`
  78. PredictChartColor string `description:"预测数据的颜色"`
  79. ChartWidth float64 `description:"线条大小"`
  80. ChartType int `description:"生成样式:1:曲线图,2:季节性图,3:面积图,4:柱状图,5:散点图,6:组合图,7:柱方图,8:商品价格曲线图,9:相关性图"`
  81. LatestDate string `description:"数据最新日期"`
  82. LatestValue float64 `description:"数据最新值"`
  83. MoveLatestDate string `description:"移动后的数据最新日期"`
  84. UniqueCode string `description:"指标唯一编码"`
  85. MinValue float64 `json:"-" description:"最小值"`
  86. MaxValue float64 `json:"-" description:"最大值"`
  87. DataList interface{}
  88. IsNullData bool `json:"-" description:"是否空数据"`
  89. MappingSource int `description:"1:ETA图库;2:商品价格曲线"`
  90. RegionType string `description:"交易所来源,海外还是国内" json:"-"`
  91. ClassifyId int `description:"分类id"`
  92. SubSourceName string `description:"子数据来源名称"`
  93. IndicatorCode string `description:"指标代码"`
  94. IsConvert int `description:"是否数据转换 0不转 1转"`
  95. ConvertType int `description:"数据转换类型 1乘 2除 3对数"`
  96. ConvertValue float64 `description:"数据转换值"`
  97. ConvertUnit string `description:"数据转换单位"`
  98. ConvertEnUnit string `description:"数据转换单位"`
  99. IsJoinPermission int `description:"是否加入权限管控,0:不加入;1:加入;默认:0"`
  100. HaveOperaAuth bool `description:"是否有数据权限,默认:false"`
  101. }
  102. func GetRelationEdbInfoListMappingByCondition(condition string, pars []interface{}) (item []*ChartEdbInfoMapping, err error) {
  103. //o := orm.NewOrmUsingDB("data")
  104. sql := ` SELECT a.* FROM edb_info AS a
  105. JOIN edb_info_calculate_mapping AS b on a.edb_info_id = b.edb_info_id WHERE 1=1 `
  106. if condition != "" {
  107. sql += condition
  108. }
  109. //_, err = o.Raw(sql, pars).QueryRows(&item)
  110. err = global.DmSQL["data"].Raw(sql, pars...).Find(&item).Error
  111. return
  112. }