| | |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.approval.vo.HrmTransferApplicationRespVO; |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.approval.vo.HrmTransferApplicationSaveReqVO; |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.approval.HrmTransferApplicationDO; |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.employee.HrmEmployeeDO; |
| | | import cn.iocoder.yudao.module.hrm.dal.mysql.approval.HrmTransferApplicationMapper; |
| | | import cn.iocoder.yudao.module.hrm.service.employee.HrmEmployeeService; |
| | | import cn.iocoder.yudao.module.hrm.dal.redis.HrmNoRedisDAO; |
| | | import cn.iocoder.yudao.module.hrm.enums.HrmAuditStatusEnum; |
| | | import cn.iocoder.yudao.module.hrm.enums.HrmTransferTypeEnum; |
| | |
| | | /** |
| | | * 调岗申请 Service 实现类 |
| | | * |
| | | * @author 芋道源码 |
| | | * @author 超级管理员 |
| | | */ |
| | | @Service |
| | | @Validated |
| | |
| | | private PostApi postApi; |
| | | @Resource |
| | | private AdminUserApi adminUserApi; |
| | | @Resource |
| | | private HrmEmployeeService employeeService; |
| | | @Resource |
| | | private BpmProcessInstanceApi bpmProcessInstanceApi; |
| | | @Resource |
| | |
| | | } |
| | | // 3. 生成申请单号 |
| | | String no = generateUniqueNo(); |
| | | // 4. 设置申请人信息 |
| | | // 4. 设置调岗人(员工ID):为空时取当前登录用户对应的员工 |
| | | Long userId = createReqVO.getUserId(); |
| | | if (userId == null) { |
| | | userId = getCurrentUserId(); |
| | | HrmEmployeeDO currentEmployee = employeeService.getEmployeeByUserId(getCurrentUserId()); |
| | | userId = currentEmployee != null ? currentEmployee.getId() : null; |
| | | } |
| | | AdminUserRespDTO user = adminUserApi.getUser(userId); |
| | | if (user == null) { |
| | | userId = getCurrentUserId(); |
| | | if (userId != null && employeeService.getEmployee(userId) == null) { |
| | | throw exception(EMPLOYEE_NOT_EXISTS); |
| | | } |
| | | // 5. 插入 |
| | | HrmTransferApplicationDO application = BeanUtils.toBean(createReqVO, HrmTransferApplicationDO.class); |
| | |
| | | } |
| | | HrmTransferApplicationDO updateObj = BeanUtils.toBean(updateReqVO, HrmTransferApplicationDO.class); |
| | | transferApplicationMapper.updateById(updateObj); |
| | | if (updateReqVO.getBlobIds() != null) { |
| | | storageAttachmentApi.deleteAttachmentsByRecord("hrm_transfer_application", updateReqVO.getId()); |
| | | storageAttachmentApi.bindAttachments("file", "hrm_transfer_application", |
| | | updateReqVO.getId(), updateReqVO.getBlobIds()); |
| | | } |
| | | storageAttachmentApi.updateAttachments("file", "hrm_transfer_application", updateReqVO.getId(), updateReqVO.getBlobIds()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | HrmTransferApplicationRespVO respVO = BeanUtils.toBean(application, HrmTransferApplicationRespVO.class); |
| | | if (application.getUserId() != null) { |
| | | AdminUserRespDTO user = adminUserApi.getUser(application.getUserId()); |
| | | if (user != null) { |
| | | respVO.setUserName(user.getNickname()); |
| | | HrmEmployeeDO employee = employeeService.getEmployee(application.getUserId()); |
| | | if (employee != null) { |
| | | respVO.setUserName(employee.getName()); |
| | | } |
| | | } |
| | | fillDeptNames(respVO, application); |
| | |
| | | .map(HrmTransferApplicationDO::getUserId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toSet()); |
| | | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userIds); |
| | | // userId 存的是员工ID,按员工表查询姓名 |
| | | Map<Long, String> employeeNameMap = new HashMap<>(); |
| | | for (Long userId : userIds) { |
| | | HrmEmployeeDO employee = employeeService.getEmployee(userId); |
| | | if (employee != null) { |
| | | employeeNameMap.put(userId, employee.getName()); |
| | | } |
| | | } |
| | | Set<Long> deptIds = pageResult.getList().stream() |
| | | .flatMap(app -> Stream.of(app.getCurrentDeptId(), app.getTargetDeptId())) |
| | | .filter(Objects::nonNull) |
| | |
| | | Map<Long, PostRespDTO> postMap = postApi.getPostMap(postIds); |
| | | List<HrmTransferApplicationRespVO> list = pageResult.getList().stream().map(app -> { |
| | | HrmTransferApplicationRespVO vo = BeanUtils.toBean(app, HrmTransferApplicationRespVO.class); |
| | | if (app.getUserId() != null && userMap.containsKey(app.getUserId())) { |
| | | vo.setUserName(userMap.get(app.getUserId()).getNickname()); |
| | | if (app.getUserId() != null && employeeNameMap.containsKey(app.getUserId())) { |
| | | vo.setUserName(employeeNameMap.get(app.getUserId())); |
| | | } |
| | | if (app.getCurrentDeptId() != null && deptMap.containsKey(app.getCurrentDeptId())) { |
| | | vo.setCurrentDeptName(deptMap.get(app.getCurrentDeptId()).getName()); |