| | |
| | | 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.IRemoteUserService; |
| | | 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 cn.hutool.core.date.DateUnit; |
| | |
| | | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) |
| | | class EmpBaseInfoServiceImpl extends ServiceImpl<EmpBaseInfoMapper, EmpBaseInfo> implements IEmpBaseInfoService { |
| | | private final RedisService redisService; |
| | | private final IRemoteDeptService remoteDeptService; |
| | | private final IRemoteUserService iRemoteUserService; |
| | | private final EmpBaseInfoMapper empBaseInfoMapper; |
| | | private final IEmpDimissionLogService dimissionLogService; |
| | | private final IEmpJobChangeService jobChangeService; |
| | | private final IEmpContractInfoService empContractInfoService; |
| | | private final FebsServerHrProperties properties; |
| | | private final String operatorId = Optional.ofNullable(FebsUtil.getCurrentUser()) |
| | | .map(u -> u.getUserId().toString()) |
| | |
| | | list.forEach(p -> { |
| | | p.setSexName("1".equals(p.getSex()) ? "男" : "女"); |
| | | p.setArchivesStatusName("0".equals(p.getArchivesStatus()) ? "未移交" : "已移交"); |
| | | p.setEmpCardStatusName("1".equals(p.getEmpCardStatus()) ? "未发" : "已发"); |
| | | p.setHandbookStatusName("1".equals(p.getHandbookStatus()) ? "未发" : "已发"); |
| | | //保险类型 |
| | | p.setInsuranceTypeName(dicItems.stream() |
| | | .filter(k -> DicCode.INSURANCETYPE.equals(k.getDicCode()) && k.getDicItemCode().equals(p.getInsuranceType())) |
| | |
| | | @Override |
| | | public boolean verifyEmpNumb(EmpBaseInfo empBaseInfo) { |
| | | QueryWrapper<EmpBaseInfo> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.lambda().eq(EmpBaseInfo::getEmpNumb, empBaseInfo.getEmpNumb()); |
| | | EmpBaseInfo tempEmpBaseInfo = this.getOne(queryWrapper); |
| | | if (tempEmpBaseInfo == null) { |
| | | queryWrapper.lambda().eq(EmpBaseInfo::getEmpNumb, empBaseInfo.getEmpNumb()).ne(EmpBaseInfo::getDelFlag, 1); |
| | | if (this.count(queryWrapper) <= 0) { |
| | | return false; |
| | | } |
| | | return !empBaseInfo.getEmpNumb().equals(tempEmpBaseInfo.getEmpNumb()); |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | |
| | | String[] str = empDimissionLog.getEmpIds().split(","); |
| | | List<String> list = new ArrayList<>(Arrays.asList(str)); |
| | | String[] strDate = empDimissionLog.getEntryDates().split(","); |
| | | |
| | | EmpDimissionLog dimissionLog = null; |
| | | for (int i = 0, k = str.length; i < k; i++) { |
| | | dimissionLog = new EmpDimissionLog(); |
| | |
| | | dimissionLog.setReporter(empDimissionLog.getReporter()); |
| | | dimissionLog.setCreator(operatorId); |
| | | dimissionLog.setModifier(operatorId); |
| | | |
| | | dimissionLogService.save(dimissionLog); |
| | | } |
| | | |
| | | if (StrUtil.isNotBlank(empDimissionLog.getAfterOperation())) { |
| | | String[] strAfterOperation = empDimissionLog.getAfterOperation().split(","); |
| | | int flag = 0; |
| | | for (String s : strAfterOperation) { |
| | | flag = flag + Integer.parseInt(s); |
| | | } |
| | | switch (flag) { |
| | | case 1: |
| | | //解除合同 |
| | | empContractInfoService.terminateContract(empDimissionLog.getEmpIds(), operatorId); |
| | | break; |
| | | case 2: |
| | | //禁用账户 |
| | | iRemoteUserService.updateStatus(empDimissionLog.getCertificateNumb()); |
| | | break; |
| | | case 3: |
| | | empContractInfoService.terminateContract(empDimissionLog.getEmpIds(), operatorId); |
| | | iRemoteUserService.updateStatus(empDimissionLog.getCertificateNumb()); |
| | | break; |
| | | } |
| | | } |
| | | return empBaseInfoMapper.closeEmpArchives(list, empDimissionLog.getDimissionType(), empDimissionLog.getDimissionDate(), empDimissionLog.getRemark(), operatorId) > 0; |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * 检查是否是带条件查询 |
| | | * |
| | | * <p> |
| | | * date 2021-02-26 13:49 |
| | | * @author: luoyibo |
| | | * |
| | | * @param empBaseInfo 人员参数 |
| | | * @return boolean |
| | | * @author: luoyibo |
| | | */ |
| | | private boolean checkQueryCondition(EmpBaseInfo empBaseInfo){ |
| | | private boolean checkQueryCondition(EmpBaseInfo empBaseInfo) { |
| | | int hasCondition = 0; |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEmpNumb())) { |
| | | hasCondition = hasCondition|1; |
| | | hasCondition = hasCondition | 1; |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEmpName())) { |
| | | hasCondition = hasCondition|1; |
| | | hasCondition = hasCondition | 1; |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getDeptName())) { |
| | | hasCondition = hasCondition|1; |
| | | hasCondition = hasCondition | 1; |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getCertificateNumb())) { |
| | | hasCondition = hasCondition|1; |
| | | hasCondition = hasCondition | 1; |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEntryDateStr())) { |
| | | hasCondition = hasCondition|1; |
| | | hasCondition = hasCondition | 1; |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getDimissionDateStr())) { |
| | | hasCondition = hasCondition|1; |
| | | hasCondition = hasCondition | 1; |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getSex())) { |
| | | hasCondition = hasCondition|1; |
| | | hasCondition = hasCondition | 1; |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEducation())) { |
| | | hasCondition = hasCondition|1; |
| | | hasCondition = hasCondition | 1; |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getPolitics())) { |
| | | hasCondition = hasCondition|1; |
| | | hasCondition = hasCondition | 1; |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getAgeStr())) { |
| | | hasCondition = hasCondition|1; |
| | | hasCondition = hasCondition | 1; |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getArchivesStatus())) { |
| | | hasCondition = hasCondition|1; |
| | | hasCondition = hasCondition | 1; |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getInsuranceType())) { |
| | | hasCondition = hasCondition|1; |
| | | hasCondition = hasCondition | 1; |
| | | } |
| | | return hasCondition==1; |
| | | return hasCondition == 1; |
| | | } |
| | | |
| | | private LambdaQueryWrapper<EmpBaseInfo> createQueryWrapper(EmpBaseInfo empBaseInfo){ |
| | | private LambdaQueryWrapper<EmpBaseInfo> createQueryWrapper(EmpBaseInfo empBaseInfo) { |
| | | LambdaQueryWrapper<EmpBaseInfo> queryWrapper = new LambdaQueryWrapper<>(); |
| | | //记录的状态,0-正常 1-删除 2-暂存 |
| | | if(StringUtils.isNotBlank(empBaseInfo.getDelFlag().toString())) { |
| | | if (StringUtils.isNotBlank(empBaseInfo.getDelFlag().toString())) { |
| | | queryWrapper.eq(EmpBaseInfo::getDelFlag, empBaseInfo.getDelFlag()); |
| | | } else{ |
| | | } else { |
| | | queryWrapper.eq(EmpBaseInfo::getDelFlag, 0); |
| | | } |
| | | //人员的状态,0-在职 1-离职 2-退休 |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEmpStatus())) { |
| | | queryWrapper.in(EmpBaseInfo::getEmpStatus, empBaseInfo.getEmpStatus().split(",")); |
| | | } else{ |
| | | } else { |
| | | queryWrapper.in(EmpBaseInfo::getEmpStatus, 0); |
| | | } |
| | | // 下面的条件就是人员的属性条件,条件之间是或的关系 |
| | | if(this.checkQueryCondition(empBaseInfo)){ |
| | | if (this.checkQueryCondition(empBaseInfo)) { |
| | | queryWrapper.and(p -> { |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEmpNumb())) { |
| | | p.like(EmpBaseInfo::getEmpNumb, empBaseInfo.getEmpNumb()); |
| | |
| | | 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(",")); |
| | | } |
| | | }); |
| | | } |
| | | return queryWrapper; |
| | | } |
| | | |
| | | @Override |
| | | public EmpBaseInfo addInEmpBaseInfo(EmpBaseInfo empBaseInfo) { |
| | | EmpBaseInfo dbEmpInfo = this.getEmpBaseInfo(empBaseInfo); |
| | | if (dbEmpInfo == null) { |
| | | this.createEmpBaseInfo(empBaseInfo); |
| | | return null; |
| | | } else { |
| | | return dbEmpInfo; |
| | | } |
| | | } |
| | | } |