|
@@ -4,30 +4,22 @@ import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.diagbot.client.UserServiceClient;
|
|
|
-import com.diagbot.dto.RelationNameDTO;
|
|
|
-import com.diagbot.dto.RelationNamesDTO;
|
|
|
-import com.diagbot.dto.RelationNodeDTO;
|
|
|
-import com.diagbot.dto.RespDTO;
|
|
|
+import com.diagbot.dto.*;
|
|
|
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.DateUtil;
|
|
|
import com.diagbot.util.ListUtil;
|
|
|
-import com.diagbot.util.UserUtils;
|
|
|
-import com.diagbot.vo.KlRelationNodeVO;
|
|
|
-import com.diagbot.vo.KlRelationSaveVO;
|
|
|
-import com.diagbot.vo.KlRelationVO;
|
|
|
-import com.diagbot.vo.RelationContactDetailVO;
|
|
|
+import com.diagbot.vo.*;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Maps;
|
|
|
import org.apache.commons.collections4.MapUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.stereotype.Component;
|
|
@@ -58,6 +50,8 @@ public class RelationContactFacade extends KlRelationServiceImpl {
|
|
|
@Autowired
|
|
|
@Qualifier("klRelationOrderServiceImpl")
|
|
|
private KlRelationOrderServiceImpl klRelationOrderServiceImpl;
|
|
|
+ @Autowired
|
|
|
+ KlDiseaseFacade klDiseaseFacade;
|
|
|
|
|
|
public RelationNodeDTO relationContactDetail(RelationContactDetailVO relationContactDetailVO) {
|
|
|
RelationNodeDTO relationNodeDTO = new RelationNodeDTO();
|
|
@@ -75,14 +69,6 @@ public class RelationContactFacade extends KlRelationServiceImpl {
|
|
|
return relationNodeDTO;
|
|
|
}
|
|
|
|
|
|
- public RelationNodeDTO relationContactDetail(KlRelationVO klRelationVO) {
|
|
|
- RelationNamesDTO relationNamesDTO = new RelationNamesDTO();
|
|
|
- RelationNodeDTO relationNodeDTO = new RelationNodeDTO();
|
|
|
- List<RelationNameDTO> relationNameDTOs_first = this.getRelationNameDTOs(klRelationVO.getConceptIds(), klRelationVO.getRelationId());
|
|
|
-
|
|
|
-
|
|
|
- return relationNodeDTO;
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* 处理关系节点-查询事件
|
|
@@ -329,136 +315,45 @@ public class RelationContactFacade extends KlRelationServiceImpl {
|
|
|
return relationList;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
- * 医学术语关联维护/医学术语多层关联维护-添加或者编辑
|
|
|
- *
|
|
|
- * @param klRelationNodeVO
|
|
|
+ * 删除某个诊断依据
|
|
|
+ * @param diseaseDeleteVO
|
|
|
* @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);
|
|
|
-
|
|
|
+ @DS("med")
|
|
|
+ @DSTransactional
|
|
|
+ public Boolean deleteRelation(DiseaseDeleteVO diseaseDeleteVO) {
|
|
|
+ String disName = diseaseDeleteVO.getDisName();
|
|
|
+ if(StringUtils.isNotBlank(disName)){
|
|
|
+ List<KlConcept> klConcepts = klConceptFacade.list(new QueryWrapper<KlConcept>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("lib_name", disName.trim())
|
|
|
+ .eq("lib_type", 100));
|
|
|
+ List<Long> ids = klConcepts.stream().map(x -> x.getId()).collect(Collectors.toList());
|
|
|
+ List<Integer> relations = Lists.newArrayList(501, 502, 503, 504, 505, 506, 507, 508);
|
|
|
+ List<KlRelation> klRelations = this.list(new QueryWrapper<KlRelation>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .in(ListUtil.isNotEmpty(ids),"start_id", ids)
|
|
|
+ .in(ListUtil.isNotEmpty(relations),"relation_id", relations));
|
|
|
+ List<Long> kids = klRelations.stream().map(x -> x.getId()).collect(Collectors.toList());
|
|
|
+ this.removeByIds(kids);
|
|
|
QueryWrapper<KlRelationOrder> relationOrderQe = new QueryWrapper<>();
|
|
|
- relationOrderQe.in("t_relation_id", relationIdList);
|
|
|
+ relationOrderQe.in(ListUtil.isNotEmpty(kids),"t_relation_id", kids);
|
|
|
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
|
|
|
+ * 新增诊断依据
|
|
|
+ * @param diseaseDeleteVO
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<Long> repairRelationDataForDelBeforeAdd(Long conceptId, KlRelationNodeVO klRelationNodeVO) {
|
|
|
- List<Long> relationIdList = Lists.newArrayList();
|
|
|
- List<KlRelation> relationList = this.list(new QueryWrapper<KlRelation>()
|
|
|
- .eq("start_id", conceptId)
|
|
|
- .eq("relation_id", klRelationNodeVO != null && klRelationNodeVO.getSonRelationId() != null ?
|
|
|
- klRelationNodeVO.getSonRelationId() : -999999l));
|
|
|
-
|
|
|
- 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;
|
|
|
+ public List<KlConcept> addDisease(DiseaseDeleteVO diseaseDeleteVO) {
|
|
|
+ List<KlConcept> diseaseAll = klDiseaseFacade.getDiseaseAll(diseaseDeleteVO);
|
|
|
+ return diseaseAll;
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * 处理关系节点-添加或者编辑事件
|
|
|
- *
|
|
|
- * @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;
|
|
|
- }
|
|
|
-
|
|
|
}
|