| | |
| | | if (userId == null) { |
| | | userId = getCurrentUserId(); |
| | | } |
| | | AdminUserRespDTO user = validateApplicant(userId); |
| | | HrmRegularizeApplicationDO existing = regularizeApplicationMapper.selectByUserIdAndStatusNot(userId, |
| | | HrmAuditStatusEnum.CANCEL.getStatus()); |
| | | if (existing != null) { |
| | | throw exception(REGULARIZE_APPLICATION_EXISTS); |
| | | } |
| | | String no = generateUniqueNo(); |
| | | AdminUserRespDTO user = adminUserApi.getUser(userId); |
| | | if (user == null) { |
| | | userId = getCurrentUserId(); |
| | | user = adminUserApi.getUser(userId); |
| | | } |
| | | HrmRegularizeApplicationDO application = BeanUtils.toBean(createReqVO, HrmRegularizeApplicationDO.class); |
| | | application.setNo(no); |
| | | application.setUserId(userId); |
| | |
| | | |
| | | private Long getCurrentUserId() { |
| | | return SecurityFrameworkUtils.getLoginUserId(); |
| | | } |
| | | |
| | | private AdminUserRespDTO validateApplicant(Long userId) { |
| | | AdminUserRespDTO user = userId == null ? null : adminUserApi.getUser(userId); |
| | | if (user == null) { |
| | | throw exception(REGULARIZE_APPLICANT_NOT_EXISTS); |
| | | } |
| | | if (employeeMapper.selectByUserId(userId) == null) { |
| | | throw exception(REGULARIZE_EMPLOYEE_LINK_REQUIRED); |
| | | } |
| | | return user; |
| | | } |
| | | |
| | | private String generateUniqueNo() { |
| | |
| | | if (!Objects.equals(application.getStatus(), HrmAuditStatusEnum.DRAFT.getStatus()) |
| | | && !Objects.equals(application.getStatus(), HrmAuditStatusEnum.REJECT.getStatus())) { |
| | | throw exception(REGULARIZE_APPLICATION_UPDATE_FAIL_NOT_DRAFT); |
| | | } |
| | | if (updateReqVO.getUserId() != null) { |
| | | validateApplicant(updateReqVO.getUserId()); |
| | | } |
| | | HrmRegularizeApplicationDO updateObj = BeanUtils.toBean(updateReqVO, HrmRegularizeApplicationDO.class); |
| | | regularizeApplicationMapper.updateById(updateObj); |
| | |
| | | && !Objects.equals(application.getStatus(), HrmAuditStatusEnum.REJECT.getStatus())) { |
| | | throw exception(REGULARIZE_APPLICATION_SUBMIT_FAIL_NOT_EDITABLE); |
| | | } |
| | | validateApplicant(application.getUserId()); |
| | | |
| | | // 2. 校验审批配置已启用且配置了有效审批人(未配置时抛出带明确提示的业务异常) |
| | | approvalConfigApi.validateApprovalEnabledAndGetApprovers(REGULARIZE_APPROVE_BIZ_TYPE); |
| | |
| | | private void writeBackEmployee(HrmRegularizeApplicationDO application) { |
| | | HrmEmployeeDO employee = employeeMapper.selectByUserId(application.getUserId()); |
| | | if (employee == null) { |
| | | log.warn("[writeBackEmployee] 转正申请({}) 用户({}) 未找到员工档案,跳过回写", application.getId(), application.getUserId()); |
| | | return; |
| | | throw exception(REGULARIZE_EMPLOYEE_LINK_REQUIRED); |
| | | } |
| | | LocalDate regularDate = application.getExpectedDate() != null ? application.getExpectedDate() : LocalDate.now(); |
| | | employeeMapper.updateById(HrmEmployeeDO.builder() |
| | |
| | | return user == null ? null : user.getNickname(); |
| | | } |
| | | |
| | | } |
| | | } |