吉安感知网项目-后端
linwei
2026-02-12 150e7984510dd3cd18319418aae5f99224d96d64
驾驶舱统计优化
6 files modified
176 ■■■■■ changed files
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/scheduler/DefenseSceneStatusScheduler.java 4 ●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/cockpit/service/impl/CockpitServiceImpl.java 2 ●●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/device/dto/FwDeviceDTO.java 3 ●●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/device/mapper/FwDeviceMapper.java 5 ●●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/device/mapper/FwDeviceMapper.xml 157 ●●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/device/service/impl/FwDeviceServiceImpl.java 5 ●●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/area/scheduler/DefenseSceneStatusScheduler.java
@@ -33,9 +33,9 @@
    /**
     * 每天凌晨0点执行,检查并更新过期的防控场景状态
     */
    @Scheduled(cron = "0 0 0 * * ?") // 每天凌晨0点执行
    // @Scheduled(cron = "0 0 0 * * ?") // 每天凌晨0点执行
    // 每10秒执行一次(用于本地调试)
    // @Scheduled(cron = "*/10 * * * * ?")
    @Scheduled(cron = "0 0/1 * * * ?")
    public void refreshDefenseSceneStatus() {
        log.info("开始执行防控场景状态刷新任务");
drone-service/drone-fw/src/main/java/org/sxkj/fw/cockpit/service/impl/CockpitServiceImpl.java
@@ -77,6 +77,7 @@
            Region byCode = RegionCache.getByCode(dept.getAreaCode());
            fwDevice.setRegionCode(HeaderUtils.formatAreaCode(byCode.getCode()));
            fwDevice.setCurrentDeptId(AuthUtil.getDeptId());
            fwDevice.setFlyTime(new Date());
        IPage<CockpitFwDeviceVO> cockpitFwDeviceVOIPage = fwDeviceService.selectCockpitDevicePage(page, fwDevice);
        return cockpitFwDeviceVOIPage;
    }
@@ -152,6 +153,7 @@
        Region byCode = RegionCache.getByCode(dept.getAreaCode());
        fwDeviceDTO.setCurrentDeptId(AuthUtil.getDeptId());
        fwDeviceDTO.setRegionCode(HeaderUtils.formatAreaCode(byCode.getCode()));
        fwDeviceDTO.setFlyTime(new Date());
        return fwDeviceService.getDeviceStatistics(fwDeviceDTO);
    }
drone-service/drone-fw/src/main/java/org/sxkj/fw/device/dto/FwDeviceDTO.java
@@ -174,5 +174,8 @@
     */
    @ApiModelProperty(value = "删除标志(0存在 1删除)")
    private Integer isDeleted;
    // flyTime
    @ApiModelProperty(value = " flyTime")
    private Date flyTime;
}
drone-service/drone-fw/src/main/java/org/sxkj/fw/device/mapper/FwDeviceMapper.java
@@ -30,6 +30,7 @@
import org.sxkj.fw.device.vo.CockpitFwDeviceVO;
import org.sxkj.fw.device.vo.FwDeviceVO;
import java.util.Date;
import java.util.List;
/**
@@ -80,7 +81,7 @@
     * 设备统计 - 驾驶舱使用
     * @return 统计数据
     */
    List<DeviceStatisticsVO> statisticalDeviceType(String regionCode, String currentDeptId);
    List<DeviceStatisticsVO> statisticalDeviceType(String regionCode, String currentDeptId, Date flyTime);
    /**
     * 设备统计 - 按类型统计
@@ -104,7 +105,7 @@
     * 告警统计
     * @return
     */
    AlarmStatisticsVO statisticalDeviceAtt(String regionCode, String currentDeptId);
    AlarmStatisticsVO statisticalDeviceAtt(String regionCode, String currentDeptId, Date flyTime);
    /**
     * 获取设备列表
drone-service/drone-fw/src/main/java/org/sxkj/fw/device/mapper/FwDeviceMapper.xml
@@ -265,7 +265,7 @@
        FROM (
            -- 子查询:拆分察打一体设备为侦测/反制两类
            SELECT
                id,
                d.id,
            CASE
            WHEN
                device_type = '3' THEN '1'  -- 察打一体拆分为侦测
@@ -275,10 +275,13 @@
                split_device_type
            FROM
                ja_fw_device d
            LEFT JOIN ja_fw_area_divide ad
                ON find_in_set(d.id, ad.device_ids) > 0
                AND ad.is_deleted = 0
            WHERE
                d.is_deleted = 0
                AND d.is_enabled = 1
                AND status != 3
                AND d.status != 3
            <if test="regionCode != null and regionCode != ''">
                and (d.final_outbound_area_code like concat(#{regionCode}, '%')
                <!-- 或者设备是共享给当前部门的 -->
@@ -291,11 +294,24 @@
                </if>
                )
            </if>
            <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 = ds.id and dsm.is_deleted = 0
                where ds.is_deleted = 0
                and ds.area_divide_ids is not null
                and ds.area_divide_ids != ''
                and find_in_set(ad.id, replace(ds.area_divide_ids, ' ', ''))
                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})
                )
            </if>
            UNION ALL  -- 合并拆分的反制部分
            SELECT
                id,
                d.id,
            CASE
            WHEN
                device_type = '3' THEN '2'  -- 察打一体拆分为反制
@@ -305,10 +321,13 @@
                split_device_type
            FROM
                ja_fw_device d
            LEFT JOIN ja_fw_area_divide ad
                ON find_in_set(d.id, ad.device_ids) > 0
                AND ad.is_deleted = 0
            WHERE
                d.is_deleted = 0
                AND is_enabled = 1
                AND status != 3
                AND d.status != 3
                AND device_type = '3'
            <if test="regionCode != null and regionCode != ''">
                and (d.final_outbound_area_code like concat(#{regionCode}, '%')
@@ -322,6 +341,19 @@
                </if>
                )
            </if>
            <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 = ds.id and dsm.is_deleted = 0
                where ds.is_deleted = 0
                and ds.area_divide_ids is not null
                and ds.area_divide_ids != ''
                and find_in_set(ad.id, replace(ds.area_divide_ids, ' ', ''))
                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})
                )
        </if>
            ) AS temp
        GROUP BY split_device_type
        ORDER BY split_device_type
@@ -423,6 +455,9 @@
                 COUNT(*)
             FROM
                 ja_fw_device d
            left join ja_fw_area_divide ad
                on find_in_set(d.id, ad.device_ids) > 0
                and ad.is_deleted = 0
             WHERE
                 d.is_deleted = 0
               and d.is_enabled = 1
@@ -438,17 +473,33 @@
                    </if>
                    )
                </if>
                <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 = ds.id and dsm.is_deleted = 0
                    where ds.is_deleted = 0
                    and ds.area_divide_ids is not null
                    and ds.area_divide_ids != ''
                    and find_in_set(ad.id, replace(ds.area_divide_ids, ' ', ''))
                    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})
                    )
                </if>
             ) AS deviceCount,
            -- 无线电设备数量
            (SELECT
                 COUNT(*)
             FROM
                 ja_fw_device d
            left join ja_fw_area_divide ad
                on find_in_set(d.id, ad.device_ids) > 0
                and ad.is_deleted = 0
             WHERE
                 d.is_deleted = 0
               and d.is_enabled = 1
               AND device_att = '1'
            <if test="regionCode != null and regionCode != ''">
                <if test="regionCode != null and regionCode != ''">
                and (d.final_outbound_area_code like concat(#{regionCode},'%')
                <!-- 或者设备是共享给当前部门的 -->
                    <if test="currentDeptId != null and currentDeptId != '' ">
@@ -460,12 +511,28 @@
                    </if>
                    )
                </if>
                <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 = ds.id and dsm.is_deleted = 0
                    where ds.is_deleted = 0
                    and ds.area_divide_ids is not null
                    and ds.area_divide_ids != ''
                    and find_in_set(ad.id, replace(ds.area_divide_ids, ' ', ''))
                    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})
                    )
                </if>
             ) AS radioCount,
            -- 光电设备数量
            (SELECT
                 COUNT(*)
             FROM
                 ja_fw_device d
            left join ja_fw_area_divide ad
                on find_in_set(d.id, ad.device_ids) > 0
                and ad.is_deleted = 0
             WHERE d.is_deleted = 0
               and d.is_enabled = 1
               AND device_att = '2'
@@ -481,15 +548,31 @@
                </if>
                )
            </if>
            <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 = ds.id and dsm.is_deleted = 0
                where ds.is_deleted = 0
                and ds.area_divide_ids is not null
                and ds.area_divide_ids != ''
                and find_in_set(ad.id, replace(ds.area_divide_ids, ' ', ''))
                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})
                )
            </if>
             ) AS opticalCount,
            -- 雷达设备数量
            (SELECT
                 COUNT(*)
             FROM ja_fw_device d
             left join ja_fw_area_divide ad
                on find_in_set(d.id, ad.device_ids) > 0
                and ad.is_deleted = 0
             WHERE d.is_deleted = 0
               and d.is_enabled = 1
               AND device_att = '3'
            <if test="regionCode != null and regionCode != ''">
                <if test="regionCode != null and regionCode != ''">
                and (d.final_outbound_area_code like concat(#{regionCode},'%')
                    <!-- 或者设备是共享给当前部门的 -->
                    <if test="currentDeptId != null and currentDeptId != '' ">
@@ -501,15 +584,31 @@
                    </if>
                    )
                </if>
                <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 = ds.id and dsm.is_deleted = 0
                    where ds.is_deleted = 0
                    and ds.area_divide_ids is not null
                    and ds.area_divide_ids != ''
                    and find_in_set(ad.id, replace(ds.area_divide_ids, ' ', ''))
                    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})
                    )
                </if>
             ) AS radarCount,
            -- 设备告警
            (SELECT
                 COUNT(*)
             FROM ja_fw_device d
            left join ja_fw_area_divide ad
                on find_in_set(d.id, ad.device_ids) > 0
                and ad.is_deleted = 0
             WHERE d.is_deleted = 0
               and d.is_enabled = 1
               AND status in ('1', '2', '3' )
            <if test="regionCode != null and regionCode != ''">
               AND d.status in ('1', '2', '3' )
                <if test="regionCode != null and regionCode != ''">
                and (d.final_outbound_area_code like concat(#{regionCode},'%')
                    <!-- 或者设备是共享给当前部门的 -->
                    <if test="currentDeptId != null and currentDeptId != '' ">
@@ -519,6 +618,19 @@
                        AND is_deleted = 0
                        )
                    </if>
                    )
                </if>
                <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 = ds.id and dsm.is_deleted = 0
                    where ds.is_deleted = 0
                    and ds.area_divide_ids is not null
                    and ds.area_divide_ids != ''
                    and find_in_set(ad.id, replace(ds.area_divide_ids, ' ', ''))
                    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})
                    )
                </if>
             ) AS deviceAlarmCount
@@ -543,6 +655,19 @@
        <where>
                d.is_deleted = 0
                and d.is_enabled = 1
            <if test=" param2.flyTime != null">
                and exists (
                select 1
                from ja_fw_defense_scene ds
                join ja_fw_defense_scene_manage dsm on dsm.defense_scene_id = ds.id and dsm.is_deleted = 0
                where ds.is_deleted = 0
                and ds.area_divide_ids is not null
                and ds.area_divide_ids != ''
                and find_in_set(ad.id, replace(ds.area_divide_ids, ' ', ''))
                and (dsm.effective_date_start is null or dsm.effective_date_start &lt;= #{param2.flyTime})
                and (dsm.effective_date_end is null or dsm.effective_date_end &gt;= #{param2.flyTime})
                )
            </if>
            <if test="param2.regionCode != null and param2.regionCode != ''">
                and (d.final_outbound_area_code like concat(#{param2.regionCode},'%')
                <!-- 或者设备是共享给当前部门的 -->
@@ -644,6 +769,9 @@
            COUNT(*) AS count
        FROM
            ja_fw_device d
        LEFT JOIN ja_fw_area_divide ad
            ON find_in_set(d.id, ad.device_ids) > 0
            AND ad.is_deleted = 0
        WHERE
            d.is_deleted = 0
        AND d.is_enabled = 1
@@ -659,6 +787,19 @@
            </if>
            )
        </if>
        <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 = ds.id and dsm.is_deleted = 0
            where ds.is_deleted = 0
            and ds.area_divide_ids is not null
            and ds.area_divide_ids != ''
            and find_in_set(ad.id, replace(ds.area_divide_ids, ' ', ''))
            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})
            )
        </if>
        GROUP BY
        d.final_outbound_area
    </select>
drone-service/drone-fw/src/main/java/org/sxkj/fw/device/service/impl/FwDeviceServiceImpl.java
@@ -46,6 +46,7 @@
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -135,7 +136,7 @@
     */
    @Override
    public List<DeviceStatisticsVO> statisticalDeviceType(String regionCode, String currentDeptId) {
        return baseMapper.statisticalDeviceType(regionCode, currentDeptId);
        return baseMapper.statisticalDeviceType(regionCode, currentDeptId, new Date());
    }
    /**
@@ -181,7 +182,7 @@
     */
    @Override
    public AlarmStatisticsVO statisticalDeviceAtt(String regionCode, String currentDeptId) {
        return baseMapper.statisticalDeviceAtt(regionCode, currentDeptId);
        return baseMapper.statisticalDeviceAtt(regionCode, currentDeptId, new Date());
    }
    @Override