123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- package excel
- import (
- "eta/eta_chart_lib/utils"
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type ExcelChartEdb struct {
- ExcelChartEdbId int `orm:"column(excel_chart_edb_id);pk"`
- ExcelInfoId int `description:"表格id"`
- ChartInfoId int `description:"图表id"`
- EdbCode string `description:"指标编码"`
- EdbName string `description:"指标名称"`
- DateSequence string `description:"日期序列选区"`
- DataSequence string `description:"数据序列选区"`
- SysUserId int `description:"创建人"`
- SysUserRealName string `description:"创建人姓名"`
- MaxData float64 `description:"上限"`
- MinData float64 `description:"下限"`
- IsOrder bool `description:"true:正序,false:逆序"`
- IsAxis int `description:"true:左轴,false:右轴"`
- EdbInfoType int `description:"true:标准指标,false:领先指标"`
- LeadValue int `description:"领先值"`
- LeadUnit string `description:"领先单位"`
- FromTag string `description:"标签"`
- ModifyTime time.Time `description:"修改时间"`
- CreateTime time.Time `description:"创建时间"`
- }
- type ExcelChartEdbView struct {
- ExcelChartEdbId int
- ExcelInfoId int `description:"表格id"`
- ChartInfoId int `description:"图表id"`
- EdbCode string `description:"指标编码"`
- EdbName string `description:"指标名称"`
- DateSequenceStr string `description:"日期序列选区"`
- DataSequenceStr string `description:"数据序列选区"`
- /*MaxData float64 `description:"上限"`
- MinData float64 `description:"下限"`
- IsOrder bool `description:"true:正序,false:逆序"`
- IsAxis int `description:"true:左轴,false:右轴"`
- EdbInfoType int `description:"true:标准指标,false:领先指标"`
- LeadValue int `description:"领先值"`
- LeadUnit string `description:"领先单位"`*/
- FromTag string `description:"标签"`
- }
- type BalanceTableChart struct {
- ChartInfoId int `description:"图表id,新增时传0"`
- ChartName string `description:"图表名称"`
- ChartType int `description:"生成样式:1:曲线图,2:季节性图,3:面积图,4:柱状图,5:散点图,6:组合图,7:柱方图"`
- Calendar string `description:"公历/农历"`
- LeftMin string `description:"图表左侧最小值"`
- LeftMax string `description:"图表左侧最大值"`
- RightMin string `description:"图表右侧最小值"`
- RightMax string `description:"图表右侧最大值"`
- Right2Min string `description:"图表右侧2最小值"`
- Right2Max string `description:"图表右侧2最大值"`
- MinMaxSave int `description:"是否手动保存过上下限:0-否;1-是"`
- ExtraConfig string `description:"图表额外配置信息,json字符串"`
- ChartImage string `description:"封面图" json:"-"`
- SeasonExtraConfig string `description:"季节性图表中的配置,json数据"`
- SourcesFrom string `description:"图表来源"`
- // ChartEdbInfoList []ExcelChartEdbView
- }
- func (e *ExcelChartEdb) TableName() string {
- return "excel_chart_edb"
- }
- // 新增
- func (e *ExcelChartEdb) Add() (err error) {
- o := orm.NewOrmUsingDB("data")
- _, err = o.Insert(e)
- return
- }
- // 修改
- func (e *ExcelChartEdb) Update(cols []string) (err error) {
- o := orm.NewOrmUsingDB("data")
- _, err = o.Update(e, cols...)
- return
- }
- // 删除
- func (e *ExcelChartEdb) Delete() (err error) {
- o := orm.NewOrmUsingDB("data")
- _, err = o.Delete(e)
- return
- }
- type AddChartEdbAndDataItem struct {
- ChartEdb *ExcelChartEdb
- DateList []string `description:"日期列表"`
- ValList []float64 `description:"数据列表"`
- }
- func GetExcelChartEdbMappingByExcelInfoId(excelInfoId int) (list []*ExcelChartEdb, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := ` SELECT *
- FROM excel_chart_edb
- WHERE excel_info_id=?
- ORDER BY excel_chart_edb_id ASC `
- _, err = o.Raw(sql, excelInfoId).QueryRows(&list)
- return
- }
- func GetExcelChartEdbMappingByExcelInfoIds(excelInfoIds []int) (list []*ExcelChartEdb, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := ` SELECT *
- FROM excel_chart_edb
- WHERE excel_info_id in (` + utils.GetOrmInReplace(len(excelInfoIds)) + `)`
- _, err = o.Raw(sql, excelInfoIds).QueryRows(&list)
- return
- }
- func GetExcelChartEdbById(id int) (item *ExcelChartEdb, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := ` SELECT * FROM excel_chart_edb WHERE excel_chart_edb_id=? `
- err = o.Raw(sql, id).QueryRow(&item)
- return
- }
- func GetExcelChartEdbMappingByChartInfoId(chartInfoId int) (list []*ExcelChartEdb, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := ` SELECT *
- FROM excel_chart_edb
- WHERE chart_info_id=?
- ORDER BY excel_chart_edb_id ASC `
- _, err = o.Raw(sql, chartInfoId).QueryRows(&list)
- return
- }
- func GetExcelInfoByChartInfoId(chartInfoId int) (item *ExcelInfo, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := ` SELECT i.*
- FROM excel_chart_edb e left join excel_info i on e.excel_info_id=i.excel_info_id
- WHERE e.chart_info_id=? limit 1`
- err = o.Raw(sql, chartInfoId).QueryRow(&item)
- return
- }
|