Commit 980204b2 authored by 刘林's avatar 刘林

fix(jg):监管业务查询性能优化

parent 69205719
...@@ -4,72 +4,96 @@ ...@@ -4,72 +4,96 @@
<select id="queryForSafetyProblemTracingPage" <select id="queryForSafetyProblemTracingPage"
resultType="com.yeejoin.amos.boot.module.jg.api.dto.SafetyProblemTracingDto"> resultType="com.yeejoin.amos.boot.module.jg.api.dto.SafetyProblemTracingDto">
select
SELECT
spt.*, spt.*,
case when spt."problem_status_code" = '0' then '红' CASE
else '绿' end hiddenDangersLevel, WHEN spt.problem_status_code = '0' THEN '红'
(select extend::json->>'pic' from cb_data_dictionary where type = 'ISSUE_TYPE' and code = spt.problem_type_code) problemTypePic ELSE '绿'
from tzs_safety_problem_tracing spt END AS hiddenDangersLevel,
cdd.extend::json ->> 'pic' AS problemTypePic
FROM tzs_safety_problem_tracing spt
LEFT JOIN cb_data_dictionary cdd
ON cdd.type = 'ISSUE_TYPE'
AND cdd.code = spt.problem_type_code
<where> <where>
spt.is_delete = false spt.is_delete = FALSE
<if test="problemModel.problemNum != null and problemModel.problemNum != ''"> <if test="problemModel.problemNum != null and problemModel.problemNum != ''">
and spt.problem_num = LIKE CONCAT('%', #{problemModel.problemNum}, '%') AND spt.problem_num LIKE CONCAT('%', #{problemModel.problemNum}, '%')
</if> </if>
<if test="problemModel.problemStatus != null and problemModel.problemStatus != ''"> <if test="problemModel.problemStatus != null and problemModel.problemStatus != ''">
and spt.problem_status = #{problemModel.problemStatus} AND spt.problem_status = #{problemModel.problemStatus}
</if> </if>
<if test="problemModel.equipListCode != null and problemModel.equipListCode != ''"> <if test="problemModel.equipListCode != null and problemModel.equipListCode != ''">
and spt.equip_list_code = #{problemModel.equipListCode} AND spt.equip_list_code = #{problemModel.equipListCode}
</if> </if>
<if test="problemModel.equCategoryCode != null and problemModel.equCategoryCode != ''"> <if test="problemModel.equCategoryCode != null and problemModel.equCategoryCode != ''">
and spt.equ_category_code = #{problemModel.equCategoryCode} AND spt.equ_category_code = #{problemModel.equCategoryCode}
</if> </if>
<if test="problemModel.sourceTypeCode != null and problemModel.sourceTypeCode != ''"> <if test="problemModel.sourceTypeCode != null and problemModel.sourceTypeCode != ''">
and spt.source_type_code = #{problemModel.sourceTypeCode} AND spt.source_type_code = #{problemModel.sourceTypeCode}
</if> </if>
<if test="problemModel.problemLevelCode != null and problemModel.problemLevelCode != ''"> <if test="problemModel.problemLevelCode != null and problemModel.problemLevelCode != ''">
and spt.problem_level_code = #{problemModel.problemLevelCode} AND spt.problem_level_code = #{problemModel.problemLevelCode}
</if> </if>
<if test="problemModel.problemTypeCode != null and problemModel.problemTypeCode != ''"> <if test="problemModel.problemTypeCode != null and problemModel.problemTypeCode != ''">
and spt.problem_type_code = #{problemModel.problemTypeCode} AND spt.problem_type_code = #{problemModel.problemTypeCode}
</if> </if>
<if test="problemModel.problemTimeRange != null and problemModel.problemTimeRange.beginDate != null"> <if test="problemModel.problemTimeRange != null and problemModel.problemTimeRange.beginDate != null">
and to_char(spt.problem_time, 'YYYY-MM-DD') <![CDATA[>=]]> AND to_char(spt.problem_time, 'YYYY-MM-DD') <![CDATA[>=]]>
to_char(#{problemModel.problemTimeRange.beginDate}::timestamp, 'YYYY-MM-DD') to_char(#{problemModel.problemTimeRange.beginDate}::timestamp, 'YYYY-MM-DD')
</if> </if>
<if test="problemModel.problemTimeRange != null and problemModel.problemTimeRange.endDate != null"> <if test="problemModel.problemTimeRange != null and problemModel.problemTimeRange.endDate != null">
and to_char(spt.problem_time, 'YYYY-MM-DD') <![CDATA[<=]]> AND to_char(spt.problem_time, 'YYYY-MM-DD') <![CDATA[<=]]>
to_char(#{problemModel.problemTimeRange.endDate}::timestamp, 'YYYY-MM-DD') to_char(#{problemModel.problemTimeRange.endDate}::timestamp, 'YYYY-MM-DD')
</if> </if>
<if test="problemModel.problemDesc != null and problemModel.problemDesc != ''"> <if test="problemModel.problemDesc != null and problemModel.problemDesc != ''">
and spt.problem_desc like CONCAT('%', #{problemModel.problemDesc}, '%') AND spt.problem_desc LIKE CONCAT('%', #{problemModel.problemDesc}, '%')
</if> </if>
<if test="problemModel.sourceId != null and problemModel.sourceId != ''"> <if test="problemModel.sourceId != null and problemModel.sourceId != ''">
and spt.source_id = #{problemModel.sourceId} AND spt.source_id = #{problemModel.sourceId}
</if> </if>
<if test="problemModel.governingBodyOrgCode != null and problemModel.governingBodyOrgCode != ''"> <if test="problemModel.governingBodyOrgCode != null and problemModel.governingBodyOrgCode != ''">
and spt.governing_body_org_code like CONCAT(#{problemModel.governingBodyOrgCode}, '%') AND spt.governing_body_org_code LIKE CONCAT(#{problemModel.governingBodyOrgCode}, '%')
</if> </if>
<if test="problemModel.governingBodyCode != null and problemModel.governingBodyCode != ''"> <if test="problemModel.governingBodyCode != null and problemModel.governingBodyCode != ''">
and spt.governing_body_code = #{problemModel.governingBodyCode} AND spt.governing_body_code = #{problemModel.governingBodyCode}
</if> </if>
<if test="problemModel.principalUnit != null and problemModel.principalUnit != ''"> <if test="problemModel.principalUnit != null and problemModel.principalUnit != ''">
and spt.principal_unit like CONCAT('%', #{problemModel.principalUnit}, '%') AND spt.principal_unit LIKE CONCAT('%', #{problemModel.principalUnit}, '%')
</if> </if>
<if test="problemModel.principalUnitType != null and problemModel.principalUnitType != ''"> <if test="problemModel.principalUnitType != null and problemModel.principalUnitType != ''">
and spt.principal_unit_type like CONCAT('%', #{problemModel.principalUnitType}, '%') AND spt.principal_unit_type LIKE CONCAT('%', #{problemModel.principalUnitType}, '%')
</if> </if>
<if test="problemModel.hiddenDangersLevel != null and problemModel.hiddenDangersLevel != ''"> <if test="problemModel.hiddenDangersLevel != null and problemModel.hiddenDangersLevel != ''">
and spt.problem_status_code = #{problemModel.hiddenDangersLevel} AND spt.problem_status_code = #{problemModel.hiddenDangersLevel}
</if> </if>
<if test="problemModel.regionCode != null and problemModel.regionCode != ''"> <if test="problemModel.regionCode != null and problemModel.regionCode != ''">
and spt.region_code like CONCAT('%',#{problemModel.regionCode}, '%') AND spt.region_code LIKE CONCAT('%', #{problemModel.regionCode}, '%')
</if> </if>
<if test="problemModel.problemStatusCode != null and problemModel.problemStatusCode != ''"> <if test="problemModel.problemStatusCode != null and problemModel.problemStatusCode != ''">
and spt.problem_status_code = #{problemModel.problemStatusCode} AND spt.problem_status_code = #{problemModel.problemStatusCode}
</if> </if>
</where> </where>
order by spt.create_date desc ORDER BY spt.create_date DESC
</select> </select>
<select id="queryEquipListByProblemId" resultType="java.util.Map"> <select id="queryEquipListByProblemId" resultType="java.util.Map">
......
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