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

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

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

@ -85,13 +85,17 @@ public class ChartServiceImpl extends Service implements ChartService {
return result; return result;
} }
Map<String, String> map = getRootAndFclass();
// 根结点 // 根结点
String root = Util.null2String(params.get("root")); String root = Util.null2String(params.get("root"));
root = StringUtils.isBlank(root) ? "0" : root; root = StringUtils.isBlank(root) ? "0" : root;
// 维度 // 维度
String dimension = Util.null2String(params.get("fclass")); 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")); String isVirtual = Util.null2String(params.get("fisvitual"));
@ -1857,4 +1861,25 @@ public class ChartServiceImpl extends Service implements ChartService {
.colorCheck(colorCheck) .colorCheck(colorCheck)
.build(); .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) { public Map<String, Object> getOptionCondition(Map<String, Object> request2Map, User user) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
Map<String, Object> defaultItem = new HashMap<>(); Map<String, Object> defaultItem = new HashMap<>(4);
rs.executeQuery("select companyname from hrmcompany"); rs.executeQuery("select companyname from hrmcompany");
rs.next(); rs.next();
int fkey = 0; int fkey = 0;
defaultItem.put("key", fkey++); defaultItem.put("key", fkey++);
defaultItem.put("id", "0"); defaultItem.put("id", "0");
defaultItem.put("companyname", Util.null2String(rs.getString("companyname"))); 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<>(); List<Map<String, Object>> fclasslist = new ArrayList<>();
fclasslist.add(defaultItem); fclasslist.add(defaultItem);
while (rs.next()) { while (rs.next()) {
Map<String, Object> item = new HashMap<>(); Map<String, Object> item = new HashMap<>(4);
item.put("key", fkey++); item.put("key", fkey++);
item.put("id", rs.getString("id")); item.put("id", rs.getString("id"));
item.put("companyname", rs.getString("companyname")); item.put("companyname", rs.getString("companyname"));
float showorder = Util.getFloatValue(rs.getString("showorder"));
item.put("showorder", (int) showorder);
fclasslist.add(item); fclasslist.add(item);
} }
List<CompanyTreePO> companyTree = new ArrayList<>(); Optional<Map<String, Object>> minCompany = fclasslist.stream()
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'"; .filter(map -> map.containsKey("showorder"))
// 一级分部数据分权处理 .min(Comparator.comparingInt(map -> (int) map.get("showorder")));
String dimension = Util.null2String(request2Map.get("fclass"));
//版本id minCompany.ifPresent(map -> result.put("fclass", map.get("id")));
String id = Util.null2String(request2Map.get("id"));
boolean isRealDimension = StringUtils.isBlank(dimension) || "0".equals(dimension); Map<String, Object> params = new HashMap<>(2);
boolean isRealTime = StringUtils.isBlank(id) || "0".equals(id); params.put("fclass",result.get("fclass"));
if (isRealTime && user.getUID() != 1 && isRealDimension) { Map<String, Object> subCompanyTree = getSubCompanyTree(params);
DetachUtil detachUtil = new DetachUtil(user); List<CompanyTreePO> companyTree = (List<CompanyTreePO>)subCompanyTree.get("companyTree");
if(detachUtil.isDETACH()) {
String ids = detachUtil.getJclRoleLevels(); Optional<CompanyTreePO> minElement = companyTree.stream()
sql = sql + " and id in (" + ids + ")"; .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("api_status", true);
result.put("fclasslist", fclasslist); result.put("fclasslist", fclasslist);
result.put("companyTree", companyTree); result.put("companyTree", companyTree);
@ -116,7 +114,7 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
} }
} }
if (StringUtils.isNotBlank(fclass) && !"0".equals(fclass)) { 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 { } 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") + " = ? "; 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); rs.executeQuery(sql, subcompany);
while (rs.next()) { 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