入库排名统计(新增):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,按货品/线路汇总排名
125 lines
6.0 KiB
XML
125 lines
6.0 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 执行出库链路)
|
|
数据源:执行出库明细 execution_out_material_detail(a,仅 level=1 主行防重复) join 执行出库单 execution_stock_out_order(b)
|
|
口径:b.status = 9已出库(OMS 状态枚举 1~11,排除已取消(10)/已关闭(11),无 12/13);
|
|
日期按执行出库单创建时间 b.create_time
|
|
-->
|
|
<sql id="outboundRankConditions">
|
|
a.del_flag = 1
|
|
and a.level = 1
|
|
and b.del_flag = 1
|
|
and b.status = 9
|
|
<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="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 execution_out_material_detail a
|
|
join execution_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,
|
|
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.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,
|
|
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"/>
|
|
<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.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>
|
|
</select>
|
|
</mapper>
|