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); }