|
@@ -6,6 +6,7 @@ import com.onemap.apply.mapper.dimentity.DimEntityMapper;
|
|
|
import com.onemap.apply.mapper.dimentity.DimEntityReponsitory;
|
|
|
import com.onemap.apply.service.dimentity.DimEntityService;
|
|
|
import com.onemap.common.core.utils.StringUtils;
|
|
|
+import com.onemap.common.core.web.domain.RequestResult;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.neo4j.core.Neo4jClient;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -276,4 +277,100 @@ public class DimEntityServiceImpl implements DimEntityService {
|
|
|
return retList;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> queryEntityRelationshipFilter(Map map) {
|
|
|
+ String query_data = (String) map.get("query_data");
|
|
|
+ String query_links = (String) map.get("query_links");
|
|
|
+ List<Map> data = (List<Map>) map.get("data");
|
|
|
+ List<Map> links = (List<Map>) map.get("links");
|
|
|
+
|
|
|
+ Map<String, Map> d0_all_data = new HashMap<>();
|
|
|
+ Map<String, Map> d0_all_links = new HashMap<>();
|
|
|
+ for (Map obj_v : data) {
|
|
|
+ String entityid = (String) obj_v.get("entityid");
|
|
|
+ d0_all_data.put(entityid, obj_v);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (Map obj_v : links) {
|
|
|
+ String value = (String) obj_v.get("value");
|
|
|
+ String source = (String) obj_v.get("source");
|
|
|
+ String target = (String) obj_v.get("target");
|
|
|
+ d0_all_links.put(value + "@@" + source + "@@" + target, obj_v);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> retData = new HashMap<>();
|
|
|
+ List<Map> retDataList = new ArrayList<>();
|
|
|
+ Set<String> retDataSet = new HashSet<>();
|
|
|
+ List<Map> retLinksList = new ArrayList<>();
|
|
|
+ if (StringUtils.isNotEmpty(query_data) && StringUtils.isNotEmpty(query_links)) {
|
|
|
+ for (String v0_key : d0_all_links.keySet()) {
|
|
|
+ String[] v0_keys = v0_key.split("@@");
|
|
|
+ if (v0_keys[0].equals(query_links)) {
|
|
|
+ String source = v0_keys[1];
|
|
|
+ String target = v0_keys[2];
|
|
|
+ Map sourceData = d0_all_data.get(source);
|
|
|
+ if (sourceData != null) {
|
|
|
+ String entityid = (String) sourceData.get("entityid");
|
|
|
+ String entityname = (String) sourceData.get("entityname");
|
|
|
+ if (entityid.contains(query_data) || entityname.contains(query_data)) {
|
|
|
+ retLinksList.add(d0_all_links.get(v0_key));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Map targetData = d0_all_data.get(target);
|
|
|
+ if (targetData != null) {
|
|
|
+ String entityid = (String) targetData.get("entityid");
|
|
|
+ String entityname = (String) targetData.get("entityname");
|
|
|
+ if (entityid.contains(query_data) || entityname.contains(query_data)) {
|
|
|
+ retLinksList.add(d0_all_links.get(v0_key));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (StringUtils.isNotEmpty(query_links)) {
|
|
|
+ for (String v0_key : d0_all_links.keySet()) {
|
|
|
+ String[] v0_keys = v0_key.split("@@");
|
|
|
+ if (v0_keys[0].equals(query_links)) {
|
|
|
+ retLinksList.add(d0_all_links.get(v0_key));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (StringUtils.isNotEmpty(query_data)) {
|
|
|
+ Set<String> d1_all_data = new HashSet<>();
|
|
|
+ for (Map sourceData : data) {
|
|
|
+ String entityid = (String) sourceData.get("entityid");
|
|
|
+ String entityname = (String) sourceData.get("entityname");
|
|
|
+ if (entityid.contains(query_data) || entityname.contains(query_data)) {
|
|
|
+ d1_all_data.add(entityid);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (Map obj_v : links) {
|
|
|
+ String source = (String) obj_v.get("source");
|
|
|
+ String target = (String) obj_v.get("target");
|
|
|
+ if (d1_all_data.contains(source) || d1_all_data.contains(target)) {
|
|
|
+ retLinksList.add(obj_v);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ retData.put("data", data);
|
|
|
+ retData.put("links", links);
|
|
|
+ return RequestResult.success(retData);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (Map obj_v : retLinksList) {
|
|
|
+ String source = (String) obj_v.get("source");
|
|
|
+ String target = (String) obj_v.get("target");
|
|
|
+ if (!retDataSet.contains(source)) {
|
|
|
+ retDataList.add(d0_all_data.get(source));
|
|
|
+ }
|
|
|
+ if (!retDataSet.contains(target)) {
|
|
|
+ retDataList.add(d0_all_data.get(target));
|
|
|
+ }
|
|
|
+ retDataSet.add(source);
|
|
|
+ retDataSet.add(target);
|
|
|
+ }
|
|
|
+ retData.put("data", retDataList);
|
|
|
+ retData.put("links", retLinksList);
|
|
|
+ return retData;
|
|
|
+ }
|
|
|
+
|
|
|
}
|