|
@@ -48,19 +48,19 @@ public class DimEntityServiceImpl implements DimEntityService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<EntityCodeListVo> queryEntityCodeTableList(String id, String entityid, String entityname) {
|
|
|
+ public List<String> queryEntityCodeTableListFront(String id) {
|
|
|
if (StringUtils.isEmpty(id)) {
|
|
|
- return new ArrayList<>();
|
|
|
+ return Collections.emptyList();
|
|
|
}
|
|
|
//创建视图
|
|
|
String viewTableName = StringUtils.getTemporaryTableName();
|
|
|
createView(viewTableName);
|
|
|
- List<String> d0_tables = dimEntityMapper.queryTablesNameByViewCode(viewTableName, id);
|
|
|
- if (d0_tables.size() > 0) {
|
|
|
- return dimEntityMapper.queryEntityCodeTableTreeDataByCodeV1(id, d0_tables, entityid, entityname);
|
|
|
- } else {
|
|
|
- return new ArrayList<>();
|
|
|
- }
|
|
|
+ return dimEntityMapper.queryTablesNameByViewCode(viewTableName, id);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<EntityCodeListVo> queryEntityCodeTableList(String id, String entityid, String entityname, List<String> tables) {
|
|
|
+ return dimEntityMapper.queryEntityCodeTableTreeDataByCodeV1(id, tables, entityid, entityname);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -197,25 +197,63 @@ public class DimEntityServiceImpl implements DimEntityService {
|
|
|
public Map<String, Object> queryEntityRelationshipToNeo4j(String entityid) {
|
|
|
Map<String, Object> retMap = new HashMap<>();
|
|
|
// String sql = "match (n:Entity{ entityid:'MA1001NE103K1034230XXXXXXXXXXXXX2501010009'}) <-[r]->(b:Entity) return b.entityid, type(r)";
|
|
|
- String sql = "match (n:Entity{ entityid:'" + entityid + "'}) <-[r]->(b:Entity) return n.entityid as source, n.entilayer as entilayer, b.entityid as target, b.entilayer as comilayer, type(r) as value";
|
|
|
- System.out.println("cql:" + sql);
|
|
|
- Collection<Map<String, Object>> links = neo4jClient.query(sql).fetch().all();
|
|
|
- if (links.isEmpty()) {
|
|
|
+ //这个sql是他关联其他
|
|
|
+ String start_sql = "match (n:Entity{ entityid:'" + entityid + "'}) -[r]->(b:Entity) return n.entityid as source, n.entilayer as entilayer, b.entityid as target, b.entilayer as comilayer, type(r) as value";
|
|
|
+ Collection<Map<String, Object>> links_start_entityid = neo4jClient.query(start_sql).fetch().all();
|
|
|
+
|
|
|
+ //这个sql是其他关联他
|
|
|
+ String end_sql = "match (n:Entity{ entityid:'" + entityid + "'}) <-[r]-(b:Entity) return b.entityid as source , b.entilayer as entilayer, n.entityid as target, n.entilayer as comilayer, type(r) as value";
|
|
|
+ Collection<Map<String, Object>> links_end_entityid = neo4jClient.query(end_sql).fetch().all();
|
|
|
+
|
|
|
+ if (links_start_entityid.isEmpty() && links_end_entityid.isEmpty()) {
|
|
|
retMap.put("links", new HashMap<>());
|
|
|
retMap.put("data", new ArrayList<>());
|
|
|
return retMap;
|
|
|
}
|
|
|
- retMap.put("links", links);
|
|
|
-
|
|
|
- List<Map<String, Object>> dataList = new ArrayList<>();
|
|
|
+ //用于判断结果是查询过
|
|
|
Set<String> dataSet = new HashSet<>();
|
|
|
- for (Map<String, Object> doMap : links) {
|
|
|
- String comentityid = (String) doMap.get("target");
|
|
|
+ //用于判断结果是否有值
|
|
|
+ Set<String> dataSetTrue = new HashSet<>();
|
|
|
+ //添加关系
|
|
|
+ List<Map<String, Object>> linksList = new ArrayList<>();
|
|
|
+ //添加数据
|
|
|
+ List<Map<String, Object>> dataList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (Map<String, Object> linksMap : links_start_entityid) {
|
|
|
+ String comentityid = (String) linksMap.get("target");
|
|
|
if (!dataSet.contains(comentityid)) {
|
|
|
- dataList.add(queryEntityData(comentityid));
|
|
|
+ Map<String, Object> dataMap = queryEntityData(comentityid);
|
|
|
+ if (dataMap != null && !dataMap.isEmpty()) {
|
|
|
+ dataSetTrue.add(comentityid);
|
|
|
+ dataList.add(dataMap);
|
|
|
+ }
|
|
|
dataSet.add(comentityid);
|
|
|
}
|
|
|
+ if (dataSetTrue.contains(comentityid)) {
|
|
|
+ linksList.add(linksMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (Map<String, Object> linksMap : links_end_entityid) {
|
|
|
+ String comentityid = (String) linksMap.get("source");
|
|
|
+ if (dataSetTrue.contains(comentityid)) {
|
|
|
+ //先判断数据存在
|
|
|
+ linksList.add(linksMap);
|
|
|
+ } else {
|
|
|
+ if (!dataSet.contains(comentityid)) {
|
|
|
+ Map<String, Object> dataMap = queryEntityData(comentityid);
|
|
|
+ if (dataMap != null && !dataMap.isEmpty()) {
|
|
|
+ dataSetTrue.add(comentityid);
|
|
|
+ dataList.add(dataMap);
|
|
|
+ }
|
|
|
+ dataSet.add(comentityid);
|
|
|
+ }
|
|
|
+ if (dataSetTrue.contains(comentityid)) {
|
|
|
+ linksList.add(linksMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ retMap.put("links", linksList);
|
|
|
retMap.put("data", dataList);
|
|
|
return retMap;
|
|
|
}
|