Commit 98b5054d by qiuchaofei

1.搜索孤立点

parent 9cecd572
......@@ -78,8 +78,19 @@ public class DataRelationAnalyController {
return dataRelationAnalyService.findTableWithoutRelations(parentId,0,200000);
}
//分页
@ApiOperation(tags = "", value = "分页查找孤立点的总数")
//搜索
@ApiOperation(tags = "", value = "搜索孤立点")
@RequestMapping(path = "/findIsolatedTableByName", method = RequestMethod.GET)
public Map<String, ReturnNode> findIsolatedTableByName(String parentId,String keyWord) {
logger.info("分页查找孤立点的总数:"+parentId);
if(parentId == null ){
return new HashMap<>();
}
return dataRelationAnalyService.findTableWithoutRelationsByName(parentId,keyWord);
}
//总数
@ApiOperation(tags = "", value = "查找孤立点的总数")
@RequestMapping(path = "/getIsolatedTableTotal", method = RequestMethod.GET)
public Integer getIsolatedTableTotal(String parentId) {
logger.info("分页查找孤立点的总数:"+parentId);
......
......@@ -9,4 +9,6 @@ public interface DataRelationAnalyService {
Map<String, ReturnNode> findTableWithoutRelations(String schemaId,int start,int end);
Integer findTableWithoutRelationsTotal(String parentId);
Map<String, ReturnNode> findTableWithoutRelationsByName(String parentId,String keyWord);
}
......@@ -95,4 +95,52 @@ public class DataRelationAnalyServiceImpl implements DataRelationAnalyService {
}
return jdcount;
}
@Override
public Map<String, ReturnNode> findTableWithoutRelationsByName(String parentId,String keyWord) {
Map<String, ReturnNode> returnNodeMap = new HashMap<>();
//区分传入的id是环境id,系统id还是schema,还是为空,为空则找出所有的孤立点
//match (n:Neo4jTable) where not ((n)-[:`流向`]-(:Neo4jTable)) return n
// Neo4jConfig neo4jConfig = new Neo4jConfig();
// Driver neo4jConnection = neo4jConfig.getNeo4jConnection();
// Session session = neo4jConnection.session();
String cypher = "";
String condition = "";
if(parentId !=null && parentId .startsWith("System=")){
condition= "<-[r1:Composition]-(:Neo4jSchema)<-[r2:Composition]-(m:Neo4jSystem{metadataId:\""+parentId+"\"})";
cypher = "match (n:Neo4jTable) " + condition + "where not ((n)-[:`流向`]-()) and n.name=~'.*"+keyWord+".*' return n order by n.name ";
}else if(parentId !=null && parentId .startsWith("Schema=")){
condition= "<-[r1:Composition]-(m:Neo4jSchema{metadataId:\""+parentId+"\"})";
cypher = "match (n:Neo4jTable) " + condition + "where not ((n)-[:`流向`]-()) and n.name=~'.*"+keyWord+".*' return n order by n.name ";
}else if(parentId !=null){
cypher = "match (n:Neo4jTable{isEnvironment:\""+parentId+"\"}) where not ((n)-[:`流向`]-()) and n.name=~'.*"+keyWord+".*' return n order by n.name ";
}
int count = 0;
logger .info("查找孤立表的语句:"+cypher);
StatementResult result = session.run(cypher);
while(result.hasNext()){
Record record = result.next();
List<Value> values = record.values();
for (Value value : values) {
if(value.type().name().equals("NODE")){
Node node = value.asNode();
Map<String, Object> stringObjectMap = node.asMap();
MetaData metaData = new MetaData();
Neo4jTool.transMap2Bean(stringObjectMap, metaData);
if(metaData.getMetadataId() == null ){
metaData.setMetadataId("System="+metaData.getName());
}
ReturnNode returnNode = new ReturnNode();
returnNode.setName(metaData.getName());
returnNode.setId(metaData.getMetadataId());
returnNode.setType(metaData.getMetaModel());
returnNode.setCnName(metaData.getCnName());
returnNodeMap.put(""+count++,returnNode);
}
}
}
return returnNodeMap;
}
}
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