Commit d6260d75 authored by 刘林's avatar 刘林

fix(jg):登记证管理性能优化

parent d4f09191
......@@ -268,7 +268,8 @@
<foreach collection="projectContraptionIdList" item="id" index="index" separator=",">
#{id}
</foreach>
GROUP BY ibjui.project_contraption_id
])) tu
GROUP BY tu.project_contraption_id
</select>
<select id="queryJgProjectContraptionPage"
resultType="com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgProjectContraption">
......@@ -361,26 +362,36 @@
</select>
<select id="selectCheckCountByNotNull" resultType="java.util.Map">
SELECT A.project_contraption_id,CAST(count(1) AS INTEGER) AS count
FROM
(
SELECT
ibjui.project_contraption_id,
( SELECT INSPECT_ORG_NAME FROM idx_biz_jg_inspection_detection_info WHERE "RECORD" = ibjui."RECORD" ORDER BY INSPECT_DATE DESC LIMIT 1 ) inspectOrgName,
( SELECT INSPECT_CONCLUSION FROM idx_biz_jg_inspection_detection_info WHERE "RECORD" = ibjui."RECORD" ORDER BY INSPECT_DATE DESC LIMIT 1 ) inspectConclusion,
( SELECT NEXT_INSPECT_DATE FROM idx_biz_jg_inspection_detection_info WHERE "RECORD" = ibjui."RECORD" ORDER BY INSPECT_DATE DESC LIMIT 1 ) nextInspectDate
FROM
idx_biz_jg_use_info ibjui
WHERE
ibjui.project_contraption_id in
<foreach collection ='projectContraptionIdList' item='id' index='index' open="(" close= ")" separator=",">
/*+ use_cplan tablescan(idx_biz_jg_use_info) tablescan(idx_biz_jg_inspection_detection_info) set(query_dop 16) */
WITH target_use AS MATERIALIZED (
SELECT "RECORD", project_contraption_id
FROM idx_biz_jg_use_info
WHERE project_contraption_id != null and
project_contraption_id IN
<foreach collection="projectContraptionIdList" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>
) A
WHERE
A.inspectOrgName IS NOT NULL AND A.inspectOrgName != '' AND A.inspectConclusion IS NOT NULL and A.inspectConclusion!=''
and A.nextInspectDate IS NOT NULL
GROUP BY A.project_contraption_id
),
latest_inspect AS (
SELECT *
FROM (
SELECT li.*,
ROW_NUMBER() OVER (PARTITION BY li."RECORD" ORDER BY li.INSPECT_DATE DESC) AS rn
FROM idx_biz_jg_inspection_detection_info li
JOIN target_use tu ON tu."RECORD" = li."RECORD"
WHERE li.INSPECT_ORG_NAME IS NOT NULL
AND li.INSPECT_ORG_NAME <![CDATA[<>]]> ''
AND li.INSPECT_CONCLUSION IS NOT NULL
AND li.INSPECT_CONCLUSION <![CDATA[<>]]> ''
AND li.NEXT_INSPECT_DATE IS NOT NULL
) t
WHERE rn = 1
)
SELECT tu.project_contraption_id,
CAST(COUNT(1) AS INTEGER) AS count
FROM target_use tu
JOIN latest_inspect li ON li."RECORD" = tu."RECORD"
GROUP BY tu.project_contraption_id
</select>
<select id="countContraptionInUseTimesForDeleteByIntoManagement" resultType="java.lang.Integer">
......
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