Commit 605e1caf by gdj

测试一键起飞保存

parent b26913c0
......@@ -25,6 +25,8 @@ public class TakeoffToPointRequest extends BaseModel {
@NotNull
private String flightId;
private String orgId;
@Min(-180)
@Max(180)
@NotNull
......@@ -91,6 +93,7 @@ public class TakeoffToPointRequest extends BaseModel {
public String toString() {
return "TakeoffToPointRequest{" +
"flightId='" + flightId + '\'' +
", orgId=" + orgId +
", targetLongitude=" + targetLongitude +
", targetLatitude=" + targetLatitude +
", targetHeight=" + targetHeight +
......@@ -116,6 +119,15 @@ public class TakeoffToPointRequest extends BaseModel {
return this;
}
public String getOrgId() {
return orgId;
}
public TakeoffToPointRequest setOrgId(String orgId) {
this.orgId = orgId;
return this;
}
public Float getTargetLongitude() {
return targetLongitude;
}
......
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.control.model.entity.ManageDeviceOperatingRecord;
import com.dji.sample.control.model.enums.DroneAuthorityEnum;
......@@ -183,8 +185,12 @@ public class ControlServiceImpl implements IControlService {
checkTakeoffCondition(sn);
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(
SDKManager.getDeviceSDK(sn), mapper.convertValue(param, TakeoffToPointRequest.class));
SDKManager.getDeviceSDK(sn), takeoffToPointRequest);
ServicesReplyData reply = response.getData();
return reply.getResult().isSuccess() ?
HttpResultResponse.success()
......
package com.dji.sample.media.service.impl;
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.service.IWebSocketMessageService;
import com.dji.sample.manage.model.dto.DeviceDTO;
......@@ -14,6 +15,7 @@ import com.dji.sample.media.service.IMediaRedisService;
import com.dji.sample.media.service.IMediaService;
import com.dji.sample.wayline.model.dto.WaylineJobDTO;
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.api.AbstractMediaService;
import com.dji.sdk.mqtt.MqttReply;
......@@ -164,6 +166,30 @@ public class MediaServiceImpl extends AbstractMediaService implements IMediaServ
// moveFile path wayline/workspaceId/jobId/fileName -> wayline/worksapceId/orgId/jobId/fileName
// 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
String orgId = "";
WaylineJobDTO jobDTO = null;
......@@ -172,23 +198,16 @@ public class MediaServiceImpl extends AbstractMediaService implements IMediaServ
jobDTO = jobOpt.get();
orgId = jobDTO.getOrgId();
}
MediaUploadCallbackRequest file = convert2callbackRequest(callback.getFile());
// Set the drone sn that shoots the media
file.getExt().setSn(device.getChildDeviceSn());
// set path
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("/"));
// todo? 是否需要修改?
if (StringUtils.hasText(orgId)) {
String orgFilePath = path;
// 增加 org路径
path = path.replace(OssConfiguration.objectDirPrefix + "/" + device.getWorkspaceId(), OssConfiguration.objectDirPrefix + "/" + device.getWorkspaceId() + "/" + orgId);
// jobId改成 jobName
if (jobDTO != null) {
path = path.replace(callback.getFile().getExt().getFlightId(), jobDTO.getJobName());
}
// if (jobDTO != null) {
// path = path.replace(callback.getFile().getExt().getFlightId(), jobDTO.getJobName());
// }
String moveFilePath = path;
// 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
} else {
file.setPath(path);
}
}
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