吉安感知网项目-后端
linwei
4 days ago 8585b431e9257333413358eb37c30ae58f74db76
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/mapper/FwDefenseSceneMapper.xml
@@ -3,12 +3,113 @@
<mapper namespace="org.sxkj.fw.area.mapper.FwDefenseSceneMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="fwDefenseSceneResultMap" type="org.sxkj.fw.area.entity.FwDefenseSceneEntity">
    <resultMap id="fwDefenseSceneResultMap" type="org.sxkj.fw.area.vo.FwDefenseSceneVO">
        <result column="id" property="id"/>
        <result column="scene_name" property="sceneName"/>
        <result column="scene_type" property="sceneType"/>
        <result column="longitude" property="longitude"/>
        <result column="latitude" property="latitude"/>
        <result column="defense_leader" property="defenseLeader"/>
        <result column="leader_phone" property="leaderPhone"/>
        <result column="defense_area" property="defenseArea"/>
        <result column="device_mode" property="deviceMode"/>
        <result column="area_divide_ids" property="areaDivideIds"/>
        <result column="area_code" property="areaCode"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
    </resultMap>
    <select id="selectFwDefenseScenePage" resultMap="fwDefenseSceneResultMap">
        select * from ja_fw_defense_scene where is_deleted = 0
        select
            *
        from
            ja_fw_defense_scene
        <where>
                and is_deleted = 0
            <if test="param2.id != null and param2.id != ''">
                and id = #{param2.id}
            </if>
            <if test="param2.sceneName != null and param2.sceneName != ''">
                and scene_name like concat('%', #{param2.sceneName}, '%')
            </if>
            <if test="param2.sceneType != null and param2.sceneType != ''">
                and scene_type = #{param2.sceneType}
            </if>
            <if test="param2.deptList != null and param2.deptList.size > 0">
                and create_dept in
                <foreach collection="param2.deptList" item="deptId" open="(" separator="," close=")">
                    #{deptId}
                </foreach>
            </if>
        </where>
    </select>
    <select id="selectFwDefenseSceneList" resultMap="fwDefenseSceneResultMap">
        select
            ds.*
        from
            ja_fw_defense_scene ds
        <where>
                ds.is_deleted = 0
            <if test="deptList != null and deptList.size > 0">
                and ds.create_dept in
                <foreach collection="deptList" item="deptId" open="(" separator="," close=")">
                    #{deptId}
                </foreach>
            </if>
            <if test="unbound != null and unbound == 1">
                and (
                    not exists (
                        select 1
                        from ja_fw_defense_scene_manage dsm
                        where dsm.is_deleted = 0
                          and dsm.defense_scene_id::VARCHAR = ds.id::VARCHAR
                    )
                    <if test="sceneManageId != null">
                        or exists (
                            select 1
                            from ja_fw_defense_scene_manage dsm
                            where dsm.is_deleted = 0
                              and dsm.id = #{sceneManageId}
                              and dsm.defense_scene_id::VARCHAR = ds.id::VARCHAR
                        )
                    </if>
                )
            </if>
            <if test="filterSelected != null and filterSelected == 1">
                and (
                    not exists (
                        select 1
                        from ja_fw_defense_zone dz
                        where dz.is_deleted = 0
                          and dz.defense_scene_ids is not null
                          and dz.defense_scene_ids != ''
                          and ds.id = ANY(string_to_array(dz.defense_scene_ids, ',')::bigint[])
                    )
                    <if test="zoneId != null">
                        or exists (
                            select 1
                            from ja_fw_defense_zone dz
                            where dz.is_deleted = 0
                              and dz.id = #{zoneId}
                              and dz.defense_scene_ids is not null
                              and dz.defense_scene_ids != ''
                              and ds.id = ANY(string_to_array(dz.defense_scene_ids, ',')::bigint[])
                        )
                    </if>
                )
            </if>
            <if test="areaId != null and (filterSelected == null or filterSelected != 1)">
                and ds.area_divide_ids is not null
                and ds.area_divide_ids != ''
                and #{areaId} = ANY(string_to_array(replace(ds.area_divide_ids, ' ', ''), ',')::bigint[])
            </if>
        </where>
    </select>