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

jcgj
dxfeng 2 years ago
parent 9435a21446
commit 1f5a8481e6

@ -1,55 +0,0 @@
//package com.engine.junchuang.service;
//
//
//import java.util.Collection;
//import java.util.Map;
//
///**
// * @Author weaver_cl
// * @Description:
// * @Date 2022/10/21
// * @Version V1.0
// **/
//public interface ManagerDetachService {
//
// /**
// * 获取table列表
// * @param params
// * @return
// */
// Map<String, Object> listPage(Map<String, Object> params);
//
// /**
// * 新建编辑表单
// * @param id
// * @return
// */
// Map<String, Object> getForm(Integer id);
//
// /**
// * 批量删除
// * @param ids
// * @return
// */
// int deleteByIds(Collection<Long> ids);
//
// /**
// * 新增
// * @param param
// * @return
// */
// int save(ManagerDetachParam param);
//
// /**
// * 更新
// * @param param
// * @return
// */
// int updateDetach(ManagerDetachParam param);
//
// /**
// * 分权开关
// * @param isDetach
// */
// String doDetach(String isDetach);
//}

@ -1,9 +1,8 @@
package com.engine.junchuang.service.impl; package com.engine.junchuang.service;
import cn.hutool.core.date.DateField; import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.engine.core.impl.Service; import com.engine.core.impl.Service;
import com.engine.junchuang.service.OrgChartService;
import com.engine.junchuang.util.OrganizationDateUtil; import com.engine.junchuang.util.OrganizationDateUtil;
import com.engine.junchuang.util.db.DBType; import com.engine.junchuang.util.db.DBType;
import com.engine.junchuang.util.detach.DetachUtil; import com.engine.junchuang.util.detach.DetachUtil;
@ -37,11 +36,22 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
String sql = "select id, fnumber, fname, ftype from junc_org_map where ftype in (0, 1) "; String sql = "select id, fnumber, fname, ftype from junc_org_map where ftype in (0, 1) ";
// 分部分权过滤 // 分部分权过滤
DetachUtil detachUtil = new DetachUtil(user.getUID()); //DetachUtil detachUtil = new DetachUtil(user.getUID());
//if (detachUtil.isDETACH()) {
// String jclRoleLevels = detachUtil.getJclRoleLevels();
// if (StringUtils.isNotBlank(jclRoleLevels)) {
// sql = "select id, fnumber, fname, ftype from junc_org_map where (ftype = 0 or (ftype = 1 and fobjid in(" + jclRoleLevels + "))) ";
// } else {
// sql = "select id, fnumber, fname, ftype from junc_org_map where ftype = 0 ";
// }
//}
DetachUtil detachUtil = new DetachUtil(user);
if (detachUtil.isDETACH()) { if (detachUtil.isDETACH()) {
String jclRoleLevels = detachUtil.getJclRoleLevels(); String companyIds = detachUtil.getCompanyIds();
if (StringUtils.isNotBlank(jclRoleLevels)) { String departmentIds = detachUtil.getDepartmentIds();
sql = "select id, fnumber, fname, ftype from junc_org_map where (ftype = 0 or (ftype = 1 and fobjid in(" + jclRoleLevels + "))) "; if (StringUtils.isNotBlank(departmentIds)) {
sql = "select id, fnumber, fname, ftype from junc_org_map where (ftype = 0 or (ftype = 1 and fobjid in(" + companyIds + ")) or (ftype = 2 and fobjid in(" + departmentIds + "))) ";
} else { } else {
sql = "select id, fnumber, fname, ftype from junc_org_map where ftype = 0 "; sql = "select id, fnumber, fname, ftype from junc_org_map where ftype = 0 ";
} }
@ -83,9 +93,11 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
rs.executeQuery("select t.id, t.fname, t.ftype, t.fparentid, t.fleadername,t.fobjid,t.fecid, t.fleaderimg, t.fleaderjob, t.fplan, t.fonjob, t.fnumber, t.fleader, t.fleaderlv, t.fleaderst, t.fecid, t.fisvitual from junc_org_map t " + whereSql + whereItemSql); rs.executeQuery("select t.id, t.fname, t.ftype, t.fparentid, t.fleadername,t.fobjid,t.fecid, t.fleaderimg, t.fleaderjob, t.fplan, t.fonjob, t.fnumber, t.fleader, t.fleaderlv, t.fleaderst, t.fecid, t.fisvitual from junc_org_map t " + whereSql + whereItemSql);
List<Map<String, Object>> list = new ArrayList<>(); List<Map<String, Object>> list = new ArrayList<>();
String id = null; String id = null;
String type = "0";
if (rs.next()) { if (rs.next()) {
Map<String, Object> item = new HashMap<>(); Map<String, Object> item = new HashMap<>();
id = rs.getString("id"); id = rs.getString("id");
type = rs.getString("ftype");
item.put("id", rs.getString("id")); item.put("id", rs.getString("id"));
item.put("fname", rs.getString("fname")); item.put("fname", rs.getString("fname"));
item.put("ftype", rs.getString("ftype")); item.put("ftype", rs.getString("ftype"));
@ -114,7 +126,7 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
} }
int currentLevel = 1; int currentLevel = 1;
findUserItemByParantId(id, currentLevel + 1, level, rs, list, whereSql, currentLevel + 1 <= Integer.parseInt(level)); findUserItemByParantId(id, currentLevel + 1, level, rs, list, whereSql, currentLevel + 1 <= Integer.parseInt(level), type, null);
// 分部数据,构建层级关系 // 分部数据,构建层级关系
reBuildTreeList(list, root); reBuildTreeList(list, root);
@ -128,28 +140,67 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
public Map<String, Object> asyncUserData(Map<String, Object> request2Map, User user) { public Map<String, Object> asyncUserData(Map<String, Object> request2Map, User user) {
String ids = (String) request2Map.get("ids"); String ids = (String) request2Map.get("ids");
String whereSql = userWhereSql(request2Map); String whereSql = userWhereSql(request2Map);
String sql = "select t.id, t.fname, t.ftype, t.fparentid, t.fleadername, t.fleaderimg, t.fleaderjob, t.fplan, t.fonjob, t.fnumber, t.fleader,t.fleaderlv, t.fleaderst,t.fobjid,t.fisvitual from junc_org_map t ";
String bmfzr = "";
RecordSet rs = new RecordSet();
whereSql += " and fparentid in (" + ids + ") "; if (ids.contains("_")) {
whereSql += " and ftype = 3 ";
} else if (Integer.parseInt(ids) > 100000000 && Integer.parseInt(ids) < 200000000) {
rs.executeQuery("select bmfzr from hrmdepartmentdefined where deptid =? ", Integer.parseInt(ids) - 100000000);
if (rs.next()) {
bmfzr = rs.getString("bmfzr");
}
}
RecordSet rs = new RecordSet(); DetachUtil detachUtil = new DetachUtil(user);
rs.executeQuery("select t.id, t.fname, t.ftype, t.fparentid, t.fleadername, t.fleaderimg, t.fleaderjob, t.fplan, t.fonjob, t.fnumber, t.fleader,t.fleaderlv, t.fleaderst,t.fobjid,t.fisvitual from junc_org_map t " + whereSql); if (detachUtil.isDETACH()) {
if ("0".equals(ids)) {
whereSql += " and t.ftype = 1 and t.fobjid in(" + detachUtil.getCompanyIds() + ")";
} else {
if (StringUtils.isNotBlank(bmfzr)) {
bmfzr = bmfzr.split(",")[0];
whereSql += " and ((t.fparentid = " + ids.split("_")[0] + " and t.ftype =2 and t.fobjid in(" + detachUtil.getDepartmentIds() + ")) or (t.ftype = 3 and fobjid = '" + bmfzr + "'))";
bmfzr = String.valueOf(200000000 + Integer.parseInt(bmfzr));
} else {
whereSql += " and t.fparentid = " + ids.split("_")[0] + " and ((t.ftype =2 and t.fobjid in(" + detachUtil.getDepartmentIds() + ")) or (t.ftype = 3 ))";
}
}
} else {
if (StringUtils.isNotBlank(bmfzr)) {
bmfzr = bmfzr.split(",")[0];
whereSql += " and ((t.fparentid = " + ids.split("_")[0] + " and t.ftype =2 ) or (t.ftype = 3 and fobjid = '" + bmfzr + "'))";
bmfzr = String.valueOf(200000000 + Integer.parseInt(bmfzr));
} else {
whereSql += " and t.fparentid = " + ids.split("_")[0];
}
}
rs.executeQuery(sql + whereSql);
List<Map<String, Object>> currentList = new ArrayList<>(); List<Map<String, Object>> currentList = new ArrayList<>();
while (rs.next()) { while (rs.next()) {
Map<String, Object> item = new HashMap<>(); Map<String, Object> item = new HashMap<>();
item.put("id", rs.getString("id")); item.put("id", rs.getString("id"));
item.put("fname", rs.getString("fname")); item.put("fname", rs.getString("fname"));
item.put("ftype", rs.getString("ftype")); item.put("ftype", rs.getString("ftype"));
item.put("parentId", rs.getString("fparentid")); item.put("parentId", ids.contains("_") ? ids : rs.getString("fparentid"));
item.put("fplan", rs.getString("fplan")); item.put("fplan", rs.getString("fplan"));
item.put("fonjob", rs.getString("fonjob")); item.put("fonjob", rs.getString("fonjob"));
item.put("fnumber", rs.getString("fnumber")); item.put("fnumber", rs.getString("fnumber"));
item.put("hasChildren", hasChildren(rs.getString("id"), false));
item.put("fleader", rs.getString("fleader")); item.put("fleader", rs.getString("fleader"));
item.put("fleaderimg", rs.getString("fleaderimg")); item.put("fleaderimg", rs.getString("fleaderimg"));
item.put("fleadername", rs.getString("fleadername")); item.put("fleadername", rs.getString("fleadername"));
item.put("fleaderjob", rs.getString("fleaderjob")); item.put("fleaderjob", rs.getString("fleaderjob"));
item.put("fobjid", rs.getString("fobjid")); item.put("fobjid", rs.getString("fobjid"));
item.put("fisvitual", rs.getString("fisvitual")); item.put("fisvitual", rs.getString("fisvitual"));
if (bmfzr.equals(item.get("id"))) {
item.put("id", ids + "_" + bmfzr);
item.put("parentId", ids);
item.put("hasChildren", hasChildren(ids, false));
} else {
item.put("hasChildren", hasChildren(rs.getString("id"), false));
}
currentList.add(item); currentList.add(item);
} }
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
@ -169,9 +220,9 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
// 1、清空当天所有数据 // 1、清空当天所有数据
rs.execute("delete from junc_org_map where fdatebegin = TO_DATE('"+date+"','yyyy-MM-dd')"); rs.execute("delete from junc_org_map where fdatebegin = TO_DATE('" + date + "','yyyy-MM-dd')");
// 2、修改所有失效数据 // 2、修改所有失效数据
rs.execute("update junc_org_map set fdateend=TO_DATE('"+yesterday+"','yyyy-MM-dd') where fdateend > TO_DATE('"+date+"','yyyy-MM-dd')"); rs.execute("update junc_org_map set fdateend=TO_DATE('" + yesterday + "','yyyy-MM-dd') where fdateend > TO_DATE('" + date + "','yyyy-MM-dd')");
// 3、同步集团数据 // 3、同步集团数据
String jtSql = "INSERT INTO junc_org_map ( id, ftype, fobjid, uuid,fclass, fclassname, fnumber, fname,\n" + String jtSql = "INSERT INTO junc_org_map ( id, ftype, fobjid, uuid,fclass, fclassname, fnumber, fname,\n" +
" fleader, fleaderimg, fleadername, fleaderjobid, fleaderjob, fparentid,fobjparentid,\n" + " fleader, fleaderimg, fleadername, fleaderjobid, fleaderjob, fparentid,fobjparentid,\n" +
@ -210,37 +261,37 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
String queryDept = "select id from hrmdepartment a where nvl(a.canceled,0)='0' "; String queryDept = "select id from hrmdepartment a where nvl(a.canceled,0)='0' ";
RecordSet recordSet = new RecordSet(); RecordSet recordSet = new RecordSet();
recordSet.execute(queryDept); recordSet.execute(queryDept);
while (recordSet.next()){ while (recordSet.next()) {
String deptId = Util.null2String(recordSet.getString("id")); String deptId = Util.null2String(recordSet.getString("id"));
// 处理部门(含子部门人数) // 处理部门(含子部门人数)
String getSupDeptSql = "select wm_concat(id) as allSupDept from hrmdepartment a start with a.id="+deptId+" connect by a.supdepid=prior a.id"; String getSupDeptSql = "select wm_concat(id) as allSupDept from hrmdepartment a start with a.id=" + deptId + " connect by a.supdepid=prior a.id";
rs.execute(getSupDeptSql); rs.execute(getSupDeptSql);
String allSupDeptIds = null; String allSupDeptIds = null;
if (rs.next()){ if (rs.next()) {
allSupDeptIds = Util.null2String(rs.getString("allSupDept")); allSupDeptIds = Util.null2String(rs.getString("allSupDept"));
} }
String getZrs = "select nvl(sum(zrs),0) zrs from (\n" + String getZrs = "select nvl(sum(zrs),0) zrs from (\n" +
"select a.departmentid,count(id) as zrs from hrmresource a where a.status<4 group by a.departmentid\n" + "select a.departmentid,count(id) as zrs from hrmresource a where a.status<4 group by a.departmentid\n" +
") b where b.departmentid in ("+allSupDeptIds+")"; ") b where b.departmentid in (" + allSupDeptIds + ")";
rs.execute(getZrs); rs.execute(getZrs);
String zrs = "0"; String zrs = "0";
if (rs.next()){ if (rs.next()) {
zrs = Util.null2String(rs.getString("zrs")); zrs = Util.null2String(rs.getString("zrs"));
} }
rs.execute("update junc_org_map set fonjob = '"+zrs+"' where ftype=2 and fdateend>sysdate and fobjid="+deptId); rs.execute("update junc_org_map set fonjob = '" + zrs + "' where ftype=2 and fdateend>sysdate and fobjid=" + deptId);
// 找出没有下级的人员 // 找出没有下级的人员
String noHaveChildSql = "select a.id,a.managerid from hrmresource a \n" + String noHaveChildSql = "select a.id,a.managerid from hrmresource a \n" +
"inner join (select id from hrmresource where departmentid='"+deptId+"'\n" + "inner join (select id from hrmresource where departmentid='" + deptId + "'\n" +
"MINUS\n" + "MINUS\n" +
"select managerid from hrmresource a \n" + "select managerid from hrmresource a \n" +
"where a.managerid in (select id from hrmresource where departmentid='"+deptId+"')\n" + "where a.managerid in (select id from hrmresource where departmentid='" + deptId + "')\n" +
"and a.departmentid='"+deptId+"') b on a.id=b.id"; "and a.departmentid='" + deptId + "') b on a.id=b.id";
rs.execute(noHaveChildSql); rs.execute(noHaveChildSql);
while (rs.next()){ while (rs.next()) {
String id = Util.null2String(rs.getString("id")); String id = Util.null2String(rs.getString("id"));
String managerid = Util.null2String(rs.getString("managerid")); String managerid = Util.null2String(rs.getString("managerid"));
handleSuperior(id,managerid,deptId); handleSuperior(id, managerid, deptId);
} }
} }
// 7、删除重复人员上级 // 7、删除重复人员上级
@ -268,8 +319,8 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
recordSet.execute("update junc_org_map set fonjob = (\n" + recordSet.execute("update junc_org_map set fonjob = (\n" +
"select nvl(sum(fbrs),0) fbrs from (\n" + "select nvl(sum(fbrs),0) fbrs from (\n" +
"select subcompanyid1,count(id) fbrs from hrmresource where status<4 group by subcompanyid1) \n" + "select subcompanyid1,count(id) fbrs from hrmresource where status<4 group by subcompanyid1) \n" +
"where subcompanyid1 in (select id from hrmsubcompany a start with a.id="+rs.getString("id")+" connect by a.supsubcomid=prior a.id)) \n" + "where subcompanyid1 in (select id from hrmsubcompany a start with a.id=" + rs.getString("id") + " connect by a.supsubcomid=prior a.id)) \n" +
"where ftype=1 and fdateend>sysdate and fobjid="+rs.getString("id")); "where ftype=1 and fdateend>sysdate and fobjid=" + rs.getString("id"));
} }
return "同步成功"; return "同步成功";
} }
@ -279,10 +330,10 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
* @Date 2023/3/7 15:47 * @Date 2023/3/7 15:47
* @Description * @Description
*/ */
private void handleSuperior(String id,String managerid,String deptId){ private void handleSuperior(String id, String managerid, String deptId) {
// 校验当前人员的直接上级是否在同一部门如不在当前部门map表中的上级应为部门id+ // 校验当前人员的直接上级是否在同一部门如不在当前部门map表中的上级应为部门id+
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
Boolean flag = checkManager(rs,managerid,deptId); Boolean flag = checkManager(rs, managerid, deptId);
if (flag) { if (flag) {
rs.execute("insert into junc_org_map\n" + rs.execute("insert into junc_org_map\n" +
@ -294,14 +345,14 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
" 0,TO_DATE(to_char(SYSDATE,'yyyy-MM-dd'),'yyyy-MM-dd'), TO_DATE('2099-12-31','yyyy-MM-dd')\n" + " 0,TO_DATE(to_char(SYSDATE,'yyyy-MM-dd'),'yyyy-MM-dd'), TO_DATE('2099-12-31','yyyy-MM-dd')\n" +
"from hrmresource a\n" + "from hrmresource a\n" +
"left join hrmjobtitles b on a.jobtitle=b.id\n" + "left join hrmjobtitles b on a.jobtitle=b.id\n" +
"where a.status < 4 and a.id='"+id+"'"); "where a.status < 4 and a.id='" + id + "'");
// 找上级的上级 // 找上级的上级
rs.execute("select id,managerid,departmentid from hrmresource where id='"+managerid+"'"); rs.execute("select id,managerid,departmentid from hrmresource where id='" + managerid + "'");
if (rs.next()){ if (rs.next()) {
String supId = Util.null2String(rs.getString("id")); String supId = Util.null2String(rs.getString("id"));
String supManagerId = Util.null2String(rs.getString("managerid")); String supManagerId = Util.null2String(rs.getString("managerid"));
String departmentid = Util.null2String(rs.getString("departmentid")); String departmentid = Util.null2String(rs.getString("departmentid"));
handleSuperior(supId,supManagerId,departmentid); handleSuperior(supId, supManagerId, departmentid);
} }
} else { } else {
rs.execute("insert into junc_org_map\n" + rs.execute("insert into junc_org_map\n" +
@ -313,7 +364,7 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
" 0,TO_DATE(to_char(SYSDATE,'yyyy-MM-dd'),'yyyy-MM-dd'), TO_DATE('2099-12-31','yyyy-MM-dd')\n" + " 0,TO_DATE(to_char(SYSDATE,'yyyy-MM-dd'),'yyyy-MM-dd'), TO_DATE('2099-12-31','yyyy-MM-dd')\n" +
"from hrmresource a\n" + "from hrmresource a\n" +
"left join hrmjobtitles b on a.jobtitle=b.id\n" + "left join hrmjobtitles b on a.jobtitle=b.id\n" +
"where a.status < 4 and a.id='"+id+"'"); "where a.status < 4 and a.id='" + id + "'");
} }
} }
@ -322,10 +373,10 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
* @Date 2023/3/7 17:14 * @Date 2023/3/7 17:14
* @Description * @Description
*/ */
private Boolean checkManager(RecordSet recordSet,String managerid,String deptId){ private Boolean checkManager(RecordSet recordSet, String managerid, String deptId) {
Boolean flag = false; Boolean flag = false;
recordSet.execute("select departmentid from hrmresource where id='"+managerid+"'"); recordSet.execute("select departmentid from hrmresource where id='" + managerid + "'");
if (recordSet.next()){ if (recordSet.next()) {
if (deptId.equals(Util.null2String(recordSet.getString("departmentid")))) { if (deptId.equals(Util.null2String(recordSet.getString("departmentid")))) {
flag = true; flag = true;
} }
@ -376,28 +427,49 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
return !"0".equals(count); return !"0".equals(count);
} }
private String getFieldName(String fieldabel) {
RecordSet recordSet = new RecordSet();
String fieldname = null;
recordSet.executeQuery("select fieldname from jcl_org_field where fieldlabel='" + fieldabel+"'");
if (recordSet.next()) {
fieldname = recordSet.getString("fieldname");
}
return fieldname;
}
private void findUserItemByParantId(String id, int currentLevel, String level, RecordSet rs, List<Map<String, Object>> list, String whereSql, boolean expand) { private void findUserItemByParantId(String id, int currentLevel, String level, RecordSet rs, List<Map<String, Object>> list, String whereSql, boolean expand, String type, String parentDeptId) {
String sql = "select t.id, t.fname, t.ftype, t.fparentid, t.fobjparentid, t.fleader, t.fleadername, t.fleaderimg, t.fleaderjob, t.fplan, t.fonjob, t.fnumber, t.fobjid, t.fecid, t.fleaderlv, t.fleaderst, t.fisvitual from junc_org_map t " + whereSql; String sql = "select t.id, t.fname, t.ftype, t.fparentid, t.fobjparentid, t.fleader, t.fleadername, t.fleaderimg, t.fleaderjob, t.fplan, t.fonjob, t.fnumber, t.fobjid, t.fecid, t.fleaderlv, t.fleaderst, t.fisvitual from junc_org_map t " + whereSql;
DetachUtil detachUtil = new DetachUtil(user.getUID()); String bmfzr = "";
String manageDeptId = "";
if ("2".equals(type)) {
rs.executeQuery("select bmfzr from hrmdepartmentdefined where deptid =? ", parentDeptId);
if (rs.next()) {
bmfzr = rs.getString("bmfzr");
}
}
if ("3".equals(type)) {
manageDeptId = id;
id = id.split("_")[0];
sql += " and ftype = 3 ";
}
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.getJclRoleLevels() + ")"; sql += " and t.ftype = 1 and t.fobjid in(" + detachUtil.getCompanyIds() + ")";
} else { } else {
sql += " and t.fparentid = " + id + " and t.ftype !=1"; if (StringUtils.isNotBlank(bmfzr)) {
bmfzr = bmfzr.split(",")[0];
sql += " and ((t.fparentid = " + id + " and t.ftype =2 and t.fobjid in(" + detachUtil.getDepartmentIds() + ")) or (t.ftype = 3 and fobjid = '" + bmfzr + "'))";
bmfzr = String.valueOf(200000000 + Integer.parseInt(bmfzr));
} else {
sql += " and t.fparentid = " + id + " and ((t.ftype =2 and t.fobjid in(" + detachUtil.getDepartmentIds() + ")) or (t.ftype = 3 ))";
}
} }
} else { } else {
sql += " and t.fparentid = " + id; if (StringUtils.isNotBlank(bmfzr)) {
bmfzr = bmfzr.split(",")[0];
sql += " and ((t.fparentid = " + id + " and t.ftype =2 ) or (t.ftype = 3 and fobjid = '" + bmfzr + "'))";
bmfzr = String.valueOf(200000000 + Integer.parseInt(bmfzr));
} else {
sql += " and t.fparentid = " + id;
}
} }
rs.executeQuery(sql); rs.executeQuery(sql);
List<Map<String, Object>> currentList = new ArrayList<>(); List<Map<String, Object>> currentList = new ArrayList<>();
while (rs.next()) { while (rs.next()) {
@ -405,7 +477,12 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
item.put("id", rs.getString("id")); item.put("id", rs.getString("id"));
item.put("fname", rs.getString("fname")); item.put("fname", rs.getString("fname"));
item.put("ftype", rs.getString("ftype")); item.put("ftype", rs.getString("ftype"));
item.put("parentId", rs.getString("fparentid")); if ("3".equals(type)) {
item.put("parentId", manageDeptId);
} else {
item.put("parentId", rs.getString("fparentid"));
}
item.put("fobjparentId", rs.getString("fobjparentid")); item.put("fobjparentId", rs.getString("fobjparentid"));
item.put("fplan", rs.getString("fplan")); item.put("fplan", rs.getString("fplan"));
item.put("fonjob", rs.getString("fonjob")); item.put("fonjob", rs.getString("fonjob"));
@ -419,30 +496,25 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
item.put("fleaderjob", rs.getString("fleaderjob")); item.put("fleaderjob", rs.getString("fleaderjob"));
item.put("fisvitual", rs.getString("fisvitual")); item.put("fisvitual", rs.getString("fisvitual"));
item.put("hasChildren", hasChildren(rs.getString("id"), false));
if (bmfzr.equals(item.get("id"))) {
// TODO
item.put("id", id + "_" + bmfzr);
item.put("parentId", id);
item.put("hasChildren", hasChildren(id, false));
} else {
item.put("hasChildren", hasChildren(rs.getString("id"), false));
}
currentList.add(item); currentList.add(item);
} }
for (Map<String, Object> stringObjectMap : currentList) { for (Map<String, Object> stringObjectMap : currentList) {
if ("4".equals(stringObjectMap.get("ftype"))) { // 员工信息 String fType = Util.null2String(stringObjectMap.get("ftype"));
rs.executeQuery("select id, mobile, homeaddress from hrmresource where id = ? ", stringObjectMap.get("fnumber"));
if (rs.next()) {
stringObjectMap.put("mobile", rs.getString("mobile"));
stringObjectMap.put("address", rs.getString("homeaddress"));
}
rs.executeQuery("select departmentname from hrmresource hrm \n" +
"left join hrmdepartment d\n" +
"on hrm.departmentid = d.id\n" +
"where hrm.id = ? ", stringObjectMap.get("fnumber"));
if (rs.next()) {
stringObjectMap.put("department", rs.getString("departmentname"));
}
}
if (currentLevel + 1 <= Integer.parseInt(level)) { if (currentLevel + 1 <= Integer.parseInt(level)) {
findUserItemByParantId((String) stringObjectMap.get("id"), currentLevel + 1, level, rs, list, whereSql, true); findUserItemByParantId((String) stringObjectMap.get("id"), currentLevel + 1, level, rs, list, whereSql, true, fType, Util.null2String(stringObjectMap.get("fobjid")));
} else if (currentLevel == Integer.parseInt(level)) { // 多查一层 } else if (currentLevel == Integer.parseInt(level)) {
findUserItemByParantId((String) stringObjectMap.get("id"), currentLevel + 1, level, rs, list, whereSql, false); // 多查一层
findUserItemByParantId((String) stringObjectMap.get("id"), currentLevel + 1, level, rs, list, whereSql, false, fType, Util.null2String(stringObjectMap.get("fobjid")));
} }
} }
list.addAll(currentList); list.addAll(currentList);
@ -458,25 +530,32 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
} }
}); });
} }
static class OrgSelectItem { static class OrgSelectItem {
private String id; private String id;
private String fnumber; private String fnumber;
private String fname; private String fname;
public String getId() { public String getId() {
return id; return id;
} }
public void setId(String id) { public void setId(String id) {
this.id = id; this.id = id;
} }
public String getFnumber() { public String getFnumber() {
return fnumber; return fnumber;
} }
public void setFnumber(String fnumber) { public void setFnumber(String fnumber) {
this.fnumber = fnumber; this.fnumber = fnumber;
} }
public String getFname() { public String getFname() {
return fname; return fname;
} }
public void setFname(String fname) { public void setFname(String fname) {
this.fname = fname; this.fname = fname;
} }

@ -1,147 +0,0 @@
//package com.engine.junchuang.service.impl;
//
//import com.api.browser.bean.SearchConditionGroup;
//import com.api.browser.bean.SearchConditionItem;
//import com.api.browser.bean.SearchConditionOption;
//import com.cloudstore.eccom.result.WeaResultMsg;
//import com.engine.core.impl.Service;
//import com.engine.junchuang.component.OrganizationWeaTable;
//import com.engine.junchuang.entity.detach.vo.ManagerDetachVO;
//import com.engine.junchuang.service.ManagerDetachService;
//import com.engine.junchuang.util.OrganizationFormItemUtil;
//import com.weaver.file.ConfigOperator;
//import com.weaver.general.BaseBean;
//import org.apache.commons.collections.CollectionUtils;
//import org.apache.commons.lang3.StringUtils;
//import weaver.conn.RecordSet;
//
//import java.util.*;
//import java.util.stream.Collectors;
//import java.util.stream.Stream;
//
///**
// * @Author weaver_cl
// * @Description:
// * @Date 2022/10/21
// * @Version V1.0
// **/
//public class ManagerDetachServiceImpl extends Service implements ManagerDetachService {
//
//
//
// @Override
// public Map<String, Object> listPage(Map<String, Object> params) {
// Map<String, Object> resultMap = new HashMap<>();
// //boolean hasRight = HasRightUtil.hasRight(user, RIGHT_NAME, true);
// resultMap.put("hasRight", true);
// //if (!hasRight) {
// // return resultMap;
// //}
// OrganizationWeaTable<ManagerDetachVO> table = new OrganizationWeaTable<>(user, ManagerDetachVO.class);
// String sqlWhere = buildSqlWhere(params);
// table.setSqlwhere(sqlWhere);
// WeaResultMsg result = new WeaResultMsg(false);
// result.putAll(table.makeDataResult());
// result.success();
// resultMap.putAll(result.getResultMap());
//
// return resultMap;
// }
//
// @Override
// public Map<String, Object> getForm(Integer id) {
// Map<String, Object> apiDatas = new HashMap<>();
// List<SearchConditionItem> selectItems = new ArrayList<>();
// List<SearchConditionGroup> addGroups = new ArrayList<>();
// List<SearchConditionOption> selectOptions = new ArrayList<>();
// SearchConditionOption moduleOption = new SearchConditionOption("0", "组织管理",true);
// selectOptions.add(moduleOption);
//
// SearchConditionItem ecManager = OrganizationFormItemUtil.browserItem(user, 2, 16, 3, true, "管理员", "1", "ecManager", "");
// ecManager.setRules("required|string");
// SearchConditionItem ecRolelevel = OrganizationFormItemUtil.browserItem(user, 2, 16, 3, false, "分管部门", "194", "ecRolelevel", "");
// ecRolelevel.setRules("required|string");
// addGroups.add(new SearchConditionGroup("基本信息", true, selectItems));
// apiDatas.put("condition", addGroups);
// return apiDatas;
// }
//
// @Override
// public int deleteByIds(Collection<Long> ids) {
// // return getMangeDetachMapper().deleteByIds(ids);
// return 0;
// }
//
// @Override
// public int save(ManagerDetachParam param) {
// ManagerDetachPO managerDetachPO = ManagerDetachPO.builder()
// .managerType(0)
// .ecManager(param.getEcManager())
// .jclManager(param.getEcManager())
// .ecRolelevel(param.getEcRolelevel())
// .jclRolelevel(param.getEcRolelevel())
// .manageModule("组织管理")
// .creator((long)user.getUID())
// .deleteType(0)
// .createTime(new Date())
// .updateTime(new Date())
// .build();
//
// // return getMangeDetachMapper().insertIgnoreNull(managerDetachPO);
// return 0;
// }
//
// @Override
// public int updateDetach(ManagerDetachParam param) {
// ManagerDetachPO managerDetachPO = ManagerDetachPO.builder()
// .id(param.getId())
// .ecManager(param.getEcManager())
// .ecRolelevel(param.getEcRolelevel())
// .jclManager(param.getEcManager())
// .jclRolelevel(param.getEcRolelevel())
// .build();
// return getMangeDetachMapper().updateDetach(managerDetachPO);
// }
//
// @Override
// public String doDetach(String isDetach) {
// ConfigOperator ConfigOperator = new ConfigOperator();
// ConfigOperator.setProp("hrmOrganization.properties", "detach", isDetach);
// return new BaseBean().getPropValue("hrmOrganization", "detach");
// }
//
// private String buildSqlWhere(Map<String, Object> params) {
// DBType dbType = DBType.get(new RecordSet().getDBType());
// String sqlWhere = " where delete_type = 0";
// String lastName = (String) params.get("ecManager");
// List<Long> resourceIds = MapperProxyFactory.getProxy(EmployeeMapper.class).getResourceIds(lastName);
// String ecManager = StringUtils.join(resourceIds,",");
// if (StringUtils.isNotBlank(lastName)) {
// sqlWhere += " AND ec_manager in ("+ecManager+") ";
// }
// String ecRolelevel = (String) params.get("ecRolelevel");
// if (StringUtils.isNotBlank(ecRolelevel)) {
// sqlWhere += " AND " + dbType.concat("ec_rolelevel") + dbType.like(ecRolelevel);
// }
// return sqlWhere;
// }
//
//
// /**
// * 查询当前人员所辖分部JCL_ID
// * @param uId
// * @return
// */
// public static List<Integer> getJclRoleLevels(Integer uId) {
// List<Integer> ecRoleLevels = new ArrayList<>();
// ManagerDetachMapper mangeDetachMapper = MapperProxyFactory.getProxy(ManagerDetachMapper.class);
// List<ManagerDetachPO> detachListById = mangeDetachMapper.getDetachListById(uId);
// for (ManagerDetachPO managerDetachPO : detachListById) {
// List<Integer> ids = Stream.of(managerDetachPO.getJclRolelevel().split(",")).map(Integer::parseInt).collect(Collectors.toList());
// if (CollectionUtils.isNotEmpty(ids)) {
// ecRoleLevels.addAll(ids);
// }
// }
// return ecRoleLevels;
// }
//}

@ -1,6 +1,13 @@
package com.engine.junchuang.util.detach; package com.engine.junchuang.util.detach;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSet; import weaver.conn.RecordSet;
import weaver.hrm.User;
import weaver.hrm.company.DepartmentComInfo;
import weaver.hrm.company.SubCompanyComInfo;
import java.util.*;
/** /**
* @author:dxfeng * @author:dxfeng
@ -8,33 +15,56 @@ import weaver.conn.RecordSet;
* @version: 1.0 * @version: 1.0
*/ */
public class DetachUtil { public class DetachUtil {
private boolean DETACH = false; private boolean DETACH = true;
private String jclRoleLevels; private final Set<String> companyIds = new HashSet<>();
private final Set<String> departmentIds = new HashSet<>();
public DetachUtil(Integer uId) { public DetachUtil(User user) {
if (1 == uId) { if (1 == user.getUID() || user.isAdmin()) {
DETACH = false; DETACH = false;
} }
if (DETACH) { if (DETACH) {
RecordSet rs = new RecordSet(); try {
String sql = "select a.RESOURCEID,b.ROLEID,GROUP_CONCAT(b.SUBCOMPANYID SEPARATOR ',') SUBCOMPANYID\n" + RecordSet rs = new RecordSet();
"from hrmrolemembers a, SysRoleSubcomRight b where a.ROLEID=b.ROLEID\n" + 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()));
"and a.RESOURCEID="+uId+"; "; while (rs.next()) {
rs.executeQuery(sql); String departmentId = rs.getString("id");
if(rs.next()){ String allSupDepartment = new DepartmentComInfo().getAllSupDepartment(departmentId);
jclRoleLevels = rs.getString("SUBCOMPANYID"); if (StringUtils.isNotBlank(allSupDepartment)) {
List<String> ids = Arrays.asList(allSupDepartment.split(","));
departmentIds.addAll(ids);
}
departmentIds.add(departmentId);
String subCompanyId = rs.getString("subcompanyid1");
String allSupCompany = new SubCompanyComInfo().getAllSupCompany(subCompanyId);
if (StringUtils.isNotBlank(allSupCompany)) {
List<String> ids = Arrays.asList(allSupCompany.split(","));
companyIds.addAll(ids);
}
companyIds.add(subCompanyId);
}
} catch (Exception e) {
throw new RuntimeException(e);
} }
} else {
jclRoleLevels = null;
} }
} }
public String getJclRoleLevels() {
return jclRoleLevels;
}
public boolean isDETACH() { public boolean isDETACH() {
return DETACH; return DETACH;
} }
public String getCompanyIds() {
if (CollectionUtils.isNotEmpty(companyIds)) {
return StringUtils.join(companyIds, ",");
}
return "";
}
public String getDepartmentIds() {
if (CollectionUtils.isNotEmpty(departmentIds)) {
return StringUtils.join(departmentIds, ",");
}
return "";
}
} }

@ -3,7 +3,7 @@ package com.engine.junchuang.wrapper;
import com.engine.common.util.ServiceUtil; import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service; import com.engine.core.impl.Service;
import com.engine.junchuang.service.OrgChartService; import com.engine.junchuang.service.OrgChartService;
import com.engine.junchuang.service.impl.OrgChartServiceImpl; import com.engine.junchuang.service.OrgChartServiceImpl;
import weaver.hrm.User; import weaver.hrm.User;
import java.util.Map; import java.util.Map;

Loading…
Cancel
Save