瀏覽代碼

合并逻辑更新

xufei 3 年之前
父節點
當前提交
b6bfc79f1a

+ 5 - 3
src/main/java/com/winhc/service/impl/PersonMergeV2Impl.java

@@ -40,12 +40,14 @@ public class PersonMergeV2Impl implements RelationService {
                         "UNWIND batch_list AS row \n" +
                         "MATCH (p:" + CompanyEnum.Lable.PERSON.code + "{person_id: row.person_id})-[*0..3]-(q:" + CompanyEnum.Lable.PERSON.code + "{name:row.name})\n" +
                         "WHERE ID(p) <> ID(q)\n" +
-                        //"SET p:" + CompanyUtils.getIncrPersonLabelV2("新增", CompanyEnum.SPLIT_HOUR) + "\n" +
-                        "WITH p as first_node, collect(distinct q) as other_nodes\n" +
+                        "WITH apoc.coll.sort(collect(distinct ID(p)) + collect(distinct ID(q))) as all_ids\n" +
+                        "MATCH(m:" + CompanyEnum.Lable.PERSON.code + ")\n" +
+                        "WHERE ID(m) in all_ids\n" +
+                        "WITH collect(m)[0] as first_node,tail(collect(m)) as other_nodes\n" +
                         "UNWIND other_nodes as other_node\n" +
                         "MATCH (other_node)-[r]-(x:" + CompanyEnum.Lable.COMPANY.code + ")\n" +
                         "WITH first_node,r,other_node,x\n" +
-                        "CALL apoc.merge.relationship(first_node, TYPE(r), properties(r),{}, x,{}) YIELD rel\n" +
+                        "CALL apoc.merge.relationship.eager(first_node, TYPE(r), properties(r),{}, x,{}) YIELD rel\n" +
                         "SET first_node:" + CompanyUtils.getIncrPersonLabelV2("新增", CompanyEnum.SPLIT_HOUR) + "\n" +
                         "SET other_node:" + CompanyUtils.getIncrPersonLabelV2("删除", CompanyEnum.SPLIT_HOUR) + "\n" +
                         "DELETE r";

+ 2 - 1
src/main/resources/application-dev.properties

@@ -9,7 +9,8 @@
 spring.data.neo4j.username.v1=neo4j
 spring.data.neo4j.password.v1=neo4j168
 #spring.data.neo4j.uri.v1=bolt://139.196.165.100:7687
-spring.data.neo4j.uri.v1=bolt://192.168.2.57:7687
+#spring.data.neo4j.uri.v1=bolt://192.168.2.57:7687
+spring.data.neo4j.uri.v1=bolt://127.0.0.1:7687
 
 #Neo4j配置(第二台机器)
 spring.data.neo4j.username.v2=neo4j