| | |
| | | import java.util.*; |
| | | import java.util.function.Consumer; |
| | | |
| | | 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; |
| | |
| | | private final IEmpJobChangeService jobChangeService; |
| | | private final IEmpContractInfoService empContractInfoService; |
| | | private final FebsServerHrProperties properties; |
| | | private final IRemoteDeptService remoteDeptService; |
| | | private final String operatorId = Optional.ofNullable(FebsUtil.getCurrentUser()) |
| | | .map(u -> u.getUserId().toString()) |
| | | .orElse("1"); |
| | |
| | | @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); |
| | |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void importEmpBaseInfo(List<List<Object>> listObject) { |
| | | public void importEmpBaseInfo(List<List<Object>> listObject,List<String> returnList) { |
| | | for (List<Object> list : listObject) { |
| | | 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())); |
| | | continue; |
| | | } |
| | | EmpBaseInfo empBaseInfo = new EmpBaseInfo(); |
| | | empBaseInfo.setEmpId(SequenceUtil.generateId(0L, ModuleCode.HR_EMPLOYEE)); |
| | | empBaseInfo.setArchivesNumb(list.get(0).toString()); |
| | |
| | | empBaseInfo.setEmpName(list.get(2).toString()); |
| | | List<Dept> depts = CastUtil.castList(redisService.get("depts"), Dept.class); |
| | | empBaseInfo.setDeptName(list.get(3).toString()); |
| | | Long deptId = depts.stream().filter(d -> d.getDeptName().equals(list.get(3).toString())).findFirst().get() |
| | | .getDeptId(); |
| | | empBaseInfo.setDeptId(deptId); |
| | | 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())); |
| | | continue; |
| | | } |
| | | empBaseInfo.setDeptId(dept.getDeptId()); |
| | | empBaseInfo.setJobName(list.get(4).toString()); |
| | | empBaseInfo.setEmpType(list.get(5).toString()); |
| | | empBaseInfo.setSex("男".equals(list.get(6).toString()) ? "1" : "2"); |
| | |
| | | empBaseInfo.setHandbookStatus(list.get(28).toString()); |
| | | empBaseInfo.setEmpCardStatus(list.get(29).toString()); |
| | | empBaseInfo.setCertificateList(list.get(30).toString()); |
| | | empBaseInfo.setDelFlag(2); |
| | | empBaseInfo.setEmpStatus("0"); |
| | | this.save(empBaseInfo); |
| | | } |
| | |
| | | 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(",")); |
| | | queryWrapper.in("a.EmpStatus", empBaseInfo.getEmpStatus().split(",")); |
| | | } else { |
| | | queryWrapper.in(EmpBaseInfo::getEmpStatus, 0); |
| | | queryWrapper.in("a.EmpStatus", 0); |
| | | } |
| | | // 下面的条件就是人员的属性条件,条件之间是或的关系 |
| | | if (this.checkQueryCondition(empBaseInfo)) { |
| | | queryWrapper.and(p -> { |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEmpNumb())) { |
| | | p.like(EmpBaseInfo::getEmpNumb, empBaseInfo.getEmpNumb()); |
| | | p.like("a.EmpNumb", empBaseInfo.getEmpNumb()); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEmpName())) { |
| | | p.or().like(EmpBaseInfo::getEmpName, empBaseInfo.getEmpName()); |
| | | p.or().like("a.EmpName", empBaseInfo.getEmpName()); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getDeptName())) { |
| | | p.or().like(EmpBaseInfo::getDeptName, empBaseInfo.getDeptName()); |
| | | p.or().like("a.DeptName", empBaseInfo.getDeptName()); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getCertificateNumb())) { |
| | | p.or().like(EmpBaseInfo::getCertificateNumb, empBaseInfo.getCertificateNumb()); |
| | | p.or().like("a.CertificateNumb", empBaseInfo.getCertificateNumb()); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEntryDateStr())) { |
| | | p.or().between(EmpBaseInfo::getEntryDate, empBaseInfo.getEntryDateStr().split(",")[0], empBaseInfo.getEntryDateStr().split(",")[1]); |
| | | p.or().between("a.EntryDate", 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]); |
| | | p.or().between("a.DimissionDate", empBaseInfo.getDimissionDateStr().split(",")[0], empBaseInfo.getDimissionDateStr().split(",")[1]); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getSex())) { |
| | | p.or().in(EmpBaseInfo::getSex, empBaseInfo.getSex().split(",")); |
| | | p.or().in("a.Sex", empBaseInfo.getSex().split(",")); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEducation())) { |
| | | p.or().in(EmpBaseInfo::getEducation, empBaseInfo.getEducation().split(",")); |
| | | p.or().in("a.Education", empBaseInfo.getEducation().split(",")); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getPolitics())) { |
| | | p.or().in(EmpBaseInfo::getPolitics, empBaseInfo.getPolitics().split(",")); |
| | | p.or().in("a.Politics", 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) { |
| | | Consumer<QueryWrapper<EmpBaseInfo>> consumer = new Consumer<QueryWrapper<EmpBaseInfo>>() { |
| | | public void accept(QueryWrapper<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]); |
| | | wrapper.or().between("a.Age", ageBtn.split("-")[0], ageBtn.split("-")[1]); |
| | | } |
| | | } |
| | | }; |
| | | p.or().and(consumer); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getArchivesStatus())) { |
| | | p.or().in(EmpBaseInfo::getArchivesStatus, empBaseInfo.getArchivesStatus().split(",")); |
| | | p.or().in("a.ArchivesStatus", empBaseInfo.getArchivesStatus().split(",")); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getInsuranceType())) { |
| | | p.or().in(EmpBaseInfo::getInsuranceType, empBaseInfo.getInsuranceType().split(",")); |
| | | p.or().in("a.InsuranceType", empBaseInfo.getInsuranceType().split(",")); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getHandbookStatus())) { |
| | | p.or().in(EmpBaseInfo::getHandbookStatus, empBaseInfo.getHandbookStatus().split(",")); |
| | | p.or().in("a.HandbookStatus", empBaseInfo.getHandbookStatus().split(",")); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEmpCardStatus())) { |
| | | p.or().in(EmpBaseInfo::getEmpCardStatus, empBaseInfo.getEmpCardStatus().split(",")); |
| | | p.or().in("a.EmpCardStatus", empBaseInfo.getEmpCardStatus().split(",")); |
| | | } |
| | | }); |
| | | } |
| | | queryWrapper.in("c.dept_Id", remoteDeptService.userRightDepts().split(StringConstant.COMMA)); |
| | | return queryWrapper; |
| | | } |
| | | |