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){ diff --git a/emis-biz/src/main/resources/mapper/EmisSettleSubBillMapper.xml b/emis-biz/src/main/resources/mapper/EmisSettleSubBillMapper.xml index bca1246b9..a6d7b309b 100644 --- a/emis-biz/src/main/resources/mapper/EmisSettleSubBillMapper.xml +++ b/emis-biz/src/main/resources/mapper/EmisSettleSubBillMapper.xml @@ -167,6 +167,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and not exists( select 1 from emis_waybill_problem_info ewpi where a.bill_code=ewpi.bill_code and ewpi.del_flag='0' and ewpi.`problem_type` in(173,170,151) ) + + and not exists( + select 1 from emis_waybill ew where a.bill_code=ew.bill_code and ew.bl_virtual='1' and ew.master_bill_code is not null and ew.master_bill_code != '' + ) and a.send_site_code = #{params.sendSiteCode} @@ -323,6 +327,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and not exists( select 1 from emis_waybill_problem_info ewpi where a.bill_code=ewpi.bill_code and ewpi.del_flag='0' and ewpi.`problem_type` in(173,170,151) ) + + and not exists( + select 1 from emis_waybill ew where a.bill_code=ew.bill_code and ew.bl_virtual='1' and ew.master_bill_code is not null and ew.master_bill_code != '' + ) and a.send_site_code = #{params.sendSiteCode}