feature/dxf #188

Merged
dxfeng merged 4 commits from feature/dxf into develop 2 years ago

@ -40,6 +40,16 @@ public class ChartServiceImpl extends Service implements ChartService {
*/
boolean hasVirtualFields;
/**
*
*/
boolean isRealDimension;
/**
*
*/
boolean isRealTime;
@Override
public Map<String, Object> getCompanyData(Map<String, Object> params) {
Map<String, Object> result = new HashMap<>();
@ -67,7 +77,7 @@ public class ChartServiceImpl extends Service implements ChartService {
String id = Util.null2String(params.get("id"));
// 初始化表名
initTableNameByClass(dimension);
initTableNameByClass(dimension, id);
RecordSet rs = new RecordSet();
List<ChartPO> dataList = new ArrayList<>();
@ -75,7 +85,7 @@ public class ChartServiceImpl extends Service implements ChartService {
ChartPO topChartPO = null;
//查询当前实际数据
if("0".equals(id)){
if (isRealTime) {
sql = getRealTimeTopSql(root, dimension);
} else {
sql = getLastTimeTopSql(root, dimension, id);
@ -98,7 +108,7 @@ public class ChartServiceImpl extends Service implements ChartService {
// 向下查询数据
if (null != topChartPO) {
findChildData(topChartPO, dataList,Integer.parseInt(depth));
findChildData(topChartPO, dataList, Integer.parseInt(depth), id);
}
@ -108,7 +118,6 @@ public class ChartServiceImpl extends Service implements ChartService {
}
@Override
public Map<String, Object> asyncCompanyData(Map<String, Object> params) {
@ -119,9 +128,11 @@ public class ChartServiceImpl extends Service implements ChartService {
// 是否展示虚拟组织
String isVirtual = Util.null2String(params.get("fisvitual"));
showVirtual = "1".equals(isVirtual);
//版本id
String id = Util.null2String(params.get("id"));
// 初始化表名
initTableNameByClass(dimension);
initTableNameByClass(dimension, id);
String ids = (String) params.get("ids");
List<ChartPO> dataList = new ArrayList<>();
@ -196,10 +207,11 @@ public class ChartServiceImpl extends Service implements ChartService {
// 是否显示岗位
String showJobStr = Util.null2String(params.get("showJob"));
boolean showJob = "1".equals(showJobStr);
//版本id
String id = Util.null2String(params.get("id"));
// 初始化表名
initTableNameByClass(dimension);
initTableNameByClass(dimension, id);
List<ChartPO> dataList = new ArrayList<>();
List<ChartPO> jobTitleList = new ArrayList<>();
@ -327,25 +339,33 @@ public class ChartServiceImpl extends Service implements ChartService {
/**
* sql
*
* @param root
* @param dimension ID
* @param vesionId
* @param versionId
* @return
*/
private String getLastTimeTopSql(String root, String dimension, String vesionId) {
private String getLastTimeTopSql(String root, String dimension, String versionId) {
if ("0".equals(root)) {
//查询集团维度历史版本
if ("0".equals(dimension)) {
if (isRealDimension) {
//组织维度
return "select id,companyname as name,'0' as type from hrmcompany";
return "select id,companyname as name,'0' as type from " + COMPANY_TABLE;
} else {
//查询其他维度集团版本信息
return "select id,companyname as name,'0' as type from jcl_chart_companyvirtual where " +
" versionid = "+vesionId+" and companyvirtualid = "+dimension;
return "select id,companyname as name,'0' as type from " + COMPANY_TABLE + " where " +
" versionid = " + versionId + " and companyvirtualid = " + dimension;
}
} else {
return "select id,subcompanyname as name,'1' as type from jcl_chart_subcompanyvirtual where " +
" versionid= "+vesionId+" and subcompanyvirtualid"+root;
if (hasVirtualFields) {
if (showVirtual) {
return "select id,subcompanyname as name,'1' as type,isvirtual as isvitual from " + SUB_COMPANY_TABLE + " where versionid = " + versionId + " and subcompanyid = " + root;
} else {
return "select id,subcompanyname as name,'1' as type,isvirtual as isvitual from " + SUB_COMPANY_TABLE + " where versionid = " + versionId + " and subcompanyid = " + root + " and (isvirtual is null or isvirtual != '1')";
}
} else {
return "select id,subcompanyname as name,'1' as type from " + SUB_COMPANY_TABLE + " where versionid = " + versionId + " and subcompanyid = " + root;
}
}
}
@ -359,7 +379,7 @@ public class ChartServiceImpl extends Service implements ChartService {
private String getRealTimeTopSql(String root, String dimension) {
if ("0".equals(root)) {
// 查询集团数据
if ("0".equals(dimension)) {
if (isRealDimension) {
// 查询实际集团表
return "select id,companyname as name,'0' as type from " + COMPANY_TABLE;
} else {
@ -381,16 +401,14 @@ public class ChartServiceImpl extends Service implements ChartService {
}
/**
* ,
* ,SQL
*
* @param topChartPO
* @param dataList
* @param selectDepth
* @param sql SQL
* @param fType
* @param fObjId ID
* @return SQL
*/
private void findChildData(ChartPO topChartPO, List<ChartPO> dataList,Integer selectDepth) {
String fType = topChartPO.getFtype();
String fObjId = topChartPO.getFobjid();
String sql = "";
private String getRealTimeChildSql(String sql, String fType, String fObjId) {
if (StringUtils.isNotBlank(fType)) {
switch (fType) {
case "0":
@ -433,6 +451,82 @@ public class ChartServiceImpl extends Service implements ChartService {
break;
}
}
return sql;
}
/**
* ,SQL
*
* @param sql SQL
* @param fType
* @param fObjId ID
* @return SQL
*/
private String getLastTimeChildSql(String sql, String fType, String fObjId, String versionId) {
if (StringUtils.isNotBlank(fType)) {
switch (fType) {
case "0":
if (hasVirtualFields) {
if (showVirtual) {
sql = "select a.id,a.subcompanyname as name,'1' as type ,isvirtual as isvitual from " + SUB_COMPANY_TABLE + " a where (a.canceled is null or a.canceled != '1') and (a.supsubcompanyid is null or a.supsubcompanyid = '0') and versionid = "+versionId;
} else {
sql = "select a.id,a.subcompanyname as name,'1' as type ,isvirtual as isvitual from " + SUB_COMPANY_TABLE + " a where (a.canceled is null or a.canceled != '1') and (a.supsubcompanyid is null or a.supsubcompanyid = '0') and (isvirtual is null or isvirtual != '1') and versionid = "+versionId;
}
} else {
sql = "select a.id,a.subcompanyname as name,'1' as type from " + SUB_COMPANY_TABLE + " a where (a.canceled is null or a.canceled != '1') and (a.supsubcompanyid is null or a.supsubcompanyid = '0') and versionid = "+versionId;
}
if(!isRealDimension){
sql += " and companyid = " + fObjId;
}
break;
case "1":
if (hasVirtualFields) {
if (showVirtual) {
sql = "select a.id,a.subcompanyname as name,'1' as type ,isvirtual as isvitual from " + SUB_COMPANY_TABLE + " a where (a.canceled is null or a.canceled != '1') and a.supsubcompanyid = '" + fObjId + "' and versionid = " + versionId +
" union select a.id,a.departmentname as name,'2' as type ,isvirtual as isvitual from " + DEPARTMENT_TABLE + " a where (a.canceled is null or a.canceled != '1') and (a.supdepartmentid is null or a.supdepartmentid = '0') and subcompanyid = '" + fObjId + "' and versionid = "+versionId;
} else {
sql = "select a.id,a.subcompanyname as name,'1' as type ,isvirtual as isvitual from " + SUB_COMPANY_TABLE + " a where (a.canceled is null or a.canceled != '1') and (isvirtual is null or isvirtual != '1') and a.supsubcompanyid = '" + fObjId + "' and versionid = "+versionId +
" union select a.id,a.departmentname as name,'2' as type ,isvirtual as isvitual from " + DEPARTMENT_TABLE + " a where (a.canceled is null or a.canceled != '1') and (a.supdepartmentid is null or a.supdepartmentid = '0') and (isvirtual is null or isvirtual != '1') and subcompanyid = '" + fObjId + "' and versionid = "+versionId;
}
} else {
sql = "select a.id,a.subcompanyname as name,'1' as type from " + SUB_COMPANY_TABLE + " a where (canceled is null or canceled != '1') and supsubcompanyid = '" + fObjId + "' and versionid = "+versionId +
" union select a.id,a.departmentname as name,'2' as type from " + DEPARTMENT_TABLE + " a where (canceled is null or canceled != '1') and (supdepartmentid is null or supdepartmentid = '0') and subcompanyid = '" + fObjId + "' and versionid = "+versionId;
}
break;
case "2":
if (hasVirtualFields) {
if (showVirtual) {
sql = "select a.id,a.departmentname as name,'2' as type ,isvirtual as isvitual from " + DEPARTMENT_TABLE + " a where (a.canceled is null or a.canceled != '1') and supdepartmentid = '" + fObjId + "' and versionid = "+versionId;
} else {
sql = "select a.id,a.departmentname as name,'2' as type ,isvirtual as isvitual from " + DEPARTMENT_TABLE + " where (canceled is null or canceled != '1') and (isvirtual is null or isvirtual != '1') and a.supdepartmentid = '" + fObjId + "' and versionid = "+versionId;
}
} else {
sql = "select a.id,a.departmentname as name,'2' as type from " + DEPARTMENT_TABLE + " a where (canceled is null or canceled != '1') and supdepartmentid = '" + fObjId + "' and versionid = "+versionId;
}
break;
default:
break;
}
}
return sql;
}
/**
* ,
*
* @param topChartPO
* @param dataList
* @param selectDepth
*/
private void findChildData(ChartPO topChartPO, List<ChartPO> dataList, Integer selectDepth,String versionId) {
String fType = topChartPO.getFtype();
String fObjId = topChartPO.getFobjid();
String sql = "";
if (isRealTime) {
sql = getRealTimeChildSql(sql, fType, fObjId);
} else {
sql = getLastTimeChildSql(sql, fType, fObjId,versionId);
}
if (StringUtils.isNotBlank(sql)) {
List<ChartPO> currentList = new ArrayList<>();
@ -453,7 +547,7 @@ public class ChartServiceImpl extends Service implements ChartService {
}
for (ChartPO chartPO : currentList) {
if (inDepth(selectDepth, chartPO.getDepartmentDepth())) {
findChildData(chartPO, dataList, selectDepth);
findChildData(chartPO, dataList, selectDepth,versionId);
}
}
dataList.addAll(currentList);
@ -466,10 +560,13 @@ public class ChartServiceImpl extends Service implements ChartService {
/**
*
*
* @param fClass
* @param dimension
*/
public void initTableNameByClass(String fClass) {
if (StringUtils.isBlank(fClass) || "0".equals(fClass)) {
public void initTableNameByClass(String dimension, String id) {
isRealDimension = StringUtils.isBlank(dimension) || "0".equals(dimension);
isRealTime = StringUtils.isBlank(id) || "0".equals(id);
if (isRealTime) {
if (isRealDimension) {
COMPANY_TABLE = "hrmcompany";
SUB_COMPANY_TABLE = "hrmsubcompany";
SUB_COMPANY_DEFINED_TABLE = "hrmsubcompanydefined";
@ -491,6 +588,20 @@ public class ChartServiceImpl extends Service implements ChartService {
// 其他维度,无虚拟组织
hasVirtualFields = false;
}
} else {
if (isRealDimension) {
COMPANY_TABLE = "hrmcompany";
SUB_COMPANY_TABLE = "jcl_chart_subcompany";
DEPARTMENT_TABLE = "jcl_chart_department";
hasVirtualFields = true;
} else {
COMPANY_TABLE = "jcl_chart_companyvirtual";
SUB_COMPANY_TABLE = "jcl_chart_subcompanyvirtual";
DEPARTMENT_TABLE = "jcl_chart_departmentvirtual";
// 其他维度,无虚拟组织
hasVirtualFields = false;
}
}
}
@ -502,35 +613,35 @@ public class ChartServiceImpl extends Service implements ChartService {
* @return boolean true,false
*/
private Boolean getHasChildren(String fType, String fObjId) {
String sql = "";
if (StringUtils.isNotBlank(fType)) {
switch (fType) {
case "0":
sql = "select id from " + SUB_COMPANY_TABLE + " where (supsubcomid is null or supsubcomid = '0') and companyid = '" + fObjId + "'";
break;
case "1":
if (hasVirtualFields && !showVirtual) {
sql = "select a.id 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 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 {
sql = "select id from " + SUB_COMPANY_TABLE + " where (canceled is null or canceled != '1') and supsubcomid = '" + fObjId + "' union select id from " + DEPARTMENT_TABLE + " where (canceled is null or canceled != '1') and (supdepid is null or supdepid = '0') and subcompanyid1 = '" + fObjId + "'";
}
break;
case "2":
if (hasVirtualFields && !showVirtual) {
sql = "select a.id 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 {
sql = "select id from " + DEPARTMENT_TABLE + " where (canceled is null or canceled != '1') and supdepid = '" + fObjId + "'";
}
break;
default:
break;
}
}
if (StringUtils.isNotBlank(sql)) {
RecordSet rs = new RecordSet();
rs.executeQuery(sql);
return rs.next();
}
//String sql = "";
//if (StringUtils.isNotBlank(fType)) {
// switch (fType) {
// case "0":
// sql = "select id from " + SUB_COMPANY_TABLE + " where (supsubcomid is null or supsubcomid = '0') and companyid = '" + fObjId + "'";
// break;
// case "1":
// if (hasVirtualFields && !showVirtual) {
// sql = "select a.id 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 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 {
// sql = "select id from " + SUB_COMPANY_TABLE + " where (canceled is null or canceled != '1') and supsubcomid = '" + fObjId + "' union select id from " + DEPARTMENT_TABLE + " where (canceled is null or canceled != '1') and (supdepid is null or supdepid = '0') and subcompanyid1 = '" + fObjId + "'";
// }
// break;
// case "2":
// if (hasVirtualFields && !showVirtual) {
// sql = "select a.id 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 {
// sql = "select id from " + DEPARTMENT_TABLE + " where (canceled is null or canceled != '1') and supdepid = '" + fObjId + "'";
// }
// break;
// default:
// break;
// }
//}
//if (StringUtils.isNotBlank(sql)) {
// RecordSet rs = new RecordSet();
// rs.executeQuery(sql);
// return rs.next();
//}
return false;
}

@ -106,10 +106,23 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
subcompany = "0";
}
String fclass = Util.null2String(params.get("fclass"));
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") + " = '" + subcompany + "'";
String id = Util.null2String(params.get("id"));
// 是否展示当前数据
boolean isSearchCurrent = StringUtils.isBlank(id) || "0".equals(id);
String sql;
if (isSearchCurrent) {
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") + " = '" + subcompany + "'";
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") + " = '" + subcompany + "' and companyid = '" + fclass + "'";
}
} else {
sql = "select id 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") + " = '" + subcompany + "'";
if (StringUtils.isNotBlank(fclass) && !"0".equals(fclass)) {
sql = "select id as id, id as value, subcompanyname as title, supsubcompanyid as pId from jcl_chart_subcompanyvirtual where (canceled is null or canceled != '1') and " + DBType.get(new RecordSet().getDBType()).ifNull("supsubcompanyid", "0") + " = '" + subcompany + "' and companyid = '" + fclass + "'";
}
// 添加时间轴条件
sql += " and versionid = " + id;
}
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")).build());

Loading…
Cancel
Save