fix:客户信息重名校验

dev_1.0.2
UNISINSIGHT\rdpnr_jiangpeng 2026-03-17 16:08:54 +08:00
parent 6b9263ca1b
commit 7bcc08ff0e
3 changed files with 25 additions and 1 deletions

View File

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

View File

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

View File

@ -155,4 +155,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</delete>
<select id="selectCountByName" resultType="java.lang.Integer">
select count(1) from customer_info
where customer_name = #{name} and status=0
<if test="excludeId != null">
and id != #{excludeId}
</if>
</select>
</mapper>