Roc 1 lună în urmă
părinte
comite
3acb364a24
1 a modificat fișierele cu 17 adăugiri și 4 ștergeri
  1. 17 4
      models/data_manage/edb_info.go

+ 17 - 4
models/data_manage/edb_info.go

@@ -759,17 +759,30 @@ func GetEdbInfoCalculateListByCondition(condition string, pars []interface{}) (i
 }
 
 // GetEdbInfoAllCalculateByEdbInfoIdList 根据指标id集合 获取基础指标对应的所有计算指标
-func GetEdbInfoAllCalculateByEdbInfoIdList(edbInfoIdList []int) (list []*EdbInfo, err error) {
-	num := len(edbInfoIdList)
+func GetEdbInfoAllCalculateByEdbInfoIdList(fromEdbInfoIdList []int) (list []*EdbInfo, err error) {
+	num := len(fromEdbInfoIdList)
 	if num <= 0 {
 		return
 	}
 
-	sql := ` SELECT DISTINCT b.* FROM edb_info_calculate_mapping AS a
+	edbEdbInfoIdList := make([]int, 0)
+	sql := ` SELECT DISTINCT b.edb_info_id FROM edb_info_calculate_mapping AS a
 			 INNER JOIN edb_info AS b ON a.edb_info_id=b.edb_info_id
              WHERE a.from_edb_info_id in (` + utils.GetOrmInReplace(num) + `)
 			 ORDER BY b.edb_info_id ASC `
-	err = global.DmSQL["data"].Raw(sql, edbInfoIdList).Scan(&list).Error
+	err = global.DmSQL["data"].Raw(sql, fromEdbInfoIdList).Scan(&edbEdbInfoIdList).Error
+	if err != nil {
+		return
+	}
+
+	// 查询来的实际id集合
+	num = len(edbEdbInfoIdList)
+	if num <= 0 {
+		return
+	}
+
+	sql = ` SELECT * FROM  edb_info  WHERE edb_info_id IN (` + utils.GetOrmInReplace(num) + `) ORDER BY edb_info_id ASC `
+	err = global.DmSQL["data"].Raw(sql, edbEdbInfoIdList).Find(&list).Error
 
 	return
 }