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
c730d968
Commit
c730d968
authored
Aug 13, 2025
by
gdj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加设备重新上线接口
parent
8fb07f3d
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
138 additions
and
0 deletions
+138
-0
cloud-sdk/src/main/java/com/dji/sdk/mqtt/events/EventsSubscribe.java
+7
-0
cloud-sdk/src/main/java/com/dji/sdk/mqtt/osd/OsdSubscribe.java
+7
-0
cloud-sdk/src/main/java/com/dji/sdk/mqtt/state/StateSubscribe.java
+6
-0
sample/src/main/java/com/dji/sample/manage/controller/DeviceController.java
+13
-0
sample/src/main/java/com/dji/sample/manage/service/IDeviceService.java
+6
-0
sample/src/main/java/com/dji/sample/manage/service/impl/DeviceServiceImpl.java
+99
-0
No files found.
cloud-sdk/src/main/java/com/dji/sdk/mqtt/events/EventsSubscribe.java
View file @
c730d968
...
...
@@ -4,6 +4,7 @@ import com.dji.sdk.config.version.GatewayManager;
import
com.dji.sdk.mqtt.IMqttTopicService
;
import
com.dji.sdk.mqtt.TopicConst
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.StringUtils
;
import
javax.annotation.Resource
;
...
...
@@ -32,6 +33,12 @@ public class EventsSubscribe {
}
}
public
void
subscribe
(
String
deviceSn
)
{
if
(
StringUtils
.
hasText
(
deviceSn
))
{
topicService
.
subscribe
(
String
.
format
(
TOPIC
,
deviceSn
));
}
}
public
void
unsubscribe
(
GatewayManager
gateway
)
{
topicService
.
unsubscribe
(
String
.
format
(
TOPIC
,
gateway
.
getGatewaySn
()));
if
(
null
!=
gateway
.
getDroneSn
())
{
...
...
cloud-sdk/src/main/java/com/dji/sdk/mqtt/osd/OsdSubscribe.java
View file @
c730d968
...
...
@@ -5,6 +5,7 @@ import com.dji.sdk.common.SDKManager;
import
com.dji.sdk.mqtt.IMqttTopicService
;
import
com.dji.sdk.mqtt.TopicConst
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.StringUtils
;
import
javax.annotation.Resource
;
...
...
@@ -34,6 +35,12 @@ public class OsdSubscribe {
}
}
public
void
subscribe
(
String
deviceSn
)
{
if
(
StringUtils
.
hasText
(
deviceSn
))
{
topicService
.
subscribe
(
String
.
format
(
TOPIC
,
deviceSn
));
}
}
public
void
unsubscribe
(
GatewayManager
gateway
)
{
SDKManager
.
logoutDevice
(
gateway
.
getGatewaySn
());
topicService
.
unsubscribe
(
String
.
format
(
TOPIC
,
gateway
.
getGatewaySn
()));
...
...
cloud-sdk/src/main/java/com/dji/sdk/mqtt/state/StateSubscribe.java
View file @
c730d968
...
...
@@ -5,6 +5,7 @@ import com.dji.sdk.common.SDKManager;
import
com.dji.sdk.mqtt.IMqttTopicService
;
import
com.dji.sdk.mqtt.TopicConst
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.StringUtils
;
import
javax.annotation.Resource
;
...
...
@@ -33,6 +34,11 @@ public class StateSubscribe {
topicService
.
subscribe
(
String
.
format
(
TOPIC
,
gateway
.
getDroneSn
()));
}
}
public
void
subscribe
(
String
deviceSn
)
{
if
(
StringUtils
.
hasText
(
deviceSn
))
{
topicService
.
subscribe
(
String
.
format
(
TOPIC
,
deviceSn
));
}
}
public
void
unsubscribe
(
GatewayManager
gateway
)
{
SDKManager
.
logoutDevice
(
gateway
.
getGatewaySn
());
...
...
sample/src/main/java/com/dji/sample/manage/controller/DeviceController.java
View file @
c730d968
...
...
@@ -324,4 +324,16 @@ public class DeviceController {
return
HttpResultResponse
.
success
();
}
/**
* recover device online
* @param device
* @return
*/
@PostMapping
(
"/{workspace_id}/recoverOnline"
)
public
HttpResultResponse
recoverOnline
(
@RequestBody
DeviceDTO
device
,
@PathVariable
(
"workspace_id"
)
String
workspaceId
)
{
deviceService
.
recoverDeviceOnline
(
device
.
getDeviceSn
());
return
HttpResultResponse
.
success
();
}
}
\ No newline at end of file
sample/src/main/java/com/dji/sample/manage/service/IDeviceService.java
View file @
c730d968
...
...
@@ -51,6 +51,8 @@ public interface IDeviceService extends IService<DeviceEntity> {
*/
void
subDeviceOnlineSubscribeTopic
(
GatewayManager
gateway
);
void
subDroneOnlineSubscribeTopic
(
String
droneSn
);
/**
* When the gateway device goes offline, unsubscribe from the topics of the gateway and sub-device.
* @param gateway
...
...
@@ -283,4 +285,7 @@ public interface IDeviceService extends IService<DeviceEntity> {
*/
PaginationData
<
DeviceDTO
>
getDockAndDrone
(
String
workspaceId
,
Long
page
,
Long
pageSize
);
void
recoverDeviceOnline
(
String
deviceSn
);
void
recoverGatewayOnline
(
String
gatewaySn
);
void
recoverDroneOnline
(
String
droneSn
);
}
\ No newline at end of file
sample/src/main/java/com/dji/sample/manage/service/impl/DeviceServiceImpl.java
View file @
c730d968
...
...
@@ -198,6 +198,20 @@ public class DeviceServiceImpl extends ServiceImpl<IDeviceMapper, DeviceEntity>
propertySetSubscribe
.
subscribe
(
gateway
);
}
/**
* 无人机订阅mqtt topic
* @param droneSn
*/
@Override
public
void
subDroneOnlineSubscribeTopic
(
String
droneSn
)
{
stateSubscribe
.
subscribe
(
droneSn
);
osdSubscribe
.
subscribe
(
droneSn
);
eventsSubscribe
.
subscribe
(
droneSn
);
}
@Override
public
void
offlineUnsubscribeTopic
(
GatewayManager
gateway
)
{
statusSubscribe
.
unsubscribe
(
gateway
);
...
...
@@ -1497,5 +1511,89 @@ public class DeviceServiceImpl extends ServiceImpl<IDeviceMapper, DeviceEntity>
.
collect
(
Collectors
.
toList
());
return
new
PaginationData
<
DeviceDTO
>(
devicesList
,
new
Pagination
(
pagination
.
getCurrent
(),
pagination
.
getSize
(),
pagination
.
getTotal
()));
}
@Override
public
void
recoverDeviceOnline
(
String
deviceSn
)
{
if
(!
StringUtils
.
hasText
(
deviceSn
))
{
return
;
}
// 查询数据库
Optional
<
DeviceDTO
>
dbDeviceOpt
=
this
.
getDeviceBySn
(
deviceSn
);
if
(
dbDeviceOpt
.
isEmpty
())
{
throw
new
RuntimeException
(
"device is null, please add device!"
);
}
DeviceDTO
dbDevice
=
dbDeviceOpt
.
get
();
if
(
DeviceDomainEnum
.
DOCK
==
dbDevice
.
getDomain
())
{
recoverGatewayOnline
(
dbDevice
);
}
else
if
(
DeviceDomainEnum
.
REMOTER_CONTROL
==
dbDevice
.
getDomain
())
{
recoverGatewayOnline
(
dbDevice
);
}
else
if
(
DeviceDomainEnum
.
DRONE
==
dbDevice
.
getDomain
())
{
recoverDroneOnline
(
dbDevice
);
}
}
@Override
public
void
recoverGatewayOnline
(
String
gatewaySn
)
{
// 查询数据库
Optional
<
DeviceDTO
>
dbGatewayOpt
=
this
.
getDeviceBySn
(
gatewaySn
);
if
(
dbGatewayOpt
.
isEmpty
())
{
throw
new
RuntimeException
(
"gateway is null, please add gateway!"
);
}
DeviceDTO
dbGateway
=
dbGatewayOpt
.
get
();
if
(
DeviceDomainEnum
.
DOCK
!=
dbGateway
.
getDomain
()
&&
DeviceDomainEnum
.
REMOTER_CONTROL
!=
dbGateway
.
getDomain
())
{
return
;
}
recoverGatewayOnline
(
dbGateway
);
}
public
void
recoverGatewayOnline
(
DeviceDTO
dbGateway
)
{
String
gatewaySn
=
dbGateway
.
getDeviceSn
();
String
deviceSn
=
dbGateway
.
getChildDeviceSn
();
Optional
<
DeviceDTO
>
dbDeviceOpt
=
this
.
getDeviceBySn
(
deviceSn
);
if
(
dbDeviceOpt
.
isEmpty
())
{
throw
new
RuntimeException
(
"device is null, please add device!"
);
}
DeviceDTO
dbDevice
=
dbDeviceOpt
.
get
();
GatewayManager
gatewayManager
=
SDKManager
.
registerDevice
(
gatewaySn
,
deviceSn
,
dbGateway
.
getDomain
(),
dbGateway
.
getType
(),
dbGateway
.
getSubType
(),
dbGateway
.
getThingVersion
(),
dbDevice
.
getThingVersion
());
deviceRedisService
.
setDeviceOnline
(
dbGateway
);
deviceRedisService
.
setDeviceOnline
(
dbDevice
);
this
.
gatewayOnlineSubscribeTopic
(
gatewayManager
);
this
.
subDeviceOnlineSubscribeTopic
(
gatewayManager
);
this
.
pushDeviceOnlineTopo
(
dbGateway
.
getWorkspaceId
(),
dbGateway
.
getDeviceSn
(),
dbDevice
.
getDeviceSn
());
}
// 无人机单独上线
@Override
public
void
recoverDroneOnline
(
String
droneSn
)
{
// 查询数据库
Optional
<
DeviceDTO
>
dbDeviceOpt
=
this
.
getDeviceBySn
(
droneSn
);
if
(
dbDeviceOpt
.
isEmpty
())
{
throw
new
RuntimeException
(
"device is null, please add device!"
);
}
DeviceDTO
dbDevice
=
dbDeviceOpt
.
get
();
if
(
DeviceDomainEnum
.
DRONE
!=
dbDevice
.
getDomain
())
{
return
;
}
recoverDroneOnline
(
dbDevice
);
}
// 无人机单独上线
public
void
recoverDroneOnline
(
DeviceDTO
dbDevice
)
{
if
(
DeviceDomainEnum
.
DRONE
!=
dbDevice
.
getDomain
())
{
return
;
}
deviceRedisService
.
setDeviceOnline
(
dbDevice
);
this
.
subDroneOnlineSubscribeTopic
(
dbDevice
.
getDeviceSn
());
// deviceService.pushDeviceOnlineTopo(dbGateway.getWorkspaceId(), dbGateway.getDeviceSn(), dbDevice.getDeviceSn());
}
}
\ No newline at end of file
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