|
|
|
|
package com.supervision.police.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.supervision.police.domain.ModelRecordType;
|
|
|
|
|
import com.supervision.police.domain.NotePrompt;
|
|
|
|
|
import com.supervision.police.domain.NotePromptTypeRel;
|
|
|
|
|
import com.supervision.police.domain.NoteRecordSplit;
|
|
|
|
|
import com.supervision.police.dto.NotePromptDTO;
|
|
|
|
|
import com.supervision.police.mapper.NotePromptMapper;
|
|
|
|
|
import com.supervision.police.service.ModelRecordTypeService;
|
|
|
|
|
import com.supervision.police.service.NotePromptService;
|
|
|
|
|
import com.supervision.police.service.NotePromptTypeRelService;
|
|
|
|
|
import com.supervision.police.service.NoteRecordSplitService;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Service
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
public class NotePromptServiceImpl extends ServiceImpl<NotePromptMapper, NotePrompt> implements NotePromptService {
|
|
|
|
|
|
|
|
|
|
private final NoteRecordSplitService noteRecordSplitService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ModelRecordTypeService modelRecordTypeService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private NotePromptMapper notePromptMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final NotePromptTypeRelService notePromptTypeRelService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<NotePrompt> listPromptBySplitId(String recordSplitId) {
|
|
|
|
|
|
|
|
|
|
List<NotePrompt> notePromptList = new ArrayList<>();
|
|
|
|
|
// 首先获取所有切分后的笔录
|
|
|
|
|
Optional<NoteRecordSplit> optById = noteRecordSplitService.getOptById(recordSplitId);
|
|
|
|
|
if (optById.isEmpty()) {
|
|
|
|
|
log.warn("listPromptBySplitId:根据笔录片段id{}未找到切分笔录数据...", recordSplitId);
|
|
|
|
|
return notePromptList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NoteRecordSplit recordSplit = optById.get();
|
|
|
|
|
String recordType = recordSplit.getRecordType();
|
|
|
|
|
if (StrUtil.isBlank(recordType)) {
|
|
|
|
|
log.info("listPromptBySplitId:笔录片段:{} 不属于任何分类...", recordSplit.getId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取所有的分类
|
|
|
|
|
List<ModelRecordType> allTypeList = modelRecordTypeService.list();
|
|
|
|
|
Map<String, String> allTypeMap = allTypeList.stream().collect(Collectors.toMap(ModelRecordType::getRecordType, ModelRecordType::getId, (k1, k2) -> k1));
|
|
|
|
|
|
|
|
|
|
// 对切分后的笔录进行遍历
|
|
|
|
|
String[] split = recordType.split(";");
|
|
|
|
|
for (String typeName : split) {
|
|
|
|
|
String typeId = allTypeMap.get(typeName);
|
|
|
|
|
if (StrUtil.isBlank(typeId)) {
|
|
|
|
|
log.info("listPromptBySplitId:笔录片段id:{} typeName:{}未在全局分类中找到数据...", recordSplit.getId(), typeName);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 根据笔录类型找到所有的提取三元组的提示词
|
|
|
|
|
// 一个提示词可能关联多个类型,要进行拆分操作
|
|
|
|
|
List<NotePromptTypeRel> promptTypeRelList = notePromptTypeRelService.lambdaQuery().eq(NotePromptTypeRel::getTypeId, typeId).select(NotePromptTypeRel::getPromptId).list();
|
|
|
|
|
if (CollUtil.isEmpty(promptTypeRelList)) {
|
|
|
|
|
log.info("listPromptBySplitId:笔录片段:{}根据typeId:{},typeName:{},未找到对应的提示词信息...", recordSplit.getId(), typeId, typeName);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<String> promptIdList = promptTypeRelList.stream().map(NotePromptTypeRel::getPromptId).toList();
|
|
|
|
|
List<NotePrompt> list = super.lambdaQuery().in(NotePrompt::getId, promptIdList).list();
|
|
|
|
|
if (CollUtil.isEmpty(list)) {
|
|
|
|
|
log.info("listPromptBySplitId:根据 promptIdList:{},未找到对应的提示词信息...", CollUtil.join(promptIdList, ","));
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
notePromptList.addAll(list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return notePromptList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public IPage<NotePromptDTO> listPrompt(int page, int size, NotePrompt notePrompt) {
|
|
|
|
|
return notePromptMapper.selectNotePromptWithMatchNum(new Page<>(page, size), notePrompt);
|
|
|
|
|
}
|
|
|
|
|
}
|