Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	src/main/java/com/supervision/neo4j/service/Neo4jService.java
topo_dev
xueqingkun 5 months ago
commit bb50ab215c

@ -9,21 +9,25 @@
# 发布时间 2024-11-06
# 变更
- 优化了案件指标(原子指标)结果详情笔录、证据的展示,统一为右侧抽屉弹框展示详情
- 优化了提示词配置的交互,支持结构化提示词的创建与修改,支持提示词的调试
- 优化了原子指标-指标算法交互,数据库、图谱推理指标保留配置语句方式,结构化提取可选择对应提示词
- 优化案件分析得分规则指标配置,支持部分证据的属性条件判断
- 优化了案件得分详情添加证据指引功能,提示当前案件待补充证据类型
- 修复笔录提取进度反复横跳的问题
- 原子指标添加结构化推理功能
- 变更指标配置规则(得分计算规则)
- 案件指标(原子指标)结果添加证据详情
- 案件得分详情添加证据指引功能
- 修复了其他已发现的交互问题
# 新特性
- 新增提示词配置功能(大模型提取属性、知识图谱展示、新增提示词、列表展示提示词)
- 新增OCR识别证据文本功能
- 新增证据文件关键信息提取功能
- 新增提示词配置、调试功能
- 新增案件证据目录分类功能
# 更新步骤
1. 加载镜像如果docker可以访问外网直接下载否则需要先上传到服务器
- docker load -i xxl-job-admin:2.4.1.tar.gz
2. 修改.env中的xxl-job中对应的配置
- XXl_JOB_PASSWORD=sT7SSTiX8&&s
- XXl_JOB_PASSWORD=sT7SSTiX8s
- XXL_JOB_PORT_HTTP=8081
- SPRING_DATASOURCE_URL=jdbc:mysql://fu-hsi-mysql:3306/xxl-job?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
3. 替换docker-compose-base.yml、docker-compose.yml配置文件

@ -1,5 +1,3 @@
## 🎬 快速开始
### 📝 前提条件
@ -10,17 +8,23 @@
- Docker >= 24.0.6 & Docker Compose >= v2.27.0
### 安装包结构说明
| 文件/文件夹 | 说明 |
| - |---------------|
| fu-hsi-nginx/ | 用于存放nginx静态文件 |
| fu-hsi-web/ | 用户存放后端服务程序 |
| .env | 应用的环境配置 |
| docker-compose.yml | docker-compose 配置文件 |
| 文件/文件夹 | 说明 |
|-------------------------|---------------------|
| fu-hsi-nginx/ | 用于存放nginx静态文件 |
| fu-hsi-web/ | 用户存放后端服务程序 |
| logs/ | 日志目录fu-hsi-web |
| minio/ | minio数据 |
| mysql/ | mysql数据 |
| neo4j/ | neo4j数据 |
| .env | 应用的环境配置 |
| docker-compose.yml | docker-compose 配置文件 |
| docker-compose-base.yml | docker-compose 配置文件 |
### 🚀 启动服务
1. 加载镜像
```shell
# 进入install-all文件目录
cd ./install-all
@ -31,6 +35,7 @@ docker load -i fu-shi-install.1.0.0.tar.gz
```
2. 修改配置文件
```shell
# 编辑配置文件
$ vi .env
@ -42,23 +47,25 @@ $ vi .env
```
3. 进入install-all目录,执行命令
```shell
docker-compose up -d
```
等待程序启动完成即可,如果没有启动成功,可重试上面的命令。
启动完成后会打印出下面的日志信息:
[+] Running 8/8
✔ Network docker-compose_fu-hsi Created 0.2s
✔ Container fu-hsi-neo4j Started 0.1s
✔ Container fu-hsi-ocr Started 0.1s
✔ Container fu-hsi-mysql Started 0.1s
✔ Container fu-hsi-minio Started 0.1s
✔ Container fu-hsi-web-docker-compose Started 0.0s
✔ Container fu-hsi-xxl-job-admin Started 0.0s
✔ Container fu-hsi-nginx-docker-compose Started
✔ Network docker-compose_fu-hsi Created 0.2s
✔ Container fu-hsi-neo4j Started 0.1s
✔ Container fu-hsi-ocr Started 0.1s
✔ Container fu-hsi-mysql Started 0.1s
✔ Container fu-hsi-minio Started 0.1s
✔ Container fu-hsi-web-docker-compose Started 0.0s
✔ Container fu-hsi-xxl-job-admin Started 0.0s
✔ Container fu-hsi-nginx-docker-compose Started
4. 查看启动情况
```shell
$ docker-compose ps
@ -74,5 +81,17 @@ fu-hsi-web-docker-compose fu-hsi-web:1.0.0
fu-hsi-xxl-job-admin xuxueli/xxl-job-admin:2.4.1 "sh -c 'java -jar $J…" xxl-job-admin 56 seconds ago Up 54 seconds 0.0.0.0:8081->8080/tcp, :::8081->8080/tcp
```
### xxl-job任务配置
1. 访问地址http://ip:8081/xxl-job-admin
2. 登录 用户名admin 密码:见.env配置文件
3. 执行器管理-新增
![img.png](asset/executorAdd.png)
4. 任务管理-新增
![img.png](asset/taskAdd.png)
5. 任务管理列表-操作-执行一次-保存
6. 调度日志查看执行结果
![img.png](asset/dispatchList.png)
## 🚀 访问服务
访问地址http://ip:9978/case-management 用户名:admin 密码:llm@sst$09637674#w

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

