- 在 IWmsMaterialCoilService 接口中新增 getDistributionByActualWarehouse 方法 - 实现钢卷按实际库区统计数量和重量的查询逻辑 - 添加对应的 Mapper XML 查询语句,支持按物品类型和 ID 过滤 - 在 Controller 中暴露新的 REST 接口 /distributionByActualWarehouse - 扩展 WmsStockBo 和 WmsStockVo 类以支持实际库区相关字段 - 新增 queryPageListActual 方法用于分页查询实际库区库存数据 - 实现递归查询子实际库区的功能,并应用到查询条件中 - 更新 Mapper 文件及服务实现类以支持新查询逻辑
166 lines
7.1 KiB
XML
166 lines
7.1 KiB
XML
<?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.klp.mapper.WmsMaterialCoilMapper">
|
|
|
|
<resultMap type="com.klp.domain.WmsMaterialCoil" id="WmsMaterialCoilResult">
|
|
<result property="coilId" column="coil_id"/>
|
|
<result property="enterCoilNo" column="enter_coil_no"/>
|
|
<result property="currentCoilNo" column="current_coil_no"/>
|
|
<result property="supplierCoilNo" column="supplier_coil_no"/>
|
|
<result property="dataType" column="data_type"/>
|
|
<result property="warehouseId" column="warehouse_id"/>
|
|
<result property="nextWarehouseId" column="next_warehouse_id"/>
|
|
<result property="qrcodeRecordId" column="qrcode_record_id"/>
|
|
<result property="team" column="team"/>
|
|
<result property="hasMergeSplit" column="has_merge_split"/>
|
|
<result property="parentCoilNos" column="parent_coil_nos"/>
|
|
<result property="itemType" column="item_type"/>
|
|
<result property="itemId" column="item_id"/>
|
|
<result property="grossWeight" column="gross_weight"/>
|
|
<result property="netWeight" column="net_weight"/>
|
|
<result property="status" column="status"/>
|
|
<result property="remark" column="remark"/>
|
|
<result property="delFlag" column="del_flag"/>
|
|
<result property="createTime" column="create_time"/>
|
|
<result property="createBy" column="create_by"/>
|
|
<result property="updateTime" column="update_time"/>
|
|
<result property="updateBy" column="update_by"/>
|
|
</resultMap>
|
|
|
|
<!-- 统计查询专用的ResultMap -->
|
|
<resultMap type="com.klp.domain.vo.WmsMaterialCoilVo" id="WmsMaterialCoilDistributionResult">
|
|
<result property="warehouseId" column="warehouse_id"/>
|
|
<result property="warehouseName" column="warehouse_name"/>
|
|
<result property="itemType" column="item_type"/>
|
|
<result property="coilCount" column="coil_count"/>
|
|
<result property="totalGrossWeight" column="total_gross_weight"/>
|
|
<result property="totalNetWeight" column="total_net_weight"/>
|
|
</resultMap>
|
|
|
|
<!-- 查询各个库区中钢卷的汇总分布情况(按仓库汇总) -->
|
|
<select id="getDistributionByWarehouse" resultType="java.util.Map">
|
|
SELECT
|
|
w.warehouse_id,
|
|
w.warehouse_name,
|
|
COUNT(mc.coil_id) as coil_count,
|
|
COALESCE(SUM(mc.gross_weight), 0) as total_gross_weight,
|
|
COALESCE(SUM(mc.net_weight), 0) as total_net_weight
|
|
FROM wms_warehouse w
|
|
LEFT JOIN wms_material_coil mc ON w.warehouse_id = mc.warehouse_id
|
|
AND mc.data_type = 1
|
|
AND mc.del_flag = '0'
|
|
WHERE w.del_flag = '0'
|
|
<if test="itemType != null and itemType != ''">
|
|
AND mc.item_type = #{itemType}
|
|
</if>
|
|
<if test="itemId != null">
|
|
AND mc.item_id = #{itemId}
|
|
</if>
|
|
GROUP BY w.warehouse_id, w.warehouse_name
|
|
ORDER BY w.warehouse_id
|
|
</select>
|
|
<select id="selectVoPagePlus" resultType="com.klp.domain.vo.WmsMaterialCoilVo">
|
|
SELECT
|
|
mc.coil_id,
|
|
mc.enter_coil_no,
|
|
mc.current_coil_no,
|
|
mc.supplier_coil_no,
|
|
mc.data_type,
|
|
mc.next_warehouse_id,
|
|
mc.qrcode_record_id,
|
|
mc.team,
|
|
mc.has_merge_split,
|
|
mc.parent_coil_nos,
|
|
mc.item_type,
|
|
mc.item_id,
|
|
mc.gross_weight,
|
|
mc.net_weight,
|
|
mc.status,
|
|
mc.remark,
|
|
mc.warehouse_id,
|
|
mc.actual_warehouse_id,
|
|
mc.del_flag,
|
|
mc.create_time,
|
|
mc.update_time,
|
|
mc.create_by,
|
|
mc.update_by,
|
|
w.warehouse_name AS warehouseName,
|
|
aw.actual_warehouse_name AS actualWarehouseName
|
|
FROM wms_material_coil mc
|
|
LEFT JOIN wms_warehouse w ON mc.warehouse_id = w.warehouse_id
|
|
LEFT JOIN wms_actual_warehouse aw ON mc.actual_warehouse_id = aw.actual_warehouse_id
|
|
${ew.customSqlSegment}
|
|
</select>
|
|
<!-- 查询不同类型的钢卷在不同库区的分布情况 -->
|
|
<select id="getDistributionByItemType" resultType="java.util.Map">
|
|
SELECT
|
|
mc.item_type,
|
|
mc.item_id,
|
|
w.warehouse_id,
|
|
w.warehouse_name,
|
|
COUNT(mc.coil_id) as coil_count,
|
|
COALESCE(SUM(mc.gross_weight), 0) as total_gross_weight,
|
|
COALESCE(SUM(mc.net_weight), 0) as total_net_weight
|
|
FROM wms_material_coil mc
|
|
LEFT JOIN wms_warehouse w ON mc.warehouse_id = w.warehouse_id
|
|
WHERE mc.data_type = 1
|
|
AND mc.del_flag = '0'
|
|
AND (w.del_flag = '0' OR w.del_flag IS NULL)
|
|
<if test="itemType != null and itemType != ''">
|
|
AND mc.item_type = #{itemType}
|
|
</if>
|
|
<if test="itemId != null">
|
|
AND mc.item_id = #{itemId}
|
|
</if>
|
|
GROUP BY mc.item_type, mc.item_id, w.warehouse_id, w.warehouse_name
|
|
ORDER BY mc.item_type, mc.item_id, w.warehouse_id
|
|
</select>
|
|
<select id="selectVoListWithDynamicJoin" resultType="com.klp.domain.vo.WmsMaterialCoilVo">
|
|
SELECT mc.*,
|
|
w.warehouse_name AS warehouseName,
|
|
aw.warehouse_name AS actualWarehouseName,
|
|
CASE
|
|
WHEN mc.item_type = 'row_material' THEN rm.raw_material_name
|
|
WHEN mc.item_type = 'product' THEN p.product_name
|
|
ELSE NULL
|
|
END as itemName,
|
|
CASE
|
|
WHEN mc.item_type = 'row_material' THEN rm.raw_material_code
|
|
WHEN mc.item_type = 'product' THEN p.product_code
|
|
ELSE NULL
|
|
END as itemCode
|
|
FROM wms_material_coil mc
|
|
LEFT JOIN wms_raw_material rm ON mc.item_type = 'row_material' AND mc.item_id = rm.raw_material_id
|
|
LEFT JOIN wms_product p ON mc.item_type = 'product' AND mc.item_id = p.product_id
|
|
LEFT JOIN wms_warehouse w ON mc.warehouse_id = w.warehouse_id
|
|
LEFT JOIN wms_actual_warehouse aw ON mc.actual_warehouse_id = aw.actual_warehouse_id
|
|
${ew.customSqlSegment}
|
|
</select>
|
|
<select id="getDistributionByActualWarehouse" resultType="java.util.Map">
|
|
SELECT
|
|
w.actual_warehouse_id,
|
|
w.actual_warehouse_name,
|
|
COUNT(mc.coil_id) as coil_count,
|
|
COALESCE(SUM(mc.gross_weight), 0) as total_gross_weight,
|
|
COALESCE(SUM(mc.net_weight), 0) as total_net_weight
|
|
FROM wms_actual_warehouse w
|
|
LEFT JOIN wms_material_coil mc ON w.actual_warehouse_id = mc.actual_warehouse_id
|
|
AND mc.data_type = 1
|
|
AND mc.del_flag = '0'
|
|
WHERE w.del_flag = '0'
|
|
<if test="itemType != null and itemType != ''">
|
|
AND mc.item_type = #{itemType}
|
|
</if>
|
|
<if test="itemId != null">
|
|
AND mc.item_id = #{itemId}
|
|
</if>
|
|
GROUP BY w.actual_warehouse_id, w.actual_warehouse_name
|
|
ORDER BY w.actual_warehouse_id
|
|
</select>
|
|
|
|
|
|
</mapper>
|
|
|