edb_info_relation.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. package data
  2. import (
  3. "eta/eta_api/models/data_manage"
  4. "eta/eta_api/models/fe_calendar"
  5. "eta/eta_api/services/alarm_msg"
  6. "eta/eta_api/services/sandbox"
  7. "eta/eta_api/utils"
  8. "fmt"
  9. "strings"
  10. "time"
  11. )
  12. // SaveChartEdbInfoRelation 添加/编辑图表指标引用关联记录
  13. func SaveChartEdbInfoRelation(edbInfoIds []int, chartInfo *data_manage.ChartInfo) (err error) {
  14. //更新指标刷新状态为启用
  15. err = saveEdbInfoRelation(edbInfoIds, chartInfo.ChartInfoId, utils.EDB_RELATION_CHART, chartInfo.Source)
  16. return
  17. }
  18. // saveEdbInfoRelation 添加/编辑图表指标引用关联记录
  19. func saveEdbInfoRelation(edbInfoIds []int, objectId, objectType, objectSubType int) (err error) {
  20. // 实现添加引用记录的逻辑
  21. if len(edbInfoIds) == 0 {
  22. return
  23. }
  24. defer func() {
  25. if err != nil {
  26. tips := "实现添加引用记录的逻辑-添加/编辑图表指标引用关联记录失败, ErrMsg:\n" + err.Error()
  27. utils.FileLog.Info(tips)
  28. go alarm_msg.SendAlarmMsg(tips, 3)
  29. }
  30. }()
  31. refreshIds := make([]int, 0)
  32. indexCodeList := make([]string, 0)
  33. // 查询指标信息
  34. edbInfoList, e := data_manage.GetEdbInfoByIdList(edbInfoIds)
  35. if e != nil {
  36. err = fmt.Errorf("查询指标信息失败,%s", e.Error())
  37. return
  38. }
  39. // 查询计算指标信息,并且建立关联关系
  40. // 查询间接引用的指标信息
  41. calculateEdbListMap, calculateEdbMappingListMap, calculateEdbMappingIdsMap, e := GetEdbListByEdbInfoId(edbInfoList)
  42. if e != nil {
  43. err = fmt.Errorf("查询计算指标信息失败,%s", e.Error())
  44. return
  45. }
  46. // 只统计钢联化工和wind来源的指标
  47. for _, edbInfo := range edbInfoList {
  48. /*if edbInfo.Source != utils.DATA_SOURCE_WIND && edbInfo.Source != utils.DATA_SOURCE_MYSTEEL_CHEMICAL {
  49. continue
  50. }*/
  51. refreshIds = append(refreshIds, edbInfo.EdbInfoId)
  52. if edbInfo.Source == utils.DATA_SOURCE_MYSTEEL_CHEMICAL {
  53. indexCodeList = append(indexCodeList, edbInfo.EdbCode)
  54. }
  55. }
  56. // 循转组装引用
  57. // 查询已有的引用关系
  58. existList, e := data_manage.GetEdbInfoRelationByReferObjectId(objectId, objectType)
  59. if e != nil {
  60. err = fmt.Errorf("查询已有的引用关系失败,%s", e.Error())
  61. return
  62. }
  63. deleteMap := make(map[int]bool)
  64. relationMap := make(map[int]bool)
  65. for _, exist := range existList {
  66. deleteMap[exist.EdbInfoId] = true
  67. relationMap[exist.EdbInfoId] = true
  68. }
  69. // 新增不存在的引用关系
  70. // 删除不再需要的引用关系
  71. nowTime := time.Now()
  72. addList := make([]*data_manage.EdbInfoRelation, 0)
  73. deleteEdbInfoIds := make([]int, 0)
  74. for _, edbInfo := range edbInfoList {
  75. /*if edbInfo.Source != utils.DATA_SOURCE_WIND && edbInfo.Source != utils.DATA_SOURCE_MYSTEEL_CHEMICAL {
  76. continue
  77. }*/
  78. if _, ok := relationMap[edbInfo.EdbInfoId]; ok {
  79. delete(deleteMap, edbInfo.EdbInfoId)
  80. } else {
  81. tmp := &data_manage.EdbInfoRelation{
  82. ReferObjectId: objectId,
  83. ReferObjectType: objectType,
  84. ReferObjectSubType: objectSubType,
  85. EdbInfoId: edbInfo.EdbInfoId,
  86. EdbName: edbInfo.EdbName,
  87. Source: edbInfo.Source,
  88. EdbCode: edbInfo.EdbCode,
  89. CreateTime: nowTime,
  90. ModifyTime: nowTime,
  91. RelationTime: nowTime,
  92. }
  93. addList = append(addList, tmp)
  94. if edbInfo.EdbType == 2 {
  95. childEdbMappingIds, ok1 := calculateEdbMappingIdsMap[edbInfo.EdbInfoId]
  96. if !ok1 {
  97. continue
  98. }
  99. for _, childEdbMappingId := range childEdbMappingIds {
  100. childEdbMapping, ok2 := calculateEdbMappingListMap[childEdbMappingId]
  101. if !ok2 {
  102. continue
  103. }
  104. childEdb, ok2 := calculateEdbListMap[childEdbMapping.FromEdbInfoId]
  105. if !ok2 {
  106. continue
  107. }
  108. if childEdb.Source == utils.DATA_SOURCE_MYSTEEL_CHEMICAL {
  109. indexCodeList = append(indexCodeList, childEdb.EdbCode)
  110. }
  111. tmp1 := &data_manage.EdbInfoRelation{
  112. ReferObjectId: objectId,
  113. ReferObjectType: objectType,
  114. ReferObjectSubType: objectSubType,
  115. EdbInfoId: childEdb.EdbInfoId,
  116. EdbName: childEdb.EdbName,
  117. Source: childEdb.Source,
  118. EdbCode: childEdb.EdbCode,
  119. CreateTime: nowTime,
  120. ModifyTime: nowTime,
  121. RelationTime: nowTime,
  122. RelationType: 1,
  123. RootEdbInfoId: edbInfo.EdbInfoId,
  124. ChildEdbInfoId: childEdbMapping.EdbInfoId,
  125. }
  126. addList = append(addList, tmp1)
  127. refreshIds = append(refreshIds, childEdb.EdbInfoId)
  128. // todo 防止重复
  129. }
  130. }
  131. }
  132. }
  133. // 删除不再需要的引用关系
  134. for deleteId, _ := range deleteMap {
  135. deleteEdbInfoIds = append(deleteEdbInfoIds, deleteId)
  136. }
  137. //更新指标刷新状态为启用
  138. err = data_manage.AddOrUpdateEdbInfoRelation(objectId, objectType, addList, deleteEdbInfoIds, refreshIds, indexCodeList)
  139. if err != nil {
  140. err = fmt.Errorf("删除不再需要的引用关系失败,%s", err.Error())
  141. return
  142. }
  143. return
  144. }
  145. // SaveSandBoxEdbInfoRelation 添加/编辑 eta逻辑图指标引用
  146. func SaveSandBoxEdbInfoRelation(sandBoxId int, sandBoxContent string) (err error) {
  147. edbInfoIds, err := sandbox.GetSandBoxEdbIdsByContent(sandBoxContent)
  148. if err != nil {
  149. return
  150. }
  151. if len(edbInfoIds) == 0 {
  152. return
  153. }
  154. //更新指标刷新状态为启用
  155. err = saveEdbInfoRelation(edbInfoIds, sandBoxId, utils.EDB_RELATION_SANDBOX, 0)
  156. return
  157. }
  158. // SaveCalendarEdbInfoRelation 添加/编辑 事件日历指标引用
  159. func SaveCalendarEdbInfoRelation(chartPermissionId int, matterDate string, editMatters, removeMatters []*fe_calendar.FeCalendarMatter) (err error) {
  160. //整理相关的事件ID
  161. matterIds := make([]int, 0)
  162. updateMatterMap := make(map[int]*fe_calendar.FeCalendarMatter)
  163. deleteMatterMap := make(map[int]struct{})
  164. for _, matter := range removeMatters {
  165. deleteMatterMap[matter.FeCalendarMatterId] = struct{}{}
  166. matterIds = append(matterIds, matter.FeCalendarMatterId)
  167. }
  168. for _, matter := range editMatters {
  169. updateMatterMap[matter.FeCalendarMatterId] = matter
  170. matterIds = append(matterIds, matter.FeCalendarMatterId)
  171. }
  172. //删除ID,先删除
  173. deleteObjectIds := make([]int, 0)
  174. if len(matterIds) > 0 {
  175. relationList, e := data_manage.GetEdbInfoRelationAllByReferObjectIds(matterIds, utils.EDB_RELATION_CALENDAR)
  176. if e != nil {
  177. err = fmt.Errorf("查询事件日历指标引用失败,%s", e.Error())
  178. return
  179. }
  180. for _, relation := range relationList {
  181. if _, ok := deleteMatterMap[relation.ReferObjectId]; ok {
  182. deleteObjectIds = append(deleteObjectIds, relation.ReferObjectId)
  183. }
  184. if newMatter, ok := updateMatterMap[relation.ReferObjectId]; ok {
  185. if relation.EdbInfoId != newMatter.EdbInfoId {
  186. deleteObjectIds = append(deleteObjectIds, relation.ReferObjectId)
  187. }
  188. }
  189. }
  190. }
  191. if len(deleteObjectIds) > 0 {
  192. err = data_manage.DeleteEdbRelationByObjectIds(deleteObjectIds, utils.EDB_RELATION_CALENDAR)
  193. if err != nil {
  194. err = fmt.Errorf("删除事件日历指标引用失败,%s", err.Error())
  195. return
  196. }
  197. }
  198. // 获取已有事项
  199. matterOb := new(fe_calendar.FeCalendarMatter)
  200. cond := fmt.Sprintf(` AND %s = ? AND %s = ?`, fe_calendar.FeCalendarMatterCols.ChartPermissionId, fe_calendar.FeCalendarMatterCols.MatterDate)
  201. pars := make([]interface{}, 0)
  202. pars = append(pars, chartPermissionId, matterDate)
  203. order := fmt.Sprintf(`%s ASC`, fe_calendar.FeCalendarMatterCols.Sort)
  204. matters, e := matterOb.GetItemsByCondition(cond, pars, []string{}, order)
  205. if e != nil {
  206. err = fmt.Errorf("查询事件日历事项失败,%s", e.Error())
  207. return
  208. }
  209. // 循环查询matters
  210. edbInfoIds := make([]int, 0)
  211. refreshIds := make([]int, 0)
  212. indexCodeList := make([]string, 0)
  213. newMatterIds := make([]int, 0)
  214. for _, matter := range matters {
  215. newMatterIds = append(newMatterIds, matter.FeCalendarMatterId)
  216. edbInfoIds = append(edbInfoIds, matter.EdbInfoId)
  217. }
  218. // 查询指标信息
  219. edbInfoList, e := data_manage.GetEdbInfoByIdList(edbInfoIds)
  220. if e != nil {
  221. err = fmt.Errorf("查询指标信息失败,%s", e.Error())
  222. return
  223. }
  224. // 查询计算指标信息,并且建立关联关系
  225. // 查询间接引用的指标信息
  226. calculateEdbListMap, calculateEdbMappingListMap, calculateEdbMappingIdsMap, e := GetEdbListByEdbInfoId(edbInfoList)
  227. if e != nil {
  228. err = fmt.Errorf("查询计算指标信息失败,%s", e.Error())
  229. return
  230. }
  231. addEdbInfoIdMap := make(map[int]*data_manage.EdbInfo)
  232. for _, edbInfo := range edbInfoList {
  233. /*if edbInfo.Source != utils.DATA_SOURCE_WIND && edbInfo.Source != utils.DATA_SOURCE_MYSTEEL_CHEMICAL {
  234. continue
  235. }*/
  236. refreshIds = append(refreshIds, edbInfo.EdbInfoId)
  237. addEdbInfoIdMap[edbInfo.EdbInfoId] = edbInfo
  238. if edbInfo.Source == utils.DATA_SOURCE_MYSTEEL_CHEMICAL {
  239. indexCodeList = append(indexCodeList, edbInfo.EdbCode)
  240. }
  241. }
  242. relationMap := make(map[int]struct{})
  243. if len(newMatterIds) > 0 {
  244. //查询已有的matters
  245. relationList, e := data_manage.GetEdbInfoRelationByReferObjectIds(newMatterIds, utils.EDB_RELATION_CALENDAR)
  246. if e != nil {
  247. err = fmt.Errorf("查询事件日历指标引用失败,%s", e.Error())
  248. return
  249. }
  250. for _, relation := range relationList {
  251. relationMap[relation.ReferObjectId] = struct{}{}
  252. }
  253. }
  254. addList := make([]*data_manage.EdbInfoRelation, 0)
  255. nowTime := time.Now()
  256. for _, matter := range matters {
  257. _, ok1 := relationMap[matter.FeCalendarMatterId]
  258. edbInfo, ok2 := addEdbInfoIdMap[matter.EdbInfoId]
  259. if !ok1 && ok2 {
  260. tmp := &data_manage.EdbInfoRelation{
  261. ReferObjectId: matter.FeCalendarMatterId,
  262. ReferObjectType: utils.EDB_RELATION_CALENDAR,
  263. ReferObjectSubType: 0,
  264. EdbInfoId: edbInfo.EdbInfoId,
  265. EdbName: edbInfo.EdbName,
  266. Source: edbInfo.Source,
  267. EdbCode: edbInfo.EdbCode,
  268. CreateTime: nowTime,
  269. ModifyTime: nowTime,
  270. }
  271. addList = append(addList, tmp)
  272. //todo 添加指标间接引用
  273. if edbInfo.EdbType == 2 {
  274. childEdbMappingIds, ok1 := calculateEdbMappingIdsMap[edbInfo.EdbInfoId]
  275. if !ok1 {
  276. continue
  277. }
  278. for _, childEdbMappingId := range childEdbMappingIds {
  279. childEdbMapping, ok2 := calculateEdbMappingListMap[childEdbMappingId]
  280. if !ok2 {
  281. continue
  282. }
  283. childEdb, ok2 := calculateEdbListMap[childEdbMapping.FromEdbInfoId]
  284. if !ok2 {
  285. continue
  286. }
  287. if childEdb.Source == utils.DATA_SOURCE_MYSTEEL_CHEMICAL {
  288. indexCodeList = append(indexCodeList, childEdb.EdbCode)
  289. }
  290. tmp1 := &data_manage.EdbInfoRelation{
  291. ReferObjectId: matter.FeCalendarMatterId,
  292. ReferObjectType: utils.EDB_RELATION_CALENDAR,
  293. ReferObjectSubType: 0,
  294. EdbInfoId: childEdb.EdbInfoId,
  295. EdbName: childEdb.EdbName,
  296. Source: childEdb.Source,
  297. EdbCode: childEdb.EdbCode,
  298. CreateTime: nowTime,
  299. ModifyTime: nowTime,
  300. RelationTime: nowTime,
  301. RelationType: 1,
  302. RootEdbInfoId: edbInfo.EdbInfoId,
  303. ChildEdbInfoId: childEdbMapping.EdbInfoId,
  304. }
  305. addList = append(addList, tmp1)
  306. refreshIds = append(refreshIds, childEdb.EdbInfoId)
  307. // todo 防止重复
  308. }
  309. }
  310. }
  311. }
  312. //更新指标刷新状态为启用
  313. err = data_manage.AddOrUpdateEdbInfoRelationFeMatter(addList, refreshIds, indexCodeList)
  314. if err != nil {
  315. err = fmt.Errorf("添加指标引用,%s", err.Error())
  316. return
  317. }
  318. return
  319. }
  320. // GetEdbRelationList 获取指标引用列表
  321. func GetEdbRelationList(source int, classifyId, sysUserId, frequency, keyword, status string, startSize, pageSize int, sortParam, sortType string) (total int, list []*data_manage.BaseRelationEdbInfo, err error) {
  322. var pars []interface{}
  323. var condition string
  324. list = make([]*data_manage.BaseRelationEdbInfo, 0)
  325. isStop := -1
  326. if status == `暂停` {
  327. isStop = 1
  328. } else if status == "启用" {
  329. isStop = 0
  330. }
  331. switch source {
  332. case utils.DATA_SOURCE_MYSTEEL_CHEMICAL, utils.DATA_SOURCE_WIND:
  333. condition += ` AND e.source = ? `
  334. pars = append(pars, source)
  335. if isStop >= 0 {
  336. condition += " AND e.no_update = ? "
  337. pars = append(pars, isStop)
  338. }
  339. if classifyId != `` {
  340. classifyIdSlice := strings.Split(classifyId, ",")
  341. condition += ` AND e.classify_id IN (` + utils.GetOrmInReplace(len(classifyIdSlice)) + `)`
  342. pars = append(pars, classifyIdSlice)
  343. }
  344. if sysUserId != `` {
  345. sysUserIdSlice := strings.Split(sysUserId, ",")
  346. condition += ` AND e.sys_user_id IN (` + utils.GetOrmInReplace(len(sysUserIdSlice)) + `)`
  347. pars = append(pars, sysUserIdSlice)
  348. }
  349. if frequency != `` {
  350. frequencySlice := strings.Split(frequency, ",")
  351. condition += ` AND e.frequency IN (` + utils.GetOrmInReplace(len(frequencySlice)) + `)`
  352. pars = append(pars, frequencySlice)
  353. }
  354. if keyword != `` {
  355. keywordSlice := strings.Split(keyword, " ")
  356. if len(keywordSlice) > 0 {
  357. tmpConditionSlice := make([]string, 0)
  358. tmpConditionSlice = append(tmpConditionSlice, ` e.edb_name like ? or e.edb_code like ? `)
  359. pars = utils.GetLikeKeywordPars(pars, keyword, 2)
  360. for _, v := range keywordSlice {
  361. if v == ` ` || v == `` {
  362. continue
  363. }
  364. tmpConditionSlice = append(tmpConditionSlice, ` e.edb_name like ? or e.edb_code like ? `)
  365. pars = utils.GetLikeKeywordPars(pars, v, 2)
  366. }
  367. condition += ` AND (` + strings.Join(tmpConditionSlice, " or ") + `)`
  368. } else {
  369. condition += ` AND (e.edb_name like ? or e.edb_code like ? )`
  370. pars = utils.GetLikeKeywordPars(pars, keyword, 2)
  371. }
  372. }
  373. sortStr := ``
  374. if sortParam != `` {
  375. sortStr = fmt.Sprintf("%s %s,e.edb_info_id desc ", sortParam, sortType)
  376. }
  377. total, list, err = data_manage.GetEdbInfoRelationList(condition, pars, sortStr, startSize, pageSize)
  378. }
  379. return
  380. }
  381. func GetEdbListByEdbInfoId(edbInfoList []*data_manage.EdbInfo) (edbInfoMap map[int]*data_manage.EdbInfo, edbMappingListMap map[int]*data_manage.EdbInfoCalculateMapping, edbInfoMappingRootIdsMap map[int][]int, err error) {
  382. //查询指标信息
  383. //查询指标映射
  384. //查询所有指标数据
  385. //查询这个指标相关的mapping信息放到数组里,
  386. //将得到的指标ID信息放到数组里
  387. hasFindMap := make(map[int]struct{})
  388. edbInfoIdMap := make(map[int]struct{})
  389. edbMappingList := make([]*data_manage.EdbInfoCalculateMapping, 0)
  390. edbInfoMappingRootIdsMap = make(map[int][]int, 0)
  391. edbMappingMap := make(map[int]struct{})
  392. for _, edbInfo := range edbInfoList {
  393. if edbInfo.EdbType == 2 {
  394. edbInfoId := edbInfo.EdbInfoId
  395. edbMappingList, err = GetCalculateEdbInfoByEdbInfoId(edbInfoId, hasFindMap, edbInfoIdMap, edbMappingList, edbMappingMap, edbInfoMappingRootIdsMap, edbInfoId)
  396. if err != nil {
  397. err = fmt.Errorf(" GetCalculateEdbInfoByEdbInfoId err: %s", err.Error())
  398. return
  399. }
  400. }
  401. }
  402. if len(edbMappingList) == 0 {
  403. return
  404. }
  405. // 查询指标信息
  406. // 指标信息map
  407. edbInfoIdList := make([]int, 0)
  408. for k, _ := range edbInfoIdMap {
  409. edbInfoIdList = append(edbInfoIdList, k)
  410. }
  411. edbInfoMap = make(map[int]*data_manage.EdbInfo)
  412. edbMappingListMap = make(map[int]*data_manage.EdbInfoCalculateMapping)
  413. if len(edbInfoIdList) > 0 {
  414. edbInfoList, err = data_manage.GetEdbInfoByIdList(edbInfoIdList)
  415. if err != nil {
  416. err = fmt.Errorf(" GetEdbInfoByIdList err: %s", err.Error())
  417. return
  418. }
  419. for _, v := range edbInfoList {
  420. edbInfoMap[v.EdbInfoId] = v
  421. }
  422. }
  423. if len(edbMappingList) > 0 {
  424. for _, v := range edbMappingList {
  425. edbMappingListMap[v.EdbInfoCalculateMappingId] = v
  426. }
  427. }
  428. return
  429. }
  430. // GetCalculateEdbInfoByEdbInfoId 计算指标追溯
  431. 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) {
  432. newEdbMappingList = edbMappingList
  433. _, ok := hasFindMap[edbInfoId]
  434. if ok {
  435. return
  436. }
  437. if _, ok1 := edbInfoIdMap[edbInfoId]; !ok1 {
  438. edbInfoIdMap[edbInfoId] = struct{}{}
  439. }
  440. edbInfoMappingList, e := data_manage.GetEdbInfoCalculateMappingListByEdbInfoId(edbInfoId)
  441. if e != nil {
  442. err = fmt.Errorf("GetEdbInfoCalculateMappingListByEdbInfoId err: %s", e.Error())
  443. return
  444. }
  445. if len(edbInfoMappingList) > 0 {
  446. fromEdbInfoIdList := make([]int, 0)
  447. edbInfoMappingIdList := make([]int, 0)
  448. for _, v := range edbInfoMappingList {
  449. fromEdbInfoIdList = append(fromEdbInfoIdList, v.FromEdbInfoId)
  450. edbInfoMappingIdList = append(edbInfoMappingIdList, v.EdbInfoCalculateMappingId)
  451. if _, ok1 := edbInfoIdMap[v.FromEdbInfoId]; !ok1 {
  452. edbInfoIdMap[v.FromEdbInfoId] = struct{}{}
  453. }
  454. if _, ok2 := edbMappingMap[v.EdbInfoCalculateMappingId]; !ok2 {
  455. edbMappingMap[v.EdbInfoCalculateMappingId] = struct{}{}
  456. tmp := &data_manage.EdbInfoCalculateMapping{
  457. EdbInfoCalculateMappingId: v.EdbInfoCalculateMappingId,
  458. EdbInfoId: v.EdbInfoId,
  459. Source: v.Source,
  460. SourceName: v.SourceName,
  461. EdbCode: v.EdbCode,
  462. FromEdbInfoId: v.FromEdbInfoId,
  463. FromEdbCode: v.FromEdbCode,
  464. FromEdbName: v.FromEdbName,
  465. FromSource: v.FromSource,
  466. FromSourceName: v.FromSourceName,
  467. FromTag: v.FromTag,
  468. Sort: v.Sort,
  469. CreateTime: v.CreateTime,
  470. ModifyTime: v.ModifyTime,
  471. }
  472. newEdbMappingList = append(newEdbMappingList, tmp)
  473. }
  474. if edbInfoId != v.FromEdbInfoId && (v.FromEdbType == 2 || v.FromEdbInfoType == 1) {
  475. // 查过了就不查了
  476. if _, ok2 := hasFindMap[v.FromEdbInfoId]; !ok2 {
  477. newEdbMappingList, e = GetCalculateEdbInfoByEdbInfoId(v.FromEdbInfoId, hasFindMap, edbInfoIdMap, newEdbMappingList, edbMappingMap, edbInfoMappingRootIdsMap, rootEdbInfoId)
  478. if e != nil {
  479. err = fmt.Errorf("traceEdbInfoByEdbInfoId err: %s", e.Error())
  480. return
  481. }
  482. }
  483. }
  484. hasFindMap[v.FromEdbInfoId] = struct{}{}
  485. }
  486. edbInfoMappingRootIdsMap[rootEdbInfoId] = append(edbInfoMappingRootIdsMap[rootEdbInfoId], edbInfoMappingIdList...)
  487. }
  488. hasFindMap[edbInfoId] = struct{}{}
  489. return
  490. }