Merge remote-tracking branch 'origin/develop' into feature/ml

# Conflicts:
#	src/com/engine/organization/service/impl/ChartServiceImpl.java
pull/193/head
Mlin 2 years ago
commit 971b997dff

@ -176,7 +176,7 @@ public interface HrmResourceService {
* @param: [departmentId] * @param: [departmentId]
* @return: java.util.Map<java.lang.String,java.lang.Object> * @return: java.util.Map<java.lang.String,java.lang.Object>
*/ */
Map<String, Object> chartResourceList(Integer departmentId); Map<String, Object> chartResourceList(Integer departmentId,String versionId,String dimension);
} }

@ -37,6 +37,8 @@ public class ChartServiceImpl extends Service implements ChartService {
public String SUB_COMPANY_DEFINED_TABLE = ""; public String SUB_COMPANY_DEFINED_TABLE = "";
public String DEPARTMENT_TABLE = ""; public String DEPARTMENT_TABLE = "";
public String DEPARTMENT_DEFINED_TABLE = ""; public String DEPARTMENT_DEFINED_TABLE = "";
public String SUB_COMPANY_ID = "''";
public String DEPARTMENT_ID = "''";
/** /**
* *
@ -57,6 +59,16 @@ public class ChartServiceImpl extends Service implements ChartService {
} }
/**
*
*/
boolean isRealDimension;
/**
*
*/
boolean isRealTime;
@Override @Override
public Map<String, Object> getCompanyData(Map<String, Object> params) { public Map<String, Object> getCompanyData(Map<String, Object> params) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
@ -84,7 +96,7 @@ public class ChartServiceImpl extends Service implements ChartService {
String id = Util.null2String(params.get("id")); String id = Util.null2String(params.get("id"));
// 初始化表名 // 初始化表名
initTableNameByClass(dimension); initTableNameByClass(dimension, id);
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
List<ChartPO> dataList = new ArrayList<>(); List<ChartPO> dataList = new ArrayList<>();
@ -92,7 +104,7 @@ public class ChartServiceImpl extends Service implements ChartService {
ChartPO topChartPO = null; ChartPO topChartPO = null;
//查询当前实际数据 //查询当前实际数据
if("0".equals(id)){ if (isRealTime) {
sql = getRealTimeTopSql(root, dimension); sql = getRealTimeTopSql(root, dimension);
} else { } else {
sql = getLastTimeTopSql(root, dimension, id); sql = getLastTimeTopSql(root, dimension, id);
@ -115,7 +127,7 @@ public class ChartServiceImpl extends Service implements ChartService {
// 向下查询数据 // 向下查询数据
if (null != topChartPO) { if (null != topChartPO) {
findChildData(topChartPO, dataList,Integer.parseInt(depth)); findChildData(topChartPO, dataList, Integer.parseInt(depth), id);
} }
@ -125,7 +137,6 @@ public class ChartServiceImpl extends Service implements ChartService {
} }
@Override @Override
public Map<String, Object> asyncCompanyData(Map<String, Object> params) { public Map<String, Object> asyncCompanyData(Map<String, Object> params) {
@ -136,9 +147,11 @@ public class ChartServiceImpl extends Service implements ChartService {
// 是否展示虚拟组织 // 是否展示虚拟组织
String isVirtual = Util.null2String(params.get("fisvitual")); String isVirtual = Util.null2String(params.get("fisvitual"));
showVirtual = "1".equals(isVirtual); showVirtual = "1".equals(isVirtual);
//版本id
String versionId = Util.null2String(params.get("id"));
// 初始化表名 // 初始化表名
initTableNameByClass(dimension); initTableNameByClass(dimension, versionId);
String ids = (String) params.get("ids"); String ids = (String) params.get("ids");
List<ChartPO> dataList = new ArrayList<>(); List<ChartPO> dataList = new ArrayList<>();
@ -150,28 +163,17 @@ public class ChartServiceImpl extends Service implements ChartService {
if (s.contains("_")) { if (s.contains("_")) {
String fObjId = s.split("_")[1]; String fObjId = s.split("_")[1];
if (s.startsWith("s")) { if (s.startsWith("s")) {
if (hasVirtualFields) { if (isRealTime) {
if (showVirtual) { rs.executeQuery(getRealTimeChildSql("", "1", fObjId));
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 { } 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 + "'" + rs.executeQuery(getLastTimeChildSql("", "1", fObjId, versionId));
" 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")) { } else if (s.startsWith("d")) {
if (hasVirtualFields) { if (isRealTime) {
if (showVirtual) { rs.executeQuery(getRealTimeChildSql("", "2", fObjId));
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 { } 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 + "'"); rs.executeQuery(getLastTimeChildSql("", "2", fObjId, versionId));
} }
} }
while (rs.next()) { while (rs.next()) {
@ -197,15 +199,6 @@ public class ChartServiceImpl extends Service implements ChartService {
@Override @Override
public Map<String, Object> getDepartmentDetail(Map<String, Object> params) { public Map<String, Object> getDepartmentDetail(Map<String, Object> params) {
String rootId = Util.null2String(params.get("rootId")); String rootId = Util.null2String(params.get("rootId"));
OrganizationAssert.isFalse(StringUtils.isBlank(rootId) || !rootId.startsWith("d_"), "数据有误,未查询到对应数据");
String departmentId = rootId.split("_")[1];
String detauleType = Util.null2String(params.get("detauleType"));
if(!"chart".equals(detauleType)){
return ServiceUtil.getService(HrmResourceServiceImpl.class, user).chartResourceList(Integer.parseInt(departmentId));
}
// 维度 // 维度
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;
@ -213,10 +206,20 @@ public class ChartServiceImpl extends Service implements ChartService {
// 是否显示岗位 // 是否显示岗位
String showJobStr = Util.null2String(params.get("showJob")); String showJobStr = Util.null2String(params.get("showJob"));
boolean showJob = "1".equals(showJobStr); boolean showJob = "1".equals(showJobStr);
//版本id
String versionId = Util.null2String(params.get("id"));
OrganizationAssert.isFalse(StringUtils.isBlank(rootId) || !rootId.startsWith("d_"), "数据有误,未查询到对应数据");
String departmentId = rootId.split("_")[1];
String detauleType = Util.null2String(params.get("detauleType"));
if (!"chart".equals(detauleType)) {
// 展示列表模块
return ServiceUtil.getService(HrmResourceServiceImpl.class, user).chartResourceList(Integer.parseInt(departmentId), versionId, dimension);
}
// 初始化表名 // 初始化表名
initTableNameByClass(dimension); initTableNameByClass(dimension, versionId);
List<ChartPO> dataList = new ArrayList<>(); List<ChartPO> dataList = new ArrayList<>();
List<ChartPO> jobTitleList = new ArrayList<>(); List<ChartPO> jobTitleList = new ArrayList<>();
@ -225,12 +228,20 @@ public class ChartServiceImpl extends Service implements ChartService {
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
// TODO 查询当前实际的数据 // TODO 查询当前实际的数据
String sql; String sql;
if (isRealTime) {
// 查询部门本身 // 查询部门本身
if (hasVirtualFields) { if (hasVirtualFields) {
sql = "select a.id,a.departmentname as name,b.bmfzr,b.bmlx as isvitual from " + DEPARTMENT_TABLE + " a left join hrmdepartmentdefined b on a.id = b.deptid where a.id = '" + departmentId + "'"; sql = "select a.id,a.departmentname as name,b.bmfzr,b.bmlx as isvitual from " + DEPARTMENT_TABLE + " a left join hrmdepartmentdefined b on a.id = b.deptid where a.id = '" + departmentId + "'";
} else { } else {
sql = "select a.id,a.departmentname as name,b.bmfzr from " + DEPARTMENT_TABLE + " a left join hrmdepartmentdefined b on a.id = b.deptid where a.id = '" + departmentId + "'"; sql = "select a.id,a.departmentname as name,b.bmfzr from " + DEPARTMENT_TABLE + " a left join hrmdepartmentdefined b on a.id = b.deptid where a.id = '" + departmentId + "'";
} }
} else {
if (hasVirtualFields) {
sql = "select " + DEPARTMENT_ID + " as id,a.departmentname as name,fleader as bmfzr,isvirtual as isvitual from " + DEPARTMENT_TABLE + " a where a.id = '" + departmentId + "' and versionid = " + versionId;
} else {
sql = "select " + DEPARTMENT_ID + " as id,a.departmentname as name from " + DEPARTMENT_TABLE + " a where a.id = '" + departmentId + "' and versionid = " + versionId;
}
}
rs.executeQuery(sql); rs.executeQuery(sql);
ChartPO departmentChartPO = new ChartPO(); ChartPO departmentChartPO = new ChartPO();
if (rs.next()) { if (rs.next()) {
@ -250,7 +261,11 @@ public class ChartServiceImpl extends Service implements ChartService {
if (showJob) { if (showJob) {
// 查询部门下的岗位 // 查询部门下的岗位
if (isRealTime) {
sql = "select a.id,a.jobtitlename as name from hrmjobtitles a inner join jcl_org_job b on a.id = b.ec_jobtitle where b.ec_department = '" + departmentId + "'"; sql = "select a.id,a.jobtitlename as name from hrmjobtitles a inner join jcl_org_job b on a.id = b.ec_jobtitle where b.ec_department = '" + departmentId + "'";
} else {
sql = "select jobid as id ,jobname as name from jcl_chart_job where departmentid = '" + departmentId + "' and versionid = " + versionId;
}
rs.executeQuery(sql); rs.executeQuery(sql);
while (rs.next()) { while (rs.next()) {
ChartPO chartPO = new ChartPO(); ChartPO chartPO = new ChartPO();
@ -265,33 +280,22 @@ public class ChartServiceImpl extends Service implements ChartService {
jobTitleList.add(chartPO); jobTitleList.add(chartPO);
} }
if ("0".equals(dimension)) { // 遍历岗位、查询对应岗位下的人员
sql = "select a.id,a.lastname as name ,a.jobtitle ,a.belongto ,a.companyworkyear from hrmresource a where a.status < 4 and a.departmentid = ? and a.jobtitle = ?"; if (isRealTime) {
if (isRealDimension) {
sql = "select a.id,a.lastname as name ,a.belongto ,a.companyworkyear from hrmresource a where a.status < 4 and a.departmentid = ? and a.jobtitle = ?";
} else { } else {
sql = "select a.id,a.lastname as name ,a.jobtitle ,a.belongto ,a.companyworkyear from hrmresource a inner join hrmresourcevirtual b on a.id = b.resourceid where a.status < 4 and b.departmentid = ? and a.jobtitle = ?"; sql = "select a.id,a.lastname as name ,a.belongto ,a.companyworkyear from hrmresource a inner join hrmresourcevirtual b on a.id = b.resourceid where a.status < 4 and b.departmentid = ? and a.jobtitle = ?";
}
} else {
sql = "select a.resourceid as id,a.lastname as name ,a.belongto ,a.companyworkyear from jcl_chart_resource a where a.status < 4 and a.departmentid = ? and a.jobtitleid = ? and versionid = " + versionId;
} }
// 遍历岗位、查询对应岗位下的人员
for (ChartPO jobTitlePO : jobTitleList) { for (ChartPO jobTitlePO : jobTitleList) {
resourceNum = 0; resourceNum = 0;
rs.executeQuery(sql, departmentId, jobTitlePO.getFobjid()); rs.executeQuery(sql, departmentId, jobTitlePO.getFobjid());
String parentId = departmentId + "_" + jobTitlePO.getFobjid();
while (rs.next()) { while (rs.next()) {
String jobTitle = Util.null2String(rs.getString("jobtitle")); ChartPO chartPO = getResourceChartPO(rs.getString("id"), rs.getString("name"), parentId, rs.getString("belongto"), rs.getString("companyworkyear"));
ChartPO chartPO = new ChartPO();
chartPO.setFtype("4");
chartPO.setFobjid(rs.getString("id"));
chartPO.setId(chartPO.getFobjid());
chartPO.setFname(rs.getString("name"));
// 岗位处理后的ID
chartPO.setParentId(departmentId + "_" + jobTitle);
chartPO.setExpand("0");
chartPO.setHasChildren("0");
chartPO.setBelongto(Util.null2String(rs.getString("belongto")));
chartPO.setCompanyWorkYear(rs.getString("companyworkyear"));
try {
chartPO.setFleaderimg(new ResourceComInfo().getMessagerUrls(chartPO.getId()));
} catch (Exception e) {
throw new RuntimeException(e);
}
resourceNum++; resourceNum++;
dataList.add(chartPO); dataList.add(chartPO);
} }
@ -302,25 +306,18 @@ public class ChartServiceImpl extends Service implements ChartService {
departmentChartPO.setHasChildren(CollectionUtils.isNotEmpty(jobTitleList) ? "1" : "0"); departmentChartPO.setHasChildren(CollectionUtils.isNotEmpty(jobTitleList) ? "1" : "0");
} else { } else {
// 直接查询岗位下的人员 // 直接查询岗位下的人员
sql = "select a.id,a.lastname as name ,a.jobtitle ,a.belongto ,a.companyworkyear from hrmresource a where a.status < 4 and a.departmentid = ? "; if (isRealTime) {
if (isRealDimension) {
sql = "select a.id,a.lastname as name ,a.belongto ,a.companyworkyear from hrmresource a where a.status < 4 and a.departmentid = ? ";
} else {
sql = "select a.id,a.lastname as name ,a.belongto ,a.companyworkyear from hrmresource a inner join hrmresourcevirtual b on a.id = b.resourceid where a.status < 4 and b.departmentid = ? ";
}
} else {
sql = "select a.resourceid as id,a.lastname as name ,a.belongto ,a.companyworkyear from jcl_chart_resource a where a.status < 4 and a.departmentid = ? and versionid = " + versionId;
}
rs.executeQuery(sql, departmentId); rs.executeQuery(sql, departmentId);
while (rs.next()) { while (rs.next()) {
ChartPO chartPO = new ChartPO(); ChartPO chartPO = getResourceChartPO(rs.getString("id"), rs.getString("name"), rootId, rs.getString("belongto"), rs.getString("companyworkyear"));
chartPO.setFtype("4");
chartPO.setFobjid(rs.getString("id"));
chartPO.setId(chartPO.getFobjid());
chartPO.setFname(rs.getString("name"));
// 岗位处理后的ID
chartPO.setParentId(rootId);
chartPO.setExpand("0");
chartPO.setHasChildren("0");
chartPO.setBelongto(Util.null2String(rs.getString("belongto")));
chartPO.setCompanyWorkYear(rs.getString("companyworkyear"));
try {
chartPO.setFleaderimg(new ResourceComInfo().getMessagerUrls(chartPO.getId()));
} catch (Exception e) {
throw new RuntimeException(e);
}
dataList.add(chartPO); dataList.add(chartPO);
departmentOnJob++; departmentOnJob++;
} }
@ -342,27 +339,65 @@ public class ChartServiceImpl extends Service implements ChartService {
return rs.getString("recorddate"); return rs.getString("recorddate");
} }
/**
*
*
* @param id ID
* @param name
* @param parentId ID
* @param belongTo
* @param companyWorkYear
* @return
*/
private ChartPO getResourceChartPO(String id, String name, String parentId, String belongTo, String companyWorkYear) {
ChartPO chartPO = new ChartPO();
chartPO.setFtype("4");
chartPO.setFobjid(id);
chartPO.setId(chartPO.getFobjid());
chartPO.setFname(name);
// 岗位处理后的ID
chartPO.setParentId(parentId);
chartPO.setExpand("0");
chartPO.setHasChildren("0");
chartPO.setBelongto(Util.null2String(belongTo));
chartPO.setCompanyWorkYear(companyWorkYear);
try {
chartPO.setFleaderimg(new ResourceComInfo().getMessagerUrls(chartPO.getId()));
} catch (Exception e) {
throw new RuntimeException(e);
}
return chartPO;
}
/** /**
* sql * sql
*
* @param root * @param root
* @param dimension ID * @param dimension ID
* @param vesionId * @param versionId
* @return * @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(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 { } else {
//查询其他维度集团版本信息 //查询其他维度集团版本信息
return "select id,companyname as name,'0' as type from jcl_chart_companyvirtual where " + return "select id,companyname as name,'0' as type from " + COMPANY_TABLE + " where " +
" versionid = "+vesionId+" and companyvirtualid = "+dimension; " versionid = " + versionId + " and companyvirtualid = " + dimension;
} }
} else { } else {
return "select id,subcompanyname as name,'1' as type from jcl_chart_subcompanyvirtual where " + if (hasVirtualFields) {
" versionid= "+vesionId+" and subcompanyvirtualid"+root; if (showVirtual) {
return "select " + SUB_COMPANY_ID + " as id,subcompanyname as name,'1' as type,isvirtual as isvitual from " + SUB_COMPANY_TABLE + " where versionid = " + versionId + " and subcompanyid = " + root;
} else {
return "select " + SUB_COMPANY_ID + " as 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 " + SUB_COMPANY_ID + " as id,subcompanyname as name,'1' as type from " + SUB_COMPANY_TABLE + " where versionid = " + versionId + " and subcompanyid = " + root;
}
} }
} }
@ -764,7 +799,7 @@ public class ChartServiceImpl extends Service implements ChartService {
private String getRealTimeTopSql(String root, String dimension) { private String getRealTimeTopSql(String root, String dimension) {
if ("0".equals(root)) { if ("0".equals(root)) {
// 查询集团数据 // 查询集团数据
if ("0".equals(dimension)) { if (isRealDimension) {
// 查询实际集团表 // 查询实际集团表
return "select id,companyname as name,'0' as type from " + COMPANY_TABLE; return "select id,companyname as name,'0' as type from " + COMPANY_TABLE;
} else { } else {
@ -786,16 +821,14 @@ public class ChartServiceImpl extends Service implements ChartService {
} }
/** /**
* , * ,SQL
* *
* @param topChartPO * @param sql SQL
* @param dataList * @param fType
* @param selectDepth * @param fObjId ID
* @return SQL
*/ */
private void findChildData(ChartPO topChartPO, List<ChartPO> dataList,Integer selectDepth) { private String getRealTimeChildSql(String sql, String fType, String fObjId) {
String fType = topChartPO.getFtype();
String fObjId = topChartPO.getFobjid();
String sql = "";
if (StringUtils.isNotBlank(fType)) { if (StringUtils.isNotBlank(fType)) {
switch (fType) { switch (fType) {
case "0": case "0":
@ -838,6 +871,82 @@ public class ChartServiceImpl extends Service implements ChartService {
break; 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 " + SUB_COMPANY_ID + " as 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 " + SUB_COMPANY_ID + " as 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 " + SUB_COMPANY_ID + " as 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 " + SUB_COMPANY_ID + " as 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 " + DEPARTMENT_ID + " as 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 " + SUB_COMPANY_ID + " as 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 " + DEPARTMENT_ID + " as 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 " + SUB_COMPANY_ID + " as 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 " + DEPARTMENT_ID + " as 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 " + DEPARTMENT_ID + " as 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 " + DEPARTMENT_ID + " as id,a.departmentname as name,'2' as type ,isvirtual as isvitual from " + DEPARTMENT_TABLE + " a where (canceled is null or canceled != '1') and (isvirtual is null or isvirtual != '1') and a.supdepartmentid = '" + fObjId + "' and versionid = " + versionId;
}
} else {
sql = "select " + DEPARTMENT_ID + " as 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)) { if (StringUtils.isNotBlank(sql)) {
List<ChartPO> currentList = new ArrayList<>(); List<ChartPO> currentList = new ArrayList<>();
@ -858,7 +967,7 @@ public class ChartServiceImpl extends Service implements ChartService {
} }
for (ChartPO chartPO : currentList) { for (ChartPO chartPO : currentList) {
if (inDepth(selectDepth, chartPO.getDepartmentDepth())) { if (inDepth(selectDepth, chartPO.getDepartmentDepth())) {
findChildData(chartPO, dataList, selectDepth); findChildData(chartPO, dataList, selectDepth, versionId);
} }
} }
dataList.addAll(currentList); dataList.addAll(currentList);
@ -871,10 +980,13 @@ public class ChartServiceImpl extends Service implements ChartService {
/** /**
* *
* *
* @param fClass * @param dimension
*/ */
public void initTableNameByClass(String fClass) { public void initTableNameByClass(String dimension, String id) {
if (StringUtils.isBlank(fClass) || "0".equals(fClass)) { isRealDimension = StringUtils.isBlank(dimension) || "0".equals(dimension);
isRealTime = StringUtils.isBlank(id) || "0".equals(id);
if (isRealTime) {
if (isRealDimension) {
COMPANY_TABLE = "hrmcompany"; COMPANY_TABLE = "hrmcompany";
SUB_COMPANY_TABLE = "hrmsubcompany"; SUB_COMPANY_TABLE = "hrmsubcompany";
SUB_COMPANY_DEFINED_TABLE = "hrmsubcompanydefined"; SUB_COMPANY_DEFINED_TABLE = "hrmsubcompanydefined";
@ -896,6 +1008,24 @@ public class ChartServiceImpl extends Service implements ChartService {
// 其他维度,无虚拟组织 // 其他维度,无虚拟组织
hasVirtualFields = false; hasVirtualFields = false;
} }
} else {
if (isRealDimension) {
COMPANY_TABLE = "hrmcompany";
SUB_COMPANY_TABLE = "jcl_chart_subcompany";
DEPARTMENT_TABLE = "jcl_chart_department";
SUB_COMPANY_ID = "subcompanyid";
DEPARTMENT_ID = "departmentid";
hasVirtualFields = true;
} else {
COMPANY_TABLE = "jcl_chart_companyvirtual";
SUB_COMPANY_TABLE = "jcl_chart_subcompanyvirtual";
DEPARTMENT_TABLE = "jcl_chart_departmentvirtual";
SUB_COMPANY_ID = "subcompanyvirtualid";
DEPARTMENT_ID = "departmentvirtualid";
// 其他维度,无虚拟组织
hasVirtualFields = false;
}
}
} }
@ -907,35 +1037,35 @@ public class ChartServiceImpl extends Service implements ChartService {
* @return boolean true,false * @return boolean true,false
*/ */
private Boolean getHasChildren(String fType, String fObjId) { private Boolean getHasChildren(String fType, String fObjId) {
String sql = ""; //String sql = "";
if (StringUtils.isNotBlank(fType)) { //if (StringUtils.isNotBlank(fType)) {
switch (fType) { // switch (fType) {
case "0": // case "0":
sql = "select id from " + SUB_COMPANY_TABLE + " where (supsubcomid is null or supsubcomid = '0') and companyid = '" + fObjId + "'"; // sql = "select id from " + SUB_COMPANY_TABLE + " where (supsubcomid is null or supsubcomid = '0') and companyid = '" + fObjId + "'";
break; // break;
case "1": // case "1":
if (hasVirtualFields && !showVirtual) { // 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 + "'"; // 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 { // } 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 + "'"; // 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; // break;
case "2": // case "2":
if (hasVirtualFields && !showVirtual) { // 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 + "'"; // 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 { // } else {
sql = "select id from " + DEPARTMENT_TABLE + " where (canceled is null or canceled != '1') and supdepid = '" + fObjId + "'"; // sql = "select id from " + DEPARTMENT_TABLE + " where (canceled is null or canceled != '1') and supdepid = '" + fObjId + "'";
} // }
break; // break;
default: // default:
break; // break;
} // }
} //}
if (StringUtils.isNotBlank(sql)) { //if (StringUtils.isNotBlank(sql)) {
RecordSet rs = new RecordSet(); // RecordSet rs = new RecordSet();
rs.executeQuery(sql); // rs.executeQuery(sql);
return rs.next(); // return rs.next();
} //}
return false; return false;
} }
@ -946,6 +1076,9 @@ public class ChartServiceImpl extends Service implements ChartService {
* @return * @return
*/ */
private String getDepartmentLeader(String ids) { private String getDepartmentLeader(String ids) {
if (!isRealTime) {
return ids;
}
if (StringUtils.isBlank(ids)) { if (StringUtils.isBlank(ids)) {
return ""; return "";
} }

@ -66,6 +66,8 @@ import java.util.*;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static weaver.general.Util.getIntValue;
/** /**
* @author:dxfeng * @author:dxfeng
* @createTime: 2022/06/20 * @createTime: 2022/06/20
@ -308,7 +310,7 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
@Override @Override
public Integer updateCustomTemplate(Map<String, Object> params) { public Integer updateCustomTemplate(Map<String, Object> params) {
int rowNum = Util.getIntValue((String) params.get("rownum")); int rowNum = getIntValue((String) params.get("rownum"));
int count = 0; int count = 0;
List<Long> allIds = getJclOrgCustomTemplateMapper().listAllId(); List<Long> allIds = getJclOrgCustomTemplateMapper().listAllId();
String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date()); String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date());
@ -424,11 +426,54 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
} }
@Override @Override
public Map<String, Object> chartResourceList(Integer departmentId) { public Map<String, Object> chartResourceList(Integer departmentId,String versionId,String dimension) {
Map<String, Object> dataMap = new HashMap<>(); Map<String, Object> dataMap = new HashMap<>();
List<ResourceListColumns> resourceListColumns = getTableColumns(); List<ResourceListColumns> resourceListColumns = getTableColumns();
List<ResourceChartPO> resourceChartPOS = getHrmResourceMapper().selectByDepartmentId(departmentId); List<ResourceChartPO> resourceChartPOS = new ArrayList<>();
List<ResourceChartVO> resourceChartVOS = ResourceChartBO.convertToVO(resourceChartPOS); List<ResourceChartVO> resourceChartVOS = new ArrayList<>();
RecordSet rs = new RecordSet();
if ("0".equals(dimension)) {
if ("0".equals(versionId)) {
//当前数据
resourceChartPOS = getHrmResourceMapper().selectByDepartmentId(departmentId);
resourceChartVOS = ResourceChartBO.convertToVO(resourceChartPOS);
}else {
rs.executeQuery("select resourceid,workcode,lastname,sex,department,subcompany,jobtitle,mobile from jcl_chart_resource where departmentid = ? and versionid = ?",departmentId,versionId);
while (rs.next()) {
ResourceChartVO build = ResourceChartVO.builder()
.id((long) Util.getIntValue(rs.getString("resourceid")))
.workCode(Util.null2String(rs.getString("workcode")))
.lastName(Util.null2String(rs.getString("lastname")))
.sex("1".equals(Util.null2String(rs.getString("workcode"))) ? "女" : "男")
.departmentName(Util.null2String(rs.getString("department")))
.subcompanyName(Util.null2String(rs.getString("subcompany")))
.jobTitle(Util.null2String(rs.getString("jobtitle")))
.mobile(Util.null2String(rs.getString("mobile")))
.build();
resourceChartVOS.add(build);
}
}
}else {
rs.executeQuery("select h.id,h.workcode,h.lastname,h.sex,h.departmentid,h.subcompanyid1,h.jobtitle,h.status,h.mobile " +
" from hrmresourcevirtual v left join hrmresource h on v.resourceid = h.id and v.virtualtype = ? and h.departmentid = ?",versionId,departmentId);
while (rs.next()) {
ResourceChartPO build = ResourceChartPO.builder()
.id((long) Util.getIntValue(rs.getString("id")))
.workCode(Util.null2String(rs.getString("workcode")))
.lastName(Util.null2String(rs.getString("lastname")))
.sex(Util.null2String(rs.getString("sex")))
.departmentId(Util.getIntValue(rs.getString("departmentid")))
.subcompanyid1(Util.getIntValue(rs.getString("subcompanyid1")))
.jobTitle(Util.getIntValue(rs.getString("jobtitle")))
.status(Util.getIntValue(rs.getString("subcompanyid1")))
.mobile(Util.null2String(rs.getString("subcompanyid1")))
.build();
resourceChartPOS.add(build);
}
resourceChartVOS = ResourceChartBO.convertToVO(resourceChartPOS);
}
dataMap.put("columns",resourceListColumns); dataMap.put("columns",resourceListColumns);
dataMap.put("dataSource",resourceChartVOS); dataMap.put("dataSource",resourceChartVOS);
return dataMap; return dataMap;

@ -106,10 +106,23 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
subcompany = "0"; subcompany = "0";
} }
String fclass = Util.null2String(params.get("fclass")); 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)) { 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 + "'"; 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); rs.executeQuery(sql);
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")).build()); companyTree.add(CompanyTreePO.builder().id(rs.getString("id")).pId(rs.getString("pId")).value(rs.getString("value")).title(rs.getString("title")).build());

Loading…
Cancel
Save