|
@@ -1,15 +1,5 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
-
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.diagbot.client.UserServiceClient;
|
|
@@ -38,6 +28,15 @@ import com.diagbot.vo.RemoveRelationContactVO;
|
|
|
import com.diagbot.vo.SingleRelationListVO;
|
|
|
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 java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @Description: 医学术语关联业务层
|
|
@@ -46,31 +45,32 @@ import com.google.common.collect.Maps;
|
|
|
*/
|
|
|
@Component
|
|
|
public class RelationContactFacade extends RelationServiceImpl {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ConceptFacade conceptFacade;
|
|
|
- @Autowired
|
|
|
- private RelationOrderFacade relationOrderFacade;
|
|
|
- @Autowired
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ConceptFacade conceptFacade;
|
|
|
+ @Autowired
|
|
|
+ private RelationOrderFacade relationOrderFacade;
|
|
|
+ @Autowired
|
|
|
@Qualifier("relationServiceImpl")
|
|
|
private RelationService relationService;
|
|
|
- @Autowired
|
|
|
+ @Autowired
|
|
|
@Qualifier("relationOrderServiceImpl")
|
|
|
private RelationOrderServiceImpl relationOrderServiceImpl;
|
|
|
- @Autowired
|
|
|
+ @Autowired
|
|
|
private UserServiceClient userServiceClient;
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 医学术语关联维护-列表
|
|
|
- * @param relationContactListVO
|
|
|
+ *
|
|
|
+ * @param singleRelationListVO
|
|
|
* @return
|
|
|
*/
|
|
|
public IPage<SingleRelationListDTO> relationContactList(SingleRelationListVO singleRelationListVO) {
|
|
|
- String[] relationModelTypeArry = singleRelationListVO.getRelationModelTypeCode().split("101");
|
|
|
- singleRelationListVO.setStartTypeId(Long.parseLong(relationModelTypeArry[0]));
|
|
|
- singleRelationListVO.setEndTypeId(Long.parseLong(relationModelTypeArry[1]));
|
|
|
-
|
|
|
- IPage<SingleRelationListDTO> ipage = this.baseMapper.singleRelationList(singleRelationListVO);
|
|
|
+ String[] relationModelTypeArry = singleRelationListVO.getRelationModelTypeCode().split("101");
|
|
|
+ singleRelationListVO.setStartTypeId(Long.parseLong(relationModelTypeArry[0]));
|
|
|
+ singleRelationListVO.setEndTypeId(Long.parseLong(relationModelTypeArry[1]));
|
|
|
+
|
|
|
+ IPage<SingleRelationListDTO> ipage = this.baseMapper.singleRelationList(singleRelationListVO);
|
|
|
if (ListUtil.isNotEmpty(ipage.getRecords())) {
|
|
|
List<String> ids = ipage.getRecords().stream().map(i -> i.getOperName()).distinct().collect(Collectors.toList());
|
|
|
RespDTO<Map<String, String>> respDTO = userServiceClient.getUserInfoByIds(ids);
|
|
@@ -78,315 +78,346 @@ public class RelationContactFacade extends RelationServiceImpl {
|
|
|
ipage.getRecords().forEach(i -> {
|
|
|
i.setOperName(respDTO.data.get(i.getOperName()));
|
|
|
i.setLibType(LexiconTypeEnum.getName(i.getLibTypeId().intValue()));
|
|
|
- i.setLibNameType(i.getLibName()+"("+i.getLibType()+")");
|
|
|
+ i.setLibNameType(i.getLibName() + "(" + i.getLibType() + ")");
|
|
|
i.setRelationModelTypeName(RelationModelTypeEnum.getName(Integer.parseInt(i.getRelationModelTypeCode())));
|
|
|
});
|
|
|
}
|
|
|
return ipage;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 医学术语关联维护/医学术语多层关联维护/化验子项维护-添加或者编辑
|
|
|
- * @param relationNodeVO
|
|
|
- * @return
|
|
|
- */
|
|
|
- public Boolean addRelation(RelationNodeVO relationNodeVO) {
|
|
|
- if(relationNodeVO.getConceptId()==null){
|
|
|
- throw new CommonException(CommonErrorCode.RPC_ERROR,"conceptId必填!");
|
|
|
- }
|
|
|
- if(ListUtil.isEmpty(relationNodeVO.getNodeList())){
|
|
|
- throw new CommonException(CommonErrorCode.RPC_ERROR,"nodeList不能为空!");
|
|
|
- }
|
|
|
-
|
|
|
- List<Long> relationIdList = repairRelationDataForDelBeforeAdd(relationNodeVO.getConceptId(),relationNodeVO);
|
|
|
- if(ListUtil.isNotEmpty(relationIdList)){
|
|
|
- removeByIds(relationIdList);
|
|
|
-
|
|
|
- QueryWrapper<RelationOrder> relationOrderQe = new QueryWrapper<>();
|
|
|
- relationOrderQe.in("t_relation_id", relationIdList);
|
|
|
- relationOrderFacade.remove(relationOrderQe);
|
|
|
- }
|
|
|
-
|
|
|
- List<List<Relation>> relationGroupList = repairRelationDataForAdd(relationNodeVO);
|
|
|
- String currentUser = UserUtils.getCurrentPrincipleID();
|
|
|
+ /**
|
|
|
+ * 医学术语关联维护/医学术语多层关联维护/化验子项维护-添加或者编辑
|
|
|
+ *
|
|
|
+ * @param relationNodeVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Boolean addRelation(RelationNodeVO relationNodeVO) {
|
|
|
+ if (relationNodeVO.getConceptId() == null) {
|
|
|
+ throw new CommonException(CommonErrorCode.RPC_ERROR, "conceptId必填!");
|
|
|
+ }
|
|
|
+ if (ListUtil.isEmpty(relationNodeVO.getNodeList())) {
|
|
|
+ throw new CommonException(CommonErrorCode.RPC_ERROR, "nodeList不能为空!");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Long> relationIdList = repairRelationDataForDelBeforeAdd(relationNodeVO.getConceptId(), relationNodeVO);
|
|
|
+ if (ListUtil.isNotEmpty(relationIdList)) {
|
|
|
+ removeByIds(relationIdList);
|
|
|
+
|
|
|
+ QueryWrapper<RelationOrder> relationOrderQe = new QueryWrapper<>();
|
|
|
+ relationOrderQe.in("t_relation_id", relationIdList);
|
|
|
+ relationOrderFacade.remove(relationOrderQe);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<List<Relation>> relationGroupList = repairRelationDataForAdd(relationNodeVO);
|
|
|
+ String currentUser = UserUtils.getCurrentPrincipleID();
|
|
|
Date now = DateUtil.now();
|
|
|
List<Relation> relationList = Lists.newArrayList();
|
|
|
- relationGroupList.forEach(i->{
|
|
|
- i.forEach(j->{
|
|
|
- j.setCreator(currentUser);
|
|
|
- j.setGmtCreate(now);
|
|
|
- j.setModifier(currentUser);
|
|
|
- j.setGmtModified(now);
|
|
|
- relationList.add(j);
|
|
|
- });
|
|
|
+ relationGroupList.forEach(i -> {
|
|
|
+ i.forEach(j -> {
|
|
|
+ j.setCreator(currentUser);
|
|
|
+ j.setGmtCreate(now);
|
|
|
+ j.setModifier(currentUser);
|
|
|
+ j.setGmtModified(now);
|
|
|
+ relationList.add(j);
|
|
|
+ });
|
|
|
});
|
|
|
relationService.saveOrUpdateBatch(relationList);
|
|
|
-
|
|
|
- if(relationNodeVO.getIsOrderBy()==1){
|
|
|
- List<RelationOrder> relationOrderList = Lists.newArrayList();
|
|
|
- relationGroupList.forEach(i->{
|
|
|
- int orderNo = 0;
|
|
|
- for(Relation j : i){
|
|
|
- orderNo++;
|
|
|
- RelationOrder relationOrder = new RelationOrder();
|
|
|
- relationOrder.setOrderNo(orderNo);
|
|
|
- relationOrder.settRelationId(j.getId());
|
|
|
- relationOrder.setGmtCreate(now);
|
|
|
- relationOrder.setGmtModified(now);
|
|
|
- relationOrder.setCreator(currentUser);
|
|
|
- relationOrder.setModifier(currentUser);
|
|
|
- relationOrderList.add(relationOrder);
|
|
|
- }
|
|
|
+
|
|
|
+ if (relationNodeVO.getIsOrderBy() == 1) {
|
|
|
+ List<RelationOrder> relationOrderList = Lists.newArrayList();
|
|
|
+ relationGroupList.forEach(i -> {
|
|
|
+ int orderNo = 0;
|
|
|
+ for (Relation j : i) {
|
|
|
+ orderNo++;
|
|
|
+ RelationOrder relationOrder = new RelationOrder();
|
|
|
+ relationOrder.setOrderNo(orderNo);
|
|
|
+ relationOrder.settRelationId(j.getId());
|
|
|
+ relationOrder.setGmtCreate(now);
|
|
|
+ relationOrder.setGmtModified(now);
|
|
|
+ relationOrder.setCreator(currentUser);
|
|
|
+ relationOrder.setModifier(currentUser);
|
|
|
+ relationOrderList.add(relationOrder);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ relationOrderServiceImpl.saveBatch(relationOrderList);
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理关系节点-添加或者编辑前先删除掉
|
|
|
+ *
|
|
|
+ * @param conceptId 当前概念id
|
|
|
+ * @param relationNodeVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<Long> repairRelationDataForDelBeforeAdd(Long conceptId, RelationNodeVO relationNodeVO) {
|
|
|
+ List<Long> relationIdList = Lists.newArrayList();
|
|
|
+
|
|
|
+ QueryWrapper<Relation> relationQe = new QueryWrapper<>();
|
|
|
+ relationQe.eq("start_id", conceptId);
|
|
|
+ if (relationNodeVO != null && relationNodeVO.getSonRelationId() != null) {
|
|
|
+ relationQe.eq("relation_id", relationNodeVO.getSonRelationId());
|
|
|
+ } else {
|
|
|
+ relationQe.eq("relation_id", -999999l);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Relation> relationList = list(relationQe);
|
|
|
+
|
|
|
+ if (ListUtil.isNotEmpty(relationList)) {
|
|
|
+ if (relationNodeVO != null && relationNodeVO.getSonTypeId() != null) {
|
|
|
+ List<Long> conceptIdList = conceptFacade.getCompatibleTypeConceptIds(relationNodeVO.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, RelationNodeVO> conceptIdRnMap = Maps.newHashMap();
|
|
|
+ if (relationNodeVO != null && ListUtil.isNotEmpty(relationNodeVO.getNodeList())) {
|
|
|
+ conceptIdRnMap = relationNodeVO.getNodeList()
|
|
|
+ .stream().collect(Collectors.toMap(RelationNodeVO::getConceptId, i -> i));
|
|
|
+ }
|
|
|
+
|
|
|
+ for (Relation i : relationList) {
|
|
|
+ relationIdList.addAll(repairRelationDataForDelBeforeAdd(i.getEndId(),
|
|
|
+ conceptIdRnMap.get(i.getEndId())));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return relationIdList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理关系节点-添加或者编辑事件
|
|
|
+ *
|
|
|
+ * @param relationNodeVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<List<Relation>> repairRelationDataForAdd(RelationNodeVO relationNodeVO) {
|
|
|
+ List<List<Relation>> retList = Lists.newArrayList();
|
|
|
+
|
|
|
+ if (ListUtil.isNotEmpty(relationNodeVO.getNodeList())) {
|
|
|
+ List<Relation> relationList = Lists.newArrayList();
|
|
|
+ relationNodeVO.getNodeList().forEach(i -> {
|
|
|
+ Relation relation = new Relation();
|
|
|
+ relation.setStartId(relationNodeVO.getConceptId());
|
|
|
+ relation.setEndId(i.getConceptId());
|
|
|
+ relation.setRelationId(i.getRelationId());
|
|
|
+ relationList.add(relation);
|
|
|
+
|
|
|
+ if (ListUtil.isNotEmpty(i.getNodeList())) {
|
|
|
+ retList.addAll(repairRelationDataForAdd(i));
|
|
|
+ }
|
|
|
});
|
|
|
- relationOrderServiceImpl.saveBatch(relationOrderList);
|
|
|
+ retList.add(relationList);
|
|
|
}
|
|
|
-
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 处理关系节点-添加或者编辑前先删除掉
|
|
|
- * @param conceptId 当前概念id
|
|
|
- * @param relationNodeVO
|
|
|
- * @return
|
|
|
- */
|
|
|
- private List<Long> repairRelationDataForDelBeforeAdd(Long conceptId,RelationNodeVO relationNodeVO){
|
|
|
- List<Long> relationIdList = Lists.newArrayList();
|
|
|
-
|
|
|
- QueryWrapper<Relation> relationQe = new QueryWrapper<>();
|
|
|
- relationQe.eq("start_id", conceptId);
|
|
|
- if(relationNodeVO!=null&&relationNodeVO.getSonRelationId()!=null){
|
|
|
- relationQe.eq("relation_id", relationNodeVO.getSonRelationId());
|
|
|
- }else{
|
|
|
- relationQe.eq("relation_id", -999999l);
|
|
|
- }
|
|
|
-
|
|
|
- List<Relation> relationList = list(relationQe);
|
|
|
-
|
|
|
- if(ListUtil.isNotEmpty(relationList)){
|
|
|
- if(relationNodeVO!=null&&relationNodeVO.getSonTypeId()!=null){
|
|
|
- List<Long> conceptIdList = conceptFacade.getCompatibleTypeConceptIds(relationNodeVO.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,RelationNodeVO> conceptIdRnMap = Maps.newHashMap();
|
|
|
- if(relationNodeVO!=null&&ListUtil.isNotEmpty(relationNodeVO.getNodeList())){
|
|
|
- conceptIdRnMap = relationNodeVO.getNodeList().stream().collect(Collectors.toMap(RelationNodeVO::getConceptId, i->i));
|
|
|
- }
|
|
|
-
|
|
|
- for(Relation i : relationList){
|
|
|
- relationIdList.addAll(repairRelationDataForDelBeforeAdd(i.getEndId(),conceptIdRnMap.get(i.getEndId())));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return relationIdList;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 处理关系节点-添加或者编辑事件
|
|
|
- * @param relationNodeVO
|
|
|
- * @return
|
|
|
- */
|
|
|
- private List<List<Relation>> repairRelationDataForAdd(RelationNodeVO relationNodeVO){
|
|
|
- List<List<Relation>> retList = Lists.newArrayList();
|
|
|
-
|
|
|
- if(ListUtil.isNotEmpty(relationNodeVO.getNodeList())){
|
|
|
- List<Relation> relationList = Lists.newArrayList();
|
|
|
- relationNodeVO.getNodeList().forEach(i->{
|
|
|
- Relation relation = new Relation();
|
|
|
- relation.setStartId(relationNodeVO.getConceptId());
|
|
|
- relation.setEndId(i.getConceptId());
|
|
|
- relation.setRelationId(i.getRelationId());
|
|
|
- relationList.add(relation);
|
|
|
-
|
|
|
- if(ListUtil.isNotEmpty(i.getNodeList())){
|
|
|
- retList.addAll(repairRelationDataForAdd(i));
|
|
|
- }
|
|
|
- });
|
|
|
- retList.add(relationList);
|
|
|
- }
|
|
|
-
|
|
|
- return retList;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 医学术语关联维护/医学术语多层关联维护/化验子项维护-详情
|
|
|
- * @param relationContactDetailVO
|
|
|
- * @return
|
|
|
- */
|
|
|
- public RelationNodeDTO relationContactDetail(RelationContactDetailVO relationContactDetailVO){
|
|
|
- RelationNodeDTO relationNodeDTO = new RelationNodeDTO();
|
|
|
-
|
|
|
- Concept concept = conceptFacade.getById(relationContactDetailVO.getConceptId());
|
|
|
- relationNodeDTO.setConceptId(concept.getId());
|
|
|
- relationNodeDTO.setConceptName(concept.getLibName());
|
|
|
- relationNodeDTO.setConceptTypeId(concept.getLibType());
|
|
|
- relationNodeDTO.setConceptTypeName(LexiconTypeEnum.getName(concept.getLibType().intValue()));
|
|
|
- relationNodeDTO.setConceptNameType(concept.getLibName()+"("+LexiconTypeEnum.getName(concept.getLibType().intValue())+")");
|
|
|
- relationNodeDTO.setIsDeletedConcept(concept.getIsDeleted());
|
|
|
-
|
|
|
- relationNodeDTO.setNodeList(repairRelationDataForQuery(relationContactDetailVO.getConceptId(),relationContactDetailVO.getRelationIds(),relationContactDetailVO.getTypeIds(),null,concept.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.setConceptTypeName(LexiconTypeEnum.getName(i.getConceptTypeId().intValue()));
|
|
|
- i.setConceptNameType(i.getConceptName()+"("+LexiconTypeEnum.getName(i.getConceptTypeId().intValue())+")");
|
|
|
- i.setParentConceptTypeName(LexiconTypeEnum.getName(i.getParentConceptTypeId().intValue()));
|
|
|
- i.setParentConceptNameType(i.getParentConceptName()+"("+LexiconTypeEnum.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 removeRelationContactVO
|
|
|
- * @return
|
|
|
- */
|
|
|
- public Boolean removeRelationContact(RemoveRelationContactVO removeRelationContactVO){
|
|
|
- String currentUser = UserUtils.getCurrentPrincipleID();
|
|
|
+
|
|
|
+ return retList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 医学术语关联维护/医学术语多层关联维护/化验子项维护-详情
|
|
|
+ *
|
|
|
+ * @param relationContactDetailVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public RelationNodeDTO relationContactDetail(RelationContactDetailVO relationContactDetailVO) {
|
|
|
+ RelationNodeDTO relationNodeDTO = new RelationNodeDTO();
|
|
|
+
|
|
|
+ Concept concept = conceptFacade.getById(relationContactDetailVO.getConceptId());
|
|
|
+ relationNodeDTO.setConceptId(concept.getId());
|
|
|
+ relationNodeDTO.setConceptName(concept.getLibName());
|
|
|
+ relationNodeDTO.setConceptTypeId(concept.getLibType());
|
|
|
+ relationNodeDTO.setConceptTypeName(LexiconTypeEnum.getName(concept.getLibType().intValue()));
|
|
|
+ relationNodeDTO.setConceptNameType(concept.getLibName() + "("
|
|
|
+ + LexiconTypeEnum.getName(concept.getLibType().intValue()) + ")");
|
|
|
+ relationNodeDTO.setIsDeletedConcept(concept.getIsDeleted());
|
|
|
+
|
|
|
+ relationNodeDTO.setNodeList(repairRelationDataForQuery(relationContactDetailVO.getConceptId(),
|
|
|
+ relationContactDetailVO.getRelationIds(), relationContactDetailVO.getTypeIds(),
|
|
|
+ null, concept.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.setConceptTypeName(LexiconTypeEnum.getName(i.getConceptTypeId().intValue()));
|
|
|
+ i.setConceptNameType(i.getConceptName() + "(" + LexiconTypeEnum.getName(i.getConceptTypeId().intValue()) + ")");
|
|
|
+ i.setParentConceptTypeName(LexiconTypeEnum.getName(i.getParentConceptTypeId().intValue()));
|
|
|
+ i.setParentConceptNameType(i.getParentConceptName() + "("
|
|
|
+ + LexiconTypeEnum.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 removeRelationContactVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Boolean removeRelationContact(RemoveRelationContactVO removeRelationContactVO) {
|
|
|
+ String currentUser = UserUtils.getCurrentPrincipleID();
|
|
|
Date now = DateUtil.now();
|
|
|
- repairRelationDataForRemove(removeRelationContactVO.getConceptId(), removeRelationContactVO.getRelationId(),removeRelationContactVO.getIsDeleted(),currentUser,now);
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 化验子项维护-逻辑删除或者恢复-处理关系节点
|
|
|
- * @param conceptId
|
|
|
- * @param relationId
|
|
|
- * @param isDeleted
|
|
|
- * @param currentUser 操作人
|
|
|
- * @param now 操作时间
|
|
|
- */
|
|
|
- private void repairRelationDataForRemove(Long conceptId,Long relationId,String isDeleted,String currentUser,Date now){
|
|
|
- QueryWrapper<Relation> relationQe = new QueryWrapper<>();
|
|
|
- relationQe.eq("start_id", conceptId);
|
|
|
- relationQe.eq(relationId!=null,"relation_id", relationId);
|
|
|
- List<Relation> relationList = list(relationQe);
|
|
|
-
|
|
|
- if(relationList.size()==0){
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if(relationList.stream().map(i->i.getIsDeleted()).distinct().count()>1){
|
|
|
- throw new CommonException(CommonErrorCode.RPC_ERROR,"数据异常!");
|
|
|
- }
|
|
|
-
|
|
|
- String isDeleted_ = relationList.get(0).getIsDeleted();
|
|
|
- if(isDeleted.equals(isDeleted_)){
|
|
|
- if(isDeleted_.equals("Y")){
|
|
|
- throw new CommonException(CommonErrorCode.RPC_ERROR,"该数据已删除!");
|
|
|
- }
|
|
|
- if(isDeleted_.equals("N")){
|
|
|
- throw new CommonException(CommonErrorCode.RPC_ERROR,"该数据已恢复!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- Relation relation = new Relation();
|
|
|
- relation.setIsDeleted(isDeleted);
|
|
|
- relation.setGmtModified(now);
|
|
|
- relation.setModifier(currentUser);
|
|
|
- if(!update(relation, relationQe)){
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR);
|
|
|
- }
|
|
|
-
|
|
|
- relationList.forEach(i->{
|
|
|
- repairRelationDataForRemove(i.getEndId(), relationId,isDeleted,currentUser,now);
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 医学术语关联维护/医学术语多层关联维护-物理删除
|
|
|
- * @param removeRelationContactVO
|
|
|
- * @return
|
|
|
- */
|
|
|
- public Boolean deleteRelationContact(DeleteRelationContactVO deleteRelationContactVO){
|
|
|
- repairRelationDataForDelete(deleteRelationContactVO.getConceptId(), deleteRelationContactVO.getRelationIds(),deleteRelationContactVO.getTypeIds());
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 医学术语关联维护/医学术语多层关联维护-物理删除-处理关系节点
|
|
|
- * @param conceptId
|
|
|
- * @param relationId
|
|
|
- */
|
|
|
- private void repairRelationDataForDelete(Long conceptId,List<Long> relationIds,List<Long> typeIds){
|
|
|
- Long relationId = null,endTypeId = null;
|
|
|
- if(ListUtil.isNotEmpty(relationIds)){
|
|
|
- relationId = relationIds.remove(0);
|
|
|
- }
|
|
|
- if(ListUtil.isNotEmpty(typeIds)){
|
|
|
- endTypeId = typeIds.remove(0);
|
|
|
- }
|
|
|
-
|
|
|
- QueryWrapper<Relation> relationQe = new QueryWrapper<>();
|
|
|
- relationQe.eq("start_id", conceptId);
|
|
|
- relationQe.eq(relationId!=null,"relation_id", relationId);
|
|
|
- List<Relation> relationList = list(relationQe);
|
|
|
-
|
|
|
- if(endTypeId!=null&&ListUtil.isNotEmpty(relationList)){
|
|
|
- List<Long> conceptIdList = conceptFacade.getCompatibleTypeConceptIds(endTypeId,relationList.stream().map(i->i.getEndId()).collect(Collectors.toList()));
|
|
|
- relationList = relationList.stream().filter(i->conceptIdList.contains(i.getEndId())).collect(Collectors.toList());
|
|
|
- }
|
|
|
-
|
|
|
- if(ListUtil.isEmpty(relationList)){
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- List<Long> removeRelationIds = relationList.stream().map(i->i.getId()).collect(Collectors.toList());
|
|
|
-
|
|
|
- QueryWrapper<RelationOrder> relationOrderQe = new QueryWrapper<>();
|
|
|
- relationOrderQe.in("t_relation_id", removeRelationIds);
|
|
|
- if(!removeByIds(removeRelationIds)||!relationOrderFacade.remove(relationOrderQe)){
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR);
|
|
|
- }
|
|
|
-
|
|
|
- removeRelationIds.forEach(i->{
|
|
|
- repairRelationDataForDelete(i, Lists.newArrayList(relationIds), Lists.newArrayList(typeIds));
|
|
|
- });
|
|
|
- }
|
|
|
+ repairRelationDataForRemove(removeRelationContactVO.getConceptId(),
|
|
|
+ removeRelationContactVO.getRelationId(), removeRelationContactVO.getIsDeleted(),
|
|
|
+ currentUser, now);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 化验子项维护-逻辑删除或者恢复-处理关系节点
|
|
|
+ *
|
|
|
+ * @param conceptId
|
|
|
+ * @param relationId
|
|
|
+ * @param isDeleted
|
|
|
+ * @param currentUser 操作人
|
|
|
+ * @param now 操作时间
|
|
|
+ */
|
|
|
+ private void repairRelationDataForRemove(Long conceptId, Long relationId,
|
|
|
+ String isDeleted, String currentUser, Date now) {
|
|
|
+ QueryWrapper<Relation> relationQe = new QueryWrapper<>();
|
|
|
+ relationQe.eq("start_id", conceptId);
|
|
|
+ relationQe.eq(relationId != null, "relation_id", relationId);
|
|
|
+ List<Relation> relationList = list(relationQe);
|
|
|
+
|
|
|
+ if (relationList.size() == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (relationList.stream().map(i -> i.getIsDeleted()).distinct().count() > 1) {
|
|
|
+ throw new CommonException(CommonErrorCode.RPC_ERROR, "数据异常!");
|
|
|
+ }
|
|
|
+
|
|
|
+ String isDeleted_ = relationList.get(0).getIsDeleted();
|
|
|
+ if (isDeleted.equals(isDeleted_)) {
|
|
|
+ if (isDeleted_.equals("Y")) {
|
|
|
+ throw new CommonException(CommonErrorCode.RPC_ERROR, "该数据已删除!");
|
|
|
+ }
|
|
|
+ if (isDeleted_.equals("N")) {
|
|
|
+ throw new CommonException(CommonErrorCode.RPC_ERROR, "该数据已恢复!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Relation relation = new Relation();
|
|
|
+ relation.setIsDeleted(isDeleted);
|
|
|
+ relation.setGmtModified(now);
|
|
|
+ relation.setModifier(currentUser);
|
|
|
+ if (!update(relation, relationQe)) {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR);
|
|
|
+ }
|
|
|
+
|
|
|
+ relationList.forEach(i -> {
|
|
|
+ repairRelationDataForRemove(i.getEndId(), relationId, isDeleted, currentUser, now);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 医学术语关联维护/医学术语多层关联维护-物理删除
|
|
|
+ *
|
|
|
+ * @param deleteRelationContactVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Boolean deleteRelationContact(DeleteRelationContactVO deleteRelationContactVO) {
|
|
|
+ repairRelationDataForDelete(deleteRelationContactVO.getConceptId(),
|
|
|
+ deleteRelationContactVO.getRelationIds(),
|
|
|
+ deleteRelationContactVO.getTypeIds());
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 医学术语关联维护/医学术语多层关联维护-物理删除-处理关系节点
|
|
|
+ *
|
|
|
+ * @param conceptId
|
|
|
+ * @param relationIds
|
|
|
+ * @param typeIds
|
|
|
+ */
|
|
|
+ private void repairRelationDataForDelete(Long conceptId, List<Long> relationIds, List<Long> typeIds) {
|
|
|
+ Long relationId = null, endTypeId = null;
|
|
|
+ if (ListUtil.isNotEmpty(relationIds)) {
|
|
|
+ relationId = relationIds.remove(0);
|
|
|
+ }
|
|
|
+ if (ListUtil.isNotEmpty(typeIds)) {
|
|
|
+ endTypeId = typeIds.remove(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ QueryWrapper<Relation> relationQe = new QueryWrapper<>();
|
|
|
+ relationQe.eq("start_id", conceptId);
|
|
|
+ relationQe.eq(relationId != null, "relation_id", relationId);
|
|
|
+ List<Relation> relationList = list(relationQe);
|
|
|
+
|
|
|
+ if (endTypeId != null && ListUtil.isNotEmpty(relationList)) {
|
|
|
+ List<Long> conceptIdList = conceptFacade.getCompatibleTypeConceptIds(endTypeId,
|
|
|
+ relationList.stream().map(i -> i.getEndId()).collect(Collectors.toList()));
|
|
|
+ relationList = relationList.stream()
|
|
|
+ .filter(i -> conceptIdList.contains(i.getEndId())).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ListUtil.isEmpty(relationList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Long> removeRelationIds = relationList.stream().map(i -> i.getId()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ QueryWrapper<RelationOrder> relationOrderQe = new QueryWrapper<>();
|
|
|
+ relationOrderQe.in("t_relation_id", removeRelationIds);
|
|
|
+ if (!removeByIds(removeRelationIds) || !relationOrderFacade.remove(relationOrderQe)) {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR);
|
|
|
+ }
|
|
|
+
|
|
|
+ removeRelationIds.forEach(i -> {
|
|
|
+ repairRelationDataForDelete(i, Lists.newArrayList(relationIds), Lists.newArrayList(typeIds));
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
}
|