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
e2a15963
Commit
e2a15963
authored
Apr 14, 2025
by
gdj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加机场,无人机增删改功能。
parent
6f09092b
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
414 additions
and
0 deletions
+414
-0
sample/src/main/java/com/dji/sample/manage/controller/DeviceController.java
+99
-0
sample/src/main/java/com/dji/sample/manage/model/dto/DeviceDTO.java
+2
-0
sample/src/main/java/com/dji/sample/manage/service/IDeviceDictionaryService.java
+3
-0
sample/src/main/java/com/dji/sample/manage/service/IDeviceService.java
+29
-0
sample/src/main/java/com/dji/sample/manage/service/impl/DeviceDictionaryServiceImpl.java
+19
-0
sample/src/main/java/com/dji/sample/manage/service/impl/DeviceServiceImpl.java
+262
-0
No files found.
sample/src/main/java/com/dji/sample/manage/controller/DeviceController.java
View file @
e2a15963
package
com
.
dji
.
sample
.
manage
.
controller
;
import
com.dji.sample.manage.model.dto.DeviceDTO
;
import
com.dji.sample.manage.model.dto.DeviceDictionaryDTO
;
import
com.dji.sample.manage.model.dto.DeviceFirmwareUpgradeDTO
;
import
com.dji.sample.manage.service.IDeviceDictionaryService
;
import
com.dji.sample.manage.service.IDeviceService
;
import
com.dji.sdk.common.HttpResultResponse
;
import
com.dji.sdk.common.PaginationData
;
...
...
@@ -10,6 +12,7 @@ import com.dji.sdk.mqtt.property.PropertySetReplyResultEnum;
import
com.fasterxml.jackson.databind.JsonNode
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
...
...
@@ -28,6 +31,9 @@ public class DeviceController {
@Autowired
private
IDeviceService
deviceService
;
@Autowired
private
IDeviceDictionaryService
deviceDictionaryService
;
/**
* Get the topology list of all online devices in one workspace.
* @param workspaceId
...
...
@@ -142,4 +148,96 @@ public class DeviceController {
return
PropertySetReplyResultEnum
.
SUCCESS
.
getResult
()
==
result
?
HttpResultResponse
.
success
()
:
HttpResultResponse
.
error
(
result
,
String
.
valueOf
(
result
));
}
/**
* add the addAircraft to the workspace
* @param aircraft
* @return
*/
@PostMapping
(
"/{workspace_id}/addDrone"
)
public
HttpResultResponse
addDrone
(
@RequestBody
DeviceDTO
aircraft
,
@PathVariable
(
"workspace_id"
)
String
workspaceId
)
{
aircraft
.
setWorkspaceId
(
workspaceId
);
boolean
isAdd
=
deviceService
.
addDrone
(
aircraft
);
return
isAdd
?
HttpResultResponse
.
success
()
:
HttpResultResponse
.
error
();
}
/**
* edit the addAircraft to the workspace
* @param aircraft
* @return
*/
@PostMapping
(
"/{workspace_id}/editDrone"
)
public
HttpResultResponse
editDrone
(
@RequestBody
DeviceDTO
aircraft
,
@PathVariable
(
"workspace_id"
)
String
workspaceId
)
{
aircraft
.
setWorkspaceId
(
workspaceId
);
boolean
isAdd
=
deviceService
.
editDrone
(
aircraft
);
return
isAdd
?
HttpResultResponse
.
success
()
:
HttpResultResponse
.
error
();
}
/**
* add the addAirport to the workspace
* @param airport
* @return
*/
@PostMapping
(
"/{workspace_id}/addAirport"
)
public
HttpResultResponse
addAirport
(
@RequestBody
DeviceDTO
airport
,
@PathVariable
(
"workspace_id"
)
String
workspaceId
)
{
airport
.
setWorkspaceId
(
workspaceId
);
boolean
isAdd
=
deviceService
.
addAirport
(
airport
);
return
isAdd
?
HttpResultResponse
.
success
()
:
HttpResultResponse
.
error
();
}
/**
* edit the addAirport to the workspace
* @param airport
* @return
*/
@PostMapping
(
"/{workspace_id}/editAirport"
)
public
HttpResultResponse
editAirport
(
@RequestBody
DeviceDTO
airport
,
@PathVariable
(
"workspace_id"
)
String
workspaceId
)
{
airport
.
setWorkspaceId
(
workspaceId
);
boolean
isAdd
=
deviceService
.
editAirport
(
airport
);
return
isAdd
?
HttpResultResponse
.
success
()
:
HttpResultResponse
.
error
();
}
/**
* get device Dictionary
* @param workspaceId
* @return
*/
@GetMapping
(
"/{workspace_id}/deviceDictionary"
)
public
HttpResultResponse
getDeviceDictionary
(
@PathVariable
(
"workspace_id"
)
String
workspaceId
,
@RequestParam
(
value
=
"domain"
,
required
=
false
)
Integer
domain
)
{
List
<
DeviceDictionaryDTO
>
infoList
=
deviceDictionaryService
.
getDictionaryInfoList
(
domain
);
return
CollectionUtils
.
isEmpty
(
infoList
)
?
HttpResultResponse
.
error
(
"deviceDictionary not found."
)
:
HttpResultResponse
.
success
(
infoList
);
}
/**
* Get the binding devices list in one workspace.
* @param workspaceId
* @param page
* @param pageSize
* @return
*/
@GetMapping
(
"/{workspace_id}/devices/list"
)
public
HttpResultResponse
<
PaginationData
<
DeviceDTO
>>
getDevicesWithDomain
(
@PathVariable
(
"workspace_id"
)
String
workspaceId
,
@RequestParam
(
value
=
"domain"
,
required
=
false
)
Integer
domain
,
@RequestParam
(
value
=
"device_name"
,
required
=
false
)
String
deviceName
,
@RequestParam
(
defaultValue
=
"1"
)
Long
page
,
@RequestParam
(
value
=
"page_size"
,
defaultValue
=
"50"
)
Long
pageSize
)
{
PaginationData
<
DeviceDTO
>
devices
=
deviceService
.
getDevicesWithDomain
(
workspaceId
,
deviceName
,
page
,
pageSize
,
domain
);
return
HttpResultResponse
.
success
(
devices
);
}
/**
* Removing the binding state of the device.
* @param deviceSn
* @return
*/
@DeleteMapping
(
"/{device_sn}/delete"
)
public
HttpResultResponse
deleteDevice
(
@PathVariable
(
"device_sn"
)
String
deviceSn
)
{
deviceService
.
deleteDevice
(
deviceSn
);
return
HttpResultResponse
.
success
();
}
}
\ No newline at end of file
sample/src/main/java/com/dji/sample/manage/model/dto/DeviceDTO.java
View file @
e2a15963
...
...
@@ -25,6 +25,8 @@ import java.util.List;
@Builder
public
class
DeviceDTO
{
private
Integer
id
;
private
String
deviceSn
;
private
String
deviceName
;
...
...
sample/src/main/java/com/dji/sample/manage/service/IDeviceDictionaryService.java
View file @
e2a15963
...
...
@@ -2,6 +2,7 @@ package com.dji.sample.manage.service;
import
com.dji.sample.manage.model.dto.DeviceDictionaryDTO
;
import
java.util.List
;
import
java.util.Optional
;
/**
...
...
@@ -21,4 +22,6 @@ public interface IDeviceDictionaryService {
*/
Optional
<
DeviceDictionaryDTO
>
getOneDictionaryInfoByTypeSubType
(
Integer
domain
,
Integer
deviceType
,
Integer
subType
);
List
<
DeviceDictionaryDTO
>
getDictionaryInfoList
(
Integer
domain
);
}
sample/src/main/java/com/dji/sample/manage/service/IDeviceService.java
View file @
e2a15963
...
...
@@ -140,6 +140,18 @@ public interface IDeviceService {
* @return
*/
PaginationData
<
DeviceDTO
>
getBoundDevicesWithDomain
(
String
workspaceId
,
String
deviceName
,
Long
page
,
Long
pageSize
,
Integer
domain
);
/**
* Get the devices list in one workspace.
* @param workspaceId
* @param deviceName 设备名称
* @param page
* @param pageSize
* @param domain
* @return
*/
PaginationData
<
DeviceDTO
>
getDevicesWithDomain
(
String
workspaceId
,
String
deviceName
,
Long
page
,
Long
pageSize
,
Integer
domain
);
/**
* Unbind device base on device's sn.
* @param deviceSn
...
...
@@ -147,6 +159,13 @@ public interface IDeviceService {
void
unbindDevice
(
String
deviceSn
);
/**
* delete device base on device's sn
* @param deviceSn
* @return
*/
boolean
deleteDevice
(
String
deviceSn
);
/**
* Get device information based on device's sn.
* @param sn device's sn
* @return device
...
...
@@ -207,4 +226,13 @@ public interface IDeviceService {
void
pushOsdDataToWeb
(
String
workspaceId
,
BizCodeEnum
codeEnum
,
String
sn
,
Object
data
);
void
updateFlightControl
(
DeviceDTO
gateway
,
ControlSourceEnum
controlSource
);
boolean
addDrone
(
DeviceDTO
drone
);
boolean
editDrone
(
DeviceDTO
drone
);
boolean
addAirport
(
DeviceDTO
airport
);
boolean
editAirport
(
DeviceDTO
airport
);
}
\ No newline at end of file
sample/src/main/java/com/dji/sample/manage/service/impl/DeviceDictionaryServiceImpl.java
View file @
e2a15963
...
...
@@ -8,8 +8,12 @@ import com.dji.sample.manage.service.IDeviceDictionaryService;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
/**
*
...
...
@@ -39,6 +43,21 @@ public class DeviceDictionaryServiceImpl implements IDeviceDictionaryService {
.
last
(
" limit 1 "
))));
}
@Override
public
List
<
DeviceDictionaryDTO
>
getDictionaryInfoList
(
Integer
domain
)
{
LambdaQueryWrapper
<
DeviceDictionaryEntity
>
wrapper
=
new
LambdaQueryWrapper
<>();
if
(
domain
!=
null
)
{
wrapper
.
eq
(
DeviceDictionaryEntity:
:
getDomain
,
domain
);
}
List
<
DeviceDictionaryEntity
>
deviceDictionaryEntities
=
mapper
.
selectList
(
wrapper
);
if
(
CollectionUtils
.
isEmpty
(
deviceDictionaryEntities
))
{
return
new
ArrayList
<>();
}
return
deviceDictionaryEntities
.
stream
().
map
(
this
::
entityConvertToDTO
).
collect
(
Collectors
.
toList
());
}
/**
* Convert database entity objects into dictionary data transfer object.
* @param entity
...
...
sample/src/main/java/com/dji/sample/manage/service/impl/DeviceServiceImpl.java
View file @
e2a15963
...
...
@@ -360,6 +360,7 @@ public class DeviceServiceImpl implements IDeviceService {
try
{
builder
.
deviceSn
(
entity
.
getDeviceSn
())
.
id
(
entity
.
getId
())
.
childDeviceSn
(
entity
.
getChildSn
())
.
deviceName
(
entity
.
getDeviceName
())
.
deviceDesc
(
entity
.
getDeviceDesc
())
...
...
@@ -500,6 +501,38 @@ public class DeviceServiceImpl implements IDeviceService {
}
@Override
public
PaginationData
<
DeviceDTO
>
getDevicesWithDomain
(
String
workspaceId
,
String
deviceName
,
Long
page
,
Long
pageSize
,
Integer
domain
)
{
LambdaQueryWrapper
<
DeviceEntity
>
wrapper
=
new
LambdaQueryWrapper
<
DeviceEntity
>()
.
eq
(
DeviceEntity:
:
getDomain
,
domain
)
.
eq
(
DeviceEntity:
:
getWorkspaceId
,
workspaceId
);
if
(
StringUtils
.
hasText
(
deviceName
))
{
wrapper
.
like
(
DeviceEntity:
:
getDeviceName
,
deviceName
);
}
Page
<
DeviceEntity
>
pagination
=
mapper
.
selectPage
(
new
Page
<>(
page
,
pageSize
),
wrapper
);
List
<
DeviceDTO
>
devicesList
=
pagination
.
getRecords
().
stream
().
map
(
this
::
deviceEntityConvertToDTO
)
.
peek
(
device
->
{
if
(
StringUtils
.
hasText
(
device
.
getDeviceSn
()))
{
device
.
setStatus
(
deviceRedisService
.
checkDeviceOnline
(
device
.
getDeviceSn
()));
}
if
(
StringUtils
.
hasText
(
device
.
getChildDeviceSn
()))
{
Optional
<
DeviceDTO
>
childOpt
=
this
.
getDeviceBySn
(
device
.
getChildDeviceSn
());
childOpt
.
ifPresent
(
child
->
{
child
.
setStatus
(
deviceRedisService
.
checkDeviceOnline
(
child
.
getDeviceSn
()));
child
.
setWorkspaceName
(
device
.
getWorkspaceName
());
device
.
setChildren
(
child
);
});
}
})
.
collect
(
Collectors
.
toList
());
return
new
PaginationData
<
DeviceDTO
>(
devicesList
,
new
Pagination
(
pagination
.
getCurrent
(),
pagination
.
getSize
(),
pagination
.
getTotal
()));
}
@Override
public
void
unbindDevice
(
String
deviceSn
)
{
Optional
<
DeviceDTO
>
deviceOpt
=
deviceRedisService
.
getDeviceOnline
(
deviceSn
);
...
...
@@ -521,6 +554,16 @@ public class DeviceServiceImpl implements IDeviceService {
}
@Override
public
boolean
deleteDevice
(
String
deviceSn
)
{
LambdaQueryWrapper
<
DeviceEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
eq
(
DeviceEntity:
:
getDeviceSn
,
deviceSn
)
int
delete
=
this
.
mapper
.
delete
(
queryWrapper
);
return
delete
>
0
;
}
@Override
public
Optional
<
DeviceDTO
>
getDeviceBySn
(
String
sn
)
{
List
<
DeviceDTO
>
devicesList
=
this
.
getDevicesByParams
(
DeviceQueryParam
.
builder
().
deviceSn
(
sn
).
build
());
if
(
devicesList
.
isEmpty
())
{
...
...
@@ -669,6 +712,7 @@ public class DeviceServiceImpl implements IDeviceService {
}
return
builder
.
deviceSn
(
dto
.
getDeviceSn
())
.
id
(
dto
.
getId
())
.
deviceIndex
(
Optional
.
ofNullable
(
dto
.
getControlSource
())
.
map
(
ControlSourceEnum:
:
getControlSource
).
orElse
(
null
))
.
deviceName
(
dto
.
getDeviceName
())
...
...
@@ -691,4 +735,221 @@ public class DeviceServiceImpl implements IDeviceService {
.
deviceDesc
(
dto
.
getDeviceDesc
())
.
build
();
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
boolean
addDrone
(
DeviceDTO
drone
)
{
DeviceEntity
deviceEntity
=
new
DeviceEntity
();
String
droneDeviceSn
=
drone
.
getDeviceSn
();
if
(
StringUtils
.
hasText
(
droneDeviceSn
))
{
// sn码不重复
List
<
DeviceEntity
>
dbDroneList
=
mapper
.
selectList
(
new
LambdaQueryWrapper
<
DeviceEntity
>().
eq
(
DeviceEntity:
:
getDeviceSn
,
droneDeviceSn
));
if
(!
CollectionUtils
.
isEmpty
(
dbDroneList
))
{
throw
new
RuntimeException
(
"deviceSn is already exit"
);
}
}
// 名称 sn码 飞机类型
deviceEntity
.
setDeviceSn
(
droneDeviceSn
);
// M350(DeviceDomainEnum.DRONE, DeviceTypeEnum.M350, DeviceSubTypeEnum.ZERO),
deviceEntity
.
setNickname
(
drone
.
getNickname
());
deviceEntity
.
setWorkspaceId
(
drone
.
getWorkspaceId
());
// 类型
deviceEntity
.
setDomain
(
DeviceDomainEnum
.
DRONE
.
getDomain
());
deviceEntity
.
setDeviceType
(
drone
.
getType
().
getType
());
deviceEntity
.
setSubType
(
drone
.
getSubType
().
getSubType
());
deviceEntity
.
setDeviceName
(
drone
.
getDeviceName
());
// deviceEntity.setUserId();
// firmware_version
// version
// child_sn The device controlled by the gateway.
deviceEntity
.
setCompatibleStatus
(
drone
.
getFirmwareStatus
()
==
null
?
null
:
DeviceFirmwareStatusEnum
.
CONSISTENT_UPGRADE
!=
drone
.
getFirmwareStatus
());
// deviceEntity.setDeviceIndex(drone.getControlSource().getControlSource());
// device_index Control of the drone, A control or B control.
deviceEntity
.
setCreateTime
(
System
.
currentTimeMillis
());
deviceEntity
.
setUpdateTime
(
System
.
currentTimeMillis
());
// bound_time bigint
// bound_status The status when the device is bound to the workspace. 1: bound; 0: not bound;
// deviceEntity.setDeviceDesc(drone.getDeviceDesc());
// url_normal The icon displayed on the remote control.
// url_select The icon displayed on the remote control when it is selected.
int
insert
=
this
.
mapper
.
insert
(
deviceEntity
);
return
insert
>
0
;
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
boolean
editDrone
(
DeviceDTO
drone
)
{
// 查询数据库
LambdaQueryWrapper
<
DeviceEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
eq
(
DeviceEntity:
:
getId
,
drone
.
getId
());
DeviceEntity
deviceEntity
=
this
.
mapper
.
selectOne
(
queryWrapper
);
if
(
deviceEntity
==
null
)
{
return
true
;
}
DeviceEntity
updateEntity
=
new
DeviceEntity
();
// 是否更改sn
if
(
StringUtils
.
hasText
(
drone
.
getDeviceSn
())
&&
!
drone
.
getDeviceSn
().
equals
(
deviceEntity
.
getDeviceSn
()))
{
// 查询数据库
LambdaQueryWrapper
<
DeviceEntity
>
deviceSnQueryWrapper
=
new
LambdaQueryWrapper
<>();
deviceSnQueryWrapper
.
eq
(
DeviceEntity:
:
getDeviceSn
,
drone
.
getDeviceSn
());
List
<
DeviceEntity
>
snList
=
this
.
mapper
.
selectList
(
deviceSnQueryWrapper
);
if
(!
CollectionUtils
.
isEmpty
(
snList
))
{
throw
new
RuntimeException
(
"deviceSn is already exit"
);
}
updateEntity
.
setDeviceSn
(
drone
.
getDeviceSn
());
// 还需要修改机场绑定的sn码
LambdaUpdateWrapper
<
DeviceEntity
>
updateDockWrapper
=
new
LambdaUpdateWrapper
<>();
updateDockWrapper
.
set
(
DeviceEntity:
:
getChildSn
,
drone
.
getDeviceSn
());
updateDockWrapper
.
eq
(
DeviceEntity:
:
getChildSn
,
deviceEntity
.
getDeviceSn
());
int
updateDockResult
=
this
.
mapper
.
update
(
new
DeviceEntity
(),
updateDockWrapper
);
}
LambdaUpdateWrapper
<
DeviceEntity
>
updateWrapper
=
new
LambdaUpdateWrapper
<>();
if
(
StringUtils
.
hasText
(
drone
.
getNickname
()))
{
// updateWrapper.set(DeviceEntity::getNickname, drone.getNickname());
updateEntity
.
setNickname
(
drone
.
getNickname
());
}
// updateWrapper.set(DeviceEntity::getDeviceSn, drone.getDeviceSn());
updateEntity
.
setDeviceSn
(
drone
.
getDeviceSn
());
updateWrapper
.
eq
(
DeviceEntity:
:
getId
,
drone
.
getId
());
int
update
=
this
.
mapper
.
update
(
updateEntity
,
updateWrapper
);
return
update
>
0
;
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
boolean
addAirport
(
DeviceDTO
dock
)
{
DeviceEntity
addDockEntity
=
new
DeviceEntity
();
String
dockSn
=
dock
.
getDeviceSn
();
if
(
StringUtils
.
hasText
(
dockSn
))
{
// sn码不重复
List
<
DeviceEntity
>
dbDeviceList
=
mapper
.
selectList
(
new
LambdaQueryWrapper
<
DeviceEntity
>().
eq
(
DeviceEntity:
:
getDeviceSn
,
dockSn
));
if
(!
CollectionUtils
.
isEmpty
(
dbDeviceList
))
{
throw
new
RuntimeException
(
"deviceSn is already exit"
);
}
}
// 机场还需要绑定 飞机
String
droneSn
=
dock
.
getChildDeviceSn
();
if
(!
StringUtils
.
hasText
(
droneSn
))
{
// throw new RuntimeException("the drone doesn't exist");
}
if
(
StringUtils
.
hasText
(
droneSn
))
{
DeviceEntity
drone
=
mapper
.
selectOne
(
new
LambdaQueryWrapper
<
DeviceEntity
>().
eq
(
DeviceEntity:
:
getDeviceSn
,
droneSn
));
// 飞机绑定了其他设备
// 飞机不存在? 新建飞机?
}
addDockEntity
.
setWorkspaceId
(
dock
.
getWorkspaceId
());
// 机场sn
addDockEntity
.
setDeviceSn
(
dock
.
getDeviceSn
());
addDockEntity
.
setNickname
(
dock
.
getNickname
());
// 机场名称
addDockEntity
.
setDeviceName
(
dock
.
getDeviceName
());
// device_name
addDockEntity
.
setDomain
(
DeviceDomainEnum
.
DRONE
.
getDomain
());
// 机场型号
addDockEntity
.
setDeviceType
(
dock
.
getType
().
getType
());
addDockEntity
.
setSubType
(
dock
.
getSubType
().
getSubType
());
// 无人机sn
addDockEntity
.
setChildSn
(
dock
.
getChildDeviceSn
());
// user_id
// firmware_version
// compatible_status
// version
addDockEntity
.
setDeviceIndex
(
ControlSourceEnum
.
A
.
getControlSource
());
// Control of the drone, A control or B control.
addDockEntity
.
setCreateTime
(
System
.
currentTimeMillis
());
addDockEntity
.
setUpdateTime
(
System
.
currentTimeMillis
());
// bound_time bigint
// bound_status The status when the device is bound to the workspace. 1: bound; 0: not bound;
// device_desc
// url_normal The icon displayed on the remote control.
// url_select The icon displayed on the remote control when it is selected.
int
insert
=
this
.
mapper
.
insert
(
addDockEntity
);
return
insert
>
0
;
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
boolean
editAirport
(
DeviceDTO
dock
)
{
// 查询数据库
LambdaQueryWrapper
<
DeviceEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
eq
(
DeviceEntity:
:
getId
,
dock
.
getId
());
DeviceEntity
deviceEntity
=
this
.
mapper
.
selectOne
(
queryWrapper
);
if
(
deviceEntity
==
null
)
{
return
true
;
}
DeviceEntity
updateEntity
=
new
DeviceEntity
();
// 是否更改sn
if
(
StringUtils
.
hasText
(
dock
.
getDeviceSn
())
&&
!
dock
.
getDeviceSn
().
equals
(
deviceEntity
.
getDeviceSn
()))
{
// 查询数据库
LambdaQueryWrapper
<
DeviceEntity
>
deviceSnQueryWrapper
=
new
LambdaQueryWrapper
<>();
deviceSnQueryWrapper
.
eq
(
DeviceEntity:
:
getDeviceSn
,
dock
.
getDeviceSn
());
List
<
DeviceEntity
>
snList
=
this
.
mapper
.
selectList
(
deviceSnQueryWrapper
);
if
(!
CollectionUtils
.
isEmpty
(
snList
))
{
throw
new
RuntimeException
(
"deviceSn is already exit"
);
}
updateEntity
.
setDeviceSn
(
dock
.
getDeviceSn
());
}
// 修改 无人机数据?
LambdaUpdateWrapper
<
DeviceEntity
>
updateWrapper
=
new
LambdaUpdateWrapper
<>();
if
(
StringUtils
.
hasText
(
dock
.
getNickname
()))
{
// updateWrapper.set(DeviceEntity::getNickname, drone.getNickname());
updateEntity
.
setNickname
(
dock
.
getNickname
());
}
// updateWrapper.set(DeviceEntity::getDeviceSn, drone.getDeviceSn());
updateEntity
.
setDeviceSn
(
dock
.
getDeviceSn
());
updateWrapper
.
eq
(
DeviceEntity:
:
getId
,
dock
.
getId
());
int
update
=
this
.
mapper
.
update
(
updateEntity
,
updateWrapper
);
return
update
>
0
;
}
}
\ 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