From d10d0faecd0d7a4818fa786c8feb9fb437d3cde1 Mon Sep 17 00:00:00 2001 From: aike <17730485278@139.com> Date: Tue, 12 Aug 2025 20:05:42 +0800 Subject: [PATCH] =?UTF-8?q?demand:=20TMS=E7=B3=BB=E7=BB=9F=20-=20=E8=BF=90?= =?UTF-8?q?=E8=BE=93=E7=AE=A1=E7=90=86=20-=20=E8=B4=A7=E7=89=A9=E7=BB=84?= =?UTF-8?q?=E6=89=B9=E6=AC=A1=E5=8E=86=E5=8F=B2=E6=95=B0=E6=8D=AE=E6=9C=89?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=8C=E2=80=9C=E6=89=B9=E6=AC=A1=E5=8F=B7?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E4=BC=9A=E5=AF=BC=E8=87=B4=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E4=BB=B6=E6=95=B0=E3=80=81=E9=87=8D=E9=87=8F=E3=80=81=E4=BD=93?= =?UTF-8?q?=E7=A7=AF=E4=B8=8D=E5=87=86=E7=A1=AE=E2=80=9D-=E9=80=82?= =?UTF-8?q?=E5=BA=94=E9=94=99=E8=AF=AF=E6=95=B0=E6=8D=AE=E5=81=9A=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E6=80=A7=E4=BF=AE=E5=A4=8D=20TMS=E7=B3=BB=E7=BB=9F=20?= =?UTF-8?q?-=20=E8=BF=90=E8=BE=93=E7=AE=A1=E7=90=86=20-=20=E8=B4=A7?= =?UTF-8?q?=E7=89=A9=E7=BB=84=E6=89=B9=E6=AC=A1-=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E6=89=B9=E6=AC=A1=E6=97=B6=E9=92=88=E5=AF=B9=E6=89=B9=E6=AC=A1?= =?UTF-8?q?=E5=8F=B7=E5=81=9A=E9=87=8D=E5=A4=8D=E6=80=A7=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=EF=BC=8C=E9=87=8D=E5=A4=8D=E6=89=B9=E6=AC=A1=E5=8F=B7=E4=B8=8D?= =?UTF-8?q?=E5=85=81=E8=AE=B8=E5=BD=95=E5=85=A5=20TMS=E7=B3=BB=E7=BB=9F=20?= =?UTF-8?q?-=20=E8=BF=90=E8=BE=93=E7=AE=A1=E7=90=86=20-=20=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E8=B4=A7=E7=89=A9=E7=BB=84=E6=89=B9=E6=AC=A1=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=92=88=E5=AF=B9=E5=8E=86=E5=8F=B2=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98=E5=81=9A=E9=80=82=E5=BA=94?= =?UTF-8?q?=E6=80=A7=E8=B0=83=E6=95=B4=20=E8=B4=A7=E7=89=A9=E7=BB=84?= =?UTF-8?q?=E6=89=B9=E6=AC=A1=E8=AF=A6=E6=83=85=E8=A1=A8=E5=8D=95=E4=B8=AA?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E3=80=81=E6=89=B9=E9=87=8F=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E8=BD=AF=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit committer: heyu --- .../impl/EmisTmsSiteBatchDtlServiceImpl.java | 16 ++++++- .../impl/EmisTmsSiteBatchServiceImpl.java | 15 +++++++ .../mapper/EmisTmsSiteBatchDtlMapper.xml | 45 +++++++++++-------- .../mapper/EmisTmsSiteBatchMapper.xml | 13 +++--- 4 files changed, 63 insertions(+), 26 deletions(-) diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisTmsSiteBatchDtlServiceImpl.java b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisTmsSiteBatchDtlServiceImpl.java index 7e7c8ce4f..08bb15d76 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisTmsSiteBatchDtlServiceImpl.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisTmsSiteBatchDtlServiceImpl.java @@ -74,7 +74,21 @@ public class EmisTmsSiteBatchDtlServiceImpl implements IEmisTmsSiteBatchDtlServi */ @Override public List selectEmisTmsSiteBatchDtlList(EmisTmsSiteBatchDtl emisTmsSiteBatchDtl) { - return emisTmsSiteBatchDtlMapper.selectEmisTmsSiteBatchDtlList(emisTmsSiteBatchDtl); + List list = emisTmsSiteBatchDtlMapper.selectEmisTmsSiteBatchDtlList(emisTmsSiteBatchDtl); + + // 如果根据batchNo查询,需要对结果按运单号去重 + if (StringUtils.isNotBlank(emisTmsSiteBatchDtl.getBatchNo()) && CollectionUtil.isNotEmpty(list)) { + // 使用LinkedHashMap保持顺序,按运单号去重,保留第一条记录 + Map uniqueMap = new LinkedHashMap<>(); + for (EmisTmsSiteBatchDtl item : list) { + if (StringUtils.isNotBlank(item.getBillCode())) { + uniqueMap.putIfAbsent(item.getBillCode(), item); + } + } + list = new ArrayList<>(uniqueMap.values()); + } + + return list; } /** diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisTmsSiteBatchServiceImpl.java b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisTmsSiteBatchServiceImpl.java index 549999c88..935007d9c 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisTmsSiteBatchServiceImpl.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisTmsSiteBatchServiceImpl.java @@ -201,6 +201,10 @@ public class EmisTmsSiteBatchServiceImpl extends EmisBaseService implements IEmi oldSiteBatch.getStartSiteCode(), oldSiteBatch.getNextSiteCode(), itemDtl.getBillCode(), itemDtl.getId()); + if (itemDtl.getId() != null) { + existingBatches = existingBatches.stream().filter(i -> !itemDtl.getBatchNo().equals(i.getBatchNo())) + .collect(Collectors.toList()); + } EmisTransPlanRule rule = rules.stream() .filter(i -> i.getSupplierCode().contains(oldSiteBatch.getSupplierCode())).collect(Collectors.toList()) .get(0); @@ -253,6 +257,7 @@ public class EmisTmsSiteBatchServiceImpl extends EmisBaseService implements IEmi currentBatch.setTotalWeight(itemDtl.getBatchWeight()); currentBatch.setTotalParcelQty(itemDtl.getBatchParcelQty()); currentBatch.setTotalVolume(itemDtl.getBatchVolume()); + allBatches.add(currentBatch); List countBatches = new ArrayList<>(allBatches); @@ -496,6 +501,16 @@ public class EmisTmsSiteBatchServiceImpl extends EmisBaseService implements IEmi @Override @Transactional public int addAll(EmisTmsSiteBatch emisTmsSiteBatch) throws EmisBizError { + + // 根据批次号查询是否已存在,已存在则报错 + if (StringUtils.isNotBlank(emisTmsSiteBatch.getBatchNo())) { + EmisTmsSiteBatch existingBatch = emisTmsSiteBatchMapper + .selectTmsSiteBatchByBatchNo(emisTmsSiteBatch.getBatchNo()); + if (existingBatch != null) { + throw new EmisBizError(EmisBizErrorType.EXISTS, "批次号[" + emisTmsSiteBatch.getBatchNo() + "]已存在,不能重复添加"); + } + } + // 插入明细数据 if (!CollectionUtils.isEmpty(emisTmsSiteBatch.getBatchDtlList())) { List distinctBatchDtlList = emisTmsSiteBatch.getBatchDtlList().stream() diff --git a/emis-biz/src/main/resources/mapper/EmisTmsSiteBatchDtlMapper.xml b/emis-biz/src/main/resources/mapper/EmisTmsSiteBatchDtlMapper.xml index 8284aa5e9..10461f492 100644 --- a/emis-biz/src/main/resources/mapper/EmisTmsSiteBatchDtlMapper.xml +++ b/emis-biz/src/main/resources/mapper/EmisTmsSiteBatchDtlMapper.xml @@ -33,22 +33,29 @@ select id, bill_code, batch_no, scan_date, scan_status, group_status, scan_man, scan_site, batch_volume, batch_parcel_qty, batch_weight, waybill_batch_status, remark, tenant_id, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_tms_site_batch_dtl - del_flag='0' - and id = #{id} - and ( FIND_IN_SET(`bill_code`,#{billCode}) or bill_code like concat('%', #{billCode}, '%') ) - and ( FIND_IN_SET(`batch_no`,#{batchNo}) or batch_no like concat('%', #{batchNo}, '%') ) - and scan_date = #{scanDate} - and scan_status=#{scanStatus} - and group_status=#{groupStatus} - and scan_man like concat('%', #{scanMan}, '%') - and scan_site =#{scanSite} - and batch_volume = #{batchVolume} - and batch_parcel_qty = #{batchParcelQty} - and batch_weight = #{batchWeight} - and waybill_batch_status = #{waybillBatchStatus} + and id = #{id} + and ( FIND_IN_SET(`bill_code`,#{billCode}) or bill_code like + concat('%', #{billCode}, '%') ) + + + and (FIND_IN_SET(#{batchNo}, `batch_no`) or batch_no = #{batchNo}) + + and scan_date = #{scanDate} + and scan_status=#{scanStatus} + and group_status=#{groupStatus} + and scan_man like concat('%', #{scanMan}, '%') + and scan_site =#{scanSite} + and batch_volume = #{batchVolume} + and batch_parcel_qty = #{batchParcelQty} + and batch_weight = #{batchWeight} + and waybill_batch_status = + #{waybillBatchStatus} + and bill_code in @@ -202,16 +209,16 @@ where id = #{id} - - delete from emis_tms_site_batch_dtl where id = #{id} - + + update emis_tms_site_batch_dtl set del_flag = '1' where id = #{id} + - - delete from emis_tms_site_batch_dtl where id in + + update emis_tms_site_batch_dtl set del_flag = '1' where id in #{id} - + @@ -547,16 +548,16 @@ b.op_man, b.remark, b.tenant_id, b.del_flag, b.create_by, b.create_time, b.update_by, b.update_time, b.create_site, b.update_site, b.bl_entering, CASE - WHEN COALESCE(SUM(d.batch_volume), 0) = 0 THEN COALESCE(w.total_volume, 0) - ELSE COALESCE(SUM(d.batch_volume), 0) + WHEN COALESCE(MAX(d.batch_volume), 0) = 0 THEN COALESCE(w.total_volume, 0) + ELSE COALESCE(MAX(d.batch_volume), 0) END as total_volume, CASE - WHEN COALESCE(SUM(d.batch_parcel_qty), 0) = 0 THEN COALESCE(w.parcel_qty, 0) - ELSE COALESCE(SUM(d.batch_parcel_qty), 0) + WHEN COALESCE(MAX(d.batch_parcel_qty), 0) = 0 THEN COALESCE(w.parcel_qty, 0) + ELSE COALESCE(MAX(d.batch_parcel_qty), 0) END as total_parcel_qty, CASE - WHEN COALESCE(SUM(d.batch_weight), 0) = 0 THEN COALESCE(w.bill_weight, 0) - ELSE COALESCE(SUM(d.batch_weight), 0) + WHEN COALESCE(MAX(d.batch_weight), 0) = 0 THEN COALESCE(w.bill_weight, 0) + ELSE COALESCE(MAX(d.batch_weight), 0) END as total_weight from emis_tms_site_batch b inner join emis_tms_site_batch_dtl d on b.batch_no = d.batch_no