|
@@ -33,19 +33,32 @@ public class CaseRelationUpdateImpl implements RelationService {
|
|
|
if (batch_list.isEmpty()) return null;
|
|
|
long start = System.currentTimeMillis();
|
|
|
Session session = driver.session();
|
|
|
+// final String cql = "\nWITH {batch_list} AS batch_list \n" +
|
|
|
+// "UNWIND batch_list AS row \n" +
|
|
|
+// " MERGE(s:CASE{case_id:row.start_id})\n" +
|
|
|
+// " SET s.case_id = row.start_id\n" +
|
|
|
+// " MERGE(m:CASE{case_id:row.end_id})\n" +
|
|
|
+// " SET m.case_id = row.end_id\n" +
|
|
|
+// " MERGE(s)-[r:RELATION]->(m)\n" +
|
|
|
+// " SET r.connect_type=row.connect_type\n" +
|
|
|
+// " WITH s,m\n" +
|
|
|
+// " CALL apoc.path.subgraphNodes(s, {maxLevel:-1}) YIELD node\n" +
|
|
|
+// " WITH node,s\n" +
|
|
|
+// " SET node.component_id = -id(s)\n" +
|
|
|
+// " SET node:" + CompanyUtils.getIncrPersonLabelV2("新增");
|
|
|
+
|
|
|
final String cql = "\nWITH {batch_list} AS batch_list \n" +
|
|
|
"UNWIND batch_list AS row \n" +
|
|
|
- " MERGE(s:CASE{case_id:row.start_id})\n" +
|
|
|
- " SET s.case_id = row.start_id\n" +
|
|
|
- " MERGE(m:CASE{case_id:row.end_id})\n" +
|
|
|
- " SET m.case_id = row.end_id\n" +
|
|
|
- " MERGE(s)-[r:RELATION]->(m)\n" +
|
|
|
- " SET r.connect_type=row.connect_type\n" +
|
|
|
- " WITH s,m\n" +
|
|
|
- " CALL apoc.path.subgraphNodes(s, {maxLevel:-1}) YIELD node\n" +
|
|
|
- " WITH node,s\n" +
|
|
|
- " SET node.component_id = -id(s)\n" +
|
|
|
- " SET node:" + CompanyUtils.getIncrPersonLabelV2("新增");
|
|
|
+ "MERGE(s:CASE{case_id:row.start_id})\n" +
|
|
|
+ "MERGE(m:CASE{case_id:row.end_id})\n" +
|
|
|
+ "MERGE(s)-[r:RELATION]->(m)\n" +
|
|
|
+ "SET r.connect_type=row.connect_type\n" +
|
|
|
+ "WITH s,m\n" +
|
|
|
+ "CALL apoc.path.subgraphNodes(s, {maxLevel:-1}) YIELD node\n" +
|
|
|
+ "WITH ID(s) as id,apoc.coll.max(collect(node.component_id) + collect(-ID(s))) as update_id,collect(node) as nodes\n" +
|
|
|
+ "UNWIND nodes AS n\n" +
|
|
|
+ "SET n.component_id = update_id\n" +
|
|
|
+ "SET n:" + CompanyUtils.getIncrPersonLabelV2("新增");
|
|
|
log.info("consumer size: {}, cql:{}", batch_list.size(), cql);
|
|
|
String data = CompanyUtils.writeNeo4j(session, cql, new HashMap<String, Object>() {{
|
|
|
put("batch_list", batch_list);
|