|
@@ -14,10 +14,10 @@ import (
|
|
|
)
|
|
|
|
|
|
func InitEdbRelation() {
|
|
|
- //InitChartEdbRelation()
|
|
|
- //InitChartCrossVariety()
|
|
|
- //initCalendarIndicatorRelation()
|
|
|
- //initSandBoxEdbRelation()
|
|
|
+ InitChartEdbRelation()
|
|
|
+ InitChartCrossVariety()
|
|
|
+ initCalendarIndicatorRelation()
|
|
|
+ initSandBoxEdbRelation()
|
|
|
InitExcelEdbRelation()
|
|
|
}
|
|
|
func InitChartEdbRelation() {
|
|
@@ -72,7 +72,7 @@ func InitChartEdbRelation() {
|
|
|
}
|
|
|
// 查询计算指标信息,并且建立关联关系
|
|
|
// 查询间接引用的指标信息
|
|
|
- calculateEdbListMap, calculateEdbMappingListMap, calculateEdbMappingIdsMap, e := GetEdbListByEdbInfoId(edbInfoList)
|
|
|
+ calculateEdbMappingListMap, calculateEdbMappingIdsMap, e := GetEdbListByEdbInfoId(edbInfoList)
|
|
|
if e != nil {
|
|
|
err = fmt.Errorf("查询计算指标信息失败,%s", e.Error())
|
|
|
return
|
|
@@ -144,10 +144,11 @@ func InitChartEdbRelation() {
|
|
|
ModifyTime: nowTime,
|
|
|
RelationTime: v.CreateTime,
|
|
|
}
|
|
|
+ tmp.RelationCode = fmt.Sprintf("%d_%d_%d_%d", tmp.EdbInfoId, tmp.ReferObjectId, tmp.ReferObjectType, tmp.ReferObjectSubType)
|
|
|
addList = append(addList, tmp)
|
|
|
existRelationMap[name] = struct{}{}
|
|
|
// 添加间接引用记录
|
|
|
- if edbInfo.EdbType == 2 {
|
|
|
+ if edbInfo.EdbType == 2 || edbInfo.EdbInfoType == 1 {
|
|
|
childEdbMappingIds, ok1 := calculateEdbMappingIdsMap[edbInfo.EdbInfoId]
|
|
|
if !ok1 {
|
|
|
continue
|
|
@@ -161,24 +162,21 @@ func InitChartEdbRelation() {
|
|
|
if _, ok2 := existRelationMap[name1]; !ok2 { //如果已经被直接引用了,则无需添加到间接引用记录中
|
|
|
continue
|
|
|
}
|
|
|
- childEdb, ok2 := calculateEdbListMap[childEdbMapping.FromEdbInfoId]
|
|
|
- if !ok2 {
|
|
|
- continue
|
|
|
- }
|
|
|
tmp1 := &data_manage.EdbInfoRelation{
|
|
|
ReferObjectId: v.ChartInfoId,
|
|
|
ReferObjectType: utils.EDB_RELATION_CHART,
|
|
|
ReferObjectSubType: chartInfo.Source,
|
|
|
- EdbInfoId: childEdb.EdbInfoId,
|
|
|
- EdbName: childEdb.EdbName,
|
|
|
- Source: childEdb.Source,
|
|
|
- EdbCode: childEdb.EdbCode,
|
|
|
+ EdbInfoId: childEdbMapping.FromEdbInfoId,
|
|
|
+ EdbName: childEdbMapping.FromEdbName,
|
|
|
+ Source: childEdbMapping.FromSource,
|
|
|
+ EdbCode: childEdbMapping.FromEdbCode,
|
|
|
CreateTime: nowTime,
|
|
|
ModifyTime: nowTime,
|
|
|
RelationTime: v.CreateTime,
|
|
|
RelationType: 1,
|
|
|
RootEdbInfoId: edbInfo.EdbInfoId,
|
|
|
ChildEdbInfoId: childEdbMapping.EdbInfoId,
|
|
|
+ RelationCode: tmp.RelationCode,
|
|
|
}
|
|
|
addList = append(addList, tmp1)
|
|
|
// todo 防止重复
|
|
@@ -307,7 +305,7 @@ func InitChartCrossVariety() {
|
|
|
}
|
|
|
// 查询计算指标信息,并且建立关联关系
|
|
|
// 查询间接引用的指标信息
|
|
|
- calculateEdbListMap, calculateEdbMappingListMap, calculateEdbMappingIdsMap, e := GetEdbListByEdbInfoId(edbInfoList)
|
|
|
+ calculateEdbMappingListMap, calculateEdbMappingIdsMap, e := GetEdbListByEdbInfoId(edbInfoList)
|
|
|
if e != nil {
|
|
|
err = fmt.Errorf("查询计算指标信息失败,%s", e.Error())
|
|
|
return
|
|
@@ -380,10 +378,11 @@ func InitChartCrossVariety() {
|
|
|
ModifyTime: nowTime,
|
|
|
RelationTime: item.CreateTime,
|
|
|
}
|
|
|
+ tmp.RelationCode = fmt.Sprintf("%d_%d_%d_%d", tmp.EdbInfoId, tmp.ReferObjectId, tmp.ReferObjectType, tmp.ReferObjectSubType)
|
|
|
addList = append(addList, tmp)
|
|
|
existRelationMap[name] = struct{}{}
|
|
|
// 添加间接引用记录
|
|
|
- if edbInfo.EdbType == 2 {
|
|
|
+ if edbInfo.EdbType == 2 || edbInfo.EdbInfoType == 1 {
|
|
|
childEdbMappingIds, ok1 := calculateEdbMappingIdsMap[edbInfo.EdbInfoId]
|
|
|
if !ok1 {
|
|
|
continue
|
|
@@ -397,24 +396,22 @@ func InitChartCrossVariety() {
|
|
|
if _, ok2 := existRelationMap[name1]; !ok2 { //如果已经被直接引用了,则无需添加到间接引用记录中
|
|
|
continue
|
|
|
}
|
|
|
- childEdb, ok2 := calculateEdbListMap[childEdbMapping.FromEdbInfoId]
|
|
|
- if !ok2 {
|
|
|
- continue
|
|
|
- }
|
|
|
+
|
|
|
tmp1 := &data_manage.EdbInfoRelation{
|
|
|
ReferObjectId: item.ChartInfoId,
|
|
|
ReferObjectType: utils.EDB_RELATION_CHART,
|
|
|
ReferObjectSubType: utils.CHART_SOURCE_CROSS_HEDGING,
|
|
|
- EdbInfoId: childEdb.EdbInfoId,
|
|
|
- EdbName: childEdb.EdbName,
|
|
|
- Source: childEdb.Source,
|
|
|
- EdbCode: childEdb.EdbCode,
|
|
|
+ EdbInfoId: childEdbMapping.FromEdbInfoId,
|
|
|
+ EdbName: childEdbMapping.FromEdbName,
|
|
|
+ Source: childEdbMapping.FromSource,
|
|
|
+ EdbCode: childEdbMapping.FromEdbCode,
|
|
|
CreateTime: nowTime,
|
|
|
ModifyTime: nowTime,
|
|
|
RelationTime: item.CreateTime,
|
|
|
RelationType: 1,
|
|
|
RootEdbInfoId: edbInfo.EdbInfoId,
|
|
|
ChildEdbInfoId: childEdbMapping.EdbInfoId,
|
|
|
+ RelationCode: tmp.RelationCode,
|
|
|
}
|
|
|
addList = append(addList, tmp1)
|
|
|
// todo 防止重复
|
|
@@ -512,7 +509,7 @@ func initCalendarIndicatorRelation() {
|
|
|
|
|
|
// 查询计算指标信息,并且建立关联关系
|
|
|
// 查询间接引用的指标信息
|
|
|
- calculateEdbListMap, calculateEdbMappingListMap, calculateEdbMappingIdsMap, e := GetEdbListByEdbInfoId(edbInfoList)
|
|
|
+ calculateEdbMappingListMap, calculateEdbMappingIdsMap, e := GetEdbListByEdbInfoId(edbInfoList)
|
|
|
if e != nil {
|
|
|
err = fmt.Errorf("查询计算指标信息失败,%s", e.Error())
|
|
|
return
|
|
@@ -559,10 +556,11 @@ func initCalendarIndicatorRelation() {
|
|
|
ModifyTime: nowTime,
|
|
|
RelationTime: v.CreateTime,
|
|
|
}
|
|
|
+ tmp.RelationCode = fmt.Sprintf("%d_%d_%d_%d", tmp.EdbInfoId, tmp.ReferObjectId, tmp.ReferObjectType, tmp.ReferObjectSubType)
|
|
|
addList = append(addList, tmp)
|
|
|
existRelationMap[name] = struct{}{}
|
|
|
// 添加间接引用记录
|
|
|
- if edbInfo.EdbType == 2 {
|
|
|
+ if edbInfo.EdbType == 2 || edbInfo.EdbInfoType == 1 {
|
|
|
childEdbMappingIds, ok1 := calculateEdbMappingIdsMap[edbInfo.EdbInfoId]
|
|
|
if !ok1 {
|
|
|
continue
|
|
@@ -576,23 +574,20 @@ func initCalendarIndicatorRelation() {
|
|
|
if _, ok2 := existRelationMap[name1]; !ok2 { //如果已经被直接引用了,则无需添加到间接引用记录中
|
|
|
continue
|
|
|
}
|
|
|
- childEdb, ok2 := calculateEdbListMap[childEdbMapping.FromEdbInfoId]
|
|
|
- if !ok2 {
|
|
|
- continue
|
|
|
- }
|
|
|
tmp1 := &data_manage.EdbInfoRelation{
|
|
|
ReferObjectId: v.FeCalendarMatterId,
|
|
|
ReferObjectType: utils.EDB_RELATION_CALENDAR,
|
|
|
- EdbInfoId: childEdb.EdbInfoId,
|
|
|
- EdbName: childEdb.EdbName,
|
|
|
- Source: childEdb.Source,
|
|
|
- EdbCode: childEdb.EdbCode,
|
|
|
+ EdbInfoId: childEdbMapping.FromEdbInfoId,
|
|
|
+ EdbName: childEdbMapping.FromEdbName,
|
|
|
+ Source: childEdbMapping.FromSource,
|
|
|
+ EdbCode: childEdbMapping.FromEdbCode,
|
|
|
CreateTime: nowTime,
|
|
|
ModifyTime: nowTime,
|
|
|
RelationTime: v.CreateTime,
|
|
|
RelationType: 1,
|
|
|
RootEdbInfoId: edbInfo.EdbInfoId,
|
|
|
ChildEdbInfoId: childEdbMapping.EdbInfoId,
|
|
|
+ RelationCode: tmp.RelationCode,
|
|
|
}
|
|
|
addList = append(addList, tmp1)
|
|
|
// todo 防止重复
|
|
@@ -680,7 +675,7 @@ func InitExcelEdbRelation() {
|
|
|
}
|
|
|
// 查询计算指标信息,并且建立关联关系
|
|
|
// 查询间接引用的指标信息
|
|
|
- calculateEdbListMap, calculateEdbMappingListMap, calculateEdbMappingIdsMap, e := GetEdbListByEdbInfoId(edbInfoList)
|
|
|
+ calculateEdbMappingListMap, calculateEdbMappingIdsMap, e := GetEdbListByEdbInfoId(edbInfoList)
|
|
|
if e != nil {
|
|
|
err = fmt.Errorf("查询计算指标信息失败,%s", e.Error())
|
|
|
return
|
|
@@ -729,10 +724,11 @@ func InitExcelEdbRelation() {
|
|
|
ModifyTime: nowTime,
|
|
|
RelationTime: v.CreateTime,
|
|
|
}
|
|
|
+ tmp.RelationCode = fmt.Sprintf("%d_%d_%d_%d", tmp.EdbInfoId, tmp.ReferObjectId, tmp.ReferObjectType, tmp.ReferObjectSubType)
|
|
|
addList = append(addList, tmp)
|
|
|
existRelationMap[name] = struct{}{}
|
|
|
// 添加间接引用记录
|
|
|
- if edbInfo.EdbType == 2 {
|
|
|
+ if edbInfo.EdbType == 2 || edbInfo.EdbInfoType == 1 {
|
|
|
childEdbMappingIds, ok1 := calculateEdbMappingIdsMap[edbInfo.EdbInfoId]
|
|
|
if !ok1 {
|
|
|
continue
|
|
@@ -746,24 +742,21 @@ func InitExcelEdbRelation() {
|
|
|
if _, ok2 := existRelationMap[name1]; !ok2 { //如果已经被直接引用了,则无需添加到间接引用记录中
|
|
|
continue
|
|
|
}
|
|
|
- childEdb, ok2 := calculateEdbListMap[childEdbMapping.FromEdbInfoId]
|
|
|
- if !ok2 {
|
|
|
- continue
|
|
|
- }
|
|
|
tmp1 := &data_manage.EdbInfoRelation{
|
|
|
ReferObjectId: v.ExcelInfoId,
|
|
|
ReferObjectType: utils.EDB_RELATION_TABLE,
|
|
|
ReferObjectSubType: v.Source,
|
|
|
- EdbInfoId: childEdb.EdbInfoId,
|
|
|
- EdbName: childEdb.EdbName,
|
|
|
- Source: childEdb.Source,
|
|
|
- EdbCode: childEdb.EdbCode,
|
|
|
+ EdbInfoId: childEdbMapping.FromEdbInfoId,
|
|
|
+ EdbName: childEdbMapping.FromEdbName,
|
|
|
+ Source: childEdbMapping.FromSource,
|
|
|
+ EdbCode: childEdbMapping.FromEdbCode,
|
|
|
CreateTime: nowTime,
|
|
|
ModifyTime: nowTime,
|
|
|
RelationTime: v.CreateTime,
|
|
|
RelationType: 1,
|
|
|
RootEdbInfoId: edbInfo.EdbInfoId,
|
|
|
ChildEdbInfoId: childEdbMapping.EdbInfoId,
|
|
|
+ RelationCode: tmp.RelationCode,
|
|
|
}
|
|
|
addList = append(addList, tmp1)
|
|
|
// todo 防止重复
|
|
@@ -864,7 +857,7 @@ func initSandBoxEdbRelation() {
|
|
|
}
|
|
|
// 查询计算指标信息,并且建立关联关系
|
|
|
// 查询间接引用的指标信息
|
|
|
- calculateEdbListMap, calculateEdbMappingListMap, calculateEdbMappingIdsMap, e := GetEdbListByEdbInfoId(edbInfoList)
|
|
|
+ calculateEdbMappingListMap, calculateEdbMappingIdsMap, e := GetEdbListByEdbInfoId(edbInfoList)
|
|
|
if e != nil {
|
|
|
err = fmt.Errorf("查询计算指标信息失败,%s", e.Error())
|
|
|
return
|
|
@@ -912,10 +905,11 @@ func initSandBoxEdbRelation() {
|
|
|
ModifyTime: nowTime,
|
|
|
RelationTime: v.CreateTime,
|
|
|
}
|
|
|
+ tmp.RelationCode = fmt.Sprintf("%d_%d_%d_%d", tmp.EdbInfoId, tmp.ReferObjectId, tmp.ReferObjectType, tmp.ReferObjectSubType)
|
|
|
addList = append(addList, tmp)
|
|
|
existRelationMap[name] = struct{}{}
|
|
|
// 添加间接引用记录
|
|
|
- if edbInfo.EdbType == 2 {
|
|
|
+ if edbInfo.EdbType == 2 || edbInfo.EdbInfoType == 1 {
|
|
|
childEdbMappingIds, ok1 := calculateEdbMappingIdsMap[edbInfo.EdbInfoId]
|
|
|
if !ok1 {
|
|
|
continue
|
|
@@ -929,23 +923,20 @@ func initSandBoxEdbRelation() {
|
|
|
if _, ok2 := existRelationMap[name1]; !ok2 { //如果已经被直接引用了,则无需添加到间接引用记录中
|
|
|
continue
|
|
|
}
|
|
|
- childEdb, ok2 := calculateEdbListMap[childEdbMapping.FromEdbInfoId]
|
|
|
- if !ok2 {
|
|
|
- continue
|
|
|
- }
|
|
|
tmp1 := &data_manage.EdbInfoRelation{
|
|
|
ReferObjectId: v.SandboxId,
|
|
|
ReferObjectType: utils.EDB_RELATION_SANDBOX,
|
|
|
- EdbInfoId: childEdb.EdbInfoId,
|
|
|
- EdbName: childEdb.EdbName,
|
|
|
- Source: childEdb.Source,
|
|
|
- EdbCode: childEdb.EdbCode,
|
|
|
+ EdbInfoId: childEdbMapping.FromEdbInfoId,
|
|
|
+ EdbName: childEdbMapping.FromEdbName,
|
|
|
+ Source: childEdbMapping.FromSource,
|
|
|
+ EdbCode: childEdbMapping.FromEdbCode,
|
|
|
CreateTime: nowTime,
|
|
|
ModifyTime: nowTime,
|
|
|
RelationTime: v.CreateTime,
|
|
|
RelationType: 1,
|
|
|
RootEdbInfoId: edbInfo.EdbInfoId,
|
|
|
ChildEdbInfoId: childEdbMapping.EdbInfoId,
|
|
|
+ RelationCode: tmp.RelationCode,
|
|
|
}
|
|
|
addList = append(addList, tmp1)
|
|
|
// todo 防止重复
|
|
@@ -998,13 +989,13 @@ func getSandBoxEdbIdsByContent(content string) (edbInfoIds []int, err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func GetEdbListByEdbInfoId(edbInfoList []*data_manage.EdbInfo) (edbInfoMap map[int]*data_manage.EdbInfo, edbMappingListMap map[int]*data_manage.EdbInfoCalculateMapping, edbInfoMappingRootIdsMap map[int][]int, err error) {
|
|
|
+func GetEdbListByEdbInfoId(edbInfoList []*data_manage.EdbInfo) (edbMappingListMap map[int]*data_manage.EdbInfoCalculateMapping, edbInfoMappingRootIdsMap map[int][]int, err error) {
|
|
|
if len(edbInfoList) == 0 {
|
|
|
return
|
|
|
}
|
|
|
edbInfoIds := make([]int, 0)
|
|
|
for _, v := range edbInfoList {
|
|
|
- if v.EdbType == 2 {
|
|
|
+ if v.EdbType == 2 || v.EdbInfoType == 1 {
|
|
|
edbInfoIds = append(edbInfoIds, v.EdbInfoId)
|
|
|
}
|
|
|
}
|
|
@@ -1034,7 +1025,7 @@ func GetEdbListByEdbInfoId(edbInfoList []*data_manage.EdbInfo) (edbInfoMap map[i
|
|
|
edbInfoMappingRootIdsMap = make(map[int][]int, 0)
|
|
|
edbMappingMap := make(map[int]struct{})
|
|
|
for _, edbInfo := range edbInfoList {
|
|
|
- if edbInfo.EdbType == 2 {
|
|
|
+ if edbInfo.EdbType == 2 || edbInfo.EdbInfoType == 1 {
|
|
|
edbInfoId := edbInfo.EdbInfoId
|
|
|
edbMappingList, err = getCalculateEdbInfoByEdbInfoId(allEdbMappingMap, edbInfoId, hasFindMap, edbInfoIdMap, edbMappingList, edbMappingMap, edbInfoMappingRootIdsMap, edbInfoId)
|
|
|
if err != nil {
|
|
@@ -1052,18 +1043,7 @@ func GetEdbListByEdbInfoId(edbInfoList []*data_manage.EdbInfo) (edbInfoMap map[i
|
|
|
for k, _ := range edbInfoIdMap {
|
|
|
edbInfoIdList = append(edbInfoIdList, k)
|
|
|
}
|
|
|
- edbInfoMap = make(map[int]*data_manage.EdbInfo)
|
|
|
edbMappingListMap = make(map[int]*data_manage.EdbInfoCalculateMapping)
|
|
|
- if len(edbInfoIdList) > 0 {
|
|
|
- edbInfoList, err = data_manage.GetEdbInfoByIdList(edbInfoIdList)
|
|
|
- if err != nil {
|
|
|
- err = fmt.Errorf(" GetEdbInfoByIdList err: %s", err.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- for _, v := range edbInfoList {
|
|
|
- edbInfoMap[v.EdbInfoId] = v
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
if len(edbMappingList) > 0 {
|
|
|
for _, v := range edbMappingList {
|