| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.OrderUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.dto.WordDateDto; |
| | | import com.ruoyi.project.system.domain.SysDept; |
| | | import com.ruoyi.project.system.domain.SysPost; |
| | | import com.ruoyi.project.system.domain.SysRole; |
| | | import com.ruoyi.project.system.domain.SysUser; |
| | | import com.ruoyi.project.system.mapper.SysDeptMapper; |
| | | import com.ruoyi.project.system.mapper.SysPostMapper; |
| | | import com.ruoyi.project.system.mapper.SysRoleMapper; |
| | | import com.ruoyi.project.system.mapper.SysUserMapper; |
| | | import com.ruoyi.project.system.service.impl.SysUserServiceImpl; |
| | | import com.ruoyi.staff.dto.StaffOnJobDto; |
| | | import com.ruoyi.staff.dto.StaffOnJobExcelDto; |
| | | import com.ruoyi.staff.mapper.*; |
| | | import com.ruoyi.staff.pojo.*; |
| | | import com.ruoyi.staff.service.IStaffOnJobService; |
| | | import freemarker.template.Configuration; |
| | | import freemarker.template.Template; |
| | | import lombok.AllArgsConstructor; |
| | | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.apache.commons.collections4.ListUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.*; |
| | | import java.io.File; |
| | | import java.io.FileOutputStream; |
| | | import java.io.OutputStreamWriter; |
| | | import java.io.StringWriter; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.time.Instant; |
| | | import java.time.LocalDate; |
| | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @AllArgsConstructor |
| | | @RequiredArgsConstructor |
| | | @Service |
| | | public class StaffOnJobServiceImpl extends ServiceImpl<StaffOnJobMapper, StaffOnJob> implements IStaffOnJobService { |
| | | |
| | | @Autowired |
| | | private StaffOnJobMapper staffOnJobMapper; |
| | | @Autowired |
| | | private SysPostMapper sysPostMapper; |
| | | |
| | | @Autowired |
| | | private StaffContractMapper staffContractMapper; |
| | | @Autowired |
| | | private StaffLeaveMapper staffLeaveMapper; |
| | | |
| | | @Autowired |
| | | private PersonalAttendanceRecordsMapper personalAttendanceRecordsMapper; |
| | | |
| | | @Autowired |
| | | private SysUserServiceImpl sysUserService; |
| | | |
| | | @Autowired |
| | | private SysUserMapper sysUserMapper; |
| | | |
| | | @Autowired |
| | | private StaffEducationServiceImpl staffEducationService; |
| | | |
| | | @Autowired |
| | | private StaffEducationMapper staffEducationMapper; |
| | | |
| | | @Autowired |
| | | private StaffWorkExperienceMapper staffWorkExperienceMapper; |
| | | |
| | | @Autowired |
| | | private StaffWorkExperienceServiceImpl staffWorkExperienceServiceImpl; |
| | | |
| | | @Autowired |
| | | private StaffEmergencyContactMapper staffEmergencyContactMapper; |
| | | |
| | | @Autowired |
| | | private StaffEmergencyContactServiceImpl staffEmergencyContactServiceImpl; |
| | | private final StaffOnJobMapper staffOnJobMapper; |
| | | private final SysDeptMapper sysDeptMapper; |
| | | private final SysRoleMapper sysRoleMapper; |
| | | private final SysPostMapper sysPostMapper; |
| | | private final StaffContractMapper staffContractMapper; |
| | | private final StaffLeaveMapper staffLeaveMapper; |
| | | private final PersonalAttendanceRecordsMapper personalAttendanceRecordsMapper; |
| | | private final SysUserServiceImpl sysUserService; |
| | | private final SysUserMapper sysUserMapper; |
| | | private final StaffEducationServiceImpl staffEducationService; |
| | | private final StaffEducationMapper staffEducationMapper; |
| | | private final StaffWorkExperienceMapper staffWorkExperienceMapper; |
| | | private final StaffWorkExperienceServiceImpl staffWorkExperienceServiceImpl; |
| | | private final StaffEmergencyContactMapper staffEmergencyContactMapper; |
| | | private final StaffEmergencyContactServiceImpl staffEmergencyContactServiceImpl; |
| | | |
| | | |
| | | //在职员工台账分页查询 |
| | | @Override |
| | | public IPage<StaffOnJobDto> staffOnJobListPage(Page page, StaffOnJob staffOnJob) { |
| | | return staffOnJobMapper.staffOnJobListPage(page,staffOnJob); |
| | | public IPage<StaffOnJobDto> staffOnJobListPage(Page page, StaffOnJobDto staffOnJob) { |
| | | IPage<StaffOnJobDto> staffOnJobDtoIPage = staffOnJobMapper.staffOnJobListPage(page, staffOnJob); |
| | | return staffOnJobDtoIPage; |
| | | } |
| | | |
| | | //新增入职 |
| | |
| | | } |
| | | |
| | | // 创建入职数据 |
| | | syncStudyInfoFromEducation(staffOnJobPrams); |
| | | staffOnJobPrams.setContractExpireTime(staffOnJobPrams.getContractEndTime()); |
| | | staffOnJobPrams.setStaffState(1); |
| | | staffOnJobMapper.insert(staffOnJobPrams); |
| | |
| | | // 绑定子表数据 |
| | | bingingStaffOnJobExtra(id,staffOnJobParams); |
| | | // 更新员工数据 |
| | | syncStudyInfoFromEducation(staffOnJobParams); |
| | | staffOnJobParams.setContractExpireTime(staffOnJobParams.getContractEndTime()); |
| | | return staffOnJobMapper.updateById(staffOnJobParams); |
| | | } |
| | |
| | | .forEach(staff -> staff.setStaffOnJobId(id)); // 赋值 |
| | | staffEducationService.saveBatch(staffOnJobPrams.getStaffEducationList()); |
| | | } |
| | | |
| | | // 新增工作经历 |
| | | if(CollectionUtils.isNotEmpty(staffOnJobPrams.getStaffWorkExperienceList())){ |
| | | staffOnJobPrams.getStaffWorkExperienceList().stream() |
| | |
| | | .forEach(staff -> staff.setStaffOnJobId(id)); // 赋值 |
| | | staffEmergencyContactServiceImpl.saveBatch(staffOnJobPrams.getStaffEmergencyContactList()); |
| | | } |
| | | } |
| | | |
| | | private void syncStudyInfoFromEducation(StaffOnJob staffOnJobPrams) { |
| | | if (staffOnJobPrams == null || CollectionUtils.isEmpty(staffOnJobPrams.getStaffEducationList())) { |
| | | if (staffOnJobPrams != null) { |
| | | staffOnJobPrams.setFirstStudy("/"); |
| | | staffOnJobPrams.setProfession("/"); |
| | | } |
| | | return; |
| | | } |
| | | Optional<StaffEducation> matchedEducation = staffOnJobPrams.getStaffEducationList().stream() |
| | | .filter(Objects::nonNull) |
| | | .filter(education -> StringUtils.isNotEmpty(education.getMajor())) |
| | | .findFirst(); |
| | | if (matchedEducation.isPresent()) { |
| | | StaffEducation education = matchedEducation.get(); |
| | | staffOnJobPrams.setFirstStudy(education.getEducation()); |
| | | staffOnJobPrams.setProfession(education.getMajor()); |
| | | return; |
| | | } |
| | | staffOnJobPrams.setFirstStudy("/"); |
| | | staffOnJobPrams.setProfession("/"); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean importData(MultipartFile file) { |
| | | try { |
| | | ExcelUtil<StaffOnJob> util = new ExcelUtil<>(StaffOnJob.class); |
| | | List<StaffOnJob> staffOnJobs = util.importExcel(file.getInputStream()); |
| | | return saveOrUpdateBatch(staffOnJobs); |
| | | ExcelUtil<StaffOnJobExcelDto> util = new ExcelUtil<>(StaffOnJobExcelDto.class); |
| | | List<StaffOnJobExcelDto> staffOnJobs = util.importExcel(file.getInputStream()); |
| | | if (CollectionUtils.isEmpty(staffOnJobs)){ |
| | | return false; |
| | | } |
| | | // 获取所有部门数据 |
| | | List<SysDept> sysDepts = sysDeptMapper.selectList(Wrappers.<SysDept>lambdaQuery().eq(SysDept::getDelFlag, 0)); |
| | | // 获取所有角色数据 |
| | | List<SysRole> sysRoles = sysRoleMapper.selectRoleAll(); |
| | | staffOnJobs.forEach(staffOnJob -> { |
| | | StaffOnJobDto staffOnJobDto = new StaffOnJobDto(); |
| | | BeanUtils.copyProperties(staffOnJob, staffOnJobDto); |
| | | // 通过名称获取部门id |
| | | staffOnJobDto.setSysDeptId(// ... existing code ... |
| | | sysDepts.stream() |
| | | .filter(dept -> dept.getDeptName() != null && dept.getDeptName().equals(staffOnJob.getSysDeptName())) |
| | | .findFirst() |
| | | .map(SysDept::getDeptId) |
| | | .orElse(null) |
| | | ); |
| | | // 通过名称获取角色id |
| | | staffOnJobDto.setRoleId(sysRoles.stream() |
| | | .filter(role -> role.getRoleName() != null && role.getRoleName().equals(staffOnJob.getRoleName())) |
| | | .findFirst() |
| | | .map(SysRole::getRoleId) |
| | | .orElse( null)); |
| | | add(staffOnJobDto); |
| | | }); |
| | | return true; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return false; |