| | |
| | | import cn.iocoder.yudao.module.hrm.service.salary.HrmSalaryPaymentService; |
| | | import cn.iocoder.yudao.module.system.api.dept.DeptApi; |
| | | import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; |
| | | import cn.iocoder.yudao.module.system.api.storage.StorageAttachmentApi; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | |
| | | private HrmEmployeeService employeeService; |
| | | @Resource |
| | | private DeptApi deptApi; |
| | | @Resource |
| | | private StorageAttachmentApi storageAttachmentApi; |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得薪资发放分页") |
| | |
| | | @PreAuthorize("@ss.hasPermission('hrm:salary:query')") |
| | | public CommonResult<HrmSalaryPaymentRespVO> getSalaryPayment(@RequestParam("id") Long id) { |
| | | HrmSalaryPaymentDO salaryPayment = salaryPaymentService.getSalaryPayment(id); |
| | | return success(BeanUtils.toBean(salaryPayment, HrmSalaryPaymentRespVO.class)); |
| | | HrmSalaryPaymentRespVO respVO = BeanUtils.toBean(salaryPayment, HrmSalaryPaymentRespVO.class); |
| | | respVO.setAttachmentList(storageAttachmentApi.listAttachments("hrm_salary_payment", id)); |
| | | return success(respVO); |
| | | } |
| | | |
| | | @PostMapping("/generate") |
| | |
| | | */ |
| | | private void fillUserInfo(List<HrmSalaryPaymentDetailRespVO> respList, List<HrmSalaryPaymentDetailDO> detailList) { |
| | | // 批量获取员工信息 |
| | | Set<Long> employeeIds = detailList.stream() |
| | | // 注意:发放明细的 userId 存的是「系统账号 ID」(system_users.id), |
| | | // 不是员工档案主键(hrm_employee.id),必须用 getEmployeeByUserId 查 |
| | | Set<Long> userIds = detailList.stream() |
| | | .map(HrmSalaryPaymentDetailDO::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); |
| | | } |
| | | } |
| | | // 批量获取部门信息 |