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) {