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

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.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<Map<String, Object>> list = new ArrayList<>();
String id = null;
String type = "0";
if (rs.next()) {
Map<String, Object> 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<String, Object> asyncUserData(Map<String, Object> 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<Map<String, Object>> currentList = new ArrayList<>();
while (rs.next()) {
Map<String, Object> 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<String, Object> result = new HashMap<>();
@ -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");
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 bmfzr = "";
String manageDeptId = "";
if ("2".equals(type)) {
rs.executeQuery("select bmfzr from hrmdepartmentdefined where deptid =? ", parentDeptId);
if (rs.next()) {
bmfzr = rs.getString("bmfzr");
}
return fieldname;
}
private void findUserItemByParantId(String id, int currentLevel, String level, RecordSet rs, List<Map<String, Object>> list, String whereSql, boolean expand) {
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());
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 {
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 !=1";
sql += " and t.fparentid = " + id + " and ((t.ftype =2 and t.fobjid in(" + detachUtil.getDepartmentIds() + ")) or (t.ftype = 3 ))";
}
}
} else {
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<Map<String, Object>> 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"));
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"));
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<String, Object> 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;
}

@ -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;
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<String> companyIds = new HashSet<>();
private final Set<String> departmentIds = new HashSet<>();
public DetachUtil(Integer uId) {
if (1 == uId) {
public DetachUtil(User user) {
if (1 == user.getUID() || user.isAdmin()) {
DETACH = false;
}
if (DETACH) {
try {
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");
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<String> ids = Arrays.asList(allSupDepartment.split(","));
departmentIds.addAll(ids);
}
} else {
jclRoleLevels = null;
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);
}
}
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 "";
}
}

@ -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;

Loading…
Cancel
Save