use of com.whoiszxl.entity.SaleDeliveryOrderPickingItem in project shopzz by whoiszxl.
the class SaleDeliverySchedulerImpl method createPickingItem.
/**
* 创建拣货条目
* @param skuId sku id
* @param productAllocationId 货位id
* @param pickingCount 拣货数量
* @return
*/
private SaleDeliveryOrderPickingItem createPickingItem(Long skuId, Long productAllocationId, Integer pickingCount) {
SaleDeliveryOrderPickingItem pickingItem = new SaleDeliveryOrderPickingItem();
pickingItem.setProductAllocationId(productAllocationId);
pickingItem.setSkuId(skuId);
pickingItem.setPickingCount(pickingCount);
return pickingItem;
}
use of com.whoiszxl.entity.SaleDeliveryOrderPickingItem in project shopzz by whoiszxl.
the class SaleDeliverySchedulerImpl method updatePickingItem.
/**
* 更新拣货条目
* @param stock wms中的库存详细信息
* @param skuId skuid
* @param pickingCount 拣货数量
* @param pickingItems 需要更新的拣货条目
*/
private void updatePickingItem(ProductAllocationStock stock, Long skuId, Integer pickingCount, Map<Long, SaleDeliveryOrderPickingItem> pickingItems) {
// 通过货位ID从需要拣货的条目中取出来
SaleDeliveryOrderPickingItem pickingItem = pickingItems.get(stock.getProductAllocationId());
// 如果不存在 ,则创建新增
if (pickingItem == null) {
pickingItem = createPickingItem(skuId, stock.getProductAllocationId(), 0);
pickingItems.put(stock.getProductAllocationId(), pickingItem);
}
pickingItem.setPickingCount(pickingItem.getPickingCount() + pickingCount);
}
use of com.whoiszxl.entity.SaleDeliveryOrderPickingItem in project shopzz by whoiszxl.
the class SubmitOrderConsumer method submitOrderSub.
@KafkaListener(topics = MQConstants.SUBMIT_ORDER_QUEUE, groupId = "default-group")
public void submitOrderSub(ConsumerRecord<String, String> record, @Header(KafkaHeaders.RECEIVED_TOPIC) String topic, Consumer consumer) {
log.info("订阅到新的提交订单,开始处理, 主题为:{}, 消息值为:{}", topic, record.value());
OrderCreateInfoDTO orderCreateInfoDTO = JsonUtil.fromJson(record.value(), OrderCreateInfoDTO.class);
List<OrderItemDTO> orderItemList = orderCreateInfoDTO.getOrderItemList();
for (OrderItemDTO orderItem : orderItemList) {
// 7.1 通过商品的SKU ID查询到货位库存的明细条目,并进行遍历,一个SKU可能在多个货位上
SaleDeliveryScheduleResult scheduleResult = saleDeliveryScheduler.schedule(orderItem);
List<SaleDeliveryOrderPickingItem> pickingItems = scheduleResult.getPickingItems();
// 7.2 创建出需要拣货的条目和发货的条目并进行批量入库
saleDeliveryPickingItemService.saveBatch(pickingItems);
// 7.3 更新wms中心的库存
WmsStockUpdater stockUpdater = wmsStockUpdaterFactory.create(WmsStockUpdateEventConstants.SUBMIT_ORDER, scheduleResult);
stockUpdater.update();
}
}
use of com.whoiszxl.entity.SaleDeliveryOrderPickingItem 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;
}
Aggregations