| | |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| | | import static cn.iocoder.yudao.module.hrm.enums.ErrorCodeConstants.*; |
| | |
| | | /** |
| | | * 离职申请 Service 实现类 |
| | | * |
| | | * @author 芋道源码 |
| | | * @author 超级管理员 |
| | | */ |
| | | @Service |
| | | @Validated |
| | |
| | | AdminUserRespDTO user = adminUserApi.getUser(userId); |
| | | if (user == null) { |
| | | userId = getCurrentUserId(); |
| | | user = adminUserApi.getUser(userId); |
| | | } |
| | | HrmResignationApplicationDO application = BeanUtils.toBean(createReqVO, HrmResignationApplicationDO.class); |
| | | application.setNo(no); |
| | | application.setUserId(userId); |
| | | application.setDeptId(createReqVO.getDeptId() != null ? createReqVO.getDeptId() : user.getDeptId()); |
| | | application.setDeptId(createReqVO.getDeptId() != null ? createReqVO.getDeptId() |
| | | : (user != null ? user.getDeptId() : null)); |
| | | application.setStatus(HrmAuditStatusEnum.DRAFT.getStatus()); |
| | | application.setHandoverStatus(HANDOVER_STATUS_NOT_STARTED); |
| | | resignationApplicationMapper.insert(application); |
| | |
| | | } |
| | | |
| | | private Long getCurrentUserId() { |
| | | return 1L; |
| | | return SecurityFrameworkUtils.getLoginUserId(); |
| | | } |
| | | |
| | | private String generateUniqueNo() { |
| | |
| | | } |
| | | HrmResignationApplicationDO updateObj = BeanUtils.toBean(updateReqVO, HrmResignationApplicationDO.class); |
| | | resignationApplicationMapper.updateById(updateObj); |
| | | if (updateReqVO.getBlobIds() != null) { |
| | | storageAttachmentApi.deleteAttachmentsByRecord("hrm_resignation_application", updateReqVO.getId()); |
| | | storageAttachmentApi.bindAttachments("file", "hrm_resignation_application", |
| | | updateReqVO.getId(), updateReqVO.getBlobIds()); |
| | | } |
| | | storageAttachmentApi.updateAttachments("file", "hrm_resignation_application", updateReqVO.getId(), updateReqVO.getBlobIds()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | private void fillUserNames(HrmResignationApplicationRespVO respVO, HrmResignationApplicationDO application) { |
| | | Set<Long> userIds = Set.of(application.getUserId(), application.getHandoverUserId()) |
| | | .stream().filter(Objects::nonNull).collect(Collectors.toSet()); |
| | | Set<Long> userIds = Stream.of(application.getUserId(), application.getHandoverUserId()) |
| | | .filter(Objects::nonNull).collect(Collectors.toSet()); |
| | | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userIds); |
| | | if (application.getUserId() != null && userMap.containsKey(application.getUserId())) { |
| | | respVO.setUserName(userMap.get(application.getUserId()).getNickname()); |