|
|
|
@ -4,12 +4,14 @@ import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.alibaba.druid.util.StringUtils;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
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 com.supervision.police.domain.*;
|
|
|
|
|
import com.supervision.police.dto.TripleInfoDTO;
|
|
|
|
|
import com.supervision.police.mapper.ModelRecordTypeMapper;
|
|
|
|
|
import com.supervision.police.mapper.NoteRecordSplitMapper;
|
|
|
|
|
import com.supervision.police.service.*;
|
|
|
|
@ -21,9 +23,11 @@ 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 java.time.LocalDateTime;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
|
|
|
|
@ -57,13 +61,37 @@ public class ModelRecordTypeServiceImpl extends ServiceImpl<ModelRecordTypeMappe
|
|
|
|
|
//笔录内容
|
|
|
|
|
List<NoteRecordSplit> noteRecords = noteRecordSplitMapper.selectByRecordType(modelRecordType.getRecordType());
|
|
|
|
|
modelRecordType.setRecords(noteRecords);
|
|
|
|
|
// grideOptions
|
|
|
|
|
//提示词
|
|
|
|
|
List<NotePrompt> prompts = notePromptService.lambdaQuery().eq(NotePrompt::getTypeId, modelRecordType.getId()).list();
|
|
|
|
|
for (NotePrompt prompt : prompts) {
|
|
|
|
|
prompt.setTripleList(buildTripleInfo(prompt));
|
|
|
|
|
}
|
|
|
|
|
modelRecordType.setPrompts(prompts);
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<TripleInfoDTO> buildTripleInfo(NotePrompt notePrompt) {
|
|
|
|
|
List<TripleInfoDTO> list = new ArrayList<>();
|
|
|
|
|
TripleInfoDTO dto = new TripleInfoDTO();
|
|
|
|
|
dto.setType("头节点");
|
|
|
|
|
dto.setTemplateName(notePrompt.getStartEntityTemplate());
|
|
|
|
|
dto.setValue(notePrompt.getStartEntityType());
|
|
|
|
|
list.add(dto);
|
|
|
|
|
TripleInfoDTO dto1 = new TripleInfoDTO();
|
|
|
|
|
dto1.setType("关系");
|
|
|
|
|
dto1.setTemplateName(notePrompt.getRelTemplate());
|
|
|
|
|
dto1.setValue(notePrompt.getRelType());
|
|
|
|
|
list.add(dto1);
|
|
|
|
|
TripleInfoDTO dto2 = new TripleInfoDTO();
|
|
|
|
|
dto2.setType("尾节点");
|
|
|
|
|
dto2.setTemplateName(notePrompt.getEndEntityTemplate());
|
|
|
|
|
dto2.setValue(notePrompt.getEndEntityType());
|
|
|
|
|
list.add(dto2);
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ModelRecordType queryByName(String content) {
|
|
|
|
|
Wrapper<ModelRecordType> wrapper = new QueryWrapper<ModelRecordType>().eq("record_type", content);
|
|
|
|
@ -88,6 +116,7 @@ public class ModelRecordTypeServiceImpl extends ServiceImpl<ModelRecordTypeMappe
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(transactionManager = "dataSourceTransactionManager",rollbackFor = Exception.class)
|
|
|
|
|
public R<?> addOrUpdPrompt(NotePrompt prompt) {
|
|
|
|
|
int i = 0;
|
|
|
|
|
boolean save;
|
|
|
|
@ -96,6 +125,24 @@ public class ModelRecordTypeServiceImpl extends ServiceImpl<ModelRecordTypeMappe
|
|
|
|
|
} else {
|
|
|
|
|
save = notePromptService.updateById(prompt);
|
|
|
|
|
}
|
|
|
|
|
// 更新类型字段
|
|
|
|
|
List<TripleInfoDTO> tripleList = prompt.getTripleList();
|
|
|
|
|
for (TripleInfoDTO dto : tripleList) {
|
|
|
|
|
if ("头节点".equals(dto.getType())) {
|
|
|
|
|
notePromptService.lambdaUpdate().set(NotePrompt::getStartEntityTemplate, dto.getTemplateName())
|
|
|
|
|
.set(NotePrompt::getStartEntityType, dto.getValue())
|
|
|
|
|
.eq(NotePrompt::getId, prompt.getId()).update();
|
|
|
|
|
}else if ("关系".equals(dto.getType())){
|
|
|
|
|
notePromptService.lambdaUpdate().set(NotePrompt::getRelTemplate, dto.getTemplateName())
|
|
|
|
|
.set(NotePrompt::getRelType, dto.getValue())
|
|
|
|
|
.eq(NotePrompt::getId, prompt.getId()).update();
|
|
|
|
|
}else if ("尾节点".equals(dto.getType())){
|
|
|
|
|
notePromptService.lambdaUpdate().set(NotePrompt::getEndEntityTemplate, dto.getTemplateName())
|
|
|
|
|
.set(NotePrompt::getEndEntityType, dto.getValue())
|
|
|
|
|
.eq(NotePrompt::getId, prompt.getId()).update();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (save) {
|
|
|
|
|
return R.ok("保存成功");
|
|
|
|
|
} else {
|
|
|
|
|