diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/CustomerInfoMapper.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/CustomerInfoMapper.java index 24b986c3..2f32b5d8 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/CustomerInfoMapper.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/CustomerInfoMapper.java @@ -1,6 +1,7 @@ package com.ruoyi.sip.mapper; import com.ruoyi.sip.domain.CustomerInfo; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -63,4 +64,8 @@ public interface CustomerInfoMapper public int selectCountByCode(CustomerInfo customerInfo); int selectMaxByPrefix(String province); + + int selectCountByName(@Param("name") String name, + @Param("excludeId") Long excludeId); + } diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/CustomerInfoServiceImpl.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/CustomerInfoServiceImpl.java index 2b1dd790..f0621290 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/CustomerInfoServiceImpl.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/CustomerInfoServiceImpl.java @@ -79,6 +79,10 @@ public class CustomerInfoServiceImpl implements ICustomerInfoService if (i > 0) { throw new ServiceException("客户编码已存在"); } + i = customerInfoMapper.selectCountByName(customerInfo.getCustomerName(), null); + if (i > 0) { + throw new ServiceException("最终客户名称已存在"); + } return customerInfoMapper.insertCustomerInfo(customerInfo); } finally { lock.unlock(); @@ -147,6 +151,10 @@ public class CustomerInfoServiceImpl implements ICustomerInfoService if (count > 0) { throw new ServiceException("客户编码已存在"); } + count = customerInfoMapper.selectCountByName(customerInfo.getCustomerName(), customerInfo.getId()); + if (count > 0) { + throw new ServiceException("最终客户名称已存在"); + } projectInfoMapper.updateCustomerCodeByCode(oldCustomerInfo.getCustomerCode(), newCustomerCode); return customerInfoMapper.updateCustomerInfo(customerInfo); } finally { @@ -154,7 +162,10 @@ public class CustomerInfoServiceImpl implements ICustomerInfoService } } - + int count = customerInfoMapper.selectCountByName(customerInfo.getCustomerName(), customerInfo.getId()); + if (count > 0) { + throw new ServiceException("最终客户名称已存在"); + } return customerInfoMapper.updateCustomerInfo(customerInfo); } diff --git a/ruoyi-sip/src/main/resources/mapper/manage/CustomerInfoMapper.xml b/ruoyi-sip/src/main/resources/mapper/manage/CustomerInfoMapper.xml index 20246edf..79966b89 100644 --- a/ruoyi-sip/src/main/resources/mapper/manage/CustomerInfoMapper.xml +++ b/ruoyi-sip/src/main/resources/mapper/manage/CustomerInfoMapper.xml @@ -155,4 +155,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + \ No newline at end of file