| | |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.salary.vo.HrmEmployeeSocialSecurityPageReqVO; |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.salary.vo.HrmEmployeeSocialSecurityRespVO; |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.salary.vo.HrmEmployeeSocialSecuritySaveReqVO; |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.employee.HrmEmployeeDO; |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.salary.HrmEmployeeSocialSecurityDO; |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.salary.HrmSocialSecuritySchemeDO; |
| | | import cn.iocoder.yudao.module.hrm.service.employee.HrmEmployeeService; |
| | | import cn.iocoder.yudao.module.hrm.service.salary.HrmEmployeeSocialSecurityService; |
| | | import cn.iocoder.yudao.module.hrm.service.salary.HrmSocialSecuritySchemeService; |
| | | import cn.iocoder.yudao.module.system.api.dept.DeptApi; |
| | |
| | | |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | |
| | | @Tag(name = "管理后台 - HRM 员工社保公积金档案") |
| | | @Tag(name = "管理后台 - HRM 部门社保公积金档案") |
| | | @RestController |
| | | @RequestMapping("/hrm/salary/employee-social-security") |
| | | @Validated |
| | |
| | | @Resource |
| | | private HrmEmployeeSocialSecurityService employeeSocialSecurityService; |
| | | @Resource |
| | | private HrmEmployeeService employeeService; |
| | | @Resource |
| | | private DeptApi deptApi; |
| | | @Resource |
| | | private HrmSocialSecuritySchemeService schemeService; |
| | | |
| | | @PostMapping("/create") |
| | | @Operation(summary = "创建员工社保公积金档案") |
| | | @Operation(summary = "创建部门社保公积金档案") |
| | | @PreAuthorize("@ss.hasPermission('hrm:employee-social-security:create')") |
| | | public CommonResult<Long> createEmployeeSocialSecurity(@Valid @RequestBody HrmEmployeeSocialSecuritySaveReqVO createReqVO) { |
| | | HrmEmployeeSocialSecurityDO socialSecurity = BeanUtils.toBean(createReqVO, HrmEmployeeSocialSecurityDO.class); |
| | |
| | | } |
| | | |
| | | @PutMapping("/update") |
| | | @Operation(summary = "更新员工社保公积金档案") |
| | | @Operation(summary = "更新部门社保公积金档案") |
| | | @PreAuthorize("@ss.hasPermission('hrm:employee-social-security:update')") |
| | | public CommonResult<Boolean> updateEmployeeSocialSecurity(@Valid @RequestBody HrmEmployeeSocialSecuritySaveReqVO updateReqVO) { |
| | | HrmEmployeeSocialSecurityDO socialSecurity = BeanUtils.toBean(updateReqVO, HrmEmployeeSocialSecurityDO.class); |
| | |
| | | } |
| | | |
| | | @DeleteMapping("/delete") |
| | | @Operation(summary = "删除员工社保公积金档案") |
| | | @Operation(summary = "删除部门社保公积金档案") |
| | | @Parameter(name = "id", description = "档案ID", required = true) |
| | | @PreAuthorize("@ss.hasPermission('hrm:employee-social-security:delete')") |
| | | public CommonResult<Boolean> deleteEmployeeSocialSecurity(@RequestParam("id") Long id) { |
| | |
| | | } |
| | | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获取员工社保公积金档案") |
| | | @Operation(summary = "获取部门社保公积金档案") |
| | | @Parameter(name = "id", description = "档案ID", required = true) |
| | | public CommonResult<HrmEmployeeSocialSecurityRespVO> getEmployeeSocialSecurity(@RequestParam("id") Long id) { |
| | | HrmEmployeeSocialSecurityDO socialSecurity = employeeSocialSecurityService.getEmployeeSocialSecurity(id); |
| | |
| | | return success(null); |
| | | } |
| | | HrmEmployeeSocialSecurityRespVO respVO = BeanUtils.toBean(socialSecurity, HrmEmployeeSocialSecurityRespVO.class); |
| | | // 填充员工和方案信息 |
| | | fillEmployeeInfo(respVO, socialSecurity.getUserId()); |
| | | fillDeptInfo(respVO, socialSecurity.getDeptId()); |
| | | fillSchemeInfo(respVO, socialSecurity.getSocialSecuritySchemeId()); |
| | | return success(respVO); |
| | | } |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获取员工社保公积金档案分页") |
| | | @Operation(summary = "获取部门社保公积金档案分页") |
| | | public CommonResult<PageResult<HrmEmployeeSocialSecurityRespVO>> getEmployeeSocialSecurityPage( |
| | | @Valid HrmEmployeeSocialSecurityPageReqVO pageReqVO) { |
| | | PageResult<HrmEmployeeSocialSecurityDO> pageResult = employeeSocialSecurityService.getEmployeeSocialSecurityPage(pageReqVO); |
| | |
| | | if (CollUtil.isEmpty(recordList)) { |
| | | return success(new PageResult<>(Collections.emptyList(), pageResult.getTotal())); |
| | | } |
| | | // userId 是员工ID,批量获取员工信息 |
| | | Set<Long> employeeIds = recordList.stream() |
| | | .map(HrmEmployeeSocialSecurityDO::getUserId) |
| | | // 批量获取部门信息 |
| | | Set<Long> deptIds = recordList.stream() |
| | | .map(HrmEmployeeSocialSecurityDO::getDeptId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toSet()); |
| | | Map<Long, HrmEmployeeDO> employeeMap = new HashMap<>(); |
| | | Set<Long> deptIds = new HashSet<>(); |
| | | for (Long employeeId : employeeIds) { |
| | | HrmEmployeeDO employee = employeeService.getEmployee(employeeId); |
| | | if (employee != null) { |
| | | employeeMap.put(employeeId, employee); |
| | | if (employee.getDeptId() != null) { |
| | | deptIds.add(employee.getDeptId()); |
| | | } |
| | | } |
| | | } |
| | | // 批量获取部门信息 |
| | | Map<Long, DeptRespDTO> deptMap = CollUtil.isEmpty(deptIds) ? Collections.emptyMap() : deptApi.getDeptMap(deptIds); |
| | | // 批量获取方案信息 |
| | | Set<Long> schemeIds = recordList.stream() |
| | |
| | | List<HrmEmployeeSocialSecurityRespVO> list = recordList.stream() |
| | | .map(socialSecurity -> { |
| | | HrmEmployeeSocialSecurityRespVO respVO = BeanUtils.toBean(socialSecurity, HrmEmployeeSocialSecurityRespVO.class); |
| | | // 填充员工姓名和部门名称(userId 是员工ID) |
| | | HrmEmployeeDO employee = employeeMap.get(socialSecurity.getUserId()); |
| | | if (employee != null) { |
| | | respVO.setUserName(employee.getName()); |
| | | if (employee.getDeptId() != null) { |
| | | DeptRespDTO dept = deptMap.get(employee.getDeptId()); |
| | | if (socialSecurity.getDeptId() != null) { |
| | | DeptRespDTO dept = deptMap.get(socialSecurity.getDeptId()); |
| | | if (dept != null) { |
| | | respVO.setDeptName(dept.getName()); |
| | | } |
| | | } |
| | | } |
| | | // 填充方案名称 |
| | | if (socialSecurity.getSocialSecuritySchemeId() != null) { |
| | | HrmSocialSecuritySchemeDO scheme = schemeMap.get(socialSecurity.getSocialSecuritySchemeId()); |
| | | if (scheme != null) { |
| | |
| | | return success(new PageResult<>(list, pageResult.getTotal())); |
| | | } |
| | | |
| | | @GetMapping("/list-by-user") |
| | | @Operation(summary = "获取员工社保公积金档案历史列表") |
| | | @Parameter(name = "userId", description = "系统用户ID", required = true) |
| | | @GetMapping("/list-by-dept") |
| | | @Operation(summary = "获取部门社保公积金档案历史列表") |
| | | @Parameter(name = "deptId", description = "部门ID", required = true) |
| | | public CommonResult<List<HrmEmployeeSocialSecurityRespVO>> getEmployeeSocialSecurityList( |
| | | @RequestParam("userId") Long userId) { |
| | | List<HrmEmployeeSocialSecurityDO> list = employeeSocialSecurityService.getEmployeeSocialSecurityList(userId); |
| | | @RequestParam("deptId") Long deptId) { |
| | | List<HrmEmployeeSocialSecurityDO> list = employeeSocialSecurityService.getEmployeeSocialSecurityList(deptId); |
| | | List<HrmEmployeeSocialSecurityRespVO> result = list.stream() |
| | | .map(socialSecurity -> { |
| | | HrmEmployeeSocialSecurityRespVO respVO = BeanUtils.toBean(socialSecurity, HrmEmployeeSocialSecurityRespVO.class); |
| | | fillDeptInfo(respVO, socialSecurity.getDeptId()); |
| | | fillSchemeInfo(respVO, socialSecurity.getSocialSecuritySchemeId()); |
| | | return respVO; |
| | | }) |
| | |
| | | } |
| | | |
| | | @GetMapping("/get-latest") |
| | | @Operation(summary = "获取员工最新生效的社保公积金档案") |
| | | @Parameter(name = "userId", description = "系统用户ID", required = true) |
| | | @Operation(summary = "获取部门最新生效的社保公积金档案") |
| | | @Parameter(name = "deptId", description = "部门ID", required = true) |
| | | public CommonResult<HrmEmployeeSocialSecurityRespVO> getLatestEmployeeSocialSecurity( |
| | | @RequestParam("userId") Long userId) { |
| | | HrmEmployeeSocialSecurityDO socialSecurity = employeeSocialSecurityService.getLatestEmployeeSocialSecurity(userId); |
| | | @RequestParam("deptId") Long deptId) { |
| | | HrmEmployeeSocialSecurityDO socialSecurity = employeeSocialSecurityService.getLatestEmployeeSocialSecurity(deptId); |
| | | if (socialSecurity == null) { |
| | | return success(null); |
| | | } |
| | | HrmEmployeeSocialSecurityRespVO respVO = BeanUtils.toBean(socialSecurity, HrmEmployeeSocialSecurityRespVO.class); |
| | | // 填充员工和方案信息 |
| | | fillEmployeeInfo(respVO, socialSecurity.getUserId()); |
| | | fillDeptInfo(respVO, socialSecurity.getDeptId()); |
| | | fillSchemeInfo(respVO, socialSecurity.getSocialSecuritySchemeId()); |
| | | return success(respVO); |
| | | } |
| | | |
| | | /** |
| | | * 填充员工信息(通过员工ID) |
| | | * 填充部门信息 |
| | | */ |
| | | private void fillEmployeeInfo(HrmEmployeeSocialSecurityRespVO respVO, Long userId) { |
| | | // userId 是员工ID,通过员工表获取姓名和部门 |
| | | HrmEmployeeDO employee = employeeService.getEmployee(userId); |
| | | if (employee != null) { |
| | | respVO.setUserName(employee.getName()); |
| | | if (employee.getDeptId() != null) { |
| | | DeptRespDTO dept = deptApi.getDept(employee.getDeptId()); |
| | | private void fillDeptInfo(HrmEmployeeSocialSecurityRespVO respVO, Long deptId) { |
| | | if (deptId == null) { |
| | | return; |
| | | } |
| | | DeptRespDTO dept = deptApi.getDept(deptId); |
| | | if (dept != null) { |
| | | respVO.setDeptName(dept.getName()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |