修改自检存放逻辑
This commit is contained in:
parent
5cd7f39d6e
commit
2d5076351b
|
|
@ -4,18 +4,12 @@ import com.alibaba.fastjson2.JSONObject;
|
|||
import com.ruoyi.device.domain.impl.tuohengmqtt.callback.IAirportFlyControlDataCallback;
|
||||
import com.ruoyi.device.mapper.entity.FlightEntity;
|
||||
import com.ruoyi.device.mapper.entity.FlightLogEntity;
|
||||
import com.ruoyi.device.mapper.entity.PreCheckLogEntity;
|
||||
import com.ruoyi.device.service.FlightService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 飞行事件回调处理器
|
||||
* 处理飞行事件日志(如起飞、返航等)
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-02-25
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class FlightEventCallback implements IAirportFlyControlDataCallback {
|
||||
|
|
@ -50,7 +44,11 @@ public class FlightEventCallback implements IAirportFlyControlDataCallback {
|
|||
}
|
||||
|
||||
if (msg != null && !msg.isEmpty()) {
|
||||
handleFlightLog(deviceSn, msg, flight);
|
||||
if (msg.contains("自检")) {
|
||||
handlePreCheckLog(deviceSn, msg, data, flight);
|
||||
} else {
|
||||
handleFlightLog(deviceSn, msg, flight);
|
||||
}
|
||||
handleFlightStatus(deviceSn, action, data, flight);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
|
@ -84,6 +82,28 @@ public class FlightEventCallback implements IAirportFlyControlDataCallback {
|
|||
}
|
||||
}
|
||||
|
||||
private void handlePreCheckLog(String deviceSn, String msg, JSONObject data, FlightEntity flight) {
|
||||
if (flight == null) {
|
||||
log.warn("飞行记录为空,无法保存自检日志: deviceSn={}, msg={}", deviceSn, msg);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Boolean success = msg.contains("通过") || msg.contains("成功");
|
||||
|
||||
PreCheckLogEntity logEntity = new PreCheckLogEntity();
|
||||
logEntity.setFlightId(flight.getFlightId());
|
||||
logEntity.setLogContent(msg);
|
||||
logEntity.setSuccess(success);
|
||||
flightService.insertPreCheckLog(logEntity);
|
||||
|
||||
log.info("保存自检日志: deviceSn={}, flightId={}, msg={}, success={}",
|
||||
deviceSn, flight.getFlightId(), msg, success);
|
||||
} catch (Exception e) {
|
||||
log.error("保存自检日志失败: deviceSn={}, msg={}, error={}",
|
||||
deviceSn, msg, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleFlightStatus(String deviceSn, String action, JSONObject data, FlightEntity flight) {
|
||||
if (flight == null) {
|
||||
log.warn("飞行记录为空,无法更新状态: deviceSn={}, action={}", deviceSn, action);
|
||||
|
|
|
|||
Loading…
Reference in New Issue