吉安感知网项目-后端
linwei
2026-04-02 d7dd44bd7f9171d0b4fcdcb2b7605d9377002440
drone-service/drone-fw/src/main/java/org/sxkj/fw/device/mapper/FwDeviceMapper.xml
@@ -256,7 +256,7 @@
   <!-- 统计设备类型(察打一体同时计入侦测和反制) -->
    <select id="statisticalDeviceType" resultType="org.sxkj.fw.cockpit.vo.DeviceStatisticsVO">
        SELECT
            CASE split_device_type  -- 自定义排序(可选)
        CASE split_device_type
                WHEN '1' THEN '侦测设备'
                WHEN '2' THEN '反制设备'
                ELSE '其他'
@@ -267,28 +267,27 @@
            SELECT
                d.id,
            CASE
            WHEN
                device_type = '3' THEN '1'  -- 察打一体拆分为侦测
            ELSE
                device_type
            END AS
                split_device_type
        WHEN device_type = '3' THEN '1'  -- 察打一体拆分为侦测
        ELSE device_type::VARCHAR
        END AS split_device_type
            FROM
                ja_fw_device d
            LEFT JOIN ja_fw_area_divide ad
        /* 修改点1:统一用 VARCHAR 对齐,移除容易崩溃的 ::bigint[] */
                ON d.id::VARCHAR = ANY(string_to_array(ad.device_ids, ','))
                AND ad.is_deleted = 0
            WHERE
                d.is_deleted = 0
                AND d.is_enabled = 1
                AND d.status != 3
        /* 修改点2:修正 bpchar <> integer 报错,给 3 加引号 */
        AND d.status::VARCHAR != '3'
            <if test="regionCode != null and regionCode != ''">
                and (d.final_outbound_area_code like concat(#{regionCode}, '%')
                <!-- 或者设备是共享给当前部门的 -->
                <if test="currentDeptId != null and currentDeptId != '' ">
                    or d.id in (
                    SELECT device_id FROM ja_fw_device_per_share
                    WHERE loan_to_dept_id = #{currentDeptId}
                /* 修改点3:loan_to_dept_id 强制转 bigint 匹配参数 */
                WHERE loan_to_dept_id = #{currentDeptId}::bigint
                    AND is_deleted = 0
                    )
                </if>
@@ -297,14 +296,15 @@
            <if test="flyTime != null">
                and exists (
                select 1
                from ja_fw_defense_scene ds
                join ja_fw_defense_scene_manage dsm on dsm.defense_scene_id::VARCHAR = ds.id::VARCHAR and dsm.is_deleted = 0
                where ds.is_deleted = 0
                and ds.area_divide_ids is not null
                and ds.area_divide_ids != ''
                and ad.id = ANY(string_to_array(replace(ds.area_divide_ids, ' ', ''), ',')::bigint[])
                and (dsm.effective_date_start is null or dsm.effective_date_start &lt;= #{flyTime})
                and (dsm.effective_date_end is null or dsm.effective_date_end &gt;= #{flyTime})
            from ja_fw_defense_scene ds_sub
            join ja_fw_defense_scene_manage dsm_sub on dsm_sub.defense_scene_id::VARCHAR = ds_sub.id::VARCHAR and dsm_sub.is_deleted = 0
            where ds_sub.is_deleted = 0
            and ds_sub.area_divide_ids is not null
            and ds_sub.area_divide_ids != ''
            /* 修改点4:ad.id 转 VARCHAR 匹配 ANY */
            and ad.id::VARCHAR = ANY(string_to_array(replace(ds_sub.area_divide_ids, ' ', ''), ','))
            and (dsm_sub.effective_date_start is null or dsm_sub.effective_date_start &lt;= #{flyTime})
            and (dsm_sub.effective_date_end is null or dsm_sub.effective_date_end &gt;= #{flyTime})
                )
            </if>
@@ -313,12 +313,9 @@
            SELECT
                d.id,
            CASE
            WHEN
                device_type = '3' THEN '2'  -- 察打一体拆分为反制
            ELSE
                device_type
            END AS
                split_device_type
        WHEN device_type = '3' THEN '2'  -- 察打一体拆分为反制
        ELSE device_type::VARCHAR
        END AS split_device_type
            FROM
                ja_fw_device d
            LEFT JOIN ja_fw_area_divide ad
@@ -327,15 +324,15 @@
            WHERE
                d.is_deleted = 0
                AND is_enabled = 1
                AND d.status != 3
        /* 修改点5:修正 bpchar <> integer 报错 */
        AND d.status::VARCHAR != '3'
                AND device_type = '3'
            <if test="regionCode != null and regionCode != ''">
                and (d.final_outbound_area_code like concat(#{regionCode}, '%')
                <!-- 或者设备是共享给当前部门的 -->
                <if test="currentDeptId != null and currentDeptId != '' ">
                    or d.id in (
                    SELECT device_id FROM ja_fw_device_per_share
                    WHERE loan_to_dept_id = #{currentDeptId}
                WHERE loan_to_dept_id = #{currentDeptId}::bigint
                    AND is_deleted = 0
                    )
                </if>
@@ -344,14 +341,14 @@
            <if test="flyTime != null">
                and exists (
                select 1
                from ja_fw_defense_scene ds
                join ja_fw_defense_scene_manage dsm on dsm.defense_scene_id::VARCHAR = ds.id::VARCHAR and dsm.is_deleted = 0
                where ds.is_deleted = 0
                and ds.area_divide_ids is not null
                and ds.area_divide_ids != ''
                and ad.id = ANY(string_to_array(replace(ds.area_divide_ids, ' ', ''), ',')::bigint[])
                and (dsm.effective_date_start is null or dsm.effective_date_start &lt;= #{flyTime})
                and (dsm.effective_date_end is null or dsm.effective_date_end &gt;= #{flyTime})
            from ja_fw_defense_scene ds_sub
            join ja_fw_defense_scene_manage dsm_sub on dsm_sub.defense_scene_id::VARCHAR = ds_sub.id::VARCHAR and dsm_sub.is_deleted = 0
            where ds_sub.is_deleted = 0
            and ds_sub.area_divide_ids is not null
            and ds_sub.area_divide_ids != ''
            and ad.id::VARCHAR = ANY(string_to_array(replace(ds_sub.area_divide_ids, ' ', ''), ','))
            and (dsm_sub.effective_date_start is null or dsm_sub.effective_date_start &lt;= #{flyTime})
            and (dsm_sub.effective_date_end is null or dsm_sub.effective_date_end &gt;= #{flyTime})
                )
        </if>
            ) AS temp