|
|
|
@ -1,8 +1,6 @@
|
|
|
|
|
package cn.estsh.i3plus.core.apiservice.controller.busi;
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.busi.ICoreTreeService;
|
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.busi.ISysDepartmentService;
|
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.busi.ISysOrganizeService;
|
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.busi.*;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.StringTool;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.util.PlatformConstWords;
|
|
|
|
@ -13,6 +11,7 @@ import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SessionUser;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SysDepartment;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SysOrganize;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SysRefUserDepartment;
|
|
|
|
|
import cn.estsh.impp.framework.base.controller.CoreBaseController;
|
|
|
|
|
import cn.estsh.impp.framework.boot.auth.AuthUtil;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
|
|
|
@ -22,11 +21,14 @@ import cn.estsh.impp.framework.boot.util.ResultBean;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ValidatorBean;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -49,8 +51,14 @@ public class SysDepartmentController extends CoreBaseController {
|
|
|
|
|
private ICoreTreeService coreTreeService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ICoreMemTreeService memTreeService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ISysOrganizeService organizeService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IPersonnelService personnelService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 添加部门
|
|
|
|
|
* @param department 部门
|
|
|
|
@ -171,20 +179,46 @@ public class SysDepartmentController extends CoreBaseController {
|
|
|
|
|
@ApiOperation(value = "查询部门", notes = "组合查询部门信息外加分页信息")
|
|
|
|
|
public ResultBean querySysDepartment(SysDepartment department, Pager pager) {
|
|
|
|
|
try {
|
|
|
|
|
ListPager list = null;
|
|
|
|
|
if(department.getOrganizeId() != null){
|
|
|
|
|
SysOrganize organize = organizeService.getSysOrganizeById(department.getOrganizeId());
|
|
|
|
|
if(organize != null){
|
|
|
|
|
coreTreeService.findSysOrganizeChildrenTreePack(organize,0);
|
|
|
|
|
List<Long> childIds = coreTreeService.findSysOrganizeChildIds(organize);
|
|
|
|
|
list = departmentService.findSysDepartmentByPager(department,childIds, pager);
|
|
|
|
|
}else {
|
|
|
|
|
return ResultBean.fail("不存在组织信息").setCode(ResourceEnumUtil.MESSAGE.EMPTY.getCode());
|
|
|
|
|
ListPager result = null;
|
|
|
|
|
List<Long> refIds = new ArrayList<>();
|
|
|
|
|
List<Long> refFilterIds = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
// 通过组织获取部门信息
|
|
|
|
|
if (department.getOrganizeId() != null && department.getOrganizeId() > 0) {
|
|
|
|
|
List<Long> organizeIdList = memTreeService.findSysOrganizeChildIdList(department.getOrganizeId());
|
|
|
|
|
List<SysRefUserDepartment> refUserDepartmentList = personnelService.findSysRefUserDepartmentByOrganizeIdList(organizeIdList);
|
|
|
|
|
if (refUserDepartmentList != null && refUserDepartmentList.size() > 0) {
|
|
|
|
|
for (SysRefUserDepartment ref : refUserDepartmentList) {
|
|
|
|
|
refIds.add(ref.getDepartmentId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 通过父节点查询部门信息
|
|
|
|
|
if (department.getParentId() != null && department.getParentId() > 0) {
|
|
|
|
|
List<Long> departmentIdList = memTreeService.findSysDepartmentChildIdList(department.getParentId());
|
|
|
|
|
if (departmentIdList != null && departmentIdList.size() > 0) {
|
|
|
|
|
refIds.addAll(departmentIdList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 用户所拥有的权限
|
|
|
|
|
if (!AuthUtil.getUserType().equals(CommonEnumUtil.USER_TYPE.ADMIN)) {
|
|
|
|
|
List<SysRefUserDepartment> refList = personnelService.findSysRefUserDepartmentByUserId(getSessionUser().getUser().getId());
|
|
|
|
|
if (refList != null && refList.size() > 0) {
|
|
|
|
|
refList.forEach(ref -> refFilterIds.add(ref.getDepartmentId()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(refIds.size() <= 0){
|
|
|
|
|
refIds = refFilterIds;
|
|
|
|
|
}else {
|
|
|
|
|
list = departmentService.findSysDepartmentByPager(department, pager);
|
|
|
|
|
// List 取交集
|
|
|
|
|
refIds = (ArrayList<Long>) CollectionUtils.intersection(refIds, refFilterIds);
|
|
|
|
|
}
|
|
|
|
|
return ResultBean.success("操作成功").setListPager(list).setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result = departmentService.findSysDepartmentPagerByIdList(department, new ArrayList<>(refIds), pager);
|
|
|
|
|
return ResultBean.success("操作成功").setListPager(result).setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|