From 75a464ed766bba8ada11d86184968d9373dac704 Mon Sep 17 00:00:00 2001 From: aike <17730485278@139.com> Date: Mon, 27 Oct 2025 14:50:43 +0800 Subject: [PATCH] =?UTF-8?q?demand:=20=20=20=20tms/app-=E8=BF=90=E5=8D=95?= =?UTF-8?q?=E5=BD=95=E5=85=A5=E3=80=81=E8=BF=90=E5=8D=95=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E5=BD=95=E5=85=A5-=E8=BF=90=E5=8D=95=E5=8F=B7=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=A0=A1=E9=AA=8C=EF=BC=8C=E4=BB=85=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=AD=97=E6=AF=8D+=E6=95=B0=E5=AD=97+=E2=80=9C-=E2=80=9D?= =?UTF-8?q?=E6=A8=AA=E6=9D=A0=E7=9A=84=E7=BB=84=E5=90=88=20committer:=20he?= =?UTF-8?q?yu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/EmisWaybillServiceImpl.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisWaybillServiceImpl.java b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisWaybillServiceImpl.java index b3e10bfa8..daf0165c4 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisWaybillServiceImpl.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisWaybillServiceImpl.java @@ -3163,6 +3163,34 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb } + /** + * 校验运单号格式 + * 只允许包含数字、字母、"-"横杠三种类型 + * 横杠只允许在中间,不能在两端,且不能连续有多个横杠 + * @param billCode 运单号 + * @throws EmisBizError 格式不符合要求时抛出异常 + */ + private void validateBillCodeFormat(String billCode) throws EmisBizError { + if (StringUtils.isEmpty(billCode)) { + throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "运单号不能为空"); + } + + // 检查是否只包含数字、字母、横杠 + if (!billCode.matches("^[0-9a-zA-Z\\-]+$")) { + throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "运单号只能包含数字、字母和横杠"); + } + + // 检查横杠是否在两端 + if (billCode.startsWith("-") || billCode.endsWith("-")) { + throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "运单号横杠不能在两端"); + } + + // 检查是否有连续的横杠 + if (billCode.contains("--")) { + throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "运单号不能有连续的横杠"); + } + } + /** * 新开单 * @param emisWaybillSave @@ -3172,6 +3200,9 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb // 当寄件国家为0095或0855时,去除billCode和billCodeSub中的第一个T // modifyBillCode(emisWaybillSave); + // 校验运单号格式 + validateBillCodeFormat(emisWaybillSave.getBillCode()); + // 获取运单号,判断是不是子单已存在 boolean isExists = checkWaybillIsExists(emisWaybillSave.getBillCode()); if(isExists){