组织架构图,添加部门层级条件
This commit is contained in:
parent
bba7288c5d
commit
a18e7a3dc7
|
|
@ -44,6 +44,9 @@ public class ChartPO {
|
|||
private String id;
|
||||
private String key;
|
||||
|
||||
// 部门层级
|
||||
private int departmentDepth;
|
||||
|
||||
public String getId() {
|
||||
if (StringUtils.isNotBlank(ftype)) {
|
||||
switch (ftype) {
|
||||
|
|
|
|||
|
|
@ -61,6 +61,8 @@ public class ChartServiceImpl extends Service implements ChartService {
|
|||
String isVirtual = Util.null2String(params.get("fisvitual"));
|
||||
showVirtual = "1".equals(isVirtual);
|
||||
|
||||
String depth = Util.null2String(params.get("level"));
|
||||
|
||||
// 初始化表名
|
||||
initTableNameByClass(dimension);
|
||||
|
||||
|
|
@ -88,7 +90,7 @@ public class ChartServiceImpl extends Service implements ChartService {
|
|||
|
||||
// 向下查询数据
|
||||
if (null != topChartPO) {
|
||||
findChildData(topChartPO, dataList);
|
||||
findChildData(topChartPO, dataList,Integer.parseInt(depth));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -339,10 +341,11 @@ public class ChartServiceImpl extends Service implements ChartService {
|
|||
/**
|
||||
* 查询实时数据,子节点元素
|
||||
*
|
||||
* @param topChartPO 父级元素
|
||||
* @param dataList 所有元素集合
|
||||
* @param topChartPO 父级元素
|
||||
* @param dataList 所有元素集合
|
||||
* @param selectDepth 所选部门层级
|
||||
*/
|
||||
private void findChildData(ChartPO topChartPO, List<ChartPO> dataList) {
|
||||
private void findChildData(ChartPO topChartPO, List<ChartPO> dataList,Integer selectDepth) {
|
||||
String fType = topChartPO.getFtype();
|
||||
String fObjId = topChartPO.getFobjid();
|
||||
String sql = "";
|
||||
|
|
@ -399,18 +402,17 @@ public class ChartServiceImpl extends Service implements ChartService {
|
|||
chartPO.setFobjid(recordSet.getString("id"));
|
||||
chartPO.setFname(recordSet.getString("name"));
|
||||
chartPO.setParentId(topChartPO.getId());
|
||||
// 非部门元素展开
|
||||
chartPO.setExpand(topChartPO.getId().startsWith("d") ? "0" : "1");
|
||||
chartPO.setFisvitual(recordSet.getString("isvitual"));
|
||||
chartPO.setHasChildren(getHasChildren(chartPO.getFtype(), chartPO.getFobjid()).toString());
|
||||
chartPO.setDepartmentDepth(getDepartmentDepth(chartPO, topChartPO));
|
||||
// 小于、等于所选层级元素展开
|
||||
chartPO.setExpand(inDepth(selectDepth,chartPO.getDepartmentDepth()) ? "1" : "0");
|
||||
currentList.add(chartPO);
|
||||
}
|
||||
for (ChartPO chartPO : currentList) {
|
||||
if (chartPO.getParentId().startsWith("d")) {
|
||||
// 部门只展示一级
|
||||
continue;
|
||||
if (inDepth(selectDepth, chartPO.getDepartmentDepth())) {
|
||||
findChildData(chartPO, dataList, selectDepth);
|
||||
}
|
||||
findChildData(chartPO, dataList);
|
||||
}
|
||||
dataList.addAll(currentList);
|
||||
}
|
||||
|
|
@ -490,6 +492,12 @@ public class ChartServiceImpl extends Service implements ChartService {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门负责人
|
||||
*
|
||||
* @param ids 部门负责人ID
|
||||
* @return 人员名称
|
||||
*/
|
||||
private String getDepartmentLeader(String ids) {
|
||||
if (StringUtils.isBlank(ids)) {
|
||||
return "";
|
||||
|
|
@ -504,4 +512,33 @@ public class ChartServiceImpl extends Service implements ChartService {
|
|||
}
|
||||
return StringUtils.join(leaderList, ",");
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前元素是否在展开层级内
|
||||
*
|
||||
* @param selectDepth 所选部门层级
|
||||
* @param currentDepth 当前部门层级
|
||||
*/
|
||||
private boolean inDepth(Integer selectDepth, Integer currentDepth) {
|
||||
if (selectDepth == 1) {
|
||||
return true;
|
||||
}
|
||||
return currentDepth < selectDepth + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前部门层级
|
||||
*
|
||||
* @param chartPO 当前元素
|
||||
* @param parentChart 上级元素
|
||||
*/
|
||||
private Integer getDepartmentDepth(ChartPO chartPO, ChartPO parentChart) {
|
||||
if ("2".equals(chartPO.getFtype())) {
|
||||
if ("1".equals(parentChart.getFtype())) {
|
||||
return 2;
|
||||
}
|
||||
return parentChart.getDepartmentDepth() + 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue