zhongrj
2025-02-11 b1e8a099eb3117bcbd5f2e0c9a2eb0accabd8cbf
src/main/java/org/springblade/modules/yw/mapper/EmergencySpaceMapper.xml
@@ -5,8 +5,9 @@
    <!--自定义分页查询-->
    <select id="selectEmergencySpacePage" resultType="org.springblade.modules.yw.vo.EmergencySpaceVO">
        select
        yes.*,
        yfi.name as firmName,
        yes.id,yes.name,yes.full_name,yes.type,yes.main_func,yes.lng,yes.lat,yes.pre_level,
        yes.capacity,yes.remark,yes.firm_id,yes.image_url,ST_AsGeoJSON(yes.geom) as geom,yes.ele,
        ifnull(yfi.name,'瑞昌工业园') as firmName,
        bdb.dict_value as emergencySpaceType
        from yw_emergency_space yes
        left join blade_dict_biz bdb on bdb.dict_key = yes.type and bdb.code = 'emergency_space_type'
@@ -21,27 +22,66 @@
        <if test="emergencySpace.type!=null">
            and yes.type = #{emergencySpace.type}
        </if>
        <if test="emergencySpace.preLevel!=null">
            and yes.pre_level = #{emergencySpace.preLevel}
        </if>
        <if test="emergencySpace.category!=null">
            and yes.category = #{emergencySpace.category}
        </if>
    </select>
    <!--获取应急空间统计数据-->
    <select id="getStatisticData" resultType="java.util.Map">
        SELECT
            case when type=1 then '应急池'
            when type =2 then '阀门'
            when type =3 then '公共管网'
            when type =4 then '污水提升泵站'
            when type =5 then '水库'
            when type =6 then '应急泵'
            when type =7 then '消防沙'
            end as type,
            count(*) as num
            BDB.dict_value AS type,
            count(*) AS num
        FROM
            yw_emergency_space yes
            LEFT JOIN blade_dict_biz BDB ON BDB.dict_key = yes.type AND BDB.CODE = 'emergency_space_type'
        WHERE
            yes.is_deleted = 0 AND yes.type IS NOT NULL
        GROUP BY yes.type
    </select>
    <!--获取应急池容量-->
    <select id="getEmePool" resultType="java.lang.String">
        SELECT
            sum( capacity ) AS num
        FROM
            yw_emergency_space
        WHERE
            is_deleted = 0
            AND type IS NOT NULL
            AND firm_id IS NOT NULL
            GROUP BY type
        WHERE type = 1  AND is_deleted = 0
    </select>
    <!--通过空间分析点位,找到离风险源最近的防控点 风险源找1,1找2,2找3-->
    <select id="spatialAnalysisPoint" resultType="org.springblade.modules.yw.vo.EmergencySpaceVO">
        SELECT
            *,
            ST_Distance_Sphere (
                ST_GeomFromText(concat("POINT(",lng," ",lat,")")),
                ST_GeomFromText (concat("POINT(",#{emergencySpace.lng}," ",#{emergencySpace.lat},")"))
            ) AS distance
        FROM
            yw_emergency_space
        where lng is not null
        <if test="emergencySpace.preLevel!=null">
            and pre_level = #{emergencySpace.preLevel}
        </if>
        <if test="emergencySpace.firmId!=null">
            and firm_id = #{emergencySpace.firmId}
        </if>
        ORDER BY distance
        LIMIT 1
    </select>
    <!--查找距离当前点最近的线-->
    <select id="spatialAnalysisPointToLines" resultType="org.springblade.modules.yw.vo.EmergencySpaceVO">
        SELECT
        2 as preLevel,
        ST_AsText(geom) as geom,
        ST_Distance(ST_GeomFromText(concat("POINT(",#{emergencySpace.lng}," ",#{emergencySpace.lat},")")), geom) AS distance
        FROM yw_geom_info
        ORDER BY distance ASC
        LIMIT 1
    </select>
</mapper>