| | |
| | | package cn.iocoder.yudao.module.hrm.controller.admin.salary; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.json.JSONUtil; |
| | | import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| | |
| | | import cn.iocoder.yudao.module.hrm.service.employee.HrmEmployeeService; |
| | | import cn.iocoder.yudao.module.hrm.service.salary.HrmSalaryCalculationService; |
| | | import cn.iocoder.yudao.module.system.api.dept.DeptApi; |
| | | import cn.iocoder.yudao.module.system.api.dept.PostApi; |
| | | import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; |
| | | import cn.iocoder.yudao.module.system.api.dept.dto.PostRespDTO; |
| | | 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 PostApi postApi; |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得薪酬核算分页") |
| | |
| | | .collect(Collectors.toSet()); |
| | | Map<Long, DeptRespDTO> deptMap = CollUtil.isEmpty(deptIds) ? Collections.emptyMap() : deptApi.getDeptMap(deptIds); |
| | | |
| | | // 批量获取岗位信息(员工表以 JSON 数组字符串保存岗位 ID) |
| | | Set<Long> postIds = new HashSet<>(); |
| | | for (HrmEmployeeDO employee : employeeMap.values()) { |
| | | if (StrUtil.isNotBlank(employee.getPostIds())) { |
| | | postIds.addAll(JSONUtil.toList(employee.getPostIds(), Long.class)); |
| | | } |
| | | } |
| | | Map<Long, PostRespDTO> postMap = CollUtil.isEmpty(postIds) ? Collections.emptyMap() : postApi.getPostMap(postIds); |
| | | |
| | | // 填充信息 |
| | | for (HrmSalaryCalculationRespVO respVO : respList) { |
| | | HrmEmployeeDO employee = employeeMap.get(respVO.getUserId()); |
| | | if (employee != null) { |
| | | respVO.setUserName(employee.getName()); |
| | | respVO.setHireDate(employee.getHireDate()); |
| | | respVO.setPostName(resolvePostName(employee, postMap)); |
| | | } |
| | | DeptRespDTO dept = deptMap.get(respVO.getDeptId()); |
| | | if (dept != null) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 解析员工岗位名称(多个岗位用逗号连接) |
| | | */ |
| | | private String resolvePostName(HrmEmployeeDO employee, Map<Long, PostRespDTO> postMap) { |
| | | if (StrUtil.isBlank(employee.getPostIds()) || CollUtil.isEmpty(postMap)) { |
| | | return null; |
| | | } |
| | | return JSONUtil.toList(employee.getPostIds(), Long.class).stream() |
| | | .filter(postMap::containsKey) |
| | | .map(id -> postMap.get(id).getName()) |
| | | .collect(Collectors.joining(",")); |
| | | } |
| | | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获得薪酬核算") |
| | | @Parameter(name = "id", description = "核算ID", required = true) |