修改对外代码查询

This commit is contained in:
wuweihua
2026-10-20 16:20:57 +08:00
parent acf4757144
commit eca8855b8d
3 changed files with 33 additions and 8 deletions
@@ -4,14 +4,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bms.price.mapper.CustomerCodeResolveMapper">
<!-- 客户主数据仅 200 余行,名称精确匹配在 MySQL 侧代价极低 -->
<!--
Resolve customer keywords to codes for Oracle TAB_ORDER.CUSTOMER_CODE IN (...).
Match: customer_code / customer_name / customer_code_dw (对外代码).
Return both internal code and outer code so either form on TAB_ORDER hits.
-->
<select id="selectCustomerCodesByKeywords" resultType="java.lang.String">
SELECT customer_code
FROM ctr_customer
WHERE
<foreach collection="keywords" item="kw" separator=" OR ">
customer_code = #{kw} OR customer_name = #{kw}
</foreach>
SELECT DISTINCT code FROM (
SELECT customer_code AS code
FROM ctr_customer
WHERE customer_code IS NOT NULL AND customer_code &lt;&gt; ''
AND (
<foreach collection="keywords" item="kw" separator=" OR ">
customer_code = #{kw} OR customer_name = #{kw} OR customer_code_dw = #{kw}
</foreach>
)
UNION ALL
SELECT customer_code_dw AS code
FROM ctr_customer
WHERE customer_code_dw IS NOT NULL AND customer_code_dw &lt;&gt; ''
AND (
<foreach collection="keywords" item="kw" separator=" OR ">
customer_code = #{kw} OR customer_name = #{kw} OR customer_code_dw = #{kw}
</foreach>
)
) t
</select>
</mapper>