Ver código fonte

matchRelation

bc_zhang 4 anos atrás
pai
commit
66916fe768
26 arquivos alterados com 1175 adições e 821 exclusões
  1. 0 1
      src/main/java/com/zglc/kg/KnowledgeGraphApplication.java
  2. 49 7
      src/main/java/com/zglc/kg/controller/MovieController.java
  3. 30 0
      src/main/java/com/zglc/kg/dao/BaseRelationDao.java
  4. 6 0
      src/main/java/com/zglc/kg/dao/MovieDao.java
  5. 71 0
      src/main/java/com/zglc/kg/entity/BaseRelationEntity.java
  6. 87 25
      src/main/java/com/zglc/kg/entity/MovieEntity.java
  7. 89 43
      src/main/java/com/zglc/kg/entity/PersonEntity.java
  8. 1 2
      src/main/java/com/zglc/kg/entity/RelationShipEntity.java
  9. 22 2
      src/main/java/com/zglc/kg/service/MovieService.java
  10. 27 24
      src/main/java/com/zglc/kg/utils/Neo4jConfig.java
  11. 707 707
      src/main/java/com/zglc/kg/utils/Neo4jUtil.java
  12. 76 0
      src/main/java/com/zglc/kg/utils/StringUtil.java
  13. 5 5
      src/main/resources/application-dev.yml
  14. 5 5
      target/classes/application-dev.yml
  15. BIN
      target/classes/com/zglc/kg/KnowledgeGraphApplication.class
  16. BIN
      target/classes/com/zglc/kg/controller/MovieController.class
  17. BIN
      target/classes/com/zglc/kg/dao/BaseRelationDao.class
  18. BIN
      target/classes/com/zglc/kg/entity/BaseRelationEntity.class
  19. BIN
      target/classes/com/zglc/kg/entity/MovieEntity.class
  20. BIN
      target/classes/com/zglc/kg/entity/PersonEntity.class
  21. BIN
      target/classes/com/zglc/kg/entity/RelationShipEntity$RelationShipEntityBuilder.class
  22. BIN
      target/classes/com/zglc/kg/entity/RelationShipEntity.class
  23. BIN
      target/classes/com/zglc/kg/service/MovieService.class
  24. BIN
      target/classes/com/zglc/kg/utils/Neo4jConfig.class
  25. BIN
      target/classes/com/zglc/kg/utils/Neo4jUtil.class
  26. BIN
      target/classes/com/zglc/kg/utils/StringUtil.class

+ 0 - 1
src/main/java/com/zglc/kg/KnowledgeGraphApplication.java

@@ -6,7 +6,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
 import com.zglc.kg.utils.DocToPdf;
 import com.zglc.kg.utils.Ppt2ToPdf;
 
-//@SpringBootApplication(scanBasePackages = {"com.zglc.kg"})
 @SpringBootApplication
 @ServletComponentScan
 @MapperScan("com.zglc.kg.dao")

+ 49 - 7
src/main/java/com/zglc/kg/controller/MovieController.java

@@ -3,6 +3,7 @@ package com.zglc.kg.controller;
 import com.zglc.kg.base.Result;
 import com.zglc.kg.entity.MovieEntity;
 import com.zglc.kg.entity.PersonEntity;
+import com.zglc.kg.entity.BaseRelationEntity;
 import com.zglc.kg.service.MovieService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -27,10 +28,10 @@ public class MovieController {
 
 
 
-    private final Driver driver;
+    private final Driver neo4jDriver;
 
-    public MovieController(Driver driver) {
-        this.driver = driver;
+    public MovieController(Driver neo4jDriver) {
+        this.neo4jDriver = neo4jDriver;
     }
 
 
@@ -53,6 +54,25 @@ public class MovieController {
         return movieService.addPerson(personEntity);
     }
 
+    @ApiOperation("增加关系")
+    @ApiResponses({
+            @ApiResponse(code = 0, message = "成功")
+    })
+    @PostMapping("addRelation")
+    public Result<String> addRelation(@RequestBody BaseRelationEntity baseRelationEntity){
+        return movieService.addRelation(baseRelationEntity);
+    }
+
+
+    @ApiOperation("删除关系")
+    @ApiResponses({
+            @ApiResponse(code = 0, message = "成功")
+    })
+    @PostMapping("deleteRelation")
+    public Result<String> deleteRelation(@RequestParam Long id){
+        return movieService.deleteRelation(id);
+    }
+
     @ApiOperation("查看电影节点")
     @ApiResponses({
             @ApiResponse(code = 0, message = "成功")
@@ -95,18 +115,40 @@ public class MovieController {
             @ApiResponse(code = 0, message = "成功")
     })
     @GetMapping("getMovieByTitle")
-    public  Result<MovieEntity> getMovieByTitle(@RequestParam String name){
-        return  Result.success(movieService.getMovieByTitle(name));
+    public Result<List<BaseRelationEntity>>  getMovieByTitle(@RequestParam String name){
+        return  movieService.getMovieByPerson(name);
+    }
+
+    @ApiOperation("根据名称查询电影1")//完全一致
+    @ApiResponses({
+            @ApiResponse(code = 0, message = "成功")
+    })
+    @GetMapping("getMovieByTitle1")
+    public Result<List<BaseRelationEntity>>  getMovieByTitle1(@RequestParam String name){
+        return  movieService.getMovieByPerson1(name);
     }
 
+//    MATCH (tom:Person {name: "Tom Hanks"})-[:ACTED_IN]->(tomHanksMovies) RETURN tom,tomHanksMovies
 
 
+//    @ApiOperation("查询演员所演电影")//完全一致
+//    @ApiResponses({
+//            @ApiResponse(code = 0, message = "成功")
+//    })
+//    @GetMapping("getMovieByPerson")
+//    public  Result<MovieEntity> getMovieByPerson(@RequestParam String name){
+//        try (Session session = neo4jDriver.session()) {
+////            return session.run("MATCH (tom:Person {name: \"Tom Hanks\"})-[:ACTED_IN]->(tomHanksMovies) RETURN tom,tomHanksMovies");
+//        }
+//
+////        return  Result.success(movieService.getMovieByTitle(name));
+//    }
 
 
     @GetMapping(path = "/movies", produces = MediaType.APPLICATION_JSON_VALUE)
     public List<String> getMovieTitles() {
-
-        try (Session session = driver.session()) {
+//        Driver driver = GraphDatabase.driver( "bolt://localhost:7687", AuthTokens.basic( "neo4j", "neo4j" ) );
+        try (Session session = neo4jDriver.session()) {
             return session.run("MATCH (m:Movie) RETURN m ORDER BY m.name ASC")
                     .list(r -> r.get("m").asNode().get("title").asString());
         }

+ 30 - 0
src/main/java/com/zglc/kg/dao/BaseRelationDao.java

@@ -0,0 +1,30 @@
+package com.zglc.kg.dao;
+
+import com.zglc.kg.entity.BaseRelationEntity;
+import com.zglc.kg.entity.PersonEntity;
+
+import org.apache.ibatis.annotations.Param;
+import org.springframework.data.neo4j.annotation.Query;
+import org.springframework.data.neo4j.repository.Neo4jRepository;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository
+public interface BaseRelationDao extends Neo4jRepository<BaseRelationEntity,Long> {
+
+
+    //返回节点n以及n指向或指向n的所有节点与关系
+//    @Query("MATCH p=(n:Person)-[:ACTED_IN]->(m:Movie) WHERE n.name={name1} RETURN p")
+//    @Query("MATCH p=(n:Bot)<-[r:BotRelation]->(m:Bot) WHERE m.name={name} RETURN p")
+    @Query("MATCH p=()-[r:Relation]->() RETURN p LIMIT 25")
+    List<BaseRelationEntity> findAllBySymptom(@Param("name1") String name);
+
+
+    @Query("MATCH p= (tom:Person)-[:Relation]->(tomHanksMovies) WHERE tom.name={name1} RETURN p")
+    List<BaseRelationEntity> findAllBySymptom1(@Param("name1") String name1);
+
+//    String nodeSql = String.format("MATCH (n:`%s`) <-[r]->(m) %s return * limit %s", domain, cqWhere,
+//            query.getPageSize());
+}
+

+ 6 - 0
src/main/java/com/zglc/kg/dao/MovieDao.java

@@ -1,6 +1,7 @@
 package com.zglc.kg.dao;
 
 import com.zglc.kg.entity.MovieEntity;
+import org.springframework.data.neo4j.annotation.Query;
 import org.springframework.data.neo4j.repository.Neo4jRepository;
 import org.springframework.stereotype.Repository;
 
@@ -8,5 +9,10 @@ import org.springframework.stereotype.Repository;
 public interface MovieDao extends Neo4jRepository<MovieEntity,Long> {
     MovieEntity getMovieEntitiesByTitle(String name);
 
+//    //返回节点n以及n指向的所有节点与关系
+//    @Query("MATCH p=(n:Bot)-[r:BotRelation]->(m:Bot) WHERE id(n)={0} RETURN p")
+//    List<BotRelation> findAllByBotNode(BotNode botNode);
+
+
 }
 

+ 71 - 0
src/main/java/com/zglc/kg/entity/BaseRelationEntity.java

@@ -0,0 +1,71 @@
+package com.zglc.kg.entity;
+import org.neo4j.ogm.annotation.*;
+
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import com.zglc.kg.entity.*;
+
+@RelationshipEntity(type = "Relation")
+public class BaseRelationEntity {
+    @Id
+    @GeneratedValue
+    private Long id;
+    @StartNode
+    private PersonEntity startNode;
+    @EndNode
+    private MovieEntity endNode;
+    @Property
+    private String relation;
+
+    public BaseRelationEntity() {
+    }
+
+    public BaseRelationEntity(Long id, PersonEntity startNode, MovieEntity endNode, String relation) {
+        this.id = id;
+        this.startNode = startNode;
+        this.endNode = endNode;
+        this.relation = relation;
+    }
+
+    public String getRelation() {
+        return relation;
+    }
+
+    public void setRelation(String relation) {
+        this.relation = relation;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public PersonEntity getStartNode() {
+        return startNode;
+    }
+
+    public void setStartNode(PersonEntity startNode) {
+        this.startNode = startNode;
+    }
+
+    public MovieEntity getEndNode() {
+        return endNode;
+    }
+
+    public void setEndNode(MovieEntity endNode) {
+        this.endNode = endNode;
+    }
+
+    @Override
+    public String toString() {
+        return "RelationEntity{" +
+                "id=" + id +
+                ", startNode=" + startNode +
+                ", endNode=" + endNode +
+                ", relation='" + relation + '\'' +
+                '}';
+    }
+}

+ 87 - 25
src/main/java/com/zglc/kg/entity/MovieEntity.java

@@ -1,34 +1,33 @@
 package com.zglc.kg.entity;
-import lombok.Getter;
-import lombok.Setter;
+import io.swagger.models.auth.In;
 import org.neo4j.ogm.annotation.NodeEntity;
+import org.neo4j.ogm.annotation.Property;
+import org.neo4j.ogm.annotation.Relationship;
 
 import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
 import javax.persistence.Id;
+import java.util.Set;
 
-@Getter
-@Setter
-@NodeEntity
-public class MovieEntity {
-
-    @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
-    private Long id;
-
-    private String title;
-
-    private String released;
-
-    public MovieEntity() {
-
-    }
-
-    public MovieEntity(String title, String released) {
-        this.title = title;
-        this.released = released;
-    }
 
+@NodeEntity(label = "Movie")
+public class MovieEntity {
+//    @Id
+//    @GeneratedValue
+//    private Long id;
+//
+//    private String title;
+//
+//    private String released;
+//
+//    public MovieEntity() {
+//
+//    }
+//
+//    public MovieEntity(String title, String released) {
+//        this.title = title;
+//        this.released = released;
+//    }
+//
 //    public Long getId() {
 //        return id;
 //    }
@@ -52,6 +51,69 @@ public class MovieEntity {
 //    public void setReleased(String released) {
 //        this.released = released;
 //    }
-}
+    @Id
+    @GeneratedValue
+    private Long id;
+    @Property(name = "title")
+    private String title;
+    @Property(name = "tagline")
+    private String tagline;
+    @Property(name = "released")
+    private Integer released;
 
 
+    public MovieEntity() {
+    }
+
+    public MovieEntity(Long id, String title, String tagline,Integer released) {
+        this.id = id;
+        this.title = title;
+        this.tagline = tagline;
+        this.released = released;
+
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getTagline() {
+        return tagline;
+    }
+
+    public void setTagline(String tagline) {
+        this.tagline = tagline;
+    }
+
+    public Integer getReleased() {
+        return released;
+    }
+
+    public void setReleased(Integer released) {
+        this.released = released;
+    }
+
+    @Override
+    public String toString() {
+        return "MovieEntity{" +
+                "id=" + id +
+                ", title='" + title + '\'' +
+                ", title='" + title + '\'' +
+                ", tagline='" + tagline + '\'' +
+                ", released='" + released + '\'' +
+                '}';
+    }
+
+}

+ 89 - 43
src/main/java/com/zglc/kg/entity/PersonEntity.java

@@ -3,56 +3,57 @@ import java.util.HashSet;
 import java.util.Set;
 
 import org.neo4j.ogm.annotation.NodeEntity;
+import org.neo4j.ogm.annotation.Property;
 import org.neo4j.ogm.annotation.Relationship;
 
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
-
-@NodeEntity
+import com.zglc.kg.entity.MovieEntity;
+@NodeEntity(label = "Person")
 public class PersonEntity {
 
-    @Id
-    @GeneratedValue(strategy = GenerationType.IDENTITY)
-    private Long id;
-
-    private String name;
-
-    private String born;
-
-
-    public PersonEntity() {// 从 Neo4j API 2.0.5开始需要无参构造函数
-
-    }
-
-    public PersonEntity(String name, String born) {
-        this.name = name;
-        this.born = born;
-    }
-
-
-    @Relationship(type = "ACTED_IN", direction = Relationship.OUTGOING)
-    public Set<MovieEntity> actors;
-
-    public void addActor(MovieEntity movie) {
-        if (actors == null) {
-            actors = new HashSet<>();
-        }
-        actors.add(movie);
-    }
-
-
-    @Relationship(type = "DIRECTED", direction = Relationship.OUTGOING)
-    public Set<MovieEntity> directors;
-
-    public void addDirector(MovieEntity movie) {
-        if (directors == null) {
-            directors = new HashSet<>();
-        }
-        directors.add(movie);
-    }
-
-
+//    @Id
+//    @GeneratedValue
+//    private Long id;
+//
+//    private String name;
+//
+//    private String born;
+//
+//
+//    public PersonEntity() {// 从 Neo4j API 2.0.5开始需要无参构造函数
+//
+//    }
+//
+//    public PersonEntity(String name, String born) {
+//        this.name = name;
+//        this.born = born;
+//    }
+//
+//
+//    @Relationship(type = "ACTED_IN", direction = Relationship.OUTGOING)
+//    public Set<MovieEntity> actors;
+//
+//    public void addActor(MovieEntity movieEntity) {
+//        if (actors == null) {
+//            actors = new HashSet<>();
+//        }
+//        actors.add(movieEntity);
+//    }
+//
+//
+//    @Relationship(type = "DIRECTED", direction = Relationship.OUTGOING)
+//    public Set<MovieEntity> directors;
+//
+//    public void addDirector(MovieEntity movieEntity) {
+//        if (directors == null) {
+//            directors = new HashSet<>();
+//        }
+//        directors.add(movieEntity);
+//    }
+//
+//
 //    public Long getId() {
 //        return id;
 //    }
@@ -76,11 +77,56 @@ public class PersonEntity {
 //    public void setBorn(String born) {
 //        this.born = born;
 //    }
+    @Id
+    @GeneratedValue
+    private Long id;
+    @Property(name = "name")
+    private String name;
+    @Property(name = "born")
+    private Integer born;
+
+    public PersonEntity() {
+    }
 
+    public PersonEntity(Long id, String name, Integer born) {
+        this.id = id;
+        this.name = name;
+        this.born = born;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
 
+    public Integer getBorn() {
+        return born;
+    }
 
+    public void setBorn(Integer born) {
+        this.born = born;
+    }
 
 
 
+    @Override
+    public String toString() {
+        return "PersonEntity{" +
+                "id=" + id +
+                ", name='" + name + '\'' +
+                ", born='" + born + '\'' +
+                '}';
+    }
 
 }

+ 1 - 2
src/main/java/com/zglc/kg/entity/RelationShipEntity.java

@@ -1,7 +1,6 @@
 package com.zglc.kg.entity;
 
-import java.util.HashSet;
-import java.util.Set;
+
 
 import lombok.Builder;
 import lombok.Data;

+ 22 - 2
src/main/java/com/zglc/kg/service/MovieService.java

@@ -4,9 +4,10 @@ import com.zglc.kg.base.Result;
 import com.zglc.kg.dao.DeptDao;
 import com.zglc.kg.dao.MovieDao;
 import com.zglc.kg.dao.PersonDao;
-import com.zglc.kg.dao.RelationShipDao;
+import com.zglc.kg.dao.BaseRelationDao;
 import com.zglc.kg.entity.MovieEntity;
 import com.zglc.kg.entity.PersonEntity;
+import com.zglc.kg.entity.BaseRelationEntity;
 import org.springframework.stereotype.Service;
 import org.springframework.web.bind.annotation.GetMapping;
 
@@ -27,7 +28,7 @@ public class MovieService {
     @Resource
     private DeptDao deptDao;
     @Resource
-    private RelationShipDao relationShipDao;
+    private BaseRelationDao baseRelationDao;
 
     public Result<String> addMovie(MovieEntity movieEntity){
         movieDao.save(movieEntity);
@@ -39,6 +40,12 @@ public class MovieService {
         return Result.success("添加成功!");
     }
 
+    public Result<String> addRelation(BaseRelationEntity baseRelationEntity){
+        baseRelationDao.save(baseRelationEntity);
+        return Result.success("添加成功!");
+    }
+
+
     public MovieEntity getMovieById(Long id){
         Optional<MovieEntity> byId = movieDao.findById(id);
         return byId.orElse(null);
@@ -59,11 +66,24 @@ public class MovieService {
         return Result.success("删除成功!");
     }
 
+    public Result<String> deleteRelation(Long id) {
+        baseRelationDao.deleteById(id);
+        return Result.success("删除成功!");
+    }
+
     public MovieEntity getMovieByTitle(String name){
         return movieDao.getMovieEntitiesByTitle(name);
     }
 
+    public Result<List<BaseRelationEntity>> getMovieByPerson(String name){
+        List<BaseRelationEntity> list = baseRelationDao.findAllBySymptom(name);
+        return Result.success(list);
+    }
 
+    public Result<List<BaseRelationEntity>> getMovieByPerson1(String name){
+        List<BaseRelationEntity> list = baseRelationDao.findAllBySymptom1(name);
+        return Result.success(list);
+    }
 
 
 }

+ 27 - 24
src/main/java/com/zglc/kg/utils/Neo4jConfig.java

@@ -1,14 +1,14 @@
-//package com.zglc.kg.utils;
-//
-//import org.neo4j.driver.AuthTokens;
-//import org.neo4j.driver.Driver;
-//import org.neo4j.driver.GraphDatabase;
-//import org.springframework.beans.factory.annotation.Value;
-//import org.springframework.context.annotation.Bean;
-//import org.springframework.context.annotation.Configuration;
-//
-//@Configuration
-//public class Neo4jConfig {
+package com.zglc.kg.utils;
+
+import org.neo4j.driver.AuthTokens;
+import org.neo4j.driver.Driver;
+import org.neo4j.driver.GraphDatabase;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class Neo4jConfig {
 //	@Value("${spring.neo4j.url}")
 //	private String url;
 //
@@ -17,16 +17,19 @@
 //
 //	@Value("${spring.neo4j.password}")
 //	private String password;
-//
-//	/**
-//	 * 图数据库驱动模式
-//	 *
-//	 * @return
-//	 */
-//
-//	@Bean
-//	public Driver neo4jDriver() {
-//		return GraphDatabase.driver(url, AuthTokens.basic(username, password));
-//	}
-//
-//}
+
+	/**
+	 * 图数据库驱动模式
+	 *
+	 * @return
+	 */
+
+	@Bean
+	public Driver neo4jDriver() {
+        String url="bolt://localhost:7687";
+		String username="neo4j";
+		String password="neo4j";
+		return GraphDatabase.driver(url, AuthTokens.basic(username, password));
+	}
+
+}

+ 707 - 707
src/main/java/com/zglc/kg/utils/Neo4jUtil.java

@@ -1,707 +1,707 @@
-//package com.zglc.kg.utils;
-//
-//import com.alibaba.fastjson.JSON;
-//import org.neo4j.driver.*;
-//import org.neo4j.driver.types.Node;
-//import org.neo4j.driver.types.Path;
-//import org.neo4j.driver.types.Relationship;
-//import org.neo4j.driver.util.Pair;
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.stereotype.Component;
-//
-//import java.lang.reflect.Field;
-//import java.util.*;
-//import java.util.Map.Entry;
-//
-//@Component
-//public class Neo4jUtil {
-//	@Autowired
-//	private Driver neo4jDriver;
-//
-//	public boolean isNeo4jOpen() {
-//		try (Session session = neo4jDriver.session()) {
-//			System.out.println("连接成功:" + session.isOpen());
-//			return session.isOpen();
-//		} catch (Exception e) {
-//
-//		}
-//		return false;
-//	}
-//
-////	public StatementResult excuteCypherSql(String cypherSql) {
-////		StatementResult result = null;
-////		try (Session session = neo4jDriver.session()) {
-////			System.out.println(cypherSql);
-////			result = session.run(cypherSql);
-////			session.close();
-////		} catch (Exception e) {
-////			throw e;
-////		}
-////		return result;
-////	}
-////
-////
-////	public HashMap<String, Object> GetEntityMap(String cypherSql) {
-////		HashMap<String, Object> rss = new HashMap<String, Object>();
-////		try {
-////			StatementResult result = excuteCypherSql(cypherSql);
-////			if (result.hasNext()) {
-////				List<Record> records = result.list();
-////				for (Record recordItem : records) {
-////					for (Value value : recordItem.values()) {
-////						if (value.type().name().equals("NODE")) {// 结果里面只要类型为节点的值
-////							Node noe4jNode = value.asNode();
-////							Map<String, Object> map = noe4jNode.asMap();
-////							for (Entry<String, Object> entry : map.entrySet()) {
-////								String key = entry.getKey();
-////								if (rss.containsKey(key)) {
-////									String oldValue = rss.get(key).toString();
-////									String newValue = oldValue + "," + entry.getValue();
-////									rss.replace(key, newValue);
-////								} else {
-////									rss.put(key, entry.getValue());
-////								}
-////							}
-////
-////						}
-////					}
-////				}
-////			}
-////
-////		} catch (Exception e) {
-////			e.printStackTrace();
-////		}
-////		return rss;
-////	}
-////
-////	public List<HashMap<String, Object>> GetGraphNode(String cypherSql) {
-////		List<HashMap<String, Object>> ents = new ArrayList<HashMap<String, Object>>();
-////		try {
-////			StatementResult result = excuteCypherSql(cypherSql);
-////			if (result.hasNext()) {
-////				List<Record> records = result.list();
-////				for (Record recordItem : records) {
-////					List<Pair<String, Value>> f = recordItem.fields();
-////					for (Pair<String, Value> pair : f) {
-////						HashMap<String, Object> rss = new HashMap<String, Object>();
-////						String typeName = pair.value().type().name();
-////						if (typeName.equals("NODE")) {
-////							Node noe4jNode = pair.value().asNode();
-////							String uuid = String.valueOf(noe4jNode.id());
-////							Map<String, Object> map = noe4jNode.asMap();
-////							for (Entry<String, Object> entry : map.entrySet()) {
-////								String key = entry.getKey();
-////								rss.put(key, entry.getValue());
-////							}
-////							rss.put("uuid", uuid);
-////							ents.add(rss);
-////						}
-////					}
-////
-////				}
-////			}
-////
-////		} catch (Exception e) {
-////			e.printStackTrace();
-////		}
-////		return ents;
-////	}
-////
-////	public List<HashMap<String, Object>> GetGraphRelationShip(String cypherSql) {
-////		List<HashMap<String, Object>> ents = new ArrayList<HashMap<String, Object>>();
-////		try {
-////			StatementResult result = excuteCypherSql(cypherSql);
-////			if (result.hasNext()) {
-////				List<Record> records = result.list();
-////				for (Record recordItem : records) {
-////					List<Pair<String, Value>> f = recordItem.fields();
-////					for (Pair<String, Value> pair : f) {
-////						HashMap<String, Object> rss = new HashMap<String, Object>();
-////						String typeName = pair.value().type().name();
-////						if (typeName.equals("RELATIONSHIP")) {
-////							Relationship rship = pair.value().asRelationship();
-////							String uuid = String.valueOf(rship.id());
-////							String sourceid = String.valueOf(rship.startNodeId());
-////							String targetid = String.valueOf(rship.endNodeId());
-////							Map<String, Object> map = rship.asMap();
-////							for (Entry<String, Object> entry : map.entrySet()) {
-////								String key = entry.getKey();
-////								rss.put(key, entry.getValue());
-////							}
-////							rss.put("uuid", uuid);
-////							rss.put("sourceid", sourceid);
-////							rss.put("targetid", targetid);
-////							ents.add(rss);
-////						}
-////					}
-////				}
-////			}
-////		} catch (Exception e) {
-////			e.printStackTrace();
-////		}
-////		return ents;
-////	}
-////	public List<HashMap<String, Object>> GetGraphItem(String cypherSql) {
-////		List<HashMap<String, Object>> ents = new ArrayList<HashMap<String, Object>>();
-////		List<String> nodeids = new ArrayList<String>();
-////		List<String> shipids = new ArrayList<String>();
-////		try {
-////			StatementResult result = excuteCypherSql(cypherSql);
-////			if (result.hasNext()) {
-////				List<Record> records = result.list();
-////				for (Record recordItem : records) {
-////					List<Pair<String, Value>> f = recordItem.fields();
-////					HashMap<String, Object> rss = new HashMap<String, Object>();
-////					for (Pair<String, Value> pair : f) {
-////						String typeName = pair.value().type().name();
-////						if (typeName.equals("NODE")) {
-////							Node noe4jNode = pair.value().asNode();
-////							String uuid = String.valueOf(noe4jNode.id());
-////							if(!nodeids.contains(uuid)) {
-////								Map<String, Object> map = noe4jNode.asMap();
-////								for (Entry<String, Object> entry : map.entrySet()) {
-////									String key = entry.getKey();
-////									rss.put(key, entry.getValue());
-////								}
-////								rss.put("uuid", uuid);
-////							}
-////						}else if (typeName.equals("RELATIONSHIP")) {
-////							Relationship rship = pair.value().asRelationship();
-////							String uuid = String.valueOf(rship.id());
-////							if (!shipids.contains(uuid)) {
-////								String sourceid = String.valueOf(rship.startNodeId());
-////								String targetid = String.valueOf(rship.endNodeId());
-////								Map<String, Object> map = rship.asMap();
-////								for (Entry<String, Object> entry : map.entrySet()) {
-////									String key = entry.getKey();
-////									rss.put(key, entry.getValue());
-////								}
-////								rss.put("uuid", uuid);
-////								rss.put("sourceid", sourceid);
-////								rss.put("targetid", targetid);
-////							}
-////						}else {
-////							rss.put(pair.key(),pair.value().toString());
-////						}
-////					}
-////					ents.add(rss);
-////				}
-////			}
-////		} catch (Exception e) {
-////			e.printStackTrace();
-////		}
-////		return ents;
-////	}
-////	/*
-////	 * 获取值类型的结果,如count,uuid
-////	 * @return 1 2 3 等数字类型
-////	 */
-////	public long GetGraphValue(String cypherSql) {
-////		long val=0;
-////		try {
-////			StatementResult cypherResult = excuteCypherSql(cypherSql);
-////			if (cypherResult.hasNext()) {
-////				Record record = cypherResult.next();
-////				for (Value value : record.values()) {
-////					val = value.asLong();
-////				}
-////			}
-////		} catch (Exception e) {
-////			e.printStackTrace();
-////		}
-////		return val;
-////	}
-////
-////	public HashMap<String, Object> GetGraphNodeAndShip(String cypherSql) {
-////		HashMap<String, Object> mo = new HashMap<String, Object>();
-////		try {
-////			StatementResult result = excuteCypherSql(cypherSql);
-////			if (result.hasNext()) {
-////				List<Record> records = result.list();
-////				List<HashMap<String, Object>> ents = new ArrayList<HashMap<String, Object>>();
-////				List<HashMap<String, Object>> ships = new ArrayList<HashMap<String, Object>>();
-////				List<String> uuids = new ArrayList<String>();
-////				List<String> shipids = new ArrayList<String>();
-////				for (Record recordItem : records) {
-////					List<Pair<String, Value>> f = recordItem.fields();
-////					for (Pair<String, Value> pair : f) {
-////						HashMap<String, Object> rships = new HashMap<String, Object>();
-////						HashMap<String, Object> rss = new HashMap<String, Object>();
-////						String typeName = pair.value().type().name();
-////						if (typeName.equals("NULL")) {
-////							continue;
-////						} else if (typeName.equals("NODE")) {
-////							Node noe4jNode = pair.value().asNode();
-////                            Map<String, Object> map = noe4jNode.asMap();
-////                            String uuid = String.valueOf(noe4jNode.id());
-////                            if (!uuids.contains(uuid)) {
-////                                for (Entry<String, Object> entry : map.entrySet()) {
-////                                    String key = entry.getKey();
-////                                    rss.put(key, entry.getValue());
-////                                }
-////                                rss.put("uuid", uuid);
-////                                uuids.add(uuid);
-////                            }
-////                            if (rss != null && !rss.isEmpty()) {
-////                                ents.add(rss);
-////                            }
-////						} else if (typeName.equals("RELATIONSHIP")) {
-////							Relationship rship = pair.value().asRelationship();
-////                            String uuid = String.valueOf(rship.id());
-////                            if (!shipids.contains(uuid)) {
-////                                String sourceid = String.valueOf(rship.startNodeId());
-////                                String targetid = String.valueOf(rship.endNodeId());
-////                                Map<String, Object> map = rship.asMap();
-////                                for (Entry<String, Object> entry : map.entrySet()) {
-////                                    String key = entry.getKey();
-////                                    rships.put(key, entry.getValue());
-////                                }
-////                                rships.put("uuid", uuid);
-////                                rships.put("sourceid", sourceid);
-////                                rships.put("targetid", targetid);
-////								shipids.add(uuid);
-////                                if (rships != null && !rships.isEmpty()) {
-////                                    ships.add(rships);
-////                                }
-////                            }
-////
-////						} else if (typeName.equals("PATH")) {
-////							Path path = pair.value().asPath();
-////							Map<String, Object> startNodemap = path.start().asMap();
-////							String startNodeuuid = String.valueOf(path.start().id());
-////							if (!uuids.contains(startNodeuuid)) {
-////								rss=new HashMap<String, Object>();
-////								for (Entry<String, Object> entry : startNodemap.entrySet()) {
-////									String key = entry.getKey();
-////									rss.put(key, entry.getValue());
-////								}
-////								rss.put("uuid", startNodeuuid);
-////								uuids.add(startNodeuuid);
-////								if (rss != null && !rss.isEmpty()) {
-////									ents.add(rss);
-////								}
-////							}
-////
-////							Map<String, Object> endNodemap = path.end().asMap();
-////							String endNodeuuid = String.valueOf(path.end().id());
-////							if (!uuids.contains(endNodeuuid)) {
-////								rss=new HashMap<String, Object>();
-////								for (Entry<String, Object> entry : endNodemap.entrySet()) {
-////									String key = entry.getKey();
-////									rss.put(key, entry.getValue());
-////								}
-////								rss.put("uuid", endNodeuuid);
-////								uuids.add(endNodeuuid);
-////								if (rss != null && !rss.isEmpty()) {
-////									ents.add(rss);
-////								}
-////							}
-////							Iterator<Node> allNodes = path.nodes().iterator();
-////							while (allNodes.hasNext()) {
-////								Node next = allNodes.next();
-////								String uuid = String.valueOf(next.id());
-////								if (!uuids.contains(uuid)) {
-////									rss=new HashMap<String, Object>();
-////									Map<String, Object> map = next.asMap();
-////									for (Entry<String, Object> entry : map.entrySet()) {
-////										String key = entry.getKey();
-////										rss.put(key, entry.getValue());
-////									}
-////									rss.put("uuid", uuid);
-////									uuids.add(uuid);
-////									if (rss != null && !rss.isEmpty()) {
-////										ents.add(rss);
-////									}
-////								}
-////							}
-////							Iterator<Relationship> reships = path.relationships().iterator();
-////							while (reships.hasNext()) {
-////								Relationship next = reships.next();
-////								String uuid = String.valueOf(next.id());
-////								if (!shipids.contains(uuid)) {
-////									rships=new HashMap<String, Object>();
-////									String sourceid = String.valueOf(next.startNodeId());
-////									String targetid = String.valueOf(next.endNodeId());
-////									Map<String, Object> map = next.asMap();
-////									for (Entry<String, Object> entry : map.entrySet()) {
-////										String key = entry.getKey();
-////										rships.put(key, entry.getValue());
-////									}
-////									rships.put("uuid", uuid);
-////									rships.put("sourceid", sourceid);
-////									rships.put("targetid", targetid);
-////									shipids.add(uuid);
-////									if (rships != null && !rships.isEmpty()) {
-////										ships.add(rships);
-////									}
-////								}
-////							}
-////						} else if (typeName.contains("LIST")) {
-////							Iterable<Value> val=pair.value().values();
-////                            Value next = val.iterator().next();
-////                            String type=next.type().name();
-////                            if (type.equals("RELATIONSHIP")) {
-////                                Relationship rship = next.asRelationship();
-////                                String uuid = String.valueOf(rship.id());
-////                                if (!shipids.contains(uuid)) {
-////                                    String sourceid = String.valueOf(rship.startNodeId());
-////                                    String targetid = String.valueOf(rship.endNodeId());
-////                                    Map<String, Object> map = rship.asMap();
-////                                    for (Entry<String, Object> entry : map.entrySet()) {
-////                                        String key = entry.getKey();
-////                                        rships.put(key, entry.getValue());
-////                                    }
-////                                    rships.put("uuid", uuid);
-////                                    rships.put("sourceid", sourceid);
-////                                    rships.put("targetid", targetid);
-////									shipids.add(uuid);
-////                                    if (rships != null && !rships.isEmpty()) {
-////                                        ships.add(rships);
-////                                    }
-////                                }
-////                            }
-////						} else if (typeName.contains("MAP")) {
-////							rss.put(pair.key(), pair.value().asMap());
-////						} else {
-////							rss.put(pair.key(), pair.value().toString());
-////                            if (rss != null && !rss.isEmpty()) {
-////                                ents.add(rss);
-////                            }
-////						}
-////
-////					}
-////				}
-////				mo.put("node", ents);
-////				mo.put("relationship", ships);
-////			}
-////
-////		} catch (Exception e) {
-////			e.printStackTrace();
-////			throw e;
-////		}
-////		return mo;
-////	}
-////	/**
-////	 * 匹配所有类型的节点,可以是节点,关系,数值,路径
-////	 * @param cypherSql
-////	 * @return
-////	 */
-////	public List<HashMap<String, Object>> GetEntityList(String cypherSql) {
-////		List<HashMap<String, Object>> ents = new ArrayList<HashMap<String, Object>>();
-////		try {
-////			StatementResult result = excuteCypherSql(cypherSql);
-////			if (result.hasNext()) {
-////				List<Record> records = result.list();
-////				for (Record recordItem : records) {
-////					HashMap<String, Object> rss = new HashMap<String, Object>();
-////					List<Pair<String, Value>> f = recordItem.fields();
-////					for (Pair<String, Value> pair : f) {
-////						String typeName = pair.value().type().name();
-////						if (typeName.equals("NULL")) {
-////							continue;
-////						} else if (typeName.equals("NODE")) {
-////							Node noe4jNode = pair.value().asNode();
-////							Map<String, Object> map = noe4jNode.asMap();
-////							for (Entry<String, Object> entry : map.entrySet()) {
-////								String key = entry.getKey();
-////								rss.put(key, entry.getValue());
-////							}
-////						} else if (typeName.equals("RELATIONSHIP")) {
-////							Relationship rship = pair.value().asRelationship();
-////							Map<String, Object> map = rship.asMap();
-////							for (Entry<String, Object> entry : map.entrySet()) {
-////								String key = entry.getKey();
-////								rss.put(key, entry.getValue());
-////							}
-////						} else if (typeName.equals("PATH")) {
-////
-////						} else if (typeName.contains("LIST")) {
-////							rss.put(pair.key(), pair.value().asList());
-////						} else if (typeName.contains("MAP")) {
-////							rss.put(pair.key(), pair.value().asMap());
-////						} else {
-////							rss.put(pair.key(), pair.value().toString());
-////						}
-////					}
-////					ents.add(rss);
-////				}
-////			}
-////
-////		} catch (Exception e) {
-////			e.printStackTrace();
-////		}
-////		return ents;
-////	}
-////
-////	public <T> List<T> GetEntityItemList(String cypherSql, Class<T> type) {
-////		List<HashMap<String, Object>> ents=GetGraphNode(cypherSql);
-////		List<T> model = HashMapToObject(ents, type);
-////		return model;
-////	}
-////
-////	public <T> T GetEntityItem(String cypherSql, Class<T> type) {
-////		HashMap<String, Object> rss = new HashMap<String, Object>();
-////		try {
-////			StatementResult result = excuteCypherSql(cypherSql);
-////			if (result.hasNext()) {
-////				Record record = result.next();
-////				for (Value value : record.values()) {
-////					if (value.type().name().equals("NODE")) {// 结果里面只要类型为节点的值
-////						Node noe4jNode = value.asNode();
-////						Map<String, Object> map = noe4jNode.asMap();
-////						for (Entry<String, Object> entry : map.entrySet()) {
-////							String key = entry.getKey();
-////							if (rss.containsKey(key)) {
-////								String oldValue = rss.get(key).toString();
-////								String newValue = oldValue + "," + entry.getValue();
-////								rss.replace(key, newValue);
-////							} else {
-////								rss.put(key, entry.getValue());
-////							}
-////						}
-////
-////					}
-////				}
-////			}
-////
-////		} catch (Exception e) {
-////			e.printStackTrace();
-////		}
-////		T model = HashMapToObjectItem(rss, type);
-////		return model;
-////	}
-////
-////	public HashMap<String, Object> GetEntity(String cypherSql) {
-////		HashMap<String, Object> rss = new HashMap<String, Object>();
-////		try {
-////			StatementResult result = excuteCypherSql(cypherSql);
-////			if (result.hasNext()) {
-////				Record record = result.next();
-////				for (Value value : record.values()) {
-////					String t = value.type().name();
-////					if (value.type().name().equals("NODE")) {// 结果里面只要类型为节点的值
-////						Node noe4jNode = value.asNode();
-////						Map<String, Object> map = noe4jNode.asMap();
-////						for (Entry<String, Object> entry : map.entrySet()) {
-////							String key = entry.getKey();
-////							if (rss.containsKey(key)) {
-////								String oldValue = rss.get(key).toString();
-////								String newValue = oldValue + "," + entry.getValue();
-////								rss.replace(key, newValue);
-////							} else {
-////								rss.put(key, entry.getValue());
-////							}
-////						}
-////
-////					}
-////				}
-////			}
-////
-////		} catch (Exception e) {
-////			e.printStackTrace();
-////		}
-////		return rss;
-////	}
-////
-////	public Integer executeScalar(String cypherSql) {
-////		Integer count = 0;
-////		try {
-////			StatementResult result = excuteCypherSql(cypherSql);
-////			if (result.hasNext()) {
-////				Record record = result.next();
-////				for (Value value : record.values()) {
-////					String t = value.type().name();
-////					if (t.equals("INTEGER")) {
-////						count = Integer.valueOf(value.toString());
-////						break;
-////					}
-////				}
-////			}
-////
-////		} catch (Exception e) {
-////			e.printStackTrace();
-////		}
-////		return count;
-////	}
-////
-////	public HashMap<String, Object> GetRelevantEntity(String cypherSql) {
-////		HashMap<String, Object> rss = new HashMap<String, Object>();
-////		try {
-////			StatementResult resultNode = excuteCypherSql(cypherSql);
-////			if (resultNode.hasNext()) {
-////				List<Record> records = resultNode.list();
-////				for (Record recordItem : records) {
-////					Map<String, Object> r = recordItem.asMap();
-////					System.out.println(JSON.toJSONString(r));
-////					String key = r.get("key").toString();
-////					if (rss.containsKey(key)) {
-////						String oldValue = rss.get(key).toString();
-////						String newValue = oldValue + "," + r.get("value");
-////						rss.replace(key, newValue);
-////					} else {
-////						rss.put(key, r.get("value"));
-////					}
-////				}
-////			}
-////
-////		} catch (Exception e) {
-////			e.printStackTrace();
-////		}
-////		return rss;
-////	}
-////
-////
-////
-////	public String getFilterPropertiesJson(String jsonStr) {
-////		String propertiesString = jsonStr.replaceAll("\"(\\w+)\"(\\s*:\\s*)", "$1$2"); // 去掉key的引号
-////		return propertiesString;
-////	}
-////	public <T>String getkeyvalCyphersql(T obj) {
-////		 Map<String, Object> map = new HashMap<String, Object>();
-////		 List<String> sqlList=new ArrayList<String>();
-////	        // 得到类对象
-////	        Class userCla = obj.getClass();
-////	        /* 得到类中的所有属性集合 */
-////	        Field[] fs = userCla.getDeclaredFields();
-////	        for (int i = 0; i < fs.length; i++) {
-////	            Field f = fs[i];
-////	            Class type = f.getType();
-////
-////	            f.setAccessible(true); // 设置些属性是可以访问的
-////	            Object val = new Object();
-////	            try {
-////	                val = f.get(obj);
-////	                if(val==null) {
-////	                	val="";
-////	                }
-////	                String sql="";
-////	                String key=f.getName();
-////	                System.out.println("key:"+key+"type:"+type);
-////	                if ( val instanceof   Integer ){
-////	                	// 得到此属性的值
-////		                map.put(key, val);// 设置键值
-////		                sql="n."+key+"="+val;
-////	    			}
-////	                else if ( val instanceof   String[] ){
-////	    				//如果为true则强转成String数组
-////	    				String [] arr = ( String[] ) val ;
-////	    				String v="";
-////	    				for ( int j = 0 ; j < arr.length ; j++ ){
-////	    					arr[j]="'"+ arr[j]+"'";
-////	    				}
-////	    				v=String.join(",", arr);
-////	    				sql="n."+key+"=["+val+"]";
-////	    			}
-////	                else if (val instanceof List){
-////	    				//如果为true则强转成String数组
-////	                	List<String> arr = ( ArrayList<String> ) val ;
-////	                	List<String> aa=new ArrayList<String>();
-////	    				String v="";
-////	    				for (String s : arr) {
-////	    					s="'"+ s+"'";
-////	    					aa.add(s);
-////						}
-////	    				v=String.join(",", aa);
-////	    				sql="n."+key+"=["+v+"]";
-////	    			}
-////	                else {
-////	                	// 得到此属性的值
-////		                map.put(key, val);// 设置键值
-////		                sql="n."+key+"='"+val+"'";
-////	                }
-////
-////	                sqlList.add(sql);
-////	            } catch (IllegalArgumentException e) {
-////	                e.printStackTrace();
-////	            } catch (IllegalAccessException e) {
-////	                e.printStackTrace();
-////	            }
-////	        }
-////	        String finasql=String.join(",",sqlList);
-////	        System.out.println("单个对象的所有键值==反射==" + map.toString());
-////		return finasql;
-////	}
-////	public <T> List<T> HashMapToObject(List<HashMap<String, Object>> maps, Class<T> type) {
-////		try {
-////			List<T> list = new ArrayList<T>();
-////			for (HashMap<String, Object> r : maps) {
-////				T t = type.newInstance();
-////				Iterator iter = r.entrySet().iterator();// 该方法获取列名.获取一系列字段名称.例如name,age...
-////				while (iter.hasNext()) {
-////					Entry entry = (Entry) iter.next();// 把hashmap转成Iterator再迭代到entry
-////					String key = entry.getKey().toString(); // 从iterator遍历获取key
-////					Object value = entry.getValue(); // 从hashmap遍历获取value
-////					if("serialVersionUID".toLowerCase().equals(key.toLowerCase()))continue;
-////					Field field = type.getDeclaredField(key);// 获取field对象
-////					if (field != null) {
-////						field.setAccessible(true);
-////						if (field.getType() == int.class || field.getType() == Integer.class) {
-////							if (value==null||StringUtil.isBlank(value.toString())) {
-////								field.set(t, 0);// 设置值
-////							} else {
-////								field.set(t, Integer.parseInt(value.toString()));// 设置值
-////							}
-////						}
-////						 else if (field.getType() == long.class||field.getType() == Long.class ) {
-////								if (value==null||StringUtil.isBlank(value.toString())) {
-////									field.set(t, 0);// 设置值
-////								} else {
-////									field.set(t, Long.parseLong(value.toString()));// 设置值
-////								}
-////
-////						}
-////						 else {
-////							field.set(t, value);// 设置值
-////						}
-////					}
-////
-////				}
-////				list.add(t);
-////			}
-////
-////			return list;
-////		} catch (Exception e) {
-////			throw new RuntimeException(e);
-////		}
-////	}
-////
-////	public <T> T HashMapToObjectItem(HashMap<String, Object> map, Class<T> type) {
-////		try {
-////			T t = type.newInstance();
-////			Iterator iter = map.entrySet().iterator();
-////			while (iter.hasNext()) {
-////				Entry entry = (Entry) iter.next();// 把hashmap转成Iterator再迭代到entry
-////				String key = entry.getKey().toString(); // 从iterator遍历获取key
-////				Object value = entry.getValue(); // 从hashmap遍历获取value
-////				if("serialVersionUID".toLowerCase().equals(key.toLowerCase()))continue;
-////				Field field = type.getDeclaredField(key);// 获取field对象
-////				if (field != null) {
-////					field.setAccessible(true);
-////					if (field.getType() == int.class || field.getType() == Integer.class) {
-////						if (value==null||StringUtil.isBlank(value.toString())) {
-////							field.set(t, 0);// 设置值
-////						} else {
-////							field.set(t, Integer.parseInt(value.toString()));// 设置值
-////						}
-////					}
-////					 else if (field.getType() == long.class||field.getType() == Long.class ) {
-////							if (value==null||StringUtil.isBlank(value.toString())) {
-////								field.set(t, 0);// 设置值
-////							} else {
-////								field.set(t, Long.parseLong(value.toString()));// 设置值
-////							}
-////
-////					}
-////					 else {
-////						field.set(t, value);// 设置值
-////					}
-////				}
-////
-////			}
-////
-////			return t;
-////		} catch (Exception e) {
-////			throw new RuntimeException(e);
-////		}
-////	}
-//}
+package com.zglc.kg.utils;
+
+import com.alibaba.fastjson.JSON;
+import org.neo4j.driver.*;
+import org.neo4j.driver.types.Node;
+import org.neo4j.driver.types.Path;
+import org.neo4j.driver.types.Relationship;
+import org.neo4j.driver.util.Pair;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.lang.reflect.Field;
+import java.util.*;
+import java.util.Map.Entry;
+
+@Component
+public class Neo4jUtil {
+	@Autowired
+	private Driver neo4jDriver;
+
+	public boolean isNeo4jOpen() {
+		try (Session session = neo4jDriver.session()) {
+			System.out.println("连接成功:" + session.isOpen());
+			return session.isOpen();
+		} catch (Exception e) {
+
+		}
+		return false;
+	}
+
+	public Result excuteCypherSql(String cypherSql) {
+        Result result = null;
+		try (Session session = neo4jDriver.session()) {
+			System.out.println(cypherSql);
+			result = session.run(cypherSql);
+			session.close();
+		} catch (Exception e) {
+			throw e;
+		}
+		return result;
+	}
+
+
+	public HashMap<String, Object> GetEntityMap(String cypherSql) {
+		HashMap<String, Object> rss = new HashMap<String, Object>();
+		try {
+			Result result = excuteCypherSql(cypherSql);
+			if (result.hasNext()) {
+				List<Record> records = result.list();
+				for (Record recordItem : records) {
+					for (Value value : recordItem.values()) {
+						if (value.type().name().equals("NODE")) {// 结果里面只要类型为节点的值
+							Node noe4jNode = value.asNode();
+							Map<String, Object> map = noe4jNode.asMap();
+							for (Entry<String, Object> entry : map.entrySet()) {
+								String key = entry.getKey();
+								if (rss.containsKey(key)) {
+									String oldValue = rss.get(key).toString();
+									String newValue = oldValue + "," + entry.getValue();
+									rss.replace(key, newValue);
+								} else {
+									rss.put(key, entry.getValue());
+								}
+							}
+
+						}
+					}
+				}
+			}
+
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return rss;
+	}
+
+	public List<HashMap<String, Object>> GetGraphNode(String cypherSql) {
+		List<HashMap<String, Object>> ents = new ArrayList<HashMap<String, Object>>();
+		try {
+			Result result = excuteCypherSql(cypherSql);
+			if (result.hasNext()) {
+				List<Record> records = result.list();
+				for (Record recordItem : records) {
+					List<Pair<String, Value>> f = recordItem.fields();
+					for (Pair<String, Value> pair : f) {
+						HashMap<String, Object> rss = new HashMap<String, Object>();
+						String typeName = pair.value().type().name();
+						if (typeName.equals("NODE")) {
+							Node noe4jNode = pair.value().asNode();
+							String uuid = String.valueOf(noe4jNode.id());
+							Map<String, Object> map = noe4jNode.asMap();
+							for (Entry<String, Object> entry : map.entrySet()) {
+								String key = entry.getKey();
+								rss.put(key, entry.getValue());
+							}
+							rss.put("uuid", uuid);
+							ents.add(rss);
+						}
+					}
+
+				}
+			}
+
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return ents;
+	}
+
+	public List<HashMap<String, Object>> GetGraphRelationShip(String cypherSql) {
+		List<HashMap<String, Object>> ents = new ArrayList<HashMap<String, Object>>();
+		try {
+			Result result = excuteCypherSql(cypherSql);
+			if (result.hasNext()) {
+				List<Record> records = result.list();
+				for (Record recordItem : records) {
+					List<Pair<String, Value>> f = recordItem.fields();
+					for (Pair<String, Value> pair : f) {
+						HashMap<String, Object> rss = new HashMap<String, Object>();
+						String typeName = pair.value().type().name();
+						if (typeName.equals("RELATIONSHIP")) {
+							Relationship rship = pair.value().asRelationship();
+							String uuid = String.valueOf(rship.id());
+							String sourceid = String.valueOf(rship.startNodeId());
+							String targetid = String.valueOf(rship.endNodeId());
+							Map<String, Object> map = rship.asMap();
+							for (Entry<String, Object> entry : map.entrySet()) {
+								String key = entry.getKey();
+								rss.put(key, entry.getValue());
+							}
+							rss.put("uuid", uuid);
+							rss.put("sourceid", sourceid);
+							rss.put("targetid", targetid);
+							ents.add(rss);
+						}
+					}
+				}
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return ents;
+	}
+	public List<HashMap<String, Object>> GetGraphItem(String cypherSql) {
+		List<HashMap<String, Object>> ents = new ArrayList<HashMap<String, Object>>();
+		List<String> nodeids = new ArrayList<String>();
+		List<String> shipids = new ArrayList<String>();
+		try {
+			Result result = excuteCypherSql(cypherSql);
+			if (result.hasNext()) {
+				List<Record> records = result.list();
+				for (Record recordItem : records) {
+					List<Pair<String, Value>> f = recordItem.fields();
+					HashMap<String, Object> rss = new HashMap<String, Object>();
+					for (Pair<String, Value> pair : f) {
+						String typeName = pair.value().type().name();
+						if (typeName.equals("NODE")) {
+							Node noe4jNode = pair.value().asNode();
+							String uuid = String.valueOf(noe4jNode.id());
+							if(!nodeids.contains(uuid)) {
+								Map<String, Object> map = noe4jNode.asMap();
+								for (Entry<String, Object> entry : map.entrySet()) {
+									String key = entry.getKey();
+									rss.put(key, entry.getValue());
+								}
+								rss.put("uuid", uuid);
+							}
+						}else if (typeName.equals("RELATIONSHIP")) {
+							Relationship rship = pair.value().asRelationship();
+							String uuid = String.valueOf(rship.id());
+							if (!shipids.contains(uuid)) {
+								String sourceid = String.valueOf(rship.startNodeId());
+								String targetid = String.valueOf(rship.endNodeId());
+								Map<String, Object> map = rship.asMap();
+								for (Entry<String, Object> entry : map.entrySet()) {
+									String key = entry.getKey();
+									rss.put(key, entry.getValue());
+								}
+								rss.put("uuid", uuid);
+								rss.put("sourceid", sourceid);
+								rss.put("targetid", targetid);
+							}
+						}else {
+							rss.put(pair.key(),pair.value().toString());
+						}
+					}
+					ents.add(rss);
+				}
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return ents;
+	}
+	/*
+	 * 获取值类型的结果,如count,uuid
+	 * @return 1 2 3 等数字类型
+	 */
+	public long GetGraphValue(String cypherSql) {
+		long val=0;
+		try {
+			Result cypherResult = excuteCypherSql(cypherSql);
+			if (cypherResult.hasNext()) {
+				Record record = cypherResult.next();
+				for (Value value : record.values()) {
+					val = value.asLong();
+				}
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return val;
+	}
+
+	public HashMap<String, Object> GetGraphNodeAndShip(String cypherSql) {
+		HashMap<String, Object> mo = new HashMap<String, Object>();
+		try {
+			Result result = excuteCypherSql(cypherSql);
+			if (result.hasNext()) {
+				List<Record> records = result.list();
+				List<HashMap<String, Object>> ents = new ArrayList<HashMap<String, Object>>();
+				List<HashMap<String, Object>> ships = new ArrayList<HashMap<String, Object>>();
+				List<String> uuids = new ArrayList<String>();
+				List<String> shipids = new ArrayList<String>();
+				for (Record recordItem : records) {
+					List<Pair<String, Value>> f = recordItem.fields();
+					for (Pair<String, Value> pair : f) {
+						HashMap<String, Object> rships = new HashMap<String, Object>();
+						HashMap<String, Object> rss = new HashMap<String, Object>();
+						String typeName = pair.value().type().name();
+						if (typeName.equals("NULL")) {
+							continue;
+						} else if (typeName.equals("NODE")) {
+							Node noe4jNode = pair.value().asNode();
+                            Map<String, Object> map = noe4jNode.asMap();
+                            String uuid = String.valueOf(noe4jNode.id());
+                            if (!uuids.contains(uuid)) {
+                                for (Entry<String, Object> entry : map.entrySet()) {
+                                    String key = entry.getKey();
+                                    rss.put(key, entry.getValue());
+                                }
+                                rss.put("uuid", uuid);
+                                uuids.add(uuid);
+                            }
+                            if (rss != null && !rss.isEmpty()) {
+                                ents.add(rss);
+                            }
+						} else if (typeName.equals("RELATIONSHIP")) {
+							Relationship rship = pair.value().asRelationship();
+                            String uuid = String.valueOf(rship.id());
+                            if (!shipids.contains(uuid)) {
+                                String sourceid = String.valueOf(rship.startNodeId());
+                                String targetid = String.valueOf(rship.endNodeId());
+                                Map<String, Object> map = rship.asMap();
+                                for (Entry<String, Object> entry : map.entrySet()) {
+                                    String key = entry.getKey();
+                                    rships.put(key, entry.getValue());
+                                }
+                                rships.put("uuid", uuid);
+                                rships.put("sourceid", sourceid);
+                                rships.put("targetid", targetid);
+								shipids.add(uuid);
+                                if (rships != null && !rships.isEmpty()) {
+                                    ships.add(rships);
+                                }
+                            }
+
+						} else if (typeName.equals("PATH")) {
+							Path path = pair.value().asPath();
+							Map<String, Object> startNodemap = path.start().asMap();
+							String startNodeuuid = String.valueOf(path.start().id());
+							if (!uuids.contains(startNodeuuid)) {
+								rss=new HashMap<String, Object>();
+								for (Entry<String, Object> entry : startNodemap.entrySet()) {
+									String key = entry.getKey();
+									rss.put(key, entry.getValue());
+								}
+								rss.put("uuid", startNodeuuid);
+								uuids.add(startNodeuuid);
+								if (rss != null && !rss.isEmpty()) {
+									ents.add(rss);
+								}
+							}
+
+							Map<String, Object> endNodemap = path.end().asMap();
+							String endNodeuuid = String.valueOf(path.end().id());
+							if (!uuids.contains(endNodeuuid)) {
+								rss=new HashMap<String, Object>();
+								for (Entry<String, Object> entry : endNodemap.entrySet()) {
+									String key = entry.getKey();
+									rss.put(key, entry.getValue());
+								}
+								rss.put("uuid", endNodeuuid);
+								uuids.add(endNodeuuid);
+								if (rss != null && !rss.isEmpty()) {
+									ents.add(rss);
+								}
+							}
+							Iterator<Node> allNodes = path.nodes().iterator();
+							while (allNodes.hasNext()) {
+								Node next = allNodes.next();
+								String uuid = String.valueOf(next.id());
+								if (!uuids.contains(uuid)) {
+									rss=new HashMap<String, Object>();
+									Map<String, Object> map = next.asMap();
+									for (Entry<String, Object> entry : map.entrySet()) {
+										String key = entry.getKey();
+										rss.put(key, entry.getValue());
+									}
+									rss.put("uuid", uuid);
+									uuids.add(uuid);
+									if (rss != null && !rss.isEmpty()) {
+										ents.add(rss);
+									}
+								}
+							}
+							Iterator<Relationship> reships = path.relationships().iterator();
+							while (reships.hasNext()) {
+								Relationship next = reships.next();
+								String uuid = String.valueOf(next.id());
+								if (!shipids.contains(uuid)) {
+									rships=new HashMap<String, Object>();
+									String sourceid = String.valueOf(next.startNodeId());
+									String targetid = String.valueOf(next.endNodeId());
+									Map<String, Object> map = next.asMap();
+									for (Entry<String, Object> entry : map.entrySet()) {
+										String key = entry.getKey();
+										rships.put(key, entry.getValue());
+									}
+									rships.put("uuid", uuid);
+									rships.put("sourceid", sourceid);
+									rships.put("targetid", targetid);
+									shipids.add(uuid);
+									if (rships != null && !rships.isEmpty()) {
+										ships.add(rships);
+									}
+								}
+							}
+						} else if (typeName.contains("LIST")) {
+							Iterable<Value> val=pair.value().values();
+                            Value next = val.iterator().next();
+                            String type=next.type().name();
+                            if (type.equals("RELATIONSHIP")) {
+                                Relationship rship = next.asRelationship();
+                                String uuid = String.valueOf(rship.id());
+                                if (!shipids.contains(uuid)) {
+                                    String sourceid = String.valueOf(rship.startNodeId());
+                                    String targetid = String.valueOf(rship.endNodeId());
+                                    Map<String, Object> map = rship.asMap();
+                                    for (Entry<String, Object> entry : map.entrySet()) {
+                                        String key = entry.getKey();
+                                        rships.put(key, entry.getValue());
+                                    }
+                                    rships.put("uuid", uuid);
+                                    rships.put("sourceid", sourceid);
+                                    rships.put("targetid", targetid);
+									shipids.add(uuid);
+                                    if (rships != null && !rships.isEmpty()) {
+                                        ships.add(rships);
+                                    }
+                                }
+                            }
+						} else if (typeName.contains("MAP")) {
+							rss.put(pair.key(), pair.value().asMap());
+						} else {
+							rss.put(pair.key(), pair.value().toString());
+                            if (rss != null && !rss.isEmpty()) {
+                                ents.add(rss);
+                            }
+						}
+
+					}
+				}
+				mo.put("node", ents);
+				mo.put("relationship", ships);
+			}
+
+		} catch (Exception e) {
+			e.printStackTrace();
+			throw e;
+		}
+		return mo;
+	}
+	/**
+	 * 匹配所有类型的节点,可以是节点,关系,数值,路径
+	 * @param cypherSql
+	 * @return
+	 */
+	public List<HashMap<String, Object>> GetEntityList(String cypherSql) {
+		List<HashMap<String, Object>> ents = new ArrayList<HashMap<String, Object>>();
+		try {
+			Result result = excuteCypherSql(cypherSql);
+			if (result.hasNext()) {
+				List<Record> records = result.list();
+				for (Record recordItem : records) {
+					HashMap<String, Object> rss = new HashMap<String, Object>();
+					List<Pair<String, Value>> f = recordItem.fields();
+					for (Pair<String, Value> pair : f) {
+						String typeName = pair.value().type().name();
+						if (typeName.equals("NULL")) {
+							continue;
+						} else if (typeName.equals("NODE")) {
+							Node noe4jNode = pair.value().asNode();
+							Map<String, Object> map = noe4jNode.asMap();
+							for (Entry<String, Object> entry : map.entrySet()) {
+								String key = entry.getKey();
+								rss.put(key, entry.getValue());
+							}
+						} else if (typeName.equals("RELATIONSHIP")) {
+							Relationship rship = pair.value().asRelationship();
+							Map<String, Object> map = rship.asMap();
+							for (Entry<String, Object> entry : map.entrySet()) {
+								String key = entry.getKey();
+								rss.put(key, entry.getValue());
+							}
+						} else if (typeName.equals("PATH")) {
+
+						} else if (typeName.contains("LIST")) {
+							rss.put(pair.key(), pair.value().asList());
+						} else if (typeName.contains("MAP")) {
+							rss.put(pair.key(), pair.value().asMap());
+						} else {
+							rss.put(pair.key(), pair.value().toString());
+						}
+					}
+					ents.add(rss);
+				}
+			}
+
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return ents;
+	}
+
+	public <T> List<T> GetEntityItemList(String cypherSql, Class<T> type) {
+		List<HashMap<String, Object>> ents=GetGraphNode(cypherSql);
+		List<T> model = HashMapToObject(ents, type);
+		return model;
+	}
+
+	public <T> T GetEntityItem(String cypherSql, Class<T> type) {
+		HashMap<String, Object> rss = new HashMap<String, Object>();
+		try {
+			Result result = excuteCypherSql(cypherSql);
+			if (result.hasNext()) {
+				Record record = result.next();
+				for (Value value : record.values()) {
+					if (value.type().name().equals("NODE")) {// 结果里面只要类型为节点的值
+						Node noe4jNode = value.asNode();
+						Map<String, Object> map = noe4jNode.asMap();
+						for (Entry<String, Object> entry : map.entrySet()) {
+							String key = entry.getKey();
+							if (rss.containsKey(key)) {
+								String oldValue = rss.get(key).toString();
+								String newValue = oldValue + "," + entry.getValue();
+								rss.replace(key, newValue);
+							} else {
+								rss.put(key, entry.getValue());
+							}
+						}
+
+					}
+				}
+			}
+
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		T model = HashMapToObjectItem(rss, type);
+		return model;
+	}
+
+	public HashMap<String, Object> GetEntity(String cypherSql) {
+		HashMap<String, Object> rss = new HashMap<String, Object>();
+		try {
+			Result result = excuteCypherSql(cypherSql);
+			if (result.hasNext()) {
+				Record record = result.next();
+				for (Value value : record.values()) {
+					String t = value.type().name();
+					if (value.type().name().equals("NODE")) {// 结果里面只要类型为节点的值
+						Node noe4jNode = value.asNode();
+						Map<String, Object> map = noe4jNode.asMap();
+						for (Entry<String, Object> entry : map.entrySet()) {
+							String key = entry.getKey();
+							if (rss.containsKey(key)) {
+								String oldValue = rss.get(key).toString();
+								String newValue = oldValue + "," + entry.getValue();
+								rss.replace(key, newValue);
+							} else {
+								rss.put(key, entry.getValue());
+							}
+						}
+
+					}
+				}
+			}
+
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return rss;
+	}
+
+	public Integer executeScalar(String cypherSql) {
+		Integer count = 0;
+		try {
+			Result result = excuteCypherSql(cypherSql);
+			if (result.hasNext()) {
+				Record record = result.next();
+				for (Value value : record.values()) {
+					String t = value.type().name();
+					if (t.equals("INTEGER")) {
+						count = Integer.valueOf(value.toString());
+						break;
+					}
+				}
+			}
+
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return count;
+	}
+
+	public HashMap<String, Object> GetRelevantEntity(String cypherSql) {
+		HashMap<String, Object> rss = new HashMap<String, Object>();
+		try {
+			Result resultNode = excuteCypherSql(cypherSql);
+			if (resultNode.hasNext()) {
+				List<Record> records = resultNode.list();
+				for (Record recordItem : records) {
+					Map<String, Object> r = recordItem.asMap();
+					System.out.println(JSON.toJSONString(r));
+					String key = r.get("key").toString();
+					if (rss.containsKey(key)) {
+						String oldValue = rss.get(key).toString();
+						String newValue = oldValue + "," + r.get("value");
+						rss.replace(key, newValue);
+					} else {
+						rss.put(key, r.get("value"));
+					}
+				}
+			}
+
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return rss;
+	}
+
+
+
+	public String getFilterPropertiesJson(String jsonStr) {
+		String propertiesString = jsonStr.replaceAll("\"(\\w+)\"(\\s*:\\s*)", "$1$2"); // 去掉key的引号
+		return propertiesString;
+	}
+	public <T>String getkeyvalCyphersql(T obj) {
+		 Map<String, Object> map = new HashMap<String, Object>();
+		 List<String> sqlList=new ArrayList<String>();
+	        // 得到类对象
+	        Class userCla = obj.getClass();
+	        /* 得到类中的所有属性集合 */
+	        Field[] fs = userCla.getDeclaredFields();
+	        for (int i = 0; i < fs.length; i++) {
+	            Field f = fs[i];
+	            Class type = f.getType();
+
+	            f.setAccessible(true); // 设置些属性是可以访问的
+	            Object val = new Object();
+	            try {
+	                val = f.get(obj);
+	                if(val==null) {
+	                	val="";
+	                }
+	                String sql="";
+	                String key=f.getName();
+	                System.out.println("key:"+key+"type:"+type);
+	                if ( val instanceof   Integer ){
+	                	// 得到此属性的值
+		                map.put(key, val);// 设置键值
+		                sql="n."+key+"="+val;
+	    			}
+	                else if ( val instanceof   String[] ){
+	    				//如果为true则强转成String数组
+	    				String [] arr = ( String[] ) val ;
+	    				String v="";
+	    				for ( int j = 0 ; j < arr.length ; j++ ){
+	    					arr[j]="'"+ arr[j]+"'";
+	    				}
+	    				v=String.join(",", arr);
+	    				sql="n."+key+"=["+val+"]";
+	    			}
+	                else if (val instanceof List){
+	    				//如果为true则强转成String数组
+	                	List<String> arr = ( ArrayList<String> ) val ;
+	                	List<String> aa=new ArrayList<String>();
+	    				String v="";
+	    				for (String s : arr) {
+	    					s="'"+ s+"'";
+	    					aa.add(s);
+						}
+	    				v=String.join(",", aa);
+	    				sql="n."+key+"=["+v+"]";
+	    			}
+	                else {
+	                	// 得到此属性的值
+		                map.put(key, val);// 设置键值
+		                sql="n."+key+"='"+val+"'";
+	                }
+
+	                sqlList.add(sql);
+	            } catch (IllegalArgumentException e) {
+	                e.printStackTrace();
+	            } catch (IllegalAccessException e) {
+	                e.printStackTrace();
+	            }
+	        }
+	        String finasql=String.join(",",sqlList);
+	        System.out.println("单个对象的所有键值==反射==" + map.toString());
+		return finasql;
+	}
+	public <T> List<T> HashMapToObject(List<HashMap<String, Object>> maps, Class<T> type) {
+		try {
+			List<T> list = new ArrayList<T>();
+			for (HashMap<String, Object> r : maps) {
+				T t = type.newInstance();
+				Iterator iter = r.entrySet().iterator();// 该方法获取列名.获取一系列字段名称.例如name,age...
+				while (iter.hasNext()) {
+					Entry entry = (Entry) iter.next();// 把hashmap转成Iterator再迭代到entry
+					String key = entry.getKey().toString(); // 从iterator遍历获取key
+					Object value = entry.getValue(); // 从hashmap遍历获取value
+					if("serialVersionUID".toLowerCase().equals(key.toLowerCase()))continue;
+					Field field = type.getDeclaredField(key);// 获取field对象
+					if (field != null) {
+						field.setAccessible(true);
+						if (field.getType() == int.class || field.getType() == Integer.class) {
+							if (value==null||StringUtil.isBlank(value.toString())) {
+								field.set(t, 0);// 设置值
+							} else {
+								field.set(t, Integer.parseInt(value.toString()));// 设置值
+							}
+						}
+						 else if (field.getType() == long.class||field.getType() == Long.class ) {
+								if (value==null||StringUtil.isBlank(value.toString())) {
+									field.set(t, 0);// 设置值
+								} else {
+									field.set(t, Long.parseLong(value.toString()));// 设置值
+								}
+
+						}
+						 else {
+							field.set(t, value);// 设置值
+						}
+					}
+
+				}
+				list.add(t);
+			}
+
+			return list;
+		} catch (Exception e) {
+			throw new RuntimeException(e);
+		}
+	}
+
+	public <T> T HashMapToObjectItem(HashMap<String, Object> map, Class<T> type) {
+		try {
+			T t = type.newInstance();
+			Iterator iter = map.entrySet().iterator();
+			while (iter.hasNext()) {
+				Entry entry = (Entry) iter.next();// 把hashmap转成Iterator再迭代到entry
+				String key = entry.getKey().toString(); // 从iterator遍历获取key
+				Object value = entry.getValue(); // 从hashmap遍历获取value
+				if("serialVersionUID".toLowerCase().equals(key.toLowerCase()))continue;
+				Field field = type.getDeclaredField(key);// 获取field对象
+				if (field != null) {
+					field.setAccessible(true);
+					if (field.getType() == int.class || field.getType() == Integer.class) {
+						if (value==null||StringUtil.isBlank(value.toString())) {
+							field.set(t, 0);// 设置值
+						} else {
+							field.set(t, Integer.parseInt(value.toString()));// 设置值
+						}
+					}
+					 else if (field.getType() == long.class||field.getType() == Long.class ) {
+							if (value==null||StringUtil.isBlank(value.toString())) {
+								field.set(t, 0);// 设置值
+							} else {
+								field.set(t, Long.parseLong(value.toString()));// 设置值
+							}
+
+					}
+					 else {
+						field.set(t, value);// 设置值
+					}
+				}
+
+			}
+
+			return t;
+		} catch (Exception e) {
+			throw new RuntimeException(e);
+		}
+	}
+}

+ 76 - 0
src/main/java/com/zglc/kg/utils/StringUtil.java

@@ -0,0 +1,76 @@
+package com.zglc.kg.utils;
+
+import org.apache.commons.lang3.ObjectUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class StringUtil {
+	 /*
+	 * 是否为空字符串
+     * @param str
+     * @return
+     */
+    public static boolean isBlank(String str){
+        int strLen;
+        if (str == null || (strLen = str.length()) == 0) {
+            return true;
+        }
+        for (int i = 0; i < strLen; i++) {
+            if (Character.isWhitespace(str.charAt(i)) == false) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    public static boolean isNotBlank(String str){
+        return !isBlank(str);
+    }
+    /**
+     * 连接方法 类似于javascript
+     * @param join 连接字符串
+     * @param strAry 需要连接的集合
+     * @return
+     */
+    public static String join(String join,String[] strAry){
+        StringBuffer sb=new StringBuffer();
+        for(int i=0,len =strAry.length;i<len;i++){
+            if(i==(len-1)){
+                sb.append(strAry[i]);
+            }else{
+                sb.append(strAry[i]).append(join);
+            }
+        }
+        return sb.toString();
+    }
+
+    /**
+     * 将结果集中的一列用指定字符连接起来
+     * @param join 指定字符
+     * @param cols 结果集
+     * @param colName 列名
+     * @return
+     */
+    public static String join(String join,List<Map> cols,String colName){
+        List<String> aColCons = new ArrayList<String>();
+        for (Map map:
+             cols) {
+            aColCons.add(ObjectUtils.toString(map.get(colName)));
+        }
+        return join(join,aColCons);
+    }
+
+    public static String join(String join,List<String> listStr){
+        StringBuffer sb=new StringBuffer();
+        for(int i=0,len =listStr.size();i<len;i++){
+            if(i==(len-1)){
+                sb.append(listStr.get(i));
+            }else{
+                sb.append(listStr.get(i)).append(join);
+            }
+        }
+        return sb.toString();
+    }
+}

+ 5 - 5
src/main/resources/application-dev.yml

@@ -3,11 +3,11 @@ spring:
   main:
     allow-bean-definition-overriding: true
 
-  data:
-    neo4j:
-      uri: bolt://localhost:7687
-      username: neo4j
-      password: neo4j
+#  data:
+#    neo4j:
+#      uri: bolt://localhost:7687
+#      username: neo4j
+#      password: neo4j
 
   datasource:
 #    url: jdbc:mysql://180.76.52.24:3306/trouble_research?userUnicode=ture&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false#

+ 5 - 5
target/classes/application-dev.yml

@@ -3,11 +3,11 @@ spring:
   main:
     allow-bean-definition-overriding: true
 
-  data:
-    neo4j:
-      uri: bolt://localhost:7687
-      username: neo4j
-      password: neo4j
+#  data:
+#    neo4j:
+#      uri: bolt://localhost:7687
+#      username: neo4j
+#      password: neo4j
 
   datasource:
 #    url: jdbc:mysql://180.76.52.24:3306/trouble_research?userUnicode=ture&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false#

BIN
target/classes/com/zglc/kg/KnowledgeGraphApplication.class


BIN
target/classes/com/zglc/kg/controller/MovieController.class


BIN
target/classes/com/zglc/kg/dao/BaseRelationDao.class


BIN
target/classes/com/zglc/kg/entity/BaseRelationEntity.class


BIN
target/classes/com/zglc/kg/entity/MovieEntity.class


BIN
target/classes/com/zglc/kg/entity/PersonEntity.class


BIN
target/classes/com/zglc/kg/entity/RelationShipEntity$RelationShipEntityBuilder.class


BIN
target/classes/com/zglc/kg/entity/RelationShipEntity.class


BIN
target/classes/com/zglc/kg/service/MovieService.class


BIN
target/classes/com/zglc/kg/utils/Neo4jConfig.class


BIN
target/classes/com/zglc/kg/utils/Neo4jUtil.class


BIN
target/classes/com/zglc/kg/utils/StringUtil.class