feat(sip): 增加编码唯一性校验功能

- 在 AgentInfo、CustomerInfo、PartnerInfo 和 ProductInfo 表中添加编码唯一性校验方法
- 在对应的 Mapper 中添加 selectCountByCode 方法用于查询重复编码数量- 在 ServiceImpl 中实现插入和更新时的编码唯一性检查逻辑
- 修改订单编辑页面,将代表处和客户名称的字段改为 orderAgentName 和 orderPartnerName
master
chenhao 2025-05-19 11:03:54 +08:00
parent ce54a3df8b
commit 37666b4471
13 changed files with 66 additions and 3 deletions

View File

@ -61,8 +61,8 @@
<label class="col-sm-4 control-label is-required">代表处:</label>
<div class="col-sm-8">
<div class="input-group">
<input name="orderDept" type="hidden" th:field="*{orderDept}" id="treeId"/>
<input class="form-control" type="text" name="orderDeptName" onclick="selectAgent()" id="treeName" th:field="*{orderDeptName}" required>
<input name="orderAgentCode" type="hidden" th:field="*{orderAgentCode}" id="treeId"/>
<input class="form-control" type="text" name="orderAgentName" onclick="selectAgent()" id="treeName" th:field="*{orderAgentName}" required>
<span class="input-group-addon"><i class="fa fa-search"></i></span>
</div>
</div>
@ -74,7 +74,7 @@
<div class="col-sm-8">
<div class="input-group">
<input name="orderPartnerCode" type="hidden" th:field="*{orderPartnerCode}" id="treeId1">
<input class="form-control" type="text" name="orderDeptName" onclick="selectPartner()" id="treeName1" th:field="*{partnerDeptName}" required>
<input class="form-control" type="text" name="orderPartnerName" onclick="selectPartner()" id="treeName1" th:field="*{orderPartnerName}" required>
<span class="input-group-addon"><i class="fa fa-search"></i></span>
</div>
</div>

View File

@ -58,4 +58,5 @@ public interface AgentInfoMapper
* @return
*/
public int deleteAgentInfoByIds(String[] ids);
public int selectCountByCode(AgentInfo agentInfo);
}

View File

@ -60,4 +60,5 @@ public interface CustomerInfoMapper
* @return
*/
public int deleteCustomerInfoByIds(String[] ids);
public int selectCountByCode(CustomerInfo customerInfo);
}

View File

@ -58,4 +58,6 @@ public interface PartnerInfoMapper
* @return
*/
public int deletePartnerInfoByIds(String[] ids);
public int selectCountByCode(PartnerInfo partnerInfo);
}

View File

@ -61,6 +61,7 @@ public interface ProductInfoMapper
* @return
*/
public int deleteProductInfoByIds(String[] ids);
public int selectCountByCode(ProductInfo productInfo);

View File

@ -1,6 +1,8 @@
package com.ruoyi.sip.service.impl;
import java.util.List;
import com.ruoyi.common.exception.ServiceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.sip.mapper.AgentInfoMapper;
@ -53,6 +55,11 @@ public class AgentInfoServiceImpl implements IAgentInfoService
@Override
public int insertAgentInfo(AgentInfo agentInfo)
{
int i = agentInfoMapper.selectCountByCode(agentInfo);
if (i>0){
throw new ServiceException("该编码已存在");
}
return agentInfoMapper.insertAgentInfo(agentInfo);
}
@ -65,6 +72,10 @@ public class AgentInfoServiceImpl implements IAgentInfoService
@Override
public int updateAgentInfo(AgentInfo agentInfo)
{
int i = agentInfoMapper.selectCountByCode(agentInfo);
if (i>0){
throw new ServiceException("该编码已存在");
}
return agentInfoMapper.updateAgentInfo(agentInfo);
}

View File

