excel_chart_edb.go 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. package excel
  2. import (
  3. "eta/eta_chart_lib/utils"
  4. "github.com/beego/beego/v2/client/orm"
  5. "time"
  6. )
  7. type ExcelChartEdb struct {
  8. ExcelChartEdbId int `orm:"column(excel_chart_edb_id);pk"`
  9. ExcelInfoId int `description:"表格id"`
  10. ChartInfoId int `description:"图表id"`
  11. EdbCode string `description:"指标编码"`
  12. EdbName string `description:"指标名称"`
  13. DateSequence string `description:"日期序列选区"`
  14. DataSequence string `description:"数据序列选区"`
  15. SysUserId int `description:"创建人"`
  16. SysUserRealName string `description:"创建人姓名"`
  17. MaxData float64 `description:"上限"`
  18. MinData float64 `description:"下限"`
  19. IsOrder bool `description:"true:正序,false:逆序"`
  20. IsAxis int `description:"true:左轴,false:右轴"`
  21. EdbInfoType int `description:"true:标准指标,false:领先指标"`
  22. LeadValue int `description:"领先值"`
  23. LeadUnit string `description:"领先单位"`
  24. FromTag string `description:"标签"`
  25. ModifyTime time.Time `description:"修改时间"`
  26. CreateTime time.Time `description:"创建时间"`
  27. }
  28. type ExcelChartEdbView struct {
  29. ExcelChartEdbId int
  30. ExcelInfoId int `description:"表格id"`
  31. ChartInfoId int `description:"图表id"`
  32. EdbCode string `description:"指标编码"`
  33. EdbName string `description:"指标名称"`
  34. DateSequenceStr string `description:"日期序列选区"`
  35. DataSequenceStr string `description:"数据序列选区"`
  36. /*MaxData float64 `description:"上限"`
  37. MinData float64 `description:"下限"`
  38. IsOrder bool `description:"true:正序,false:逆序"`
  39. IsAxis int `description:"true:左轴,false:右轴"`
  40. EdbInfoType int `description:"true:标准指标,false:领先指标"`
  41. LeadValue int `description:"领先值"`
  42. LeadUnit string `description:"领先单位"`*/
  43. FromTag string `description:"标签"`
  44. }
  45. type BalanceTableChart struct {
  46. ChartInfoId int `description:"图表id,新增时传0"`
  47. ChartName string `description:"图表名称"`
  48. ChartType int `description:"生成样式:1:曲线图,2:季节性图,3:面积图,4:柱状图,5:散点图,6:组合图,7:柱方图"`
  49. Calendar string `description:"公历/农历"`
  50. LeftMin string `description:"图表左侧最小值"`
  51. LeftMax string `description:"图表左侧最大值"`
  52. RightMin string `description:"图表右侧最小值"`
  53. RightMax string `description:"图表右侧最大值"`
  54. Right2Min string `description:"图表右侧2最小值"`
  55. Right2Max string `description:"图表右侧2最大值"`
  56. MinMaxSave int `description:"是否手动保存过上下限:0-否;1-是"`
  57. ExtraConfig string `description:"图表额外配置信息,json字符串"`
  58. ChartImage string `description:"封面图" json:"-"`
  59. SeasonExtraConfig string `description:"季节性图表中的配置,json数据"`
  60. SourcesFrom string `description:"图表来源"`
  61. // ChartEdbInfoList []ExcelChartEdbView
  62. }
  63. func (e *ExcelChartEdb) TableName() string {
  64. return "excel_chart_edb"
  65. }
  66. // 新增
  67. func (e *ExcelChartEdb) Add() (err error) {
  68. o := orm.NewOrmUsingDB("data")
  69. _, err = o.Insert(e)
  70. return
  71. }
  72. // 修改
  73. func (e *ExcelChartEdb) Update(cols []string) (err error) {
  74. o := orm.NewOrmUsingDB("data")
  75. _, err = o.Update(e, cols...)
  76. return
  77. }
  78. // 删除
  79. func (e *ExcelChartEdb) Delete() (err error) {
  80. o := orm.NewOrmUsingDB("data")
  81. _, err = o.Delete(e)
  82. return
  83. }
  84. type AddChartEdbAndDataItem struct {
  85. ChartEdb *ExcelChartEdb
  86. DateList []string `description:"日期列表"`
  87. ValList []float64 `description:"数据列表"`
  88. }
  89. func GetExcelChartEdbMappingByExcelInfoId(excelInfoId int) (list []*ExcelChartEdb, err error) {
  90. o := orm.NewOrmUsingDB("data")
  91. sql := ` SELECT *
  92. FROM excel_chart_edb
  93. WHERE excel_info_id=?
  94. ORDER BY excel_chart_edb_id ASC `
  95. _, err = o.Raw(sql, excelInfoId).QueryRows(&list)
  96. return
  97. }
  98. func GetExcelChartEdbMappingByExcelInfoIds(excelInfoIds []int) (list []*ExcelChartEdb, err error) {
  99. o := orm.NewOrmUsingDB("data")
  100. sql := ` SELECT *
  101. FROM excel_chart_edb
  102. WHERE excel_info_id in (` + utils.GetOrmInReplace(len(excelInfoIds)) + `)`
  103. _, err = o.Raw(sql, excelInfoIds).QueryRows(&list)
  104. return
  105. }
  106. func GetExcelChartEdbById(id int) (item *ExcelChartEdb, err error) {
  107. o := orm.NewOrmUsingDB("data")
  108. sql := ` SELECT * FROM excel_chart_edb WHERE excel_chart_edb_id=? `
  109. err = o.Raw(sql, id).QueryRow(&item)
  110. return
  111. }
  112. func GetExcelChartEdbMappingByChartInfoId(chartInfoId int) (list []*ExcelChartEdb, err error) {
  113. o := orm.NewOrmUsingDB("data")
  114. sql := ` SELECT *
  115. FROM excel_chart_edb
  116. WHERE chart_info_id=?
  117. ORDER BY excel_chart_edb_id ASC `
  118. _, err = o.Raw(sql, chartInfoId).QueryRows(&list)
  119. return
  120. }
  121. func GetExcelInfoByChartInfoId(chartInfoId int) (item *ExcelInfo, err error) {
  122. o := orm.NewOrmUsingDB("data")
  123. sql := ` SELECT i.*
  124. FROM excel_chart_edb e left join excel_info i on e.excel_info_id=i.excel_info_id
  125. WHERE e.chart_info_id=? limit 1`
  126. err = o.Raw(sql, chartInfoId).QueryRow(&item)
  127. return
  128. }