@ -23,7 +23,7 @@ public class Neo4jConfig {
// 这里可以添加额外的配置,比如加密、连接池设置等
Config config = Config.builder()
// 示例:关闭加密(注意:在生产环境中应该启用加密)
.withoutEncryption()
// .withoutEncryption()
// 你可以在这里添加更多的配置选项
.build();

@ -5,8 +5,7 @@ import com.supervision.common.domain.R;
import com.supervision.neo4j.domain.CaseNode;
import com.supervision.neo4j.domain.Rel;
import com.supervision.neo4j.service.Neo4jService;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
import com.supervision.police.vo.GraphReqVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -85,9 +84,14 @@ public class Neo4jController {
/*************************************************************************************/
@GetMapping("/getNode")
public R<?> getNode(@RequestParam String picType, @RequestParam String caseId) {
return neo4jService.getNode(picType, caseId);
@PostMapping("/getCaseGraph")
public R<?> getCaseGraph(@RequestBody GraphReqVO graphReqVO) {
return neo4jService.getCaseGraph(graphReqVO);
}
@GetMapping("/getNodeAndRelationListByCaseId")
public R<?> getNodeAndRelationListByCaseId(@RequestParam String picType, @RequestParam String caseId) {
return neo4jService.getNodeAndRelationListByCaseId(picType, caseId);
}
// @GetMapping("/test")

@ -4,6 +4,7 @@ import com.supervision.common.domain.R;
import com.supervision.neo4j.domain.CaseNode;
import com.supervision.neo4j.domain.Rel;
import org.neo4j.driver.Record;
import com.supervision.police.vo.GraphReqVO;
import java.util.List;
import java.util.Map;
@ -35,7 +36,22 @@ public interface Neo4jService {
Rel saveRelation(Rel rel);
R<?> getNode(String picType, String caseId);
/**
*
*
* @param graphReqVO
* @return
*/
R<?> getCaseGraph(GraphReqVO graphReqVO);
/**
*
*
* @param picType
* @param caseId id
* @return
*/
R<?> getNodeAndRelationListByCaseId(String picType, String caseId);
// R<?> test();
@ -43,6 +59,7 @@ public interface Neo4jService {
void createAbstractGraph(String path, String sheetName);
void mockTestGraph(String path, String sheetName, String recordId, String recordSplitId, String caseId);
void mockTestGraph(String path, String sheetName, String recordId, String recordSplitId,String caseId);
List<Record> executeCypher(String cypher, Map<String, Object> parameters);

@ -4,16 +4,17 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import com.supervision.common.domain.R;
import com.supervision.common.utils.StringUtils;
import com.supervision.neo4j.domain.CaseNode;
import com.supervision.neo4j.domain.Rel;
import com.supervision.neo4j.dto.WebRelDTO;
import com.supervision.neo4j.service.Neo4jService;
import com.supervision.neo4j.utils.Neo4jUtils;
import com.supervision.police.vo.GraphReqVO;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.neo4j.driver.*;
import org.apache.commons.lang3.StringUtils;
import org.neo4j.driver.Record;
import org.neo4j.driver.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -50,7 +51,7 @@ public class Neo4jServiceImpl implements Neo4jService {
CaseNode res = null;
try {
Session session = driver.session();
StringBuffer cql = new StringBuffer();
StringBuilder cql = new StringBuilder();
Map<String, Object> params = new HashMap<>();
cql.append("CREATE (n:").append(caseNode.getNodeType()).append("{name:$name");
params.put("name", caseNode.getName());
@ -74,7 +75,7 @@ public class Neo4jServiceImpl implements Neo4jService {
Result run = session.run(cql.toString(), params);
res = Neo4jUtils.getOneNode(run);
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage(), e);
}
return res;
}
@ -88,13 +89,12 @@ public class Neo4jServiceImpl implements Neo4jService {
public void delNode(Long id) {
try {
Session session = driver.session();
StringBuffer cql = new StringBuffer();
StringBuilder cql = new StringBuilder();
cql.append("MATCH (n) where id(n) = ").append(id).append(" DELETE n");
log.info(cql.toString());
Result run = session.run(cql.toString());
while (run.hasNext()) {
Record next = run.next();
// log.info(next.toString());
run.next();
}
} catch (Exception e) {
log.error(e.getMessage(), e);
@ -105,13 +105,12 @@ public class Neo4jServiceImpl implements Neo4jService {
public void deleteNoRelationNode(Long id) {
try {
Session session = driver.session();
StringBuffer cql = new StringBuffer();
cql.append("MATCH (n) WHERE n.id = " ).append(id).append(" AND NOT (n)--() DELETE n");
StringBuilder cql = new StringBuilder();
cql.append("MATCH (n) WHERE n.id = ").append(id).append(" AND NOT (n)--() DELETE n");
log.info(cql.toString());
Result run = session.run(cql.toString());
while (run.hasNext()) {
Record next = run.next();
// log.info(next.toString());
run.next();
}
} catch (Exception e) {
log.error(e.getMessage(), e);
@ -131,11 +130,10 @@ public class Neo4jServiceImpl implements Neo4jService {
log.info(cql.toString());
Result run = session.run(cql.toString());
while (run.hasNext()) {
Record next = run.next();
// log.info(next.toString());
run.next();
}
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage(), e);
}
}
@ -144,12 +142,10 @@ public class Neo4jServiceImpl implements Neo4jService {
CaseNode node = null;
try {
Session session = driver.session();
StringBuffer cql = new StringBuffer();
cql.append("MATCH (n) where id(n) = ").append(id).append(Neo4jUtils.NODE_RETURN);
Result run = session.run(cql.toString());
Result run = session.run("MATCH (n) where id(n) = " + id + Neo4jUtils.NODE_RETURN);
node = Neo4jUtils.getOneNode(run);
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage(), e);
}
return node;
}
@ -159,7 +155,7 @@ public class Neo4jServiceImpl implements Neo4jService {
List<CaseNode> list = new ArrayList<>();
try {
Session session = driver.session();
StringBuffer cql = new StringBuffer();
StringBuilder cql = new StringBuilder();
cql.append("MATCH (n");
if (StringUtils.isNotEmpty(nodeType)) {
cql.append(":");
@ -187,7 +183,7 @@ public class Neo4jServiceImpl implements Neo4jService {
Result run = session.run(cql.toString());
list = Neo4jUtils.getNodeList(run);
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage(), e);
}
return list;
}
@ -197,7 +193,7 @@ public class Neo4jServiceImpl implements Neo4jService {
CaseNode node = null;
try {
Session session = driver.session();
StringBuffer cql = new StringBuffer();
StringBuilder cql = new StringBuilder();
Map<String, Object> params = new HashMap<>();
cql.append("MATCH (n");
if (StringUtils.isNotEmpty(nodeType)) {
@ -225,7 +221,7 @@ public class Neo4jServiceImpl implements Neo4jService {
Result run = session.run(cql.toString(), params);
node = Neo4jUtils.getOneNode(run);
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage(), e);
}
return node;
}
@ -234,17 +230,16 @@ public class Neo4jServiceImpl implements Neo4jService {
public Rel findRelation(Rel rel) {
try {
Session session = driver.session();
StringBuffer cql = new StringBuffer();
Map<String, Object> params = new HashMap<>();
cql.append("MATCH (a)-[rel:").append(rel.getName()).append("]->(b) where id(a) = $sourceId and id(b) = $targetId")
.append(Neo4jUtils.REL_RETURN);
String cql = "MATCH (a)-[rel:" + rel.getName() + "]->(b) where id(a) = $sourceId and id(b) = $targetId" +
Neo4jUtils.REL_RETURN;
params.put("sourceId", rel.getSourceId());
params.put("targetId", rel.getTargetId());
Result run = session.run(cql.toString(), params);
Result run = session.run(cql, params);
rel = Neo4jUtils.getOneRel(run);
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage(), e);
}
if (rel != null && rel.getId() != null) {
return rel;
@ -255,64 +250,83 @@ public class Neo4jServiceImpl implements Neo4jService {
@Override
public Rel saveRelation(Rel rel) {
Rel res = null;
try {
Session session = driver.session();
StringBuffer cql = new StringBuffer();
Map<String, Object> params = new HashMap<>();
cql.append("MATCH (a), (b) where id(a) = $sourceId and id(b) = $targetId CREATE(a)-[rel:").append(rel.getName())
.append("]->(b) ").append(Neo4jUtils.REL_RETURN);
String cql = "MATCH (a), (b) where id(a) = $sourceId and id(b) = $targetId CREATE(a)-[rel:" + rel.getName() +
"]->(b) " + Neo4jUtils.REL_RETURN;
params.put("sourceId", rel.getSourceId());
params.put("targetId", rel.getTargetId());
Result run = session.run(cql.toString(), params);
Result run = session.run(cql, params);
rel = Neo4jUtils.getOneRel(run);
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage(), e);
}
return rel;
}
@Override
public R<?> getNode(String picType, String caseId) {
public R<?> getCaseGraph(GraphReqVO graphReqVO) {
Map<String, Object> map = new HashMap<>();
List<WebRelDTO> list = new ArrayList<>();
List<Map<String, String>> nodes = new ArrayList<>();
try {
Session session = driver.session();
StringBuilder relQuery = new StringBuilder("MATCH (n)-[rel]->(m) " +
"WHERE n.picType = $picType " +
"AND n.caseId = $caseId ");
Map<String, Object> params = new HashMap<>();
params.put("picType", picType);
params.put("caseId", caseId);
Result run = session.run("MATCH (n)-[rel]->(r) where n.picType = r.picType = $picType and n.caseId = r.caseId = $caseId" +
" RETURN id(rel) as id, n.name as source, id(n) as sourceId, type(rel) as name, r.name as target, id(r) as targetId", params);
params.put("picType", graphReqVO.getPicType());
params.put("caseId", graphReqVO.getCaseId());
if (StringUtils.isNotEmpty(graphReqVO.getQueryStr())) {
params.put("queryStr", graphReqVO.getQueryStr());
relQuery.append("AND (n.name CONTAINS $queryStr OR type(rel) CONTAINS $queryStr OR m.name CONTAINS $queryStr) ");
}
if (graphReqVO.getNodeLabels() != null && !graphReqVO.getNodeLabels().isEmpty()) {
params.put("nodeLabels", graphReqVO.getNodeLabels());
relQuery.append("AND (ANY(label IN $nodeLabels WHERE label IN labels(n)) " +
"OR ANY(label IN $nodeLabels WHERE label IN labels(m))) ");
}
if (graphReqVO.getRelTypes() != null && !graphReqVO.getRelTypes().isEmpty()) {
params.put("relTypes", graphReqVO.getRelTypes());
relQuery.append("AND ANY(type IN $relTypes WHERE type = type(rel)) ");
}
relQuery.append("RETURN id(rel) as id, n.name as source, id(n) as sourceId, n.name as sourceName, type(rel) as relName, m.name as target, id(m) as targetId, m.name as targetName");
log.info("relQuery:{}", relQuery);
Result run = session.run(relQuery.toString(), params);
while (run.hasNext()) {
Record record = run.next();
//long id = record.get("id").asLong();
//String source = record.get("source").asString();
// 组织边
long sourceId = record.get("sourceId").asLong();
String name = record.get("name").asString();
//String target = record.get("target").asString();
String relName = record.get("relName").asString();
long targetId = record.get("targetId").asLong();
list.add(new WebRelDTO(sourceId, targetId, name));
}
Result node = session.run("MATCH (n) where n.picType = $picType and n.caseId = $caseId RETURN id(n) as id, n.name as name", params);
while (node.hasNext()) {
Record record = node.next();
String name = record.get("name").asString();
long idLong = record.get("id").asLong();
Map<String, String> nodeMap = new HashMap<>();
nodeMap.put("name", name);
nodeMap.put("entityName", name);
nodeMap.put("id", String.valueOf(idLong));
nodes.add(nodeMap);
list.add(new WebRelDTO(sourceId, targetId, relName));
// 组织节点
Map<String, String> sourceNodeMap = new HashMap<>();
sourceNodeMap.put("name", record.get("sourceName").asString());
sourceNodeMap.put("id", String.valueOf(sourceId));
nodes.add(sourceNodeMap);
Map<String, String> targetNodeMap = new HashMap<>();
targetNodeMap.put("name", record.get("targetName").asString());
targetNodeMap.put("id", String.valueOf(targetId));
nodes.add(targetNodeMap);
}
} catch (Exception e) {
e.printStackTrace();
log.error("查询失败", e);
}
// 根据节点ID去重
List<Map<String, String>> distinctNodes = new ArrayList<>(nodes.stream()
.collect(Collectors.toMap(
node -> node.get("id"), // 以 ID 为唯一键
node -> node, // 保留整个 Map 作为值
(existing, replacement) -> existing)) // 如果有重复 ID保留第一个
.values());
// 节点和关系合并
Map<String, NodeMapRecord> nodeRecordMap = electNodeRecord(nodes);
list = mergerWebRel(list,nodeRecordMap);
Map<String, NodeMapRecord> nodeRecordMap = electNodeRecord(distinctNodes);
list = mergerWebRel(list, nodeRecordMap);
nodes = mergeNode(nodes, nodeRecordMap);
map.put("list", list);
@ -320,6 +334,40 @@ public class Neo4jServiceImpl implements Neo4jService {
return R.ok(map);
}
@Override
public R<?> getNodeAndRelationListByCaseId(String picType, String caseId) {
Map<String, Set<String>> map = new HashMap<>();
Set<String> nodeLabels = new HashSet<>();
Set<String> relTypes = new HashSet<>();
try (Session session = driver.session()) {
// 查询所有匹配caseId的节点及其关联关系
String query = "MATCH (n)-[r]->(m) WHERE n.caseId = $caseId AND m.caseId = $caseId RETURN labels(n) as sourceLabels, type(r) as relName, labels(m) as targetLabels";
session.executeRead(tx -> {
Result result = tx.run(query, Values.parameters("caseId", caseId));
while (result.hasNext()) {
Record record = result.next();
List<String> sourceLabels = record.get("sourceLabels").asList(Value::asString);
List<String> targetLabels = record.get("targetLabels").asList(Value::asString);
if (!sourceLabels.isEmpty()) {
nodeLabels.add(sourceLabels.get(0));
}
if (!targetLabels.isEmpty()) {
nodeLabels.add(targetLabels.get(0));
}
relTypes.add(record.get("relName").asString());
}
return null;
});
} catch (Exception e) {
log.error("查询失败", e);
}
log.info("查询到的节点类型{}个:{}", nodeLabels.size(), nodeLabels);
log.info("查询到的关系类型{}个:{}", relTypes.size(), relTypes);
map.put("nodeLabels", nodeLabels);
map.put("relTypes", relTypes);
return R.ok(map);
}
record NodeMapRecord(String name, String id, Set<String> idSet) {
}
@ -327,91 +375,93 @@ public class Neo4jServiceImpl implements Neo4jService {
/**
*
*
* @param nodes key: name ,entityName,id
* @return
* @return key: name ,value: NodeMapRecord
*/
private Map<String, NodeMapRecord> electNodeRecord(List<Map<String, String>> nodes){
private Map<String, NodeMapRecord> electNodeRecord(List<Map<String, String>> nodes) {
Map<String, NodeMapRecord> nodeRecordMap = new HashMap<>();
for (Map<String, String> node : nodes) {
String name = node.get("name");
String id = node.get("id");
NodeMapRecord nodeMapRecord = nodeRecordMap.get(name);
if (nodeMapRecord == null){
if (nodeMapRecord == null) {
Set<String> idSet = new HashSet<>();
idSet.add(id);
nodeRecordMap.put(name, new NodeMapRecord(name, id,idSet));
}else {
nodeRecordMap.put(name, new NodeMapRecord(name, id, idSet));
} else {
nodeMapRecord.idSet.add(id);
}
}
return nodeRecordMap;
}
/**
*
*
*
* name
* @param nodes key: name ,entityName,id
* name
*
* @param nodes key: name ,entityName,id
* @param nodeRecordMap
* @return
* @return
*/
private List<Map<String, String>> mergeNode(List<Map<String, String>> nodes,Map<String, NodeMapRecord> nodeRecordMap) {
private List<Map<String, String>> mergeNode(List<Map<String, String>> nodes, Map<String, NodeMapRecord> nodeRecordMap) {
return nodes.stream().map(map -> {
Map<String, String> nodeMap = new HashMap<>();
nodeMap.put("name", map.get("name"));
nodeMap.put("entityName", map.get("entityName"));
NodeMapRecord nodeMapRecord = nodeRecordMap.get(map.get("name"));
if (null == nodeMapRecord) {
log.warn("mergeNode:节点信息异常nodeRecordMap中不存在节点名称为{}的NodeMapRecord", map.get("name"));
return nodeMap;
}
if (!nodeMapRecord.idSet.contains(map.get("id"))) {
log.warn("mergeNode:节点信息异常nodeMapRecord.idSet中不包含节点id:{},节点名称为:{}", map.get("id"), map.get("name"));
return nodeMap;
}
nodeMap.put("id", nodeMapRecord.id);
return nodeMap;
}).filter(map -> StrUtil.isNotEmpty(map.get("id")))
.filter(distinctPredicate(m->m.get("id"))).collect(Collectors.toList());
Map<String, String> nodeMap = new HashMap<>();
nodeMap.put("name", map.get("name"));
NodeMapRecord nodeMapRecord = nodeRecordMap.get(map.get("name"));
if (null == nodeMapRecord) {
log.warn("mergeNode:节点信息异常nodeRecordMap中不存在节点名称为{}的NodeMapRecord", map.get("name"));
return nodeMap;
}
if (!nodeMapRecord.idSet.contains(map.get("id"))) {
log.warn("mergeNode:节点信息异常nodeMapRecord.idSet中不包含节点id:{},节点名称为:{}", map.get("id"), map.get("name"));
return nodeMap;
}
nodeMap.put("id", nodeMapRecord.id);
return nodeMap;
}).filter(map -> StrUtil.isNotEmpty(map.get("id")))
.filter(distinctPredicate(m -> m.get("id"))).collect(Collectors.toList());
}
/**
*
*
* @param webRelDTOList
* @param nodeRecordMap
* @return
* @param nodeRecordMap
* @return
*/
private List<WebRelDTO> mergerWebRel(List<WebRelDTO> webRelDTOList, Map<String, NodeMapRecord> nodeRecordMap) {
Map<String, NodeMapRecord> idNodeRecordMap = nodeRecordMap.entrySet().stream()
.collect(Collectors.toMap(entry -> entry.getValue().id, Map.Entry::getValue));
return webRelDTOList.stream().map(webRelDTO -> {
String target = webRelDTO.getTarget();
String source = webRelDTO.getSource();
String name = webRelDTO.getName();
return webRelDTOList.stream().map(webRelDTO -> {
String target = webRelDTO.getTarget();
String source = webRelDTO.getSource();
String name = webRelDTO.getName();
String sourceNew = idNodeRecordMap.entrySet().stream()
.filter(entry -> entry.getValue().idSet.contains(source))
.findAny().map(Map.Entry::getKey).orElse("");
String sourceNew = idNodeRecordMap.entrySet().stream()
.filter(entry -> entry.getValue().idSet.contains(source))
.findAny().map(Map.Entry::getKey).orElse("");
String targetNew = idNodeRecordMap.entrySet().stream()
.filter(entry -> entry.getValue().idSet.contains(target))
.findAny().map(Map.Entry::getKey).orElse("");
String targetNew = idNodeRecordMap.entrySet().stream()
.filter(entry -> entry.getValue().idSet.contains(target))
.findAny().map(Map.Entry::getKey).orElse("");
if (StrUtil.isEmpty(sourceNew) || StrUtil.isEmpty(targetNew)){
log.warn("mergerWebRel:关系信息异常nodeRecordMap中不存在节点id:{}或节点id:{}信息,节点名称为:{}", source, target, name);
}
if (StrUtil.isEmpty(sourceNew) || StrUtil.isEmpty(targetNew)) {
log.warn("mergerWebRel:关系信息异常nodeRecordMap中不存在节点id:{}或节点id:{}信息,节点名称为:{}", source, target, name);
}
return new WebRelDTO(sourceNew, targetNew, name);
}).filter(webRelDTO -> StrUtil.isNotEmpty(webRelDTO.getSource()) && StrUtil.isNotEmpty(webRelDTO.getTarget()))
return new WebRelDTO(sourceNew, targetNew, name);
}).filter(webRelDTO -> StrUtil.isNotEmpty(webRelDTO.getSource()) && StrUtil.isNotEmpty(webRelDTO.getTarget()))
.filter(distinctPredicate(rel -> rel.getSource() + rel.getTarget())).toList();
}
private <K> Predicate<K> distinctPredicate(Function<K,Object> function){
private <K> Predicate<K> distinctPredicate(Function<K, Object> function) {
ConcurrentHashMap<Object, Boolean> map = new ConcurrentHashMap<>();
return (t)-> null == map.putIfAbsent(function.apply(t),true);
return (t) -> null == map.putIfAbsent(function.apply(t), true);
}

@ -0,0 +1,32 @@
package com.supervision.police.vo;
import lombok.Data;
import java.util.List;
/**
*
*/
@Data
public class GraphReqVO {
/**
* id
*/
private String caseId;
/**
*
*/
private String picType;
/**
*
*/
private String queryStr;
/**
* (
*/
private List<String> nodeLabels;
/**
*
*/
private List<String> relTypes;
}
Loading…
Cancel
Save