组织架构图,添加部门层级条件

pull/183/head
dxfeng 2 years ago
parent bba7288c5d
commit a18e7a3dc7

@ -44,6 +44,9 @@ public class ChartPO {
private String id; private String id;
private String key; private String key;
// 部门层级
private int departmentDepth;
public String getId() { public String getId() {
if (StringUtils.isNotBlank(ftype)) { if (StringUtils.isNotBlank(ftype)) {
switch (ftype) { switch (ftype) {

@ -61,6 +61,8 @@ public class ChartServiceImpl extends Service implements ChartService {
String isVirtual = Util.null2String(params.get("fisvitual")); String isVirtual = Util.null2String(params.get("fisvitual"));
showVirtual = "1".equals(isVirtual); showVirtual = "1".equals(isVirtual);
String depth = Util.null2String(params.get("level"));
// 初始化表名 // 初始化表名
initTableNameByClass(dimension); initTableNameByClass(dimension);
@ -88,7 +90,7 @@ public class ChartServiceImpl extends Service implements ChartService {
// 向下查询数据 // 向下查询数据
if (null != topChartPO) { if (null != topChartPO) {
findChildData(topChartPO, dataList); findChildData(topChartPO, dataList,Integer.parseInt(depth));
} }
@ -341,8 +343,9 @@ public class ChartServiceImpl extends Service implements ChartService {
* *
* @param topChartPO * @param topChartPO
* @param dataList * @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 fType = topChartPO.getFtype();
String fObjId = topChartPO.getFobjid(); String fObjId = topChartPO.getFobjid();
String sql = ""; String sql = "";
@ -399,18 +402,17 @@ public class ChartServiceImpl extends Service implements ChartService {
chartPO.setFobjid(recordSet.getString("id")); chartPO.setFobjid(recordSet.getString("id"));
chartPO.setFname(recordSet.getString("name")); chartPO.setFname(recordSet.getString("name"));
chartPO.setParentId(topChartPO.getId()); chartPO.setParentId(topChartPO.getId());
// 非部门元素展开
chartPO.setExpand(topChartPO.getId().startsWith("d") ? "0" : "1");
chartPO.setFisvitual(recordSet.getString("isvitual")); chartPO.setFisvitual(recordSet.getString("isvitual"));
chartPO.setHasChildren(getHasChildren(chartPO.getFtype(), chartPO.getFobjid()).toString()); chartPO.setHasChildren(getHasChildren(chartPO.getFtype(), chartPO.getFobjid()).toString());
chartPO.setDepartmentDepth(getDepartmentDepth(chartPO, topChartPO));
// 小于、等于所选层级元素展开
chartPO.setExpand(inDepth(selectDepth,chartPO.getDepartmentDepth()) ? "1" : "0");
currentList.add(chartPO); currentList.add(chartPO);
} }
for (ChartPO chartPO : currentList) { for (ChartPO chartPO : currentList) {
if (chartPO.getParentId().startsWith("d")) { if (inDepth(selectDepth, chartPO.getDepartmentDepth())) {
// 部门只展示一级 findChildData(chartPO, dataList, selectDepth);
continue;
} }
findChildData(chartPO, dataList);
} }
dataList.addAll(currentList); dataList.addAll(currentList);
} }
@ -490,6 +492,12 @@ public class ChartServiceImpl extends Service implements ChartService {
return false; return false;
} }
/**
*
*
* @param ids ID
* @return
*/
private String getDepartmentLeader(String ids) { private String getDepartmentLeader(String ids) {
if (StringUtils.isBlank(ids)) { if (StringUtils.isBlank(ids)) {
return ""; return "";
@ -504,4 +512,33 @@ public class ChartServiceImpl extends Service implements ChartService {
} }
return StringUtils.join(leaderList, ","); 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…
Cancel
Save