Compare commits
13 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
eb76ef35e0 | |
|
|
01e0504bba | |
|
|
83b76fecdd | |
|
|
22f18ebbe5 | |
|
|
135402e725 | |
|
|
b7825ab099 | |
|
|
f4820b809f | |
|
|
1a241f809b | |
|
|
3d4d995d05 | |
|
|
3f1c4c21be | |
|
|
88cfd84fd8 | |
|
|
e5cfb7068f | |
|
|
b5b3d3cc9d |
|
|
@ -12,6 +12,7 @@ import com.ruoyi.device.domain.impl.machine.command.CommandResult;
|
|||
import com.ruoyi.device.domain.impl.machine.command.CommandType;
|
||||
import com.ruoyi.device.domain.impl.machine.state.MachineStates;
|
||||
import com.ruoyi.device.service.FlightService;
|
||||
import com.ruoyi.task.api.domain.TaskResultVO;
|
||||
import com.ruoyi.task.api.enums.StatusEnum;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
|
|
@ -66,11 +67,15 @@ public class AircraftFlyController extends BaseController
|
|||
CommandType commandType;
|
||||
java.util.Map<String, Object> params = new java.util.HashMap<>();
|
||||
|
||||
// 处理消息ID
|
||||
if (request.getMessageID() != null) {
|
||||
params.put("messageID", request.getMessageID());
|
||||
Long currentTaskId = flightService.currentRunningTask(sn);
|
||||
if (currentTaskId != null) {
|
||||
params.put("messageID", currentTaskId);
|
||||
} else {
|
||||
params.put("messageID", System.currentTimeMillis());
|
||||
if (request.getMessageID() != null) {
|
||||
params.put("messageID", request.getMessageID());
|
||||
} else {
|
||||
params.put("messageID", System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
||||
// 处理扩展参数
|
||||
|
|
@ -202,6 +207,7 @@ public class AircraftFlyController extends BaseController
|
|||
@Parameter(description = "任务ID", required = true, example = "1")
|
||||
@PathVariable("taskId") Long taskId)
|
||||
{
|
||||
|
||||
// TODO: 实现获取实时信息逻辑
|
||||
DroneRealtimeInfoVO vo = new DroneRealtimeInfoVO();
|
||||
vo.setClimbSpeed(0);
|
||||
|
|
@ -273,17 +279,19 @@ public class AircraftFlyController extends BaseController
|
|||
CommandResult result = future.get();
|
||||
|
||||
if (result.isSuccess()) {
|
||||
log.info("无人机起飞命令发送成功: sn={}", request.getSn());
|
||||
flightService.updateFlightStatus(request.getTaskId(), StatusEnum.CHECKING);
|
||||
log.info("无人机起飞命令发送成功 executeCommand: sn={}", request.getSn());
|
||||
flightService.updateFlightStatus(request.getTaskId(), TaskResultVO.Checking("无人机起飞命令发送成功"));
|
||||
return R.ok("无人机起飞命令发送成功");
|
||||
} else {
|
||||
log.error("无人机起飞命令发送失败: sn={}, reason={}", request.getSn(), result.getErrorMessage());
|
||||
flightService.updateFlightStatus(request.getTaskId(), StatusEnum.FAILED);
|
||||
log.error("无人机起飞失败 无人机起飞命令发送失败: sn={}, reason={}", request.getSn(), result.getErrorMessage());
|
||||
flightService.updateFlightStatus(request.getTaskId(),
|
||||
TaskResultVO.Error("人机起飞命令发送失败 executeCommand"+ result.getErrorMessage()));
|
||||
return R.fail("无人机起飞命令发送失败: " + result.getErrorMessage());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("无人机起飞命令发送失败: sn={}", request.getSn(), e);
|
||||
flightService.updateFlightStatus(request.getTaskId(), StatusEnum.FAILED);
|
||||
log.error("无人机起飞失败 无人机起飞命令发送失败: sn={}", request.getSn(), e);
|
||||
flightService.updateFlightStatus(request.getTaskId(),
|
||||
TaskResultVO.Error("人机起飞命令发送失败 executeCommand E" + e.getMessage()));
|
||||
return R.fail("无人机起飞命令发送失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
@ -473,12 +481,12 @@ public class AircraftFlyController extends BaseController
|
|||
|
||||
try {
|
||||
|
||||
Long currentTaskId = flightService.currentRunningTask(request.getSn());
|
||||
Long currentTaskId = flightService.currentRunningTask(request.getSn());
|
||||
java.util.Map<String, Object> params = new java.util.HashMap<>();
|
||||
if(Objects.isNull(currentTaskId)){
|
||||
params.put("messageID", UUID.randomUUID().toString());
|
||||
}else {
|
||||
params.put("messageID",currentTaskId);
|
||||
if (currentTaskId != null) {
|
||||
params.put("messageID", currentTaskId);
|
||||
} else {
|
||||
params.put("messageID", System.currentTimeMillis());
|
||||
}
|
||||
params.put("taskId", 9074);
|
||||
params.put("zhilin", "03");
|
||||
|
|
|
|||
|
|
@ -139,9 +139,9 @@ public class GroupController extends BaseController
|
|||
DockDetailDTO dockDetailDTO = bufferDeviceService.getDockDetailById(dock.getDockId());
|
||||
if (dockDetailDTO != null) {
|
||||
dockDetailDTO.setLastActiveTime(dock.getLastActiveTime());
|
||||
dockDetailDTO.setCabinVideoUrl(dock.getCabinVideoUrl());
|
||||
dockDetailDTO.setOutsideVideoUrl(dock.getOutsideVideoUrl());
|
||||
dockDetailDTO.setLiveVideoUrl(dock.getLiveVideoUrl());
|
||||
// dockDetailDTO.setCabinVideoUrl(dock.getCabinVideoUrl());
|
||||
// dockDetailDTO.setOutsideVideoUrl(dock.getOutsideVideoUrl());
|
||||
// dockDetailDTO.setLiveVideoUrl(dock.getLiveVideoUrl());
|
||||
dtoList.add(dockDetailDTO);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.ruoyi.device.service;
|
||||
|
||||
import com.ruoyi.device.mapper.entity.FlightEntity;
|
||||
import com.ruoyi.task.api.domain.TaskResultVO;
|
||||
import com.ruoyi.task.api.enums.StatusEnum;
|
||||
|
||||
import java.util.Map;
|
||||
|
|
@ -53,7 +54,7 @@ public interface FlightService
|
|||
* @param flightId 飞行ID
|
||||
* @param status 状态:自检中、飞行中、已返航
|
||||
*/
|
||||
void updateFlightStatus(Long flightId, StatusEnum status);
|
||||
void updateFlightStatus(Long flightId, TaskResultVO status);
|
||||
|
||||
// /**
|
||||
// * 更新返航时间
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import lombok.Data;
|
|||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* DJI MQTT配置属性
|
||||
*
|
||||
|
|
@ -32,7 +34,7 @@ public class TuohengMqttProperties {
|
|||
/**
|
||||
* 客户端ID
|
||||
*/
|
||||
private String clientId = "ThingsBoard_gateway";
|
||||
private String clientId = "ThingsBoard_gateway_" + UUID.randomUUID().toString().substring(0, 8);
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ public class DjiService {
|
|||
DjiMqttClientConfig config = DjiMqttClientConfig.builder()
|
||||
.host(mqttProperties.getHost())
|
||||
.port(mqttProperties.getPort())
|
||||
.clientId(mqttProperties.getClientId())
|
||||
.clientId(mqttProperties.getClientId() + "_" + System.currentTimeMillis())
|
||||
.username(mqttProperties.getUsername())
|
||||
.password(mqttProperties.getPassword())
|
||||
.connectionTimeout(mqttProperties.getConnectionTimeout())
|
||||
|
|
@ -73,7 +73,7 @@ public class DjiService {
|
|||
.autoReconnect(mqttProperties.getAutoReconnect())
|
||||
.cleanSession(mqttProperties.getCleanSession())
|
||||
.useSharedSubscription(true)
|
||||
.sharedGroupName("dji-group")
|
||||
.sharedGroupName("dji-server-group")
|
||||
.build();
|
||||
|
||||
// 创建客户端
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.ruoyi.device.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.ruoyi.device.domain.impl.tuohengmqtt.callback.IAirportFlyControlCallback;
|
||||
import com.ruoyi.device.domain.impl.tuohengmqtt.callback.IAirportFlyControlDataCallback;
|
||||
|
|
@ -7,6 +8,7 @@ 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 com.ruoyi.task.api.domain.TaskResultVO;
|
||||
import com.ruoyi.task.api.enums.StatusEnum;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -109,7 +111,7 @@ public class FlightEventCallback implements IAirportFlyControlCallback, IAirport
|
|||
handleFlightLog(deviceSn, msg, taskId);
|
||||
// 更新状态为 FLYING
|
||||
log.info("【FlightEventCallback】检测到起飞成功,更新状态为FLYING: deviceSn={}, flightId={}", deviceSn, taskId);
|
||||
flightService.updateFlightStatus(taskId, StatusEnum.RUNNING);
|
||||
flightService.updateFlightStatus(taskId, TaskResultVO.Running());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -124,9 +126,17 @@ public class FlightEventCallback implements IAirportFlyControlCallback, IAirport
|
|||
// 检查是否任务完成
|
||||
String dataContent = data.getString("data");
|
||||
if ("操作成功".equals(msg) && "[地面站]任务飞行完成".equals(dataContent)) {
|
||||
log.info("【FlightEventCallback】检测到任务完成,更新状态为HOME: deviceSn={}, flightId={}", deviceSn, taskId);
|
||||
flightService.updateFlightStatus(taskId, StatusEnum.COMPLETED);
|
||||
log.info("【FlightEventCallback】检测到 [地面站]任务飞行完成 ,更新状态为HOME: deviceSn={}, flightId={}", deviceSn, taskId);
|
||||
flightService.updateFlightStatus(taskId, TaskResultVO.Completed("检测到 [地面站]任务飞行完成 ,更新状态为HOME"));
|
||||
}
|
||||
|
||||
if ("[机巢]无人机关机成功".equals(dataContent)) {
|
||||
log.info("【FlightEventCallback】检测到 [机巢]无人机关机成功 ,更新状态为HOME: deviceSn={}, flightId={}", deviceSn, taskId);
|
||||
flightService.updateFlightStatus(taskId, TaskResultVO.Completed("[机巢]无人机关机成功 ,更新状态为HOME"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
// 未起飞,所有消息存到 device_pre_check_log
|
||||
log.info("【FlightEventCallback】未起飞,存入自检日志: deviceSn={}, flightId={}, msg={}, code={}", deviceSn, taskId, msg, code);
|
||||
|
|
@ -134,8 +144,9 @@ public class FlightEventCallback implements IAirportFlyControlCallback, IAirport
|
|||
|
||||
// 检查是否自检失败(code=1 表示失败)
|
||||
if (code != null && (code == 1 || code == -1)) {
|
||||
log.info("【FlightEventCallback】检测到自检失败(code=1),更新状态为ERROR: deviceSn={}, flightId={}", deviceSn, taskId);
|
||||
flightService.updateFlightStatus(taskId, StatusEnum.FAILED);
|
||||
log.info("无人机起飞失败【FlightEventCallback】检测到自检失败(code=1),更新状态为ERROR: deviceSn={}, flightId={} msg {}",
|
||||
deviceSn, taskId, JSON.toJSONString(data));
|
||||
flightService.updateFlightStatus(taskId, TaskResultVO.Error("handleControlDataMessage 检测到自检失败(code=1)"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ 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 com.ruoyi.task.api.domain.TaskResultVO;
|
||||
import com.ruoyi.task.api.enums.StatusEnum;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -104,7 +105,9 @@ public class FlightLogCallback implements IDroneRealTimeCallback {
|
|||
String logContent = check + " " + value + " " + statusText;
|
||||
|
||||
if(Boolean.FALSE.equals(result)){
|
||||
flightService.updateFlightStatus(taskId, StatusEnum.FAILED);
|
||||
log.info("无人机起飞失败: sn={}", deviceSn);
|
||||
flightService.updateFlightStatus(taskId, TaskResultVO.Error("无人机起飞失败 " +
|
||||
"handlePreCheckLog 自检失败" + deviceSn));
|
||||
}
|
||||
|
||||
logEntity.setLogContent(logContent);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import com.ruoyi.device.mapper.entity.FlightLogEntity;
|
|||
import com.ruoyi.device.mapper.entity.PreCheckLogEntity;
|
||||
import com.ruoyi.device.service.FlightService;
|
||||
import com.ruoyi.task.api.RemoteTaskService;
|
||||
import com.ruoyi.task.api.domain.TaskResultVO;
|
||||
import com.ruoyi.task.api.domain.TaskVO;
|
||||
import com.ruoyi.task.api.enums.ExecuteTypeEnum;
|
||||
import com.ruoyi.task.api.enums.StatusEnum;
|
||||
|
|
@ -113,7 +114,7 @@ public class FlightServiceImpl implements FlightService
|
|||
// }
|
||||
|
||||
@Override
|
||||
public void updateFlightStatus(Long flightId,StatusEnum status) {
|
||||
public void updateFlightStatus(Long flightId, TaskResultVO status) {
|
||||
|
||||
remoteTaskService.updateTaskStatus(flightId,status,SecurityConstants.INNER);
|
||||
|
||||
|
|
|
|||
|
|
@ -69,6 +69,9 @@ public class TuohengBufferDeviceImpl implements IBufferDeviceService {
|
|||
return null;
|
||||
}
|
||||
|
||||
log.info("Dock对象详细信息: dockId={}, cabinVideoUrl={}, outsideVideoUrl={}, liveVideoUrl={}",
|
||||
dock.getDockId(), dock.getCabinVideoUrl(), dock.getOutsideVideoUrl(), dock.getLiveVideoUrl());
|
||||
|
||||
// 查询设备信息
|
||||
Device device = deviceDomain.selectDeviceByDeviceId(dock.getDeviceId());
|
||||
if (device == null) {
|
||||
|
|
@ -91,6 +94,9 @@ public class TuohengBufferDeviceImpl implements IBufferDeviceService {
|
|||
dto.setInternalCamera(dock.getCabinVideoUrl());
|
||||
dto.setExternalCamera(dock.getOutsideVideoUrl());
|
||||
dto.setLiveCamera(dock.getLiveVideoUrl());
|
||||
|
||||
log.info("设置DTO视频地址: internalCamera={}, externalCamera={}, liveCamera={}",
|
||||
dto.getInternalCamera(), dto.getExternalCamera(), dto.getLiveCamera());
|
||||
dto.setDockIotId(device.getIotDeviceId());
|
||||
dto.setSnNumber(device.getDeviceSn());
|
||||
dto.setBindTime(device.getCreateTime().getTime());
|
||||
|
|
@ -338,20 +344,21 @@ public class TuohengBufferDeviceImpl implements IBufferDeviceService {
|
|||
machineStates.getCoverState();
|
||||
log.info("机场舱门状态(从MachineStateManager): {}", coverState);
|
||||
|
||||
// 先判断MODE是否为飞行模式
|
||||
boolean isFlyingMode = "auto".equalsIgnoreCase(mode) ||
|
||||
"guided".equalsIgnoreCase(mode) ||
|
||||
"loiter".equalsIgnoreCase(mode) ||
|
||||
"rtl".equalsIgnoreCase(mode);
|
||||
// 通过MODE判断飞行模式(暂时注释掉,数据不准确)
|
||||
// boolean isFlyingMode = "auto".equalsIgnoreCase(mode) ||
|
||||
// "guided".equalsIgnoreCase(mode) ||
|
||||
// "loiter".equalsIgnoreCase(mode) ||
|
||||
// "rtl".equalsIgnoreCase(mode);
|
||||
|
||||
if (isFlyingMode) {
|
||||
dockStatus = "WORKING";
|
||||
log.info("无人机处于{}模式,设置机场状态为 WORKING", mode);
|
||||
} else if (coverState == CoverState.OPENED) {
|
||||
// if (isFlyingMode) {
|
||||
// dockStatus = "WORKING";
|
||||
// log.info("无人机处于{}模式,设置机场状态为 WORKING", mode);
|
||||
// } else if (coverState == CoverState.OPENED) {
|
||||
if (coverState == CoverState.OPENED) {
|
||||
dockStatus = "WORKING";
|
||||
log.info("舱门打开,设置机场状态为 WORKING");
|
||||
} else {
|
||||
log.info("无人机处于{}模式且舱门关闭,设置机场状态为 IDLE", mode);
|
||||
log.info("舱门关闭,设置机场状态为 IDLE");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("获取无人机mode或舱门状态失败,默认设置为IDLE: {}", e.getMessage());
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ public class TuohengService {
|
|||
TuohengMqttClientConfig config = TuohengMqttClientConfig.builder()
|
||||
.host(mqttProperties.getHost())
|
||||
.port(mqttProperties.getPort())
|
||||
.clientId(mqttProperties.getClientId())
|
||||
.clientId(mqttProperties.getClientId() + "_" + System.currentTimeMillis())
|
||||
.username(mqttProperties.getUsername())
|
||||
.password(mqttProperties.getPassword())
|
||||
.connectionTimeout(mqttProperties.getConnectionTimeout())
|
||||
|
|
@ -97,7 +97,7 @@ public class TuohengService {
|
|||
.autoReconnect(mqttProperties.getAutoReconnect())
|
||||
.cleanSession(mqttProperties.getCleanSession())
|
||||
.useSharedSubscription(true)
|
||||
.sharedGroupName("tuoheng-group")
|
||||
.sharedGroupName("tuoheng-server-group")
|
||||
.build();
|
||||
|
||||
clientManager.initClient(config);
|
||||
|
|
|
|||
|
|
@ -101,9 +101,9 @@ public class PreCheckLogWebSocket {
|
|||
|
||||
if(Objects.nonNull(taskVOR) && Objects.nonNull(taskVOR.getData())){
|
||||
TaskVO taskVO = taskVOR.getData();
|
||||
if(Objects.equals(true,taskVO.getRecovery())){
|
||||
continue;
|
||||
}
|
||||
// if(Objects.equals(true,taskVO.getRecovery())){
|
||||
// continue;
|
||||
// }
|
||||
|
||||
if(taskVO.getStatus() == StatusEnum.PENDING || taskVO.getStatus() == StatusEnum.CANCELED
|
||||
|| taskVO.getStatus() == StatusEnum.COMPLETED){
|
||||
|
|
@ -116,6 +116,7 @@ public class PreCheckLogWebSocket {
|
|||
if (flightData == null) {
|
||||
continue;
|
||||
}
|
||||
flightData.put("recovery", taskVOR.getData().getRecovery());
|
||||
|
||||
ws.sendMessage(JSON.toJSONString(flightData));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue