| | |
| | | import cn.iocoder.yudao.module.hrm.enums.HrmTransferTypeEnum; |
| | | 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.storage.StorageAttachmentApi; |
| | | import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; |
| | | import cn.iocoder.yudao.module.system.api.dept.dto.PostRespDTO; |
| | | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| | |
| | | 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 |
| | |
| | | private BpmProcessInstanceApi bpmProcessInstanceApi; |
| | | @Resource |
| | | private BpmCategoryService bpmCategoryService; |
| | | @Resource |
| | | private StorageAttachmentApi storageAttachmentApi; |
| | | @Resource |
| | | private BpmProcessDefinitionService bpmProcessDefinitionService; |
| | | |
| | |
| | | application.setUserId(userId); |
| | | application.setStatus(HrmAuditStatusEnum.DRAFT.getStatus()); |
| | | transferApplicationMapper.insert(application); |
| | | storageAttachmentApi.bindAttachments("file", "hrm_transfer_application", |
| | | application.getId(), createReqVO.getBlobIds()); |
| | | return application.getId(); |
| | | } |
| | | |
| | | private Long getCurrentUserId() { |
| | | return 1L; |
| | | return SecurityFrameworkUtils.getLoginUserId(); |
| | | } |
| | | |
| | | private String generateUniqueNo() { |
| | |
| | | } |
| | | HrmTransferApplicationDO updateObj = BeanUtils.toBean(updateReqVO, HrmTransferApplicationDO.class); |
| | | transferApplicationMapper.updateById(updateObj); |
| | | storageAttachmentApi.updateAttachments("file", "hrm_transfer_application", updateReqVO.getId(), updateReqVO.getBlobIds()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | if (!Objects.equals(application.getStatus(), HrmAuditStatusEnum.DRAFT.getStatus())) { |
| | | throw exception(TRANSFER_APPLICATION_UPDATE_FAIL_NOT_DRAFT); |
| | | } |
| | | storageAttachmentApi.deleteAttachmentsByRecord("hrm_transfer_application", id); |
| | | transferApplicationMapper.deleteById(id); |
| | | } |
| | | |
| | |
| | | fillPostNames(respVO, application); |
| | | respVO.setTransferTypeName(HrmTransferTypeEnum.getNameByStatus(application.getTransferType())); |
| | | respVO.setStatusName(HrmAuditStatusEnum.getNameByStatus(application.getStatus())); |
| | | respVO.setAttachmentList(storageAttachmentApi.listAttachments("hrm_transfer_application", id)); |
| | | return respVO; |
| | | } |
| | | |
| | | private void fillDeptNames(HrmTransferApplicationRespVO respVO, HrmTransferApplicationDO application) { |
| | | Set<Long> deptIds = Set.of(application.getCurrentDeptId(), application.getTargetDeptId()) |
| | | .stream().filter(Objects::nonNull).collect(Collectors.toSet()); |
| | | Set<Long> deptIds = Stream.of(application.getCurrentDeptId(), application.getTargetDeptId()) |
| | | .filter(Objects::nonNull).collect(Collectors.toSet()); |
| | | Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(deptIds); |
| | | if (application.getCurrentDeptId() != null && deptMap.containsKey(application.getCurrentDeptId())) { |
| | | respVO.setCurrentDeptName(deptMap.get(application.getCurrentDeptId()).getName()); |
| | |
| | | } |
| | | |
| | | private void fillPostNames(HrmTransferApplicationRespVO respVO, HrmTransferApplicationDO application) { |
| | | Set<Long> postIds = Set.of(application.getCurrentPostId(), application.getTargetPostId()) |
| | | .stream().filter(Objects::nonNull).collect(Collectors.toSet()); |
| | | Set<Long> postIds = Stream.of(application.getCurrentPostId(), application.getTargetPostId()) |
| | | .filter(Objects::nonNull).collect(Collectors.toSet()); |
| | | Map<Long, PostRespDTO> postMap = postApi.getPostMap(postIds); |
| | | if (application.getCurrentPostId() != null && postMap.containsKey(application.getCurrentPostId())) { |
| | | respVO.setCurrentPostName(postMap.get(application.getCurrentPostId()).getName()); |