From 969d90fff51fae310a294f7e35040930f623d16c Mon Sep 17 00:00:00 2001
From: rcx <3084692334@qq.com>
Date: Sat, 8 Aug 2026 15:08:01 +0800
Subject: [PATCH] =?UTF-8?q?fix(wms=20=E5=BA=93=E5=AD=98=E6=A8=A1=E5=9D=97)?=
=?UTF-8?q?:=20=E4=BF=AE=E5=A4=8D=E5=BA=93=E5=AD=98=E6=9F=A5=E8=AF=A2?=
=?UTF-8?q?=E5=90=84=E9=A1=B5=E7=AD=BE=E5=88=86=E7=BB=84=E7=BB=B4=E5=BA=A6?=
=?UTF-8?q?=E4=B8=8D=E7=AC=A6=E5=90=88=E9=9C=80=E6=B1=82=E7=9A=84=E9=97=AE?=
=?UTF-8?q?=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
1. queryListByWl(物料查询):原按单物料分组会把同一物料跨仓库库存合并成一行,丢失仓库维度。子查询 partition by 增加 warehouse_id、join 增加 warehouse_id 关联、外层 GROUP BY 增加 warehouse_id,改为按"物料+仓库"汇总。
2. queryListByWlKw(物料/库位查询):GROUP BY 增加 shipper_id,改为按"货主+库位+物料"汇总,避免不同货主在同库位同物料的库存被错误合并。
3. queryListByHz(按货主查询):GROUP BY 增加 warehouse_id,改为按"货主+仓库"汇总;hzwl 分支改走 queryListByHz,符合"按货主查询:货主+仓库"需求。
---
...nventoryAdjustmentRecordDomainService.java | 6 +--
.../persistence/MaterialInventoryImpl.java | 3 +-
.../MaterialInventoryMapper.xml | 50 +++++++++----------
3 files changed, 30 insertions(+), 29 deletions(-)
diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/inventoryAdjustmentRecord/service/InventoryAdjustmentRecordDomainService.java b/mhd_wms/src/main/java/com/mhd/wms/domain/inventoryAdjustmentRecord/service/InventoryAdjustmentRecordDomainService.java
index 51ad599be..482c92cfc 100644
--- a/mhd_wms/src/main/java/com/mhd/wms/domain/inventoryAdjustmentRecord/service/InventoryAdjustmentRecordDomainService.java
+++ b/mhd_wms/src/main/java/com/mhd/wms/domain/inventoryAdjustmentRecord/service/InventoryAdjustmentRecordDomainService.java
@@ -3,7 +3,7 @@ package com.mhd.wms.domain.inventoryAdjustmentRecord.service;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson2.JSONObject;
-import com.aliyun.oss.ServiceException;
+import com.mhd.common.core.exception.ServiceException;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mhd.common.core.constant.SnowFlakeConstants;
import com.mhd.common.core.domain.po.UserPo;
@@ -175,7 +175,7 @@ public class InventoryAdjustmentRecordDomainService {
}
materialInventory.setAllocationQuantity(materialInventory.getAllocationQuantity().subtract(inventoryAdjustmentRecordDO.getAdjustQuantity()));
if (materialInventory.getAllocationQuantity().compareTo(BigDecimal.ZERO) < 0) {
- throw new ServiceException("可用数量调整之后不能小于0");
+ throw new ServiceException("调整之后可用数量不能小于0");
}
}
inventoryAdjustmentRecord.setInventoryAfterQuantity(materialInventory.getInventoryQuantity());
@@ -231,7 +231,7 @@ public class InventoryAdjustmentRecordDomainService {
}
materialInventory.setAllocationQuantity(materialInventory.getAllocationQuantity().subtract(inventoryAdjustmentRecordDO.getAdjustQuantity()));
if (materialInventory.getAllocationQuantity().compareTo(BigDecimal.ZERO) < 0) {
- throw new ServiceException("可用数量调整之后不能小于0");
+ throw new ServiceException("调整之后可用数量不能小于0");
}
inventoryAdjustmentRecord.setInventoryAfterQuantity(materialInventory.getInventoryQuantity());
inventoryAdjustmentRecord.setAllocationAfterQuantity(materialInventory.getAllocationQuantity());
diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/persistence/MaterialInventoryImpl.java b/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/persistence/MaterialInventoryImpl.java
index a536436ce..ee83c4cd7 100644
--- a/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/persistence/MaterialInventoryImpl.java
+++ b/mhd_wms/src/main/java/com/mhd/wms/domain/materialInventory/repository/persistence/MaterialInventoryImpl.java
@@ -78,7 +78,8 @@ public class MaterialInventoryImpl extends ServiceImpl
- GROUP BY a.MATERIAL_BASE_INFO_ID,a.WAREHOUSE_ID,a.STORAGE_SECTION_ID,a.STORAGE_LOCATION_ID order by sort_order, a.update_time desc
+ GROUP BY a.SHIPPER_ID,a.MATERIAL_BASE_INFO_ID,a.WAREHOUSE_ID,a.STORAGE_SECTION_ID,a.STORAGE_LOCATION_ID order by sort_order, a.update_time desc
@@ -534,7 +534,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
a.shipper_id,
MAX(a.shipper_code) AS shipper_code,
MAX(a.shipper_name) AS shipper_name,
- b.material_base_info_id,
+ MAX(b.material_base_info_id) AS material_base_info_id,
MAX(b.material_code) AS material_code,
MAX(b.material_name) AS material_name,
MAX(b.SPECIFICATION_MODEL) AS SPECIFICATION_MODEL,
@@ -551,7 +551,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
MAX(b.pack_id) AS pack_id,
MAX(b.pack_code) AS pack_code,
MAX(b.pack_name) AS pack_name,
- MAX(a.unit) AS unit,
+ MAX(a.unit) AS unit,
IFNULL(SUM(a.freeze_quantity), 0) AS freeze_quantity,
IFNULL(SUM(a.inventory_quantity), 0) AS inventory_quantity,
IFNULL(SUM(a.allocation_quantity), 0) AS allocation_quantity,
@@ -580,7 +580,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
GROUP BY a.shipper_id,
- b.material_base_info_id,
+ b.material_code,
a.warehouse_id,
a.organization_id, a.top_organization_id
ORDER BY sort_order, MAX(a.update_time) DESC
@@ -596,7 +596,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- GROUP BY a.SHIPPER_ID order by sort_order, a.update_time desc
+ GROUP BY a.SHIPPER_ID, a.WAREHOUSE_ID order by sort_order, a.update_time desc