diff --git a/dq-financial-crms/src/main/java/com/daqing/financial/crms/dao/CustomerDao.java b/dq-financial-crms/src/main/java/com/daqing/financial/crms/dao/CustomerDao.java index 2e41e8cd..631968ba 100644 --- a/dq-financial-crms/src/main/java/com/daqing/financial/crms/dao/CustomerDao.java +++ b/dq-financial-crms/src/main/java/com/daqing/financial/crms/dao/CustomerDao.java @@ -39,4 +39,8 @@ public interface CustomerDao extends BaseMapper { List queryCompanyCodeAndName(int type); String getCodeByType(Integer type); + + List listCustomerName(Integer type); + + String getNameByCustomerId(Long CustomerId); } diff --git a/dq-financial-crms/src/main/java/com/daqing/financial/crms/service/impl/CustomerServiceImpl.java b/dq-financial-crms/src/main/java/com/daqing/financial/crms/service/impl/CustomerServiceImpl.java index 0ee98a22..38dc57a4 100644 --- a/dq-financial-crms/src/main/java/com/daqing/financial/crms/service/impl/CustomerServiceImpl.java +++ b/dq-financial-crms/src/main/java/com/daqing/financial/crms/service/impl/CustomerServiceImpl.java @@ -215,11 +215,20 @@ public class CustomerServiceImpl extends ServiceImpl names = customerDao.listCustomerName(0); // 个人类型客户名称 + for (String name : names) { + if (customerPersonalTOI.getName().equals(name)) { + ExceptionCast.cast(CrmsCode.CUSTOMER_NAME_REPETITION); + } + } + } CustomerEntity customerEntity = new CustomerEntity(); PersonalCustomerEntity personalCustomerEntity = new PersonalCustomerEntity(); BeanUtils.copyProperties(customerPersonalTOI, customerEntity); BeanUtils.copyProperties(customerPersonalTOI, personalCustomerEntity); - //TODO 设置客户编号 + // 设置客户编号 String code = customerDao.getCodeByType(CrmsConstant.CustomerType.PERSONAL_CUSTOMER.getType()); if (code == null || code.length() == 0) { code = PromptSuccess.PERSONAL_START_CODE; @@ -263,12 +272,25 @@ public class CustomerServiceImpl extends ServiceImpl names = customerDao.listCustomerName(0); + for (String name : names) { + if (customerPersonalTOU.getName().equals(name)) { + ExceptionCast.cast(CrmsCode.CUSTOMER_NAME_REPETITION); + } + } + } + } CustomerEntity customerEntity = new CustomerEntity(); PersonalCustomerEntity personalCustomerEntity = new PersonalCustomerEntity(); BeanUtils.copyProperties(customerPersonalTOU, customerEntity); @@ -568,6 +590,15 @@ public class CustomerServiceImpl extends ServiceImpl names = customerDao.listCustomerName(1); // 企业类型客户名称 + for (String name : names) { + if (companyCustomerReq.getName().equals(name)) { + ExceptionCast.cast(CrmsCode.CUSTOMER_NAME_REPETITION); + } + } + } CustomerEntity customerEntity = new CustomerEntity(); CompanyCustomerEntity companyCustomerEntity = new CompanyCustomerEntity(); BeanUtils.copyProperties(companyCustomerReq, customerEntity); @@ -612,6 +643,18 @@ public class CustomerServiceImpl extends ServiceImpl names = customerDao.listCustomerName(1); + for (String name : names) { + if (companyCustomerReq.getName().equals(name)) { + ExceptionCast.cast(CrmsCode.CUSTOMER_NAME_REPETITION); + } + } + } + } CustomerEntity customerEntity = new CustomerEntity(); CompanyCustomerEntity companyCustomerEntity = new CompanyCustomerEntity(); BeanUtils.copyProperties(companyCustomerReq, customerEntity); diff --git a/dq-financial-crms/src/main/resources/mapper/crms/CustomerDao.xml b/dq-financial-crms/src/main/resources/mapper/crms/CustomerDao.xml index a0ccbe54..8f147d8f 100644 --- a/dq-financial-crms/src/main/resources/mapper/crms/CustomerDao.xml +++ b/dq-financial-crms/src/main/resources/mapper/crms/CustomerDao.xml @@ -100,4 +100,14 @@ + + + + + + \ No newline at end of file diff --git a/dq-framework-common/src/main/java/com/daqing/framework/model/response/ResponseResult.java b/dq-framework-common/src/main/java/com/daqing/framework/model/response/ResponseResult.java index b04b8237..dee2b60c 100644 --- a/dq-framework-common/src/main/java/com/daqing/framework/model/response/ResponseResult.java +++ b/dq-framework-common/src/main/java/com/daqing/framework/model/response/ResponseResult.java @@ -57,7 +57,7 @@ public class ResponseResult { } public static ResponseResult FAIL(Object t) { - return new ResponseResult<>(false, 99999, t, "操作失败,请检查文件或者数据格式是否正确!"); + return new ResponseResult<>(false, 99999, t, "操作失败,请检查客户名称是否已存在或者文件和数据格式是否正确!"); } public ResponseResult SUCCESS_DATA(T t){ diff --git a/dq-framework-model/src/main/java/com/daqing/framework/domain/crms/response/CrmsCode.java b/dq-framework-model/src/main/java/com/daqing/framework/domain/crms/response/CrmsCode.java index 9e91ff7e..318d16d5 100644 --- a/dq-framework-model/src/main/java/com/daqing/framework/domain/crms/response/CrmsCode.java +++ b/dq-framework-model/src/main/java/com/daqing/framework/domain/crms/response/CrmsCode.java @@ -19,7 +19,8 @@ public enum CrmsCode implements ResultCode { CUSTOMER_EXPORT_EXSIT(false,20002,"导出数据失败,请稍后再试!"), CUSTOMER_EXPORTTEMPLATE_EXSIT(false,20003,"导出excel模板失败,请稍后再试!"), NOT_NULL(false,20004,"上传的文件不能为空"), - CUSTOMER_IS_NULL(false,20005,"导入数据失败,当前员工不存在!"); + CUSTOMER_IS_NULL(false,20005,"导入数据失败,当前员工不存在!"), + CUSTOMER_NAME_REPETITION(false, 20006, "当前客户名称已存在!"); /**