package predict_edb_conf_calculate_mapping

import (
	"hongze/hongze_yb/global"
	"time"
)

// GetPredictEdbRuleDataList 根据基础预测指标id集合 获取 所有的普通指标列表数据
func GetPredictEdbRuleDataList(fromEdbInfoIdList []int) (items []*PredictEdbConfCalculateMappingDetail, err error) {
	sql := ` SELECT a.predict_edb_conf_calculate_mapping_id,a.edb_info_id,a.from_edb_info_id,a.from_edb_code,a.from_source,a.from_source_name,a.sort,a.create_time,a.modify_time,a.from_tag,b.edb_name_source as from_edb_name,b.start_date,b.end_date,b.edb_type,b.edb_code FROM predict_edb_conf_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 in (?) GROUP BY a.edb_info_id ORDER BY sort ASC `

	err = global.MYSQL["data"].Raw(sql, fromEdbInfoIdList).Scan(&items).Error
	return
}

type PredictEdbConfCalculateMappingDetail struct {
	PredictEdbConfCalculateMappingId int       `orm:"column(predict_edb_conf_calculate_mapping_id);pk"`
	EdbInfoId                        int       `description:"指标id"`
	ConfigId                         int       `description:"配置id"`
	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:"结束日期"`
	EdbType                          int       `description:"指标类型:1:基础指标,2:计算指标"`
	EdbCode                          string    `description:"指标code"`
}
