|
|
|
@ -5,6 +5,7 @@ import cn.hutool.core.lang.Assert;
|
|
|
|
|
import cn.hutool.core.lang.Pair;
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.supervision.chat.client.LangChainChatService;
|
|
|
|
|
import com.supervision.common.utils.IPages;
|
|
|
|
@ -18,10 +19,10 @@ import com.supervision.minio.service.MinioService;
|
|
|
|
|
import com.supervision.neo4j.service.Neo4jService;
|
|
|
|
|
import com.supervision.police.domain.*;
|
|
|
|
|
import com.supervision.police.dto.NoteRecordDTO;
|
|
|
|
|
import com.supervision.police.dto.NoteRecordDetailDTO;
|
|
|
|
|
import com.supervision.police.dto.NoteRecordFileDTO;
|
|
|
|
|
import com.supervision.police.dto.RecordFileDTO;
|
|
|
|
|
import com.supervision.police.vo.NoteRecordReqVO;
|
|
|
|
|
import com.supervision.police.dto.NoteRecordDetailDTO;
|
|
|
|
|
import com.supervision.police.mapper.NoteRecordSplitMapper;
|
|
|
|
|
import com.supervision.police.service.*;
|
|
|
|
|
import com.supervision.utils.RecordRegexUtil;
|
|
|
|
@ -77,7 +78,7 @@ public class NoteRecordSplitServiceImpl extends ServiceImpl<NoteRecordSplitMappe
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(transactionManager = "dataSourceTransactionManager", rollbackFor = Exception.class)
|
|
|
|
|
public String uploadRecords(NoteRecordReqVO records) throws IOException {
|
|
|
|
|
public String uploadRecords(NoteRecordReqVO records) {
|
|
|
|
|
|
|
|
|
|
ModelCase modelCase = modelCaseService.getById(records.getCaseId());
|
|
|
|
|
Assert.notEmpty(modelCase.getCaseNo(), "案件编号不能为空");
|
|
|
|
@ -85,7 +86,7 @@ public class NoteRecordSplitServiceImpl extends ServiceImpl<NoteRecordSplitMappe
|
|
|
|
|
NoteRecord record = records.toNoteRecord();
|
|
|
|
|
String recordId = noteRecordService.saveOrUpdRecord(record);
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isEmpty(records.getFileIdList())){
|
|
|
|
|
if (CollUtil.isEmpty(records.getFileIdList())) {
|
|
|
|
|
log.info("uploadRecords:文件内容为空...不进行笔录分析操作...");
|
|
|
|
|
return recordId;
|
|
|
|
|
}
|
|
|
|
@ -251,14 +252,14 @@ public class NoteRecordSplitServiceImpl extends ServiceImpl<NoteRecordSplitMappe
|
|
|
|
|
public List<NoteRecordSplit> batchSaveRecordSplit(NoteRecord record, String fileId) {
|
|
|
|
|
|
|
|
|
|
String context = WordReadUtil.readWordInMinio(minioService, fileId);
|
|
|
|
|
if (StrUtil.isEmpty(context)){
|
|
|
|
|
if (StrUtil.isEmpty(context)) {
|
|
|
|
|
log.info("文件id:{}内容为空,不进行解析...", fileId);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MinioFile minioFile = minioService.getMinioFile(fileId);
|
|
|
|
|
List<QARecordNodeDTO> qaList = RecordRegexUtil.recordRegex(context, record.getName());
|
|
|
|
|
log.info("文件:{}拆分问答对:{}",minioFile.getFilename(), qaList.size());
|
|
|
|
|
log.info("文件:{}拆分问答对:{}", minioFile.getFilename(), qaList.size());
|
|
|
|
|
|
|
|
|
|
List<NoteRecordSplit> splitList = new ArrayList<>();
|
|
|
|
|
for (QARecordNodeDTO qa : qaList) {
|
|
|
|
@ -309,21 +310,58 @@ public class NoteRecordSplitServiceImpl extends ServiceImpl<NoteRecordSplitMappe
|
|
|
|
|
return IPages.buildDataMap(pager, noteRecordDetailDTOList.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(transactionManager = "dataSourceTransactionManager", rollbackFor = Exception.class)
|
|
|
|
|
public String redoExtract(NoteRecordReqVO records) throws IOException {
|
|
|
|
|
// 删除旧数据
|
|
|
|
|
// 删除问答对数据
|
|
|
|
|
noteRecordSplitService.remove(new QueryWrapper<NoteRecordSplit>().eq("note_record_id", records.getId()));
|
|
|
|
|
// 删除任务数据
|
|
|
|
|
caseTaskRecordService.remove(new QueryWrapper<CaseTaskRecord>().eq("record_id", records.getId()));
|
|
|
|
|
// 删除neo4j的节点
|
|
|
|
|
List<TripleInfo> list = tripleInfoService.lambdaQuery().eq(TripleInfo::getRecordId, records.getId()).list();
|
|
|
|
|
list.forEach(item -> {
|
|
|
|
|
// 如果已经入库,就删除已经入库的图
|
|
|
|
|
if (StrUtil.equals("1", item.getAddNeo4j())) {
|
|
|
|
|
// 删除尾节点(不删除头节点),如果删除尾节点,关系会被自动删除
|
|
|
|
|
try {
|
|
|
|
|
if (ObjectUtil.isNotEmpty(item.getRelGraphId())) {
|
|
|
|
|
// 先移除关系
|
|
|
|
|
neo4jService.deleteRel(item.getRelGraphId());
|
|
|
|
|
}
|
|
|
|
|
if (ObjectUtil.isNotEmpty(item.getEndNodeGraphId())) {
|
|
|
|
|
// 再移除尾节点
|
|
|
|
|
neo4jService.delNode(item.getEndNodeGraphId());
|
|
|
|
|
}
|
|
|
|
|
if (ObjectUtil.isNotEmpty(item.getStartNodeGraphId())) {
|
|
|
|
|
// 尝试删除头节点(只有头节点不存在任何关系的时候才进行删除)
|
|
|
|
|
neo4jService.deleteNoRelationNode(item.getStartNodeGraphId());
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("删除关系失败:{}", item.getRelation(), e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
// 删除三元组数据
|
|
|
|
|
tripleInfoService.remove(new QueryWrapper<TripleInfo>().eq("record_id", records.getId()));
|
|
|
|
|
return uploadRecords(records);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setRecordDetailSerialNumber(List<NoteRecordDetailDTO> noteRecordDetailDTOList) {
|
|
|
|
|
|
|
|
|
|
List<Pair<String, Integer>> pairs = new ArrayList<>();
|
|
|
|
|
for (NoteRecordDetailDTO noteRecordDetailDTO : noteRecordDetailDTOList) {
|
|
|
|
|
String personId = noteRecordDetailDTO.getPersonId();
|
|
|
|
|
int index = findPair(pairs, personId);
|
|
|
|
|
if (index == -1){
|
|
|
|
|
if (index == -1) {
|
|
|
|
|
pairs.add(Pair.of(personId, 1));
|
|
|
|
|
index = findPair(pairs, personId);
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
pairs.set(index, Pair.of(personId, pairs.get(index).getValue() + 1));
|
|
|
|
|
}
|
|
|
|
|
noteRecordDetailDTO.setSerialNumber(index+1 + "." + pairs.get(index).getValue());
|
|
|
|
|
}
|
|
|
|
|
noteRecordDetailDTO.setSerialNumber(index + 1 + "." + pairs.get(index).getValue());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int findPair(List<Pair<String, Integer>> pairs, String personId) {
|
|
|
|
@ -337,5 +375,4 @@ public class NoteRecordSplitServiceImpl extends ServiceImpl<NoteRecordSplitMappe
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|