From 14c2d7fc17595c86e7fe70f2d25f93a7d2c0a635 Mon Sep 17 00:00:00 2001
From: 孔祥富 <kongxf@daryun.com>
Date: 星期日, 07 三月 2021 13:59:23 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/service/impl/EmpBaseInfoServiceImpl.java |   67 +++++++++++++++++++++++++--------
 1 files changed, 51 insertions(+), 16 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 25c29d7..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
@@ -14,6 +14,7 @@
 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;
@@ -48,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;
 
@@ -69,12 +71,10 @@
     private final EmpBaseInfoMapper empBaseInfoMapper;
     private final IEmpDimissionLogService dimissionLogService;
     private final IEmpJobChangeService jobChangeService;
-    private final IEmpContractInfoService empContractInfoService;
+    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");
+    private final String operatorId = Optional.of(FebsUtil.getUserId()).orElse("1");
 
     @Override
     public IPage<EmpBaseInfo> findEmpBaseInfos(QueryRequest request, EmpBaseInfo empBaseInfo) {
@@ -104,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()))
@@ -237,7 +237,12 @@
     @Override
     public boolean verifyEmpNumb(EmpBaseInfo empBaseInfo) {
         QueryWrapper<EmpBaseInfo> queryWrapper = new QueryWrapper<>();
-        queryWrapper.lambda().eq(EmpBaseInfo::getEmpNumb, empBaseInfo.getEmpNumb()).ne(EmpBaseInfo::getDelFlag, 1);
+        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;
         }
@@ -300,14 +305,15 @@
             switch (flag) {
                 case 1:
                     //解除合同
-                    empContractInfoService.terminateContract(empDimissionLog.getEmpIds(), operatorId);
+
+                    empContractInfoMapper.terminateContract(new ArrayList<>(Arrays.asList(empDimissionLog.getEmpIds().split(StringConstant.COMMA))), operatorId);
                     break;
                 case 2:
                     //禁用账户
                     iRemoteUserService.updateStatus(empDimissionLog.getCertificateNumb());
                     break;
                 case 3:
-                    empContractInfoService.terminateContract(empDimissionLog.getEmpIds(), operatorId);
+                    empContractInfoMapper.terminateContract(new ArrayList<>(Arrays.asList(empDimissionLog.getEmpIds().split(StringConstant.COMMA))), operatorId);
                     iRemoteUserService.updateStatus(empDimissionLog.getCertificateNumb());
                     break;
             }
@@ -369,13 +375,13 @@
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public void importEmpBaseInfo(List<List<Object>> listObject,List<String>  returnList) {
+    public void importEmpBaseInfo(List<List<Object>> listObject, List<String> returnList) {
         for (List<Object> list : listObject) {
-            if (list.size()==0){
+            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),list.get(1).toString()));
+            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();
@@ -387,7 +393,7 @@
             empBaseInfo.setDeptName(list.get(3).toString());
             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),list.get(3).toString()));
+                returnList.add(StrUtil.format("导入员工基本信息异常: 出现位置第{}行, 原因:{}部门不存在", listObject.indexOf(list) + 1, list.get(3).toString()));
                 continue;
             }
             empBaseInfo.setDeptId(dept.getDeptId());
@@ -826,7 +832,7 @@
     }
 
     private QueryWrapper<EmpBaseInfo> createQueryWrapper(EmpBaseInfo empBaseInfo) {
-    	QueryWrapper<EmpBaseInfo> queryWrapper = new QueryWrapper<>();
+        QueryWrapper<EmpBaseInfo> queryWrapper = new QueryWrapper<>();
         //记录的状态,0-正常 1-删除 2-暂存
         if (StringUtils.isNotBlank(empBaseInfo.getDelFlag().toString())) {
             queryWrapper.eq("a.DelFlag", empBaseInfo.getDelFlag());
@@ -838,6 +844,12 @@
             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)) {
@@ -855,10 +867,10 @@
                     p.or().like("a.CertificateNumb", empBaseInfo.getCertificateNumb());
                 }
                 if (StringUtils.isNotBlank(empBaseInfo.getEntryDateStr())) {
-                    p.or().between("a.EntryDate", 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("a.DimissionDate", 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("a.Sex", empBaseInfo.getSex().split(","));
@@ -893,6 +905,9 @@
                 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));
@@ -909,4 +924,24 @@
             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