xufei 3 năm trước cách đây
mục cha
commit
460d70aa5f

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

@@ -40,13 +40,11 @@ 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" +
-                        "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" +
+                        "WITH p.person_id as person_id, p as first_node, apoc.coll.sort(collect(distinct ID(q))) as all_ids\n" +
+                        "UNWIND all_ids as all_id\n" +
+                        "MATCH(m:" + CompanyEnum.Lable.PERSON.code + ")-[r]-(x:" + CompanyEnum.Lable.COMPANY.code + ")\n" +
+                        "WHERE ID(m) in all_id\n" +
+                        "WITH person_id, first_node, m as other_node, x, r\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" +