From b77e7a737ce59da48004bf00a541535f1f2260b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Wed, 19 Jul 2023 09:58:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=96=E9=83=A8=E4=BA=BA=E5=91=98=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E4=B8=8D=E5=8F=AF=E9=87=8D=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ExtEmpServiceImpl.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/com/engine/salary/service/impl/ExtEmpServiceImpl.java b/src/com/engine/salary/service/impl/ExtEmpServiceImpl.java index 8db902160..8936dfd1e 100644 --- a/src/com/engine/salary/service/impl/ExtEmpServiceImpl.java +++ b/src/com/engine/salary/service/impl/ExtEmpServiceImpl.java @@ -9,6 +9,7 @@ import com.engine.salary.entity.extemp.po.ExtEmpPO; import com.engine.salary.entity.hrm.DeptInfo; import com.engine.salary.entity.hrm.SubCompanyInfo; import com.engine.salary.entity.salarysob.param.SalarySobRangeEmpQueryParam; +import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.mapper.extemp.ExternalEmployeeMapper; import com.engine.salary.service.ExtEmpService; import com.engine.salary.service.SalaryEmployeeService; @@ -18,6 +19,7 @@ import com.engine.salary.util.page.SalaryPageUtil; import com.google.common.collect.Lists; import dm.jdbc.util.IdGenerator; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import weaver.hrm.User; @@ -58,6 +60,12 @@ public class ExtEmpServiceImpl extends Service implements ExtEmpService { @Override public void save(ExtEmpSaveParam param) { + + List extEmpPOS = getExternalEmployeeMapper().listSome(ExtEmpPO.builder().username(param.getUsername()).build()); + if (CollectionUtils.isNotEmpty(extEmpPOS)) { + throw new SalaryRunTimeException("姓名已存在!"); + } + ExtEmpPO po = new ExtEmpPO(); BeanUtils.copyProperties(param, po); @@ -75,6 +83,15 @@ public class ExtEmpServiceImpl extends Service implements ExtEmpService { @Override public void update(ExtEmpSaveParam param) { + + ExtEmpPO oldPO = getExternalEmployeeMapper().getById(param.getId()); + if (!StringUtils.equals(oldPO.getUsername(), param.getUsername())) { + List extEmpPOS = getExternalEmployeeMapper().listSome(ExtEmpPO.builder().username(param.getUsername()).build()); + if (CollectionUtils.isNotEmpty(extEmpPOS)) { + throw new SalaryRunTimeException("姓名已存在!"); + } + } + ExtEmpPO po = new ExtEmpPO(); BeanUtils.copyProperties(param, po); @@ -105,7 +122,7 @@ public class ExtEmpServiceImpl extends Service implements ExtEmpService { } List extEmpPOS = new ArrayList<>(); List> partition = Lists.partition(ids, 500); - partition.forEach(list ->extEmpPOS.addAll(getExternalEmployeeMapper().listSome(ExtEmpPO.builder().ids(list).build())) ); + partition.forEach(list -> extEmpPOS.addAll(getExternalEmployeeMapper().listSome(ExtEmpPO.builder().ids(list).build()))); return coverList(extEmpPOS); }