透视图分权、部门负责人展示

jcgj
dxfeng 2 years ago
parent cf9d05beee
commit 5bdade63f1

@ -37,7 +37,7 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
DetachUtil detachUtil = new DetachUtil(user); DetachUtil detachUtil = new DetachUtil(user);
if (detachUtil.isDETACH()) { if (detachUtil.isDetach()) {
String companyIds = detachUtil.getCompanyIds(); String companyIds = detachUtil.getCompanyIds();
String departmentIds = detachUtil.getDepartmentIds(); String departmentIds = detachUtil.getDepartmentIds();
if (StringUtils.isNotBlank(departmentIds)) { if (StringUtils.isNotBlank(departmentIds)) {
@ -138,8 +138,9 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
for (String id : split) { for (String id : split) {
String whereSql = userWhereSql(request2Map); String whereSql = userWhereSql(request2Map);
String bmfzr = ""; String bmfzr = "";
if (id.contains("_")) {
if (!id.contains("_") && Integer.parseInt(id) > 100000000 && Integer.parseInt(id) < 200000000) { whereSql += " and t.id != '" + id.split("_")[1] + "'";
} else if (Integer.parseInt(id) > 100000000 && Integer.parseInt(id) < 200000000) {
rs.executeQuery("select bmfzr from hrmdepartmentdefined where deptid =? ", Integer.parseInt(id) - 100000000); rs.executeQuery("select bmfzr from hrmdepartmentdefined where deptid =? ", Integer.parseInt(id) - 100000000);
if (rs.next()) { if (rs.next()) {
bmfzr = rs.getString("bmfzr"); bmfzr = rs.getString("bmfzr");
@ -147,7 +148,7 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
} }
if (detachUtil.isDETACH()) { if (detachUtil.isDetach()) {
if ("0".equals(id)) { if ("0".equals(id)) {
whereSql += " and t.ftype = 1 and t.fobjid in(" + detachUtil.getCompanyIds() + ")"; whereSql += " and t.ftype = 1 and t.fobjid in(" + detachUtil.getCompanyIds() + ")";
} else { } else {
@ -439,11 +440,12 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
manageDeptId = id; manageDeptId = id;
id = id.split("_")[0]; id = id.split("_")[0];
//sql += " and ftype = 3 "; //sql += " and ftype = 3 ";
sql += " and t.id != '" + id.split("_")[1] + "'";
} }
DetachUtil detachUtil = new DetachUtil(user); DetachUtil detachUtil = new DetachUtil(user);
if (detachUtil.isDETACH()) { if (detachUtil.isDetach()) {
if ("0".equals(id)) { if ("0".equals(id)) {
sql += " and t.ftype = 1 and t.fobjid in(" + detachUtil.getCompanyIds() + ")"; sql += " and t.ftype = 1 and t.fobjid in(" + detachUtil.getCompanyIds() + ")";
} else { } else {

@ -15,37 +15,43 @@ import java.util.*;
* @version: 1.0 * @version: 1.0
*/ */
public class DetachUtil { public class DetachUtil {
private boolean DETACH = true; private boolean detach = true;
private final Set<String> companyIds = new HashSet<>(); private final Set<String> companyIds = new HashSet<>();
private final Set<String> departmentIds = new HashSet<>(); private final Set<String> departmentIds = new HashSet<>();
public DetachUtil(User user) { public DetachUtil(User user) {
if (1 == user.getUID() || user.isAdmin()) { if (1 == user.getUID() || user.isAdmin()) {
DETACH = false; detach = false;
} }
if (DETACH) { if (detach) {
try { try {
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
// 查询建模表、添加相应的权限
rs.executeQuery("select fbqx from uf_zzjgtqx where yh = ? ", user.getUID());
if (rs.next()) {
String fbqx = rs.getString("fbqx");
if (StringUtils.isNotBlank(fbqx)) {
String[] manageCompanyIds = fbqx.split(",");
for (String companyId : manageCompanyIds) {
rs.executeQuery("select id from hrmdepartment where subcompanyid1 = ? ", companyId);
while (rs.next()) {
getDetachDepartment(rs.getString("id"));
}
getDetachCompany(companyId);
}
}
}
// 拥有所辖部门及所在部门的权限
rs.executeQuery("select a.id, a.subcompanyid1 from hrmdepartment a inner join hrmdepartmentdefined b on a.id = b.deptid where a.id = ? or b.bmfzr = ? ", String.valueOf(user.getUserDepartment()), String.valueOf(user.getUID())); rs.executeQuery("select a.id, a.subcompanyid1 from hrmdepartment a inner join hrmdepartmentdefined b on a.id = b.deptid where a.id = ? or b.bmfzr = ? ", String.valueOf(user.getUserDepartment()), String.valueOf(user.getUID()));
while (rs.next()) { while (rs.next()) {
String departmentId = rs.getString("id"); String departmentId = rs.getString("id");
String allSupDepartment = new DepartmentComInfo().getAllSupDepartment(departmentId); getDetachDepartment(departmentId);
if (StringUtils.isNotBlank(allSupDepartment)) {
List<String> ids = Arrays.asList(allSupDepartment.split(","));
departmentIds.addAll(ids);
}
ArrayList<String> childDeptIds = new ArrayList<>();
new DepartmentComInfo().getAllChildDeptByDepId(childDeptIds, departmentId);
departmentIds.addAll(childDeptIds);
departmentIds.add(departmentId);
String subCompanyId = rs.getString("subcompanyid1"); String subCompanyId = rs.getString("subcompanyid1");
String allSupCompany = new SubCompanyComInfo().getAllSupCompany(subCompanyId); getDetachCompany(subCompanyId);
if (StringUtils.isNotBlank(allSupCompany)) {
List<String> ids = Arrays.asList(allSupCompany.split(","));
companyIds.addAll(ids);
}
companyIds.add(subCompanyId);
} }
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
@ -53,8 +59,8 @@ public class DetachUtil {
} }
} }
public boolean isDETACH() { public boolean isDetach() {
return DETACH; return detach;
} }
public String getCompanyIds() { public String getCompanyIds() {
@ -70,4 +76,31 @@ public class DetachUtil {
} }
return ""; return "";
} }
private void getDetachDepartment(String departmentId) throws Exception {
if (StringUtils.isBlank(departmentId)) {
return;
}
String allSupDepartment = new DepartmentComInfo().getAllSupDepartment(departmentId);
if (StringUtils.isNotBlank(allSupDepartment)) {
List<String> ids = Arrays.asList(allSupDepartment.split(","));
departmentIds.addAll(ids);
}
ArrayList<String> childDeptIds = new ArrayList<>();
new DepartmentComInfo().getAllChildDeptByDepId(childDeptIds, departmentId);
departmentIds.addAll(childDeptIds);
departmentIds.add(departmentId);
}
private void getDetachCompany(String companyId) throws Exception {
if (StringUtils.isBlank(companyId)) {
return;
}
String allSupCompany = new SubCompanyComInfo().getAllSupCompany(companyId);
if (StringUtils.isNotBlank(allSupCompany)) {
List<String> ids = Arrays.asList(allSupCompany.split(","));
companyIds.addAll(ids);
}
companyIds.add(companyId);
}
} }

Loading…
Cancel
Save