123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- package data_manage
- import (
- "eta_gn/eta_chart_lib/global"
- "eta_gn/eta_chart_lib/utils"
- "time"
- )
- func GetEdbInfoCalculateMap(edbInfoId, source int) (list []*EdbInfo, err error) {
- o := global.DmSQL["data"]
- //calculateTableName := GetEdbInfoCalculateTableName(source)
- //sql := ` SELECT b.* FROM %s AS a
- // INNER JOIN edb_info AS b ON a.from_edb_info_id=b.edb_info_id
- // WHERE a.edb_info_id=? ORDER BY sort ASC `
- //sql = fmt.Sprintf(sql, calculateTableName)
- sql := ` SELECT b.* FROM edb_info_calculate_mapping AS a
- INNER JOIN edb_info AS b ON a.from_edb_info_id=b.edb_info_id
- WHERE a.edb_info_id=? ORDER BY sort ASC `
- err = o.Raw(sql, edbInfoId).Find(&list).Error
- return
- }
- // GetEdbInfoAllCalculateByEdbInfoIdList 根据指标id集合 获取基础指标对应的所有计算指标
- func GetEdbInfoAllCalculateByEdbInfoIdList(edbInfoIdList []int) (list []*EdbInfo, err error) {
- num := len(edbInfoIdList)
- if num <= 0 {
- return
- }
- o := global.DmSQL["data"]
- sql := ` SELECT b.* FROM edb_info_calculate_mapping AS a
- INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
- WHERE a.from_edb_info_id in (` + utils.GetGormInReplace(num) + `)
- GROUP BY a.edb_info_id
- ORDER BY a.edb_info_id ASC `
- err = o.Raw(sql, edbInfoIdList).Scan(&list).Error
- return
- }
- // func GetEdbInfoCalculateMap(edbInfoId, source int) (list []*EdbInfo, err error) {
- // o := orm.NewOrmUsingDB("data")
- // //calculateTableName := GetEdbInfoCalculateTableName(source)
- // //sql := ` SELECT b.* FROM %s AS a
- // // INNER JOIN edb_info AS b ON a.from_edb_info_id=b.edb_info_id
- // // WHERE a.edb_info_id=? ORDER BY sort ASC `
- // //sql = fmt.Sprintf(sql, calculateTableName)
- // sql := ` SELECT b.* FROM edb_info_calculate_mapping AS a
- // INNER JOIN edb_info AS b ON a.from_edb_info_id=b.edb_info_id
- // WHERE a.edb_info_id=? ORDER BY sort ASC `
- // _, err = o.Raw(sql, edbInfoId).QueryRows(&list)
- // return
- // }
- // // GetEdbInfoAllCalculateByEdbInfoIdList 根据指标id集合 获取基础指标对应的所有计算指标
- // func GetEdbInfoAllCalculateByEdbInfoIdList(edbInfoIdList []int) (list []*EdbInfo, err error) {
- // num := len(edbInfoIdList)
- // if num <= 0 {
- // return
- // }
- // o := orm.NewOrmUsingDB("data")
- // sql := ` SELECT b.* FROM edb_info_calculate_mapping AS a
- // INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
- // WHERE a.from_edb_info_id in (` + utils.GetOrmInReplace(num) + `)
- // GROUP BY a.edb_info_id
- // ORDER BY a.edb_info_id ASC `
- // _, err = o.Raw(sql, edbInfoIdList).QueryRows(&list)
- // return
- // }
- // EdbInfoCalculateMappingInfo
- //
- // type EdbInfoCalculateMappingInfo struct {
- // EdbInfoCalculateMappingId int `orm:"column(edb_info_calculate_mapping_id);pk"`
- // EdbInfoId int `description:"计算指标id"`
- // Source int `description:"计算指标来源"`
- // SourceName string `description:"计算指标来源名称"`
- // EdbCode string `description:"计算指标编码"`
- // FromEdbInfoId int `description:"基础指标id"`
- // FromEdbCode string `description:"基础指标编码"`
- // FromEdbName string `description:"基础指标名称"`
- // FromSource int `description:"基础指标来源"`
- // FromSourceName string `description:"基础指标来源名称"`
- // MoveValue int `description:"领先值"`
- // FromTag string `description:"来源指标标签"`
- // Sort int `description:"计算指标名称排序"`
- // CreateTime time.Time `description:"创建时间"`
- // ModifyTime time.Time `description:"修改时间"`
- // FromEdbType int `description:"来源指标类型:1:基础指标,2:计算指标"`
- // FromEdbInfoType int `description:"来源指标类型: 0-基础指标; 1-预测指标"`
- // FromClassifyId int `description:"来源指标分类ID"`
- // FromUniqueCode string `description:"来源指标唯一编码"`
- // }
- type EdbInfoCalculateMappingInfo struct {
- EdbInfoCalculateMappingId int `gorm:"column:edb_info_calculate_mapping_id;primaryKey" description:"计算指标映射ID" orm:"column(edb_info_calculate_mapping_id);pk"`
- EdbInfoId int `gorm:"column:edb_info_id" description:"计算指标id"`
- Source int `gorm:"column:source" description:"计算指标来源"`
- SourceName string `gorm:"column:source_name" description:"计算指标来源名称"`
- EdbCode string `gorm:"column:edb_code" description:"计算指标编码"`
- FromEdbInfoId int `gorm:"column:from_edb_info_id" description:"基础指标id"`
- FromEdbCode string `gorm:"column:from_edb_code" description:"基础指标编码"`
- FromEdbName string `gorm:"column:from_edb_name" description:"基础指标名称"`
- FromSource int `gorm:"column:from_source" description:"基础指标来源"`
- FromSourceName string `gorm:"column:from_source_name" description:"基础指标来源名称"`
- MoveValue int `gorm:"column:move_value" description:"领先值"`
- FromTag string `gorm:"column:from_tag" description:"来源指标标签"`
- Sort int `gorm:"column:sort" description:"计算指标名称排序"`
- CreateTime time.Time `gorm:"column:create_time" description:"创建时间"`
- ModifyTime time.Time `gorm:"column:modify_time" description:"修改时间"`
- FromEdbType int `gorm:"column:from_edb_type" description:"来源指标类型:1:基础指标,2:计算指标"`
- FromEdbInfoType int `gorm:"column:from_edb_info_type" description:"来源指标类型: 0-基础指标; 1-预测指标"`
- FromClassifyId int `gorm:"column:from_classify_id" description:"来源指标分类ID"`
- FromUniqueCode string `gorm:"column:from_unique_code" description:"来源指标唯一编码"`
- }
- // GetEdbInfoCalculateMappingListByEdbInfoId 根据生成的指标id获取来源的指标id列表
- func GetEdbInfoCalculateMappingListByEdbInfoId(edbInfoId int) (items []*EdbInfoCalculateMappingInfo, err error) {
- o := global.DmSQL["data"]
- sql := ` SELECT a.*,b.edb_type as from_edb_type,b.edb_info_type as from_edb_info_type, b.unique_code AS from_unique_code, b.classify_id AS from_classify_id FROM edb_info_calculate_mapping AS a
- INNER JOIN edb_info AS b ON a.from_edb_info_id=b.edb_info_id
- WHERE a.edb_info_id=? `
- err = o.Raw(sql, edbInfoId).Scan(&items).Error
- return
- }
- // GetEdbInfoCalculateMappingListByEdbInfoId 根据生成的指标id获取来源的指标id列表
- // func GetEdbInfoCalculateMappingListByEdbInfoId(edbInfoId int) (items []*EdbInfoCalculateMappingInfo, err error) {
- // o := orm.NewOrmUsingDB("data")
- // sql := ` SELECT a.*,b.edb_type as from_edb_type,b.edb_info_type as from_edb_info_type, b.unique_code AS from_unique_code, b.classify_id AS from_classify_id FROM edb_info_calculate_mapping AS a
- // INNER JOIN edb_info AS b ON a.from_edb_info_id=b.edb_info_id
- // WHERE a.edb_info_id=? `
- // _, err = o.Raw(sql, edbInfoId).QueryRows(&items)
- // return
- // }
|