|
@@ -2,129 +2,240 @@ package models
|
|
|
|
|
|
import (
|
|
|
"errors"
|
|
|
+ "eta_gn/eta_chart_lib/global"
|
|
|
"eta_gn/eta_chart_lib/models/mgo"
|
|
|
"eta_gn/eta_chart_lib/utils"
|
|
|
"fmt"
|
|
|
"strconv"
|
|
|
"time"
|
|
|
|
|
|
- "github.com/beego/beego/v2/client/orm"
|
|
|
"go.mongodb.org/mongo-driver/bson"
|
|
|
|
|
|
"github.com/nosixtools/solarlunar"
|
|
|
)
|
|
|
|
|
|
+// type ChartInfo struct {
|
|
|
+// ChartInfoId int `json:"-" orm:"column(chart_info_id);pk"`
|
|
|
+// ChartName string `description:"来源名称"`
|
|
|
+// ChartNameEn string `description:"英文图表名称"`
|
|
|
+// ChartClassifyId int `json:"-" description:"图表分类id"`
|
|
|
+// SysUserId int `json:"-"`
|
|
|
+// SysUserRealName string `json:"-"`
|
|
|
+// 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:"图表图片"`
|
|
|
+// BarConfig string `description:"柱方图的配置,json数据" json:"-"`
|
|
|
+// XMin string `description:"图表X轴最小值"`
|
|
|
+// XMax string `description:"图表X轴最大值"`
|
|
|
+// 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-是"`
|
|
|
+// Source int `description:"1:ETA图库;2:商品价格曲线"`
|
|
|
+// Unit string `description:"中文单位名称"`
|
|
|
+// UnitEn string `description:"英文单位名称"`
|
|
|
+// ExtraConfig string `description:"图表额外配置,json数据" json:"-"`
|
|
|
+// ChartSource string `description:"图表来源str"`
|
|
|
+// ChartSourceEn string `description:"图表来源(英文)"`
|
|
|
+// 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 ChartInfo struct {
|
|
|
- ChartInfoId int `json:"-" orm:"column(chart_info_id);pk"`
|
|
|
- ChartName string `description:"来源名称"`
|
|
|
- ChartNameEn string `description:"英文图表名称"`
|
|
|
- ChartClassifyId int `json:"-" description:"图表分类id"`
|
|
|
- SysUserId int `json:"-"`
|
|
|
- SysUserRealName string `json:"-"`
|
|
|
- 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:"图表图片"`
|
|
|
- BarConfig string `description:"柱方图的配置,json数据" json:"-"`
|
|
|
- XMin string `description:"图表X轴最小值"`
|
|
|
- XMax string `description:"图表X轴最大值"`
|
|
|
- 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-是"`
|
|
|
- Source int `description:"1:ETA图库;2:商品价格曲线"`
|
|
|
- Unit string `description:"中文单位名称"`
|
|
|
- UnitEn string `description:"英文单位名称"`
|
|
|
- ExtraConfig string `description:"图表额外配置,json数据" json:"-"`
|
|
|
- ChartSource string `description:"图表来源str"`
|
|
|
- ChartSourceEn string `description:"图表来源(英文)"`
|
|
|
- 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:"标识区"`
|
|
|
+ ChartInfoId int `gorm:"column:chart_info_id;primaryKey" json:"-" orm:"column(chart_info_id);pk"`
|
|
|
+ ChartName string `gorm:"column:chart_name" description:"来源名称"`
|
|
|
+ ChartNameEn string `gorm:"column:chart_name_en" description:"英文图表名称"`
|
|
|
+ ChartClassifyId int `gorm:"column:chart_classify_id" json:"-" description:"图表分类id"`
|
|
|
+ SysUserId int `gorm:"column:sys_user_id" json:"-"`
|
|
|
+ SysUserRealName string `gorm:"column:sys_user_real_name" json:"-"`
|
|
|
+ UniqueCode string `gorm:"column:unique_code" description:"图表唯一编码"`
|
|
|
+ CreateTime time.Time `gorm:"column:create_time" json:"-"`
|
|
|
+ ModifyTime time.Time `gorm:"column:modify_time" json:"-"`
|
|
|
+ DateType int `gorm:"column:date_type" description:"日期类型:1:00年至今,2:10年至今,3:15年至今,4:年初至今,5:自定义时间"`
|
|
|
+ StartDate string `gorm:"column:start_date" description:"自定义开始日期"`
|
|
|
+ EndDate string `gorm:"column:end_date" description:"自定义结束日期"`
|
|
|
+ IsSetName int `gorm:"column:is_set_name" description:"设置名称"`
|
|
|
+ EdbInfoIds string `gorm:"column:edb_info_ids" description:"指标id"`
|
|
|
+ ChartType int `gorm:"column:chart_type" description:"生成样式:1:曲线图,2:季节性图"`
|
|
|
+ Calendar string `gorm:"column:calendar" description:"公历/农历"`
|
|
|
+ SeasonStartDate string `gorm:"column:season_start_date" description:"季节性图开始日期"`
|
|
|
+ SeasonEndDate string `gorm:"column:season_end_date" description:"季节性图结束日期"`
|
|
|
+ ChartImage string `gorm:"column:chart_image" description:"图表图片"`
|
|
|
+ BarConfig string `gorm:"column:bar_config" description:"柱方图的配置,json数据" json:"-"`
|
|
|
+ XMin string `gorm:"column:x_min" description:"图表X轴最小值"`
|
|
|
+ XMax string `gorm:"column:x_max" description:"图表X轴最大值"`
|
|
|
+ LeftMin string `gorm:"column:left_min" description:"图表左侧最小值"`
|
|
|
+ LeftMax string `gorm:"column:left_max" description:"图表左侧最大值"`
|
|
|
+ RightMin string `gorm:"column:right_min" description:"图表右侧最小值"`
|
|
|
+ RightMax string `gorm:"column:right_max" description:"图表右侧最大值"`
|
|
|
+ Right2Min string `gorm:"column:right2_min" description:"图表右侧2最小值"`
|
|
|
+ Right2Max string `gorm:"column:right2_max" description:"图表右侧2最大值"`
|
|
|
+ MinMaxSave int `gorm:"column:min_max_save" description:"是否手动保存过上下限:0-否;1-是"`
|
|
|
+ Source int `gorm:"column:source" description:"1:ETA图库;2:商品价格曲线"`
|
|
|
+ Unit string `gorm:"column:unit" description:"中文单位名称"`
|
|
|
+ UnitEn string `gorm:"column:unit_en" description:"英文单位名称"`
|
|
|
+ ExtraConfig string `gorm:"column:extra_config" description:"图表额外配置,json数据" json:"-"`
|
|
|
+ ChartSource string `gorm:"column:chart_source" description:"图表来源"`
|
|
|
+ ChartSourceEn string `gorm:"column:chart_source_en" description:"图表来源(英文)"`
|
|
|
+ SeasonExtraConfig string `gorm:"column:season_extra_config" description:"季节性图表中的配置,json数据"`
|
|
|
+ StartYear int `gorm:"column:start_year" description:"当选择的日期类型为最近N年类型时,即date_type=20,用start_year表示N"`
|
|
|
+ ChartThemeId int `gorm:"column:chart_theme_id" description:"图表应用主题ID"`
|
|
|
+ ChartThemeStyle string `gorm:"column:chart_theme_style" description:"图表应用主题样式"`
|
|
|
+ SourcesFrom string `gorm:"column:sources_from" description:"图表来源"`
|
|
|
+ Instructions string `gorm:"column:instructions" description:"图表说明"`
|
|
|
+ MarkersLines string `gorm:"column:markers_lines" description:"标识线"`
|
|
|
+ MarkersAreas string `gorm:"column:markers_areas" description:"标识区"`
|
|
|
+}
|
|
|
+
|
|
|
+func (c *ChartInfo) TableName() string {
|
|
|
+ return "chart_info"
|
|
|
}
|
|
|
|
|
|
func GetChartInfoByUniqueCode(uniqueCode string) (item *ChartInfo, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DmSQL["data"]
|
|
|
sql := ` SELECT * FROM chart_info WHERE unique_code=? `
|
|
|
- err = o.Raw(sql, uniqueCode).QueryRow(&item)
|
|
|
+ err = o.Raw(sql, uniqueCode).First(&item).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// func GetChartInfoByUniqueCode(uniqueCode string) (item *ChartInfo, err error) {
|
|
|
+// o := orm.NewOrmUsingDB("data")
|
|
|
+// sql := ` SELECT * FROM chart_info WHERE unique_code=? `
|
|
|
+// err = o.Raw(sql, uniqueCode).QueryRow(&item)
|
|
|
+// return
|
|
|
+// }
|
|
|
+
|
|
|
+// type ChartEdbInfoMapping struct {
|
|
|
+// EdbInfoId int `description:"指标id"`
|
|
|
+// SourceName string `description:"来源名称"`
|
|
|
+// Source int `description:"来源id"`
|
|
|
+// EdbCode string `description:"指标编码"`
|
|
|
+// EdbName string `description:"指标名称"`
|
|
|
+// EdbAliasName string `description:"指标名称(别名)"`
|
|
|
+// EdbAliasNameEn string `description:"英文指标名称(别名)"`
|
|
|
+// EdbNameEn string `description:"英文指标名称"`
|
|
|
+// Frequency string `description:"频率"`
|
|
|
+// FrequencyEn string `description:"英文频率"`
|
|
|
+// Unit string `description:"单位"`
|
|
|
+// UnitEn string `description:"英文单位"`
|
|
|
+// StartDate string `description:"起始日期"`
|
|
|
+// EndDate string `description:"终止日期"`
|
|
|
+// ModifyTime string `description:"指标最后更新时间"`
|
|
|
+// ChartEdbMappingId int `description:"图表指标id" json:"-"`
|
|
|
+// ChartInfoId int `description:"图表id"`
|
|
|
+// MaxData float64 `description:"上限"`
|
|
|
+// MinData float64 `description:"下限"`
|
|
|
+// IsOrder bool `description:"true:正序,false:逆序"`
|
|
|
+// IsAxis int `description:"1:左轴,0:右轴"`
|
|
|
+// EdbInfoType int `description:"1:标准指标,0:领先指标"`
|
|
|
+// EdbType int `description:"指标类型:1:基础指标,2:计算指标"`
|
|
|
+// LeadValue int `description:"领先值"`
|
|
|
+// LeadUnit string `description:"领先单位"`
|
|
|
+// LeadUnitEn string `description:"领先英文单位"`
|
|
|
+// ChartStyle string `description:"图表类型"`
|
|
|
+// ChartColor string `description:"颜色"`
|
|
|
+// ChartWidth float64 `description:"线条大小"`
|
|
|
+// DataList interface{}
|
|
|
+
|
|
|
+// EdbInfoCategoryType int `description:"0:普通指标,1:预测指标"`
|
|
|
+// PredictChartColor string `description:"预测数据的颜色"`
|
|
|
+// ChartType int `description:"生成样式:1:曲线图,2:季节性图,3:面积图,4:柱状图,5:散点图,6:组合图"`
|
|
|
+// LatestDate string `description:"数据最新日期"`
|
|
|
+// LatestValue float64 `description:"数据最新值"`
|
|
|
+// MoveLatestDate string `description:"移动后的数据最新日期"`
|
|
|
+// UniqueCode string `description:"指标唯一编码"`
|
|
|
+// MinValue float64 `json:"-" description:"最小值"`
|
|
|
+// MaxValue float64 `json:"-" description:"最大值"`
|
|
|
+// IsNullData bool `json:"-" description:"是否空数据"`
|
|
|
+// MappingSource int `description:"1:ETA图库;2:商品价格曲线"`
|
|
|
+// SubSource int `description:"子数据来源:0:经济数据库,1:日期序列"`
|
|
|
+// SubSourceName string `description:"子数据来源名称"`
|
|
|
+// IndicatorCode string `description:"指标代码"`
|
|
|
+// StockCode string `description:"证券代码"`
|
|
|
+// IsConvert int `description:"是否数据转换 0不转 1转"`
|
|
|
+// ConvertType int `description:"数据转换类型 1乘 2除 3对数"`
|
|
|
+// ConvertValue float64 `description:"数据转换值"`
|
|
|
+// ConvertUnit string `description:"数据转换单位"`
|
|
|
+// ConvertEnUnit string `description:"数据转换单位"`
|
|
|
+// ClassifyId int `description:"分类id"`
|
|
|
+// IsJoinPermission int `description:"是否加入权限管控,0:不加入;1:加入;默认:0"`
|
|
|
+// }
|
|
|
+
|
|
|
type ChartEdbInfoMapping struct {
|
|
|
- EdbInfoId int `description:"指标id"`
|
|
|
- SourceName string `description:"来源名称"`
|
|
|
- Source int `description:"来源id"`
|
|
|
- EdbCode string `description:"指标编码"`
|
|
|
- EdbName string `description:"指标名称"`
|
|
|
- EdbAliasName string `description:"指标名称(别名)"`
|
|
|
- EdbAliasNameEn string `description:"英文指标名称(别名)"`
|
|
|
- EdbNameEn string `description:"英文指标名称"`
|
|
|
- Frequency string `description:"频率"`
|
|
|
- FrequencyEn string `description:"英文频率"`
|
|
|
- Unit string `description:"单位"`
|
|
|
- UnitEn string `description:"英文单位"`
|
|
|
- StartDate string `description:"起始日期"`
|
|
|
- EndDate string `description:"终止日期"`
|
|
|
- ModifyTime string `description:"指标最后更新时间"`
|
|
|
- ChartEdbMappingId int `description:"图表指标id" json:"-"`
|
|
|
- ChartInfoId int `description:"图表id"`
|
|
|
- MaxData float64 `description:"上限"`
|
|
|
- MinData float64 `description:"下限"`
|
|
|
- IsOrder bool `description:"true:正序,false:逆序"`
|
|
|
- IsAxis int `description:"1:左轴,0:右轴"`
|
|
|
- EdbInfoType int `description:"1:标准指标,0:领先指标"`
|
|
|
- EdbType int `description:"指标类型:1:基础指标,2:计算指标"`
|
|
|
- LeadValue int `description:"领先值"`
|
|
|
- LeadUnit string `description:"领先单位"`
|
|
|
- LeadUnitEn string `description:"领先英文单位"`
|
|
|
- ChartStyle string `description:"图表类型"`
|
|
|
- ChartColor string `description:"颜色"`
|
|
|
- ChartWidth float64 `description:"线条大小"`
|
|
|
- DataList interface{}
|
|
|
-
|
|
|
- EdbInfoCategoryType int `description:"0:普通指标,1:预测指标"`
|
|
|
- PredictChartColor string `description:"预测数据的颜色"`
|
|
|
- ChartType int `description:"生成样式:1:曲线图,2:季节性图,3:面积图,4:柱状图,5:散点图,6:组合图"`
|
|
|
- LatestDate string `description:"数据最新日期"`
|
|
|
- LatestValue float64 `description:"数据最新值"`
|
|
|
- MoveLatestDate string `description:"移动后的数据最新日期"`
|
|
|
- UniqueCode string `description:"指标唯一编码"`
|
|
|
- MinValue float64 `json:"-" description:"最小值"`
|
|
|
- MaxValue float64 `json:"-" description:"最大值"`
|
|
|
- IsNullData bool `json:"-" description:"是否空数据"`
|
|
|
- MappingSource int `description:"1:ETA图库;2:商品价格曲线"`
|
|
|
- SubSource int `description:"子数据来源:0:经济数据库,1:日期序列"`
|
|
|
- SubSourceName string `description:"子数据来源名称"`
|
|
|
- IndicatorCode string `description:"指标代码"`
|
|
|
- StockCode string `description:"证券代码"`
|
|
|
- IsConvert int `description:"是否数据转换 0不转 1转"`
|
|
|
- ConvertType int `description:"数据转换类型 1乘 2除 3对数"`
|
|
|
- ConvertValue float64 `description:"数据转换值"`
|
|
|
- ConvertUnit string `description:"数据转换单位"`
|
|
|
- ConvertEnUnit string `description:"数据转换单位"`
|
|
|
- ClassifyId int `description:"分类id"`
|
|
|
- IsJoinPermission int `description:"是否加入权限管控,0:不加入;1:加入;默认:0"`
|
|
|
+ EdbInfoId int `gorm:"column:edb_info_id;primaryKey" description:"指标id"`
|
|
|
+ SourceName string `gorm:"column:source_name" description:"来源名称"`
|
|
|
+ Source int `gorm:"column:source" description:"来源id"`
|
|
|
+ EdbCode string `gorm:"column:edb_code" description:"指标编码"`
|
|
|
+ EdbName string `gorm:"column:edb_name" description:"指标名称"`
|
|
|
+ EdbAliasName string `gorm:"column:edb_alias_name" description:"指标名称(别名)"`
|
|
|
+ EdbAliasNameEn string `gorm:"column:edb_alias_name_en" description:"英文指标名称(别名)"`
|
|
|
+ EdbNameEn string `gorm:"column:edb_name_en" description:"英文指标名称"`
|
|
|
+ Frequency string `gorm:"column:frequency" description:"频率"`
|
|
|
+ FrequencyEn string `gorm:"column:frequency_en" description:"英文频率"`
|
|
|
+ Unit string `gorm:"column:unit" description:"单位"`
|
|
|
+ UnitEn string `gorm:"column:unit_en" description:"英文单位"`
|
|
|
+ StartDate string `gorm:"column:start_date" description:"起始日期"`
|
|
|
+ EndDate string `gorm:"column:end_date" description:"终止日期"`
|
|
|
+ ModifyTime string `gorm:"column:modify_time" description:"指标最后更新时间"`
|
|
|
+ ChartEdbMappingId int `gorm:"column:chart_edb_mapping_id" description:"图表指标id" json:"-"`
|
|
|
+ ChartInfoId int `gorm:"column:chart_info_id" description:"图表id"`
|
|
|
+ MaxData float64 `gorm:"column:max_data" description:"上限"`
|
|
|
+ MinData float64 `gorm:"column:min_data" description:"下限"`
|
|
|
+ IsOrder bool `gorm:"column:is_order" description:"true:正序,false:逆序"`
|
|
|
+ IsAxis int `gorm:"column:is_axis" description:"1:左轴,0:右轴"`
|
|
|
+ EdbInfoType int `gorm:"column:edb_info_type" description:"1:标准指标,0:领先指标"`
|
|
|
+ EdbType int `gorm:"column:edb_type" description:"指标类型:1:基础指标,2:计算指标"`
|
|
|
+ LeadValue int `gorm:"column:lead_value" description:"领先值"`
|
|
|
+ LeadUnit string `gorm:"column:lead_unit" description:"领先单位"`
|
|
|
+ LeadUnitEn string `gorm:"column:lead_unit_en" description:"领先英文单位"`
|
|
|
+ ChartStyle string `gorm:"column:chart_style" description:"图表类型"`
|
|
|
+ ChartColor string `gorm:"column:chart_color" description:"颜色"`
|
|
|
+ ChartWidth float64 `gorm:"column:chart_width" description:"线条大小"`
|
|
|
+ DataList interface{} `gorm:"column:data_list" description:"数据列表"`
|
|
|
+ EdbInfoCategoryType int `gorm:"column:edb_info_category_type" description:"0:普通指标,1:预测指标"`
|
|
|
+ PredictChartColor string `gorm:"column:predict_chart_color" description:"预测数据的颜色"`
|
|
|
+ ChartType int `gorm:"column:chart_type" description:"生成样式:1:曲线图,2:季节性图,3:面积图,4:柱状图,5:散点图,6:组合图"`
|
|
|
+ LatestDate string `gorm:"column:latest_date" description:"数据最新日期"`
|
|
|
+ LatestValue float64 `gorm:"column:latest_value" description:"数据最新值"`
|
|
|
+ MoveLatestDate string `gorm:"column:move_latest_date" description:"移动后的数据最新日期"`
|
|
|
+ UniqueCode string `gorm:"column:unique_code" description:"指标唯一编码"`
|
|
|
+ MinValue float64 `gorm:"column:min_value" json:"-" description:"最小值"`
|
|
|
+ MaxValue float64 `gorm:"column:max_value" json:"-" description:"最大值"`
|
|
|
+ IsNullData bool `gorm:"column:is_null_data" json:"-" description:"是否空数据"`
|
|
|
+ MappingSource int `gorm:"column:mapping_source" description:"1:ETA图库;2:商品价格曲线"`
|
|
|
+ SubSource int `gorm:"column:sub_source" description:"子数据来源:0:经济数据库,1:日期序列"`
|
|
|
+ SubSourceName string `gorm:"column:sub_source_name" description:"子数据来源名称"`
|
|
|
+ IndicatorCode string `gorm:"column:indicator_code" description:"指标代码"`
|
|
|
+ StockCode string `gorm:"column:stock_code" description:"证券代码"`
|
|
|
+ IsConvert int `gorm:"column:is_convert" description:"是否数据转换 0不转 1转"`
|
|
|
+ ConvertType int `gorm:"column:convert_type" description:"数据转换类型 1乘 2除 3对数"`
|
|
|
+ ConvertValue float64 `gorm:"column:convert_value" description:"数据转换值"`
|
|
|
+ ConvertUnit string `gorm:"column:convert_unit" description:"数据转换单位"`
|
|
|
+ ConvertEnUnit string `gorm:"column:convert_en_unit" description:"数据转换单位英文"`
|
|
|
+ ClassifyId int `gorm:"column:classify_id" description:"分类id"`
|
|
|
+ IsJoinPermission int `gorm:"column:is_join_permission" description:"是否加入权限管控,0:不加入;1:加入;默认:0"`
|
|
|
}
|
|
|
|
|
|
func GetChartEdbMappingList(chartInfoId int) (list []*ChartEdbInfoMapping, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DmSQL["data"]
|
|
|
aField := `a.chart_edb_mapping_id,a.chart_info_id,a.edb_info_id,a.create_time,a.modify_time,a.unique_code,a.max_data,a.min_data,a.is_order,a.is_axis,a.edb_info_type,a.lead_value,a.lead_unit,a.chart_style,a.chart_color,a.predict_chart_color,a.chart_width,a.source as mapping_source,a.edb_alias_name`
|
|
|
sql := ` SELECT ` + aField + `,b.source_name,b.source,b.edb_code,b.edb_name,b.edb_name_en,b.frequency,b.unit,b.unit_en,b.start_date,b.end_date,b.modify_time,b.edb_type,b.latest_date,b.latest_value,b.unique_code,b.edb_info_type AS edb_info_category_type,b.sub_source,
|
|
|
a.is_convert, a.convert_type, a.convert_value, a.convert_unit, a.convert_en_unit
|
|
@@ -132,16 +243,37 @@ a.is_convert, a.convert_type, a.convert_value, a.convert_unit, a.convert_en_unit
|
|
|
INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
|
|
|
WHERE chart_info_id=?
|
|
|
ORDER BY chart_edb_mapping_id ASC `
|
|
|
- _, err = o.Raw(sql, chartInfoId).QueryRows(&list)
|
|
|
+ err = o.Raw(sql, chartInfoId).Scan(&list).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// func GetChartEdbMappingList(chartInfoId int) (list []*ChartEdbInfoMapping, err error) {
|
|
|
+// o := orm.NewOrmUsingDB("data")
|
|
|
+// aField := `a.chart_edb_mapping_id,a.chart_info_id,a.edb_info_id,a.create_time,a.modify_time,a.unique_code,a.max_data,a.min_data,a.is_order,a.is_axis,a.edb_info_type,a.lead_value,a.lead_unit,a.chart_style,a.chart_color,a.predict_chart_color,a.chart_width,a.source as mapping_source,a.edb_alias_name`
|
|
|
+// sql := ` SELECT ` + aField + `,b.source_name,b.source,b.edb_code,b.edb_name,b.edb_name_en,b.frequency,b.unit,b.unit_en,b.start_date,b.end_date,b.modify_time,b.edb_type,b.latest_date,b.latest_value,b.unique_code,b.edb_info_type AS edb_info_category_type,b.sub_source,
|
|
|
+// a.is_convert, a.convert_type, a.convert_value, a.convert_unit, a.convert_en_unit
|
|
|
+// FROM chart_edb_mapping AS a
|
|
|
+// INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
|
|
|
+// WHERE chart_info_id=?
|
|
|
+// ORDER BY chart_edb_mapping_id ASC `
|
|
|
+// _, err = o.Raw(sql, chartInfoId).QueryRows(&list)
|
|
|
+// return
|
|
|
+// }
|
|
|
+
|
|
|
+// type EdbDataList struct {
|
|
|
+// EdbDataId int `json:"-" description:" 指标数据ID"`
|
|
|
+// EdbInfoId int `json:"-" description:"指标ID"`
|
|
|
+// DataTime string `description:"数据日期"`
|
|
|
+// DataTimestamp int64 `description:"数据日期"`
|
|
|
+// Value float64 `description:"数据值"`
|
|
|
+// }
|
|
|
+
|
|
|
type EdbDataList struct {
|
|
|
- EdbDataId int `json:"-" description:" 指标数据ID"`
|
|
|
- EdbInfoId int `json:"-" description:"指标ID"`
|
|
|
- DataTime string `description:"数据日期"`
|
|
|
- DataTimestamp int64 `description:"数据日期"`
|
|
|
- Value float64 `description:"数据值"`
|
|
|
+ EdbDataId int `gorm:"column:edb_data_id;primaryKey" description:"指标数据ID"`
|
|
|
+ EdbInfoId int `gorm:"column:edb_info_id" description:"指标ID"`
|
|
|
+ DataTime string `gorm:"column:data_time" description:"数据日期"`
|
|
|
+ DataTimestamp int64 `gorm:"column:data_timestamp" description:"数据日期时间戳"`
|
|
|
+ Value float64 `gorm:"column:value" description:"数据值"`
|
|
|
}
|
|
|
|
|
|
// GetEdbDataList 获取指标的数据(日期正序返回)
|
|
@@ -191,8 +323,8 @@ func getEdbDataListByMysql(source, subSource, edbInfoId int, startDate, endDate
|
|
|
}
|
|
|
sql += ` ORDER BY data_time ASC `
|
|
|
sql = fmt.Sprintf(sql, tableName)
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
- _, err = o.Raw(sql, edbInfoId, pars).QueryRows(&list)
|
|
|
+ o := global.DmSQL["data"]
|
|
|
+ err = o.Raw(sql, edbInfoId, pars).Scan(&list).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -243,6 +375,92 @@ func getEdbDataListByMongo(source, subSource, edbInfoId int, startDate, endDate
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// getEdbDataListByMysql
|
|
|
+// @Description: 从mysql中获取指标的数据(日期正序返回)
|
|
|
+// @author: Roc
|
|
|
+// @datetime 2024-05-08 16:49:48
|
|
|
+// @param source int
|
|
|
+// @param subSource int
|
|
|
+// @param edbInfoId int
|
|
|
+// @param startDate string
|
|
|
+// @param endDate string
|
|
|
+// @return list []*EdbDataList
|
|
|
+// @return err error
|
|
|
+// func getEdbDataListByMysql(source, subSource, edbInfoId int, startDate, endDate string) (list []*EdbDataList, err error) {
|
|
|
+// tableName := GetEdbDataTableName(source, subSource)
|
|
|
+// if tableName == "" {
|
|
|
+// err = errors.New("无效的渠道:" + strconv.Itoa(source))
|
|
|
+// list = make([]*EdbDataList, 0)
|
|
|
+// return list, err
|
|
|
+// }
|
|
|
+// var pars []interface{}
|
|
|
+// var condition string
|
|
|
+// if startDate != "" {
|
|
|
+// condition += ` AND data_time>=? `
|
|
|
+// pars = append(pars, startDate)
|
|
|
+// }
|
|
|
+// if endDate != "" {
|
|
|
+// condition += ` AND data_time<=? `
|
|
|
+// pars = append(pars, endDate)
|
|
|
+// }
|
|
|
+// sql := `SELECT edb_data_id,edb_info_id,data_time,value,data_timestamp FROM %s WHERE edb_info_id=? `
|
|
|
+// if condition != "" {
|
|
|
+// sql += condition
|
|
|
+// }
|
|
|
+// sql += ` ORDER BY data_time ASC `
|
|
|
+// sql = fmt.Sprintf(sql, tableName)
|
|
|
+// o := orm.NewOrmUsingDB("data")
|
|
|
+// _, err = o.Raw(sql, edbInfoId, pars).QueryRows(&list)
|
|
|
+// return
|
|
|
+// }
|
|
|
+
|
|
|
+// // getEdbDataListByMongo
|
|
|
+// // @Description: 从mongo中获取指标的数据(日期正序返回)
|
|
|
+// // @author: Roc
|
|
|
+// // @datetime 2024-05-08 16:49:59
|
|
|
+// // @param source int
|
|
|
+// // @param subSource int
|
|
|
+// // @param edbInfoId int
|
|
|
+// // @param startDate string
|
|
|
+// // @param endDate string
|
|
|
+// // @return list []*EdbDataList
|
|
|
+// // @return err error
|
|
|
+// func getEdbDataListByMongo(source, subSource, edbInfoId int, startDate, endDate string) (list []*EdbDataList, err error) {
|
|
|
+// list = make([]*EdbDataList, 0)
|
|
|
+
|
|
|
+// mogDataObj := mgo.EdbDataBusiness{}
|
|
|
+// // 构建查询条件
|
|
|
+// queryConditions := bson.M{
|
|
|
+// "edb_info_id": edbInfoId,
|
|
|
+// }
|
|
|
+// // 日期
|
|
|
+// dateCondition, err := mgo.BuildDateCondition(startDate, endDate)
|
|
|
+// if err != nil {
|
|
|
+// return
|
|
|
+// }
|
|
|
+// if len(dateCondition) > 0 {
|
|
|
+// queryConditions["data_time"] = dateCondition
|
|
|
+// }
|
|
|
+
|
|
|
+// // 获取列表数据
|
|
|
+// tmpDataList, tmpErr := mogDataObj.GetAllDataList(queryConditions, []string{"data_time"})
|
|
|
+// if tmpErr != nil {
|
|
|
+// err = tmpErr
|
|
|
+// return
|
|
|
+// }
|
|
|
+// for k, v := range tmpDataList {
|
|
|
+// list = append(list, &EdbDataList{
|
|
|
+// EdbDataId: k + 1,
|
|
|
+// EdbInfoId: v.EdbInfoId,
|
|
|
+// DataTime: v.DataTime.Format(utils.FormatDate),
|
|
|
+// DataTimestamp: v.DataTimestamp,
|
|
|
+// Value: v.Value,
|
|
|
+// })
|
|
|
+// }
|
|
|
+
|
|
|
+// return
|
|
|
+// }
|
|
|
+
|
|
|
type EdbDataItemList struct {
|
|
|
EdbDataId int `json:"-" description:" 指标数据ID"`
|
|
|
EdbInfoId int `json:"-" description:"指标ID"`
|
|
@@ -251,11 +469,17 @@ type EdbDataItemList struct {
|
|
|
Value float64 `description:"数据值"`
|
|
|
}
|
|
|
|
|
|
+// type EdbDataItems struct {
|
|
|
+// Items []*EdbDataList
|
|
|
+// Year int
|
|
|
+// BetweenDay int `json:"-" description:"公历与农历之间相差的天数"`
|
|
|
+// CuttingDataTimestamp int64 `description:"切割的时间戳"`
|
|
|
+// }
|
|
|
type EdbDataItems struct {
|
|
|
- Items []*EdbDataList
|
|
|
- Year int
|
|
|
- BetweenDay int `json:"-" description:"公历与农历之间相差的天数"`
|
|
|
- CuttingDataTimestamp int64 `description:"切割的时间戳"`
|
|
|
+ Items []*EdbDataList `gorm:"column:items" description:"指标数据项列表"`
|
|
|
+ Year int `gorm:"column:year" description:"年份"`
|
|
|
+ BetweenDay int `gorm:"column:between_day" json:"-" description:"公历与农历之间相差的天数"`
|
|
|
+ CuttingDataTimestamp int64 `gorm:"column:cutting_data_timestamp" description:"切割的时间戳"`
|
|
|
}
|
|
|
|
|
|
type EdbDataResult struct {
|
|
@@ -673,6 +897,355 @@ func AddCalculateQuarterV6(dataList []*EdbDataList) (result *EdbDataResult, err
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// func AddCalculateQuarterV5(dataList []*EdbDataList) (result *EdbDataResult, err error) {
|
|
|
+// var errMsg string
|
|
|
+// defer func() {
|
|
|
+// if errMsg != "" {
|
|
|
+// fmt.Println("errMsg:", errMsg)
|
|
|
+// }
|
|
|
+// }()
|
|
|
+// if len(dataList) <= 0 {
|
|
|
+// result.List = make([]*EdbDataItems, 0)
|
|
|
+// return
|
|
|
+// }
|
|
|
+
|
|
|
+// endDate := dataList[len(dataList)-1].DataTime
|
|
|
+// endDateForm, err := time.Parse(utils.FormatDate, endDate)
|
|
|
+// if err != nil {
|
|
|
+// return result, err
|
|
|
+// }
|
|
|
+// thisMonth := int(endDateForm.Month())
|
|
|
+
|
|
|
+// result = new(EdbDataResult)
|
|
|
+// var yearArr []int
|
|
|
+// yearMap := make(map[int]int)
|
|
|
+// var cureentDate time.Time
|
|
|
+// if thisMonth < 11 {
|
|
|
+// for k, v := range dataList {
|
|
|
+// dateTime, err := time.Parse(utils.FormatDate, v.DataTime)
|
|
|
+// if err != nil {
|
|
|
+// errMsg = "time.Parse Err:" + err.Error() + ";DataTime:" + v.DataTime
|
|
|
+// return result, err
|
|
|
+// }
|
|
|
+// if k == len(dataList)-1 {
|
|
|
+// cureentDate = dateTime
|
|
|
+// }
|
|
|
+// year := dateTime.Year()
|
|
|
+// if _, ok := yearMap[year]; !ok {
|
|
|
+// yearArr = append(yearArr, year)
|
|
|
+// }
|
|
|
+// yearMap[year] = year
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// for k, v := range dataList {
|
|
|
+// dateTime, err := time.Parse(utils.FormatDate, v.DataTime)
|
|
|
+// if err != nil {
|
|
|
+// errMsg = "time.Parse Err:" + err.Error() + ";DataTime:" + v.DataTime
|
|
|
+// return result, err
|
|
|
+// }
|
|
|
+// if k == len(dataList)-1 {
|
|
|
+// cureentDate = dateTime
|
|
|
+// }
|
|
|
+// year := dateTime.Year() + 1
|
|
|
+// if _, ok := yearMap[year]; !ok {
|
|
|
+// yearArr = append(yearArr, year)
|
|
|
+// }
|
|
|
+// yearMap[year] = year
|
|
|
+// }
|
|
|
+// }
|
|
|
+// //排序
|
|
|
+// fmt.Println("yearArr:", yearArr)
|
|
|
+// thisYear := cureentDate.Year()
|
|
|
+// //thisMonth := int(cureentDate.Month())
|
|
|
+
|
|
|
+// fmt.Println("thisMonth:", thisMonth)
|
|
|
+// for ky, vy := range yearArr {
|
|
|
+// fmt.Println("line 432:", ky, vy, thisYear, thisMonth)
|
|
|
+// if thisMonth < 11 {
|
|
|
+// currentYearCjnl := strconv.Itoa(thisYear) + "-01-01" //当前年份春节农历
|
|
|
+// currentYearCjgl := solarlunar.LunarToSolar(currentYearCjnl, false) //当前年份春节公历
|
|
|
+// currentYearCjglDate, err := time.Parse(utils.FormatDate, currentYearCjgl)
|
|
|
+// if err != nil {
|
|
|
+// errMsg = "生成当前春节失败,Err:" + err.Error()
|
|
|
+// return result, err
|
|
|
+// }
|
|
|
+
|
|
|
+// preYear := vy
|
|
|
+// preYearCjnl := strconv.Itoa(preYear) + "-01-01" //之前年份春节农历
|
|
|
+// preYearCjgl := solarlunar.LunarToSolar(preYearCjnl, false) //之前年份春节公历
|
|
|
+// preYearCjglDate, err := time.Parse(utils.FormatDate, preYearCjgl)
|
|
|
+// if err != nil {
|
|
|
+// errMsg = "生成历史年份春节失败,Err:" + err.Error()
|
|
|
+// return result, err
|
|
|
+// }
|
|
|
+// day := currentYearCjglDate.Sub(preYearCjglDate).Hours() / float64(24)
|
|
|
+
|
|
|
+// items := new(EdbDataItems)
|
|
|
+// items.BetweenDay = int(day) //公历日期换算成农历,需要减除的天数
|
|
|
+// items.Year = preYear
|
|
|
+// for _, v := range dataList {
|
|
|
+// dateTime, err := time.Parse(utils.FormatDate, v.DataTime)
|
|
|
+// if err != nil {
|
|
|
+// errMsg = "time.Parse Err:" + err.Error() + ";DataTime:" + v.DataTime
|
|
|
+// return result, err
|
|
|
+// }
|
|
|
+// newDate := dateTime.AddDate(0, 0, int(day))
|
|
|
+// selectDateStr := strconv.Itoa(thisYear) + "-11" + "-30"
|
|
|
+// selectDate, _ := time.Parse(utils.FormatDate, selectDateStr)
|
|
|
+// if newDate.Before(selectDate) || newDate == selectDate {
|
|
|
+// timestamp := newDate.UnixNano() / 1e6
|
|
|
+// item := new(EdbDataList)
|
|
|
+// item.DataTime = newDate.Format(utils.FormatDate)
|
|
|
+// item.EdbInfoId = v.EdbInfoId
|
|
|
+// item.Value = v.Value
|
|
|
+// item.EdbDataId = v.EdbDataId
|
|
|
+// item.DataTimestamp = timestamp
|
|
|
+// items.Items = append(items.Items, item)
|
|
|
+// }
|
|
|
+// }
|
|
|
+// result.List = append(result.List, items)
|
|
|
+// } else {
|
|
|
+// nextYear := thisYear + 1
|
|
|
+// nextYearCjnl := strconv.Itoa(nextYear) + "-01-01" //当前年份春节农历
|
|
|
+// nextYearCjgl := solarlunar.LunarToSolar(nextYearCjnl, false) //当前年份春节公历
|
|
|
+
|
|
|
+// nextYearCjglDate, err := time.Parse(utils.FormatDate, nextYearCjgl)
|
|
|
+// if err != nil {
|
|
|
+// errMsg = "生成当前春节失败,Err:" + err.Error()
|
|
|
+// return result, err
|
|
|
+// }
|
|
|
+// preYear := vy
|
|
|
+// preYearCjnl := strconv.Itoa(preYear) + "-01-01" //之前年份春节农历
|
|
|
+// preYearCjgl := solarlunar.LunarToSolar(preYearCjnl, false) //之前年份春节公历
|
|
|
+// preYearCjglDate, err := time.Parse(utils.FormatDate, preYearCjgl)
|
|
|
+// if err != nil {
|
|
|
+// errMsg = "生成历史年份春节失败,Err:" + err.Error()
|
|
|
+// return result, err
|
|
|
+// }
|
|
|
+// day := nextYearCjglDate.Sub(preYearCjglDate).Hours() / float64(24)
|
|
|
+
|
|
|
+// fmt.Println("day:", day, nextYearCjglDate, preYearCjglDate)
|
|
|
+
|
|
|
+// items := new(EdbDataItems)
|
|
|
+// items.BetweenDay = int(day) //公历日期换算成农历,需要减除的天数
|
|
|
+// items.Year = preYear - 1
|
|
|
+// fmt.Println("preYear:", preYear, "ky:", ky, "yearArrLen:", len(yearArr))
|
|
|
+// if ky+1 < len(yearArr) {
|
|
|
+// for _, v := range dataList {
|
|
|
+// dateTime, err := time.Parse(utils.FormatDate, v.DataTime)
|
|
|
+// if err != nil {
|
|
|
+// errMsg = "time.Parse Err:" + err.Error() + ";DataTime:" + v.DataTime
|
|
|
+// return result, err
|
|
|
+// }
|
|
|
+// newDate := dateTime.AddDate(0, 0, int(day))
|
|
|
+// selectDateStr := strconv.Itoa(nextYear) + "-05" + "-31"
|
|
|
+// selectDate, _ := time.Parse(utils.FormatDate, selectDateStr)
|
|
|
+
|
|
|
+// if newDate.Before(selectDate) || newDate == selectDate {
|
|
|
+// timestamp := newDate.UnixNano() / 1e6
|
|
|
+// item := new(EdbDataList)
|
|
|
+// item.DataTime = newDate.Format(utils.FormatDate)
|
|
|
+// item.EdbInfoId = v.EdbInfoId
|
|
|
+// item.Value = v.Value
|
|
|
+// item.EdbDataId = v.EdbDataId
|
|
|
+// item.DataTimestamp = timestamp
|
|
|
+// items.Items = append(items.Items, item)
|
|
|
+// }
|
|
|
+// }
|
|
|
+// result.List = append(result.List, items)
|
|
|
+// } else {
|
|
|
+// for _, v := range dataList {
|
|
|
+// dateTime, err := time.Parse(utils.FormatDate, v.DataTime)
|
|
|
+// if err != nil {
|
|
|
+// errMsg = "time.Parse Err:" + err.Error() + ";DataTime:" + v.DataTime
|
|
|
+// return result, err
|
|
|
+// }
|
|
|
+// timestamp := dateTime.UnixNano() / 1e6
|
|
|
+// item := new(EdbDataList)
|
|
|
+// item.DataTime = dateTime.Format(utils.FormatDate)
|
|
|
+// item.EdbInfoId = v.EdbInfoId
|
|
|
+// item.Value = v.Value
|
|
|
+// item.EdbDataId = v.EdbDataId
|
|
|
+// item.DataTimestamp = timestamp
|
|
|
+// items.Items = append(items.Items, item)
|
|
|
+// }
|
|
|
+// result.List = append(result.List, items)
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return
|
|
|
+// }
|
|
|
+
|
|
|
+// // AddCalculateQuarterV6 指标季度数据计算(季节性图表)
|
|
|
+// func AddCalculateQuarterV6(dataList []*EdbDataList) (result *EdbDataResult, err error) {
|
|
|
+// var errMsg string
|
|
|
+// defer func() {
|
|
|
+// if errMsg != "" {
|
|
|
+// fmt.Println("errMsg:", errMsg)
|
|
|
+// }
|
|
|
+// }()
|
|
|
+
|
|
|
+// endDate := dataList[len(dataList)-1].DataTime
|
|
|
+// endDateForm, err := time.Parse(utils.FormatDate, endDate)
|
|
|
+// if err != nil {
|
|
|
+// return result, err
|
|
|
+// }
|
|
|
+// thisMonth := int(endDateForm.Month())
|
|
|
+
|
|
|
+// result = new(EdbDataResult)
|
|
|
+// var yearArr []int
|
|
|
+// yearMap := make(map[int]int)
|
|
|
+// var cureentDate time.Time
|
|
|
+// if thisMonth < 11 {
|
|
|
+// for k, v := range dataList {
|
|
|
+// dateTime, err := time.Parse(utils.FormatDate, v.DataTime)
|
|
|
+// if err != nil {
|
|
|
+// errMsg = "time.Parse Err:" + err.Error() + ";DataTime:" + v.DataTime
|
|
|
+// return result, err
|
|
|
+// }
|
|
|
+// if k == len(dataList)-1 {
|
|
|
+// cureentDate = dateTime
|
|
|
+// }
|
|
|
+// year := dateTime.Year()
|
|
|
+// if _, ok := yearMap[year]; !ok {
|
|
|
+// yearArr = append(yearArr, year)
|
|
|
+// }
|
|
|
+// yearMap[year] = year
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// for k, v := range dataList {
|
|
|
+// dateTime, err := time.Parse(utils.FormatDate, v.DataTime)
|
|
|
+// if err != nil {
|
|
|
+// errMsg = "time.Parse Err:" + err.Error() + ";DataTime:" + v.DataTime
|
|
|
+// return result, err
|
|
|
+// }
|
|
|
+// if k == len(dataList)-1 {
|
|
|
+// cureentDate = dateTime
|
|
|
+// }
|
|
|
+// year := dateTime.Year() + 1
|
|
|
+// if _, ok := yearMap[year]; !ok {
|
|
|
+// yearArr = append(yearArr, year)
|
|
|
+// }
|
|
|
+// yearMap[year] = year
|
|
|
+// }
|
|
|
+// }
|
|
|
+// //排序
|
|
|
+// fmt.Println("yearArr:", yearArr)
|
|
|
+// thisYear := cureentDate.Year()
|
|
|
+// //thisMonth := int(cureentDate.Month())
|
|
|
+
|
|
|
+// fmt.Println("thisMonth:", thisMonth)
|
|
|
+// for ky, vy := range yearArr {
|
|
|
+// fmt.Printf("line 432:ky:%d, vy:%d, thisYear:%d, thisMonth:%d", ky, vy, thisYear, thisMonth)
|
|
|
+// fmt.Println("")
|
|
|
+// if thisMonth < 11 {
|
|
|
+// currentYearCjnl := strconv.Itoa(thisYear) + "-01-01" //当前年份春节农历
|
|
|
+// currentYearCjgl := solarlunar.LunarToSolar(currentYearCjnl, false) //当前年份春节公历
|
|
|
+// currentYearCjglDate, err := time.Parse(utils.FormatDate, currentYearCjgl)
|
|
|
+// if err != nil {
|
|
|
+// errMsg = "生成当前春节失败,Err:" + err.Error()
|
|
|
+// return result, err
|
|
|
+// }
|
|
|
+
|
|
|
+// preYear := vy
|
|
|
+// preYearCjnl := strconv.Itoa(preYear) + "-01-01" //之前年份春节农历
|
|
|
+// preYearCjgl := solarlunar.LunarToSolar(preYearCjnl, false) //之前年份春节公历
|
|
|
+// preYearCjglDate, err := time.Parse(utils.FormatDate, preYearCjgl)
|
|
|
+// if err != nil {
|
|
|
+// errMsg = "生成历史年份春节失败,Err:" + err.Error()
|
|
|
+// return result, err
|
|
|
+// }
|
|
|
+// day := currentYearCjglDate.Sub(preYearCjglDate).Hours() / float64(24)
|
|
|
+
|
|
|
+// fmt.Println("day:", day, currentYearCjglDate, preYearCjglDate)
|
|
|
+
|
|
|
+// items := new(EdbDataItems)
|
|
|
+// items.BetweenDay = int(day) //公历日期换算成农历,需要减除的天数
|
|
|
+// items.Year = preYear
|
|
|
+// for _, v := range dataList {
|
|
|
+// dateTime, err := time.Parse(utils.FormatDate, v.DataTime)
|
|
|
+// if err != nil {
|
|
|
+// errMsg = "time.Parse Err:" + err.Error() + ";DataTime:" + v.DataTime
|
|
|
+// return result, err
|
|
|
+// }
|
|
|
+// newDate := dateTime.AddDate(0, 0, int(day))
|
|
|
+// timestamp := newDate.UnixNano() / 1e6
|
|
|
+// item := new(EdbDataList)
|
|
|
+// item.DataTime = newDate.Format(utils.FormatDate)
|
|
|
+// item.EdbInfoId = v.EdbInfoId
|
|
|
+// item.Value = v.Value
|
|
|
+// item.EdbDataId = v.EdbDataId
|
|
|
+// item.DataTimestamp = timestamp
|
|
|
+// items.Items = append(items.Items, item)
|
|
|
+// }
|
|
|
+// result.List = append(result.List, items)
|
|
|
+// } else {
|
|
|
+// nextYear := thisYear + 1
|
|
|
+// nextYearCjnl := strconv.Itoa(nextYear) + "-01-01" //当前年份春节农历
|
|
|
+// nextYearCjgl := solarlunar.LunarToSolar(nextYearCjnl, false) //当前年份春节公历
|
|
|
+
|
|
|
+// nextYearCjglDate, err := time.Parse(utils.FormatDate, nextYearCjgl)
|
|
|
+// if err != nil {
|
|
|
+// errMsg = "生成当前春节失败,Err:" + err.Error()
|
|
|
+// return result, err
|
|
|
+// }
|
|
|
+// preYear := vy
|
|
|
+// preYearCjnl := strconv.Itoa(preYear) + "-01-01" //之前年份春节农历
|
|
|
+// preYearCjgl := solarlunar.LunarToSolar(preYearCjnl, false) //之前年份春节公历
|
|
|
+// preYearCjglDate, err := time.Parse(utils.FormatDate, preYearCjgl)
|
|
|
+// if err != nil {
|
|
|
+// errMsg = "生成历史年份春节失败,Err:" + err.Error()
|
|
|
+// return result, err
|
|
|
+// }
|
|
|
+// day := nextYearCjglDate.Sub(preYearCjglDate).Hours() / float64(24)
|
|
|
+
|
|
|
+// fmt.Println("day:", day, nextYearCjglDate, preYearCjglDate)
|
|
|
+
|
|
|
+// items := new(EdbDataItems)
|
|
|
+// items.BetweenDay = int(day) //公历日期换算成农历,需要减除的天数
|
|
|
+// items.Year = preYear
|
|
|
+// fmt.Println("preYear:", preYear, "ky:", ky, "yearArrLen:", len(yearArr))
|
|
|
+// //if ky+1 < len(yearArr) {
|
|
|
+// for _, v := range dataList {
|
|
|
+// dateTime, err := time.Parse(utils.FormatDate, v.DataTime)
|
|
|
+// if err != nil {
|
|
|
+// errMsg = "time.Parse Err:" + err.Error() + ";DataTime:" + v.DataTime
|
|
|
+// return result, err
|
|
|
+// }
|
|
|
+// newDate := dateTime.AddDate(0, 0, int(day))
|
|
|
+// timestamp := newDate.UnixNano() / 1e6
|
|
|
+// item := new(EdbDataList)
|
|
|
+// item.DataTime = newDate.Format(utils.FormatDate)
|
|
|
+// item.EdbInfoId = v.EdbInfoId
|
|
|
+// item.Value = v.Value
|
|
|
+// item.EdbDataId = v.EdbDataId
|
|
|
+// item.DataTimestamp = timestamp
|
|
|
+// items.Items = append(items.Items, item)
|
|
|
+// }
|
|
|
+// result.List = append(result.List, items)
|
|
|
+// /*} else {
|
|
|
+// for _, v := range dataList {
|
|
|
+// dateTime, err := time.Parse(utils.FormatDate, v.DataTime)
|
|
|
+// if err != nil {
|
|
|
+// errMsg = "time.Parse Err:" + err.Error() + ";DataTime:" + v.DataTime
|
|
|
+// return result, err
|
|
|
+// }
|
|
|
+// timestamp := dateTime.UnixNano() / 1e6
|
|
|
+// item := new(EdbDataList)
|
|
|
+// item.DataTime = dateTime.Format(utils.FormatDate)
|
|
|
+// item.EdbInfoId = v.EdbInfoId
|
|
|
+// item.Value = v.Value
|
|
|
+// item.EdbDataId = v.EdbDataId
|
|
|
+// item.DataTimestamp = timestamp
|
|
|
+// items.Items = append(items.Items, item)
|
|
|
+// }
|
|
|
+// result.List = append(result.List, items)
|
|
|
+// }*/
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return
|
|
|
+// }
|
|
|
+
|
|
|
type CorrelationInfo struct {
|
|
|
LeadValue int `description:"领先值"`
|
|
|
LeadUnit string `description:"领先单位"`
|
|
@@ -865,24 +1438,43 @@ type ChartSectionDateChange struct {
|
|
|
ChangeType int `description:"日期变换类型1日期位移,2指定频率"`
|
|
|
}
|
|
|
|
|
|
+// 截面组合图系列配置
|
|
|
+// type ChartSectionSeriesItem struct {
|
|
|
+// ChartSeriesId int `description:"系列ID"`
|
|
|
+// SeriesName string `description:"系列名称"` //系列名称不可同名
|
|
|
+// SeriesNameEn string `description:"系列英文名称"`
|
|
|
+// ChartStyle string `description:"图表类型"`
|
|
|
+// ChartColor string `description:"颜色"`
|
|
|
+// ChartWidth int `description:"线条大小"`
|
|
|
+// IsPoint int `description:"是否用数据点展示(0 否,1是)"`
|
|
|
+// IsNumber int `description:"是否用数值展示(0 否,1是)"`
|
|
|
+// IsAxis int `description:"1:左轴,0:右轴"`
|
|
|
+// MaxData float64 `description:"上限"`
|
|
|
+// MinData float64 `description:"下限"`
|
|
|
+// //IsOrder bool `description:"true:正序,false:逆序"`
|
|
|
+// EdbInfoList []*ChartSectionSeriesEdbConf
|
|
|
+// DataList []float64
|
|
|
+// NoDataEdbIndex []int
|
|
|
+// }
|
|
|
+
|
|
|
// 截面组合图系列配置
|
|
|
type ChartSectionSeriesItem struct {
|
|
|
- ChartSeriesId int `description:"系列ID"`
|
|
|
- SeriesName string `description:"系列名称"` //系列名称不可同名
|
|
|
- SeriesNameEn string `description:"系列英文名称"`
|
|
|
- ChartStyle string `description:"图表类型"`
|
|
|
- ChartColor string `description:"颜色"`
|
|
|
- ChartWidth int `description:"线条大小"`
|
|
|
- IsPoint int `description:"是否用数据点展示(0 否,1是)"`
|
|
|
- IsNumber int `description:"是否用数值展示(0 否,1是)"`
|
|
|
- IsAxis int `description:"1:左轴,0:右轴"`
|
|
|
- MaxData float64 `description:"上限"`
|
|
|
- MinData float64 `description:"下限"`
|
|
|
- //IsOrder bool `description:"true:正序,false:逆序"`
|
|
|
- EdbInfoList []*ChartSectionSeriesEdbConf
|
|
|
- DataList []float64
|
|
|
- NoDataEdbIndex []int
|
|
|
+ ChartSeriesId int `gorm:"column:chart_series_id;primaryKey" description:"系列ID"`
|
|
|
+ SeriesName string `gorm:"column:series_name" description:"系列名称"` //系列名称不可同名
|
|
|
+ SeriesNameEn string `gorm:"column:series_name_en" description:"系列英文名称"`
|
|
|
+ ChartStyle string `gorm:"column:chart_style" description:"图表类型"`
|
|
|
+ ChartColor string `gorm:"column:chart_color" description:"颜色"`
|
|
|
+ ChartWidth int `gorm:"column:chart_width" description:"线条大小"`
|
|
|
+ IsPoint int `gorm:"column:is_point" description:"是否用数据点展示(0 否,1是)"`
|
|
|
+ IsNumber int `gorm:"column:is_number" description:"是否用数值展示(0 否,1是)"`
|
|
|
+ IsAxis int `gorm:"column:is_axis" description:"1:左轴,0:右轴"`
|
|
|
+ MaxData float64 `gorm:"column:max_data" description:"上限"`
|
|
|
+ MinData float64 `gorm:"column:min_data" description:"下限"`
|
|
|
+ EdbInfoList []*ChartSectionSeriesEdbConf `gorm:"foreignkey:ChartSeriesId" description:"指标列表"`
|
|
|
+ DataList []float64 `gorm:"column:data_list" description:"数据列表"`
|
|
|
+ NoDataEdbIndex []int `gorm:"column:no_data_edb_index" description:"没有数据的指标索引"`
|
|
|
}
|
|
|
+
|
|
|
type ChartSectionSeriesEdbConf struct {
|
|
|
ChartSeriesEdbMappingId int `description:"映射ID"`
|
|
|
ChartSeriesId int `description:"系列ID"`
|
|
@@ -946,12 +1538,19 @@ type ChartTimeCombineDataResp struct {
|
|
|
}
|
|
|
|
|
|
func GetChartInfoById(chartInfoId int) (item *ChartInfo, err error) {
|
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
+ o := global.DmSQL["data"]
|
|
|
sql := ` SELECT * FROM chart_info WHERE chart_info_id=? `
|
|
|
- err = o.Raw(sql, chartInfoId).QueryRow(&item)
|
|
|
+ err = o.Raw(sql, chartInfoId).First(&item).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// func GetChartInfoById(chartInfoId int) (item *ChartInfo, err error) {
|
|
|
+// o := orm.NewOrmUsingDB("data")
|
|
|
+// sql := ` SELECT * FROM chart_info WHERE chart_info_id=? `
|
|
|
+// err = o.Raw(sql, chartInfoId).QueryRow(&item)
|
|
|
+// return
|
|
|
+// }
|
|
|
+
|
|
|
type MarkersLine struct {
|
|
|
Axis int `json:"axis" description:"1左轴 2右轴 3横轴"`
|
|
|
AxisName string `json:"axisName" description:"轴的名称,例如'左轴'"`
|