package edb_refresh import ( "errors" "eta_gn/eta_index_lib/global" "eta_gn/eta_index_lib/utils" "time" ) // EdbRefreshMapping // @Description: 指标刷新时间配置关系表 type EdbRefreshMapping struct { 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 // @Description: 添加 // @author: Roc // @receiver m // @datetime 2023-12-14 16:11:10 // @param cols []string // @return err error func (m *EdbRefreshMapping) Add() (err error) { if m.EdbRefreshMappingId > 0 { err = errors.New("该配置已存在") return } err = global.DEFAULT_DmSQL.Create(m).Error return } // Update // @Description: 更新 // @author: Roc // @receiver m // @datetime 2023-12-14 16:11:10 // @param cols []string // @return err error func (m *EdbRefreshMapping) Update(cols []string) (err error) { err = global.DEFAULT_DmSQL.Model(m).Select(cols).Updates(m).Error return } // Delete // @Description: 删除 // @author: Roc // @receiver m // @datetime 2023-12-14 16:11:10 // @return err error func (m *EdbRefreshMapping) Delete() (err error) { err = global.DEFAULT_DmSQL.Delete(m).Error return } type EdbInfoListAndRefreshConfig struct { 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 // @Description: 根据来源和配置id列表获取指标列表 // @author: Roc // @datetime 2024-01-09 17:28:06 // @param sourceList []int // @param configIdList []int // @return list []*data_manage.EdbInfoList // @return err error func GetConfigRefreshEdbInfoListBySourceAndSubSource(sourceList, configIdList []int) (list []*EdbInfoListAndRefreshConfig, err error) { num := len(configIdList) if num <= 0 { return } var pars []interface{} 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) + `) ` pars = append(pars, configIdList) sourceNum := len(sourceList) if sourceNum > 0 { sql += ` AND b.source not in (` + utils.GetOrmInReplace(sourceNum) + `) ` pars = append(pars, sourceList) } err = global.DEFAULT_DmSQL.Raw(sql, pars...).Scan(&list).Error return }