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
a52642df
Commit
a52642df
authored
May 21, 2025
by
guoxuejian
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'prod' of
http://git.raytue.com/GeoFly/GeoFlyApi
into prod
parents
d3a3ee49
ccec91c8
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
132 additions
and
53 deletions
+132
-53
cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DeviceEnum.java
+8
-8
cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DeviceTypeEnum.java
+6
-6
cloud-sdk/src/main/java/com/dji/sdk/config/version/GatewayTypeEnum.java
+1
-1
sample/src/main/java/com/dji/sample/manage/service/impl/SDKDeviceService.java
+114
-35
sample/src/main/java/com/dji/sample/uom/UOMRecordService.java
+3
-3
No files found.
cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DeviceEnum.java
View file @
a52642df
...
...
@@ -83,34 +83,34 @@ public enum DeviceEnum {
/**
* 草莓机场S
uperDock Pro V4
* 草莓机场S
2301
*/
S
UPER_DOCK_PRO_V4
(
DeviceDomainEnum
.
DOCK
,
DeviceTypeEnum
.
DOCK
,
DeviceSubTypeEnum
.
_99
),
S
2301
(
DeviceDomainEnum
.
DOCK
,
DeviceTypeEnum
.
DOCK
,
DeviceSubTypeEnum
.
_99
),
/**
* 草莓机场S22M300
*/
S22M300
(
DeviceDomainEnum
.
DOCK
,
DeviceTypeEnum
.
_97
,
DeviceSubTypeEnum
.
ZERO
),
S22M300
(
DeviceDomainEnum
.
DOCK
,
DeviceTypeEnum
.
_
880
97
,
DeviceSubTypeEnum
.
ZERO
),
/**
* 草莓机场S2201
*/
S2201
(
DeviceDomainEnum
.
DOCK
,
DeviceTypeEnum
.
_98
,
DeviceSubTypeEnum
.
ZERO
),
S2201
(
DeviceDomainEnum
.
DOCK
,
DeviceTypeEnum
.
_
880
98
,
DeviceSubTypeEnum
.
ZERO
),
/**
* 草莓机场S24M350
*/
S24M350
(
DeviceDomainEnum
.
DOCK
,
DeviceTypeEnum
.
_100
,
DeviceSubTypeEnum
.
ZERO
),
S24M350
(
DeviceDomainEnum
.
DOCK
,
DeviceTypeEnum
.
_
88
100
,
DeviceSubTypeEnum
.
ZERO
),
/**
* 草莓机场S24M350S
*/
S24M350S
(
DeviceDomainEnum
.
DOCK
,
DeviceTypeEnum
.
_101
,
DeviceSubTypeEnum
.
ZERO
),
S24M350S
(
DeviceDomainEnum
.
DOCK
,
DeviceTypeEnum
.
_
88
101
,
DeviceSubTypeEnum
.
ZERO
),
/**
* 草莓机场S24M3
*/
S24M3
(
DeviceDomainEnum
.
DOCK
,
DeviceTypeEnum
.
_102
,
DeviceSubTypeEnum
.
ZERO
),
S24M3
(
DeviceDomainEnum
.
DOCK
,
DeviceTypeEnum
.
_
88
102
,
DeviceSubTypeEnum
.
ZERO
),
/**
* 草莓机场S24M4
*/
S24M4
(
DeviceDomainEnum
.
DOCK
,
DeviceTypeEnum
.
_103
,
DeviceSubTypeEnum
.
ZERO
),
S24M4
(
DeviceDomainEnum
.
DOCK
,
DeviceTypeEnum
.
_
88
103
,
DeviceSubTypeEnum
.
ZERO
),
M3D
(
DeviceDomainEnum
.
DRONE
,
DeviceTypeEnum
.
M3D
,
DeviceSubTypeEnum
.
ZERO
),
...
...
cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/DeviceTypeEnum.java
View file @
a52642df
...
...
@@ -91,12 +91,12 @@ public enum DeviceTypeEnum {
M4TD_CAMERA
(
99
),
// 草莓
_
97
(
97
),
_
98
(
98
),
_
100
(
100
),
_
101
(
101
),
_
102
(
102
),
_
103
(
103
),
_
88097
(
880
97
),
_
88098
(
880
98
),
_
88100
(
88
100
),
_
88101
(
88
101
),
_
88102
(
88
102
),
_
88103
(
88
103
),
;
private
final
int
type
;
...
...
cloud-sdk/src/main/java/com/dji/sdk/config/version/GatewayTypeEnum.java
View file @
a52642df
...
...
@@ -14,7 +14,7 @@ public enum GatewayTypeEnum {
RC
(
DeviceEnum
.
RC
,
DeviceEnum
.
RC_PLUS
,
DeviceEnum
.
RC_PRO
,
DeviceEnum
.
RC_PRO_TWO
),
DOCK
(
DeviceEnum
.
DOCK
,
DeviceEnum
.
S
UPER_DOCK_PRO_V4
,
DeviceEnum
.
S22M300
,
DeviceEnum
.
S2201
,
DOCK
(
DeviceEnum
.
DOCK
,
DeviceEnum
.
S
2301
,
DeviceEnum
.
S22M300
,
DeviceEnum
.
S2201
,
DeviceEnum
.
S24M350
,
DeviceEnum
.
S24M350S
,
DeviceEnum
.
S24M3
,
DeviceEnum
.
S24M4
),
DOCK2
(
DeviceEnum
.
DOCK2
),
...
...
sample/src/main/java/com/dji/sample/manage/service/impl/SDKDeviceService.java
View file @
a52642df
...
...
@@ -35,10 +35,10 @@ import org.springframework.util.StringUtils;
import
java.math.RoundingMode
;
import
java.time.LocalDateTime
;
import
java.util.
Date
;
import
java.util.
List
;
import
java.util.
Object
s
;
import
java.util.
Optional
;
import
java.util.
*
;
import
java.util.
concurrent.ConcurrentHashMap
;
import
java.util.
concurrent.Executor
s
;
import
java.util.
concurrent.ScheduledExecutorService
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -68,6 +68,9 @@ public class SDKDeviceService extends AbstractDeviceService {
@Autowired
private
UOMRecordService
uomRecordService
;
private
static
final
ScheduledExecutorService
recordExecutor
=
Executors
.
newScheduledThreadPool
(
4
);
private
static
final
Map
<
String
,
Long
>
lastRecordTimeMap
=
new
ConcurrentHashMap
<>();
private
static
final
long
MIN_RECORD_INTERVAL
=
2000
;
// 2秒间隔
@Override
public
TopicStatusResponse
<
MqttReply
>
updateTopoOnline
(
TopicStatusRequest
<
UpdateTopo
>
request
,
MessageHeaders
headers
)
{
UpdateTopoSubDevice
updateTopoSubDevice
=
request
.
getData
().
getSubDevices
().
get
(
0
);
...
...
@@ -188,37 +191,38 @@ public class SDKDeviceService extends AbstractDeviceService {
DeviceDTO
device
=
deviceOpt
.
get
();
deviceRedisService
.
setDeviceOnline
(
device
);
deviceRedisService
.
setDeviceOsd
(
from
,
request
.
getData
());
new
Thread
(()
->
{
UOMDroneFlightRecordDTO
uomDroneFlightRecordDTO
=
new
UOMDroneFlightRecordDTO
();
uomDroneFlightRecordDTO
.
setOrderID
(
device
.
getDeviceSn
()+
"-"
+
DateUtil
.
format
(
new
Date
(),
"yyyyMMdd"
)+
"-"
+
RandomUtil
.
randomString
(
8
));
uomDroneFlightRecordDTO
.
setSn
(
device
.
getDeviceSn
());
uomDroneFlightRecordDTO
.
setFlightStatus
(
"Land"
);
uomDroneFlightRecordDTO
.
setManufacturerID
(
"914403007954257495"
);
uomDroneFlightRecordDTO
.
setUasID
(
"UAS-DEFAULT"
);
uomDroneFlightRecordDTO
.
setTimeStamp
(
DateUtil
.
format
(
DateUtil
.
date
(
request
.
getTimestamp
()),
"yyyyMMddHHmmss"
));
uomDroneFlightRecordDTO
.
setUasModel
(
device
.
getType
().
name
());
uomDroneFlightRecordDTO
.
setCoordinate
(
1
);
uomDroneFlightRecordDTO
.
setLongitude
((
long
)
(
NumberUtil
.
round
(
request
.
getData
().
getLongitude
(),
7
,
RoundingMode
.
DOWN
).
doubleValue
()
*
10000000
));
uomDroneFlightRecordDTO
.
setLatitude
((
long
)
(
NumberUtil
.
round
(
request
.
getData
().
getLatitude
(),
7
,
RoundingMode
.
DOWN
).
doubleValue
()
*
10000000
));
uomDroneFlightRecordDTO
.
setHeightType
(
1
);
uomDroneFlightRecordDTO
.
setHeight
((
int
)
(
NumberUtil
.
round
(
request
.
getData
().
getElevation
(),
1
,
RoundingMode
.
DOWN
).
doubleValue
()
*
10
));
uomDroneFlightRecordDTO
.
setAltitude
((
int
)
(
request
.
getData
().
getHeight
().
doubleValue
()
*
10
));
uomDroneFlightRecordDTO
.
setVS
((
int
)
(
NumberUtil
.
round
(
request
.
getData
().
getVerticalSpeed
(),
1
,
RoundingMode
.
DOWN
).
doubleValue
()
*
10
));
uomDroneFlightRecordDTO
.
setGS
((
int
)
(
NumberUtil
.
round
(
request
.
getData
().
getHorizontalSpeed
(),
1
,
RoundingMode
.
DOWN
).
doubleValue
()
*
10
));
uomDroneFlightRecordDTO
.
setCourse
(-
999
);
log
.
info
(
"UOM Record start: =================+++++++++++++++++"
);
log
.
info
(
"UOM Record DTO: "
+
JSONUtil
.
toJsonStr
(
uomDroneFlightRecordDTO
));
try
{
String
body
=
uomRecordService
.
sendRecord
(
uomDroneFlightRecordDTO
);
log
.
info
(
"UOM Record: "
+
body
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
"UOM Record Error: "
+
e
.
getMessage
());
log
.
error
(
"UOM Record Error: "
+
e
.
getMessage
());
}
log
.
info
(
"UOM Record end: =================+++++++++++++++++"
);
}).
start
();
// 3. 带频率控制的记录上报
submitRecordWithRateLimit
(
device
,
request
);
// new Thread(() -> {
// UOMDroneFlightRecordDTO uomDroneFlightRecordDTO = new UOMDroneFlightRecordDTO();
// uomDroneFlightRecordDTO.setOrderID(device.getDeviceSn()+"-"+ DateUtil.format(new Date(), "yyyyMMdd")+"-"+ RandomUtil.randomString(8));
// uomDroneFlightRecordDTO.setSn(device.getDeviceSn());
// uomDroneFlightRecordDTO.setFlightStatus("Land");
// uomDroneFlightRecordDTO.setManufacturerID("914403007954257495");
// uomDroneFlightRecordDTO.setUasID("UAS-DEFAULT");
// uomDroneFlightRecordDTO.setTimeStamp(DateUtil.format(DateUtil.date(request.getTimestamp()),"yyyyMMddHHmmss"));
// uomDroneFlightRecordDTO.setUasModel(device.getType().name());
// uomDroneFlightRecordDTO.setCoordinate(1);
// uomDroneFlightRecordDTO.setLongitude((long) (NumberUtil.round(request.getData().getLongitude(),7, RoundingMode.DOWN).doubleValue() * 10000000));
// uomDroneFlightRecordDTO.setLatitude((long) (NumberUtil.round(request.getData().getLatitude(),7, RoundingMode.DOWN).doubleValue() * 10000000));
// uomDroneFlightRecordDTO.setHeightType(1);
// uomDroneFlightRecordDTO.setHeight((int) (NumberUtil.round(request.getData().getElevation(),1, RoundingMode.DOWN).doubleValue() * 10));
// uomDroneFlightRecordDTO.setAltitude((int) (request.getData().getHeight().doubleValue() * 10));
// uomDroneFlightRecordDTO.setVS((int) (NumberUtil.round(request.getData().getVerticalSpeed(),1, RoundingMode.DOWN).doubleValue() * 10));
// uomDroneFlightRecordDTO.setGS((int) (NumberUtil.round(request.getData().getHorizontalSpeed(),1, RoundingMode.DOWN).doubleValue() * 10));
// uomDroneFlightRecordDTO.setCourse(-999);
// log.info("UOM Record start: =================+++++++++++++++++");
// log.info("UOM Record DTO: " + JSONUtil.toJsonStr(uomDroneFlightRecordDTO));
// try {
// String body = uomRecordService.sendRecord(uomDroneFlightRecordDTO);
// log.info("UOM Record: " + body);
// } catch (Exception e) {
// e.printStackTrace();
// log.error("UOM Record Error: " + e.getMessage());
// log.error("UOM Record Error: " + e.getMessage());
// }
// log.info("UOM Record end: =================+++++++++++++++++");
// }).start();
deviceService
.
pushOsdDataToWeb
(
device
.
getWorkspaceId
(),
BizCodeEnum
.
DEVICE_OSD
,
from
,
request
.
getData
());
}
...
...
@@ -538,4 +542,79 @@ public class SDKDeviceService extends AbstractDeviceService {
deviceRedisService
.
setDeviceOsd
(
dockSn
,
oldDock
);
}
}
private
void
submitRecordWithRateLimit
(
DeviceDTO
device
,
TopicOsdRequest
<
OsdDockDrone
>
request
)
{
String
sn
=
device
.
getDeviceSn
();
long
currentTime
=
System
.
currentTimeMillis
();
// 检查时间间隔
if
(
lastRecordTimeMap
.
containsKey
(
sn
))
{
long
lastTime
=
lastRecordTimeMap
.
get
(
sn
);
if
(
currentTime
-
lastTime
<
MIN_RECORD_INTERVAL
)
{
log
.
debug
(
"Skip record for SN {} due to rate limit"
,
sn
);
return
;
}
}
// 更新时间戳并提交任务
lastRecordTimeMap
.
put
(
sn
,
currentTime
);
recordExecutor
.
submit
(()
->
processFlightRecord
(
device
,
request
));
}
private
void
processFlightRecord
(
DeviceDTO
device
,
TopicOsdRequest
<
OsdDockDrone
>
request
)
{
// 1. 构建DTO(提取为独立方法)
UOMDroneFlightRecordDTO
recordDto
=
buildFlightRecordDto
(
device
,
request
);
// 2. 记录日志(优化日志格式)
log
.
info
(
"UOM Record start ================= [SN: {}]"
,
device
.
getDeviceSn
());
log
.
debug
(
"UOM Record DTO: {}"
,
JSONUtil
.
toJsonStr
(
recordDto
));
// 3. 发送记录(带异常处理)
try
{
String
response
=
uomRecordService
.
sendRecord
(
recordDto
);
log
.
info
(
"UOM Record success, response: {}"
,
response
);
}
catch
(
Exception
e
)
{
log
.
error
(
"UOM Record failed for SN {}: {}"
,
device
.
getDeviceSn
(),
e
.
getMessage
());
log
.
debug
(
"Stack trace: "
,
e
);
}
finally
{
log
.
info
(
"UOM Record end =================== [SN: {}]"
,
device
.
getDeviceSn
());
}
}
private
UOMDroneFlightRecordDTO
buildFlightRecordDto
(
DeviceDTO
device
,
TopicOsdRequest
<
OsdDockDrone
>
request
)
{
UOMDroneFlightRecordDTO
dto
=
new
UOMDroneFlightRecordDTO
();
// 公共字段设置
dto
.
setOrderID
(
String
.
format
(
"%s-%s-%s"
,
device
.
getDeviceSn
(),
DateUtil
.
format
(
new
Date
(),
"yyyyMMdd"
),
RandomUtil
.
randomString
(
8
)));
dto
.
setSn
(
device
.
getDeviceSn
());
dto
.
setFlightStatus
(
"Land"
);
dto
.
setManufacturerID
(
"914403007954257495"
);
dto
.
setUasID
(
"UAS-DEFAULT"
);
dto
.
setTimeStamp
(
DateUtil
.
format
(
DateUtil
.
date
(
request
.
getTimestamp
()),
"yyyyMMddHHmmss"
));
dto
.
setUasModel
(
device
.
getType
().
name
());
// 坐标相关计算
OsdDockDrone
data
=
request
.
getData
();
dto
.
setCoordinate
(
1
);
dto
.
setLongitude
(
convertCoordinate
(
data
.
getLongitude
().
doubleValue
()));
dto
.
setLatitude
(
convertCoordinate
(
data
.
getLatitude
().
doubleValue
()));
dto
.
setHeightType
(
1
);
dto
.
setHeight
(
convertToInt
(
data
.
getElevation
().
doubleValue
(),
1
));
dto
.
setAltitude
(
convertToInt
(
data
.
getHeight
().
doubleValue
(),
1
));
dto
.
setVS
(
convertToInt
(
data
.
getVerticalSpeed
().
doubleValue
(),
1
));
dto
.
setGS
(
convertToInt
(
data
.
getHorizontalSpeed
().
doubleValue
(),
1
));
dto
.
setCourse
(-
999
);
return
dto
;
}
// 辅助方法
private
long
convertCoordinate
(
Double
value
)
{
return
(
long
)
(
NumberUtil
.
round
(
value
,
7
,
RoundingMode
.
DOWN
).
doubleValue
()
*
10000000
);
}
private
int
convertToInt
(
Double
value
,
int
decimalPlaces
)
{
return
(
int
)
(
NumberUtil
.
round
(
value
,
decimalPlaces
,
RoundingMode
.
DOWN
).
doubleValue
()
*
10
);
}
}
sample/src/main/java/com/dji/sample/uom/UOMRecordService.java
View file @
a52642df
...
...
@@ -48,11 +48,11 @@ public class UOMRecordService {
post
.
header
(
"source"
,
String
.
valueOf
(
uomConfiguration
.
getSource
()));
post
.
header
(
"platform"
,
uomConfiguration
.
getPlatform
());
post
.
header
(
"programVersion"
,
uomConfiguration
.
getProgramVersion
());
post
.
header
(
"signature"
,
JSONUtil
.
toJsonStr
(
sendUOMDTO
));
String
encrypt
=
SM3Util
.
encrypt
(
JSONUtil
.
toJsonStr
(
sendUOMDTO
),
uomConfiguration
.
getAppKey
());
post
.
header
(
"signature"
,
encrypt
);
post
.
header
(
"Content-Type"
,
"application/json"
);
sendUOMDTO
.
setPaths
(
paths
);
String
encrypt
=
SM3Util
.
encrypt
(
JSONUtil
.
toJsonStr
(
sendUOMDTO
),
uomConfiguration
.
getAppKey
());
post
.
body
(
encrypt
);
post
.
body
(
JSONUtil
.
toJsonStr
(
sendUOMDTO
));
log
.
info
(
"UOM Record: "
+
JSONUtil
.
toJsonStr
(
sendUOMDTO
));
return
post
.
execute
().
body
();
}
...
...
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