From eb75ecc4eacb90f786ddf2e64c00547496345eeb Mon Sep 17 00:00:00 2001
From: 孔祥富 <kongxf@daryun.com>
Date: 星期日, 07 三月 2021 14:41:58 +0800
Subject: [PATCH] 提交
---
febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/service/impl/EmpBaseInfoServiceImpl.java | 189 ++++++++++++++++++++++++++++++++--------------
1 files changed, 130 insertions(+), 59 deletions(-)
diff --git a/febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/service/impl/EmpBaseInfoServiceImpl.java b/febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/service/impl/EmpBaseInfoServiceImpl.java
index 840a5e8..a4f034d 100644
--- a/febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/service/impl/EmpBaseInfoServiceImpl.java
+++ b/febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/service/impl/EmpBaseInfoServiceImpl.java
@@ -7,12 +7,16 @@
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;
import cc.mrbird.febs.server.hr.feign.IRemoteUserService;
+import cc.mrbird.febs.server.hr.mapper.EmpContractInfoMapper;
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;
@@ -45,6 +49,7 @@
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;
@@ -66,10 +71,10 @@
private final EmpBaseInfoMapper empBaseInfoMapper;
private final IEmpDimissionLogService dimissionLogService;
private final IEmpJobChangeService jobChangeService;
+ 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 String operatorId = Optional.of(FebsUtil.getUserId()).orElse("1");
@Override
public IPage<EmpBaseInfo> findEmpBaseInfos(QueryRequest request, EmpBaseInfo empBaseInfo) {
@@ -79,7 +84,7 @@
@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);
@@ -99,7 +104,7 @@
.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()))
@@ -232,8 +237,13 @@
@Override
public boolean verifyEmpNumb(EmpBaseInfo empBaseInfo) {
QueryWrapper<EmpBaseInfo> queryWrapper = new QueryWrapper<>();
- queryWrapper.lambda().eq(EmpBaseInfo::getEmpNumb, empBaseInfo.getEmpNumb()).ne(EmpBaseInfo::getDelFlag,1);
- if (this.count(queryWrapper)<=0) {
+ 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;
}
return true;
@@ -269,6 +279,7 @@
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();
@@ -284,9 +295,29 @@
dimissionLog.setModifier(operatorId);
dimissionLogService.save(dimissionLog);
}
- EmpBaseInfo empBaseInfo = this.getById(dimissionLog.getEmpId());
- //禁用账户
- iRemoteUserService.updateStatus(empBaseInfo.getCertificateNumb());
+
+ 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:
+ //解除合同
+
+ empContractInfoMapper.terminateContract(new ArrayList<>(Arrays.asList(empDimissionLog.getEmpIds().split(StringConstant.COMMA))), operatorId);
+ break;
+ case 2:
+ //禁用账户
+ iRemoteUserService.updateStatus(empDimissionLog.getCertificateNumb());
+ break;
+ case 3:
+ empContractInfoMapper.terminateContract(new ArrayList<>(Arrays.asList(empDimissionLog.getEmpIds().split(StringConstant.COMMA))), operatorId);
+ iRemoteUserService.updateStatus(empDimissionLog.getCertificateNumb());
+ break;
+ }
+ }
return empBaseInfoMapper.closeEmpArchives(list, empDimissionLog.getDimissionType(), empDimissionLog.getDimissionDate(), empDimissionLog.getRemark(), operatorId) > 0;
}
@@ -344,8 +375,15 @@
*/
@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) + 1, list.get(1).toString()));
+ continue;
+ }
EmpBaseInfo empBaseInfo = new EmpBaseInfo();
empBaseInfo.setEmpId(SequenceUtil.generateId(0L, ModuleCode.HR_EMPLOYEE));
empBaseInfo.setArchivesNumb(list.get(0).toString());
@@ -353,9 +391,12 @@
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) + 1, 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");
@@ -389,6 +430,7 @@
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);
}
@@ -740,137 +782,166 @@
}
/**
- *
* 检查是否是带条件查询
- *
+ * <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){
- 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());
- } else{
- queryWrapper.eq(EmpBaseInfo::getDelFlag, 0);
+ if (StringUtils.isNotBlank(empBaseInfo.getDelFlag().toString())) {
+ queryWrapper.eq("a.DelFlag", empBaseInfo.getDelFlag());
+ } else {
+ 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(","));
+ } else {
+ queryWrapper.in("a.EmpStatus", 0);
+ }
+ 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(this.checkQueryCondition(empBaseInfo)){
+ 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.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.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(","));
+ }
+ if (StringUtils.isNotBlank(empBaseInfo.getEmpType())) {
+ p.or().in("a.empType", empBaseInfo.getEmpType().split(","));
}
});
}
+ queryWrapper.in("c.dept_Id", remoteDeptService.userRightDepts().split(StringConstant.COMMA));
return queryWrapper;
}
@Override
public EmpBaseInfo addInEmpBaseInfo(EmpBaseInfo empBaseInfo) {
EmpBaseInfo dbEmpInfo = this.getEmpBaseInfo(empBaseInfo);
- if(dbEmpInfo==null){
+ if (dbEmpInfo == null) {
this.createEmpBaseInfo(empBaseInfo);
return null;
} else {
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;
+ }
+
+ }
}
--
Gitblit v1.8.0