|
|
|
@ -16,7 +16,10 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
@ -35,6 +38,7 @@ public class OCRRecordServiceImpl implements OCRRecordService {
|
|
|
|
|
private final ModelRecordTypeService modelRecordTypeService;
|
|
|
|
|
|
|
|
|
|
private final CasePersonService casePersonService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String saveRecord(NoteRecordReqVO noteRecordReqVO) {
|
|
|
|
|
|
|
|
|
@ -42,7 +46,7 @@ public class OCRRecordServiceImpl implements OCRRecordService {
|
|
|
|
|
NoteRecord record = noteRecordReqVO.toNoteRecord();
|
|
|
|
|
String recordId = noteRecordService.saveOrUpdRecord(record);
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isEmpty(noteRecordReqVO.getFileIdList())){
|
|
|
|
|
if (CollUtil.isEmpty(noteRecordReqVO.getFileIdList())) {
|
|
|
|
|
log.info("uploadRecords:文件内容为空...不进行笔录分析操作...");
|
|
|
|
|
return recordId;
|
|
|
|
|
}
|
|
|
|
@ -56,7 +60,7 @@ public class OCRRecordServiceImpl implements OCRRecordService {
|
|
|
|
|
NoteRecord noteRecord = new NoteRecord();
|
|
|
|
|
noteRecord.setId(recordId);
|
|
|
|
|
List<NoteRecordDTO> noteRecordDTOS = noteRecordService.selectNoteRecordDTOList(noteRecord);
|
|
|
|
|
if (CollUtil.isEmpty(noteRecordDTOS)){
|
|
|
|
|
if (CollUtil.isEmpty(noteRecordDTOS)) {
|
|
|
|
|
return new NoteRecordDTO();
|
|
|
|
|
}
|
|
|
|
|
return CollUtil.getFirst(noteRecordDTOS);
|
|
|
|
@ -68,17 +72,17 @@ public class OCRRecordServiceImpl implements OCRRecordService {
|
|
|
|
|
NoteRecord noteRecord = noteRecordService.getById(recordId);
|
|
|
|
|
Assert.notNull(noteRecord, "笔录不存在,可能已经被删除!");
|
|
|
|
|
String fileIds = noteRecord.getFileIds();
|
|
|
|
|
if (StrUtil.isEmpty(fileIds)){
|
|
|
|
|
log.info("queryFileList:笔录:{}对应的fileIds为空...",recordId);
|
|
|
|
|
if (StrUtil.isEmpty(fileIds)) {
|
|
|
|
|
log.info("queryFileList:笔录:{}对应的fileIds为空...", recordId);
|
|
|
|
|
return CollUtil.newArrayList();
|
|
|
|
|
}
|
|
|
|
|
List<String> fileIdList = Arrays.stream(fileIds.split(",")).toList();
|
|
|
|
|
|
|
|
|
|
List<RecordFileDTO> recordFileDTOS = fileOcrProcessService.queryFileListWithIdSort(fileIdList);
|
|
|
|
|
recordFileDTOS.forEach(record->{
|
|
|
|
|
recordFileDTOS.forEach(record -> {
|
|
|
|
|
record.formatFileSize();
|
|
|
|
|
record.setDefaultEvidenceTypeDesc();
|
|
|
|
|
if (StrUtil.isEmpty(record.getReviseText())){
|
|
|
|
|
if (StrUtil.isEmpty(record.getReviseText())) {
|
|
|
|
|
record.setReviseText(record.getOcrText());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
@ -87,7 +91,7 @@ public class OCRRecordServiceImpl implements OCRRecordService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean reviseOcrText(String id,String reviseText) {
|
|
|
|
|
public Boolean reviseOcrText(String id, String reviseText) {
|
|
|
|
|
|
|
|
|
|
Assert.notEmpty(id, "id不能为空");
|
|
|
|
|
|
|
|
|
@ -98,7 +102,7 @@ public class OCRRecordServiceImpl implements OCRRecordService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean reviseOcrText(List<OCRTextDTO> ocrTextDTOList) {
|
|
|
|
|
if (CollUtil.isEmpty(ocrTextDTOList)){
|
|
|
|
|
if (CollUtil.isEmpty(ocrTextDTOList)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
ocrTextDTOList.forEach(ocrTextDTO -> this.reviseOcrText(ocrTextDTO.getOcrId(), ocrTextDTO.getReviseText()));
|
|
|
|
@ -119,8 +123,8 @@ public class OCRRecordServiceImpl implements OCRRecordService {
|
|
|
|
|
public Boolean submitRecordTask(String recordId) {
|
|
|
|
|
Assert.notEmpty(recordId, "recordId不能为空");
|
|
|
|
|
NoteRecord noteRecord = noteRecordService.getById(recordId);
|
|
|
|
|
if (Objects.isNull(noteRecord) || StrUtil.isEmpty(noteRecord.getFileIds())){
|
|
|
|
|
log.info("submitRecordTask:笔录:{}对应的笔录文件为空...",recordId);
|
|
|
|
|
if (Objects.isNull(noteRecord) || StrUtil.isEmpty(noteRecord.getFileIds())) {
|
|
|
|
|
log.info("submitRecordTask:笔录:{}对应的笔录文件为空...", recordId);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -131,14 +135,14 @@ public class OCRRecordServiceImpl implements OCRRecordService {
|
|
|
|
|
List<RecordFileDTO> recordFileDTOS = fileOcrProcessService.queryFileList(fileIdList);
|
|
|
|
|
|
|
|
|
|
recordFileDTOS = recordFileDTOS.stream()
|
|
|
|
|
.filter(file->StrUtil.isAllNotEmpty(file.getOcrText(),file.getReviseText())).toList();
|
|
|
|
|
if (CollUtil.isEmpty(recordFileDTOS)){
|
|
|
|
|
log.info("submitRecordTask:笔录:{}对应的笔录文件为空...",recordId);
|
|
|
|
|
.filter(file -> StrUtil.isAllNotEmpty(file.getOcrText(), file.getReviseText())).toList();
|
|
|
|
|
if (CollUtil.isEmpty(recordFileDTOS)) {
|
|
|
|
|
log.info("submitRecordTask:笔录:{}对应的笔录文件为空...", recordId);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (StrUtil.isNotEmpty(noteRecord.getCasePersonId())){
|
|
|
|
|
if (StrUtil.isNotEmpty(noteRecord.getCasePersonId())) {
|
|
|
|
|
CasePerson casePerson = casePersonService.getById(noteRecord.getCasePersonId());
|
|
|
|
|
if (Objects.nonNull(casePerson)){
|
|
|
|
|
if (Objects.nonNull(casePerson)) {
|
|
|
|
|
noteRecord.setName(casePerson.getName());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -158,7 +162,7 @@ public class OCRRecordServiceImpl implements OCRRecordService {
|
|
|
|
|
public Boolean deleteFile(String recordId, String fileId) {
|
|
|
|
|
|
|
|
|
|
Assert.notEmpty(recordId, "recordId不能为空");
|
|
|
|
|
if (StrUtil.isEmpty(fileId)){
|
|
|
|
|
if (StrUtil.isEmpty(fileId)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -166,7 +170,7 @@ public class OCRRecordServiceImpl implements OCRRecordService {
|
|
|
|
|
Assert.notNull(noteRecord, "recordId:{}对应的笔录信息不存在", recordId);
|
|
|
|
|
|
|
|
|
|
String fileIds = noteRecord.getFileIds();
|
|
|
|
|
if (StrUtil.isEmpty(fileIds)){
|
|
|
|
|
if (StrUtil.isEmpty(fileIds)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -185,12 +189,12 @@ public class OCRRecordServiceImpl implements OCRRecordService {
|
|
|
|
|
List<QARecordNodeDTO> qaList = RecordRegexUtil.recordRegex(
|
|
|
|
|
StrUtil.isEmpty(reviseText) ? ocrText : reviseText, noteRecord.getName());
|
|
|
|
|
|
|
|
|
|
log.info("文件:{}拆分问答对:{}",recordFileDTO.getFileName(), qaList.size());
|
|
|
|
|
log.info("文件:{}拆分问答对:{}", recordFileDTO.getFileName(), qaList.size());
|
|
|
|
|
|
|
|
|
|
List<NoteRecordSplit> splitList = new ArrayList<>();
|
|
|
|
|
for (QARecordNodeDTO qa : qaList) {
|
|
|
|
|
splitList.add(
|
|
|
|
|
noteRecordSplitService.saveRecordSplit(noteRecord,
|
|
|
|
|
noteRecordSplitService.saveRecordSplit(noteRecord, recordFileDTO.getFileId(),
|
|
|
|
|
recordFileDTO.getFileName(), qa.getQuestion(), qa.getAnswer())
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|