xiaoyi
3 天以前 f71dabccb0e4c2fa410683e6058eb906a7dbf094
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/itemreceipt/MesWmItemReceiptServiceImpl.java
@@ -184,12 +184,20 @@
            if (item == null) {
                continue;
            }
            // 如果物料开启批次管理,检查行上的批次号是否为空
            if (Boolean.TRUE.equals(item.getIsBatchManaged()) && line.getBatchId() == null) {
            // 如果物料开启批次管理,行或其上架明细必须携带批次号,否则无法生成库存事务
            if (Boolean.TRUE.equals(item.getIsBatchManaged())) {
                boolean hasBatch = line.getBatchId() != null
                        || hasDetailBatch(itemReceiptDetailService.getItemReceiptDetailListByLineId(line.getId()));
                if (!hasBatch) {
                throw exception(WM_ITEM_RECEIPT_BATCH_REQUIRED, item.getCode(), item.getName());
            }
        }
    }
    }
    private boolean hasDetailBatch(List<MesWmItemReceiptDetailDO> details) {
        return details.stream().anyMatch(detail -> detail.getBatchId() != null);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)