|
@@ -0,0 +1,451 @@
|
|
|
|
+package data_manage
|
|
|
|
+
|
|
|
|
+import (
|
|
|
|
+ "eta/eta_hub/utils"
|
|
|
|
+ "fmt"
|
|
|
|
+ "github.com/beego/beego/v2/client/orm"
|
|
|
|
+ "strings"
|
|
|
|
+ "time"
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+type ChartInfo struct {
|
|
|
|
+ ChartInfoId int `orm:"column(chart_info_id);pk"`
|
|
|
|
+ ChartName string `description:"来源名称"`
|
|
|
|
+ ChartNameEn string `description:"英文图表名称"`
|
|
|
|
+ ChartClassifyId int `description:"图表分类id"`
|
|
|
|
+ SysUserId int `description:"创建人ID"`
|
|
|
|
+ SysUserRealName string `description:"创建人姓名"`
|
|
|
|
+ UniqueCode string `description:"图表唯一编码"`
|
|
|
|
+ DateType int `description:"日期类型:1:00年至今,2:10年至今,3:15年至今,4:年初至今,5:自定义时间"`
|
|
|
|
+ StartDate string `description:"自定义开始日期"`
|
|
|
|
+ EndDate string `description:"自定义结束日期"`
|
|
|
|
+ IsSetName int `description:"设置名称"`
|
|
|
|
+ EdbInfoIds string `description:"指标id"`
|
|
|
|
+ ChartType int `description:"生成样式:1:曲线图,2:季节性图,3:面积图,4:柱状图,5:散点图,6:组合图,7:柱方图,8:商品价格曲线图,9:相关性图"`
|
|
|
|
+ Calendar string `description:"公历/农历"`
|
|
|
|
+ SeasonStartDate string `description:"季节性图开始日期"`
|
|
|
|
+ SeasonEndDate string `description:"季节性图开始日期"`
|
|
|
|
+ ChartImage string `description:"图表图片"`
|
|
|
|
+ Sort int `description:"排序字段,数字越小越排前面"`
|
|
|
|
+ LeftMin string `description:"图表左侧最小值"`
|
|
|
|
+ LeftMax string `description:"图表左侧最大值"`
|
|
|
|
+ RightMin string `description:"图表右侧最小值"`
|
|
|
|
+ RightMax string `description:"图表右侧最大值"`
|
|
|
|
+ Disabled int `description:"是否禁用,0:启用,1:禁用,默认:0"`
|
|
|
|
+ BarConfig string `description:"柱方图的配置,json数据"`
|
|
|
|
+ Source int `description:"1:ETA图库;2:商品价格曲线"`
|
|
|
|
+ ExtraConfig string `description:"图表额外配置,json数据"`
|
|
|
|
+ SeasonExtraConfig string `description:"季节性图表中的配置,json数据"`
|
|
|
|
+ StartYear int `description:"当选择的日期类型为最近N年类型时,即date_type=20, 用start_year表示N"`
|
|
|
|
+ CreateTime time.Time `description:"创建时间"`
|
|
|
|
+ ModifyTime time.Time `description:"更新时间"`
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (m *ChartInfo) GetItemsByCondition(cond string, pars []interface{}, fieldArr []string, orderRule string) (items []*ChartInfo, err error) {
|
|
|
|
+ o := orm.NewOrmUsingDB("data")
|
|
|
|
+ fields := strings.Join(fieldArr, ",")
|
|
|
|
+ if len(fieldArr) == 0 {
|
|
|
|
+ fields = `*`
|
|
|
|
+ }
|
|
|
|
+ order := `ORDER BY create_time DESC`
|
|
|
|
+ if orderRule != "" {
|
|
|
|
+ order = ` ORDER BY ` + orderRule
|
|
|
|
+ }
|
|
|
|
+ sql := fmt.Sprintf(`SELECT %s FROM chart_info WHERE 1=1 %s %s`, fields, cond, order)
|
|
|
|
+ _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (m *ChartInfo) GetItemByCode(code string) (item *ChartInfo, err error) {
|
|
|
|
+ o := orm.NewOrmUsingDB("data")
|
|
|
|
+ sql := fmt.Sprintf(`SELECT * FROM chart_info WHERE unique_code = ? LIMIT 1`)
|
|
|
|
+ err = o.Raw(sql, code).QueryRow(&item)
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+type ChartInfoItem struct {
|
|
|
|
+ ChartInfoId int `description:"图表ID"`
|
|
|
|
+ ChartName string `description:"来源名称"`
|
|
|
|
+ ChartNameEn string `description:"英文图表名称"`
|
|
|
|
+ ChartClassifyId int `description:"图表分类id"`
|
|
|
|
+ UniqueCode string `description:"图表唯一编码"`
|
|
|
|
+ DateType int `description:"日期类型:1:00年至今,2:10年至今,3:15年至今,4:年初至今,5:自定义时间" json:"-"`
|
|
|
|
+ StartDate string `description:"自定义开始日期"`
|
|
|
|
+ EndDate string `description:"自定义结束日期"`
|
|
|
|
+ ChartType int `description:"生成样式:1:曲线图,2:季节性图,3:面积图,4:柱状图,5:散点图,6:组合图,7:柱方图,8:商品价格曲线图,9:相关性图"`
|
|
|
|
+ Calendar string `description:"公历/农历"`
|
|
|
|
+ SeasonStartDate string `description:"季节性图开始日期" json:"-"`
|
|
|
|
+ SeasonEndDate string `description:"季节性图开始日期" json:"-"`
|
|
|
|
+ ChartImage string `description:"图表图片"`
|
|
|
|
+ Sort int `description:"排序字段,数字越小越排前面"`
|
|
|
|
+ LeftMin string `description:"图表左侧最小值" json:"-"`
|
|
|
|
+ LeftMax string `description:"图表左侧最大值" json:"-"`
|
|
|
|
+ RightMin string `description:"图表右侧最小值" json:"-"`
|
|
|
|
+ RightMax string `description:"图表右侧最大值" json:"-"`
|
|
|
|
+ BarConfig string `description:"柱方图的配置,json数据" json:"-"`
|
|
|
|
+ Source int `description:"1:ETA图库;2:商品价格曲线" json:"-"`
|
|
|
|
+ ExtraConfig string `description:"图表额外配置,json数据" json:"-"`
|
|
|
|
+ SeasonExtraConfig string `description:"季节性图表中的配置,json数据" json:"-"`
|
|
|
|
+ StartYear int `description:"当选择的日期类型为最近N年类型时,即date_type=20, 用start_year表示N" json:"-"`
|
|
|
|
+ CreateTime string `description:"创建时间"`
|
|
|
|
+ ModifyTime string `description:"更新时间"`
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func FormatChartInfo2Item(origin *ChartInfo) (item *ChartInfoItem) {
|
|
|
|
+ if origin == nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ item = new(ChartInfoItem)
|
|
|
|
+ item.ChartInfoId = origin.ChartInfoId
|
|
|
|
+ item.ChartName = origin.ChartName
|
|
|
|
+ item.ChartNameEn = origin.ChartNameEn
|
|
|
|
+ item.ChartClassifyId = origin.ChartClassifyId
|
|
|
|
+ item.UniqueCode = origin.UniqueCode
|
|
|
|
+ item.DateType = origin.DateType
|
|
|
|
+ item.StartDate = origin.StartDate
|
|
|
|
+ item.EndDate = origin.EndDate
|
|
|
|
+ item.ChartType = origin.ChartType
|
|
|
|
+ item.Calendar = origin.Calendar
|
|
|
|
+ item.SeasonStartDate = origin.SeasonStartDate
|
|
|
|
+ item.SeasonEndDate = origin.SeasonEndDate
|
|
|
|
+ item.ChartImage = origin.ChartImage
|
|
|
|
+ item.Sort = origin.Sort
|
|
|
|
+ item.LeftMin = origin.LeftMin
|
|
|
|
+ item.LeftMax = origin.LeftMax
|
|
|
|
+ item.RightMin = origin.RightMin
|
|
|
|
+ item.RightMax = origin.RightMax
|
|
|
|
+ item.BarConfig = origin.BarConfig
|
|
|
|
+ item.Source = origin.Source
|
|
|
|
+ item.ExtraConfig = origin.ExtraConfig
|
|
|
|
+ item.SeasonExtraConfig = origin.SeasonExtraConfig
|
|
|
|
+ item.StartYear = origin.StartYear
|
|
|
|
+ item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
|
|
|
|
+ item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime)
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+type ChartInfoDetailResp struct {
|
|
|
|
+ ChartInfo *ChartInfo `description:"图表信息"`
|
|
|
|
+ Status bool `description:"true:图表存在,false:图表不存在" json:"-"`
|
|
|
|
+ EdbInfoList []*ChartEdbInfoMapping `description:"指标信息"`
|
|
|
|
+ XEdbIdValue []int `description:"柱方图的x轴数据,指标id"`
|
|
|
|
+ YDataList []YData `description:"柱方图的y轴数据"`
|
|
|
|
+ XDataList []XData `description:"商品价格曲线的X轴数据"`
|
|
|
|
+ BarChartInfo BarChartInfoReq `description:"柱方图的配置"`
|
|
|
|
+ CorrelationChartInfo *CorrelationInfo `description:"相关性图表信息"`
|
|
|
|
+ DataResp interface{} `description:"图表数据,根据图的类型而定的,没有确定的数据格式"`
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+type XData struct {
|
|
|
|
+ Name string `description:"别名"`
|
|
|
|
+ NameEn string `description:"英文别名"`
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+type YData struct {
|
|
|
|
+ Date string `description:"数据日期"`
|
|
|
|
+ ConfigDate time.Time `description:"配置的日期" json:"-"`
|
|
|
|
+ Color string `description:"数据颜色"`
|
|
|
|
+ Name string `description:"别名"`
|
|
|
|
+ NameEn string `description:"英文别名"`
|
|
|
|
+ Value []float64 `description:"每个指标的值"`
|
|
|
|
+ NoDataEdbList []int `description:"没有数据的指标列表"`
|
|
|
|
+ XEdbInfoIdList []int `description:"对应X轴的指标id列表"`
|
|
|
|
+ NameList []string `description:"每个值对应的名称"`
|
|
|
|
+ EnNameList []string `description:"每个值对应的英文名称"`
|
|
|
|
+ EdbValMap map[int]float64 `description:"指标与值的对应" json:"-"`
|
|
|
|
+ M []int `description:"对应开始日期的间隔值" json:"-"`
|
|
|
|
+ Unit string `description:"中文单位名称"`
|
|
|
|
+ UnitEn string `description:"英文单位名称"`
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+type BarChartInfoReq struct {
|
|
|
|
+ EdbInfoIdList []BarChartInfoEdbItemReq `description:"指标信息"`
|
|
|
|
+ DateList []BarChartInfoDateReq `description:"日期配置"`
|
|
|
|
+ Sort BarChartInfoSortReq `description:"排序"`
|
|
|
|
+ XEdbList []BarChartInfoEdbItemReq `description:"X轴选择的指标列表"`
|
|
|
|
+ YEdbList []BarChartInfoEdbItemReq `description:"Y轴选择的指标列表"`
|
|
|
|
+ Unit string `description:"中文单位"`
|
|
|
|
+ UnitEn string `description:"英文单位"`
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+type BarChartInfoEdbItemReq struct {
|
|
|
|
+ EdbInfoId int `description:"指标ID"`
|
|
|
|
+ Name string `description:"别名"`
|
|
|
|
+ NameEn string `description:"英文别名"`
|
|
|
|
+ Source int `description:"1:ETA图库;2:商品价格"`
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+type BarChartInfoDateReq struct {
|
|
|
|
+ Type int `description:"配置类型"`
|
|
|
|
+ Date string `description:"固定日期"`
|
|
|
|
+ Value int `description:"N天的值"`
|
|
|
|
+ Color string `description:"颜色"`
|
|
|
|
+ Name string `description:"别名"`
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+type BarChartInfoSortReq struct {
|
|
|
|
+ Sort int `description:"排序类型,0:默认,1:升序,2:降序"`
|
|
|
|
+ DateIndex int `description:"日期数据的下标,从0开始"`
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+type CorrelationInfo struct {
|
|
|
|
+ LeadValue int `description:"领先值"`
|
|
|
|
+ LeadUnit string `description:"领先单位"`
|
|
|
|
+ CalculateValue int `description:"计算窗口"`
|
|
|
|
+ CalculateUnit string `description:"计算频度"`
|
|
|
|
+ StartDate string `description:"开始日期"`
|
|
|
|
+ EndDate string `description:"结束日期"`
|
|
|
|
+ EdbInfoIdFirst int `description:"A指标ID"`
|
|
|
|
+ EdbInfoIdSecond int `description:"B指标ID"`
|
|
|
|
+ PeriodData string `description:"X轴-期数数据"`
|
|
|
|
+ CorrelationData string `description:"Y轴-相关性系数"`
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+type ChartInfoView struct {
|
|
|
|
+ ChartInfoId int `orm:"column(chart_info_id);pk"`
|
|
|
|
+ ChartName string `description:"来源名称"`
|
|
|
|
+ ChartNameEn string `description:"英文图表名称"`
|
|
|
|
+ Unit string `description:"中文单位名称"`
|
|
|
|
+ UnitEn string `description:"英文单位名称"`
|
|
|
|
+ ChartClassifyId int `description:"图表分类id"`
|
|
|
|
+ ChartClassifyName string `description:"图表名称"`
|
|
|
|
+ SysUserId int
|
|
|
|
+ SysUserRealName string
|
|
|
|
+ UniqueCode string `description:"图表唯一编码"`
|
|
|
|
+ CreateTime time.Time
|
|
|
|
+ ModifyTime time.Time
|
|
|
|
+ DateType int `description:"日期类型:1:00年至今,2:10年至今,3:15年至今,4:年初至今,5:自定义时间"`
|
|
|
|
+ StartDate string `description:"自定义开始日期"`
|
|
|
|
+ EndDate string `description:"自定义结束日期"`
|
|
|
|
+ IsSetName int `description:"设置名称"`
|
|
|
|
+ EdbInfoIds string `description:"指标id"`
|
|
|
|
+ ChartType int `description:"生成样式:1:曲线图,2:季节性图"`
|
|
|
|
+ Calendar string `description:"公历/农历"`
|
|
|
|
+ SeasonStartDate string `description:"季节性图开始日期"`
|
|
|
|
+ SeasonEndDate string `description:"季节性图开始日期"`
|
|
|
|
+ ChartImage string `description:"图表图片"`
|
|
|
|
+ Sort int `description:"排序字段,数字越小越排前面"`
|
|
|
|
+ IsAdd bool `description:"true:已加入我的图库,false:未加入我的图库"`
|
|
|
|
+ MyChartId int
|
|
|
|
+ MyChartClassifyId string `description:"我的图表分类,多个用逗号隔开"`
|
|
|
|
+ ChartClassify []*ChartClassifyView
|
|
|
|
+ EdbEndDate string `description:"指标最新更新日期"`
|
|
|
|
+ LeftMin string `description:"图表左侧最小值"`
|
|
|
|
+ LeftMax string `description:"图表左侧最大值"`
|
|
|
|
+ RightMin string `description:"图表右侧最小值"`
|
|
|
|
+ RightMax string `description:"图表右侧最大值"`
|
|
|
|
+ IsEdit bool `description:"是否有编辑权限"`
|
|
|
|
+ IsEnChart bool `description:"是否展示英文标识"`
|
|
|
|
+ WarnMsg string `description:"错误信息"`
|
|
|
|
+ Disabled int `description:"是否禁用,0:启用,1:禁用,默认:0"`
|
|
|
|
+ BarConfig string `description:"柱方图的配置,json数据" json:"-"`
|
|
|
|
+ Source int `description:"1:ETA图库;2:商品价格曲线;3:相关性图表"`
|
|
|
|
+
|
|
|
|
+ ExtraConfig string `description:"图表额外配置,json数据"`
|
|
|
|
+ Button ChartViewButton `description:"操作按钮" json:"-"`
|
|
|
|
+ SeasonExtraConfig string `description:"季节性图表中的配置,json数据"`
|
|
|
|
+ StartYear int `description:"当选择的日期类型为最近N年类型时,即date_type=20, 用start_year表示N"`
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+type ChartViewButton struct {
|
|
|
|
+ IsEdit bool `description:"是否有编辑权限"`
|
|
|
|
+ IsEnChart bool `description:"是否展示英文标识"`
|
|
|
|
+ IsAdd bool `description:"true:已加入我的图库,false:未加入我的图库"`
|
|
|
|
+ IsCopy bool `description:"是否有另存为按钮"`
|
|
|
|
+ IsSetName int `description:"设置名称"`
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|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