| | |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | |
| | | import cc.mrbird.febs.server.hr.entity.EmpDimissionLog; |
| | | import cc.mrbird.febs.server.hr.service.IEmpDimissionLogService; |
| | | import cn.hutool.core.date.DateUnit; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | |
| | | private final RedisService redisService; |
| | | private final IRemoteDeptService remoteDeptService; |
| | | private final EmpBaseInfoMapper empBaseInfoMapper; |
| | | private final IEmpDimissionLogService dimissionLogService; |
| | | private final String operatorId = Optional.ofNullable(FebsUtil.getCurrentUser()) |
| | | .map(u -> u.getUserId().toString()) |
| | | .orElse("1"); |
| | |
| | | LambdaQueryWrapper<EmpBaseInfo> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(EmpBaseInfo::getDelFlag, empBaseInfo.getDelFlag()); |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEmpNumb())) { |
| | | queryWrapper.eq(EmpBaseInfo::getEmpNumb, empBaseInfo.getEmpNumb()); |
| | | queryWrapper.like(EmpBaseInfo::getEmpNumb, empBaseInfo.getEmpNumb()); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEmpName())) { |
| | | queryWrapper.eq(EmpBaseInfo::getEmpName, empBaseInfo.getEmpName()); |
| | | queryWrapper.like(EmpBaseInfo::getEmpName, empBaseInfo.getEmpName()); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getCertificateNumb())) { |
| | | queryWrapper.eq(EmpBaseInfo::getCertificateNumb, empBaseInfo.getCertificateNumb()); |
| | | queryWrapper.like(EmpBaseInfo::getCertificateNumb, empBaseInfo.getCertificateNumb()); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getDeptName())) { |
| | | queryWrapper.eq(EmpBaseInfo::getDeptName, empBaseInfo.getDeptName()); |
| | | queryWrapper.like(EmpBaseInfo::getDeptName, empBaseInfo.getDeptName()); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEntryDateStr())) { |
| | | queryWrapper.between(EmpBaseInfo::getEntryDate, empBaseInfo.getEntryDateStr().split(",")[0], empBaseInfo.getEntryDateStr().split(",")[1]); |
| | |
| | | queryWrapper.eq(EmpBaseInfo::getSex, empBaseInfo.getSex()); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEducation())) { |
| | | queryWrapper.eq(EmpBaseInfo::getEducation, empBaseInfo.getEducation()); |
| | | queryWrapper.like(EmpBaseInfo::getEducation, empBaseInfo.getEducation()); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getPolitics())) { |
| | | queryWrapper.eq(EmpBaseInfo::getPolitics, empBaseInfo.getPolitics()); |
| | | queryWrapper.like(EmpBaseInfo::getPolitics, empBaseInfo.getPolitics()); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getAgeStr())) { |
| | | queryWrapper.between(EmpBaseInfo::getAge, empBaseInfo.getAgeStr().split(",")[0], empBaseInfo.getAgeStr().split(",")[1]); |
| | |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEmpStatus())) { |
| | | queryWrapper.eq(EmpBaseInfo::getEmpStatus, empBaseInfo.getEmpStatus()); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getHandbookStatus())) { |
| | | queryWrapper.eq(EmpBaseInfo::getHandbookStatus, empBaseInfo.getHandbookStatus()); |
| | | } |
| | | if (StringUtils.isNotBlank(empBaseInfo.getEmpCardStatus())) { |
| | | queryWrapper.eq(EmpBaseInfo::getEmpCardStatus, empBaseInfo.getEmpCardStatus()); |
| | | } |
| | | Page<EmpBaseInfo> page = new Page<>(request.getPageNum(), request.getPageSize()); |
| | | IPage<EmpBaseInfo> iPage = this.page(page, queryWrapper); |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void createEmpBaseInfo(EmpBaseInfo empBaseInfo) { |
| | | empBaseInfo.setEmpId(SequenceUtil.generateId(0L, ModuleCode.HR_EMPLOYEE)); |
| | | EmpBaseInfo dbInfo = this.getEmpBaseInfo(empBaseInfo); |
| | | if(dbInfo==null) { |
| | | empBaseInfo.setEmpId(SequenceUtil.generateId(0L, ModuleCode.HR_EMPLOYEE)); |
| | | } else{ |
| | | empBaseInfo.setEmpId(dbInfo.getEmpId()); |
| | | } |
| | | empBaseInfo.setCreator(operatorId); |
| | | empBaseInfo.setModifier(operatorId); |
| | | this.save(empBaseInfo); |
| | | this.saveOrUpdate(empBaseInfo); |
| | | } |
| | | |
| | | @Override |
| | |
| | | List<String> list = new ArrayList<>(Arrays.asList(str)); |
| | | return empBaseInfoMapper.momentToNormal(list, operatorId) > 0; |
| | | } |
| | | |
| | | @Override |
| | | public EmpBaseInfo getEmpBaseInfo(EmpBaseInfo empBaseInfo) { |
| | | QueryWrapper<EmpBaseInfo> queryWrapper = new QueryWrapper<>(); |
| | | if(StringUtils.isEmpty(empBaseInfo.getCertificateNumb())){ |
| | | queryWrapper.lambda().eq(EmpBaseInfo::getCertificateNumb, empBaseInfo.getCertificateNumb()); |
| | | } |
| | | |
| | | return this.getOne(queryWrapper); |
| | | } |
| | | /** |
| | | * |
| | | * 关闭员工档案 |
| | | * |
| | | * date 2021-02-18 12:54 |
| | | * @author: luoyibo |
| | | * @param empDimissionLog |
| | | * @return boolean |
| | | */ |
| | | @Override |
| | | public boolean closeEmpArchives(EmpDimissionLog empDimissionLog) { |
| | | 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.setCloseId(SequenceUtil.generateId(0L, ModuleCode.HR_EMPLOYEE)); |
| | | dimissionLog.setEmpId(Long.parseLong(str[i])); |
| | | dimissionLog.setEntryDate(DateUtil.parse(strDate[i],"yyyy-MM-dd")); |
| | | dimissionLog.setDimissionDate(empDimissionLog.getDimissionDate()); |
| | | dimissionLog.setDimissionType(empDimissionLog.getDimissionType()); |
| | | dimissionLog.setRemark(empDimissionLog.getRemark()); |
| | | dimissionLog.setSelfLeaveDay(empDimissionLog.getSelfLeaveDay()); |
| | | dimissionLog.setReporter(empDimissionLog.getReporter()); |
| | | dimissionLog.setCreator(operatorId); |
| | | dimissionLog.setModifier(operatorId); |
| | | |
| | | dimissionLogService.save(dimissionLog); |
| | | } |
| | | return empBaseInfoMapper.closeEmpArchives(list, empDimissionLog.getDimissionType(), empDimissionLog.getDimissionDate(), empDimissionLog.getRemark(), operatorId)>0; |
| | | } |
| | | } |