Search in sources :

Example 1 with ProductAllocationStock

use of com.whoiszxl.entity.ProductAllocationStock in project shopzz by whoiszxl.

the class PurchaseInboundWmsStockUpdater method updateProductAllocationStock.

/**
 * 更新商品货位库存
 */
@Override
protected void updateProductAllocationStock() {
    // 1. 拿到采购入库单条目并进行遍历
    for (PurchaseOrderItemDTO item : purchaseOrder.getItems()) {
        // 2. 再从入库单条目中拿到上架条目
        for (PurchaseInboundOnItemDTO onItemDTO : item.getOnItems()) {
            // 3. 获取商品货位库存,如果货位不存在则新建一个
            ProductAllocationStock productAllocationStock = productAllocationStockService.getOrSave(onItemDTO.getProductAllocationId(), onItemDTO.getProductSkuId());
            // 4. 累加可用库存数量并更新
            productAllocationStock.setAvailableStockQuantity(productAllocationStock.getAvailableStockQuantity() + onItemDTO.getPutOnShelvesCount());
            productAllocationStockService.updateById(productAllocationStock);
        }
    }
}
Also used : PurchaseOrderItemDTO(com.whoiszxl.dto.PurchaseOrderItemDTO) PurchaseInboundOnItemDTO(com.whoiszxl.dto.PurchaseInboundOnItemDTO) ProductAllocationStock(com.whoiszxl.entity.ProductAllocationStock)

Example 2 with ProductAllocationStock

use of com.whoiszxl.entity.ProductAllocationStock in project shopzz by whoiszxl.

the class SaleDeliverySchedulerImpl method schedule.

@Override
public SaleDeliveryScheduleResult schedule(OrderItemDTO orderItem) {
    SaleDeliveryScheduleResult scheduleResult = new SaleDeliveryScheduleResult();
    scheduleResult.setOrderItem(orderItem);
    // 查询货位库存明细
    LambdaQueryWrapper<ProductAllocationStock> queryWrapper = new LambdaQueryWrapper<>();
    queryWrapper.eq(ProductAllocationStock::getProductSkuId, orderItem.getSkuId());
    List<ProductAllocationStock> stockList = productAllocationStockService.list(queryWrapper);
    Integer remainingSendOutQuantity = orderItem.getQuantity();
    Map<Long, SaleDeliveryOrderPickingItem> pickingItems = new HashMap<>(100);
    for (ProductAllocationStock stock : stockList) {
        // 如果这个货位上的库存刚好可以满足发货就直接更新
        if (stock.getAvailableStockQuantity() >= remainingSendOutQuantity) {
            updatePickingItem(stock, orderItem.getSkuId(), remainingSendOutQuantity, pickingItems);
            break;
        }
        // 如果不满足,则需要分批处理
        // 将当前的wms库存货位上的sku数量全部上到拣货里
        updatePickingItem(stock, orderItem.getSkuId(), stock.getAvailableStockQuantity(), pickingItems);
        // 剩余发货数量进行扣减
        remainingSendOutQuantity = remainingSendOutQuantity - stock.getAvailableStockQuantity();
    }
    scheduleResult.setPickingItems(new ArrayList<>(pickingItems.values()));
    return scheduleResult;
}
Also used : SaleDeliveryOrderPickingItem(com.whoiszxl.entity.SaleDeliveryOrderPickingItem) HashMap(java.util.HashMap) SaleDeliveryScheduleResult(com.whoiszxl.entity.schedule.SaleDeliveryScheduleResult) ProductAllocationStock(com.whoiszxl.entity.ProductAllocationStock) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Example 3 with ProductAllocationStock

use of com.whoiszxl.entity.ProductAllocationStock in project shopzz by whoiszxl.

the class ProductAllocationStockServiceImpl method getOrSave.

/**
 * 获取商品货位库存,如果不存在则新建一条空记录
 * @param productAllocationId 商品货位ID
 * @param productSkuId 商品SKU ID
 * @return 商品货位库存
 */
@Override
public ProductAllocationStock getOrSave(Long productAllocationId, Long productSkuId) {
    // 1. 从数据库中拿到商品库存记录
    QueryWrapper queryWrapper = new QueryWrapper<ProductAllocationStock>();
    queryWrapper.eq("product_allocation_id", productAllocationId);
    queryWrapper.eq("product_sku_id", productSkuId);
    ProductAllocationStock productAllocationStock = this.getOne(queryWrapper);
    if (productAllocationStock == null) {
        productAllocationStock = new ProductAllocationStock();
        productAllocationStock.setProductAllocationId(productAllocationId);
        productAllocationStock.setProductSkuId(productSkuId);
        productAllocationStock.setAvailableStockQuantity(0);
        productAllocationStock.setLockedStockQuantity(0);
        productAllocationStock.setDeliveriedStockQuantity(0);
        this.save(productAllocationStock);
    }
    return productAllocationStock;
}
Also used : QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) ProductAllocationStock(com.whoiszxl.entity.ProductAllocationStock)

Aggregations

ProductAllocationStock (com.whoiszxl.entity.ProductAllocationStock)3 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)1 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)1 PurchaseInboundOnItemDTO (com.whoiszxl.dto.PurchaseInboundOnItemDTO)1 PurchaseOrderItemDTO (com.whoiszxl.dto.PurchaseOrderItemDTO)1 SaleDeliveryOrderPickingItem (com.whoiszxl.entity.SaleDeliveryOrderPickingItem)1 SaleDeliveryScheduleResult (com.whoiszxl.entity.schedule.SaleDeliveryScheduleResult)1 HashMap (java.util.HashMap)1