From 2d5076351bf6521b6e4191db457850d2af9d3b6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=B0=8F=E4=BA=91?= Date: Wed, 25 Feb 2026 13:17:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=87=AA=E6=A3=80=E5=AD=98?= =?UTF-8?q?=E6=94=BE=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/FlightEventCallback.java | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/ruoyi/device/service/impl/FlightEventCallback.java b/src/main/java/com/ruoyi/device/service/impl/FlightEventCallback.java index 9de4d70..44a694d 100644 --- a/src/main/java/com/ruoyi/device/service/impl/FlightEventCallback.java +++ b/src/main/java/com/ruoyi/device/service/impl/FlightEventCallback.java @@ -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);