You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
130 lines
5.5 KiB
Java
130 lines
5.5 KiB
Java
package com.supervision.service.impl;
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.supervision.dto.QaKnowledgeDTO;
|
|
import com.supervision.mapper.AskTemplateQuestionLibraryMapper;
|
|
import com.supervision.model.AskTemplateQuestionLibrary;
|
|
import com.supervision.model.ConfigAncillaryItem;
|
|
import com.supervision.model.ConfigPhysicalTool;
|
|
import com.supervision.service.AskTemplateQuestionLibraryService;
|
|
import com.supervision.service.ConfigAncillaryItemService;
|
|
import com.supervision.service.ConfigPhysicalToolService;
|
|
import com.supervision.vo.manage.AskQuestionLibraryReqVo;
|
|
import com.supervision.vo.manage.AskQuestionLibraryResVo;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
|
|
/**
|
|
* @author flevance
|
|
* @description 针对表【vp_ask_template_question_library(诊断问询意图问题库)】的数据库操作Service实现
|
|
* @createDate 2023-11-03 11:13:26
|
|
*/
|
|
@Slf4j
|
|
@Service
|
|
@RequiredArgsConstructor
|
|
public class AskTemplateQuestionLibraryServiceImpl extends ServiceImpl<AskTemplateQuestionLibraryMapper, AskTemplateQuestionLibrary>
|
|
implements AskTemplateQuestionLibraryService {
|
|
|
|
private final ConfigPhysicalToolService configPhysicalToolService;
|
|
|
|
private final ConfigAncillaryItemService configAncillaryItemService;
|
|
|
|
@Override
|
|
public List<AskQuestionLibraryResVo> queryList(AskQuestionLibraryReqVo askQuestionLibraryReqVo) {
|
|
|
|
return super.getBaseMapper().queryList(askQuestionLibraryReqVo);
|
|
}
|
|
|
|
@Override
|
|
public Page<AskQuestionLibraryResVo> queryPageList(Integer pageNum, Integer pageSize,
|
|
AskQuestionLibraryReqVo askQuestionLibraryReqVo) {
|
|
|
|
return super.getBaseMapper().queryPageList(new Page<>(pageNum,pageSize),askQuestionLibraryReqVo);
|
|
}
|
|
|
|
@Override
|
|
public String getMaxCode() {
|
|
AskTemplateQuestionLibrary askTemplateQuestionLibrary = super.getBaseMapper()
|
|
.selectOne(new QueryWrapper<AskTemplateQuestionLibrary>().select("max(code) as code"));
|
|
if (Objects.isNull(askTemplateQuestionLibrary)){
|
|
return null;
|
|
}
|
|
return askTemplateQuestionLibrary.getCode();
|
|
}
|
|
|
|
@Override
|
|
public String getMaxDefaultAnswerCode() {
|
|
AskTemplateQuestionLibrary askTemplateQuestionLibrary = super.getBaseMapper()
|
|
.selectOne(new QueryWrapper<AskTemplateQuestionLibrary>()
|
|
.select("max(default_answer_code) as default_answer_code"));
|
|
if (Objects.isNull(askTemplateQuestionLibrary)) {
|
|
return null;
|
|
}
|
|
return askTemplateQuestionLibrary.getDefaultAnswerCode();
|
|
}
|
|
|
|
@Override
|
|
public List<QaKnowledgeDTO> queryQaKnowledge() {
|
|
// 查询所有的问题,忽略错误和静默视频
|
|
List<AskTemplateQuestionLibrary> libraryList = this.lambdaQuery()
|
|
.ne(AskTemplateQuestionLibrary::getDictId, 180).ne(AskTemplateQuestionLibrary::getDictId, 182).list();
|
|
List<QaKnowledgeDTO> knowledgeList = new ArrayList<>();
|
|
|
|
for (AskTemplateQuestionLibrary library : libraryList) {
|
|
QaKnowledgeDTO qaKnowledgeDTO = new QaKnowledgeDTO();
|
|
qaKnowledgeDTO.setQuestionCode(library.getId());
|
|
qaKnowledgeDTO.setQuestionList(library.getQuestion());
|
|
knowledgeList.add(qaKnowledgeDTO);
|
|
}
|
|
|
|
// 这里处理呼出体格检查的问题
|
|
List<ConfigPhysicalTool> physicalToolList = configPhysicalToolService.lambdaQuery()
|
|
.isNotNull(ConfigPhysicalTool::getCode)
|
|
.isNotNull(ConfigPhysicalTool::getCallOutQuestion).list();
|
|
|
|
for (ConfigPhysicalTool tool : physicalToolList) {
|
|
if (CollUtil.isEmpty(tool.getCallOutQuestion())) {
|
|
log.warn("getIntentCodeAndIdMap: toolId:{},toolName:{},tool.getCallOutQuestion() is empty", tool.getId(), tool.getToolName());
|
|
continue;
|
|
}
|
|
// 把呼出的问题全部加进去
|
|
String toolIntent = "tool_" + tool.getId();
|
|
QaKnowledgeDTO qaKnowledgeDTO = new QaKnowledgeDTO();
|
|
qaKnowledgeDTO.setQuestionCode(toolIntent);
|
|
qaKnowledgeDTO.setQuestionList(tool.getCallOutQuestion());
|
|
knowledgeList.add(qaKnowledgeDTO);
|
|
}
|
|
|
|
// 生成呼出的辅助检查的问题
|
|
List<ConfigAncillaryItem> ancillaryItemList = configAncillaryItemService.lambdaQuery()
|
|
.isNotNull(ConfigAncillaryItem::getCode)
|
|
.isNotNull(ConfigAncillaryItem::getCallOutQuestion).list();
|
|
|
|
for (ConfigAncillaryItem ancillary : ancillaryItemList) {
|
|
if (CollUtil.isEmpty(ancillary.getCallOutQuestion())) {
|
|
log.warn("getIntentCodeAndIdMap: ancillaryId:{},itemName:{},ancillary.getCallOutQuestion() is empty", ancillary.getId(), ancillary.getItemName());
|
|
continue;
|
|
}
|
|
// 把辅助问诊的问题全部加进去
|
|
String ancillaryIntent = "ancillary_" + ancillary.getId();
|
|
QaKnowledgeDTO qaKnowledgeDTO = new QaKnowledgeDTO();
|
|
qaKnowledgeDTO.setQuestionCode(ancillaryIntent);
|
|
qaKnowledgeDTO.setQuestionList(ancillary.getCallOutQuestion());
|
|
knowledgeList.add(qaKnowledgeDTO);
|
|
}
|
|
return knowledgeList;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|