浏览代码

刷新设置批量停用启用

kobe6258 1 周之前
父节点
当前提交
64587bbd19
共有 3 个文件被更改,包括 50 次插入4 次删除
  1. 20 0
      controllers/data_manage/edb_info.go
  2. 6 4
      models/data_manage/edb_info.go
  3. 24 0
      services/data/edb_info_relation.go

+ 20 - 0
controllers/data_manage/edb_info.go

@@ -3899,6 +3899,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
 
@@ -5660,6 +5670,16 @@ 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
+				}
 			}
 		}
 

+ 6 - 4
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
@@ -761,14 +763,14 @@ type EdbInfoMaxAndMinInfo struct {
 }
 
 func (edbInfoMaxAndMinInfo *EdbInfoMaxAndMinInfo) AfterFind(tx *gorm.DB) (err error) {
-			edbInfoMaxAndMinInfo.MinDate = utils.GormDateStrToDateStr(edbInfoMaxAndMinInfo.MinDate)
-			edbInfoMaxAndMinInfo.MaxDate = utils.GormDateStrToDateStr(edbInfoMaxAndMinInfo.MaxDate)
+	edbInfoMaxAndMinInfo.MinDate = utils.GormDateStrToDateStr(edbInfoMaxAndMinInfo.MinDate)
+	edbInfoMaxAndMinInfo.MaxDate = utils.GormDateStrToDateStr(edbInfoMaxAndMinInfo.MaxDate)
 	return
 }
 
 func (edbInfoMaxAndMinInfo *EdbInfoMaxAndMinInfo) ConvertTimeStr() {
-			edbInfoMaxAndMinInfo.MinDate = utils.GormDateStrToDateStr(edbInfoMaxAndMinInfo.MinDate)
-			edbInfoMaxAndMinInfo.MaxDate = utils.GormDateStrToDateStr(edbInfoMaxAndMinInfo.MaxDate)
+	edbInfoMaxAndMinInfo.MinDate = utils.GormDateStrToDateStr(edbInfoMaxAndMinInfo.MinDate)
+	edbInfoMaxAndMinInfo.MaxDate = utils.GormDateStrToDateStr(edbInfoMaxAndMinInfo.MaxDate)
 }
 
 // GetEdbInfoMaxAndMinInfo

+ 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 {