1.媒体库增加媒体标识

2.飞行日志优化
This commit is contained in:
sdy 2026-06-04 13:45:05 +08:00
parent d4bb56c863
commit 30c4ae5eb7
6 changed files with 93 additions and 66 deletions

View File

@ -79,6 +79,7 @@ public interface BusinessConstant {
String FLIGHT_TASK_KMZ_FILE_INFO = "flight_task_kmz_file_info_"; String FLIGHT_TASK_KMZ_FILE_INFO = "flight_task_kmz_file_info_";
String UAV_SPEAKER_INDEX = "uav_speaker_index_"; String UAV_SPEAKER_INDEX = "uav_speaker_index_";
String UAV_LIGHT_INDEX = "uav_light_index_"; String UAV_LIGHT_INDEX = "uav_light_index_";
String UAV_MODE_CODE = "uav_mode_code_";
//********************************* other *********************************// //********************************* other *********************************//
String HTTP_PROTOCOL = "http://"; String HTTP_PROTOCOL = "http://";

View File

@ -21,6 +21,9 @@ public class MediaFileDTO implements Serializable {
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Schema(description = "媒体id")
private Long id;
@Schema(description = "架次编号") @Schema(description = "架次编号")
private String taskId; private String taskId;

View File

@ -276,53 +276,56 @@ public class EventsHandler implements MessageHandler {
} }
} else if (BusinessConstant.RETURN_HOME_INFO.equals(method)) { } else if (BusinessConstant.RETURN_HOME_INFO.equals(method)) {
log.debug("events --> 返航信息: {}", payload); log.debug("events --> 返航信息: {}", payload);
//飞行日志 //飞行日志 飞机一起飞就会上报返航信息所以需要先判断飞机返航 才能保存返航信息防止信息错乱
JSONObject data = message.getJSONObject(BusinessConstant.DATA); Object modeCode = CacheUtils.get(BusinessConstant.UAV_MODE_CODE + gateway);
if (data != null) { if (modeCode instanceof Integer && (Integer) modeCode == 9) {
FlightLog flightLog = new FlightLog(); JSONObject data = message.getJSONObject(BusinessConstant.DATA);
flightLog.setDockSn(gateway); if (data != null) {
flightLog.setTime(Instant.ofEpochMilli(message.getLong("timestamp"))); FlightLog flightLog = new FlightLog();
flightLog.setMethod("返航信息\n" + BusinessConstant.RETURN_HOME_INFO); flightLog.setDockSn(gateway);
flightLog.setLevel(0); flightLog.setTime(Instant.ofEpochMilli(message.getLong("timestamp")));
flightLog.setMethod("返航信息\n" + BusinessConstant.RETURN_HOME_INFO);
flightLog.setLevel(0);
int lastPointType = data.getInt("last_point_type", -1); int lastPointType = data.getInt("last_point_type", -1);
String lastPointTypeCn = lastPointType == 0 ? "轨迹最后一个点在返航点的上空" String lastPointTypeCn = lastPointType == 0 ? "轨迹最后一个点在返航点的上空"
: lastPointType == 1 ? "轨迹最后一个点不在返航点上空" : String.valueOf(lastPointType); : lastPointType == 1 ? "轨迹最后一个点不在返航点上空" : lastPointType == -1 ? "飞机降落完成" : String.valueOf(lastPointType);
StringBuilder msg = new StringBuilder(); StringBuilder msg = new StringBuilder();
msg.append("任务ID: ").append(data.getStr("flight_id", "")).append("\n"); msg.append("任务ID: ").append(data.getStr("flight_id", "")).append("\n");
msg.append("最后轨迹点类型: ").append(lastPointTypeCn).append("\n"); msg.append("最后轨迹点类型: ").append(lastPointTypeCn).append("\n");
if (data.containsKey("home_dock_sn")) { if (data.containsKey("home_dock_sn")) {
msg.append("Home点机场SN: ").append(data.getStr("home_dock_sn")).append("\n"); msg.append("Home点机场SN: ").append(data.getStr("home_dock_sn")).append("\n");
}
JSONArray points = data.getJSONArray("planned_path_points");
if (points != null && !points.isEmpty()) {
msg.append("规划轨迹点(").append(points.size()).append("个):\n");
for (int i = 0; i < points.size(); i++) {
JSONObject point = points.getJSONObject(i);
msg.append(i + 1).append(". 纬度: ").append(point.getDouble("latitude", 0d))
.append(" 经度: ").append(point.getDouble("longitude", 0d))
.append(" 高度: ").append(point.getDouble("height", 0d)).append("m\n");
} }
} JSONArray points = data.getJSONArray("planned_path_points");
JSONArray homeInfo = data.getJSONArray("multi_dock_home_info"); if (points != null && !points.isEmpty()) {
if (homeInfo != null && !homeInfo.isEmpty()) { msg.append("规划轨迹点(").append(points.size()).append("个):\n");
msg.append("蛙跳任务返航信息:\n"); for (int i = 0; i < points.size(); i++) {
for (int i = 0; i < homeInfo.size(); i++) { JSONObject point = points.getJSONObject(i);
JSONObject info = homeInfo.getJSONObject(i); msg.append(i + 1).append(". 纬度: ").append(point.getDouble("latitude", 0d))
int planStatus = info.getInt("plan_status", -1); .append(" 经度: ").append(point.getDouble("longitude", 0d))
String planStatusCn = planStatus == 0 ? "规划失败或正在规划中" .append(" 高度: ").append(point.getDouble("height", 0d)).append("m\n");
: planStatus == 1 ? "规划路径不可达" }
: planStatus == 2 ? "规划路径因电量不可达"
: planStatus == 3 ? "目标可达" : String.valueOf(planStatus);
msg.append(" 机场SN: ").append(info.getStr("sn", "")).append("\n");
msg.append(" 路径规划状态: ").append(planStatusCn).append("\n");
msg.append(" 预估电量消耗: ").append(info.getInt("estimated_battery_consumption", 0)).append("%\n");
msg.append(" Home点距离: ").append(info.getDouble("home_distance", 0d)).append("m\n");
} }
JSONArray homeInfo = data.getJSONArray("multi_dock_home_info");
if (homeInfo != null && !homeInfo.isEmpty()) {
msg.append("蛙跳任务返航信息:\n");
for (int i = 0; i < homeInfo.size(); i++) {
JSONObject info = homeInfo.getJSONObject(i);
int planStatus = info.getInt("plan_status", -1);
String planStatusCn = planStatus == 0 ? "规划失败或正在规划中"
: planStatus == 1 ? "规划路径不可达"
: planStatus == 2 ? "规划路径因电量不可达"
: planStatus == 3 ? "目标可达" : String.valueOf(planStatus);
msg.append("\t机场SN: ").append(info.getStr("sn", "")).append("\n");
msg.append("\t路径规划状态: ").append(planStatusCn).append("\n");
msg.append("\t预估电量消耗: ").append(info.getInt("estimated_battery_consumption", 0)).append("%\n");
msg.append("\tHome点距离: ").append(info.getDouble("home_distance", 0d)).append("m\n");
}
}
flightLog.setMessage(msg.toString());
influxService.addRecord(flightLog);
} }
flightLog.setMessage(msg.toString());
influxService.addRecord(flightLog);
} }
} else if (BusinessConstant.DEVICE_EXIT_HOMING_NOTIFY.equals(method)) { } else if (BusinessConstant.DEVICE_EXIT_HOMING_NOTIFY.equals(method)) {
log.debug("events --> 设备返航退出状态通知: {}", payload); log.debug("events --> 设备返航退出状态通知: {}", payload);
@ -391,7 +394,7 @@ public class EventsHandler implements MessageHandler {
"当前航点索引: " + wayPointIndex "当前航点索引: " + wayPointIndex
); );
influxService.addRecord(flightLog); influxService.addRecord(flightLog);
}else if(BusinessConstant.OBSTACLE_AVOIDANCE_NOTIFY.equals(method)){ } else if (BusinessConstant.OBSTACLE_AVOIDANCE_NOTIFY.equals(method)) {
log.debug("events --> 避障记录上报事件通知: {}", payload); log.debug("events --> 避障记录上报事件通知: {}", payload);
//飞行日志 //飞行日志
JSONObject data = message.getJSONObject(BusinessConstant.DATA); JSONObject data = message.getJSONObject(BusinessConstant.DATA);
@ -401,7 +404,7 @@ public class EventsHandler implements MessageHandler {
boolean isFinalReport = data.getBool("is_final_report", false); boolean isFinalReport = data.getBool("is_final_report", false);
JSONArray obstacles = data.getJSONArray("obstacles"); JSONArray obstacles = data.getJSONArray("obstacles");
StringBuilder msg = new StringBuilder(); StringBuilder msg = new StringBuilder();
msg.append("航线ID: ").append(waylineUuid).append("\n"); // msg.append("航线ID: ").append(waylineUuid).append("\n");
msg.append("任务ID: ").append(flightId).append("\n"); msg.append("任务ID: ").append(flightId).append("\n");
if (obstacles != null && !obstacles.isEmpty()) { if (obstacles != null && !obstacles.isEmpty()) {
msg.append("避障记录(").append(obstacles.size()).append("条):\n"); msg.append("避障记录(").append(obstacles.size()).append("条):\n");
@ -492,23 +495,38 @@ public class EventsHandler implements MessageHandler {
"日志拉取-上传飞行器日志", "日志拉取-上传机场日志", "日志拉取-通知结果", "日志拉取-上传飞行器日志", "日志拉取-上传机场日志", "日志拉取-通知结果",
"自定义飞行区文件更新准备中", "自定义飞行区更新中", "离线地图更新准备中", "离线地图更新中" "自定义飞行区文件更新准备中", "自定义飞行区更新中", "离线地图更新准备中", "离线地图更新中"
}; };
String stepStr = currentStep >= 0 && currentStep < stepCn.length ? stepCn[currentStep] : String.valueOf(currentStep); String stepStr;
if (currentStep > 6000) {
stepStr = currentStep == 65533 ? "结束后等待服务回包" : currentStep == 65534 ? "无具体状态" : "UNKNOWN";
} else {
stepStr = currentStep >= 0 && currentStep < stepCn.length ? stepCn[currentStep] : String.valueOf(currentStep);
}
StringBuilder msg = new StringBuilder(); StringBuilder msg = new StringBuilder();
msg.append("任务状态: ").append(statusCn).append("\n"); // msg.append("任务状态: ").append(statusCn).append("\n");
msg.append("执行步骤: ").append(stepStr).append("\n"); // msg.append("执行步骤: ").append(stepStr).append("\n");
msg.append("进度: ").append(percent).append("%\n"); // msg.append("进度: ").append(percent).append("%\n");
if (output.containsKey("ext")) { if (output.containsKey("ext")) {
JSONObject ext = output.getJSONObject("ext"); JSONObject ext = output.getJSONObject("ext");
int missionState = ext.getInt("wayline_mission_state", -1); int missionState = ext.getInt("wayline_mission_state", -1);
String[] missionStateCn = {"断连", "不支持该航点", "航线准备状态", "航线文件上传中", String[] missionStateCn = {"断连", "不支持该航点", "航线准备状态,可上传文件,可执行已有文件", "航线文件上传中",
"触发开始命令", "进入航线", "航线执行", "航线中断", "航线恢复", "航线停止"}; "触发开始命令,飞行器触发读航线等逻辑,还未开始任务,处于准备状态", "进入航线,到第一个航点", "航线执行",
msg.append("航线任务状态: ").append(missionState >= 0 && missionState < missionStateCn.length ? missionStateCn[missionState] : missionState).append("\n"); "航线中断触发条件1.用户主动暂停 2.飞控异常", "航线恢复", "航线停止"};
msg.append("当前航点: ").append(ext.getInt("current_waypoint_index", -1)).append("\n"); // msg.append("航线ID: ").append(ext.getInt("wayline_id", -1)).append("\n");
msg.append("航线ID: ").append(ext.getInt("wayline_id", -1)).append("\n");
msg.append("任务ID: ").append(ext.getStr("flight_id", "")).append("\n"); msg.append("任务ID: ").append(ext.getStr("flight_id", "")).append("\n");
msg.append("航迹ID: ").append(ext.getStr("track_id", "")).append("\n"); String trackId = ext.getStr("track_id", "");
msg.append("媒体文件数: ").append(ext.getInt("media_count", 0)).append("\n"); if (StrUtil.isNotBlank(trackId)) {
msg.append("航迹ID: ").append(trackId).append("\n");
}
msg.append("任务状态: ").append(statusCn).append("\n");
msg.append("航线状态: ").append(missionState >= 0 && missionState < missionStateCn.length ? missionStateCn[missionState] : missionState).append("\n");
msg.append("当前航点: ").append(ext.getInt("current_waypoint_index", -1)).append("\n");
msg.append("进度: ").append("\n");
msg.append("\t执行步骤: ").append(stepStr).append("\n");
msg.append("\t进度值: ").append(percent).append("%\n");
if ("ok".equals(status)) {
msg.append("媒体文件数: ").append(ext.getInt("media_count", 0)).append("\n");
}
if (ext.containsKey("break_point")) { if (ext.containsKey("break_point")) {
appendBreakPointInfo(msg, ext.getJSONObject("break_point")); appendBreakPointInfo(msg, ext.getJSONObject("break_point"));
} }
@ -524,15 +542,15 @@ public class EventsHandler implements MessageHandler {
int bpState = bp.getInt("state", -1); int bpState = bp.getInt("state", -1);
int breakReason = bp.getInt("break_reason", 0); int breakReason = bp.getInt("break_reason", 0);
msg.append("断点信息:\n"); msg.append("断点信息:\n");
msg.append(" 断点序号: ").append(bp.getInt("index", -1)).append("\n"); msg.append("\t断点序号: ").append(bp.getInt("index", -1)).append("\n");
msg.append(" 断点状态: ").append(bpState == 0 ? "在航段上" : bpState == 1 ? "在航点上" : bpState).append("\n"); msg.append("\t断点状态: ").append(bpState == 0 ? "在航段上" : bpState == 1 ? "在航点上" : bpState).append("\n");
msg.append(" 航段进度: ").append(bp.getDouble("progress", 0d)).append("\n"); msg.append("\t航段进度: ").append(bp.getDouble("progress", 0d)).append("\n");
msg.append(" 航线ID: ").append(bp.getInt("wayline_id", -1)).append("\n"); // msg.append("\t航线ID: ").append(bp.getInt("wayline_id", -1)).append("\n");
msg.append(" 中断原因: ").append(getBreakReasonCn(breakReason)).append("\n"); msg.append("\t中断原因: ").append(getBreakReasonCn(breakReason)).append("\n");
msg.append(" 纬度: ").append(bp.getDouble("latitude", 0d)).append("\n"); msg.append("\t纬度: ").append(bp.getDouble("latitude", 0d)).append("\n");
msg.append(" 经度: ").append(bp.getDouble("longitude", 0d)).append("\n"); msg.append("\t经度: ").append(bp.getDouble("longitude", 0d)).append("\n");
msg.append(" 高度: ").append(bp.getDouble("height", 0d)).append("m\n"); msg.append("\t高度: ").append(bp.getDouble("height", 0d)).append("m\n");
msg.append(" 偏航角: ").append(bp.getDouble("attitude_head", 0d)); msg.append("\t偏航角: ").append(bp.getDouble("attitude_head", 0d));
} }
/** /**

View File

@ -77,6 +77,11 @@ public class OsdHandler implements MessageHandler {
} else { } else {
// log.debug("uav osd --> topic: {}, payload: {}", topic, payload); // log.debug("uav osd --> topic: {}, payload: {}", topic, payload);
CacheUtils.set(BusinessConstant.UAV_OSD + dockSn, data); CacheUtils.set(BusinessConstant.UAV_OSD + dockSn, data);
//保存无人机状态 {"0":"待机","1":"起飞准备","2":"起飞准备完毕","3":"手动飞行","4":"自动起飞","5":"航线飞行","6":"全景拍照","7":"智能跟随","8":"ADS-B 躲避","9":"自动返航","10":"自动降落","11":"强制降落","12":"三桨叶降落","13":"升级中","14":"未连接","15":"APAS","16":"虚拟摇杆状态","17":"指令飞行","18":"空中 RTK 收敛模式","19":"机场选址中","20":"POI环绕","21":"进离场航线飞行过程中"}
Integer mode = data.getInt("mode_code");
if (mode != null) {
CacheUtils.set(BusinessConstant.UAV_MODE_CODE + dockSn, mode, 1000 * 5);
}
//保存osd到influxdb //保存osd到influxdb
String latitude = data.getStr("latitude"); String latitude = data.getStr("latitude");
String longitude = data.getStr("longitude"); String longitude = data.getStr("longitude");

View File

@ -298,7 +298,7 @@ public class FlightTaskServiceImpl extends CrudServiceImpl<FlightTaskDao, Flight
HashMap<String, Object> condition = Maps.newHashMap(); HashMap<String, Object> condition = Maps.newHashMap();
condition.put("dockSn", dockSn); condition.put("dockSn", dockSn);
return influxService.queryData(DateUtils.format(outboundDate, DateUtils.DATE_TIME_PATTERN), return influxService.queryData(DateUtils.format(DateUtils.getBeforeTime(outboundDate, -5), DateUtils.DATE_TIME_PATTERN),
DateUtils.format(inboundDate, DateUtils.DATE_TIME_PATTERN), "flight_log", condition, JSONObject.class, DateUtils.format(inboundDate, DateUtils.DATE_TIME_PATTERN), "flight_log", condition, JSONObject.class,
"dockSn", "_time", "method", "level", "message"); "dockSn", "_time", "method", "level", "message");
} }

View File

@ -71,7 +71,7 @@ srs:
server-url: http://${host.ip}:61630 server-url: http://${host.ip}:61630
influx: influx:
saveOpen: true saveOpen: false
url: http://${host.ip}:61634 url: http://${host.ip}:61634
token: u32ol28aVjyZzAi1Wi-GydHcULZymvqZMKOX8lLZUwr3WdTpx1rBB2sBvk62_0zo7Ot0LnsgxJlHA0gInegWXg== token: u32ol28aVjyZzAi1Wi-GydHcULZymvqZMKOX8lLZUwr3WdTpx1rBB2sBvk62_0zo7Ot0LnsgxJlHA0gInegWXg==
bucket: flight_records bucket: flight_records