|
@@ -1,9 +1,16 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.diagbot.client.AiptServiceClient;
|
|
|
+import com.diagbot.dto.ConceptRetrievalDTO;
|
|
|
+import com.diagbot.dto.RespDTO;
|
|
|
import com.diagbot.dto.RetrievalDTO;
|
|
|
import com.diagbot.entity.QuestionInfo;
|
|
|
+import com.diagbot.enums.IsDeleteEnum;
|
|
|
import com.diagbot.service.impl.RetrievalServiceImpl;
|
|
|
import com.diagbot.util.ListUtil;
|
|
|
+import com.diagbot.util.RespDTOUtil;
|
|
|
+import com.diagbot.util.StringUtil;
|
|
|
import com.diagbot.vo.RetrievalVO;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
@@ -25,6 +32,8 @@ public class RetrievalFacade extends RetrievalServiceImpl {
|
|
|
|
|
|
@Autowired
|
|
|
QuestionFacade questionFacade;
|
|
|
+ @Autowired
|
|
|
+ AiptServiceClient aiptServiceClient;
|
|
|
|
|
|
/**
|
|
|
* 获取标签信息
|
|
@@ -33,46 +42,48 @@ public class RetrievalFacade extends RetrievalServiceImpl {
|
|
|
* @return
|
|
|
*/
|
|
|
public List<RetrievalDTO> getTagInfos(@Valid @RequestBody RetrievalVO retrievalVO) {
|
|
|
- if (retrievalVO.getInputStr() == null || retrievalVO.getInputStr() == "") {
|
|
|
- retrievalVO.setInputStr(" ");
|
|
|
- }
|
|
|
- //过滤传来的空值
|
|
|
- if(ListUtil.isNotEmpty(retrievalVO.getInputIds())){
|
|
|
- List<Long> questionIds = new ArrayList<>();
|
|
|
- for (Long questionId:retrievalVO.getInputIds()) {
|
|
|
- if (null != questionId){
|
|
|
- questionIds.add(questionId);
|
|
|
+ List<RetrievalDTO> retrievalDTOS = new ArrayList<>();
|
|
|
+ //调用aipt-服务
|
|
|
+ RespDTO<List<ConceptRetrievalDTO>> conceptInfos = aiptServiceClient.retrivelConceptInfo(retrievalVO);
|
|
|
+ RespDTOUtil.respNGDeal(conceptInfos,"获取检索信息失败");
|
|
|
+ //获取questionId
|
|
|
+ List<String> questionNames = new ArrayList<>();
|
|
|
+ if(ListUtil.isNotEmpty(conceptInfos.data)){
|
|
|
+ for (ConceptRetrievalDTO conceptRetrievalDTO: conceptInfos.data) {
|
|
|
+ if(!questionNames.contains(conceptRetrievalDTO.getSameName())){
|
|
|
+ questionNames.add(conceptRetrievalDTO.getSelfName());
|
|
|
+ }
|
|
|
+ if(!questionNames.contains(conceptRetrievalDTO.getParentName())){
|
|
|
+ questionNames.add(conceptRetrievalDTO.getParentName());
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- retrievalVO.setInputIds(questionIds);
|
|
|
- }
|
|
|
- //获取同义词标签信息
|
|
|
- List<RetrievalDTO> data = this.getSymptopInfo(retrievalVO);
|
|
|
- List<Long> selfIds = new ArrayList<>();
|
|
|
- for (RetrievalDTO bean : data) {//筛选本身的id
|
|
|
- if ((1 == bean.getShowType())
|
|
|
- && !selfIds.contains(bean.getQuestionId())) {
|
|
|
- selfIds.add(bean.getQuestionId());
|
|
|
- }
|
|
|
- }
|
|
|
- List<RetrievalDTO> resultSubitemData = new ArrayList<>();
|
|
|
- for (RetrievalDTO bean : data) {//当出现本体和同义词时,不显示同义词
|
|
|
- if (1 == bean.getShowType()) {
|
|
|
- resultSubitemData.add(bean);
|
|
|
- } else {
|
|
|
- if (!selfIds.contains(bean.getQuestionId())) {
|
|
|
- resultSubitemData.add(bean);
|
|
|
+ QueryWrapper<QuestionInfo> questionInfoQueryWrapper = new QueryWrapper<>();
|
|
|
+ questionInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .in("tag_name",questionNames)
|
|
|
+ .eq("type",retrievalVO.getType());
|
|
|
+ List<QuestionInfo> questionInfoList = questionFacade.list(questionInfoQueryWrapper);
|
|
|
+ Map<String,QuestionInfo> questionInfoMap = questionInfoList.stream().collect(Collectors.toMap(QuestionInfo::getTagName,questionInfo -> questionInfo));
|
|
|
+ RetrievalDTO retrievalDTO = new RetrievalDTO();
|
|
|
+ //封装
|
|
|
+ for (ConceptRetrievalDTO conceptRetrievalDTO: conceptInfos.data) {
|
|
|
+ retrievalDTO = new RetrievalDTO();
|
|
|
+ retrievalDTO.setConceptId(conceptRetrievalDTO.getSelfId());
|
|
|
+ retrievalDTO.setName(conceptRetrievalDTO.getSelfName());
|
|
|
+ if(StringUtil.isNotEmpty(conceptRetrievalDTO.getParentName())){//parent不为空时说明有子项,返回父级id
|
|
|
+ retrievalDTO.setQuestionId(questionInfoMap.get(conceptRetrievalDTO.getParentName()).getId());
|
|
|
+ }else {//parent为空时说明没有子项返回本体id
|
|
|
+ retrievalDTO.setQuestionId(questionInfoMap.get(conceptRetrievalDTO.getSelfName()).getId());
|
|
|
+ }
|
|
|
+ if(StringUtil.isNotEmpty(conceptRetrievalDTO.getSameName())){//同义词
|
|
|
+ retrievalDTO.setRetrievalName(conceptRetrievalDTO.getSameName());
|
|
|
}
|
|
|
+ if(StringUtil.isNotEmpty(conceptRetrievalDTO.getParentName())){//子项
|
|
|
+ retrievalDTO.setRetrievalName(conceptRetrievalDTO.getParentName());
|
|
|
+ }
|
|
|
+ retrievalDTO.setShowType(conceptRetrievalDTO.getShowType());
|
|
|
+ retrievalDTOS.add(retrievalDTO);
|
|
|
}
|
|
|
}
|
|
|
- List<Long> questionIdList = resultSubitemData.stream()
|
|
|
- .map(r -> r.getQuestionId())
|
|
|
- .collect(Collectors.toList());
|
|
|
- //将标签名放入实体
|
|
|
- Map<Long, QuestionInfo> map = questionFacade.getQuestionInfos(questionIdList);
|
|
|
- for (RetrievalDTO retrievalDTO : resultSubitemData) {
|
|
|
- retrievalDTO.setName(map.get(retrievalDTO.getQuestionId()).getTagName());
|
|
|
- }
|
|
|
- return resultSubitemData;
|
|
|
+ return retrievalDTOS;
|
|
|
}
|
|
|
}
|