edb_info_replace.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. package services
  2. import (
  3. "encoding/json"
  4. "errors"
  5. "eta_gn/eta_api/models/data_manage"
  6. excelModel "eta_gn/eta_api/models/data_manage/excel"
  7. "eta_gn/eta_api/models/data_manage/excel/request"
  8. "eta_gn/eta_api/services/alarm_msg"
  9. "eta_gn/eta_api/services/data"
  10. "eta_gn/eta_api/services/sandbox"
  11. "eta_gn/eta_api/utils"
  12. "fmt"
  13. "strconv"
  14. "time"
  15. )
  16. // 全局的指标替换
  17. func DealReplaceEdbCache() {
  18. var err error
  19. for {
  20. utils.Rc.Brpop(utils.CACHE_KEY_REPLACE_EDB, func(b []byte) {
  21. defer func() {
  22. if err != nil {
  23. utils.FileLog.Info("DealReplaceEdbCache err:" + err.Error())
  24. go alarm_msg.SendAlarmMsg("替换表格中的指标失败提醒,errmsg:"+err.Error(), 3)
  25. }
  26. }()
  27. record := new(data_manage.ReplaceEdbInfoItem)
  28. if err = json.Unmarshal(b, &record); err != nil {
  29. fmt.Println("json unmarshal wrong!")
  30. return
  31. }
  32. oldEdbInfo := record.OldEdbInfo
  33. newEdbInfo := record.NewEdbInfo
  34. utils.FileLog.Info(fmt.Sprintf("指标开始替换 DealReplaceEdbCache: 旧指标ID:%d,新指标ID:%d", oldEdbInfo.EdbInfoId, newEdbInfo.EdbInfoId))
  35. deleteCache := true
  36. setNxKey := fmt.Sprintf("EDB_INFO_REPLACE:%d-%d", oldEdbInfo.EdbInfoId, newEdbInfo.EdbInfoId)
  37. defer func() {
  38. if deleteCache {
  39. utils.Rc.Delete(setNxKey)
  40. }
  41. }()
  42. if !utils.Rc.SetNX(setNxKey, 1, 30*time.Minute) {
  43. deleteCache = false
  44. err = fmt.Errorf("替换表格中的指标失败旧指标:%d为新指标%d:正在处理中", oldEdbInfo.EdbInfoId, newEdbInfo.EdbInfoId)
  45. return
  46. }
  47. // 替换相关性图表配置
  48. _, err = data_manage.ReplaceMultipleGraphConfigChartEdb(oldEdbInfo, newEdbInfo)
  49. if err != nil {
  50. err = fmt.Errorf("替换相关性图表配置失败,errmsg:%s", err.Error())
  51. return
  52. }
  53. // 替换拟合方程指标
  54. _, err = data_manage.ReplaceEdbInfoInLineEquationMultipleGraphConfig(oldEdbInfo, newEdbInfo)
  55. if err != nil {
  56. err = fmt.Errorf("替换拟合方程指标失败,errmsg:%s", err.Error())
  57. return
  58. }
  59. // 替换表格中的指标
  60. err = ReplaceEdbInExcel(oldEdbInfo, newEdbInfo)
  61. if err != nil {
  62. err = fmt.Errorf("替换表格中的指标失败,errmsg:%s", err.Error())
  63. return
  64. }
  65. //替换逻辑图中的指标
  66. err = sandbox.ReplaceEdbInSandbox(oldEdbInfo.EdbInfoId, newEdbInfo.EdbInfoId)
  67. if err != nil {
  68. err = fmt.Errorf("替换逻辑图中的指标失败,errmsg:%s", err.Error())
  69. return
  70. }
  71. // todo 重置指标引用表
  72. ReplaceEdbInRelation(oldEdbInfo, newEdbInfo)
  73. })
  74. }
  75. }
  76. // ReplaceEdbInExcel 替换表格中的指标
  77. func ReplaceEdbInExcel(oldEdbInfo, newEdbInfo *data_manage.EdbInfo) (err error) {
  78. defer func() {
  79. if err != nil {
  80. go alarm_msg.SendAlarmMsg("替换表格中的指标失败提醒,errMsg:"+err.Error(), 3)
  81. }
  82. }()
  83. //查询和指标相关的时间序列表格和混合表格
  84. mappingList, err := excelModel.GetExcelEdbMappingByEdbInfoIdAndSource(oldEdbInfo.EdbInfoId, []int{utils.TIME_TABLE, utils.MIXED_TABLE})
  85. if err != nil {
  86. err = fmt.Errorf("查询和指标相关的表格失败,错误:%s", err.Error())
  87. return
  88. }
  89. updateList := make([]*excelModel.ExcelInfo, 0)
  90. // 循环列表,根据表格类型单独处理
  91. for _, excelMapping := range mappingList {
  92. //查询和指标相关的混合表格
  93. excelInfo, tmpErr := excelModel.GetExcelInfoById(excelMapping.ExcelInfoId)
  94. if tmpErr != nil {
  95. err = fmt.Errorf("查询和指标相关的混合表格失败,错误:%s", tmpErr.Error())
  96. return
  97. }
  98. // 清除缓存
  99. key := utils.HZ_CHART_LIB_EXCEL_TABLE_DETAIL + ":" + excelInfo.UniqueCode
  100. if utils.Re == nil {
  101. _ = utils.Rc.Delete(key)
  102. }
  103. // 根据表格类型,调用不同的处理函数
  104. switch excelMapping.Source {
  105. case utils.TIME_TABLE: // 时间序列表格
  106. // 替换余额表格中的指标
  107. newExcelInfo, e := replaceEdbInTimeExcel(oldEdbInfo, newEdbInfo, excelInfo)
  108. if e != nil {
  109. err = fmt.Errorf("替换余额表格中的指标失败,错误:%s", e.Error())
  110. return
  111. }
  112. updateList = append(updateList, newExcelInfo)
  113. case utils.MIXED_TABLE, utils.BALANCE_TABLE:
  114. // 替换余额表格中的指标
  115. newExcelInfo, e := replaceEdbInBalanceExcel(oldEdbInfo, newEdbInfo, excelInfo)
  116. if e != nil {
  117. err = fmt.Errorf("替换余额表格中的指标失败,错误:%s", e.Error())
  118. return
  119. }
  120. updateList = append(updateList, newExcelInfo)
  121. default:
  122. // 其他表格类型的处理逻辑
  123. }
  124. }
  125. err = excelModel.ReplaceEdbInExcel(oldEdbInfo.EdbInfoId, newEdbInfo.EdbInfoId, updateList)
  126. if err != nil {
  127. err = fmt.Errorf("替换表格中的指标失败,错误:%s", err.Error())
  128. return
  129. }
  130. //todo 是否需要刷新表格中的指标数据
  131. return
  132. }
  133. func replaceEdbInBalanceExcel(oldEdbInfo, newEdbInfo *data_manage.EdbInfo, excelInfo *excelModel.ExcelInfo) (newExcelInfo *excelModel.ExcelInfo, err error) {
  134. newExcelInfo = excelInfo
  135. var mixedTableReq request.MixedTableReq
  136. err = json.Unmarshal([]byte(excelInfo.Content), &mixedTableReq)
  137. if err != nil {
  138. err = fmt.Errorf("表格json转结构体失败,Err:" + err.Error())
  139. return
  140. }
  141. // 处理data
  142. configList := mixedTableReq.Data
  143. for ck, rowList := range configList {
  144. for rk, cell := range rowList {
  145. switch cell.DataType {
  146. case request.EdbDT: // 指标信息
  147. if cell.EdbInfoId == oldEdbInfo.EdbInfoId {
  148. //更换成新指标ID
  149. configList[ck][rk].EdbInfoId = newEdbInfo.EdbInfoId
  150. }
  151. case request.InsertDataDT, request.PopInsertDataDT: // 插值、弹框插值
  152. if cell.EdbInfoId == oldEdbInfo.EdbInfoId {
  153. //更换成新指标ID
  154. configList[ck][rk].EdbInfoId = newEdbInfo.EdbInfoId
  155. }
  156. case request.InsertEdbCalculateDataDT: // 插入指标计算公式生成的值
  157. var config request.CalculateConf
  158. err = json.Unmarshal([]byte(cell.Value), &config)
  159. if err != nil {
  160. return
  161. }
  162. if cell.EdbInfoId == oldEdbInfo.EdbInfoId {
  163. //更换成新指标ID
  164. configList[ck][rk].EdbInfoId = newEdbInfo.EdbInfoId
  165. }
  166. if config.EdbInfoId == oldEdbInfo.EdbInfoId {
  167. config.EdbInfoId = newEdbInfo.EdbInfoId
  168. var configStr []byte
  169. configStr, err = json.Marshal(config)
  170. if err != nil {
  171. return
  172. }
  173. configList[ck][rk].Value = string(configStr)
  174. }
  175. case request.DateDT: // 日期类型
  176. // 指标日期类型的单元格需要额外将指标id取出来
  177. if cell.DataTimeType == request.EdbDateDT {
  178. var config request.EdbDateConf
  179. err = json.Unmarshal([]byte(cell.Value), &config)
  180. if err != nil {
  181. return
  182. }
  183. if config.EdbInfoId == oldEdbInfo.EdbInfoId {
  184. config.EdbInfoId = newEdbInfo.EdbInfoId
  185. var configStr []byte
  186. configStr, err = json.Marshal(config)
  187. if err != nil {
  188. return
  189. }
  190. configList[ck][rk].Value = string(configStr)
  191. }
  192. }
  193. }
  194. }
  195. }
  196. mixedTableReq.Data = configList
  197. var newContentByte []byte
  198. newContentByte, err = json.Marshal(mixedTableReq)
  199. if err != nil {
  200. return
  201. }
  202. // 生成的新内容替换原先的旧内容
  203. excelInfo.Content = string(newContentByte)
  204. newExcelInfo = excelInfo
  205. return
  206. }
  207. func replaceEdbInTimeExcel(oldEdbInfo, newEdbInfo *data_manage.EdbInfo, excelInfo *excelModel.ExcelInfo) (newExcelInfo *excelModel.ExcelInfo, err error) {
  208. newExcelInfo = excelInfo
  209. var tableDataConfig request.TimeTableDataConfig
  210. err = json.Unmarshal([]byte(excelInfo.Content), &tableDataConfig)
  211. if err != nil {
  212. err = errors.New("表格json转结构体失败,Err:" + err.Error())
  213. return
  214. }
  215. if len(tableDataConfig.EdbInfoIdList) <= 0 {
  216. return
  217. }
  218. // 实际期数没有的情况下,直接返回吧
  219. if tableDataConfig.Num <= 0 {
  220. return
  221. }
  222. // 先处理edbInfoList
  223. for k, id := range tableDataConfig.EdbInfoIdList {
  224. if id == oldEdbInfo.EdbInfoId {
  225. tableDataConfig.EdbInfoIdList[k] = newEdbInfo.EdbInfoId
  226. }
  227. }
  228. // 先处理tableEdbInfoList
  229. for k, tableEdbInfo := range tableDataConfig.TableEdbInfoList {
  230. if tableEdbInfo.EdbInfoId == oldEdbInfo.EdbInfoId {
  231. tableDataConfig.TableEdbInfoList[k].EdbInfoId = newEdbInfo.EdbInfoId
  232. }
  233. }
  234. var newContentByte []byte
  235. newContentByte, err = json.Marshal(tableDataConfig)
  236. if err != nil {
  237. return
  238. }
  239. // 生成的新内容替换原先的旧内容
  240. excelInfo.Content = string(newContentByte)
  241. newExcelInfo = excelInfo
  242. return
  243. }
  244. func ReplaceEdbInRelation(oldEdbInfo, newEdbInfo *data_manage.EdbInfo) {
  245. var err error
  246. var logMsg string
  247. var replaceTotal int
  248. defer func() {
  249. if err != nil {
  250. msg := fmt.Sprintf(" 替换指标引用表中的指标,并修改引用时间 replaceEdbInRelation err: %v", err)
  251. utils.FileLog.Info(msg)
  252. fmt.Println(msg)
  253. go alarm_msg.SendAlarmMsg(msg, 3)
  254. }
  255. if logMsg != `` {
  256. utils.FileLog.Info(fmt.Sprintf("替换指标引用表中的指标记录 替换总数%d,旧的指标id:%d,新的指标id:%d;涉及到的引用id:%s", replaceTotal, oldEdbInfo.EdbInfoId, newEdbInfo.EdbInfoId, logMsg))
  257. }
  258. }()
  259. calculateEdbMappingListMap := make(map[int]*data_manage.EdbInfoCalculateMapping)
  260. calculateEdbMappingIdsMap := make(map[int][]int)
  261. childEdbMappingIds := make([]int, 0)
  262. //indexCodeList := make([]string, 0)
  263. //refreshIds := make([]int, 0)
  264. //分页查询,每次处理500条记录
  265. pageSize := 500
  266. // 替换直接引用中的指标
  267. if newEdbInfo.EdbType == 2 {
  268. edbInfoList := make([]*data_manage.EdbInfo, 0)
  269. edbInfoList = append(edbInfoList, newEdbInfo)
  270. calculateEdbMappingListMap, calculateEdbMappingIdsMap, err = data.GetEdbListByEdbInfoId(edbInfoList)
  271. if err != nil {
  272. err = fmt.Errorf("查询指标关联指标列表失败 Err:%s", err)
  273. return
  274. }
  275. var ok bool
  276. childEdbMappingIds, ok = calculateEdbMappingIdsMap[newEdbInfo.EdbInfoId]
  277. if !ok {
  278. err = fmt.Errorf("查询%d指标关联指标列表为空", newEdbInfo.EdbInfoId)
  279. return
  280. }
  281. }
  282. total, err := data_manage.GetReplaceEdbInfoRelationTotal(oldEdbInfo.EdbInfoId)
  283. if err != nil {
  284. err = fmt.Errorf("查询引用表中关联的指标总数失败 err: %v", err)
  285. return
  286. }
  287. totalPage := 0
  288. if total > 0 {
  289. totalPage = (total + pageSize - 1) / pageSize // 使用整数除法,并添加一页以防有余数
  290. //查询图表列表
  291. for i := 0; i < totalPage; i += 1 {
  292. startSize := i * pageSize
  293. list, e := data_manage.GetReplaceEdbInfoRelationList(oldEdbInfo.EdbInfoId, startSize, pageSize)
  294. if e != nil {
  295. err = fmt.Errorf("查询图表关联指标列表失败 Err:%s", e)
  296. return
  297. }
  298. if len(list) == 0 {
  299. break
  300. }
  301. replaceTotal1, logMsg1, e := replaceEdbInRelation(oldEdbInfo, newEdbInfo, list, childEdbMappingIds, calculateEdbMappingListMap)
  302. if e != nil {
  303. err = e
  304. return
  305. }
  306. replaceTotal += replaceTotal1
  307. logMsg += logMsg1
  308. }
  309. }
  310. // 更新间接引用中的指标
  311. //查询相关的记录总数
  312. total, err = data_manage.GetReplaceChildEdbInfoRelationTotal(oldEdbInfo.EdbInfoId)
  313. if err != nil {
  314. if utils.IsErrNoRow(err) {
  315. err = nil
  316. } else {
  317. err = fmt.Errorf("查询引用表中关联的指标总数失败 err: %v", err)
  318. return
  319. }
  320. }
  321. if total > 0 {
  322. totalPage = (total + pageSize - 1) / pageSize // 使用整数除法,并添加一页以防有余数
  323. //查询列表
  324. for i := 0; i < totalPage; i += 1 {
  325. startSize := i * pageSize
  326. tmpList, e := data_manage.GetReplaceChildEdbInfoRelationList(oldEdbInfo.EdbInfoId, startSize, pageSize)
  327. if e != nil {
  328. err = fmt.Errorf("查询图表关联指标列表失败 Err:%s", e)
  329. return
  330. }
  331. // 查询直接引用
  332. relationIds := make([]int, 0)
  333. for _, v := range tmpList {
  334. relationIds = append(relationIds, v.ParentRelationId)
  335. }
  336. if len(relationIds) > 0 {
  337. list, e := data_manage.GetEdbInfoRelationByRelationIds(relationIds)
  338. if e != nil {
  339. err = fmt.Errorf("查询图表关联指标列表失败 Err:%s", e)
  340. return
  341. }
  342. //查询直接引用指标关联关系
  343. edbInfoListMap := make(map[int]struct{})
  344. edbInfoIds := make([]int, 0)
  345. for _, v := range list {
  346. if _, ok := edbInfoListMap[v.EdbInfoId]; !ok {
  347. edbInfoListMap[v.EdbInfoId] = struct{}{}
  348. edbInfoIds = append(edbInfoIds, v.EdbInfoId)
  349. }
  350. }
  351. edbInfoList := make([]*data_manage.EdbInfo, 0)
  352. if len(edbInfoIds) > 0 {
  353. // 查询指标信息
  354. edbInfoList, err = data_manage.GetEdbInfoByIdList(edbInfoIds)
  355. if err != nil {
  356. err = fmt.Errorf("查询指标信息失败 Err:%s", err)
  357. return
  358. }
  359. }
  360. calculateEdbMappingListMap, calculateEdbMappingIdsMap, err = data.GetEdbListByEdbInfoId(edbInfoList)
  361. if err != nil {
  362. err = fmt.Errorf("查询指标关联指标列表失败 Err:%s", err)
  363. return
  364. }
  365. //如何过滤掉只有间接引用,没有直接引用的
  366. replaceTotal1, logMsg1, e := UpdateSecondEdbInRelation(list, calculateEdbMappingListMap, calculateEdbMappingIdsMap, edbInfoList)
  367. if e != nil {
  368. err = e
  369. return
  370. }
  371. replaceTotal += replaceTotal1
  372. logMsg += logMsg1
  373. }
  374. }
  375. }
  376. return
  377. }
  378. // 完成直接引用中的指标替换工程
  379. func replaceEdbInRelation(oldEdbInfo, newEdbInfo *data_manage.EdbInfo, list []*data_manage.EdbInfoRelation, childEdbMappingIds []int, calculateEdbMappingListMap map[int]*data_manage.EdbInfoCalculateMapping) (replaceTotal int, logMsg string, err error) {
  380. replaceEdbIds := make([]int, 0)
  381. indexCodeList := make([]string, 0)
  382. addList := make([]*data_manage.EdbInfoRelation, 0)
  383. refreshIds := make([]int, 0)
  384. nowTime := time.Now()
  385. for _, v := range list {
  386. replaceEdbIds = append(replaceEdbIds, v.EdbInfoRelationId)
  387. if newEdbInfo.EdbType == 2 {
  388. for _, childEdbMappingId := range childEdbMappingIds {
  389. childEdbMapping, ok2 := calculateEdbMappingListMap[childEdbMappingId]
  390. if !ok2 {
  391. continue
  392. }
  393. if childEdbMapping.FromSource == utils.DATA_SOURCE_MYSTEEL_CHEMICAL {
  394. indexCodeList = append(indexCodeList, childEdbMapping.FromEdbCode)
  395. }
  396. tmp1 := &data_manage.EdbInfoRelation{
  397. ReferObjectId: v.ReferObjectId,
  398. ReferObjectType: v.ReferObjectType,
  399. ReferObjectSubType: v.ReferObjectSubType,
  400. EdbInfoId: childEdbMapping.FromEdbInfoId,
  401. EdbName: childEdbMapping.FromEdbName,
  402. Source: childEdbMapping.FromSource,
  403. EdbCode: childEdbMapping.FromEdbCode,
  404. CreateTime: nowTime,
  405. ModifyTime: nowTime,
  406. RelationTime: nowTime,
  407. RelationType: 1,
  408. RootEdbInfoId: newEdbInfo.EdbInfoId,
  409. ChildEdbInfoId: childEdbMapping.EdbInfoId,
  410. }
  411. tmp1.RelationCode = fmt.Sprintf("%d_%d_%d_%d", tmp1.RootEdbInfoId, tmp1.ReferObjectId, tmp1.ReferObjectType, tmp1.ReferObjectSubType)
  412. addList = append(addList, tmp1)
  413. refreshIds = append(refreshIds, childEdbMapping.FromEdbInfoId)
  414. // todo 防止重复
  415. }
  416. }
  417. logMsg += strconv.Itoa(v.EdbInfoRelationId) + ";"
  418. }
  419. if len(replaceEdbIds) > 0 {
  420. err = data_manage.ReplaceRelationEdbInfoId(oldEdbInfo, newEdbInfo, replaceEdbIds, addList, refreshIds, indexCodeList)
  421. if err != nil {
  422. logMsg = ""
  423. err = fmt.Errorf("替换指标引用表中的指标ID失败 Err:%s", err)
  424. return
  425. }
  426. replaceTotal = len(replaceEdbIds)
  427. }
  428. return
  429. }
  430. func UpdateSecondEdbInRelation(list []*data_manage.EdbInfoRelation, calculateEdbMappingListMap map[int]*data_manage.EdbInfoCalculateMapping, calculateEdbMappingIdsMap map[int][]int, edbInfoList []*data_manage.EdbInfo) (replaceTotal int, logMsg string, err error) {
  431. nowTime := time.Now()
  432. edbInfoRelationIds := make([]int, 0)
  433. indexCodeList := make([]string, 0)
  434. addList := make([]*data_manage.EdbInfoRelation, 0)
  435. refreshIds := make([]int, 0)
  436. edbInfoMap := make(map[int]*data_manage.EdbInfo)
  437. for _, v := range edbInfoList {
  438. edbInfoMap[v.EdbInfoId] = v
  439. }
  440. // 查询所有的直接引用,删除所有的间接引用,添加所有直接引用的间接引用
  441. for _, v := range list {
  442. if v.RelationType == 0 {
  443. edbInfoRelationIds = append(edbInfoRelationIds, v.EdbInfoRelationId)
  444. edbInfo, ok := edbInfoMap[v.EdbInfoId]
  445. if !ok {
  446. err = fmt.Errorf("查询指标信息失败 EdbInfoId:%d", v.EdbInfoId)
  447. return
  448. }
  449. if edbInfo.EdbType == 2 { //计算指标
  450. childEdbMappingIds, ok := calculateEdbMappingIdsMap[edbInfo.EdbInfoId]
  451. if !ok {
  452. err = fmt.Errorf("查询%d指标关联指标列表为空", edbInfo.EdbInfoId)
  453. return
  454. }
  455. for _, childEdbMappingId := range childEdbMappingIds {
  456. childEdbMapping, ok2 := calculateEdbMappingListMap[childEdbMappingId]
  457. if !ok2 {
  458. continue
  459. }
  460. if childEdbMapping.FromSource == utils.DATA_SOURCE_MYSTEEL_CHEMICAL {
  461. indexCodeList = append(indexCodeList, childEdbMapping.FromEdbCode)
  462. }
  463. tmp1 := &data_manage.EdbInfoRelation{
  464. ReferObjectId: v.ReferObjectId,
  465. ReferObjectType: v.ReferObjectType,
  466. ReferObjectSubType: v.ReferObjectSubType,
  467. EdbInfoId: childEdbMapping.FromEdbInfoId,
  468. EdbName: childEdbMapping.FromEdbName,
  469. Source: childEdbMapping.FromSource,
  470. EdbCode: childEdbMapping.FromEdbCode,
  471. CreateTime: nowTime,
  472. ModifyTime: nowTime,
  473. RelationTime: nowTime,
  474. RelationType: 1,
  475. RootEdbInfoId: edbInfo.EdbInfoId,
  476. ChildEdbInfoId: childEdbMapping.EdbInfoId,
  477. }
  478. tmp1.RelationCode = fmt.Sprintf("%d_%d_%d_%d", tmp1.RootEdbInfoId, tmp1.ReferObjectId, tmp1.ReferObjectType, tmp1.ReferObjectSubType)
  479. addList = append(addList, tmp1)
  480. refreshIds = append(refreshIds, childEdbMapping.FromEdbInfoId)
  481. }
  482. }
  483. logMsg += strconv.Itoa(v.EdbInfoRelationId) + ";"
  484. }
  485. }
  486. if len(edbInfoRelationIds) > 0 {
  487. err = data_manage.UpdateSecondRelationEdbInfoId(edbInfoRelationIds, addList, refreshIds, indexCodeList)
  488. if err != nil {
  489. logMsg = ""
  490. err = fmt.Errorf("替换指标引用表中的指标ID失败 Err:%s", err)
  491. return
  492. }
  493. replaceTotal = len(edbInfoRelationIds)
  494. }
  495. return
  496. }