Commit 9afe897f by 李小龙

整理代码

parent 11d07b81
...@@ -94,7 +94,7 @@ public class RedisConst { ...@@ -94,7 +94,7 @@ public class RedisConst {
public static final String ALARM_DEVICE_ID = "alarm:device:id:"; public static final String ALARM_DEVICE_ID = "alarm:device:id:";
public static final String ALARM_CONFIG_ORG_ID = "alram:config:org:id"; public static final String ALARM_CONFIG_ORG_ID = "alarm:config:org:id";
......
...@@ -453,7 +453,11 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg> ...@@ -453,7 +453,11 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
public List<PlatOrg> createOrgTree(List<PlatOrg> orgList) { public List<PlatOrg> createOrgTree(List<PlatOrg> orgList) {
Map<String, PlatOrg> orgMap = orgList.stream().collect(Collectors.toMap(BaseEntity::getId, vo -> vo, (a, b) -> a)); Map<String, PlatOrg> orgMap = orgList.stream().collect(Collectors.toMap(BaseEntity::getId, vo -> vo, (a, b) -> a));
for (PlatOrg platOrg : orgList) { for (PlatOrg platOrg : orgList) {
String[] split = platOrg.getPath().split(","); String path = platOrg.getPath();
if(StringUtils.isBlank(path)){
continue;
}
String[] split = path.split(",");
findParent(orgMap,platOrg,split,split.length-1); findParent(orgMap,platOrg,split,split.length-1);
} }
return orgList.stream().filter(vo->StringUtils.isBlank(vo.getParentNodeId())).collect(Collectors.toList()); return orgList.stream().filter(vo->StringUtils.isBlank(vo.getParentNodeId())).collect(Collectors.toList());
...@@ -514,7 +518,7 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg> ...@@ -514,7 +518,7 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
private LambdaQueryWrapper<PlatOrg> getLambdaQueryWrapper(PlatOrgQueryDTO dto) { private LambdaQueryWrapper<PlatOrg> getLambdaQueryWrapper(PlatOrgQueryDTO dto) {
LambdaQueryWrapper<PlatOrg> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PlatOrg> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PlatOrg::getParentId, dto.getParentId()) queryWrapper.eq(StringUtils.isNotBlank(dto.getParentId()), PlatOrg::getParentId, dto.getParentId())
.orderByDesc(BaseEntity::getUpdateDate); .orderByDesc(BaseEntity::getUpdateDate);
return queryWrapper; return queryWrapper;
} }
...@@ -524,8 +528,21 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg> ...@@ -524,8 +528,21 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
public List<PlatOrg> subOrgList(PlatOrgQueryDTO platOrgQueryDTO) { public List<PlatOrg> subOrgList(PlatOrgQueryDTO platOrgQueryDTO) {
LambdaQueryWrapper<PlatOrg> queryWrapper = getLambdaQueryWrapper(platOrgQueryDTO); LambdaQueryWrapper<PlatOrg> queryWrapper = getLambdaQueryWrapper(platOrgQueryDTO);
List<PlatOrg> list = list(queryWrapper);
List<PlatOrg> orgTree = createOrgTree2(list);
return orgTree;
}
private List<PlatOrg> createOrgTree2(List<PlatOrg> orgList){
if(CollectionUtils.isEmpty(orgList)){
return new ArrayList<>();
}
Map<String, List<PlatOrg>> parentMap = orgList.stream().collect(Collectors.groupingBy(PlatOrg::getParentId));
orgList.forEach(vo->{
vo.setChildren(parentMap.get(vo.getId()));
});
return list(queryWrapper); return orgList.stream().filter(vo->StringUtils.equals(vo.getParentId(),"1")).collect(Collectors.toList());
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment