Commit ae8a503b by qiuchaofei

1.按照关键字搜孤立点的数量与详情

parent 98b5054d
...@@ -69,13 +69,16 @@ public class DataRelationAnalyController { ...@@ -69,13 +69,16 @@ public class DataRelationAnalyController {
@ApiOperation(tags = "", value = "全量查找指定节点下面的孤立点。parentId参数可以为schemaId,sysemId,evnId") @ApiOperation(tags = "", value = "全量查找指定节点下面的孤立点。parentId参数可以为schemaId,sysemId,evnId")
@RequestMapping(path = "/getIsolatedNode", method = RequestMethod.GET) @RequestMapping(path = "/getIsolatedNode", method = RequestMethod.GET)
public Map<String, ReturnNode> getIsolatedTableBySchema(String parentId) { public Map<String, ReturnNode> getIsolatedTableBySchema(String parentId,String keyWord) {
logger.info("查找指定schema下面的孤立点:"+parentId); logger.info("查找指定schema下面的孤立点:"+parentId);
if(parentId == null ){ if(parentId == null ){
return new HashMap<>(); return new HashMap<>();
} }
return dataRelationAnalyService.findTableWithoutRelations(parentId,0,200000); if(keyWord == null ){
keyWord = "";
}
return dataRelationAnalyService.findTableWithoutRelations(parentId,0,200000,keyWord);
} }
//搜索 //搜索
...@@ -86,28 +89,37 @@ public class DataRelationAnalyController { ...@@ -86,28 +89,37 @@ public class DataRelationAnalyController {
if(parentId == null ){ if(parentId == null ){
return new HashMap<>(); return new HashMap<>();
} }
if(keyWord == null ){
keyWord = "";
}
return dataRelationAnalyService.findTableWithoutRelationsByName(parentId,keyWord); return dataRelationAnalyService.findTableWithoutRelationsByName(parentId,keyWord);
} }
//总数 //总数
@ApiOperation(tags = "", value = "查找孤立点的总数") @ApiOperation(tags = "", value = "查找孤立点的总数")
@RequestMapping(path = "/getIsolatedTableTotal", method = RequestMethod.GET) @RequestMapping(path = "/getIsolatedTableTotal", method = RequestMethod.GET)
public Integer getIsolatedTableTotal(String parentId) { public Integer getIsolatedTableTotal(String parentId,String keyWord) {
logger.info("分页查找孤立点的总数:"+parentId); logger.info("分页查找孤立点的总数:"+parentId);
if(parentId == null ){ if(parentId == null ){
return 0; return 0;
} }
return dataRelationAnalyService.findTableWithoutRelationsTotal(parentId); if(keyWord == null ){
keyWord = "";
}
return dataRelationAnalyService.findTableWithoutRelationsTotal(parentId,keyWord);
} }
@ApiOperation(tags = "", value = "分页查找指定节点的孤立点。parentId参数可以为schemaId,sysemId,evnId") @ApiOperation(tags = "", value = "分页查找指定节点的孤立点。parentId参数可以为schemaId,sysemId,evnId")
@RequestMapping(path = "/getIsolatedTableByPage", method = RequestMethod.GET) @RequestMapping(path = "/getIsolatedTableByPage", method = RequestMethod.GET)
public Map<String, ReturnNode> getIsolatedTableByPage(String parentId,int start,int size) { public Map<String, ReturnNode> getIsolatedTableByPage(String parentId,int start,int size,String keyWord) {
logger.info("查找指定schema下面的孤立点:"+parentId); logger.info("查找指定schema下面的孤立点:"+parentId);
if(parentId == null ){ if(parentId == null ){
return new HashMap<>(); return new HashMap<>();
} }
return dataRelationAnalyService.findTableWithoutRelations(parentId,start,size); if(keyWord == null ){
keyWord = "";
}
return dataRelationAnalyService.findTableWithoutRelations(parentId,start,size,keyWord);
} }
@ApiOperation(tags = "", value = "搜索指定table下面的字段。") @ApiOperation(tags = "", value = "搜索指定table下面的字段。")
......
...@@ -6,9 +6,9 @@ import java.util.Map; ...@@ -6,9 +6,9 @@ import java.util.Map;
public interface DataRelationAnalyService { public interface DataRelationAnalyService {
Map<String, ReturnNode> findTableWithoutRelations(String schemaId,int start,int end); Map<String, ReturnNode> findTableWithoutRelations(String schemaId,int start,int end,String keyWord);
Integer findTableWithoutRelationsTotal(String parentId); Integer findTableWithoutRelationsTotal(String parentId, String keyWord);
Map<String, ReturnNode> findTableWithoutRelationsByName(String parentId,String keyWord); Map<String, ReturnNode> findTableWithoutRelationsByName(String parentId,String keyWord);
} }
package com.keymobile.metadata.metadataRelation.service.impl; package com.keymobile.metadata.metadataRelation.service.impl;
import com.keymobile.metadata.metadataRelation.config.Neo4jConfig;
import com.keymobile.metadata.metadataRelation.pojo.MetaData; import com.keymobile.metadata.metadataRelation.pojo.MetaData;
import com.keymobile.metadata.metadataRelation.pojo.returnBean.ReturnNode; import com.keymobile.metadata.metadataRelation.pojo.returnBean.ReturnNode;
import com.keymobile.metadata.metadataRelation.service.DataRelationAnalyService; import com.keymobile.metadata.metadataRelation.service.DataRelationAnalyService;
...@@ -25,7 +24,7 @@ public class DataRelationAnalyServiceImpl implements DataRelationAnalyService { ...@@ -25,7 +24,7 @@ public class DataRelationAnalyServiceImpl implements DataRelationAnalyService {
private Session session; private Session session;
@Override @Override
public Map<String, ReturnNode> findTableWithoutRelations(String parentId,int start,int end) { public Map<String, ReturnNode> findTableWithoutRelations(String parentId,int start,int end,String keyWord) {
Map<String, ReturnNode> returnNodeMap = new HashMap<>(); Map<String, ReturnNode> returnNodeMap = new HashMap<>();
//区分传入的id是环境id,系统id还是schema,还是为空,为空则找出所有的孤立点 //区分传入的id是环境id,系统id还是schema,还是为空,为空则找出所有的孤立点
...@@ -37,12 +36,12 @@ public class DataRelationAnalyServiceImpl implements DataRelationAnalyService { ...@@ -37,12 +36,12 @@ public class DataRelationAnalyServiceImpl implements DataRelationAnalyService {
String condition = ""; String condition = "";
if(parentId !=null && parentId .startsWith("System=")){ if(parentId !=null && parentId .startsWith("System=")){
condition= "<-[r1:Composition]-(:Neo4jSchema)<-[r2:Composition]-(m:Neo4jSystem{metadataId:\""+parentId+"\"})"; condition= "<-[r1:Composition]-(:Neo4jSchema)<-[r2:Composition]-(m:Neo4jSystem{metadataId:\""+parentId+"\"})";
cypher = "match (n:Neo4jTable) " + condition + "where not ((n)-[:`流向`]-()) return n order by n.name SKIP "+start+" LIMIT "+end+" "; cypher = "match (n:Neo4jTable) " + condition + "where not ((n)-[:`流向`]-()) and n.name=~'.*"+keyWord+".*' return n order by n.name SKIP "+start+" LIMIT "+end+" ";
}else if(parentId !=null && parentId .startsWith("Schema=")){ }else if(parentId !=null && parentId .startsWith("Schema=")){
condition= "<-[r1:Composition]-(m:Neo4jSchema{metadataId:\""+parentId+"\"})"; condition= "<-[r1:Composition]-(m:Neo4jSchema{metadataId:\""+parentId+"\"})";
cypher = "match (n:Neo4jTable) " + condition + "where not ((n)-[:`流向`]-()) return n order by n.name SKIP "+start+" LIMIT "+end+" "; cypher = "match (n:Neo4jTable) " + condition + "where not ((n)-[:`流向`]-()) and n.name=~'.*"+keyWord+".*' return n order by n.name SKIP "+start+" LIMIT "+end+" ";
}else if(parentId !=null){ }else if(parentId !=null){
cypher = "match (n:Neo4jTable{isEnvironment:\""+parentId+"\"}) where not ((n)-[:`流向`]-()) return n order by n.name SKIP "+start+" LIMIT "+end+" "; cypher = "match (n:Neo4jTable{isEnvironment:\""+parentId+"\"}) where not ((n)-[:`流向`]-()) and n.name=~'.*"+keyWord+".*' return n order by n.name SKIP "+start+" LIMIT "+end+" ";
} }
int count = 0; int count = 0;
logger .info("查找孤立表的语句:"+cypher); logger .info("查找孤立表的语句:"+cypher);
...@@ -73,17 +72,17 @@ public class DataRelationAnalyServiceImpl implements DataRelationAnalyService { ...@@ -73,17 +72,17 @@ public class DataRelationAnalyServiceImpl implements DataRelationAnalyService {
} }
@Override @Override
public Integer findTableWithoutRelationsTotal(String parentId) { public Integer findTableWithoutRelationsTotal(String parentId, String keyWord) {
String cypher = ""; String cypher = "";
String condition = ""; String condition = "";
if(parentId !=null && parentId .startsWith("System=")){ if(parentId !=null && parentId .startsWith("System=")){
condition= "<-[r1:Composition]-(:Neo4jSchema)<-[r2:Composition]-(m:Neo4jSystem{metadataId:\""+parentId+"\"})"; condition= "<-[r1:Composition]-(:Neo4jSchema)<-[r2:Composition]-(m:Neo4jSystem{metadataId:\""+parentId+"\"})";
cypher = "match (n:Neo4jTable) " + condition + "where not ((n)-[:`流向`]-()) return count(n) as count "; cypher = "match (n:Neo4jTable) " + condition + "where not ((n)-[:`流向`]-()) and n.name=~'.*"+keyWord+".*' return count(n) as count ";
}else if(parentId !=null && parentId .startsWith("Schema=")){ }else if(parentId !=null && parentId .startsWith("Schema=")){
condition= "<-[r1:Composition]-(m:Neo4jSchema{metadataId:\""+parentId+"\"})"; condition= "<-[r1:Composition]-(m:Neo4jSchema{metadataId:\""+parentId+"\"})";
cypher = "match (n:Neo4jTable) " + condition + "where not ((n)-[:`流向`]-()) return count(n) as count "; cypher = "match (n:Neo4jTable) " + condition + "where not ((n)-[:`流向`]-()) and n.name=~'.*"+keyWord+".*' return count(n) as count ";
}else if(parentId !=null){ }else if(parentId !=null){
cypher = "match (n:Neo4jTable{isEnvironment:\""+parentId+"\"}) where not ((n)-[:`流向`]-()) return count(n) as count "; cypher = "match (n:Neo4jTable{isEnvironment:\""+parentId+"\"}) where not ((n)-[:`流向`]-()) and n.name=~'.*"+keyWord+".*' return count(n) as count ";
} }
logger .info("查找孤立表总数的语句:"+cypher); logger .info("查找孤立表总数的语句:"+cypher);
......
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