Browse Source

Merge branch 'fix/edb_trace_0905' into debug

hsun 1 year ago
parent
commit
a94f176d22
2 changed files with 85 additions and 84 deletions
  1. 72 73
      controllers/data_manage/edb_info.go
  2. 13 11
      services/data/edb_info.go

+ 72 - 73
controllers/data_manage/edb_info.go

@@ -4356,6 +4356,78 @@ func (this *EdbInfoController) EdbSourceList() {
 	br.Msg = "获取成功"
 }
 
+// EdbSourceListByPython
+// @Title 指标来源列表
+// @Description 指标来源列表
+// @Param   IsBase   query   int  false	"是否为基础指标: 1-是"
+// @Success 200 {object} data_manage.EdbInfoListResp
+// @router /edb_source/list/python [get]
+func (this *EdbInfoController) EdbSourceListByPython() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		if br.ErrMsg == "" {
+			br.IsSendEmail = false
+		}
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	isBase, _ := this.GetInt("IsBase", 0)
+
+	cond := ``
+	if isBase > 0 {
+		cond = ` AND is_base = 1`
+	}
+	pars := make([]interface{}, 0)
+	list, e := data_manage.GetEdbSourceItemsByCondition(cond, pars, []string{}, "")
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取指标来源列表失败, Err: " + e.Error()
+		return
+	}
+
+	baseEdbList := make([]data_manage.EdbSourceChild, 0)
+	calEdbList := make([]data_manage.EdbSourceChild, 0)
+	for _, v := range list {
+		switch v.IsBase {
+		case 1:
+			baseEdbList = append(baseEdbList, data_manage.EdbSourceChild{
+				EdbSourceId: v.EdbSourceId,
+				SourceName:  v.SourceName,
+				IsBase:      v.IsBase,
+				TableName:   v.TableName,
+				Child:       []data_manage.EdbSourceChild{},
+			})
+		case 2:
+			calEdbList = append(calEdbList, data_manage.EdbSourceChild{
+				EdbSourceId: v.EdbSourceId,
+				SourceName:  v.SourceName,
+				IsBase:      v.IsBase,
+				TableName:   v.TableName,
+				Child:       []data_manage.EdbSourceChild{},
+			})
+		}
+	}
+	resp := []data_manage.EdbSourceChild{
+		{
+			EdbSourceId: 0,
+			SourceName:  "基础指标",
+			IsBase:      1,
+			Child:       baseEdbList,
+		},
+		{
+			EdbSourceId: 0,
+			SourceName:  "计算指标",
+			IsBase:      1,
+			Child:       calEdbList,
+		},
+	}
+
+	br.Data = resp
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}
+
 // EdbChartList
 // @Title 指标缩略图列表接口
 // @Description 指标缩略图列表接口
@@ -4614,76 +4686,3 @@ func (this *EdbInfoController) ChartImageSet() {
 	br.Success = true
 	br.Msg = "保存成功"
 }
-
-// EdbSourceListByPython
-// @Title 指标来源列表
-// @Description 指标来源列表
-// @Param   IsBase   query   int  false	"是否为基础指标: 1-是"
-// @Success 200 {object} data_manage.EdbInfoListResp
-// @router /edb_source/list/python [get]
-func (this *EdbInfoController) EdbSourceListByPython() {
-	br := new(models.BaseResponse).Init()
-	defer func() {
-		if br.ErrMsg == "" {
-			br.IsSendEmail = false
-		}
-		this.Data["json"] = br
-		this.ServeJSON()
-	}()
-	isBase, _ := this.GetInt("IsBase", 0)
-
-	cond := ``
-	if isBase > 0 {
-		cond = ` AND is_base = 1`
-	}
-	pars := make([]interface{}, 0)
-	list, e := data_manage.GetEdbSourceItemsByCondition(cond, pars, []string{}, "")
-	if e != nil {
-		br.Msg = "获取失败"
-		br.ErrMsg = "获取指标来源列表失败, Err: " + e.Error()
-		return
-	}
-
-	baseEdbList := make([]data_manage.EdbSourceChild, 0)
-	calEdbList := make([]data_manage.EdbSourceChild, 0)
-	for _, v := range list {
-		switch v.IsBase {
-		case 1:
-			baseEdbList = append(baseEdbList, data_manage.EdbSourceChild{
-				EdbSourceId: v.EdbSourceId,
-				SourceName:  v.SourceName,
-				IsBase:      v.IsBase,
-				TableName:   v.TableName,
-				Child:       []data_manage.EdbSourceChild{},
-			})
-		case 2:
-			calEdbList = append(calEdbList, data_manage.EdbSourceChild{
-				EdbSourceId: v.EdbSourceId,
-				SourceName:  v.SourceName,
-				IsBase:      v.IsBase,
-				TableName:   v.TableName,
-				Child:       []data_manage.EdbSourceChild{},
-			})
-		}
-	}
-	resp := []data_manage.EdbSourceChild{
-		{
-			EdbSourceId: 0,
-			SourceName:  "基础指标",
-			IsBase:      1,
-			Child:       baseEdbList,
-		},
-		{
-			EdbSourceId: 0,
-			SourceName:  "计算指标",
-			IsBase:      1,
-			Child:       calEdbList,
-		},
-	}
-
-	br.Data = resp
-	br.Ret = 200
-	br.Success = true
-	br.Msg = "获取成功"
-}
-

+ 13 - 11
services/data/edb_info.go

@@ -2621,17 +2621,19 @@ func getEdbRuleTitle(edbInfo, parentEdbInfo *data_manage.EdbInfo, childList []da
 			}
 
 		} else {
-			edbMappingList, ok := edbMappingMap[parentEdbInfo.EdbInfoId]
-			if !ok {
-				edbMappingList = []*data_manage.EdbInfoCalculateMappingInfo{}
-			}
-			tagMap := make(map[string]int)
-			for _, v := range edbMappingList {
-				tagMap[v.FromTag] = v.FromEdbInfoId
-			}
-			for _, v := range config.CheckList {
-				if tmpEdbInfoId, ok := tagMap[v]; ok {
-					childEdbInfoIdList = append(childEdbInfoIdList, tmpEdbInfoId)
+			if parentEdbInfo != nil {
+				edbMappingList, ok := edbMappingMap[parentEdbInfo.EdbInfoId]
+				if !ok {
+					edbMappingList = []*data_manage.EdbInfoCalculateMappingInfo{}
+				}
+				tagMap := make(map[string]int)
+				for _, v := range edbMappingList {
+					tagMap[v.FromTag] = v.FromEdbInfoId
+				}
+				for _, v := range config.CheckList {
+					if tmpEdbInfoId, ok := tagMap[v]; ok {
+						childEdbInfoIdList = append(childEdbInfoIdList, tmpEdbInfoId)
+					}
 				}
 			}
 		}