Преглед изворни кода

查询协议列表 字符串转 bigint 溢出导致的查询不准确的bug

wanghao пре 3 месеци
родитељ
комит
0b3dc56478
1 измењених фајлова са 20 додато и 14 уклоњено
  1. 20 14
      tenant/organization/src/main/resources/mapper/PtlAgreementMapper.xml

+ 20 - 14
tenant/organization/src/main/resources/mapper/PtlAgreementMapper.xml

@@ -62,6 +62,25 @@
         pa.api_type,pa.jq_entrance_fee_ratio,pa.sy_entrance_fee_ratio,pa.jy_entrance_fee_ratio
     </sql>
     <select id="queryPage" resultType="com.jzg.commons.entity.vo.AgreementVo">
+        WITH RECURSIVE t AS (
+        SELECT
+        id,
+        CAST(id AS CHAR) COLLATE utf8mb4_general_ci AS str_id
+        FROM
+        esm_ins_company
+        WHERE
+        id = #{param.companyId}
+        AND is_delete = 0
+        AND parent_id = 0 UNION ALL
+        SELECT
+        c.id,
+        CAST(c.id AS CHAR) COLLATE utf8mb4_general_ci AS str_id
+        FROM
+        esm_ins_company c
+        JOIN t ON c.parent_id = t.id
+        WHERE
+        c.is_delete = 0
+        )
         select <include refid="Base_Column_List"/>
         FROM ptl_agreement pa
         LEFT JOIN ptl_agreement_attribution paa on pa.attribution_id = paa.id AND paa.is_delete = 0
@@ -80,20 +99,7 @@
                 and pa.system_code = #{param.systemCode}
             </if>
             <if test="param.companyId != null and param.companyId != ''">
-                and pa.company_id in (
-                WITH RECURSIVE t AS (
-                SELECT id
-                FROM esm_ins_company
-                WHERE id = #{param.companyId}
-                AND parent_id = 0
-                AND is_delete = 0
-                UNION ALL
-                SELECT c.id
-                FROM esm_ins_company c
-                JOIN t ON c.parent_id = t.id
-                WHERE c.is_delete = 0
-                )
-                SELECT id FROM t)
+                AND pa.company_id IN (SELECT str_id FROM t)
             </if>
             <if test="param.companyIds != null and param.companyIds != ''">
                 and pa.company_id in