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
99cfdb17
authored
Oct 09, 2023
by
huangjy
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix:同步更新iot设备名称,todo
parent
41d7fe28
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
3 deletions
server-common/src/main/java/com/makeit/module/iot/service/IotCommonService.java
server-common/src/main/java/com/makeit/module/iot/service/IotProductDeviceService.java
server-service/src/main/java/com/makeit/service/platform/device/impl/PlatDeviceServiceImpl.java
server-common/src/main/java/com/makeit/module/iot/service/IotCommonService.java
View file @
99cfdb17
...
@@ -14,6 +14,8 @@ import com.makeit.module.iot.vo.ResponseMessage;
...
@@ -14,6 +14,8 @@ import com.makeit.module.iot.vo.ResponseMessage;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.http.client.HttpClient
;
import
org.apache.http.client.HttpClient
;
import
org.apache.http.entity.ContentType
;
import
org.apache.http.entity.StringEntity
;
import
org.apache.http.impl.client.HttpClientBuilder
;
import
org.apache.http.impl.client.HttpClientBuilder
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
...
@@ -49,6 +51,7 @@ public class IotCommonService {
...
@@ -49,6 +51,7 @@ public class IotCommonService {
}
}
public
ResponseMessage
sendPatch
(
String
url
,
HttpRequest
request
)
throws
IOException
{
public
ResponseMessage
sendPatch
(
String
url
,
HttpRequest
request
)
throws
IOException
{
Response
response
=
request
.
patch
();
Response
response
=
request
.
patch
();
ResponseMessage
responseMessage
=
getResponseMessage
(
url
,
response
);
ResponseMessage
responseMessage
=
getResponseMessage
(
url
,
response
);
return
responseMessage
;
return
responseMessage
;
}
}
...
...
server-common/src/main/java/com/makeit/module/iot/service/IotProductDeviceService.java
View file @
99cfdb17
...
@@ -73,15 +73,17 @@ public class IotProductDeviceService extends IotCommonService {
...
@@ -73,15 +73,17 @@ public class IotProductDeviceService extends IotCommonService {
}
}
@Async
@Async
public
void
syncUpdateDeviceInfo
(
String
id
,
String
name
)
{
public
void
syncUpdateDeviceInfo
(
String
id
,
String
name
,
String
productId
)
{
String
url
=
iotUrl
+
"/device-instance"
;
String
url
=
iotUrl
+
"/device-instance"
;
// 条件可以自己改
Map
<
String
,
Object
>
reqMap
=
Maps
.
newHashMap
();
Map
<
String
,
Object
>
reqMap
=
Maps
.
newHashMap
();
reqMap
.
put
(
"id"
,
id
);
reqMap
.
put
(
"id"
,
id
);
reqMap
.
put
(
"name"
,
name
);
reqMap
.
put
(
"name"
,
name
);
reqMap
.
put
(
"productId"
,
productId
);
String
body
=
JsonUtil
.
toJson
(
reqMap
);
String
body
=
JsonUtil
.
toJson
(
reqMap
);
HttpRequest
request
=
buildRequest
(
url
,
body
);
HttpRequest
request
=
buildRequest
(
url
,
body
);
request
.
encode
(
"UTF-8"
);
request
.
contentType
(
"application/json"
);
try
{
try
{
ResponseMessage
responseMessage
=
sendPatch
(
url
,
request
);
ResponseMessage
responseMessage
=
sendPatch
(
url
,
request
);
if
(
responseMessage
.
getStatus
()
==
200
)
{
if
(
responseMessage
.
getStatus
()
==
200
)
{
...
...
server-service/src/main/java/com/makeit/service/platform/device/impl/PlatDeviceServiceImpl.java
View file @
99cfdb17
...
@@ -128,7 +128,7 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
...
@@ -128,7 +128,7 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
deviceCacheUtil
.
put
(
db
);
deviceCacheUtil
.
put
(
db
);
iotProductDeviceService
.
syncUpdateDeviceInfo
(
db
.
getOriDeviceId
(),
dto
.
getName
());
// iotProductDeviceService.syncUpdateDeviceInfo(db.getOriDeviceId(),dto.getName(),db.getProductId
());
}
}
@Override
@Override
...
...
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