@ -2,6 +2,7 @@ package com.ruoyi.sip.service.impl;
import java.util.List;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.sip.domain.CustomerInfo;
import com.ruoyi.sip.mapper.CustomerInfoMapper;
import com.ruoyi.sip.service.ICustomerInfoService;
@ -55,6 +56,10 @@ public class CustomerInfoServiceImpl implements ICustomerInfoService
@Override
public int insertCustomerInfo(CustomerInfo customerInfo)
{
int i = customerInfoMapper.selectCountByCode(customerInfo);
if (i > 0){
throw new ServiceException("客户编码已存在");
}
return customerInfoMapper.insertCustomerInfo(customerInfo);
}
@ -67,6 +72,10 @@ public class CustomerInfoServiceImpl implements ICustomerInfoService
@Override
public int updateCustomerInfo(CustomerInfo customerInfo)
{
int i = customerInfoMapper.selectCountByCode(customerInfo);
if (i > 0){
throw new ServiceException("客户编码已存在");
}
return customerInfoMapper.updateCustomerInfo(customerInfo);
}

View File

@ -1,6 +1,8 @@
package com.ruoyi.sip.service.impl;
import java.util.List;
import com.ruoyi.common.exception.ServiceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.sip.mapper.PartnerInfoMapper;
@ -53,6 +55,10 @@ public class PartnerInfoServiceImpl implements IPartnerInfoService
@Override
public int insertPartnerInfo(PartnerInfo partnerInfo)
{
int i = partnerInfoMapper.selectCountByCode(partnerInfo);
if (i>0){
throw new ServiceException("该编码已存在");
}
return partnerInfoMapper.insertPartnerInfo(partnerInfo);
}
@ -65,6 +71,10 @@ public class PartnerInfoServiceImpl implements IPartnerInfoService
@Override
public int updatePartnerInfo(PartnerInfo partnerInfo)
{
int i = partnerInfoMapper.selectCountByCode(partnerInfo);
if (i>0){
throw new ServiceException("该编码已存在");
}
return partnerInfoMapper.updatePartnerInfo(partnerInfo);
}

View File

@ -2,6 +2,7 @@ package com.ruoyi.sip.service.impl;
import java.util.List;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.sip.domain.MaintenanceRecordsDto;
import org.springframework.beans.factory.annotation.Autowired;
@ -56,6 +57,10 @@ public class ProductInfoServiceImpl implements IProductInfoService
@Override
public int insertProductInfo(ProductInfo productInfo)
{
int i = productInfoMapper.selectCountByCode(productInfo);
if (i>0){
throw new ServiceException("BOM编码已存在");
}
return productInfoMapper.insertProductInfo(productInfo);
}
@ -68,6 +73,10 @@ public class ProductInfoServiceImpl implements IProductInfoService
@Override
public int updateProductInfo(ProductInfo productInfo)
{
int i = productInfoMapper.selectCountByCode(productInfo);
if (i>0){
throw new ServiceException("BOM编码已存在");
}
return productInfoMapper.updateProductInfo(productInfo);
}

View File

@ -61,6 +61,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectCustomerInfoVo"/>
where id = #{id}
</select>
<select id="selectCountByCode" resultType="java.lang.Integer">
select count(1) from customer_info where customer_code = #{customerCode}
<if test="id != null">and id != #{id}</if>
</select>
<insert id="insertCustomerInfo" parameterType="CustomerInfo">
insert into customer_info

View File

@ -42,6 +42,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectAgentInfoVo"/>
where id = #{id}
</select>
<select id="selectCountByCode" resultType="java.lang.Integer">
select count(1) from agent_info
where agent_code=#{agentCode}
<if test="id != null">and id!=#{id}</if>
</select>
<insert id="insertAgentInfo" parameterType="AgentInfo" useGeneratedKeys="true" keyProperty="id">
insert into agent_info

View File

@ -37,6 +37,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectPartnerInfoVo"/>
where id = #{id}
</select>
<select id="selectCountByCode" resultType="java.lang.Integer">
select count(1) from partner_info where partner_code = #{partnerCode}
<if test="id != null">and id != #{id}</if>
</select>
<insert id="insertPartnerInfo" parameterType="PartnerInfo" useGeneratedKeys="true" keyProperty="id">
insert into partner_info

View File

@ -68,6 +68,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
</where>
</select>
<select id="selectCountByCode" resultType="java.lang.Integer">
select count(1) from product_info where product_code=#{productCode}
<if test="id!=null ">
and id!=#{id}
</if>
</select>
<insert id="insertProductInfo" parameterType="ProductInfo" useGeneratedKeys="true" keyProperty="id">