From 6343cac51e460280c721c9db0238b62389146590 Mon Sep 17 00:00:00 2001
From: yz <yz_0812@outlook.com>
Date: 星期四, 04 三月 2021 00:56:46 +0800
Subject: [PATCH] 权限与导出

---
 febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/service/impl/EmpPhysicalExamServiceImpl.java |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/service/impl/EmpPhysicalExamServiceImpl.java b/febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/service/impl/EmpPhysicalExamServiceImpl.java
index fb1fe0d..ac4990a 100644
--- a/febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/service/impl/EmpPhysicalExamServiceImpl.java
+++ b/febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/service/impl/EmpPhysicalExamServiceImpl.java
@@ -12,6 +12,7 @@
 import cc.mrbird.febs.common.core.utils.CastUtil;
 import cc.mrbird.febs.common.redis.service.RedisService;
 import cc.mrbird.febs.server.hr.entity.EmpBaseInfo;
+import cn.hutool.core.util.StrUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
@@ -169,14 +170,20 @@
     @Transactional(rollbackFor = Exception.class)
 	public void importEmpPhysicalExam(List<List<Object>> listObject,List<String>  returnList) {
 		for (List<Object> list : listObject) {
+            if (list.size()==0){
+                continue;
+            }
 			EmpPhysicalExam physicalExam = new EmpPhysicalExam();
 			physicalExam.setPhysicalExamId(SequenceUtil.generateId(0L, ModuleCode.HR_EMPLOYEE));
 			physicalExam.setEmpNumb(list.get(0).toString());
 			physicalExam.setDeptName(list.get(1).toString());
 			List<Dept> depts = CastUtil.castList(redisService.get("depts"), Dept.class);
-			Long deptId = depts.stream().filter(d -> d.getDeptName().equals(list.get(1).toString())).findFirst().get()
-					.getDeptId();
-			physicalExam.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),list.get(3).toString()));
+                continue;
+            }
+			physicalExam.setDeptId(dept.getDeptId());
 			physicalExam.setJobName(list.get(2).toString());
 			physicalExam.setEmpName(list.get(3).toString());
 			physicalExam.setCertificateNumb(list.get(4).toString());

--
Gitblit v1.8.0