Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄嘉阳
/
iot-platform-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
454f3d96
authored
Nov 07, 2023
by
huangjy
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix:修改设备属性问题
parent
bfc6e8d0
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
91 additions
and
63 deletions
server-module/src/main/java/com/makeit/module/controller/wechat/device/PlatDeviceWechatController.java
server-service/src/main/java/com/makeit/dto/wechat/device/PlatDeviceAttrWechatDTO.java
server-service/src/main/java/com/makeit/dto/wechat/device/PlatDeviceEditWechatDTO.java
server-service/src/main/java/com/makeit/dto/wechat/device/PlatDeviceNetAttrWechatDTO.java
server-service/src/main/java/com/makeit/service/platform/device/PlatDeviceService.java
server-service/src/main/java/com/makeit/service/platform/device/impl/PlatDeviceServiceImpl.java
server-module/src/main/java/com/makeit/module/controller/wechat/device/PlatDeviceWechatController.java
View file @
454f3d96
...
@@ -10,6 +10,7 @@ import com.makeit.common.response.ApiResponseUtils;
...
@@ -10,6 +10,7 @@ import com.makeit.common.response.ApiResponseUtils;
import
com.makeit.dto.platform.device.PlatDeviceQueryDTO
;
import
com.makeit.dto.platform.device.PlatDeviceQueryDTO
;
import
com.makeit.dto.wechat.device.PlatDeviceAttrWechatDTO
;
import
com.makeit.dto.wechat.device.PlatDeviceAttrWechatDTO
;
import
com.makeit.dto.wechat.device.PlatDeviceEditWechatDTO
;
import
com.makeit.dto.wechat.device.PlatDeviceEditWechatDTO
;
import
com.makeit.dto.wechat.device.PlatDeviceNetAttrWechatDTO
;
import
com.makeit.dto.wechat.device.PlatDeviceSetupDTO
;
import
com.makeit.dto.wechat.device.PlatDeviceSetupDTO
;
import
com.makeit.entity.platform.auth.PlatOrg
;
import
com.makeit.entity.platform.auth.PlatOrg
;
import
com.makeit.entity.platform.auth.PlatRole
;
import
com.makeit.entity.platform.auth.PlatRole
;
...
@@ -106,5 +107,12 @@ public class PlatDeviceWechatController {
...
@@ -106,5 +107,12 @@ public class PlatDeviceWechatController {
return
ApiResponseUtils
.
success
();
return
ApiResponseUtils
.
success
();
}
}
@ApiOperation
(
"编辑设备网络属性"
)
@PostMapping
(
"editDeviceNetInfo"
)
public
ApiResponseEntity
<?>
editDeviceNetInfo
(
@RequestBody
PlatDeviceNetAttrWechatDTO
dto
)
{
platDeviceService
.
editDeviceNetInfo
(
dto
);
return
ApiResponseUtils
.
success
();
}
}
}
server-service/src/main/java/com/makeit/dto/wechat/device/PlatDeviceAttrWechatDTO.java
View file @
454f3d96
...
@@ -25,8 +25,4 @@ public class PlatDeviceAttrWechatDTO extends PlatDeviceBaseAttrDTO {
...
@@ -25,8 +25,4 @@ public class PlatDeviceAttrWechatDTO extends PlatDeviceBaseAttrDTO {
@ApiModelProperty
(
value
=
"读取硬件的系统参数,主要读取服务信息和雷达信息,多个逗号隔开"
)
@ApiModelProperty
(
value
=
"读取硬件的系统参数,主要读取服务信息和雷达信息,多个逗号隔开"
)
private
String
readProperties
;
private
String
readProperties
;
//private String usrServerInfo;
@ApiModelProperty
(
value
=
"服务信息 {\"password\":\"1234576\",\"secureKey\":\"kuangshi\",\"secureId\":\"kuangshi\",\"addr\":\"mqtt://121.1.1.2\",\"username\":\"kuangshi\",\"port\":1883} "
)
private
UserServerInfo
usrServerInfo
;
}
}
server-service/src/main/java/com/makeit/dto/wechat/device/PlatDeviceEditWechatDTO.java
View file @
454f3d96
...
@@ -27,15 +27,5 @@ public class PlatDeviceEditWechatDTO extends BaseTenantDTO {
...
@@ -27,15 +27,5 @@ public class PlatDeviceEditWechatDTO extends BaseTenantDTO {
@ApiModelProperty
(
value
=
"设备名称"
)
@ApiModelProperty
(
value
=
"设备名称"
)
private
String
name
;
private
String
name
;
@ApiModelProperty
(
value
=
"设备安装方式"
)
private
String
installation
;
@ApiModelProperty
(
value
=
"开关指示灯"
)
private
String
indicatorLight
;
@ApiModelProperty
(
value
=
"设备属性json"
)
private
String
attribute
;
}
}
server-service/src/main/java/com/makeit/dto/wechat/device/PlatDeviceNetAttrWechatDTO.java
0 → 100644
View file @
454f3d96
package
com
.
makeit
.
dto
.
wechat
.
device
;
import
com.makeit.dto.platform.device.PlatDeviceBaseAttrDTO
;
import
com.makeit.module.iot.dto.UserServerInfo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* <p>
* 设备
* </p>
*
* @author eugene young
* @since 2023-09-05
*/
@Data
@ApiModel
(
value
=
"PlatDeviceNetAttrWechatDTO"
,
description
=
"设备网络信息"
)
public
class
PlatDeviceNetAttrWechatDTO
{
@ApiModelProperty
(
value
=
"设备id"
)
private
String
deviceId
;
//private String usrServerInfo;
@ApiModelProperty
(
value
=
"服务信息 {\"password\":\"1234576\",\"secureKey\":\"kuangshi\",\"secureId\":\"kuangshi\",\"addr\":\"mqtt://121.1.1.2\",\"username\":\"kuangshi\",\"port\":1883} "
)
private
UserServerInfo
usrServerInfo
;
}
server-service/src/main/java/com/makeit/service/platform/device/PlatDeviceService.java
View file @
454f3d96
...
@@ -12,6 +12,7 @@ import com.makeit.dto.platform.device.PlatDeviceQueryDTO;
...
@@ -12,6 +12,7 @@ import com.makeit.dto.platform.device.PlatDeviceQueryDTO;
import
com.makeit.dto.saas.device.PlatDeviceEditSaasDTO
;
import
com.makeit.dto.saas.device.PlatDeviceEditSaasDTO
;
import
com.makeit.dto.wechat.device.PlatDeviceAttrWechatDTO
;
import
com.makeit.dto.wechat.device.PlatDeviceAttrWechatDTO
;
import
com.makeit.dto.wechat.device.PlatDeviceEditWechatDTO
;
import
com.makeit.dto.wechat.device.PlatDeviceEditWechatDTO
;
import
com.makeit.dto.wechat.device.PlatDeviceNetAttrWechatDTO
;
import
com.makeit.dto.wechat.device.PlatDeviceSetupDTO
;
import
com.makeit.dto.wechat.device.PlatDeviceSetupDTO
;
import
com.makeit.entity.platform.device.PlatDevice
;
import
com.makeit.entity.platform.device.PlatDevice
;
import
com.makeit.module.iot.vo.DeviceProperties
;
import
com.makeit.module.iot.vo.DeviceProperties
;
...
@@ -75,4 +76,6 @@ public interface PlatDeviceService extends IService<PlatDevice> {
...
@@ -75,4 +76,6 @@ public interface PlatDeviceService extends IService<PlatDevice> {
void
batchEditProperties
(
PlatDeviceAttrDTO
dto
);
void
batchEditProperties
(
PlatDeviceAttrDTO
dto
);
boolean
updateDeviceStatus
(
String
messageType
,
String
deviceId
,
String
iot_tenantId
);
boolean
updateDeviceStatus
(
String
messageType
,
String
deviceId
,
String
iot_tenantId
);
void
editDeviceNetInfo
(
PlatDeviceNetAttrWechatDTO
dto
);
}
}
server-service/src/main/java/com/makeit/service/platform/device/impl/PlatDeviceServiceImpl.java
View file @
454f3d96
...
@@ -19,6 +19,7 @@ import com.makeit.dto.platform.device.*;
...
@@ -19,6 +19,7 @@ import com.makeit.dto.platform.device.*;
import
com.makeit.dto.saas.device.PlatDeviceEditSaasDTO
;
import
com.makeit.dto.saas.device.PlatDeviceEditSaasDTO
;
import
com.makeit.dto.wechat.device.PlatDeviceAttrWechatDTO
;
import
com.makeit.dto.wechat.device.PlatDeviceAttrWechatDTO
;
import
com.makeit.dto.wechat.device.PlatDeviceEditWechatDTO
;
import
com.makeit.dto.wechat.device.PlatDeviceEditWechatDTO
;
import
com.makeit.dto.wechat.device.PlatDeviceNetAttrWechatDTO
;
import
com.makeit.dto.wechat.device.PlatDeviceSetupDTO
;
import
com.makeit.dto.wechat.device.PlatDeviceSetupDTO
;
import
com.makeit.entity.platform.auth.PlatOrg
;
import
com.makeit.entity.platform.auth.PlatOrg
;
import
com.makeit.entity.platform.auth.PlatRole
;
import
com.makeit.entity.platform.auth.PlatRole
;
...
@@ -220,7 +221,7 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
...
@@ -220,7 +221,7 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
// 写入设备
// 写入设备
PlatDeviceAttrWechatDTO
platDeviceAttrWechatDTO
=
JSON
.
parseObject
(
dto
.
getAttribute
(),
PlatDeviceAttrWechatDTO
.
class
);
PlatDeviceAttrWechatDTO
platDeviceAttrWechatDTO
=
JSON
.
parseObject
(
dto
.
getAttribute
(),
PlatDeviceAttrWechatDTO
.
class
);
platDeviceAttrWechatDTO
.
setDeviceId
(
db
.
getId
());
platDeviceAttrWechatDTO
.
setDeviceId
(
db
.
get
OriDevice
Id
());
editDeviceProperties
(
platDeviceAttrWechatDTO
);
editDeviceProperties
(
platDeviceAttrWechatDTO
);
}
}
...
@@ -316,40 +317,10 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
...
@@ -316,40 +317,10 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
wechatEdit
(
PlatDeviceEditWechatDTO
dto
)
{
public
void
wechatEdit
(
PlatDeviceEditWechatDTO
dto
)
{
PlatDevice
db
=
getById
(
dto
.
getId
());
PlatDevice
db
=
getById
(
dto
.
getId
());
db
.
setName
(
dto
.
getName
());
String
id
=
db
.
getId
();
PlatDeviceOther
other
=
platDeviceOtherService
.
getOne
(
new
QueryWrapper
<
PlatDeviceOther
>().
lambda
()
.
eq
(
PlatDeviceOther:
:
getDeviceId
,
db
.
getId
()));
if
(
other
==
null
)
{
other
=
new
PlatDeviceOther
();
}
String
otherId
=
other
.
getId
();
BeanUtils
.
copyProperties
(
dto
,
db
);
db
.
setId
(
id
);
BeanUtils
.
copyProperties
(
dto
,
other
);
other
.
setId
(
otherId
);
other
.
setDeviceId
(
id
);
other
.
setOriDeviceId
(
db
.
getOriDeviceId
());
updateById
(
db
);
updateById
(
db
);
deviceCacheUtil
.
put
(
db
);
deviceCacheUtil
.
put
(
db
);
platDeviceOtherService
.
saveOrUpdate
(
other
);
if
(
StringUtils
.
isNotEmpty
(
other
.
getAttribute
()))
{
PlatDeviceAttrWechatDTO
deviceAttrWechatDTO
=
JsonUtil
.
toObj
(
other
.
getAttribute
(),
PlatDeviceAttrWechatDTO
.
class
);
if
(
deviceAttrWechatDTO
!=
null
)
{
deviceAttrWechatDTO
.
setDeviceId
(
db
.
getId
());
//更新区域设置设备安装方式
editDeviceProperties
(
deviceAttrWechatDTO
);
}
}
}
}
@Override
@Override
...
@@ -394,7 +365,7 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
...
@@ -394,7 +365,7 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
if
(
StringUtils
.
isNotEmpty
(
dto
.
getAttribute
()))
{
if
(
StringUtils
.
isNotEmpty
(
dto
.
getAttribute
()))
{
// 写入设备
// 写入设备
PlatDeviceAttrWechatDTO
platDeviceAttrWechatDTO
=
JSON
.
parseObject
(
dto
.
getAttribute
(),
PlatDeviceAttrWechatDTO
.
class
);
PlatDeviceAttrWechatDTO
platDeviceAttrWechatDTO
=
JSON
.
parseObject
(
dto
.
getAttribute
(),
PlatDeviceAttrWechatDTO
.
class
);
platDeviceAttrWechatDTO
.
setDeviceId
(
db
.
getId
());
platDeviceAttrWechatDTO
.
setDeviceId
(
db
.
get
OriDevice
Id
());
editDeviceProperties
(
platDeviceAttrWechatDTO
);
editDeviceProperties
(
platDeviceAttrWechatDTO
);
}
}
}
}
...
@@ -437,13 +408,33 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
...
@@ -437,13 +408,33 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
log
.
info
(
"写入设备属性请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
log
.
info
(
"写入设备属性请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
String
deviceId
=
dto
.
getDeviceId
();
String
deviceId
=
dto
.
getDeviceId
();
Map
<
String
,
Object
>
map
=
getAttrMap
(
dto
);
Map
<
String
,
Object
>
map
=
getAttrMap
(
dto
);
String
result
=
devicePropertiesOperateService
.
deviceWriteAttr
(
deviceId
,
map
);
if
(
StringUtils
.
isNotEmpty
(
result
))
{
throw
new
RuntimeException
(
"设备写入失败:"
+
result
);
}
PlatDeviceOther
other
=
platDeviceOtherService
.
getOne
(
new
QueryWrapper
<
PlatDeviceOther
>().
lambda
()
.
eq
(
PlatDeviceOther:
:
getOriDeviceId
,
deviceId
)
.
last
(
"limit 1"
));
if
(
other
!=
null
)
{
other
.
setAttribute
(
JSON
.
toJSONString
(
map
));
platDeviceOtherService
.
updateById
(
other
);
}
if
(
dto
.
getRadarMount
()
!=
null
)
{
List
<
PlatDevice
>
platDeviceList
=
list
(
new
QueryWrapper
<
PlatDevice
>().
lambda
().
eq
(
PlatDevice:
:
getOriDeviceId
,
deviceId
));
//更新区域设置设备安装方式
platRegionSettingService
.
update
(
new
UpdateWrapper
<
PlatRegionSetting
>().
lambda
()
.
set
(
PlatRegionSetting:
:
getInstallType
,
dto
.
getRadarMount
())
.
in
(
CollectionUtils
.
isNotEmpty
(
platDeviceList
),
PlatRegionSetting:
:
getDeviceId
,
StreamUtil
.
map
(
platDeviceList
,
BaseEntity:
:
getId
)));
}
}
@Override
public
void
editDeviceNetInfo
(
PlatDeviceNetAttrWechatDTO
dto
)
{
String
deviceId
=
dto
.
getDeviceId
();
UserServerInfo
usrServerInfo
=
dto
.
getUsrServerInfo
();
UserServerInfo
usrServerInfo
=
dto
.
getUsrServerInfo
();
boolean
usrServerInfoFlag
=
usrServerInfo
!=
null
&&
(
StringUtils
.
isNotEmpty
(
usrServerInfo
.
getUsername
())
||
StringUtils
.
isNotEmpty
(
usrServerInfo
.
getPassword
())
log
.
info
(
"写入设备属性请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
||
StringUtils
.
isNotEmpty
(
usrServerInfo
.
getAddr
())
||
usrServerInfo
.
getPort
()
!=
null
||
Map
<
String
,
Object
>
map
=
Maps
.
newHashMap
();
StringUtils
.
isNotEmpty
(
usrServerInfo
.
getSecureId
())
||
StringUtils
.
isNotEmpty
(
usrServerInfo
.
getSecureKey
()));
if
(
usrServerInfoFlag
)
{
map
.
put
(
"usrServerInfo"
,
JSON
.
toJSONString
(
usrServerInfo
));
map
.
put
(
"usrServerInfo"
,
JSON
.
toJSONString
(
usrServerInfo
));
}
String
result
=
devicePropertiesOperateService
.
deviceWriteAttr
(
deviceId
,
map
);
String
result
=
devicePropertiesOperateService
.
deviceWriteAttr
(
deviceId
,
map
);
if
(
StringUtils
.
isNotEmpty
(
result
))
{
if
(
StringUtils
.
isNotEmpty
(
result
))
{
throw
new
RuntimeException
(
"设备写入失败:"
+
result
);
throw
new
RuntimeException
(
"设备写入失败:"
+
result
);
...
@@ -451,25 +442,15 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
...
@@ -451,25 +442,15 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
PlatDeviceOther
other
=
platDeviceOtherService
.
getOne
(
new
QueryWrapper
<
PlatDeviceOther
>().
lambda
()
PlatDeviceOther
other
=
platDeviceOtherService
.
getOne
(
new
QueryWrapper
<
PlatDeviceOther
>().
lambda
()
.
eq
(
PlatDeviceOther:
:
getOriDeviceId
,
deviceId
)
.
eq
(
PlatDeviceOther:
:
getOriDeviceId
,
deviceId
)
.
last
(
"limit 1"
));
.
last
(
"limit 1"
));
if
(
other
!=
null
&&
usrServerInfoFlag
)
{
if
(
other
!=
null
)
{
other
.
setProtocolAccount
(
usrServerInfo
.
getUsername
());
other
.
setProtocolAccount
(
usrServerInfo
.
getUsername
());
other
.
setProtocolPassword
(
usrServerInfo
.
getPassword
());
other
.
setProtocolPassword
(
usrServerInfo
.
getPassword
());
other
.
setProtocolAddress
(
usrServerInfo
.
getAddr
());
other
.
setProtocolAddress
(
usrServerInfo
.
getAddr
());
other
.
setProtocolPort
(
usrServerInfo
.
getPort
()
==
null
?
""
:
usrServerInfo
.
getPort
().
toString
());
other
.
setProtocolPort
(
usrServerInfo
.
getPort
()
==
null
?
""
:
usrServerInfo
.
getPort
().
toString
());
other
.
setSecureId
(
usrServerInfo
.
getSecureId
());
other
.
setSecureId
(
usrServerInfo
.
getSecureId
());
other
.
setSecureKey
(
usrServerInfo
.
getSecureKey
());
other
.
setSecureKey
(
usrServerInfo
.
getSecureKey
());
}
if
(
other
!=
null
&&
!
map
.
isEmpty
()
&&
!
usrServerInfoFlag
)
{
other
.
setAttribute
(
JSON
.
toJSONString
(
map
));
platDeviceOtherService
.
updateById
(
other
);
platDeviceOtherService
.
updateById
(
other
);
}
}
if
(
dto
.
getRadarMount
()
!=
null
)
{
PlatDevice
platDevice
=
getOne
(
new
QueryWrapper
<
PlatDevice
>().
lambda
().
eq
(
PlatDevice:
:
getOriDeviceId
,
deviceId
));
//更新区域设置设备安装方式
platRegionSettingService
.
update
(
new
UpdateWrapper
<
PlatRegionSetting
>().
lambda
()
.
set
(
PlatRegionSetting:
:
getInstallType
,
dto
.
getRadarMount
())
.
eq
(
PlatRegionSetting:
:
getDeviceId
,
platDevice
.
getId
()));
}
}
}
private
static
Map
<
String
,
Object
>
getAttrMap
(
PlatDeviceBaseAttrDTO
dto
)
{
private
static
Map
<
String
,
Object
>
getAttrMap
(
PlatDeviceBaseAttrDTO
dto
)
{
...
@@ -586,6 +567,9 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
...
@@ -586,6 +567,9 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
.
in
(
PlatRoomBedDevice:
:
getDeviceId
,
deviceIdList
)
.
in
(
PlatRoomBedDevice:
:
getDeviceId
,
deviceIdList
)
.
eq
(
BaseBusEntity:
:
getTenantId
,
platTenant
.
getId
()));
.
eq
(
BaseBusEntity:
:
getTenantId
,
platTenant
.
getId
()));
}
}
if
(
CollectionUtils
.
isEmpty
(
iotDeviceIdSet
))
{
continue
;
}
LambdaQueryWrapper
<
PlatDevice
>
deviceLambdaQueryWrapper
=
new
LambdaQueryWrapper
<
PlatDevice
>().
eq
(
BaseBusEntity:
:
getTenantId
,
platTenant
.
getId
())
LambdaQueryWrapper
<
PlatDevice
>
deviceLambdaQueryWrapper
=
new
LambdaQueryWrapper
<
PlatDevice
>().
eq
(
BaseBusEntity:
:
getTenantId
,
platTenant
.
getId
())
.
in
(
PlatDevice:
:
getOriDeviceId
,
iotDeviceIdSet
);
.
in
(
PlatDevice:
:
getOriDeviceId
,
iotDeviceIdSet
);
...
@@ -594,14 +578,33 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
...
@@ -594,14 +578,33 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
List
<
PlatDevice
>
deviceList
=
list
(
deviceLambdaQueryWrapper
);
List
<
PlatDevice
>
deviceList
=
list
(
deviceLambdaQueryWrapper
);
//更新平台设备
//更新平台设备
Collection
<
PlatDevice
>
platDevices
=
convertToPlatDevice
(
iotDeviceList
,
deviceList
,
platTenant
.
getId
(),
dicNameIdMap
);
Collection
<
PlatDevice
>
platDevices
=
convertToPlatDevice
(
iotDeviceList
,
deviceList
,
platTenant
.
getId
(),
dicNameIdMap
);
saveOrUpdateBatch
(
platDevices
);
saveOrUpdateBatch
(
platDevices
);
saveDeviceOtherInfo
(
platDevices
);
deviceCacheUtil
.
putAll
(
platDevices
);
deviceCacheUtil
.
putAll
(
platDevices
);
}
}
log
.
info
(
"结束执行同步设备信息接口"
);
log
.
info
(
"结束执行同步设备信息接口"
);
}
}
private
void
saveDeviceOtherInfo
(
Collection
<
PlatDevice
>
platDevices
)
{
List
<
String
>
deviceIdList
=
platDevices
.
stream
().
map
(
BaseEntity:
:
getId
).
collect
(
Collectors
.
toList
());
List
<
PlatDeviceOther
>
platDeviceOtherList
=
platDeviceOtherService
.
list
(
new
QueryWrapper
<
PlatDeviceOther
>().
lambda
().
in
(
PlatDeviceOther:
:
getDeviceId
,
deviceIdList
));
Map
<
String
,
PlatDeviceOther
>
deviceOtherMap
=
StreamUtil
.
toMap
(
platDeviceOtherList
,
PlatDeviceOther:
:
getDeviceId
);
for
(
PlatDevice
platDevice
:
platDevices
)
{
PlatDeviceOther
platDeviceOther
=
deviceOtherMap
.
get
(
platDevice
.
getId
());
if
(
platDeviceOther
==
null
)
{
platDeviceOther
=
new
PlatDeviceOther
();
platDeviceOther
.
setDeviceId
(
platDevice
.
getId
());
platDeviceOther
.
setOriDeviceId
(
platDevice
.
getOriDeviceId
());
platDeviceOther
.
setTenantId
(
platDevice
.
getTenantId
());
platDeviceOtherService
.
save
(
platDeviceOther
);
}
}
}
private
Collection
<
PlatDevice
>
convertToPlatDevice
(
List
<
DeviceInstanceEntity
>
iotDeviceList
,
List
<
PlatDevice
>
deviceList
,
String
tenantId
,
Map
<
String
,
String
>
dicNameIdMap
)
{
private
Collection
<
PlatDevice
>
convertToPlatDevice
(
List
<
DeviceInstanceEntity
>
iotDeviceList
,
List
<
PlatDevice
>
deviceList
,
String
tenantId
,
Map
<
String
,
String
>
dicNameIdMap
)
{
Map
<
String
,
PlatDevice
>
deviceMap
=
deviceList
.
stream
().
collect
(
Collectors
.
toMap
(
PlatDevice:
:
getOriDeviceId
,
v
->
v
,
(
a
,
b
)
->
a
));
Map
<
String
,
PlatDevice
>
deviceMap
=
deviceList
.
stream
().
collect
(
Collectors
.
toMap
(
PlatDevice:
:
getOriDeviceId
,
v
->
v
,
(
a
,
b
)
->
a
));
iotDeviceList
.
forEach
(
iotDevice
->
{
iotDeviceList
.
forEach
(
iotDevice
->
{
...
...
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