xyxie 8 hónapja
szülő
commit
ee9959bf2e
2 módosított fájl, 22 hozzáadás és 23 törlés
  1. 1 1
      models/data_manage/edb_info_relation.go
  2. 21 22
      services/edb_info_replace.go

+ 1 - 1
models/data_manage/edb_info_relation.go

@@ -327,7 +327,7 @@ func GetReplaceChildEdbInfoRelationTotal(edbInfoId int) (total int, err error) {
 func GetReplaceChildEdbInfoRelationList(edbInfoId int, startSize, pageSize int) (items []*EdbInfoRelation, err error) {
 	o := orm.NewOrmUsingDB("data")
 	// 列表数据
-	sql := ` SELECT * FROM edb_info_relation where  child_edb_info_id=? and root_edb_info_id !=? ORDER BY edb_info_relation_id ASC group by parent_relation_id  LIMIT ?,? `
+	sql := ` SELECT * FROM edb_info_relation where  child_edb_info_id=? and root_edb_info_id !=?  group by parent_relation_id ORDER BY edb_info_relation_id ASC  LIMIT ?,? `
 	_, err = o.Raw(sql, edbInfoId, edbInfoId, startSize, pageSize).QueryRows(&items)
 	return
 }

+ 21 - 22
services/edb_info_replace.go

@@ -304,29 +304,28 @@ func ReplaceEdbInRelation(oldEdbInfo, newEdbInfo *data_manage.EdbInfo) {
 		err = fmt.Errorf("查询引用表中关联的指标总数失败 err: %v", err)
 		return
 	}
-	if total == 0 {
-		return
-	}
-
-	totalPage := (total + pageSize - 1) / pageSize // 使用整数除法,并添加一页以防有余数
-	//查询图表列表
-	for i := 0; i < totalPage; i += 1 {
-		startSize := i * pageSize
-		list, e := data_manage.GetReplaceEdbInfoRelationList(oldEdbInfo.EdbInfoId, startSize, pageSize)
-		if e != nil {
-			err = fmt.Errorf("查询图表关联指标列表失败 Err:%s", e)
-			return
-		}
-		if len(list) == 0 {
-			break
-		}
-		replaceTotal1, logMsg1, e := replaceEdbInRelation(oldEdbInfo, newEdbInfo, list, childEdbMappingIds, calculateEdbMappingListMap)
-		if e != nil {
-			err = e
-			return
+	totalPage := 0
+	if total > 0 {
+		totalPage = (total + pageSize - 1) / pageSize // 使用整数除法,并添加一页以防有余数
+		//查询图表列表
+		for i := 0; i < totalPage; i += 1 {
+			startSize := i * pageSize
+			list, e := data_manage.GetReplaceEdbInfoRelationList(oldEdbInfo.EdbInfoId, startSize, pageSize)
+			if e != nil {
+				err = fmt.Errorf("查询图表关联指标列表失败 Err:%s", e)
+				return
+			}
+			if len(list) == 0 {
+				break
+			}
+			replaceTotal1, logMsg1, e := replaceEdbInRelation(oldEdbInfo, newEdbInfo, list, childEdbMappingIds, calculateEdbMappingListMap)
+			if e != nil {
+				err = e
+				return
+			}
+			replaceTotal += replaceTotal1
+			logMsg += logMsg1
 		}
-		replaceTotal += replaceTotal1
-		logMsg += logMsg1
 	}
 
 	// 更新间接引用中的指标