Procházet zdrojové kódy

关系维护术语检索修改

rengb před 5 roky
rodič
revize
e69c9d684c

+ 32 - 9
knowledgeman-service/src/main/java/com/diagbot/facade/ConceptFacade.java

@@ -22,7 +22,6 @@ import com.diagbot.entity.Lexicon;
 import com.diagbot.entity.LibraryInfo;
 import com.diagbot.entity.QuestionInfo;
 import com.diagbot.entity.Relation;
-import com.diagbot.entity.ScaleContent;
 import com.diagbot.entity.wrapper.ConceptWrapper;
 import com.diagbot.enums.DiseaseClassifyEnum;
 import com.diagbot.enums.IsDeleteEnum;
@@ -63,6 +62,7 @@ import com.diagbot.vo.IndexVO;
 import com.diagbot.vo.KLQuestionVO;
 import com.diagbot.vo.RemoveConceptInfoVO;
 import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
 import org.apache.commons.lang.time.DateFormatUtils;
 import org.apache.poi.hssf.usermodel.HSSFDateUtil;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
@@ -240,7 +240,7 @@ public class ConceptFacade extends ConceptServiceImpl {
             List<Concept> conceptList = list(conceptQe);
 
             if (ListUtil.isNotEmpty(conceptList)) {
-                Map<Long, Long> reCouMap = new HashMap<>();
+                Map<Long, Long> reCouMap = Maps.newHashMap();
                 if (getAllForRelationVO.getRelationPosition() != 3) {
                     if (getAllForRelationVO.getRelationId() == null) {
                         throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "关系类型id必传!");
@@ -264,18 +264,40 @@ public class ConceptFacade extends ConceptServiceImpl {
                     if (ListUtil.isNotEmpty(relationConceptIdList)) {
                         if (getAllForRelationVO.getRelationPosition() == 1) {
                             relationQe.in("start_id", conceptIdList);
-                            relationQe.in(ListUtil.isNotEmpty(relationConceptIdList), "end_id", relationConceptIdList);
+                            relationQe.in("end_id", relationConceptIdList);
                             reCouMap = relationFacade.list(relationQe)
                                     .stream()
                                     .collect(Collectors.groupingBy(Relation::getStartId, Collectors.counting()));
-                        } else {
+                        } else if (getAllForRelationVO.getRelationPosition() == 2) {
                             relationQe.in("end_id", conceptIdList);
-                            relationQe.in(ListUtil.isNotEmpty(relationConceptIdList), "start_id", relationConceptIdList);
+                            relationQe.in("start_id", relationConceptIdList);
                             reCouMap = relationFacade.list(relationQe)
                                     .stream()
                                     .collect(Collectors.groupingBy(Relation::getEndId, Collectors.counting()));
                         }
                     }
+
+                    if (getAllForRelationVO.getRelationPosition() == 0) {
+                        List<Long> relationConceptIdList_ = relationConceptIdList;
+                        relationQe.and(
+                                qwall -> qwall
+                                        .and(qw1 -> qw1
+                                                .in("start_id", conceptIdList)
+                                                .in(ListUtil.isNotEmpty(relationConceptIdList_), "end_id", relationConceptIdList_))
+                                        .or(qw2 -> qw2
+                                                .in("end_id", conceptIdList)
+                                                .in(ListUtil.isNotEmpty(relationConceptIdList_), "start_id", relationConceptIdList_))
+                        );
+
+                        List<Relation> relationList = relationFacade.list(relationQe);
+                        reCouMap.putAll(relationList
+                                .stream()
+                                .collect(Collectors.groupingBy(Relation::getStartId, Collectors.counting())));
+
+                        reCouMap.putAll(relationList
+                                .stream()
+                                .collect(Collectors.groupingBy(Relation::getEndId, Collectors.counting())));
+                    }
                 }
 
                 for (Concept i : conceptList) {
@@ -382,7 +404,7 @@ public class ConceptFacade extends ConceptServiceImpl {
     public Boolean removeConceptInfo(RemoveConceptInfoVO removeConceptInfoVO) {
 
         //清理缓存
-        if(removeConceptInfoVO.getConceptId()!=null) {
+        if (removeConceptInfoVO.getConceptId() != null) {
             this.cacheClearByConceptId(removeConceptInfoVO.getConceptId());
         }
 
@@ -520,7 +542,7 @@ public class ConceptFacade extends ConceptServiceImpl {
      */
     public Boolean addConceptInfo(AddConceptInfoVO addConceptInfoVO) {
         //清理原名称对应标签缓存
-        if(addConceptInfoVO.getConceptId()!=null) {
+        if (addConceptInfoVO.getConceptId() != null) {
             this.cacheClearByConceptId(addConceptInfoVO.getConceptId());
         }
 
@@ -1119,7 +1141,7 @@ public class ConceptFacade extends ConceptServiceImpl {
         //删除标签缓存
         List<Long> saveConceptIds = saveOrUpdateConceptList.stream()
                 .map(i -> i.getId()).filter(j -> j != null).distinct().collect(Collectors.toList());
-        if(ListUtil.isNotEmpty(saveConceptIds)) {
+        if (ListUtil.isNotEmpty(saveConceptIds)) {
             this.cacheClearByConceptIds(saveConceptIds);
         }
         conceptService.saveOrUpdateBatch(saveOrUpdateConceptList);
@@ -1224,9 +1246,10 @@ public class ConceptFacade extends ConceptServiceImpl {
 
     /**
      * 知识库标准化-获取医学数据统计
+     *
      * @return
      */
-    public List<BIItemDTO> queryLibTypeCou(){
+    public List<BIItemDTO> queryLibTypeCou() {
         return this.baseMapper.queryLibTypeCou();
     }
 

+ 1 - 1
knowledgeman-service/src/main/java/com/diagbot/vo/GetAllForRelationVO.java

@@ -30,7 +30,7 @@ public class GetAllForRelationVO {
     /**
      * 搜索出来的概念在关系中的位置,1-起点术语,2-终点术语,3-不考虑关系
      */
-    @ApiModelProperty(value="搜索出来的概念在关系中的位置,1-起点术语,2-终点术语,3-不考虑关系")
+    @ApiModelProperty(value="搜索出来的概念在关系中的位置,0-既是起点术语又是终点术语,1-起点术语,2-终点术语,3-不考虑关系")
     private Integer relationPosition=3;
 
     /**