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);
|
}
|
}
|
}
|