- 商品tab:一行=一个货品(跨出库单汇总),返回 货号/货名/件数/毛重(吨)/体积(CBM)/退保总额(占位null),忽略线路筛选参数 - 线路tab:一行=线路×货品(按线路+物料编码合并),额外返回 线路编码/线路,仅统计带线路的单(排除line_code为空的历史单);商品/线路筛选参数均生效 - 单据级字段(种类/仓单编号/入库单号/客户编号/收货人/出仓日期)合并后无单值可对应,不再返回 - 件数=SUM(CHECK_QUANTITY)复核确认的实际出库量(与入库排名实际上架量SHELVES_QUANTITY对称),按件数降序,编码次之 - 合计行:件数/毛重吨/体积 全量合计;商品tab含totalOrderCount(去重出库单数),线路tab含totalOrderCount+totalLineCount(去重线路数) - 数据源不变:WMS查本库出库表,OMS跨库查NGWL_TEST_WMS同名表,两边数字一致;接口路径/传参不变
134 lines
7.7 KiB
XML
134 lines
7.7 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.mhd.oms.domain.outboundRank.repository.mapper.ExecutionOutboundRankMapper">
|
||
|
||
<!--
|
||
出库排名统计公共查询条件(OMS 端,跨库取 WMS 出库数据)
|
||
数据源:WMS 库出库明细 NGWL_TEST_WMS.out_material_detail(a,仅 level=1 主行防重复)
|
||
join WMS 库出库单 NGWL_TEST_WMS.stock_out_order(b)
|
||
说明:OMS 库出库单状态不流转(无"已出库"数据),"已出库"状态的真实数据在 WMS 库,
|
||
故跨库取数(与 OMS 库存查询跨库 join NGWL_TEST_WMS.material_base_info 同一模式),
|
||
口径与 WMS 端 /outboundRankApi 完全一致,两边数字一致;
|
||
条件:b.status in (9已出库,12已复核,13已交接),排除已取消(10)/已关闭(11);
|
||
日期按出库单创建时间 b.create_time;
|
||
商品排名:一行 = 一个货品(GROUP BY a.material_code),区间内跨单汇总,按实际出库量降序;
|
||
线路排名:一行 = 线路×货品(GROUP BY b.line_code, a.material_code),仅统计带线路的单;
|
||
件数 = SUM(a.CHECK_QUANTITY) 复核确认的实际出库量(与入库排名的实际上架量 SHELVES_QUANTITY 对称)
|
||
-->
|
||
<sql id="outboundRankConditions">
|
||
a.del_flag = 1
|
||
and a.level = 1
|
||
and b.status in (9, 12, 13)
|
||
<if test="topOrganizationId != null">
|
||
and b.top_organization_id = #{topOrganizationId}
|
||
</if>
|
||
<if test="warehouseName != null and warehouseName != ''">
|
||
and b.warehouse_name like concat('%', #{warehouseName}, '%')
|
||
</if>
|
||
<if test="customerName != null and customerName != ''">
|
||
and b.customer_name like concat('%', #{customerName}, '%')
|
||
</if>
|
||
<if test="shipperName != null and shipperName != ''">
|
||
and b.shipper_name like concat('%', #{shipperName}, '%')
|
||
</if>
|
||
<if test="lineCode != null and lineCode != ''">
|
||
and b.line_code like concat('%', #{lineCode}, '%')
|
||
</if>
|
||
<if test="lineName != null and lineName != ''">
|
||
and b.line_name like concat('%', #{lineName}, '%')
|
||
</if>
|
||
<if test="outOrderNumber != null and outOrderNumber != ''">
|
||
and b.out_order_number like concat('%', #{outOrderNumber}, '%')
|
||
</if>
|
||
<if test="inOrderNumber != null and inOrderNumber != ''">
|
||
and a.in_order_number like concat('%', #{inOrderNumber}, '%')
|
||
</if>
|
||
<if test="materialCode != null and materialCode != ''">
|
||
and a.material_code like concat('%', #{materialCode}, '%')
|
||
</if>
|
||
<if test="materialName != null and materialName != ''">
|
||
and a.material_name like concat('%', #{materialName}, '%')
|
||
</if>
|
||
<if test="createTimeStart != null and createTimeStart != ''">
|
||
and date_format(b.create_time,'%Y-%m-%d') >= #{createTimeStart}
|
||
</if>
|
||
<if test="createTimeEnd != null and createTimeEnd != ''">
|
||
and date_format(b.create_time,'%Y-%m-%d') <= #{createTimeEnd}
|
||
</if>
|
||
</sql>
|
||
|
||
<sql id="outboundRankFrom">
|
||
from NGWL_TEST_WMS.out_material_detail a
|
||
join NGWL_TEST_WMS.stock_out_order b on a.out_order_number = b.out_order_number and b.del_flag = 1
|
||
</sql>
|
||
|
||
<!-- 商品出库排名列表(按物料编码合并,跨单汇总;退保总额暂无后端字段不提供) -->
|
||
<select id="queryMaterialRankList" parameterType="com.mhd.oms.domain.outboundRank.repository.todo.ExecutionOutboundRankDO"
|
||
resultType="com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundMaterialRankPO">
|
||
select
|
||
a.material_code AS materialCode,
|
||
MAX(a.material_name) AS materialName,
|
||
IFNULL(SUM(a.CHECK_QUANTITY), 0) AS pieceCount,
|
||
ROUND(IFNULL(SUM(a.TOTAL_GROSS_WEIGHT), 0) / 1000, 3) AS grossWeightTon,
|
||
IFNULL(SUM(a.TOTAL_VOLUME), 0) AS totalVolume
|
||
<include refid="outboundRankFrom"/>
|
||
<where>
|
||
<include refid="outboundRankConditions"/>
|
||
</where>
|
||
GROUP BY a.material_code
|
||
order by pieceCount desc, materialCode asc
|
||
</select>
|
||
|
||
<!-- 商品出库排名合计(当前筛选条件全量) -->
|
||
<select id="queryMaterialRankTotal" parameterType="com.mhd.oms.domain.outboundRank.repository.todo.ExecutionOutboundRankDO"
|
||
resultType="com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundDetailRankTotalPO">
|
||
select
|
||
IFNULL(SUM(a.CHECK_QUANTITY), 0) AS totalPieceCount,
|
||
ROUND(IFNULL(SUM(a.TOTAL_GROSS_WEIGHT), 0) / 1000, 3) AS totalGrossWeightTon,
|
||
IFNULL(SUM(a.TOTAL_VOLUME), 0) AS totalVolume,
|
||
COUNT(DISTINCT a.out_order_number) AS totalOrderCount
|
||
<include refid="outboundRankFrom"/>
|
||
<where>
|
||
<include refid="outboundRankConditions"/>
|
||
</where>
|
||
</select>
|
||
|
||
<!-- 线路出库排名列表(线路+物料编码合并,仅统计带线路的单;商品/线路筛选参数均生效) -->
|
||
<select id="queryLineRankList" parameterType="com.mhd.oms.domain.outboundRank.repository.todo.ExecutionOutboundRankDO"
|
||
resultType="com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundLineRankPO">
|
||
select
|
||
b.line_code AS lineCode,
|
||
MAX(b.line_name) AS lineName,
|
||
a.material_code AS materialCode,
|
||
MAX(a.material_name) AS materialName,
|
||
IFNULL(SUM(a.CHECK_QUANTITY), 0) AS pieceCount,
|
||
ROUND(IFNULL(SUM(a.TOTAL_GROSS_WEIGHT), 0) / 1000, 3) AS grossWeightTon,
|
||
IFNULL(SUM(a.TOTAL_VOLUME), 0) AS totalVolume
|
||
<include refid="outboundRankFrom"/>
|
||
<where>
|
||
<include refid="outboundRankConditions"/>
|
||
and b.line_code is not null and b.line_code != ''
|
||
</where>
|
||
GROUP BY b.line_code, a.material_code
|
||
order by pieceCount desc, lineCode asc, materialCode asc
|
||
</select>
|
||
|
||
<!-- 线路出库排名合计(当前筛选条件全量) -->
|
||
<select id="queryLineRankTotal" parameterType="com.mhd.oms.domain.outboundRank.repository.todo.ExecutionOutboundRankDO"
|
||
resultType="com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundDetailRankTotalPO">
|
||
select
|
||
IFNULL(SUM(a.CHECK_QUANTITY), 0) AS totalPieceCount,
|
||
ROUND(IFNULL(SUM(a.TOTAL_GROSS_WEIGHT), 0) / 1000, 3) AS totalGrossWeightTon,
|
||
IFNULL(SUM(a.TOTAL_VOLUME), 0) AS totalVolume,
|
||
COUNT(DISTINCT b.line_code) AS totalLineCount,
|
||
COUNT(DISTINCT b.out_order_number) AS totalOrderCount
|
||
<include refid="outboundRankFrom"/>
|
||
<where>
|
||
<include refid="outboundRankConditions"/>
|
||
and b.line_code is not null and b.line_code != ''
|
||
</where>
|
||
</select>
|
||
</mapper>
|