From d5d2c335bfdb88857943cc3d4331429e7c358888 Mon Sep 17 00:00:00 2001 From: leiqiaozhen Date: Fri, 11 Apr 2025 10:59:11 +0800 Subject: [PATCH] =?UTF-8?q?feat(wms=5Fpicking=E4=BF=9D=E5=AD=98)=EF=BC=9A?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E7=AB=AF=EF=BC=8C=E6=89=80=E6=9C=89=E5=8D=95?= =?UTF-8?q?=E6=8D=AE=E6=89=A7=E8=A1=8C=E5=8A=9F=E8=83=BD=EF=BC=8C=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E6=8B=A3=E9=85=8D=E8=A1=A8=E6=95=B0=E6=8D=AE=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E5=A6=82=E6=9E=9CBATCH=5FNUMBER=E4=B8=BA=E7=A9=BA?= =?UTF-8?q?=EF=BC=8C=E5=88=99=E5=8E=BB=E5=BA=93=E5=AD=98=E8=A1=A8=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2BATCH=5FNO=E7=9A=84=E5=80=BC;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wms/service/impl/DocumentServiceImpl.java | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/mom-wms-core/src/main/java/com/foreverwin/mom/wms/service/impl/DocumentServiceImpl.java b/mom-wms-core/src/main/java/com/foreverwin/mom/wms/service/impl/DocumentServiceImpl.java index 0c18089..ba21814 100644 --- a/mom-wms-core/src/main/java/com/foreverwin/mom/wms/service/impl/DocumentServiceImpl.java +++ b/mom-wms-core/src/main/java/com/foreverwin/mom/wms/service/impl/DocumentServiceImpl.java @@ -3272,13 +3272,17 @@ public class DocumentServiceImpl extends ServiceImpl i if (documentDetailed == null) { throw BusinessException.build("公司间入库根据站点[" + site + "]单据主键[" + documentBo + "]物料[" + scanCodeDTO.getItem() + "未找到单据明细数据"); } + // 如果 batchNo 为空,则根据 inventoryId 查询库存表的 batchNo + if (StringUtils.isBlank(batchNo)) { + batchNo = getBatchNo(site, scanCodeDTO.getInventoryId()); + } Picking picking = new Picking(); picking.setSite(site); picking.setDocumentNo(documentNo); picking.setPickingStatus(Constant.PICKING_STATUS_PICKING); picking.setSeq(documentDetailed.getSeq()); picking.setItem(scanCodeDTO.getItem()); - picking.setBatchNumber(batchNo); + picking.setBatchNumber(StringUtils.isBlank(batchNo) ? null : batchNo); picking.setQty(scanCodeDTO.getQty()); picking.setDocumentType(document.getDocumentType()); picking.setInventoryId(scanCodeDTO.getInventoryId()); @@ -3294,6 +3298,11 @@ public class DocumentServiceImpl extends ServiceImpl i if(scanCodeDTO.getDetailSeq()==null){ throw BusinessException.build("拣配明细数据未匹配到单据明细的行"); }else{ + // 如果 batchNo 为空,则根据 inventoryId 查询库存表的 batchNo + String batchNo = scanCodeDTO.getBatchNo(); + if (StringUtils.isBlank(batchNo)) { + batchNo = getBatchNo(site, scanCodeDTO.getInventoryId()); + } DocumentDetailed documentDetailed = documentDetailedService.lambdaQuery().eq(DocumentDetailed::getSite, site).eq(DocumentDetailed::getDocumentBo, documentBo).eq(DocumentDetailed::getItem, scanCodeDTO.getItem()).eq(DocumentDetailed::getSeq, scanCodeDTO.getDetailSeq()).one(); Picking picking = new Picking(); picking.setSite(site); @@ -3301,7 +3310,7 @@ public class DocumentServiceImpl extends ServiceImpl i picking.setPickingStatus(Constant.PICKING_STATUS_PICKING); picking.setSeq(documentDetailed.getSeq()); picking.setItem(scanCodeDTO.getItem()); - picking.setBatchNumber(scanCodeDTO.getBatchNo()); + picking.setBatchNumber(StringUtils.isBlank(batchNo) ? null : batchNo); picking.setQty(scanCodeDTO.getQty()); picking.setDocumentType(document.getDocumentType()); picking.setInventoryId(scanCodeDTO.getInventoryId()); @@ -3316,13 +3325,18 @@ public class DocumentServiceImpl extends ServiceImpl i } else { Map seqMap = documentDetailedService.lambdaQuery().eq(DocumentDetailed::getDocumentBo, documentBo).select(DocumentDetailed::getItem, DocumentDetailed::getSeq).list().stream().collect(Collectors.toMap(DocumentDetailed::getItem, DocumentDetailed::getSeq, (s, s2) -> s)); pickingService.saveBatch(list.stream().map(o -> { + // 如果 batchNo 为空,则根据 inventoryId 查询库存表的 batchNo + String batchNo = o.getBatchNo(); + if (StringUtils.isBlank(batchNo)) { + batchNo = getBatchNo(site, o.getInventoryId()); + } Picking picking = new Picking(); picking.setSite(site); picking.setDocumentNo(documentNo); picking.setPickingStatus(Constant.PICKING_STATUS_PICKING); picking.setSeq(seqMap.get(o.getItem())); picking.setItem(o.getItem()); - picking.setBatchNumber(o.getBatchNo()); + picking.setBatchNumber(StringUtils.isBlank(batchNo) ? null : batchNo); picking.setQty(o.getQty()); picking.setDocumentType(document.getDocumentType()); picking.setInventoryId(o.getInventoryId()); @@ -3354,6 +3368,19 @@ public class DocumentServiceImpl extends ServiceImpl i } } + // 获取库存表 batchNo + public String getBatchNo(String site, String inventoryId) { + String handle = Inventory.genHandle(site, inventoryId); + String batchNo = "" ; + Inventory inventory = inventoryService.getById(handle); + if (inventory == null) { + throw BusinessException.build("条码" + inventoryId + "在库存表不存在"); + } else { + batchNo = inventory.getBatchNo(); + } + return batchNo; + } + @Override @Transactional public void cleanPicking(String site, String user, String documentNo, List seqList) {