|
@@ -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";
|