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
0e06c7d6
authored
Oct 09, 2023
by
huangjy
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix:修复bug
parent
43228883
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
0 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 @
0e06c7d6
...
...
@@ -47,6 +47,11 @@ public class IotCommonService {
ResponseMessage
responseMessage
=
getResponseMessage
(
url
,
response
);
return
responseMessage
;
}
public
ResponseMessage
sendPatch
(
String
url
,
HttpRequest
request
)
throws
IOException
{
Response
response
=
request
.
patch
();
ResponseMessage
responseMessage
=
getResponseMessage
(
url
,
response
);
return
responseMessage
;
}
public
ResponseMessage
sendGet
(
String
url
,
HttpRequest
request
)
throws
IOException
{
Response
response
=
request
.
get
();
ResponseMessage
responseMessage
=
getResponseMessage
(
url
,
response
);
...
...
server-common/src/main/java/com/makeit/module/iot/service/IotProductDeviceService.java
View file @
0e06c7d6
...
...
@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.makeit.module.iot.dto.IotQueryParam
;
import
com.makeit.module.iot.dto.IotSort
;
import
com.makeit.module.iot.dto.Term
;
...
...
@@ -23,12 +24,14 @@ import com.makeit.utils.old.StringUtils;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.RandomUtils
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Component
;
import
java.io.IOException
;
import
java.time.*
;
import
java.time.format.DateTimeFormatter
;
import
java.util.List
;
import
java.util.Map
;
/**
* iot产品设备相关接口
...
...
@@ -69,6 +72,28 @@ public class IotProductDeviceService extends IotCommonService {
return
Lists
.
newArrayList
();
}
@Async
public
void
syncUpdateDeviceInfo
(
String
id
,
String
name
)
{
String
url
=
iotUrl
+
"/device-instance"
;
// 条件可以自己改
Map
<
String
,
Object
>
reqMap
=
Maps
.
newHashMap
();
reqMap
.
put
(
"id"
,
id
);
reqMap
.
put
(
"name"
,
name
);
String
body
=
JsonUtil
.
toJson
(
reqMap
);
HttpRequest
request
=
buildRequest
(
url
,
body
);
try
{
ResponseMessage
responseMessage
=
sendPatch
(
url
,
request
);
if
(
responseMessage
.
getStatus
()
==
200
)
{
log
.
info
(
"修改设备名称成功:{}"
,
id
);
}
else
{
log
.
error
(
"获取设备接口失败:{}"
,
responseMessage
.
getMessage
());
}
}
catch
(
IOException
e
)
{
log
.
error
(
"调用:{}接口异常:{}"
,
url
,
e
.
getMessage
());
}
}
/**
* 获取最新一条设备日志
*
...
...
server-service/src/main/java/com/makeit/service/platform/device/impl/PlatDeviceServiceImpl.java
View file @
0e06c7d6
...
...
@@ -26,6 +26,7 @@ import com.makeit.enums.CodeMessageEnum;
import
com.makeit.exception.BusinessException
;
import
com.makeit.mapper.platform.device.PlatDeviceMapper
;
import
com.makeit.module.iot.service.IotDevicePropertiesOperateService
;
import
com.makeit.module.iot.service.IotProductDeviceService
;
import
com.makeit.module.iot.vo.DeviceProperties
;
import
com.makeit.service.platform.auth.PlatOrgService
;
import
com.makeit.service.platform.device.PlatDeviceOtherService
;
...
...
@@ -71,6 +72,8 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
private
PlatTenantService
platTenantService
;
@Autowired
private
PlatRegionSettingService
platRegionSettingService
;
@Autowired
private
IotProductDeviceService
iotProductDeviceService
;
@Override
public
PageVO
<
PlatDeviceListVO
>
page
(
PageReqDTO
<
PlatDeviceQueryDTO
>
pageReqDTO
)
{
...
...
@@ -125,6 +128,7 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
deviceCacheUtil
.
put
(
db
);
iotProductDeviceService
.
syncUpdateDeviceInfo
(
db
.
getOriDeviceId
(),
dto
.
getName
());
}
@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