feat(wms,oms):出库排名统计改造为仓单×货品明细列表,按出库数量降序排名

- 字段:种类/仓单编号/入库单号/客户编号/收货人/货名/线路/件数/毛重(吨)/体积(CBM)/退保总额(占位null,数据来源待确认)/出仓日期

- 商品/线路各一套接口,路径名不变;商品接口忽略线路筛选参数,线路接口忽略商品筛选参数;含合计行(件数/毛重吨/体积/仓单数)与Excel导出

- 统计口径不变:出库单创建时间区间+已出库状态(9,12,13)+明细level=1主行;排序按出库数量(销售量)降序,件数/出仓日期/单号次之

- 数据源:WMS查本库出库表;OMS跨库查NGWL_TEST_WMS同名表(OMS库出库单状态不流转,跨库与WMS端数字一致)

- 删除原按商品/线路聚合的排名接口(销售量/交易数/金额字段)
This commit is contained in:
rcx
2026-09-02 15:25:51 +08:00
parent e821619a96
commit 3af78d5d7b
28 changed files with 554 additions and 684 deletions
@@ -5,14 +5,14 @@
<mapper namespace="com.mhd.oms.domain.outboundRank.repository.mapper.ExecutionOutboundRankMapper">
<!--
出库排名统计公共查询条件(OMS 端,跨库取 WMS 出库数据)
出库排名统计(明细)公共查询条件(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
日期按出库单创建时间 b.create_time;一行 = 某仓单内某货品的合计,按出库数量(销售量)降序,件数/出仓日期/单号次之
-->
<sql id="outboundRankConditions">
a.del_flag = 1
@@ -36,6 +36,12 @@
<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>
@@ -55,67 +61,50 @@
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 id="queryDetailList" parameterType="com.mhd.oms.domain.outboundRank.repository.todo.ExecutionOutboundRankDO"
resultType="com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundDetailRankPO">
select
a.material_code AS materialCode,
MAX(a.material_name) AS materialName,
MAX(a.SPECIFICATION_MODEL) AS specificationModel,
MAX(a.unit_name) AS unitName,
IFNULL(SUM(a.outbound_quantity), 0) AS salesQuantity,
COUNT(DISTINCT a.out_order_number) AS tradeCount,
IFNULL(SUM(IFNULL(a.TOTAL_AMOUNT, 0)), 0) AS amount
MAX(b.ORDER_TYPE_NAME) AS orderTypeName,
b.out_order_number AS outOrderNumber,
MAX(a.in_order_number) AS inOrderNumber,
MAX(b.customer_code) AS customerCode,
MAX(IFNULL(b."TO", b.contact_person)) AS receiver,
a.material_code AS materialCode,
MAX(a.material_name) AS materialName,
MAX(b.line_code) AS lineCode,
MAX(b.line_name) AS lineName,
IFNULL(SUM(a.PIECE_COUNT), 0) AS pieceCount,
ROUND(IFNULL(SUM(a.TOTAL_GROSS_WEIGHT), 0) / 1000, 3) AS grossWeightTon,
IFNULL(SUM(a.TOTAL_VOLUME), 0) AS totalVolume,
MAX(IFNULL(b.OUTBOUND_DATE, IFNULL(b.COMPLETE_TIME, b.create_time))) AS outboundDate
<include refid="outboundRankFrom"/>
<where>
<include refid="outboundRankConditions"/>
</where>
GROUP BY a.material_code
order by salesQuantity desc
GROUP BY b.out_order_number, a.material_code
order by IFNULL(SUM(a.outbound_quantity), 0) desc, pieceCount desc, outboundDate desc, outOrderNumber desc
</select>
<!-- 线路出库排名列表(线路为空的历史单不参与线路排名 -->
<select id="queryLineRankList" parameterType="com.mhd.oms.domain.outboundRank.repository.todo.ExecutionOutboundRankDO"
resultType="com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundLineRankPO">
<!-- 出库明细合计(当前筛选条件全量;外层对分组结果再汇总,与入库排名同模板 -->
<select id="queryDetailTotal" parameterType="com.mhd.oms.domain.outboundRank.repository.todo.ExecutionOutboundRankDO"
resultType="com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundDetailRankTotalPO">
select
b.line_code AS lineCode,
MAX(b.line_name) AS lineName,
IFNULL(SUM(a.outbound_quantity), 0) AS salesQuantity,
COUNT(DISTINCT b.out_order_number) AS tradeCount,
IFNULL(SUM(IFNULL(a.TOTAL_AMOUNT, 0)), 0) AS amount
<include refid="outboundRankFrom"/>
<where>
<include refid="outboundRankConditions"/>
and b.line_code is not null and b.line_code != ''
</where>
GROUP BY b.line_code
order by salesQuantity desc
</select>
<!-- 商品出库排名合计(当前筛选条件全量) -->
<select id="queryMaterialRankTotal" parameterType="com.mhd.oms.domain.outboundRank.repository.todo.ExecutionOutboundRankDO"
resultType="com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundRankTotalPO">
select
IFNULL(SUM(a.outbound_quantity), 0) AS totalSalesQuantity,
COUNT(DISTINCT a.out_order_number) AS totalTradeCount,
IFNULL(SUM(IFNULL(a.TOTAL_AMOUNT, 0)), 0) AS totalAmount
<include refid="outboundRankFrom"/>
<where>
<include refid="outboundRankConditions"/>
</where>
</select>
<!-- 线路出库排名合计(当前筛选条件全量) -->
<select id="queryLineRankTotal" parameterType="com.mhd.oms.domain.outboundRank.repository.todo.ExecutionOutboundRankDO"
resultType="com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundRankTotalPO">
select
IFNULL(SUM(a.outbound_quantity), 0) AS totalSalesQuantity,
COUNT(DISTINCT b.out_order_number) AS totalTradeCount,
IFNULL(SUM(IFNULL(a.TOTAL_AMOUNT, 0)), 0) AS totalAmount
<include refid="outboundRankFrom"/>
<where>
<include refid="outboundRankConditions"/>
and b.line_code is not null and b.line_code != ''
</where>
IFNULL(SUM(t.pieceCount), 0) AS totalPieceCount,
ROUND(IFNULL(SUM(t.grossWeightKG), 0) / 1000, 3) AS totalGrossWeightTon,
IFNULL(SUM(t.totalVolume), 0) AS totalVolume,
COUNT(DISTINCT t.outOrderNumber) AS totalOrderCount
from (
select
b.out_order_number AS outOrderNumber,
IFNULL(SUM(a.PIECE_COUNT), 0) AS pieceCount,
IFNULL(SUM(a.TOTAL_GROSS_WEIGHT), 0) AS grossWeightKG,
IFNULL(SUM(a.TOTAL_VOLUME), 0) AS totalVolume
<include refid="outboundRankFrom"/>
<where>
<include refid="outboundRankConditions"/>
</where>
GROUP BY b.out_order_number, a.material_code
) t
</select>
</mapper>