feat(wms,oms):库存管理新增入库排名统计(按仓单+货品汇总,件数降序,与出库排名tab配对);还原出库排名第一版源码

入库排名统计(新增):WMS /inboundRankApi、OMS /executionInboundRankApi 的 queryMaterialRankList 分页+合计、exportMaterialRank 导出;口径:仅已入库(status=5),明细仅level=1主行,日期区间按入仓日期warehouse_date筛选(必填);一行=仓单内某货品合计(GROUP BY 仓单+货品 ORDER BY 件数DESC);字段:入仓日期/仓单编号/客户编号/存货人/货名/件数/毛重(吨=KG/1000)/投保总额(货品档案保额,组内MAX防重复累加)/体积(CBM)+货号/规格/单位;合计行:totalPieceCount/totalGrossWeightTon/totalInsureAmount/totalVolume/totalOrderCount;登录上下文:日期必填校验+topOrganizationId租户隔离,WMS另注入关联仓库warehouseId。出库排名统计(还原第一版):/outboundRankApi、/executionOutboundRankApi,按货品/线路汇总排名
This commit is contained in:
rcx
2026-08-31 17:47:09 +08:00
parent a983ae639e
commit bf96f5f005
50 changed files with 2887 additions and 0 deletions
@@ -0,0 +1,104 @@
<?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.inboundRank.repository.mapper.InboundRankMapper">
<!--
入库排名统计公共查询条件
数据源:入库明细 in_material_detail(a,仅 level=1 主行防重复) join 入仓单 stock_in_order(b)
left join 货品档案 material_base_info(c,取保额作投保总额)
口径:b.status = 5已入库(排除已取消(6)/已关闭(7)及未完成单据);
日期筛选按入仓单入仓日期 b.warehouse_date(与列表"入仓日期"列同源);
一行 = 某仓单(b.in_order_number)内某货品(a.material_code)的合计,按件数降序排名
-->
<sql id="inboundRankConditions">
a.del_flag = 1
and a.level = 1
and b.status = 5
<if test="topOrganizationId != null">
and b.top_organization_id = #{topOrganizationId}
</if>
<if test="warehouseId != null">
and b.warehouse_id = #{warehouseId}
</if>
<if test="warehouseName != null and warehouseName != ''">
and b.warehouse_name like concat('%', #{warehouseName}, '%')
</if>
<if test="inOrderNumber != null and inOrderNumber != ''">
and b.in_order_number like concat('%', #{inOrderNumber}, '%')
</if>
<if test="shipperCode != null and shipperCode != ''">
and b.shipper_code like concat('%', #{shipperCode}, '%')
</if>
<if test="shipperName != null and shipperName != ''">
and b.shipper_name like concat('%', #{shipperName}, '%')
</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="warehouseDateStart != null and warehouseDateStart != ''">
and date_format(b.warehouse_date,'%Y-%m-%d') &gt;= #{warehouseDateStart}
</if>
<if test="warehouseDateEnd != null and warehouseDateEnd != ''">
and date_format(b.warehouse_date,'%Y-%m-%d') &lt;= #{warehouseDateEnd}
</if>
</sql>
<sql id="inboundRankFrom">
from in_material_detail a
join stock_in_order b on a.in_order_number = b.in_order_number and b.del_flag = 1
left join material_base_info c on a.material_base_info_id = c.material_base_info_id
</sql>
<!-- 商品入库排名列表(仓单+货品汇总,按件数降序) -->
<select id="queryMaterialRankList" parameterType="com.mhd.wms.domain.inboundRank.repository.todo.InboundRankDO"
resultType="com.mhd.wms.domain.inboundRank.repository.po.InboundMaterialRankPO">
select
MAX(b.warehouse_date) AS warehouseDate,
b.in_order_number AS inOrderNumber,
MAX(b.shipper_code) AS shipperCode,
MAX(b.shipper_name) AS shipperName,
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.PIECE_COUNT), 0) AS pieceCount,
ROUND(IFNULL(SUM(a.TOTAL_GROSS_WEIGHT), 0) / 1000, 3) AS grossWeightTon,
MAX(IFNULL(c.insure_amount, 0)) AS insureAmount,
IFNULL(SUM(a.TOTAL_VOLUME), 0) AS totalVolume
<include refid="inboundRankFrom"/>
<where>
<include refid="inboundRankConditions"/>
</where>
GROUP BY b.in_order_number, a.material_code
order by pieceCount desc, warehouseDate desc, inOrderNumber desc
</select>
<!-- 商品入库排名合计(当前筛选条件全量;外层对分组结果再汇总,保证投保总额合计=各行列值之和) -->
<select id="queryMaterialRankTotal" parameterType="com.mhd.wms.domain.inboundRank.repository.todo.InboundRankDO"
resultType="com.mhd.wms.domain.inboundRank.repository.po.InboundRankTotalPO">
select
IFNULL(SUM(t.pieceCount), 0) AS totalPieceCount,
ROUND(IFNULL(SUM(t.grossWeightKG), 0) / 1000, 3) AS totalGrossWeightTon,
IFNULL(SUM(t.insureAmount), 0) AS totalInsureAmount,
IFNULL(SUM(t.totalVolume), 0) AS totalVolume,
COUNT(DISTINCT t.inOrderNumber) AS totalOrderCount
from (
select
b.in_order_number AS inOrderNumber,
IFNULL(SUM(a.PIECE_COUNT), 0) AS pieceCount,
IFNULL(SUM(a.TOTAL_GROSS_WEIGHT), 0) AS grossWeightKG,
MAX(IFNULL(c.insure_amount, 0)) AS insureAmount,
IFNULL(SUM(a.TOTAL_VOLUME), 0) AS totalVolume
<include refid="inboundRankFrom"/>
<where>
<include refid="inboundRankConditions"/>
</where>
GROUP BY b.in_order_number, a.material_code
) t
</select>
</mapper>
@@ -0,0 +1,126 @@
<?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.outboundRank.repository.mapper.OutboundRankMapper">
<!--
出库排名统计公共查询条件
数据源:出库明细 out_material_detail(a,仅 level=1 主行防重复) join 出库单 stock_out_order(b)
口径:b.status in (9已出库,12已复核,13已交接),排除已取消(10)/已关闭(11);
日期按出库单创建时间 b.create_time(与出库单列表日期筛选一致)
-->
<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="warehouseId != null">
and b.warehouse_id = #{warehouseId}
</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="createTimeStart != null and createTimeStart != ''">
and date_format(b.create_time,'%Y-%m-%d') &gt;= #{createTimeStart}
</if>
<if test="createTimeEnd != null and createTimeEnd != ''">
and date_format(b.create_time,'%Y-%m-%d') &lt;= #{createTimeEnd}
</if>
</sql>
<sql id="outboundRankFrom">
from out_material_detail a
join 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.wms.domain.outboundRank.repository.todo.OutboundRankDO"
resultType="com.mhd.wms.domain.outboundRank.repository.po.OutboundMaterialRankPO">
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
<include refid="outboundRankFrom"/>
<where>
<include refid="outboundRankConditions"/>
<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>
</where>
GROUP BY a.material_code
order by salesQuantity desc
</select>
<!-- 线路出库排名列表(线路为空的历史单不参与线路排名) -->
<select id="queryLineRankList" parameterType="com.mhd.wms.domain.outboundRank.repository.todo.OutboundRankDO"
resultType="com.mhd.wms.domain.outboundRank.repository.po.OutboundLineRankPO">
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.wms.domain.outboundRank.repository.todo.OutboundRankDO"
resultType="com.mhd.wms.domain.outboundRank.repository.po.OutboundRankTotalPO">
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"/>
<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>
</where>
</select>
<!-- 线路出库排名合计(当前筛选条件全量) -->
<select id="queryLineRankTotal" parameterType="com.mhd.wms.domain.outboundRank.repository.todo.OutboundRankDO"
resultType="com.mhd.wms.domain.outboundRank.repository.po.OutboundRankTotalPO">
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>
</select>
</mapper>