feat:人员导出bug

This commit is contained in:
dzc committed 2025-02-21 15:58:41 +08:00
1 parent 3df60e707c
commit a7fe7c5c32
3 files changed
+31 -11

No files matched your search

@@ -20,7 +20,6 @@
package com.bsd.pjcloud.admin.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -247,10 +246,10 @@ public class SysUserController {
* @return
*/
@ResponseExcel
@GetMapping("/export")
@PostMapping("/export")
@HasPermission("sys_user_export")
public List export(UserDTO userDTO, Long[] ids) {
return userService.listUser(userDTO, ids);
public List export(@RequestBody UserDTO userDTO) {
return userService.listUser(userDTO, null);
}
/**
@@ -380,11 +379,11 @@ public class SysUserController {
@GetMapping("/getSimpleUserAll")
@Schema(description = "简要用户信息")
public R<List<SimpleUserAllListVO>> getSimpleUserAllList(@RequestParam(value = "mobile",required = false) String mobile,
@RequestParam(value = "name",required = false) String name){
public R<List<SimpleUserAllListVO>> getSimpleUserAllList(@RequestParam(value = "mobile", required = false) String mobile,
@RequestParam(value = "name", required = false) String name) {
LambdaQueryWrapper<SysUser> sysUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
sysUserLambdaQueryWrapper.like(StringUtils.isNotBlank(mobile),SysUser::getPhone,mobile);
sysUserLambdaQueryWrapper.like(StringUtils.isNotBlank(name),SysUser::getName,name);
sysUserLambdaQueryWrapper.like(StringUtils.isNotBlank(mobile), SysUser::getPhone, mobile);
sysUserLambdaQueryWrapper.like(StringUtils.isNotBlank(name), SysUser::getName, name);
List<SimpleUserAllListVO> list = userService.listScope(sysUserLambdaQueryWrapper);
return R.ok(list);
@@ -220,6 +220,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
*/
@Override
public IPage getUsersWithRolePage(Page page, UserDTO userDTO) {
// 部门
if (ObjectUtil.isNotEmpty(userDTO.getIsDeepDept()) && userDTO.getIsDeepDept() && ObjectUtil.isNotEmpty(userDTO.getDeptId())) {
List<SysDept> deptList = sysDeptService.listDescendant(userDTO.getDeptId());
userDTO.setDeptId(null);
@@ -227,6 +228,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
userDTO.setDeptIds(deptList.stream().map(SysDept::getDeptId).collect(Collectors.toList()));
}
}
if (ObjectUtil.isNotEmpty(userDTO.getDeptIds())) {
userDTO.setDeptId(null);
}
IPage<UserVO> list = baseMapper.getUserVosPage(page, userDTO, DataScope.of());
if (ObjectUtil.isNotEmpty(list.getRecords())) {
List<Long> userIds = list.getRecords().stream().map(UserVO::getUserId).distinct().toList();
@@ -363,6 +367,17 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
*/
@Override
public List<UserExcelVO> listUser(UserDTO userDTO, Long[] ids) {
// 部门
if (ObjectUtil.isNotEmpty(userDTO.getIsDeepDept()) && userDTO.getIsDeepDept() && ObjectUtil.isNotEmpty(userDTO.getDeptId())) {
List<SysDept> deptList = sysDeptService.listDescendant(userDTO.getDeptId());
userDTO.setDeptId(null);
if (ObjectUtil.isNotEmpty(deptList)) {
userDTO.setDeptIds(deptList.stream().map(SysDept::getDeptId).collect(Collectors.toList()));
}
}
if (ObjectUtil.isNotEmpty(userDTO.getDeptIds())) {
userDTO.setDeptId(null);
}
// 根据数据权限查询全部的用户信息
List<UserVO> voList = baseMapper.selectVoListByScope(userDTO, ids, DataScope.of());
// 转换成execl 对象输出
@@ -768,7 +783,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
@Override
public List<SimpleUserAllListVO> listScope(LambdaQueryWrapper<SysUser> sysUserLambdaQueryWrapper) {
List<SysUser> sysUsers = baseMapper.selectListByScope(sysUserLambdaQueryWrapper,DataScope.of());
List<SysUser> sysUsers = baseMapper.selectListByScope(sysUserLambdaQueryWrapper, DataScope.of());
List<SimpleUserAllListVO> collect = sysUsers.stream().map(sysUser -> {
SimpleUserAllListVO vo = new SimpleUserAllListVO();
vo.setId(sysUser.getUserId());
@@ -247,9 +247,15 @@
<if test="query.deptId != null and query.deptId != ''">
AND u.dept_id = #{query.deptId}
</if>
<if test="ids != null">
<if test="query.deptIds != null and query.deptIds.size() != 0">
AND u.dept_id in
<foreach collection="query.deptIds" index="index" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
<if test="query.ids != null and query.ids.size() != 0">
AND u.user_id in
<foreach collection="ids" index="index" item="id" open="(" separator="," close=")">
<foreach collection="query.ids" index="index" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>