Commit 185611fd by qiuchaofei

优化查表的属性的性能

parent 6fc1deee
...@@ -33,16 +33,6 @@ public class TableServiceImpl implements ITableService { ...@@ -33,16 +33,6 @@ public class TableServiceImpl implements ITableService {
private Neo4jTableRepository neo4jTableRepository; private Neo4jTableRepository neo4jTableRepository;
@Autowired @Autowired
private Neo4jSystemRepository neo4jSystemRepository;
@Autowired
private Neo4jSchemaRepository neo4jSchemaRepository;
@Autowired
private MetadataRepoRemoteService metadataRepoRemoteService;
@Autowired
private DataStandardRemoteService dataStandardRemoteService; private DataStandardRemoteService dataStandardRemoteService;
@Autowired @Autowired
...@@ -128,8 +118,8 @@ public class TableServiceImpl implements ITableService { ...@@ -128,8 +118,8 @@ public class TableServiceImpl implements ITableService {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
List<ReturnNode> neo4jTableList = getCurrentTableInfo(tableId); List<ReturnNode> neo4jTableList = getCurrentTableInfo(tableId);
long ent = System.currentTimeMillis(); long end = System.currentTimeMillis();
logger.info("查找当前表用时:"+(ent-start)); logger.info("查找当前表用时:"+(end-start));
relationObjects.put("当前表",neo4jTableList); relationObjects.put("当前表",neo4jTableList);
return relationObjects; return relationObjects;
...@@ -139,31 +129,14 @@ public class TableServiceImpl implements ITableService { ...@@ -139,31 +129,14 @@ public class TableServiceImpl implements ITableService {
List<Neo4jTable> neo4jTableList = neo4jTableRepository.findNeo4jTableByMetadataId(tableId); List<Neo4jTable> neo4jTableList = neo4jTableRepository.findNeo4jTableByMetadataId(tableId);
List<ReturnNode> returnTableList = new ArrayList<>(); List<ReturnNode> returnTableList = new ArrayList<>();
Map<String ,String> systemIdAndName = new HashMap<>();
Iterable<Neo4jSystem> neo4jSystems = neo4jSystemRepository.findAll();
for(Neo4jSystem neo4jSystem:neo4jSystems ){
systemIdAndName.put(neo4jSystem.getMetadataId(),neo4jSystem.getName());
}
for(Neo4jTable neo4jTable:neo4jTableList){ for(Neo4jTable neo4jTable:neo4jTableList){
ReturnNode returnNode = new ReturnNode(); ReturnNode returnNode = new ReturnNode();
returnNode.setId(neo4jTable.getMetadataId()); returnNode.setId(neo4jTable.getMetadataId());
returnNode.setName(neo4jTable.getName()); returnNode.setName(neo4jTable.getName());
returnNode.setType("Table"); returnNode.setType("Table");
returnTableList.add(returnNode); returnTableList.add(returnNode);
// 获取属性 // 获取属性
Map<String,String> attributeMap = getAttributeMap(tableId); Map<String,String> attributeMap = getAttributeMap(tableId);
String systemString = attributeMap.get("所属系统");
String belongSystem = "";
String[] systemList = systemString.split(",");
for(String system :systemList ){
if(systemIdAndName.containsKey("System="+system)){
belongSystem += systemIdAndName.get("System="+system)+",";
}
}
attributeMap.put("所属系统",belongSystem);
returnNode.setAttributeMaps(attributeMap); returnNode.setAttributeMaps(attributeMap);
} }
...@@ -242,7 +215,6 @@ public class TableServiceImpl implements ITableService { ...@@ -242,7 +215,6 @@ public class TableServiceImpl implements ITableService {
if(metaData.getMetadataId() == null ){ if(metaData.getMetadataId() == null ){
metaData.setMetadataId("System="+metaData.getName()); metaData.setMetadataId("System="+metaData.getName());
} }
ReturnNode returnNode = new ReturnNode(); ReturnNode returnNode = new ReturnNode();
returnNode.setId(metaData.getMetadataId()); returnNode.setId(metaData.getMetadataId());
returnNode.setName(metaData.getName()); returnNode.setName(metaData.getName());
...@@ -272,19 +244,13 @@ public class TableServiceImpl implements ITableService { ...@@ -272,19 +244,13 @@ public class TableServiceImpl implements ITableService {
Map<String, List<ReturnNode>> sourceAndTargetTable = new HashMap<>(); Map<String, List<ReturnNode>> sourceAndTargetTable = new HashMap<>();
List<ReturnNode> sourceTables = new ArrayList<>(); List<ReturnNode> sourceTables = new ArrayList<>();
Map<String ,String> systemIdAndName = new HashMap<>();
Iterable<Neo4jSystem> neo4jSystems = neo4jSystemRepository.findAll();
for(Neo4jSystem neo4jSystem:neo4jSystems ){
systemIdAndName.put(neo4jSystem.getMetadataId(),neo4jSystem.getName());
}
List<ReturnNode> neo4jTableList = getCurrentTableInfo(tableId); List<ReturnNode> neo4jTableList = getCurrentTableInfo(tableId);
sourceAndTargetTable.put("当前表",neo4jTableList); sourceAndTargetTable.put("当前表",neo4jTableList);
getSourceTable(tableId ,sourceTables,systemIdAndName); getSourceTable(tableId ,sourceTables);
List<ReturnNode> targetTables = new ArrayList<>(); List<ReturnNode> targetTables = new ArrayList<>();
getTargetTable(tableId ,targetTables,systemIdAndName); getTargetTable(tableId ,targetTables);
sourceAndTargetTable.put("来源",sourceTables); sourceAndTargetTable.put("来源",sourceTables);
sourceAndTargetTable.put("目标",targetTables); sourceAndTargetTable.put("目标",targetTables);
...@@ -321,8 +287,7 @@ public class TableServiceImpl implements ITableService { ...@@ -321,8 +287,7 @@ public class TableServiceImpl implements ITableService {
return returnMap; return returnMap;
} }
private void getTargetTable(String tableId, List<ReturnNode> targetTables, private void getTargetTable(String tableId, List<ReturnNode> targetTables) {
Map<String, String> systemIdAndName) {
List<BaseNode> sourceBaseNodeList = neo4jTableRepository.getTargetTable(tableId); List<BaseNode> sourceBaseNodeList = neo4jTableRepository.getTargetTable(tableId);
for(BaseNode baseNode:sourceBaseNodeList){ for(BaseNode baseNode:sourceBaseNodeList){
String metadataId = baseNode.getMetadataId(); String metadataId = baseNode.getMetadataId();
...@@ -333,29 +298,18 @@ public class TableServiceImpl implements ITableService { ...@@ -333,29 +298,18 @@ public class TableServiceImpl implements ITableService {
returnNode.setType("Table"); returnNode.setType("Table");
// 获取属性 // 获取属性
Map<String,String> attributeMap = getAttributeMap(metadataId); Map<String,String> attributeMap = getAttributeMap(metadataId);
String systemString = attributeMap.get("所属系统");
String belongSystem = "";
String[] systemList = systemString.split(",");
for(String system :systemList ){
if(systemIdAndName.containsKey("System="+system)){
belongSystem += systemIdAndName.get("System="+system)+",";
}
}
attributeMap.put("所属系统",belongSystem);
returnNode.setAttributeMaps(attributeMap); returnNode.setAttributeMaps(attributeMap);
if(!targetTables.contains(returnNode)){ if(!targetTables.contains(returnNode)){
targetTables.add(returnNode); targetTables.add(returnNode);
} }
}else { }else {
getTargetTable(metadataId,targetTables,systemIdAndName); getTargetTable(metadataId,targetTables);
} }
} }
} }
private void getSourceTable(String tableId, List<ReturnNode> sourceTables, private void getSourceTable(String tableId, List<ReturnNode> sourceTables) {
Map<String, String> systemIdAndName) {
List<BaseNode> sourceBaseNodeList = neo4jTableRepository.getSourceTable(tableId); List<BaseNode> sourceBaseNodeList = neo4jTableRepository.getSourceTable(tableId);
for(BaseNode baseNode:sourceBaseNodeList){ for(BaseNode baseNode:sourceBaseNodeList){
String metadataId = baseNode.getMetadataId(); String metadataId = baseNode.getMetadataId();
...@@ -367,22 +321,13 @@ public class TableServiceImpl implements ITableService { ...@@ -367,22 +321,13 @@ public class TableServiceImpl implements ITableService {
// 获取属性 // 获取属性
Map<String,String> attributeMap = getAttributeMap(metadataId); Map<String,String> attributeMap = getAttributeMap(metadataId);
String systemString = attributeMap.get("所属系统");
String belongSystem = "";
String[] systemList = systemString.split(",");
for(String system :systemList ){
if(systemIdAndName.containsKey("System="+system)){
belongSystem += systemIdAndName.get("System="+system)+",";
}
}
attributeMap.put("所属系统",belongSystem);
if(!sourceTables.contains(returnNode)){ if(!sourceTables.contains(returnNode)){
sourceTables.add(returnNode); sourceTables.add(returnNode);
} }
returnNode.setAttributeMaps(attributeMap); returnNode.setAttributeMaps(attributeMap);
}else { }else {
getSourceTable(metadataId,sourceTables, systemIdAndName); getSourceTable(metadataId,sourceTables);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment