[color=red]
应用场景:[/color]当需构造根据部门ID构造从此部门一直到最顶层部门的字符串时,如:[color=red]XXX股份有限公司->XXX热电厂->运行分场->一厂->一厂运行三值->一厂汽机三班[/color],此时传入此方法的是"一厂汽机三班"对应的DEPID,则返回此构造好的字符串,不过得保证最顶级部门的PID为NULL或为"".
应用场景:[/color]当需构造根据部门ID构造从此部门一直到最顶层部门的字符串时,如:[color=red]XXX股份有限公司->XXX热电厂->运行分场->一厂->一厂运行三值->一厂汽机三班[/color],此时传入此方法的是"一厂汽机三班"对应的DEPID,则返回此构造好的字符串,不过得保证最顶级部门的PID为NULL或为"".
public String findFullPathDepNameByDepid(String depid) {
log.debug("finding SysDepartment fullPathDepName by property depid: " + depid);
StringBuffer fullName = new StringBuffer();
if (depid != null && !depid.equals("")) {
try {
do {//开始循环构造字符串
fullName.insert(0, findDepNameByDepid(depid) + "->");
depid = findPardepidByDepid(depid);//将上一部门的PID作为ID继续循环
} while ((depid != null) && (!depid.equals("")));//直至PID为NULL或为""
} catch (RuntimeException re) {
log.error("finding SysDepartment fullPathDepName by property depid failed",re);
throw re;
}
}
return fullName.toString().substring(0,fullName.toString().length() - 2);//将最后一个"->"去掉
}