فهرست منبع

Merge branch 'feature/eta_2.5.6_pb_data_deal' into debug

kobe6258 1 ماه پیش
والد
کامیت
e1618f5946
3فایلهای تغییر یافته به همراه46 افزوده شده و 1 حذف شده
  1. 20 1
      controllers/data_manage/edb_info.go
  2. 2 0
      models/data_manage/edb_info.go
  3. 24 0
      services/data/edb_info_relation.go

+ 20 - 1
controllers/data_manage/edb_info.go

@@ -3904,6 +3904,16 @@ func (this *ChartInfoController) EdbInfoData() {
 	fullEdb.EdbInfo = edbInfo
 	// 是否供应商停更
 	fullEdb.IsSupplierStop = data.GetIsSupplierStop(edbInfo.Source, edbInfo.EdbCode)
+	//是否被引用
+	relation, err := data.GetEdbRelationListById(edbInfo.EdbInfoId, edbInfo.Source)
+	if err != nil {
+		br.Msg = err.Error()
+		br.ErrMsg = "获取指标关联关系失败,err:" + err.Error()
+		return
+	}
+	if relation.RelationNum > 0 {
+		fullEdb.IsRelation = true
+	}
 
 	fullEdb.ClassifyList = classifyList
 
@@ -5671,9 +5681,18 @@ func (this *EdbInfoController) EdbChartList() {
 						v.IsSupplierStop = 1
 					}
 				}
+				var relation *data_manage.BaseRelationEdbInfo
+				relation, err = data.GetEdbRelationListById(v.EdbInfoId, v.Source)
+				if err != nil {
+					br.Msg = "获取失败"
+					br.ErrMsg = "获取数据引用信息失败,Err:" + e.Error()
+					return
+				}
+				if relation.RelationNum > 0 {
+					v.IsRelation = true
+				}
 			}
 		}
-
 		page = paging.GetPaging(currentIndex, pageSize, int(dataCount))
 	}
 

+ 2 - 0
models/data_manage/edb_info.go

@@ -104,6 +104,7 @@ type EdbInfoFullClassify struct {
 	ClassifyList   []*EdbClassifyIdItems
 	HaveOperaAuth  bool `description:"是否有数据权限,默认:false"`
 	IsSupplierStop int  `description:"是否供应商停更:1:停更,0:未停更"`
+	IsRelation     bool `description:"是否被引用,默认:0"`
 }
 
 func AddEdbInfo(item *EdbInfo) (lastId int64, err error) {
@@ -527,6 +528,7 @@ type EdbInfoList struct {
 	MinValue         float64                 `description:"最小值"`
 	MaxValue         float64                 `description:"最大值"`
 	SearchText       string                  `description:"搜索结果(含高亮)"`
+	IsRelation       bool                    `description:"是否被引用"`
 }
 
 // AfterFind

+ 24 - 0
services/data/edb_info_relation.go

@@ -495,6 +495,30 @@ func GetEdbRelationListByIds(edbIds []int, source int) (total int, list []*data_
 	return
 }
 
+// GetEdbRelationList 获取指标引用列表
+func GetEdbRelationListById(edbId int, source int) (item *data_manage.BaseRelationEdbInfo, err error) {
+	var pars []interface{}
+	var condition string
+	condition += ` AND e.edb_info_id = ?`
+	pars = append(pars, edbId)
+	list := make([]*data_manage.BaseRelationEdbInfo, 0)
+	// 关联表语句
+	var addFieldStr, joinTableStr string
+	// 供应商停用
+	if source == utils.DATA_SOURCE_MYSTEEL_CHEMICAL {
+		joinTableStr = ` LEFT JOIN base_from_mysteel_chemical_index z ON e.edb_code = z.index_code `
+		addFieldStr = ` ,z.is_supplier_stop `
+	}
+	_, list, err = data_manage.GetEdbInfoRelationList(condition, pars, addFieldStr, joinTableStr, "", 0, 1)
+	if err != nil {
+		return
+	}
+	if len(list) > 0 {
+		item = list[0]
+	}
+	return
+}
+
 // 查找当前计算指标的所有溯源指标
 func GetEdbListByEdbInfoId(edbInfoList []*data_manage.EdbInfo, needPredict bool) (edbMappingListMap map[int]*data_manage.EdbInfoCalculateMapping, edbInfoMappingRootIdsMap map[int][]int, err error) {
 	if len(edbInfoList) == 0 {