This commit is contained in:
2019-04-17 16:57:22 +08:00
parent 523bc304aa
commit e6e655c4b3
6 changed files with 58 additions and 208 deletions

View File

@@ -12,10 +12,8 @@ public class Liangs {
public static <T> Set<T> streamConcat(Stream<T> ... streams) {
Stream<T> stream = Stream.empty();
for (int i = 0; i < streams.length-1; i++) {
stream = Stream.concat(
stream, streams[i]
);
for (int i = 0; i < streams.length; i++) {
stream = Stream.concat(stream, streams[i]);
}
return stream.collect(Collectors.toSet());
}

View File

@@ -148,14 +148,16 @@ public class ParseMysql implements Parser {
if (!isEmpty.test(links)) {
links.forEach(x -> {
MetaTable rightTable = tables.get(metaTable.getAlias().equals(x.getTables()[0]) ? x.getTables()[1] : x.getTables()[0]);
bufFrom.append(" left join ").append(rightTable.getCatalog()).append(".").append(rightTable.getName()).append(" ").append(rightTable.getAlias()).append(" on ");
int tag = bufFrom.length();
x.getLink().forEach((k,v) -> {
if (bufFrom.length() > tag) {
bufFrom.append(" and ");
}
bufFrom.append(k).append("=").append(v);
});
if (rightTable != null) {
bufFrom.append(" left join ").append(rightTable.getCatalog()).append(".").append(rightTable.getName()).append(" ").append(rightTable.getAlias()).append(" on ");
int tag = bufFrom.length();
x.getLink().forEach((k, v) -> {
if (bufFrom.length() > tag) {
bufFrom.append(" and ");
}
bufFrom.append(k).append("=").append(v);
});
}
});
}

View File

@@ -90,6 +90,10 @@ public class MetadataService extends BaseService { //arango
.set("catalog", x.getCatalog())
.set("alias", x.getAlias())
.set("dbPlatId", x.getDbPlatId())
.set("linkCount", MetaKit.getMetaLinks().stream().filter(link -> { // 关联表数量
String[] tables = link.getTables();
return x.getAlias().equals(tables[0]) || x.getAlias().equals(tables[1]);
}).count())
).collect(Collectors.toList());
jBean.setBody(list);
return jBean;