订单数据源增加订单对比功能
This commit is contained in:
@@ -154,6 +154,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
WHERE rn > #{startRow}
|
||||
</select>
|
||||
|
||||
<!--
|
||||
订单比对专用 SQL(异步分页):仅返回转单号,
|
||||
筛选与列表相同;排除空转单号。
|
||||
-->
|
||||
<select id="selectTabOrderCompareKeyPage" resultType="java.util.HashMap">
|
||||
SELECT TRANSFER_ORDER_ID FROM (
|
||||
SELECT inner_q.TRANSFER_ORDER_ID AS TRANSFER_ORDER_ID, ROWNUM AS rn
|
||||
FROM (
|
||||
SELECT o.TRANSFER_ORDER_ID, o.PICKUP_DATE, o.ORDER_ID
|
||||
FROM ${orderTable} o
|
||||
WHERE
|
||||
<include refid="tabOrderMonitorWhere"/>
|
||||
AND o.TRANSFER_ORDER_ID IS NOT NULL
|
||||
ORDER BY o.PICKUP_DATE DESC, o.ORDER_ID DESC
|
||||
) inner_q
|
||||
WHERE ROWNUM <= #{endRow}
|
||||
)
|
||||
WHERE rn > #{startRow}
|
||||
</select>
|
||||
|
||||
<!-- List detail by primary keys (display columns only). -->
|
||||
<select id="selectTabOrderMonitorListByIds" resultType="java.util.HashMap">
|
||||
SELECT
|
||||
@@ -195,10 +215,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
ORDER BY o.PICKUP_DATE DESC, o.ORDER_ID DESC
|
||||
</select>
|
||||
|
||||
<!--
|
||||
大批量单号分批收集:每批最多 900 个(避开 Oracle IN 1000 上限)。
|
||||
用 UNION ALL 三段分别匹配三列(比三列 OR 快约 2 倍:不依赖优化器 OR-expansion,
|
||||
ORDER_ID/ORG_ORDER_ID/TRANSFER_ORDER_ID 各走自己的索引);重复 ID 由 Java 侧去重。
|
||||
<!--
|
||||
大批量单号分批收集:每批最多 900 个。
|
||||
三列 UNION ALL(订单号/运单号/转单号),叠加 tabOrderFilterWhere。
|
||||
比对回填搜索请用 selectMatchedTransferOrderKeys,不走本 SQL。
|
||||
-->
|
||||
<select id="selectMatchedOrderKeys" resultType="java.util.HashMap">
|
||||
SELECT * FROM (
|
||||
@@ -231,6 +251,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
)
|
||||
</select>
|
||||
|
||||
<!--
|
||||
比对缺失转单号回填搜索专用:仅 TRANSFER_ORDER_ID IN,
|
||||
不带提货时间,不影响列表/同步/比对共用 SQL。
|
||||
-->
|
||||
<select id="selectMatchedTransferOrderKeys" resultType="java.util.HashMap">
|
||||
SELECT o.ID AS ID, o.PICKUP_DATE AS PICKUP_DATE
|
||||
FROM ${orderTable} o
|
||||
WHERE o.TRANSFER_ORDER_ID IN
|
||||
<foreach collection="batch" item="bid" open="(" separator="," close=")">
|
||||
#{bid}
|
||||
</foreach>
|
||||
AND o.BL_PICKUP = 1
|
||||
AND o.ORDER_STATUS IN (3, 4, 5, 6, 7, 8, 11)
|
||||
<if test="customerCodes != null and customerCodes.size() > 0">
|
||||
AND o.CUSTOMER_CODE IN
|
||||
<foreach collection="customerCodes" item="code" open="(" separator="," close=")">
|
||||
#{code}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 内存分页切片后的主键回查(一批最多一个页大小,远低于 IN 上限) -->
|
||||
<select id="selectTabOrderMonitorByIds" resultType="java.util.HashMap">
|
||||
<!-- 全行数据:同步计费时直接复用,不再按单号回查 Oracle -->
|
||||
|
||||
@@ -204,6 +204,69 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<!-- 订单比对:仅转单号 -->
|
||||
<select id="selectExistingTransferNos" resultType="String">
|
||||
SELECT DISTINCT p.transfer_no
|
||||
FROM prc_order_bill p
|
||||
WHERE p.transfer_no IN
|
||||
<foreach collection="transferNos" item="tn" open="(" separator="," close=")">
|
||||
#{tn}
|
||||
</foreach>
|
||||
<if test="customerCodes != null and customerCodes.size() > 0">
|
||||
AND p.customer_code IN
|
||||
<foreach collection="customerCodes" item="ccode" open="(" separator="," close=")">
|
||||
#{ccode}
|
||||
</foreach>
|
||||
</if>
|
||||
AND p.transfer_no IS NOT NULL AND p.transfer_no != ''
|
||||
</select>
|
||||
|
||||
<!-- 订单比对:上游单号中已落库本地的 order_no/tracking_no/transfer_no -->
|
||||
<select id="selectExistingOrderIdentifiers" resultType="String">
|
||||
SELECT DISTINCT hit.idn
|
||||
FROM (
|
||||
SELECT p.order_no AS idn
|
||||
FROM prc_order_bill p
|
||||
WHERE p.order_no IN
|
||||
<foreach collection="identifiers" item="idn" open="(" separator="," close=")">
|
||||
#{idn}
|
||||
</foreach>
|
||||
<if test="customerCodes != null and customerCodes.size() > 0">
|
||||
AND p.customer_code IN
|
||||
<foreach collection="customerCodes" item="ccode" open="(" separator="," close=")">
|
||||
#{ccode}
|
||||
</foreach>
|
||||
</if>
|
||||
UNION
|
||||
SELECT p.tracking_no AS idn
|
||||
FROM prc_order_bill p
|
||||
WHERE p.tracking_no IN
|
||||
<foreach collection="identifiers" item="idn" open="(" separator="," close=")">
|
||||
#{idn}
|
||||
</foreach>
|
||||
<if test="customerCodes != null and customerCodes.size() > 0">
|
||||
AND p.customer_code IN
|
||||
<foreach collection="customerCodes" item="ccode" open="(" separator="," close=")">
|
||||
#{ccode}
|
||||
</foreach>
|
||||
</if>
|
||||
UNION
|
||||
SELECT p.transfer_no AS idn
|
||||
FROM prc_order_bill p
|
||||
WHERE p.transfer_no IN
|
||||
<foreach collection="identifiers" item="idn" open="(" separator="," close=")">
|
||||
#{idn}
|
||||
</foreach>
|
||||
<if test="customerCodes != null and customerCodes.size() > 0">
|
||||
AND p.customer_code IN
|
||||
<foreach collection="customerCodes" item="ccode" open="(" separator="," close=")">
|
||||
#{ccode}
|
||||
</foreach>
|
||||
</if>
|
||||
) hit
|
||||
WHERE hit.idn IS NOT NULL AND hit.idn != ''
|
||||
</select>
|
||||
|
||||
<select id="selectOrderNoOptions" resultType="String">
|
||||
select p.order_no
|
||||
from prc_order_bill p
|
||||
@@ -246,6 +309,106 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
limit #{limit}
|
||||
</select>
|
||||
|
||||
<!-- Product-check filters: customer + billing time (+ optional status/identifiers). -->
|
||||
<sql id="orderBillProductCheckWhere">
|
||||
<if test="customerCodes != null and customerCodes.size() > 0">
|
||||
AND p.customer_code IN
|
||||
<foreach collection="customerCodes" item="ccode" open="(" separator="," close=")">
|
||||
#{ccode}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="params != null and params.beginBizDate != null and params.beginBizDate != ''">
|
||||
AND p.biz_date >= #{params.beginBizDate}
|
||||
</if>
|
||||
<if test="params != null and params.endBizDate != null and params.endBizDate != ''">
|
||||
AND p.biz_date <= #{params.endBizDate}
|
||||
</if>
|
||||
<if test="params != null and params.beginPickupDate != null and params.beginPickupDate != ''">
|
||||
AND p.pickup_date >= #{params.beginPickupDate}
|
||||
</if>
|
||||
<if test="params != null and params.endPickupDate != null and params.endPickupDate != ''">
|
||||
AND p.pickup_date <= #{params.endPickupDate}
|
||||
</if>
|
||||
<if test="orderStatuses != null and orderStatuses.size() > 0">
|
||||
AND p.order_status IN
|
||||
<foreach collection="orderStatuses" item="os" open="(" separator="," close=")">
|
||||
#{os}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="billingFailStatuses != null and billingFailStatuses.size() > 0">
|
||||
AND p.billing_fail_status IN
|
||||
<foreach collection="billingFailStatuses" item="bfs" open="(" separator="," close=")">
|
||||
#{bfs}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="orderIdentifiers != null and orderIdentifiers.size() > 0">
|
||||
AND (
|
||||
p.order_no IN
|
||||
<foreach collection="orderIdentifiers" item="idn" open="(" separator="," close=")">
|
||||
#{idn}
|
||||
</foreach>
|
||||
OR p.tracking_no IN
|
||||
<foreach collection="orderIdentifiers" item="idn" open="(" separator="," close=")">
|
||||
#{idn}
|
||||
</foreach>
|
||||
OR p.transfer_no IN
|
||||
<foreach collection="orderIdentifiers" item="idn" open="(" separator="," close=")">
|
||||
#{idn}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
<include refid="orderBillDataScopeFilter"/>
|
||||
</sql>
|
||||
|
||||
<select id="selectDistinctProductGroups" parameterType="PrcOrderBill" resultType="java.util.HashMap">
|
||||
SELECT p.customer_code AS customer_code,
|
||||
p.product_code AS product_code,
|
||||
MAX(p.product_name) AS product_name,
|
||||
COUNT(1) AS order_count
|
||||
FROM prc_order_bill p
|
||||
WHERE p.product_code IS NOT NULL
|
||||
AND p.product_code <> ''
|
||||
<include refid="orderBillProductCheckWhere"/>
|
||||
GROUP BY p.customer_code, p.product_code
|
||||
ORDER BY p.customer_code, p.product_code
|
||||
</select>
|
||||
|
||||
<select id="selectOrderBillsByProductForCheck" resultMap="PrcOrderBillResult">
|
||||
<include refid="selectPrcOrderBillVo"/>
|
||||
<where>
|
||||
<if test="query.productCode != null and query.productCode != ''">
|
||||
AND p.product_code = #{query.productCode}
|
||||
</if>
|
||||
<if test="query.customerCodes != null and query.customerCodes.size() > 0">
|
||||
AND p.customer_code IN
|
||||
<foreach collection="query.customerCodes" item="ccode" open="(" separator="," close=")">
|
||||
#{ccode}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="query.params != null and query.params.beginBizDate != null and query.params.beginBizDate != ''">
|
||||
AND p.biz_date >= #{query.params.beginBizDate}
|
||||
</if>
|
||||
<if test="query.params != null and query.params.endBizDate != null and query.params.endBizDate != ''">
|
||||
AND p.biz_date <= #{query.params.endBizDate}
|
||||
</if>
|
||||
<if test="query.params != null and query.params.beginPickupDate != null and query.params.beginPickupDate != ''">
|
||||
AND p.pickup_date >= #{query.params.beginPickupDate}
|
||||
</if>
|
||||
<if test="query.params != null and query.params.endPickupDate != null and query.params.endPickupDate != ''">
|
||||
AND p.pickup_date <= #{query.params.endPickupDate}
|
||||
</if>
|
||||
<if test="query.orderStatuses != null and query.orderStatuses.size() > 0">
|
||||
AND p.order_status IN
|
||||
<foreach collection="query.orderStatuses" item="os" open="(" separator="," close=")">
|
||||
#{os}
|
||||
</foreach>
|
||||
</if>
|
||||
<include refid="orderBillDataScopeFilterByQuery"/>
|
||||
</where>
|
||||
order by p.biz_date desc, p.bill_id desc
|
||||
limit #{limit}
|
||||
</select>
|
||||
|
||||
<select id="selectPrcOrderBillList" parameterType="PrcOrderBill" resultMap="PrcOrderBillResult">
|
||||
<include refid="selectPrcOrderBillVo"/>
|
||||
<where>
|
||||
@@ -364,6 +527,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="params.endBizDate != null and params.endBizDate != ''">
|
||||
AND p.biz_date <= #{params.endBizDate}
|
||||
</if>
|
||||
<if test="params.beginPickupDate != null and params.beginPickupDate != ''">
|
||||
AND p.pickup_date >= #{params.beginPickupDate}
|
||||
</if>
|
||||
<if test="params.endPickupDate != null and params.endPickupDate != ''">
|
||||
AND p.pickup_date <= #{params.endPickupDate}
|
||||
</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''">
|
||||
AND date_format(p.create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||
</if>
|
||||
|
||||
Reference in New Issue
Block a user