集成wms服务模块

This commit is contained in:
hjx
2026-01-19 18:55:23 +08:00
parent aab59723f9
commit 1655d57057
835 changed files with 96160 additions and 0 deletions
@@ -0,0 +1,601 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mhd.wms.domain.materialInventory.repository.mapper.MaterialInventoryMapper">
<resultMap type="com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryPO" id="MaterialInventoryResult">
<result property="materialInventoryId" column="material_inventory_id" />
<result property="organizationId" column="organization_id" />
<result property="organizationName" column="organization_name" />
<result property="topOrganizationId" column="top_organization_id" />
<result property="warehouseId" column="warehouse_id" />
<result property="warehouseCode" column="warehouse_code" />
<result property="warehouseName" column="warehouse_name" />
<result property="storageSectionId" column="storage_section_id" />
<result property="storageCode" column="storage_code" />
<result property="storageName" column="storage_name" />
<result property="storageLocationId" column="storage_location_id" />
<result property="storageLocationCode" column="storage_location_code" />
<result property="storageLocationName" column="storage_location_name" />
<result property="materialBaseInfoId" column="material_base_info_id" />
<result property="materialDetailId" column="material_detail_id" />
<result property="batchNumber" column="batch_number" />
<result property="materialStatusCode" column="material_status_code" />
<result property="materialStatusName" column="material_status_name" />
<result property="containerId" column="container_id" />
<result property="containerCode" column="container_code" />
<result property="containerType" column="container_type" />
<result property="containerTypeName" column="container_type_name" />
<result property="freezeQuantity" column="freeze_quantity" />
<result property="inventoryQuantity" column="inventory_quantity" />
<result property="allocationQuantity" column="allocation_quantity" />
<result property="remark" column="remark" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="createByName" column="create_by_name" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
<result property="updateByName" column="update_by_name" />
<result property="delFlag" column="del_flag" />
<result property="isAble" column="is_able" />
</resultMap>
<sql id="selectMaterialInventoryPo">
a.material_inventory_id, a.organization_id, a.organization_name, a.top_organization_id, a.warehouse_id, a.warehouse_code, a.warehouse_name,
a.storage_section_id, a.storage_code, a.storage_name, a.storage_location_id, a.storage_location_code, a.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(a.freeze_quantity,0) freeze_quantity,a.is_able,
IFNULL(a.inventory_quantity,0) inventory_quantity, IFNULL(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
</sql>
<sql id="selectMaterialInventoryPo1">
<if test="organizationId != null ">
and a.organization_id = #{organizationId}
</if>
<if test="organizationName != null and organizationName != ''">
and a.organization_name like concat('%', #{organizationName}, '%')
</if>
<if test="topOrganizationId != null ">
and a.top_organization_id = #{topOrganizationId}
</if>
<if test="warehouseId != null ">
and a.warehouse_id = #{warehouseId}
</if>
<if test="warehouseCode != null and warehouseCode != ''">
and a.warehouse_code = #{warehouseCode}
</if>
<if test="warehouseName != null and warehouseName != ''">
and a.warehouse_name like concat('%', #{warehouseName}, '%')
</if>
<if test="storageSectionId != null ">
and a.storage_section_id = #{storageSectionId}
</if>
<if test="storageCode != null and storageCode != ''">
and a.storage_code = #{storageCode}
</if>
<if test="storageName != null and storageName != ''">
and a.storage_name like concat('%', #{storageName}, '%')
</if>
<if test="storageLocationId != null ">
and a.storage_location_id = #{storageLocationId}
</if>
<if test="storageLocationCode != null and storageLocationCode != ''">
and a.storage_location_code = #{storageLocationCode}
</if>
<if test="storageLocationName != null and storageLocationName != ''">
and a.storage_location_name like concat('%', #{storageLocationName}, '%')
</if>
<if test="materialBaseInfoId != null ">
and a.material_base_info_id = #{materialBaseInfoId}
</if>
<if test="materialDetailId != null ">
and a.material_detail_id, = #{materialDetailId}
</if>
<if test="batchNumber != null and batchNumber != ''">
and a.batch_number = #{batchNumber}
</if>
<if test="materialStatusCode != null and materialStatusCode != ''">
and a.material_status_code like concat('%', #{materialStatusCode}, '%')
</if>
<if test="materialStatusName != null and materialStatusName != ''">
and a.material_status_name like concat('%', #{materialStatusName}, '%')
</if>
<if test="containerId != null ">
and a.container_id = #{containerId}
</if>
<if test="containerCode != null and containerCode != ''">
and a.container_code like concat('%', #{containerCode}, '%')
</if>
<if test="containerType != null and containerType != ''">
and a.container_type like concat('%', #{containerType}, '%')
</if>
<if test="containerTypeName != null and containerTypeName != ''">
and a.container_type_name like concat('%', #{containerTypeName}, '%')
</if>
<choose>
<when test="inventoryQuantity != null"> and a.inventory_quantity = #{inventoryQuantity} </when>
<otherwise> and a.inventory_quantity != 0 </otherwise>
</choose>
<if test="allocationQuantity != null ">
and a.allocation_quantity = #{allocationQuantity}
</if>
<if test="freezeQuantity != null ">
and a.freeze_quantity = #{freezeQuantity}
</if>
<if test="createByName != null and createByName != ''">
and a.create_by_name like concat('%', #{createByName}, '%')
</if>
<if test="updateByName != null and updateByName != ''">
and a.update_by_name like concat('%', #{updateByName}, '%')
</if>
<choose>
<when test="delFlag != null"> and a.del_flag = #{delFlag} </when>
<otherwise> and a.del_flag = 1 </otherwise>
</choose>
<if test="storageInfo != null and storageInfo != ''">
and (a.storage_location_code = #{storageInfo} or material_code = #{storageInfo} or material_name like concat('%', #{storageInfo}, '%') or bar_code = #{storageInfo})
</if>
</sql>
<select id="queryList" parameterType="com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryDO" resultMap="MaterialInventoryResult">
select
<include refid="selectMaterialInventoryPo"/>
<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
<where>
<include refid="selectMaterialInventoryPo1"/>
<include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPoWhere"/>
</where>
</select>
<resultMap type="com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryQueryListPO" id="MaterialQueryListResult">
<result property="materialInventoryId" column="material_inventory_id" />
<result property="organizationId" column="organization_id" />
<result property="organizationName" column="organization_name" />
<result property="topOrganizationId" column="top_organization_id" />
<result property="shipperId" column="shipper_id" />
<result property="shipperName" column="shipper_name" />
<result property="materialCode" column="material_code" />
<result property="materialName" column="material_name" />
<result property="barCode" column="bar_code" />
<result property="warehouseId" column="warehouse_id" />
<result property="warehouseCode" column="warehouse_code" />
<result property="warehouseName" column="warehouse_name" />
<result property="storageSectionId" column="storage_section_id" />
<result property="storageCode" column="storage_code" />
<result property="storageName" column="storage_name" />
<result property="storageLocationId" column="storage_location_id" />
<result property="storageLocationCode" column="storage_location_code" />
<result property="storageLocationName" column="storage_location_name" />
<result property="materialBaseInfoId" column="material_base_info_id" />
<result property="inventoryQuantity" column="inventory_quantity" />
<result property="allocationQuantity" column="allocation_quantity" />
<result property="remark" column="remark" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="createByName" column="create_by_name" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
<result property="updateByName" column="update_by_name" />
<result property="delFlag" column="del_flag" />
</resultMap>
<sql id="materialQueryListByGroup">
<choose>
<when test="queryType != null and queryType == 1">
group by b.shipper_id
order by b.shipper_id
</when>
<when test="queryType != null and queryType == 2">
group by b.material_base_info_id
order by b.material_base_info_id
</when>
<when test="queryType != null and queryType == 3">
group by a.batch_number
order by b.material_name,a.batch_number
</when>
<when test="queryType != null and queryType == 4">
group by a.storage_location_id
order by a.storage_location_id
</when>
<when test="queryType != null and queryType == 5">
group by b.material_base_info_id,a.storage_location_id
order by b.material_name,a.storage_location_id
</when>
<when test="queryType != null and queryType == 6">
group by a.container_id
order by a.container_type_name,b.material_name,a.storage_location_name
</when>
<otherwise>
group by a.material_inventory_id
order by b.shipper_name,b.material_name,a.storage_location_name,a.batch_number
</otherwise>
</choose>
</sql>
<select id="materialQueryList"
resultType="com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryQueryListPO" resultMap="MaterialQueryListResult">
select
<include refid="selectMaterialInventoryPo"/>
<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
<where>
<include refid="selectMaterialInventoryPo1"/>
<include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPoWhere"/>
</where>
<include refid="materialQueryListByGroup"/>
</select>
<update id="batchAddInventoryQuantity" parameterType="com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryParentDO" >
UPDATE material_inventory
<set>
<trim prefix="inventory_quantity = CASE material_inventory_id" suffix="END,">
<foreach collection="materialInventoryDOList" item="item" index="index">
WHEN #{item.materialInventoryId} THEN inventory_quantity + #{item.inventoryQuantity}
</foreach>
</trim>
<trim prefix="allocation_quantity = CASE material_inventory_id" suffix="END,">
<foreach collection="materialInventoryDOList" item="item" index="index">
WHEN #{item.materialInventoryId} THEN allocation_quantity + #{item.inventoryQuantity}
</foreach>
</trim>
update_by = #{updateBy},
update_by_name = #{updateByName},
update_time = #{updateTime}
</set>
WHERE material_inventory_id IN
<foreach collection="materialInventoryDOList" item="item" index="index" separator="," open="(" close=")">
#{item.materialInventoryId}
</foreach>
</update>
<update id="batchSubtractInventoryQuantity" parameterType="com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryParentDO" >
UPDATE material_inventory
<set>
<trim prefix="inventory_quantity = CASE material_inventory_id" suffix="END,">
<foreach collection="materialInventoryDOList" item="item" index="index">
WHEN #{item.materialInventoryId} THEN GREATEST(inventory_quantity - #{item.inventoryQuantity}, 0)
</foreach>
</trim>
<trim prefix="allocation_quantity = CASE material_inventory_id" suffix="END,">
<foreach collection="materialInventoryDOList" item="item" index="index">
WHEN #{item.materialInventoryId} THEN GREATEST( allocation_quantity - #{item.inventoryQuantity}, 0)
</foreach>
</trim>
update_by = #{updateBy},
update_by_name = #{updateByName},
update_time = #{updateTime}
</set>
WHERE material_inventory_id IN
<foreach collection="materialInventoryDOList" item="item" index="index" separator="," open="(" close=")" >
#{item.materialInventoryId}
</foreach>
</update>
<update id="batchSubtractAllocationQuantity" parameterType="com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryParentDO" >
UPDATE material_inventory
<set>
allocation_quantity = CASE material_inventory_id
<foreach collection="materialInventoryDOList" item="item" index="index" separator=",">
WHEN #{item.materialInventoryId} THEN GREATEST(allocation_quantity - #{item.inventoryQuantity}, 0)
</foreach>
END,
update_by = #{updateBy},
update_by_name = #{updateByName},
update_time = #{updateTime}
</set>
WHERE material_inventory_id IN
<foreach collection="materialInventoryDOList" item="item" index="index" separator="," open="(" close=")">
#{item.materialInventoryId}
</foreach>
</update>
<update id="updateMaterial">
update material_inventory
set inventory_quantity = #{inventoryQuantity},allocation_quantity = #{allocationQuantity}
where material_inventory_id = #{materialInventoryId}
</update>
<update id="updatePanDian">
update material_inventory
set inventory_quantity = #{inventoryQuantity}
where storage_location_id = #{storageLocationId}
and material_baseInfo_id = #{materialBaseInfoId}
and container_id = #{containerId}
</update>
<resultMap type="com.mhd.wms.domain.statementStatistics.po.ImmediateInventoryPO" id="queryImmediateInventoryListResult">
<result property="shipperName" column="shipper_name" />
<result property="materialCode" column="material_code" />
<result property="materialName" column="material_name" />
<result property="barCode" column="bar_code" />
<result property="warehouseName" column="warehouse_name" />
<result property="inventoryQuantity" column="inventory_quantity" />
<result property="allocationQuantity" column="allocation_quantity" />
<result property="freezeQuantity" column="freeze_quantity" />
<result property="receivedQuantity" column="received_quantity" />
<result property="shelvesQuantity" column="shelves_quantity" />
<result property="pickQuantity" column="pick_quantity" />
</resultMap>
<select id="queryImmediateInventoryList" parameterType="com.mhd.wms.domain.statementStatistics.todo.ImmediateInventoryDO"
resultMap="queryImmediateInventoryListResult">
select
a.warehouse_id,
a.warehouse_name,
b.shipper_name,
b.material_name,
b.material_code,
b.bar_code,
sum(a.inventory_quantity) inventory_quantity,
sum(a.allocation_quantity) allocation_quantity,
sum(a.freeze_quantity) freeze_quantity,
ifnull(
(
SELECT
sum( c.receipt_quantity )
FROM
receipt_material_detail c
LEFT JOIN stock_receipt_order d ON c.receipt_order_number = d.receipt_order_number
AND d.del_flag = 1
LEFT JOIN stock_in_order e ON d.in_order_number = e.in_order_number
WHERE
c.del_flag = 1
AND e.warehouse_id = a.warehouse_id
AND e.shipper_id = b.shipper_id
AND c.material_base_info_id = b.material_base_info_id
),
0
) received_quantity,
ifnull(
(
SELECT
sum( c.shelves_quantity )
FROM
shelf_material_detail c
LEFT JOIN stock_shelf_order d ON c.shelf_order_number = d.shelf_order_number
AND d.del_flag = 1
LEFT JOIN stock_in_order e ON d.in_order_number = e.in_order_number
WHERE
c.del_flag = 1
AND e.warehouse_id = a.warehouse_id
AND e.shipper_id = b.shipper_id
AND c.material_base_info_id = b.material_base_info_id
),
0
) shelves_quantity,
ifnull(
(
SELECT
sum( c.picking_quantity )
FROM
picking_material_detail c
LEFT JOIN picking_order d ON c.picking_order_number = d.order_number
WHERE
c.del_flag = 1
AND d.warehouse_id = a.warehouse_id
AND d.shipper_id = b.shipper_id
AND c.material_base_info_id = b.material_base_info_id
),
0
) pick_quantity
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
<if test="topOrganizationId != null ">
and a.top_organization_id = #{topOrganizationId}
</if>
<if test="shipperName != null and shipperName != ''">
and b.shipper_name = #{shipperName}
</if>
<if test="warehouseId != null and warehouseId != '' ">
and a.warehouse_id = #{warehouseId}
</if>
<if test="warehouseName != null and warehouseName != '' ">
and a.warehouse_name = #{warehouseName}
</if>
<if test="materialName != null and materialName != '' ">
and b.material_name = #{materialName}
</if>
<if test="barCode != null and barCode != '' ">
and b.bar_code = #{barCode}
</if>
<if test="inventoryQuantityStart != null ">
and sum(a.inventory_quantity) > #{inventoryQuantityStart}
</if>
<if test="inventoryQuantityEnd != null ">
and sum(a.inventory_quantity) lt #{inventoryQuantityEnd}
</if>
<if test="allocationQuantityStart != null ">
and sum(a.allocation_quantity) > #{allocationQuantityStart}
</if>
<if test="allocationQuantityEnd != null ">
and sum(a.allocation_quantity)lt #{allocationQuantityEnd}
</if>
<if test="freezeQuantityStart != null ">
and sum(a.freeze_quantity) > #{freezeQuantityStart}
</if>
<if test="freezeQuantityEnd != null ">
and sum(a.freeze_quantity) lt #{freezeQuantityEnd}
</if>
<if test="receivedQuantityStart != null ">
and ifnull(
(
SELECT
sum( c.receipt_quantity )
FROM
receipt_material_detail c
LEFT JOIN stock_receipt_order d ON c.receipt_order_number = d.receipt_order_number
AND d.del_flag = 1
LEFT JOIN stock_in_order e ON d.in_order_number = e.in_order_number
WHERE
c.del_flag = 1
AND e.warehouse_id = a.warehouse_id
AND e.shipper_id = b.shipper_id
AND c.material_base_info_id = b.material_base_info_id
),
0
)> #{receivedQuantityStart}
</if>
<if test="receivedQuantityEnd != null ">
and ifnull(
(
SELECT
sum( c.receipt_quantity )
FROM
receipt_material_detail c
LEFT JOIN stock_receipt_order d ON c.receipt_order_number = d.receipt_order_number
AND d.del_flag = 1
LEFT JOIN stock_in_order e ON d.in_order_number = e.in_order_number
WHERE
c.del_flag = 1
AND e.warehouse_id = a.warehouse_id
AND e.shipper_id = b.shipper_id
AND c.material_base_info_id = b.material_base_info_id
),
0
) lt #{receivedQuantityEnd}
</if>
<if test="shelvesQuantityStart != null ">
and ifnull(
(
SELECT
sum( c.shelves_quantity )
FROM
shelf_material_detail c
LEFT JOIN stock_shelf_order d ON c.shelf_order_number = d.shelf_order_number
AND d.del_flag = 1
LEFT JOIN stock_in_order e ON d.in_order_number = e.in_order_number
WHERE
c.del_flag = 1
AND e.warehouse_id = a.warehouse_id
AND e.shipper_id = b.shipper_id
AND c.material_base_info_id = b.material_base_info_id
),
0
) > #{shelvesQuantityStart}
</if>
<if test="shelvesQuantityEnd != null ">
and ifnull(
(
SELECT
sum( c.shelves_quantity )
FROM
shelf_material_detail c
LEFT JOIN stock_shelf_order d ON c.shelf_order_number = d.shelf_order_number
AND d.del_flag = 1
LEFT JOIN stock_in_order e ON d.in_order_number = e.in_order_number
WHERE
c.del_flag = 1
AND e.warehouse_id = a.warehouse_id
AND e.shipper_id = b.shipper_id
AND c.material_base_info_id = b.material_base_info_id
),
0
) lt #{shelvesQuantityEnd}
</if>
<if test="pickQuantityStart != null ">
and ifnull(
(
SELECT
sum( c.picking_quantity )
FROM
picking_material_detail c
LEFT JOIN picking_order d ON c.picking_order_number = d.order_number
WHERE
c.del_flag = 1
AND d.warehouse_id = a.warehouse_id
AND d.shipper_id = b.shipper_id
AND c.material_base_info_id = b.material_base_info_id
),
0
) > #{pickQuantityStart}
</if>
<if test="pickQuantityEnd != null ">
and ifnull(
(
SELECT
sum( c.picking_quantity )
FROM
picking_material_detail c
LEFT JOIN picking_order d ON c.picking_order_number = d.order_number
WHERE
c.del_flag = 1
AND d.warehouse_id = a.warehouse_id
AND d.shipper_id = b.shipper_id
AND c.material_base_info_id = b.material_base_info_id
),
0
) lt #{pickQuantityEnd}
</if>
GROUP BY
a.warehouse_id,
a.material_base_info_id,
b.shipper_id
</select>
<select id="selectOneByWhere" parameterType="com.mhd.wms.domain.statementStatistics.todo.ImmediateInventoryDO"
resultMap="MaterialInventoryResult">
SELECT
sum(a.inventory_quantity) inventory_quantity,
a.organization_id,
a.organization_name,
a.top_organization_id,
a.material_base_info_id,
a.warehouse_id,
a.warehouse_code,
a.warehouse_name,
a.storage_section_id,
a.storage_code,
a.storage_name,
a.storage_location_id,
a.storage_location_code,
a.storage_location_name
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 AND b.shipper_id = #{shipperId} AND a.top_organization_id = #{topOrganizationId}
<if test="materialBaseInfoId != null and materialBaseInfoId != ''">
AND a.material_base_info_id = #{materialBaseInfoId}
</if>
<if test="warehouseId != null and warehouseId != ''">
AND a.warehouse_id = #{warehouseId}
</if>
<if test="storageSectionId != null and storageSectionId != ''">
AND a.storage_section_id = #{storageSectionId}
</if>
<if test="storageLocationId != null and storageLocationId != ''">
AND a.storage_location_id = #{storageLocationId}
</if>
</select>
</mapper>