This commit is contained in:
parent
42e6643b52
commit
d075d913fb
|
|
@ -150,6 +150,40 @@ public class AircraftFlyController extends BaseController
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 无人机关机接口
|
||||
*
|
||||
* @param sn 机场SN号
|
||||
* @return 关机响应
|
||||
*/
|
||||
@Operation(summary = "无人机关机", description = "控制指定机场的无人机执行关机操作")
|
||||
@PostMapping("/power-off/{sn}")
|
||||
public R<String> powerOff(
|
||||
@Parameter(description = "机场SN号", required = true, example = "THJSQ03B2309DN7VQN43")
|
||||
@PathVariable("sn") String sn)
|
||||
{
|
||||
log.info("收到无人机关机请求: sn={}", sn);
|
||||
|
||||
try {
|
||||
// 调用机器命令管理器执行关机命令
|
||||
CompletableFuture<CommandResult> future = machineCommandManager.executeCommand(sn, CommandType.POWER_OFF);
|
||||
|
||||
// 等待命令执行完成
|
||||
CommandResult result = future.get();
|
||||
|
||||
if (result.isSuccess()) {
|
||||
log.info("无人机关机成功: sn={}", sn);
|
||||
return R.ok("关机命令执行成功");
|
||||
} else {
|
||||
log.error("无人机关机失败: sn={}, reason={}", sn, result.getErrorMessage());
|
||||
return R.fail("关机命令执行失败: " + result.getErrorMessage());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("无人机关机异常: sn={}", sn, e);
|
||||
return R.fail("关机命令执行异常: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询无人机状态
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue