123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- package index
- import (
- "eta_gn/eta_bridge/global"
- "fmt"
- "time"
- )
- type EdbUpdateLog struct {
- Id int64 `gorm:"column:id;type:bigint(20) UNSIGNED;primaryKey;not null;" json:"id"`
- OpDbName string `gorm:"column:op_db_name;type:varchar(255);comment:库名;default:NULL;" json:"op_db_name"` // 库名
- OpTableName string `gorm:"column:op_table_name;type:varchar(255);comment:表名;" json:"op_table_name"` // 表名
- OpType string `gorm:"column:op_type;type:varchar(16);comment:变更类型;default:NULL;" json:"op_type"` // 变更类型
- OldData string `gorm:"column:old_data;type:text;comment:历史数据;" json:"old_data"` // 历史数据
- NewData string `gorm:"column:new_data;type:text;comment:新数据;" json:"new_data"` // 新数据
- CreateTime time.Time `gorm:"column:create_time;type:timestamp;default:CURRENT_TIMESTAMP;" json:"create_time"`
- }
- func (m *EdbUpdateLog) TableName() string {
- return "edb_update_log"
- }
- // Create 添加数据
- func (m *EdbUpdateLog) Create() (err error) {
- err = global.MYSQL["index"].Create(m).Error
- return
- }
- // DeleteBeforeTenDayLog 清除n前的日志数据
- func (m *EdbUpdateLog) DeleteBeforeTenDayLog(beforeDate string) (err error) {
- sql := fmt.Sprintf(`DELETE FROM %s WHERE create_time < ?`, m.TableName())
- err = global.MYSQL["index"].Exec(sql, beforeDate).Error
- return
- }
- type EdbInfo struct {
- EdbInfoId int `gorm:"primaryKey;autoIncrement;column:edb_info_id" description:"唯一标识"`
- EdbInfoType int `gorm:"column:edb_info_type" description:"指标类型,0:普通指标,1:预测指标"`
- 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:"指标名称"`
- EdbNameEn string `gorm:"column:edb_name_en" description:"英文指标名称"`
- EdbNameSource string `gorm:"column:edb_name_source" description:"指标名称来源"`
- Frequency string `gorm:"column:frequency" 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:"终止日期"`
- ClassifyId int `gorm:"column:classify_id" description:"分类id"`
- SysUserId int `gorm:"column:sys_user_id" description:"系统用户ID"`
- SysUserRealName string `gorm:"column:sys_user_real_name" description:"系统用户真实姓名"`
- UniqueCode string `gorm:"column:unique_code" description:"指标唯一编码"`
- CreateTime time.Time `gorm:"column:create_time" description:"创建时间"`
- ModifyTime time.Time `gorm:"column:modify_time" description:"修改时间"`
- BaseModifyTime time.Time `gorm:"column:base_modify_time" description:"基础修改时间"`
- MinValue float64 `gorm:"column:min_value" description:"指标最小值"`
- MaxValue float64 `gorm:"column:max_value" description:"指标最大值"`
- CalculateFormula string `gorm:"column:calculate_formula" description:"计算公式"`
- EdbType int `gorm:"column:edb_type" description:"指标类型:1:基础指标,2:计算指标"`
- IsUpdate int `gorm:"column:is_update" description:"当天是否已更新,1:未更新,2:已更新"`
- Sort int `gorm:"column:sort" description:"排序字段"`
- LatestDate string `gorm:"column:latest_date" description:"数据最新日期(实际日期)"`
- LatestValue float64 `gorm:"column:latest_value" description:"数据最新值(实际值)"`
- EndValue float64 `gorm:"column:end_value" description:"数据的最新值(预测日期的最新值)"`
- MoveType int `gorm:"column:move_type" description:"移动方式:1:领先(默认),2:滞后"`
- MoveFrequency string `gorm:"column:move_frequency" description:"移动频度"`
- NoUpdate int8 `gorm:"column:no_update" description:"是否停止更新,0:继续更新;1:停止更新"`
- ServerUrl string `gorm:"column:server_url" description:"服务器地址"`
- ChartImage string `gorm:"column:chart_image" description:"图表图片"`
- Calendar string `gorm:"column:calendar;default:公历" description:"公历/农历"`
- EmptyType int `gorm:"column:empty_type" description:"空值处理类型(0查找前后35天,1不计算,2前值填充,3后值填充,4等于0)"`
- MaxEmptyType int `gorm:"column:max_empty_type" description:"MAX、MIN公式空值处理类型(1、等于0;2、跳过空值)"`
- DataDateType string `gorm:"column:data_date_type;size:255;default:交易日" description:"数据日期类型"`
- ManualSave int `gorm:"column:manual_save" description:"是否有手动保存过上下限: 0-否; 1-是"`
- TerminalCode string `gorm:"column:terminal_code" description:"终端编码,用于配置在机器上"`
- DataUpdateTime string `gorm:"column:data_update_time" description:"最近一次数据发生变化的时间"`
- ErDataUpdateDate string `gorm:"column:er_data_update_date" description:"本次更新,数据发生变化的最早日期"`
- SourceIndexName string `gorm:"column:source_index_name" description:"数据源中的指标名称"`
- 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:"证券代码"`
- Extra string `gorm:"column:extra" description:"指标的额外配置"`
- OriginalEdbCode string `description:"指标原始编码"`
- }
- // GetAllBaseEdbInfo
- // @Description: 获取所有基础指标(只有国能数据节点的数据)
- // @return item
- // @return err
- func GetAllBaseEdbInfo() (item []*EdbInfo, err error) {
- sql := ` SELECT * FROM edb_info WHERE 1=1 AND "edb_info_type" = ? AND "edb_type" = ?`
- pars := []interface{}{0, 1}
- err = global.MYSQL["index"].Raw(sql, pars...).Find(&item).Error
- return
- }
- // Update
- // @Description: 更新指定参数
- // @receiver m
- // @param cols
- // @return err
- func (m *EdbInfo) Update(cols []string) (err error) {
- err = global.MYSQL["index"].Select(cols).Updates(m).Error
- return
- }
|