feat: 「库存管理」-「库存查询」增加按货主/物料查询
- 实现按(货主 + 物料 + 仓库 + 包装单位)组合聚合逻辑,更新日期取组内最新时间
This commit is contained in:
+2
@@ -38,6 +38,8 @@ public interface MaterialInventoryMapper extends BaseMapper<MaterialInventory>
|
||||
public List<MaterialInventoryPO> queryListByHz(MaterialInventoryDO materialInventoryDO);
|
||||
//查物料库存列表-货主+物料(同一物料在不同货主下各一行)
|
||||
public List<MaterialInventoryPO> queryListByHzWl(MaterialInventoryDO materialInventoryDO);
|
||||
//查物料库存列表-按货主+物料+仓库(库存查询第三个页签,update_time 取合并后最大值)
|
||||
public List<MaterialInventoryPO> queryListByHzWlUnit(MaterialInventoryDO materialInventoryDO);
|
||||
|
||||
/**
|
||||
* @description 批量增加库存
|
||||
|
||||
+7
-5
@@ -77,17 +77,19 @@ public class MaterialInventoryImpl extends ServiceImpl<MaterialInventoryMapper,
|
||||
String queryRule = materialInventoryDO.getQueryRule();
|
||||
if ("hz".equals(queryRule)) {
|
||||
return materialInventoryMapper.queryListByHz(materialInventoryDO);
|
||||
} else if ("hzwl".equals(queryRule)) {
|
||||
} else if ("hzwl".equals(queryRule)) { // 货主查询
|
||||
return materialInventoryMapper.queryListByHzWl(materialInventoryDO);
|
||||
} else if ("wl".equals(queryRule)) {
|
||||
} else if ("wl".equals(queryRule)) { // 物料查询
|
||||
return materialInventoryMapper.queryListByWl(materialInventoryDO);
|
||||
} else if ("kw".equals(queryRule)) {
|
||||
return materialInventoryMapper.queryListByKw(materialInventoryDO);
|
||||
} else if ("wlkw".equals(queryRule)) {
|
||||
} else if ("wlkw".equals(queryRule)) { // 物料/库位查询
|
||||
return materialInventoryMapper.queryListByWlKw(materialInventoryDO);
|
||||
} else if ("wlExpiry".equals(queryRule)) {
|
||||
} else if ("wlExpiry".equals(queryRule)) { // 物料/过期日期查询
|
||||
return materialInventoryMapper.queryListByWlExpiry(materialInventoryDO);
|
||||
} else if ("all".equals(queryRule)) {
|
||||
} else if("hzwlunit".equals(queryRule)){ // 货主/物料查询
|
||||
return materialInventoryMapper.queryListByHzWlUnit(materialInventoryDO);
|
||||
}else if ("all".equals(queryRule)) { // 全部查询
|
||||
return materialInventoryMapper.queryList(materialInventoryDO);
|
||||
} else {
|
||||
//不传返回全部
|
||||
|
||||
@@ -528,6 +528,55 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
loc.storage_location_id, loc.storage_location_code, loc.storage_location_name order by sort_order, a.update_time desc
|
||||
</select>
|
||||
|
||||
<!-- ============ 按货主+物料+仓库+单位 汇总(库存查询第三个页签) ============ -->
|
||||
<!-- SELECT 列:需求字段,全部聚合;包装单位优先库存表,回退物料基础信息表 -->
|
||||
<sql id="selectMaterialInventoryPoByHzWlUnit">
|
||||
a.shipper_id, a.shipper_code, a.shipper_name,
|
||||
b.material_base_info_id, b.material_code, b.material_name, b.SPECIFICATION_MODEL,
|
||||
a.warehouse_id, a.warehouse_code, a.warehouse_name,
|
||||
a.organization_id, a.organization_name, a.top_organization_id,
|
||||
MAX(b.material_type) AS material_type,
|
||||
MAX(b.material_type_name) AS material_type_name,
|
||||
MAX(b.bar_code) AS bar_code,
|
||||
MAX(nvl(a.unit_name, b.unit_name)) AS unit_name,
|
||||
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,
|
||||
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,
|
||||
IFNULL(SUM(a.area), 0) AS area,
|
||||
IFNULL(SUM(a.NET_WEIGHT), 0) AS NET_WEIGHT,
|
||||
IFNULL(SUM(a.GROSS_WEIGHT), 0) AS GROSS_WEIGHT,
|
||||
IFNULL(SUM(a.VOLUME), 0) AS VOLUME,
|
||||
MIN(a.create_time) AS create_time, -- 新增:首次入库时间
|
||||
MAX(a.update_time) AS update_time,
|
||||
CASE WHEN IFNULL(SUM(a.inventory_quantity), 0) = 0 THEN 1 ELSE 0 END AS sort_order
|
||||
</sql>
|
||||
|
||||
<select id="queryListByHzWlUnit"
|
||||
parameterType="com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryDO"
|
||||
resultMap="MaterialInventoryResult">
|
||||
select
|
||||
<include refid="selectMaterialInventoryPoByHzWlUnit"/>
|
||||
from material_inventory a
|
||||
left join material_base_info b on a.material_base_info_id = b.material_base_info_id
|
||||
<where>
|
||||
a.del_flag = 1
|
||||
<include refid="selectMaterialInventoryPo1"/>
|
||||
<include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPoWhere"/>
|
||||
<if test="excludeZeroInventoryQuantity != null and excludeZeroInventoryQuantity == true">
|
||||
and IFNULL(a.inventory_quantity, 0) > 0
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY a.shipper_id, a.shipper_code, a.shipper_name,
|
||||
b.material_base_info_id, b.material_code, b.material_name, b.SPECIFICATION_MODEL,
|
||||
a.warehouse_id, a.warehouse_code, a.warehouse_name,
|
||||
a.organization_id, a.organization_name, a.top_organization_id
|
||||
ORDER BY sort_order, MAX(a.update_time) DESC
|
||||
</select>
|
||||
|
||||
<select id="queryListByHz" parameterType="com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryDO" resultMap="MaterialInventoryResult">
|
||||
select
|
||||
<include refid="selectMaterialInventoryPo"/>
|
||||
|
||||
Reference in New Issue
Block a user