| | |
| | | employee = employeeService.getEmployee(employeeId); |
| | | } |
| | | if (employee == null && userId != null) { |
| | | // 约定 user_id 存 system_users.id;但历史上前端也有把「员工主键」塞进 userId 的情况,两种都兼容 |
| | | employee = employeeService.getEmployeeByUserId(userId); |
| | | if (employee == null) { |
| | | employee = employeeService.getEmployee(userId); |
| | | } |
| | | } |
| | | // 以员工档案上的 user_id 为准(前端可能把员工主键塞在 userId 字段里,直接用会写错申请人) |
| | | if (employee != null && employee.getUserId() != null) { |
| | | userId = employee.getUserId(); |
| | | } |
| | | if (userId == null && employee != null) { |
| | | userId = employee.getUserId(); |
| | |
| | | if (user != null) { |
| | | respVO.setUserName(user.getNickname()); |
| | | } |
| | | // 表里只存了 user_id,前端修改时需要用 employeeId 回显「被调岗员工」,这里按用户反查员工档案 |
| | | // user_id 正常存 system_users.id;历史数据也有存「员工主键」的,两种都兼容 |
| | | HrmEmployeeDO employee = employeeService.getEmployeeByUserId(application.getUserId()); |
| | | if (employee == null) { |
| | | employee = employeeService.getEmployee(application.getUserId()); |
| | | } |
| | | if (employee != null) { |
| | | respVO.setEmployeeId(employee.getId()); |
| | | if (user == null) { |
| | | respVO.setUserName(employee.getName()); |
| | | } |
| | | } |
| | | } |
| | | fillDeptNames(respVO, application); |
| | |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toSet()); |
| | | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userIds); |
| | | // 兜底:历史数据里 user_id 可能存的是「员工主键」而不是 system_users.id,查不到用户时按员工档案补姓名 |
| | | Map<Long, String> employeeNameMap = new HashMap<>(); |
| | | for (Long userId : userIds) { |
| | | if (!userMap.containsKey(userId)) { |
| | | HrmEmployeeDO employee = employeeService.getEmployee(userId); |
| | | if (employee != null) { |
| | | employeeNameMap.put(userId, employee.getName()); |
| | | } |
| | | } |
| | | } |
| | | Set<Long> deptIds = pageResult.getList().stream() |
| | | .flatMap(app -> Stream.of(app.getCurrentDeptId(), app.getTargetDeptId())) |
| | | .filter(Objects::nonNull) |
| | |
| | | Map<Long, PostRespDTO> postMap = postApi.getPostMap(postIds); |
| | | List<HrmTransferApplicationRespVO> list = pageResult.getList().stream().map(app -> { |
| | | HrmTransferApplicationRespVO vo = BeanUtils.toBean(app, HrmTransferApplicationRespVO.class); |
| | | if (app.getUserId() != null && userMap.containsKey(app.getUserId())) { |
| | | vo.setUserName(userMap.get(app.getUserId()).getNickname()); |
| | | if (app.getUserId() != null) { |
| | | if (userMap.containsKey(app.getUserId())) { |
| | | vo.setUserName(userMap.get(app.getUserId()).getNickname()); |
| | | } else if (employeeNameMap.containsKey(app.getUserId())) { |
| | | vo.setUserName(employeeNameMap.get(app.getUserId())); |
| | | } |
| | | } |
| | | if (app.getCurrentDeptId() != null && deptMap.containsKey(app.getCurrentDeptId())) { |
| | | vo.setCurrentDeptName(deptMap.get(app.getCurrentDeptId()).getName()); |