| | |
| | | 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 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 |
| | |
| | | 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; |
| | | } |
| | | |
| | | } |