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
982951f8
Commit
982951f8
authored
Mar 06, 2026
by
guoxuejian
Committed by
gdj
Mar 14, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: implement auto-recovery trigger for offline devices in OSD handling
parent
c3305092
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
sample/src/main/java/com/dji/sample/manage/service/impl/SDKDeviceService.java
+30
-0
No files found.
sample/src/main/java/com/dji/sample/manage/service/impl/SDKDeviceService.java
View file @
982951f8
...
...
@@ -151,6 +151,7 @@ public class SDKDeviceService extends AbstractDeviceService {
public
void
osdDock
(
TopicOsdRequest
<
OsdDock
>
request
,
MessageHeaders
headers
)
{
String
from
=
request
.
getFrom
();
Optional
<
DeviceDTO
>
deviceOpt
=
deviceRedisService
.
getDeviceOnline
(
from
);
boolean
needsRecovery
=
deviceOpt
.
isEmpty
();
if
(
deviceOpt
.
isEmpty
()
||
!
StringUtils
.
hasText
(
deviceOpt
.
get
().
getWorkspaceId
()))
{
deviceOpt
=
deviceService
.
getDeviceBySn
(
from
);
if
(
deviceOpt
.
isEmpty
())
{
...
...
@@ -168,6 +169,11 @@ public class SDKDeviceService extends AbstractDeviceService {
}
deviceRedisService
.
setDeviceOnline
(
device
);
if
(
needsRecovery
&&
StringUtils
.
hasText
(
device
.
getWorkspaceId
()))
{
triggerDeviceAutoRecovery
(
from
);
}
fillDockOsd
(
from
,
request
.
getData
());
deviceService
.
pushOsdDataToWeb
(
device
.
getWorkspaceId
(),
BizCodeEnum
.
DOCK_OSD
,
from
,
request
.
getData
());
...
...
@@ -177,6 +183,7 @@ public class SDKDeviceService extends AbstractDeviceService {
public
void
osdDockDrone
(
TopicOsdRequest
<
OsdDockDrone
>
request
,
MessageHeaders
headers
)
{
String
from
=
request
.
getFrom
();
Optional
<
DeviceDTO
>
deviceOpt
=
deviceRedisService
.
getDeviceOnline
(
from
);
boolean
needsRecovery
=
deviceOpt
.
isEmpty
();
if
(
deviceOpt
.
isEmpty
())
{
deviceOpt
=
deviceService
.
getDeviceBySn
(
from
);
if
(
deviceOpt
.
isEmpty
())
{
...
...
@@ -191,6 +198,10 @@ public class SDKDeviceService extends AbstractDeviceService {
DeviceDTO
device
=
deviceOpt
.
get
();
deviceRedisService
.
setDeviceOnline
(
device
);
if
(
needsRecovery
&&
StringUtils
.
hasText
(
device
.
getWorkspaceId
()))
{
triggerDeviceAutoRecovery
(
from
);
}
deviceRedisService
.
setDeviceOsd
(
from
,
request
.
getData
());
// 存放数据
deviceDetailService
.
saveDeviceOsd
(
from
,
request
.
getData
());
...
...
@@ -234,6 +245,7 @@ public class SDKDeviceService extends AbstractDeviceService {
public
void
osdRemoteControl
(
TopicOsdRequest
<
OsdRemoteControl
>
request
,
MessageHeaders
headers
)
{
String
from
=
request
.
getFrom
();
Optional
<
DeviceDTO
>
deviceOpt
=
deviceRedisService
.
getDeviceOnline
(
from
);
boolean
needsRecovery
=
deviceOpt
.
isEmpty
();
if
(
deviceOpt
.
isEmpty
()
||
!
StringUtils
.
hasText
(
deviceOpt
.
get
().
getWorkspaceId
()))
{
deviceOpt
=
deviceService
.
getDeviceBySn
(
from
);
if
(
deviceOpt
.
isEmpty
())
{
...
...
@@ -247,6 +259,10 @@ public class SDKDeviceService extends AbstractDeviceService {
}
deviceRedisService
.
setDeviceOnline
(
device
);
if
(
needsRecovery
&&
StringUtils
.
hasText
(
device
.
getWorkspaceId
()))
{
triggerDeviceAutoRecovery
(
from
);
}
OsdRemoteControl
data
=
request
.
getData
();
deviceService
.
pushOsdDataToPilot
(
device
.
getWorkspaceId
(),
from
,
new
DeviceOsdHost
()
...
...
@@ -261,6 +277,7 @@ public class SDKDeviceService extends AbstractDeviceService {
public
void
osdRcDrone
(
TopicOsdRequest
<
OsdRcDrone
>
request
,
MessageHeaders
headers
)
{
String
from
=
request
.
getFrom
();
Optional
<
DeviceDTO
>
deviceOpt
=
deviceRedisService
.
getDeviceOnline
(
from
);
boolean
needsRecovery
=
deviceOpt
.
isEmpty
();
if
(
deviceOpt
.
isEmpty
())
{
deviceOpt
=
deviceService
.
getDeviceBySn
(
from
);
if
(
deviceOpt
.
isEmpty
())
{
...
...
@@ -275,6 +292,10 @@ public class SDKDeviceService extends AbstractDeviceService {
deviceRedisService
.
setDeviceOnline
(
device
);
if
(
needsRecovery
&&
StringUtils
.
hasText
(
device
.
getWorkspaceId
()))
{
triggerDeviceAutoRecovery
(
from
);
}
OsdRcDrone
data
=
request
.
getData
();
deviceService
.
pushOsdDataToPilot
(
device
.
getWorkspaceId
(),
from
,
new
DeviceOsdHost
()
...
...
@@ -425,6 +446,15 @@ public class SDKDeviceService extends AbstractDeviceService {
}
private
void
triggerDeviceAutoRecovery
(
String
deviceSn
)
{
log
.
warn
(
"[Auto-Recovery] OSD received from offline device {}, triggering online recovery"
,
deviceSn
);
try
{
deviceService
.
recoverDeviceOnline
(
deviceSn
);
}
catch
(
Exception
e
)
{
log
.
error
(
"[Auto-Recovery] Failed to recover device {}: {}"
,
deviceSn
,
e
.
getMessage
());
}
}
public
void
deviceOnlineAgain
(
String
workspaceId
,
String
gatewaySn
,
String
deviceSn
)
{
DeviceDTO
device
=
DeviceDTO
.
builder
().
loginTime
(
LocalDateTime
.
now
()).
deviceSn
(
deviceSn
).
build
();
DeviceDTO
gateway
=
DeviceDTO
.
builder
()
...
...
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