From 8a2f817bc1a489f873e048d36e24f355bdb55756 Mon Sep 17 00:00:00 2001
From: yz_08 <yz_0812@outlook.com>
Date: 星期五, 05 三月 2021 15:44:05 +0800
Subject: [PATCH] 修改bug
---
febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/service/impl/EmpBaseInfoServiceImpl.java | 194 +++++++++++++++++++++++++++++++++++-------------
1 files changed, 141 insertions(+), 53 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 3cdd4fc..ec3c1e4 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,11 +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;
@@ -44,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;
@@ -61,11 +67,13 @@
@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 EmpContractInfoMapper empContractInfoMapper;
private final FebsServerHrProperties properties;
+ private final IRemoteDeptService remoteDeptService;
private final String operatorId = Optional.ofNullable(FebsUtil.getCurrentUser())
.map(u -> u.getUserId().toString())
.orElse("1");
@@ -78,13 +86,15 @@
@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);
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()))
@@ -229,12 +239,16 @@
@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 (empBaseInfo.getEmpId()!=null) {
+ queryWrapper.lambda().ne(EmpBaseInfo::getEmpId, empBaseInfo.getEmpId());
+ }
+
+ if (this.count(queryWrapper) <= 0) {
return false;
}
- return !empBaseInfo.getEmpNumb().equals(tempEmpBaseInfo.getEmpNumb());
+ return true;
}
@Override
@@ -267,6 +281,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();
@@ -280,8 +295,30 @@
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:
+ //解除合同
+
+ 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;
}
@@ -340,8 +377,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());
@@ -349,9 +393,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");
@@ -385,6 +432,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);
}
@@ -736,120 +784,160 @@
}
/**
- *
* 检查是否是带条件查询
- *
+ * <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(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.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("a.HandbookStatus", empBaseInfo.getHandbookStatus().split(","));
+ }
+ if (StringUtils.isNotBlank(empBaseInfo.getEmpCardStatus())) {
+ 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) {
+ 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