liusuyi
2025-12-19 e0a6ad18bb69cdba48064327a439efca5673dcf1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.ard.work.listener;
 
import com.ard.work.domain.event.DeviceStatusEvent;
import com.ard.work.service.IArdFlightTaskPartService;
import lombok.extern.java.Log;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
 
/**
 * 无人机状态事件监听
 *
 * @author lsy
 * @date 2025/12/19
 */
 
@Component
@Slf4j
public class DeviceStatusEventListener {
 
    @Autowired
    private IArdFlightTaskPartService ardFlightTaskPartService;
 
    @EventListener
    public void handleDeviceStatusEvent(DeviceStatusEvent event) {
        String boxSn = event.getBoxSn();
        boolean isOnline = event.isOnline();
 
        if (isOnline) {
            log.info("设备 {} 已上线", boxSn);
        } else {
            log.info("设备 {} 已离线", boxSn);
            //将剩余轨迹分片数据入库
            ardFlightTaskPartService.flushRemaining(boxSn);
        }
    }
}