| | |
| | | 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.mybatis.core.query.LambdaQueryWrapperX; |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.employee.vo.HrmEmployeeEducationSaveReqVO; |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.employee.vo.HrmEmployeeEmergencyContactSaveReqVO; |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.employee.vo.HrmEmployeeImportExcelVO; |
| | |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.employee.vo.HrmEmployeeSaveReqVO; |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.employee.vo.HrmEmployeeSimpleRespVO; |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.employee.vo.HrmEmployeeWorkHistorySaveReqVO; |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.employee.HrmEmployeeContractDO; |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.employee.HrmEmployeeDO; |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.employee.HrmEmployeeEducationDO; |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.employee.HrmEmployeeEmergencyContactDO; |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.employee.HrmEmployeeWorkHistoryDO; |
| | | import cn.iocoder.yudao.module.hrm.dal.mysql.employee.HrmEmployeeContractMapper; |
| | | import cn.iocoder.yudao.module.hrm.dal.mysql.employee.HrmEmployeeEducationMapper; |
| | | import cn.iocoder.yudao.module.hrm.dal.mysql.employee.HrmEmployeeEmergencyContactMapper; |
| | | import cn.iocoder.yudao.module.hrm.dal.mysql.employee.HrmEmployeeMapper; |
| | |
| | | import cn.iocoder.yudao.module.system.api.dept.dto.PostRespDTO; |
| | | import cn.iocoder.yudao.module.system.api.permission.RoleApi; |
| | | import cn.iocoder.yudao.module.system.api.permission.dto.RoleRespDTO; |
| | | import cn.iocoder.yudao.module.system.api.storage.StorageAttachmentApi; |
| | | import cn.iocoder.yudao.module.system.api.storage.dto.StorageBlobRespDTO; |
| | | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| | | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserCreateReqDTO; |
| | | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserUpdateReqDTO; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | |
| | | @Resource |
| | | private HrmEmployeeMapper employeeMapper; |
| | | @Resource |
| | | private HrmEmployeeContractMapper contractMapper; |
| | | @Resource |
| | | private HrmEmployeeEducationMapper educationMapper; |
| | | @Resource |
| | | private HrmEmployeeWorkHistoryMapper workHistoryMapper; |
| | |
| | | private AdminUserApi adminUserApi; |
| | | @Resource |
| | | private RoleApi roleApi; |
| | | @Resource |
| | | private StorageAttachmentApi storageAttachmentApi; |
| | | @Resource |
| | | @Lazy // 自注入需延迟加载,否则 bean 被代理包装后注入原始版本导致启动失败 |
| | | private HrmEmployeeService self; |
| | |
| | | } |
| | | employeeMapper.insert(employee); |
| | | Long employeeId = employee.getId(); |
| | | // 绑定附件 |
| | | storageAttachmentApi.bindAttachments("file", "hrm_employee", employeeId, createReqVO.getBlobIds()); |
| | | // 7. 同步添加教育经历 |
| | | if (CollUtil.isNotEmpty(createReqVO.getEducations())) { |
| | | createReqVO.getEducations().forEach(educationVO -> { |
| | |
| | | syncWorkHistoryList(employeeId, updateReqVO.getWorkHistories()); |
| | | // 同步紧急联系人 |
| | | syncEmergencyContactList(employeeId, updateReqVO.getEmergencyContacts()); |
| | | // 更新附件 |
| | | storageAttachmentApi.updateAttachments("file", "hrm_employee", employeeId, updateReqVO.getBlobIds()); |
| | | } |
| | | |
| | | private void syncEducationList(Long employeeId, List<HrmEmployeeEducationSaveReqVO> newList) { |
| | |
| | | educationMapper.deleteByEmployeeId(id); |
| | | workHistoryMapper.deleteByEmployeeId(id); |
| | | emergencyContactMapper.deleteByEmployeeId(id); |
| | | // 删除附件 |
| | | storageAttachmentApi.deleteAttachmentsByRecord("hrm_employee", id); |
| | | // 删除员工 |
| | | employeeMapper.deleteById(id); |
| | | } |
| | |
| | | respVO.setRoleNames(roles.stream().map(RoleRespDTO::getName).collect(Collectors.joining(","))); |
| | | } |
| | | } |
| | | // 填充附件 |
| | | respVO.setAttachmentList(storageAttachmentApi.listAttachments("hrm_employee", id)); |
| | | return respVO; |
| | | } |
| | | |
| | |
| | | reqVO.setEducation(importEmployee.getEducation()); |
| | | reqVO.setPoliticalStatus(importEmployee.getPoliticalStatus()); |
| | | reqVO.setRemark(importEmployee.getRemark()); |
| | | reqVO.setEmployeeCategory(importEmployee.getEmployeeCategory()); |
| | | reqVO.setBaseSalary(importEmployee.getBaseSalary()); |
| | | reqVO.setBankName(importEmployee.getBankName()); |
| | | reqVO.setBankAccount(importEmployee.getBankAccount()); |
| | | reqVO.setAddress(importEmployee.getAddress()); |
| | | return reqVO; |
| | | } |
| | | |
| | |
| | | return roleIds; |
| | | } |
| | | |
| | | // ========== 转正 ========== |
| | | |
| | | @Override |
| | | public void regularizeEmployee(Long id) { |
| | | validateEmployee(id); |
| | | HrmEmployeeContractDO contract = findCurrentContract(id); |
| | | // 仅「劳动合同」可转正;劳务合同不转正 |
| | | if (contract == null || !Integer.valueOf(1).equals(contract.getContractType())) { |
| | | throw exception(EMPLOYEE_REGULARIZE_NEED_LABOR_CONTRACT); |
| | | } |
| | | HrmEmployeeDO updateObj = new HrmEmployeeDO(); |
| | | updateObj.setId(id); |
| | | updateObj.setEmployeeStatus(1); // 1-在职 |
| | | updateObj.setRegularDate(LocalDate.now()); |
| | | employeeMapper.updateById(updateObj); |
| | | } |
| | | |
| | | @Override |
| | | public List<HrmEmployeeDO> getRegularizeReminderList(Integer days) { |
| | | int aheadDays = days == null ? 7 : days; |
| | | LocalDate limit = LocalDate.now().plusDays(aheadDays); |
| | | // 试用中的员工 |
| | | List<HrmEmployeeDO> trials = employeeMapper.selectList( |
| | | new LambdaQueryWrapperX<HrmEmployeeDO>().eq(HrmEmployeeDO::getEmployeeStatus, 2)); |
| | | List<HrmEmployeeDO> result = new ArrayList<>(); |
| | | for (HrmEmployeeDO employee : trials) { |
| | | HrmEmployeeContractDO contract = findCurrentContract(employee.getId()); |
| | | // 仅劳动合同、且试用期即将到期 |
| | | if (contract == null || !Integer.valueOf(1).equals(contract.getContractType())) { |
| | | continue; |
| | | } |
| | | LocalDate probationEnd = contract.getProbationEndDate(); |
| | | if (probationEnd != null && !probationEnd.isAfter(limit)) { |
| | | result.add(employee); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** 查询员工当前生效合同 */ |
| | | private HrmEmployeeContractDO findCurrentContract(Long employeeId) { |
| | | List<HrmEmployeeContractDO> list = contractMapper.selectListByEmployee(employeeId); |
| | | if (CollUtil.isEmpty(list)) { |
| | | return null; |
| | | } |
| | | for (HrmEmployeeContractDO contract : list) { |
| | | if (Boolean.TRUE.equals(contract.getIsCurrent())) { |
| | | return contract; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |