|
|
|
|
@ -276,7 +276,9 @@ public class EventsHandler implements MessageHandler {
|
|
|
|
|
}
|
|
|
|
|
} else if (BusinessConstant.RETURN_HOME_INFO.equals(method)) {
|
|
|
|
|
log.debug("events --> 返航信息: {}", payload);
|
|
|
|
|
//飞行日志
|
|
|
|
|
//飞行日志 飞机一起飞就会上报返航信息,所以需要先判断飞机返航 才能保存返航信息防止信息错乱
|
|
|
|
|
Object modeCode = CacheUtils.get(BusinessConstant.UAV_MODE_CODE + gateway);
|
|
|
|
|
if (modeCode instanceof Integer && (Integer) modeCode == 9) {
|
|
|
|
|
JSONObject data = message.getJSONObject(BusinessConstant.DATA);
|
|
|
|
|
if (data != null) {
|
|
|
|
|
FlightLog flightLog = new FlightLog();
|
|
|
|
|
@ -287,7 +289,7 @@ public class EventsHandler implements MessageHandler {
|
|
|
|
|
|
|
|
|
|
int lastPointType = data.getInt("last_point_type", -1);
|
|
|
|
|
String lastPointTypeCn = lastPointType == 0 ? "轨迹最后一个点在返航点的上空"
|
|
|
|
|
: lastPointType == 1 ? "轨迹最后一个点不在返航点上空" : String.valueOf(lastPointType);
|
|
|
|
|
: lastPointType == 1 ? "轨迹最后一个点不在返航点上空" : lastPointType == -1 ? "飞机降落完成" : String.valueOf(lastPointType);
|
|
|
|
|
|
|
|
|
|
StringBuilder msg = new StringBuilder();
|
|
|
|
|
msg.append("任务ID: ").append(data.getStr("flight_id", "")).append("\n");
|
|
|
|
|
@ -315,15 +317,16 @@ public class EventsHandler implements MessageHandler {
|
|
|
|
|
: 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");
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (BusinessConstant.DEVICE_EXIT_HOMING_NOTIFY.equals(method)) {
|
|
|
|
|
log.debug("events --> 设备返航退出状态通知: {}", payload);
|
|
|
|
|
JSONObject data = message.getJSONObject(BusinessConstant.DATA);
|
|
|
|
|
@ -401,7 +404,7 @@ public class EventsHandler implements MessageHandler {
|
|
|
|
|
boolean isFinalReport = data.getBool("is_final_report", false);
|
|
|
|
|
JSONArray obstacles = data.getJSONArray("obstacles");
|
|
|
|
|
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");
|
|
|
|
|
if (obstacles != null && !obstacles.isEmpty()) {
|
|
|
|
|
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();
|
|
|
|
|
msg.append("任务状态: ").append(statusCn).append("\n");
|
|
|
|
|
msg.append("执行步骤: ").append(stepStr).append("\n");
|
|
|
|
|
msg.append("进度: ").append(percent).append("%\n");
|
|
|
|
|
// msg.append("任务状态: ").append(statusCn).append("\n");
|
|
|
|
|
// msg.append("执行步骤: ").append(stepStr).append("\n");
|
|
|
|
|
// msg.append("进度: ").append(percent).append("%\n");
|
|
|
|
|
if (output.containsKey("ext")) {
|
|
|
|
|
JSONObject ext = output.getJSONObject("ext");
|
|
|
|
|
int missionState = ext.getInt("wayline_mission_state", -1);
|
|
|
|
|
String[] missionStateCn = {"断连", "不支持该航点", "航线准备状态", "航线文件上传中",
|
|
|
|
|
"触发开始命令", "进入航线", "航线执行", "航线中断", "航线恢复", "航线停止"};
|
|
|
|
|
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("航线ID: ").append(ext.getInt("wayline_id", -1)).append("\n");
|
|
|
|
|
String[] missionStateCn = {"断连", "不支持该航点", "航线准备状态,可上传文件,可执行已有文件", "航线文件上传中",
|
|
|
|
|
"触发开始命令,飞行器触发读航线等逻辑,还未开始任务,处于准备状态", "进入航线,到第一个航点", "航线执行",
|
|
|
|
|
"航线中断,触发条件:1.用户主动暂停 2.飞控异常", "航线恢复", "航线停止"};
|
|
|
|
|
// 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("track_id", "")).append("\n");
|
|
|
|
|
String trackId = ext.getStr("track_id", "");
|
|
|
|
|
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")) {
|
|
|
|
|
appendBreakPointInfo(msg, ext.getJSONObject("break_point"));
|
|
|
|
|
}
|
|
|
|
|
@ -524,15 +542,15 @@ public class EventsHandler implements MessageHandler {
|
|
|
|
|
int bpState = bp.getInt("state", -1);
|
|
|
|
|
int breakReason = bp.getInt("break_reason", 0);
|
|
|
|
|
msg.append("断点信息:\n");
|
|
|
|
|
msg.append(" 断点序号: ").append(bp.getInt("index", -1)).append("\n");
|
|
|
|
|
msg.append(" 断点状态: ").append(bpState == 0 ? "在航段上" : bpState == 1 ? "在航点上" : bpState).append("\n");
|
|
|
|
|
msg.append(" 航段进度: ").append(bp.getDouble("progress", 0d)).append("\n");
|
|
|
|
|
msg.append(" 航线ID: ").append(bp.getInt("wayline_id", -1)).append("\n");
|
|
|
|
|
msg.append(" 中断原因: ").append(getBreakReasonCn(breakReason)).append("\n");
|
|
|
|
|
msg.append(" 纬度: ").append(bp.getDouble("latitude", 0d)).append("\n");
|
|
|
|
|
msg.append(" 经度: ").append(bp.getDouble("longitude", 0d)).append("\n");
|
|
|
|
|
msg.append(" 高度: ").append(bp.getDouble("height", 0d)).append("m\n");
|
|
|
|
|
msg.append(" 偏航角: ").append(bp.getDouble("attitude_head", 0d));
|
|
|
|
|
msg.append("\t断点序号: ").append(bp.getInt("index", -1)).append("\n");
|
|
|
|
|
msg.append("\t断点状态: ").append(bpState == 0 ? "在航段上" : bpState == 1 ? "在航点上" : bpState).append("\n");
|
|
|
|
|
msg.append("\t航段进度: ").append(bp.getDouble("progress", 0d)).append("\n");
|
|
|
|
|
// msg.append("\t航线ID: ").append(bp.getInt("wayline_id", -1)).append("\n");
|
|
|
|
|
msg.append("\t中断原因: ").append(getBreakReasonCn(breakReason)).append("\n");
|
|
|
|
|
msg.append("\t纬度: ").append(bp.getDouble("latitude", 0d)).append("\n");
|
|
|
|
|
msg.append("\t经度: ").append(bp.getDouble("longitude", 0d)).append("\n");
|
|
|
|
|
msg.append("\t高度: ").append(bp.getDouble("height", 0d)).append("m\n");
|
|
|
|
|
msg.append("\t偏航角: ").append(bp.getDouble("attitude_head", 0d));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|