|
|
@ -2,6 +2,7 @@ package com.supervision.police.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
|
|
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
@ -83,64 +84,52 @@ public class NoteRecordSplitServiceImpl extends ServiceImpl<NoteRecordSplitMappe
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@Transactional(transactionManager = "dataSourceTransactionManager", rollbackFor = Exception.class)
|
|
|
|
@Transactional(transactionManager = "dataSourceTransactionManager", rollbackFor = Exception.class)
|
|
|
|
public String uploadRecords(NoteRecordReqVO records) throws IOException {
|
|
|
|
public String uploadRecords(NoteRecordReqVO records) throws IOException {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
ModelCase modelCase = modelCaseService.getById(records.getCaseId());
|
|
|
|
ModelCase modelCase = modelCaseService.getById(records.getCaseId());
|
|
|
|
if (StringUtils.isEmpty(modelCase.getCaseNo())) {
|
|
|
|
Assert.notEmpty(modelCase.getCaseNo(), "案件编号不能为空");
|
|
|
|
throw new BusinessException("案件编号不能为空");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
NoteRecord record = records.toNoteRecord();
|
|
|
|
NoteRecord record = records.toNoteRecord();
|
|
|
|
if (StringUtils.isEmpty(records.getId())) {
|
|
|
|
String recordId = noteRecordService.saveOrUpdRecord(record);
|
|
|
|
i = noteRecordService.getBaseMapper().insert(record);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if (CollUtil.isEmpty(records.getFileIdList())){
|
|
|
|
i = noteRecordService.getBaseMapper().updateById(record);
|
|
|
|
log.info("uploadRecords:文件内容为空...不进行笔录分析操作...");
|
|
|
|
|
|
|
|
return recordId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//所有对话类型
|
|
|
|
//所有对话类型
|
|
|
|
|
|
|
|
extracted(records.getFileIdList(), record);
|
|
|
|
|
|
|
|
caseStatusManageService.whenUploadRecord(record.getCaseId());
|
|
|
|
|
|
|
|
return record.getId();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void extracted(List<String> recordIds, NoteRecord record) {
|
|
|
|
|
|
|
|
// 拆分笔录
|
|
|
|
List<ModelRecordType> allTypeList = modelRecordTypeService.lambdaQuery().list();
|
|
|
|
List<ModelRecordType> allTypeList = modelRecordTypeService.lambdaQuery().list();
|
|
|
|
if (i > 0 && CollUtil.isNotEmpty(records.getFileIdList())) {
|
|
|
|
for (String fileId : recordIds) {
|
|
|
|
// 拆分笔录
|
|
|
|
|
|
|
|
for (String fileId : records.getFileIdList()) {
|
|
|
|
String context = WordReadUtil.readWordInMinio(minioService, fileId);
|
|
|
|
MinioFile minioFile = minioService.getMinioFile(fileId);
|
|
|
|
if (StrUtil.isEmpty(context)){
|
|
|
|
InputStream inputStream = null;
|
|
|
|
log.info("文件id:{}内容为空,不进行解析...", fileId);
|
|
|
|
try {
|
|
|
|
continue;
|
|
|
|
inputStream = minioService.getObjectInputStream(minioFile);
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
MinioFile minioFile = minioService.getMinioFile(fileId);
|
|
|
|
log.error("从minio中获取文件失败:{}", e.getMessage());
|
|
|
|
List<QARecordNodeDTO> qaList = RecordRegexUtil.recordRegex(context, minioFile.getFilename());
|
|
|
|
continue;
|
|
|
|
log.info("拆分问答对:{}", qaList.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
String context = WordReadUtil.readWord(inputStream);
|
|
|
|
List<NoteRecordSplit> splitList = new ArrayList<>();
|
|
|
|
List<QARecordNodeDTO> qaList = RecordRegexUtil.recordRegex(context, record.getName());
|
|
|
|
for (QARecordNodeDTO qa : qaList) {
|
|
|
|
log.info("拆分问答对:{}", qaList.size());
|
|
|
|
splitList.add(
|
|
|
|
List<NoteRecordSplit> splitList = new ArrayList<>();
|
|
|
|
saveRecordSplit(record, record.getName(), qa.getQuestion(), qa.getAnswer())
|
|
|
|
for (QARecordNodeDTO qa : qaList) {
|
|
|
|
);
|
|
|
|
try {
|
|
|
|
}
|
|
|
|
NoteRecordSplit noteRecord = new NoteRecordSplit();
|
|
|
|
|
|
|
|
noteRecord.setCaseId(record.getCaseId());
|
|
|
|
// 创建任务之后,再开始
|
|
|
|
noteRecord.setNoteRecordId(record.getId());
|
|
|
|
boolean taskStatus = saveRecordProcessTask(record.getCaseId(), record.getId(), qaList.size());
|
|
|
|
noteRecord.setNoteName(minioFile.getFilename());
|
|
|
|
// 如果校验结果为true,则说明需要进行分类以及三元组操作
|
|
|
|
noteRecord.setPersonName(record.getName());
|
|
|
|
if (taskStatus) {
|
|
|
|
noteRecord.setQuestion(qa.getQuestion());
|
|
|
|
// 对笔录进行分类,并对笔录进行提取三元组
|
|
|
|
noteRecord.setAnswer(qa.getAnswer());
|
|
|
|
recordSplitProcessService.process(allTypeList, splitList);
|
|
|
|
noteRecord.setCreateTime(LocalDateTime.now());
|
|
|
|
|
|
|
|
this.save(noteRecord);
|
|
|
|
|
|
|
|
splitList.add(noteRecord);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 创建任务之后,再开始
|
|
|
|
|
|
|
|
boolean taskStatus = saveRecordProcessTask(record.getCaseId(), record.getId(), qaList.size());
|
|
|
|
|
|
|
|
// 如果校验结果为true,则说明需要进行分类以及三元组操作
|
|
|
|
|
|
|
|
if (taskStatus) {
|
|
|
|
|
|
|
|
// 对笔录进行分类,并对笔录进行提取三元组
|
|
|
|
|
|
|
|
recordSplitProcessService.process(allTypeList, splitList);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
caseStatusManageService.whenUploadRecord(record.getCaseId());
|
|
|
|
|
|
|
|
return "保存成功";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return "保存笔录失败";
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -333,4 +322,19 @@ public class NoteRecordSplitServiceImpl extends ServiceImpl<NoteRecordSplitMappe
|
|
|
|
modelAtomicResultService.lambdaUpdate().eq(ModelAtomicResult::getRecordId, id).remove();
|
|
|
|
modelAtomicResultService.lambdaUpdate().eq(ModelAtomicResult::getRecordId, id).remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public NoteRecordSplit saveRecordSplit(NoteRecord record, String fileName, String question, String answer) {
|
|
|
|
|
|
|
|
NoteRecordSplit noteRecord = new NoteRecordSplit();
|
|
|
|
|
|
|
|
noteRecord.setCaseId(record.getCaseId());
|
|
|
|
|
|
|
|
noteRecord.setNoteRecordId(record.getId());
|
|
|
|
|
|
|
|
noteRecord.setNoteName(fileName);
|
|
|
|
|
|
|
|
noteRecord.setPersonName(record.getName());
|
|
|
|
|
|
|
|
noteRecord.setQuestion(question);
|
|
|
|
|
|
|
|
noteRecord.setAnswer(answer);
|
|
|
|
|
|
|
|
noteRecord.setCreateTime(LocalDateTime.now());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.save(noteRecord);
|
|
|
|
|
|
|
|
return noteRecord;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|