|
@@ -15,12 +15,12 @@ import (
|
|
// SaveChartEdbInfoRelation 添加/编辑图表指标引用关联记录
|
|
// SaveChartEdbInfoRelation 添加/编辑图表指标引用关联记录
|
|
func SaveChartEdbInfoRelation(edbInfoIds []int, chartInfo *data_manage.ChartInfo) (err error) {
|
|
func SaveChartEdbInfoRelation(edbInfoIds []int, chartInfo *data_manage.ChartInfo) (err error) {
|
|
//更新指标刷新状态为启用
|
|
//更新指标刷新状态为启用
|
|
- err = saveEdbInfoRelation(edbInfoIds, chartInfo.ChartInfoId, utils.EDB_RELATION_CHART, chartInfo.Source)
|
|
|
|
|
|
+ err = saveEdbInfoRelation(edbInfoIds, chartInfo.ChartInfoId, utils.EDB_RELATION_CHART, chartInfo.Source, false)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
// saveEdbInfoRelation 添加/编辑图表指标引用关联记录
|
|
// saveEdbInfoRelation 添加/编辑图表指标引用关联记录
|
|
-func saveEdbInfoRelation(edbInfoIds []int, objectId, objectType, objectSubType int) (err error) {
|
|
|
|
|
|
+func saveEdbInfoRelation(edbInfoIds []int, objectId, objectType, objectSubType int, needPredict bool) (err error) {
|
|
// 实现添加引用记录的逻辑
|
|
// 实现添加引用记录的逻辑
|
|
if len(edbInfoIds) == 0 {
|
|
if len(edbInfoIds) == 0 {
|
|
return
|
|
return
|
|
@@ -43,13 +43,13 @@ func saveEdbInfoRelation(edbInfoIds []int, objectId, objectType, objectSubType i
|
|
// 过滤预测指标
|
|
// 过滤预测指标
|
|
edbInfoList := make([]*data_manage.EdbInfo, 0)
|
|
edbInfoList := make([]*data_manage.EdbInfo, 0)
|
|
for _, v := range edbInfoListTmp {
|
|
for _, v := range edbInfoListTmp {
|
|
- if v.EdbInfoType == 0 {
|
|
|
|
|
|
+ if v.EdbInfoType == 0 || (v.EdbType == 1 && v.EdbInfoType == 1 && needPredict) {
|
|
edbInfoList = append(edbInfoList, v)
|
|
edbInfoList = append(edbInfoList, v)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// 查询计算指标信息,并且建立关联关系
|
|
// 查询计算指标信息,并且建立关联关系
|
|
// 查询间接引用的指标信息
|
|
// 查询间接引用的指标信息
|
|
- calculateEdbMappingListMap, calculateEdbMappingIdsMap, e := GetEdbListByEdbInfoId(edbInfoList)
|
|
|
|
|
|
+ calculateEdbMappingListMap, calculateEdbMappingIdsMap, e := GetEdbListByEdbInfoId(edbInfoList, needPredict)
|
|
if e != nil {
|
|
if e != nil {
|
|
err = fmt.Errorf("查询计算指标信息失败,%s", e.Error())
|
|
err = fmt.Errorf("查询计算指标信息失败,%s", e.Error())
|
|
return
|
|
return
|
|
@@ -103,7 +103,7 @@ func saveEdbInfoRelation(edbInfoIds []int, objectId, objectType, objectSubType i
|
|
}
|
|
}
|
|
tmp.RelationCode = fmt.Sprintf("%d_%d_%d_%d", tmp.EdbInfoId, tmp.ReferObjectId, tmp.ReferObjectType, tmp.ReferObjectSubType)
|
|
tmp.RelationCode = fmt.Sprintf("%d_%d_%d_%d", tmp.EdbInfoId, tmp.ReferObjectId, tmp.ReferObjectType, tmp.ReferObjectSubType)
|
|
addList = append(addList, tmp)
|
|
addList = append(addList, tmp)
|
|
- if edbInfo.EdbType == 2 && edbInfo.EdbInfoType == 0 {
|
|
|
|
|
|
+ if (edbInfo.EdbType == 2 && edbInfo.EdbInfoType == 0) || (edbInfo.EdbType == 1 && edbInfo.EdbInfoType == 1 && needPredict) {
|
|
childEdbMappingIds, ok1 := calculateEdbMappingIdsMap[edbInfo.EdbInfoId]
|
|
childEdbMappingIds, ok1 := calculateEdbMappingIdsMap[edbInfo.EdbInfoId]
|
|
if !ok1 {
|
|
if !ok1 {
|
|
continue
|
|
continue
|
|
@@ -165,7 +165,7 @@ func SaveSandBoxEdbInfoRelation(sandBoxId int, sandBoxContent string) (err error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
//更新指标刷新状态为启用
|
|
//更新指标刷新状态为启用
|
|
- err = saveEdbInfoRelation(edbInfoIds, sandBoxId, utils.EDB_RELATION_SANDBOX, 0)
|
|
|
|
|
|
+ err = saveEdbInfoRelation(edbInfoIds, sandBoxId, utils.EDB_RELATION_SANDBOX, 0, false)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -254,7 +254,7 @@ func SaveCalendarEdbInfoRelation(chartPermissionId int, matterDate string, editM
|
|
}
|
|
}
|
|
// 查询计算指标信息,并且建立关联关系
|
|
// 查询计算指标信息,并且建立关联关系
|
|
// 查询间接引用的指标信息
|
|
// 查询间接引用的指标信息
|
|
- calculateEdbMappingListMap, calculateEdbMappingIdsMap, e := GetEdbListByEdbInfoId(edbInfoList)
|
|
|
|
|
|
+ calculateEdbMappingListMap, calculateEdbMappingIdsMap, e := GetEdbListByEdbInfoId(edbInfoList, false)
|
|
if e != nil {
|
|
if e != nil {
|
|
err = fmt.Errorf("查询计算指标信息失败,%s", e.Error())
|
|
err = fmt.Errorf("查询计算指标信息失败,%s", e.Error())
|
|
return
|
|
return
|
|
@@ -456,13 +456,13 @@ func GetEdbRelationList(source, edbType int, classifyId, sysUserId, frequency, k
|
|
}
|
|
}
|
|
|
|
|
|
// 查找当前计算指标的所有溯源指标
|
|
// 查找当前计算指标的所有溯源指标
|
|
-func GetEdbListByEdbInfoId(edbInfoList []*data_manage.EdbInfo) (edbMappingListMap map[int]*data_manage.EdbInfoCalculateMapping, edbInfoMappingRootIdsMap map[int][]int, err error) {
|
|
|
|
|
|
+func GetEdbListByEdbInfoId(edbInfoList []*data_manage.EdbInfo, needPredict bool) (edbMappingListMap map[int]*data_manage.EdbInfoCalculateMapping, edbInfoMappingRootIdsMap map[int][]int, err error) {
|
|
if len(edbInfoList) == 0 {
|
|
if len(edbInfoList) == 0 {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
edbInfoIds := make([]int, 0)
|
|
edbInfoIds := make([]int, 0)
|
|
for _, v := range edbInfoList {
|
|
for _, v := range edbInfoList {
|
|
- if v.EdbType == 2 && v.EdbInfoType == 0 { //普通计算指标,排除预算指标
|
|
|
|
|
|
+ if (v.EdbType == 2 && v.EdbInfoType == 0) || (v.EdbType == 1 && v.EdbInfoType == 1 && needPredict) { //普通计算指标,或者是基础预测指标
|
|
edbInfoIds = append(edbInfoIds, v.EdbInfoId)
|
|
edbInfoIds = append(edbInfoIds, v.EdbInfoId)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -492,7 +492,7 @@ func GetEdbListByEdbInfoId(edbInfoList []*data_manage.EdbInfo) (edbMappingListMa
|
|
edbInfoMappingRootIdsMap = make(map[int][]int, 0)
|
|
edbInfoMappingRootIdsMap = make(map[int][]int, 0)
|
|
edbMappingMap := make(map[int]struct{})
|
|
edbMappingMap := make(map[int]struct{})
|
|
for _, edbInfo := range edbInfoList {
|
|
for _, edbInfo := range edbInfoList {
|
|
- if edbInfo.EdbType == 2 && edbInfo.EdbInfoType == 0 {
|
|
|
|
|
|
+ if (edbInfo.EdbType == 2 && edbInfo.EdbInfoType == 0) || (edbInfo.EdbType == 1 && edbInfo.EdbInfoType == 1 && needPredict) {
|
|
edbInfoId := edbInfo.EdbInfoId
|
|
edbInfoId := edbInfo.EdbInfoId
|
|
edbMappingList, err = getCalculateEdbInfoByEdbInfoId(allEdbMappingMap, edbInfoId, hasFindMap, edbInfoIdMap, edbMappingList, edbMappingMap, edbInfoMappingRootIdsMap, edbInfoId)
|
|
edbMappingList, err = getCalculateEdbInfoByEdbInfoId(allEdbMappingMap, edbInfoId, hasFindMap, edbInfoIdMap, edbMappingList, edbMappingMap, edbInfoMappingRootIdsMap, edbInfoId)
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -636,7 +636,7 @@ func SaveExcelEdbInfoRelation(excelInfoId, source int, addChildExcel bool) (err
|
|
if !ok {
|
|
if !ok {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- err = saveEdbInfoRelation(edbInfoIds, v.ExcelInfoId, utils.EDB_RELATION_TABLE, source)
|
|
|
|
|
|
+ err = saveEdbInfoRelation(edbInfoIds, v.ExcelInfoId, utils.EDB_RELATION_TABLE, source, false)
|
|
}
|
|
}
|
|
//更新
|
|
//更新
|
|
}
|
|
}
|
|
@@ -656,7 +656,14 @@ func SaveExcelEdbInfoRelation(excelInfoId, source int, addChildExcel bool) (err
|
|
if len(edbInfoIds) == 0 {
|
|
if len(edbInfoIds) == 0 {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- err = saveEdbInfoRelation(edbInfoIds, excelInfoId, utils.EDB_RELATION_TABLE, source)
|
|
|
|
|
|
+ err = saveEdbInfoRelation(edbInfoIds, excelInfoId, utils.EDB_RELATION_TABLE, source, false)
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// SavePredictEdbInfoRelation 添加/编辑预测指标引用关联记录
|
|
|
|
+func SavePredictEdbInfoRelation(edbInfoIds []int, edbInfoId int) (err error) {
|
|
|
|
+ //更新指标刷新状态为启用
|
|
|
|
+ err = saveEdbInfoRelation(edbInfoIds, edbInfoId, utils.EDB_RELATION_PREDICT_EDB, 1, true)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|