diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisCustomerAddressServiceImpl.java b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisCustomerAddressServiceImpl.java index d695eaeb3..e58fdbee4 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisCustomerAddressServiceImpl.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisCustomerAddressServiceImpl.java @@ -16,6 +16,7 @@ import cn.hutool.core.collection.CollectionUtil; import com.xdadan.erp.emis.domain.enumtype.EmisBizErrorType; import com.xdadan.erp.emis.domain.exception.EmisBizError; import com.xdadan.erp.emis.service.EmisBaseService; +import jodd.util.StringUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.xdadan.erp.emis.domain.EmisCustomerAddress; @@ -71,15 +72,7 @@ public class EmisCustomerAddressServiceImpl extends EmisBaseService implements I emisCustomerAddress.setUseSiteCode(getCurrentUser().getOwnerSiteCode()); emisCustomerAddress.setUseSite(getCurrentUser().getOwnerSiteName()); - // 验证企业名称格式 - if (!validateEnterpriseName(emisCustomerAddress.getEnterpriseName())) { - throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "企业名称不能包含空格、回车、@、#、$、%、&、数字等特殊符号"); - } - - // 验证企业税号格式 - if (!validateEnterpriseTaxId(emisCustomerAddress.getEnterpriseTaxId())) { - throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "企业税号必须为8-18位数字和大写字母组成,不能包含汉字、空格等特殊符号"); - } + checkEnterprise(emisCustomerAddress); List emisCustomerAddressList = emisCustomerAddressMapper.checkAndQuery(emisCustomerAddress); if (CollectionUtil.isEmpty(emisCustomerAddressList)) { // 不重复的情况则 创建地址 @@ -100,16 +93,25 @@ public class EmisCustomerAddressServiceImpl extends EmisBaseService implements I // emisCustomerAddress.setUseSiteCode(getCurrentUser().getOwnerSiteCode()); // emisCustomerAddress.setUseSite(getCurrentUser().getOwnerSiteName()); + checkEnterprise(emisCustomerAddress); + + return emisCustomerAddressMapper.updateEmisCustomerAddress(emisCustomerAddress); + } + + private void checkEnterprise(EmisCustomerAddress emisCustomerAddress) throws EmisBizError { // 验证企业名称格式 - if (!validateEnterpriseName(emisCustomerAddress.getEnterpriseName())) { - throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "企业名称不能包含空格、回车、@、#、$、%、&、数字等特殊符号"); + if (StringUtil.isNotBlank(emisCustomerAddress.getEnterpriseName())) { + if (!validateEnterpriseName(emisCustomerAddress.getEnterpriseName())) { + throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "企业名称不能包含空格、回车、@、#、$、%、&、数字等特殊符号"); + } } // 验证企业税号格式 - if (!validateEnterpriseTaxId(emisCustomerAddress.getEnterpriseTaxId())) { - throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "企业税号必须为8-18位数字和大写字母组成,不能包含汉字、空格等特殊符号"); + if (StringUtil.isNotBlank(emisCustomerAddress.getEnterpriseTaxId())) { + if (!validateEnterpriseTaxId(emisCustomerAddress.getEnterpriseTaxId())) { + throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "企业税号必须为8-18位数字和大写字母组成,不能包含汉字、空格等特殊符号"); + } } - return emisCustomerAddressMapper.updateEmisCustomerAddress(emisCustomerAddress); } /**