guoshilong
2023-10-26 ac0bf12a07cb0c4c7dc9f62ff81c30d8cbf15a3b
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/damSecurity/mapper/DamSecurityMapper.xml
@@ -1137,6 +1137,184 @@
        </choose>
        )
    </select>
    <select id="getRegionList" resultType="cn.gistack.sm.damSecurity.vo.DamMonitor">
        SELECT aab."ad_name" adName , aab."guid" adCode from SJZT_MD."att_ad_base" aab where
        <choose>
            <when test="dam.adCode != null and dam.adCode !='' ">
                "p_ad_code" = #{dam.adCode}
            </when>
            <otherwise>
                "ad_grad" = 2
            </otherwise>
        </choose>
    </select>
    <select id="getLevelList" resultType="cn.gistack.sm.damSecurity.vo.LevelPo">
        SELECT COUNT(*) AS num ,level FROM NKY_ALARM_GET NAG
                LEFT JOIN SJZT_MD."att_res_base" arb ON arb."guid" = NAG.DAM_ID
                left join SJZT_MD."att_ad_base" b on arb."interior_ad_guid" = b."ad_code"
                left join SJZT_MD."att_ad_base" c on b."p_ad_code" = c."ad_code"
                left join SJZT_MD."att_ad_base" d on c."p_ad_code" = d."ad_code"
                LEFT JOIN SJZT_MD."rel_res_bas_loc" rrbl ON rrbl."res_guid" = NAG.DAM_ID
                LEFT JOIN SJZT_MD."att_bas_base" abb ON abb."code" = rrbl."bas_guid"
                LEFT JOIN SJZT_MD."att_bas_base" pabb ON abb."p_code" = pabb."code"
        where 1=1
        AND (d."ad_code" = #{dam.adCode} or c."ad_code" = #{dam.adCode} or b."ad_code" = #{dam.adCode})
        <if test="dam.startTime != null and dam.startTime != ''">
            AND DATE_FORMAT(time,'%Y-%m-%d') &gt;= #{dam.startTime}
        </if>
        <if test="dam.endTime != null and dam.endTime !='' ">
            AND DATE_FORMAT(time,'%Y-%m-%d') &lt;= #{dam.endTime}
        </if>
        <if test="dam.engScal != null and dam.engScal !='' ">
            AND arb."eng_scal" = #{dam.engScal}
        </if>
        <if test="dam.type != null and dam.type != '' and dam.type != 3">
            AND NAG.type = #{dam.type}
        </if>
        <if test="dam.type != null and dam.type != '' and dam.type == 3">
            AND (NAG.type = 3 or NAG.type = 4 or NAG.type = 5)
        </if>
        <if test="dam.labels != null and dam.labels != '' ">
            AND( 1!=1
            <foreach collection="dam.labels.split(',')" item="item" open="" separator="" close="" index="index">
                OR  #{item}  in (arb."label")
            </foreach>
            )
        </if>
        <if test="dam.basGuids != null and dam.basGuids !='' ">
            AND(
            abb."code" in
            <foreach collection="dam.basGuids.split(',')" item="item" index="index" open="(" separator="," close=")">
                #{item}
            </foreach>
            or pabb."code" in
            <foreach collection="dam.basGuids.split(',')" item="item" index="index" open="(" separator="," close=")">
                #{item}
            </foreach>
            )
        </if>
        GROUP BY LEVEL ORDER BY level ASC
    </select>
    <select id="pageMonitor" resultType="cn.gistack.nky.vo.AlarmGetVO">
        SELECT
        NAG.ID,
        NAG.DAM_ID,
        NAG.POINT_ID,
        NAG.TYPE,
        (
        CASE
        WHEN NAG.TYPE=1 THEN '渗压'
        WHEN NAG.TYPE=2 THEN '渗流'
        WHEN (NAG.TYPE=3 OR NAG.TYPE=4 OR NAG.TYPE=5) THEN '位移'
        END) AS typeName,
        NAG.TIME,
        NAG.VALUE,
        NAG."DESC",
        NAG.CREATE_TIME,
        NAG.TASK_CATEGORY,
        NAG.LEVEL,
        NAG.BAOJINGZHI,
        NAG.ORIGIN_ID,
        NAG.FORWARD,
        NAG."REVERSE",
        NAG.RATIO,
        NAG.STATUS,
        province."guid" as provinceCode,
        province."ad_name" as provinceName,
        city."guid" as cityCode,
        city."ad_name" as cityName,
        county."guid" as countyCode,
        county."ad_name" as countyName,
        arb."name" as reservoirName
        FROM NKY_ALARM_GET NAG
        LEFT JOIN SJZT_MD."att_res_base" arb ON arb."guid" = NAG.DAM_ID
        LEFT JOIN SJZT_MD."att_ad_base" town ON town."guid" = arb."interior_ad_guid"
        LEFT JOIN SJZT_MD."att_ad_base" county ON county."guid" = town."p_ad_code"
        LEFT JOIN SJZT_MD."att_ad_base" city ON city."guid" = county."p_ad_code"
        LEFT JOIN SJZT_MD."att_ad_base" province ON province."guid" = city."p_ad_code"
        LEFT JOIN SJZT_MD."rel_res_bas_loc" rrbl ON rrbl."res_guid" = NAG.DAM_ID
        LEFT JOIN SJZT_MD."att_bas_base" abb ON abb."code" = rrbl."bas_guid"
        LEFT JOIN SJZT_MD."att_bas_base" pabb ON abb."p_code" = pabb."code"
        WHERE 1=1
        <if test=" vo.adCode != null and vo.adCode !='' ">
            AND (province."ad_code" =#{vo.adCode} or city."ad_code" = #{vo.adCode} or county."ad_code" = #{vo.adCode})
        </if>
        <if test="vo.startTime != null and vo.startTime != ''">
            AND DATE_FORMAT(NAG.time,'%Y-%m-%d')  &gt;= #{vo.startTime}
        </if>
        <if test="vo.endTime != null and vo.endTime !='' ">
            AND DATE_FORMAT(NAG.time,'%Y-%m-%d') &lt;= #{vo.endTime}
        </if>
        <if test="vo.level != null and vo.level !='' ">
            AND NAG.level = #{vo.level}
        </if>
        <if test="vo.status != null and vo.status !='' ">
            AND NAG.status = #{vo.status}
        </if>
        <if test="vo.type != null and vo.type !='' and vo.type == 1 ">
            AND NAG.type = #{vo.type}
        </if>
        <if test="vo.type != null and vo.type !='' and vo.type == 2">
            AND NAG.type = #{vo.type}
        </if>
        <if test="vo.type != null and vo.type !='' and vo.type == 3">
            AND (NAG.type = '3' or NAG.type = '4' or NAG.type = '5')
        </if>
        <if test="vo.pointId != null and vo.pointId !='' ">
            AND NAG.POINT_id = #{vo.pointId}
        </if>
        <if test="vo.basGuids != null and vo.basGuids !='' ">
            AND(
            abb."code" in
            <foreach collection="vo.basGuids.split(',')" item="item" index="index" open="(" separator="," close=")">
                #{item}
            </foreach>
            or pabb."code" in
            <foreach collection="vo.basGuids.split(',')" item="item" index="index" open="(" separator="," close=")">
                #{item}
            </foreach>
            )
        </if>
        <if test="vo.labels != null and vo.labels != '' ">
            AND( 1!=1
            <foreach collection="vo.labels.split(',')" item="item" open="" separator="" close="" index="index">
                OR  #{item}  in (arb."label")
            </foreach>
            )
        </if>
        <if test="vo.engScal != null and vo.engScal !='' ">
            AND arb."eng_scal" = #{vo.engScal}
        </if>
    </select>