瀏覽代碼

术语关系维护筛选接口修改

rgb 6 年之前
父節點
當前提交
09712a40d2

+ 42 - 3
knowledgeman-service/src/main/java/com/diagbot/facade/ConceptFacade.java

@@ -39,6 +39,7 @@ import com.diagbot.entity.ConceptCommon;
 import com.diagbot.entity.Lexicon;
 import com.diagbot.entity.LibraryInfo;
 import com.diagbot.entity.Medical;
+import com.diagbot.entity.Relation;
 import com.diagbot.entity.wrapper.ConceptWrapper;
 import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.enums.LexiconRSTypeEnum;
@@ -84,8 +85,8 @@ public class ConceptFacade extends ConceptServiceImpl {
     //    private LibraryDetailFacade libraryDetailFacade;
     @Autowired
     private MedicalFacade medicalFacade;
-    //    @Autowired
-    //    private RelationFacade relationFacade;
+    @Autowired
+    private RelationFacade relationFacade;
     @Autowired
     @Qualifier("libraryInfoServiceImpl")
     private LibraryInfoService libraryInfoService;
@@ -167,7 +168,45 @@ public class ConceptFacade extends ConceptServiceImpl {
      * @return
      */
     public List<GetAllForRelationDTO> getAllForRelation(GetAllForRelationVO getAllForRelationVO) {
-    	return this.baseMapper.getAllForRelation(getAllForRelationVO);
+    	List<GetAllForRelationDTO> retList = new ArrayList<>();
+    	
+    	QueryWrapper<Concept> conceptQe = new QueryWrapper<>();
+    	conceptQe.eq("is_deleted", "N");
+    	conceptQe.like(StringUtil.isNotEmpty(getAllForRelationVO.getName()),"lib_name", getAllForRelationVO.getName());
+    	conceptQe.eq(getAllForRelationVO.getTypeId()!=null,"lib_type", getAllForRelationVO.getTypeId());
+    	List<Concept> conceptList = list(conceptQe);
+    	
+    	Map<Long,Long> reCouMap = new HashMap<>();
+    	if(getAllForRelationVO.getRelationPosition()!=3){
+    		if(getAllForRelationVO.getRelationId()==null){
+    			throw new CommonException(CommonErrorCode.RPC_ERROR, "关系类型id必传!");
+    		}
+    		
+    		List<Long> conceptIdList = conceptList.stream().map(i->i.getId()).collect(Collectors.toList());
+    		QueryWrapper<Relation> relationQe = new QueryWrapper<>();
+    		relationQe.eq("relation_id", getAllForRelationVO.getRelationId());
+    		if(getAllForRelationVO.getRelationPosition()==1){
+    			relationQe.in("start_id", conceptIdList);
+    			relationQe.eq(getAllForRelationVO.getRelationConceptId()!=null,"end_id", getAllForRelationVO.getRelationConceptId());
+    			reCouMap = relationFacade.list(relationQe).stream().collect(Collectors.groupingBy(Relation::getStartId,Collectors.counting()));
+    		}else{
+    			relationQe.in("end_id", conceptIdList);
+    			relationQe.eq(getAllForRelationVO.getRelationConceptId()!=null,"start_id", getAllForRelationVO.getRelationConceptId());
+    			reCouMap = relationFacade.list(relationQe).stream().collect(Collectors.groupingBy(Relation::getEndId,Collectors.counting()));
+    		}
+    	}
+    	
+    	for(Concept i : conceptList){
+    		if(reCouMap.get(i.getId())!=null){
+    			continue;
+    		}
+    		GetAllForRelationDTO getAllForRelationDTO = new GetAllForRelationDTO();
+    		getAllForRelationDTO.setConceptId(i.getId());
+    		getAllForRelationDTO.setConceptName(i.getLibName());
+    		retList.add(getAllForRelationDTO);
+    	}
+    	
+    	return retList;
     }
 
     /**

+ 0 - 8
knowledgeman-service/src/main/java/com/diagbot/mapper/ConceptMapper.java

@@ -6,11 +6,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.diagbot.dto.ConceptBaseDTO;
 import com.diagbot.dto.ConceptRes;
 import com.diagbot.dto.ConceptWithOrderRes;
-import com.diagbot.dto.GetAllForRelationDTO;
 import com.diagbot.dto.GetAllLisConceptDTO;
 import com.diagbot.entity.Concept;
 import com.diagbot.entity.wrapper.ConceptWrapper;
-import com.diagbot.vo.GetAllForRelationVO;
 import com.diagbot.vo.GetAllLisConceptVO;
 import com.diagbot.vo.IndexVO;
 
@@ -58,10 +56,4 @@ public interface ConceptMapper extends BaseMapper<Concept> {
      */
     List<ConceptBaseDTO> index(IndexVO indexVO);
     
-    /**
-     * 获取所有概念(术语关系维护时筛选使用)
-     * @param getAllForRelationVO
-     * @return
-     */
-    List<GetAllForRelationDTO> getAllForRelation(GetAllForRelationVO getAllForRelationVO);
 }

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

@@ -1,7 +1,5 @@
 package com.diagbot.vo;
 
-import javax.validation.constraints.NotNull;
-
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Getter;
 import lombok.Setter;
@@ -27,27 +25,22 @@ public class GetAllForRelationVO {
     @ApiModelProperty(value="词性id")
     private Long typeId;
     
+    /**
+     * 搜索出来的概念在关系中的位置,1-起点术语,2-终点术语,3-不考虑关系
+     */
+    @ApiModelProperty(value="搜索出来的概念在关系中的位置,1-起点术语,2-终点术语,3-不考虑关系")
+    private Integer relationPosition=3;
+
     /**
      * 相关联的概念id
      */
     @ApiModelProperty(value="相关联的概念id")
-    @NotNull(message="相关联的概念id必传")
-    private Long conceptId;
+    private Long relationConceptId;
     
     /**
      * 关系类型id
      */
     @ApiModelProperty(value="关系类型id")
-    @NotNull(message="关系类型id必传")
     private Long relationId;
     
-    
-    /**
-     * 是否起始术语,1-是,0-否
-     */
-    @ApiModelProperty(value="是否起始术语,1-是,0-否")
-    @NotNull(message="是否起始术语必传")
-    private Integer isStart;
-
-    
 }

+ 0 - 28
knowledgeman-service/src/main/resources/mapper/ConceptMapper.xml

@@ -60,34 +60,6 @@
 		</if>
     </select>
     
-    <select id="getAllForRelation" parameterType="com.diagbot.vo.GetAllForRelationVO" resultType="com.diagbot.dto.GetAllForRelationDTO">
-    	SELECT
-		t1.*
-		FROM
-		(SELECT
-		id AS conceptId,
-		lib_name AS conceptName
-		FROM kl_concept
-		WHERE is_deleted='N' 
-		<if test="name!=null and name!=''">
-			AND lib_name LIKE CONCAT('%',#{name},'%')
-		</if>
-		<if test="typeId!=null">
-			AND lib_type=typeId
-		</if>
-		) t1 
-		LEFT JOIN kl_relation t2
-		<if test="isStart==1">
-			ON t1.conceptId=t2.start_id
-		</if>
-		<if test="isStart==0">
-			ON t1.conceptId=t2.end_id
-		</if>
-		WHERE 1=1 
-		AND t2.relation_id=#{relationId}
-		AND t2.id IS NULL
-    </select>
-
 	<select id="getConcept" resultType="com.diagbot.dto.ConceptRes" parameterType="com.diagbot.entity.wrapper.ConceptWrapper">
 		SELECT
 		t1.id AS startId,