123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- package chart_info
- import (
- "hongze/hongze_yb/global"
- "time"
- )
- type ChartInfoView struct {
- ChartInfoId int `description:"图表ID"`
- ChartName string `description:"来源名称"`
- ChartClassifyId int `description:"图表分类id"`
- ChartClassifyName string `description:"图表名称"`
- SysUserId int
- SysUserRealName string
- UniqueCode string `description:"图表唯一编码"`
- CreateTime time.Time `json:"-"`
- ModifyTime time.Time `json:"-"`
- 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:"我的图表分类,多个用逗号隔开"`
- EdbEndDate 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-是"`
- ChartSource string `description:"图表来源str"`
- ChartSourceEn string `description:"图表来源(英文)"`
- BarConfig string `description:"柱方图的配置,json数据" json:"-"`
- ChartNameEn string `description:"英文图表名称"`
- Unit string `description:"中文单位名称"`
- UnitEn string `description:"英文单位名称"`
- Source int `description:"1:ETA图库;2:商品价格"`
- ExtraConfig string `description:"图表额外配置,json数据"`
- //ChartClassify []*chart_classify.ChartClassifyView
- SeasonExtraConfig string `description:"季节性图表中的配置,json数据"`
- StartYear int `description:"当选择的日期类型为最近N年类型时,即date_type=20, 用start_year表示N"`
- ChartThemeId int `description:"图表应用主题ID"`
- ChartThemeStyle string `description:"图表应用主题样式"`
- SourcesFrom string `description:"图表来源"`
- Instructions string `description:"图表说明"`
- MarkersLines string `description:"标识线"`
- MarkersAreas string `description:"标识区"`
- }
- type SaveChartInfoReq struct {
- ChartEdbInfoList []*ChartSaveItem `description:"指标及配置信息"`
- ChartInfoId int `description:"图表id,新增时传0"`
- DateType int `description:"日期类型:1:00年至今,2:10年至今,3:15年至今,4:年初至今,5:自定义时间,6:起始日期至今"`
- StartDate string `description:"自定义开始日期"`
- EndDate string `description:"自定义结束日期"`
- Calendar string `description:"公历/农历"`
- SeasonStartDate string `description:"季节性图开始日期"`
- SeasonEndDate string `description:"季节性图开始日期"`
- LeftMin string `description:"图表左侧最小值"`
- LeftMax string `description:"图表左侧最大值"`
- RightMin string `description:"图表右侧最小值"`
- RightMax string `description:"图表右侧最大值"`
- ExtraConfig string `description:"图表额外配置信息,json字符串"`
- }
- type ChartSaveItem struct {
- EdbInfoId int `description:"指标id"`
- MaxData float64 `description:"上限"`
- MinData float64 `description:"下限"`
- IsOrder bool `description:"true:正序,false:逆序"`
- IsAxis int `description:"1:左轴,0:右轴"`
- EdbInfoType int `description:"1:标准指标,0:领先指标"`
- LeadValue int `description:"领先值"`
- LeadUnit string `description:"领先单位"`
- ChartStyle string `description:"图表类型"`
- ChartColor string `description:"颜色"`
- ChartWidth float64 `description:"线条大小"`
- Source int `description:"1:ETA图库;2:商品价格"`
- }
- type ChartSortInfo struct {
- ChartInfoId int `description:"图表ID"`
- ChartInfoSource int `description:"1:ETA图库;2:商品价格"`
- MyChartId int `description:"我的图表ID"`
- MyChartClassifyId int `description:"我的图表分类ID"`
- MyChartClassifyName string `description:"我的图表分类名称"`
- UniqueCode string `description:"图表唯一编码"`
- Sort int `description:"排序"`
- Switch int `description:"是否切换 0-未切换 1-已切换"`
- //SwitchTips string `description:"切换分类提示信息"`
- }
- type ChartBeforeNext struct {
- PrevChart ChartSortInfo
- NextChart ChartSortInfo
- }
- type RefreshChartInfoReq struct {
- ChartInfoId int
- }
- // GetChartInfoViewById 通过Id获取图表展示信息
- func GetChartInfoViewById(chartInfoId int) (item *ChartInfoView, err error) {
- sql := `SELECT * FROM chart_info WHERE chart_info_id = ? `
- err = global.MYSQL["data"].Raw(sql, chartInfoId).First(&item).Error
- //err = global.MYSQL["data"].Model(ChartInfo{}).Where("chart_info_id = ?", chartInfoId).First(&item).Error
- return
- }
- // GetChartInfoViewById 通过ID获取图表数据库信息
- func GetChartInfoById(chartInfoId int) (item *ChartInfo, err error) {
- err = global.MYSQL["data"].Model(ChartInfo{}).Where("chart_info_id = ?", chartInfoId).First(&item).Error
- return
- }
- // GetChartInfoViewByUniqueCode 通过唯一编码获取图表展示信息
- func GetChartInfoViewByUniqueCode(uniqueCode string) (item *ChartInfoView, err error) {
- sql := `SELECT * FROM chart_info WHERE unique_code = ? LIMIT 1`
- err = global.MYSQL["data"].Raw(sql, uniqueCode).First(&item).Error
- return
- }
- type ChartSectionSeriesValSortAsc []ChartSectionSeriesValSort
- type ChartSectionSeriesValSortDesc []ChartSectionSeriesValSort
- type ChartSectionSeriesValSort struct {
- Index int
- Value float64
- }
- func (s ChartSectionSeriesValSortAsc) Len() int {
- return len(s)
- }
- func (s ChartSectionSeriesValSortAsc) Less(i, j int) bool {
- return s[i].Value < s[j].Value // 升序排序,如果想要降序则改为 s[i].Value > s[j].Value
- }
- func (s ChartSectionSeriesValSortAsc) Swap(i, j int) {
- s[i], s[j] = s[j], s[i]
- }
- func (s ChartSectionSeriesValSortDesc) Len() int {
- return len(s)
- }
- func (s ChartSectionSeriesValSortDesc) Less(i, j int) bool {
- return s[i].Value > s[j].Value // 升序排序,如果想要降序则改为 s[i].Value > s[j].Value
- }
- func (s ChartSectionSeriesValSortDesc) Swap(i, j int) {
- s[i], s[j] = s[j], s[i]
- }
|