吉安感知网项目-后端
linwei
2026-01-31 1c3d9f4f6d0dc330a80b199cfb824f41a048fe6c
设备权限优化
6 files modified
310 ■■■■ changed files
drone-service/drone-fw/src/main/java/org/sxkj/fw/cockpit/controller/CockpitController.java 16 ●●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/cockpit/service/ICockpitService.java 7 ●●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/cockpit/service/impl/CockpitServiceImpl.java 13 ●●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/device/mapper/FwDeviceMapper.xml 212 ●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/record/mapper/FwDroneAlarmRecordMapper.xml 42 ●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/record/mapper/FwDroneFlightRecordMapper.xml 20 ●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/cockpit/controller/CockpitController.java
@@ -3,6 +3,8 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.support.Condition;
@@ -70,6 +72,20 @@
    }
    /**
     * 设备出库去向统计
     * @return 统计数据
     */
    @GetMapping("/statisticalDeviceOut")
    @ApiOperationSupport(order = 7)
    @ApiOperation(value = "设备出库去向统计", notes = "设备出库去向统计")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "effectiveRangeKmIsNotNull", value = "有效范围是否为空:0-不处理 1-不为空 2-为空", paramType = "query", dataType = "string")
    })
    public R<List<DeviceStatisticsVO>> statisticalDeviceOut(String effectiveRangeKmIsNotNull) {
        return R.data(cockpitService.getDeviceOutStatistics(effectiveRangeKmIsNotNull));
    }
    /**
     * 告警记录统计接口
     */
    @GetMapping("/alarmStatistics")
drone-service/drone-fw/src/main/java/org/sxkj/fw/cockpit/service/ICockpitService.java
@@ -47,4 +47,11 @@
     * @return
     */
    AlarmStatisticsVO statisticsAlarmsAndDeviceRecords();
    /**
     *
     * @param effectiveRangeKmIsNotNull
     * @return
     */
    List<DeviceStatisticsVO> getDeviceOutStatistics(String effectiveRangeKmIsNotNull);
}
drone-service/drone-fw/src/main/java/org/sxkj/fw/cockpit/service/impl/CockpitServiceImpl.java
@@ -55,7 +55,8 @@
        String regionName = byCode.getName();
        fwDevice.setRegionName(regionName);
        fwDevice.setCurrentDeptId(AuthUtil.getDeptId());
        return fwDeviceService.selectCockpitDevicePage(page, fwDevice);
        IPage<CockpitFwDeviceVO> cockpitFwDeviceVOIPage = fwDeviceService.selectCockpitDevicePage(page, fwDevice);
        return cockpitFwDeviceVOIPage;
    }
    @Override
