123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- package data_manage
- import (
- "eta/eta_chart_lib/utils"
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- 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:"来源指标唯一编码"`
- }
- // 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
- }
|