- OMS入库业务单/执行单: list/list1返回totalPlanQuantity/totalInQuantity(与行quantity/in_quantity列同源) - WMS入库/收货/上架: 返回totalPlanQuantity/totalInQuantity(上架计划数量=明细应上架量; 入库数量=收货/上架数量, 与行列同口径) - WMS出库/拣货/复核/交接: 返回totalPlanQuantity/totalOutboundQuantity(各页实际量列同口径; 复核明细聚合不滤del_flag兼容已反审tab) - 合计SQL与queryList同条件片段/同JOIN结构, 分页查询后同一DO查询, 响应与total同层级追加字段, 前端纯增量兼容
218 lines
12 KiB
XML
218 lines
12 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.wms.domain.stockReceiptOrder.repository.mapper.StockReceiptOrderMapper">
|
|
|
|
<resultMap type="com.mhd.wms.domain.stockReceiptOrder.repository.po.StockReceiptOrderPO" id="StockReceiptOrderResult">
|
|
<result property="receiptOrderId" column="receipt_order_id" />
|
|
<result property="organizationId" column="organization_id" />
|
|
<result property="organizationName" column="organization_name" />
|
|
<result property="topOrganizationId" column="top_organization_id" />
|
|
<result property="receiptOrderNumber" column="receipt_order_number" />
|
|
<result property="status" column="status" />
|
|
<result property="platformId" column="platform_id" />
|
|
<result property="platformCode" column="platform_code" />
|
|
<result property="platformName" column="platform_name" />
|
|
<result property="platformUseTimeId" column="platform_use_time_id" />
|
|
<result property="platformUseStartTime" column="platform_use_start_time" />
|
|
<result property="platformUseEndTime" column="platform_use_end_time" />
|
|
<result property="platformUseStatus" column="platform_use_status" />
|
|
<result property="quantity" column="quantity" />
|
|
<result property="receiptQuantity" column="receipt_quantity" />
|
|
<result property="receiptMaterialQuantity" column="receipt_material_quantity" />
|
|
<result property="materialQuantity" column="material_quantity" />
|
|
<result property="abnormal" column="abnormal" />
|
|
<result property="taskDistribution" column="task_distribution" />
|
|
<result property="taskDistributionTime" column="task_distribution_time" />
|
|
<result property="operatorsBy" column="operators_by" />
|
|
<result property="operatorsName" column="operators_name" />
|
|
<result property="remark" column="remark" />
|
|
<result property="createTime" column="create_time" />
|
|
<result property="createBy" column="create_by" />
|
|
<result property="createByName" column="create_by_name" />
|
|
<result property="updateTime" column="update_time" />
|
|
<result property="updateBy" column="update_by" />
|
|
<result property="updateByName" column="update_by_name" />
|
|
<result property="delFlag" column="del_flag" />
|
|
<result property="copyCode" column="copy_code"/>
|
|
<result property="batchNumber" column="batch_number"/>
|
|
<result property="materialCode" column="material_code"/>
|
|
<result property="netWeight" column="netWeight"/>
|
|
<result property="grossWeight" column="grossWeight"/>
|
|
<result property="boxPalletNo" column="boxPalletNo"/>
|
|
<result property="serialNumber" column="serial_number"/>
|
|
<result property="billingJson" column="billing_json" />
|
|
<result property="businessOrderNo" column="business_order_no" />
|
|
<result property="batchNo" column="batch_no" />
|
|
<result property="reverseAuditStatus" column="REVERSE_AUDIT_STATUS" />
|
|
<result property="reverseAuditRemark" column="REVERSE_AUDIT_REMARK" />
|
|
<result property="reverseAuditBy" column="REVERSE_AUDIT_BY" />
|
|
<result property="reverseAuditByName" column="REVERSE_AUDIT_BY_NAME" />
|
|
<result property="reverseAuditTime" column="REVERSE_AUDIT_TIME" />
|
|
|
|
</resultMap>
|
|
|
|
|
|
<sql id="selectStockReceiptOrderPo">
|
|
a.receipt_order_id, a.organization_id, a.organization_name, a.top_organization_id, a.in_order_number, a.receipt_order_number,
|
|
a.status, a.platform_id, a.platform_code, a.platform_name, a.platform_use_time_id, a.platform_use_start_time, a.platform_use_end_time,
|
|
a.platform_use_status, a.quantity, a.receipt_quantity, a.receipt_material_quantity, a.material_quantity, a.abnormal, a.task_distribution, a.task_distribution_time,
|
|
a.operators_by, a.operators_name, a.remark, a.create_time, a.create_by, a.create_by_name,
|
|
a.update_time, a.update_by, a.update_by_name, a.del_flag, a.billing_json,a.business_order_no,a.batch_no,
|
|
a.REVERSE_AUDIT_STATUS, a.REVERSE_AUDIT_REMARK, a.REVERSE_AUDIT_BY, a.REVERSE_AUDIT_BY_NAME, a.REVERSE_AUDIT_TIME
|
|
</sql>
|
|
|
|
<sql id="selectStockReceiptOrderPo1">
|
|
1=1
|
|
<if test="receiptOrderId != null ">
|
|
and a.receipt_order_id = #{receiptOrderId}
|
|
</if>
|
|
<if test="organizationId != null ">
|
|
and a.organization_id = #{organizationId}
|
|
</if>
|
|
<if test="organizationName != null and organizationName != ''">
|
|
and a.organization_name like concat('%', #{organizationName}, '%')
|
|
</if>
|
|
<if test="topOrganizationId != null ">
|
|
and a.top_organization_id = #{topOrganizationId}
|
|
</if>
|
|
<if test="inOrderNumber != null and inOrderNumber != '' ">
|
|
and a.in_order_number like concat('%', #{inOrderNumber}, '%')
|
|
</if>
|
|
<if test="receiptOrderNumber != null and receiptOrderNumber != ''">
|
|
and a.receipt_order_number like concat('%', #{receiptOrderNumber}, '%')
|
|
</if>
|
|
<if test="taskDistributionMerge != null ">
|
|
and a.task_distribution_merge = #{taskDistributionMerge}
|
|
</if>
|
|
<if test="status != null ">
|
|
and a.status = #{status}
|
|
</if>
|
|
<if test="ltStatus != null ">
|
|
and a.status < #{ltStatus}
|
|
</if>
|
|
<if test="gtStatus != null ">
|
|
and a.status > #{gtStatus}
|
|
</if>
|
|
<if test="platformId != null ">
|
|
and a.platform_id = #{platformId}
|
|
</if>
|
|
<if test="platformCode != null and platformCode != ''">
|
|
and a.platform_code = #{platformCode}
|
|
</if>
|
|
<if test="platformName != null and platformName != ''">
|
|
and a.platform_name like concat('%', #{platformName}, '%')
|
|
</if>
|
|
<if test="platformUseTimeId != null ">
|
|
and a.platform_use_time_id = #{platformUseTimeId}
|
|
</if>
|
|
<if test="platformUseStartTime != null ">
|
|
and a.platform_use_start_time = #{platformUseStartTime}
|
|
</if>
|
|
<if test="platformUseEndTime != null ">
|
|
and a.platform_use_end_time = #{platformUseEndTime}
|
|
</if>
|
|
<if test="platformUseStatus != null ">
|
|
and a.platform_use_status = #{platformUseStatus}
|
|
</if>
|
|
<if test="receiptQuantity != null ">
|
|
and a.receipt_quantity = #{receiptQuantity}
|
|
</if>
|
|
<if test="abnormal != null ">
|
|
and a.abnormal = #{abnormal}
|
|
</if>
|
|
<if test="taskDistribution != null ">
|
|
and a.task_distribution = #{taskDistribution}
|
|
</if>
|
|
<if test="operatorsBy != null and operatorsBy != ''">
|
|
and a.operators_by = #{operatorsBy}
|
|
</if>
|
|
<if test="createByName != null and createByName != ''">
|
|
and a.create_by_name like concat('%', #{createByName}, '%')
|
|
</if>
|
|
<if test="updateByName != null and updateByName != ''">
|
|
and a.update_by_name like concat('%', #{updateByName}, '%')
|
|
</if>
|
|
<if test="receiptOrderIds != null and receiptOrderIds.size > 0 ">
|
|
and a.receipt_order_id in
|
|
<foreach collection="receiptOrderIds" item="item" index="index" open="(" close=")" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
<if test="createTimeStart != null and createTimeStart != ''">
|
|
and date_format(a.create_time,'%Y-%m-%d') >= #{createTimeStart}
|
|
</if>
|
|
<if test="createTimeEnd != null and createTimeEnd != ''">
|
|
and date_format(a.create_time,'%Y-%m-%d') <= #{createTimeEnd}
|
|
</if>
|
|
<!-- 反审状态过滤:收货单【已反审】tab 传 reverseAuditStatus=1,查询已软删且打反审标记的归档数据 -->
|
|
<choose>
|
|
<when test="reverseAuditStatus != null">
|
|
and a.REVERSE_AUDIT_STATUS = #{reverseAuditStatus}
|
|
and a.del_flag = 2
|
|
</when>
|
|
<otherwise>
|
|
<choose>
|
|
<when test="delFlag != null"> and a.del_flag = #{delFlag} </when>
|
|
<otherwise> and a.del_flag = 1 </otherwise>
|
|
</choose>
|
|
</otherwise>
|
|
</choose>
|
|
|
|
</sql>
|
|
|
|
<select id="queryList" parameterType="com.mhd.wms.domain.stockReceiptOrder.repository.todo.StockReceiptOrderDO" resultMap="StockReceiptOrderResult">
|
|
select
|
|
<include refid="selectStockReceiptOrderPo"/>
|
|
<include refid="com.mhd.wms.domain.stockInOrder.repository.mapper.StockInOrderMapper.joinStockInOrderPo"/>
|
|
from stock_receipt_order a
|
|
<!-- 已反审tab查归档数据: a/b 均已软删(del_flag=2), 仍按 del_flag=1 关联会导致 b 全为 NULL,
|
|
基于 b 的过滤条件(仓库/货主等)随之失效为 false, 列表恒为空; 故按是否查反审归档切换关联条件 -->
|
|
LEFT JOIN stock_in_order b ON a.in_order_number = b.in_order_number
|
|
<choose>
|
|
<when test="reverseAuditStatus != null">
|
|
and a.DEL_FLAG = 2 and b.DEL_FLAG = 2
|
|
<!-- 历史重复下发会产生同号多张入库单,限定只关联同状态最新一张,防止列表出现重复行 -->
|
|
and b.IN_ORDER_ID = (select max(c.IN_ORDER_ID) from stock_in_order c
|
|
where c.IN_ORDER_NUMBER = a.in_order_number and c.DEL_FLAG = 2)
|
|
</when>
|
|
<otherwise>
|
|
and a.DEL_FLAG = 1 and b.DEL_FLAG = 1
|
|
and b.IN_ORDER_ID = (select max(c.IN_ORDER_ID) from stock_in_order c
|
|
where c.IN_ORDER_NUMBER = a.in_order_number and c.DEL_FLAG = 1)
|
|
</otherwise>
|
|
</choose>
|
|
<where>
|
|
<include refid="selectStockReceiptOrderPo1"/>
|
|
<include refid="com.mhd.wms.domain.stockInOrder.repository.mapper.StockInOrderMapper.joinStockInOrderPoWhere"/>
|
|
</where>
|
|
ORDER BY a.create_time DESC
|
|
</select>
|
|
|
|
<!-- 列表合计:与queryList完全同构(FROM/JOIN/WHERE一致, 含反审归档del_flag切换与最新入库单去重关联), 仅SELECT换成全量聚合;
|
|
计划数量与行的quantity列同源, 入库数量与行的receipt_quantity列(收货单实收)同源, 底部总和与列值之和一致 -->
|
|
<select id="queryListTotal" parameterType="com.mhd.wms.domain.stockReceiptOrder.repository.todo.StockReceiptOrderDO" resultType="com.mhd.wms.domain.stockReceiptOrder.repository.po.StockReceiptOrderTotalPO">
|
|
select
|
|
coalesce(sum(a.quantity), 0) as totalPlanQuantity,
|
|
coalesce(sum(a.receipt_quantity), 0) as totalInQuantity
|
|
from stock_receipt_order a
|
|
LEFT JOIN stock_in_order b ON a.in_order_number = b.in_order_number
|
|
<choose>
|
|
<when test="reverseAuditStatus != null">
|
|
and a.DEL_FLAG = 2 and b.DEL_FLAG = 2
|
|
and b.IN_ORDER_ID = (select max(c.IN_ORDER_ID) from stock_in_order c
|
|
where c.IN_ORDER_NUMBER = a.in_order_number and c.DEL_FLAG = 2)
|
|
</when>
|
|
<otherwise>
|
|
and a.DEL_FLAG = 1 and b.DEL_FLAG = 1
|
|
and b.IN_ORDER_ID = (select max(c.IN_ORDER_ID) from stock_in_order c
|
|
where c.IN_ORDER_NUMBER = a.in_order_number and c.DEL_FLAG = 1)
|
|
</otherwise>
|
|
</choose>
|
|
<where>
|
|
<include refid="selectStockReceiptOrderPo1"/>
|
|
<include refid="com.mhd.wms.domain.stockInOrder.repository.mapper.StockInOrderMapper.joinStockInOrderPoWhere"/>
|
|
</where>
|
|
</select>
|
|
</mapper> |