@@ -120,4 +121,14 @@
        alarmStatisticsVO.setRealTimeAlarmCount(alarmStatistics.getRealTimeAlarmCount());
        return alarmStatisticsVO;
    }
    /**
     *
     * @param effectiveRangeKmIsNotNull
     * @return
     */
    @Override
    public List<DeviceStatisticsVO> getDeviceOutStatistics(String effectiveRangeKmIsNotNull) {
        return fwDeviceService.getDeviceOutStatistics(effectiveRangeKmIsNotNull);
    }
}
drone-service/drone-fw/src/main/java/org/sxkj/fw/device/mapper/FwDeviceMapper.xml
@@ -245,29 +245,13 @@
                split_device_type
            FROM
                ja_fw_device d
            LEFT JOIN (
                SELECT
                    device_id,
                    out_target,
                    ROW_NUMBER() OVER (
                    PARTITION BY
                    device_id
                    ORDER BY
                    create_time DESC
                    ) AS rn
                FROM
                    ja_fw_device_track
                WHERE
                    out_target IS NOT NULL
                ) t ON d.id = t.device_id AND t.rn = 1
            WHERE
                d.is_deleted = 0
            AND status != 3
            AND track_status = 1
            AND effective_range_km is not null
            AND effective_range_km > 0
                AND d.is_enabled = 1
                AND status != 3
                AND track_status = 1
            <if test="regionName != null and regionName != ''">
                and (t.out_target = #{regionName}
                and (d.final_outbound_area = #{regionName}
                <!-- 或者设备是共享给当前部门的 -->
                <if test="currentDeptId != null and currentDeptId != '' ">
                    or d.id in (
@@ -292,30 +276,14 @@
                split_device_type
            FROM
                ja_fw_device d
            LEFT JOIN (
                SELECT
                    device_id,
                    out_target,
                    ROW_NUMBER() OVER (
                    PARTITION BY
                    device_id
                    ORDER BY
                    create_time DESC
                ) AS rn
            FROM
                ja_fw_device_track
            WHERE
                out_target IS NOT NULL
            ) t ON d.id = t.device_id AND t.rn = 1
            WHERE
                d.is_deleted = 0
            AND status != 3
            AND device_type = '3'
            AND track_status = 1
            AND effective_range_km is not null
            AND effective_range_km > 0
                AND is_enabled = 1
                AND status != 3
                AND device_type = '3'
                AND track_status = 1
            <if test="regionName != null and regionName != ''">
                and (t.out_target = #{regionName}
                and (d.final_outbound_area = #{regionName}
                <!-- 或者设备是共享给当前部门的 -->
                <if test="currentDeptId != null and currentDeptId != '' ">
                    or d.id in (
@@ -355,29 +323,14 @@
    <!-- 设备出库去向统计 -->
    <select id="getDeviceOutStatistics" resultType="org.sxkj.fw.cockpit.vo.DeviceStatisticsVO">
        SELECT
            t.out_target AS type,
            d.final_outbound_area AS type,
            COUNT(*) AS count
        FROM
            ja_fw_device d
                LEFT JOIN (
                SELECT
                    device_id,
                    out_target,
                    ROW_NUMBER() OVER (
                        PARTITION BY
                            device_id
                        ORDER BY
                            create_time DESC
                        ) AS rn
                FROM
                    ja_fw_device_track
                WHERE
                    out_target IS NOT NULL
            ) t ON d.id = t.device_id
                AND t.rn = 1
        WHERE
            d.is_deleted = 0
          AND t.out_target IS NOT NULL
            AND d.is_enabled = 1
            AND d.final_outbound_area IS NOT NULL
        <if test="effectiveRangeKmIsNotNull != null and effectiveRangeKmIsNotNull == 1">
            and d.effective_range_km is not null
            and d.effective_range_km > 0
@@ -392,7 +345,7 @@
            </foreach>
        </if>
        GROUP BY
            t.out_target
            d.final_outbound_area
    </select>
    <!--  设备生产厂商统计  -->
@@ -422,29 +375,14 @@
                 COUNT(*)
             FROM
                 ja_fw_device d
            LEFT JOIN (
            SELECT
                device_id,
                out_target,
                ROW_NUMBER() OVER (
                PARTITION BY
                device_id
                ORDER BY
                create_time DESC
                ) AS rn
            FROM
                ja_fw_device_track
            WHERE
            out_target IS NOT NULL
            ) t
                ON d.id = t.device_id AND t.rn = 1
             WHERE
                 d.is_deleted = 0
               and d.is_enabled = 1
               and effective_range_km is not null
               and effective_range_km > 0
                AND track_status = 1
                <if test="regionName != null and regionName != ''">
                    and (t.out_target = #{regionName}
                    and (d.final_outbound_area = #{regionName}
                    <!-- 或者设备是共享给当前部门的 -->
                    <if test="currentDeptId != null and currentDeptId != '' ">
                        or d.id in (
@@ -461,30 +399,15 @@
                 COUNT(*)
             FROM
                 ja_fw_device d
            LEFT JOIN (
                SELECT
                    device_id,
                    out_target,
                    ROW_NUMBER() OVER (
                    PARTITION BY
                    device_id
                    ORDER BY
                    create_time DESC
                    ) AS rn
                FROM
                    ja_fw_device_track
                WHERE
                    out_target IS NOT NULL
                ) t
                ON d.id = t.device_id AND t.rn = 1
             WHERE
                 d.is_deleted = 0
               and d.is_enabled = 1
               AND device_att = '1'
               and effective_range_km is not null
               and effective_range_km > 0
               AND track_status = 1
                <if test="regionName != null and regionName != ''">
                and (t.out_target = #{regionName}
                and (d.final_outbound_area = #{regionName}
                <!-- 或者设备是共享给当前部门的 -->
                    <if test="currentDeptId != null and currentDeptId != '' ">
                        or d.id in (
@@ -501,29 +424,14 @@
                 COUNT(*)
             FROM
                 ja_fw_device d
            LEFT JOIN (
                SELECT
                    device_id,
                    out_target,
                    ROW_NUMBER() OVER (
                    PARTITION BY
                    device_id
                    ORDER BY
                    create_time DESC
                    ) AS rn
                FROM
                    ja_fw_device_track
                WHERE
                    out_target IS NOT NULL
                ) t
                ON d.id = t.device_id AND t.rn = 1
             WHERE d.is_deleted = 0
               and d.is_enabled = 1
               AND device_att = '2'
               and effective_range_km is not null
               and effective_range_km > 0
               AND track_status = 1
            <if test="regionName != null and regionName != ''">
                and (t.out_target = #{regionName}
                and (d.final_outbound_area = #{regionName}
                <!-- 或者设备是共享给当前部门的 -->
                <if test="currentDeptId != null and currentDeptId != '' ">
                    or d.id in (
@@ -539,29 +447,14 @@
            (SELECT
                 COUNT(*)
             FROM ja_fw_device d
            LEFT JOIN (
            SELECT
                device_id,
                out_target,
                ROW_NUMBER() OVER (
                PARTITION BY
                device_id
                ORDER BY
                create_time DESC
                ) AS rn
            FROM
                ja_fw_device_track
            WHERE
            out_target IS NOT NULL
            ) t
            ON d.id = t.device_id AND t.rn = 1
             WHERE d.is_deleted = 0
               and d.is_enabled = 1
               AND device_att = '3'
               and effective_range_km is not null
               and effective_range_km > 0
               AND track_status = 1
                <if test="regionName != null and regionName != ''">
                    and (t.out_target = #{regionName}
                    and (d.final_outbound_area = #{regionName}
                    <!-- 或者设备是共享给当前部门的 -->
                    <if test="currentDeptId != null and currentDeptId != '' ">
                        or d.id in (
@@ -576,30 +469,15 @@
            -- 设备告警
            (SELECT
                 COUNT(*)
             FROM ja_fw_device  d
            LEFT JOIN (
                SELECT
                    device_id,
                    out_target,
                    ROW_NUMBER() OVER (
                    PARTITION BY
                    device_id
                    ORDER BY
                    create_time DESC
                    ) AS rn
                FROM
                    ja_fw_device_track
                WHERE
                    out_target IS NOT NULL
                ) t
                ON d.id = t.device_id AND t.rn = 1
             FROM ja_fw_device d
             WHERE d.is_deleted = 0
               and d.is_enabled = 1
               AND status in ('1', '2', '3' )
               and effective_range_km is not null
               and effective_range_km > 0
               AND track_status = 1
                <if test="regionName != null and regionName != ''">
                    and (t.out_target = #{regionName}
                    and (d.final_outbound_area = #{regionName}
                    <!-- 或者设备是共享给当前部门的 -->
                    <if test="currentDeptId != null and currentDeptId != '' ">
                        or d.id in (
@@ -618,29 +496,14 @@
            d.*
        from
            ja_fw_device d
        LEFT JOIN (
            SELECT
                device_id,
                out_target,
                ROW_NUMBER() OVER (
                PARTITION BY
                device_id
                ORDER BY
                create_time DESC
                ) AS rn
            FROM
                ja_fw_device_track
            WHERE
                out_target IS NOT NULL
            ) t
            ON d.id = t.device_id AND t.rn = 1
        <where>
            d.is_deleted = 0
            and d.effective_range_km is not null
            and d.effective_range_km > 0
--             and d.effective_range_km is not null
--             and d.effective_range_km > 0
            and d.track_status = 1
            and d.is_enabled = 1
            <if test="param2.regionName != null and param2.regionName != ''">
                and (t.out_target = #{param2.regionName}
                and (d.final_outbound_area = #{param2.regionName}
                <!-- 或者设备是共享给当前部门的 -->
                <if test="param2.currentDeptId != null and param2.currentDeptId != '' ">
                    or d.id in (
@@ -720,31 +583,16 @@
            END AS isShared
        FROM
            ja_fw_device d
            LEFT JOIN (
            SELECT
            device_id,
            out_target,
            ROW_NUMBER() OVER (
            PARTITION BY
            device_id
            ORDER BY
            create_time DESC
            ) AS rn
            FROM
            ja_fw_device_track
            WHERE
            out_target IS NOT NULL
            ) t ON d.id = t.device_id
            AND t.rn = 1
            LEFT JOIN ja_fw_device_per_share ps ON ps.device_id = d.id
            AND ps.loan_to_dept_id = #{currentDeptId}
            AND ps.is_deleted = 0
        WHERE
            d.is_deleted = 0
          and d.is_enabled = 1
          and d.effective_range_km is not null
          and d.effective_range_km > 0
          and d.track_status = 1
          AND t.out_target != #{regionName}
          AND d.final_outbound_area != #{regionName}
    </select>
</mapper>
drone-service/drone-fw/src/main/java/org/sxkj/fw/record/mapper/FwDroneAlarmRecordMapper.xml
@@ -38,7 +38,7 @@
            dar.*,
            d.device_name,
            d.status deviceStatus,
            t.out_target,
            d.final_outbound_area,
            /* 1=已关注,0=未关注 */
            EXISTS (
                SELECT
@@ -54,28 +54,12 @@
            ja_fw_drone_alarm_record dar
        left join
            ja_fw_device d on dar.device_id = d.id
        /* 关联出库去向表,看设备去了哪里  */
        LEFT JOIN (
            SELECT
                device_id,
                out_target,
                ROW_NUMBER() OVER (
                PARTITION BY
                device_id
                ORDER BY
                create_time DESC
            ) AS rn
            FROM
                ja_fw_device_track
            WHERE
                out_target IS NOT NULL
            ) t
            ON d.id = t.device_id AND t.rn = 1
        <where>
                dar.is_deleted = 0
                and d.track_status = 1
                and d.is_enabled = 1
            <if test="param2.regionName != null and param2.regionName != ''">
                and (t.out_target = #{param2.regionName}
                and (d.final_outbound_area = #{param2.regionName}
                <!-- 或者设备是共享给当前部门的 -->
                <if test="param2.currentDeptId != null and param2.currentDeptId != '' ">
                    or dar.device_id in (
@@ -187,28 +171,12 @@
            ja_fw_drone_alarm_record  dar
        left join
            ja_fw_device d on dar.device_id = d.id
        /* 关联出库去向表,看设备去了哪里  */
        LEFT JOIN (
            SELECT
                device_id,
                out_target,
                ROW_NUMBER() OVER (
                PARTITION BY
                device_id
                ORDER BY
                create_time DESC
                ) AS rn
            FROM
                ja_fw_device_track
            WHERE
            out_target IS NOT NULL
            ) t
            ON d.id = t.device_id AND t.rn = 1
        WHERE dar.is_deleted = 0
            AND d.track_status = 1
            AND d.is_deleted = 0
            and d.is_enabled = 1
        <if test="regionName != null and regionName != ''">
            and (t.out_target = #{regionName}
            and (d.final_outbound_area = #{regionName}
            <!-- 或者设备是共享给当前部门的 -->
            <if test="currentDeptId != null and currentDeptId != '' ">
                or dar.device_id in (
drone-service/drone-fw/src/main/java/org/sxkj/fw/record/mapper/FwDroneFlightRecordMapper.xml
@@ -29,28 +29,12 @@
            ja_fw_drone_flight_record dfr
        left join
            ja_fw_device d on dfr.device_id = d.id
        /* 关联出库去向表,看设备去了哪里  */
        LEFT JOIN (
            SELECT
                device_id,
                out_target,
                ROW_NUMBER() OVER (
                PARTITION BY
                device_id
                ORDER BY
                create_time DESC
                ) AS rn
            FROM
                ja_fw_device_track
            WHERE
                out_target IS NOT NULL
            ) t
            ON d.id = t.device_id AND t.rn = 1
        <where>
                dfr.is_deleted = 0
                and d.track_status = 1
                and d.is_enabled = 1
            <if test="param2.regionName != null and param2.regionName != ''">
                and (t.out_target = #{param2.regionName}
                and (d.final_outbound_area = #{param2.regionName}
                <!-- 或者设备是共享给当前部门的 -->
                <if test="param2.currentDeptId != null and param2.currentDeptId != '' ">
                    or dfr.device_id in (