fix(core):没有按指定条件导出

yun-zuoyi
汪云昊 5 years ago
parent cc3bd5e4d5
commit 8c1476227a

@ -195,36 +195,7 @@ public class SysUserInfoController extends CoreBaseController{
@ApiOperation(value="查询用户信息",notes="复杂查询用户信息带分页")
public ResultBean querySysUserInfo(SysUserInfo userInfo, Pager pager){
try{
List<Long> idList = new ArrayList<>();
if(userInfo.getOrganizeId() == null || userInfo.getOrganizeId() <= 0) {
if (AuthUtil.getUserType().equals(CommonEnumUtil.USER_TYPE.ADMIN)) {
userInfo.setOrganizeCode(null);
userInfo.setOrganizeId(null);
} else {
userInfo.setOrganizeId(AuthUtil.getOrganize().getId());
userInfo.setOrganizeCode(AuthUtil.getOrganize().getOrganizeCode());
}
}
List<Long> departmentIdList = memTreeService.findDepartmentIdListByOrganizeIdAndDepartmentId(userInfo.getOrganizeId(), userInfo.getDepartmentId());
if(departmentIdList != null && departmentIdList.size() > 0){
List<SysRefUserInfoDepartment> refList = personnelService.findSysRefUserInfoDepartmentByDepartmentIdList(departmentIdList);
if(refList != null && refList.size() > 0){
refList.forEach(ref -> idList.add(ref.getUserId()));
}
}
if(userInfo.getPositionId() != null && userInfo.getPositionId() > 0){
List<Long> refList = memTreeService.findSysPositionChildIdList(userInfo.getPositionId());
if(refList != null && refList.size() > 0){
List<SysRefUserPosition> refUserPositionList = personnelService.findSysRefUserPositionByIdList(refList);
if(refUserPositionList != null && refUserPositionList.size() > 0){
refUserPositionList.forEach(ref -> idList.add(ref.getUserId()));
}
}
}
ListPager<SysUserInfo> result = sysUserInfoService.querySysUserInfo(userInfo,idList, pager);
ListPager<SysUserInfo> result = sysUserInfoService.querySysUserInfo(userInfo, packUserInfo(userInfo), pager);
return ResultBean.success("操作成功").setListPager(result).setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
}catch(ImppBusiException busExcep){
return ResultBean.fail(busExcep);
@ -406,10 +377,10 @@ public class SysUserInfoController extends CoreBaseController{
@GetMapping("/export")
@ApiOperation(value = "导出用户信息",notes = "导出用户信息")
public void exportSysUserInfo(SysUserInfo sysUserInfo, HttpServletResponse response) throws Exception {
public void exportSysUserInfo(SysUserInfo userInfo, HttpServletResponse response) throws Exception {
File file = null;
try {
List<SysUserInfo> list = sysUserInfoService.findSysUserInfoList(sysUserInfo);
List<SysUserInfo> list = sysUserInfoService.querySysUserInfoList(userInfo, packUserInfo(userInfo));
Map<Long, SysUser> sysUserMap = sysUserService.list().stream()
.collect(Collectors.toMap(SysUser::getId, Function.identity()));
List<UserExportModel> exportModelList = new ArrayList<>();
@ -418,16 +389,16 @@ public class SysUserInfoController extends CoreBaseController{
UserExportModel userExportModel;
List<SysRefUserRole> sysRefUserRoleList;
StringBuilder roleName = new StringBuilder();
for (SysUserInfo userInfo : list) {
for (SysUserInfo userInfoItem : list) {
// 关联角色信息
sysRefUserRoleList = sysUserService.findSysRefUserRoleByUserId(userInfo.getUserId());
sysRefUserRoleList = sysUserService.findSysRefUserRoleByUserId(userInfoItem.getUserId());
for (SysRefUserRole sysRefUserRole : sysRefUserRoleList) {
roleName.append(sysRefUserRole.getRoleNameRdd()).append(",");
}
roleName.setLength(roleName.length() - 1);
// 封装model
userExportModel = new UserExportModel(sysUserMap.get(userInfo.getUserId()), userInfo);
userExportModel = new UserExportModel(sysUserMap.get(userInfoItem.getUserId()), userInfoItem);
userExportModel.setRoleNameRdd(roleName.toString());
exportModelList.add(userExportModel);
@ -461,4 +432,38 @@ public class SysUserInfoController extends CoreBaseController{
}
}
private ArrayList<Long> packUserInfo(SysUserInfo userInfo){
ArrayList<Long> idList = new ArrayList<>();
if (userInfo.getOrganizeId() == null || userInfo.getOrganizeId() <= 0) {
if (AuthUtil.getUserType().equals(CommonEnumUtil.USER_TYPE.ADMIN)) {
userInfo.setOrganizeCode(null);
userInfo.setOrganizeId(null);
} else {
userInfo.setOrganizeId(AuthUtil.getOrganize().getId());
userInfo.setOrganizeCode(AuthUtil.getOrganize().getOrganizeCode());
}
}
List<Long> departmentIdList = memTreeService.findDepartmentIdListByOrganizeIdAndDepartmentId(
userInfo.getOrganizeId(), userInfo.getDepartmentId()
);
if (departmentIdList != null && departmentIdList.size() > 0) {
List<SysRefUserInfoDepartment> refList = personnelService.findSysRefUserInfoDepartmentByDepartmentIdList(departmentIdList);
if (refList != null && refList.size() > 0) {
refList.forEach(ref -> idList.add(ref.getUserId()));
}
}
if (userInfo.getPositionId() != null && userInfo.getPositionId() > 0) {
List<Long> refList = memTreeService.findSysPositionChildIdList(userInfo.getPositionId());
if (refList != null && refList.size() > 0) {
List<SysRefUserPosition> refUserPositionList = personnelService.findSysRefUserPositionByIdList(refList);
if (refUserPositionList != null && refUserPositionList.size() > 0) {
refUserPositionList.forEach(ref -> idList.add(ref.getUserId()));
}
}
}
return idList;
}
}

Loading…
Cancel
Save