src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
@@ -308,29 +308,30 @@
        }
        int count = 0;
        StringBuilder stringBuffer = new StringBuilder();
        // 扁平BOM只维护“物料规格 + 消耗工序”,不配置用量,
        // 因此这里只校验每个物料是否有可用库存,不再按单位用量核算需求数量。
        for (TechnologyBomStructureVo structure : structureList) {
            if (structure.getParentId() == null) {
            if (structure == null || structure.getProductModelId() == null) {
                continue;
            }
            StockInventory stockInventory = stockInventoryMapper.selectOne(
                    new QueryWrapper<StockInventory>().lambda().eq(StockInventory::getProductModelId, structure.getProductModelId()));
            if (stockInventory == null) {
                count++;
                stringBuffer.append(structure.getProductName()).append("-").append(structure.getModel()).append("库存不足").append(System.lineSeparator());
                continue;
            List<StockInventory> stockList = stockInventoryMapper.selectList(
                    new QueryWrapper<StockInventory>().lambda()
                            .eq(StockInventory::getProductModelId, structure.getProductModelId()));
            BigDecimal available = BigDecimal.ZERO;
            for (StockInventory stockInventory : stockList) {
                if (stockInventory == null) {
                    continue;
                }
                BigDecimal quantity = stockInventory.getQualitity() == null ? BigDecimal.ZERO : stockInventory.getQualitity();
                BigDecimal locked = stockInventory.getLockedQuantity() == null ? BigDecimal.ZERO : stockInventory.getLockedQuantity();
                available = available.add(quantity.subtract(locked));
            }
            BigDecimal required = salesLedgerProduct.getQuantity().multiply(structure.getUnitQuantity() == null ? BigDecimal.ZERO : structure.getUnitQuantity());
            BigDecimal remain = stockInventory.getQualitity()
                    .subtract(stockInventory.getLockedQuantity())
                    .subtract(required)
                    .divide(BigDecimal.ONE, 2, RoundingMode.CEILING);
            if (remain.compareTo(BigDecimal.ZERO) < 0) {
            if (available.compareTo(BigDecimal.ZERO) <= 0) {
                count++;
                stringBuffer.append(structure.getProductName())
                        .append("-")
                        .append(structure.getModel())
                        .append("库存不足,少")
                        .append(remain.abs())
                        .append("无可用库存")
                        .append(System.lineSeparator());
            }
        }