组织架构图重构-异步数据接口

pull/173/head
dxfeng 2 years ago
parent 78c4aa5127
commit c115308f9e

@ -9,6 +9,21 @@ import java.util.Map;
*/
public interface ChartService {
/**
* ,
*
* @param params
* @return
*/
Map<String, Object> getCompanyData(Map<String, Object> params);
/**
* ,
*
* @param params
* @return
*/
Map<String, Object> asyncCompanyData(Map<String, Object> params);
}

@ -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<String, Object> getCompanyData(Map<String, Object> params) {
Map<String, Object> result = new HashMap<>();
@ -108,6 +94,74 @@ public class ChartServiceImpl extends Service implements ChartService {
return result;
}
@Override
public Map<String, Object> asyncCompanyData(Map<String, Object> 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<ChartPO> 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<String, Object> 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";

@ -49,7 +49,8 @@ public class OrgChartWrapper extends Service {
}
public Map<String, Object> asyncCompanyData(Map<String, Object> request2Map, User user) {
return getOrgChartService(user).asyncCompanyData(request2Map, user);
// return getOrgChartService(user).asyncCompanyData(request2Map, user);
return getChartService(user).asyncCompanyData(request2Map);
}
public String synchronousData(Map<String, Object> request2Map) {

Loading…
Cancel
Save