|
@@ -2,23 +2,23 @@ package edb_refresh
|
|
|
|
|
|
import (
|
|
|
"errors"
|
|
|
+ "eta/eta_index_lib/global"
|
|
|
"eta/eta_index_lib/utils"
|
|
|
- "github.com/beego/beego/v2/client/orm"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
// EdbRefreshMapping
|
|
|
// @Description: 指标刷新时间配置关系表
|
|
|
type EdbRefreshMapping struct {
|
|
|
- EdbRefreshMappingId int `orm:"column(edb_refresh_mapping_id);pk"`
|
|
|
- Source int `description:"来源"`
|
|
|
- SubSource int `description:"来源名称"`
|
|
|
- EdbInfoId int `description:"指标id,如果是数据源(钢联、有色)的,那么就是数据源里面的id"`
|
|
|
- EdbRefreshConfigId int `description:"刷新配置id"`
|
|
|
- SysUserId int `description:"操作人id"`
|
|
|
- SysUserRealName string `description:"操作人真实姓名"`
|
|
|
- ModifyTime time.Time `description:"最晚一次的更新时间"`
|
|
|
- CreateTime time.Time `description:"添加时间"`
|
|
|
+ EdbRefreshMappingId int `gorm:"primaryKey;autoIncrement;column:edb_refresh_mapping_id" description:"映射ID"`
|
|
|
+ Source int `gorm:"column:source" description:"来源"`
|
|
|
+ SubSource int `gorm:"column:sub_source" description:"来源名称"`
|
|
|
+ EdbInfoId int `gorm:"column:edb_info_id" description:"指标id,如果是数据源(钢联、有色)的,那么就是数据源里面的id"`
|
|
|
+ EdbRefreshConfigId int `gorm:"column:edb_refresh_config_id" description:"刷新配置id"`
|
|
|
+ SysUserId int `gorm:"column:sys_user_id" description:"操作人id"`
|
|
|
+ SysUserRealName string `gorm:"column:sys_user_real_name" description:"操作人真实姓名"`
|
|
|
+ ModifyTime time.Time `gorm:"column:modify_time" description:"最晚一次的更新时间"`
|
|
|
+ CreateTime time.Time `gorm:"column:create_time" description:"添加时间"`
|
|
|
}
|
|
|
|
|
|
// Add
|
|
@@ -33,12 +33,7 @@ func (m *EdbRefreshMapping) Add() (err error) {
|
|
|
err = errors.New("该配置已存在")
|
|
|
return
|
|
|
}
|
|
|
- o := orm.NewOrm()
|
|
|
- lastId, err := o.Insert(m)
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
- m.EdbRefreshMappingId = int(lastId)
|
|
|
+ err = global.DEFAULT_DB.Create(m).Error
|
|
|
|
|
|
return
|
|
|
}
|
|
@@ -51,8 +46,8 @@ func (m *EdbRefreshMapping) Add() (err error) {
|
|
|
// @param cols []string
|
|
|
// @return err error
|
|
|
func (m *EdbRefreshMapping) Update(cols []string) (err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
- _, err = o.Update(m, cols...)
|
|
|
+ err = global.DEFAULT_DB.Model(m).Select(cols).Updates(m).Error
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -63,30 +58,30 @@ func (m *EdbRefreshMapping) Update(cols []string) (err error) {
|
|
|
// @datetime 2023-12-14 16:11:10
|
|
|
// @return err error
|
|
|
func (m *EdbRefreshMapping) Delete() (err error) {
|
|
|
- o := orm.NewOrm()
|
|
|
- _, err = o.Delete(m)
|
|
|
+ err = global.DEFAULT_DB.Delete(m).Error
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
|
type EdbInfoListAndRefreshConfig struct {
|
|
|
- EdbInfoId int `orm:"column(edb_info_id);pk"`
|
|
|
- SourceName string `description:"来源名称"`
|
|
|
- Source int `description:"来源id"`
|
|
|
- SubSource int `description:"子数据来源:0:经济数据库,1:日期序列"`
|
|
|
- SubSourceName string `description:"子数据来源名称"`
|
|
|
- EdbCode string `description:"指标编码"`
|
|
|
- EdbName string `description:"指标名称"`
|
|
|
- Frequency string `description:"频率"`
|
|
|
- Unit string `description:"单位"`
|
|
|
- StartDate time.Time `description:"起始日期"`
|
|
|
- EndDate time.Time `description:"终止日期"`
|
|
|
- ClassifyId int `description:"分类id"`
|
|
|
- UniqueCode string `description:"指标唯一编码"`
|
|
|
- CalculateFormula string `description:"计算公式"`
|
|
|
- ModifyTime string `description:"更新时间"`
|
|
|
- NoUpdate int8 `description:"是否停止更新,0:继续更新;1:停止更新"`
|
|
|
- EdbRefreshConfigId int `description:"刷新配置id"`
|
|
|
- DataRefreshNum int `description:"刷新的期数"`
|
|
|
+ EdbInfoId int `gorm:"primaryKey;autoIncrement;column:edb_info_id"`
|
|
|
+ SourceName string `gorm:"column:source_name" description:"来源名称"`
|
|
|
+ Source int `gorm:"column:source" description:"来源id"`
|
|
|
+ SubSource int `gorm:"column:sub_source" description:"子数据来源:0:经济数据库,1:日期序列"`
|
|
|
+ SubSourceName string `gorm:"column:sub_source_name" description:"子数据来源名称"`
|
|
|
+ EdbCode string `gorm:"column:edb_code" description:"指标编码"`
|
|
|
+ EdbName string `gorm:"column:edb_name" description:"指标名称"`
|
|
|
+ Frequency string `gorm:"column:frequency" description:"频率"`
|
|
|
+ Unit string `gorm:"column:unit" description:"单位"`
|
|
|
+ StartDate time.Time `gorm:"column:start_date" description:"起始日期"`
|
|
|
+ EndDate time.Time `gorm:"column:end_date" description:"终止日期"`
|
|
|
+ ClassifyId int `gorm:"column:classify_id" description:"分类id"`
|
|
|
+ UniqueCode string `gorm:"column:unique_code" description:"指标唯一编码"`
|
|
|
+ CalculateFormula string `gorm:"column:calculate_formula" description:"计算公式"`
|
|
|
+ ModifyTime string `gorm:"column:modify_time" description:"更新时间"`
|
|
|
+ NoUpdate int8 `gorm:"column:no_update" description:"是否停止更新,0:继续更新;1:停止更新"`
|
|
|
+ EdbRefreshConfigId int `gorm:"column:edb_refresh_config_id" description:"刷新配置id"`
|
|
|
+ DataRefreshNum int `gorm:"column:data_refresh_num" description:"刷新的期数"`
|
|
|
}
|
|
|
|
|
|
// GetConfigRefreshEdbInfoListBySourceAndSubSource
|
|
@@ -105,7 +100,6 @@ func GetConfigRefreshEdbInfoListBySourceAndSubSource(sourceList, configIdList []
|
|
|
|
|
|
var pars []interface{}
|
|
|
|
|
|
- o := orm.NewOrm()
|
|
|
sql := `SELECT a.*,b.edb_refresh_config_id FROM edb_info a
|
|
|
JOIN edb_refresh_mapping b ON a.edb_info_id = b.edb_info_id
|
|
|
WHERE b.edb_refresh_config_id IN (` + utils.GetOrmInReplace(num) + `) `
|
|
@@ -116,7 +110,7 @@ WHERE b.edb_refresh_config_id IN (` + utils.GetOrmInReplace(num) + `) `
|
|
|
sql += ` AND b.source not in (` + utils.GetOrmInReplace(sourceNum) + `) `
|
|
|
pars = append(pars, sourceList)
|
|
|
}
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&list)
|
|
|
+ err = global.DEFAULT_DB.Raw(sql, pars...).Scan(&list).Error
|
|
|
|
|
|
return
|
|
|
}
|