顺胜组织架构图虚拟维度默认值控制

上海顺胜组织架构图v2
Chengliang 11 months ago
parent 22bdc54741
commit fb415853fd

@ -24,6 +24,7 @@ public class CompanyTreePO {
private boolean disabled;
private int level;
private int depth;
private int showorder;
public boolean getIsLeaf() {
return isLeaf;

@ -85,13 +85,17 @@ public class ChartServiceImpl extends Service implements ChartService {
return result;
}
Map<String, String> map = getRootAndFclass();
// 根结点
String root = Util.null2String(params.get("root"));
root = StringUtils.isBlank(root) ? "0" : root;
// 维度
String dimension = Util.null2String(params.get("fclass"));
dimension = StringUtils.isBlank(dimension) ? "0" : dimension;
//dimension = StringUtils.isBlank(dimension) ? "0" : dimension;
dimension = StringUtils.isBlank(dimension) ? map.get("fclass") : dimension;
// 是否展示虚拟组织
String isVirtual = Util.null2String(params.get("fisvitual"));
@ -1857,4 +1861,25 @@ public class ChartServiceImpl extends Service implements ChartService {
.colorCheck(colorCheck)
.build();
}
/**
* showorder
* @return
*/
private Map<String,String> getRootAndFclass(){
Map<String,String> map = new HashMap<>();
RecordSet rs = new RecordSet();
String fclass = "0";
rs.executeQuery("select id from HrmCompanyVirtual order by showorder asc");
if(rs.next()) {
fclass = Util.null2String(rs.getString("id"));
map.put("fclass",fclass);
}
rs.executeQuery("select id from hrmsubcompanyvirtual where companyid = ? order by showorder asc",fclass);
if (rs.next()) {
map.put("root",Util.null2String(rs.getString("id")));
}
return map;
}
}

@ -41,44 +41,42 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
public Map<String, Object> getOptionCondition(Map<String, Object> request2Map, User user) {
Map<String, Object> result = new HashMap<>();
RecordSet rs = new RecordSet();
Map<String, Object> defaultItem = new HashMap<>();
Map<String, Object> defaultItem = new HashMap<>(4);
rs.executeQuery("select companyname from hrmcompany");
rs.next();
int fkey = 0;
defaultItem.put("key", fkey++);
defaultItem.put("id", "0");
defaultItem.put("companyname", Util.null2String(rs.getString("companyname")));
rs.executeQuery("select id, companyname from HrmCompanyVirtual order by id");
rs.executeQuery("select id, companyname,showorder from HrmCompanyVirtual order by id");
List<Map<String, Object>> fclasslist = new ArrayList<>();
fclasslist.add(defaultItem);
while (rs.next()) {
Map<String, Object> item = new HashMap<>();
Map<String, Object> item = new HashMap<>(4);
item.put("key", fkey++);
item.put("id", rs.getString("id"));
item.put("companyname", rs.getString("companyname"));
float showorder = Util.getFloatValue(rs.getString("showorder"));
item.put("showorder", (int) showorder);
fclasslist.add(item);
}
List<CompanyTreePO> companyTree = new ArrayList<>();
String sql = "select id as id, id as value, subcompanyname as title, supsubcomid as pId from hrmsubcompany where (canceled is null or canceled != '1') and " + DBType.get(new RecordSet().getDBType()).ifNull("supsubcomid", "0") + " = '0'";
// 一级分部数据分权处理
String dimension = Util.null2String(request2Map.get("fclass"));
//版本id
String id = Util.null2String(request2Map.get("id"));
boolean isRealDimension = StringUtils.isBlank(dimension) || "0".equals(dimension);
boolean isRealTime = StringUtils.isBlank(id) || "0".equals(id);
if (isRealTime && user.getUID() != 1 && isRealDimension) {
DetachUtil detachUtil = new DetachUtil(user);
if(detachUtil.isDETACH()) {
String ids = detachUtil.getJclRoleLevels();
sql = sql + " and id in (" + ids + ")";
}
}
Optional<Map<String, Object>> minCompany = fclasslist.stream()
.filter(map -> map.containsKey("showorder"))
.min(Comparator.comparingInt(map -> (int) map.get("showorder")));
minCompany.ifPresent(map -> result.put("fclass", map.get("id")));
Map<String, Object> params = new HashMap<>(2);
params.put("fclass",result.get("fclass"));
Map<String, Object> subCompanyTree = getSubCompanyTree(params);
List<CompanyTreePO> companyTree = (List<CompanyTreePO>)subCompanyTree.get("companyTree");
Optional<CompanyTreePO> minElement = companyTree.stream()
.min(Comparator.comparingInt(CompanyTreePO::getShoworder));
minElement.ifPresent(companyTreePO -> result.put("root",companyTreePO.getId()));
rs.executeQuery(sql);
while (rs.next()) {
companyTree.add(CompanyTreePO.builder().id(rs.getString("id")).pId(rs.getString("pId")).value(rs.getString("value")).title(rs.getString("title")).isLeaf(judgeTreeLeaf("select id from hrmsubcompany where (canceled is null or canceled != '1') and supsubcomid = ?", rs.getString("id"))).build());
}
result.put("api_status", true);
result.put("fclasslist", fclasslist);
result.put("companyTree", companyTree);
@ -116,7 +114,7 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
}
}
if (StringUtils.isNotBlank(fclass) && !"0".equals(fclass)) {
sql = "select id as id, id as value, subcompanyname as title, supsubcomid as pId from hrmsubcompanyvirtual where (canceled is null or canceled != '1') and " + DBType.get(new RecordSet().getDBType()).ifNull("supsubcomid", "0") + " = ? and companyid = '" + fclass + "'";
sql = "select id as id, id as value, subcompanyname as title, supsubcomid as pId,showorder from hrmsubcompanyvirtual where (canceled is null or canceled != '1') and " + DBType.get(new RecordSet().getDBType()).ifNull("supsubcomid", "0") + " = ? and companyid = '" + fclass + "'";
}
} else {
sql = "select subcompanyid as id, id as value, subcompanyname as title, supsubcompanyid as pId from jcl_chart_subcompany where (canceled is null or canceled != '1') and " + DBType.get(new RecordSet().getDBType()).ifNull("supsubcompanyid", "0") + " = ? ";
@ -129,7 +127,8 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
}
rs.executeQuery(sql, subcompany);
while (rs.next()) {
companyTree.add(CompanyTreePO.builder().id(rs.getString("id")).pId(rs.getString("pId")).value(rs.getString("value")).title(rs.getString("title")).isLeaf(judgeTreeLeaf(judgeTreeLeafSql, rs.getString("id"))).build());
float showorder = Util.getFloatValue(rs.getString("showorder"));
companyTree.add(CompanyTreePO.builder().id(rs.getString("id")).pId(rs.getString("pId")).value(rs.getString("value")).title(rs.getString("title")).isLeaf(judgeTreeLeaf(judgeTreeLeafSql, rs.getString("id"))).showorder((int)showorder).build());
}

Loading…
Cancel
Save