| | |
| | | package cc.mrbird.febs.server.hr.service.impl; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.*; |
| | | |
| | | import cc.mrbird.febs.server.hr.entity.EmpDimissionLog; |
| | | import cc.mrbird.febs.server.hr.entity.EmpJobChange; |
| | | import cc.mrbird.febs.server.hr.service.IEmpDimissionLogService; |
| | | import cc.mrbird.febs.server.hr.service.IEmpJobChangeService; |
| | | 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 IEmpJobChangeService jobChangeService; |
| | | 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); |
| | |
| | | |
| | | 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; |
| | | } |
| | | /** |
| | | * |
| | | * 员工岗位变更 |
| | | * |
| | | * date 2021-02-18 20:32 |
| | | * @author: luoyibo |
| | | * @param empJobChange 1 |
| | | * @return boolean |
| | | */ |
| | | @Override |
| | | public boolean changeEmpJob(EmpJobChange empJobChange) { |
| | | String[] str = empJobChange.getEmpIds().split(","); |
| | | List<String> list = new ArrayList<>(Arrays.asList(str)); |
| | | String[] strName = empJobChange.getEmpNames().split(","); |
| | | String[] strDeptName = empJobChange.getOldDeptNames().split(","); |
| | | String[] strJobName = empJobChange.getOldJobNames().split(","); |
| | | |
| | | EmpJobChange saveChange = null; |
| | | |
| | | for (int i = 0,k=str.length; i <k ; i++) { |
| | | saveChange = new EmpJobChange(); |
| | | saveChange.setJobChangeId(SequenceUtil.generateId(0L, ModuleCode.HR_EMPLOYEE)); |
| | | saveChange.setEmpId(Long.parseLong(str[i])); |
| | | saveChange.setEmpName(strName[i]); |
| | | saveChange.setOldDeptName(strDeptName[i]); |
| | | saveChange.setOldJobName(strJobName[i]); |
| | | saveChange.setNewDeptName(empJobChange.getNewDeptName()); |
| | | saveChange.setNewJobName(empJobChange.getNewJobName()); |
| | | saveChange.setChangeType(empJobChange.getChangeType()); |
| | | saveChange.setChangeDate(empJobChange.getChangeDate()); |
| | | saveChange.setChangeReason(empJobChange.getChangeReason()); |
| | | saveChange.setCreator(operatorId); |
| | | saveChange.setModifier(operatorId); |
| | | |
| | | jobChangeService.save(saveChange); |
| | | |
| | | } |
| | | |
| | | Map<String, Object> mapParams = new HashMap<>(); |
| | | mapParams.put("deptId", empJobChange.getDeptId()); |
| | | mapParams.put("deptName", empJobChange.getNewDeptName()); |
| | | mapParams.put("jobId", empJobChange.getJobId()); |
| | | mapParams.put("jobName", empJobChange.getNewJobName()); |
| | | mapParams.put("operatorId", operatorId); |
| | | return empBaseInfoMapper.changeEmpJob(list,mapParams)>0; |
| | | } |
| | | |
| | | /** |
| | | * 导入员工 |
| | | * @param listObject |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void importEmpBaseInfo(List<List<Object>> listObject) { |
| | | for (List<Object> list : listObject) { |
| | | EmpBaseInfo empBaseInfo = new EmpBaseInfo(); |
| | | empBaseInfo.setEmpId(SequenceUtil.generateId(0L, ModuleCode.HR_EMPLOYEE)); |
| | | empBaseInfo.setEmpNumb(list.get(0).toString()); |
| | | List<Dept> depts = CastUtil.castList(redisService.get("depts"), Dept.class); |
| | | empBaseInfo.setDeptName(list.get(1).toString()); |
| | | Long deptId=depts.stream().filter(d -> d.getDeptName().equals(list.get(1).toString())).findFirst().get().getDeptId(); |
| | | empBaseInfo.setDeptId(deptId); |
| | | empBaseInfo.setJobName(list.get(2).toString()); |
| | | empBaseInfo.setEmpName(list.get(3).toString()); |
| | | empBaseInfo.setCertificateNumb(list.get(4).toString()); |
| | | empBaseInfo.setSex("男".equals(list.get(5).toString())?"1":"0"); |
| | | if (StringUtils.isNotBlank(list.get(6).toString())) { |
| | | empBaseInfo.setAge(Integer.valueOf(list.get(6).toString())); |
| | | } |
| | | empBaseInfo.setEducation(list.get(7).toString()); |
| | | empBaseInfo.setNativePlace(list.get(8).toString()); |
| | | empBaseInfo.setTelePhone(list.get(9).toString()); |
| | | if (StringUtils.isNotBlank(list.get(10).toString())) { |
| | | empBaseInfo.setEntryDate(DateUtil.parseDate(list.get(10).toString())); |
| | | } |
| | | empBaseInfo.setEmpStatus("0"); |
| | | this.save(empBaseInfo); |
| | | } |
| | | |
| | | } |
| | | } |