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
bd8cdbef
Commit
bd8cdbef
authored
Mar 31, 2026
by
gdj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加获取设备osd接口getDeviceOsd
parent
dff5999c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
0 deletions
+66
-0
sample/src/main/java/com/dji/sample/manage/controller/DeviceController.java
+20
-0
sample/src/main/java/com/dji/sample/manage/service/IDeviceService.java
+11
-0
sample/src/main/java/com/dji/sample/manage/service/impl/DeviceServiceImpl.java
+33
-0
sample/src/main/java/com/dji/sample/manage/service/impl/SDKDeviceService.java
+2
-0
No files found.
sample/src/main/java/com/dji/sample/manage/controller/DeviceController.java
View file @
bd8cdbef
...
...
@@ -346,4 +346,23 @@ public class DeviceController {
return
HttpResultResponse
.
success
(
deviceInfoTotal
);
}
/**
* Get the real-time OSD data of a device from Redis cache.
* Returns different OSD structures depending on device type:
* - Dock (domain=3): OsdDock (contains modeCode: Idle/Debugging/Working etc.)
* - Drone (domain=0): OsdDockDrone or OsdRcDrone (contains modeCode, lat/lng, altitude, speed, battery etc.)
* - Remote Controller (domain=2): OsdRemoteControl (contains lat/lng, height etc.)
* @param workspaceId
* @param deviceSn
* @return OSD data object
*/
@GetMapping
(
"/{workspace_id}/devices/{device_sn}/osd"
)
public
HttpResultResponse
getDeviceOsd
(
@PathVariable
(
"workspace_id"
)
String
workspaceId
,
@PathVariable
(
"device_sn"
)
String
deviceSn
)
{
Optional
<
Object
>
osdOpt
=
deviceService
.
getDeviceOsd
(
workspaceId
,
deviceSn
);
return
osdOpt
.
isEmpty
()
?
HttpResultResponse
.
error
(
"Device OSD data not found. The device may be offline, not reporting data, or not belong to this workspace."
)
:
HttpResultResponse
.
success
(
osdOpt
.
get
());
}
}
\ No newline at end of file
sample/src/main/java/com/dji/sample/manage/service/IDeviceService.java
View file @
bd8cdbef
...
...
@@ -294,4 +294,14 @@ public interface IDeviceService extends IService<DeviceEntity> {
DeviceDetailCountDTO
getDeviceInfoTotal
(
String
workspaceId
);
/**
* Get the OSD real-time data of the device from Redis.
* Automatically determines the device type (Dock, Drone, RC) and returns the corresponding OSD data.
* Validates that the device belongs to the specified workspace.
* @param workspaceId
* @param deviceSn
* @return OSD data object, or empty if device not found or no OSD data
*/
Optional
<
Object
>
getDeviceOsd
(
String
workspaceId
,
String
deviceSn
);
}
\ No newline at end of file
sample/src/main/java/com/dji/sample/manage/service/impl/DeviceServiceImpl.java
View file @
bd8cdbef
...
...
@@ -1042,6 +1042,39 @@ public class DeviceServiceImpl extends ServiceImpl<IDeviceMapper, DeviceEntity>
}
@Override
public
Optional
<
Object
>
getDeviceOsd
(
String
workspaceId
,
String
deviceSn
)
{
Optional
<
DeviceDTO
>
deviceOpt
=
getDeviceBySn
(
deviceSn
);
if
(
deviceOpt
.
isEmpty
())
{
return
Optional
.
empty
();
}
DeviceDTO
device
=
deviceOpt
.
get
();
// Validate that the device belongs to the specified workspace
if
(!
workspaceId
.
equals
(
device
.
getWorkspaceId
()))
{
log
.
warn
(
"Device {} does not belong to workspace {}"
,
deviceSn
,
workspaceId
);
return
Optional
.
empty
();
}
DeviceDomainEnum
domain
=
device
.
getDomain
();
if
(
domain
==
null
)
{
return
Optional
.
empty
();
}
switch
(
domain
)
{
case
DOCK:
return
deviceRedisService
.
getDeviceOsd
(
deviceSn
,
OsdDock
.
class
).
map
(
osd
->
osd
);
case
DRONE:
// Try DockDrone first, then RcDrone
Optional
<
OsdDockDrone
>
dockDrone
=
deviceRedisService
.
getDeviceOsd
(
deviceSn
,
OsdDockDrone
.
class
);
if
(
dockDrone
.
isPresent
())
{
return
dockDrone
.
map
(
osd
->
osd
);
}
return
deviceRedisService
.
getDeviceOsd
(
deviceSn
,
OsdRcDrone
.
class
).
map
(
osd
->
osd
);
case
REMOTER_CONTROL:
return
deviceRedisService
.
getDeviceOsd
(
deviceSn
,
OsdRemoteControl
.
class
).
map
(
osd
->
osd
);
default
:
return
Optional
.
empty
();
}
}
@Override
public
Boolean
checkDockDrcMode
(
String
dockSn
)
{
if
(
CUSTOM_DOCK_LIST
.
contains
(
dockSn
)
||
dockSn
.
contains
(
"12345"
))
{
...
...
sample/src/main/java/com/dji/sample/manage/service/impl/SDKDeviceService.java
View file @
bd8cdbef
...
...
@@ -264,6 +264,7 @@ public class SDKDeviceService extends AbstractDeviceService {
}
OsdRemoteControl
data
=
request
.
getData
();
deviceRedisService
.
setDeviceOsd
(
from
,
data
);
deviceService
.
pushOsdDataToPilot
(
device
.
getWorkspaceId
(),
from
,
new
DeviceOsdHost
()
.
setLatitude
(
data
.
getLatitude
())
...
...
@@ -297,6 +298,7 @@ public class SDKDeviceService extends AbstractDeviceService {
}
OsdRcDrone
data
=
request
.
getData
();
deviceRedisService
.
setDeviceOsd
(
from
,
data
);
deviceService
.
pushOsdDataToPilot
(
device
.
getWorkspaceId
(),
from
,
new
DeviceOsdHost
()
.
setLatitude
(
data
.
getLatitude
())
...
...
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