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
1073a8b0
authored
Sep 12, 2023
by
lzy
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'dev' of git.xmmakeit.com:huangjiay/iot-platform-server into dev
parents
48fbec66
cb720511
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
40 additions
and
19 deletions
server-common/src/main/java/com/makeit/enums/redis/RedisConst.java
server-common/src/main/java/com/makeit/module/iot/enums/DeviceState.java
server-common/src/main/java/com/makeit/module/iot/enums/DeviceType.java
server-service/src/main/java/com/makeit/entity/platform/device/PlatDevice.java
server-service/src/main/java/com/makeit/service/platform/auth/impl/PlatOrgServiceImpl.java
server-service/src/main/java/com/makeit/task/IotSyncTask.java
server-web/src/main/java/com/makeit/mqtt/MqttConfig.java
server-web/src/main/java/com/makeit/mqtt/PushCallback.java
server-web/src/main/resources/application-dev.yml
server-web/src/main/resources/application-test.yml
server-common/src/main/java/com/makeit/enums/redis/RedisConst.java
View file @
1073a8b0
...
...
@@ -94,7 +94,7 @@ public class RedisConst {
public
static
final
String
ALARM_DEVICE_ID
=
"alarm:device:id:"
;
public
static
final
String
ALARM_CONFIG_ORG_ID
=
"al
ra
m:config:org:id"
;
public
static
final
String
ALARM_CONFIG_ORG_ID
=
"al
ar
m:config:org:id"
;
...
...
server-common/src/main/java/com/makeit/module/iot/enums/DeviceState.java
View file @
1073a8b0
...
...
@@ -7,11 +7,12 @@ import lombok.Getter;
@AllArgsConstructor
@Getter
public
enum
DeviceState
{
notActive
(
"禁用"
),
offline
(
"离线"
),
online
(
"在线"
);
notActive
(
"
notActive"
,
"
禁用"
),
offline
(
"
offline"
,
"
离线"
),
online
(
"
online"
,
"
在线"
);
private
final
String
text
;
private
final
String
value
;
private
final
String
name
;
}
server-common/src/main/java/com/makeit/module/iot/enums/DeviceType.java
View file @
1073a8b0
...
...
@@ -7,10 +7,11 @@ import lombok.Getter;
@AllArgsConstructor
@Getter
public
enum
DeviceType
{
device
(
"直连设备"
),
childrenDevice
(
"网关子设备"
),
gateway
(
"网关设备"
);
device
(
"
device"
,
"
直连设备"
),
childrenDevice
(
"
device"
,
"
网关子设备"
),
gateway
(
"
gateway"
,
"
网关设备"
);
private
final
String
value
;
private
final
String
text
;
...
...
server-service/src/main/java/com/makeit/entity/platform/device/PlatDevice.java
View file @
1073a8b0
package
com
.
makeit
.
entity
.
platform
.
device
;
import
com.makeit.common.entity.BaseBusEntity
;
import
com.makeit.module.iot.enums.DeviceState
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
...
...
@@ -47,7 +48,10 @@ public class PlatDevice extends BaseBusEntity {
@ApiModelProperty
(
value
=
"说明"
)
private
String
description
;
@ApiModelProperty
(
value
=
"状态 数据字典 1 在线 0离线"
)
/**
* @see DeviceState
*/
@ApiModelProperty
(
value
=
"状态 数据字典 1 在线 0离线 "
)
private
String
status
;
@ApiModelProperty
(
value
=
"组织id"
)
...
...
server-service/src/main/java/com/makeit/service/platform/auth/impl/PlatOrgServiceImpl.java
View file @
1073a8b0
...
...
@@ -453,7 +453,11 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
public
List
<
PlatOrg
>
createOrgTree
(
List
<
PlatOrg
>
orgList
)
{
Map
<
String
,
PlatOrg
>
orgMap
=
orgList
.
stream
().
collect
(
Collectors
.
toMap
(
BaseEntity:
:
getId
,
vo
->
vo
,
(
a
,
b
)
->
a
));
for
(
PlatOrg
platOrg
:
orgList
)
{
String
[]
split
=
platOrg
.
getPath
().
split
(
","
);
String
path
=
platOrg
.
getPath
();
if
(
StringUtils
.
isBlank
(
path
)){
continue
;
}
String
[]
split
=
path
.
split
(
","
);
findParent
(
orgMap
,
platOrg
,
split
,
split
.
length
-
1
);
}
return
orgList
.
stream
().
filter
(
vo
->
StringUtils
.
isBlank
(
vo
.
getParentNodeId
())).
collect
(
Collectors
.
toList
());
...
...
@@ -514,7 +518,7 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
private
LambdaQueryWrapper
<
PlatOrg
>
getLambdaQueryWrapper
(
PlatOrgQueryDTO
dto
)
{
LambdaQueryWrapper
<
PlatOrg
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
eq
(
PlatOrg:
:
getParentId
,
dto
.
getParentId
())
queryWrapper
.
eq
(
StringUtils
.
isNotBlank
(
dto
.
getParentId
()),
PlatOrg:
:
getParentId
,
dto
.
getParentId
())
.
orderByDesc
(
BaseEntity:
:
getUpdateDate
);
return
queryWrapper
;
}
...
...
@@ -524,8 +528,21 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
public
List
<
PlatOrg
>
subOrgList
(
PlatOrgQueryDTO
platOrgQueryDTO
)
{
LambdaQueryWrapper
<
PlatOrg
>
queryWrapper
=
getLambdaQueryWrapper
(
platOrgQueryDTO
);
List
<
PlatOrg
>
list
=
list
(
queryWrapper
);
List
<
PlatOrg
>
orgTree
=
createOrgTree2
(
list
);
return
orgTree
;
}
private
List
<
PlatOrg
>
createOrgTree2
(
List
<
PlatOrg
>
orgList
){
if
(
CollectionUtils
.
isEmpty
(
orgList
)){
return
new
ArrayList
<>();
}
Map
<
String
,
List
<
PlatOrg
>>
parentMap
=
orgList
.
stream
().
collect
(
Collectors
.
groupingBy
(
PlatOrg:
:
getParentId
));
orgList
.
forEach
(
vo
->{
vo
.
setChildren
(
parentMap
.
get
(
vo
.
getId
()));
});
return
list
(
queryWrapper
);
return
orgList
.
stream
().
filter
(
vo
->
StringUtils
.
equals
(
vo
.
getParentId
(),
"1"
)).
collect
(
Collectors
.
toList
()
);
}
/**
...
...
server-service/src/main/java/com/makeit/task/IotSyncTask.java
View file @
1073a8b0
...
...
@@ -106,7 +106,7 @@ public class IotSyncTask {
platDevice
.
setRegistrationDate
(
registryTime
);
platDevice
.
setDescription
(
iotDevice
.
getDescribe
());
String
state
=
iotDevice
.
getState
();
platDevice
.
setStatus
(
StringUtils
.
equals
(
"online"
,
state
)
?
CommonEnum
.
YES
.
getValue
()
:
CommonEnum
.
NO
.
getValue
()
);
platDevice
.
setStatus
(
state
);
//todo 根据类型名称来匹配
platDevice
.
setCategory
(
dicNameIdMap
.
get
(
iotDevice
.
getProductName
()));
...
...
server-web/src/main/java/com/makeit/mqtt/MqttConfig.java
View file @
1073a8b0
...
...
@@ -44,9 +44,7 @@ public class MqttConfig {
@Bean
public
MqttPushClient
getMqttPushClient
()
{
String
iotToken
=
iotTokenService
.
getIotToken
();
clientId
=
StringUtils
.
isNotEmpty
(
iotToken
)
?
iotToken
:
clientId
;
clientId
=
StringUtils
.
isNotEmpty
(
clientId
)
?
clientId
:
iotTokenService
.
getIotToken
();
mqttPushClient
.
connect
(
hostUrl
,
clientId
,
username
,
password
,
timeout
,
keepalive
);
// 订阅主题
mqttPushClient
.
subscribe
(
defaultTopic
,
0
);
...
...
server-web/src/main/java/com/makeit/mqtt/PushCallback.java
View file @
1073a8b0
...
...
@@ -84,7 +84,7 @@ public class PushCallback implements MqttCallback {
DeviceInfo
device
=
JSON
.
parseObject
(
payload
,
DeviceInfo
.
class
);
// todo
checkAlarm
(
device
);
//
checkAlarm(device);
}
@Override
...
...
server-web/src/main/resources/application-dev.yml
View file @
1073a8b0
...
...
@@ -115,7 +115,7 @@ mqtt:
username
:
admin|1693982115969
password
:
8e3795ef7b5e95869fa8c323b865b3a9
hostUrl
:
tcp://124.71.33.17:11883
clientId
:
ab3a2fd694c8c838aba2686df3a80e7b
clientId
:
defaultTopic
:
/device/*/*/**
timeout
:
10
keepalive
:
60
...
...
server-web/src/main/resources/application-test.yml
View file @
1073a8b0
...
...
@@ -112,7 +112,7 @@ mqtt:
username
:
admin|1693982115969
password
:
8e3795ef7b5e95869fa8c323b865b3a9
hostUrl
:
tcp://124.71.33.17:11883
clientId
:
ab3a2fd694c8c838aba2686df3a80e7b
clientId
:
defaultTopic
:
/device/*/*/**
timeout
:
10
keepalive
:
60
...
...
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