|
|
@@ -442,6 +442,37 @@ public class ReplenisherOperationController {
|
|
|
return Result.success(String.format("补货完成,成功%d项,失败%d项", successCount, dto.getItems().size() - successCount), result);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 补货员盘点修正库存
|
|
|
+ * 直接设置指定商品的库存为 newStock
|
|
|
+ */
|
|
|
+ @PostMapping("/stock/adjust")
|
|
|
+ public Result<DeviceInventory> adjustStock(@RequestBody Map<String, Object> body) {
|
|
|
+ Replenisher replenisher = getCurrentReplenisher();
|
|
|
+
|
|
|
+ String deviceId = (String) body.get("deviceId");
|
|
|
+ Number productIdNum = (Number) body.get("productId");
|
|
|
+ Number newStockNum = (Number) body.get("newStock");
|
|
|
+ String remark = (String) body.getOrDefault("remark", "补货员盘点修正");
|
|
|
+
|
|
|
+ if (deviceId == null || productIdNum == null || newStockNum == null) {
|
|
|
+ return Result.error(400, "deviceId, productId, newStock 不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!canAccessDevice(deviceId)) {
|
|
|
+ return Result.error(403, "您无权对此设备进行操作");
|
|
|
+ }
|
|
|
+
|
|
|
+ Long productId = productIdNum.longValue();
|
|
|
+ int newStock = newStockNum.intValue();
|
|
|
+
|
|
|
+ DeviceInventory inventory = deviceInventoryService.adjustStock(
|
|
|
+ deviceId, productId, newStock, remark,
|
|
|
+ replenisher.getId(), replenisher.getName());
|
|
|
+
|
|
|
+ return Result.success("库存修正成功", inventory);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取补货员关联的补货单列表
|
|
|
*/
|