| | |
| | | * 填充员工和部门信息(userId 是员工ID) |
| | | */ |
| | | private void fillUserInfo(List<HrmSalaryCalculationRespVO> respList, List<HrmSalaryCalculationDO> calculationList) { |
| | | // userId 是员工ID,批量获取员工信息 |
| | | Set<Long> employeeIds = calculationList.stream() |
| | | // 注意:核算记录的 userId 存的是「系统账号 ID」(system_users.id), |
| | | // 不是员工档案主键(hrm_employee.id)。用 getEmployee 会永远查不到, |
| | | // 导致列表里「员工姓名」一列全空。必须用 getEmployeeByUserId。 |
| | | Set<Long> userIds = calculationList.stream() |
| | | .map(HrmSalaryCalculationDO::getUserId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toSet()); |
| | | Map<Long, HrmEmployeeDO> employeeMap = new HashMap<>(); |
| | | for (Long employeeId : employeeIds) { |
| | | HrmEmployeeDO employee = employeeService.getEmployee(employeeId); |
| | | for (Long userId : userIds) { |
| | | HrmEmployeeDO employee = employeeService.getEmployeeByUserId(userId); |
| | | if (employee != null) { |
| | | employeeMap.put(employeeId, employee); |
| | | employeeMap.put(userId, employee); |
| | | } |
| | | } |
| | | |
| | |
| | | return success(null); |
| | | } |
| | | HrmSalaryCalculationRespVO respVO = BeanUtils.toBean(salaryCalculation, HrmSalaryCalculationRespVO.class); |
| | | // 填充员工和部门信息(userId 是员工ID) |
| | | // 填充员工和部门信息 |
| | | // 注意:核算记录的 userId 存的是「系统账号 ID」(system_users.id), |
| | | // 不是员工档案主键(hrm_employee.id),必须用 getEmployeeByUserId 查 |
| | | if (salaryCalculation.getUserId() != null) { |
| | | HrmEmployeeDO employee = employeeService.getEmployee(salaryCalculation.getUserId()); |
| | | HrmEmployeeDO employee = employeeService.getEmployeeByUserId(salaryCalculation.getUserId()); |
| | | if (employee != null) { |
| | | respVO.setUserName(employee.getName()); |
| | | } |