Commit 41f3ac0e authored by tianbo's avatar tianbo

refactor(amos-boot-module-jg): 优化使用登记列表查询 SQL

- 重构了 getListPage1 查询,使用 WITH 子句优化复杂查询结构 - 将设备过滤条件和公共主表过滤条件分离,提高可读性 - 使用 EXISTS 子查询替代左连接,提升查询性能 - 优化了字符串聚合和类别映射的处理方式 - 调整了排序和分页逻辑,提高查询效率
parent 44019c76
...@@ -380,369 +380,261 @@ ...@@ -380,369 +380,261 @@
</select> </select>
<select id="getListPage1" resultType="java.util.Map"> <select id="getListPage1" resultType="java.util.Map">
<choose> WITH pre_filtered_equipment AS NOT MATERIALIZED (
<!-- 情况1:有设备过滤条件 --> SELECT re.equip_transfer_id
<when test="dto.equList != null or dto.equCategory != null or dto.equDefine != null or FROM tzs_jg_use_registration_eq re
dto.equCode != null or dto.code96333 != null or dto.supervisoryCode != null"> WHERE
WITH pre_filtered_equipment AS ( EXISTS (
SELECT DISTINCT re.equip_transfer_id SELECT 1 FROM tzs_jg_use_registration fu
FROM tzs_jg_use_registration_eq re WHERE fu.sequence_nbr = re.equip_transfer_id
WHERE EXISTS ( AND fu.is_delete = '0'
SELECT 1 FROM idx_biz_jg_register_info jri,idx_biz_jg_other_info other <!-- 公共主表过滤条件 -->
WHERE jri."RECORD" = re.equ_id AND other."RECORD" = re.equ_id <if test="dto.status != null and dto.status != ''">
<!-- 设备表过滤条件 --> AND fu.status = #{dto.status}
<if test="dto.equList != null and dto.equList != ''"> </if>
AND jri."EQU_LIST" = #{dto.equList} <if test="dto.applicationDate != null">
</if> AND DATE(fu.create_date) = DATE(#{dto.applicationDate})
<if test="dto.equCategory != null and dto.equCategory != ''"> </if>
AND jri."EQU_CATEGORY" = #{dto.equCategory} <if test="dto.fullAddress != null and dto.fullAddress != ''">
</if> AND fu.use_address LIKE CONCAT('%', #{dto.fullAddress}, '%')
<if test="dto.equDefine != null and dto.equDefine != ''"> </if>
AND jri."EQU_DEFINE" = #{dto.equDefine} <if test="dto.useUnitName != null and dto.useUnitName != ''">
</if> AND fu.use_unit_name LIKE CONCAT('%', #{dto.useUnitName}, '%')
<if test="dto.equCode != null and dto.equCode != ''"> </if>
AND jri."EQU_CODE" LIKE CONCAT(#{dto.equCode}, '%') <if test="dto.applyNo != null and dto.applyNo != ''">
</if> AND fu.apply_no LIKE CONCAT(#{dto.applyNo}, '%')
<if test="dto.code96333 != null and dto.code96333 != ''"> </if>
AND other."CODE96333" LIKE CONCAT(#{dto.code96333}, '%') <if test="dto.useRegistrationCode != null and dto.useRegistrationCode != ''">
</if> AND fu.use_registration_code LIKE CONCAT(#{dto.useRegistrationCode}, '%')
<if test="dto.supervisoryCode != null and dto.supervisoryCode != ''"> </if>
AND other."SUPERVISORY_CODE" LIKE CONCAT(#{dto.supervisoryCode}, '%') <if test="dto.useUnitCode != null and dto.useUnitCode != ''">
</if> AND fu.use_unit_credit_code = #{dto.useUnitCode}
) </if>
AND EXISTS ( <if test="dto.orgBranchCode != null and dto.orgBranchCode != ''">
SELECT 1 FROM tzs_jg_use_registration fu <choose>
WHERE fu.sequence_nbr = re.equip_transfer_id <when test="client == 'jgLook'">
AND fu.is_delete = '0' AND fu.supervision_org_code LIKE CONCAT(#{dto.orgBranchCode}, '%')
<!-- 公共主表过滤条件 --> </when>
<if test="dto.status != null and dto.status != ''"> <otherwise>
AND fu.status = #{dto.status} AND fu.supervision_org_code = #{dto.orgBranchCode}
</if> </otherwise>
<if test="dto.applicationDate != null"> </choose>
AND DATE(fu.create_date) = DATE(#{dto.applicationDate}) </if>
</if> <if test="dto.auditPassDateStart != null and dto.auditPassDateEnd != null">
<if test="dto.fullAddress != null and dto.fullAddress != ''"> AND fu.audit_pass_date BETWEEN #{dto.auditPassDateStart} AND #{dto.auditPassDateEnd}
AND fu.use_address LIKE CONCAT('%', #{dto.fullAddress}, '%') </if>
</if> <if test="dto.dataType == 'supervision' ">
<if test="dto.useUnitName != null and dto.useUnitName != ''"> <choose>
AND fu.use_unit_name LIKE CONCAT('%', #{dto.useUnitName}, '%') <when test="client == 'jgAudit'">
</if> AND (fu.receive_company_code = #{dto.receiveCompanyCode}
<if test="dto.applyNo != null and dto.applyNo != ''">
AND fu.apply_no LIKE CONCAT(#{dto.applyNo}, '%')
</if>
<if test="dto.useRegistrationCode != null and dto.useRegistrationCode != ''">
AND fu.use_registration_code LIKE CONCAT(#{dto.useRegistrationCode}, '%')
</if>
<if test="dto.useUnitCode != null and dto.useUnitCode != ''">
AND fu.use_unit_credit_code = #{dto.useUnitCode}
</if>
<if test="dto.orgBranchCode != null and dto.orgBranchCode != ''">
<choose>
<when test="client == 'jgLook'">
AND fu.supervision_org_code LIKE CONCAT(#{dto.orgBranchCode}, '%')
</when>
<otherwise>
AND fu.supervision_org_code = #{dto.orgBranchCode}
</otherwise>
</choose>
</if>
<if test="dto.auditPassDateStart != null and dto.auditPassDateEnd != null">
AND fu.audit_pass_date BETWEEN #{dto.auditPassDateStart} AND #{dto.auditPassDateEnd}
</if>
<if test="dto.dataType == 'supervision' ">
<choose>
<when test="client == 'jgAudit'">
AND (fu.receive_company_code = #{dto.receiveCompanyCode}
OR fu.transfer_to_user_ids LIKE CONCAT('%', #{dto.currentUserId}, '%'))
</when>
<otherwise>
AND fu.supervision_org_code LIKE CONCAT(#{dto.supervisionOrgCode}, '%')
</otherwise>
</choose>
AND fu.status != '使用单位待提交'
</if>
<if test="dto.dataType == 'company' ">
AND (fu.use_unit_credit_code = #{dto.unitCode}
OR fu.transfer_to_user_ids LIKE CONCAT('%', #{dto.currentUserId}, '%')) OR fu.transfer_to_user_ids LIKE CONCAT('%', #{dto.currentUserId}, '%'))
</if> </when>
) <otherwise>
), AND fu.supervision_org_code LIKE CONCAT(#{dto.supervisionOrgCode}, '%')
main_data AS ( </otherwise>
SELECT </choose>
fu.sequence_nbr AS sequenceNbr, AND fu.status != '使用单位待提交'
fu.audit_status AS auditStatus, </if>
DATE_FORMAT ( fu.reg_date, '%Y-%m-%d' ) AS regDate, <if test="dto.dataType == 'company' ">
fu.use_unit_name AS useUnitName, AND (fu.use_unit_credit_code = #{dto.unitCode}
fu.supervision_org_code AS supervisionOrgCode, OR fu.transfer_to_user_ids LIKE CONCAT('%', #{dto.currentUserId}, '%'))
fu.status, </if>
fu.receive_org_name AS receiveOrgName, )
fu.use_address AS place, <if test="dto.equList != null or dto.equCategory != null or dto.equDefine != null or
fu.instance_id AS instanceId, dto.equCode != null">
fu.apply_no AS applyNo, AND EXISTS (
fu.next_execute_ids AS nextExecuteIds, SELECT 1 FROM idx_biz_jg_register_info jri
fu.promoter, WHERE jri."RECORD" = re.equ_id
fu.use_registration_code AS useRegistrationCode, <!-- 设备表过滤条件 -->
DATE_FORMAT ( fu.audit_pass_date, '%Y-%m-%d' ) AS auditPassDate, <if test="dto.equList != null and dto.equList != ''">
DATE_FORMAT ( fu.create_date, '%Y-%m-%d' ) AS createDate, AND jri."EQU_LIST" = #{dto.equList}
fu.receive_org_name AS receiveOrgName, </if>
fu.next_execute_user_ids AS nextExecuteUserIds, <if test="dto.equCategory != null and dto.equCategory != ''">
fu.next_task_id AS nextTaskId, AND jri."EQU_CATEGORY" = #{dto.equCategory}
fu.create_user_id AS createUserId, </if>
fu.rec_date AS recDate, <if test="dto.equDefine != null and dto.equDefine != ''">
fu.manage_type AS manageType, AND jri."EQU_DEFINE" = #{dto.equDefine}
fu.reg_type AS regType, </if>
fu.is_delete, <if test="dto.equCode != null and dto.equCode != ''">
fu.create_date, AND jri."EQU_CODE" LIKE CONCAT(#{dto.equCode}, '%')
fu.receive_company_code, </if>
fu.use_unit_credit_code, )
fu.transfer_to_user_ids, </if>
fu.supervision_org_code, <if test="dto.code96333 != null or dto.supervisoryCode != null">
fu.use_address AS fullAddress, AND EXISTS (
fu.cancel_reason AS cancelReason, SELECT 1 FROM idx_biz_jg_other_info other
fu.project_contraption_id AS projectContraptionId, WHERE other."RECORD" = re.equ_id
( SELECT company_name FROM privilege_company WHERE org_code = fu.supervision_org_code AND is_deleted = FALSE LIMIT 1 ) AS orgBranchName <!-- 设备表过滤条件 -->
FROM pre_filtered_equipment pfe <if test="dto.code96333 != null and dto.code96333 != ''">
JOIN tzs_jg_use_registration fu ON pfe.equip_transfer_id = fu.sequence_nbr AND other."CODE96333" LIKE CONCAT(#{dto.code96333}, '%')
ORDER BY fu.create_date DESC, fu.apply_no DESC </if>
LIMIT 20 OFFSET 0 <if test="dto.supervisoryCode != null and dto.supervisoryCode != ''">
) AND other."SUPERVISORY_CODE" LIKE CONCAT(#{dto.supervisoryCode}, '%')
SELECT </if>
md.*, )
(SELECT STRING_AGG(DISTINCT other.code96333, ',') </if>
FROM tzs_jg_use_registration_eq re ),
JOIN idx_biz_jg_register_info jri ON re.equ_id = jri."RECORD" main_data AS (
JOIN idx_biz_jg_other_info other ON jri."RECORD" = other."RECORD" SELECT
WHERE re.equip_transfer_id = md.sequenceNbr) AS code96333, fu.sequence_nbr AS sequenceNbr,
(SELECT STRING_AGG(DISTINCT other.supervisory_code, ',') fu.audit_status AS auditStatus,
FROM tzs_jg_use_registration_eq re DATE_FORMAT(fu.reg_date, '%Y-%m-%d') AS regDate,
JOIN idx_biz_jg_register_info jri ON re.equ_id = jri."RECORD" fu.use_unit_name AS useUnitName,
JOIN idx_biz_jg_other_info other ON jri."RECORD" = other."RECORD" fu.supervision_org_code AS supervisionOrgCode,
WHERE re.equip_transfer_id = md.sequenceNbr) AS supervisoryCode, fu.status,
(SELECT STRING_AGG(DISTINCT jri.PRODUCT_NAME, ',') fu.receive_org_name AS receiveOrgName,
FROM tzs_jg_use_registration_eq re fu.use_address AS place,
JOIN idx_biz_jg_register_info jri ON re.equ_id = jri."RECORD" fu.instance_id AS instanceId,
WHERE re.equip_transfer_id = md.sequenceNbr) AS productName , fu.apply_no AS applyNo,
(SELECT STRING_AGG(DISTINCT jri.EQU_CODE, ',') fu.next_execute_ids AS nextExecuteIds,
FROM tzs_jg_use_registration_eq re fu.promoter,
JOIN idx_biz_jg_register_info jri ON re.equ_id = jri."RECORD" fu.use_registration_code AS useRegistrationCode,
WHERE re.equip_transfer_id = md.sequenceNbr) AS equCode, DATE_FORMAT(fu.audit_pass_date, '%Y-%m-%d') AS auditPassDate,
(SELECT STRING_AGG(DISTINCT jri.EQU_LIST, ',') DATE_FORMAT(fu.create_date, '%Y-%m-%d') AS createDate,
FROM tzs_jg_use_registration_eq re fu.next_execute_user_ids AS nextExecuteUserIds,
JOIN idx_biz_jg_register_info jri ON re.equ_id = jri."RECORD" fu.next_task_id AS nextTaskId,
WHERE re.equip_transfer_id = md.sequenceNbr) AS equListCode , fu.create_user_id AS createUserId,
(SELECT STRING_AGG(DISTINCT jri.EQU_CATEGORY, ',') fu.rec_date AS recDate,
FROM tzs_jg_use_registration_eq re fu.manage_type AS manageType,
JOIN idx_biz_jg_register_info jri ON re.equ_id = jri."RECORD" fu.reg_type AS regType,
WHERE re.equip_transfer_id = md.sequenceNbr) AS equCategoryCode , fu.is_delete,
(SELECT STRING_AGG(DISTINCT jri.EQU_DEFINE, ',') fu.create_date,
FROM tzs_jg_use_registration_eq re fu.receive_company_code,
JOIN idx_biz_jg_register_info jri ON re.equ_id = jri."RECORD" fu.use_unit_credit_code,
WHERE re.equip_transfer_id = md.sequenceNbr) AS equDefineCode, fu.transfer_to_user_ids,
(SELECT name from tz_equipment_category where code = equListCode ) AS equListName, fu.supervision_org_code,
(SELECT name from tz_equipment_category where code = equCategoryCode ) AS equCategory, fu.use_address AS fullAddress,
(SELECT name from tz_equipment_category where code = equDefineCode ) AS equDefine fu.cancel_reason AS cancelReason,
FROM main_data md fu.project_contraption_id AS projectContraptionId,
GROUP BY md.sequenceNbr (
ORDER BY SELECT company_name
FROM privilege_company
WHERE org_code = fu.supervision_org_code
AND is_deleted = FALSE
LIMIT 1
) AS orgBranchName
FROM tzs_jg_use_registration fu
WHERE EXISTS (
SELECT 1
FROM pre_filtered_equipment pfe
WHERE pfe.equip_transfer_id = fu.sequence_nbr
)
ORDER BY fu.create_date DESC, fu.apply_no DESC
LIMIT #{size} OFFSET #{offset}
),
equipment_aggregates AS MATERIALIZED (
SELECT
re.equip_transfer_id,
STRING_AGG(DISTINCT other."CODE96333", ',') AS code96333,
STRING_AGG(DISTINCT other."SUPERVISORY_CODE", ',') AS supervisoryCode,
STRING_AGG(DISTINCT jri."PRODUCT_NAME", ',') AS productName,
STRING_AGG(DISTINCT jri."EQU_CODE", ',') AS equCode,
STRING_AGG(DISTINCT jri."EQU_LIST", ',') AS equListCode,
STRING_AGG(DISTINCT jri."EQU_CATEGORY", ',') AS equCategoryCode,
STRING_AGG(DISTINCT jri."EQU_DEFINE", ',') AS equDefineCode
FROM main_data md
JOIN tzs_jg_use_registration_eq re ON md.sequenceNbr = re.equip_transfer_id
LEFT JOIN idx_biz_jg_other_info other ON re.equ_id = other."RECORD"
LEFT JOIN idx_biz_jg_register_info jri ON re.equ_id = jri."RECORD"
GROUP BY re.equip_transfer_id
),
category_mapping AS MATERIALIZED (
SELECT
code,
name
FROM tz_equipment_category
WHERE code IN (
SELECT DISTINCT unnest(string_to_array(agg.equListCode || ',' || agg.equCategoryCode || ',' || agg.equDefineCode, ','))
FROM equipment_aggregates agg
WHERE agg.equListCode IS NOT NULL
OR agg.equCategoryCode IS NOT NULL
OR agg.equDefineCode IS NOT NULL
)
)
SELECT
md.*,
ea.code96333,
ea.supervisoryCode,
ea.productName,
ea.equCode,
ea.equListCode,
ea.equCategoryCode,
ea.equDefineCode,
(
SELECT STRING_AGG(DISTINCT cm.name, ',')
FROM unnest(string_to_array(ea.equListCode, ',')) AS equ_list(code)
JOIN category_mapping cm ON cm.code = equ_list.code
) AS equListName,
(
SELECT STRING_AGG(DISTINCT cm.name, ',')
FROM unnest(string_to_array(ea.equCategoryCode, ',')) AS equ_category(code)
JOIN category_mapping cm ON cm.code = equ_category.code
) AS equCategory,
(
SELECT STRING_AGG(DISTINCT cm.name, ',')
FROM unnest(string_to_array(ea.equDefineCode, ',')) AS equ_define(code)
JOIN category_mapping cm ON cm.code = equ_define.code
) AS equDefine
FROM main_data md
JOIN equipment_aggregates ea ON md.sequenceNbr = ea.equip_transfer_id
ORDER BY
<choose>
<when test="sort != null and sort.field != null and sort.sortType != null">
<choose> <choose>
<when test="sort != null and sort.field != null and sort.sortType != null"> <when test="sort.field == 'create_date'">md.create_date</when>
<choose> <when test="sort.field == 'apply_no'">md.applyNo</when>
<when test="sort.field == 'create_date'">md.create_date</when> <when test="sort.field == 'reg_date'">md.regType</when>
<when test="sort.field == 'apply_no'">md.applyNo</when> <when test="sort.field == 'audit_pass_date'">fu.auditPassDate</when>
<when test="sort.field == 'reg_date'">md.regType</when> <otherwise>${sort.field}</otherwise>
<when test="sort.field == 'audit_pass_date'">fu.auditPassDate</when>
<otherwise>${sort.field}</otherwise>
</choose>
${sort.sortType}
</when>
<otherwise>
md.create_date DESC, md.applyNo DESC
</otherwise>
</choose> </choose>
LIMIT #{size} OFFSET #{offset} ${sort.sortType}
</when> </when>
<!-- 情况2:无设备过滤条件 -->
<otherwise> <otherwise>
WITH paginated_ids AS ( md.create_date DESC, md.applyNo DESC
SELECT sequence_nbr
FROM tzs_jg_use_registration fu
WHERE fu.is_delete = '0'
<!-- 公共主表过滤条件 -->
<if test="dto.status != null and dto.status != ''">
AND fu.status = #{dto.status}
</if>
<if test="dto.applicationDate != null">
AND DATE(fu.create_date) = DATE(#{dto.applicationDate})
</if>
<if test="dto.fullAddress != null and dto.fullAddress != ''">
AND fu.use_address LIKE CONCAT('%', #{dto.fullAddress}, '%')
</if>
<if test="dto.useUnitName != null and dto.useUnitName != ''">
AND fu.use_unit_name LIKE CONCAT('%', #{dto.useUnitName}, '%')
</if>
<if test="dto.applyNo != null and dto.applyNo != ''">
AND fu.apply_no LIKE CONCAT(#{dto.applyNo}, '%')
</if>
<if test="dto.useRegistrationCode != null and dto.useRegistrationCode != ''">
AND fu.use_registration_code LIKE CONCAT(#{dto.useRegistrationCode}, '%')
</if>
<if test="dto.useUnitCode != null and dto.useUnitCode != ''">
AND fu.use_unit_credit_code = #{dto.useUnitCode}
</if>
<if test="dto.orgBranchCode != null and dto.orgBranchCode != ''">
<choose>
<when test="client == 'jgLook'">
AND fu.supervision_org_code LIKE CONCAT(#{dto.orgBranchCode}, '%')
</when>
<otherwise>
AND fu.supervision_org_code = #{dto.orgBranchCode}
</otherwise>
</choose>
</if>
<if test="dto.auditPassDateStart != null and dto.auditPassDateEnd != null">
AND fu.audit_pass_date BETWEEN #{dto.auditPassDateStart} AND #{dto.auditPassDateEnd}
</if>
<if test="dto.dataType == 'supervision' ">
<choose>
<when test="client == 'jgAudit'">
AND (fu.receive_company_code = #{dto.receiveCompanyCode}
OR fu.transfer_to_user_ids LIKE CONCAT('%', #{dto.currentUserId}, '%'))
</when>
<otherwise>
AND fu.supervision_org_code LIKE CONCAT(#{dto.supervisionOrgCode}, '%')
</otherwise>
</choose>
AND fu.status != '使用单位待提交'
</if>
<if test="dto.dataType == 'company' ">
AND (fu.use_unit_credit_code = #{dto.unitCode}
OR fu.transfer_to_user_ids LIKE CONCAT('%', #{dto.currentUserId}, '%'))
</if>
ORDER BY
<choose>
<when test="sort != null and sort.field != null and sort.sortType != null">
<choose>
<when test="sort.field == 'create_date'">fu.create_date</when>
<when test="sort.field == 'apply_no'">fu.apply_no</when>
<when test="sort.field == 'reg_date'">fu.reg_date</when>
<when test="sort.field == 'audit_pass_date'">fu.audit_pass_date</when>
<otherwise>${sort.field}</otherwise>
</choose>
${sort.sortType}
</when>
<otherwise>
fu.create_date DESC, fu.apply_no DESC
</otherwise>
</choose>
LIMIT #{size} OFFSET #{offset}
)
SELECT
fu.sequence_nbr AS sequenceNbr,
fu.audit_status AS auditStatus,
DATE_FORMAT(fu.reg_date,'%Y-%m-%d') AS regDate,
fu.use_unit_name AS useUnitName,
fu.supervision_org_code AS supervisionOrgCode,
fu.status,
fu.receive_org_name AS receiveOrgName,
fu.use_address AS place,
fu.instance_id AS instanceId,
fu.apply_no AS applyNo,
fu.next_execute_ids AS nextExecuteIds,
fu.promoter,
fu.use_registration_code AS useRegistrationCode,
DATE_FORMAT(fu.audit_pass_date,'%Y-%m-%d') AS auditPassDate,
DATE_FORMAT(fu.create_date,'%Y-%m-%d') AS createDate,
fu.receive_org_name AS receiveOrgName,
fu.next_execute_user_ids AS nextExecuteUserIds,
fu.next_task_id AS nextTaskId,
fu.create_user_id AS createUserId,
fu.rec_date AS recDate,
fu.manage_type AS manageType,
fu.reg_type AS regType,
fu.is_delete,
fu.create_date,
fu.receive_company_code,
fu.use_unit_credit_code,
fu.transfer_to_user_ids,
fu.supervision_org_code,
fu.use_address AS fullAddress,
fu.cancel_reason AS cancelReason,
fu.project_contraption_id AS projectContraptionId,
(select company_name from privilege_company where org_code = fu.supervision_org_code and is_deleted = false limit 1) AS orgBranchName,
COALESCE(GROUP_CONCAT(DISTINCT re.equ_id), '') AS equipId,
COALESCE(GROUP_CONCAT(DISTINCT other.supervisory_code), '') AS supervisoryCode,
COALESCE(GROUP_CONCAT(DISTINCT other.CODE96333), '') AS code96333,
COALESCE(GROUP_CONCAT(DISTINCT jri.PRODUCT_NAME), '') AS productName,
COALESCE(GROUP_CONCAT(DISTINCT jri.EQU_CODE), '') AS equCode,
COALESCE(GROUP_CONCAT(DISTINCT jri.EQU_LIST), '') AS equListCode,
COALESCE(GROUP_CONCAT(DISTINCT jri.EQU_CATEGORY), '') AS equCategoryCode,
COALESCE(GROUP_CONCAT(DISTINCT jri.EQU_DEFINE), '') AS equDefineCode,
COALESCE(GROUP_CONCAT(DISTINCT c_list.name), '') AS equListName,
COALESCE(GROUP_CONCAT(DISTINCT c_cate.name), '') AS equCategory,
COALESCE(GROUP_CONCAT(DISTINCT c_def.name), '') AS equDefine
FROM paginated_ids pi
JOIN tzs_jg_use_registration fu ON pi.sequence_nbr = fu.sequence_nbr
LEFT JOIN tzs_jg_use_registration_eq re ON fu.sequence_nbr = re.equip_transfer_id
LEFT JOIN idx_biz_jg_register_info jri ON re.equ_id = jri."RECORD"
LEFT JOIN idx_biz_jg_other_info other ON jri."RECORD" = other."RECORD"
LEFT JOIN tz_equipment_category c_list ON jri.EQU_LIST = c_list.code
LEFT JOIN tz_equipment_category c_cate ON jri.EQU_CATEGORY = c_cate.code
LEFT JOIN tz_equipment_category c_def ON jri.EQU_DEFINE = c_def.code
GROUP BY fu.sequence_nbr
ORDER BY
<choose>
<when test="sort != null and sort.field != null and sort.sortType != null">
<choose>
<when test="sort.field == 'create_date'">fu.create_date</when>
<when test="sort.field == 'apply_no'">fu.apply_no</when>
<when test="sort.field == 'reg_date'">fu.reg_date</when>
<when test="sort.field == 'audit_pass_date'">fu.audit_pass_date</when>
<otherwise>${sort.field}</otherwise>
</choose>
${sort.sortType}
</when>
<otherwise>
fu.create_date DESC, fu.apply_no DESC
</otherwise>
</choose>
</otherwise> </otherwise>
</choose> </choose>
</select> </select>
<select id="getListPageCount" resultType="long"> <select id="getListPageCount" resultType="long">
SELECT <![CDATA[/*+ set(query_dop 16)*/]]> COUNT(DISTINCT ur.sequence_nbr) SELECT <![CDATA[/*+ set(query_dop 16)*/]]> COUNT(*)
FROM tzs_jg_use_registration ur FROM tzs_jg_use_registration ur
LEFT JOIN tzs_jg_use_registration_eq re ON ur.sequence_nbr = re.equip_transfer_id <if test="dto.equList != null or dto.equCategory != null or dto.equDefine != null or
LEFT JOIN idx_biz_jg_register_info jri ON re.equ_id = jri."RECORD" dto.equCode != null or dto.code96333 != null or dto.supervisoryCode != null">
LEFT JOIN idx_biz_jg_other_info other ON re.equ_id = other."RECORD" INNER JOIN tzs_jg_use_registration_eq re ON ur.sequence_nbr = re.equip_transfer_id
WHERE ur.is_delete = 0 INNER JOIN idx_biz_jg_register_info jri ON re.equ_id = jri."RECORD"
<!-- 统一设备过滤条件 --> <if test="dto.code96333 != null or dto.supervisoryCode != null">
<if test="dto.equList != null and dto.equList != ''"> INNER JOIN idx_biz_jg_other_info other ON re.equ_id = other."RECORD"
AND jri."EQU_LIST" = #{dto.equList}
</if> </if>
<if test="dto.equCategory != null and dto.equCategory != ''">
AND jri."EQU_CATEGORY" = #{dto.equCategory}
</if>
<if test="dto.equDefine != null and dto.equDefine != ''">
AND jri."EQU_DEFINE" = #{dto.equDefine}
</if>
<!-- 设备代码过滤 -->
<if test="dto.equCode != null and dto.equCode != ''">
AND jri."EQU_CODE" LIKE CONCAT('%', #{dto.equCode}, '%')
</if> </if>
WHERE ur.is_delete = 0
<if test="dto.equList != null or dto.equCategory != null or dto.equDefine != null or
dto.equCode != null or dto.code96333 != null or dto.supervisoryCode != null">
<!-- 统一设备过滤条件 -->
<if test="dto.equList != null and dto.equList != ''">
AND jri."EQU_LIST" = #{dto.equList}
</if>
<if test="dto.equCategory != null and dto.equCategory != ''">
AND jri."EQU_CATEGORY" = #{dto.equCategory}
</if>
<if test="dto.equDefine != null and dto.equDefine != ''">
AND jri."EQU_DEFINE" = #{dto.equDefine}
</if>
<!-- 设备代码过滤 -->
<if test="dto.equCode != null and dto.equCode != ''">
AND jri."EQU_CODE" LIKE CONCAT('%', #{dto.equCode}, '%')
</if>
<!-- 96333码过滤 --> <!-- 96333码过滤 -->
<if test="dto.code96333 != null and dto.code96333 != ''"> <if test="dto.code96333 != null and dto.code96333 != ''">
AND other."CODE96333" LIKE CONCAT('%', #{dto.code96333}, '%') AND other."CODE96333" LIKE CONCAT('%', #{dto.code96333}, '%')
</if> </if>
<!-- 监管码过滤 --> <!-- 监管码过滤 -->
<if test="dto.supervisoryCode != null and dto.supervisoryCode != ''"> <if test="dto.supervisoryCode != null and dto.supervisoryCode != ''">
AND other."SUPERVISORY_CODE" LIKE CONCAT('%', #{dto.supervisoryCode}, '%') AND other."SUPERVISORY_CODE" LIKE CONCAT('%', #{dto.supervisoryCode}, '%')
</if>
</if> </if>
<if test="dto.status != null and dto.status != ''"> <if test="dto.status != null and dto.status != ''">
AND ur.status = #{dto.status} AND ur.status = #{dto.status}
</if> </if>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment