| | |
| | | @Override |
| | | public void exportPersonBasicInfo(UserPageDto userPageDto, HttpServletResponse response) throws Exception { |
| | | ArrayList<PersonBasicInfoDto> data = new ArrayList<>(); |
| | | List<User> list = userMapper.selectList(null); |
| | | LambdaQueryWrapper<User> userWrapper = Wrappers.<User>lambdaQuery() |
| | | .and(w -> w.eq(User::getDelFlag, "0").or().isNull(User::getDelFlag)) |
| | | .and(w -> w.eq(User::getIsCustom, 0).or().isNull(User::getIsCustom)); |
| | | if (userPageDto != null) { |
| | | if (ObjectUtils.isNotEmpty(userPageDto.getName())) { |
| | | userWrapper.like(User::getName, userPageDto.getName().trim()); |
| | | } |
| | | if (userPageDto.getDepartmentId() != null) { |
| | | userWrapper.apply("FIND_IN_SET({0}, depart_lims_id)", userPageDto.getDepartmentId()); |
| | | } |
| | | } |
| | | List<User> list = userMapper.selectList(userWrapper); |
| | | for (User user : list) { |
| | | PersonBasicInfoDto personBasicInfoDto = new PersonBasicInfoDto(); |
| | | PersonBasicInfo personBasicInfo = baseMapper.selectOne(Wrappers.<PersonBasicInfo>lambdaQuery().eq(PersonBasicInfo::getUserId, user.getId())); |
| | |
| | | |
| | | @Override |
| | | public String exportPersonBasicInfoById(Integer id, HttpServletResponse response) { |
| | | Map<String, Object> userMap = baseMapper.selectexportPersonBasic(id); |
| | | if (id == null) { |
| | | throw new ErrorException("缺少人员id"); |
| | | } |
| | | User user = userMapper.selectById(id); |
| | | PersonBasicInfo personBasicInfo = baseMapper.selectOne(Wrappers.<PersonBasicInfo>lambdaQuery().eq(PersonBasicInfo::getUserId, user.getId())); |
| | | if (user == null) { |
| | | throw new ErrorException("人员不存在或已被删除"); |
| | | } |
| | | PersonBasicInfo personBasicInfo = baseMapper.selectOne(Wrappers.<PersonBasicInfo>lambdaQuery().eq(PersonBasicInfo::getUserId, id)); |
| | | if (ObjectUtils.isEmpty(personBasicInfo)){ |
| | | throw new ErrorException("该用户的基本信息没有录入,暂无法导出"); |
| | | } |
| | | Map<String, Object> userMap = baseMapper.selectexportPersonBasic(id); |
| | | // 证件 |
| | | List<Annex> annexList = annexMapper.selectList(Wrappers.<Annex>lambdaQuery() |
| | | .eq(Annex::getUserId, id)); |
| | |
| | | */ |
| | | @Override |
| | | public boolean delDepartment(Integer id) { |
| | | //判断是否有子类,直到没有为止 |
| | | List<DepartmentLims> department = getDepartment(id); |
| | | List<Integer> ids = department.stream().map(DepartmentLims::getId).collect(Collectors.toList()); |
| | | departmentMapper.delete(Wrappers.<DepartmentLims>lambdaQuery() |
| | | .in(DepartmentLims::getId, ids)); |
| | | return true; |
| | | } |
| | | |
| | | //判断是否有子类,直到没有为止 |
| | | public List<DepartmentLims> getDepartment(Integer id) { |
| | | List<DepartmentLims> list = new ArrayList<>(); |
| | | DepartmentLims depart = departmentMapper.selectById(id); |
| | | list.add(depart); |
| | | List<DepartmentLims> departments = departmentMapper.selectList(Wrappers.<DepartmentLims>lambdaQuery().eq(DepartmentLims::getFatherId, id)); |
| | | if (ObjectUtils.isNotEmpty(departments)) { |
| | | list.addAll(departments); |
| | | for (DepartmentLims department : departments) { |
| | | list.addAll(getDepartment(department.getId())); |
| | | } |
| | | if (id == null) { |
| | | throw new ErrorException("缺少架构id"); |
| | | } |
| | | return list; |
| | | DepartmentLims depart = departmentMapper.selectById(id); |
| | | if (depart == null) { |
| | | throw new ErrorException("该架构不存在或已被删除"); |
| | | } |
| | | Long childCount = departmentMapper.selectCount(Wrappers.<DepartmentLims>lambdaQuery() |
| | | .eq(DepartmentLims::getFatherId, id)); |
| | | if (childCount != null && childCount > 0) { |
| | | throw new ErrorException("该架构下存在下级架构,请先删除下级架构"); |
| | | } |
| | | Long userCount = userMapper.selectCount(Wrappers.<User>lambdaQuery() |
| | | .and(w -> w.eq(User::getDelFlag, "0").or().isNull(User::getDelFlag)) |
| | | .apply("FIND_IN_SET({0}, depart_lims_id)", id)); |
| | | if (userCount != null && userCount > 0) { |
| | | throw new ErrorException("该架构下还有人员,请先将人员移出该架构"); |
| | | } |
| | | departmentMapper.deleteById(id); |
| | | return true; |
| | | } |
| | | |
| | | /** |