|
@@ -60,7 +60,7 @@ func InitChartEdbRelation() {
|
|
|
edbInfoIds = append(edbInfoIds, v.EdbInfoId)
|
|
|
}
|
|
|
// 查询指标信息表
|
|
|
- edbInfoList, e := data_manage.GetEdbInfoByIdListAndSource(edbInfoIds, []int{utils.DATA_SOURCE_WIND, utils.DATA_SOURCE_MYSTEEL_CHEMICAL})
|
|
|
+ edbInfoList, e := data_manage.GetEdbInfoByIdList(edbInfoIds)
|
|
|
if e != nil {
|
|
|
err = fmt.Errorf("查询指标信息列表失败 Err:%s", e)
|
|
|
return
|
|
@@ -68,6 +68,14 @@ func InitChartEdbRelation() {
|
|
|
if len(edbInfoList) == 0 {
|
|
|
continue
|
|
|
}
|
|
|
+ // 查询计算指标信息,并且建立关联关系
|
|
|
+ // 查询间接引用的指标信息
|
|
|
+ calculateEdbListMap, calculateEdbMappingListMap, calculateEdbMappingIdsMap, e := GetEdbListByEdbInfoId(edbInfoList)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("查询计算指标信息失败,%s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 查询指标间接引用
|
|
|
edbInfoMap := make(map[int]*data_manage.EdbInfo)
|
|
|
for _, v := range edbInfoList {
|
|
|
edbInfoMap[v.EdbInfoId] = v
|
|
@@ -136,6 +144,41 @@ func InitChartEdbRelation() {
|
|
|
}
|
|
|
addList = append(addList, tmp)
|
|
|
existRelationMap[name] = struct{}{}
|
|
|
+ // 添加间接引用记录
|
|
|
+ if edbInfo.EdbType == 2 {
|
|
|
+ childEdbMappingIds, ok1 := calculateEdbMappingIdsMap[edbInfo.EdbInfoId]
|
|
|
+ if !ok1 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ for _, childEdbMappingId := range childEdbMappingIds {
|
|
|
+ childEdbMapping, ok2 := calculateEdbMappingListMap[childEdbMappingId]
|
|
|
+ if !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,
|
|
|
+ CreateTime: nowTime,
|
|
|
+ ModifyTime: nowTime,
|
|
|
+ RelationTime: v.CreateTime,
|
|
|
+ RelationType: 1,
|
|
|
+ RootEdbInfoId: edbInfo.EdbInfoId,
|
|
|
+ ChildEdbInfoId: childEdbMapping.EdbInfoId,
|
|
|
+ }
|
|
|
+ addList = append(addList, tmp1)
|
|
|
+ // todo 防止重复
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if len(addList) > pageSize {
|
|
|
err = data_manage.AddEdbInfoRelationMulti(addList)
|
|
|
if err != nil {
|
|
@@ -248,7 +291,7 @@ func InitChartCrossVariety() {
|
|
|
}
|
|
|
|
|
|
// 查询指标信息表
|
|
|
- edbInfoList, e := data_manage.GetEdbInfoByIdListAndSource(edbInfoIds, []int{utils.DATA_SOURCE_WIND, utils.DATA_SOURCE_MYSTEEL_CHEMICAL})
|
|
|
+ edbInfoList, e := data_manage.GetEdbInfoByIdList(edbInfoIds)
|
|
|
if e != nil {
|
|
|
err = fmt.Errorf("查询指标信息列表失败 Err:%s", e)
|
|
|
return
|
|
@@ -256,6 +299,13 @@ func InitChartCrossVariety() {
|
|
|
if len(edbInfoList) == 0 {
|
|
|
continue
|
|
|
}
|
|
|
+ // 查询计算指标信息,并且建立关联关系
|
|
|
+ // 查询间接引用的指标信息
|
|
|
+ calculateEdbListMap, calculateEdbMappingListMap, calculateEdbMappingIdsMap, e := GetEdbListByEdbInfoId(edbInfoList)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("查询计算指标信息失败,%s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
edbInfoMap := make(map[int]*data_manage.EdbInfo)
|
|
|
chartInfoCrossMap := make(map[int]struct{})
|
|
|
chartInfoCrossList := make([]*cross_variety.ChartInfoCrossVariety, 0)
|
|
@@ -326,6 +376,40 @@ func InitChartCrossVariety() {
|
|
|
}
|
|
|
addList = append(addList, tmp)
|
|
|
existRelationMap[name] = struct{}{}
|
|
|
+ // 添加间接引用记录
|
|
|
+ if edbInfo.EdbType == 2 {
|
|
|
+ childEdbMappingIds, ok1 := calculateEdbMappingIdsMap[edbInfo.EdbInfoId]
|
|
|
+ if !ok1 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ for _, childEdbMappingId := range childEdbMappingIds {
|
|
|
+ childEdbMapping, ok2 := calculateEdbMappingListMap[childEdbMappingId]
|
|
|
+ if !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,
|
|
|
+ CreateTime: nowTime,
|
|
|
+ ModifyTime: nowTime,
|
|
|
+ RelationTime: item.CreateTime,
|
|
|
+ RelationType: 1,
|
|
|
+ RootEdbInfoId: edbInfo.EdbInfoId,
|
|
|
+ ChildEdbInfoId: childEdbMapping.EdbInfoId,
|
|
|
+ }
|
|
|
+ addList = append(addList, tmp1)
|
|
|
+ // todo 防止重复
|
|
|
+ }
|
|
|
+ }
|
|
|
if len(addList) > pageSize {
|
|
|
err = data_manage.AddEdbInfoRelationMulti(addList)
|
|
|
if err != nil {
|
|
@@ -407,7 +491,7 @@ func initCalendarIndicatorRelation() {
|
|
|
}
|
|
|
}
|
|
|
// 查询指标信息表
|
|
|
- edbInfoList, e := data_manage.GetEdbInfoByIdListAndSource(edbInfoIds, []int{utils.DATA_SOURCE_WIND, utils.DATA_SOURCE_MYSTEEL_CHEMICAL})
|
|
|
+ edbInfoList, e := data_manage.GetEdbInfoByIdList(edbInfoIds)
|
|
|
if e != nil {
|
|
|
err = fmt.Errorf("查询指标信息列表失败 Err:%s", e)
|
|
|
return
|
|
@@ -415,6 +499,14 @@ func initCalendarIndicatorRelation() {
|
|
|
if len(edbInfoList) == 0 {
|
|
|
continue
|
|
|
}
|
|
|
+
|
|
|
+ // 查询计算指标信息,并且建立关联关系
|
|
|
+ // 查询间接引用的指标信息
|
|
|
+ calculateEdbListMap, calculateEdbMappingListMap, calculateEdbMappingIdsMap, e := GetEdbListByEdbInfoId(edbInfoList)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("查询计算指标信息失败,%s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
edbInfoMap := make(map[int]*data_manage.EdbInfo)
|
|
|
matterIds := make([]int, 0)
|
|
|
for _, v := range edbInfoList {
|
|
@@ -459,6 +551,39 @@ func initCalendarIndicatorRelation() {
|
|
|
}
|
|
|
addList = append(addList, tmp)
|
|
|
existRelationMap[name] = struct{}{}
|
|
|
+ // 添加间接引用记录
|
|
|
+ if edbInfo.EdbType == 2 {
|
|
|
+ childEdbMappingIds, ok1 := calculateEdbMappingIdsMap[edbInfo.EdbInfoId]
|
|
|
+ if !ok1 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ for _, childEdbMappingId := range childEdbMappingIds {
|
|
|
+ childEdbMapping, ok2 := calculateEdbMappingListMap[childEdbMappingId]
|
|
|
+ if !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,
|
|
|
+ CreateTime: nowTime,
|
|
|
+ ModifyTime: nowTime,
|
|
|
+ RelationTime: v.CreateTime,
|
|
|
+ RelationType: 1,
|
|
|
+ RootEdbInfoId: edbInfo.EdbInfoId,
|
|
|
+ ChildEdbInfoId: childEdbMapping.EdbInfoId,
|
|
|
+ }
|
|
|
+ addList = append(addList, tmp1)
|
|
|
+ // todo 防止重复
|
|
|
+ }
|
|
|
+ }
|
|
|
if len(addList) > pageSize {
|
|
|
err = data_manage.AddEdbInfoRelationMulti(addList)
|
|
|
if err != nil {
|
|
@@ -546,7 +671,7 @@ func initSandBoxEdbRelation() {
|
|
|
continue
|
|
|
}
|
|
|
// 查询指标信息表
|
|
|
- edbInfoList, e := data_manage.GetEdbInfoByIdListAndSource(edbInfoIds, []int{utils.DATA_SOURCE_WIND, utils.DATA_SOURCE_MYSTEEL_CHEMICAL})
|
|
|
+ edbInfoList, e := data_manage.GetEdbInfoByIdList(edbInfoIds)
|
|
|
if e != nil {
|
|
|
err = fmt.Errorf("查询指标信息列表失败 Err:%s", e)
|
|
|
return
|
|
@@ -554,6 +679,13 @@ func initSandBoxEdbRelation() {
|
|
|
if len(edbInfoList) == 0 {
|
|
|
continue
|
|
|
}
|
|
|
+ // 查询计算指标信息,并且建立关联关系
|
|
|
+ // 查询间接引用的指标信息
|
|
|
+ calculateEdbListMap, calculateEdbMappingListMap, calculateEdbMappingIdsMap, e := GetEdbListByEdbInfoId(edbInfoList)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("查询计算指标信息失败,%s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
edbInfoMap := make(map[int]*data_manage.EdbInfo)
|
|
|
sandboxIds := make([]int, 0)
|
|
|
for _, v := range edbInfoList {
|
|
@@ -599,6 +731,39 @@ func initSandBoxEdbRelation() {
|
|
|
}
|
|
|
addList = append(addList, tmp)
|
|
|
existRelationMap[name] = struct{}{}
|
|
|
+ // 添加间接引用记录
|
|
|
+ if edbInfo.EdbType == 2 {
|
|
|
+ childEdbMappingIds, ok1 := calculateEdbMappingIdsMap[edbInfo.EdbInfoId]
|
|
|
+ if !ok1 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ for _, childEdbMappingId := range childEdbMappingIds {
|
|
|
+ childEdbMapping, ok2 := calculateEdbMappingListMap[childEdbMappingId]
|
|
|
+ if !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,
|
|
|
+ CreateTime: nowTime,
|
|
|
+ ModifyTime: nowTime,
|
|
|
+ RelationTime: v.CreateTime,
|
|
|
+ RelationType: 1,
|
|
|
+ RootEdbInfoId: edbInfo.EdbInfoId,
|
|
|
+ ChildEdbInfoId: childEdbMapping.EdbInfoId,
|
|
|
+ }
|
|
|
+ addList = append(addList, tmp1)
|
|
|
+ // todo 防止重复
|
|
|
+ }
|
|
|
+ }
|
|
|
if len(addList) > pageSize {
|
|
|
err = data_manage.AddEdbInfoRelationMulti(addList)
|
|
|
if err != nil {
|
|
@@ -645,3 +810,122 @@ 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) {
|
|
|
+ //查询指标信息
|
|
|
+ //查询指标映射
|
|
|
+ //查询所有指标数据
|
|
|
+ //查询这个指标相关的mapping信息放到数组里,
|
|
|
+ //将得到的指标ID信息放到数组里
|
|
|
+ hasFindMap := make(map[int]struct{})
|
|
|
+ edbInfoIdMap := make(map[int]struct{})
|
|
|
+ edbMappingList := make([]*data_manage.EdbInfoCalculateMapping, 0)
|
|
|
+ edbInfoMappingRootIdsMap = make(map[int][]int, 0)
|
|
|
+ edbMappingMap := make(map[int]struct{})
|
|
|
+ for _, edbInfo := range edbInfoList {
|
|
|
+ if edbInfo.EdbType == 2 {
|
|
|
+ edbInfoId := edbInfo.EdbInfoId
|
|
|
+ edbMappingList, err = getCalculateEdbInfoByEdbInfoId(edbInfoId, hasFindMap, edbInfoIdMap, edbMappingList, edbMappingMap, edbInfoMappingRootIdsMap, edbInfoId)
|
|
|
+ if err != nil {
|
|
|
+ err = fmt.Errorf(" GetCalculateEdbInfoByEdbInfoId err: %s", err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(edbMappingList) == 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 查询指标信息
|
|
|
+ // 指标信息map
|
|
|
+ edbInfoIdList := make([]int, 0)
|
|
|
+ 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 {
|
|
|
+ edbMappingListMap[v.EdbInfoCalculateMappingId] = v
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// getCalculateEdbInfoByEdbInfoId 计算指标追溯
|
|
|
+func getCalculateEdbInfoByEdbInfoId(edbInfoId int, hasFindMap map[int]struct{}, edbInfoIdMap map[int]struct{}, edbMappingList []*data_manage.EdbInfoCalculateMapping, edbMappingMap map[int]struct{}, edbInfoMappingRootIdsMap map[int][]int, rootEdbInfoId int) (newEdbMappingList []*data_manage.EdbInfoCalculateMapping, err error) {
|
|
|
+ newEdbMappingList = edbMappingList
|
|
|
+ _, ok := hasFindMap[edbInfoId]
|
|
|
+ if ok {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if _, ok1 := edbInfoIdMap[edbInfoId]; !ok1 {
|
|
|
+ edbInfoIdMap[edbInfoId] = struct{}{}
|
|
|
+ }
|
|
|
+
|
|
|
+ edbInfoMappingList, e := data_manage.GetEdbInfoCalculateMappingListByEdbInfoId(edbInfoId)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("GetEdbInfoCalculateMappingListByEdbInfoId err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(edbInfoMappingList) > 0 {
|
|
|
+ fromEdbInfoIdList := make([]int, 0)
|
|
|
+ edbInfoMappingIdList := make([]int, 0)
|
|
|
+ for _, v := range edbInfoMappingList {
|
|
|
+ fromEdbInfoIdList = append(fromEdbInfoIdList, v.FromEdbInfoId)
|
|
|
+ edbInfoMappingIdList = append(edbInfoMappingIdList, v.EdbInfoCalculateMappingId)
|
|
|
+ if _, ok1 := edbInfoIdMap[v.FromEdbInfoId]; !ok1 {
|
|
|
+ edbInfoIdMap[v.FromEdbInfoId] = struct{}{}
|
|
|
+ }
|
|
|
+ if _, ok2 := edbMappingMap[v.EdbInfoCalculateMappingId]; !ok2 {
|
|
|
+ edbMappingMap[v.EdbInfoCalculateMappingId] = struct{}{}
|
|
|
+ tmp := &data_manage.EdbInfoCalculateMapping{
|
|
|
+ EdbInfoCalculateMappingId: v.EdbInfoCalculateMappingId,
|
|
|
+ EdbInfoId: v.EdbInfoId,
|
|
|
+ Source: v.Source,
|
|
|
+ SourceName: v.SourceName,
|
|
|
+ EdbCode: v.EdbCode,
|
|
|
+ FromEdbInfoId: v.FromEdbInfoId,
|
|
|
+ FromEdbCode: v.FromEdbCode,
|
|
|
+ FromEdbName: v.FromEdbName,
|
|
|
+ FromSource: v.FromSource,
|
|
|
+ FromSourceName: v.FromSourceName,
|
|
|
+ FromTag: v.FromTag,
|
|
|
+ Sort: v.Sort,
|
|
|
+ CreateTime: v.CreateTime,
|
|
|
+ ModifyTime: v.ModifyTime,
|
|
|
+ }
|
|
|
+ newEdbMappingList = append(newEdbMappingList, tmp)
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if edbInfoId != v.FromEdbInfoId && (v.FromEdbType == 2 || v.FromEdbInfoType == 1) {
|
|
|
+ // 查过了就不查了
|
|
|
+ if _, ok2 := hasFindMap[v.FromEdbInfoId]; !ok2 {
|
|
|
+ newEdbMappingList, e = getCalculateEdbInfoByEdbInfoId(v.FromEdbInfoId, hasFindMap, edbInfoIdMap, newEdbMappingList, edbMappingMap, edbInfoMappingRootIdsMap, rootEdbInfoId)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("traceEdbInfoByEdbInfoId err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ hasFindMap[v.FromEdbInfoId] = struct{}{}
|
|
|
+ }
|
|
|
+ edbInfoMappingRootIdsMap[rootEdbInfoId] = append(edbInfoMappingRootIdsMap[rootEdbInfoId], edbInfoMappingIdList...)
|
|
|
+ }
|
|
|
+
|
|
|
+ hasFindMap[edbInfoId] = struct{}{}
|
|
|
+ return
|
|
|
+}
|