فهرست منبع

fix(warehouse): 解决库存匹配和片区一致性验证问题

- 添加仓库标识字段inboundArea用于库存查询
- 修复库存查询时片区参数传递错误的问题
- 添加销售计划片区与库存片区一致性校验逻辑
- 优化库存ID查询逻辑并添加空值保护
- 修复实时库存验证中的片区不匹配异常处理
xiaosonghong 6 روز پیش
والد
کامیت
a2b1bd65da
1فایلهای تغییر یافته به همراه11 افزوده شده و 4 حذف شده
  1. 11 4
      src/main/java/com/steerinfo/dil/service/impl/OyeWarehouseServiceImpl.java

+ 11 - 4
src/main/java/com/steerinfo/dil/service/impl/OyeWarehouseServiceImpl.java

@@ -84,6 +84,8 @@ public class OyeWarehouseServiceImpl implements IOyeWarehouseService {
         BigDecimal shipperId = DataChange.dataToBigDecimal(mapValue.get("shipperId"));
         // 收货单位
         BigDecimal receiveId = DataChange.dataToBigDecimal(mapValue.get("receiveId"));
+        //仓库标识
+        String inboundArea = mapValue.get("inboundAreaSide") == null ? null : mapValue.get("inboundAreaSide").toString();
         if (receiveId == null || receiveId.intValue() == 0) {
             receiveId = amsSaleOrderMapper.findReceiveIdByOye(mapValue.get("receiveName"));
             if (receiveId == null) {
@@ -176,14 +178,15 @@ public class OyeWarehouseServiceImpl implements IOyeWarehouseService {
             searchInventoryMap.put("materialId",materialId);
             searchInventoryMap.put("saleArea",saleRemark);
             searchInventoryMap.put("receiveId",receiveId);
-            searchInventoryMap.put("meter",steelMeters);
+            //searchInventoryMap.put("meter",steelMeters);
             searchInventoryMap.put("inboundWarehouse",inboundWarehouse);
-            searchInventoryMap.put("inboundArea",map.get("inboundArea") == null ? null : map.get("inboundArea").toString());
+            searchInventoryMap.put("inboundArea", inboundArea);
             BigDecimal inventoryId = DataChange.dataToBigDecimal(map.get("inventoryId"));
+            BigDecimal q_inventoryId = amsSaleMaterialMapper.selectInventoryId(searchInventoryMap);
             if (inventoryId == null || inventoryId.intValue() == 0) {
                 try {
-                    inventoryId = amsSaleMaterialMapper.selectInventoryId(searchInventoryMap);
-                    if(inventoryId == null) {
+                    inventoryId = q_inventoryId;
+                    if(inventoryId == null || inventoryId.intValue() == 0) {
                         throw new Exception("无法匹配实时库存,请检查输入参数");
                     }
                 } catch (Exception e) {
@@ -191,6 +194,10 @@ public class OyeWarehouseServiceImpl implements IOyeWarehouseService {
                     throw new Exception("无法匹配实时库存,请检查输入参数");
                 }
             }
+            q_inventoryId = q_inventoryId == null ? BigDecimal.ZERO : q_inventoryId;
+            if(inventoryId.compareTo(q_inventoryId) != 0){
+                throw new Exception("销售计划片区与库存片区不一致,请检查!");
+            }
             map.put("inventoryId",inventoryId);
             if (!getRealTimeInfo(map)) {
                 throw new Exception("超出实时库存数量,无法通过");