|
@@ -0,0 +1,111 @@
|
|
|
+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.enums.QuestionTypeEnum;
|
|
|
+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;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Iterator;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Description:
|
|
|
+ * @author: wangyu
|
|
|
+ * @time: 2018/11/27 14:54
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class RetrievalFacade {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ QuestionFacade questionFacade;
|
|
|
+ @Autowired
|
|
|
+ AiptServiceClient aiptServiceClient;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取标签信息
|
|
|
+ *
|
|
|
+ * @param retrievalVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<RetrievalDTO> getTagInfos(RetrievalVO retrievalVO) {
|
|
|
+ retrievalVO.setType(QuestionTypeEnum.Symptom.getKey());
|
|
|
+ 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())
|
|
|
+ && conceptRetrievalDTO.getSelfName() != null) {
|
|
|
+ questionNames.add(conceptRetrievalDTO.getSelfName());
|
|
|
+ }
|
|
|
+ if (!questionNames.contains(conceptRetrievalDTO.getParentName())
|
|
|
+ && conceptRetrievalDTO.getParentName() != null) {
|
|
|
+ questionNames.add(conceptRetrievalDTO.getParentName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ QueryWrapper<QuestionInfo> questionInfoQueryWrapper = new QueryWrapper<>();
|
|
|
+ questionInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .in("tag_name", questionNames)
|
|
|
+ .eq("type", retrievalVO.getType())
|
|
|
+ .ne("tag_type", 8)
|
|
|
+ .eq("item_type", 0);
|
|
|
+ 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
|
|
|
+ if(null != questionInfoMap.get(conceptRetrievalDTO.getParentName())){//如果匹配到就添加questionId
|
|
|
+ retrievalDTO.setQuestionId(questionInfoMap.get(conceptRetrievalDTO.getParentName()).getId());
|
|
|
+ }
|
|
|
+ retrievalDTO.setConceptId(conceptRetrievalDTO.getParentId());
|
|
|
+ retrievalDTO.setName(conceptRetrievalDTO.getParentName());
|
|
|
+ retrievalDTO.setRetrievalName(conceptRetrievalDTO.getSelfName());
|
|
|
+ } else {//parent为空时说明没有子项返回本体id
|
|
|
+ if(null != questionInfoMap.get(conceptRetrievalDTO.getSelfName())){//如果匹配到就添加questionId
|
|
|
+ retrievalDTO.setQuestionId(questionInfoMap.get(conceptRetrievalDTO.getSelfName()).getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotEmpty(conceptRetrievalDTO.getSameName())) {//同义词
|
|
|
+ retrievalDTO.setRetrievalName(conceptRetrievalDTO.getSameName());
|
|
|
+ }
|
|
|
+ retrievalDTO.setLibTypeId(conceptRetrievalDTO.getLibTypeId());
|
|
|
+ retrievalDTO.setLibTypeName(conceptRetrievalDTO.getLibTypeName());
|
|
|
+ retrievalDTO.setType(conceptRetrievalDTO.getType());
|
|
|
+ retrievalDTO.setShowType(conceptRetrievalDTO.getShowType());
|
|
|
+ retrievalDTOS.add(retrievalDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //如何没有匹配到questionId就移除
|
|
|
+ Iterator<RetrievalDTO> retrievalDTOIterator = retrievalDTOS.iterator();
|
|
|
+ while (retrievalDTOIterator.hasNext()){
|
|
|
+ RetrievalDTO retrievalDTO = new RetrievalDTO();
|
|
|
+ retrievalDTO = retrievalDTOIterator.next();
|
|
|
+ if(retrievalDTO.getQuestionId() == null
|
|
|
+ && retrievalDTO.getType().intValue() != QuestionTypeEnum.Pacs.getKey()
|
|
|
+ && retrievalDTO.getType().intValue() != QuestionTypeEnum.Disease.getKey()){
|
|
|
+ retrievalDTOIterator.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return retrievalDTOS;
|
|
|
+ }
|
|
|
+}
|