| | |
| | | package cc.mrbird.febs.server.hr.service.impl; |
| | | |
| | | import java.io.FileInputStream; |
| | | import java.io.FileNotFoundException; |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.io.*; |
| | | import java.util.*; |
| | | import java.util.function.Consumer; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import cc.mrbird.febs.common.core.entity.constant.StringConstant; |
| | | import cc.mrbird.febs.common.core.entity.system.SysConfig; |
| | | import cc.mrbird.febs.common.core.exception.FebsException; |
| | | import cc.mrbird.febs.common.core.utils.MyUtil; |
| | | import cc.mrbird.febs.server.hr.entity.EmpDimissionLog; |
| | | import cc.mrbird.febs.server.hr.entity.EmpJobChange; |
| | | import cc.mrbird.febs.server.hr.feign.IRemoteDicItemService; |
| | | import cc.mrbird.febs.server.hr.feign.IRemoteUserService; |
| | | import cc.mrbird.febs.server.hr.mapper.*; |
| | | import cc.mrbird.febs.server.hr.properties.FebsServerHrProperties; |
| | | import cc.mrbird.febs.server.hr.service.IEmpContractInfoService; |
| | | import cc.mrbird.febs.server.hr.service.IEmpDimissionLogService; |
| | | import cc.mrbird.febs.server.hr.service.IEmpJobChangeService; |
| | | import cc.mrbird.febs.server.hr.service.*; |
| | | import cc.mrbird.febs.server.hr.util.PoiExportExcel; |
| | | import cn.hutool.core.collection.ListUtil; |
| | | import cn.hutool.core.date.DateUnit; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cc.mrbird.febs.server.hr.entity.*; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import io.prometheus.client.Collector; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | |
| | | import cc.mrbird.febs.common.redis.service.RedisService; |
| | | import cc.mrbird.febs.server.hr.entity.EmpBaseInfo; |
| | | import cc.mrbird.febs.server.hr.feign.IRemoteDeptService; |
| | | import cc.mrbird.febs.server.hr.mapper.EmpBaseInfoMapper; |
| | | import cc.mrbird.febs.server.hr.service.IEmpBaseInfoService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.util.FileSystemUtils; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | |
| | | private final EmpBaseInfoMapper empBaseInfoMapper; |
| | | private final IEmpDimissionLogService dimissionLogService; |
| | | private final IEmpJobChangeService jobChangeService; |
| | | private final IEmpContractInfoService empContractInfoService; |
| | | private final EmpContractInfoMapper empContractInfoMapper; |
| | | private final FebsServerHrProperties properties; |
| | | private final String operatorId = Optional.ofNullable(FebsUtil.getCurrentUser()) |
| | | .map(u -> u.getUserId().toString()) |
| | | .orElse("1"); |
| | | private final IRemoteDeptService remoteDeptService; |
| | | private final EmpWorkExperienceMapper empWorkExperienceMapper; |
| | | private final EmpPhysicalExamMapper empPhysicalExamMapper; |
| | | private final EmpJobChangeMapper empJobChangeMapper; |
| | | private final EmpLeaveInfoMapper empLeaveInfoMapper; |
| | | private final EmpUnemploymentMapper empUnemploymentMapper; |
| | | private final EmpDimissionAttendMapper empDimissionAttendMapper; |
| | | private final EmpInsuranceMapper empInsuranceMapper; |
| | | private final EmpAccidentCasesMapper empAccidentCasesMapper; |
| | | private final EmpLaborTroubleMapper empLaborTroubleMapper; |
| | | private final EmpBadRecordMapper empBadRecordMapper; |
| | | private final EmpRemarkInfoMapper empRemarkInfoMapper; |
| | | private final IRemoteDicItemService remoteDicItemService; |
| | | private final EmpOccupationalMapper empOccupationalMapper; |
| | | |
| | | |
| | | @Override |
| | | public IPage<EmpBaseInfo> findEmpBaseInfos(QueryRequest request, EmpBaseInfo empBaseInfo) { |
| | |
| | | @Override |
| | | public IPage<EmpBaseInfo> findZsEmpBaseInfos(QueryRequest request, EmpBaseInfo empBaseInfo) { |
| | | Page<EmpBaseInfo> page = new Page<>(request.getPageNum(), request.getPageSize()); |
| | | IPage<EmpBaseInfo> iPage = this.page(page, createQueryWrapper(empBaseInfo)); |
| | | IPage<EmpBaseInfo> iPage = empBaseInfoMapper.selectPageVo(page, createQueryWrapper(empBaseInfo)); |
| | | //设置部门 |
| | | List<EmpBaseInfo> list = setDeptName(iPage.getRecords()); |
| | | List<DicItem> dicItems = CastUtil.castList(redisService.get("dicItems"), DicItem.class); |
| | |
| | | p.setArchivesStatusName("0".equals(p.getArchivesStatus()) ? "未移交" : "已移交"); |
| | | p.setEmpCardStatusName("1".equals(p.getEmpCardStatus()) ? "未发" : "已发"); |
| | | p.setHandbookStatusName("1".equals(p.getHandbookStatus()) ? "未发" : "已发"); |
| | | p.setEmpStatusName("0".equals(p.getEmpStatus()) ? "在职" : "离职"); |
| | | //保险类型 |
| | | p.setInsuranceTypeName(dicItems.stream() |
| | | .filter(k -> DicCode.INSURANCETYPE.equals(k.getDicCode()) && k.getDicItemCode().equals(p.getInsuranceType())) |
| | | .findFirst() |
| | | .map(DicItem::getDicItemName) |
| | | .orElse("汉族")); |
| | | .orElse("未知")); |
| | | //员工类别 |
| | | p.setEmpTypeName(dicItems.stream() |
| | | .filter(k -> DicCode.EMPTYPE.equals(k.getDicCode()) && k.getDicItemCode().equals(p.getEmpType())) |
| | | .findFirst() |
| | | .map(DicItem::getDicItemName) |
| | | .orElse("汉族")); |
| | | .orElse("正式工")); |
| | | // 设置民族 |
| | | p.setNationName(dicItems.stream() |
| | | .filter(k -> DicCode.NATION.equals(k.getDicCode()) && k.getDicItemCode().equals(p.getNation())) |
| | |
| | | .findFirst() |
| | | .map(DicItem::getDicItemName) |
| | | .orElse("未知")); |
| | | p.setEntryTypeName(dicItems.stream() |
| | | .filter(k -> DicCode.IN_OUT_TYPE.equals(k.getDicCode()) && k.getDicItemCode().equals(p.getEntryType())) |
| | | .findFirst() |
| | | .map(DicItem::getDicItemName) |
| | | .orElse("未知")); |
| | | p.setDimissionTypeName(dicItems.stream() |
| | | .filter(k -> DicCode.IN_OUT_TYPE.equals(k.getDicCode()) && k.getDicItemCode().equals(p.getDimissionType())) |
| | | .findFirst() |
| | | .map(DicItem::getDicItemName) |
| | | .orElse("未知")); |
| | | }); |
| | | iPage.setRecords(list); |
| | | return iPage; |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void createEmpBaseInfo(EmpBaseInfo empBaseInfo) { |
| | | String operatorId = Optional.of(FebsUtil.getUserId()).orElse("1"); |
| | | EmpBaseInfo dbInfo = this.getEmpBaseInfo(empBaseInfo); |
| | | if (dbInfo == null) { |
| | | empBaseInfo.setEmpId(SequenceUtil.generateId(0L, ModuleCode.HR_EMPLOYEE)); |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void updateEmpBaseInfo(EmpBaseInfo empBaseInfo) { |
| | | String operatorId = Optional.of(FebsUtil.getUserId()).orElse("1"); |
| | | if (StrUtil.isNotBlank(empBaseInfo.getImagePath())) { |
| | | String path = properties.getEmpBaseInfoPath() + empBaseInfo.getEmpId() + ".png"; |
| | | if (MyUtil.generateImage(empBaseInfo.getImagePath(), path)) { |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void logicDelEmpBaseInfo(String ids) { |
| | | String operatorId = Optional.of(FebsUtil.getUserId()).orElse("1"); |
| | | String[] str = ids.split(","); |
| | | List<String> list = new ArrayList<>(Arrays.asList(str)); |
| | | empBaseInfoMapper.logicDeleteByIds(list, operatorId); |
| | |
| | | @Override |
| | | public boolean verifyEmpNumb(EmpBaseInfo empBaseInfo) { |
| | | QueryWrapper<EmpBaseInfo> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.lambda().eq(EmpBaseInfo::getEmpNumb, empBaseInfo.getEmpNumb()).ne(EmpBaseInfo::getDelFlag, 1); |
| | | queryWrapper.lambda().eq(EmpBaseInfo::getEmpNumb, empBaseInfo.getEmpNumb()) |
| | | .ne(EmpBaseInfo::getDelFlag, 1); |
| | | if (empBaseInfo.getEmpId() != null) { |
| | | queryWrapper.lambda().ne(EmpBaseInfo::getEmpId, empBaseInfo.getEmpId()); |
| | | } |
| | | |
| | | if (this.count(queryWrapper) <= 0) { |
| | | return false; |
| | | } |
| | |
| | | |
| | | @Override |
| | | public boolean momentToNormal(String ids) { |
| | | String operatorId = Optional.of(FebsUtil.getUserId()).orElse("1"); |
| | | String[] str = ids.split(","); |
| | | List<String> list = new ArrayList<>(Arrays.asList(str)); |
| | | return empBaseInfoMapper.momentToNormal(list, operatorId) > 0; |
| | |
| | | */ |
| | | @Override |
| | | public boolean closeEmpArchives(EmpDimissionLog empDimissionLog) { |
| | | String operatorId = Optional.of(FebsUtil.getUserId()).orElse("1"); |
| | | String[] str = empDimissionLog.getEmpIds().split(","); |
| | | List<String> list = new ArrayList<>(Arrays.asList(str)); |
| | | String[] strDate = empDimissionLog.getEntryDates().split(","); |
| | |
| | | switch (flag) { |
| | | case 1: |
| | | //解除合同 |
| | | empContractInfoService.terminateContract(empDimissionLog.getEmpIds(), operatorId); |
| | | empContractInfoMapper.terminateContract(new ArrayList<>(Arrays.asList(empDimissionLog.getEmpIds().split(StringConstant.COMMA))), operatorId); |
| | | break; |
| | | case 2: |
| | | //禁用账户 |
| | | iRemoteUserService.updateStatus(empDimissionLog.getCertificateNumb()); |
| | | break; |
| | | case 3: |
| | | empContractInfoService.terminateContract(empDimissionLog.getEmpIds(), operatorId); |
| | | empContractInfoMapper.terminateContract(new ArrayList<>(Arrays.asList(empDimissionLog.getEmpIds().split(StringConstant.COMMA))), operatorId); |
| | | iRemoteUserService.updateStatus(empDimissionLog.getCertificateNumb()); |
| | | break; |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public boolean changeEmpJob(EmpJobChange empJobChange) { |
| | | String operatorId = Optional.of(FebsUtil.getUserId()).orElse("1"); |
| | | String[] str = empJobChange.getEmpIds().split(","); |
| | | List<String> list = new ArrayList<>(Arrays.asList(str)); |
| | | String[] strName = empJobChange.getEmpNames().split(","); |
| | |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void importEmpBaseInfo(List<List<Object>> listObject,List<String> returnList) { |
| | | public void importEmpBaseInfo(List<List<Object>> listObject, List<String> returnList) { |
| | | for (List<Object> list : listObject) { |
| | | if (list.size()==0){ |
| | | if (list.size() == 0) { |
| | | continue; |
| | | } |
| | | if (this.count(new LambdaQueryWrapper<EmpBaseInfo>().eq(EmpBaseInfo::getEmpNumb,list.get(1).toString()).ne(EmpBaseInfo::getDelFlag,1))>0){ |
| | | returnList.add(StrUtil.format("导入员工基本信息异常: 出现位置第{}行, 原因:{}员工编号重复",listObject.indexOf(list),list.get(1).toString())); |
| | | if (this.count(new LambdaQueryWrapper<EmpBaseInfo>().eq(EmpBaseInfo::getEmpNumb, list.get(1).toString()).ne(EmpBaseInfo::getDelFlag, 1)) > 0) { |
| | | returnList.add(StrUtil.format("导入员工基本信息异常: 出现位置第{}行, 原因:{}员工编号重复", listObject.indexOf(list) + 1, list.get(1).toString())); |
| | | continue; |
| | | } |
| | | EmpBaseInfo empBaseInfo = new EmpBaseInfo(); |
| | |
| | | empBaseInfo.setDeptName(list.get(3).toString()); |
| | | Dept dept = depts.stream().filter(d -> d.getDeptName().equals(list.get(3).toString())).findFirst().orElse(null); |
| | | if (null == dept) { |
| | | returnList.add(StrUtil.format("导入员工基本信息异常: 出现位置第{}行, 原因:{}部门不存在",listObject.indexOf(list),list.get(3).toString())); |
| | | returnList.add(StrUtil.format("导入员工基本信息异常: 出现位置第{}行, 原因:{}部门不存在", listObject.indexOf(list) + 1, list.get(3).toString())); |
| | | continue; |
| | | } |
| | | empBaseInfo.setDeptId(dept.getDeptId()); |
| | |
| | | } |
| | | |
| | | //离职员工总数 |
| | | Integer empStatus = this.baseMapper.selectCount(new QueryWrapper<EmpBaseInfo>().eq("empStatus", 1)); |
| | | Integer empStatus = this.baseMapper.selectCount(new QueryWrapper<EmpBaseInfo>().eq("delFlag", 0).eq("empStatus", 1)); |
| | | if (empStatus != null) { |
| | | stringObjectMap.put("lzyg", empStatus); |
| | | } |
| | |
| | | if (StringUtils.isNotBlank(empBaseInfo.getCertificateNumb())) { |
| | | hasCondition = hasCondition | 1; |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEntryDateStr())) { |
| | | hasCondition = hasCondition | 1; |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getDimissionDateStr())) { |
| | | hasCondition = hasCondition | 1; |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getSex())) { |
| | | hasCondition = hasCondition | 1; |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEducation())) { |
| | | hasCondition = hasCondition | 1; |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getPolitics())) { |
| | | hasCondition = hasCondition | 1; |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getAgeStr())) { |
| | | hasCondition = hasCondition | 1; |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getArchivesStatus())) { |
| | | hasCondition = hasCondition | 1; |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getInsuranceType())) { |
| | | hasCondition = hasCondition | 1; |
| | | } |
| | | return hasCondition == 1; |
| | | } |
| | | |
| | | private LambdaQueryWrapper<EmpBaseInfo> createQueryWrapper(EmpBaseInfo empBaseInfo) { |
| | | LambdaQueryWrapper<EmpBaseInfo> queryWrapper = new LambdaQueryWrapper<>(); |
| | | private QueryWrapper<EmpBaseInfo> createQueryWrapper(EmpBaseInfo empBaseInfo) { |
| | | QueryWrapper<EmpBaseInfo> queryWrapper = new QueryWrapper<>(); |
| | | //记录的状态,0-正常 1-删除 2-暂存 |
| | | if (StringUtils.isNotBlank(empBaseInfo.getDelFlag().toString())) { |
| | | queryWrapper.eq(EmpBaseInfo::getDelFlag, empBaseInfo.getDelFlag()); |
| | | queryWrapper.eq("a.DelFlag", empBaseInfo.getDelFlag()); |
| | | } else { |
| | | queryWrapper.eq(EmpBaseInfo::getDelFlag, 0); |
| | | queryWrapper.eq("a.DelFlag", 0); |
| | | } |
| | | //人员的状态,0-在职 1-离职 2-退休 |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEmpStatus())) { |
| | | queryWrapper.in(EmpBaseInfo::getEmpStatus, empBaseInfo.getEmpStatus().split(",")); |
| | | } else { |
| | | queryWrapper.in(EmpBaseInfo::getEmpStatus, 0); |
| | | queryWrapper.in("a.EmpStatus", empBaseInfo.getEmpStatus().split(",")); |
| | | } |
| | | // 下面的条件就是人员的属性条件,条件之间是或的关系 |
| | | if (this.checkQueryCondition(empBaseInfo)) { |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEmpCardStatus())) { |
| | | queryWrapper.in("a.empCardStatus", empBaseInfo.getEmpCardStatus().split(",")); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getHandbookStatus())) { |
| | | queryWrapper.in("a.handBookStatus", empBaseInfo.getHandbookStatus().split(",")); |
| | | } |
| | | // 关键词查询,是或的关系 |
| | | if (StringUtils.isNotBlank(empBaseInfo.getBaseKey())) { |
| | | queryWrapper.and(p -> { |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEmpNumb())) { |
| | | p.like(EmpBaseInfo::getEmpNumb, empBaseInfo.getEmpNumb()); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEmpName())) { |
| | | p.or().like(EmpBaseInfo::getEmpName, empBaseInfo.getEmpName()); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getDeptName())) { |
| | | p.or().like(EmpBaseInfo::getDeptName, empBaseInfo.getDeptName()); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getCertificateNumb())) { |
| | | p.or().like(EmpBaseInfo::getCertificateNumb, empBaseInfo.getCertificateNumb()); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEntryDateStr())) { |
| | | p.or().between(EmpBaseInfo::getEntryDate, empBaseInfo.getEntryDateStr().split(",")[0], empBaseInfo.getEntryDateStr().split(",")[1]); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getDimissionDateStr())) { |
| | | p.or().between(EmpBaseInfo::getDimissionDate, empBaseInfo.getDimissionDateStr().split(",")[0], empBaseInfo.getDimissionDateStr().split(",")[1]); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getSex())) { |
| | | p.or().in(EmpBaseInfo::getSex, empBaseInfo.getSex().split(",")); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEducation())) { |
| | | p.or().in(EmpBaseInfo::getEducation, empBaseInfo.getEducation().split(",")); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getPolitics())) { |
| | | p.or().in(EmpBaseInfo::getPolitics, empBaseInfo.getPolitics().split(",")); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getAgeStr())) { |
| | | String[] ages = empBaseInfo.getAgeStr().split(","); |
| | | Consumer<LambdaQueryWrapper<EmpBaseInfo>> consumer = new Consumer<LambdaQueryWrapper<EmpBaseInfo>>() { |
| | | @Override |
| | | public void accept(LambdaQueryWrapper<EmpBaseInfo> wrapper) { |
| | | for (int i = 0; i < ages.length; i++) { |
| | | String ageBtn = ages[i]; |
| | | wrapper.or().between(EmpBaseInfo::getAge, ageBtn.split("-")[0], ageBtn.split("-")[1]); |
| | | } |
| | | } |
| | | }; |
| | | p.or().and(consumer); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getArchivesStatus())) { |
| | | p.or().in(EmpBaseInfo::getArchivesStatus, empBaseInfo.getArchivesStatus().split(",")); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getInsuranceType())) { |
| | | p.or().in(EmpBaseInfo::getInsuranceType, empBaseInfo.getInsuranceType().split(",")); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getHandbookStatus())) { |
| | | p.or().in(EmpBaseInfo::getHandbookStatus, empBaseInfo.getHandbookStatus().split(",")); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEmpCardStatus())) { |
| | | p.or().in(EmpBaseInfo::getEmpCardStatus, empBaseInfo.getEmpCardStatus().split(",")); |
| | | } |
| | | p.like("a.EmpNumb", empBaseInfo.getBaseKey()); |
| | | p.or().like("a.EmpName", empBaseInfo.getBaseKey()); |
| | | p.or().like("a.DeptName", empBaseInfo.getBaseKey()); |
| | | p.or().like("a.CertificateNumb", empBaseInfo.getBaseKey()); |
| | | p.or().like("a.archivesNumb", empBaseInfo.getBaseKey()); |
| | | p.or().like("a.stature", empBaseInfo.getBaseKey()); |
| | | p.or().like("a.seniority", empBaseInfo.getBaseKey()); |
| | | p.or().like("a.nativePlace", empBaseInfo.getBaseKey()); |
| | | p.or().like("a.censusAddress", empBaseInfo.getBaseKey()); |
| | | p.or().like("a.guardNumb", empBaseInfo.getBaseKey()); |
| | | p.or().like("a.telePhone", empBaseInfo.getBaseKey()); |
| | | p.or().like("a.socialNumb", empBaseInfo.getBaseKey()); |
| | | p.or().like("a.bankName", empBaseInfo.getBaseKey()); |
| | | p.or().like("a.bankNumb", empBaseInfo.getBaseKey()); |
| | | p.or().like("a.family", empBaseInfo.getBaseKey()); |
| | | p.or().like("a.certificateList", empBaseInfo.getBaseKey()); |
| | | }); |
| | | } |
| | | |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEmpNumb())) { |
| | | queryWrapper.like("a.EmpNumb", empBaseInfo.getEmpNumb()); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEmpName())) { |
| | | queryWrapper.like("a.EmpName", empBaseInfo.getEmpName()); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getDeptName())) { |
| | | queryWrapper.like("a.DeptName", empBaseInfo.getDeptName()); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getCertificateNumb())) { |
| | | queryWrapper.like("a.CertificateNumb", empBaseInfo.getCertificateNumb()); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEntryDateStr())) { |
| | | queryWrapper.between("a.EntryDate", empBaseInfo.getEntryDateStr().split(",")[0], empBaseInfo.getEntryDateStr().split(",")[1]); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getDimissionDateStr())) { |
| | | queryWrapper.between("a.DimissionDate", empBaseInfo.getDimissionDateStr().split(",")[0], empBaseInfo.getDimissionDateStr().split(",")[1]); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getSex())) { |
| | | queryWrapper.in("a.Sex", empBaseInfo.getSex().split(",")); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEducation())) { |
| | | queryWrapper.in("a.Education", empBaseInfo.getEducation().split(",")); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getPolitics())) { |
| | | queryWrapper.in("a.Politics", empBaseInfo.getPolitics().split(",")); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getAgeStr())) { |
| | | String[] ages = empBaseInfo.getAgeStr().split(","); |
| | | Consumer<QueryWrapper<EmpBaseInfo>> consumer = new Consumer<QueryWrapper<EmpBaseInfo>>() { |
| | | @Override |
| | | public void accept(QueryWrapper<EmpBaseInfo> wrapper) { |
| | | for (int i = 0; i < ages.length; i++) { |
| | | String ageBtn = ages[i]; |
| | | wrapper.or().between("a.Age", ageBtn.split("-")[0], ageBtn.split("-")[1]); |
| | | } |
| | | } |
| | | }; |
| | | queryWrapper.and(consumer); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getArchivesStatus())) { |
| | | queryWrapper.in("a.ArchivesStatus", empBaseInfo.getArchivesStatus().split(",")); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getInsuranceType())) { |
| | | queryWrapper.in("a.InsuranceType", empBaseInfo.getInsuranceType().split(",")); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getHandbookStatus())) { |
| | | queryWrapper.in("a.HandbookStatus", empBaseInfo.getHandbookStatus().split(",")); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEmpCardStatus())) { |
| | | queryWrapper.in("a.EmpCardStatus", empBaseInfo.getEmpCardStatus().split(",")); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEmpType())) { |
| | | queryWrapper.in("a.empType", empBaseInfo.getEmpType().split(",")); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEntryType())) { |
| | | queryWrapper.in("a.entryType", empBaseInfo.getEntryType().split(",")); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getDimissionType())) { |
| | | queryWrapper.in("a.dimissionType", empBaseInfo.getDimissionType().split(",")); |
| | | } |
| | | queryWrapper.in("c.dept_Id", remoteDeptService.userRightDepts().split(StringConstant.COMMA)); |
| | | return queryWrapper; |
| | | } |
| | | |
| | |
| | | return dbEmpInfo; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Long getEmpIdByEmpNumb(String empNumb) { |
| | | try { |
| | | return this.getOne(new LambdaQueryWrapper<EmpBaseInfo>().eq(EmpBaseInfo::getEmpNumb, empNumb).ne(EmpBaseInfo::getDelFlag, 1)).getEmpId(); |
| | | } catch (Exception e) { |
| | | return null; |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public EmpBaseInfo getEmpBaseInfoByEmpNumb(String empNumb) { |
| | | try { |
| | | return this.getOne(new LambdaQueryWrapper<EmpBaseInfo>().eq(EmpBaseInfo::getEmpNumb, empNumb).ne(EmpBaseInfo::getDelFlag, 1)); |
| | | } catch (Exception e) { |
| | | return null; |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void exportEmpAll(HttpServletResponse response, EmpBaseInfo empBaseinfo) throws IOException { |
| | | //获取字典 |
| | | List<DicItem> dicItemList = remoteDicItemService.getAllDicitemsAll(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | |
| | | List<Long> itemCode = dicItemList.stream().map(i -> i.getDicId()).distinct().collect(Collectors.toList()); |
| | | itemCode.stream().forEach(i -> { |
| | | List<DicItem> dicItems = dicItemList.stream().filter(j -> j.getDicId().equals(i)).collect(Collectors.toList()); |
| | | Map<String, Object> itemMap = new HashMap<>(); |
| | | dicItems.stream().forEach(dicItem -> itemMap.put(dicItem.getDicItemCode(), dicItem.getDicItemName())); |
| | | map.put(dicItems.get(0).getDicCode().toLowerCase(), itemMap); |
| | | }); |
| | | List<String> sheetNames = new ArrayList<>(); |
| | | sheetNames.add("基本信息"); |
| | | //基本信息 |
| | | QueryRequest request = new QueryRequest(); |
| | | request.setPageSize(25535); |
| | | request.setPageNum(1); |
| | | List<EmpBaseInfo> exportList = this.findZsEmpBaseInfos(request, empBaseinfo).getRecords(); |
| | | List<Map<String, Object>> listMapDicItem = new ArrayList(); |
| | | listMapDicItem.add(map); |
| | | String exportField = FebsUtil.reflectAnnotation(EmpBaseInfo.class); |
| | | List<Map<String, Object>> allList = PoiExportExcel.getDataList(exportField, exportList, listMapDicItem); |
| | | Page<EmpBaseInfo> page = new Page<>(request.getPageNum(), request.getPageSize()); |
| | | List<Long> empIds = exportList.stream().map(i -> i.getEmpId()).collect(Collectors.toList()); |
| | | |
| | | //工作经历 |
| | | IPage<EmpWorkExperience> workExperienceIPage = empWorkExperienceMapper.selectPageVo(page, new QueryWrapper<EmpWorkExperience>().in("a.empId", empIds).ne("a.delFlag", 1)); |
| | | if (workExperienceIPage.getRecords().size() != 0) { |
| | | exportField = FebsUtil.reflectAnnotation(EmpWorkExperience.class); |
| | | List<Map<String, Object>> allListEmpWork = PoiExportExcel.getDataList(exportField, workExperienceIPage.getRecords(), listMapDicItem); |
| | | allList.add(allListEmpWork.get(0)); |
| | | sheetNames.add("工作经历"); |
| | | } |
| | | |
| | | //体检信息 |
| | | IPage<EmpPhysicalExam> empPhysicalExamIPage = empPhysicalExamMapper.selectPageVo(page, new QueryWrapper<EmpPhysicalExam>().in("a.empId", empIds).ne("a.delFlag", 1)); |
| | | if (empPhysicalExamIPage.getRecords().size() != 0) { |
| | | exportField = FebsUtil.reflectAnnotation(EmpWorkExperience.class); |
| | | List<Map<String, Object>> allListEmpPhysical = PoiExportExcel.getDataList(exportField, empPhysicalExamIPage.getRecords(), listMapDicItem); |
| | | allList.add(allListEmpPhysical.get(0)); |
| | | sheetNames.add("体检信息"); |
| | | } |
| | | |
| | | //调岗记录 |
| | | IPage<EmpJobChange> jobChangeIPage = empJobChangeMapper.selectPageVoBean(page, new QueryWrapper<EmpJobChange>().in("a.empId", empIds).ne("a.delFlag", 1)); |
| | | if (jobChangeIPage.getRecords().size() != 0) { |
| | | exportField = FebsUtil.reflectAnnotation(EmpJobChange.class); |
| | | List<Map<String, Object>> allListjobChangeI = PoiExportExcel.getDataList(exportField, jobChangeIPage.getRecords(), listMapDicItem); |
| | | allList.add(allListjobChangeI.get(0)); |
| | | sheetNames.add("调岗记录"); |
| | | } |
| | | |
| | | //合同信息 |
| | | IPage<EmpContractInfo> empContractInfoIPage = empContractInfoMapper.selectPageVo(page, new QueryWrapper<EmpContractInfo>().in("a.empId", empIds).ne("a.delFlag", 1)); |
| | | if (empContractInfoIPage.getRecords().size() != 0) { |
| | | exportField = FebsUtil.reflectAnnotation(EmpContractInfo.class); |
| | | List<Map<String, Object>> allListEmpContractInfo = PoiExportExcel.getDataList(exportField, empContractInfoIPage.getRecords(), listMapDicItem); |
| | | allList.add(allListEmpContractInfo.get(0)); |
| | | sheetNames.add("合同信息"); |
| | | } |
| | | |
| | | //入离职记录 |
| | | IPage<EmpDimissionAttend> empDimissionAttendIPage = empDimissionAttendMapper.selectPageVo(page, new QueryWrapper<EmpDimissionAttend>().in("a.empId", empIds).ne("a.delFlag", 1)); |
| | | if (empDimissionAttendIPage.getRecords().size() != 0) { |
| | | exportField = FebsUtil.reflectAnnotation(EmpDimissionAttend.class); |
| | | List<Map<String, Object>> allListEmpDimissionAtt = PoiExportExcel.getDataList(exportField, empDimissionAttendIPage.getRecords(), listMapDicItem); |
| | | allList.add(allListEmpDimissionAtt.get(0)); |
| | | sheetNames.add("入离职记录"); |
| | | } |
| | | |
| | | //请假记录 |
| | | IPage<EmpLeaveInfo> empLeaveInfoIPage = empLeaveInfoMapper.selectPageVo(page, new QueryWrapper<EmpLeaveInfo>().in("a.empId", empIds).ne("a.delFlag", 1)); |
| | | if (empLeaveInfoIPage.getRecords().size() != 0) { |
| | | exportField = FebsUtil.reflectAnnotation(EmpLeaveInfo.class); |
| | | List<Map<String, Object>> allListEmpLoeaveInfo = PoiExportExcel.getDataList(exportField, empLeaveInfoIPage.getRecords(), listMapDicItem); |
| | | allList.add(allListEmpLoeaveInfo.get(0)); |
| | | sheetNames.add("请假记录"); |
| | | } |
| | | |
| | | |
| | | //失业金领取 |
| | | IPage<EmpUnemployment> empUnemploymentIPage = empUnemploymentMapper.selectPageVo(page, new QueryWrapper<EmpUnemployment>().in("a.empId", empIds).ne("a.delFlag", 1)); |
| | | if (empUnemploymentIPage.getRecords().size() != 0) { |
| | | exportField = FebsUtil.reflectAnnotation(EmpUnemployment.class); |
| | | List<Map<String, Object>> allListEmpUnemployment = PoiExportExcel.getDataList(exportField, empUnemploymentIPage.getRecords(), listMapDicItem); |
| | | allList.add(allListEmpUnemployment.get(0)); |
| | | sheetNames.add("失业金领取"); |
| | | } |
| | | |
| | | //社保申请 |
| | | IPage<EmpInsurance> empInsuranceIPage = empInsuranceMapper.selectPageVo(page, new QueryWrapper<EmpInsurance>().in("a.empId", empIds).ne("a.delFlag", 1)); |
| | | if (empInsuranceIPage.getRecords().size() != 0) { |
| | | exportField = FebsUtil.reflectAnnotation(EmpInsurance.class); |
| | | List<Map<String, Object>> allListEmpInsurance = PoiExportExcel.getDataList(exportField, empInsuranceIPage.getRecords(), listMapDicItem); |
| | | allList.add(allListEmpInsurance.get(0)); |
| | | sheetNames.add("社保申请"); |
| | | } |
| | | |
| | | |
| | | //意外险案件 |
| | | IPage<EmpAccidentCases> empAccidentCasesIPage = empAccidentCasesMapper.selectPageVo(page, new QueryWrapper<EmpInsurance>().in("a.empId", empIds).ne("a.delFlag", 1)); |
| | | if (empAccidentCasesIPage.getRecords().size() != 0) { |
| | | exportField = FebsUtil.reflectAnnotation(EmpAccidentCases.class); |
| | | List<Map<String, Object>> allListEmpAccidentCases = PoiExportExcel.getDataList(exportField, empAccidentCasesIPage.getRecords(), listMapDicItem); |
| | | allList.add(allListEmpAccidentCases.get(0)); |
| | | sheetNames.add("意外险案件"); |
| | | } |
| | | |
| | | //工伤案件 |
| | | IPage<EmpOccupational> empOccupationalIPage = empOccupationalMapper.selectPageVo(page, new QueryWrapper<EmpOccupational>().in("a.empId", empIds).ne("a.delFlag", 1)); |
| | | if (empOccupationalIPage.getRecords().size() != 0) { |
| | | exportField = FebsUtil.reflectAnnotation(EmpOccupational.class); |
| | | List<Map<String, Object>> allListEmpOccupational = PoiExportExcel.getDataList(exportField, empOccupationalIPage.getRecords(), listMapDicItem); |
| | | allList.add(allListEmpOccupational.get(0)); |
| | | sheetNames.add("工伤案件"); |
| | | } |
| | | |
| | | //劳资案件 |
| | | IPage<EmpLaborTrouble> empLaborTroubleIPage = empLaborTroubleMapper.selectPageVo(page, new QueryWrapper<EmpInsurance>().in("a.empId", empIds).ne("a.delFlag", 1)); |
| | | if (empLaborTroubleIPage.getRecords().size() != 0) { |
| | | exportField = FebsUtil.reflectAnnotation(EmpLaborTrouble.class); |
| | | List<Map<String, Object>> allListEmpLaborTrouble = PoiExportExcel.getDataList(exportField, empLaborTroubleIPage.getRecords(), listMapDicItem); |
| | | allList.add(allListEmpLaborTrouble.get(0)); |
| | | sheetNames.add("劳资案件"); |
| | | } |
| | | |
| | | |
| | | //不良记录 |
| | | IPage<EmpBadRecord> empBadRecordIPage = empBadRecordMapper.selectPageVo(page, new QueryWrapper<EmpInsurance>().in("a.empId", empIds).ne("a.delFlag", 1)); |
| | | if (empBadRecordIPage.getRecords().size() != 0) { |
| | | exportField = FebsUtil.reflectAnnotation(EmpBadRecord.class); |
| | | List<Map<String, Object>> allListEmpBadRecord = PoiExportExcel.getDataList(exportField, empBadRecordIPage.getRecords(), listMapDicItem); |
| | | allList.add(allListEmpBadRecord.get(0)); |
| | | sheetNames.add("不良记录"); |
| | | } |
| | | |
| | | |
| | | //备注信息 |
| | | IPage<EmpRemarkInfo> empRemarkInfoIPage = empRemarkInfoMapper.selectPageVo(page, new QueryWrapper<EmpRemarkInfo>().in("a.empId", empIds).ne("a.delFlag", 1)); |
| | | if (empRemarkInfoIPage.getRecords().size() != 0) { |
| | | exportField = FebsUtil.reflectAnnotation(EmpRemarkInfo.class); |
| | | List<Map<String, Object>> allListEmpRemarkInfo = PoiExportExcel.getDataList(exportField, empRemarkInfoIPage.getRecords(), listMapDicItem); |
| | | allList.add(allListEmpRemarkInfo.get(0)); |
| | | sheetNames.add("备注信息"); |
| | | } |
| | | |
| | | |
| | | boolean result = PoiExportExcel.exportCommonExcelMultiSheet(response, "在职员工列表", allList, sheetNames); |
| | | } |
| | | } |