修改环境配置,修改测试环境
This commit is contained in:
parent
946e80288d
commit
db2d1a70f5
4
pom.xml
4
pom.xml
|
|
@ -135,6 +135,10 @@
|
|||
<artifactId>org.eclipse.paho.mqttv5.client</artifactId>
|
||||
<version>1.2.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>tuoheng-api-task</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.ruoyi.device.controller;
|
||||
|
||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.web.controller.BaseController;
|
||||
import com.ruoyi.device.api.domain.*;
|
||||
|
|
@ -8,6 +9,10 @@ import com.ruoyi.device.api.enums.DroneMissionStatusEnum;
|
|||
import com.ruoyi.device.domain.impl.machine.MachineCommandManager;
|
||||
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.RemoteTaskService;
|
||||
import com.ruoyi.task.api.domain.TaskDTO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
|
@ -15,6 +20,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
|
@ -38,7 +44,8 @@ public class AircraftFlyController extends BaseController
|
|||
private com.ruoyi.device.domain.impl.machine.statemachine.MachineStateManager machineStateManager;
|
||||
|
||||
@Autowired
|
||||
private com.ruoyi.device.domain.impl.machine.mqtt.MqttClient mqttClient;
|
||||
private FlightService flightService;
|
||||
|
||||
/**
|
||||
* 无人机飞控命令
|
||||
*
|
||||
|
|
@ -229,6 +236,9 @@ public class AircraftFlyController extends BaseController
|
|||
return R.ok(vo);
|
||||
}
|
||||
|
||||
//从配置文件获取
|
||||
private String airlineFileUrl = "";
|
||||
|
||||
/**
|
||||
* 无人机一键起飞
|
||||
*
|
||||
|
|
@ -239,11 +249,16 @@ public class AircraftFlyController extends BaseController
|
|||
@PostMapping("/takeoff")
|
||||
public R<String> takeoff(@RequestBody DroneTakeoffRequest request)
|
||||
{
|
||||
|
||||
flightService.onClickTakeOff(request.getSn(),airlineFileUrl);
|
||||
|
||||
|
||||
log.info("收到无人机起飞请求: sn={}, messageID={}", request.getSn(), request.getMessageID());
|
||||
|
||||
try {
|
||||
java.util.Map<String, Object> params = new java.util.HashMap<>();
|
||||
if(Objects.isNull(request.getMessageID())){
|
||||
|
||||
params.put("messageID", UUID.randomUUID().toString());
|
||||
}else {
|
||||
params.put("messageID", request.getMessageID());
|
||||
|
|
@ -350,7 +365,7 @@ public class AircraftFlyController extends BaseController
|
|||
|
||||
try {
|
||||
// 从 MachineStateManager 获取状态
|
||||
com.ruoyi.device.domain.impl.machine.state.MachineStates states = machineStateManager.getStates(sn);
|
||||
MachineStates states = machineStateManager.getStates(sn);
|
||||
|
||||
// 转换为 VO 对象
|
||||
MachineStateVO vo = new MachineStateVO();
|
||||
|
|
|
|||
|
|
@ -20,16 +20,28 @@ public class TuohengMqttClientService {
|
|||
private final TuohengMqttMessageHandler messageHandler;
|
||||
private MqttClient mqttClient;
|
||||
|
||||
public static final String AIRPORT_NEST_REALTIME_TOPIC = "/topic/v1/airportNest/+/realTime/data";
|
||||
public static final String AIRPORT_NEST_BASIC_TOPIC = "/topic/v1/airportNest/+/realTime/basic";
|
||||
public static final String AIRPORT_NEST_CONFIRM_TOPIC = "/topic/v1/airportNest/+/control/confirm";
|
||||
public static final String AIRPORT_DRONE_REALTIME_TOPIC = "/topic/v1/airportDrone/+/realTime/data";
|
||||
public static final String AIRPORT_FLY_CONTROL_TOPIC = "/topic/v1/airportFly/+/control";
|
||||
public static final String AIRPORT_FLY_DATA_TOPIC = "/topic/v1/airportFly/+/control/data";
|
||||
public static final String AIRPORT_FLY_CONFIRM_TOPIC = "/topic/v1/airportFly/+/control/confirm";
|
||||
public static final String HEARTBEAT_MESSAGE_TOPIC = "/topic/v1/heartbeat/+/message";
|
||||
public static final String PRODUCT_OSD_TOPIC = "thing/product/+/osd";
|
||||
public static final String PRODUCT_EVENTS_TOPIC = "thing/product/+/events";
|
||||
// public static final String AIRPORT_NEST_REALTIME_TOPIC = "/topic/v1/airportNest/+/realTime/data";
|
||||
// public static final String AIRPORT_NEST_BASIC_TOPIC = "/topic/v1/airportNest/+/realTime/basic";
|
||||
// public static final String AIRPORT_NEST_CONFIRM_TOPIC = "/topic/v1/airportNest/+/control/confirm";
|
||||
// public static final String AIRPORT_DRONE_REALTIME_TOPIC = "/topic/v1/airportDrone/+/realTime/data";
|
||||
// public static final String AIRPORT_FLY_CONTROL_TOPIC = "/topic/v1/airportFly/+/control";
|
||||
// public static final String AIRPORT_FLY_DATA_TOPIC = "/topic/v1/airportFly/+/control/data";
|
||||
// public static final String AIRPORT_FLY_CONFIRM_TOPIC = "/topic/v1/airportFly/+/control/confirm";
|
||||
// public static final String HEARTBEAT_MESSAGE_TOPIC = "/topic/v1/heartbeat/+/message";
|
||||
// public static final String PRODUCT_OSD_TOPIC = "thing/product/+/osd";
|
||||
// public static final String PRODUCT_EVENTS_TOPIC = "thing/product/+/events";
|
||||
|
||||
|
||||
public static final String AIRPORT_NEST_REALTIME_TOPIC = "/topic/v1/airportNest/THJSQ03A2302KSPYGJ2G/realTime/data";
|
||||
public static final String AIRPORT_NEST_BASIC_TOPIC = "/topic/v1/airportNest/THJSQ03A2302KSPYGJ2G/realTime/basic";
|
||||
public static final String AIRPORT_NEST_CONFIRM_TOPIC = "/topic/v1/airportNest/THJSQ03A2302KSPYGJ2G/control/confirm";
|
||||
public static final String AIRPORT_DRONE_REALTIME_TOPIC = "/topic/v1/airportDrone/THJSQ03A2302KSPYGJ2G/realTime/data";
|
||||
public static final String AIRPORT_FLY_CONTROL_TOPIC = "/topic/v1/airportFly/THJSQ03A2302KSPYGJ2G/control";
|
||||
public static final String AIRPORT_FLY_DATA_TOPIC = "/topic/v1/airportFly/THJSQ03A2302KSPYGJ2G/control/data";
|
||||
public static final String AIRPORT_FLY_CONFIRM_TOPIC = "/topic/v1/airportFly/THJSQ03A2302KSPYGJ2G/control/confirm";
|
||||
public static final String HEARTBEAT_MESSAGE_TOPIC = "/topic/v1/heartbeat/THJSQ03A2302KSPYGJ2G/message";
|
||||
public static final String PRODUCT_OSD_TOPIC = "thing/product/THJSQ03A2302KSPYGJ2G/osd";
|
||||
public static final String PRODUCT_EVENTS_TOPIC = "thing/product/THJSQ03A2302KSPYGJ2G/events";
|
||||
|
||||
public TuohengMqttClientService(TuohengMqttClientConfig config, TuohengMqttMessageHandler messageHandler) {
|
||||
this.config = config;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ import java.util.Map;
|
|||
public interface FlightService
|
||||
{
|
||||
|
||||
public Long onClickTakeOff(String sn,String url);
|
||||
|
||||
/**
|
||||
* 获取或创建飞行记录(通过messageID匹配)
|
||||
* 如果存在相同messageID的飞行记录,返回该记录
|
||||
|
|
@ -24,23 +26,23 @@ public interface FlightService
|
|||
*/
|
||||
FlightEntity getOrCreateFlightByMessageId(String deviceSn, String messageId);
|
||||
|
||||
/**
|
||||
* 获取最新的飞行记录(包括已返航的)
|
||||
* 用于WebSocket推送
|
||||
*
|
||||
* @param deviceSn 设备SN号
|
||||
* @return 飞行记录
|
||||
*/
|
||||
FlightEntity getLatestFlight(String deviceSn);
|
||||
// /**
|
||||
// * 获取最新的飞行记录(包括已返航的)
|
||||
// * 用于WebSocket推送
|
||||
// *
|
||||
// * @param deviceSn 设备SN号
|
||||
// * @return 飞行记录
|
||||
// */
|
||||
// FlightEntity getLatestFlight(String deviceSn);
|
||||
|
||||
|
||||
/**
|
||||
* 更新飞行ID(外部ID)
|
||||
*
|
||||
* @param flightId 飞行ID
|
||||
* @param flightIdExternal 外部飞行ID
|
||||
*/
|
||||
void updateFlightIdExternal(Long flightId, String flightIdExternal);
|
||||
// /**
|
||||
// * 更新飞行ID(外部ID)
|
||||
// *
|
||||
// * @param flightId 飞行ID
|
||||
// * @param flightIdExternal 外部飞行ID
|
||||
// */
|
||||
// void updateFlightIdExternal(Long flightId, String flightIdExternal);
|
||||
|
||||
/**
|
||||
* 更新飞行状态
|
||||
|
|
@ -50,12 +52,12 @@ public interface FlightService
|
|||
*/
|
||||
void updateFlightStatus(Long flightId, String status);
|
||||
|
||||
/**
|
||||
* 更新返航时间
|
||||
*
|
||||
* @param flightId 飞行ID
|
||||
*/
|
||||
void updateReturnTime(Long flightId);
|
||||
// /**
|
||||
// * 更新返航时间
|
||||
// *
|
||||
// * @param flightId 飞行ID
|
||||
// */
|
||||
// void updateReturnTime(Long flightId);
|
||||
|
||||
/**
|
||||
* 获取飞行记录和日志(用于WebSocket推送)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.ruoyi.device.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.device.mapper.FlightLogMapper;
|
||||
import com.ruoyi.device.mapper.FlightMapper;
|
||||
import com.ruoyi.device.mapper.PreCheckLogMapper;
|
||||
|
|
@ -7,16 +9,17 @@ 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.RemoteTaskService;
|
||||
import com.ruoyi.task.api.domain.TaskDTO;
|
||||
import com.ruoyi.task.api.enums.ExecuteTypeEnum;
|
||||
import com.ruoyi.task.api.enums.StatusEnum;
|
||||
import com.ruoyi.task.api.enums.TaskCategoryEnum;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 飞行服务实现类
|
||||
|
|
@ -37,7 +40,22 @@ public class FlightServiceImpl implements FlightService
|
|||
@Autowired
|
||||
private FlightLogMapper flightLogMapper;
|
||||
|
||||
@Autowired
|
||||
private RemoteTaskService remoteTaskService;
|
||||
|
||||
public Long onClickTakeOff(String sn,String routeUrl){
|
||||
TaskDTO taskDTO = new TaskDTO();
|
||||
taskDTO.setActualStartTime(new Date());
|
||||
taskDTO.setStartTime(new Date());
|
||||
taskDTO.setExecuteType(ExecuteTypeEnum.ONCE);
|
||||
taskDTO.setTaskCategory(TaskCategoryEnum.MANUAL_FLIGHT);
|
||||
taskDTO.setRouteId(-1L);
|
||||
taskDTO.setUavId(sn);
|
||||
taskDTO.setStatus(StatusEnum.RUNNING);
|
||||
taskDTO.setRouteUrl(routeUrl);
|
||||
R<Long> taskId = remoteTaskService.createTaskWithoutPlan(taskDTO,SecurityConstants.INNER);
|
||||
return taskId.getData();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
|
@ -65,21 +83,21 @@ public class FlightServiceImpl implements FlightService
|
|||
return flight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FlightEntity getLatestFlight(String deviceSn) {
|
||||
return flightMapper.selectLatestFlightByDeviceSn(deviceSn);
|
||||
}
|
||||
// @Override
|
||||
// public FlightEntity getLatestFlight(String deviceSn) {
|
||||
// return flightMapper.selectLatestFlightByDeviceSn(deviceSn);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void updateFlightIdExternal(Long flightId, String flightIdExternal) {
|
||||
FlightEntity flight = new FlightEntity();
|
||||
flight.setFlightId(flightId);
|
||||
flight.setFlightIdExternal(flightIdExternal);
|
||||
flightMapper.updateFlight(flight);
|
||||
log.info("更新飞行ID: flightId={}, flightIdExternal={}", flightId, flightIdExternal);
|
||||
}
|
||||
//
|
||||
// @Override
|
||||
// public void updateFlightIdExternal(Long flightId, String flightIdExternal) {
|
||||
// FlightEntity flight = new FlightEntity();
|
||||
// flight.setFlightId(flightId);
|
||||
// flight.setFlightIdExternal(flightIdExternal);
|
||||
// flightMapper.updateFlight(flight);
|
||||
// log.info("更新飞行ID: flightId={}, flightIdExternal={}", flightId, flightIdExternal);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void updateFlightStatus(Long flightId, String status) {
|
||||
|
|
@ -92,10 +110,10 @@ public class FlightServiceImpl implements FlightService
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateReturnTime(Long flightId) {
|
||||
flightMapper.updateReturnTime(flightId);
|
||||
}
|
||||
// @Override
|
||||
// public void updateReturnTime(Long flightId) {
|
||||
// flightMapper.updateReturnTime(flightId);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getLatestFlightWithLogs(String deviceSn) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue