|
@@ -2,6 +2,8 @@ package com.diagbot.facade;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
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.ConceptDTO;
|
|
|
import com.diagbot.dto.RelationDTO;
|
|
|
import com.diagbot.entity.Concept;
|
|
@@ -10,6 +12,7 @@ import com.diagbot.entity.LibraryInfo;
|
|
|
import com.diagbot.entity.Relation;
|
|
|
import com.diagbot.service.impl.RelationServiceImpl;
|
|
|
import com.diagbot.vo.AmendTermVo;
|
|
|
+import com.diagbot.vo.RelationVo;
|
|
|
import com.diagbot.vo.TermVo;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -35,6 +38,21 @@ public class RelationFacade extends RelationServiceImpl {
|
|
|
@Autowired
|
|
|
private RelationshipFacade relationshipFacade;
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * 获取所有医学术语的关系
|
|
|
+ *
|
|
|
+ * @param page
|
|
|
+ * @result IPage<RelationDTO>
|
|
|
+ */
|
|
|
+ public IPage<RelationDTO> getAllRelations(Page page) {
|
|
|
+ RelationDTO relationDTO = new RelationDTO();
|
|
|
+
|
|
|
+ return getAllRelation(page, relationDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 获取指定医学术语的关联关系
|
|
|
*
|
|
@@ -53,29 +71,46 @@ public class RelationFacade extends RelationServiceImpl {
|
|
|
/**
|
|
|
*
|
|
|
*
|
|
|
- * 获取指定医学术语的所有信息
|
|
|
+ * 获取指定医学术语的所有上级关系
|
|
|
*
|
|
|
- * @param termVo
|
|
|
+ * @param relationVo
|
|
|
* @result List<Relation>
|
|
|
*/
|
|
|
- public List<RelationDTO> getAllRelation(TermVo termVo) {
|
|
|
+ public List<RelationDTO> getRelations(RelationVo relationVo) {
|
|
|
List<RelationDTO> relationDTOs = new ArrayList<>();
|
|
|
+ RelationDTO relationDTO = new RelationDTO();
|
|
|
+ int concept_id = 0;
|
|
|
|
|
|
- if (termVo.getConcept_id() == 0) {
|
|
|
- ConceptDTO conceptDTO = conceptFacade.getConcept(termVo);
|
|
|
+ if (relationVo.getStart_term().length() > 0 && relationVo.getEnd_term().length() > 0) {
|
|
|
+ QueryWrapper<LibraryInfo> query = new QueryWrapper<>();
|
|
|
+ query.eq("name", relationVo.getStart_term());
|
|
|
+ query.eq("type", relationVo.getStart_type());
|
|
|
|
|
|
- if (conceptDTO != null) {
|
|
|
- termVo.setConcept_id(conceptDTO.getId());
|
|
|
+ LibraryInfo libraryInfo = libraryInfoFacade.getOne(query);
|
|
|
+
|
|
|
+ if (libraryInfo == null) {
|
|
|
+ relationDTO.setMsg("术语 \"" + relationVo.getStart_term() + "\" 不存在!");
|
|
|
+ relationDTOs.add(relationDTO);
|
|
|
+
|
|
|
+ return relationDTOs;
|
|
|
}
|
|
|
+ concept_id = (libraryInfo == null) ? 0 : libraryInfo.getConceptId();
|
|
|
+ }
|
|
|
+ else if (relationVo.getStart_concept_id() > 0) {
|
|
|
+ concept_id = relationVo.getStart_concept_id();
|
|
|
}
|
|
|
|
|
|
- List<Relation> relations = new ArrayList<>();
|
|
|
- relations = getList(relations, termVo.getConcept_id(), -1);
|
|
|
- relationDTOs.addAll(ConvertListtoDTO(relations));
|
|
|
+ if (concept_id > 0) {
|
|
|
+ List<Relation> relations = new ArrayList<>();
|
|
|
+ relations = getList(relations, concept_id, -1);
|
|
|
+ relationDTOs.addAll(ConvertListtoDTO(relations));
|
|
|
+ }
|
|
|
|
|
|
return relationDTOs;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
public List<RelationDTO> ConvertListtoDTO (List<Relation> src) {
|
|
|
List<RelationDTO> dest = new ArrayList<>();
|
|
|
RelationDTO relationDTO;
|
|
@@ -210,24 +245,62 @@ public class RelationFacade extends RelationServiceImpl {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
- * 清空医学术语关系表
|
|
|
*
|
|
|
+ * 删除指定医学术语的关系
|
|
|
+ *
|
|
|
+ * @param relationVo
|
|
|
+ * @result RelationDTO
|
|
|
*/
|
|
|
- public void deleteRelation() {
|
|
|
- truncateRelation();
|
|
|
+ public RelationDTO removeRelations(RelationVo relationVo) {
|
|
|
+ RelationDTO relationDTO = new RelationDTO();
|
|
|
+ QueryWrapper<Relation> query;
|
|
|
+
|
|
|
+ int startid = relationVo.getStart_concept_id();
|
|
|
+ int relationid = relationVo.getRelation_id();
|
|
|
+ int endid = relationVo.getEnd_concept_id();
|
|
|
+ String startname = relationVo.getStart_term().trim();
|
|
|
+ String relationname = relationVo.getRelation_name().trim();
|
|
|
+ String endname = relationVo.getEnd_term().trim();
|
|
|
+
|
|
|
+ if (startid > 0 && relationid > 0 && endid > 0) {
|
|
|
+ query = new QueryWrapper<>();
|
|
|
+ query.eq("start_id", startid);
|
|
|
+ query.eq("relation_id", relationid);
|
|
|
+ query.eq("end_id", endid);
|
|
|
+
|
|
|
+ relationDTO.setMsg(String.valueOf(remove(query)));
|
|
|
+ }
|
|
|
+ else if (startname.length() > 0 && endname.length() > 0 && relationname.length() > 0) {
|
|
|
+ relationDTO = getRelationbyName(relationVo);
|
|
|
+
|
|
|
+ if (relationDTO != null) {
|
|
|
+ int id = relationDTO.getId();
|
|
|
+ query = new QueryWrapper<>();
|
|
|
+ query.eq("id", id);
|
|
|
+
|
|
|
+ relationDTO.setMsg(String.valueOf(remove(query)));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ relationDTO.setMsg("此关系不存在!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ relationDTO.setMsg("此关系不存在!");
|
|
|
+ }
|
|
|
+
|
|
|
+ return relationDTO;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
- * 根据概念Id删除医学术语关系
|
|
|
+ * 清空医学术语关系表
|
|
|
*
|
|
|
*/
|
|
|
- public void removeRelationbyIds(List<Integer> Ids) {
|
|
|
- int concept_id = 0;
|
|
|
- for (int i=0; i<Ids.size(); i++) {
|
|
|
- concept_id = Ids.get(i);
|
|
|
+ public void deleteRelation() {
|
|
|
+ truncateRelation();
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- }
|
|
|
- }
|
|
|
}
|