| | |
| | | |
| | | import cn.iocoder.yudao.module.bpm.api.event.BpmProcessInstanceStatusEvent; |
| | | 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.dal.mysql.employee.HrmEmployeeMapper; |
| | | import cn.iocoder.yudao.module.hrm.enums.HrmAuditStatusEnum; |
| | | import cn.iocoder.yudao.module.hrm.service.approval.HrmTransferApplicationService; |
| | | import cn.iocoder.yudao.module.hrm.util.HrmAuditStatusUtils; |
| | |
| | | /** |
| | | * 调岗申请审批的结果监听器实现类 |
| | | * |
| | | * @author 芋道源码 |
| | | * @author 超级管理员 |
| | | */ |
| | | @Component |
| | | @Slf4j |
| | |
| | | private HrmTransferApplicationService transferApplicationService; |
| | | @Resource |
| | | private HrmTransferApplicationMapper transferApplicationMapper; |
| | | @Resource |
| | | private HrmEmployeeMapper employeeMapper; |
| | | |
| | | @Override |
| | | public void onApplicationEvent(BpmProcessInstanceStatusEvent event) { |
| | |
| | | // 更新审批状态 |
| | | Integer auditStatus = HrmAuditStatusUtils.convertBpmResultToAuditStatus(event.getStatus()); |
| | | transferApplicationService.updateTransferApplicationAuditStatus(applicationId, auditStatus); |
| | | // 审批通过:回写员工主档(部门 = 目标部门,岗位 = 目标岗位) |
| | | if (HrmAuditStatusEnum.APPROVE.getStatus().equals(auditStatus)) { |
| | | writeBackEmployee(application); |
| | | } |
| | | } |
| | | |
| | | private void writeBackEmployee(HrmTransferApplicationDO application) { |
| | | HrmEmployeeDO employee = employeeMapper.selectByUserId(application.getUserId()); |
| | | if (employee == null) { |
| | | log.warn("[writeBackEmployee] 调岗申请({}) 用户({}) 未找到员工档案,跳过回写", application.getId(), application.getUserId()); |
| | | return; |
| | | } |
| | | employeeMapper.updateById(HrmEmployeeDO.builder() |
| | | .id(employee.getId()) |
| | | .deptId(application.getTargetDeptId()) |
| | | .postId(application.getTargetPostId()) |
| | | .build()); |
| | | } |
| | | |
| | | } |