xiaoyi
2 天以前 f83950d292a8933390b3b4b516f90f21a9946c68
yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/service/approval/HrmTransferApplicationServiceImpl.java
@@ -19,6 +19,7 @@
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;
@@ -40,6 +41,8 @@
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.*;
@@ -47,7 +50,7 @@
/**
 * 调岗申请 Service 实现类
 *
 * @author 芋道源码
 * @author 超级管理员
 */
@Service
@Validated
@@ -68,6 +71,8 @@
    private BpmProcessInstanceApi bpmProcessInstanceApi;
    @Resource
    private BpmCategoryService bpmCategoryService;
    @Resource
    private StorageAttachmentApi storageAttachmentApi;
    @Resource
    private BpmProcessDefinitionService bpmProcessDefinitionService;
@@ -99,11 +104,13 @@
        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() {
@@ -129,6 +136,7 @@
        }
        HrmTransferApplicationDO updateObj = BeanUtils.toBean(updateReqVO, HrmTransferApplicationDO.class);
        transferApplicationMapper.updateById(updateObj);
        storageAttachmentApi.updateAttachments("file", "hrm_transfer_application", updateReqVO.getId(), updateReqVO.getBlobIds());
    }
    @Override
@@ -137,6 +145,7 @@
        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);
    }
@@ -170,12 +179,13 @@
        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());
@@ -186,8 +196,8 @@
    }
    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());