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
c8d2e6be
authored
Dec 21, 2023
by
罗志长
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix: 网络信息编辑
parent
a15f0218
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
8 deletions
server-service/src/main/java/com/makeit/service/platform/device/impl/PlatDeviceServiceImpl.java
server-service/src/main/java/com/makeit/service/platform/device/impl/PlatDeviceServiceImpl.java
View file @
c8d2e6be
...
@@ -3,6 +3,7 @@ package com.makeit.service.platform.device.impl;
...
@@ -3,6 +3,7 @@ package com.makeit.service.platform.device.impl;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.date.DatePattern
;
import
cn.hutool.core.date.DatePattern
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.thread.ThreadUtil
;
import
cn.hutool.crypto.SecureUtil
;
import
cn.hutool.crypto.SecureUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
...
@@ -682,21 +683,34 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
...
@@ -682,21 +683,34 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
String
deviceId
=
dto
.
getDeviceId
();
String
deviceId
=
dto
.
getDeviceId
();
UserServerInfo
usrServerInfo
=
dto
.
getUsrServerInfo
();
UserServerInfo
usrServerInfo
=
dto
.
getUsrServerInfo
();
log
.
info
(
"写入设备属性请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
log
.
info
(
"写入设备属性请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
Map
<
String
,
Object
>
map
=
Maps
.
newHashMap
();
String
value
=
JSON
.
toJSONString
(
usrServerInfo
);
map
.
put
(
"usrServerInfo"
,
JSON
.
toJSONString
(
usrServerInfo
));
boolean
needWrite
=
true
;
/* String result = devicePropertiesOperateService.deviceWriteAttr(deviceId, map);
if (StringUtils.isNotEmpty(result)) {
throw new RuntimeException("设备写入失败:" + result);
}*/
List
<
PlatDeviceOther
>
platDeviceOtherList
=
platDeviceOtherService
.
list
(
new
QueryWrapper
<
PlatDeviceOther
>().
lambda
()
List
<
PlatDeviceOther
>
platDeviceOtherList
=
platDeviceOtherService
.
list
(
new
QueryWrapper
<
PlatDeviceOther
>().
lambda
()
.
eq
(
PlatDeviceOther:
:
getOriDeviceId
,
deviceId
));
.
eq
(
PlatDeviceOther:
:
getOriDeviceId
,
deviceId
));
if
(
CollectionUtils
.
isNotEmpty
(
platDeviceOtherList
))
{
PlatDeviceOther
platDeviceOther
=
platDeviceOtherList
.
get
(
0
);
UserServerInfo
existInfo
=
new
UserServerInfo
();
existInfo
.
setAddr
(
platDeviceOther
.
getProtocolAddress
());
existInfo
.
setPort
(
platDeviceOther
.
getProtocolPort
()
!=
null
?
Integer
.
valueOf
(
platDeviceOther
.
getProtocolPort
())
:
null
);
existInfo
.
setUsername
(
platDeviceOther
.
getProtocolAccount
());
existInfo
.
setPassword
(
platDeviceOther
.
getProtocolPassword
());
String
jsonString
=
JSON
.
toJSONString
(
existInfo
);
needWrite
=
!
value
.
equals
(
jsonString
);
}
if
(
needWrite
)
{
ThreadUtil
.
sleep
(
200
);
// 受限于设备不支持同时写入 稍微延迟一点执行(前端先修改属性再修改网络信息)
Map
<
String
,
Object
>
map
=
Maps
.
newHashMap
();
map
.
put
(
"usrServerInfo"
,
value
);
String
result
=
devicePropertiesOperateService
.
deviceWriteAttr
(
deviceId
,
map
);
if
(
StringUtils
.
isNotEmpty
(
result
))
{
throw
new
RuntimeException
(
"设备写入失败:"
+
result
);
}
}
for
(
PlatDeviceOther
platDeviceOther
:
platDeviceOtherList
)
{
for
(
PlatDeviceOther
platDeviceOther
:
platDeviceOtherList
)
{
platDeviceOther
.
setProtocolAccount
(
usrServerInfo
.
getUsername
());
platDeviceOther
.
setProtocolAccount
(
usrServerInfo
.
getUsername
());
platDeviceOther
.
setProtocolPassword
(
usrServerInfo
.
getPassword
());
platDeviceOther
.
setProtocolPassword
(
usrServerInfo
.
getPassword
());
platDeviceOther
.
setProtocolAddress
(
usrServerInfo
.
getAddr
());
platDeviceOther
.
setProtocolAddress
(
usrServerInfo
.
getAddr
());
platDeviceOther
.
setProtocolPort
(
usrServerInfo
.
getPort
()
==
null
?
""
:
usrServerInfo
.
getPort
().
toString
());
platDeviceOther
.
setProtocolPort
(
usrServerInfo
.
getPort
()
==
null
?
""
:
usrServerInfo
.
getPort
().
toString
());
platDeviceOther
.
setSecureId
(
usrServerInfo
.
getSecureId
());
platDeviceOther
.
setSecureKey
(
usrServerInfo
.
getSecureKey
());
platDeviceOtherService
.
updateById
(
platDeviceOther
);
platDeviceOtherService
.
updateById
(
platDeviceOther
);
}
}
}
}
...
...
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