|
@@ -9,19 +9,19 @@ import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
- * <P>
|
|
|
+ * <p>
|
|
|
* 对应部门的表,处理并查找树级数据
|
|
|
- * <P>
|
|
|
+ * <p>
|
|
|
*
|
|
|
* @Author: Steve
|
|
|
* @Date: 2019-01-22
|
|
|
*/
|
|
|
public class FindsDepartsChildrenUtil {
|
|
|
|
|
|
- //部门树信息-树结构
|
|
|
- //private static List<SysDepartTreeModel> sysDepartTreeList = new ArrayList<SysDepartTreeModel>();
|
|
|
+ //部门树信息-树结构
|
|
|
+ //private static List<SysDepartTreeModel> sysDepartTreeList = new ArrayList<SysDepartTreeModel>();
|
|
|
|
|
|
- //部门树id-树结构
|
|
|
+ //部门树id-树结构
|
|
|
//private static List<DepartIdModel> idList = new ArrayList<>();
|
|
|
|
|
|
|
|
@@ -32,7 +32,7 @@ public class FindsDepartsChildrenUtil {
|
|
|
public static List<SysDepartTreeModel> wrapTreeDataToTreeList(List<SysDepart> recordList) {
|
|
|
// 在该方法每请求一次,都要对全局list集合进行一次清理
|
|
|
//idList.clear();
|
|
|
- List<DepartIdModel> idList = new ArrayList<DepartIdModel>();
|
|
|
+ List<DepartIdModel> idList = new ArrayList<DepartIdModel>();
|
|
|
List<SysDepartTreeModel> records = new ArrayList<>();
|
|
|
for (int i = 0; i < recordList.size(); i++) {
|
|
|
SysDepart depart = recordList.get(i);
|
|
@@ -45,6 +45,7 @@ public class FindsDepartsChildrenUtil {
|
|
|
|
|
|
/**
|
|
|
* 获取 DepartIdModel
|
|
|
+ *
|
|
|
* @param recordList
|
|
|
* @return
|
|
|
*/
|
|
@@ -55,6 +56,11 @@ public class FindsDepartsChildrenUtil {
|
|
|
List<SysDepartTreeModel> records = new ArrayList<>();
|
|
|
for (int i = 0; i < recordList.size(); i++) {
|
|
|
SysDepart depart = recordList.get(i);
|
|
|
+ if (!Check.isNull(depart.getLeaderName())) {
|
|
|
+ depart.setTitle(depart.getDepartName().concat("(").concat(depart.getLeaderName()).concat(")"));
|
|
|
+ } else {
|
|
|
+ depart.setTitle(depart.getDepartName());
|
|
|
+ }
|
|
|
records.add(new SysDepartTreeModel(depart));
|
|
|
}
|
|
|
findChildren(records, idList);
|
|
@@ -77,7 +83,7 @@ public class FindsDepartsChildrenUtil {
|
|
|
departIdList.add(departIdModel);
|
|
|
}
|
|
|
}
|
|
|
- getGrandChildren(treeList,recordList,departIdList);
|
|
|
+ getGrandChildren(treeList, recordList, departIdList);
|
|
|
|
|
|
//idList = departIdList;
|
|
|
return treeList;
|
|
@@ -85,16 +91,16 @@ public class FindsDepartsChildrenUtil {
|
|
|
|
|
|
/**
|
|
|
* queryTreeList的子方法====3====
|
|
|
- *该方法是找到顶级父类下的所有子节点集合并封装到TreeList集合
|
|
|
+ * 该方法是找到顶级父类下的所有子节点集合并封装到TreeList集合
|
|
|
*/
|
|
|
- private static void getGrandChildren(List<SysDepartTreeModel> treeList,List<SysDepartTreeModel> recordList,List<DepartIdModel> idList) {
|
|
|
+ private static void getGrandChildren(List<SysDepartTreeModel> treeList, List<SysDepartTreeModel> recordList, List<DepartIdModel> idList) {
|
|
|
|
|
|
for (int i = 0; i < treeList.size(); i++) {
|
|
|
SysDepartTreeModel model = treeList.get(i);
|
|
|
DepartIdModel idModel = idList.get(i);
|
|
|
for (int i1 = 0; i1 < recordList.size(); i1++) {
|
|
|
SysDepartTreeModel m = recordList.get(i1);
|
|
|
- if (m.getParentId()!=null && m.getParentId().equals(model.getId())) {
|
|
|
+ if (m.getParentId() != null && m.getParentId().equals(model.getId())) {
|
|
|
model.getChildren().add(m);
|
|
|
DepartIdModel dim = new DepartIdModel().convert(m);
|
|
|
idModel.getChildren().add(dim);
|
|
@@ -117,7 +123,7 @@ public class FindsDepartsChildrenUtil {
|
|
|
if (model.getChildren().size() == 0) {
|
|
|
model.setChildren(null);
|
|
|
model.setIsLeaf(true);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
setEmptyChildrenAsNull(model.getChildren());
|
|
|
model.setIsLeaf(false);
|
|
|
}
|