Browse Source

代码优化

gaodm 5 years ago
parent
commit
5ce6c89751

+ 23 - 23
knowledgeman-service/src/main/java/com/diagbot/facade/RelationContactFacade.java

@@ -168,10 +168,10 @@ public class RelationContactFacade extends RelationServiceImpl {
         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()));
+                        relationList.stream().map(i -> i.getEndId()).collect(Collectors.toList()));
                 if (conceptIdList != null) {
                     relationList = relationList.stream()
-							.filter(i -> conceptIdList.contains(i.getEndId())).collect(Collectors.toList());
+                            .filter(i -> conceptIdList.contains(i.getEndId())).collect(Collectors.toList());
                 }
             }
 
@@ -181,12 +181,12 @@ public class RelationContactFacade extends RelationServiceImpl {
                 Map<Long, RelationNodeVO> conceptIdRnMap = Maps.newHashMap();
                 if (relationNodeVO != null && ListUtil.isNotEmpty(relationNodeVO.getNodeList())) {
                     conceptIdRnMap = relationNodeVO.getNodeList()
-							.stream().collect(Collectors.toMap(RelationNodeVO::getConceptId, i -> i));
+                            .stream().collect(Collectors.toMap(RelationNodeVO::getConceptId, i -> i));
                 }
 
                 for (Relation i : relationList) {
                     relationIdList.addAll(repairRelationDataForDelBeforeAdd(i.getEndId(),
-							conceptIdRnMap.get(i.getEndId())));
+                            conceptIdRnMap.get(i.getEndId())));
                 }
             }
         }
@@ -237,12 +237,12 @@ public class RelationContactFacade extends RelationServiceImpl {
         relationNodeDTO.setConceptTypeId(concept.getLibType());
         relationNodeDTO.setConceptTypeName(LexiconTypeEnum.getName(concept.getLibType().intValue()));
         relationNodeDTO.setConceptNameType(concept.getLibName() + "("
-				+ LexiconTypeEnum.getName(concept.getLibType().intValue()) + ")");
+                + LexiconTypeEnum.getName(concept.getLibType().intValue()) + ")");
         relationNodeDTO.setIsDeletedConcept(concept.getIsDeleted());
 
         relationNodeDTO.setNodeList(repairRelationDataForQuery(relationContactDetailVO.getConceptId(),
-				relationContactDetailVO.getRelationIds(), relationContactDetailVO.getTypeIds(),
-				null, concept.getIsDeleted()));
+                relationContactDetailVO.getRelationIds(), relationContactDetailVO.getTypeIds(),
+                null, concept.getIsDeleted()));
 
         return relationNodeDTO;
     }
@@ -258,8 +258,8 @@ public class RelationContactFacade extends RelationServiceImpl {
      * @return
      */
     private List<RelationNodeDTO> repairRelationDataForQuery(Long conceptId, List<Long> relationIds,
-															 List<Long> typeIds, List<Long> hookConceptIds,
-															 String isDeletedParent) {
+                                                             List<Long> typeIds, List<Long> hookConceptIds,
+                                                             String isDeletedParent) {
         if (hookConceptIds == null) {
             hookConceptIds = new ArrayList<>();
             hookConceptIds.add(conceptId);
@@ -282,18 +282,18 @@ public class RelationContactFacade extends RelationServiceImpl {
             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()) + ")");
+                    + LexiconTypeEnum.getName(i.getParentConceptTypeId().intValue()) + ")");
             i.setIsDeletedConcept(
-            		isDeletedParent.equals(IsDeleteEnum.Y.getKey()) ? IsDeleteEnum.Y.getKey() : i.getIsDeletedConcept()
-			);
+                    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()));
+                        Lists.newArrayList(relationIds), Lists.newArrayList(typeIds),
+                        hookConceptIds_, i.getIsDeletedConcept()));
             }
         }
 
@@ -310,8 +310,8 @@ public class RelationContactFacade extends RelationServiceImpl {
         String currentUser = UserUtils.getCurrentPrincipleID();
         Date now = DateUtil.now();
         repairRelationDataForRemove(removeRelationContactVO.getConceptId(),
-				removeRelationContactVO.getRelationId(), removeRelationContactVO.getIsDeleted(),
-				currentUser, now);
+                removeRelationContactVO.getRelationId(), removeRelationContactVO.getIsDeleted(),
+                currentUser, now);
         return true;
     }
 
@@ -325,7 +325,7 @@ public class RelationContactFacade extends RelationServiceImpl {
      * @param now         操作时间
      */
     private void repairRelationDataForRemove(Long conceptId, Long relationId,
-											 String isDeleted, String currentUser, Date now) {
+                                             String isDeleted, String currentUser, Date now) {
         QueryWrapper<Relation> relationQe = new QueryWrapper<>();
         relationQe.eq("start_id", conceptId);
         relationQe.eq(relationId != null, "relation_id", relationId);
@@ -341,10 +341,10 @@ public class RelationContactFacade extends RelationServiceImpl {
 
         String isDeleted_ = relationList.get(0).getIsDeleted();
         if (isDeleted.equals(isDeleted_)) {
-            if (isDeleted_.equals("Y")) {
+            if (isDeleted_.equals(IsDeleteEnum.Y.getKey())) {
                 throw new CommonException(CommonErrorCode.RPC_ERROR, "该数据已删除!");
             }
-            if (isDeleted_.equals("N")) {
+            if (isDeleted_.equals(IsDeleteEnum.N.getKey())) {
                 throw new CommonException(CommonErrorCode.RPC_ERROR, "该数据已恢复!");
             }
         }
@@ -370,8 +370,8 @@ public class RelationContactFacade extends RelationServiceImpl {
      */
     public Boolean deleteRelationContact(DeleteRelationContactVO deleteRelationContactVO) {
         repairRelationDataForDelete(deleteRelationContactVO.getConceptId(),
-				deleteRelationContactVO.getRelationIds(),
-				deleteRelationContactVO.getTypeIds());
+                deleteRelationContactVO.getRelationIds(),
+                deleteRelationContactVO.getTypeIds());
         return true;
     }
 
@@ -398,9 +398,9 @@ public class RelationContactFacade extends RelationServiceImpl {
 
         if (endTypeId != null && ListUtil.isNotEmpty(relationList)) {
             List<Long> conceptIdList = conceptFacade.getCompatibleTypeConceptIds(endTypeId,
-					relationList.stream().map(i -> i.getEndId()).collect(Collectors.toList()));
+                    relationList.stream().map(i -> i.getEndId()).collect(Collectors.toList()));
             relationList = relationList.stream()
-					.filter(i -> conceptIdList.contains(i.getEndId())).collect(Collectors.toList());
+                    .filter(i -> conceptIdList.contains(i.getEndId())).collect(Collectors.toList());
         }
 
         if (ListUtil.isEmpty(relationList)) {