diff --git a/src/com/engine/organization/service/ChartService.java b/src/com/engine/organization/service/ChartService.java index 15f8e4aa..d49e9e78 100644 --- a/src/com/engine/organization/service/ChartService.java +++ b/src/com/engine/organization/service/ChartService.java @@ -9,6 +9,21 @@ import java.util.Map; */ public interface ChartService { + /** + * 组织架构图 ,获取数据(同步) + * + * @param params 请求参数 + * @return 数据集合 + */ Map getCompanyData(Map params); + /** + * 组织架构图 ,获取数据(异步) + * + * @param params 请求参数 + * @return 数据集合 + */ + Map asyncCompanyData(Map params); + + } diff --git a/src/com/engine/organization/service/impl/ChartServiceImpl.java b/src/com/engine/organization/service/impl/ChartServiceImpl.java index 21a446b0..68fdb5af 100644 --- a/src/com/engine/organization/service/impl/ChartServiceImpl.java +++ b/src/com/engine/organization/service/impl/ChartServiceImpl.java @@ -20,7 +20,6 @@ import java.util.Map; */ public class ChartServiceImpl extends Service implements ChartService { private static final String COMPANY_RIGHT = "OrgChart:All"; - private static final String USER_RIGHT = "OrgPerspective:All"; public String COMPANY_TABLE = ""; public String SUB_COMPANY_TABLE = ""; @@ -38,19 +37,6 @@ public class ChartServiceImpl extends Service implements ChartService { */ boolean hasVirtualFields; - public ChartServiceImpl() { - super(); - RecordSet rs = new RecordSet(); - rs.executeQuery("select count(1) as num from hrm_formfield where (GROUPID =6 and FIELDNAME = 'fblx') or (GROUPID =7 and FIELDNAME = 'bmlx')"); - if (rs.next()) { - String num = rs.getString("num"); - hasVirtualFields = "2".equals(num); - - } else { - hasVirtualFields = false; - } - } - @Override public Map getCompanyData(Map params) { Map result = new HashMap<>(); @@ -108,6 +94,74 @@ public class ChartServiceImpl extends Service implements ChartService { return result; } + @Override + public Map asyncCompanyData(Map params) { + + // 维度 + String dimension = Util.null2String(params.get("fclass")); + dimension = StringUtils.isBlank(dimension) ? "0" : dimension; + + // 是否展示虚拟组织 + String isVirtual = Util.null2String(params.get("fisvitual")); + showVirtual = "1".equals(isVirtual); + + // 初始化表名 + initTableNameByClass(dimension); + + String ids = (String) params.get("ids"); + List dataList = new ArrayList<>(); + if (StringUtils.isNotBlank(ids)) { + RecordSet rs = new RecordSet(); + String[] split = ids.split(","); + for (String s : split) { + //TODO 查询当前实际数据 + if (s.contains("_")) { + String fObjId = s.split("_")[1]; + if (s.startsWith("s")) { + if (hasVirtualFields) { + if (showVirtual) { + rs.executeQuery("select a.id,a.subcompanyname as 'name','1' as 'type' ,b.fblx as 'isvitual' from " + SUB_COMPANY_TABLE + " a left join " + SUB_COMPANY_DEFINED_TABLE + " b on a.id = b.subcomid where (a.canceled is null or a.canceled != '1') and a.supsubcomid = '" + fObjId + "'" + + " union select a.id,a.departmentname as 'name','2' as 'type' ,b.bmlx as 'isvitual' from " + DEPARTMENT_TABLE + " a left join " + DEPARTMENT_DEFINED_TABLE + " b on a.id = b.deptid where (a.canceled is null or a.canceled != '1') and (a.supdepid is null or a.supdepid = '0') and subcompanyid1 = '" + fObjId + "'"); + } else { + rs.executeQuery("select a.id,a.subcompanyname as 'name','1' as 'type' ,b.fblx as 'isvitual' from " + SUB_COMPANY_TABLE + " a left join " + SUB_COMPANY_DEFINED_TABLE + " b on a.id = b.subcomid where (a.canceled is null or a.canceled != '1') and (b.fblx is null or b.fblx != '1') and a.supsubcomid = '" + fObjId + "'" + + " union select a.id,a.departmentname as 'name','2' as 'type' ,b.bmlx as 'isvitual' from " + DEPARTMENT_TABLE + " a left join " + DEPARTMENT_DEFINED_TABLE + " b on a.id = b.deptid where (a.canceled is null or a.canceled != '1') and (a.supdepid is null or a.supdepid = '0') and (b.bmlx is null or b.bmlx != '1') and subcompanyid1 = '" + fObjId + "'"); + } + } else { + rs.executeQuery("select a.id,a.subcompanyname as 'name','1' as 'type' from " + SUB_COMPANY_TABLE + " a where (canceled is null or canceled != '1') and supsubcomid = '" + fObjId + "'" + + " union select a.id,a.departmentname as 'name','2' as 'type' from " + DEPARTMENT_TABLE + " a where (canceled is null or canceled != '1') and (supdepid is null or supdepid = '0') and subcompanyid1 = '" + fObjId + "'"); + } + + } else if (s.startsWith("d")) { + if (hasVirtualFields) { + if (showVirtual) { + rs.executeQuery( "select a.id,a.departmentname as 'name','2' as 'type' ,b.bmlx as 'isvitual' from " + DEPARTMENT_TABLE + " a left join " + DEPARTMENT_DEFINED_TABLE + " b on a.id = b.deptid where (a.canceled is null or a.canceled != '1') and supdepid = '" + fObjId + "'"); + } else { + rs.executeQuery( "select a.id,a.departmentname as 'name','2' as 'type' ,b.bmlx as 'isvitual' from " + DEPARTMENT_TABLE + " a left join hrmdepartmentdefined b on a.id = b.deptid where (canceled is null or canceled != '1') and (b.bmlx is null or b.bmlx != '1') and a.supdepid = '" + fObjId + "'"); + } + } else { + rs.executeQuery( "select a.id,a.departmentname as 'name','2' as 'type' from " + DEPARTMENT_TABLE + " a where (canceled is null or canceled != '1') and supdepid = '" + fObjId + "'"); + } + } + while (rs.next()){ + ChartPO chartPO = new ChartPO(); + chartPO.setFtype(rs.getString("type")); + chartPO.setFobjid(rs.getString("id")); + chartPO.setFname(rs.getString("name")); + chartPO.setParentId(s); + chartPO.setExpand("0"); + chartPO.setFisvitual(rs.getString("isvitual")); + chartPO.setHasChildren(getHasChildren(chartPO.getFtype(), chartPO.getFobjid()).toString()); + dataList.add(chartPO); + } + } + } + } + Map result = new HashMap<>(); + result.put("api_status", true); + result.put("data", dataList); + return result; + } + /** * 查询实时数据,顶级元素SQL * @@ -234,6 +288,15 @@ public class ChartServiceImpl extends Service implements ChartService { SUB_COMPANY_DEFINED_TABLE = "hrmsubcompanydefined"; DEPARTMENT_TABLE = "hrmdepartment"; DEPARTMENT_DEFINED_TABLE = "hrmdepartmentdefined"; + RecordSet rs = new RecordSet(); + rs.executeQuery("select count(1) as num from hrm_formfield where (GROUPID =6 and FIELDNAME = 'fblx') or (GROUPID =7 and FIELDNAME = 'bmlx')"); + if (rs.next()) { + String num = rs.getString("num"); + hasVirtualFields = "2".equals(num); + + } else { + hasVirtualFields = false; + } } else { COMPANY_TABLE = "hrmcompanyvirtual"; SUB_COMPANY_TABLE = "hrmsubcompanyvirtual"; diff --git a/src/com/engine/organization/wrapper/OrgChartWrapper.java b/src/com/engine/organization/wrapper/OrgChartWrapper.java index 47f35bc7..8d117795 100644 --- a/src/com/engine/organization/wrapper/OrgChartWrapper.java +++ b/src/com/engine/organization/wrapper/OrgChartWrapper.java @@ -49,7 +49,8 @@ public class OrgChartWrapper extends Service { } public Map asyncCompanyData(Map request2Map, User user) { - return getOrgChartService(user).asyncCompanyData(request2Map, user); + // return getOrgChartService(user).asyncCompanyData(request2Map, user); + return getChartService(user).asyncCompanyData(request2Map); } public String synchronousData(Map request2Map) {