diff --git a/src/com/engine/organization/service/impl/ChartServiceImpl.java b/src/com/engine/organization/service/impl/ChartServiceImpl.java index 4f005b5a..e43ee6cb 100644 --- a/src/com/engine/organization/service/impl/ChartServiceImpl.java +++ b/src/com/engine/organization/service/impl/ChartServiceImpl.java @@ -525,34 +525,47 @@ public class ChartServiceImpl extends Service implements ChartService { */ private void addParentTreeId(List expandedKeys,String expandedKeyStr) { if (StringUtils.isNotBlank(expandedKeyStr)) { - expandedKeyStr = expandedKeyStr.replace("d", ""); try { - String[] array; - // 上级分部ID - String subcompanyid1 = new DepartmentComInfo().getSubcompanyid1(expandedKeyStr); - if (StringUtils.isNotBlank(subcompanyid1)) { - String allSupCompany = new SubCompanyComInfo().getAllSupCompany(subcompanyid1); - array = allSupCompany.split(","); + if (expandedKeyStr.startsWith("d")) { + expandedKeyStr = expandedKeyStr.replace("d", ""); + String[] array; + // 上级分部ID + String subcompanyid1 = new DepartmentComInfo().getSubcompanyid1(expandedKeyStr); + if (StringUtils.isNotBlank(subcompanyid1)) { + String allSupCompany = new SubCompanyComInfo().getAllSupCompany(subcompanyid1); + array = allSupCompany.split(","); + for (String supCompany : array) { + if (StringUtils.isBlank(supCompany)) { + continue; + } + expandedKeys.add("s" + supCompany); + } + expandedKeys.add("s" + subcompanyid1); + } + + // 上级部门ID + String allSupDepartment = new DepartmentComInfo().getAllSupDepartment(expandedKeyStr); + array = allSupDepartment.split(","); + for (String supDepartment : array) { + if (StringUtils.isBlank(supDepartment)) { + continue; + } + expandedKeys.add("d" + supDepartment); + } + expandedKeys.add("d" + expandedKeyStr); + } else { + // 上级分部ID + String allSupCompany = new SubCompanyComInfo().getAllSupCompany(expandedKeyStr); + String[] array = allSupCompany.split(","); for (String supCompany : array) { if (StringUtils.isBlank(supCompany)) { continue; } expandedKeys.add("s" + supCompany); } - expandedKeys.add("s" + subcompanyid1); - } + expandedKeys.add("s" + expandedKeyStr); - // 上级部门ID - String allSupDepartment = new DepartmentComInfo().getAllSupDepartment(expandedKeyStr); - array = allSupDepartment.split(","); - for (String supDepartment : array) { - if (StringUtils.isBlank(supDepartment)) { - continue; - } - expandedKeys.add("d" + supDepartment); } - - expandedKeys.add("d" + expandedKeyStr); } catch (Exception e) { throw new RuntimeException(e); } @@ -1350,7 +1363,7 @@ public class ChartServiceImpl extends Service implements ChartService { } } else { if (isSearchCurrent) { - sql = "select id as id, id as value, subcompanyname as title, supsubcomid as pId, showorder from hrmsubcompany where (canceled is null or canceled != '1') and " + dbType.ifNull("supsubcomid", "0") + " = " + subCompany + + sql = "select " + dbType.concat("", "id") + " as id, id as value, subcompanyname as title, supsubcomid as pId, showorder from hrmsubcompany where (canceled is null or canceled != '1') and " + dbType.ifNull("supsubcomid", "0") + " = " + subCompany + " union select " + dbType.concat("d", "id") + "as id, id as value, departmentname as title, subcompanyid1 as pId, showorder from hrmdepartment where (canceled is null or canceled != '1') and (supdepid is null or supdepid =0) and " + dbType.ifNull("subcompanyid1", "0") + " = " + subCompany; if (isCurrentDimension) { 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.ifNull("supsubcomid", "0") + " = " + subCompany + " and companyid = '" + dimension + "' " + @@ -1358,10 +1371,10 @@ public class ChartServiceImpl extends Service implements ChartService { } sql += " order by showorder,id "; } else { - sql = "select subcompanyid as id, subcompanyid as value, subcompanyname as title, supsubcompanyid as pId from jcl_chart_subcompany where (canceled is null or canceled != '1') and " + dbType.ifNull("supsubcompanyid", "0") + " = " + subCompany + + sql = "select " + dbType.concat("", "subcompanyid") + " as id, subcompanyid as value, subcompanyname as title, supsubcompanyid as pId from jcl_chart_subcompany where (canceled is null or canceled != '1') and " + dbType.ifNull("supsubcompanyid", "0") + " = " + subCompany + " union select " + dbType.concat("d", "subcompanyid") + "as id, subcompanyid as value, departmentname as title, subcompanyid as pId from jcl_chart_department where (canceled is null or canceled != '1') and (supdepartmentid is null or supdepartmentid =0) and " + dbType.ifNull("subcompanyid", "0") + " = " + subCompany; if (isCurrentDimension) { - sql = "select subcompanyvirtualid as id, subcompanyvirtualid as value, subcompanyname as title, supsubcompanyid as pId from jcl_chart_subcompanyvirtual where (canceled is null or canceled != '1') and " + dbType.ifNull("supsubcompanyid", "0") + " = " + subCompany + " and companyid = '" + dimension + "' " + + sql = "select " + dbType.concat("", "subcompanyvirtualid") + " as id, subcompanyvirtualid as value, subcompanyname as title, supsubcompanyid as pId from jcl_chart_subcompanyvirtual where (canceled is null or canceled != '1') and " + dbType.ifNull("supsubcompanyid", "0") + " = " + subCompany + " and companyid = '" + dimension + "' " + " union select " + dbType.concat("d", "departmentvirtualid") + "as id, departmentvirtualid as value, departmentname as title, subcompanyid as pId from jcl_chart_departmentvirtual where (canceled is null or canceled != '1') and (supdepid is null or supdepid =0) and" + dbType.ifNull("subcompanyid", "0") + " = " + subCompany; } // 添加时间轴条件 diff --git a/src/com/engine/organization/util/db/DBType.java b/src/com/engine/organization/util/db/DBType.java index fa12c713..fae51acb 100644 --- a/src/com/engine/organization/util/db/DBType.java +++ b/src/com/engine/organization/util/db/DBType.java @@ -47,7 +47,7 @@ public enum DBType implements DBOperateAdapter { @Override public String concat(String concatStr, String fieldName) { - return " '" + concatStr + "' + " + fieldName; + return " '" + concatStr + "' + cast(" + fieldName + " as varchar) "; } @Override @@ -73,7 +73,7 @@ public enum DBType implements DBOperateAdapter { @Override public String concat(String concatStr, String fieldName) { - return " '" + concatStr + "' ||" + fieldName; + return " '" + concatStr + "' ||" + fieldName + " "; } @Override @@ -99,7 +99,7 @@ public enum DBType implements DBOperateAdapter { @Override public String concat(String concatStr, String fieldName) { - return " '" + concatStr + "' ||" + fieldName; + return " '" + concatStr + "' ||" + fieldName + " "; } @Override