tuqin
7 天以前 58214df7901e2a57799d9b6bee897aa634165e69
yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/controller/admin/salary/HrmSalaryPaymentController.java
@@ -15,6 +15,7 @@
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;
@@ -41,6 +42,8 @@
    private HrmEmployeeService employeeService;
    @Resource
    private DeptApi deptApi;
    @Resource
    private StorageAttachmentApi storageAttachmentApi;
    @GetMapping("/page")
    @Operation(summary = "获得薪资发放分页")
@@ -56,7 +59,9 @@
    @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")
@@ -135,15 +140,17 @@
     */
    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);
            }
        }
        // 批量获取部门信息