出库单编辑计划数量不变问题,库存查询显示问题
This commit is contained in:
@@ -89,6 +89,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
a.in_order_number,a.lot_number
|
||||
</sql>
|
||||
|
||||
<!-- 按物料(wl)汇总:仓库/库区/库位取创建时间最新的一条明细(与 queryListByWl 中 loc 子查询一致;并列时取 material_inventory_id 更大) -->
|
||||
<sql id="selectMaterialInventoryPoWl">
|
||||
a.material_inventory_id, a.organization_id, a.organization_name, a.top_organization_id,
|
||||
a.shipper_id, a.shipper_code, a.shipper_name,
|
||||
loc.warehouse_id, loc.warehouse_code, loc.warehouse_name,
|
||||
loc.storage_section_id, loc.storage_code, loc.storage_name, loc.storage_location_id, loc.storage_location_code, loc.storage_location_name, a.material_base_info_id,a.material_detail_id,
|
||||
a.batch_number,a.material_status_code,a.material_status_name,a.container_id,a.container_code,a.container_type,a.container_type_name
|
||||
,IFNULL (sum(a.freeze_quantity), 0) freeze_quantity,a.is_able,
|
||||
IFNULL (sum(a.inventory_quantity), 0) inventory_quantity,
|
||||
IFNULL (sum(a.allocation_quantity), 0) allocation_quantity,
|
||||
a.remark, a.create_time, a.create_by, a.create_by_name, a.update_time, a.update_by, a.update_by_name,
|
||||
a.del_flag,a.unit,
|
||||
IFNULL (sum(a.area), 0) area,
|
||||
IFNULL (sum(a.NET_WEIGHT), 0) NET_WEIGHT,
|
||||
IFNULL (sum(a.GROSS_WEIGHT), 0) GROSS_WEIGHT,
|
||||
IFNULL (sum(a.VOLUME), 0) VOLUME,
|
||||
a.ext_attr_1, a.ext_attr_2, a.ext_attr_3, a.ext_attr_4,
|
||||
a.production_date, a.expiry_date, a.inventory_date,
|
||||
a.BATCH_REF_NO, a.SHEET_REF_NO, a.BOX_PALLET_NO,nvl(a.unit_name,b.unit_name) as unit_name,
|
||||
a.bar_code as inv_bar_code,
|
||||
a.in_order_number,a.lot_number
|
||||
</sql>
|
||||
|
||||
<sql id="selectMaterialInventoryPo1">
|
||||
<if test="materialInventoryId != null ">
|
||||
and a.material_inventory_id = #{materialInventoryId}
|
||||
@@ -211,6 +234,124 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<!-- 与 selectMaterialInventoryPo1 相同条件,表别名为 mi(用于 queryListByWl 最新明细子查询) -->
|
||||
<sql id="selectMaterialInventoryPo1Mi">
|
||||
<if test="materialInventoryId != null ">
|
||||
and mi.material_inventory_id = #{materialInventoryId}
|
||||
</if>
|
||||
<if test="organizationId != null ">
|
||||
and mi.organization_id = #{organizationId}
|
||||
</if>
|
||||
<if test="organizationName != null and organizationName != ''">
|
||||
and mi.organization_name like concat('%', #{organizationName}, '%')
|
||||
</if>
|
||||
<if test="topOrganizationId != null ">
|
||||
and mi.top_organization_id = #{topOrganizationId}
|
||||
</if>
|
||||
<if test="warehouseId != null ">
|
||||
and mi.warehouse_id = #{warehouseId}
|
||||
</if>
|
||||
<if test="shipperId != null ">
|
||||
and mi.shipper_id = #{shipperId}
|
||||
</if>
|
||||
<if test="warehouseCode != null and warehouseCode != ''">
|
||||
and mi.warehouse_code = #{warehouseCode}
|
||||
</if>
|
||||
<if test="warehouseName != null and warehouseName != ''">
|
||||
and mi.warehouse_name like concat('%', #{warehouseName}, '%')
|
||||
</if>
|
||||
<if test="storageSectionId != null ">
|
||||
and mi.storage_section_id = #{storageSectionId}
|
||||
</if>
|
||||
<if test="storageCode != null and storageCode != ''">
|
||||
and mi.storage_code = #{storageCode}
|
||||
</if>
|
||||
<if test="storageName != null and storageName != ''">
|
||||
and mi.storage_name like concat('%', #{storageName}, '%')
|
||||
</if>
|
||||
<if test="storageLocationId != null ">
|
||||
and mi.storage_location_id = #{storageLocationId}
|
||||
</if>
|
||||
<if test="storageLocationCode != null and storageLocationCode != ''">
|
||||
and mi.storage_location_code = #{storageLocationCode}
|
||||
</if>
|
||||
<if test="storageLocationName != null and storageLocationName != ''">
|
||||
and mi.storage_location_name like concat('%', #{storageLocationName}, '%')
|
||||
</if>
|
||||
<if test="materialBaseInfoId != null ">
|
||||
and mi.material_base_info_id = #{materialBaseInfoId}
|
||||
</if>
|
||||
<if test="materialDetailId != null ">
|
||||
and mi.material_detail_id, = #{materialDetailId}
|
||||
</if>
|
||||
<choose>
|
||||
<when test="containerOrBatch != null and containerOrBatch != ''">
|
||||
and (mi.container_code like concat('%', #{containerOrBatch}, '%') or mi.batch_number like concat('%', #{containerOrBatch}, '%'))
|
||||
</when>
|
||||
<when test="batchNumber != null and batchNumber != '' and containerCode != null and containerCode != '' and batchNumber == containerCode">
|
||||
and (mi.batch_number like concat('%', #{batchNumber}, '%') or mi.container_code like concat('%', #{containerCode}, '%'))
|
||||
</when>
|
||||
<otherwise>
|
||||
<if test="batchNumber != null and batchNumber != ''">
|
||||
and mi.batch_number like concat('%', #{batchNumber}, '%')
|
||||
</if>
|
||||
<if test="containerCode != null and containerCode != ''">
|
||||
and mi.container_code like concat('%', #{containerCode}, '%')
|
||||
</if>
|
||||
</otherwise>
|
||||
</choose>
|
||||
<if test="materialStatusCode != null and materialStatusCode != ''">
|
||||
and mi.material_status_code like concat('%', #{materialStatusCode}, '%')
|
||||
</if>
|
||||
<if test="materialStatusName != null and materialStatusName != ''">
|
||||
and mi.material_status_name like concat('%', #{materialStatusName}, '%')
|
||||
</if>
|
||||
<if test="containerId != null ">
|
||||
and mi.container_id = #{containerId}
|
||||
</if>
|
||||
<if test="containerType != null and containerType != ''">
|
||||
and mi.container_type like concat('%', #{containerType}, '%')
|
||||
</if>
|
||||
<if test="containerTypeName != null and containerTypeName != ''">
|
||||
and mi.container_type_name like concat('%', #{containerTypeName}, '%')
|
||||
</if>
|
||||
<if test="inventoryQuantity != null ">
|
||||
and mi.inventory_quantity = #{inventoryQuantity}
|
||||
</if>
|
||||
<if test="allocationQuantity != null ">
|
||||
and mi.allocation_quantity = #{allocationQuantity}
|
||||
</if>
|
||||
<if test="freezeQuantity != null ">
|
||||
and mi.freeze_quantity = #{freezeQuantity}
|
||||
</if>
|
||||
<if test="excludeZeroInventoryQuantity != null and excludeZeroInventoryQuantity == true">
|
||||
and COALESCE(mi.inventory_quantity, 0) > 0
|
||||
</if>
|
||||
|
||||
<if test="createByName != null and createByName != ''">
|
||||
and mi.create_by_name like concat('%', #{createByName}, '%')
|
||||
</if>
|
||||
<if test="updateByName != null and updateByName != ''">
|
||||
and mi.update_by_name like concat('%', #{updateByName}, '%')
|
||||
</if>
|
||||
<choose>
|
||||
<when test="delFlag != null"> and mi.del_flag = #{delFlag} </when>
|
||||
<otherwise> and mi.del_flag = 1 </otherwise>
|
||||
</choose>
|
||||
<if test="storageInfo != null and storageInfo != ''">
|
||||
and (mi.storage_location_code = #{storageInfo} or material_code = #{storageInfo} or material_name like concat('%', #{storageInfo}, '%') or bar_code = #{storageInfo})
|
||||
</if>
|
||||
<if test="batchRefNo != null and batchRefNo != ''">
|
||||
and mi.BATCH_REF_NO like concat('%', #{batchRefNo}, '%')
|
||||
</if>
|
||||
<if test="sheetRefNo != null and sheetRefNo != ''">
|
||||
and mi.SHEET_REF_NO like concat('%', #{sheetRefNo}, '%')
|
||||
</if>
|
||||
<if test="boxPalletNo != null and boxPalletNo != ''">
|
||||
and mi.BOX_PALLET_NO like concat('%', #{boxPalletNo}, '%')
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="queryList" parameterType="com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryDO" resultMap="MaterialInventoryResult">
|
||||
select
|
||||
<include refid="selectMaterialInventoryPo"/>
|
||||
@@ -252,15 +393,69 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<select id="queryListByWl" parameterType="com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryDO" resultMap="MaterialInventoryResult">
|
||||
select
|
||||
<include refid="selectMaterialInventoryPo"/>
|
||||
<include refid="selectMaterialInventoryPoWl"/>
|
||||
<include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPo"/>
|
||||
from material_inventory a
|
||||
left join material_base_info b on a.material_base_info_id = b.material_base_info_id
|
||||
inner join (
|
||||
select material_base_info_id, warehouse_id, warehouse_code, warehouse_name,
|
||||
storage_section_id, storage_code, storage_name,
|
||||
storage_location_id, storage_location_code, storage_location_name
|
||||
from (
|
||||
select mi.material_base_info_id, mi.warehouse_id, mi.warehouse_code, mi.warehouse_name,
|
||||
mi.storage_section_id, mi.storage_code, mi.storage_name,
|
||||
mi.storage_location_id, mi.storage_location_code, mi.storage_location_name,
|
||||
row_number() over (partition by mi.material_base_info_id order by mi.create_time desc, mi.material_inventory_id desc) as wl_rn
|
||||
from material_inventory mi
|
||||
left join material_base_info b on mi.material_base_info_id = b.material_base_info_id
|
||||
<where>
|
||||
<include refid="selectMaterialInventoryPo1Mi"/>
|
||||
<include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPoWhere"/>
|
||||
</where>
|
||||
) wl_ranked where wl_ranked.wl_rn = 1
|
||||
) loc on loc.material_base_info_id = a.material_base_info_id
|
||||
<where>
|
||||
<include refid="selectMaterialInventoryPo1"/>
|
||||
<include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPoWhere"/>
|
||||
</where>
|
||||
GROUP BY a.MATERIAL_BASE_INFO_ID
|
||||
GROUP BY a.MATERIAL_BASE_INFO_ID,
|
||||
loc.warehouse_id, loc.warehouse_code, loc.warehouse_name,
|
||||
loc.storage_section_id, loc.storage_code, loc.storage_name,
|
||||
loc.storage_location_id, loc.storage_location_code, loc.storage_location_name
|
||||
</select>
|
||||
|
||||
<!-- 按货主+物料汇总:A货主物料1、A货主物料2、B货主物料1、B货主物料2 为 4 行;库位取该货主+该物料下创建时间最新的一条明细 -->
|
||||
<select id="queryListByHzWl" parameterType="com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryDO" resultMap="MaterialInventoryResult">
|
||||
select
|
||||
<include refid="selectMaterialInventoryPoWl"/>
|
||||
<include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPo"/>
|
||||
from material_inventory a
|
||||
left join material_base_info b on a.material_base_info_id = b.material_base_info_id
|
||||
inner join (
|
||||
select shipper_id, material_base_info_id, warehouse_id, warehouse_code, warehouse_name,
|
||||
storage_section_id, storage_code, storage_name,
|
||||
storage_location_id, storage_location_code, storage_location_name
|
||||
from (
|
||||
select mi.shipper_id, mi.material_base_info_id, mi.warehouse_id, mi.warehouse_code, mi.warehouse_name,
|
||||
mi.storage_section_id, mi.storage_code, mi.storage_name,
|
||||
mi.storage_location_id, mi.storage_location_code, mi.storage_location_name,
|
||||
row_number() over (partition by mi.shipper_id, mi.material_base_info_id order by mi.create_time desc, mi.material_inventory_id desc) as hzwl_rn
|
||||
from material_inventory mi
|
||||
left join material_base_info b on mi.material_base_info_id = b.material_base_info_id
|
||||
<where>
|
||||
<include refid="selectMaterialInventoryPo1Mi"/>
|
||||
<include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPoWhere"/>
|
||||
</where>
|
||||
) hzwl_ranked where hzwl_ranked.hzwl_rn = 1
|
||||
) loc on loc.shipper_id = a.shipper_id and loc.material_base_info_id = a.material_base_info_id
|
||||
<where>
|
||||
<include refid="selectMaterialInventoryPo1"/>
|
||||
<include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPoWhere"/>
|
||||
</where>
|
||||
GROUP BY a.SHIPPER_ID, a.MATERIAL_BASE_INFO_ID,
|
||||
loc.warehouse_id, loc.warehouse_code, loc.warehouse_name,
|
||||
loc.storage_section_id, loc.storage_code, loc.storage_name,
|
||||
loc.storage_location_id, loc.storage_location_code, loc.storage_location_name
|
||||
</select>
|
||||
|
||||
<select id="queryListByHz" parameterType="com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryDO" resultMap="MaterialInventoryResult">
|
||||
|
||||
Reference in New Issue
Block a user