|
|
|
@ -2,10 +2,8 @@ package com.supervision.police.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.supervision.common.domain.R;
|
|
|
|
|
import com.supervision.common.utils.IPages;
|
|
|
|
|
import com.supervision.common.utils.ListUtils;
|
|
|
|
|
import com.supervision.common.utils.StringUtils;
|
|
|
|
@ -13,13 +11,12 @@ import com.supervision.minio.domain.MinioFile;
|
|
|
|
|
import com.supervision.minio.mapper.MinioFileMapper;
|
|
|
|
|
import com.supervision.minio.service.MinioService;
|
|
|
|
|
import com.supervision.police.domain.ModelCase;
|
|
|
|
|
import com.supervision.police.domain.ModelRecordType;
|
|
|
|
|
import com.supervision.police.domain.NoteRecordSplit;
|
|
|
|
|
import com.supervision.police.domain.NoteRecord;
|
|
|
|
|
import com.supervision.police.domain.NoteRecords;
|
|
|
|
|
import com.supervision.police.mapper.ModelCaseMapper;
|
|
|
|
|
import com.supervision.police.mapper.ModelRecordTypeMapper;
|
|
|
|
|
import com.supervision.police.mapper.NoteRecordSplitMapper;
|
|
|
|
|
import com.supervision.police.mapper.NoteRecordMapper;
|
|
|
|
|
import com.supervision.police.mapper.NoteRecordsMapper;
|
|
|
|
|
import com.supervision.police.service.RecordService;
|
|
|
|
|
import com.supervision.springaidemo.dto.QARecordNodeDTO;
|
|
|
|
|
import com.supervision.springaidemo.util.RecordRegexUtil;
|
|
|
|
@ -28,15 +25,10 @@ import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.json.JSONObject;
|
|
|
|
|
import org.springframework.ai.chat.ChatResponse;
|
|
|
|
|
import org.springframework.ai.chat.Generation;
|
|
|
|
|
import org.springframework.ai.chat.messages.Message;
|
|
|
|
|
import org.springframework.ai.chat.messages.SystemMessage;
|
|
|
|
|
import org.springframework.ai.chat.messages.UserMessage;
|
|
|
|
|
import org.springframework.ai.chat.prompt.Prompt;
|
|
|
|
|
import org.springframework.ai.ollama.OllamaChatClient;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.util.StopWatch;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
@ -48,11 +40,11 @@ import java.util.stream.Collectors;
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Service
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
public class RecordServiceImpl extends ServiceImpl<NoteRecordMapper, NoteRecord> implements RecordService {
|
|
|
|
|
public class RecordServiceImpl extends ServiceImpl<NoteRecordSplitMapper, NoteRecordSplit> implements RecordService {
|
|
|
|
|
|
|
|
|
|
private final NoteRecordMapper noteRecordMapper;
|
|
|
|
|
private final NoteRecordSplitMapper noteRecordSplitMapper;
|
|
|
|
|
|
|
|
|
|
private final NoteRecordsMapper noteRecordsMapper;
|
|
|
|
|
private final NoteRecordMapper noteRecordMapper;
|
|
|
|
|
|
|
|
|
|
private final MinioService minioService;
|
|
|
|
|
|
|
|
|
@ -65,7 +57,7 @@ public class RecordServiceImpl extends ServiceImpl<NoteRecordMapper, NoteRecord>
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
// @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public String uploadRecords(NoteRecords records, List<MultipartFile> fileList) throws IOException {
|
|
|
|
|
public String uploadRecords(NoteRecord records, List<MultipartFile> fileList) throws IOException {
|
|
|
|
|
//上传文件,获取文件ids
|
|
|
|
|
List<String> fileIds = new ArrayList<>();
|
|
|
|
|
for (MultipartFile file : fileList) {
|
|
|
|
@ -98,9 +90,9 @@ public class RecordServiceImpl extends ServiceImpl<NoteRecordMapper, NoteRecord>
|
|
|
|
|
}
|
|
|
|
|
int i = 0;
|
|
|
|
|
if (StringUtils.isEmpty(records.getId())) {
|
|
|
|
|
i = noteRecordsMapper.insert(records);
|
|
|
|
|
i = noteRecordMapper.insert(records);
|
|
|
|
|
} else {
|
|
|
|
|
i = noteRecordsMapper.updateById(records);
|
|
|
|
|
i = noteRecordMapper.updateById(records);
|
|
|
|
|
}
|
|
|
|
|
//所有对话类型
|
|
|
|
|
List<String> allTypes = modelRecordTypeMapper.getAllType();
|
|
|
|
@ -112,7 +104,7 @@ public class RecordServiceImpl extends ServiceImpl<NoteRecordMapper, NoteRecord>
|
|
|
|
|
List<QARecordNodeDTO> qaList = RecordRegexUtil.recordRegex(context, records.getName());
|
|
|
|
|
for (QARecordNodeDTO qa : qaList) {
|
|
|
|
|
try {
|
|
|
|
|
NoteRecord noteRecord = new NoteRecord();
|
|
|
|
|
NoteRecordSplit noteRecord = new NoteRecordSplit();
|
|
|
|
|
noteRecord.setCaseId(records.getCaseId());
|
|
|
|
|
noteRecord.setNoteRecordsId(records.getId());
|
|
|
|
|
noteRecord.setNoteName(file.getName());
|
|
|
|
@ -159,7 +151,7 @@ public class RecordServiceImpl extends ServiceImpl<NoteRecordMapper, NoteRecord>
|
|
|
|
|
}*/
|
|
|
|
|
//保存笔录
|
|
|
|
|
noteRecord.setRecordType(type);
|
|
|
|
|
noteRecordMapper.insert(noteRecord);
|
|
|
|
|
noteRecordSplitMapper.insert(noteRecord);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
@ -178,25 +170,25 @@ public class RecordServiceImpl extends ServiceImpl<NoteRecordMapper, NoteRecord>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> queryRecords(NoteRecords noteRecords, Integer page, Integer size) {
|
|
|
|
|
LambdaQueryWrapper<NoteRecords> wrapper = Wrappers.lambdaQuery();
|
|
|
|
|
wrapper.like(StringUtils.isNotEmpty(noteRecords.getName()), NoteRecords::getName, noteRecords.getName())
|
|
|
|
|
.eq(NoteRecords::getCaseId, noteRecords.getCaseId())
|
|
|
|
|
.eq(NoteRecords::getDataStatus, "1");
|
|
|
|
|
List<NoteRecords> list = noteRecordsMapper.selectList(wrapper);
|
|
|
|
|
public Map<String, Object> queryRecords(NoteRecord noteRecords, Integer page, Integer size) {
|
|
|
|
|
LambdaQueryWrapper<NoteRecord> wrapper = Wrappers.lambdaQuery();
|
|
|
|
|
wrapper.like(StringUtils.isNotEmpty(noteRecords.getName()), NoteRecord::getName, noteRecords.getName())
|
|
|
|
|
.eq(NoteRecord::getCaseId, noteRecords.getCaseId())
|
|
|
|
|
.eq(NoteRecord::getDataStatus, "1");
|
|
|
|
|
List<NoteRecord> list = noteRecordMapper.selectList(wrapper);
|
|
|
|
|
// LinkedHashMap 保障顺序
|
|
|
|
|
Map<String, List<NoteRecords>> nameMap = list.stream().filter(item -> StringUtils.isNotBlank(item.getName()))
|
|
|
|
|
.collect(Collectors.groupingBy(NoteRecords::getName, LinkedHashMap::new, Collectors.toList()));
|
|
|
|
|
List<NoteRecords> res = new ArrayList<>();
|
|
|
|
|
Map<String, List<NoteRecord>> nameMap = list.stream().filter(item -> StringUtils.isNotBlank(item.getName()))
|
|
|
|
|
.collect(Collectors.groupingBy(NoteRecord::getName, LinkedHashMap::new, Collectors.toList()));
|
|
|
|
|
List<NoteRecord> res = new ArrayList<>();
|
|
|
|
|
for (String name : nameMap.keySet()) {
|
|
|
|
|
NoteRecords noteRecord = new NoteRecords();
|
|
|
|
|
NoteRecord noteRecord = new NoteRecord();
|
|
|
|
|
noteRecord.setName(name);
|
|
|
|
|
noteRecord.setChildren(nameMap.get(name));
|
|
|
|
|
res.add(noteRecord);
|
|
|
|
|
}
|
|
|
|
|
List<NoteRecords> pager = ListUtils.Pager(size, page, res);
|
|
|
|
|
for (NoteRecords person : pager) {
|
|
|
|
|
for (NoteRecords noteRecord : person.getChildren()) {
|
|
|
|
|
List<NoteRecord> pager = ListUtils.Pager(size, page, res);
|
|
|
|
|
for (NoteRecord person : pager) {
|
|
|
|
|
for (NoteRecord noteRecord : person.getChildren()) {
|
|
|
|
|
String fileIds = noteRecord.getFileIds();
|
|
|
|
|
if (StringUtils.isNotEmpty(fileIds)) {
|
|
|
|
|
noteRecord.setConfessionMaterial(fileIds.split(",").length);
|
|
|
|
@ -208,10 +200,10 @@ public class RecordServiceImpl extends ServiceImpl<NoteRecordMapper, NoteRecord>
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void delRecords(String id) {
|
|
|
|
|
NoteRecords noteRecords = noteRecordsMapper.selectById(id);
|
|
|
|
|
noteRecords.setDataStatus(StringUtils.getUUID());
|
|
|
|
|
noteRecordsMapper.updateById(noteRecords);
|
|
|
|
|
String fileIds = noteRecords.getFileIds();
|
|
|
|
|
NoteRecord noteRecord = noteRecordMapper.selectById(id);
|
|
|
|
|
noteRecord.setDataStatus(StringUtils.getUUID());
|
|
|
|
|
noteRecordMapper.updateById(noteRecord);
|
|
|
|
|
String fileIds = noteRecord.getFileIds();
|
|
|
|
|
if (StringUtils.isNotEmpty(fileIds)) {
|
|
|
|
|
//删除文件
|
|
|
|
|
for (String fileId : fileIds.split(",")) {
|
|
|
|
|