Commit 605e1caf by gdj

测试一键起飞保存

parent b26913c0
...@@ -25,6 +25,8 @@ public class TakeoffToPointRequest extends BaseModel { ...@@ -25,6 +25,8 @@ public class TakeoffToPointRequest extends BaseModel {
@NotNull @NotNull
private String flightId; private String flightId;
private String orgId;
@Min(-180) @Min(-180)
@Max(180) @Max(180)
@NotNull @NotNull
...@@ -91,6 +93,7 @@ public class TakeoffToPointRequest extends BaseModel { ...@@ -91,6 +93,7 @@ public class TakeoffToPointRequest extends BaseModel {
public String toString() { public String toString() {
return "TakeoffToPointRequest{" + return "TakeoffToPointRequest{" +
"flightId='" + flightId + '\'' + "flightId='" + flightId + '\'' +
", orgId=" + orgId +
", targetLongitude=" + targetLongitude + ", targetLongitude=" + targetLongitude +
", targetLatitude=" + targetLatitude + ", targetLatitude=" + targetLatitude +
", targetHeight=" + targetHeight + ", targetHeight=" + targetHeight +
...@@ -116,6 +119,15 @@ public class TakeoffToPointRequest extends BaseModel { ...@@ -116,6 +119,15 @@ public class TakeoffToPointRequest extends BaseModel {
return this; return this;
} }
public String getOrgId() {
return orgId;
}
public TakeoffToPointRequest setOrgId(String orgId) {
this.orgId = orgId;
return this;
}
public Float getTargetLongitude() { public Float getTargetLongitude() {
return targetLongitude; return targetLongitude;
} }
......
package com.dji.sample.control.service.impl; package com.dji.sample.control.service.impl;
import com.dji.sample.common.util.SecurityUtils;
import com.dji.sample.component.redis.RedisOpsUtils;
import com.dji.sample.component.websocket.service.IWebSocketMessageService; import com.dji.sample.component.websocket.service.IWebSocketMessageService;
import com.dji.sample.control.model.entity.ManageDeviceOperatingRecord; import com.dji.sample.control.model.entity.ManageDeviceOperatingRecord;
import com.dji.sample.control.model.enums.DroneAuthorityEnum; import com.dji.sample.control.model.enums.DroneAuthorityEnum;
...@@ -183,8 +185,12 @@ public class ControlServiceImpl implements IControlService { ...@@ -183,8 +185,12 @@ public class ControlServiceImpl implements IControlService {
checkTakeoffCondition(sn); checkTakeoffCondition(sn);
param.setFlightId(UUID.randomUUID().toString()); param.setFlightId(UUID.randomUUID().toString());
TakeoffToPointRequest takeoffToPointRequest = mapper.convertValue(param, TakeoffToPointRequest.class);
takeoffToPointRequest.setOrgId(SecurityUtils.getOrgId());
RedisOpsUtils.setWithExpire("templateTask:"+param.getFlightId(), takeoffToPointRequest, 24*60*60);
TopicServicesResponse<ServicesReplyData> response = abstractControlService.takeoffToPoint( TopicServicesResponse<ServicesReplyData> response = abstractControlService.takeoffToPoint(
SDKManager.getDeviceSDK(sn), mapper.convertValue(param, TakeoffToPointRequest.class)); SDKManager.getDeviceSDK(sn), takeoffToPointRequest);
ServicesReplyData reply = response.getData(); ServicesReplyData reply = response.getData();
return reply.getResult().isSuccess() ? return reply.getResult().isSuccess() ?
HttpResultResponse.success() HttpResultResponse.success()
......
package com.dji.sample.media.service.impl; package com.dji.sample.media.service.impl;
import com.dji.sample.component.oss.model.OssConfiguration; import com.dji.sample.component.oss.model.OssConfiguration;
import com.dji.sample.component.redis.RedisOpsUtils;
import com.dji.sample.component.websocket.model.BizCodeEnum; import com.dji.sample.component.websocket.model.BizCodeEnum;
import com.dji.sample.component.websocket.service.IWebSocketMessageService; import com.dji.sample.component.websocket.service.IWebSocketMessageService;
import com.dji.sample.manage.model.dto.DeviceDTO; import com.dji.sample.manage.model.dto.DeviceDTO;
...@@ -14,6 +15,7 @@ import com.dji.sample.media.service.IMediaRedisService; ...@@ -14,6 +15,7 @@ import com.dji.sample.media.service.IMediaRedisService;
import com.dji.sample.media.service.IMediaService; import com.dji.sample.media.service.IMediaService;
import com.dji.sample.wayline.model.dto.WaylineJobDTO; import com.dji.sample.wayline.model.dto.WaylineJobDTO;
import com.dji.sample.wayline.service.IWaylineJobService; import com.dji.sample.wayline.service.IWaylineJobService;
import com.dji.sdk.cloudapi.control.TakeoffToPointRequest;
import com.dji.sdk.cloudapi.media.*; import com.dji.sdk.cloudapi.media.*;
import com.dji.sdk.cloudapi.media.api.AbstractMediaService; import com.dji.sdk.cloudapi.media.api.AbstractMediaService;
import com.dji.sdk.mqtt.MqttReply; import com.dji.sdk.mqtt.MqttReply;
...@@ -164,6 +166,30 @@ public class MediaServiceImpl extends AbstractMediaService implements IMediaServ ...@@ -164,6 +166,30 @@ public class MediaServiceImpl extends AbstractMediaService implements IMediaServ
// moveFile path wayline/workspaceId/jobId/fileName -> wayline/worksapceId/orgId/jobId/fileName // moveFile path wayline/workspaceId/jobId/fileName -> wayline/worksapceId/orgId/jobId/fileName
// file.path name objectKey // file.path name objectKey
MediaUploadCallbackRequest file = convert2callbackRequest(callback.getFile());
// Set the drone sn that shoots the media
file.getExt().setSn(device.getChildDeviceSn());
String objectKey = file.getObjectKey();
String path = objectKey.substring(Optional.of(objectKey.indexOf(OssConfiguration.objectDirPrefix))
.filter(index -> index > 0).map(index -> index++).orElse(0), objectKey.lastIndexOf("/"));
String orgFilePath = path;
//可能是临时任务
if (RedisOpsUtils.checkExist("templateTask:"+callback.getFile().getExt().getFlightId())) {
TakeoffToPointRequest takeoffToPointRequest = (TakeoffToPointRequest) RedisOpsUtils.get("templateTask:" + callback.getFile().getExt().getFlightId());
String orgId = takeoffToPointRequest.getOrgId();
path = path.replace(OssConfiguration.objectDirPrefix + "/" + device.getWorkspaceId(), OssConfiguration.objectDirPrefix + "/" + device.getWorkspaceId() + "/" + orgId + "/临时任务");
String moveFilePath = path;
file.setPath(path);
file.setObjectKey(moveFilePath);
moveFile(orgFilePath, moveFilePath, callback.getFile().getName());
} else {
// 查询 任务的orgId // 查询 任务的orgId
String orgId = ""; String orgId = "";
WaylineJobDTO jobDTO = null; WaylineJobDTO jobDTO = null;
...@@ -172,23 +198,16 @@ public class MediaServiceImpl extends AbstractMediaService implements IMediaServ ...@@ -172,23 +198,16 @@ public class MediaServiceImpl extends AbstractMediaService implements IMediaServ
jobDTO = jobOpt.get(); jobDTO = jobOpt.get();
orgId = jobDTO.getOrgId(); orgId = jobDTO.getOrgId();
} }
MediaUploadCallbackRequest file = convert2callbackRequest(callback.getFile());
// Set the drone sn that shoots the media
file.getExt().setSn(device.getChildDeviceSn());
// set path // set path
String objectKey = file.getObjectKey(); // todo? 是否需要修改?
String path = objectKey.substring(Optional.of(objectKey.indexOf(OssConfiguration.objectDirPrefix))
.filter(index -> index > 0).map(index -> index++).orElse(0), objectKey.lastIndexOf("/"));
if (StringUtils.hasText(orgId)) { if (StringUtils.hasText(orgId)) {
String orgFilePath = path;
// 增加 org路径 // 增加 org路径
path = path.replace(OssConfiguration.objectDirPrefix + "/" + device.getWorkspaceId(), OssConfiguration.objectDirPrefix + "/" + device.getWorkspaceId() + "/" + orgId); path = path.replace(OssConfiguration.objectDirPrefix + "/" + device.getWorkspaceId(), OssConfiguration.objectDirPrefix + "/" + device.getWorkspaceId() + "/" + orgId);
// jobId改成 jobName // jobId改成 jobName
if (jobDTO != null) { // if (jobDTO != null) {
path = path.replace(callback.getFile().getExt().getFlightId(), jobDTO.getJobName()); // path = path.replace(callback.getFile().getExt().getFlightId(), jobDTO.getJobName());
} // }
String moveFilePath = path; String moveFilePath = path;
// DJI_20250801115516_0033_V.jpeg // DJI_20250801115516_0033_V.jpeg
// wayline/e3dea0f5-37f2-4d79-ae58-490af3228069/test-8-1-11-52-2025-08-01-11-52-49-9c08/DJI_202508011152_001_test-8-1-11-52-2025-08-01-11-52-49-9c08/DJI_20250801115516_0033_V.jpeg // wayline/e3dea0f5-37f2-4d79-ae58-490af3228069/test-8-1-11-52-2025-08-01-11-52-49-9c08/DJI_202508011152_001_test-8-1-11-52-2025-08-01-11-52-49-9c08/DJI_20250801115516_0033_V.jpeg
...@@ -199,6 +218,7 @@ public class MediaServiceImpl extends AbstractMediaService implements IMediaServ ...@@ -199,6 +218,7 @@ public class MediaServiceImpl extends AbstractMediaService implements IMediaServ
} else { } else {
file.setPath(path); file.setPath(path);
} }
}
return fileService.saveFile(device.getWorkspaceId(), file) > 0; return fileService.saveFile(device.getWorkspaceId(), file) > 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment