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
9b27333c
authored
Dec 22, 2023
by
罗志长
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix: 设备详情部分信息从接口拉取
parent
a13e9404
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
80 additions
and
14 deletions
server-common/src/main/java/com/makeit/module/iot/service/IotProductDeviceService.java
server-common/src/main/java/com/makeit/module/iot/vo/DeviceDetail.java
server-common/src/main/java/com/makeit/module/iot/vo/DeviceFirmwareInfo.java
server-service/src/main/java/com/makeit/dto/platform/device/PlatDeviceEditDTO.java
server-service/src/main/java/com/makeit/service/platform/device/impl/PlatDeviceServiceImpl.java
server-common/src/main/java/com/makeit/module/iot/service/IotProductDeviceService.java
View file @
9b27333c
...
...
@@ -10,10 +10,8 @@ import com.makeit.module.iot.dto.IotQueryParam;
import
com.makeit.module.iot.dto.IotSort
;
import
com.makeit.module.iot.dto.Term
;
import
com.makeit.module.iot.util.HttpRequest
;
import
com.makeit.module.iot.vo.DeviceInstanceEntity
;
import
com.makeit.module.iot.vo.DeviceOperationLogEntity
;
import
com.makeit.module.iot.vo.IotPagerResult
;
import
com.makeit.module.iot.vo.ResponseMessage
;
import
com.makeit.module.iot.util.SimpleHttpRequest
;
import
com.makeit.module.iot.vo.*
;
import
com.makeit.module.iot.vo.analysis.AnalysisVO
;
import
com.makeit.module.iot.vo.breathe.DeviceInfoContentBreathe
;
import
com.makeit.module.iot.vo.fall.DeviceInfoContentFall
;
...
...
@@ -33,10 +31,7 @@ import java.io.IOException;
import
java.time.*
;
import
java.time.format.DateTimeFormatter
;
import
java.time.temporal.ChronoUnit
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.TreeMap
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -78,13 +73,33 @@ public class IotProductDeviceService extends IotCommonService {
return
Lists
.
newArrayList
();
}
public
DeviceDetail
getDetail
(
String
deviceId
)
{
String
url
=
iotUrl
+
DEVICE_PREFIX_URL
+
"/"
+
deviceId
+
"/detail"
;
HttpRequest
request
=
new
SimpleHttpRequest
(
url
,
httpClient
);
request
.
headers
(
headerUtils
.
createHeadersOfParams
(
new
HashMap
<>()));
try
{
ResponseMessage
responseMessage
=
sendGet
(
url
,
request
);
if
(
responseMessage
.
getStatus
()
==
200
)
{
log
.
info
(
"获取设备详情成功:{}"
,
deviceId
);
return
JSON
.
parseObject
(
responseMessage
.
getResult
().
toString
(),
DeviceDetail
.
class
);
}
else
{
log
.
error
(
"获取设备详情失败:{}"
,
responseMessage
.
getMessage
());
}
}
catch
(
IOException
e
)
{
log
.
error
(
"调用:{}接口异常:{}"
,
url
,
e
.
getMessage
());
}
return
null
;
}
@Async
public
void
syncUpdateDeviceInfo
(
String
id
,
String
name
,
String
productId
)
{
public
void
syncUpdateDeviceInfo
(
String
id
,
String
name
,
String
productId
,
String
describe
)
{
String
url
=
iotUrl
+
"/device-instance"
;
Map
<
String
,
Object
>
reqMap
=
Maps
.
newHashMap
();
reqMap
.
put
(
"id"
,
id
);
reqMap
.
put
(
"name"
,
name
);
reqMap
.
put
(
"productId"
,
productId
);
reqMap
.
put
(
"id"
,
id
);
reqMap
.
put
(
"name"
,
name
);
reqMap
.
put
(
"productId"
,
productId
);
reqMap
.
put
(
"describe"
,
describe
);
String
body
=
JsonUtil
.
toJson
(
reqMap
);
HttpRequest
request
=
buildRequest
(
url
,
body
);
...
...
server-common/src/main/java/com/makeit/module/iot/vo/DeviceDetail.java
0 → 100644
View file @
9b27333c
package
com
.
makeit
.
module
.
iot
.
vo
;
import
lombok.Data
;
@Data
public
class
DeviceDetail
{
// 固件信息
private
DeviceFirmwareInfo
firmwareInfo
;
// 上线时间
private
long
onlineTime
;
//说明
private
String
description
;
}
server-common/src/main/java/com/makeit/module/iot/vo/DeviceFirmwareInfo.java
0 → 100644
View file @
9b27333c
package
com
.
makeit
.
module
.
iot
.
vo
;
import
lombok.Data
;
import
java.util.Map
;
@Data
public
class
DeviceFirmwareInfo
{
// 固件版本
private
String
version
;
// 创建时间(只读)
private
Long
createTime
;
// 修改时间
private
Long
updateTime
;
// 其他配置
private
Map
<
String
,
Object
>
properties
;
}
server-service/src/main/java/com/makeit/dto/platform/device/PlatDeviceEditDTO.java
View file @
9b27333c
...
...
@@ -30,6 +30,7 @@ public class PlatDeviceEditDTO extends BaseTenantDTO {
@ApiModelProperty
(
value
=
"设备属性json"
)
private
String
attribute
;
@ApiModelProperty
(
value
=
"描述"
)
private
String
description
;
}
server-service/src/main/java/com/makeit/service/platform/device/impl/PlatDeviceServiceImpl.java
View file @
9b27333c
...
...
@@ -49,6 +49,7 @@ import com.makeit.module.iot.dto.UserServerInfo;
import
com.makeit.module.iot.service.IotDevicePropertiesOperateService
;
import
com.makeit.module.iot.service.IotOrgService
;
import
com.makeit.module.iot.service.IotProductDeviceService
;
import
com.makeit.module.iot.vo.DeviceDetail
;
import
com.makeit.module.iot.vo.DeviceInstanceEntity
;
import
com.makeit.module.iot.vo.DeviceProperties
;
import
com.makeit.module.iot.vo.DeviceState
;
...
...
@@ -383,7 +384,7 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
platDeviceAttrWechatDTO
.
setDeviceId
(
db
.
getOriDeviceId
());
editDeviceProperties
(
platDeviceAttrWechatDTO
);
}
iotProductDeviceService
.
syncUpdateDeviceInfo
(
db
.
getOriDeviceId
(),
dto
.
getName
(),
db
.
getProductId
());
iotProductDeviceService
.
syncUpdateDeviceInfo
(
db
.
getOriDeviceId
(),
dto
.
getName
(),
db
.
getProductId
(),
dto
.
getDescription
());
}
@Override
...
...
@@ -400,6 +401,16 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
}
vo
.
setId
(
db
.
getId
());
DeviceDetail
detail
=
iotProductDeviceService
.
getDetail
(
db
.
getOriDeviceId
());
if
(
detail
!=
null
)
{
if
(
detail
.
getFirmwareInfo
()
!=
null
)
{
vo
.
setFirmwareVersion
(
detail
.
getFirmwareInfo
().
getVersion
());
}
if
(
detail
.
getOnlineTime
()
!=
0
)
{
vo
.
setLastOnlineData
(
LocalDateTime
.
ofEpochSecond
(
detail
.
getOnlineTime
()
/
1000
,
0
,
ZoneOffset
.
ofHours
(
8
)));
}
vo
.
setDescription
(
detail
.
getDescription
());
}
return
vo
;
...
...
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