Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
GeoFlyApi
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GeoFly
GeoFlyApi
Commits
3a2670ba
Commit
3a2670ba
authored
Jun 07, 2025
by
gdj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.调整oss保存路径增加workspaceId。
2.修改航飞任务id为任务名称+时间。
parent
c70a8def
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
66 additions
and
10 deletions
+66
-10
sample/src/main/java/com/dji/sample/manage/service/impl/DeviceFirmwareServiceImpl.java
+2
-1
sample/src/main/java/com/dji/sample/map/service/impl/FlightAreaFileServiceImpl.java
+1
-1
sample/src/main/java/com/dji/sample/media/service/impl/MediaServiceImpl.java
+1
-1
sample/src/main/java/com/dji/sample/storage/controller/StorageController.java
+1
-1
sample/src/main/java/com/dji/sample/storage/service/IStorageService.java
+1
-0
sample/src/main/java/com/dji/sample/storage/service/impl/StorageServiceImpl.java
+47
-1
sample/src/main/java/com/dji/sample/wayline/service/impl/WaylineFileServiceImpl.java
+3
-3
sample/src/main/java/com/dji/sample/wayline/service/impl/WaylineJobServiceImpl.java
+10
-2
No files found.
sample/src/main/java/com/dji/sample/manage/service/impl/DeviceFirmwareServiceImpl.java
View file @
3a2670ba
...
...
@@ -212,7 +212,8 @@ public class DeviceFirmwareServiceImpl extends AbstractFirmwareService implement
}
String
firmwareId
=
UUID
.
randomUUID
().
toString
();
String
objectKey
=
OssConfiguration
.
objectDirPrefix
+
File
.
separator
+
firmwareId
+
FirmwareFileProperties
.
FIRMWARE_FILE_SUFFIX
;
// String objectKey = OssConfiguration.objectDirPrefix + File.separator + firmwareId + FirmwareFileProperties.FIRMWARE_FILE_SUFFIX;
String
objectKey
=
OssConfiguration
.
objectDirPrefix
+
"/"
+
workspaceId
+
"/"
+
firmwareId
+
FirmwareFileProperties
.
FIRMWARE_FILE_SUFFIX
;
ossServiceContext
.
putObject
(
OssConfiguration
.
bucket
,
objectKey
,
file
.
getInputStream
());
log
.
info
(
"upload success. {}"
,
file
.
getOriginalFilename
());
...
...
sample/src/main/java/com/dji/sample/map/service/impl/FlightAreaFileServiceImpl.java
View file @
3a2670ba
...
...
@@ -115,7 +115,7 @@ public class FlightAreaFileServiceImpl implements IFlightAreaFileService {
try
(
ByteArrayInputStream
is
=
new
ByteArrayInputStream
(
os
.
toByteArray
()))
{
String
name
=
String
.
format
(
"geofence_%s.json"
,
org
.
springframework
.
util
.
DigestUtils
.
md5DigestAsHex
(
is
));
is
.
reset
();
String
objectKey
=
OssConfiguration
.
objectDirPrefix
+
"/"
+
name
;
String
objectKey
=
OssConfiguration
.
objectDirPrefix
+
"/"
+
workspaceId
+
"/"
+
name
;
ossServiceContext
.
putObject
(
OssConfiguration
.
bucket
,
objectKey
,
is
);
return
FlightAreaFileDTO
.
builder
()
.
name
(
name
)
...
...
sample/src/main/java/com/dji/sample/media/service/impl/MediaServiceImpl.java
View file @
3a2670ba
...
...
@@ -158,7 +158,7 @@ public class MediaServiceImpl extends AbstractMediaService implements IMediaServ
String
objectKey
=
file
.
getObjectKey
();
file
.
setPath
(
objectKey
.
substring
(
Optional
.
of
(
objectKey
.
indexOf
(
OssConfiguration
.
objectDirPrefix
))
.
filter
(
index
->
index
>
0
).
map
(
index
->
index
++).
orElse
(
0
),
objectKey
.
lastIndexOf
(
"/"
)));
objectKey
.
lastIndexOf
(
"/"
))
+
"/"
+
device
.
getWorkspaceId
()
);
return
fileService
.
saveFile
(
device
.
getWorkspaceId
(),
file
)
>
0
;
}
...
...
sample/src/main/java/com/dji/sample/storage/controller/StorageController.java
View file @
3a2670ba
...
...
@@ -28,7 +28,7 @@ public class StorageController implements IHttpStorageService {
*/
@Override
public
HttpResultResponse
<
StsCredentialsResponse
>
getTemporaryCredential
(
String
workspaceId
,
HttpServletRequest
req
,
HttpServletResponse
rsp
)
{
StsCredentialsResponse
stsCredentials
=
storageService
.
getSTSCredentials
();
StsCredentialsResponse
stsCredentials
=
storageService
.
getSTSCredentials
(
workspaceId
);
return
HttpResultResponse
.
success
(
stsCredentials
);
}
}
sample/src/main/java/com/dji/sample/storage/service/IStorageService.java
View file @
3a2670ba
...
...
@@ -14,5 +14,6 @@ public interface IStorageService {
* @return temporary credentials object
*/
StsCredentialsResponse
getSTSCredentials
();
StsCredentialsResponse
getSTSCredentials
(
String
workspaceId
);
}
sample/src/main/java/com/dji/sample/storage/service/impl/StorageServiceImpl.java
View file @
3a2670ba
package
com
.
dji
.
sample
.
storage
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.dji.sample.component.oss.model.OssConfiguration
;
import
com.dji.sample.component.oss.service.impl.OssServiceContext
;
import
com.dji.sample.manage.model.dto.DeviceDTO
;
import
com.dji.sample.manage.model.entity.DeviceEntity
;
import
com.dji.sample.manage.service.IDeviceRedisService
;
import
com.dji.sample.manage.service.IDeviceService
;
import
com.dji.sample.storage.service.IStorageService
;
import
com.dji.sdk.cloudapi.media.StorageConfigGet
;
import
com.dji.sdk.cloudapi.media.api.AbstractMediaService
;
...
...
@@ -12,6 +17,11 @@ import com.dji.sdk.mqtt.requests.TopicRequestsResponse;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.messaging.MessageHeaders
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.StringUtils
;
import
java.util.List
;
import
java.util.Optional
;
/**
* @author sean
...
...
@@ -24,6 +34,12 @@ public class StorageServiceImpl extends AbstractMediaService implements IStorage
@Autowired
private
OssServiceContext
ossService
;
@Autowired
private
IDeviceRedisService
deviceRedisService
;
@Autowired
private
IDeviceService
deviceService
;
@Override
public
StsCredentialsResponse
getSTSCredentials
()
{
return
new
StsCredentialsResponse
()
...
...
@@ -36,7 +52,37 @@ public class StorageServiceImpl extends AbstractMediaService implements IStorage
}
@Override
public
StsCredentialsResponse
getSTSCredentials
(
String
workspaceId
)
{
return
new
StsCredentialsResponse
()
.
setEndpoint
(
OssConfiguration
.
endpoint
)
.
setBucket
(
OssConfiguration
.
bucket
)
.
setCredentials
(
ossService
.
getCredentials
())
.
setProvider
(
OssConfiguration
.
provider
)
.
setObjectKeyPrefix
(
OssConfiguration
.
objectDirPrefix
+
"/"
+
workspaceId
)
.
setRegion
(
OssConfiguration
.
region
);
}
@Override
public
TopicRequestsResponse
<
MqttReply
<
StsCredentialsResponse
>>
storageConfigGet
(
TopicRequestsRequest
<
StorageConfigGet
>
response
,
MessageHeaders
headers
)
{
return
new
TopicRequestsResponse
<
MqttReply
<
StsCredentialsResponse
>>().
setData
(
MqttReply
.
success
(
getSTSCredentials
()));
String
gateWay
=
response
.
getGateway
();
Optional
<
DeviceDTO
>
deviceOnline
=
deviceRedisService
.
getDeviceOnline
(
gateWay
);
String
workspaceId
=
null
;
if
(
deviceOnline
.
isPresent
())
{
workspaceId
=
deviceOnline
.
get
().
getWorkspaceId
();
}
else
{
List
<
DeviceEntity
>
deviceEntities
=
deviceService
.
list
(
new
LambdaQueryWrapper
<
DeviceEntity
>().
eq
(
DeviceEntity:
:
getDeviceSn
,
gateWay
));
if
(!
CollectionUtils
.
isEmpty
(
deviceEntities
))
{
workspaceId
=
deviceEntities
.
get
(
0
).
getWorkspaceId
();
}
}
StsCredentialsResponse
stsCredentials
;
if
(
StringUtils
.
hasText
(
workspaceId
))
{
stsCredentials
=
getSTSCredentials
(
workspaceId
);
}
else
{
stsCredentials
=
getSTSCredentials
();
}
return
new
TopicRequestsResponse
<
MqttReply
<
StsCredentialsResponse
>>().
setData
(
MqttReply
.
success
(
stsCredentials
));
}
}
sample/src/main/java/com/dji/sample/wayline/service/impl/WaylineFileServiceImpl.java
View file @
3a2670ba
...
...
@@ -208,7 +208,7 @@ public class WaylineFileServiceImpl extends ServiceImpl<IWaylineFileMapper, Wayl
@Override
public
void
importKmzFile
(
MultipartFile
file
,
String
workspaceId
,
String
creator
,
String
fileParentId
)
{
Optional
<
WaylineFileDTO
>
waylineFileOpt
=
validKmzFile
(
file
);
Optional
<
WaylineFileDTO
>
waylineFileOpt
=
validKmzFile
(
file
,
workspaceId
);
if
(
waylineFileOpt
.
isEmpty
())
{
throw
new
RuntimeException
(
"The file format is incorrect."
);
}
...
...
@@ -354,7 +354,7 @@ public class WaylineFileServiceImpl extends ServiceImpl<IWaylineFileMapper, Wayl
return
roots
;
}
private
Optional
<
WaylineFileDTO
>
validKmzFile
(
MultipartFile
file
)
{
private
Optional
<
WaylineFileDTO
>
validKmzFile
(
MultipartFile
file
,
String
workspaceId
)
{
String
filename
=
file
.
getOriginalFilename
();
if
(
Objects
.
nonNull
(
filename
)
&&
!
filename
.
endsWith
(
WAYLINE_FILE_SUFFIX
))
{
throw
new
RuntimeException
(
"The file format is incorrect."
);
...
...
@@ -390,7 +390,7 @@ public class WaylineFileServiceImpl extends ServiceImpl<IWaylineFileMapper, Wayl
.
droneModelKey
(
DeviceEnum
.
find
(
DeviceDomainEnum
.
DRONE
,
type
,
subType
).
getDevice
())
.
payloadModelKeys
(
List
.
of
(
DeviceEnum
.
find
(
DeviceDomainEnum
.
PAYLOAD
,
payloadType
,
payloadSubType
).
getDevice
()))
// .objectKey(OssConfiguration.objectDirPrefix + File.separator + filename)
.
objectKey
(
OssConfiguration
.
objectDirPrefix
+
"/"
+
filename
)
.
objectKey
(
OssConfiguration
.
objectDirPrefix
+
"/"
+
workspaceId
+
"/"
+
filename
)
.
name
(
filename
.
substring
(
0
,
filename
.
lastIndexOf
(
WAYLINE_FILE_SUFFIX
)))
.
sign
(
DigestUtils
.
md5DigestAsHex
(
file
.
getInputStream
()))
.
templateTypes
(
List
.
of
(
WaylineTypeEnum
.
find
(
templateType
).
getValue
()))
...
...
sample/src/main/java/com/dji/sample/wayline/service/impl/WaylineJobServiceImpl.java
View file @
3a2670ba
...
...
@@ -94,13 +94,18 @@ public class WaylineJobServiceImpl extends ServiceImpl<IWaylineJobMapper, Waylin
return
Optional
.
empty
();
}
// Immediate tasks, allocating time on the backend.
LocalDateTime
now
=
LocalDateTime
.
now
();
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
);
String
formattedDateTime
=
now
.
format
(
formatter
);
String
jobId
=
param
.
getName
()
+
"-"
+
formattedDateTime
+
"-"
+
UUID
.
randomUUID
().
toString
().
substring
(
0
,
4
);
WaylineJobEntity
jobEntity
=
WaylineJobEntity
.
builder
()
.
name
(
param
.
getName
())
.
dockSn
(
param
.
getDockSn
())
.
fileId
(
param
.
getFileId
())
.
username
(
username
)
.
workspaceId
(
workspaceId
)
.
jobId
(
UUID
.
randomUUID
().
toString
()
)
.
jobId
(
jobId
)
.
beginTime
(
beginTime
)
.
endTime
(
endTime
)
.
status
(
WaylineJobStatusEnum
.
PENDING
.
getVal
())
...
...
@@ -121,7 +126,10 @@ public class WaylineJobServiceImpl extends ServiceImpl<IWaylineJobMapper, Waylin
return
Optional
.
empty
();
}
WaylineJobEntity
jobEntity
=
this
.
dto2Entity
(
parentJobOpt
.
get
());
jobEntity
.
setJobId
(
UUID
.
randomUUID
().
toString
());
LocalDateTime
now
=
LocalDateTime
.
now
();
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
);
String
formattedDateTime
=
now
.
format
(
formatter
);
jobEntity
.
setJobId
(
jobEntity
.
getName
()
+
"-"
+
formattedDateTime
+
"-"
+
UUID
.
randomUUID
().
toString
().
substring
(
0
,
4
));
jobEntity
.
setErrorCode
(
null
);
jobEntity
.
setCompletedTime
(
null
);
jobEntity
.
setExecuteTime
(
null
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment