|
@@ -0,0 +1,93 @@
|
|
|
+package com.diagbot.facade;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.diagbot.client.AiptServiceClient;
|
|
|
+import com.diagbot.client.bean.SearchData;
|
|
|
+import com.diagbot.dto.ConceptPushDTO;
|
|
|
+import com.diagbot.dto.PushDTO;
|
|
|
+import com.diagbot.dto.RespDTO;
|
|
|
+import com.diagbot.entity.QuestionInfo;
|
|
|
+import com.diagbot.enums.FeatureTypeEnum;
|
|
|
+import com.diagbot.enums.IsDeleteEnum;
|
|
|
+import com.diagbot.util.EntityUtil;
|
|
|
+import com.diagbot.util.ListUtil;
|
|
|
+import com.diagbot.util.RespDTOUtil;
|
|
|
+import com.diagbot.vo.PushVO;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.HashSet;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Description:
|
|
|
+ * @Author:zhaops
|
|
|
+ * @time: 2019/6/14 11:08
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class PushFacade {
|
|
|
+ @Autowired
|
|
|
+ AiptServiceClient aiptServiceClient;
|
|
|
+ @Autowired
|
|
|
+ AssembleFacade assembleFacade;
|
|
|
+ @Autowired
|
|
|
+ QuestionFacade questionFacade;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 推理接口
|
|
|
+ *
|
|
|
+ * @param pushVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public PushDTO push(PushVO pushVO) {
|
|
|
+ PushDTO pushDTO = new PushDTO();
|
|
|
+ SearchData searchData = assembleFacade.assembleData(pushVO);
|
|
|
+ RespDTO<PushDTO> respDTO = aiptServiceClient.pushInner(searchData);
|
|
|
+ PushDTO data = new PushDTO();
|
|
|
+ if (RespDTOUtil.respIsOK(respDTO)) {
|
|
|
+ data = respDTO.data;
|
|
|
+ }
|
|
|
+
|
|
|
+ String featureType = searchData.getFeatureType();
|
|
|
+ String[] featureTypes = featureType.split(",|,");
|
|
|
+ Set<String> featureTypeSet = new HashSet(Arrays.asList(featureTypes));
|
|
|
+
|
|
|
+ //症状
|
|
|
+ if (featureTypeSet.contains(String.valueOf(FeatureTypeEnum.Symptom.getKey()))) {
|
|
|
+ List<ConceptPushDTO> symptom = data.getSymptom();
|
|
|
+ if (ListUtil.isNotEmpty(symptom)) {
|
|
|
+ List<ConceptPushDTO> symptomDTO = addQuestionId(symptom, 1);
|
|
|
+ pushDTO.setSymptom(symptomDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return pushDTO;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 概念关联标签,添加标签id ——症状
|
|
|
+ *
|
|
|
+ * @param concepts
|
|
|
+ * @param type
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<ConceptPushDTO> addQuestionId(List<ConceptPushDTO> concepts, Integer type) {
|
|
|
+ QueryWrapper<QuestionInfo> questionInfoQueryWrapper = new QueryWrapper<>();
|
|
|
+ List<String> nameList = concepts.stream().map(concept -> concept.getName()).collect(Collectors.toList());
|
|
|
+ questionInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).in("tag_name", nameList).eq("type", type);
|
|
|
+ List<QuestionInfo> questionInfoList = questionFacade.list(questionInfoQueryWrapper);
|
|
|
+ if (ListUtil.isNotEmpty(questionInfoList)) {
|
|
|
+ Map<String, QuestionInfo> questionInfoMap = EntityUtil.makeEntityMap(questionInfoList, "tagName");
|
|
|
+ for (ConceptPushDTO concept : concepts) {
|
|
|
+ concept.setType(1);
|
|
|
+ if (questionInfoMap.containsKey(concept.getName())) {
|
|
|
+ concept.setId(questionInfoMap.get(concept.getName()).getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return concepts;
|
|
|
+ }
|
|
|
+}
|