| | |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjUtil; |
| | | import cn.iocoder.yudao.framework.common.exception.ServiceException; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; |
| | | import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi; |
| | | import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; |
| | | import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO; |
| | |
| | | if (Objects.equals(createReqVO.getTargetPostId(), createReqVO.getCurrentPostId())) { |
| | | throw exception(TRANSFER_APPLICATION_SAME_POST); |
| | | } |
| | | // 3. 生成申请单号 |
| | | String no = generateUniqueNo(); |
| | | // 4. 设置申请人信息 |
| | | Long userId = createReqVO.getUserId(); |
| | | if (userId == null) { |
| | | userId = getCurrentUserId(); |
| | | } |
| | | AdminUserRespDTO user = adminUserApi.getUser(userId); |
| | | // 3. 确定被调岗员工(未指定时默认当前登录用户) |
| | | Long userId = createReqVO.getUserId() != null ? createReqVO.getUserId() : getLoginUserId(); |
| | | AdminUserRespDTO user = userId != null ? adminUserApi.getUser(userId) : null; |
| | | if (user == null) { |
| | | userId = getCurrentUserId(); |
| | | throw new ServiceException(TRANSFER_APPLICATION_APPLICANT_NOT_EXISTS.getCode(), |
| | | String.format("调岗申请失败:所选员工未关联有效的系统账号(用户编号 %s)。请到「员工管理」确认该员工已绑定账号且账号未停用后重新选择。", userId)); |
| | | } |
| | | // 5. 插入 |
| | | // 4. 校验原部门、原岗位(表字段非空;员工档案缺失时给出可执行提示,避免直接抛数据库异常) |
| | | if (createReqVO.getCurrentDeptId() == null) { |
| | | throw new ServiceException(TRANSFER_APPLICATION_APPLICANT_DEPT_EMPTY.getCode(), |
| | | String.format("调岗申请失败:员工[%s]未设置部门,无法确定原部门。请先到「员工管理」编辑该员工档案补全部门,再重新发起调岗申请。", user.getNickname())); |
| | | } |
| | | if (createReqVO.getCurrentPostId() == null) { |
| | | throw new ServiceException(TRANSFER_APPLICATION_APPLICANT_POST_EMPTY.getCode(), |
| | | String.format("调岗申请失败:员工[%s]未设置岗位,无法确定原岗位。请先到「员工管理」编辑该员工档案补全岗位,再重新发起调岗申请。", user.getNickname())); |
| | | } |
| | | // 5. 生成申请单号 |
| | | String no = generateUniqueNo(); |
| | | // 6. 插入 |
| | | HrmTransferApplicationDO application = BeanUtils.toBean(createReqVO, HrmTransferApplicationDO.class); |
| | | application.setNo(no); |
| | | application.setUserId(userId); |
| | |
| | | return application.getId(); |
| | | } |
| | | |
| | | private Long getCurrentUserId() { |
| | | return 1L; |
| | | private Long getLoginUserId() { |
| | | return SecurityFrameworkUtils.getLoginUserId(); |
| | | } |
| | | |
| | | private String generateUniqueNo() { |