|
@@ -455,11 +455,11 @@ public class ReplenisherOperationController {
|
|
|
Replenisher replenisher = getCurrentReplenisher();
|
|
Replenisher replenisher = getCurrentReplenisher();
|
|
|
|
|
|
|
|
String deviceId = (String) body.get("deviceId");
|
|
String deviceId = (String) body.get("deviceId");
|
|
|
- Number productIdNum = (Number) body.get("productId");
|
|
|
|
|
- Number newStockNum = (Number) body.get("newStock");
|
|
|
|
|
|
|
+ Object productIdObj = body.get("productId");
|
|
|
|
|
+ Object newStockObj = body.get("newStock");
|
|
|
String remark = (String) body.getOrDefault("remark", "补货员盘点修正");
|
|
String remark = (String) body.getOrDefault("remark", "补货员盘点修正");
|
|
|
|
|
|
|
|
- if (deviceId == null || productIdNum == null || newStockNum == null) {
|
|
|
|
|
|
|
+ if (deviceId == null || productIdObj == null || newStockObj == null) {
|
|
|
return Result.error(400, "deviceId, productId, newStock 不能为空");
|
|
return Result.error(400, "deviceId, productId, newStock 不能为空");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -467,8 +467,12 @@ public class ReplenisherOperationController {
|
|
|
return Result.error(403, "您无权对此设备进行操作");
|
|
return Result.error(403, "您无权对此设备进行操作");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- Long productId = productIdNum.longValue();
|
|
|
|
|
- int newStock = newStockNum.intValue();
|
|
|
|
|
|
|
+ // 兼容前端传 String(雪花ID过长JS自动转字符串)或 Number
|
|
|
|
|
+ Long productId = toLong(productIdObj);
|
|
|
|
|
+ Integer newStock = toInt(newStockObj);
|
|
|
|
|
+ if (productId == null || newStock == null) {
|
|
|
|
|
+ return Result.error(400, "productId, newStock 格式不正确");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
DeviceInventory inventory = deviceInventoryService.adjustStock(
|
|
DeviceInventory inventory = deviceInventoryService.adjustStock(
|
|
|
deviceId, productId, newStock, remark,
|
|
deviceId, productId, newStock, remark,
|
|
@@ -594,4 +598,36 @@ public class ReplenisherOperationController {
|
|
|
default: return "未知";
|
|
default: return "未知";
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 安全转 Long,兼容前端传 String(雪花ID过长JS自动转字符串)或 Number
|
|
|
|
|
+ */
|
|
|
|
|
+ private Long toLong(Object obj) {
|
|
|
|
|
+ if (obj == null) return null;
|
|
|
|
|
+ if (obj instanceof Number) return ((Number) obj).longValue();
|
|
|
|
|
+ if (obj instanceof String) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ return Long.parseLong((String) obj);
|
|
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 安全转 Integer,兼容前端传 String 或 Number
|
|
|
|
|
+ */
|
|
|
|
|
+ private Integer toInt(Object obj) {
|
|
|
|
|
+ if (obj == null) return null;
|
|
|
|
|
+ if (obj instanceof Number) return ((Number) obj).intValue();
|
|
|
|
|
+ if (obj instanceof String) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ return Integer.parseInt((String) obj);
|
|
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|