浏览代码

树形结构接口

kongwz 4 年之前
父节点
当前提交
2e6624b5b6

+ 36 - 0
cdssman-service/src/main/java/com/diagbot/dto/GetAllForRelationDTO.java

@@ -0,0 +1,36 @@
+package com.diagbot.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description
+ * @author kongwz
+ * @time 2018年12月5日下午5:00:34
+ */
+@Getter
+@Setter
+public class GetAllForRelationDTO {
+	
+	/**
+	 * 概念id
+	 */
+	@ApiModelProperty(value="概念id")
+	private Long conceptId;
+	
+	/**
+	 * 概念名称
+	 */
+	@ApiModelProperty(value="概念名称")
+	private String conceptName;
+	
+	/**
+	 * 概念名称(类型)
+	 */
+	@ApiModelProperty(value="概念名称(类型)")
+	private String conceptNameType;
+	
+	
+
+}

+ 58 - 0
cdssman-service/src/main/java/com/diagbot/facade/KlConceptFacade.java

@@ -3,11 +3,16 @@ package com.diagbot.facade;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.diagbot.dto.GetAllForRelationDTO;
 import com.diagbot.dto.KlConceptAllDTO;
 import com.diagbot.dto.KlConceptInfoDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.entity.KlConcept;
+import com.diagbot.entity.KlRelation;
 import com.diagbot.enums.IsDeleteEnum;
+import com.diagbot.enums.LexiconEnum;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
 import com.diagbot.service.KlConceptService;
 import com.diagbot.service.impl.KlConceptServiceImpl;
 import com.diagbot.util.BeanUtil;
@@ -15,11 +20,15 @@ import com.diagbot.util.CryptUtil;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.RespDTOUtil;
 import com.diagbot.util.StringUtil;
+import com.diagbot.vo.GetAllForRelationVO;
 import com.diagbot.vo.KlConceptAllVO;
 import com.diagbot.vo.KlConceptInfoVO;
 import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import javax.management.relation.Relation;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -49,4 +58,53 @@ public class KlConceptFacade extends KlConceptServiceImpl {
     public List<KlConceptAllDTO> getConceptAlls(KlConceptAllVO klConceptAllVO) {
         return  getConceptAll(klConceptAllVO);
     }
+
+    /**
+     * 获取所有概念(术语关系维护时筛选使用)
+     *
+     * @param getAllForRelationVO
+     * @return
+     */
+    public List<GetAllForRelationDTO> getAllForRelation(GetAllForRelationVO getAllForRelationVO) {
+        List<GetAllForRelationDTO> retList = Lists.newArrayList();
+
+        if (StringUtil.isNotBlank(getAllForRelationVO.getName())
+                || getAllForRelationVO.getTypeId() != null) {
+            List<KlConcept> conceptList = this.list(new QueryWrapper<KlConcept>()
+                    .eq("is_deleted", IsDeleteEnum.N.getKey())
+                    .like(StringUtil.isNotBlank(getAllForRelationVO.getName()), "lib_name", getAllForRelationVO.getName().trim())
+                    .eq(getAllForRelationVO.getTypeId() != null, "lib_type", getAllForRelationVO.getTypeId())
+                    .notIn(ListUtil.isNotEmpty(getAllForRelationVO.getExcludedConceptIds()), "id", getAllForRelationVO.getExcludedConceptIds())
+            );
+//            retList = BeanUtil.listCopyTo(conceptList, GetAllForRelationDTO.class);
+            if(ListUtil.isNotEmpty(conceptList)){
+                retList = conceptList.stream().map(x ->{
+                    GetAllForRelationDTO getAllForRelationDTO = new GetAllForRelationDTO();
+                    getAllForRelationDTO.setConceptId(x.getId());
+                    getAllForRelationDTO.setConceptName(x.getLibName());
+                    getAllForRelationDTO.setConceptNameType(String.valueOf(x.getLibType()));
+                    return getAllForRelationDTO;
+                }).collect(Collectors.toList());
+            }
+
+        }
+        return retList;
+    }
+
+    /**
+     * 筛选符合类型的概念id
+     *
+     * @param libTypeId
+     * @param sourceConceptIds
+     * @return
+     */
+    public List<Long> getCompatibleTypeConceptIds(Long libTypeId, List<Long> sourceConceptIds) {
+        if (libTypeId == null || ListUtil.isEmpty(sourceConceptIds)) {
+            return null;
+        }
+        QueryWrapper<KlConcept> conceptQe = new QueryWrapper<>();
+        conceptQe.in("id", sourceConceptIds);
+        conceptQe.eq("lib_type", libTypeId);
+        return list(conceptQe).stream().map(i -> i.getId()).collect(Collectors.toList());
+    }
 }

+ 14 - 0
cdssman-service/src/main/java/com/diagbot/facade/KlRelationOrderFacade.java

@@ -0,0 +1,14 @@
+package com.diagbot.facade;
+
+import com.diagbot.service.impl.KlRelationOrderServiceImpl;
+import org.springframework.stereotype.Component;
+
+/**
+ * 术语顺序业务层
+ * @author kwz
+ * @date 2021/3/4
+ * @time 16:59
+ */
+@Component
+public class KlRelationOrderFacade extends KlRelationOrderServiceImpl {
+}

+ 260 - 0
cdssman-service/src/main/java/com/diagbot/facade/RelationContactFacade.java

@@ -0,0 +1,260 @@
+package com.diagbot.facade;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.diagbot.dto.RelationNodeDTO;
+import com.diagbot.entity.KlConcept;
+import com.diagbot.entity.KlRelation;
+import com.diagbot.entity.KlRelationOrder;
+import com.diagbot.enums.IsDeleteEnum;
+import com.diagbot.enums.LexiconEnum;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
+import com.diagbot.service.KlRelationService;
+import com.diagbot.service.impl.KlRelationOrderServiceImpl;
+import com.diagbot.service.impl.KlRelationServiceImpl;
+import com.diagbot.util.CryptUtil;
+import com.diagbot.util.DateUtil;
+import com.diagbot.util.ListUtil;
+import com.diagbot.util.UserUtils;
+import com.diagbot.vo.KlRelationNodeVO;
+import com.diagbot.vo.RelationContactDetailVO;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Component;
+
+import javax.management.relation.Relation;
+import javax.management.relation.RelationService;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * @author kwz
+ * @date 2021/3/3
+ * @time 15:42
+ */
+@Component
+public class RelationContactFacade extends KlRelationServiceImpl {
+    @Autowired
+    private KlConceptFacade klConceptFacade;
+    @Autowired
+    private KlRelationOrderFacade klRelationOrderFacade;
+    @Autowired
+    @Qualifier("klRelationServiceImpl")
+    private KlRelationService klRelationService;
+    @Autowired
+    @Qualifier("klRelationOrderServiceImpl")
+    private KlRelationOrderServiceImpl klRelationOrderServiceImpl;
+
+    public RelationNodeDTO relationContactDetail(RelationContactDetailVO relationContactDetailVO) {
+        RelationNodeDTO relationNodeDTO = new RelationNodeDTO();
+
+        KlConcept klConcept = klConceptFacade.getById(relationContactDetailVO.getConceptId());
+        relationNodeDTO.setConceptId(klConcept.getId());
+        relationNodeDTO.setConceptName(klConcept.getLibName());
+        relationNodeDTO.setIsDeletedConcept(klConcept.getIsDeleted());
+        relationNodeDTO.setConceptTypeId(new Long(klConcept.getLibType()));
+
+        relationNodeDTO.setNodeList(repairRelationDataForQuery(relationContactDetailVO.getConceptId(),
+                relationContactDetailVO.getRelationIds(), relationContactDetailVO.getTypeIds(),
+                null, klConcept.getIsDeleted()));
+
+        return relationNodeDTO;
+    }
+
+    /**
+     * 处理关系节点-查询事件
+     *
+     * @param conceptId
+     * @param relationIds
+     * @param typeIds
+     * @param hookConceptIds
+     * @param isDeletedParent
+     * @return
+     */
+    private List<RelationNodeDTO> repairRelationDataForQuery(Long conceptId, List<Long> relationIds,
+                                                             List<Long> typeIds, List<Long> hookConceptIds,
+                                                             String isDeletedParent) {
+        if (hookConceptIds == null) {
+            hookConceptIds = new ArrayList<>();
+            hookConceptIds.add(conceptId);
+        }
+
+        Long relationId = null, endTypeId = null;
+        if (ListUtil.isNotEmpty(relationIds)) {
+            relationId = relationIds.remove(0);
+        }
+        if (relationId == null) {
+            relationId = -999999l;
+        }
+        if (ListUtil.isNotEmpty(typeIds)) {
+            endTypeId = typeIds.remove(0);
+        }
+        List<RelationNodeDTO> relationNodeDTOList = this.baseMapper.getRelationNodeDTOs(conceptId, relationId, endTypeId);
+
+        for (RelationNodeDTO i : relationNodeDTOList) {
+            i.setConceptName(i.getConceptName());
+            i.setParentConceptName(i.getParentConceptName());
+            i.setConceptTypeName(LexiconEnum.getName(i.getConceptTypeId().intValue()));
+            i.setConceptNameType(i.getConceptName() + "(" + LexiconEnum.getName(i.getConceptTypeId().intValue()) + ")");
+            i.setParentConceptTypeName(LexiconEnum.getName(i.getParentConceptTypeId().intValue()));
+            i.setParentConceptNameType(i.getParentConceptName() + "("
+                    + LexiconEnum.getName(i.getParentConceptTypeId().intValue()) + ")");
+            i.setIsDeletedConcept(
+                    isDeletedParent.equals(IsDeleteEnum.Y.getKey()) ? IsDeleteEnum.Y.getKey() : i.getIsDeletedConcept()
+            );
+
+            if (!hookConceptIds.contains(i.getConceptId())) {
+                List<Long> hookConceptIds_ = new ArrayList<>();
+                hookConceptIds_.addAll(hookConceptIds);
+                hookConceptIds_.add(i.getConceptId());
+                i.setNodeList(repairRelationDataForQuery(i.getConceptId(),
+                        Lists.newArrayList(relationIds), Lists.newArrayList(typeIds),
+                        hookConceptIds_, i.getIsDeletedConcept()));
+            }
+        }
+
+        return relationNodeDTOList;
+    }
+
+    /**
+     * 医学术语关联维护/医学术语多层关联维护-添加或者编辑
+     *
+     * @param klRelationNodeVO
+     * @return
+     */
+    public Boolean addRelation(KlRelationNodeVO klRelationNodeVO) {
+        if (klRelationNodeVO.getConceptId() == null) {
+            throw new CommonException(CommonErrorCode.RPC_ERROR, "conceptId必填!");
+        }
+        if (ListUtil.isEmpty(klRelationNodeVO.getNodeList())) {
+            throw new CommonException(CommonErrorCode.RPC_ERROR, "nodeList不能为空!");
+        }
+
+        //先删除
+        List<Long> relationIdList = repairRelationDataForDelBeforeAdd(klRelationNodeVO.getConceptId(), klRelationNodeVO);
+        if (ListUtil.isNotEmpty(relationIdList)) {
+            removeByIds(relationIdList);
+
+            QueryWrapper<KlRelationOrder> relationOrderQe = new QueryWrapper<>();
+            relationOrderQe.in("t_relation_id", relationIdList);
+            klRelationOrderFacade.remove(relationOrderQe);
+        }
+
+        //后添加
+        List<List<KlRelation>> relationGroupList = repairRelationDataForAdd(klRelationNodeVO);
+        String currentUser = UserUtils.getCurrentPrincipleID();
+        Date now = DateUtil.now();
+        List<KlRelation> relationList = Lists.newArrayList();
+        relationGroupList.forEach(i -> {
+            i.forEach(j -> {
+                j.setCreator(currentUser);
+                j.setGmtCreate(now);
+                j.setModifier(currentUser);
+                j.setGmtModified(now);
+                relationList.add(j);
+            });
+        });
+        klRelationService.saveOrUpdateBatch(relationList);
+
+        if (klRelationNodeVO.getIsOrderBy() == 1) {
+            List<KlRelationOrder> relationOrderList = Lists.newArrayList();
+            relationGroupList.forEach(i -> {
+                int orderNo = 0;
+                for (KlRelation j : i) {
+                    orderNo++;
+                    KlRelationOrder relationOrder = new KlRelationOrder();
+                    relationOrder.setOrderNo(orderNo);
+                    relationOrder.settRelationId(j.getId());
+                    relationOrder.setGmtCreate(now);
+                    relationOrder.setGmtModified(now);
+                    relationOrder.setCreator(currentUser);
+                    relationOrder.setModifier(currentUser);
+                    relationOrderList.add(relationOrder);
+                }
+            });
+            klRelationOrderServiceImpl.saveBatch(relationOrderList);
+        }
+
+        return true;
+    }
+
+    /**
+     * 处理关系节点-添加或者编辑前先删除掉
+     *
+     * @param conceptId      当前概念id
+     * @param klRelationNodeVO
+     * @return
+     */
+    private List<Long> repairRelationDataForDelBeforeAdd(Long conceptId, KlRelationNodeVO klRelationNodeVO) {
+        List<Long> relationIdList = Lists.newArrayList();
+        QueryWrapper<KlRelation> relationQe = new QueryWrapper<>();
+        relationQe.eq("start_id", conceptId);
+        if (klRelationNodeVO != null && klRelationNodeVO.getSonRelationId() != null) {
+            relationQe.eq("relation_id", klRelationNodeVO.getSonRelationId());
+        } else {
+            relationQe.eq("relation_id", -999999l);
+        }
+        List<KlRelation> relationList = this.list(relationQe);
+
+        if (ListUtil.isNotEmpty(relationList)) {
+            if (klRelationNodeVO != null && klRelationNodeVO.getSonTypeId() != null) {
+                List<Long> conceptIdList = klConceptFacade.getCompatibleTypeConceptIds(klRelationNodeVO.getSonTypeId(),
+                        relationList.stream().map(i -> i.getEndId()).collect(Collectors.toList()));
+                if (conceptIdList != null) {
+                    relationList = relationList.stream()
+                            .filter(i -> conceptIdList.contains(i.getEndId())).collect(Collectors.toList());
+                }
+            }
+
+            if (ListUtil.isNotEmpty(relationList)) {
+                relationIdList.addAll(relationList.stream().map(i -> i.getId()).collect(Collectors.toList()));
+
+                Map<Long, KlRelationNodeVO> conceptIdRnMap = Maps.newHashMap();
+                if (klRelationNodeVO != null && ListUtil.isNotEmpty(klRelationNodeVO.getNodeList())) {
+                    conceptIdRnMap = klRelationNodeVO.getNodeList()
+                            .stream().collect(Collectors.toMap(KlRelationNodeVO::getConceptId, i -> i));
+                }
+
+                for (KlRelation i : relationList) {
+                    relationIdList.addAll(repairRelationDataForDelBeforeAdd(i.getEndId(),
+                            conceptIdRnMap.get(i.getEndId())));
+                }
+            }
+        }
+        return relationIdList;
+    }
+
+    /**
+     * 处理关系节点-添加或者编辑事件
+     *
+     * @param klRelationNodeVO
+     * @return
+     */
+    private List<List<KlRelation>> repairRelationDataForAdd(KlRelationNodeVO klRelationNodeVO) {
+        List<List<KlRelation>> retList = Lists.newArrayList();
+
+        if (ListUtil.isNotEmpty(klRelationNodeVO.getNodeList())) {
+            List<KlRelation> relationList = Lists.newArrayList();
+            klRelationNodeVO.getNodeList().forEach(i -> {
+                KlRelation relation = new KlRelation();
+                relation.setStartId(klRelationNodeVO.getConceptId());
+                relation.setEndId(i.getConceptId());
+                relation.setRelationId(Integer.parseInt(String.valueOf(i.getRelationId())));
+                relationList.add(relation);
+
+                if (ListUtil.isNotEmpty(i.getNodeList())) {
+                    retList.addAll(repairRelationDataForAdd(i));
+                }
+            });
+            retList.add(relationList);
+        }
+
+        return retList;
+    }
+
+}

+ 7 - 0
cdssman-service/src/main/java/com/diagbot/mapper/KlRelationMapper.java

@@ -1,6 +1,11 @@
 package com.diagbot.mapper;
 
+import com.diagbot.dto.RelationNodeDTO;
+import com.diagbot.entity.KlRelation;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 import com.diagbot.dto.MedClassMedDTO;
 import com.diagbot.entity.KlRelation;
 
@@ -15,5 +20,7 @@ import java.util.List;
  * @since 2021-03-01
  */
 public interface KlRelationMapper extends BaseMapper<KlRelation> {
+    List<RelationNodeDTO> getRelationNodeDTOs(@Param(value="conceptId")Long conceptId, @Param(value="relationId")Long relationId, @Param(value="endTypeId")Long endTypeId);
+
     List<MedClassMedDTO> getMedClassMedList();
 }

+ 74 - 0
cdssman-service/src/main/java/com/diagbot/vo/GetAllForRelationVO.java

@@ -0,0 +1,74 @@
+package com.diagbot.vo;
+
+import com.diagbot.annotation.CryptField;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * @Description:
+ * @author: Weixuan Huang
+ * @time: 2019/3/14 16:03
+ */
+@Getter
+@Setter
+public class GetAllForRelationVO {
+    
+    /**
+     * 名称
+     */
+    @CryptField
+    @ApiModelProperty(value="名称")
+    private String name;
+    
+    /**
+     * 词性id
+     */
+    @ApiModelProperty(value="词性id")
+    private Long typeId;
+    
+    /**
+     * 搜索出来的概念在关系中的位置,1-起点术语,2-终点术语,3-不考虑关系
+     */
+    @ApiModelProperty(value="搜索出来的概念在关系中的位置,0-既是起点术语又是终点术语,1-起点术语,2-终点术语,3-不考虑关系")
+    private Integer relationPosition=3;
+
+    /**
+     * 相关联的概念id
+     */
+    @ApiModelProperty(value="相关联的概念id")
+    private Long relationConceptId;
+
+    /**
+     * 相关联的概念id补充
+     */
+    @ApiModelProperty(value="相关联的概念id补充")
+    private List<Long> relationConceptIdSupplement;
+    
+    /**
+     * 相关联的概念类型
+     */
+    @ApiModelProperty(value="相关联的概念类型")
+    private Long relationTypeId;
+
+    /**
+     * 相关联的概念类型补充
+     */
+    @ApiModelProperty(value="相关联的概念类型补充")
+    private List<Long> relationTypeIdSupplement;
+    
+    /**
+     * 关系类型id
+     */
+    @ApiModelProperty(value="关系类型id")
+    private Long relationId;
+    
+    /**
+     * 需要排除的概念id集合
+     */
+    @ApiModelProperty(value="需要排除的概念id集合")
+    private List<Long> excludedConceptIds;
+    
+}

+ 51 - 0
cdssman-service/src/main/java/com/diagbot/vo/KlRelationNodeVO.java

@@ -0,0 +1,51 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * @Description:
+ * @author: Weixuan Huang
+ * @time: 2019/3/14 16:03
+ */
+@Getter
+@Setter
+public class KlRelationNodeVO {
+	
+	/**
+	 * 当前概念id start_id
+	 */
+	private Long conceptId;
+	
+	/**
+	 * 下一级概念类型id
+	 */
+	private Long sonTypeId;
+	
+	/**
+	 * 当前概念(起点术语) 与 上一级概念(终点术语) 关系id
+	 */
+	private Long relationId;
+    
+	/**
+	 * 当前概念 与 下一级概念 关系id
+	 * 当前系列操作的关系一样时,relationId和sonRelationId都传过来,传一样的值,方便操作,sonRelationId用来删除相关一系列关系;
+	 * 当前系列操作的关系不是全部一样时,不传sonRelationId,这样会删除当前概念下的全部关系
+	 */
+	private Long sonRelationId;
+	
+	/**
+	 * 主要第一级时用,判断是否需要排序
+	 * 是否排序,1-排序,0-不排序
+	 */
+	private Integer isOrderBy = 1;
+	
+	/**
+	 * 下一级概念
+	 */
+	private List<KlRelationNodeVO> nodeList;
+	
+    
+}

+ 38 - 0
cdssman-service/src/main/java/com/diagbot/vo/RelationContactDetailVO.java

@@ -0,0 +1,38 @@
+package com.diagbot.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotNull;
+import java.util.List;
+
+/**
+ * @Description:
+ * @author: Weixuan Huang
+ * @time: 2019/3/14 16:03
+ */
+@Getter
+@Setter
+public class RelationContactDetailVO {
+    
+    /**
+     * 概念id
+     */
+	@ApiModelProperty(value="概念id",required=true)
+	@NotNull(message="概念id必传")
+    private Long conceptId;
+	
+	/**
+	 * 各级关系类型id集合
+	 */
+	@ApiModelProperty(value="各级关系类型id集合")
+	private List<Long> relationIds;
+	
+	/**
+	 * 各级终点术语类型id集合
+	 */
+	@ApiModelProperty(value="各级终点术语类型id集合")
+	private List<Long> typeIds;
+    
+}

+ 9 - 0
cdssman-service/src/main/java/com/diagbot/web/KlConceptController.java

@@ -3,10 +3,12 @@ package com.diagbot.web;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.annotation.SysLogger;
+import com.diagbot.dto.GetAllForRelationDTO;
 import com.diagbot.dto.KlConceptAllDTO;
 import com.diagbot.dto.KlConceptInfoDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.facade.KlConceptFacade;
