根据ID拼装部门路径

// 根据ID拼装部门路径

private static String getsrt(List sysDepts, Long id) {

StringBuffer str = new StringBuffer();

final Long[] ids = {id};

if (sysDepts.stream().noneMatch(sysDept -> sysDept.getId().longValue() == id.longValue()))

return null;

for (int i = 0; i < sysDepts.size(); i++) {

if (ids[0] != null && ids[0].longValue() > 0) {

//判断id在组织单元表中是否存在,如果不存在,则返回已经拼装的路径;如果存在继续遍历

if(sysDepts.stream().noneMatch(sysDept -> sysDept.getId().longValue() == ids[0].longValue())){

str.deleteCharAt(str.length() - 1);

return str.toString();

}

for (SysDept sysDept : sysDepts) {

if (ids[0].longValue() == sysDept.getId().longValue()) {

str.insert(0,sysDept.getDeptName() + "/");

ids[0] = sysDept.getParentId();

break;

}

}

} else {

break;

}

}

str.deleteCharAt(str.length() - 1);

return str.toString();

}

发表评论
留言与评论(共有 0 条评论) “”
   
验证码:

相关文章

推荐文章