Parcourir la source

新增指标查询指标基本信息

xyxie il y a 1 an
Parent
commit
f65838f729

+ 7 - 1
controllers/data_manage/edb_info.go

@@ -1638,7 +1638,13 @@ func (this *EdbInfoController) EdbInfoSearch() {
 				}
 				isAdd = true
 			}
-
+			// 查询基本信息
+			baseIndexInfo, tErr := data_manage.GetBaseIndexInfoByEdbCode(edbCode, source)
+			if tErr == nil {
+				searchItem.EdbName = baseIndexInfo.IndexName
+				searchItem.Frequency = baseIndexInfo.Frequency
+				searchItem.Unit = baseIndexInfo.Unit
+			}
 			// 指标来源于桥接服务: 桥接服务获取指标取频度信息等
 			if sourceItem.BridgeFlag != "" {
 				bridgeOb := data.InitBridgeOB(sourceItem.BridgeFlag)

+ 25 - 0
models/data_manage/edb_data_base.go

@@ -165,6 +165,14 @@ func GetEdbDataTableName(source int) (tableName string) {
 	return
 }
 
+func GetBaseIndexTableName(source int) (tableName string) {
+	edbSource := EdbSourceIdMap[source]
+	if edbSource != nil {
+		tableName = edbSource.IndexTableName
+	}
+	return
+}
+
 //计算指标->关联的基础指标表
 //func GetEdbInfoCalculateTableName(source int) (tableName string) {
 //	switch source {
@@ -218,6 +226,23 @@ func GetEdbDataAllByEdbCode(edbCode string, source, limit int) (items []*EdbInfo
 	return
 }
 
+func GetBaseIndexInfoByEdbCode(edbCode string, source int) (item *BaseIndexInfo, err error) {
+	var pars []interface{}
+	pars = append(pars, edbCode)
+	o := orm.NewOrmUsingDB("data")
+
+	tableName := GetBaseIndexTableName(source)
+	if tableName == "" {
+		err = fmt.Errorf("未找到对应的表")
+		return
+	}
+	sql := ` SELECT * FROM %s WHERE index_code=? `
+
+	sql = fmt.Sprintf(sql, tableName)
+	err = o.Raw(sql, pars).QueryRow(&item)
+	return
+}
+
 func GetEdbDataBaseByCodeAndDate(source int, edbCode string, startDate string) (count int, err error) {
 	o := orm.NewOrmUsingDB("data")
 	tableName := GetEdbDataTableName(source)

+ 6 - 0
models/data_manage/edb_info.go

@@ -105,6 +105,12 @@ type EdbInfoSearchData struct {
 	Value    float64 `description:"数据"`
 }
 
+type BaseIndexInfo struct {
+	IndexName string `description:"数据日期"`
+	Unit      string `description:"单位"`
+	Frequency string `description:"频率"`
+}
+
 type EdbInfoSearchResp struct {
 	SearchItem      *EdbInfoSearch `description:"指标分类"`
 	Status          int            `description:"1:数据已存在于弘则数据库,2:新数据,3:数据已存在于弘则数据库,但是当前账号无权限"`

+ 1 - 0
models/data_manage/edb_source.go

@@ -23,6 +23,7 @@ type EdbSource struct {
 	BridgeFlag       string `description:"桥接服务对象标识"`
 	SourceExtend     string `description:"扩展字段做查询用"`
 	EdbCodeRequired  int    `description:"指标编码是否必填: 0-否; 1-是"`
+	IndexTableName   string `description:"数据源指标表名"`
 }
 
 // GetEdbSourceItemsByCondition 获取指标来源列表