+import com.diagbot.vo.GetAllForRelationVO;
 import com.diagbot.vo.KlConceptAllVO;
 import com.diagbot.vo.KlConceptInfoVO;
 import io.swagger.annotations.Api;
@@ -50,4 +52,11 @@ public class KlConceptController {
         return RespDTO.onSuc(klConceptFacade.getConceptAlls(klConceptAllVO));
     }
 
+    @ApiOperation(value = "知识库标准化-获取所有概念(术语关系维护时筛选使用)[by:kongwz]")
+    @PostMapping("/getAllForRelation")
+    @SysLogger("getAllForRelation")
+    public RespDTO<List<GetAllForRelationDTO>> getAllForRelation(@RequestBody GetAllForRelationVO getAllForRelationVO) {
+        return RespDTO.onSuc(klConceptFacade.getAllForRelation(getAllForRelationVO));
+    }
+
 }

+ 49 - 0
cdssman-service/src/main/java/com/diagbot/web/MultContactController.java

@@ -0,0 +1,49 @@
+package com.diagbot.web;
+
+import com.diagbot.annotation.SysLogger;
+import com.diagbot.dto.RelationNodeDTO;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.facade.RelationContactFacade;
+import com.diagbot.vo.KlRelationNodeVO;
+import com.diagbot.vo.RelationContactDetailVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.validation.Valid;
+
+/**
+ * @author kwz
+ * @date 2021/3/3
+ * @time 15:40
+ */
+@RestController
+@RequestMapping("/multContact")
+@SuppressWarnings("unchecked")
+@Api(value = "树形结构维护相关API", tags = { "知识库标准化-树形结构维护相关API" })
+public class MultContactController {
+    @Autowired
+    private RelationContactFacade relationContactFacade;
+
+
+    @ApiOperation(value = "知识库标准化-树形结构维护相关API-详情[by:kongwz]")
+    @PostMapping("/relationContactDetail")
+    @SysLogger("relationContactDetail")
+    public RespDTO<RelationNodeDTO> relationContactDetail(@Valid @RequestBody RelationContactDetailVO relationContactDetailVO) {
+        return RespDTO.onSuc(relationContactFacade.relationContactDetail(relationContactDetailVO));
+    }
+
+    @ApiOperation(value = "知识库标准化-医学术语多层关联维护-添加或者编辑[by:kongwz]")
+    @PostMapping("/addRelation")
+    @SysLogger("addRelation")
+    @Transactional
+    public RespDTO<Boolean> addRelation(@Valid @RequestBody KlRelationNodeVO klRelationNodeVO) {
+        return RespDTO.onSuc(relationContactFacade.addRelation(klRelationNodeVO));
+    }
+
+}

+ 28 - 0
cdssman-service/src/main/resources/mapper/KlRelationMapper.xml

@@ -40,4 +40,32 @@
         AND b.`status` = 1
         AND c.`status` = 1
     </select>
+    <select id="getRelationNodeDTOs" resultType="com.diagbot.dto.RelationNodeDTO">
+        SELECT
+        d.id AS conceptId,
+        d.lib_name AS conceptName,
+        d.lib_type AS conceptTypeId,
+        d.is_deleted AS isDeletedConcept,
+        c.id AS parentConceptId,
+        c.lib_name AS parentConceptName,
+        c.lib_type AS parentConceptTypeId,
+        e.id AS relationId,
+        e.`name` AS relationName
+        FROM kl_relation a LEFT JOIN kl_relation_order b ON a.id=b.t_relation_id
+        JOIN kl_concept c ON a.start_id=c.id
+        JOIN kl_concept d ON a.end_id=d.id
+        JOIN kl_lexicon_relationship e ON a.relation_id=e.code
+        WHERE 1=1
+        AND a.is_deleted='N'
+        AND e.is_deleted='N'
+        AND a.start_id=#{conceptId}
+        <if test="relationId!=null">
+            AND a.relation_id=#{relationId}
+        </if>
+        <if test="endTypeId!=null">
+            AND d.lib_type=#{endTypeId}
+        </if>
+        ORDER BY b.order_no ASC,a.gmt_modified DESC
+    </select>
+
 </mapper>