1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- package data_manage
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- // Seal 计算指标于基础指标,关系表
- type EdbInfoCalculateMapping 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:"基础指标来源名称"`
- FromTag string `description:"来源指标标签"`
- Sort int `description:"计算指标名称排序"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"修改时间"`
- }
- func AddEdbInfoCalculateMappingMulti(items []*EdbInfoCalculateMapping) (err error) {
- o := orm.NewOrmUsingDB("data")
- _, err = o.InsertMulti(1, items)
- return
- }
- func GetEdbInfoCalculateMappingCount(edbInfoId int) (count int, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := ` SELECT COUNT(1) AS count FROM edb_info_calculate_mapping WHERE from_edb_info_id=? `
- err = o.Raw(sql, edbInfoId).QueryRow(&count)
- return
- }
- type EdbInfoCalculateMappingView 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:"基础指标来源名称"`
- FromTag string `description:"来源指标标签"`
- Sort int `description:"计算指标名称排序"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"修改时间"`
- StartDate string `description:"开始日期"`
- EndDate string `description:"结束日期"`
- CalculateFormula string `description:"N值"`
- MoveType int `description:"移动方式:1:领先(默认),2:滞后"`
- MoveFrequency string `description:"移动频度"`
- }
- func GetEdbInfoCalculateMappingDetail(edbInfoId int) (item *EdbInfoCalculateMappingView, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := ` SELECT a.*,b.start_date,b.end_date,b.calculate_formula,b.move_type,b.move_frequency FROM edb_info_calculate_mapping AS a
- INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
- WHERE a.edb_info_id=? `
- err = o.Raw(sql, edbInfoId).QueryRow(&item)
- 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:"修改时间"`
- EdbType int `description:"指标类型:1:基础指标,2:计算指标"`
- }
- // GetEdbInfoCalculateMappingListByEdbInfoId 根据生成的指标id获取来源的指标id列表
- func GetEdbInfoCalculateMappingListByEdbInfoId(edbInfoId int) (items []*EdbInfoCalculateMappingInfo, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := ` SELECT a.*,b.edb_type 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
- }
|