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);
}
}
}
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;
}
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;
}
Aggregations