|
|
@@ -15,6 +15,7 @@ import com.haha.entity.Replenisher;
|
|
|
import com.haha.entity.ReplenishmentOrder;
|
|
|
import com.haha.entity.ReplenishmentOrderItem;
|
|
|
import com.haha.entity.dto.ReplenishDTO;
|
|
|
+import com.haha.mapper.ReplenishmentOrderItemMapper;
|
|
|
import com.haha.service.DeviceInventoryService;
|
|
|
import com.haha.service.DeviceService;
|
|
|
import com.haha.service.InventoryLogService;
|
|
|
@@ -46,6 +47,7 @@ public class ReplenisherOperationController {
|
|
|
private final DeviceService deviceService;
|
|
|
private final ReplenishmentOrderService replenishmentOrderService;
|
|
|
private final InventoryLogService inventoryLogService;
|
|
|
+ private final ReplenishmentOrderItemMapper orderItemMapper;
|
|
|
|
|
|
/**
|
|
|
* 获取当前补货员信息
|
|
|
@@ -315,6 +317,10 @@ public class ReplenisherOperationController {
|
|
|
|
|
|
for (ReplenishDTO.ReplenishItem item : dto.getItems()) {
|
|
|
try {
|
|
|
+ // 补货前获取当前库存
|
|
|
+ DeviceInventory beforeInv = deviceInventoryService.getByDeviceAndProduct(dto.getDeviceId(), item.getProductId());
|
|
|
+ int beforeStock = beforeInv != null ? beforeInv.getStock() : 0;
|
|
|
+
|
|
|
DeviceInventory inventory = deviceInventoryService.increaseStock(
|
|
|
dto.getDeviceId(),
|
|
|
item.getProductId(),
|
|
|
@@ -328,6 +334,20 @@ public class ReplenisherOperationController {
|
|
|
null
|
|
|
);
|
|
|
|
|
|
+ // 回写订单明细:实际补货数量、补货前/后库存
|
|
|
+ if (dto.getOrderId() != null) {
|
|
|
+ ReplenishmentOrderItem orderItem = orderItemMapper.selectOne(
|
|
|
+ new LambdaQueryWrapper<ReplenishmentOrderItem>()
|
|
|
+ .eq(ReplenishmentOrderItem::getOrderId, dto.getOrderId())
|
|
|
+ .eq(ReplenishmentOrderItem::getProductCode, item.getProductCode()));
|
|
|
+ if (orderItem != null) {
|
|
|
+ orderItem.setActualQuantity(item.getQuantity());
|
|
|
+ orderItem.setBeforeStock(beforeStock);
|
|
|
+ orderItem.setAfterStock(inventory.getStock());
|
|
|
+ orderItemMapper.updateById(orderItem);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
successCount++;
|
|
|
Map<String, Object> itemResult = new HashMap<>();
|
|
|
itemResult.put("productId", item.getProductId());
|