|
@@ -199,50 +199,61 @@ public class ConceptFacade extends ConceptServiceImpl {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public List<GetAllForRelationDTO> getAllForRelation(GetAllForRelationVO getAllForRelationVO) {
|
|
public List<GetAllForRelationDTO> getAllForRelation(GetAllForRelationVO getAllForRelationVO) {
|
|
- List<GetAllForRelationDTO> retList = new ArrayList<>();
|
|
|
|
- if(StringUtil.isBlank(getAllForRelationVO.getName())&&getAllForRelationVO.getTypeId()==null){
|
|
|
|
- return retList;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- QueryWrapper<Concept> conceptQe = new QueryWrapper<>();
|
|
|
|
- conceptQe.eq("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
|
- conceptQe.like(StringUtil.isNotBlank(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.PARAM_IS_NULL, "关系类型id必传!");
|
|
|
|
- }
|
|
|
|
|
|
+ List<GetAllForRelationDTO> retList = Lists.newArrayList();
|
|
|
|
+
|
|
|
|
+ if(StringUtil.isNotBlank(getAllForRelationVO.getName())||getAllForRelationVO.getTypeId()!=null){
|
|
|
|
+ QueryWrapper<Concept> conceptQe = new QueryWrapper<>();
|
|
|
|
+ conceptQe.eq("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
|
+ conceptQe.like(StringUtil.isNotBlank(getAllForRelationVO.getName()),"lib_name", getAllForRelationVO.getName());
|
|
|
|
+ conceptQe.eq(getAllForRelationVO.getTypeId()!=null,"lib_type", getAllForRelationVO.getTypeId());
|
|
|
|
+ List<Concept> conceptList = list(conceptQe);
|
|
|
|
+
|
|
|
|
+ if(ListUtil.isNotEmpty(conceptList)){
|
|
|
|
+ Map<Long, Long> reCouMap = new HashMap<>();
|
|
|
|
+ if (getAllForRelationVO.getRelationPosition() != 3) {
|
|
|
|
+ if (getAllForRelationVO.getRelationId() == null) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "关系类型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) {
|
|
|
|
- if(getAllForRelationVO.getIsStartRootExt()==1){
|
|
|
|
- relationQe.eq(getAllForRelationVO.getRelationConceptId() != null, "end_id", getAllForRelationVO.getRelationConceptId());
|
|
|
|
- relationQe.and(wrapper->wrapper.in("start_id", conceptIdList).or(getAllForRelationVO.getRelationConceptId() == null).in("end_id", conceptIdList));
|
|
|
|
- reCouMap = relationFacade.list(relationQe).stream().collect(Collectors.groupingBy(Relation::getStartId, Collectors.counting()));
|
|
|
|
- }
|
|
|
|
- } else if(getAllForRelationVO.getRelationConceptId() != null) {
|
|
|
|
- relationQe.in("end_id", conceptIdList);
|
|
|
|
- relationQe.eq("start_id", getAllForRelationVO.getRelationConceptId());
|
|
|
|
- reCouMap = relationFacade.list(relationQe).stream().collect(Collectors.groupingBy(Relation::getEndId, Collectors.counting()));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ List<Long> conceptIdList = conceptList.stream().map(i -> i.getId()).collect(Collectors.toList());
|
|
|
|
+ QueryWrapper<Relation> relationQe = new QueryWrapper<>();
|
|
|
|
+ relationQe.eq("relation_id", getAllForRelationVO.getRelationId());
|
|
|
|
+
|
|
|
|
+ List<Long> relationConceptIdList = Lists.newArrayList();
|
|
|
|
+ if(getAllForRelationVO.getRelationTypeId() != null){
|
|
|
|
+ QueryWrapper<Concept> conceptQe1 = new QueryWrapper<>();
|
|
|
|
+ conceptQe1.eq("lib_type", getAllForRelationVO.getRelationTypeId());
|
|
|
|
+ relationConceptIdList = list(conceptQe1).stream().map(i->i.getId()).collect(Collectors.toList());
|
|
|
|
+ }
|
|
|
|
+ if(getAllForRelationVO.getRelationConceptId() != null){
|
|
|
|
+ relationConceptIdList.add(getAllForRelationVO.getRelationConceptId());
|
|
|
|
+ }
|
|
|
|
+ if(ListUtil.isNotEmpty(relationConceptIdList)){
|
|
|
|
+ if (getAllForRelationVO.getRelationPosition() == 1) {
|
|
|
|
+ relationQe.in("start_id", conceptIdList);
|
|
|
|
+ relationQe.in("end_id", relationConceptIdList);
|
|
|
|
+ reCouMap = relationFacade.list(relationQe).stream().collect(Collectors.groupingBy(Relation::getStartId, Collectors.counting()));
|
|
|
|
+ }else{
|
|
|
|
+ relationQe.in("end_id", conceptIdList);
|
|
|
|
+ relationQe.in("start_id", relationConceptIdList);
|
|
|
|
+ reCouMap = relationFacade.list(relationQe).stream().collect(Collectors.groupingBy(Relation::getEndId, Collectors.counting()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- for (Concept i : conceptList) {
|
|
|
|
- if (reCouMap.get(i.getId()) != null
|
|
|
|
- || (getAllForRelationVO.getExcludedConceptIds() != null && getAllForRelationVO.getExcludedConceptIds().contains(i.getId()))
|
|
|
|
- || (getAllForRelationVO.getRelationConceptId() != null && getAllForRelationVO.getRelationConceptId() == i.getId())) {
|
|
|
|
- continue;
|
|
|
|
|
|
+ for (Concept i : conceptList) {
|
|
|
|
+ if (reCouMap.get(i.getId()) != null
|
|
|
|
+ || (getAllForRelationVO.getExcludedConceptIds() != null && getAllForRelationVO.getExcludedConceptIds().contains(i.getId()))
|
|
|
|
+ || (getAllForRelationVO.getRelationConceptId() != null && getAllForRelationVO.getRelationConceptId() == i.getId())) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ GetAllForRelationDTO getAllForRelationDTO = new GetAllForRelationDTO();
|
|
|
|
+ getAllForRelationDTO.setConceptId(i.getId());
|
|
|
|
+ getAllForRelationDTO.setConceptName(i.getLibName());
|
|
|
|
+ getAllForRelationDTO.setConceptNameType(i.getLibName()+"("+LexiconTypeEnum.getName(i.getLibType().intValue())+")");
|
|
|
|
+ retList.add(getAllForRelationDTO);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- GetAllForRelationDTO getAllForRelationDTO = new GetAllForRelationDTO();
|
|
|
|
- getAllForRelationDTO.setConceptId(i.getId());
|
|
|
|
- getAllForRelationDTO.setConceptName(i.getLibName());
|
|
|
|
- getAllForRelationDTO.setConceptNameType(i.getLibName()+"("+LexiconTypeEnum.getName(i.getLibType().intValue())+")");
|
|
|
|
- retList.add(getAllForRelationDTO);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
return retList;
|
|
return retList;
|