diff --git a/src/com/engine/junchuang/service/ManagerDetachService.java b/src/com/engine/junchuang/service/ManagerDetachService.java deleted file mode 100644 index c420d31..0000000 --- a/src/com/engine/junchuang/service/ManagerDetachService.java +++ /dev/null @@ -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 listPage(Map params); -// -// /** -// * 新建编辑表单 -// * @param id -// * @return -// */ -// Map getForm(Integer id); -// -// /** -// * 批量删除 -// * @param ids -// * @return -// */ -// int deleteByIds(Collection ids); -// -// /** -// * 新增 -// * @param param -// * @return -// */ -// int save(ManagerDetachParam param); -// -// /** -// * 更新 -// * @param param -// * @return -// */ -// int updateDetach(ManagerDetachParam param); -// -// /** -// * 分权开关 -// * @param isDetach -// */ -// String doDetach(String isDetach); -//} diff --git a/src/com/engine/junchuang/service/impl/OrgChartServiceImpl.java b/src/com/engine/junchuang/service/OrgChartServiceImpl.java similarity index 74% rename from src/com/engine/junchuang/service/impl/OrgChartServiceImpl.java rename to src/com/engine/junchuang/service/OrgChartServiceImpl.java index e281e05..3fccbd8 100644 --- a/src/com/engine/junchuang/service/impl/OrgChartServiceImpl.java +++ b/src/com/engine/junchuang/service/OrgChartServiceImpl.java @@ -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.DateUtil; import com.engine.core.impl.Service; -import com.engine.junchuang.service.OrgChartService; import com.engine.junchuang.util.OrganizationDateUtil; import com.engine.junchuang.util.db.DBType; 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) "; // 分部分权过滤 - 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()) { - 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 + "))) "; + String companyIds = detachUtil.getCompanyIds(); + String departmentIds = detachUtil.getDepartmentIds(); + 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 { 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); List> list = new ArrayList<>(); String id = null; + String type = "0"; if (rs.next()) { Map item = new HashMap<>(); id = rs.getString("id"); + type = rs.getString("ftype"); item.put("id", rs.getString("id")); item.put("fname", rs.getString("fname")); item.put("ftype", rs.getString("ftype")); @@ -114,7 +126,7 @@ public class OrgChartServiceImpl extends Service implements OrgChartService { } 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); @@ -128,28 +140,67 @@ public class OrgChartServiceImpl extends Service implements OrgChartService { public Map asyncUserData(Map request2Map, User user) { String ids = (String) request2Map.get("ids"); 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(); - 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); + DetachUtil detachUtil = new DetachUtil(user); + 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> currentList = new ArrayList<>(); while (rs.next()) { Map item = new HashMap<>(); item.put("id", rs.getString("id")); item.put("fname", rs.getString("fname")); 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("fonjob", rs.getString("fonjob")); item.put("fnumber", rs.getString("fnumber")); - item.put("hasChildren", hasChildren(rs.getString("id"), false)); item.put("fleader", rs.getString("fleader")); item.put("fleaderimg", rs.getString("fleaderimg")); item.put("fleadername", rs.getString("fleadername")); item.put("fleaderjob", rs.getString("fleaderjob")); item.put("fobjid", rs.getString("fobjid")); 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); } Map result = new HashMap<>(); @@ -169,9 +220,9 @@ public class OrgChartServiceImpl extends Service implements OrgChartService { RecordSet rs = new RecordSet(); // 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、修改所有失效数据 - 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、同步集团数据 String jtSql = "INSERT INTO junc_org_map ( id, ftype, fobjid, uuid,fclass, fclassname, fnumber, fname,\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' "; RecordSet recordSet = new RecordSet(); recordSet.execute(queryDept); - while (recordSet.next()){ + while (recordSet.next()) { 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); String allSupDeptIds = null; - if (rs.next()){ + if (rs.next()) { allSupDeptIds = Util.null2String(rs.getString("allSupDept")); } 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" + - ") b where b.departmentid in ("+allSupDeptIds+")"; + ") b where b.departmentid in (" + allSupDeptIds + ")"; rs.execute(getZrs); String zrs = "0"; - if (rs.next()){ + if (rs.next()) { 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" + - "inner join (select id from hrmresource where departmentid='"+deptId+"'\n" + + "inner join (select id from hrmresource where departmentid='" + deptId + "'\n" + "MINUS\n" + "select managerid from hrmresource a \n" + - "where a.managerid in (select id from hrmresource where departmentid='"+deptId+"')\n" + - "and a.departmentid='"+deptId+"') b on a.id=b.id"; + "where a.managerid in (select id from hrmresource where departmentid='" + deptId + "')\n" + + "and a.departmentid='" + deptId + "') b on a.id=b.id"; rs.execute(noHaveChildSql); - while (rs.next()){ + while (rs.next()) { String id = Util.null2String(rs.getString("id")); String managerid = Util.null2String(rs.getString("managerid")); - handleSuperior(id,managerid,deptId); + handleSuperior(id, managerid, deptId); } } // 7、删除重复人员上级 @@ -268,8 +319,8 @@ public class OrgChartServiceImpl extends Service implements OrgChartService { recordSet.execute("update junc_org_map set fonjob = (\n" + "select nvl(sum(fbrs),0) fbrs from (\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 ftype=1 and fdateend>sysdate and fobjid="+rs.getString("id")); + "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")); } return "同步成功"; } @@ -279,10 +330,10 @@ public class OrgChartServiceImpl extends Service implements OrgChartService { * @Date 2023/3/7 15:47 * @Description 处理上级 */ - private void handleSuperior(String id,String managerid,String deptId){ + private void handleSuperior(String id, String managerid, String deptId) { // 校验当前人员的直接上级是否在同一部门,如不在当前部门,map表中的上级应为部门id+ RecordSet rs = new RecordSet(); - Boolean flag = checkManager(rs,managerid,deptId); + Boolean flag = checkManager(rs, managerid, deptId); if (flag) { 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" + "from hrmresource a\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+"'"); - if (rs.next()){ + rs.execute("select id,managerid,departmentid from hrmresource where id='" + managerid + "'"); + if (rs.next()) { String supId = Util.null2String(rs.getString("id")); String supManagerId = Util.null2String(rs.getString("managerid")); String departmentid = Util.null2String(rs.getString("departmentid")); - handleSuperior(supId,supManagerId,departmentid); + handleSuperior(supId, supManagerId, departmentid); } } else { 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" + "from hrmresource a\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 * @Description 校验上级是否在当前部门 */ - private Boolean checkManager(RecordSet recordSet,String managerid,String deptId){ + private Boolean checkManager(RecordSet recordSet, String managerid, String deptId) { Boolean flag = false; - recordSet.execute("select departmentid from hrmresource where id='"+managerid+"'"); - if (recordSet.next()){ + recordSet.execute("select departmentid from hrmresource where id='" + managerid + "'"); + if (recordSet.next()) { if (deptId.equals(Util.null2String(recordSet.getString("departmentid")))) { flag = true; } @@ -376,28 +427,49 @@ public class OrgChartServiceImpl extends Service implements OrgChartService { 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> list, String whereSql, boolean expand) { + private void findUserItemByParantId(String id, int currentLevel, String level, RecordSet rs, List> 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; - 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 ("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 { - 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 { - 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); List> currentList = new ArrayList<>(); while (rs.next()) { @@ -405,7 +477,12 @@ public class OrgChartServiceImpl extends Service implements OrgChartService { item.put("id", rs.getString("id")); item.put("fname", rs.getString("fname")); 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("fplan", rs.getString("fplan")); 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("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); } for (Map stringObjectMap : currentList) { - if ("4".equals(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")); - } - - } + String fType = Util.null2String(stringObjectMap.get("ftype")); if (currentLevel + 1 <= Integer.parseInt(level)) { - findUserItemByParantId((String) stringObjectMap.get("id"), currentLevel + 1, level, rs, list, whereSql, true); - } 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, true, fType, Util.null2String(stringObjectMap.get("fobjid"))); + } else if (currentLevel == Integer.parseInt(level)) { + // 多查一层 + findUserItemByParantId((String) stringObjectMap.get("id"), currentLevel + 1, level, rs, list, whereSql, false, fType, Util.null2String(stringObjectMap.get("fobjid"))); } } list.addAll(currentList); @@ -458,25 +530,32 @@ public class OrgChartServiceImpl extends Service implements OrgChartService { } }); } + static class OrgSelectItem { private String id; private String fnumber; private String fname; + public String getId() { return id; } + public void setId(String id) { this.id = id; } + public String getFnumber() { return fnumber; } + public void setFnumber(String fnumber) { this.fnumber = fnumber; } + public String getFname() { return fname; } + public void setFname(String fname) { this.fname = fname; } diff --git a/src/com/engine/junchuang/service/impl/ManagerDetachServiceImpl.java b/src/com/engine/junchuang/service/impl/ManagerDetachServiceImpl.java deleted file mode 100644 index f2b1f4e..0000000 --- a/src/com/engine/junchuang/service/impl/ManagerDetachServiceImpl.java +++ /dev/null @@ -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 listPage(Map params) { -// Map resultMap = new HashMap<>(); -// //boolean hasRight = HasRightUtil.hasRight(user, RIGHT_NAME, true); -// resultMap.put("hasRight", true); -// //if (!hasRight) { -// // return resultMap; -// //} -// OrganizationWeaTable 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 getForm(Integer id) { -// Map apiDatas = new HashMap<>(); -// List selectItems = new ArrayList<>(); -// List addGroups = new ArrayList<>(); -// List 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 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 params) { -// DBType dbType = DBType.get(new RecordSet().getDBType()); -// String sqlWhere = " where delete_type = 0"; -// String lastName = (String) params.get("ecManager"); -// List 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 getJclRoleLevels(Integer uId) { -// List ecRoleLevels = new ArrayList<>(); -// ManagerDetachMapper mangeDetachMapper = MapperProxyFactory.getProxy(ManagerDetachMapper.class); -// List detachListById = mangeDetachMapper.getDetachListById(uId); -// for (ManagerDetachPO managerDetachPO : detachListById) { -// List ids = Stream.of(managerDetachPO.getJclRolelevel().split(",")).map(Integer::parseInt).collect(Collectors.toList()); -// if (CollectionUtils.isNotEmpty(ids)) { -// ecRoleLevels.addAll(ids); -// } -// } -// return ecRoleLevels; -// } -//} diff --git a/src/com/engine/junchuang/util/detach/DetachUtil.java b/src/com/engine/junchuang/util/detach/DetachUtil.java index df3d806..db9901c 100644 --- a/src/com/engine/junchuang/util/detach/DetachUtil.java +++ b/src/com/engine/junchuang/util/detach/DetachUtil.java @@ -1,6 +1,13 @@ package com.engine.junchuang.util.detach; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import weaver.conn.RecordSet; +import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.company.SubCompanyComInfo; + +import java.util.*; /** * @author:dxfeng @@ -8,33 +15,56 @@ import weaver.conn.RecordSet; * @version: 1.0 */ public class DetachUtil { - private boolean DETACH = false; + private boolean DETACH = true; - private String jclRoleLevels; + private final Set companyIds = new HashSet<>(); + private final Set departmentIds = new HashSet<>(); - public DetachUtil(Integer uId) { - if (1 == uId) { + public DetachUtil(User user) { + if (1 == user.getUID() || user.isAdmin()) { DETACH = false; } if (DETACH) { - RecordSet rs = new RecordSet(); - String sql = "select a.RESOURCEID,b.ROLEID,GROUP_CONCAT(b.SUBCOMPANYID SEPARATOR ',') SUBCOMPANYID\n" + - "from hrmrolemembers a, SysRoleSubcomRight b where a.ROLEID=b.ROLEID\n" + - "and a.RESOURCEID="+uId+"; "; - rs.executeQuery(sql); - if(rs.next()){ - jclRoleLevels = rs.getString("SUBCOMPANYID"); + try { + RecordSet rs = new RecordSet(); + 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()) { + String departmentId = rs.getString("id"); + String allSupDepartment = new DepartmentComInfo().getAllSupDepartment(departmentId); + if (StringUtils.isNotBlank(allSupDepartment)) { + List 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 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() { 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 ""; + } } diff --git a/src/com/engine/junchuang/wrapper/OrgChartWrapper.java b/src/com/engine/junchuang/wrapper/OrgChartWrapper.java index 1e07cb3..8224f30 100644 --- a/src/com/engine/junchuang/wrapper/OrgChartWrapper.java +++ b/src/com/engine/junchuang/wrapper/OrgChartWrapper.java @@ -3,7 +3,7 @@ package com.engine.junchuang.wrapper; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.junchuang.service.OrgChartService; -import com.engine.junchuang.service.impl.OrgChartServiceImpl; +import com.engine.junchuang.service.OrgChartServiceImpl; import weaver.hrm.User; import java.util.Map;